From 6fb3bf3491d489addb3bd352caccf615f2bee064 Mon Sep 17 00:00:00 2001 From: Denis Fadeev Date: Thu, 31 Oct 2024 18:45:27 +0300 Subject: [PATCH] nft test --- .github/workflows/test.yaml | 6 ++--- examples/hello/scripts/run.sh | 40 ------------------------------- examples/nft/package.json | 4 ++-- examples/nft/scripts/test.sh | 11 ++++++++- examples/nft/yarn.lock | 45 +++++++++++++++++++++++++++++++---- 5 files changed, 55 insertions(+), 51 deletions(-) delete mode 100755 examples/hello/scripts/run.sh diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 98d1b073..13493264 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -16,7 +16,7 @@ jobs: - name: Set up Test Matrix id: set-matrix run: | - test_dirs=$(find examples/*/scripts -type f -name 'run.sh' -exec dirname {} \; | xargs dirname) + 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 @@ -39,5 +39,5 @@ jobs: run: | cd "${{ matrix.example-dir }}" yarn - chmod +x ./scripts/run.sh - ./scripts/run.sh + chmod +x ./scripts/test.sh + ./scripts/test.sh diff --git a/examples/hello/scripts/run.sh b/examples/hello/scripts/run.sh deleted file mode 100755 index 85c8585b..00000000 --- a/examples/hello/scripts/run.sh +++ /dev/null @@ -1,40 +0,0 @@ -#!/bin/bash - -set -e - -npx hardhat localnet --exit-on-error & - -sleep 10 - -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 \ No newline at end of file diff --git a/examples/nft/package.json b/examples/nft/package.json index bb920fe9..1446194d 100644 --- a/examples/nft/package.json +++ b/examples/nft/package.json @@ -27,7 +27,7 @@ "@types/node": ">=12.0.0", "@typescript-eslint/eslint-plugin": "^5.59.9", "@typescript-eslint/parser": "^5.59.9", - "@zetachain/localnet": "4.0.0-rc1", + "@zetachain/localnet": "4.0.0-rc2", "@zetachain/toolkit": "13.0.0-rc4", "axios": "^1.3.6", "chai": "^4.2.0", @@ -58,4 +58,4 @@ "@solana/web3.js": "^1.95.2", "@zetachain/protocol-contracts": "11.0.0-rc3" } -} \ No newline at end of file +} diff --git a/examples/nft/scripts/test.sh b/examples/nft/scripts/test.sh index 2878d124..15ef145a 100755 --- a/examples/nft/scripts/test.sh +++ b/examples/nft/scripts/test.sh @@ -2,6 +2,8 @@ set -e +npx hardhat localnet --exit-on-error & + function nft_balance() { echo -e "\nšŸ–¼ļø NFT Balance" echo "---------------------------------------------" @@ -42,23 +44,30 @@ npx hardhat universal-set-counterparty --network localhost --contract "$CONTRACT npx hardhat universal-set-counterparty --network localhost --contract "$CONTRACT_ZETACHAIN" --counterparty "$CONTRACT_BNB" --zrc20 "$ZRC20_BNB" --json &>/dev/null nft_balance +npx hardhat localnet-check NFT_ID=$(npx hardhat mint --network localhost --json --contract "$CONTRACT_ZETACHAIN" --token-uri https://example.com/nft/metadata/1 | jq -r '.tokenId') echo -e "\nMinted NFT with ID: $NFT_ID on ZetaChain." nft_balance +npx hardhat localnet-check echo -e "\nTransferring NFT: ZetaChain ā†’ Ethereum..." npx hardhat transfer --network localhost --json --token-id "$NFT_ID" --from "$CONTRACT_ZETACHAIN" --to "$ZRC20_ETHEREUM" nft_balance +npx hardhat localnet-check echo -e "\nTransferring NFT: Ethereum ā†’ BNB..." npx hardhat transfer --network localhost --json --token-id "$NFT_ID" --from "$CONTRACT_ETHEREUM" --to "$ZRC20_BNB" --gas-amount 0.1 nft_balance +npx hardhat localnet-check echo -e "\nTransferring NFT: BNB ā†’ ZetaChain..." npx hardhat transfer --network localhost --json --token-id "$NFT_ID" --from "$CONTRACT_BNB" -nft_balance \ No newline at end of file +nft_balance +npx hardhat localnet-check + +npx hardhat localnet-stop \ No newline at end of file diff --git a/examples/nft/yarn.lock b/examples/nft/yarn.lock index e4be84d0..a25e5ac5 100644 --- a/examples/nft/yarn.lock +++ b/examples/nft/yarn.lock @@ -2532,6 +2532,13 @@ resolved "https://registry.yarnpkg.com/@types/node/-/node-18.15.13.tgz#f64277c341150c979e42b00e4ac289290c9df469" integrity sha512-N+0kuo9KgrUQ1Sn/ifDXsvg0TTleP7rIy4zOBGECxAljqvqfqpTfzx0Q1NUedOixRMBfe2Whhb056a42cWs26Q== +"@types/node@22.7.5": + version "22.7.5" + resolved "https://registry.yarnpkg.com/@types/node/-/node-22.7.5.tgz#cfde981727a7ab3611a481510b473ae54442b92b" + integrity sha512-jML7s2NAzMWc//QSJ1a3prpk78cOPchGvXJsC3C6R6PSMoooztvRVQEz89gmBTBY1SPMaqo5teB4uNHPdetShQ== + dependencies: + undici-types "~6.19.2" + "@types/node@^10.0.3": version "10.17.60" resolved "https://registry.yarnpkg.com/@types/node/-/node-10.17.60.tgz#35f3d6213daed95da7f0f73e75bcc6980e90597b" @@ -2743,15 +2750,15 @@ typescript "5.5.4" zod "3.22.4" -"@zetachain/localnet@4.0.0-rc1": - version "4.0.0-rc1" - resolved "https://registry.yarnpkg.com/@zetachain/localnet/-/localnet-4.0.0-rc1.tgz#0476fc28f184849ccd170927bc9fe6cd6768ca76" - integrity sha512-IWyw+FcrCQ0wCDKs8D2eEdj+L2aBZne81Y2o3e23l1lZ+v7P95cXEmHvHNILF96awKRWvaadregwk8LWdCJcDA== +"@zetachain/localnet@4.0.0-rc2": + version "4.0.0-rc2" + resolved "https://registry.yarnpkg.com/@zetachain/localnet/-/localnet-4.0.0-rc2.tgz#b5c9ff118c4e7e9ff0c82915292b77659b920e3e" + integrity sha512-Ic2ohIJvFau6stF4HFF5fpI219RxBSago0dKiro9k7tVnOIsi8hnnGZ5snxBaLNCHsiSntZNAAoRfm7crHG3bA== dependencies: "@inquirer/prompts" "^5.5.0" "@uniswap/v2-core" "^1.0.1" "@uniswap/v2-periphery" "^1.1.0-beta.0" - "@zetachain/protocol-contracts" "11.0.0-rc3" + "@zetachain/protocol-contracts" "10.0.0-rc11" ansis "^3.3.2" concurrently "^8.2.2" ethers "^6.13.2" @@ -2765,6 +2772,16 @@ dependencies: dotenv "^16.1.4" +"@zetachain/protocol-contracts@10.0.0-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/protocol-contracts@11.0.0-rc3": version "11.0.0-rc3" resolved "https://registry.yarnpkg.com/@zetachain/protocol-contracts/-/protocol-contracts-11.0.0-rc3.tgz#9b719391d0728fd1b4e046c5f496180a45ecf0d5" @@ -4708,6 +4725,19 @@ ethers@^4.0.40: uuid "2.0.1" xmlhttprequest "1.8.0" +ethers@^6.13.1: + version "6.13.4" + resolved "https://registry.yarnpkg.com/ethers/-/ethers-6.13.4.tgz#bd3e1c3dc1e7dc8ce10f9ffb4ee40967a651b53c" + integrity sha512-21YtnZVg4/zKkCQPjrDj38B1r4nQvTZLopUGMLQ1ePU2zV/joCfDC3t3iKQjWRzjjjbzR+mdAIoikeBRNkdllA== + dependencies: + "@adraffy/ens-normalize" "1.10.1" + "@noble/curves" "1.2.0" + "@noble/hashes" "1.3.2" + "@types/node" "22.7.5" + aes-js "4.0.0-beta.5" + tslib "2.7.0" + ws "8.17.1" + ethers@^6.13.2: version "6.13.2" resolved "https://registry.yarnpkg.com/ethers/-/ethers-6.13.2.tgz#4b67d4b49e69b59893931a032560999e5e4419fe" @@ -7876,6 +7906,11 @@ tslib@2.4.0: resolved "https://registry.yarnpkg.com/tslib/-/tslib-2.4.0.tgz#7cecaa7f073ce680a05847aa77be941098f36dc3" integrity sha512-d6xOpEDfsi2CZVlPQzGeux8XMwLT9hssAsaPYExaQMuYskwb+x1x7J371tWlbBdWHroy99KnVB6qIkUbs5X3UQ== +tslib@2.7.0: + version "2.7.0" + resolved "https://registry.yarnpkg.com/tslib/-/tslib-2.7.0.tgz#d9b40c5c40ab59e8738f297df3087bf1a2690c01" + integrity sha512-gLXCKdN1/j47AiHiOkJN69hJmcbGTHI0ImLmbYLHykhgeN0jVGola9yVjFgzCUklsZQMW55o+dW7IXv3RCXDzA== + tslib@^1.8.1, tslib@^1.9.3: version "1.14.1" resolved "https://registry.yarnpkg.com/tslib/-/tslib-1.14.1.tgz#cf2d38bdc34a134bcaf1091c41f6619e2f672d00"