diff --git a/integration-tests/package-lock.json b/integration-tests/package-lock.json index 6a45d2ee..31a99be5 100644 --- a/integration-tests/package-lock.json +++ b/integration-tests/package-lock.json @@ -9,7 +9,7 @@ "version": "v2.7.0", "license": "MIT", "dependencies": { - "@terra-money/feather.js": "^2.0.0-beta.8", + "@terra-money/feather.js": "^2.0.0-beta.12", "@terra-money/terra.proto": "^4.0.1", "moment": "^2.29.4" }, @@ -1803,9 +1803,9 @@ } }, "node_modules/@terra-money/feather.js": { - "version": "2.0.0-beta.8", - "resolved": "https://registry.npmjs.org/@terra-money/feather.js/-/feather.js-2.0.0-beta.8.tgz", - "integrity": "sha512-lIVCPTf/YXDigujVPHnjsPDg0Gnjmo4y5Z/bGVSOj4mqHcPOsKjzAeu1ZKZyRqVVTU6/y4EJhroOxoTcSbPwTg==", + "version": "2.0.0-beta.12", + "resolved": "https://registry.npmjs.org/@terra-money/feather.js/-/feather.js-2.0.0-beta.12.tgz", + "integrity": "sha512-qxUQJtHOp3Ybpr5T5s1XXYiADZbH6g0HdLEhkPkJtBtjxxKN+UeLVJ+4SmkxglA7sITCuSoZebBrv8yukHsmJw==", "dependencies": { "@ethersproject/bytes": "^5.7.0", "@terra-money/legacy.proto": "npm:@terra-money/terra.proto@^0.1.7", @@ -7008,9 +7008,9 @@ } }, "@terra-money/feather.js": { - "version": "2.0.0-beta.8", - "resolved": "https://registry.npmjs.org/@terra-money/feather.js/-/feather.js-2.0.0-beta.8.tgz", - "integrity": "sha512-lIVCPTf/YXDigujVPHnjsPDg0Gnjmo4y5Z/bGVSOj4mqHcPOsKjzAeu1ZKZyRqVVTU6/y4EJhroOxoTcSbPwTg==", + "version": "2.0.0-beta.12", + "resolved": "https://registry.npmjs.org/@terra-money/feather.js/-/feather.js-2.0.0-beta.12.tgz", + "integrity": "sha512-qxUQJtHOp3Ybpr5T5s1XXYiADZbH6g0HdLEhkPkJtBtjxxKN+UeLVJ+4SmkxglA7sITCuSoZebBrv8yukHsmJw==", "requires": { "@ethersproject/bytes": "^5.7.0", "@terra-money/legacy.proto": "npm:@terra-money/terra.proto@^0.1.7", diff --git a/integration-tests/package.json b/integration-tests/package.json index d1197f89..c0085c73 100644 --- a/integration-tests/package.json +++ b/integration-tests/package.json @@ -4,7 +4,7 @@ "description": "Integration tests for Core using feather.js", "main": "index.ts", "scripts": { - "test": "jest" + "test": "jest --maxConcurrency=4" }, "repository": { "type": "git", @@ -30,7 +30,7 @@ "typescript": "^5.2.2" }, "dependencies": { - "@terra-money/feather.js": "^2.0.0-beta.8", + "@terra-money/feather.js": "^2.0.0-beta.12", "@terra-money/terra.proto": "^4.0.1", "moment": "^2.29.4" } diff --git a/integration-tests/src/modules/feeshare/feeshare.test.ts b/integration-tests/src/modules/feeshare/feeshare.test.ts index 2d5cf3e6..4dacfe5d 100644 --- a/integration-tests/src/modules/feeshare/feeshare.test.ts +++ b/integration-tests/src/modules/feeshare/feeshare.test.ts @@ -12,7 +12,7 @@ describe("Feeshare Module (https://github.com/terra-money/core/tree/release/v2.6 const randomAccountAddress = new MnemonicKey().accAddress("terra"); let contractAddress: string; - // Reat the reflect contract, store on chain, + // Read the reflect contract, store on chain, // instantiate to be used in the following tests // and finally save the contract address. beforeAll(async () => { diff --git a/integration-tests/src/modules/tokenfactory/tokenfactory.test.ts b/integration-tests/src/modules/tokenfactory/tokenfactory.test.ts index 0abdebcc..9de2e9bb 100644 --- a/integration-tests/src/modules/tokenfactory/tokenfactory.test.ts +++ b/integration-tests/src/modules/tokenfactory/tokenfactory.test.ts @@ -1,4 +1,4 @@ -import { Coins, MsgInstantiateContract, MsgStoreCode } from "@terra-money/feather.js"; +import { Coin, Coins, Fee, MnemonicKey, MsgBurn, MsgChangeAdmin, MsgCreateDenom, MsgInstantiateContract, MsgMint, MsgStoreCode, MsgSetBeforeSendHook, MsgSend } from "@terra-money/feather.js"; import { getMnemonics, getLCDClient, blockInclusion } from "../../helpers"; import fs from "fs"; import path from 'path'; @@ -9,9 +9,12 @@ describe("Feeshare Module (https://github.com/terra-money/core/tree/release/v2.7 const accounts = getMnemonics(); const wallet = LCD.chain1.wallet(accounts.tokenFactoryMnemonic); const tokenFactoryWalletAddr = accounts.tokenFactoryMnemonic.accAddress("terra"); + const randomAccountAddr = new MnemonicKey().accAddress("terra"); let contractAddress: string; + let subdenom = Math.random().toString(36).substring(7); + let factoryDenom: string | undefined = undefined - // Reat the reflect contract, store on chain, + // Read the no100 contract, store on chain, // instantiate to be used in the following tests // and finally save the contract address. beforeAll(async () => { @@ -47,35 +50,501 @@ describe("Feeshare Module (https://github.com/terra-money/core/tree/release/v2.7 txResult = await LCD.chain1.tx.txInfo(result.txhash, "test-1") as any; contractAddress = txResult.logs[0].events[4].attributes[0].value; expect(contractAddress).toBeDefined(); - }); + }) - test('Must contain the correct module params', async () => { - const moduleParams = await LCD.chain1.feeshare.params("test-1"); + // Validate the token factory having the correct params + test('Must have the correct module params', async () => { + const moduleParams = await LCD.chain1.tokenfactory.params("test-1"); expect(moduleParams) - .toMatchObject({ + .toStrictEqual({ "params": { - "allowed_denoms": [], - "developer_shares": "0.500000000000000000", - "enable_fee_share": true, - }, + "denom_creation_fee": [{ + "amount": "10000000", + "denom": "uluna" + }], + "denom_creation_gas_consume": "1000000" + } }); - }); - - test('Must query all endpoints before creating a denom', async () => { - // // Register feeshare - // let tx = await wallet.createAndSignTx({ - // msgs: [new MsgCreateDenom( - // contractAddress, - // subdenom, - // )], - // chainID: "test-1", - // }); - // let result = await LCD.chain1.tx.broadcastSync(tx, "test-1"); - // await blockInclusion(); - // let txResult = await LCD.chain1.tx.txInfo(result.txhash, "test-1") as any; - // console.log(txResult.logs) - // console.log(randomAccountAddress) - // expect(txResult.logs).toBeDefined(); - }); + }) + + // Create a denom using token factory, + // store the factoryDenom and read the + // transaction result logs to assert + // the logs are correctly formatted. + test('Must create a denom', async () => { + let tx = await wallet.createAndSignTx({ + msgs: [ + new MsgCreateDenom( + tokenFactoryWalletAddr, + subdenom, + ), + ], + chainID: "test-1", + }); + let result = await LCD.chain1.tx.broadcastSync(tx, "test-1"); + await blockInclusion(); + let txResult = await LCD.chain1.tx.txInfo(result.txhash, "test-1") as any; + factoryDenom = txResult.logs[0].eventsByType.create_denom.new_token_denom[0] as string + expect(txResult.logs[0].events).toStrictEqual([{ + "type": "message", + "attributes": [{ + "key": "action", + "value": "/osmosis.tokenfactory.v1beta1.MsgCreateDenom" + }, { + "key": "sender", + "value": tokenFactoryWalletAddr + }, { + "key": "module", + "value": "tokenfactory" + }] + }, { + "type": "coin_spent", + "attributes": [{ + "key": "spender", + "value": tokenFactoryWalletAddr + }, { + "key": "amount", + "value": "10000000uluna" + }] + }, { + "type": "coin_received", + "attributes": [{ + "key": "receiver", + "value": "terra1jv65s3grqf6v6jl3dp4t6c9t9rk99cd8pm7utl" + }, { + "key": "amount", + "value": "10000000uluna" + }] + }, { + "type": "transfer", + "attributes": [{ + "key": "recipient", + "value": "terra1jv65s3grqf6v6jl3dp4t6c9t9rk99cd8pm7utl" + }, { + "key": "sender", + "value": tokenFactoryWalletAddr + }, { + "key": "amount", + "value": "10000000uluna" + }] + }, { + "type": "message", + "attributes": [{ + "key": "sender", + "value": tokenFactoryWalletAddr + }] + }, { + "type": "create_denom", + "attributes": [{ + "key": "creator", + "value": tokenFactoryWalletAddr + }, { + "key": "new_token_denom", + "value": factoryDenom + }] + }]); + }) + + // Mint tokens to the minter address + // and assert the logs are correctly formatted. + describe("After creating the token", () => { + test('Must mint some tokens', async () => { + let tx = await wallet.createAndSignTx({ + msgs: [ + new MsgMint( + tokenFactoryWalletAddr, + Coin.fromString("1000000000" + factoryDenom) + ), + ], + chainID: "test-1", + }); + let result = await LCD.chain1.tx.broadcastSync(tx, "test-1"); + await blockInclusion(); + let txResult = await LCD.chain1.tx.txInfo(result.txhash, "test-1") as any; + expect(txResult.logs[0].events).toStrictEqual([{ + "type": "message", + "attributes": [{ + "key": "action", + "value": "/osmosis.tokenfactory.v1beta1.MsgMint" + }, { + "key": "sender", + "value": tokenFactoryWalletAddr + }, { + "key": "module", + "value": "tokenfactory" + }] + }, + { + "type": "coin_received", + "attributes": [{ + "key": "receiver", + "value": "terra19ejy8n9qsectrf4semdp9cpknflld0j6my8d0p" + }, { + "key": "amount", + "value": "1000000000" + factoryDenom + }] + }, + { + "type": "coinbase", + "attributes": [{ + "key": "minter", + "value": "terra19ejy8n9qsectrf4semdp9cpknflld0j6my8d0p" + }, { + "key": "amount", + "value": "1000000000" + factoryDenom + }] + }, + { + "type": "coin_spent", + "attributes": [{ + "key": "spender", + "value": "terra19ejy8n9qsectrf4semdp9cpknflld0j6my8d0p" + }, { + "key": "amount", + "value": "1000000000" + factoryDenom + }] + }, + { + "type": "coin_received", + "attributes": [{ + "key": "receiver", + "value": tokenFactoryWalletAddr + }, { + "key": "amount", + "value": "1000000000" + factoryDenom + }] + }, + { + "type": "transfer", + "attributes": [{ + "key": "recipient", + "value": tokenFactoryWalletAddr + }, { + "key": "sender", + "value": "terra19ejy8n9qsectrf4semdp9cpknflld0j6my8d0p" + }, { + "key": "amount", + "value": "1000000000" + factoryDenom + }] + }, + { + "type": "message", + "attributes": [{ + "key": "sender", + "value": "terra19ejy8n9qsectrf4semdp9cpknflld0j6my8d0p" + }] + }, + { + "type": "tf_mint", + "attributes": [{ + "key": "mint_to_address", + "value": tokenFactoryWalletAddr + }, { + "key": "amount", + "value": "1000000000" + factoryDenom + }] + }]); + }); + }) + + // Burn some tokens from the minter account + // and asser the logs are correctly formatted. + describe("After minting the tokens", () => { + test('Must burn some tokens', async () => { + let tx = await wallet.createAndSignTx({ + msgs: [ + new MsgBurn( + tokenFactoryWalletAddr, + Coin.fromString("500000000" + factoryDenom) + ), + ], + chainID: "test-1", + fee: new Fee(100_000, new Coins({ uluna: 100_000 })), + }); + let result = await LCD.chain1.tx.broadcastSync(tx, "test-1"); + await blockInclusion(); + let txResult = await LCD.chain1.tx.txInfo(result.txhash, "test-1") as any; + expect(txResult.logs[0].events).toStrictEqual([{ + "type": "message", + "attributes": [{ + "key": "action", + "value": "/osmosis.tokenfactory.v1beta1.MsgBurn" + }, { + "key": "sender", + "value": tokenFactoryWalletAddr + }, { + "key": "module", + "value": "tokenfactory" + }] + }, { + "type": "coin_spent", + "attributes": [{ + "key": "spender", + "value": tokenFactoryWalletAddr + }, { + "key": "amount", + "value": "500000000" + factoryDenom + }] + }, { + "type": "coin_received", + "attributes": [{ + "key": "receiver", + "value": "terra19ejy8n9qsectrf4semdp9cpknflld0j6my8d0p" + }, { + "key": "amount", + "value": "500000000" + factoryDenom + }] + }, { + "type": "transfer", + "attributes": [{ + "key": "recipient", + "value": "terra19ejy8n9qsectrf4semdp9cpknflld0j6my8d0p" + }, { + "key": "sender", + "value": tokenFactoryWalletAddr + }, { + "key": "amount", + "value": "500000000" + factoryDenom + }] + }, { + "type": "message", + "attributes": [{ + "key": "sender", + "value": tokenFactoryWalletAddr + } + ] + }, { + "type": "coin_spent", + "attributes": [{ + "key": "spender", + "value": "terra19ejy8n9qsectrf4semdp9cpknflld0j6my8d0p" + }, { + "key": "amount", + "value": "500000000" + factoryDenom + }] + }, { + "type": "burn", + "attributes": [{ + "key": "burner", + "value": "terra19ejy8n9qsectrf4semdp9cpknflld0j6my8d0p" + }, { + "key": "amount", + "value": "500000000" + factoryDenom + }] + }, { + "type": "tf_burn", + "attributes": [{ + "key": "burn_from_address", + "value": tokenFactoryWalletAddr + }, { + "key": "amount", + "value": "500000000" + factoryDenom + }] + }]) + }); + }) + + + describe("Use before send hooks", () => { + test("Must register the hooks to the no100 contract", async () => { + let tx = await wallet.createAndSignTx({ + msgs: [ + new MsgSetBeforeSendHook( + tokenFactoryWalletAddr, + factoryDenom as string, + contractAddress, + ), + ], + fee: new Fee(100_000, new Coins({ uluna: 100_000 })), + chainID: "test-1", + }); + let result = await LCD.chain1.tx.broadcastSync(tx, "test-1"); + await blockInclusion(); + let txResult = await LCD.chain1.tx.txInfo(result.txhash, "test-1") as any; + expect(txResult.logs[0].events).toStrictEqual([{ + "type": "message", + "attributes": [{ + "key": "action", + "value": "/osmosis.tokenfactory.v1beta1.MsgSetBeforeSendHook" + }, { + "key": "sender", + "value": tokenFactoryWalletAddr + }, { + "key": "module", + "value": "tokenfactory" + }] + }, { + "type": "set_before_send_hook", + "attributes": [{ + "key": "denom", + "value": factoryDenom + }, { + "key": "before_send_hook_address", + "value": contractAddress + }] + }]); + }); + + + // This test proves that the wasm contract + // is being executed on the sudo before send + // hook, one test allows transaction and the + // other one blocks the transaction. + describe("Must send tokens and be intercepted by beforesendhooks", () => { + test("1 token successfuly", async () => { + let tx = await wallet.createAndSignTx({ + msgs: [ + new MsgSend( + tokenFactoryWalletAddr, + randomAccountAddr, + Coins.fromString("1" + factoryDenom), + ), + ], + chainID: "test-1", + }); + let result = await LCD.chain1.tx.broadcastSync(tx, "test-1"); + await blockInclusion(); + let txResult = await LCD.chain1.tx.txInfo(result.txhash, "test-1") as any; + expect(txResult.logs[0].events) + .toStrictEqual([{ + "type": "message", + "attributes": [{ + "key": "action", + "value": "/cosmos.bank.v1beta1.MsgSend" + }, { + "key": "sender", + "value": tokenFactoryWalletAddr + }, { + "key": "module", + "value": "bank" + }] + }, { + "type": "coin_spent", + "attributes": [{ + "key": "spender", + "value": tokenFactoryWalletAddr + }, { + "key": "amount", + "value": "1" + factoryDenom + }] + }, { + "type": "coin_received", + "attributes": [{ + "key": "receiver", + "value": randomAccountAddr + }, { + "key": "amount", + "value": "1" + factoryDenom + }] + }, { + "type": "transfer", + "attributes": [{ + "key": "recipient", + "value": randomAccountAddr + }, { + "key": "sender", + "value": tokenFactoryWalletAddr + }, { + "key": "amount", + "value": "1" + factoryDenom + }] + }, { + "type": "message", + "attributes": [{ + "key": "sender", + "value": tokenFactoryWalletAddr + }] + }]); + }); + + test("100 token blocked by the smart contract", async () => { + let tx = await wallet.createAndSignTx({ + msgs: [ + new MsgSend( + tokenFactoryWalletAddr, + randomAccountAddr, + Coins.fromString("1000000000" + factoryDenom), + ), + ], + chainID: "test-1", + fee: new Fee(100_000, new Coins({ uluna: 100_000 })), + }); + let result = await LCD.chain1.tx.broadcastSync(tx, "test-1"); + await blockInclusion(); + let txResult = await LCD.chain1.tx.txInfo(result.txhash, "test-1") as any; + expect(txResult.raw_log) + .toStrictEqual("failed to execute message; message index: 0: {Loading CosmWasm module: sudo}: gas meter hit maximum limit"); + }); + }); + }) + + + // Change the token admin to a random account + // to validate that the functionality works and + // assert the logs are correctly formatted. + describe("After all operations", () => { + test("Must change the admin of the denom", async () => { + let tx = await wallet.createAndSignTx({ + msgs: [ + new MsgChangeAdmin( + tokenFactoryWalletAddr, + randomAccountAddr, + factoryDenom as string, + ), + ], + fee: new Fee(100_000, new Coins({ uluna: 100_000 })), + chainID: "test-1", + }); + let result = await LCD.chain1.tx.broadcastSync(tx, "test-1"); + await blockInclusion(); + let txResult = await LCD.chain1.tx.txInfo(result.txhash, "test-1") as any; + expect(txResult.logs[0].events).toStrictEqual([{ + "type": "message", + "attributes": [{ + "key": "action", + "value": "/osmosis.tokenfactory.v1beta1.MsgChangeAdmin" + }, { + "key": "sender", + "value": tokenFactoryWalletAddr + }, { + "key": "module", + "value": "tokenfactory" + }] + }, + { + "type": "change_admin", + "attributes": [{ + "key": "denom", + "value": factoryDenom + }, { + "key": "new_admin", + "value": randomAccountAddr + }] + }]); + }); + + test("Must query the new admin of the denom", async () => { + const res = await LCD.chain1.tokenfactory.authorityMetadata("test-1", encodeURIComponent(encodeURIComponent(factoryDenom as string))); + + expect(res) + .toStrictEqual({ + "authority_metadata": { + "admin": randomAccountAddr + } + }) + }) + + test("Must query the before send hook", async () => { + const res = await LCD.chain1.tokenfactory.beforeSendHook("test-1", encodeURIComponent(encodeURIComponent(factoryDenom as string))); + + expect(res) + .toStrictEqual({ "cosmwasm_address": contractAddress }) + }) + + test("Must query the before send hook", async () => { + const res = await LCD.chain1.tokenfactory.denomsFromCreator(tokenFactoryWalletAddr); + expect(res.denoms.length).toBeGreaterThanOrEqual(1); + }) + }) }); \ No newline at end of file diff --git a/scripts/tests/tokenfactory/tokenfactory.sh b/scripts/tests/tokenfactory/tokenfactory.sh deleted file mode 100755 index e619fe55..00000000 --- a/scripts/tests/tokenfactory/tokenfactory.sh +++ /dev/null @@ -1,99 +0,0 @@ -#!/bin/bash - -echo "" -echo "##########################################" -echo "# Create, Delete, Mint with Tokenfactory #" -echo "##########################################" -echo "" - -BINARY=terrad -CHAIN_DIR=$(pwd)/data -TOKEN_DENOM=utoken$RANDOM -MINT_AMOUNT=1000000 - -WALLET_1=$($BINARY keys show wallet1 -a --keyring-backend test --home $CHAIN_DIR/test-1) -WALLET_2=$($BINARY keys show wallet2 -a --keyring-backend test --home $CHAIN_DIR/test-2) -WALLET_3=$($BINARY keys show wallet3 -a --keyring-backend test --home $CHAIN_DIR/test-1) - -echo "Creating token denom $TOKEN_DENOM with $WALLET_1 on chain test-1" -TX_HASH=$($BINARY tx tokenfactory create-denom $TOKEN_DENOM --from $WALLET_1 --home $CHAIN_DIR/test-1 --chain-id test-1 --node tcp://localhost:16657 --gas 2000000 --keyring-backend test -o json -y | jq -r '.txhash') -sleep 3 -CREATED_RES_DENOM=$($BINARY query tx $TX_HASH -o josn --chain-id test-1 --home $CHAIN_DIR/test-1 --node tcp://localhost:16657 | jq -r '.logs[0].events[5].attributes[1].value') - -if [ "$CREATED_RES_DENOM" != "factory/$WALLET_1/$TOKEN_DENOM" ]; then - echo "ERROR: Tokenfactory creating denom error. Expected result 'factory/$WALLET_1/$TOKEN_DENOM', got '$CREATED_RES_DENOM'" - exit 1 -fi - -echo "Minting $MINT_AMOUNT units of $TOKEN_DENOM with $WALLET_1 on chain test-1" -TX_HASH=$($BINARY tx tokenfactory mint $MINT_AMOUNT$CREATED_RES_DENOM --from $WALLET_1 --home $CHAIN_DIR/test-1 --chain-id test-1 --node tcp://localhost:16657 --keyring-backend test -o json -y | jq -r '.txhash') -sleep 3 -MINT_RES=$($BINARY query tx $TX_HASH -o josn --chain-id test-1 --home $CHAIN_DIR/test-1 --node tcp://localhost:16657 | jq -r '.logs[0].events[2].type') -if [ "$MINT_RES" != "coinbase" ]; then - echo "ERROR: Tokenfactory minting error. Expected result 'coinbase', got '$CREATED_RES_DENOM'" - exit 1 -fi - -echo "Querying $TOKEN_DENOM from $WALLET_1 on chain test-1 to validate the amount minted" -BALANCE_RES_AMOUNT=$($BINARY query bank balances $WALLET_1 --denom $CREATED_RES_DENOM --chain-id test-2 --node tcp://localhost:16657 -o json | jq -r '.amount') -if [ "$BALANCE_RES_AMOUNT" != $MINT_AMOUNT ]; then - echo "ERROR: Tokenfactory minting error. Expected minted balance '$MINT_AMOUNT', got '$BALANCE_RES_AMOUNT'" - exit 1 -fi - -echo "Burning 1 $TOKEN_DENOM from $WALLET_1 on chain test-1" -TX_HASH=$($BINARY tx tokenfactory burn 1$CREATED_RES_DENOM --from $WALLET_1 --home $CHAIN_DIR/test-1 --chain-id test-1 --node tcp://localhost:16657 --keyring-backend test -o json -y | jq -r '.txhash') -sleep 3 -BURN_RES=$($BINARY query tx $TX_HASH -o josn --chain-id test-1 --home $CHAIN_DIR/test-1 --node tcp://localhost:16657 | jq -r '.logs[0].events[7].type') -if [ "$BURN_RES" != "tf_burn" ]; then - echo "ERROR: Tokenfactory burning error. Expected result 'tf_burn', got '$BURN_RES'" - exit 1 -fi - -echo "Querying $TOKEN_DENOM from $WALLET_1 on chain test-1 to validate the burned amount" -BALANCES_AFTER_BURNING=$($BINARY query bank balances $WALLET_1 --denom $CREATED_RES_DENOM --chain-id test-2 --node tcp://localhost:16657 -o json | jq -r '.amount') -if [ "$BALANCES_AFTER_BURNING" != 999999 ]; then - echo "ERROR: Tokenfactory minting error. Expected minted balance '999999', got '$BALANCES_AFTER_BURNING'" - exit 1 -fi - -echo "Sending 1 $TOKEN_DENOM from $WALLET_1 to $WALLET_3 on chain test-1" -TX_HASH=$($BINARY tx bank send $WALLET_1 $WALLET_3 1$CREATED_RES_DENOM --from $WALLET_1 --home $CHAIN_DIR/test-1 --chain-id test-1 --node tcp://localhost:16657 --keyring-backend test -o json -y | jq -r '.txhash') -sleep 3 -SEND_RES_MSG_TYPE=$($BINARY query tx $TX_HASH -o josn --chain-id test-1 --home $CHAIN_DIR/test-1 --node tcp://localhost:16657 | jq -r '.logs[0].events[0].attributes[0].value') -if [ "$SEND_RES_MSG_TYPE" != "/cosmos.bank.v1beta1.MsgSend" ]; then - echo "ERROR: Sending expected to be '/cosmos.bank.v1beta1.MsgSend' but got '$SEND_RES_MSG_TYPE'" - exit 1 -fi - -echo "Querying $TOKEN_DENOM from $WALLET_3 on chain test-1 to validate the funds were received" -BALANCES_RECEIVED=$($BINARY query bank balances $WALLET_3 --denom $CREATED_RES_DENOM --chain-id test-2 --node tcp://localhost:16657 -o json | jq -r '.amount') -if [ "$BALANCES_RECEIVED" != 1 ]; then - echo "ERROR: Tokenfactory minting error. Expected minted balance '1', got '$BALANCES_RECEIVED'" - exit 1 -fi - - -echo "IBC'ing 1 $TOKEN_DENOM from $WALLET_1 chain test-1 to $WALLET_2 chain test-2" -TX_HASH=$($BINARY tx ibc-transfer transfer transfer channel-0 $WALLET_2 1$CREATED_RES_DENOM --chain-id test-1 --home $CHAIN_DIR/test-1 --node tcp://localhost:16657 --keyring-backend test --from $WALLET_1 -y -o json | jq -r '.txhash') -sleep 3 -IBC_SEND_RES=$($BINARY query tx $TX_HASH -o josn --chain-id test-1 --home $CHAIN_DIR/test-1 --node tcp://localhost:16657 | jq -r '.logs[0].events[0].attributes[0].value') -if [ "$IBC_SEND_RES" != "/ibc.applications.transfer.v1.MsgTransfer" ]; then - echo "ERROR: IBC'ing expected type '/ibc.applications.transfer.v1.MsgTransfer' but got '$IBC_SEND_RES'" - exit 1 -fi - -IBC_RECEIVED_RES_AMOUNT=$($BINARY query bank balances $WALLET_2 --chain-id test-2 --node tcp://localhost:26657 -o json | jq -r '.balances[0].amount') -IBC_RECEIVED_RES_DENOM="" -while [ "$IBC_RECEIVED_RES_AMOUNT" != "1" ] || [ "${IBC_RECEIVED_RES_DENOM:0:4}" != "ibc/" ]; do - sleep 2 - IBC_RECEIVED_RES_AMOUNT=$($BINARY query bank balances $WALLET_2 --chain-id test-2 --node tcp://localhost:26657 -o json | jq -r '.balances[0].amount') - IBC_RECEIVED_RES_DENOM=$($BINARY query bank balances $WALLET_2 --chain-id test-2 --node tcp://localhost:26657 -o json | jq -r '.balances[0].denom') - echo "Received:" $IBC_RECEIVED_RES_AMOUNT $IBC_RECEIVED_RES_DENOM -done - -echo "" -echo "###################################################" -echo "# SUCCESS: Create, Delete, Mint with Tokenfactory #" -echo "###################################################" -echo "" diff --git a/x/tokenfactory/keeper/grpc_query.go b/x/tokenfactory/keeper/grpc_query.go index 048cad7f..2eac0817 100644 --- a/x/tokenfactory/keeper/grpc_query.go +++ b/x/tokenfactory/keeper/grpc_query.go @@ -41,6 +41,10 @@ func (k Keeper) DenomsFromCreator(ctx context.Context, req *types.QueryDenomsFro func (k Keeper) BeforeSendHookAddress(ctx context.Context, req *types.QueryBeforeSendHookAddressRequest) (*types.QueryBeforeSendHookAddressResponse, error) { sdkCtx := sdk.UnwrapSDKContext(ctx) + decodedDenom, err := url.QueryUnescape(req.Denom) + if err == nil { + req.Denom = decodedDenom + } cosmwasmAddress := k.GetBeforeSendHook(sdkCtx, req.GetDenom())