forked from informalsystems/hermes
-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
210 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,190 @@ | ||
#!/bin/bash | ||
|
||
# This script sets up Namada and Gaia locally | ||
# `make build-release` and `make build-wasm-scripts` on Namada directory in advance | ||
# Run with `namada-gaia-simple-transfers ${namada_dir}` | ||
|
||
set -e | ||
|
||
NAMADA_DIR=$1 | ||
if [ -z "${NAMADA_DIR}" ] | ||
then | ||
echo "ERROR: Namada directory should be given" | ||
exit 1 | ||
fi | ||
cd $(dirname $0) | ||
HERMES_DIR=${PWD%/e2e*} | ||
|
||
# edit for your environment | ||
NAMADAC="${NAMADA_DIR}/target/debug/namadac" | ||
NAMADAN="${NAMADA_DIR}/target/debug/namadan" | ||
NAMADAW="${NAMADA_DIR}/target/debug/namadaw" | ||
DATA_DIR="${HERMES_DIR}/data" | ||
IBC_TOKEN="transfer/channel-0/samoleans" | ||
|
||
NAMADA_LEDGER_ADDR="127.0.0.1:27657" | ||
|
||
GAIA_CHAIN_CONFIG=" | ||
[[chains]] | ||
id = 'gaia-0' | ||
type = 'CosmosSdk' | ||
rpc_addr = 'http://127.0.0.1:26657' | ||
grpc_addr = 'http://127.0.0.1:9090' | ||
event_source = { mode = 'push', url = 'ws://127.0.0.1:26657/websocket', batch_delay = '500ms' } | ||
account_prefix = 'cosmos' | ||
key_name = 'testkey' | ||
store_prefix = 'ibc' | ||
gas_price = { price = 0.001, denom = 'stake' } | ||
" | ||
|
||
#### main #### | ||
mkdir -p ${DATA_DIR} | ||
|
||
# Gaia | ||
rm -rf ${DATA_DIR}/gaia-0 | ||
|
||
${HERMES_DIR}/scripts/one-chain gaiad gaia-0 ${DATA_DIR} \ | ||
26657 26656 6060 9090 10000 | ||
|
||
# Namada | ||
${HERMES_DIR}/scripts/setup-namada-single-node ${NAMADA_DIR} | ||
base_dir=${DATA_DIR}/namada | ||
|
||
cd ${HERMES_DIR} | ||
chain_id=$(grep id config_for_namada.toml | sed -e s/\'//g | awk '{print $3}') | ||
|
||
# Add Gaia chain config | ||
echo "${GAIA_CHAIN_CONFIG}" >> config_for_namada.toml | ||
|
||
# add Gaia key | ||
cargo run -q --bin hermes -- --config config_for_namada.toml \ | ||
keys add --chain gaia-0 --key-file ${DATA_DIR}/gaia-0/user_seed.json --overwrite | ||
|
||
# Initialize Relayer's balance on Namada | ||
${NAMADAC} --base-dir ${base_dir} \ | ||
transfer \ | ||
--source albert \ | ||
--target relayer \ | ||
--token nam \ | ||
--amount 10000 \ | ||
--node ${NAMADA_LEDGER_ADDR} | ||
|
||
${NAMADAC} --base-dir ${base_dir} \ | ||
transfer \ | ||
--source albert \ | ||
--target relayer \ | ||
--token apfel \ | ||
--amount 1000 \ | ||
--node ${NAMADA_LEDGER_ADDR} | ||
|
||
# create a channel | ||
cargo run --bin hermes -- --config config_for_namada.toml \ | ||
create channel --a-chain ${chain_id} \ | ||
--b-chain gaia-0 \ | ||
--a-port transfer \ | ||
--b-port transfer \ | ||
--new-client-connection --yes | ||
|
||
# Transfer 100 samoleans from Gaia to Namada | ||
namada_receiver=$(${NAMADAW} --base-dir ${base_dir} address find --alias relayer | awk '{print $4}') | ||
cargo run --bin hermes -- --config config_for_namada.toml \ | ||
tx ft-transfer \ | ||
--dst-chain ${chain_id} \ | ||
--src-chain gaia-0 \ | ||
--src-port transfer \ | ||
--src-channel channel-0 \ | ||
--amount 100 \ | ||
--receiver ${namada_receiver} \ | ||
--denom samoleans \ | ||
--timeout-height-offset 1000 | ||
|
||
# packet-recv | ||
cargo run --bin hermes -- --config config_for_namada.toml \ | ||
tx packet-recv \ | ||
--dst-chain ${chain_id} \ | ||
--src-chain gaia-0 \ | ||
--src-port transfer \ | ||
--src-channel channel-0 | ||
|
||
# packet-ack | ||
cargo run --bin hermes -- --config config_for_namada.toml \ | ||
tx packet-ack \ | ||
--dst-chain gaia-0 \ | ||
--src-chain ${chain_id} \ | ||
--src-port transfer \ | ||
--src-channel channel-0 | ||
|
||
echo "Balances on Namada" | ||
${NAMADAC} --base-dir ${base_dir} balance \ | ||
--token ${IBC_TOKEN} \ | ||
--owner relayer \ | ||
--node ${NAMADA_LEDGER_ADDR} | ||
|
||
echo "Balances on Gaia" | ||
gaia_user=$(gaiad --home ${DATA_DIR}/gaia-0 \ | ||
keys --keyring-backend="test" show user -a) | ||
gaiad query bank balances ${gaia_user} | ||
|
||
# transfer back 50 samoleans from Namada to Gaia | ||
${NAMADAC} --base-dir ${base_dir} ibc-transfer \ | ||
--source relayer \ | ||
--receiver ${gaia_user} \ | ||
--token ${IBC_TOKEN} \ | ||
--amount 50 \ | ||
--signing-keys relayer \ | ||
--channel-id channel-0 \ | ||
--node ${NAMADA_LEDGER_ADDR} | ||
|
||
# packet-recv | ||
cargo run --bin hermes -- --config config_for_namada.toml \ | ||
tx packet-recv \ | ||
--dst-chain gaia-0 \ | ||
--src-chain ${chain_id} \ | ||
--src-port transfer \ | ||
--src-channel channel-0 | ||
|
||
# packet-ack | ||
cargo run --bin hermes -- --config config_for_namada.toml \ | ||
tx packet-ack \ | ||
--dst-chain ${chain_id} \ | ||
--src-chain gaia-0 \ | ||
--src-port transfer \ | ||
--src-channel channel-0 | ||
|
||
echo "Balances on Namada" | ||
${NAMADAC} --base-dir ${base_dir} balance \ | ||
--token ${IBC_TOKEN} \ | ||
--owner relayer \ | ||
--node ${NAMADA_LEDGER_ADDR} | ||
|
||
echo "Balances on Gaia" | ||
gaiad query bank balances ${gaia_user} | ||
|
||
echo "==== Start Hermes ====" | ||
cargo run --bin hermes -- --config config_for_namada.toml \ | ||
start > ${HERMES_DIR}/e2e/hermes.log 2>&1 & | ||
|
||
# transfer 200 apfel from Namada to Gaia | ||
${NAMADAC} --base-dir ${base_dir} ibc-transfer \ | ||
--source relayer \ | ||
--receiver ${gaia_user} \ | ||
--token apfel \ | ||
--amount 200 \ | ||
--signing-keys relayer \ | ||
--channel-id channel-0 \ | ||
--node ${NAMADA_LEDGER_ADDR} | ||
|
||
# wait for relaying | ||
sleep 10 | ||
|
||
echo "Balances on Namada" | ||
${NAMADAC} --base-dir ${base_dir} balance \ | ||
--owner relayer \ | ||
--node ${NAMADA_LEDGER_ADDR} | ||
|
||
echo "Balances on Gaia" | ||
gaiad query bank balances ${gaia_user} | ||
|
||
killall hermes | ||
killall gaiad | ||
killall namadan |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters