2020-11-16 04:28:07 -08:00
|
|
|
use schemars::JsonSchema;
|
|
|
|
use serde::{Deserialize, Serialize};
|
|
|
|
|
2020-11-19 11:05:05 -08:00
|
|
|
use cosmwasm_std::{CanonicalAddr, ReadonlyStorage, Storage, Binary};
|
2020-11-16 04:28:07 -08:00
|
|
|
use cosmwasm_storage::{singleton, singleton_read, ReadonlySingleton, Singleton};
|
|
|
|
|
|
|
|
pub const KEY_WRAPPED_ASSET: &[u8] = b"wrappedAsset";
|
|
|
|
|
|
|
|
// Created at initialization and reference original asset and bridge address
|
|
|
|
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
|
|
|
|
pub struct WrappedAssetInfo {
|
2021-05-31 06:13:59 -07:00
|
|
|
pub asset_chain: u16, // Asset chain id
|
2020-11-19 11:05:05 -08:00
|
|
|
pub asset_address: Binary, // Asset smart contract address on the original chain
|
2020-11-16 04:28:07 -08:00
|
|
|
pub bridge: CanonicalAddr, // Bridge address, authorized to mint and burn wrapped tokens
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn wrapped_asset_info<S: Storage>(storage: &mut S) -> Singleton<S, WrappedAssetInfo> {
|
|
|
|
singleton(storage, KEY_WRAPPED_ASSET)
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn wrapped_asset_info_read<S: ReadonlyStorage>(
|
|
|
|
storage: &S,
|
|
|
|
) -> ReadonlySingleton<S, WrappedAssetInfo> {
|
|
|
|
singleton_read(storage, KEY_WRAPPED_ASSET)
|
|
|
|
}
|