Skip to content

Commit 0d647e4

Browse files
committed
merge update-cli branch
2 parents c4574d9 + 8076f4a commit 0d647e4

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+12787
-9175
lines changed

.github/workflows/localnet.yaml

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
name: Run Localnet
2+
3+
on:
4+
pull_request:
5+
workflow_dispatch:
6+
7+
permissions:
8+
contents: read
9+
10+
jobs:
11+
setup-matrix:
12+
runs-on: ubuntu-latest
13+
outputs:
14+
matrix: ${{ steps.set-matrix.outputs.matrix }}
15+
steps:
16+
- name: Checkout code
17+
uses: actions/checkout@v4
18+
19+
- name: Set up Test Matrix
20+
id: set-matrix
21+
run: |
22+
test_dirs=$(find examples/*/scripts -type f -name 'localnet.sh' -print0 | xargs -0 dirname | xargs dirname)
23+
matrix_json=$(echo "$test_dirs" | jq -R '{"example-dir": .}' | jq -s . | jq -c .)
24+
echo "matrix=$matrix_json" >> $GITHUB_OUTPUT
25+
26+
test:
27+
needs: setup-matrix
28+
runs-on: ubuntu-latest
29+
strategy:
30+
matrix:
31+
include: ${{ fromJSON(needs.setup-matrix.outputs.matrix) }}
32+
fail-fast: false
33+
34+
steps:
35+
- name: Checkout code
36+
uses: actions/checkout@v4
37+
38+
- name: Install Foundry
39+
uses: foundry-rs/foundry-toolchain@v1
40+
41+
- name: Install Anchor (Solana)
42+
uses: metadaoproject/[email protected]
43+
44+
- name: Setup Node.js
45+
uses: actions/setup-node@v4
46+
with:
47+
node-version: "22"
48+
registry-url: "https://registry.npmjs.org"
49+
50+
- name: Run Test Script
51+
run: |
52+
cd "${{ matrix.example-dir }}"
53+
yarn
54+
chmod +x ./scripts/localnet.sh
55+
./scripts/localnet.sh start

.github/workflows/slither.yaml

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ jobs:
3636
- name: Install Node.js
3737
uses: actions/setup-node@v2
3838
with:
39-
node-version: "18"
39+
node-version: "22"
4040

4141
- name: Install Dependencies
4242
run: yarn install
@@ -45,20 +45,18 @@ jobs:
4545
uses: foundry-rs/foundry-toolchain@v1
4646

4747
- name: Build projects
48-
continue-on-error: true
4948
run: yarn build
5049

5150
- name: Run Slither on ${{ matrix.project}}
5251
uses: crytic/slither-action@main
53-
continue-on-error: true
5452
with:
5553
ignore-compile: true
5654
sarif: ${{ matrix.file}}
57-
node-version: "18"
55+
node-version: "22"
5856
target: ${{ matrix.project}}
5957
fail-on: none
6058

61-
- name: Upload zevm-app-contracts SARIF file
59+
- name: Upload SARIF file
6260
uses: github/codeql-action/upload-sarif@v3
6361
with:
6462
sarif_file: ${{ matrix.file}}

.github/workflows/test.yaml

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ jobs:
1616
- name: Set up Test Matrix
1717
id: set-matrix
1818
run: |
19-
test_dirs=$(find examples/*/scripts -type f -name 'localnet.sh' -exec dirname {} \; | xargs dirname)
19+
test_dirs=$(find examples/*/test -type f -name '*.t.sol' -exec dirname {} \; | xargs dirname)
2020
matrix_json=$(echo "$test_dirs" | jq -R '{"example-dir": .}' | jq -s . | jq -c .)
2121
echo "matrix=$matrix_json" >> $GITHUB_OUTPUT
2222
@@ -35,12 +35,9 @@ jobs:
3535
- name: Install Foundry
3636
uses: foundry-rs/foundry-toolchain@v1
3737

38-
- name: Install Anchor (Solana)
39-
uses: metadaoproject/[email protected]
40-
4138
- name: Run Test Script
4239
run: |
4340
cd "${{ matrix.example-dir }}"
4441
yarn
45-
chmod +x ./scripts/localnet.sh
46-
./scripts/localnet.sh start
42+
forge soldeer update
43+
forge test

.gitmodules

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[submodule "examples/hello/lib/forge-std"]
2+
path = examples/hello/lib/forge-std
3+
url = https://github.com/foundry-rs/forge-std

examples/call/contracts/Connected.sol

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,8 @@ contract Connected {
8282
MessageContext calldata context,
8383
bytes calldata message
8484
) external payable onlyGateway returns (bytes4) {
85-
emit HelloEvent("Hello on EVM from onCall()", "hey");
85+
string memory name = abi.decode(message, (string));
86+
emit HelloEvent("Hello on EVM from onCall()", name);
8687
return "";
8788
}
8889

examples/call/foundry.toml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,14 @@
22
src = 'contracts'
33
out = 'out'
44
viaIR = true
5-
libs = ['node_modules', 'lib']
5+
libs = ['node_modules', "dependencies"]
66
test = 'test'
77
cache_path = 'cache_forge'
88
verbosity = 3
9+
fs_permissions = [{ access = "read", path = "./node_modules" }]
10+
remappings = [
11+
"forge-std/=dependencies/forge-std-1.9.7/src/",
12+
]
913

1014
[dependencies]
11-
forge-std = { version = "1.9.2" }
15+
forge-std = "1.9.7"

examples/call/hardhat.config.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@ import * as dotenv from "dotenv";
55
import "./tasks";
66
import "@zetachain/localnet/tasks";
77
import "@zetachain/toolkit/tasks";
8-
import { getHardhatConfig } from "@zetachain/toolkit/client";
8+
import { getHardhatConfig } from "@zetachain/toolkit/utils";
99

1010
dotenv.config();
1111

1212
const config: HardhatUserConfig = {
13-
...getHardhatConfig({ accounts: [process.env.PRIVATE_KEY] }),
13+
...getHardhatConfig({ accounts: [process.env.PRIVATE_KEY || ""] }),
1414
};
1515

1616
export default config;

examples/call/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
"@typescript-eslint/eslint-plugin": "^5.59.9",
3030
"@typescript-eslint/parser": "^5.59.9",
3131
"@zetachain/localnet": "7.1.0",
32-
"@zetachain/toolkit": "13.0.0-rc17",
32+
"@zetachain/toolkit": "^16.0.0",
3333
"axios": "^1.3.6",
3434
"chai": "^4.2.0",
3535
"dotenv": "^16.0.3",

examples/call/remappings.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
forge-std-1.9.7/=dependencies/forge-std-1.9.7/

examples/call/scripts/localnet.sh

Lines changed: 2 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ set -e
44
set -x
55
set -o pipefail
66

7-
yarn zetachain localnet start --skip sui ton solana --exit-on-error &
7+
yarn zetachain localnet start --force-kill --skip sui ton solana --exit-on-error &
88

99
while [ ! -f "localnet.json" ]; do sleep 1; done
1010

@@ -13,7 +13,6 @@ npx hardhat compile --force --quiet
1313
ZRC20_ETHEREUM=$(jq -r '.addresses[] | select(.type=="ZRC-20 ETH on 5") | .address' localnet.json)
1414
ERC20_ETHEREUM=$(jq -r '.addresses[] | select(.type=="ERC-20 USDC" and .chain=="ethereum") | .address' localnet.json)
1515
ZRC20_BNB=$(jq -r '.addresses[] | select(.type=="ZRC-20 BNB on 97") | .address' localnet.json)
16-
# ZRC20_SOL=$(jq -r '.addresses[] | select(.type=="ZRC-20 SOL on 901") | .address' localnet.json)
1716
ZRC20_SPL=$(jq -r '.addresses[] | select(.type=="ZRC-20 USDC on 901") | .address' localnet.json)
1817
USDC_SPL=$(jq -r '.addresses[] | select(.type=="SPL-20 USDC") | .address' localnet.json)
1918
GATEWAY_ETHEREUM=$(jq -r '.addresses[] | select(.type=="gatewayEVM" and .chain=="ethereum") | .address' localnet.json)
@@ -26,9 +25,6 @@ echo -e "\n🚀 Deployed contract on ZetaChain: $CONTRACT_ZETACHAIN"
2625
CONTRACT_ETHEREUM=$(npx hardhat deploy --name Connected --json --network localhost --gateway "$GATEWAY_ETHEREUM" | jq -r '.contractAddress')
2726
echo -e "🚀 Deployed contract on Ethereum: $CONTRACT_ETHEREUM"
2827

29-
# CONTRACT_SOL=9BjVGjn28E58LgSi547JYEpqpgRoo1TErkbyXiRSNDQy
30-
# cd solana && anchor build && npx ts-node setup/main.ts "$USDC_SPL" && cd -
31-
3228
npx hardhat connected-deposit \
3329
--contract "$CONTRACT_ETHEREUM" \
3430
--receiver "$CONTRACT_ZETACHAIN" \
@@ -94,6 +90,7 @@ npx hardhat universal-call \
9490
--zrc20 "$ZRC20_ETHEREUM" \
9591
--function "hello(string)" \
9692
--network localhost \
93+
--call-options-is-arbitrary-call \
9794
--abort-address "$CONTRACT_ZETACHAIN" \
9895
--types '["string"]' alice
9996

@@ -178,67 +175,4 @@ npx hardhat zetachain-withdraw \
178175

179176
yarn zetachain localnet check
180177

181-
# npx hardhat zetachain-withdraw \
182-
# --receiver "DrexsvCMH9WWjgnjVbx1iFf3YZcKadupFmxnZLfSyotd" \
183-
# --gateway-zeta-chain "$GATEWAY_ZETACHAIN" \
184-
# --zrc20 "$ZRC20_SOL" \
185-
# --network localhost \
186-
# --amount 1
187-
188-
# yarn zetachain localnet check
189-
190-
npx hardhat zetachain-call \
191-
--receiver "$CONTRACT_ETHEREUM" \
192-
--gateway-zeta-chain "$GATEWAY_ZETACHAIN" \
193-
--zrc20 "$ZRC20_ETHEREUM" \
194-
--function "hello(string)" \
195-
--network localhost \
196-
--types '["string"]' alice
197-
198-
yarn zetachain localnet check
199-
200-
npx hardhat zetachain-withdraw-and-call \
201-
--receiver "$CONTRACT_ETHEREUM" \
202-
--gateway-zeta-chain "$GATEWAY_ZETACHAIN" \
203-
--zrc20 "$ZRC20_ETHEREUM" \
204-
--function "hello(string)" \
205-
--amount 1 \
206-
--network localhost \
207-
--call-options-is-arbitrary-call \
208-
--types '["string"]' hello
209-
210-
yarn zetachain localnet check
211-
212-
# ENCODED_ACCOUNTS_AND_DATA=$(npx ts-node solana/setup/encodeCallArgs.ts "sol" "$USDC_SPL")
213-
# npx hardhat zetachain-withdraw-and-call \
214-
# --receiver "$CONTRACT_SOL" \
215-
# --gateway-zeta-chain "$GATEWAY_ZETACHAIN" \
216-
# --zrc20 "$ZRC20_SOL" \
217-
# --amount 1 \
218-
# --network localhost \
219-
# --types '["bytes"]' $ENCODED_ACCOUNTS_AND_DATA
220-
221-
# yarn zetachain localnet check
222-
223-
# ENCODED_ACCOUNTS_AND_DATA=$(npx ts-node solana/setup/encodeCallArgs.ts "spl" "$USDC_SPL")
224-
# npx hardhat zetachain-withdraw-and-call \
225-
# --receiver "$CONTRACT_SOL" \
226-
# --gateway-zeta-chain "$GATEWAY_ZETACHAIN" \
227-
# --zrc20 "$ZRC20_SPL" \
228-
# --amount 1 \
229-
# --network localhost \
230-
# --types '["bytes"]' $ENCODED_ACCOUNTS_AND_DATA
231-
232-
# yarn zetachain localnet check
233-
234-
npx hardhat zetachain-withdraw-and-call \
235-
--receiver "$CONTRACT_ETHEREUM" \
236-
--gateway-zeta-chain "$GATEWAY_ZETACHAIN" \
237-
--zrc20 "$ZRC20_ETHEREUM" \
238-
--amount 1 \
239-
--network localhost \
240-
--types '["string"]' hello
241-
242-
yarn zetachain localnet check
243-
244178
yarn zetachain localnet stop

0 commit comments

Comments
 (0)