state.rs 988 B

12345678910111213141516171819202122232425262728293031323334353637
  1. use schemars::JsonSchema;
  2. use serde::{
  3. Deserialize,
  4. Serialize,
  5. };
  6. use cosmwasm_std::{
  7. Binary,
  8. CanonicalAddr,
  9. Storage,
  10. };
  11. use cosmwasm_storage::{
  12. singleton,
  13. singleton_read,
  14. ReadonlySingleton,
  15. Singleton,
  16. };
  17. pub const KEY_WRAPPED_ASSET: &[u8] = b"wrappedAsset";
  18. // Created at initialization and reference original asset and bridge address
  19. #[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
  20. pub struct WrappedAssetInfo {
  21. pub asset_chain: u16, // Asset chain id
  22. pub asset_address: Binary, // Asset smart contract address on the original chain
  23. pub bridge: CanonicalAddr, // Bridge address, authorized to mint and burn wrapped tokens
  24. }
  25. pub fn wrapped_asset_info(storage: &mut dyn Storage) -> Singleton<WrappedAssetInfo> {
  26. singleton(storage, KEY_WRAPPED_ASSET)
  27. }
  28. pub fn wrapped_asset_info_read(
  29. storage: &dyn Storage,
  30. ) -> ReadonlySingleton<WrappedAssetInfo> {
  31. singleton_read(storage, KEY_WRAPPED_ASSET)
  32. }