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: typescript generated files errors - #475 #477

Merged
merged 9 commits into from
Mar 19, 2025
2 changes: 0 additions & 2 deletions data/addresses.mainnet.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@


[
{
"address": "0x70e967acFcC17c3941E87562161406d41676FD83",
Expand Down
15 changes: 13 additions & 2 deletions data/addresses.testnet.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@


[
{
"address": "0x0000ecb8cdd25a18f12daa23f6422e07fbf8b9e1",
Expand Down Expand Up @@ -287,6 +285,19 @@
"symbol": "USDC.AMOY",
"type": "zrc20"
},
{
"address": "0xE80e3e8Ac1C19c744d4c2147172489BEAF23E3C5",
"asset": "a1ec7fc00a6f40db9693ad1415d0c193ad3906494428cf252621037bd7117e29::usdc::USDC",
"category": "omnichain",
"chain_id": 7001,
"chain_name": "zeta_testnet",
"coin_type": "erc20",
"decimals": 6,
"description": "ZetaChain ZRC20 USDC on Sui Testnet",
"foreign_chain_id": "103",
"symbol": "USDC.SUI",
"type": "zrc20"
},
{
"address": "0xEe9CC614D03e7Dbe994b514079f4914a605B4719",
"asset": "",
Expand Down
2 changes: 1 addition & 1 deletion lib/types.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export type ParamSymbol = "USDC.ARB" | "USDC.BSC" | "USDT.ARB" | "USDC.ETH" | "BTC.BTC" | "ETH.BASE" | "PEPE.ETH" | "USDT.AVAX" | "CBBTC.ETH" | "BNB.BSC" | "SOL.SOL" | "CBBTC.SOL" | "SHIB.ETH" | "USDT.ETH" | "USDC.SOL" | "USDT.BSC" | "USDC.BASE" | "USDC.AVAX" | "ETH.ARB" | "POL.POLYGON" | "DAI.ETH" | "WBTC.ETH" | "ULTI.BSC" | "ETH.ETH" | "USDT.POL" | "NPC.ETH" | "ULTI.ETH" | "CBBTC.BASE" | "AVAX.AVAX" | "USDT.SOL" | "USDC.POL" | "sETH.SEPOLIA" | "ETH.ARBSEP" | "ETH.BASESEPOLIA" | "SUI.SUI" | "USDC.ARBSEP" | "TON.TON" | "MATIC.AMOY" | "USDC" | "USDC.FUJI" | "SOL.SOLANA" | "USDC.SEPOLIA" | "tBNB" | "sBTC" | "USDC.AMOY" | "AVAX.FUJI" | "tBTC";
export type ParamSymbol = "USDC.ARB" | "USDC.BSC" | "USDT.ARB" | "USDC.ETH" | "BTC.BTC" | "ETH.BASE" | "PEPE.ETH" | "USDT.AVAX" | "CBBTC.ETH" | "BNB.BSC" | "SOL.SOL" | "CBBTC.SOL" | "SHIB.ETH" | "USDT.ETH" | "USDC.SOL" | "USDT.BSC" | "USDC.BASE" | "USDC.AVAX" | "ETH.ARB" | "POL.POLYGON" | "DAI.ETH" | "WBTC.ETH" | "ULTI.BSC" | "ETH.ETH" | "USDT.POL" | "NPC.ETH" | "ULTI.ETH" | "CBBTC.BASE" | "AVAX.AVAX" | "USDT.SOL" | "USDC.POL" | "sETH.SEPOLIA" | "ETH.ARBSEP" | "ETH.BASESEPOLIA" | "SUI.SUI" | "USDC.ARBSEP" | "TON.TON" | "MATIC.AMOY" | "USDC" | "USDC.FUJI" | "SOL.SOLANA" | "USDC.SEPOLIA" | "tBNB" | "sBTC" | "USDC.AMOY" | "USDC.SUI" | "AVAX.FUJI" | "tBTC";
export type ParamChainName = "eth_mainnet" | "bsc_mainnet" | "polygon_mainnet" | "solana_mainnet" | "zeta_mainnet" | "btc_mainnet" | "base_mainnet" | "arbitrum_mainnet" | "avalanche_mainnet" | "bsc_testnet" | "sui_testnet" | "solana_devnet" | "zeta_testnet" | "btc_testnet" | "avalanche_testnet" | "amoy_testnet" | "base_sepolia" | "arbitrum_sepolia" | "ton_testnet" | "sepolia_testnet";
export type ParamType = "tss" | "connector" | "erc20Custody" | "gateway" | "zetaToken" | "fungibleModule" | "systemContract" | "uniswapV2Factory" | "uniswapV2Router02" | "zrc20";

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).sol/!(*.abi).json\" --out-dir types && npx ts-node ./src/fix-duplicates.ts",
"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
36 changes: 36 additions & 0 deletions src/fix-duplicates.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import * as fs from 'fs';
import * as path from 'path';

// get the project root directory
const root = process.cwd();
// path to index.ts file
const indexPath = path.join(root, 'types', 'index.ts');
// read the file
let content = fs.readFileSync(indexPath, 'utf8');

// track exports, we've seen to avoid duplicates
const seenExports = new Set<string>();

// process the file line by line
const lines = content.split('\n');
const filteredLines = lines.filter(line => {
// check if line is an export type statement
const match = line.match(/export type \{ ([^}]+) \} from/);
if (!match) return true;

const exportName = match[1];

// if we've seen this export before, filter it out
if (seenExports.has(exportName)) {
console.log(`Removing duplicate export: ${exportName}`);
return false;
}

// otherwise, track it and keep the line
seenExports.add(exportName);
return true;
});

// write the filtered content back to the file
fs.writeFileSync(indexPath, filteredLines.join('\n'));
console.log('Duplicate exports have been removed from index.ts');
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
4 changes: 0 additions & 4 deletions types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,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";
Expand Down Expand Up @@ -258,11 +257,8 @@ export type { VmSafe } from "./Vm.sol/VmSafe";
export { VmSafe__factory } from "./factories/Vm.sol/VmSafe__factory";
export type { ZetaEth } from "./Zeta.eth.sol/ZetaEth";
export { ZetaEth__factory } from "./factories/Zeta.eth.sol/ZetaEth__factory";
export type { ZetaErrors } from "./Zeta.non-eth.sol/ZetaErrors";
export { ZetaErrors__factory } from "./factories/Zeta.non-eth.sol/ZetaErrors__factory";
export type { ZetaNonEthInterface } from "./Zeta.non-eth.sol/ZetaNonEthInterface";
export { ZetaNonEthInterface__factory } from "./factories/Zeta.non-eth.sol/ZetaNonEthInterface__factory";
export type { ZetaConnectorBase } from "./ZetaConnector.base.sol/ZetaConnectorBase";
export { ZetaConnectorBase__factory } from "./factories/ZetaConnector.base.sol/ZetaConnectorBase__factory";
export type { ZetaConnectorEth } from "./ZetaConnector.eth.sol/ZetaConnectorEth";
export { ZetaConnectorEth__factory } from "./factories/ZetaConnector.eth.sol/ZetaConnectorEth__factory";
Expand Down
Loading
Loading