-
Notifications
You must be signed in to change notification settings - Fork 49
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
90 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
import { task, types } from "hardhat/config"; | ||
import type { HardhatRuntimeEnvironment } from "hardhat/types"; | ||
|
||
import { ZetaChainClient } from "@zetachain/toolkit/client"; | ||
|
||
export const evmDepositAndCall = async ( | ||
args: any, | ||
hre: HardhatRuntimeEnvironment | ||
) => { | ||
try { | ||
const [signer] = await hre.ethers.getSigners(); | ||
const client = new ZetaChainClient({ network: "testnet", signer }); | ||
const tx = await client.evmDepositAndCall({ | ||
amount: args.amount, | ||
erc20: args.erc20, | ||
gatewayEvm: args.gatewayEvm, | ||
receiver: args.receiver, | ||
revertOptions: { | ||
callOnRevert: args.callOnRevert, | ||
onRevertGasLimit: args.onRevertGasLimit, | ||
revertAddress: args.revertAddress, | ||
revertMessage: args.revertMessage, | ||
}, | ||
txOptions: { | ||
gasLimit: args.gasLimit, | ||
gasPrice: args.gasPrice, | ||
}, | ||
types: ["address", "bytes", "bool"], | ||
values: [args.target, args.recipient, JSON.stringify(args.withdraw)], | ||
}); | ||
if (tx) { | ||
const receipt = await tx.wait(); | ||
console.log("Transaction hash:", receipt.transactionHash); | ||
} | ||
} catch (e) { | ||
console.error("Transaction error:", e); | ||
} | ||
}; | ||
|
||
task("swap-from-evm", "Swap tokens from EVM", evmDepositAndCall) | ||
.addParam("receiver", "Receiver address on ZetaChain") | ||
.addOptionalParam( | ||
"gatewayEvm", | ||
"contract address of gateway on EVM", | ||
"0x9fE46736679d2D9a65F0992F2272dE9f3c7fa6e0" | ||
) | ||
.addFlag("callOnRevert", "Whether to call on revert") | ||
.addOptionalParam( | ||
"revertAddress", | ||
"Revert address", | ||
"0x0000000000000000000000000000000000000000", | ||
types.string | ||
) | ||
.addOptionalParam( | ||
"gasPrice", | ||
"The gas price for the transaction", | ||
50000000000, | ||
types.int | ||
) | ||
.addOptionalParam( | ||
"gasLimit", | ||
"The gas limit for the transaction", | ||
7000000, | ||
types.int | ||
) | ||
.addOptionalParam( | ||
"onRevertGasLimit", | ||
"The gas limit for the revert transaction", | ||
7000000, | ||
types.int | ||
) | ||
.addOptionalParam("revertMessage", "Revert message", "0x") | ||
.addParam("amount", "amount of ETH to send with the transaction") | ||
.addOptionalParam("erc20", "ERC-20 token address") | ||
.addParam("target", "ZRC-20 address of the token to swap for") | ||
.addParam("recipient", "Recipient address") | ||
.addFlag("withdraw", "Withdraw to destination or keep token on ZetaChain"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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.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" | ||
|
@@ -2176,10 +2176,10 @@ | |
resolved "https://registry.yarnpkg.com/@zetachain/protocol-contracts/-/protocol-contracts-9.0.0.tgz#c20ad5da43f6f3676f31556b303d1cb4ea17357e" | ||
integrity sha512-L4A8bddlyhjaBAsIv/x1Bvxc38RJz8U8rbbBtxK5oVyOAd5Zz04ZiT3HqzO4FuKq6RGGM1uiA8jvUfmRkKchXw== | ||
|
||
"@zetachain/[email protected]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== | ||
"@zetachain/[email protected]rc5": | ||
version "13.0.0-rc5" | ||
resolved "https://registry.yarnpkg.com/@zetachain/toolkit/-/toolkit-13.0.0-rc5.tgz#56b2603c8367819a5265fcc7354e93ffdfbc3ea3" | ||
integrity sha512-/97eSf3ALdrLHc9vyaO/xcjuAI9wa4JUNkB8NtnNT6dMeSBPI2ME9lmG+Qk2YDoZkrYlzmEzeru+zcZI9v7cog== | ||
dependencies: | ||
"@coral-xyz/anchor" "^0.30.1" | ||
"@inquirer/prompts" "^2.1.1" | ||
|