Skip to content

Commit

Permalink
Merge pull request #58 from balancednetwork/bugfix/add-missing-cw20-m…
Browse files Browse the repository at this point in the history
…ethod-to-bnusd

fix: Add missing CW20 methods
  • Loading branch information
AntonAndell authored Jan 31, 2024
2 parents 21c1e7e + 1484ff7 commit 2bf9ae4
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 19 deletions.
32 changes: 19 additions & 13 deletions contracts/cw-common/src/hub_token_msg.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use cosmwasm_schema::cw_serde;
use cosmwasm_std::{Addr, Uint128};
use cosmwasm_std::{Addr, Uint128, Binary};
use cw20::Expiration;

use crate::network_address::NetworkAddress;
Expand Down Expand Up @@ -27,13 +27,15 @@ pub enum ExecuteMsg {
data: Vec<u8>,
},
/// Transfer is a base message to move tokens to another account without triggering actions
Transfer {
recipient: String,
amount: Uint128,
},
Transfer { recipient: String, amount: Uint128 },
/// Burn is a base message to destroy tokens forever
Burn {
Burn { amount: Uint128 },
/// Send is a base message to transfer tokens to a contract and trigger an action
/// on the receiving contract.
Send {
contract: String,
amount: Uint128,
msg: Binary,
},
/// Only with "approval" extension. Allows spender to access an additional amount tokens
/// from the owner's (env.sender) account. If expires is Some(), overwrites current allowance
Expand Down Expand Up @@ -63,18 +65,22 @@ pub enum ExecuteMsg {
owner: String,
amount: Uint128,
},
/// Only with the "mintable" extension. If authorized, creates amount new tokens
/// and adds to the recipient balance.
Mint {
recipient: String,
/// Only with "approval" extension. Sends amount tokens from owner -> contract
/// if `env.sender` has sufficient pre-approval.
SendFrom {
owner: String,
contract: String,
amount: Uint128,
msg: Binary,
},
/// Only with the "mintable" extension. If authorized, creates amount new tokens
/// and adds to the recipient balance.
Mint { recipient: String, amount: Uint128 },
/// Only with the "mintable" extension. The current minter may set
/// a new minter. Setting the minter to None will remove the
/// token's minter forever.
UpdateMinter {
new_minter: Option<String>,
},
UpdateMinter { new_minter: Option<String> },

}

#[cw_serde]
Expand Down
25 changes: 19 additions & 6 deletions contracts/token-contracts/cw-hub-bnusd/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@ use cw_common::hub_token_msg::{ExecuteMsg, InstantiateMsg, MigrateMsg, QueryMsg}
use cw_common::x_call_msg::{GetNetworkAddress, XCallMsg};

use cw20_base::allowances::{
execute_burn_from, execute_decrease_allowance, execute_increase_allowance,
execute_burn_from, execute_decrease_allowance, execute_increase_allowance, execute_send_from,
execute_transfer_from, query_allowance,
};
use cw20_base::contract::{
execute_burn, execute_mint, execute_transfer, execute_update_minter, query_download_logo,
query_marketing_info,
execute_burn, execute_mint, execute_send, execute_transfer, execute_update_minter,
query_download_logo, query_marketing_info,
};
use cw20_base::contract::{query_balance, query_minter, query_token_info};
use cw20_base::enumerable::{query_all_accounts, query_owner_allowances, query_spender_allowances};
Expand Down Expand Up @@ -100,6 +100,15 @@ pub fn execute(
ExecuteMsg::Burn { amount } => {
execute_burn(deps, env, info, amount).map_err(ContractError::Cw20BaseError)
}
ExecuteMsg::Send {
contract,
amount,
msg,
} => execute_send(deps, env, info, contract, amount, msg)
.map_err(ContractError::Cw20BaseError),
ExecuteMsg::Mint { recipient, amount } => {
execute_mint(deps, env, info, recipient, amount).map_err(ContractError::Cw20BaseError)
}
ExecuteMsg::IncreaseAllowance {
spender,
amount,
Expand All @@ -121,9 +130,13 @@ pub fn execute(
ExecuteMsg::BurnFrom { owner, amount } => {
execute_burn_from(deps, env, info, owner, amount).map_err(ContractError::Cw20BaseError)
}
ExecuteMsg::Mint { recipient, amount } => {
execute_mint(deps, env, info, recipient, amount).map_err(ContractError::Cw20BaseError)
}
ExecuteMsg::SendFrom {
owner,
contract,
amount,
msg,
} => execute_send_from(deps, env, info, owner, contract, amount, msg)
.map_err(ContractError::Cw20BaseError),
ExecuteMsg::UpdateMinter { new_minter } => {
execute_update_minter(deps, env, info, new_minter).map_err(ContractError::Cw20BaseError)
}
Expand Down
1 change: 1 addition & 0 deletions scripts/generate_wasm.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ fi

# Generate optimized wasm files and verify generated wasm with cosmwasm-check
mkdir -p artifacts/archway
cargo install [email protected] --locked

RUSTFLAGS='-C link-arg=-s' cargo wasm
for WASM in ./target/wasm32-unknown-unknown/release/*.wasm; do
Expand Down

0 comments on commit 2bf9ae4

Please sign in to comment.