Skip to content
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

Gateway testnet #207

Merged
merged 14 commits into from
Nov 1, 2024
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
44 changes: 44 additions & 0 deletions .github/workflows/test.yaml
Copy link
Member

Choose a reason for hiding this comment

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

The following actions use a deprecated Node.js version and will be forced to run on node20: actions/checkout@v3

Copy link
Member Author

Choose a reason for hiding this comment

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

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
Comment on lines +20 to +22
Copy link
Member

Choose a reason for hiding this comment

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

might be cleaner to just write this in actions/github-script in javascript: https://github.com/actions/github-script

Comment on lines +17 to +22
Copy link

Choose a reason for hiding this comment

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

πŸ› οΈ Refactor suggestion

Enhance matrix setup using github-script.

Replace the shell script with a more robust JavaScript implementation using the github-script action.

-      - 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
+      - name: Set up Test Matrix
+        id: set-matrix
+        uses: actions/github-script@v7
+        with:
+          script: |
+            const { execSync } = require('child_process');
+            try {
+              const testDirs = execSync('find examples/*/scripts -type f -name "test.sh"')
+                .toString()
+                .trim()
+                .split('\n')
+                .map(path => path.replace(/\/scripts\/test\.sh$/, ''))
+                .filter(Boolean);
+              
+              if (!testDirs.length) {
+                throw new Error('No test directories found');
+              }
+              
+              const matrix = {
+                'example-dir': testDirs
+              };
+              
+              core.setOutput('matrix', JSON.stringify(matrix));
+            } catch (error) {
+              core.setFailed(`Matrix setup failed: ${error.message}`);
+            }
πŸ“ Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
- 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
- name: Set up Test Matrix
id: set-matrix
uses: actions/github-script@v7
with:
script: |
const { execSync } = require('child_process');
try {
const testDirs = execSync('find examples/*/scripts -type f -name "test.sh"')
.toString()
.trim()
.split('\n')
.map(path => path.replace(/\/scripts\/test\.sh$/, ''))
.filter(Boolean);
if (!testDirs.length) {
throw new Error('No test directories found');
}
const matrix = {
'example-dir': testDirs
};
core.setOutput('matrix', JSON.stringify(matrix));
} catch (error) {
core.setFailed(`Matrix setup failed: ${error.message}`);
}
🧰 Tools
πŸͺ› actionlint

18-18: shellcheck reported issue in this script: SC2038:warning:1:13: Use -print0/-0 or -exec + to allow for non-alphanumeric filenames

(shellcheck)


18-18: shellcheck reported issue in this script: SC2086:info:3:31: Double quote to prevent globbing and word splitting

(shellcheck)


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,
Comment on lines +20 to +21
Copy link

Choose a reason for hiding this comment

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

πŸ’‘ Codebase verification

API Evolution Requires Attention: Legacy Contracts Found

The verification reveals that legacy contracts in the omnichain/swap/ directory still use the old onCrossChainCall function with zContext parameter type. Specifically:

  • omnichain/swap/contracts/Swap.sol
  • omnichain/swap/contracts/SwapToAnyToken.sol

This indicates a breaking change in the contract interface from zContract to UniversalContract, where newer examples use the updated onCall with MessageContext. To maintain protocol consistency:

  1. Update the legacy contracts in omnichain/swap/ to use the new interface
  2. Update corresponding test files that call onCrossChainCall
  3. Consider deprecating the zContract interface in favor of UniversalContract
πŸ”— Analysis chain

Verify migration steps for onCall function signature change.

The function signature change from onCrossChainCall to onCall with MessageContext parameter type might impact existing deployments. Ensure that:

  1. Protocol documentation is updated to reflect this change
  2. Migration guide is provided for existing implementations
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for other contracts that might need similar updates
rg -l "onCrossChainCall" --type sol

# Check if there are any remaining references to zContext
rg -l "zContext" --type sol

Length of output: 119


Script:

#!/bin/bash
# Search for Solidity files first
fd -e sol

# Then search for function and type references without file type filter
rg "onCrossChainCall" 
rg "zContext"

# Look for any interface definitions that might show the evolution of the API
rg "interface.*Contract" -A 5

Length of output: 4767

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"
Copy link

Choose a reason for hiding this comment

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

πŸ› οΈ Refactor suggestion

Add deployment scripts for testnets mentioned in PR objectives.

The current script only handles localhost deployment. Consider adding separate scripts for Base Sepolia, Polygon Amoy, and ZetaChain testnet deployments to align with the PR objectives.

 "scripts": {
   "deploy:localnet": "npx hardhat compile --force && npx hardhat deploy --network localhost --gateway 0x9A676e781A523b5d0C0e43731313A708CB607508 && npx hardhat deploy --name Echo --network localhost --gateway 0x9fE46736679d2D9a65F0992F2272dE9f3c7fa6e0",
+  "deploy:base-sepolia": "npx hardhat compile --force && npx hardhat deploy --network base-sepolia",
+  "deploy:polygon-amoy": "npx hardhat compile --force && npx hardhat deploy --network polygon-amoy",
+  "deploy:zeta-testnet": "npx hardhat compile --force && npx hardhat deploy --network zeta-testnet"
 }

Committable suggestion was skipped due to low confidence.

},
"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

Comment on lines +1 to +4
Copy link

Choose a reason for hiding this comment

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

πŸ› οΈ Refactor suggestion

Enhance script robustness with additional safety measures.

While set -e is good, consider adding these Bash safety measures for production-grade scripts:

 #!/bin/bash
 
-set -e
+set -euo pipefail
+
+# Cleanup function to ensure the local network is stopped
+cleanup() {
+    if [ "${1:-}" = "localnet" ]; then
+        npx hardhat localnet-stop || true
+    fi
+}
+
+# Set up trap for script interruption
+trap 'cleanup "$1"' EXIT
πŸ“ Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
#!/bin/bash
set -e
#!/bin/bash
set -euo pipefail
# Cleanup function to ensure the local network is stopped
cleanup() {
if [ "${1:-}" = "localnet" ]; then
npx hardhat localnet-stop || true
fi
}
# Set up trap for script interruption
trap 'cleanup "$1"' EXIT

if [ "$1" = "localnet" ]; then
npx hardhat localnet --exit-on-error & sleep 10
fi
Comment on lines +5 to +7
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

Implement proper network readiness check.

Replace the fixed sleep with a proper health check loop:

 if [ "$1" = "localnet" ]; then
-  npx hardhat localnet --exit-on-error & sleep 10
+  npx hardhat localnet --exit-on-error &
+  network_pid=$!
+  
+  # Wait for network to be ready with timeout
+  max_attempts=30
+  attempt=1
+  echo "Waiting for local network to be ready..."
+  while ! npx hardhat localnet-check &>/dev/null; do
+    if [ $attempt -gt $max_attempts ]; then
+      echo "Network failed to start within timeout"
+      kill $network_pid
+      exit 1
+    fi
+    sleep 1
+    ((attempt++))
+  done
+  echo "Local network is ready"
 fi
πŸ“ Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
if [ "$1" = "localnet" ]; then
npx hardhat localnet --exit-on-error & sleep 10
fi
if [ "$1" = "localnet" ]; then
npx hardhat localnet --exit-on-error &
network_pid=$!
# Wait for network to be ready with timeout
max_attempts=30
attempt=1
echo "Waiting for local network to be ready..."
while ! npx hardhat localnet-check &>/dev/null; do
if [ $attempt -gt $max_attempts ]; then
echo "Network failed to start within timeout"
kill $network_pid
exit 1
fi
sleep 1
((attempt++))
done
echo "Local network is ready"
fi


yarn deploy:localnet

npx hardhat echo-call \
--contract 0x9E545E3C0baAB3E08CdfD552C960A1050f373042 \
--receiver 0x84eA74d481Ee0A5332c457a4d796187F6Ba67fEB \
--network localhost \
--types '["string"]' alice
Comment on lines +9 to +15
Copy link

Choose a reason for hiding this comment

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

πŸ› οΈ Refactor suggestion

Refactor contract interactions for maintainability and safety.

The script contains several issues:

  1. Hardcoded contract addresses should be externalized
  2. Repeated command patterns could be simplified
  3. Missing validation of contract deployment and interaction results
+# Load contract addresses from configuration
+source ./config/addresses.sh
+
+# Helper function for contract calls
+do_contract_call() {
+    local cmd=$1
+    shift
+    if ! npx hardhat "$cmd" "$@"; then
+        echo "Contract call failed: $cmd"
+        exit 1
+    fi
+}
+
 yarn deploy:localnet
+# Verify deployment success
+if [ $? -ne 0 ]; then
+    echo "Deployment failed"
+    exit 1
+fi
 
-npx hardhat echo-call \
-  --contract 0x9E545E3C0baAB3E08CdfD552C960A1050f373042 \
-  --receiver 0x84eA74d481Ee0A5332c457a4d796187F6Ba67fEB \
+do_contract_call echo-call \
+  --contract "$ECHO_CONTRACT" \
+  --receiver "$HELLO_CONTRACT" \
   --network localhost \
   --types '["string"]' alice

Also applies to: 19-26, 29-37


npx hardhat localnet-check
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

Enhance network monitoring reliability.

The network checks lack proper error handling and timeout mechanisms:

+# Helper function for network checks
+check_network() {
+    local max_attempts=5
+    local attempt=1
+    while [ $attempt -le $max_attempts ]; do
+        if npx hardhat localnet-check; then
+            return 0
+        fi
+        echo "Network check attempt $attempt failed, retrying..."
+        sleep 2
+        ((attempt++))
+    done
+    echo "Network check failed after $max_attempts attempts"
+    return 1
+}
+
-npx hardhat localnet-check
+check_network || exit 1

Also applies to: 27-27, 38-38, 40-40


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"
Comment on lines +34 to +35
Copy link

Choose a reason for hiding this comment

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

πŸ› οΈ Refactor suggestion

Consider using environment-specific gateway addresses

While the updated gateway address is correct for the testnet, hardcoding it directly in the task definition might cause issues when deploying to different environments. Consider implementing a more flexible configuration approach.

Here's a suggested implementation using network-specific configuration:

+ const GATEWAY_ADDRESSES = {
+   baseSepolia: "0x6c533f7fe93fae114d0954697069df33c9b74fd7",
+   polygonAmoy: "0x...", // Add Polygon Amoy gateway address
+   zetaChainTestnet: "0x...", // Add ZetaChain testnet gateway address
+ };

task("deploy", "Deploy the contract", main)
  .addFlag("json", "Output in JSON")
  .addOptionalParam("name", "Contract to deploy", "Hello")
  .addOptionalParam(
    "gateway",
-   "Gateway address (default: ZetaChain Gateway on testnet)",
-   "0x6c533f7fe93fae114d0954697069df33c9b74fd7"
+   "Gateway address (defaults to network-specific gateway address)",
+   undefined,
    types.string
  );

Then update the main function to use network-specific addresses:

const main = async (args: any, hre: HardhatRuntimeEnvironment) => {
  const network = hre.network.name;
  const gatewayAddress = args.gateway || GATEWAY_ADDRESSES[network];
  
  if (!gatewayAddress) {
    throw new Error(`No gateway address configured for network: ${network}`);
  }
  
  // ... rest of the deployment logic
  const contract = await (factory as any).deploy(gatewayAddress);

πŸ’‘ Codebase verification

Different gateway addresses detected across examples

The hello and NFT examples are using different gateway addresses:

  • Hello example: 0x6c533f7fe93fae114d0954697069df33c9b74fd7
  • NFT example: 0x5FC8d32690cc91D4c39d9d3abcBD16989F875707

This inconsistency in gateway addresses between examples should be addressed to prevent confusion. Consider:

  • Using the same gateway address across examples if they target the same network
  • Adding clear documentation about which network each gateway address corresponds to
  • Using environment variables or configuration files to manage network-specific addresses
πŸ”— Analysis chain

Verify gateway address usage across networks

Let's verify how this gateway address is being used across different networks to ensure consistency.


Let me check the gateway address configuration in the NFT example to get a complete picture.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for gateway address usage across the codebase
echo "Searching for gateway address references..."
rg -i "0x6c533f7fe93fae114d0954697069df33c9b74fd7"

echo "\nSearching for potential gateway configurations..."
rg -l "gateway.*address" --type ts

Length of output: 406


Script:

#!/bin/bash
# Check the gateway address configuration in the NFT example
echo "Content of examples/nft/tasks/deploy.ts:"
cat examples/nft/tasks/deploy.ts

Length of output: 1498

);
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",
],
Comment on lines +18 to +24
Copy link

Choose a reason for hiding this comment

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

πŸ› οΈ Refactor suggestion

Consider adding error prevention plugins

While the current plugins focus on code organization and formatting, consider adding plugins for error prevention:

  plugins: [
    "@typescript-eslint",
    "prettier",
    "simple-import-sort",
    "sort-keys-fix",
    "typescript-sort-keys",
+   "eslint-plugin-import",
+   "eslint-plugin-promise",
+   "eslint-plugin-security"
  ],
πŸ“ Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
plugins: [
"@typescript-eslint",
"prettier",
"simple-import-sort",
"sort-keys-fix",
"typescript-sort-keys",
],
plugins: [
"@typescript-eslint",
"prettier",
"simple-import-sort",
"sort-keys-fix",
"typescript-sort-keys",
"eslint-plugin-import",
"eslint-plugin-promise",
"eslint-plugin-security"
],

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",
},
Comment on lines +25 to +33
Copy link

Choose a reason for hiding this comment

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

πŸ› οΈ Refactor suggestion

Consider strengthening TypeScript-specific rules

The current rules focus on sorting and formatting. Consider adding stricter TypeScript-specific rules for better type safety.

  rules: {
    "@typescript-eslint/sort-type-union-intersection-members": "error",
+   "@typescript-eslint/explicit-function-return-type": "error",
+   "@typescript-eslint/no-explicit-any": "error",
+   "@typescript-eslint/strict-boolean-expressions": "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",
  },
πŸ“ Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
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",
},
rules: {
"@typescript-eslint/sort-type-union-intersection-members": "error",
"@typescript-eslint/explicit-function-return-type": "error",
"@typescript-eslint/no-explicit-any": "error",
"@typescript-eslint/strict-boolean-expressions": "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
Loading