diff --git a/contracts/test/lib.js b/contracts/test/lib.js index 83655dc40d..e1493de681 100644 --- a/contracts/test/lib.js +++ b/contracts/test/lib.js @@ -91,6 +91,43 @@ async function fundAddress(addr, amount="1000000000000000000000") { return result } +// submitAndWaitForTx submits a tx (the command must already use -b sync / +// --broadcast-mode sync) and polls `seid query tx ` until the tx is +// included in a block, then returns the post-execution response with +// `code`, `events`, `logs`, etc. populated. +// +// Use this in helpers that need to read post-execution fields and previously +// relied on -b block. Under Autobahn -b block hangs and times out, so the +// "submit and forget" -b sync pattern is the only viable broadcast mode; +// this helper recovers the post-execution data the previous -b block +// callers depended on. +// +// On CheckTx rejection (mempool admission failure), returns the broadcast +// response immediately (its `code` is non-zero and callers should detect +// the failure at that point). +async function submitAndWaitForTx(command, opts = {}) { + const maxAttempts = opts.maxAttempts || 30 + const pollIntervalMs = opts.pollIntervalMs || 500 + + const submitOutput = await execute(command) + const submitResponse = JSON.parse(submitOutput) + if (submitResponse.code !== 0) { + return submitResponse + } + const txHash = submitResponse.txhash + + for (let i = 0; i < maxAttempts; i++) { + await sleep(pollIntervalMs) + try { + const queryOut = await execute(`seid query tx ${txHash} -o json`) + return JSON.parse(queryOut) + } catch (e) { + // tx not yet included; continue polling + } + } + throw new Error(`tx ${txHash} not included after ${maxAttempts * pollIntervalMs}ms`) +} + async function evmSend(addr, fromKey, amount="10000000000000000000000000") { const output = await execute(`seid tx evm send ${addr} ${amount} --from ${fromKey} -b block -y`); return output.replace(/.*0x/, "0x").trim() @@ -260,9 +297,11 @@ async function getPointerForNative(name) { } async function storeWasm(path, from=adminKeyName) { - const command = `seid tx wasm store ${path} --from ${from} --gas=5000000 --fees=1000000usei -y --broadcast-mode block -o json` - const output = await execute(command); - const response = JSON.parse(output) + // -b sync + submitAndWaitForTx: -b block hangs under Autobahn (no + // CometBFT consensus to wait on). The poll-for-tx-by-hash pattern + // recovers the post-execution `events` we need to extract the code_id. + const command = `seid tx wasm store ${path} --from ${from} --gas=5000000 --fees=1000000usei -y --broadcast-mode sync -o json` + const response = await submitAndWaitForTx(command) if (response.code !== 0) { throw new Error(`storeWasm failed: ${response.raw_log}`) } @@ -288,7 +327,7 @@ async function getPointerForCw1155(cw1155Address) { } async function deployErc20PointerForCw20(provider, cw20Address, attempts=10, from=adminKeyName, evmRpc="") { - let command = `seid tx evm register-evm-pointer CW20 ${cw20Address} --from=${from} -b block` + let command = `seid tx evm register-evm-pointer CW20 ${cw20Address} --from=${from} -b sync` if (evmRpc) { command = command + ` --evm-rpc=${evmRpc}` } @@ -309,7 +348,7 @@ async function deployErc20PointerForCw20(provider, cw20Address, attempts=10, fro } async function deployErc20PointerNative(provider, name, from=adminKeyName, evmRpc="") { - let command = `seid tx evm call-precompile pointer addNativePointer ${name} --from=${from} -b block` + let command = `seid tx evm call-precompile pointer addNativePointer ${name} --from=${from} -b sync` if (evmRpc) { command = command + ` --evm-rpc=${evmRpc}` } @@ -328,7 +367,7 @@ async function deployErc20PointerNative(provider, name, from=adminKeyName, evmRp } async function deployErc721PointerForCw721(provider, cw721Address, from=adminKeyName, evmRpc="") { - let command = `seid tx evm register-evm-pointer CW721 ${cw721Address} --from=${from} -b block` + let command = `seid tx evm register-evm-pointer CW721 ${cw721Address} --from=${from} -b sync` if (evmRpc) { command = command + ` --evm-rpc=${evmRpc}` } @@ -349,7 +388,7 @@ async function deployErc721PointerForCw721(provider, cw721Address, from=adminKey } async function deployErc1155PointerForCw1155(provider, cw1155Address, from=adminKeyName, evmRpc="") { - let command = `seid tx evm register-evm-pointer CW1155 ${cw1155Address} --from=${from} -b block` + let command = `seid tx evm register-evm-pointer CW1155 ${cw1155Address} --from=${from} -b sync` if (evmRpc) { command = command + ` --evm-rpc=${evmRpc}` } @@ -375,10 +414,11 @@ async function deployWasm(path, adminAddr, label, args = {}, from=adminKeyName) } async function instantiateWasm(codeId, adminAddr, label, args = {}, from=adminKeyName) { + // -b sync + submitAndWaitForTx for Autobahn compatibility; we need + // post-execution `events` to read the instantiated contract address. const jsonString = JSON.stringify(args).replace(/"/g, '\\"'); - const command = `seid tx wasm instantiate ${codeId} "${jsonString}" --label ${label} --admin ${adminAddr} --from ${from} --gas=5000000 --fees=1000000usei -y --broadcast-mode block -o json`; - const output = await execute(command); - const response = JSON.parse(output); + const command = `seid tx wasm instantiate ${codeId} "${jsonString}" --label ${label} --admin ${adminAddr} --from ${from} --gas=5000000 --fees=1000000usei -y --broadcast-mode sync -o json`; + const response = await submitAndWaitForTx(command); if (response.code !== 0) { throw new Error(`instantiateWasm failed: ${response.raw_log}`) } @@ -386,9 +426,11 @@ async function instantiateWasm(codeId, adminAddr, label, args = {}, from=adminKe } async function proposeCW20toERC20Upgrade(erc20Address, cw20Address, title="erc20-pointer", version=99, description="erc20 pointer",fees="200000usei", from=adminKeyName) { - const command = `seid tx evm add-cw-erc20-pointer "${title}" "${description}" ${erc20Address} ${version} 200000000usei ${cw20Address} --from ${from} --fees ${fees} -y -o json --broadcast-mode=block` - const output = await execute(command); - const proposalId = getEventAttribute(JSON.parse(output), "submit_proposal", "proposal_id") + // -b sync + submitAndWaitForTx for Autobahn compatibility; we need + // the post-execution `events` to read the submitted proposal_id. + const command = `seid tx evm add-cw-erc20-pointer "${title}" "${description}" ${erc20Address} ${version} 200000000usei ${cw20Address} --from ${from} --fees ${fees} -y -o json --broadcast-mode=sync` + const response = await submitAndWaitForTx(command) + const proposalId = getEventAttribute(response, "submit_proposal", "proposal_id") return await passProposal(proposalId) } @@ -518,9 +560,10 @@ async function passProposal(proposalId, desposit="200000000usei", fees="200000u } async function registerPointerForERC20(erc20Address, fees="20000usei", from=adminKeyName) { - const command = `seid tx evm register-cw-pointer ERC20 ${erc20Address} --from ${from} --fees ${fees} --broadcast-mode block -y -o json` - const output = await execute(command); - const response = JSON.parse(output) + // -b sync + submitAndWaitForTx for Autobahn compatibility; we need the + // post-execution `events` to read the registered pointer_address. + const command = `seid tx evm register-cw-pointer ERC20 ${erc20Address} --from ${from} --fees ${fees} --broadcast-mode sync -y -o json` + const response = await submitAndWaitForTx(command) if(response.code !== 0) { throw new Error("contract deployment failed") } @@ -528,9 +571,10 @@ async function registerPointerForERC20(erc20Address, fees="20000usei", from=admi } async function registerPointerForERC721(erc721Address, fees="20000usei", from=adminKeyName) { - const command = `seid tx evm register-cw-pointer ERC721 ${erc721Address} --from ${from} --fees ${fees} --broadcast-mode block -y -o json` - const output = await execute(command); - const response = JSON.parse(output) + // -b sync + submitAndWaitForTx for Autobahn compatibility; we need the + // post-execution `events` to read the registered pointer_address. + const command = `seid tx evm register-cw-pointer ERC721 ${erc721Address} --from ${from} --fees ${fees} --broadcast-mode sync -y -o json` + const response = await submitAndWaitForTx(command) if(response.code !== 0) { throw new Error("contract deployment failed") } @@ -538,9 +582,10 @@ async function registerPointerForERC721(erc721Address, fees="20000usei", from=ad } async function registerPointerForERC1155(erc1155Address, fees="200000usei", from=adminKeyName) { - const command = `seid tx evm register-cw-pointer ERC1155 ${erc1155Address} --from ${from} --fees ${fees} --broadcast-mode block -y -o json` - const output = await execute(command); - const response = JSON.parse(output) + // -b sync + submitAndWaitForTx for Autobahn compatibility; we need the + // post-execution `events` to read the registered pointer_address. + const command = `seid tx evm register-cw-pointer ERC1155 ${erc1155Address} --from ${from} --fees ${fees} --broadcast-mode sync -y -o json` + const response = await submitAndWaitForTx(command) if(response.code !== 0) { throw new Error("contract deployment failed") } @@ -602,16 +647,22 @@ async function queryWasm(contractAddress, operation, args={}){ } async function executeWasm(contractAddress, msg, coins = "0usei") { + // -b sync + submitAndWaitForTx: callers (e.g. CW1155toERC1155PointerTest's + // "should not transfer an NFT if not owned") read the post-execution + // res.code to assert that DeliverTx failed. Under naked -b sync we'd + // get the CheckTx code instead (always 0 for wellformed txs). The + // poll-for-tx-by-hash recovers the DeliverTx code so those assertions + // remain meaningful under Autobahn. const jsonString = JSON.stringify(msg).replace(/"/g, '\\"'); // Properly escape JSON string - const command = `seid tx wasm execute ${contractAddress} "${jsonString}" --amount ${coins} --from ${adminKeyName} --gas=5000000 --fees=1000000usei -y --broadcast-mode block -o json`; - const output = await execute(command); - return JSON.parse(output); + const command = `seid tx wasm execute ${contractAddress} "${jsonString}" --amount ${coins} --from ${adminKeyName} --gas=5000000 --fees=1000000usei -y --broadcast-mode sync -o json`; + return await submitAndWaitForTx(command); } async function associateWasm(contractAddress) { - const command = `seid tx evm associate-contract-address ${contractAddress} --from ${adminKeyName} --gas=5000000 --fees=1000000usei -y --broadcast-mode block -o json`; - const output = await execute(command); - return JSON.parse(output); + // -b sync + submitAndWaitForTx for Autobahn compatibility; callers read + // the post-execution code/events. + const command = `seid tx evm associate-contract-address ${contractAddress} --from ${adminKeyName} --gas=5000000 --fees=1000000usei -y --broadcast-mode sync -o json`; + return await submitAndWaitForTx(command); } async function printClaimMsg(sender, claimer) { diff --git a/integration_test/contracts/_tx_helpers.sh b/integration_test/contracts/_tx_helpers.sh new file mode 100755 index 0000000000..fc94bf1bad --- /dev/null +++ b/integration_test/contracts/_tx_helpers.sh @@ -0,0 +1,65 @@ +#!/bin/bash +# Shared tx submission helpers for integration_test/contracts/*.sh. +# +# Source this file at the top of a deploy script: +# source $(dirname "$0")/_tx_helpers.sh +# +# Background: deploy scripts in this directory historically used +# `--broadcast-mode=block` to wait for the tx to be included in a block +# before reading the post-execution `code_id` / `events` / `logs` from +# the response. Under Autobahn, --broadcast-mode=block hangs and times +# out at 60s (CometBFT consensus is disabled, so the chain has no +# "block-acceptance" round-trip to wait on). +# +# submit_and_wait_for_tx implements the equivalent semantics on top of +# --broadcast-mode=sync: it reads the broadcast response from stdin +# (which contains the txhash + a CheckTx code), then polls +# `$seidbin query tx ` until the tx is included in a block, and +# prints the included tx response on stdout. The shape of the output +# is the same as `--broadcast-mode=block` would have produced, so +# callers don't need to change how they parse it. +# +# Usage: +# tx_response=$(printf "12345678\n" | $seidbin tx wasm store ... \ +# --broadcast-mode=sync --output=json \ +# | submit_and_wait_for_tx "$seidbin") +# +# Optional env vars: +# SUBMIT_MAX_ATTEMPTS (default 30) poll attempts before giving up +# SUBMIT_POLL_INTERVAL_SEC (default 1) seconds between attempts +submit_and_wait_for_tx() { + local seidbin="${1:-$HOME/go/bin/seid}" + local max_attempts="${SUBMIT_MAX_ATTEMPTS:-30}" + local poll_interval="${SUBMIT_POLL_INTERVAL_SEC:-1}" + + local submit_output + submit_output=$(cat) + + # CheckTx rejection — return the broadcast response unchanged so the + # caller can read .code / .raw_log to detect mempool failures. + local check_code + check_code=$(echo "$submit_output" | jq -r '.code // 0') + if [ "$check_code" != "0" ]; then + echo "$submit_output" + return 0 + fi + + local txhash + txhash=$(echo "$submit_output" | jq -r '.txhash // empty') + if [ -z "$txhash" ]; then + echo "$submit_output" + return 1 + fi + + local i + for ((i=0; i/dev/null); then + echo "$tx_response" + return 0 + fi + done + echo "ERROR: tx $txhash not included after $((max_attempts * poll_interval))s" >&2 + return 1 +} diff --git a/integration_test/contracts/create_tokenfactory_denoms.sh b/integration_test/contracts/create_tokenfactory_denoms.sh index 65cdd95849..7ac7d81422 100755 --- a/integration_test/contracts/create_tokenfactory_denoms.sh +++ b/integration_test/contracts/create_tokenfactory_denoms.sh @@ -1,5 +1,7 @@ #!/bin/bash +source "$(dirname "$0")/_tx_helpers.sh" + seidbin=$(which ~/go/bin/seid | tr -d '"') keyname=$(printf "12345678\n" | $seidbin keys list --output json | jq ".[0].name" | tr -d '"') keyaddress=$(printf "12345678\n" | $seidbin keys list --output json | jq ".[0].address" | tr -d '"') @@ -17,7 +19,7 @@ echo "$keyaddress" > $seihome/integration_test/contracts/tfk_creator_id.txt for i in {1..10} do echo "Creating first set of tokenfactory denoms #$i..." - create_denom_result=$(printf "12345678\n" | $seidbin tx tokenfactory create-denom "$i" -y --from="$keyname" --chain-id="$chainid" --gas=500000 --fees=100000usei --broadcast-mode=block --output=json) + create_denom_result=$(printf "12345678\n" | $seidbin tx tokenfactory create-denom "$i" -y --from="$keyname" --chain-id="$chainid" --gas=500000 --fees=100000usei --broadcast-mode=sync --output=json | submit_and_wait_for_tx "$seidbin") new_token_denom=$(echo "$create_denom_result" | jq -r '.logs[].events[].attributes[] | select(.key == "new_token_denom").value') echo "Got token $new_token_denom for iteration $i" done @@ -32,7 +34,7 @@ sleep 5 for i in {11..20} do echo "Creating first set of tokenfactory denoms #$i..." - create_denom_result=$(printf "12345678\n" | $seidbin tx tokenfactory create-denom "$i" -y --from="$keyname" --chain-id="$chainid" --gas=500000 --fees=100000usei --broadcast-mode=block --output=json) + create_denom_result=$(printf "12345678\n" | $seidbin tx tokenfactory create-denom "$i" -y --from="$keyname" --chain-id="$chainid" --gas=500000 --fees=100000usei --broadcast-mode=sync --output=json | submit_and_wait_for_tx "$seidbin") new_token_denom=$(echo "$create_denom_result" | jq -r '.logs[].events[].attributes[] | select(.key == "new_token_denom").value') echo "Got token $new_token_denom for iteration $i" done @@ -46,7 +48,7 @@ sleep 5 for i in {21..30} do echo "Creating first set of tokenfactory denoms #$i..." - create_denom_result=$(printf "12345678\n" | $seidbin tx tokenfactory create-denom "$i" -y --from="$keyname" --chain-id="$chainid" --gas=500000 --fees=100000usei --broadcast-mode=block --output=json) + create_denom_result=$(printf "12345678\n" | $seidbin tx tokenfactory create-denom "$i" -y --from="$keyname" --chain-id="$chainid" --gas=500000 --fees=100000usei --broadcast-mode=sync --output=json | submit_and_wait_for_tx "$seidbin") new_token_denom=$(echo "$create_denom_result" | jq -r '.logs[].events[].attributes[] | select(.key == "new_token_denom").value') echo "Got token $new_token_denom for iteration $i" done diff --git a/integration_test/contracts/deploy_dex_contract.sh b/integration_test/contracts/deploy_dex_contract.sh index 73878762fa..21a2d7451f 100755 --- a/integration_test/contracts/deploy_dex_contract.sh +++ b/integration_test/contracts/deploy_dex_contract.sh @@ -1,5 +1,7 @@ #!/bin/bash +source "$(dirname "$0")/_tx_helpers.sh" + seidbin=$(which ~/go/bin/seid | tr -d '"') keyname=$(printf "12345678\n" | $seidbin keys list --output json | jq ".[0].name" | tr -d '"') chainid=$($seidbin status | jq ".NodeInfo.network" | tr -d '"') @@ -16,33 +18,33 @@ echo "Deploying $contract_name contract..." # store echo "Storing contract..." -store_result=$(printf "12345678\n" | $seidbin tx wasm store integration_test/contracts/"$contract_name".wasm -y --from="$keyname" --chain-id="$chainid" --gas=5000000 --fees=1000000usei --broadcast-mode=block --output=json) +store_result=$(printf "12345678\n" | $seidbin tx wasm store integration_test/contracts/"$contract_name".wasm -y --from="$keyname" --chain-id="$chainid" --gas=5000000 --fees=1000000usei --broadcast-mode=sync --output=json | submit_and_wait_for_tx "$seidbin") contract_id=$(echo "$store_result" | jq -r '.logs[].events[].attributes[] | select(.key == "code_id").value') echo "Got contract id $contract_id" # instantiate echo "Instantiating contract..." -instantiate_result=$(printf "12345678\n" | $seidbin tx wasm instantiate "$contract_id" '{}' -y --no-admin --from="$keyname" --chain-id="$chainid" --gas=5000000 --fees=1000000usei --broadcast-mode=block --label=dex --output=json) +instantiate_result=$(printf "12345678\n" | $seidbin tx wasm instantiate "$contract_id" '{}' -y --no-admin --from="$keyname" --chain-id="$chainid" --gas=5000000 --fees=1000000usei --broadcast-mode=sync --label=dex --output=json | submit_and_wait_for_tx "$seidbin") contract_addr=$(echo "$instantiate_result" |jq -r '.logs[].events[].attributes[] | select(.key == "_contract_address").value') # register echo "Registering contract..." -printf "12345678\n" | $seidbin tx dex register-contract "$contract_addr" "$contract_id" false true 100000000000 -y --from="$keyname" --chain-id="$chainid" --fees=100000000000usei --gas=500000 --broadcast-mode=block +printf "12345678\n" | $seidbin tx dex register-contract "$contract_addr" "$contract_id" false true 100000000000 -y --from="$keyname" --chain-id="$chainid" --fees=100000000000usei --gas=500000 --broadcast-mode=sync --output=json | submit_and_wait_for_tx "$seidbin" echo '{"batch_contract_pair":[{"contract_addr":"'$contract_addr'","pairs":[{"price_denom":"SEI","asset_denom":"ATOM","price_tick_size":"0.0000001", "quantity_tick_size":"0.0000001"}]}]}' > integration_test/contracts/"$contract_name"-pair.json -contract_pair=$(printf "12345678\n" | $seidbin tx dex register-pairs integration_test/contracts/"$contract_name"-pair.json -y --from=$keyname --chain-id=$chainid --fees=10000000usei --gas=500000 --broadcast-mode=block --output=json) +contract_pair=$(printf "12345678\n" | $seidbin tx dex register-pairs integration_test/contracts/"$contract_name"-pair.json -y --from=$keyname --chain-id=$chainid --fees=10000000usei --gas=500000 --broadcast-mode=sync --output=json | submit_and_wait_for_tx "$seidbin") rm -rf integration_test/contracts/"$contract_name"-pair.json echo '{"batch_contract_pair":[{"contract_addr":"'$contract_addr'","pairs":[{"price_denom":"usei","asset_denom":"uatom","price_tick_size":"0.0000001", "quantity_tick_size":"0.0000001"}]}]}' > integration_test/contracts/"$contract_name"-pair.json -contract_pair=$(printf "12345678\n" | $seidbin tx dex register-pairs integration_test/contracts/"$contract_name"-pair.json -y --from=$keyname --chain-id=$chainid --fees=10000000usei --gas=500000 --broadcast-mode=block --output=json) +contract_pair=$(printf "12345678\n" | $seidbin tx dex register-pairs integration_test/contracts/"$contract_name"-pair.json -y --from=$keyname --chain-id=$chainid --fees=10000000usei --gas=500000 --broadcast-mode=sync --output=json | submit_and_wait_for_tx "$seidbin") rm -rf integration_test/contracts/"$contract_name"-pair.json echo '{"batch_contract_pair":[{"contract_addr":"'$contract_addr'","pairs":[{"price_denom":"usei","asset_denom":"uatomatom","price_tick_size":"0.0000001", "quantity_tick_size":"0.0000001"}]}]}' > integration_test/contracts/"$contract_name"-pair.json -contract_pair=$(printf "12345678\n" | $seidbin tx dex register-pairs integration_test/contracts/"$contract_name"-pair.json -y --from=$keyname --chain-id=$chainid --fees=10000000usei --gas=500000 --broadcast-mode=block --output=json) +contract_pair=$(printf "12345678\n" | $seidbin tx dex register-pairs integration_test/contracts/"$contract_name"-pair.json -y --from=$keyname --chain-id=$chainid --fees=10000000usei --gas=500000 --broadcast-mode=sync --output=json | submit_and_wait_for_tx "$seidbin") rm -rf integration_test/contracts/"$contract_name"-pair.json echo '{"batch_contract_pair":[{"contract_addr":"'$contract_addr'","pairs":[{"price_denom":"usei","asset_denom":"uatomatomatom","price_tick_size":"0.0000001", "quantity_tick_size":"0.0000001"}]}]}' > integration_test/contracts/"$contract_name"-pair.json -contract_pair=$(printf "12345678\n" | $seidbin tx dex register-pairs integration_test/contracts/"$contract_name"-pair.json -y --from=$keyname --chain-id=$chainid --fees=10000000usei --gas=500000 --broadcast-mode=block --output=json) +contract_pair=$(printf "12345678\n" | $seidbin tx dex register-pairs integration_test/contracts/"$contract_name"-pair.json -y --from=$keyname --chain-id=$chainid --fees=10000000usei --gas=500000 --broadcast-mode=sync --output=json | submit_and_wait_for_tx "$seidbin") rm -rf integration_test/contracts/"$contract_name"-pair.json diff --git a/integration_test/contracts/deploy_timelocked_token_contract.sh b/integration_test/contracts/deploy_timelocked_token_contract.sh index 99e04c31bd..d2ae141a3e 100755 --- a/integration_test/contracts/deploy_timelocked_token_contract.sh +++ b/integration_test/contracts/deploy_timelocked_token_contract.sh @@ -1,5 +1,7 @@ #!/bin/bash +source "$(dirname "$0")/_tx_helpers.sh" + seidbin=$(which ~/go/bin/seid | tr -d '"') keyname=$(printf "12345678\n" | $seidbin keys list --output json | jq ".[0].name" | tr -d '"') chainid=$($seidbin status | jq ".NodeInfo.network" | tr -d '"') @@ -22,13 +24,13 @@ key_admin4=$(printf "12345678\n" |$seidbin keys show admin4 -a) key_op=$(printf "12345678\n" |$seidbin keys show op -a) key_staking=$(printf "12345678\n" |$seidbin keys show staking_reward_dest -a) key_unlock=$(printf "12345678\n" |$seidbin keys show unlocked_dest -a) -printf "12345678\n" | $seidbin tx bank send admin "$key_admin1" 10000000sei -y --chain-id=$chainid --gas=5000000 --fees=1000000usei --broadcast-mode=block -printf "12345678\n" | $seidbin tx bank send admin "$key_admin2" 10000000sei -y --chain-id=$chainid --gas=5000000 --fees=1000000usei --broadcast-mode=block -printf "12345678\n" | $seidbin tx bank send admin "$key_admin3" 10000000sei -y --chain-id=$chainid --gas=5000000 --fees=1000000usei --broadcast-mode=block -printf "12345678\n" | $seidbin tx bank send admin "$key_admin4" 10000000sei -y --chain-id=$chainid --gas=5000000 --fees=1000000usei --broadcast-mode=block -printf "12345678\n" | $seidbin tx bank send admin "$key_op" 10000000sei -y --chain-id=$chainid --gas=5000000 --fees=1000000usei --broadcast-mode=block -printf "12345678\n" | $seidbin tx bank send admin "$key_staking" 10000000sei -y --chain-id=$chainid --gas=5000000 --fees=1000000usei --broadcast-mode=block -printf "12345678\n" | $seidbin tx bank send admin "$key_unlock" 10000000sei -y --chain-id=$chainid --gas=5000000 --fees=1000000usei --broadcast-mode=block +printf "12345678\n" | $seidbin tx bank send admin "$key_admin1" 10000000sei -y --chain-id=$chainid --gas=5000000 --fees=1000000usei --broadcast-mode=sync --output=json | submit_and_wait_for_tx "$seidbin" >/dev/null +printf "12345678\n" | $seidbin tx bank send admin "$key_admin2" 10000000sei -y --chain-id=$chainid --gas=5000000 --fees=1000000usei --broadcast-mode=sync --output=json | submit_and_wait_for_tx "$seidbin" >/dev/null +printf "12345678\n" | $seidbin tx bank send admin "$key_admin3" 10000000sei -y --chain-id=$chainid --gas=5000000 --fees=1000000usei --broadcast-mode=sync --output=json | submit_and_wait_for_tx "$seidbin" >/dev/null +printf "12345678\n" | $seidbin tx bank send admin "$key_admin4" 10000000sei -y --chain-id=$chainid --gas=5000000 --fees=1000000usei --broadcast-mode=sync --output=json | submit_and_wait_for_tx "$seidbin" >/dev/null +printf "12345678\n" | $seidbin tx bank send admin "$key_op" 10000000sei -y --chain-id=$chainid --gas=5000000 --fees=1000000usei --broadcast-mode=sync --output=json | submit_and_wait_for_tx "$seidbin" >/dev/null +printf "12345678\n" | $seidbin tx bank send admin "$key_staking" 10000000sei -y --chain-id=$chainid --gas=5000000 --fees=1000000usei --broadcast-mode=sync --output=json | submit_and_wait_for_tx "$seidbin" >/dev/null +printf "12345678\n" | $seidbin tx bank send admin "$key_unlock" 10000000sei -y --chain-id=$chainid --gas=5000000 --fees=1000000usei --broadcast-mode=sync --output=json | submit_and_wait_for_tx "$seidbin" >/dev/null # Deploy goblin contract @@ -38,14 +40,14 @@ echo "Deploying $contract_name contract..." # store echo "Storing contract..." -store_result=$(printf "12345678\n" | $seidbin tx wasm store integration_test/contracts/"$contract_name".wasm -y --from="$keyname" --chain-id="$chainid" --gas=5000000 --fees=1000000usei --broadcast-mode=block --output=json) +store_result=$(printf "12345678\n" | $seidbin tx wasm store integration_test/contracts/"$contract_name".wasm -y --from="$keyname" --chain-id="$chainid" --gas=5000000 --fees=1000000usei --broadcast-mode=sync --output=json | submit_and_wait_for_tx "$seidbin") contract_id=$(echo "$store_result" | jq -r '.logs[].events[].attributes[] | select(.key == "code_id").value') echo "Got $contract_name contract id: $contract_id" # instantiate echo "Instantiating contract..." params='{"admins":["'$key_admin1'", "'$key_admin2'", "'$key_admin3'", "'$key_admin4'"], "max_voting_period": {"time":1800}, "admin_voting_threshold_percentage": 75}' -instantiate_result=$(printf "12345678\n" | $seidbin tx wasm instantiate "$contract_id" "$params" -y --no-admin --amount=1500000usei --from="$keyname" --chain-id="$chainid" --gas=5000000 --fees=1000000usei --broadcast-mode=block --label=$contract_name --output=json) +instantiate_result=$(printf "12345678\n" | $seidbin tx wasm instantiate "$contract_id" "$params" -y --no-admin --amount=1500000usei --from="$keyname" --chain-id="$chainid" --gas=5000000 --fees=1000000usei --broadcast-mode=sync --label=$contract_name --output=json | submit_and_wait_for_tx "$seidbin") contract_addr=$(echo "$instantiate_result" |jq -r '.logs[].events[].attributes[] | select(.key == "_contract_address").value') echo "Instantiated $contract_name contract address: $contract_addr" echo "$contract_addr,$contract_id" > $seihome/integration_test/contracts/"$contract_name"-contract-addr.txt @@ -68,7 +70,7 @@ echo "Deploying $contract_name contract..." # store echo "Storing contract..." -store_result=$(printf "12345678\n" | $seidbin tx wasm store integration_test/contracts/"$contract_name".wasm -y --from="$keyname" --chain-id="$chainid" --gas=5000000 --fees=1000000usei --broadcast-mode=block --output=json) +store_result=$(printf "12345678\n" | $seidbin tx wasm store integration_test/contracts/"$contract_name".wasm -y --from="$keyname" --chain-id="$chainid" --gas=5000000 --fees=1000000usei --broadcast-mode=sync --output=json | submit_and_wait_for_tx "$seidbin") contract_id=$(echo "$store_result" | jq -r '.logs[].events[].attributes[] | select(.key == "code_id").value') echo "Got $contract_name contract id: $contract_id" @@ -77,7 +79,7 @@ echo "Instantiating contract..." VESTING_TIMESTAMPS='["1893456000000000000", "1924992000000000000"]' # nanoseconds since unix epoch VESTING_AMOUNTS='["1000000", "500000"]' # in usei params='{"admins":["'$key_admin1'", "'$key_admin2'", "'$key_admin3'", "'$key_admin4'"], "ops": ["'$key_op'"], "tranche": {"denom":"usei", "vesting_timestamps":'$VESTING_TIMESTAMPS', "vesting_amounts":'$VESTING_AMOUNTS', "unlocked_token_distribution_address": "'$key_unlock'", "staking_reward_distribution_address": "'$key_staking'"}, "max_voting_period": {"time":1800}, "admin_voting_threshold_percentage": 75}' -instantiate_result=$(printf "12345678\n" | $seidbin tx wasm instantiate "$contract_id" "$params" -y --admin="$goblin_addr" --amount=1500000usei --from="$keyname" --chain-id="$chainid" --gas=5000000 --fees=1000000usei --broadcast-mode=block --label=$contract_name --output=json) +instantiate_result=$(printf "12345678\n" | $seidbin tx wasm instantiate "$contract_id" "$params" -y --admin="$goblin_addr" --amount=1500000usei --from="$keyname" --chain-id="$chainid" --gas=5000000 --fees=1000000usei --broadcast-mode=sync --label=$contract_name --output=json | submit_and_wait_for_tx "$seidbin") contract_addr=$(echo "$instantiate_result" |jq -r '.logs[].events[].attributes[] | select(.key == "_contract_address").value') echo "Instantiated $contract_name contract address: $contract_addr" echo "$contract_addr,$contract_id" > $seihome/integration_test/contracts/"$contract_name"-contract-addr.txt diff --git a/integration_test/contracts/deploy_wasm_contracts.sh b/integration_test/contracts/deploy_wasm_contracts.sh index 483fdbd3b7..28732f9309 100755 --- a/integration_test/contracts/deploy_wasm_contracts.sh +++ b/integration_test/contracts/deploy_wasm_contracts.sh @@ -1,5 +1,7 @@ #!/bin/bash +source "$(dirname "$0")/_tx_helpers.sh" + seidbin=$(which ~/go/bin/seid | tr -d '"') keyname=$(printf "12345678\n" | $seidbin keys list --output json | jq ".[0].name" | tr -d '"') keyaddress=$(printf "12345678\n" | $seidbin keys list --output json | jq ".[0].address" | tr -d '"') @@ -17,9 +19,9 @@ echo "$keyaddress" > $seihome/integration_test/contracts/wasm_creator_id.txt for i in {1..10} do echo "Storing first set contract #$i..." - store_result=$(printf "12345678\n" | $seidbin tx wasm store integration_test/contracts/mars.wasm -y --from="$keyname" --chain-id="$chainid" --gas=5000000 --fees=1000000usei --broadcast-mode=block --output=json) + store_result=$(printf "12345678\n" | $seidbin tx wasm store integration_test/contracts/mars.wasm -y --from="$keyname" --chain-id="$chainid" --gas=5000000 --fees=1000000usei --broadcast-mode=sync --output=json | submit_and_wait_for_tx "$seidbin") contract_id=$(echo "$store_result" | jq -r '.logs[].events[].attributes[] | select(.key == "code_id").value') - printf "12345678\n" | $seidbin tx wasm instantiate "$contract_id" '{}' -y --no-admin --from="$keyname" --chain-id="$chainid" --gas=5000000 --fees=1000000usei --broadcast-mode=block --label=dex --output=json + printf "12345678\n" | $seidbin tx wasm instantiate "$contract_id" '{}' -y --no-admin --from="$keyname" --chain-id="$chainid" --gas=5000000 --fees=1000000usei --broadcast-mode=sync --label=dex --output=json | submit_and_wait_for_tx "$seidbin" echo "Got contract id $contract_id for iteration $i" done @@ -32,9 +34,9 @@ sleep 5 for i in {11..20} do echo "Storing second set contract #$i..." - store_result=$(printf "12345678\n" | $seidbin tx wasm store integration_test/contracts/saturn.wasm -y --from="$keyname" --chain-id="$chainid" --gas=5000000 --fees=1000000usei --broadcast-mode=block --output=json) + store_result=$(printf "12345678\n" | $seidbin tx wasm store integration_test/contracts/saturn.wasm -y --from="$keyname" --chain-id="$chainid" --gas=5000000 --fees=1000000usei --broadcast-mode=sync --output=json | submit_and_wait_for_tx "$seidbin") contract_id=$(echo "$store_result" | jq -r '.logs[].events[].attributes[] | select(.key == "code_id").value') - printf "12345678\n" | $seidbin tx wasm instantiate "$contract_id" '{}' -y --no-admin --from="$keyname" --chain-id="$chainid" --gas=5000000 --fees=1000000usei --broadcast-mode=block --label=dex --output=json + printf "12345678\n" | $seidbin tx wasm instantiate "$contract_id" '{}' -y --no-admin --from="$keyname" --chain-id="$chainid" --gas=5000000 --fees=1000000usei --broadcast-mode=sync --label=dex --output=json | submit_and_wait_for_tx "$seidbin" echo "Got contract id $contract_id for iteration $i" done @@ -47,9 +49,9 @@ sleep 5 for i in {21..30} do echo "Storing third set contract #$i..." - store_result=$(printf "12345678\n" | $seidbin tx wasm store integration_test/contracts/venus.wasm -y --from="$keyname" --chain-id="$chainid" --gas=5000000 --fees=1000000usei --broadcast-mode=block --output=json) + store_result=$(printf "12345678\n" | $seidbin tx wasm store integration_test/contracts/venus.wasm -y --from="$keyname" --chain-id="$chainid" --gas=5000000 --fees=1000000usei --broadcast-mode=sync --output=json | submit_and_wait_for_tx "$seidbin") contract_id=$(echo "$store_result" | jq -r '.logs[].events[].attributes[] | select(.key == "code_id").value') - printf "12345678\n" | $seidbin tx wasm instantiate "$contract_id" '{}' -y --no-admin --from="$keyname" --chain-id="$chainid" --gas=5000000 --fees=1000000usei --broadcast-mode=block --label=dex --output=json + printf "12345678\n" | $seidbin tx wasm instantiate "$contract_id" '{}' -y --no-admin --from="$keyname" --chain-id="$chainid" --gas=5000000 --fees=1000000usei --broadcast-mode=sync --label=dex --output=json | submit_and_wait_for_tx "$seidbin" echo "Got contract id $contract_id for iteration $i" done