Skip to content

Commit 63b4a4b

Browse files
committed
wip
1 parent c0a77f4 commit 63b4a4b

File tree

8 files changed

+23
-127
lines changed

8 files changed

+23
-127
lines changed

examples/call/hardhat.config.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,15 @@ import "./tasks/universalWithdrawAndCall";
88
import "@zetachain/localnet/tasks";
99
import "@nomicfoundation/hardhat-toolbox";
1010
import "@zetachain/toolkit/tasks";
11+
import * as dotenv from "dotenv";
1112

12-
import { getHardhatConfigNetworks } from "@zetachain/networks";
13+
import { getHardhatConfig } from "@zetachain/toolkit/client";
1314
import { HardhatUserConfig } from "hardhat/config";
1415

16+
dotenv.config();
17+
1518
const config: HardhatUserConfig = {
16-
networks: {
17-
...getHardhatConfigNetworks(),
18-
},
19-
solidity: "0.8.26",
19+
...getHardhatConfig({ accounts: [process.env.PRIVATE_KEY] }),
2020
};
2121

2222
export default config;

examples/call/scripts/localnet.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
#!/bin/bash
22

33
set -e
4+
set -x
5+
set -o pipefail
46

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

examples/call/tasks/connectedCall.ts

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,6 @@ const main = async (args: any, hre: HardhatRuntimeEnvironment) => {
55
const { ethers } = hre;
66
const [signer] = await ethers.getSigners();
77

8-
const txOptions = {
9-
gasPrice: args.txOptionsGasPrice,
10-
gasLimit: args.txOptionsGasLimit,
11-
};
12-
138
const revertOptions = {
149
abortAddress: "0x0000000000000000000000000000000000000000", // not used
1510
callOnRevert: args.callOnRevert,
@@ -54,8 +49,7 @@ const main = async (args: any, hre: HardhatRuntimeEnvironment) => {
5449
const tx = await contract.call(
5550
args.receiver,
5651
encodedParameters,
57-
revertOptions,
58-
txOptions
52+
revertOptions
5953
);
6054

6155
await tx.wait();
@@ -68,18 +62,6 @@ task(
6862
main
6963
)
7064
.addParam("contract", "The address of the deployed contract")
71-
.addOptionalParam(
72-
"txOptionsGasPrice",
73-
"The gas price for the transaction",
74-
20000000000,
75-
types.int
76-
)
77-
.addOptionalParam(
78-
"txOptionsGasLimit",
79-
"The gas limit for the transaction",
80-
500000,
81-
types.int
82-
)
8365
.addFlag("callOnRevert", "Whether to call on revert")
8466
.addOptionalParam(
8567
"revertAddress",

examples/call/tasks/connectedDeposit.ts

Lines changed: 2 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,6 @@ const main = async (args: any, hre: HardhatRuntimeEnvironment) => {
66
const { ethers } = hre;
77
const [signer] = await ethers.getSigners();
88

9-
const txOptions = {
10-
gasPrice: args.txOptionsGasPrice,
11-
gasLimit: args.txOptionsGasLimit,
12-
};
13-
149
const revertOptions = {
1510
abortAddress: "0x0000000000000000000000000000000000000000", // not used
1611
callOnRevert: args.callOnRevert,
@@ -43,16 +38,12 @@ const main = async (args: any, hre: HardhatRuntimeEnvironment) => {
4338
args.receiver,
4439
value,
4540
args.erc20,
46-
revertOptions,
47-
txOptions
41+
revertOptions
4842
);
4943
} else {
5044
const value = hre.ethers.utils.parseEther(args.amount);
5145
const method = "deposit(address,(address,bool,address,bytes,uint256))";
52-
tx = await contract[method](args.receiver, revertOptions, {
53-
...txOptions,
54-
value,
55-
});
46+
tx = await contract[method](args.receiver, revertOptions, { value });
5647
}
5748

5849
await tx.wait();
@@ -61,18 +52,6 @@ const main = async (args: any, hre: HardhatRuntimeEnvironment) => {
6152

6253
task("connected-deposit", "Deposit tokens to ZetaChain", main)
6354
.addParam("contract", "The address of the deployed contract")
64-
.addOptionalParam(
65-
"txOptionsGasPrice",
66-
"The gas price for the transaction",
67-
20000000000,
68-
types.int
69-
)
70-
.addOptionalParam(
71-
"txOptionsGasLimit",
72-
"The gas limit for the transaction",
73-
500000,
74-
types.int
75-
)
7655
.addFlag("callOnRevert", "Whether to call on revert")
7756
.addOptionalParam(
7857
"revertAddress",

examples/call/tasks/connectedDepositAndCall.ts

Lines changed: 2 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,6 @@ const main = async (args: any, hre: HardhatRuntimeEnvironment) => {
66
const { ethers } = hre;
77
const [signer] = await ethers.getSigners();
88

9-
const txOptions = {
10-
gasPrice: args.txOptionsGasPrice,
11-
gasLimit: args.txOptionsGasLimit,
12-
};
13-
149
const revertOptions = {
1510
abortAddress: "0x0000000000000000000000000000000000000000", // not used
1611
callOnRevert: args.callOnRevert,
@@ -72,8 +67,7 @@ const main = async (args: any, hre: HardhatRuntimeEnvironment) => {
7267
value,
7368
args.erc20,
7469
encodedParameters,
75-
revertOptions,
76-
txOptions
70+
revertOptions
7771
);
7872
} else {
7973
const value = hre.ethers.utils.parseEther(args.amount);
@@ -83,10 +77,7 @@ const main = async (args: any, hre: HardhatRuntimeEnvironment) => {
8377
args.receiver,
8478
encodedParameters,
8579
revertOptions,
86-
{
87-
...txOptions,
88-
value,
89-
}
80+
{ value }
9081
);
9182
}
9283

@@ -100,18 +91,6 @@ task(
10091
main
10192
)
10293
.addParam("contract", "The address of the deployed contract")
103-
.addOptionalParam(
104-
"txOptionsGasPrice",
105-
"The gas price for the transaction",
106-
20000000000,
107-
types.int
108-
)
109-
.addOptionalParam(
110-
"txOptionsGasLimit",
111-
"The gas limit for the transaction",
112-
500000,
113-
types.int
114-
)
11594
.addFlag("callOnRevert", "Whether to call on revert")
11695
.addOptionalParam(
11796
"revertAddress",

examples/call/tasks/universalCall.ts

Lines changed: 4 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,6 @@ const main = async (args: any, hre: HardhatRuntimeEnvironment) => {
66
const { ethers } = hre;
77
const [signer] = await ethers.getSigners();
88

9-
const txOptions = {
10-
gasPrice: args.txOptionsGasPrice,
11-
gasLimit: args.txOptionsGasLimit,
12-
};
13-
149
const callOptions = {
1510
isArbitraryCall: args.callOptionsIsArbitraryCall,
1611
gasLimit: args.callOptionsGasLimit,
@@ -60,10 +55,10 @@ const main = async (args: any, hre: HardhatRuntimeEnvironment) => {
6055
ethers.utils.concat([functionSignature, encodedParameters])
6156
);
6257

63-
const gasLimit = hre.ethers.BigNumber.from(args.txOptionsGasLimit);
58+
const gasLimit = hre.ethers.BigNumber.from(callOptions.gasLimit);
6459
const zrc20 = new ethers.Contract(args.zrc20, ZRC20ABI.abi, signer);
6560
const [, gasFee] = await zrc20.withdrawGasFeeWithGasLimit(gasLimit);
66-
const zrc20TransferTx = await zrc20.approve(args.contract, gasFee, txOptions);
61+
const zrc20TransferTx = await zrc20.approve(args.contract, gasFee);
6762

6863
await zrc20TransferTx.wait();
6964

@@ -75,8 +70,7 @@ const main = async (args: any, hre: HardhatRuntimeEnvironment) => {
7570
args.zrc20,
7671
message,
7772
callOptions,
78-
revertOptions,
79-
txOptions
73+
revertOptions
8074
);
8175

8276
await tx.wait();
@@ -90,18 +84,6 @@ task(
9084
)
9185
.addParam("contract", "The address of the deployed universal contract")
9286
.addParam("zrc20", "The address of ZRC-20 to pay fees")
93-
.addOptionalParam(
94-
"txOptionsGasPrice",
95-
"The gas price for the transaction",
96-
20000000000,
97-
types.int
98-
)
99-
.addOptionalParam(
100-
"txOptionsGasLimit",
101-
"The gas limit for the transaction",
102-
500000,
103-
types.int
104-
)
10587
.addFlag("callOnRevert", "Whether to call on revert")
10688
.addOptionalParam(
10789
"revertAddress",
@@ -116,7 +98,7 @@ task(
11698
.addOptionalParam(
11799
"onRevertGasLimit",
118100
"The gas limit for the revert transaction",
119-
50000,
101+
500000,
120102
types.int
121103
)
122104
.addFlag("callOptionsIsArbitraryCall", "Call any function")

examples/call/tasks/universalWithdraw.ts

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,6 @@ const main = async (args: any, hre: HardhatRuntimeEnvironment) => {
66
const { ethers } = hre;
77
const [signer] = await ethers.getSigners();
88

9-
const txOptions = {
10-
gasPrice: args.txOptionsGasPrice,
11-
gasLimit: args.txOptionsGasLimit,
12-
};
13-
149
const revertOptions = {
1510
abortAddress: "0x0000000000000000000000000000000000000000", // not used
1611
callOnRevert: args.callOnRevert,
@@ -28,16 +23,14 @@ const main = async (args: any, hre: HardhatRuntimeEnvironment) => {
2823
const gasZRC20Contract = new ethers.Contract(gasZRC20, ZRC20ABI.abi, signer);
2924
const gasFeeApprove = await gasZRC20Contract.approve(
3025
args.contract,
31-
gasZRC20 == args.zrc20 ? gasFee.add(amount) : gasFee,
32-
txOptions
26+
gasZRC20 == args.zrc20 ? gasFee.add(amount) : gasFee
3327
);
3428
await gasFeeApprove.wait();
3529

3630
if (gasZRC20 !== args.zrc20) {
3731
const targetTokenApprove = await zrc20.approve(
3832
args.contract,
39-
gasFee.add(amount),
40-
txOptions
33+
gasFee.add(amount)
4134
);
4235
await targetTokenApprove.wait();
4336
}
@@ -49,8 +42,7 @@ const main = async (args: any, hre: HardhatRuntimeEnvironment) => {
4942
ethers.utils.hexlify(args.receiver),
5043
amount,
5144
args.zrc20,
52-
revertOptions,
53-
txOptions
45+
revertOptions
5446
);
5547

5648
await tx.wait();

examples/call/tasks/universalWithdrawAndCall.ts

Lines changed: 4 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,6 @@ const main = async (args: any, hre: HardhatRuntimeEnvironment) => {
1414
throw new Error("Function is not allowed for non-arbitrary calls");
1515
}
1616

17-
const txOptions = {
18-
gasPrice: args.txOptionsGasPrice,
19-
gasLimit: args.txOptionsGasLimit,
20-
};
21-
2217
const callOptions = {
2318
isArbitraryCall: args.callOptionsIsArbitraryCall,
2419
gasLimit: args.callOptionsGasLimit,
@@ -73,7 +68,7 @@ const main = async (args: any, hre: HardhatRuntimeEnvironment) => {
7368
message = encodedParameters;
7469
}
7570

76-
const gasLimit = hre.ethers.BigNumber.from(args.txOptionsGasLimit);
71+
const gasLimit = hre.ethers.BigNumber.from(callOptions.gasLimit);
7772

7873
const amount = hre.ethers.utils.parseUnits(args.amount, 18);
7974

@@ -82,16 +77,14 @@ const main = async (args: any, hre: HardhatRuntimeEnvironment) => {
8277
const gasZRC20Contract = new ethers.Contract(gasZRC20, ZRC20ABI.abi, signer);
8378
const gasFeeApprove = await gasZRC20Contract.approve(
8479
args.contract,
85-
gasZRC20 == args.zrc20 ? gasFee.add(amount) : gasFee,
86-
txOptions
80+
gasZRC20 == args.zrc20 ? gasFee.add(amount) : gasFee
8781
);
8882
await gasFeeApprove.wait();
8983

9084
if (gasZRC20 !== args.zrc20) {
9185
const targetTokenApprove = await zrc20.approve(
9286
args.contract,
93-
gasFee.add(amount),
94-
txOptions
87+
gasFee.add(amount)
9588
);
9689
await targetTokenApprove.wait();
9790
}
@@ -105,8 +98,7 @@ const main = async (args: any, hre: HardhatRuntimeEnvironment) => {
10598
args.zrc20,
10699
message,
107100
callOptions,
108-
revertOptions,
109-
txOptions
101+
revertOptions
110102
);
111103

112104
await tx.wait();
@@ -120,18 +112,6 @@ task(
120112
)
121113
.addParam("contract", "The address of the deployed Hello contract")
122114
.addParam("zrc20", "The address of ZRC-20 to pay fees")
123-
.addOptionalParam(
124-
"txOptionsGasPrice",
125-
"The gas price for the transaction",
126-
20000000000,
127-
types.int
128-
)
129-
.addOptionalParam(
130-
"txOptionsGasLimit",
131-
"The gas limit for the transaction",
132-
500000,
133-
types.int
134-
)
135115
.addFlag("callOnRevert", "Whether to call on revert")
136116
.addOptionalParam(
137117
"revertAddress",

0 commit comments

Comments
 (0)