Skip to content

Commit

Permalink
Gateway testnet (#207)
Browse files Browse the repository at this point in the history
  • Loading branch information
fadeev authored Nov 1, 2024
1 parent 7cec245 commit 31fb966
Show file tree
Hide file tree
Showing 30 changed files with 9,489 additions and 35 deletions.
44 changes: 44 additions & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: Run Tests

on:
push:
pull_request:
workflow_dispatch:

jobs:
setup-matrix:
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Test Matrix
id: set-matrix
run: |
test_dirs=$(find examples/*/scripts -type f -name 'test.sh' -exec dirname {} \; | xargs dirname)
matrix_json=$(echo "$test_dirs" | jq -R '{"example-dir": .}' | jq -s . | jq -c .)
echo "matrix=$matrix_json" >> $GITHUB_OUTPUT
test:
needs: setup-matrix
runs-on: ubuntu-latest
strategy:
matrix:
include: ${{ fromJSON(needs.setup-matrix.outputs.matrix) }}
fail-fast: false

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Install Foundry
uses: foundry-rs/foundry-toolchain@v1

- name: Run Test Script
run: |
cd "${{ matrix.example-dir }}"
yarn
chmod +x ./scripts/test.sh
./scripts/test.sh localnet
4 changes: 2 additions & 2 deletions examples/hello/contracts/Hello.sol
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ contract Hello is UniversalContract {
gateway = GatewayZEVM(gatewayAddress);
}

function onCrossChainCall(
zContext calldata context,
function onCall(
MessageContext calldata context,
address zrc20,
uint256 amount,
bytes calldata message
Expand Down
6 changes: 3 additions & 3 deletions examples/hello/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"test": "echo \"Error: no test specified\" && exit 1",
"lint:fix": "npx eslint . --ext .js,.ts --fix",
"lint": "npx eslint . --ext .js,.ts",
"deploy": "npx hardhat compile --force && npx hardhat deploy --network localhost && npx hardhat deploy --name Echo --network localhost --gateway 0x9fE46736679d2D9a65F0992F2272dE9f3c7fa6e0"
"deploy:localnet": "npx hardhat compile --force && npx hardhat deploy --network localhost --gateway 0x9A676e781A523b5d0C0e43731313A708CB607508 && npx hardhat deploy --name Echo --network localhost --gateway 0x9fE46736679d2D9a65F0992F2272dE9f3c7fa6e0"
},
"keywords": [],
"author": "",
Expand All @@ -28,7 +28,7 @@
"@types/node": ">=12.0.0",
"@typescript-eslint/eslint-plugin": "^5.59.9",
"@typescript-eslint/parser": "^5.59.9",
"@zetachain/localnet": "^3.3.0",
"@zetachain/localnet": "^3.5.0",
"@zetachain/toolkit": "13.0.0-rc4",
"axios": "^1.3.6",
"chai": "^4.2.0",
Expand Down Expand Up @@ -57,6 +57,6 @@
"@solana-developers/helpers": "^2.4.0",
"@solana/spl-memo": "^0.2.5",
"@solana/web3.js": "^1.95.2",
"@zetachain/protocol-contracts": "10.0.0-rc10"
"@zetachain/protocol-contracts": "10.0.0-rc11"
}
}
40 changes: 40 additions & 0 deletions examples/hello/scripts/test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#!/bin/bash

set -e

if [ "$1" = "localnet" ]; then
npx hardhat localnet --exit-on-error & sleep 10
fi

yarn deploy:localnet

npx hardhat echo-call \
--contract 0x9E545E3C0baAB3E08CdfD552C960A1050f373042 \
--receiver 0x84eA74d481Ee0A5332c457a4d796187F6Ba67fEB \
--network localhost \
--types '["string"]' alice

npx hardhat localnet-check

npx hardhat hello-call \
--contract 0x84eA74d481Ee0A5332c457a4d796187F6Ba67fEB \
--receiver 0x9E545E3C0baAB3E08CdfD552C960A1050f373042 \
--zrc20 0x2ca7d64A7EFE2D62A725E2B35Cf7230D6677FfEe \
--function "hello(string)" \
--network localhost \
--types '["string"]' alice

npx hardhat localnet-check

npx hardhat hello-withdraw-and-call \
--contract 0x84eA74d481Ee0A5332c457a4d796187F6Ba67fEB \
--receiver 0x9E545E3C0baAB3E08CdfD552C960A1050f373042 \
--zrc20 0x9fd96203f7b22bCF72d9DCb40ff98302376cE09c \
--function "hello(string)" \
--amount 1 \
--network localhost \
--types '["string"]' hello

npx hardhat localnet-check

npx hardhat localnet-stop
4 changes: 2 additions & 2 deletions examples/hello/tasks/deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,6 @@ task("deploy", "Deploy the contract", main)
.addOptionalParam("name", "Contract to deploy", "Hello")
.addOptionalParam(
"gateway",
"Gateway address (default: ZetaChain Gateway)",
"0xA51c1fc2f0D1a1b8494Ed1FE312d7C3a78Ed91C0"
"Gateway address (default: ZetaChain Gateway on testnet)",
"0x6c533f7fe93fae114d0954697069df33c9b74fd7"
);
19 changes: 10 additions & 9 deletions examples/hello/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2402,15 +2402,15 @@
typescript "5.5.4"
zod "3.22.4"

"@zetachain/localnet@^3.3.0":
version "3.3.0"
resolved "https://registry.yarnpkg.com/@zetachain/localnet/-/localnet-3.3.0.tgz#eb026e1e56ef4ea78fd5efb15df2f931daeba884"
integrity sha512-8PbS6GQrROYicyEHk3QGhspwKnm3Nn8tmgISbtVw2ca4I+9lIAnuo4WstBPXhV3/kR9zPxgxErWnBWNSE78BuA==
"@zetachain/localnet@^3.5.0":
version "3.5.0"
resolved "https://registry.yarnpkg.com/@zetachain/localnet/-/localnet-3.5.0.tgz#a4d1509a154a736b868d7a89eb6a920f8047083e"
integrity sha512-awZMdQE/inTGmR4dBa+yrMwoedZGSjU+QPOx91gBgRAWcWOx6BYX+MJxcrfpmdu/oMPbMWUK262o2HD19Kfrkw==
dependencies:
"@inquirer/prompts" "^5.5.0"
"@uniswap/v2-core" "^1.0.1"
"@uniswap/v2-periphery" "^1.1.0-beta.0"
"@zetachain/protocol-contracts" "10.0.0-rc10"
"@zetachain/protocol-contracts" "10.0.0-rc11"
ansis "^3.3.2"
concurrently "^8.2.2"
ethers "^6.13.2"
Expand All @@ -2424,13 +2424,14 @@
dependencies:
dotenv "^16.1.4"

"@zetachain/[email protected]rc10":
version "10.0.0-rc10"
resolved "https://registry.yarnpkg.com/@zetachain/protocol-contracts/-/protocol-contracts-10.0.0-rc10.tgz#e3c21b493904ec743c9026627b2f809009fec7a2"
integrity sha512-kOH7Lk0os3xt9N/FCdeaLUMyonfez97q69Jy2YFwddjv9jpqaxwLXWj2hvdIFc21inKZ7HIjmDDcj9/n8gITKg==
"@zetachain/[email protected]rc11":
version "10.0.0-rc11"
resolved "https://registry.yarnpkg.com/@zetachain/protocol-contracts/-/protocol-contracts-10.0.0-rc11.tgz#53f55ead492f7b5802b1feae4e51abc75730af33"
integrity sha512-qWazjqnIGRngf4OmyeSIv7sHICQRdMQ1CKPIQIqxA8qFR+gHhDHSfvMdRAvgWbsfkimXOIFiHVIATypyWhviJw==
dependencies:
"@openzeppelin/contracts" "^5.0.2"
"@openzeppelin/contracts-upgradeable" "^5.0.2"
"@zetachain/networks" "^10.0.0"
ethers "^6.13.1"

"@zetachain/[email protected]":
Expand Down
6 changes: 6 additions & 0 deletions examples/nft/.eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
.yarn
artifacts
cache
coverage
node_modules
typechain-types
47 changes: 47 additions & 0 deletions examples/nft/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
const path = require("path");

/**
* @type {import("eslint").Linter.Config}
*/
module.exports = {
env: {
browser: false,
es2021: true,
mocha: true,
node: true,
},
extends: ["plugin:prettier/recommended"],
parser: "@typescript-eslint/parser",
parserOptions: {
ecmaVersion: 12,
},
plugins: [
"@typescript-eslint",
"prettier",
"simple-import-sort",
"sort-keys-fix",
"typescript-sort-keys",
],
rules: {
"@typescript-eslint/sort-type-union-intersection-members": "error",
camelcase: "off",
"simple-import-sort/exports": "error",
"simple-import-sort/imports": "error",
"sort-keys-fix/sort-keys-fix": "error",
"typescript-sort-keys/interface": "error",
"typescript-sort-keys/string-enum": "error",
},
settings: {
"import/parsers": {
"@typescript-eslint/parser": [".js", ".jsx", ".ts", ".tsx", ".d.ts"],
},
"import/resolver": {
node: {
extensions: [".js", ".jsx", ".ts", ".tsx", ".d.ts"],
},
typescript: {
project: path.join(__dirname, "tsconfig.json"),
},
},
},
};
17 changes: 17 additions & 0 deletions examples/nft/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
node_modules
.env
coverage
coverage.json
typechain
typechain-types
dependencies

# Hardhat files
cache
artifacts

# Foundry files
out
cache_forge

access_token
21 changes: 21 additions & 0 deletions examples/nft/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2023 ZetaChain

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
4 changes: 4 additions & 0 deletions examples/nft/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# NFT Example

This example currently only works with localnet `v4.0.0-rc*`, which supports
authenticated calls and multiple EVM chains.
Loading

0 comments on commit 31fb966

Please sign in to comment.