Skip to content

Commit 35c7848

Browse files
authored
fix: use correct param oder in messaging example constructor (#303)
1 parent 3c74e59 commit 35c7848

File tree

8 files changed

+58
-6
lines changed

8 files changed

+58
-6
lines changed

examples/messaging/commands/deploy.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ const main = async (options: any) => {
1111
const contractFactory = new ethers.ContractFactory(abi, bytecode, signer);
1212

1313
const contract = await contractFactory.deploy(
14+
signer.address,
1415
options.gateway,
15-
signer.address, // owner
1616
options.router
1717
);
1818

examples/messaging/contracts/Messaging.sol

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@ contract Example is Messaging {
1010
event OnRevertEventEVM();
1111

1212
constructor(
13-
address payable _gateway,
1413
address owner,
14+
address payable _gateway,
1515
address _router
16-
) Messaging(_gateway, owner, _router) {}
16+
) Messaging(owner, _gateway, _router) {}
1717

1818
function onMessageReceive(
1919
bytes memory data,

examples/messaging/foundry.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ src = 'contracts'
33
out = 'out'
44
viaIR = true
55
libs = ['node_modules', "dependencies"]
6-
evm_version = "paris"
76
test = 'test'
87
cache_path = 'cache_forge'
98
verbosity = 3

examples/messaging/hardhat.config.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ const config: HardhatUserConfig = {
1515
compilers: [
1616
{
1717
settings: {
18+
evmVersion: "cancun",
1819
optimizer: {
1920
enabled: true,
2021
runs: 1000,

examples/messaging/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@
5858
"@solana-developers/helpers": "^2.4.0",
5959
"@solana/spl-memo": "^0.2.5",
6060
"@solana/web3.js": "^1.95.8",
61-
"@zetachain/protocol-contracts": "13.0.0",
61+
"@zetachain/protocol-contracts": "14.1.0",
6262
"@zetachain/standard-contracts": "^4.1.0",
6363
"@zetachain/toolkit": "^16.2.2",
6464
"commander": "^13.1.0",
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
#!/bin/bash
2+
3+
set -exo pipefail
4+
5+
yarn zetachain localnet start --force-kill --no-analytics &
6+
7+
REGISTRY_FILE="$HOME/.zetachain/localnet/registry.json"
8+
while [ ! -f "$REGISTRY_FILE" ]; do sleep 1; done
9+
10+
forge soldeer update
11+
12+
forge build
13+
14+
ZRC20_ETHEREUM=$(jq -r '."11155112".zrc20Tokens[] | select(.symbol=="ETH.ETH") | .address' "$REGISTRY_FILE")
15+
USDC_ETHEREUM=$(jq -r '."11155112".zrc20Tokens[] | select(.symbol=="USDC.ETH") | .originAddress' "$REGISTRY_FILE")
16+
ZRC20_USDC_BNB=$(jq -r '."98".zrc20Tokens[] | select(.symbol=="USDC.BNB") | .address' "$REGISTRY_FILE")
17+
ZRC20_BNB=$(jq -r '."98".zrc20Tokens[] | select(.symbol=="BNB.BNB") | .address' "$REGISTRY_FILE")
18+
GATEWAY_ETHEREUM=$(jq -r '."11155112".contracts[] | select(.contractType=="gateway") | .address' "$REGISTRY_FILE")
19+
GATEWAY_ZETACHAIN=$(jq -r '."31337".contracts[] | select(.contractType=="gateway") | .address' "$REGISTRY_FILE")
20+
GATEWAY_BNB=$(jq -r '."98".contracts[] | select(.contractType=="gateway") | .address' "$REGISTRY_FILE")
21+
PRIVATE_KEY=$(jq -r '.private_keys[0]' ~/.zetachain/localnet/anvil.json) && echo $PRIVATE_KEY
22+
DEPLOYER_ADDRESS=$(cast wallet address $PRIVATE_KEY)
23+
24+
CONTRACT_ZETACHAIN=$(forge create --broadcast --json test/UniversalRouter.sol:UniversalRouter --rpc-url http://localhost:8545 --private-key $PRIVATE_KEY --constructor-args $DEPLOYER_ADDRESS | jq -r '.deployedTo')
25+
26+
CONTRACT_ETHEREUM=$(npx tsx commands deploy --rpc http://localhost:8545 --gateway "$GATEWAY_ETHEREUM" --router "$CONTRACT_ZETACHAIN" --private-key $PRIVATE_KEY | jq -r '.contractAddress')
27+
28+
CONTRACT_BNB=$(npx tsx commands deploy --rpc http://localhost:8545 --gateway "$GATEWAY_BNB" --router "$CONTRACT_ZETACHAIN" --private-key $PRIVATE_KEY | jq -r '.contractAddress')
29+
30+
npx tsx commands connect --rpc http://localhost:8545 --private-key $PRIVATE_KEY --contract "$CONTRACT_ETHEREUM" --target-chain-id 98 --target-contract "$CONTRACT_BNB"
31+
npx tsx commands connect --rpc http://localhost:8545 --private-key $PRIVATE_KEY --contract "$CONTRACT_BNB" --target-chain-id 11155112 --target-contract "$CONTRACT_ETHEREUM"
32+
33+
# Gas
34+
npx tsx commands message --rpc http://localhost:8545 --private-key $PRIVATE_KEY --contract "$CONTRACT_ETHEREUM" --target-contract "$CONTRACT_BNB" --amount 1 --call-on-revert --revert-address "$CONTRACT_ETHEREUM" --revert-message "hello" --types string --values alice --target-token "$ZRC20_BNB"
35+
36+
npx zetachain localnet check
37+
38+
# Source ERC-20
39+
npx tsx commands message --rpc http://localhost:8545 --private-key $PRIVATE_KEY --contract "$CONTRACT_ETHEREUM" --target-contract "$CONTRACT_BNB" --amount 1 --call-on-revert --revert-address "$CONTRACT_ETHEREUM" --revert-message "hello" --types string --values alice --erc20 "$USDC_ETHEREUM" --target-token "$ZRC20_BNB"
40+
41+
npx zetachain localnet check
42+
43+
yarn zetachain localnet stop
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
// SPDX-License-Identifier: MIT
2+
pragma solidity 0.8.26;
3+
4+
import {UniversalRouter as UniversalRouterImport} from "@zetachain/standard-contracts/contracts/messaging/contracts/UniversalRouter.sol";
5+
6+
contract UniversalRouter is UniversalRouterImport {
7+
constructor(address owner) UniversalRouterImport(owner) {}
8+
}

scripts/build.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ rm -rf typescript-types && mkdir typescript-types
66
for dir in ./examples/*/; do
77
subdir=$(echo $dir | cut -d'/' -f2)
88

9-
cd $dir && yarn && npx hardhat compile --force && cp -r artifacts/contracts/* ../../abi/$subdir/ && cd ../../;
9+
echo "Building $subdir"
10+
(cd $dir && yarn && npx hardhat compile --force && cp -r artifacts/contracts/* ../../abi/$subdir/)
1011
done
1112

1213
find ./abi/ -name '*.dbg.json' -exec rm {} \;

0 commit comments

Comments
 (0)