cw20_wrapped/
msg.rs

1#![allow(clippy::field_reassign_with_default)]
2use schemars::JsonSchema;
3use serde::{
4    Deserialize,
5    Serialize,
6};
7
8use cosmwasm_std::{
9    Addr,
10    Binary,
11    Uint128,
12};
13use cw20::Expiration;
14
15type HumanAddr = String;
16
17#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
18pub struct InstantiateMsg {
19    pub name: String,
20    pub symbol: String,
21    pub asset_chain: u16,
22    pub asset_address: Binary,
23    pub decimals: u8,
24    pub mint: Option<InitMint>,
25    pub init_hook: Option<InitHook>,
26}
27
28#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
29pub struct InitHook {
30    pub msg: Binary,
31    pub contract_addr: HumanAddr,
32}
33
34#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
35pub struct InitMint {
36    pub recipient: HumanAddr,
37    pub amount: Uint128,
38}
39
40#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
41#[serde(rename_all = "snake_case")]
42pub struct MigrateMsg {}
43
44#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
45#[serde(rename_all = "snake_case")]
46pub enum ExecuteMsg {
47    /// Implements CW20. Transfer is a base message to move tokens to another account without triggering actions
48    Transfer {
49        recipient: HumanAddr,
50        amount: Uint128,
51    },
52    /// Slightly different than CW20. Burn is a base message to destroy tokens forever
53    Burn { account: HumanAddr, amount: Uint128 },
54    /// Implements CW20. Send is a base message to transfer tokens to a contract and trigger an action
55    /// on the receiving contract.
56    Send {
57        contract: HumanAddr,
58        amount: Uint128,
59        msg: Binary,
60    },
61    /// Implements CW20 "mintable" extension. If authorized, creates amount new tokens
62    /// and adds to the recipient balance.
63    Mint {
64        recipient: HumanAddr,
65        amount: Uint128,
66    },
67    /// Implements CW20 "approval" extension. Allows spender to access an additional amount tokens
68    /// from the owner's (env.sender) account. If expires is Some(), overwrites current allowance
69    /// expiration with this one.
70    IncreaseAllowance {
71        spender: HumanAddr,
72        amount: Uint128,
73        expires: Option<Expiration>,
74    },
75    /// Implements CW20 "approval" extension. Lowers the spender's access of tokens
76    /// from the owner's (env.sender) account by amount. If expires is Some(), overwrites current
77    /// allowance expiration with this one.
78    DecreaseAllowance {
79        spender: HumanAddr,
80        amount: Uint128,
81        expires: Option<Expiration>,
82    },
83    /// Implements CW20 "approval" extension. Transfers amount tokens from owner -> recipient
84    /// if `env.sender` has sufficient pre-approval.
85    TransferFrom {
86        owner: HumanAddr,
87        recipient: HumanAddr,
88        amount: Uint128,
89    },
90    /// Implements CW20 "approval" extension. Sends amount tokens from owner -> contract
91    /// if `env.sender` has sufficient pre-approval.
92    SendFrom {
93        owner: HumanAddr,
94        contract: HumanAddr,
95        amount: Uint128,
96        msg: Binary,
97    },
98    /// Implements CW20 "approval" extension. Destroys tokens forever
99    BurnFrom { owner: HumanAddr, amount: Uint128 },
100    /// Extend Interface with the ability to update token metadata.
101    UpdateMetadata { name: String, symbol: String },
102}
103
104#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
105#[serde(rename_all = "snake_case")]
106pub enum QueryMsg {
107    // Generic information about the wrapped asset
108    WrappedAssetInfo {},
109    /// Implements CW20. Returns the current balance of the given address, 0 if unset.
110    Balance {
111        address: HumanAddr,
112    },
113    /// Implements CW20. Returns metadata on the contract - name, decimals, supply, etc.
114    TokenInfo {},
115    /// Implements CW20 "allowance" extension.
116    /// Returns how much spender can use from owner account, 0 if unset.
117    Allowance {
118        owner: HumanAddr,
119        spender: HumanAddr,
120    },
121}
122
123#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
124pub struct WrappedAssetInfoResponse {
125    pub asset_chain: u16,      // Asset chain id
126    pub asset_address: Binary, // Asset smart contract address in the original chain
127    pub bridge: Addr,          // Bridge address, authorized to mint and burn wrapped tokens
128}