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

fix: use callOptions in call/withdrawAndCall #195

Merged
merged 6 commits into from
Nov 29, 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
54 changes: 0 additions & 54 deletions contracts/TestSystemContract.sol

This file was deleted.

8 changes: 0 additions & 8 deletions contracts/ZetaConnectorMock.sol

This file was deleted.

112 changes: 0 additions & 112 deletions contracts/shared/MockSystemContract.sol

This file was deleted.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@
"@uniswap/v2-periphery": "^1.1.0-beta.0",
"@zetachain/faucet-cli": "^4.1.1",
"@zetachain/networks": "10.0.0",
"@zetachain/protocol-contracts": "9.0.0",
"@zetachain/protocol-contracts": "11.0.0-rc3",
"axios": "^1.4.0",
"bech32": "^2.0.0",
"bip39": "^3.1.0",
Expand Down
1 change: 0 additions & 1 deletion packages/client/src/abi/GatewayEVM.sol/GatewayEVM.json

This file was deleted.

1 change: 0 additions & 1 deletion packages/client/src/abi/GatewayZEVM.sol/GatewayZEVM.json

This file was deleted.

1 change: 0 additions & 1 deletion packages/client/src/abi/ZRC20.sol/ZRC20.json

This file was deleted.

1 change: 0 additions & 1 deletion packages/client/src/abi/ZRC20.sol/ZRC20Errors.json

This file was deleted.

4 changes: 0 additions & 4 deletions packages/client/src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import type { Signer, Wallet } from "ethers";
import merge from "lodash/merge";

import {
deposit,
evmCall,
evmDeposit,
evmDepositAndCall,
Expand All @@ -22,7 +21,6 @@ import {
sendZeta,
solanaDeposit,
trackCCTX,
withdraw,
zetachainCall,
zetachainWithdraw,
zetachainWithdrawAndCall,
Expand Down Expand Up @@ -124,8 +122,6 @@ export class ZetaChainClient {
getFees = getFees;
getPools = getPools;
trackCCTX = trackCCTX;
deposit = deposit;
withdraw = withdraw;
sendZeta = sendZeta;
getChainId = getChainId;
getQuote = getQuote;
Expand Down
107 changes: 0 additions & 107 deletions packages/client/src/deposit.ts

This file was deleted.

2 changes: 1 addition & 1 deletion packages/client/src/evmCall.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import GatewayABI from "@zetachain/protocol-contracts/abi/GatewayEVM.sol/GatewayEVM.json";
import { ethers } from "ethers";

import GatewayABI from "./abi/GatewayEVM.sol/GatewayEVM.json";
import { ZetaChainClient } from "./client";
import type { revertOptions, txOptions } from "./types";

Expand Down
2 changes: 1 addition & 1 deletion packages/client/src/evmDeposit.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import ERC20_ABI from "@openzeppelin/contracts/build/contracts/ERC20.json";
import GatewayABI from "@zetachain/protocol-contracts/abi/GatewayEVM.sol/GatewayEVM.json";
Copy link
Contributor

Choose a reason for hiding this comment

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

💡 Codebase verification

Update required: More files need the same import change

The ABI structure is compatible, containing both required deposit method signatures. However, two other files still use the old local import path:

  • packages/client/src/evmCall.ts
  • packages/client/src/evmDepositAndCall.ts

These files should also be updated to use the centralized ABI from @zetachain/protocol-contracts package for consistency.

🔗 Analysis chain

LGTM! Centralized ABI import.

The change to import GatewayABI from @zetachain/protocol-contracts package is a good practice as it centralizes the ABI definitions.

Let's verify the ABI compatibility:

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify that the GatewayABI structure remains compatible
# by checking for the required deposit methods and their signatures

# Check if the required deposit methods exist in the ABI
ast-grep --pattern 'deposit(address,uint256,address,(address,bool,address,bytes,uint256))' && \
ast-grep --pattern 'deposit(address,(address,bool,address,bytes,uint256))'

# Additionally, check if there are any other files still using the old import path
rg -l "GatewayEVM.sol/GatewayEVM.json" --type ts

Length of output: 324


Script:

#!/bin/bash
# Let's check the content of the ABI file to verify the method signatures
fd GatewayEVM.json -t f --exec cat {} | jq '.abi[] | select(.type == "function" and .name == "deposit") | {name: .name, inputs: .inputs}'

# Also check other files that might need the same import update
rg -l --type ts "./abi/GatewayEVM.sol/GatewayEVM.json"

Length of output: 2241

import { ethers } from "ethers";

import GatewayABI from "./abi/GatewayEVM.sol/GatewayEVM.json";
import { ZetaChainClient } from "./client";
import type { revertOptions, txOptions } from "./types";

Expand Down
2 changes: 1 addition & 1 deletion packages/client/src/evmDepositAndCall.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import ERC20_ABI from "@openzeppelin/contracts/build/contracts/ERC20.json";
import GatewayABI from "@zetachain/protocol-contracts/abi/GatewayEVM.sol/GatewayEVM.json";
import { ethers } from "ethers";

import GatewayABI from "./abi/GatewayEVM.sol/GatewayEVM.json";
import { ZetaChainClient } from "./client";
import type { revertOptions, txOptions } from "./types";

Expand Down
2 changes: 1 addition & 1 deletion packages/client/src/getBalances.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import ERC20_ABI from "@openzeppelin/contracts/build/contracts/ERC20.json";
import { getAddress } from "@zetachain/protocol-contracts";
import ZRC20 from "@zetachain/protocol-contracts/abi/zevm/ZRC20.sol/ZRC20.json";
import ZRC20 from "@zetachain/protocol-contracts/abi/ZRC20.sol/ZRC20.json";
import { ethers } from "ethers";
import { formatUnits } from "ethers/lib/utils";
import fetch from "isomorphic-fetch";
Expand Down
2 changes: 1 addition & 1 deletion packages/client/src/getFees.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { mainnet, testnet } from "@zetachain/protocol-contracts";
import ZRC20 from "@zetachain/protocol-contracts/abi/zevm/ZRC20.sol/ZRC20.json";
import ZRC20 from "@zetachain/protocol-contracts/abi/ZRC20.sol/ZRC20.json";
import { ethers, utils } from "ethers";
import fetch from "isomorphic-fetch";

import { ZetaChainClient } from "./client";

const fetchZEVMFees = async function (

Check warning on line 8 in packages/client/src/getFees.ts

View workflow job for this annotation

GitHub Actions / build

Prefer using arrow functions over plain functions
zrc20: any,
rpcUrl: string,
foreignCoins: any
Expand Down
2 changes: 1 addition & 1 deletion packages/client/src/getPools.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import UniswapV2Factory from "@uniswap/v2-core/build/UniswapV2Factory.json";
import UniswapV2Pair from "@uniswap/v2-core/build/UniswapV2Pair.json";
import { getAddress, ParamChainName } from "@zetachain/protocol-contracts";
import SystemContract from "@zetachain/protocol-contracts/abi/zevm/SystemContract.sol/SystemContract.json";
import SystemContract from "@zetachain/protocol-contracts/abi/SystemContract.sol/SystemContract.json";
import { ethers } from "ethers";

import { ZetaChainClient } from "./client";
Expand Down
2 changes: 1 addition & 1 deletion packages/client/src/getQuote.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { parseUnits } from "@ethersproject/units";
import UniswapV2RouterABI from "@uniswap/v2-periphery/build/IUniswapV2Router02.json";
import { getAddress } from "@zetachain/protocol-contracts";
import ZRC20 from "@zetachain/protocol-contracts/abi/zevm/ZRC20.sol/ZRC20.json";
import ZRC20 from "@zetachain/protocol-contracts/abi/ZRC20.sol/ZRC20.json";
import { ethers } from "ethers";

import { ZetaChainClient } from "./client";
Expand Down
2 changes: 0 additions & 2 deletions packages/client/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
export * from "./client";
export * from "./deposit";
export * from "./evmCall";
export * from "./evmDeposit";
export * from "./evmDepositAndCall";
Expand All @@ -16,7 +15,6 @@ export * from "./prepareData";
export * from "./sendZeta";
export * from "./solanaDeposit";
export * from "./trackCCTX";
export * from "./withdraw";
export * from "./zetachainCall";
export * from "./zetachainWithdraw";
export * from "./zetachainWithdrawAndCall";
Loading
Loading