diff --git a/contracts/tokenwrapper/src/contract.rs b/contracts/tokenwrapper/src/contract.rs index 96b17b0..ea151f1 100644 --- a/contracts/tokenwrapper/src/contract.rs +++ b/contracts/tokenwrapper/src/contract.rs @@ -77,7 +77,7 @@ pub fn instantiate( fee_recipient, fee_percentage, native_token_denom: msg.native_token_denom, - is_native_allowed: msg.is_native_allowed != 0, + is_native_allowed: msg.is_native_allowed, wrapping_limit: msg.wrapping_limit, proposal_nonce: 0_u64, }, @@ -253,10 +253,13 @@ fn wrap_native( } // send "fee" to fee_recipient - let msgs: Vec = vec![CosmosMsg::Bank(BankMsg::Send { - to_address: config.fee_recipient.to_string(), - amount: coins(cost_to_wrap.u128(), config.native_token_denom), - })]; + let mut msgs: Vec = vec![]; + if !cost_to_wrap.is_zero() { + msgs.push(CosmosMsg::Bank(BankMsg::Send { + to_address: config.fee_recipient.to_string(), + amount: coins(cost_to_wrap.u128(), config.native_token_denom), + })); + } Ok(Response::new().add_messages(msgs).add_attributes(vec![ attr("action", "wrap_native"), @@ -424,14 +427,17 @@ fn wrap_cw20( } // Send the "fee" to "fee_recipient". - let msgs: Vec = vec![CosmosMsg::Wasm(WasmMsg::Execute { - contract_addr: cw20_address.to_string(), - funds: vec![], - msg: to_binary(&Cw20ExecuteMsg::Transfer { - recipient: config.fee_recipient.to_string(), - amount: cost_to_wrap, - })?, - })]; + let mut msgs: Vec = vec![]; + if !cost_to_wrap.is_zero() { + msgs.push(CosmosMsg::Wasm(WasmMsg::Execute { + contract_addr: cw20_address.to_string(), + funds: vec![], + msg: to_binary(&Cw20ExecuteMsg::Transfer { + recipient: config.fee_recipient.to_string(), + amount: cost_to_wrap, + })?, + })); + } Ok(Response::new().add_messages(msgs).add_attributes(vec![ attr("action", "wrap_cw20"), diff --git a/contracts/tokenwrapper/src/tests.rs b/contracts/tokenwrapper/src/tests.rs index fa7bcf6..19d78a5 100644 --- a/contracts/tokenwrapper/src/tests.rs +++ b/contracts/tokenwrapper/src/tests.rs @@ -20,7 +20,7 @@ const FEE_PERCENTAGE: u8 = 1_u8; const NATIVE_TOKEN_DENOM: &str = "uusd"; const CW20_TOKEN: &str = "cw20_token"; const WRAPPING_LIMIT: u128 = 5000000; -const IS_NATIVE_ALLOWED: u32 = 1; +const IS_NATIVE_ALLOWED: bool = true; fn init_tokenwrapper(coins: Vec) -> OwnedDeps { let mut deps = mock_dependencies_with_balance(&coins); diff --git a/packages/protocol_cosmwasm/src/token_wrapper.rs b/packages/protocol_cosmwasm/src/token_wrapper.rs index 0db1a79..620a2c9 100644 --- a/packages/protocol_cosmwasm/src/token_wrapper.rs +++ b/packages/protocol_cosmwasm/src/token_wrapper.rs @@ -23,7 +23,7 @@ pub struct InstantiateMsg { /// native token denom string to be wrapped pub native_token_denom: String, /// flag of is_native_allowed - pub is_native_allowed: u32, + pub is_native_allowed: bool, /// wrapping limit pub wrapping_limit: Uint128, } diff --git a/test-scripts/src/config/localjunoConstants.ts.example b/test-scripts/src/config/localjunoConstants.ts.example index 7a2ab07..c4a2119 100644 --- a/test-scripts/src/config/localjunoConstants.ts.example +++ b/test-scripts/src/config/localjunoConstants.ts.example @@ -30,5 +30,42 @@ export const localjuno = { anchor: "juno...", vanchor: "juno...", mixer: "juno...", + treasuryHandler: "juno...", + treasury: "juno...", }, + + contractsConsts: { + chain_id: "3751615234", // "testing" + + // Test Cw20 token + cw20TokenName: "ABC_TOKEN", + cw20TokenSymbol: "ABCT", + decimals: 6, + + // "SignatureBridge" + testPubKey: [], + testPrivKey: "0x...", + + // "TokenWrapper" + tokenWrapperTokenName: "Webb_Wrap_Token", + tokenWrapperTokenSymbol: "WWRT", + + feePercentage: 0, + nativeTokenDenom: "ucosm", + isNativeAllowed: true, + tokenWrapperWrappingLimit: "1000000", + + + // "TokenWrapperHandler" + + // "Anchor", "VAnchor" & "Mixer" + maxEdges: 2, + levels: 30, + depositSize: "1000000", + + maxDepositAmt: "1000000", + minWithdrawAmt: "0", + maxExtAmt: "1000000", + maxFee: "1000000", + } }; \ No newline at end of file diff --git a/test-scripts/src/environments/localjuno.ts b/test-scripts/src/environments/localjuno.ts index b8a1dfa..3a1e62a 100644 --- a/test-scripts/src/environments/localjuno.ts +++ b/test-scripts/src/environments/localjuno.ts @@ -62,7 +62,7 @@ async function initialize() { treasury = config.contracts.treasury; treasuryHandler = config.contracts.treasuryHandler; - console.log(`Use ${chalk.cyan(cw20)} as Cw20(AUTO) token`); + console.log(`Use ${chalk.cyan(cw20)} as Cw20(ABCT) token`); console.log(`Use ${chalk.cyan(signatureBridge)} as SignatureBridge`); console.log(`Use ${chalk.cyan(tokenWrapper)} as TokenWrapper`); console.log(`Use ${chalk.cyan(tokenWrapperHandler)} as TokenWrapperHandler`); diff --git a/test-scripts/src/environments/testnet.ts b/test-scripts/src/environments/testnet.ts index 8fe7dd7..f9b11c9 100644 --- a/test-scripts/src/environments/testnet.ts +++ b/test-scripts/src/environments/testnet.ts @@ -63,7 +63,7 @@ async function initialize() { treasury = config.contracts.treasury; treasury = config.contracts.treasuryHandler; - console.log(`Use ${chalk.cyan(cw20)} as Cw20(AUTO) token`); + console.log(`Use ${chalk.cyan(cw20)} as Cw20(ABCT) token`); console.log(`Use ${chalk.cyan(signatureBridge)} as SignatureBridge`); console.log(`Use ${chalk.cyan(tokenWrapper)} as TokenWrapper`); console.log(`Use ${chalk.cyan(tokenWrapperHandler)} as TokenWrapperHandler`); diff --git a/test-scripts/src/processes/setup/testnet.ts b/test-scripts/src/processes/setup/testnet.ts index 9da4c75..9b26a7a 100644 --- a/test-scripts/src/processes/setup/testnet.ts +++ b/test-scripts/src/processes/setup/testnet.ts @@ -50,8 +50,8 @@ export async function setupContracts( wallet3 = wallets.wallet3; // Send some test tokens to test wallets - await junod.sendTokens(localjuno.addresses.wallet1, localjuno.addresses.wallet2, [coin("100000000", "ucosm"), coin("10000000", "ujunox")], "auto"); - await junod.sendTokens(localjuno.addresses.wallet1, localjuno.addresses.wallet3, [coin("100000000", "ucosm"), coin("10000000", "ujunox")], "auto"); + await junod.sendTokens(localjuno.addresses.wallet1, localjuno.addresses.wallet2, [coin("10000000", "ucosm"), coin("1000000", "ujunox")], "auto"); + await junod.sendTokens(localjuno.addresses.wallet1, localjuno.addresses.wallet3, [coin("10000000", "ucosm"), coin("1000000", "ujunox")], "auto"); await setup(junod, wallet1); @@ -149,9 +149,9 @@ async function setup( // Step 2. Instantiate contracts // CW20 token - process.stdout.write("Instantiating CW20(AUTO) token contract"); + process.stdout.write("Instantiating CW20(ABC) token contract"); - const autoTokenResult = await instantiateContract( + const cw20TokenResult = await instantiateContract( junod, wallet1, wallet1, @@ -176,7 +176,7 @@ async function setup( ] } ); - cw20 = autoTokenResult.contractAddress; + cw20 = cw20TokenResult.contractAddress; console.log(chalk.green(" Done!"), `${chalk.blue("contractAddress")}=${cw20}`); @@ -222,7 +222,7 @@ async function setup( ); tokenWrapper = tokenWrapperResult.contractAddress; - // Register Cw20(AUTO) token in "TokenWrapper" + // Register Cw20(ABCT) token in "TokenWrapper" await junod.execute(localjuno.addresses.wallet1, tokenWrapper, { add_cw20_token_addr: { token: cw20, diff --git a/test-scripts/src/processes/tests/anchor.ts b/test-scripts/src/processes/tests/anchor.ts index 9eea663..df6987b 100644 --- a/test-scripts/src/processes/tests/anchor.ts +++ b/test-scripts/src/processes/tests/anchor.ts @@ -229,7 +229,7 @@ export async function testAnchorInitialize( // TEST: Anchor // // SCENARIO: - // 1. Wallet3 "wrap"s some CW20 token(AUTO) in anchor + // 1. Wallet3 "wrap"s some CW20 token(ABCT) in anchor // ------------------------------------------------ export async function testAnchorWrapCw20( junod: SigningCosmWasmClient, @@ -239,7 +239,7 @@ export async function testAnchorInitialize( wallet3: DirectSecp256k1HdWallet, auto_amount: string, ): Promise { - process.stdout.write(`Test - Wallet3 wrap ${auto_amount} AUTO in anchor`); + process.stdout.write(`Test - Wallet3 wrap ${auto_amount} ABCT in anchor`); let wallet3_client = await SigningCosmWasmClient.connectWithSigner( localjuno.networkInfo.url, @@ -286,7 +286,7 @@ export async function testAnchorInitialize( // TEST: Anchor // // SCENARIO: - // 1. Wallet3 "unwrap"s some WTW to Cw20 token(AUTO) in anchor + // 1. Wallet3 "unwrap"s some WTW to Cw20 token(ABCT) in anchor // ------------------------------------------------ export async function testAnchorUnwrapCw20( junod: SigningCosmWasmClient, diff --git a/test-scripts/src/processes/tests/tokenWrapper.ts b/test-scripts/src/processes/tests/tokenWrapper.ts index 96e9c9b..697c15b 100644 --- a/test-scripts/src/processes/tests/tokenWrapper.ts +++ b/test-scripts/src/processes/tests/tokenWrapper.ts @@ -31,7 +31,7 @@ export async function testTokenWrapperInitialize( expect(result.native_token_denom == localjuno.contractsConsts.nativeTokenDenom).to.be.ok; expect(result.fee_recipient == localjuno.addresses.wallet2).to.be.ok; expect(result.fee_percentage == localjuno.contractsConsts.feePercentage.toString()).to.be.ok; - expect(result.is_native_allowed == (localjuno.contractsConsts.isNativeAllowed == 1).toString()).to.be.ok; + expect(result.is_native_allowed == localjuno.contractsConsts.isNativeAllowed.toString()).to.be.ok; expect(result.wrapping_limit == localjuno.contractsConsts.tokenWrapperWrappingLimit).to.be.ok; expect(result.proposal_nonce == "1").to.be.ok; diff --git a/test-scripts/src/processes/tests/vanchor.ts b/test-scripts/src/processes/tests/vanchor.ts index 93878db..ea4735f 100644 --- a/test-scripts/src/processes/tests/vanchor.ts +++ b/test-scripts/src/processes/tests/vanchor.ts @@ -58,7 +58,7 @@ export async function testVAnchorInitialize( out_ext_amount: string, out_fee: string, ): Promise { - process.stdout.write(`Test - Wallet3 deposit ${in_auto_public_amount} AUTO to vanchor`); + process.stdout.write(`Test - Wallet3 deposit ${in_auto_public_amount} ABCT to vanchor`); // Query the "amt_to_send" for "WrapAndDeposit" action const amt_to_send_query: any = await junod.queryContractSmart(localjuno.contracts.tokenWrapper, { @@ -287,7 +287,7 @@ export async function testVAnchorInitialize( // TEST: VAnchor // // SCENARIO: - // 1. Wallet3 "wrap"s some CW20 token(AUTO) in anchor + // 1. Wallet3 "wrap"s some CW20 token(ABCT) in anchor // ------------------------------------------------ export async function testVAnchorWrapCw20( junod: SigningCosmWasmClient, @@ -297,7 +297,7 @@ export async function testVAnchorInitialize( wallet3: DirectSecp256k1HdWallet, auto_amount: string, ): Promise { - process.stdout.write(`Test - Wallet3 wrap ${auto_amount} AUTO in vanchor`); + process.stdout.write(`Test - Wallet3 wrap ${auto_amount} ABCT in vanchor`); let wallet3_client = await SigningCosmWasmClient.connectWithSigner( localjuno.networkInfo.url, @@ -346,7 +346,7 @@ export async function testVAnchorInitialize( // TEST: VAnchor // // SCENARIO: - // 1. Wallet3 "unwrap"s some WTW to Cw20 token(AUTO) in vanchor + // 1. Wallet3 "unwrap"s some WTW to Cw20 token(ABCT) in vanchor // ------------------------------------------------ export async function testVAnchorUnwrapCw20( junod: SigningCosmWasmClient,