Skip to content

Commit

Permalink
add a ICS20 case with eth being an asset locker and tm being a vouche…
Browse files Browse the repository at this point in the history
…r minter

Signed-off-by: Masanori Yoshida <[email protected]>
  • Loading branch information
siburu committed Sep 27, 2024
1 parent ddf690f commit 7d40343
Showing 1 changed file with 62 additions and 6 deletions.
68 changes: 62 additions & 6 deletions tests/cases/tm2eth/scripts/test-ics20-packet-relay
Original file line number Diff line number Diff line change
Expand Up @@ -12,38 +12,43 @@ RLY="${RLY_BINARY} --debug"
PATH_NAME=ics20-path

TM_ADDRESS=$(${RLY} tendermint keys show ibc0 testkey)
DEPLOYER_INDEX=0
BOB_INDEX=2

ADDRESSES_DIR_B="${FIXTURES_DIR}/ethereum/ibc1/addresses"
ERC20_TOKEN_CONTRACT_B=`cat ${ADDRESSES_DIR_B}/ERC20Token`
ICS20_BANK_CONTRACT_B=`cat ${ADDRESSES_DIR_B}/ICS20Bank`
ICS20_TRANSFER_BANK_CONTRACT_B=`cat ${ADDRESSES_DIR_B}/ICS20TransferBank`

MNEMONIC_B=$($RLY config show | jq -r '.chains[] | select(.chain.chain_id == "ibc1").chain.signer.mnemonic')
RPC_ADDRESS_B=$($RLY config show | jq -r '.chains[] | select(.chain.chain_id == "ibc1").chain.rpc_addr')
PORT_A=$($RLY paths list --json | jq -r --arg path $PATH_NAME '.[$path].src."port-id"')
PORT_B=$($RLY paths list --json | jq -r --arg path $PATH_NAME '.[$path].dst."port-id"')
CHANNEL_A=$($RLY paths list --json | jq -r --arg path $PATH_NAME '.[$path].src."channel-id"')
CHANNEL_B=$($RLY paths list --json | jq -r --arg path $PATH_NAME '.[$path].dst."channel-id"')
ETH_ADDRESS_B=$(cast wallet address --mnemonic "$MNEMONIC_B" --mnemonic-index $BOB_INDEX)
BOB_ADDRESS=$(cast wallet address --mnemonic "$MNEMONIC_B" --mnemonic-index $BOB_INDEX)

DENOM_A=samoleans
DENOM_B="${PORT_B}/${CHANNEL_B}/${DENOM_A}"
DENOM_B=$(echo $ERC20_TOKEN_CONTRACT_B | tr '[:upper:]' '[:lower:]')

TX_INTERVAL=3

echo "!!! ibc0 -> ibc1 !!!"
${RLY} tx transfer $PATH_NAME ibc0 ibc1 "100${DENOM_A}" $ETH_ADDRESS_B
echo "!!! ibc0(lock) -> ibc1(mint) !!!"
${RLY} tx transfer $PATH_NAME ibc0 ibc1 "100${DENOM_A}" $BOB_ADDRESS
sleep ${TX_INTERVAL}
${RLY} tx relay $PATH_NAME --src-seqs 1
sleep ${TX_INTERVAL}
${RLY} tx acks $PATH_NAME --dst-seqs 1
sleep ${TX_INTERVAL}

echo "!!! ibc1 -> ibc0 !!!"
echo "!!! ibc1(burn) -> ibc0(unlock) !!!"
cast send \
--rpc-url $RPC_ADDRESS_B \
--mnemonic "$MNEMONIC_B" \
--mnemonic-index ${BOB_INDEX} \
$ICS20_TRANSFER_BANK_CONTRACT_B \
'sendTransfer(string,uint256,string,string,string,uint64)' \
$DENOM_B \
$PORT_B/$CHANNEL_B/$DENOM_A \
100 \
$TM_ADDRESS \
$PORT_B \
Expand All @@ -53,3 +58,54 @@ sleep ${TX_INTERVAL}
${RLY} tx relay $PATH_NAME --dst-seqs 1
sleep ${TX_INTERVAL}
${RLY} tx acks $PATH_NAME --src-seqs 1

echo "!!! ibc1(lock) -> ibc0(mint) !!!"
cast send \
--rpc-url $RPC_ADDRESS_B \
--mnemonic "$MNEMONIC_B" \
--mnemonic-index ${DEPLOYER_INDEX} \
$ERC20_TOKEN_CONTRACT_B \
'transfer(address,uint256)' \
$BOB_ADDRESS \
500
cast send \
--rpc-url $RPC_ADDRESS_B \
--mnemonic "$MNEMONIC_B" \
--mnemonic-index ${BOB_INDEX} \
$ERC20_TOKEN_CONTRACT_B \
'approve(address,uint256)' \
$ICS20_BANK_CONTRACT_B \
500
cast send \
--rpc-url $RPC_ADDRESS_B \
--mnemonic "$MNEMONIC_B" \
--mnemonic-index ${BOB_INDEX} \
$ICS20_BANK_CONTRACT_B \
'deposit(address,uint256,address)' \
$ERC20_TOKEN_CONTRACT_B \
500 \
$BOB_ADDRESS
cast send \
--rpc-url $RPC_ADDRESS_B \
--mnemonic "$MNEMONIC_B" \
--mnemonic-index ${BOB_INDEX} \
$ICS20_TRANSFER_BANK_CONTRACT_B \
'sendTransfer(string,uint256,string,string,string,uint64)' \
$DENOM_B \
500 \
$TM_ADDRESS \
$PORT_B \
$CHANNEL_B \
100000
sleep ${TX_INTERVAL}
${RLY} tx relay $PATH_NAME --dst-seqs 2
sleep ${TX_INTERVAL}
${RLY} tx acks $PATH_NAME --src-seqs 2

echo "!!! ibc0(burn) -> ibc1(unlock) !!!"
${RLY} tx transfer $PATH_NAME ibc0 ibc1 "500${PORT_A}/${CHANNEL_A}/${DENOM_B}" $BOB_ADDRESS
sleep ${TX_INTERVAL}
${RLY} tx relay $PATH_NAME --src-seqs 2
sleep ${TX_INTERVAL}
${RLY} tx acks $PATH_NAME --dst-seqs 2
sleep ${TX_INTERVAL}

0 comments on commit 7d40343

Please sign in to comment.