Skip to content

chore: switch to context sender/senderEVM #257

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
May 6, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions examples/call/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,8 @@
"@solana/spl-token": "^0.4.13",
"@solana/web3.js": "^1.95.8",
"@zetachain/networks": "13.0.0-rc1",
"@zetachain/protocol-contracts": "12.0.0-rc1",
"@zetachain/protocol-contracts-solana": "2.0.0-rc1"
"@zetachain/protocol-contracts": "13.0.0",
"@zetachain/protocol-contracts-solana": "2.0.0-rc1",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we are already on 3.0.0 here so might be worth checking to upgrade this as well in separate PR

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will do!

"zetachain": "^3.0.0"
}
}
61 changes: 31 additions & 30 deletions examples/call/scripts/localnet.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@ set -e
set -x
set -o pipefail

if [ "$1" = "start" ]; then npx hardhat localnet & sleep 20; fi
yarn zetachain localnet start --skip sui ton solana --exit-on-error &

while [ ! -f "localnet.json" ]; do sleep 1; done
Comment on lines +7 to +9
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Capture and trap the background process.

Running the CLI in the background without tracking its PID can lead to orphaned processes. Consider:

yarn zetachain localnet start --skip sui ton solana --exit-on-error &
LOCALNET_PID=$!
trap "kill $LOCALNET_PID" EXIT

This ensures proper cleanup on script exit.


echo -e "\n🚀 Compiling contracts..."
npx hardhat compile --force --quiet

ZRC20_ETHEREUM=$(jq -r '.addresses[] | select(.type=="ZRC-20 ETH on 5") | .address' localnet.json)
Expand Down Expand Up @@ -35,7 +36,7 @@ npx hardhat connected-deposit \
--abort-address "$CONTRACT_ZETACHAIN" \
--amount 1

npx hardhat localnet-check
yarn zetachain localnet check

npx hardhat connected-deposit \
--contract "$CONTRACT_ETHEREUM" \
Expand All @@ -45,7 +46,7 @@ npx hardhat connected-deposit \
--abort-address "$CONTRACT_ZETACHAIN" \
--amount 1

npx hardhat localnet-check
yarn zetachain localnet check

npx hardhat connected-call \
--contract "$CONTRACT_ETHEREUM" \
Expand All @@ -54,7 +55,7 @@ npx hardhat connected-call \
--abort-address "$CONTRACT_ZETACHAIN" \
--types '["string"]' alice

npx hardhat localnet-check
yarn zetachain localnet check

npx hardhat connected-deposit-and-call \
--contract "$CONTRACT_ETHEREUM" \
Expand All @@ -64,7 +65,7 @@ npx hardhat connected-deposit-and-call \
--abort-address "$CONTRACT_ZETACHAIN" \
--types '["string"]' alice

npx hardhat localnet-check
yarn zetachain localnet check

npx hardhat connected-deposit-and-call \
--contract "$CONTRACT_ETHEREUM" \
Expand All @@ -75,7 +76,7 @@ npx hardhat connected-deposit-and-call \
--abort-address "$CONTRACT_ZETACHAIN" \
--types '["string"]' alice

npx hardhat localnet-check
yarn zetachain localnet check

npx hardhat universal-withdraw \
--contract "$CONTRACT_ZETACHAIN" \
Expand All @@ -85,7 +86,7 @@ npx hardhat universal-withdraw \
--abort-address "$CONTRACT_ZETACHAIN" \
--amount 1

npx hardhat localnet-check
yarn zetachain localnet check

npx hardhat universal-call \
--contract "$CONTRACT_ZETACHAIN" \
Expand All @@ -96,7 +97,7 @@ npx hardhat universal-call \
--abort-address "$CONTRACT_ZETACHAIN" \
--types '["string"]' alice

npx hardhat localnet-check
yarn zetachain localnet check

npx hardhat universal-withdraw-and-call \
--contract "$CONTRACT_ZETACHAIN" \
Expand All @@ -109,7 +110,7 @@ npx hardhat universal-withdraw-and-call \
--abort-address "$CONTRACT_ZETACHAIN" \
--types '["string"]' hello

npx hardhat localnet-check
yarn zetachain localnet check

npx hardhat universal-withdraw-and-call \
--contract "$CONTRACT_ZETACHAIN" \
Expand All @@ -120,7 +121,7 @@ npx hardhat universal-withdraw-and-call \
--abort-address "$CONTRACT_ZETACHAIN" \
--types '["string"]' hello

npx hardhat localnet-check
yarn zetachain localnet check

# Testing toolkit methods

Expand All @@ -130,7 +131,7 @@ npx hardhat evm-deposit \
--network localhost \
--amount 1

npx hardhat localnet-check
yarn zetachain localnet check

npx hardhat evm-deposit \
--receiver "$CONTRACT_ZETACHAIN" \
Expand All @@ -139,15 +140,15 @@ npx hardhat evm-deposit \
--erc20 "$ERC20_ETHEREUM" \
--amount 1

npx hardhat localnet-check
yarn zetachain localnet check

npx hardhat evm-call \
--receiver "$CONTRACT_ZETACHAIN" \
--gateway-evm "$GATEWAY_ETHEREUM" \
--network localhost \
--types '["string"]' alice

npx hardhat localnet-check
yarn zetachain localnet check

npx hardhat evm-deposit-and-call \
--receiver "$CONTRACT_ZETACHAIN" \
Expand All @@ -156,7 +157,7 @@ npx hardhat evm-deposit-and-call \
--amount 1 \
--types '["string"]' alice

npx hardhat localnet-check
yarn zetachain localnet check

npx hardhat evm-deposit-and-call \
--receiver "$CONTRACT_ZETACHAIN" \
Expand All @@ -166,7 +167,7 @@ npx hardhat evm-deposit-and-call \
--erc20 "$ERC20_ETHEREUM" \
--types '["string"]' alice

npx hardhat localnet-check
yarn zetachain localnet check

npx hardhat zetachain-withdraw \
--receiver "$CONTRACT_ETHEREUM" \
Expand All @@ -175,16 +176,16 @@ npx hardhat zetachain-withdraw \
--network localhost \
--amount 1

npx hardhat localnet-check
yarn zetachain localnet check

npx hardhat zetachain-withdraw \
--receiver "DrexsvCMH9WWjgnjVbx1iFf3YZcKadupFmxnZLfSyotd" \
--gateway-zeta-chain "$GATEWAY_ZETACHAIN" \
--zrc20 "$ZRC20_SOL" \
--network localhost \
--amount 1
# npx hardhat zetachain-withdraw \
# --receiver "DrexsvCMH9WWjgnjVbx1iFf3YZcKadupFmxnZLfSyotd" \
# --gateway-zeta-chain "$GATEWAY_ZETACHAIN" \
# --zrc20 "$ZRC20_SOL" \
# --network localhost \
# --amount 1

npx hardhat localnet-check
# yarn zetachain localnet check

npx hardhat zetachain-call \
--receiver "$CONTRACT_ETHEREUM" \
Expand All @@ -194,7 +195,7 @@ npx hardhat zetachain-call \
--network localhost \
--types '["string"]' alice

npx hardhat localnet-check
yarn zetachain localnet check

npx hardhat zetachain-withdraw-and-call \
--receiver "$CONTRACT_ETHEREUM" \
Expand All @@ -206,7 +207,7 @@ npx hardhat zetachain-withdraw-and-call \
--call-options-is-arbitrary-call \
--types '["string"]' hello

npx hardhat localnet-check
yarn zetachain localnet check

# ENCODED_ACCOUNTS_AND_DATA=$(npx ts-node solana/setup/encodeCallArgs.ts "sol" "$USDC_SPL")
# npx hardhat zetachain-withdraw-and-call \
Expand All @@ -217,7 +218,7 @@ npx hardhat localnet-check
# --network localhost \
# --types '["bytes"]' $ENCODED_ACCOUNTS_AND_DATA

# npx hardhat localnet-check
# yarn zetachain localnet check

# ENCODED_ACCOUNTS_AND_DATA=$(npx ts-node solana/setup/encodeCallArgs.ts "spl" "$USDC_SPL")
# npx hardhat zetachain-withdraw-and-call \
Expand All @@ -228,7 +229,7 @@ npx hardhat localnet-check
# --network localhost \
# --types '["bytes"]' $ENCODED_ACCOUNTS_AND_DATA

# npx hardhat localnet-check
# yarn zetachain localnet check

npx hardhat zetachain-withdraw-and-call \
--receiver "$CONTRACT_ETHEREUM" \
Expand All @@ -238,6 +239,6 @@ npx hardhat zetachain-withdraw-and-call \
--network localhost \
--types '["string"]' hello

npx hardhat localnet-check
yarn zetachain localnet check

if [ "$1" = "start" ]; then npx hardhat localnet-stop; fi
yarn zetachain localnet stop
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Ensure graceful shutdown.

After yarn zetachain localnet stop, wait on the background process to avoid race conditions:

yarn zetachain localnet stop
wait $LOCALNET_PID

Loading