diff --git a/examples/hello/README.md b/examples/hello/README.md index 62730f9d..52ea5607 100644 --- a/examples/hello/README.md +++ b/examples/hello/README.md @@ -1,15 +1,45 @@ -# ZetaChain Contracts Template +# Hello Example -## Getting Started +``` +yarn deploy +``` + +## EVM + +Successful call: + +``` +npx hardhat echo-call --contract 0xc3e53F4d16Ae77Db1c982e75a937B9f60FE63690 --receiver 0xE6E340D132b5f46d1e472DebcD681B2aBc16e57E --network localhost --types '["string"]' hello +``` + +Failed call: + +``` +npx hardhat echo-call --contract 0xc3e53F4d16Ae77Db1c982e75a937B9f60FE63690 --receiver 0xE6E340D132b5f46d1e472DebcD681B2aBc16e57E --network localhost --types '["uint256"]' 42 +``` -Install dependencies: +Failed call with handled revert: ``` -yarn +npx hardhat echo-call --contract 0xc3e53F4d16Ae77Db1c982e75a937B9f60FE63690 --receiver 0xE6E340D132b5f46d1e472DebcD681B2aBc16e57E --network localhost --revert-address 0xc3e53F4d16Ae77Db1c982e75a937B9f60FE63690 --revert-message 0x --call-on-revert --types '["uint256"]' 42 ``` -## Next Steps +## ZetaChain -Ready to dive in? Follow our [**🚀 smart contract -tutorials**](https://www.zetachain.com/docs/developers/tutorials/intro/) to -start building universal app contracts. +Successful call: + +``` +npx hardhat hello-call --contract 0xE6E340D132b5f46d1e472DebcD681B2aBc16e57E --receiver 0xc3e53F4d16Ae77Db1c982e75a937B9f60FE63690 --zrc20 0x2ca7d64A7EFE2D62A725E2B35Cf7230D6677FfEe --function "hello(string)" --network localhost --types '["string"]' hello +``` + +Failed call: + +``` +npx hardhat hello-call --contract 0xE6E340D132b5f46d1e472DebcD681B2aBc16e57E --receiver 0xc3e53F4d16Ae77Db1c982e75a937B9f60FE63690 --zrc20 0x2ca7d64A7EFE2D62A725E2B35Cf7230D6677FfEe --function "hello(string)" --network localhost --types '["uint256"]' 42 +``` + +Failed call with handled revert: + +``` +npx hardhat hello-call --contract 0xE6E340D132b5f46d1e472DebcD681B2aBc16e57E --receiver 0xc3e53F4d16Ae77Db1c982e75a937B9f60FE63690 --zrc20 0x2ca7d64A7EFE2D62A725E2B35Cf7230D6677FfEe --function "hello(string)" --network localhost --revert-address 0xE6E340D132b5f46d1e472DebcD681B2aBc16e57E --revert-message 0x --call-on-revert --types '["uint256"]' 42 +``` diff --git a/examples/hello/contracts/Echo.sol b/examples/hello/contracts/Echo.sol new file mode 100644 index 00000000..a5271205 --- /dev/null +++ b/examples/hello/contracts/Echo.sol @@ -0,0 +1,36 @@ +// SPDX-License-Identifier: MIT +pragma solidity 0.8.26; + +import {RevertContext} from "@zetachain/protocol-contracts/contracts/Revert.sol"; +import "@zetachain/protocol-contracts/contracts/evm/GatewayEVM.sol"; + +contract Echo { + GatewayEVM public immutable gateway; + + event RevertEvent(string, RevertContext); + event HelloEvent(string, string); + + constructor(address payable gatewayAddress) { + gateway = GatewayEVM(gatewayAddress); + } + + function hello(string memory message) external payable { + emit HelloEvent("Hello on EVM", message); + } + + function onRevert(RevertContext calldata revertContext) external { + emit RevertEvent("Revert on EVM", revertContext); + } + + function call( + address receiver, + bytes calldata message, + RevertOptions memory revertOptions + ) external { + gateway.call(receiver, message, revertOptions); + } + + receive() external payable {} + + fallback() external payable {} +} diff --git a/examples/hello/contracts/Hello.sol b/examples/hello/contracts/Hello.sol index da9310cb..2f6fa158 100644 --- a/examples/hello/contracts/Hello.sol +++ b/examples/hello/contracts/Hello.sol @@ -7,10 +7,11 @@ import "@zetachain/protocol-contracts/contracts/zevm/interfaces/IGatewayZEVM.sol import "@zetachain/protocol-contracts/contracts/zevm/GatewayZEVM.sol"; contract Hello is UniversalContract { - GatewayZEVM public gateway; + GatewayZEVM public immutable gateway; event HelloEvent(string, string); event RevertEvent(string, RevertContext); + error TransferFailed(); constructor(address payable gatewayAddress) { gateway = GatewayZEVM(gatewayAddress); @@ -30,7 +31,7 @@ contract Hello is UniversalContract { emit RevertEvent("Revert on ZetaChain", revertContext); } - function gatewayCall( + function call( bytes memory receiver, address zrc20, bytes calldata message, @@ -38,7 +39,43 @@ contract Hello is UniversalContract { RevertOptions memory revertOptions ) external { (, uint256 gasFee) = IZRC20(zrc20).withdrawGasFeeWithGasLimit(gasLimit); + if (!IZRC20(zrc20).transferFrom(msg.sender, address(this), gasFee)) + revert TransferFailed(); IZRC20(zrc20).approve(address(gateway), gasFee); gateway.call(receiver, zrc20, message, gasLimit, revertOptions); } + + function withdrawAndCall( + bytes memory receiver, + uint256 amount, + address zrc20, + bytes calldata message, + uint256 gasLimit, + RevertOptions memory revertOptions + ) external { + (address gasZRC20, uint256 gasFee) = IZRC20(zrc20) + .withdrawGasFeeWithGasLimit(gasLimit); + uint256 target = zrc20 == gasZRC20 ? amount + gasFee : amount; + if (!IZRC20(zrc20).transferFrom(msg.sender, address(this), target)) + revert TransferFailed(); + IZRC20(zrc20).approve(address(gateway), target); + if (zrc20 != gasZRC20) { + if ( + !IZRC20(gasZRC20).transferFrom( + msg.sender, + address(this), + gasFee + ) + ) revert TransferFailed(); + IZRC20(gasZRC20).approve(address(gateway), gasFee); + } + gateway.withdrawAndCall( + receiver, + amount, + zrc20, + message, + gasLimit, + revertOptions + ); + } } diff --git a/examples/hello/contracts/Revert.sol b/examples/hello/contracts/Revert.sol deleted file mode 100644 index aa0b821e..00000000 --- a/examples/hello/contracts/Revert.sol +++ /dev/null @@ -1,21 +0,0 @@ -// SPDX-License-Identifier: MIT -pragma solidity 0.8.26; - -import {RevertContext} from "@zetachain/protocol-contracts/contracts/Revert.sol"; - -contract Revert { - event RevertEvent(string, RevertContext); - event HelloEvent(string, string); - - function hello(string memory message) external { - emit HelloEvent("Hello on EVM", message); - } - - function onRevert(RevertContext calldata revertContext) external { - emit RevertEvent("Revert on EVM", revertContext); - } - - receive() external payable {} - - fallback() external payable {} -} diff --git a/examples/hello/hardhat.config.ts b/examples/hello/hardhat.config.ts index 7b9bd47f..c41f9d0b 100644 --- a/examples/hello/hardhat.config.ts +++ b/examples/hello/hardhat.config.ts @@ -1,6 +1,7 @@ import "./tasks/deploy"; -import "./tasks/deployRevert"; -import "./tasks/gatewayCall"; +import "./tasks/helloCall"; +import "./tasks/echoCall"; +import "./tasks/helloWithdrawAndCall"; import "@zetachain/localnet/tasks"; import "@nomicfoundation/hardhat-toolbox"; import "@zetachain/toolkit/tasks"; diff --git a/examples/hello/package.json b/examples/hello/package.json index 2a8151fd..658706bf 100644 --- a/examples/hello/package.json +++ b/examples/hello/package.json @@ -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-revert --network localhost" + "deploy": "npx hardhat compile --force && npx hardhat deploy --network localhost && npx hardhat deploy --name Echo --network localhost --gateway 0x9fE46736679d2D9a65F0992F2272dE9f3c7fa6e0" }, "keywords": [], "author": "", @@ -28,8 +28,8 @@ "@types/node": ">=12.0.0", "@typescript-eslint/eslint-plugin": "^5.59.9", "@typescript-eslint/parser": "^5.59.9", - "@zetachain/localnet": "^3.0.4", - "@zetachain/toolkit": "13.0.0-rc2", + "@zetachain/localnet": "^3.3.0", + "@zetachain/toolkit": "13.0.0-rc4", "axios": "^1.3.6", "chai": "^4.2.0", "dotenv": "^16.0.3", diff --git a/examples/hello/tasks/deploy.ts b/examples/hello/tasks/deploy.ts index 647ea6bf..877d2b34 100644 --- a/examples/hello/tasks/deploy.ts +++ b/examples/hello/tasks/deploy.ts @@ -12,7 +12,7 @@ const main = async (args: any, hre: HardhatRuntimeEnvironment) => { } const factory = await hre.ethers.getContractFactory(args.name); - const contract = await (factory as any).deploy(args.gatewayZetaChain); + const contract = await (factory as any).deploy(args.gateway); await contract.deployed(); if (args.json) { @@ -30,7 +30,7 @@ task("deploy", "Deploy the contract", main) .addFlag("json", "Output in JSON") .addOptionalParam("name", "Contract to deploy", "Hello") .addOptionalParam( - "gatewayZetaChain", - "Gateway address", + "gateway", + "Gateway address (default: ZetaChain Gateway)", "0xA51c1fc2f0D1a1b8494Ed1FE312d7C3a78Ed91C0" ); diff --git a/examples/hello/tasks/deployRevert.ts b/examples/hello/tasks/deployRevert.ts deleted file mode 100644 index 080808c7..00000000 --- a/examples/hello/tasks/deployRevert.ts +++ /dev/null @@ -1,31 +0,0 @@ -import { task, types } from "hardhat/config"; -import { HardhatRuntimeEnvironment } from "hardhat/types"; - -const main = async (args: any, hre: HardhatRuntimeEnvironment) => { - const network = hre.network.name; - - const [signer] = await hre.ethers.getSigners(); - if (signer === undefined) { - throw new Error( - `Wallet not found. Please, run "npx hardhat account --save" or set PRIVATE_KEY env variable (for example, in a .env file)` - ); - } - - const factory = await hre.ethers.getContractFactory(args.name); - const contract = await (factory as any).deploy(); - await contract.deployed(); - - if (args.json) { - console.log(JSON.stringify(contract)); - } else { - console.log(`🔑 Using account: ${signer.address} - -🚀 Successfully deployed "${args.name}" contract on ${network}. -📜 Contract address: ${contract.address} -`); - } -}; - -task("deploy-revert", "Deploy the contract", main) - .addFlag("json", "Output in JSON") - .addOptionalParam("name", "Contract to deploy", "Revert"); diff --git a/examples/hello/tasks/echoCall.ts b/examples/hello/tasks/echoCall.ts new file mode 100644 index 00000000..ee8c46f0 --- /dev/null +++ b/examples/hello/tasks/echoCall.ts @@ -0,0 +1,99 @@ +import { task, types } from "hardhat/config"; +import type { HardhatRuntimeEnvironment } from "hardhat/types"; + +const main = async (args: any, hre: HardhatRuntimeEnvironment) => { + const { ethers } = hre; + const [signer] = await ethers.getSigners(); + + const txOptions = { + gasPrice: args.txOptionsGasPrice, + gasLimit: args.txOptionsGasLimit, + }; + + const revertOptions = { + abortAddress: "0x0000000000000000000000000000000000000000", // not used + callOnRevert: args.callOnRevert, + onRevertGasLimit: args.onRevertGasLimit, + revertAddress: args.revertAddress, + revertMessage: ethers.utils.hexlify( + ethers.utils.toUtf8Bytes(args.revertMessage) + ), + }; + + const types = JSON.parse(args.types); + + if (types.length !== args.values.length) { + throw new Error( + `The number of types (${types.length}) does not match the number of values (${args.values.length}).` + ); + } + + const valuesArray = args.values.map((value: any, index: number) => { + const type = types[index]; + + if (type === "bool") { + try { + return JSON.parse(value.toLowerCase()); + } catch (e) { + throw new Error(`Invalid boolean value: ${value}`); + } + } else if (type.startsWith("uint") || type.startsWith("int")) { + return ethers.BigNumber.from(value); + } else { + return value; + } + }); + const encodedParameters = ethers.utils.defaultAbiCoder.encode( + types, + valuesArray + ); + + const factory = (await hre.ethers.getContractFactory(args.name)) as any; + const contract = factory.attach(args.contract).connect(signer); + + const tx = await contract.call( + args.receiver, + encodedParameters, + revertOptions, + txOptions + ); + + console.log(`Transaction hash: ${tx.hash}`); + await tx.wait(); + console.log("gatewayCall executed successfully"); +}; + +task("echo-call", "Calls the gateway on a contract on EVM", main) + .addParam("contract", "The address of the deployed contract") + .addOptionalParam( + "txOptionsGasPrice", + "The gas price for the transaction", + 10000000000, + types.int + ) + .addOptionalParam( + "txOptionsGasLimit", + "The gas limit for the transaction", + 7000000, + types.int + ) + .addFlag("callOnRevert", "Whether to call on revert") + .addOptionalParam( + "revertAddress", + "Revert address", + "0x0000000000000000000000000000000000000000" + ) + .addOptionalParam("revertMessage", "Revert message", "0x") + .addParam( + "receiver", + "The address of the receiver contract on a connected chain" + ) + .addOptionalParam( + "onRevertGasLimit", + "The gas limit for the revert transaction", + 7000000, + types.int + ) + .addParam("name", "The name of the contract", "Echo") + .addParam("types", `The types of the parameters (example: '["string"]')`) + .addVariadicPositionalParam("values", "The values of the parameters"); diff --git a/examples/hello/tasks/gatewayCall.ts b/examples/hello/tasks/helloCall.ts similarity index 84% rename from examples/hello/tasks/gatewayCall.ts rename to examples/hello/tasks/helloCall.ts index 35a34acd..ef977e98 100644 --- a/examples/hello/tasks/gatewayCall.ts +++ b/examples/hello/tasks/helloCall.ts @@ -25,6 +25,12 @@ const main = async (args: any, hre: HardhatRuntimeEnvironment) => { const types = JSON.parse(args.types); + if (types.length !== args.values.length) { + throw new Error( + `The number of types (${types.length}) does not match the number of values (${args.values.length}).` + ); + } + const valuesArray = args.values.map((value: any, index: number) => { const type = types[index]; @@ -49,21 +55,17 @@ const main = async (args: any, hre: HardhatRuntimeEnvironment) => { ethers.utils.concat([functionSignature, encodedParameters]) ); - const gasLimit = hre.ethers.BigNumber.from(args.gasLimit); + const gasLimit = hre.ethers.BigNumber.from(args.txOptionsGasLimit); const zrc20 = new ethers.Contract(args.zrc20, ZRC20ABI.abi, signer); const [, gasFee] = await zrc20.withdrawGasFeeWithGasLimit(gasLimit); - const zrc20TransferTx = await zrc20.transfer( - args.contract, - gasFee, - txOptions - ); + const zrc20TransferTx = await zrc20.approve(args.contract, gasFee, txOptions); await zrc20TransferTx.wait(); - const factory = await hre.ethers.getContractFactory("Hello"); + const factory = (await hre.ethers.getContractFactory(args.name)) as any; const contract = factory.attach(args.contract); - const tx = await contract.gatewayCall( + const tx = await contract.call( ethers.utils.hexlify(args.receiver), args.zrc20, message, @@ -78,18 +80,12 @@ const main = async (args: any, hre: HardhatRuntimeEnvironment) => { }; task( - "gateway-call", - "Calls the gatewayCall function on the Hello contract", + "hello-call", + "Calls the gatewayCall function on a contract on ZetaChain", main ) .addParam("contract", "The address of the deployed Hello contract") .addParam("zrc20", "The address of ZRC-20 to pay fees") - .addOptionalParam( - "gasLimit", - "Gas limit for for a cross-chain call", - 7000000, - types.int - ) .addOptionalParam( "txOptionsGasPrice", "The gas price for the transaction", @@ -120,7 +116,6 @@ task( types.int ) .addParam("function", `Function to call (example: "hello(string)")`) + .addParam("name", "The name of the contract", "Hello") .addParam("types", `The types of the parameters (example: '["string"]')`) .addVariadicPositionalParam("values", "The values of the parameters"); - -module.exports = {}; diff --git a/examples/hello/tasks/helloWithdrawAndCall.ts b/examples/hello/tasks/helloWithdrawAndCall.ts new file mode 100644 index 00000000..43818bd5 --- /dev/null +++ b/examples/hello/tasks/helloWithdrawAndCall.ts @@ -0,0 +1,139 @@ +import { task, types } from "hardhat/config"; +import type { HardhatRuntimeEnvironment } from "hardhat/types"; +import ZRC20ABI from "@zetachain/protocol-contracts/abi/ZRC20.sol/ZRC20.json"; + +const main = async (args: any, hre: HardhatRuntimeEnvironment) => { + const { ethers } = hre; + const [signer] = await ethers.getSigners(); + + const txOptions = { + gasPrice: args.txOptionsGasPrice, + gasLimit: args.txOptionsGasLimit, + }; + + const revertOptions = { + abortAddress: "0x0000000000000000000000000000000000000000", // not used + callOnRevert: args.callOnRevert, + onRevertGasLimit: args.onRevertGasLimit, + revertAddress: args.revertAddress, + revertMessage: ethers.utils.hexlify( + ethers.utils.toUtf8Bytes(args.revertMessage) + ), + }; + + const functionSignature = ethers.utils.id(args.function).slice(0, 10); + + const types = JSON.parse(args.types); + + if (types.length !== args.values.length) { + throw new Error( + `The number of types (${types.length}) does not match the number of values (${args.values.length}).` + ); + } + + const valuesArray = args.values.map((value: any, index: number) => { + const type = types[index]; + + if (type === "bool") { + try { + return JSON.parse(value.toLowerCase()); + } catch (e) { + throw new Error(`Invalid boolean value: ${value}`); + } + } else if (type.startsWith("uint") || type.startsWith("int")) { + return ethers.BigNumber.from(value); + } else { + return value; + } + }); + const encodedParameters = ethers.utils.defaultAbiCoder.encode( + types, + valuesArray + ); + + const message = ethers.utils.hexlify( + ethers.utils.concat([functionSignature, encodedParameters]) + ); + + const gasLimit = hre.ethers.BigNumber.from(args.txOptionsGasLimit); + + const amount = hre.ethers.utils.parseUnits(args.amount, 18); + + const zrc20 = new ethers.Contract(args.zrc20, ZRC20ABI.abi, signer); + const [gasZRC20, gasFee] = await zrc20.withdrawGasFeeWithGasLimit(gasLimit); + const gasZRC20Contract = new ethers.Contract(gasZRC20, ZRC20ABI.abi, signer); + const gasFeeApprove = await gasZRC20Contract.approve( + args.contract, + gasZRC20 == args.zrc20 ? gasFee.add(amount) : gasFee, + txOptions + ); + await gasFeeApprove.wait(); + + if (gasZRC20 !== args.zrc20) { + const targetTokenApprove = await zrc20.approve( + args.contract, + gasFee.add(amount), + txOptions + ); + await targetTokenApprove.wait(); + } + + const factory = (await hre.ethers.getContractFactory(args.name)) as any; + const contract = factory.attach(args.contract); + + const tx = await contract.withdrawAndCall( + ethers.utils.hexlify(args.receiver), + amount, + args.zrc20, + message, + gasLimit, + revertOptions, + txOptions + ); + + console.log(`Transaction hash: ${tx.hash}`); + await tx.wait(); + console.log("gatewayCall executed successfully"); +}; + +task( + "hello-withdraw-and-call", + "Calls the gatewayWithdrawAndCall function on a contract on ZetaChain", + main +) + .addParam("contract", "The address of the deployed Hello contract") + .addParam("zrc20", "The address of ZRC-20 to pay fees") + .addOptionalParam( + "txOptionsGasPrice", + "The gas price for the transaction", + 10000000000, + types.int + ) + .addOptionalParam( + "txOptionsGasLimit", + "The gas limit for the transaction", + 7000000, + types.int + ) + .addFlag("callOnRevert", "Whether to call on revert") + .addOptionalParam( + "revertAddress", + "Revert address", + "0x0000000000000000000000000000000000000000" + ) + .addOptionalParam("revertMessage", "Revert message", "0x") + .addParam( + "receiver", + "The address of the receiver contract on a connected chain" + ) + .addOptionalParam( + "onRevertGasLimit", + "The gas limit for the revert transaction", + 7000000, + types.int + ) + .addParam("function", `Function to call (example: "hello(string)")`) + .addParam("name", "The name of the contract", "Hello") + .addParam("amount", "Amount of ZRC-20 to withdraw") + .addParam("types", `The types of the parameters (example: '["string"]')`) + .addVariadicPositionalParam("values", "The values of the parameters"); diff --git a/examples/hello/yarn.lock b/examples/hello/yarn.lock index 246fb4e9..94afc56b 100644 --- a/examples/hello/yarn.lock +++ b/examples/hello/yarn.lock @@ -1669,11 +1669,6 @@ resolved "https://registry.yarnpkg.com/@openzeppelin/contracts-upgradeable/-/contracts-upgradeable-5.0.2.tgz#3e5321a2ecdd0b206064356798c21225b6ec7105" integrity sha512-0MmkHSHiW2NRFiT9/r5Lu4eJq5UJ4/tzlOgYXNAIj/ONkQTVnz22pLxDvp4C4uZ9he7ZFvGn3Driptn1/iU7tQ== -"@openzeppelin/contracts@^4.9.6": - version "4.9.6" - resolved "https://registry.yarnpkg.com/@openzeppelin/contracts/-/contracts-4.9.6.tgz#2a880a24eb19b4f8b25adc2a5095f2aa27f39677" - integrity sha512-xSmezSupL+y9VkHZJGDoCBpmnB2ogM13ccaYDWqJTfS3dbuHkgjuwDFUmaFauBCboQMGB/S5UqUl2y54X99BmA== - "@openzeppelin/contracts@^5.0.2": version "5.0.2" resolved "https://registry.yarnpkg.com/@openzeppelin/contracts/-/contracts-5.0.2.tgz#b1d03075e49290d06570b2fd42154d76c2a5d210" @@ -2407,10 +2402,10 @@ typescript "5.5.4" zod "3.22.4" -"@zetachain/localnet@^3.0.4": - version "3.0.4" - resolved "https://registry.yarnpkg.com/@zetachain/localnet/-/localnet-3.0.4.tgz#ff457f732f9ea52f491c16dc4cc5ac77d9561a9b" - integrity sha512-biZhhonyUrtXSZCPzunT6x6pKK3GANtFtwkXHoEnDfQsjICRgfBMMrC76IsfM8XgEdRF15dp845QeDHMa19GkA== +"@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== dependencies: "@inquirer/prompts" "^5.5.0" "@uniswap/v2-core" "^1.0.1" @@ -2443,16 +2438,17 @@ resolved "https://registry.yarnpkg.com/@zetachain/protocol-contracts/-/protocol-contracts-9.0.0.tgz#c20ad5da43f6f3676f31556b303d1cb4ea17357e" integrity sha512-L4A8bddlyhjaBAsIv/x1Bvxc38RJz8U8rbbBtxK5oVyOAd5Zz04ZiT3HqzO4FuKq6RGGM1uiA8jvUfmRkKchXw== -"@zetachain/toolkit@13.0.0-rc2": - version "13.0.0-rc2" - resolved "https://registry.yarnpkg.com/@zetachain/toolkit/-/toolkit-13.0.0-rc2.tgz#8b85ecea407c572fa9f7c693367266ecf1a55540" - integrity sha512-0Nc0qjAfIZ0r7BjgAM2AcOxYaMtDLAxpU5Si6f814m/SPhbPYP/V91HgARj1Ia1IvH9g0NyqvQLnKlBrCh9r9w== +"@zetachain/toolkit@13.0.0-rc4": + version "13.0.0-rc4" + resolved "https://registry.yarnpkg.com/@zetachain/toolkit/-/toolkit-13.0.0-rc4.tgz#e137fc16043f1416469f709c48808cfa301d9299" + integrity sha512-4z4MKbQKjRIeNruUyDBjZDRO5oTLa1w/7wVn+PfMsXn++mFFGkiawkLcitnkH9dadBJiERzmo89MRJxsLQ3U6w== dependencies: "@coral-xyz/anchor" "^0.30.1" "@inquirer/prompts" "^2.1.1" "@inquirer/select" "1.1.3" "@nomiclabs/hardhat-ethers" "^2.2.3" - "@openzeppelin/contracts" "^4.9.6" + "@openzeppelin/contracts" "^5.0.2" + "@openzeppelin/contracts-upgradeable" "^5.0.2" "@solana/web3.js" "^1.95.3" "@uniswap/v2-periphery" "^1.1.0-beta.0" "@zetachain/faucet-cli" "^4.1.1" diff --git a/examples/swap/package.json b/examples/swap/package.json index 2d5c7eae..d3398027 100644 --- a/examples/swap/package.json +++ b/examples/swap/package.json @@ -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.0.4", + "@zetachain/localnet": "^3.2.0", "axios": "^1.3.6", "chai": "^4.2.0", "dotenv": "^16.0.3", diff --git a/examples/swap/tasks/deploy.ts b/examples/swap/tasks/deploy.ts index e5858fb9..c8c98ba2 100644 --- a/examples/swap/tasks/deploy.ts +++ b/examples/swap/tasks/deploy.ts @@ -14,7 +14,7 @@ const main = async (args: any, hre: HardhatRuntimeEnvironment) => { const factory = await hre.ethers.getContractFactory(args.name); const contract = await (factory as any).deploy( args.systemContract, - args.gatewayZetaChain + args.gateway ); await contract.deployed(); @@ -38,7 +38,7 @@ task("deploy", "Deploy the contract", main) "0x610178dA211FEF7D417bC0e6FeD39F05609AD788" ) .addOptionalParam( - "gatewayZetaChain", - "Gateway address", + "gateway", + "Gateway address (default: ZetaChain Gateway)", "0xA51c1fc2f0D1a1b8494Ed1FE312d7C3a78Ed91C0" ); diff --git a/examples/swap/yarn.lock b/examples/swap/yarn.lock index a991d4d3..7f6c175e 100644 --- a/examples/swap/yarn.lock +++ b/examples/swap/yarn.lock @@ -2140,10 +2140,10 @@ typescript "5.5.4" zod "3.22.4" -"@zetachain/localnet@^3.0.4": - version "3.0.4" - resolved "https://registry.yarnpkg.com/@zetachain/localnet/-/localnet-3.0.4.tgz#ff457f732f9ea52f491c16dc4cc5ac77d9561a9b" - integrity sha512-biZhhonyUrtXSZCPzunT6x6pKK3GANtFtwkXHoEnDfQsjICRgfBMMrC76IsfM8XgEdRF15dp845QeDHMa19GkA== +"@zetachain/localnet@^3.2.0": + version "3.2.0" + resolved "https://registry.yarnpkg.com/@zetachain/localnet/-/localnet-3.2.0.tgz#66c09120397dbaf4f0c461ba6671f249c3379f6b" + integrity sha512-oqyxrxuSraj1A6/CAkeEBa9VfIvp+QxBIivTu/L9jK1zUa5MQw+rLqTL/rD1LR/k9om6x/zJHzhzZKU9Vpk3Bw== dependencies: "@inquirer/prompts" "^5.5.0" "@uniswap/v2-core" "^1.0.1"