Skip to content
Merged
Show file tree
Hide file tree
Changes from 8 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
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"lint:fix": "npx eslint . --fix --ignore-pattern coverage/ --ignore-pattern coverage.json --ignore-pattern lib/ --ignore-pattern out --ignore-pattern cache_forge/",
"test": "forge clean && forge test -vvv",
"coverage": "forge coverage --no-match-coverage \"(script|test|legacy)\" --report lcov",
"typechain": "npx typechain --target ethers-v6 \"out/**/!(*.t|test).sol/!(*.abi).json\" --out-dir types",
"typechain": "npx typechain --target ethers-v6 \"out/**/!(*.t|test|IERC20|ZetaConnectorBase|ZetaErrors|ZetaNonEthInterface).sol/!(*.abi).json\" --out-dir types",
Copy link
Contributor

Choose a reason for hiding this comment

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

could you please add some details on why is this excluded? is it because these are imported in other contracts and it is duplicated or something else? wondering if there is some configuration on typechain to exclude duplicates automatically

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes, the duplicates happen because these interfaces (IERC20, ZetaConnectorBase, etc.) are imported in multiple places in our contracts.

When forge compiles, it creates JSON artifacts for these interfaces in different locations based on where they were imported from. That's why we see IERC20 both in the root directory and in the ERC20 subdirectory.

Typechain doesn't have a built-in config option to automatically detect and exclude duplicates. It just processes all JSON files that match the glob pattern.

My solution of explicitly excluding the problematic interfaces works for now, though we'll need to update it if we encounter more duplicates later.

examples:
export type { IERC20 } from "./IERC20";
export type { IERC20 } from "./ERC20/IERC20";

export type { ZetaConnectorBase } from "./ZetaConnectorBase";
export type { ZetaConnectorBase } from "./ZetaConnector.base.sol/ZetaConnectorBase";

export type { ZetaErrors } from "./ZetaErrors";
export type { ZetaErrors } from "./Zeta.non-eth.sol/ZetaErrors";

export type { ZetaNonEthInterface } from "./ZetaNonEthInterface";
export type { ZetaNonEthInterface } from "./Zeta.non-eth.sol/ZetaNonEthInterface";

Copy link
Contributor

Choose a reason for hiding this comment

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

got it, previously we had v1 and v2 directories and then they got merged into 1 repo, so probably some of these can be removed in the solidity code itself, and only have them on 1 place and import from that 1 place

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

will check it

"generate": "forge clean && forge build && forge fmt && ./scripts/generate_go.sh || true && ./scripts/generate_addresses.sh && yarn lint:fix && yarn typechain && yarn docs && del-cli dist && tsc || true",
"prepublishOnly": "copyfiles -u 1 'out/**/*' 'abi'",
"docs": "./scripts/generate_docs.sh"
Expand Down Expand Up @@ -59,7 +59,7 @@
"@openzeppelin/contracts": "^5.0.2",
"@openzeppelin/contracts-upgradeable": "^5.0.2",
"@zetachain/networks": "^10.0.0",
"ethers": "5.6.8"
"ethers": "6.13.5"
},
"types": "./dist/lib/index.d.ts",
"packageManager": "[email protected]+sha1.1959a18351b811cdeedbd484a8f86c3cc3bbaf72"
Expand Down
14 changes: 7 additions & 7 deletions tasks/addresses.ts
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ const fetchAthensAddresses = async (addresses: any, network: Network) => {
const systemContract = addresses.find((a: any) => {
return a.chain_name === network && a.type === "systemContract";
})?.address;
const provider = new ethers.providers.JsonRpcProvider(api[network].evm);
const provider = new ethers.JsonRpcProvider(api[network].evm);
const sc = SystemContract__factory.connect(systemContract, provider);
const common = {
category: "omnichain",
Expand All @@ -168,7 +168,7 @@ const fetchChainSpecificAddresses = async (chains: any, addresses: any, network:
.get(`${api[network].rpc}/zeta-chain/observer/get_chain_params_for_chain/${chain.chain_id}`)
.then(({ data }) => {
const zetaToken = data.chain_params.zeta_token_contract_address;
if (zetaToken && zetaToken != ethers.constants.AddressZero) {
if (zetaToken && zetaToken != ethers.ZeroAddress) {
addresses.push({
address: zetaToken,
category: "messaging",
Expand All @@ -178,7 +178,7 @@ const fetchChainSpecificAddresses = async (chains: any, addresses: any, network:
});
}
const connector = data.chain_params.connector_contract_address;
if (connector && connector != ethers.constants.AddressZero) {
if (connector && connector != ethers.ZeroAddress) {
addresses.push({
address: connector,
category: "messaging",
Expand All @@ -188,7 +188,7 @@ const fetchChainSpecificAddresses = async (chains: any, addresses: any, network:
});
}
const erc20Custody = data.chain_params.erc20_custody_contract_address;
if (erc20Custody && erc20Custody != ethers.constants.AddressZero) {
if (erc20Custody && erc20Custody != ethers.ZeroAddress) {
addresses.push({
address: erc20Custody,
category: "omnichain",
Expand All @@ -198,7 +198,7 @@ const fetchChainSpecificAddresses = async (chains: any, addresses: any, network:
});
}
const gateway = data.chain_params.gateway_address;
if (gateway && gateway != ethers.constants.AddressZero) {
if (gateway && gateway != ethers.ZeroAddress) {
addresses.push({
address: gateway,
category: "omnichain",
Expand All @@ -217,7 +217,7 @@ const fetchFactoryV2 = async (addresses: any, network: Network) => {

for (const router of routers) {
const rpc = getEndpoints("evm", router.chain_name)[0]?.url;
const provider = new ethers.providers.JsonRpcProvider(rpc);
const provider = new ethers.JsonRpcProvider(rpc);
const routerContract = new ethers.Contract(router.address, uniswapV2Router.abi, provider);

try {
Expand Down Expand Up @@ -253,7 +253,7 @@ const fetchFactoryV3 = async (addresses: any, network: Network) => {

for (const router of routers) {
const rpc = getEndpoints("evm", router.chain_name)[0]?.url;
const provider = new ethers.providers.JsonRpcProvider(rpc);
const provider = new ethers.JsonRpcProvider(rpc);
const routerContract = new ethers.Contract(router.address, SwapRouter.abi, provider);

try {
Expand Down
5 changes: 0 additions & 5 deletions types/factories/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
/* Autogenerated file. Do not edit manually. */
/* tslint:disable */
/* eslint-disable */
export * as erc20 from "./ERC20";
Copy link
Contributor

Choose a reason for hiding this comment

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

just to double check, did you remove these manually or it is now working fine with yarn generate?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

that got removed when I ran yarn generate

export * as errorsSol from "./Errors.sol";
export * as ierc20CustodySol from "./IERC20Custody.sol";
export * as ierc721Sol from "./IERC721.sol";
Expand Down Expand Up @@ -53,7 +52,6 @@ export { IAccessControl__factory } from "./IAccessControl__factory";
export { IBeacon__factory } from "./IBeacon__factory";
export { IERC165__factory } from "./IERC165__factory";
export { IERC1967__factory } from "./IERC1967__factory";
export { IERC20__factory } from "./IERC20__factory";
export { IERC20Metadata__factory } from "./IERC20Metadata__factory";
export { IERC20Permit__factory } from "./IERC20Permit__factory";
export { IMulticall3__factory } from "./IMulticall3__factory";
Expand Down Expand Up @@ -84,10 +82,7 @@ export { TestERC20__factory } from "./TestERC20__factory";
export { TestUniversalContract__factory } from "./TestUniversalContract__factory";
export { UUPSUpgradeable__factory } from "./UUPSUpgradeable__factory";
export { UpgradeableBeacon__factory } from "./UpgradeableBeacon__factory";
export { ZetaConnectorBase__factory } from "./ZetaConnectorBase__factory";
export { ZetaConnectorNative__factory } from "./ZetaConnectorNative__factory";
export { ZetaConnectorNativeUpgradeTest__factory } from "./ZetaConnectorNativeUpgradeTest__factory";
export { ZetaConnectorNonNative__factory } from "./ZetaConnectorNonNative__factory";
export { ZetaConnectorNonNativeUpgradeTest__factory } from "./ZetaConnectorNonNativeUpgradeTest__factory";
export { ZetaErrors__factory } from "./ZetaErrors__factory";
export { ZetaNonEthInterface__factory } from "./ZetaNonEthInterface__factory";
8 changes: 0 additions & 8 deletions types/index.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
/* Autogenerated file. Do not edit manually. */
/* tslint:disable */
/* eslint-disable */
import type * as erc20 from "./ERC20";
export type { erc20 };
import type * as errorsSol from "./Errors.sol";
export type { errorsSol };
import type * as ierc20CustodySol from "./IERC20Custody.sol";
Expand Down Expand Up @@ -85,7 +83,6 @@ export type { IAccessControl } from "./IAccessControl";
export type { IBeacon } from "./IBeacon";
export type { IERC165 } from "./IERC165";
export type { IERC1967 } from "./IERC1967";
export type { IERC20 } from "./IERC20";
export type { IERC20Metadata } from "./IERC20Metadata";
export type { IERC20Permit } from "./IERC20Permit";
export type { IMulticall3 } from "./IMulticall3";
Expand Down Expand Up @@ -116,13 +113,10 @@ export type { TestERC20 } from "./TestERC20";
export type { TestUniversalContract } from "./TestUniversalContract";
export type { UUPSUpgradeable } from "./UUPSUpgradeable";
export type { UpgradeableBeacon } from "./UpgradeableBeacon";
export type { ZetaConnectorBase } from "./ZetaConnectorBase";
export type { ZetaConnectorNative } from "./ZetaConnectorNative";
export type { ZetaConnectorNativeUpgradeTest } from "./ZetaConnectorNativeUpgradeTest";
export type { ZetaConnectorNonNative } from "./ZetaConnectorNonNative";
export type { ZetaConnectorNonNativeUpgradeTest } from "./ZetaConnectorNonNativeUpgradeTest";
export type { ZetaErrors } from "./ZetaErrors";
export type { ZetaNonEthInterface } from "./ZetaNonEthInterface";
export * as factories from "./factories";
export { AccessControlUpgradeable__factory } from "./factories/AccessControlUpgradeable__factory";
export { Address__factory } from "./factories/Address__factory";
Expand All @@ -141,8 +135,6 @@ export { ERC165Upgradeable__factory } from "./factories/ERC165Upgradeable__facto
export { ERC1967Proxy__factory } from "./factories/ERC1967Proxy__factory";
export { ERC1967Utils__factory } from "./factories/ERC1967Utils__factory";
export { ERC20__factory } from "./factories/ERC20__factory";
export type { IERC20 } from "./ERC20/IERC20";
export { IERC20__factory } from "./factories/ERC20/IERC20__factory";
export { ERC20Burnable__factory } from "./factories/ERC20Burnable__factory";
export { ERC20Custody__factory } from "./factories/ERC20Custody__factory";
export { ERC20CustodyUpgradeTest__factory } from "./factories/ERC20CustodyUpgradeTest__factory";
Expand Down
Loading
Loading