Skip to content

Commit 26f0708

Browse files
authored
fix: typescript generated files errors - #475 (#477)
1 parent 693a55b commit 26f0708

File tree

8 files changed

+107
-402
lines changed

8 files changed

+107
-402
lines changed

data/addresses.mainnet.json

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
2-
31
[
42
{
53
"address": "0x70e967acFcC17c3941E87562161406d41676FD83",

data/addresses.testnet.json

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
2-
31
[
42
{
53
"address": "0x0000ecb8cdd25a18f12daa23f6422e07fbf8b9e1",
@@ -287,6 +285,19 @@
287285
"symbol": "USDC.AMOY",
288286
"type": "zrc20"
289287
},
288+
{
289+
"address": "0xE80e3e8Ac1C19c744d4c2147172489BEAF23E3C5",
290+
"asset": "a1ec7fc00a6f40db9693ad1415d0c193ad3906494428cf252621037bd7117e29::usdc::USDC",
291+
"category": "omnichain",
292+
"chain_id": 7001,
293+
"chain_name": "zeta_testnet",
294+
"coin_type": "erc20",
295+
"decimals": 6,
296+
"description": "ZetaChain ZRC20 USDC on Sui Testnet",
297+
"foreign_chain_id": "103",
298+
"symbol": "USDC.SUI",
299+
"type": "zrc20"
300+
},
290301
{
291302
"address": "0xEe9CC614D03e7Dbe994b514079f4914a605B4719",
292303
"asset": "",

lib/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
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";
1+
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";
22
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";
33
export type ParamType = "tss" | "connector" | "erc20Custody" | "gateway" | "zetaToken" | "fungibleModule" | "systemContract" | "uniswapV2Factory" | "uniswapV2Router02" | "zrc20";
44

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
"lint:fix": "npx eslint . --fix --ignore-pattern coverage/ --ignore-pattern coverage.json --ignore-pattern lib/ --ignore-pattern out --ignore-pattern cache_forge/",
1515
"test": "forge clean && forge test -vvv",
1616
"coverage": "forge coverage --no-match-coverage \"(script|test|legacy)\" --report lcov",
17-
"typechain": "npx typechain --target ethers-v6 \"out/**/!(*.t|test).sol/!(*.abi).json\" --out-dir types",
17+
"typechain": "npx typechain --target ethers-v6 \"out/**/!(*.t|test).sol/!(*.abi).json\" --out-dir types && npx ts-node ./src/fix-duplicates.ts",
1818
"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",
1919
"prepublishOnly": "copyfiles -u 1 'out/**/*' 'abi'",
2020
"docs": "./scripts/generate_docs.sh"
@@ -59,7 +59,7 @@
5959
"@openzeppelin/contracts": "^5.0.2",
6060
"@openzeppelin/contracts-upgradeable": "^5.0.2",
6161
"@zetachain/networks": "^10.0.0",
62-
"ethers": "5.6.8"
62+
"ethers": "6.13.5"
6363
},
6464
"types": "./dist/lib/index.d.ts",
6565
"packageManager": "yarn@1.22.21+sha1.1959a18351b811cdeedbd484a8f86c3cc3bbaf72"

src/fix-duplicates.ts

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
import * as fs from 'fs';
2+
import * as path from 'path';
3+
4+
// get the project root directory
5+
const root = process.cwd();
6+
// path to index.ts file
7+
const indexPath = path.join(root, 'types', 'index.ts');
8+
// read the file
9+
let content = fs.readFileSync(indexPath, 'utf8');
10+
11+
// track exports, we've seen to avoid duplicates
12+
const seenExports = new Set<string>();
13+
14+
// process the file line by line
15+
const lines = content.split('\n');
16+
const filteredLines = lines.filter(line => {
17+
// check if line is an export type statement
18+
const match = line.match(/export type \{ ([^}]+) \} from/);
19+
if (!match) return true;
20+
21+
const exportName = match[1];
22+
23+
// if we've seen this export before, filter it out
24+
if (seenExports.has(exportName)) {
25+
console.log(`Removing duplicate export: ${exportName}`);
26+
return false;
27+
}
28+
29+
// otherwise, track it and keep the line
30+
seenExports.add(exportName);
31+
return true;
32+
});
33+
34+
// write the filtered content back to the file
35+
fs.writeFileSync(indexPath, filteredLines.join('\n'));
36+
console.log('Duplicate exports have been removed from index.ts');

tasks/addresses.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ const fetchAthensAddresses = async (addresses: any, network: Network) => {
143143
const systemContract = addresses.find((a: any) => {
144144
return a.chain_name === network && a.type === "systemContract";
145145
})?.address;
146-
const provider = new ethers.providers.JsonRpcProvider(api[network].evm);
146+
const provider = new ethers.JsonRpcProvider(api[network].evm);
147147
const sc = SystemContract__factory.connect(systemContract, provider);
148148
const common = {
149149
category: "omnichain",
@@ -168,7 +168,7 @@ const fetchChainSpecificAddresses = async (chains: any, addresses: any, network:
168168
.get(`${api[network].rpc}/zeta-chain/observer/get_chain_params_for_chain/${chain.chain_id}`)
169169
.then(({ data }) => {
170170
const zetaToken = data.chain_params.zeta_token_contract_address;
171-
if (zetaToken && zetaToken != ethers.constants.AddressZero) {
171+
if (zetaToken && zetaToken != ethers.ZeroAddress) {
172172
addresses.push({
173173
address: zetaToken,
174174
category: "messaging",
@@ -178,7 +178,7 @@ const fetchChainSpecificAddresses = async (chains: any, addresses: any, network:
178178
});
179179
}
180180
const connector = data.chain_params.connector_contract_address;
181-
if (connector && connector != ethers.constants.AddressZero) {
181+
if (connector && connector != ethers.ZeroAddress) {
182182
addresses.push({
183183
address: connector,
184184
category: "messaging",
@@ -188,7 +188,7 @@ const fetchChainSpecificAddresses = async (chains: any, addresses: any, network:
188188
});
189189
}
190190
const erc20Custody = data.chain_params.erc20_custody_contract_address;
191-
if (erc20Custody && erc20Custody != ethers.constants.AddressZero) {
191+
if (erc20Custody && erc20Custody != ethers.ZeroAddress) {
192192
addresses.push({
193193
address: erc20Custody,
194194
category: "omnichain",
@@ -198,7 +198,7 @@ const fetchChainSpecificAddresses = async (chains: any, addresses: any, network:
198198
});
199199
}
200200
const gateway = data.chain_params.gateway_address;
201-
if (gateway && gateway != ethers.constants.AddressZero) {
201+
if (gateway && gateway != ethers.ZeroAddress) {
202202
addresses.push({
203203
address: gateway,
204204
category: "omnichain",
@@ -217,7 +217,7 @@ const fetchFactoryV2 = async (addresses: any, network: Network) => {
217217

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

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

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

259259
try {

types/index.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,6 @@ export { ERC165Upgradeable__factory } from "./factories/ERC165Upgradeable__facto
141141
export { ERC1967Proxy__factory } from "./factories/ERC1967Proxy__factory";
142142
export { ERC1967Utils__factory } from "./factories/ERC1967Utils__factory";
143143
export { ERC20__factory } from "./factories/ERC20__factory";
144-
export type { IERC20 } from "./ERC20/IERC20";
145144
export { IERC20__factory } from "./factories/ERC20/IERC20__factory";
146145
export { ERC20Burnable__factory } from "./factories/ERC20Burnable__factory";
147146
export { ERC20Custody__factory } from "./factories/ERC20Custody__factory";
@@ -258,11 +257,8 @@ export type { VmSafe } from "./Vm.sol/VmSafe";
258257
export { VmSafe__factory } from "./factories/Vm.sol/VmSafe__factory";
259258
export type { ZetaEth } from "./Zeta.eth.sol/ZetaEth";
260259
export { ZetaEth__factory } from "./factories/Zeta.eth.sol/ZetaEth__factory";
261-
export type { ZetaErrors } from "./Zeta.non-eth.sol/ZetaErrors";
262260
export { ZetaErrors__factory } from "./factories/Zeta.non-eth.sol/ZetaErrors__factory";
263-
export type { ZetaNonEthInterface } from "./Zeta.non-eth.sol/ZetaNonEthInterface";
264261
export { ZetaNonEthInterface__factory } from "./factories/Zeta.non-eth.sol/ZetaNonEthInterface__factory";
265-
export type { ZetaConnectorBase } from "./ZetaConnector.base.sol/ZetaConnectorBase";
266262
export { ZetaConnectorBase__factory } from "./factories/ZetaConnector.base.sol/ZetaConnectorBase__factory";
267263
export type { ZetaConnectorEth } from "./ZetaConnector.eth.sol/ZetaConnectorEth";
268264
export { ZetaConnectorEth__factory } from "./factories/ZetaConnector.eth.sol/ZetaConnectorEth__factory";

0 commit comments

Comments
 (0)