From 00f1a2525b1fc4e3245ce2f6292f92a2317a2946 Mon Sep 17 00:00:00 2001 From: Denis Fadeev Date: Sun, 7 May 2023 17:20:28 +0400 Subject: [PATCH 01/27] feat: fetch addresses from chain --- hardhat.config.ts | 32 +++++--- package.json | 3 +- tasks/addresses.ts | 182 +++++++++++++++++++++++++++++++++++++++++++++ yarn.lock | 25 ++++++- 4 files changed, 228 insertions(+), 14 deletions(-) create mode 100644 tasks/addresses.ts diff --git a/hardhat.config.ts b/hardhat.config.ts index 23b1440e..25dc43e4 100644 --- a/hardhat.config.ts +++ b/hardhat.config.ts @@ -7,6 +7,8 @@ import * as dotenv from "dotenv"; import type { HardhatUserConfig } from "hardhat/types"; +import "./tasks/addresses"; + dotenv.config(); const PRIVATE_KEYS = @@ -90,18 +92,24 @@ const config: HardhatUserConfig = { compilers: [ { version: "0.4.19" /** For zevm/wzeta.sol */ }, { version: "0.5.10" /** For create2 factory */ }, - { version: "0.5.16", settings: { - optimizer: { - enabled: true, - runs: 999999, - } - } }, - { version: "0.6.6", settings: { - optimizer: { - enabled: true, - runs: 999999, - } - } /** For uniswap v2 */ }, + { + version: "0.5.16", + settings: { + optimizer: { + enabled: true, + runs: 999999, + }, + }, + }, + { + version: "0.6.6", + settings: { + optimizer: { + enabled: true, + runs: 999999, + }, + } /** For uniswap v2 */, + }, { version: "0.7.6" /** For uniswap v3 */ }, { version: "0.8.7" }, ], diff --git a/package.json b/package.json index 3ac87414..5e64808d 100644 --- a/package.json +++ b/package.json @@ -37,6 +37,7 @@ "@uniswap/v3-periphery": "^1.4.3", "@zetachain/addresses": "^0.0.9", "@zetachain/addresses-tools": "^0.0.1", + "axios": "^1.4.0", "chai": "^4.3.6", "dotenv": "^16.0.0", "eslint": "^8.13.0", @@ -65,4 +66,4 @@ "typechain": "^8.1.0", "typescript": "^4.6.3" } -} \ No newline at end of file +} diff --git a/tasks/addresses.ts b/tasks/addresses.ts new file mode 100644 index 00000000..45ee1f5c --- /dev/null +++ b/tasks/addresses.ts @@ -0,0 +1,182 @@ +import { task } from "hardhat/config"; +import { HardhatRuntimeEnvironment } from "hardhat/types"; +import axios, { AxiosResponse } from "axios"; +import { SystemContract__factory } from "../typechain-types/factories/contracts/zevm/SystemContract.sol/SystemContract__factory"; + +const ATHENS_EVM_RPC = "https://rpc.ankr.com/zetachain_evm_testnet"; +const ATHENS_TENDERMINT_RPC = "https://api.athens2.zetachain.com"; + +interface ChainObject { + [chainName: string]: Record; +} + +interface ApiResponse { + Chains: string[]; +} + +interface ForeignCoinsResponse { + foreignCoins: { + index: string; + zrc20ContractAddress: string; + erc20ContractAddress: string; + foreignChain: string; + decimals: number; + name: string; + symbol: string; + coinType: string; + }[]; + pagination: { + next_key: string | null; + total: string; + }; +} + +interface TssResponse { + TSS: { + creator: string; + index: string; + chain: string; + address: string; + pubkey: string; + signer: string[]; + finalizedZetaHeight: string; + }[]; +} + +interface SystemContractResponse { + SystemContract: { + systemContract: string; + }; +} + +const fetchChains = async (chainObject: ChainObject) => { + const URL = `${ATHENS_TENDERMINT_RPC}/zeta-chain/observer/supportedChains`; + try { + const response: AxiosResponse = await axios.get(URL); + + if (response.status === 200) { + const chains: string[] = response.data.Chains; + chains.forEach((chain: string) => { + chainObject[chain.toLowerCase()] = {}; + }); + } else { + console.error( + "Error fetching chains:", + response.status, + response.statusText + ); + } + } catch (error) { + console.error("Error fetching chains:", error); + } +}; + +const fetchTssData = async (chainObject: ChainObject) => { + const URL = `${ATHENS_TENDERMINT_RPC}/zeta-chain/crosschain/TSS`; + try { + const tssResponse: AxiosResponse = await axios.get(URL); + + if (tssResponse.status === 200) { + tssResponse.data.TSS.forEach((tssItem) => { + if (chainObject[tssItem.chain.toLowerCase()]) { + chainObject[tssItem.chain.toLowerCase()]["tss"] = tssItem.address; + } + }); + } else { + console.error( + "Error fetching TSS data:", + tssResponse.status, + tssResponse.statusText + ); + } + } catch (error) { + console.error("Error fetching TSS data:", error); + } +}; + +const fetchSystemContract = async (chainObject: ChainObject) => { + const URL = `${ATHENS_TENDERMINT_RPC}/zeta-chain/zetacore/fungible/system_contract`; + try { + const systemContractResponse: AxiosResponse = + await axios.get(URL); + + if (systemContractResponse.status === 200) { + if (!chainObject["athens"]) { + chainObject["athens"] = {}; + } + chainObject["athens"]["systemContract"] = + systemContractResponse.data.SystemContract.systemContract; + } else { + console.error( + "Error fetching system contract:", + systemContractResponse.statusText + ); + } + } catch (error) { + console.error("Error fetching system contract:", error); + } +}; + +const fetchForeignCoinsData = async (chainObject: ChainObject) => { + const URL = `${ATHENS_TENDERMINT_RPC}/zeta-chain/zetacore/fungible/foreign_coins`; + try { + const foreignCoinsResponse: AxiosResponse = + await axios.get(URL); + if (foreignCoinsResponse.status === 200) { + foreignCoinsResponse.data.foreignCoins.forEach((coin) => { + const chain = coin.foreignChain.toLowerCase(); + if (chainObject[chain]) { + chainObject[chain]["zrc20ContractAddress"] = + coin.zrc20ContractAddress; + } else { + chainObject[chain] = { + zrc20ContractAddress: coin.zrc20ContractAddress, + }; + } + }); + } else { + console.error( + "Error fetching foreign coins data:", + foreignCoinsResponse.status, + foreignCoinsResponse.statusText + ); + } + } catch (error) { + console.error("Error fetching foreign coins data:", error); + } +}; + +const fetchAthensAddresses = async ( + chainObject: ChainObject, + hre: HardhatRuntimeEnvironment +) => { + if (chainObject["athens"] && chainObject["athens"]["systemContract"]) { + const athens = chainObject["athens"]; + const systemContract = athens["systemContract"] as string; + const provider = new hre.ethers.providers.JsonRpcProvider(ATHENS_EVM_RPC); + const sc = SystemContract__factory.connect(systemContract, provider); + try { + athens["uniswapv2FactoryAddress"] = await sc.uniswapv2FactoryAddress(); + athens["wZetaContractAddress"] = await sc.wZetaContractAddress(); + athens["uniswapv2Router02Address"] = await sc.uniswapv2Router02Address(); + } catch (error) { + console.error("Error fetching addresses from Athens:", error); + } + } else { + console.error("Athens system contract not found."); + } +}; + +const main = async (args: any, hre: HardhatRuntimeEnvironment) => { + const chainObject: ChainObject = {}; + + await fetchChains(chainObject); + await fetchTssData(chainObject); + await fetchSystemContract(chainObject); + await fetchForeignCoinsData(chainObject); + await fetchAthensAddresses(chainObject, hre); + + console.log(JSON.stringify(chainObject, null, 2)); +}; + +task("addresses", "").setAction(main); diff --git a/yarn.lock b/yarn.lock index cc96fdf2..246f786d 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2437,6 +2437,15 @@ aws4@^1.8.0: resolved "https://registry.yarnpkg.com/aws4/-/aws4-1.12.0.tgz#ce1c9d143389679e253b314241ea9aa5cec980d3" integrity sha512-NmWvPnx0F1SfrQbYwOi7OeaNGokp9XhzNioJ/CSBs8Qa4vxug81mhJEAVZwxXuBmYB5KDRfMq/F3RR0BIU7sWg== +axios@^1.4.0: + version "1.4.0" + resolved "https://registry.yarnpkg.com/axios/-/axios-1.4.0.tgz#38a7bf1224cd308de271146038b551d725f0be1f" + integrity sha512-S4XCWMEmzvo64T9GfvQDOXgYRDJ/wsSZc7Jvdgx5u1sd0JwsuPLqb3SYmusag+edF6ziyMensPVqLTSc1PiSEA== + dependencies: + follow-redirects "^1.15.0" + form-data "^4.0.0" + proxy-from-env "^1.1.0" + balanced-match@^1.0.0: version "1.0.2" resolved "https://registry.yarnpkg.com/balanced-match/-/balanced-match-1.0.2.tgz#e83e3a7e3f300b34cb9d87f615fa0cbf357690ee" @@ -4119,7 +4128,7 @@ flatted@^3.1.0: resolved "https://registry.yarnpkg.com/flatted/-/flatted-3.2.7.tgz#609f39207cb614b89d0765b477cb2d437fbf9787" integrity sha512-5nqDSxl8nn5BSNxyR3n4I6eDmbolI6WT+QqR547RwxQapgjQBmtktdP+HTBb/a/zLsbzERTONyUB5pefh5TtjQ== -follow-redirects@^1.12.1: +follow-redirects@^1.12.1, follow-redirects@^1.15.0: version "1.15.2" resolved "https://registry.yarnpkg.com/follow-redirects/-/follow-redirects-1.15.2.tgz#b460864144ba63f2681096f274c4e57026da2c13" integrity sha512-VQLG33o04KaQ8uYi2tVNbdrWp1QWxNNea+nmIB4EVM28v0hmP17z7aG1+wAkNzVq4KeXTq3221ye5qTJP91JwA== @@ -4154,6 +4163,15 @@ form-data@^3.0.0: combined-stream "^1.0.8" mime-types "^2.1.12" +form-data@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/form-data/-/form-data-4.0.0.tgz#93919daeaf361ee529584b9b31664dc12c9fa452" + integrity sha512-ETEklSGi5t0QMZuiXoA/Q6vcnxcLQP5vdugSpuAyi6SVGi2clPPp+xgEhuMaHC+zGgn31Kd235W35f7Hykkaww== + dependencies: + asynckit "^0.4.0" + combined-stream "^1.0.8" + mime-types "^2.1.12" + form-data@~2.3.2: version "2.3.3" resolved "https://registry.yarnpkg.com/form-data/-/form-data-2.3.3.tgz#dcce52c05f644f298c6a7ab936bd724ceffbf3a6" @@ -6272,6 +6290,11 @@ promise@^8.0.0: dependencies: asap "~2.0.6" +proxy-from-env@^1.1.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/proxy-from-env/-/proxy-from-env-1.1.0.tgz#e102f16ca355424865755d2c9e8ea4f24d58c3e2" + integrity sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg== + prr@~1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/prr/-/prr-1.0.1.tgz#d3fc114ba06995a45ec6893f484ceb1d78f5f476" From 6385d094c5a371dfbb9c2a775891d8a89455cf30 Mon Sep 17 00:00:00 2001 From: Denis Fadeev Date: Tue, 13 Jun 2023 19:16:05 +0400 Subject: [PATCH 02/27] fix: update to Athens 3 --- tasks/addresses.ts | 199 ++++++++++++++++++++++++++------------------- 1 file changed, 114 insertions(+), 85 deletions(-) diff --git a/tasks/addresses.ts b/tasks/addresses.ts index 45ee1f5c..9da84647 100644 --- a/tasks/addresses.ts +++ b/tasks/addresses.ts @@ -2,62 +2,30 @@ import { task } from "hardhat/config"; import { HardhatRuntimeEnvironment } from "hardhat/types"; import axios, { AxiosResponse } from "axios"; import { SystemContract__factory } from "../typechain-types/factories/contracts/zevm/SystemContract.sol/SystemContract__factory"; - -const ATHENS_EVM_RPC = "https://rpc.ankr.com/zetachain_evm_testnet"; -const ATHENS_TENDERMINT_RPC = "https://api.athens2.zetachain.com"; - -interface ChainObject { - [chainName: string]: Record; -} - -interface ApiResponse { - Chains: string[]; -} - -interface ForeignCoinsResponse { - foreignCoins: { - index: string; - zrc20ContractAddress: string; - erc20ContractAddress: string; - foreignChain: string; - decimals: number; - name: string; - symbol: string; - coinType: string; - }[]; - pagination: { - next_key: string | null; - total: string; - }; -} - -interface TssResponse { - TSS: { - creator: string; - index: string; - chain: string; - address: string; - pubkey: string; - signer: string[]; - finalizedZetaHeight: string; - }[]; -} - -interface SystemContractResponse { - SystemContract: { - systemContract: string; - }; -} - -const fetchChains = async (chainObject: ChainObject) => { +import { + ZetaConnectorBase__factory, + ZetaConnectorEth__factory, + ZetaConnectorNonEth__factory, + ZetaConnectorZEVM__factory, +} from "@typechain-types"; +import { ZetaConnector__factory } from "dist/typechain-types"; +import { zetaConnectorNonEthSol } from "typechain-types/factories/contracts/evm"; + +const ATHENS_EVM_RPC = + "https://zetachain-athens-evm.blockpi.network/v1/rpc/public"; +const ATHENS_TENDERMINT_RPC = "http://46.4.15.110:1317"; + +const fetchChains = async (chainObject: any) => { const URL = `${ATHENS_TENDERMINT_RPC}/zeta-chain/observer/supportedChains`; try { - const response: AxiosResponse = await axios.get(URL); + const response: AxiosResponse = await axios.get(URL); if (response.status === 200) { - const chains: string[] = response.data.Chains; - chains.forEach((chain: string) => { - chainObject[chain.toLowerCase()] = {}; + const chains: string[] = response.data.chains; + chains.forEach((chain: any) => { + chainObject[chain.chain_name.toLowerCase()] = { + chainId: chain.chain_id, + }; }); } else { console.error( @@ -71,17 +39,17 @@ const fetchChains = async (chainObject: ChainObject) => { } }; -const fetchTssData = async (chainObject: ChainObject) => { - const URL = `${ATHENS_TENDERMINT_RPC}/zeta-chain/crosschain/TSS`; +const fetchTssData = async (chainObject: any) => { + const URL = `${ATHENS_TENDERMINT_RPC}/zeta-chain/zetacore/crosschain/get_tss_address`; try { - const tssResponse: AxiosResponse = await axios.get(URL); + const tssResponse: AxiosResponse = await axios.get(URL); if (tssResponse.status === 200) { - tssResponse.data.TSS.forEach((tssItem) => { - if (chainObject[tssItem.chain.toLowerCase()]) { - chainObject[tssItem.chain.toLowerCase()]["tss"] = tssItem.address; - } - }); + for (const chain in chainObject) { + const { btc, eth } = tssResponse.data; + if (chain.includes("zeta")) continue; + chainObject[chain]["tss"] = chain.includes("btc") ? btc : eth; + } } else { console.error( "Error fetching TSS data:", @@ -94,18 +62,19 @@ const fetchTssData = async (chainObject: ChainObject) => { } }; -const fetchSystemContract = async (chainObject: ChainObject) => { +const fetchSystemContract = async (chainObject: any) => { const URL = `${ATHENS_TENDERMINT_RPC}/zeta-chain/zetacore/fungible/system_contract`; try { - const systemContractResponse: AxiosResponse = - await axios.get(URL); + const systemContractResponse: AxiosResponse = await axios.get(URL); if (systemContractResponse.status === 200) { - if (!chainObject["athens"]) { - chainObject["athens"] = {}; + if (!chainObject["zeta_testnet"]) { + chainObject["zeta_testnet"] = {}; } - chainObject["athens"]["systemContract"] = - systemContractResponse.data.SystemContract.systemContract; + chainObject["zeta_testnet"]["systemContract"] = + systemContractResponse.data.SystemContract.system_contract; + chainObject["zeta_testnet"]["connectorZEVM"] = + systemContractResponse.data.SystemContract.connector_zevm; } else { console.error( "Error fetching system contract:", @@ -117,21 +86,19 @@ const fetchSystemContract = async (chainObject: ChainObject) => { } }; -const fetchForeignCoinsData = async (chainObject: ChainObject) => { +const fetchForeignCoinsData = async (chainObject: any) => { const URL = `${ATHENS_TENDERMINT_RPC}/zeta-chain/zetacore/fungible/foreign_coins`; try { - const foreignCoinsResponse: AxiosResponse = - await axios.get(URL); + const foreignCoinsResponse: AxiosResponse = await axios.get(URL); if (foreignCoinsResponse.status === 200) { - foreignCoinsResponse.data.foreignCoins.forEach((coin) => { - const chain = coin.foreignChain.toLowerCase(); - if (chainObject[chain]) { - chainObject[chain]["zrc20ContractAddress"] = - coin.zrc20ContractAddress; - } else { - chainObject[chain] = { - zrc20ContractAddress: coin.zrc20ContractAddress, - }; + foreignCoinsResponse.data.foreignCoins.forEach((coin: any) => { + for (const key in chainObject) { + if (chainObject.hasOwnProperty(key)) { + const chain = chainObject[key]; + if (chain.chainId === coin.foreign_chain_id) { + chain.zrc20ContractAddress = coin.zrc20_contract_address; + } + } } }); } else { @@ -147,11 +114,70 @@ const fetchForeignCoinsData = async (chainObject: ChainObject) => { }; const fetchAthensAddresses = async ( - chainObject: ChainObject, + chainObject: any, + hre: HardhatRuntimeEnvironment +) => { + const zeta = "zeta_testnet"; + if (chainObject[zeta] && chainObject[zeta]["systemContract"]) { + const athens = chainObject[zeta]; + const systemContract = athens["systemContract"] as string; + const provider = new hre.ethers.providers.JsonRpcProvider(ATHENS_EVM_RPC); + const sc = SystemContract__factory.connect(systemContract, provider); + try { + athens["uniswapv2FactoryAddress"] = await sc.uniswapv2FactoryAddress(); + athens["wZetaContractAddress"] = await sc.wZetaContractAddress(); + athens["uniswapv2Router02Address"] = await sc.uniswapv2Router02Address(); + athens["zetaConnectorZEVMAddress"] = await sc.zetaConnectorZEVMAddress(); + athens["fungibleModuleAddress"] = await sc.FUNGIBLE_MODULE_ADDRESS(); + } catch (error) { + console.error("Error fetching addresses from ZetaChain:", error); + } + } else { + console.error("ZetaChain system contract not found."); + } +}; + +const fetchChainSpecificAddresses = async (chainObject: any) => { + const URL = `${ATHENS_TENDERMINT_RPC}/zeta-chain/zetacore/observer/get_client_params_for_chain`; + try { + for (const chain in chainObject) { + if (chain.includes("zeta") || chain.includes("btc")) continue; + const id = chainObject[chain].chainId; + const response: AxiosResponse = await axios.get(`${URL}/${id}`); + if (response.status === 200) { + chainObject[chain]["zetaTokenContractAddress"] = + response.data.core_params.zeta_token_contract_address; + chainObject[chain]["connectorContractAddress"] = + response.data.core_params.connector_contract_address; + chainObject[chain]["erc20CustodyContractAddress"] = + response.data.core_params.erc20_custody_contract_address; + } else { + console.error( + "Error fetching chain data:", + response.status, + response.statusText + ); + } + } + } catch (error) { + console.error("Error fetching chain data:", error); + } +}; + +const fetchPauserUpdater = async ( + chainObject: any, hre: HardhatRuntimeEnvironment ) => { - if (chainObject["athens"] && chainObject["athens"]["systemContract"]) { - const athens = chainObject["athens"]; + try { + for (const chain in chainObject) { + const provider = new hre.ethers.providers.JsonRpcProvider(ATHENS_EVM_RPC); + } + } catch (error) { + console.error("Error fetching addresses from ZetaChain:", error); + } + const zeta = "zeta_testnet"; + if (chainObject[zeta] && chainObject[zeta]["systemContract"]) { + const athens = chainObject[zeta]; const systemContract = athens["systemContract"] as string; const provider = new hre.ethers.providers.JsonRpcProvider(ATHENS_EVM_RPC); const sc = SystemContract__factory.connect(systemContract, provider); @@ -159,22 +185,25 @@ const fetchAthensAddresses = async ( athens["uniswapv2FactoryAddress"] = await sc.uniswapv2FactoryAddress(); athens["wZetaContractAddress"] = await sc.wZetaContractAddress(); athens["uniswapv2Router02Address"] = await sc.uniswapv2Router02Address(); + athens["zetaConnectorZEVMAddress"] = await sc.zetaConnectorZEVMAddress(); + athens["fungibleModuleAddress"] = await sc.FUNGIBLE_MODULE_ADDRESS(); } catch (error) { - console.error("Error fetching addresses from Athens:", error); + console.error("Error fetching addresses from ZetaChain:", error); } } else { - console.error("Athens system contract not found."); + console.error("ZetaChain system contract not found."); } }; const main = async (args: any, hre: HardhatRuntimeEnvironment) => { - const chainObject: ChainObject = {}; + const chainObject: any = {}; await fetchChains(chainObject); await fetchTssData(chainObject); await fetchSystemContract(chainObject); await fetchForeignCoinsData(chainObject); await fetchAthensAddresses(chainObject, hre); + await fetchChainSpecificAddresses(chainObject); console.log(JSON.stringify(chainObject, null, 2)); }; From 32e4912f74a13b6278f0a1e6ddf3afc8c221edf7 Mon Sep 17 00:00:00 2001 From: Denis Fadeev Date: Wed, 10 Jan 2024 11:22:35 +0400 Subject: [PATCH 03/27] remove zetacore from url --- package.json | 3 ++- tasks/addresses.ts | 65 ++++++++++++---------------------------------- yarn.lock | 28 ++++++++++++++++++++ 3 files changed, 47 insertions(+), 49 deletions(-) diff --git a/package.json b/package.json index 9e7bde0a..94e7504c 100644 --- a/package.json +++ b/package.json @@ -23,6 +23,7 @@ "@uniswap/v2-periphery": "^1.1.0-beta.0", "@uniswap/v3-periphery": "^1.4.3", "@zetachain/networks": "^2.4.3", + "axios": "^1.6.5", "chai": "^4.3.6", "cpx": "^1.5.0", "del-cli": "^5.0.0", @@ -79,4 +80,4 @@ }, "types": "./dist/lib/index.d.ts", "version": "0.0.8" -} \ No newline at end of file +} diff --git a/tasks/addresses.ts b/tasks/addresses.ts index 9da84647..3f40844e 100644 --- a/tasks/addresses.ts +++ b/tasks/addresses.ts @@ -11,8 +11,7 @@ import { import { ZetaConnector__factory } from "dist/typechain-types"; import { zetaConnectorNonEthSol } from "typechain-types/factories/contracts/evm"; -const ATHENS_EVM_RPC = - "https://zetachain-athens-evm.blockpi.network/v1/rpc/public"; +const ATHENS_EVM_RPC = "https://zetachain-athens-evm.blockpi.network/v1/rpc/public"; const ATHENS_TENDERMINT_RPC = "http://46.4.15.110:1317"; const fetchChains = async (chainObject: any) => { @@ -28,11 +27,7 @@ const fetchChains = async (chainObject: any) => { }; }); } else { - console.error( - "Error fetching chains:", - response.status, - response.statusText - ); + console.error("Error fetching chains:", response.status, response.statusText); } } catch (error) { console.error("Error fetching chains:", error); @@ -40,7 +35,7 @@ const fetchChains = async (chainObject: any) => { }; const fetchTssData = async (chainObject: any) => { - const URL = `${ATHENS_TENDERMINT_RPC}/zeta-chain/zetacore/crosschain/get_tss_address`; + const URL = `${ATHENS_TENDERMINT_RPC}/zeta-chain/crosschain/get_tss_address`; try { const tssResponse: AxiosResponse = await axios.get(URL); @@ -51,11 +46,7 @@ const fetchTssData = async (chainObject: any) => { chainObject[chain]["tss"] = chain.includes("btc") ? btc : eth; } } else { - console.error( - "Error fetching TSS data:", - tssResponse.status, - tssResponse.statusText - ); + console.error("Error fetching TSS data:", tssResponse.status, tssResponse.statusText); } } catch (error) { console.error("Error fetching TSS data:", error); @@ -63,7 +54,7 @@ const fetchTssData = async (chainObject: any) => { }; const fetchSystemContract = async (chainObject: any) => { - const URL = `${ATHENS_TENDERMINT_RPC}/zeta-chain/zetacore/fungible/system_contract`; + const URL = `${ATHENS_TENDERMINT_RPC}/zeta-chain/fungible/system_contract`; try { const systemContractResponse: AxiosResponse = await axios.get(URL); @@ -71,15 +62,10 @@ const fetchSystemContract = async (chainObject: any) => { if (!chainObject["zeta_testnet"]) { chainObject["zeta_testnet"] = {}; } - chainObject["zeta_testnet"]["systemContract"] = - systemContractResponse.data.SystemContract.system_contract; - chainObject["zeta_testnet"]["connectorZEVM"] = - systemContractResponse.data.SystemContract.connector_zevm; + chainObject["zeta_testnet"]["systemContract"] = systemContractResponse.data.SystemContract.system_contract; + chainObject["zeta_testnet"]["connectorZEVM"] = systemContractResponse.data.SystemContract.connector_zevm; } else { - console.error( - "Error fetching system contract:", - systemContractResponse.statusText - ); + console.error("Error fetching system contract:", systemContractResponse.statusText); } } catch (error) { console.error("Error fetching system contract:", error); @@ -87,7 +73,7 @@ const fetchSystemContract = async (chainObject: any) => { }; const fetchForeignCoinsData = async (chainObject: any) => { - const URL = `${ATHENS_TENDERMINT_RPC}/zeta-chain/zetacore/fungible/foreign_coins`; + const URL = `${ATHENS_TENDERMINT_RPC}/zeta-chain/fungible/foreign_coins`; try { const foreignCoinsResponse: AxiosResponse = await axios.get(URL); if (foreignCoinsResponse.status === 200) { @@ -102,21 +88,14 @@ const fetchForeignCoinsData = async (chainObject: any) => { } }); } else { - console.error( - "Error fetching foreign coins data:", - foreignCoinsResponse.status, - foreignCoinsResponse.statusText - ); + console.error("Error fetching foreign coins data:", foreignCoinsResponse.status, foreignCoinsResponse.statusText); } } catch (error) { console.error("Error fetching foreign coins data:", error); } }; -const fetchAthensAddresses = async ( - chainObject: any, - hre: HardhatRuntimeEnvironment -) => { +const fetchAthensAddresses = async (chainObject: any, hre: HardhatRuntimeEnvironment) => { const zeta = "zeta_testnet"; if (chainObject[zeta] && chainObject[zeta]["systemContract"]) { const athens = chainObject[zeta]; @@ -138,25 +117,18 @@ const fetchAthensAddresses = async ( }; const fetchChainSpecificAddresses = async (chainObject: any) => { - const URL = `${ATHENS_TENDERMINT_RPC}/zeta-chain/zetacore/observer/get_client_params_for_chain`; + const URL = `${ATHENS_TENDERMINT_RPC}/zeta-chain/observer/get_client_params_for_chain`; try { for (const chain in chainObject) { if (chain.includes("zeta") || chain.includes("btc")) continue; const id = chainObject[chain].chainId; const response: AxiosResponse = await axios.get(`${URL}/${id}`); if (response.status === 200) { - chainObject[chain]["zetaTokenContractAddress"] = - response.data.core_params.zeta_token_contract_address; - chainObject[chain]["connectorContractAddress"] = - response.data.core_params.connector_contract_address; - chainObject[chain]["erc20CustodyContractAddress"] = - response.data.core_params.erc20_custody_contract_address; + chainObject[chain]["zetaTokenContractAddress"] = response.data.core_params.zeta_token_contract_address; + chainObject[chain]["connectorContractAddress"] = response.data.core_params.connector_contract_address; + chainObject[chain]["erc20CustodyContractAddress"] = response.data.core_params.erc20_custody_contract_address; } else { - console.error( - "Error fetching chain data:", - response.status, - response.statusText - ); + console.error("Error fetching chain data:", response.status, response.statusText); } } } catch (error) { @@ -164,10 +136,7 @@ const fetchChainSpecificAddresses = async (chainObject: any) => { } }; -const fetchPauserUpdater = async ( - chainObject: any, - hre: HardhatRuntimeEnvironment -) => { +const fetchPauserUpdater = async (chainObject: any, hre: HardhatRuntimeEnvironment) => { try { for (const chain in chainObject) { const provider = new hre.ethers.providers.JsonRpcProvider(ATHENS_EVM_RPC); diff --git a/yarn.lock b/yarn.lock index 6a8cfffc..8172cd4b 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2497,6 +2497,15 @@ aws4@^1.8.0: resolved "https://registry.yarnpkg.com/aws4/-/aws4-1.12.0.tgz#ce1c9d143389679e253b314241ea9aa5cec980d3" integrity sha512-NmWvPnx0F1SfrQbYwOi7OeaNGokp9XhzNioJ/CSBs8Qa4vxug81mhJEAVZwxXuBmYB5KDRfMq/F3RR0BIU7sWg== +axios@^1.6.5: + version "1.6.5" + resolved "https://registry.yarnpkg.com/axios/-/axios-1.6.5.tgz#2c090da14aeeab3770ad30c3a1461bc970fb0cd8" + integrity sha512-Ii012v05KEVuUoFWmMW/UQv9aRIc3ZwkWDcM+h5Il8izZCtRVpDUfwpoFf7eOtajT3QiGR4yDUx7lPqHJULgbg== + dependencies: + follow-redirects "^1.15.4" + form-data "^4.0.0" + proxy-from-env "^1.1.0" + babel-runtime@^6.9.2: version "6.26.0" resolved "https://registry.yarnpkg.com/babel-runtime/-/babel-runtime-6.26.0.tgz#965c7058668e82b55d7bfe04ff2337bc8b5647fe" @@ -4496,6 +4505,11 @@ follow-redirects@^1.12.1: resolved "https://registry.yarnpkg.com/follow-redirects/-/follow-redirects-1.15.2.tgz#b460864144ba63f2681096f274c4e57026da2c13" integrity sha512-VQLG33o04KaQ8uYi2tVNbdrWp1QWxNNea+nmIB4EVM28v0hmP17z7aG1+wAkNzVq4KeXTq3221ye5qTJP91JwA== +follow-redirects@^1.15.4: + version "1.15.4" + resolved "https://registry.yarnpkg.com/follow-redirects/-/follow-redirects-1.15.4.tgz#cdc7d308bf6493126b17ea2191ea0ccf3e535adf" + integrity sha512-Cr4D/5wlrb0z9dgERpUL3LrmPKVDsETIJhaCMeDfuFYcqa5bldGV6wBsAN6X/vxlXQtFBMrXdXxdL8CbDTGniw== + for-each@^0.3.3: version "0.3.3" resolved "https://registry.yarnpkg.com/for-each/-/for-each-0.3.3.tgz#69b447e88a0a5d32c3e7084f3f1710034b21376e" @@ -4538,6 +4552,15 @@ form-data@^3.0.0: combined-stream "^1.0.8" mime-types "^2.1.12" +form-data@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/form-data/-/form-data-4.0.0.tgz#93919daeaf361ee529584b9b31664dc12c9fa452" + integrity sha512-ETEklSGi5t0QMZuiXoA/Q6vcnxcLQP5vdugSpuAyi6SVGi2clPPp+xgEhuMaHC+zGgn31Kd235W35f7Hykkaww== + dependencies: + asynckit "^0.4.0" + combined-stream "^1.0.8" + mime-types "^2.1.12" + form-data@~2.3.2: version "2.3.3" resolved "https://registry.yarnpkg.com/form-data/-/form-data-2.3.3.tgz#dcce52c05f644f298c6a7ab936bd724ceffbf3a6" @@ -7108,6 +7131,11 @@ promise@^8.0.0: dependencies: asap "~2.0.6" +proxy-from-env@^1.1.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/proxy-from-env/-/proxy-from-env-1.1.0.tgz#e102f16ca355424865755d2c9e8ea4f24d58c3e2" + integrity sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg== + prr@~1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/prr/-/prr-1.0.1.tgz#d3fc114ba06995a45ec6893f484ceb1d78f5f476" From c226039f4541932155f70e3a47ed30f3db8839d1 Mon Sep 17 00:00:00 2001 From: Denis Fadeev Date: Wed, 10 Jan 2024 11:33:46 +0400 Subject: [PATCH 04/27] remove yarn clean --- package.json | 9 ++++----- tasks/addresses.ts | 2 +- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/package.json b/package.json index 94e7504c..27768c18 100644 --- a/package.json +++ b/package.json @@ -68,16 +68,15 @@ "registry": "https://registry.npmjs.org/" }, "scripts": { - "build": "yarn clean && yarn compile && npx del-cli dist abi && tsc || exit 0 && npx del-cli './dist/typechain-types/**/*.js' && npx cpx './data/**/*' dist/data && npx cpx './artifacts/contracts/**/*' ./abi && npx del-cli './abi/**/*.dbg.json'", - "clean": "npx hardhat clean", - "compile": "yarn clean && npx hardhat compile", + "build": "yarn compile && npx del-cli dist abi && tsc || exit 0 && npx del-cli './dist/typechain-types/**/*.js' && npx cpx './data/**/*' dist/data && npx cpx './artifacts/contracts/**/*' ./abi && npx del-cli './abi/**/*.dbg.json'", + "compile": "npx hardhat compile --force", "generate": "yarn compile && ./scripts/generate_go.sh", "lint": "npx eslint . --ext .js,.ts", "lint:fix": "npx eslint . --ext .js,.ts,.json --fix", "prepublishOnly": "yarn build", - "test": "npx hardhat clean && npx hardhat test", + "test": "yarn compile && npx hardhat test", "tsc:watch": "npx tsc --watch" }, "types": "./dist/lib/index.d.ts", "version": "0.0.8" -} +} \ No newline at end of file diff --git a/tasks/addresses.ts b/tasks/addresses.ts index 3f40844e..ace71054 100644 --- a/tasks/addresses.ts +++ b/tasks/addresses.ts @@ -8,7 +8,7 @@ import { ZetaConnectorNonEth__factory, ZetaConnectorZEVM__factory, } from "@typechain-types"; -import { ZetaConnector__factory } from "dist/typechain-types"; +import { ZetaConnector__factory } from "../typechain-types"; import { zetaConnectorNonEthSol } from "typechain-types/factories/contracts/evm"; const ATHENS_EVM_RPC = "https://zetachain-athens-evm.blockpi.network/v1/rpc/public"; From 7ba85a919a2975d03b5023bbc95ec5017fc59d7d Mon Sep 17 00:00:00 2001 From: Denis Fadeev Date: Wed, 10 Jan 2024 16:20:36 +0400 Subject: [PATCH 05/27] update script --- tasks/addresses.ts | 240 ++++++++++++++++++++++++++------------------- 1 file changed, 140 insertions(+), 100 deletions(-) diff --git a/tasks/addresses.ts b/tasks/addresses.ts index ace71054..cbd5424b 100644 --- a/tasks/addresses.ts +++ b/tasks/addresses.ts @@ -1,6 +1,7 @@ import { task } from "hardhat/config"; import { HardhatRuntimeEnvironment } from "hardhat/types"; import axios, { AxiosResponse } from "axios"; +import { ERC20Custody__factory } from "../typechain-types/factories/contracts/evm/ERC20Custody__factory"; import { SystemContract__factory } from "../typechain-types/factories/contracts/zevm/SystemContract.sol/SystemContract__factory"; import { ZetaConnectorBase__factory, @@ -9,23 +10,19 @@ import { ZetaConnectorZEVM__factory, } from "@typechain-types"; import { ZetaConnector__factory } from "../typechain-types"; -import { zetaConnectorNonEthSol } from "typechain-types/factories/contracts/evm"; +import { zetaConnectorNonEthSol } from "../typechain-types/factories/contracts/evm"; +import { getEndpoints } from "@zetachain/networks"; const ATHENS_EVM_RPC = "https://zetachain-athens-evm.blockpi.network/v1/rpc/public"; -const ATHENS_TENDERMINT_RPC = "http://46.4.15.110:1317"; +const ATHENS_TENDERMINT_RPC = "https://zetachain-athens.blockpi.network/lcd/v1/public"; -const fetchChains = async (chainObject: any) => { +const fetchChains = async () => { const URL = `${ATHENS_TENDERMINT_RPC}/zeta-chain/observer/supportedChains`; try { const response: AxiosResponse = await axios.get(URL); if (response.status === 200) { - const chains: string[] = response.data.chains; - chains.forEach((chain: any) => { - chainObject[chain.chain_name.toLowerCase()] = { - chainId: chain.chain_id, - }; - }); + return response.data.chains; } else { console.error("Error fetching chains:", response.status, response.statusText); } @@ -34,17 +31,23 @@ const fetchChains = async (chainObject: any) => { } }; -const fetchTssData = async (chainObject: any) => { +const fetchTssData = async (chains: any, addresses: any) => { const URL = `${ATHENS_TENDERMINT_RPC}/zeta-chain/crosschain/get_tss_address`; try { const tssResponse: AxiosResponse = await axios.get(URL); if (tssResponse.status === 200) { - for (const chain in chainObject) { + chains.forEach((chain: any) => { const { btc, eth } = tssResponse.data; - if (chain.includes("zeta")) continue; - chainObject[chain]["tss"] = chain.includes("btc") ? btc : eth; - } + if (chain.chain_name === "zeta_testnet") return; + addresses.push({ + chain_id: chain.chain_id, + chain_name: chain.chain_name, + type: "tss", + category: "omnichain", + address: chain.chain_name === "btc_testnet" ? btc : eth, + }); + }); } else { console.error("Error fetching TSS data:", tssResponse.status, tssResponse.statusText); } @@ -53,17 +56,26 @@ const fetchTssData = async (chainObject: any) => { } }; -const fetchSystemContract = async (chainObject: any) => { +const fetchSystemContract = async (addresses: any) => { const URL = `${ATHENS_TENDERMINT_RPC}/zeta-chain/fungible/system_contract`; try { const systemContractResponse: AxiosResponse = await axios.get(URL); if (systemContractResponse.status === 200) { - if (!chainObject["zeta_testnet"]) { - chainObject["zeta_testnet"] = {}; - } - chainObject["zeta_testnet"]["systemContract"] = systemContractResponse.data.SystemContract.system_contract; - chainObject["zeta_testnet"]["connectorZEVM"] = systemContractResponse.data.SystemContract.connector_zevm; + addresses.push({ + chain_id: 7001, + chain_name: "zeta_testnet", + type: "systemContract", + category: "omnichain", + address: systemContractResponse.data.SystemContract.system_contract, + }); + addresses.push({ + chain_id: 7001, + chain_name: "zeta_testnet", + type: "connectorZEVM", + category: "messaging", + address: systemContractResponse.data.SystemContract.connector_zevm, + }); } else { console.error("Error fetching system contract:", systemContractResponse.statusText); } @@ -72,20 +84,32 @@ const fetchSystemContract = async (chainObject: any) => { } }; -const fetchForeignCoinsData = async (chainObject: any) => { +const fetchForeignCoinsData = async (chains: any, addresses: any) => { const URL = `${ATHENS_TENDERMINT_RPC}/zeta-chain/fungible/foreign_coins`; try { const foreignCoinsResponse: AxiosResponse = await axios.get(URL); if (foreignCoinsResponse.status === 200) { - foreignCoinsResponse.data.foreignCoins.forEach((coin: any) => { - for (const key in chainObject) { - if (chainObject.hasOwnProperty(key)) { - const chain = chainObject[key]; - if (chain.chainId === coin.foreign_chain_id) { - chain.zrc20ContractAddress = coin.zrc20_contract_address; - } - } - } + foreignCoinsResponse.data.foreignCoins.forEach((token: any) => { + addresses.push({ + chain_id: token.foreign_chain_id, + chain_name: chains.find((c: any) => c.chain_id === token.foreign_chain_id)?.chain_name, + coin_type: token.coin_type, + address: token.asset, + symbol: token.symbol, + zrc20: token.zrc20_contract_address, + category: "omnichain", + decimals: token.decimals, // TODO: dynamically fetch from contract (to verify) + }); + addresses.push({ + chain_id: 7001, + chain_name: "zeta_testnet", + coin_type: "ZRC20", + address: token.zrc20_contract_address, + symbol: token.name, + asset: token.asset, + category: "omnichain", + decimals: 18, // TODO: dynamically fetch from contract + }); }); } else { console.error("Error fetching foreign coins data:", foreignCoinsResponse.status, foreignCoinsResponse.statusText); @@ -95,86 +119,102 @@ const fetchForeignCoinsData = async (chainObject: any) => { } }; -const fetchAthensAddresses = async (chainObject: any, hre: HardhatRuntimeEnvironment) => { - const zeta = "zeta_testnet"; - if (chainObject[zeta] && chainObject[zeta]["systemContract"]) { - const athens = chainObject[zeta]; - const systemContract = athens["systemContract"] as string; - const provider = new hre.ethers.providers.JsonRpcProvider(ATHENS_EVM_RPC); - const sc = SystemContract__factory.connect(systemContract, provider); - try { - athens["uniswapv2FactoryAddress"] = await sc.uniswapv2FactoryAddress(); - athens["wZetaContractAddress"] = await sc.wZetaContractAddress(); - athens["uniswapv2Router02Address"] = await sc.uniswapv2Router02Address(); - athens["zetaConnectorZEVMAddress"] = await sc.zetaConnectorZEVMAddress(); - athens["fungibleModuleAddress"] = await sc.FUNGIBLE_MODULE_ADDRESS(); - } catch (error) { - console.error("Error fetching addresses from ZetaChain:", error); - } - } else { - console.error("ZetaChain system contract not found."); - } -}; - -const fetchChainSpecificAddresses = async (chainObject: any) => { - const URL = `${ATHENS_TENDERMINT_RPC}/zeta-chain/observer/get_client_params_for_chain`; +const fetchAthensAddresses = async (addresses: any, hre: HardhatRuntimeEnvironment) => { + const systemContract = addresses.find((a: any) => { + return a.chain_name === "zeta_testnet" && a.type === "systemContract"; + })?.address; + const provider = new hre.ethers.providers.JsonRpcProvider(ATHENS_EVM_RPC); + const sc = SystemContract__factory.connect(systemContract, provider); + const common = { + chain_id: 7001, + chain_name: "zeta_testnet", + category: "omnichain", + }; try { - for (const chain in chainObject) { - if (chain.includes("zeta") || chain.includes("btc")) continue; - const id = chainObject[chain].chainId; - const response: AxiosResponse = await axios.get(`${URL}/${id}`); - if (response.status === 200) { - chainObject[chain]["zetaTokenContractAddress"] = response.data.core_params.zeta_token_contract_address; - chainObject[chain]["connectorContractAddress"] = response.data.core_params.connector_contract_address; - chainObject[chain]["erc20CustodyContractAddress"] = response.data.core_params.erc20_custody_contract_address; - } else { - console.error("Error fetching chain data:", response.status, response.statusText); - } - } + addresses.push({ ...common, type: "uniswapv2FactoryAddress", address: await sc.uniswapv2FactoryAddress() }); + addresses.push({ ...common, type: "wZetaContractAddress", address: await sc.wZetaContractAddress() }); + addresses.push({ ...common, type: "uniswapv2Router02Address", address: await sc.uniswapv2Router02Address() }); + addresses.push({ ...common, type: "zetaConnectorZEVMAddress", address: await sc.zetaConnectorZEVMAddress() }); + addresses.push({ ...common, type: "fungibleModuleAddress", address: await sc.FUNGIBLE_MODULE_ADDRESS() }); } catch (error) { - console.error("Error fetching chain data:", error); + console.error("Error fetching addresses from ZetaChain:", error); } }; -const fetchPauserUpdater = async (chainObject: any, hre: HardhatRuntimeEnvironment) => { - try { - for (const chain in chainObject) { - const provider = new hre.ethers.providers.JsonRpcProvider(ATHENS_EVM_RPC); - } - } catch (error) { - console.error("Error fetching addresses from ZetaChain:", error); - } - const zeta = "zeta_testnet"; - if (chainObject[zeta] && chainObject[zeta]["systemContract"]) { - const athens = chainObject[zeta]; - const systemContract = athens["systemContract"] as string; - const provider = new hre.ethers.providers.JsonRpcProvider(ATHENS_EVM_RPC); - const sc = SystemContract__factory.connect(systemContract, provider); - try { - athens["uniswapv2FactoryAddress"] = await sc.uniswapv2FactoryAddress(); - athens["wZetaContractAddress"] = await sc.wZetaContractAddress(); - athens["uniswapv2Router02Address"] = await sc.uniswapv2Router02Address(); - athens["zetaConnectorZEVMAddress"] = await sc.zetaConnectorZEVMAddress(); - athens["fungibleModuleAddress"] = await sc.FUNGIBLE_MODULE_ADDRESS(); - } catch (error) { - console.error("Error fetching addresses from ZetaChain:", error); - } - } else { - console.error("ZetaChain system contract not found."); - } +const fetchChainSpecificAddresses = async (chains: any, addresses: any) => { + await Promise.all( + chains.map(async (chain: any) => { + return axios + .get(`${ATHENS_TENDERMINT_RPC}/zeta-chain/observer/get_client_params_for_chain/${chain.chain_id}`) + .then(({ data }) => { + if (data.core_params.zeta_token_contract_address) { + addresses.push({ + chain_id: chain.chain_id, + chain_name: chain.chain_name, + category: "messaging", + type: "zetaToken", + address: data.core_params.zeta_token_contract_address, + }); + } + if (data.core_params.connector_contract_address) { + addresses.push({ + chain_id: chain.chain_id, + chain_name: chain.chain_name, + category: "messaging", + type: "connector", + address: data.core_params.connector_contract_address, + }); + } + if (data.core_params.erc20_custody_contract_address) { + addresses.push({ + chain_id: chain.chain_id, + category: "omnichain", + chain_name: chain.chain_name, + type: "erc20Custody", + address: data.core_params.erc20_custody_contract_address, + }); + } + }); + }) + ); +}; + +const fetchTSSUpdater = async (chains: any, addresses: any) => { + await Promise.all( + chains.map(async (chain: any) => { + const erc20Custody = addresses.find((a: any) => { + return a.chain_name === chain.chain_name && a.type === "erc20Custody"; + })?.address; + if (erc20Custody) { + const rpc = getEndpoints("evm", chain.chain_name)[0]?.url; + const provider = new hre.ethers.providers.JsonRpcProvider(rpc); + const custody = ERC20Custody__factory.connect(erc20Custody, provider); + return custody.TSSAddressUpdater().then((address: string) => { + addresses.push({ + chain_id: chain.chain_id, + chain_name: chain.chain_name, + category: "omnichain", + type: "tssUpdater", + address, + }); + }); + } + }) + ); }; const main = async (args: any, hre: HardhatRuntimeEnvironment) => { - const chainObject: any = {}; + const addresses: any = []; - await fetchChains(chainObject); - await fetchTssData(chainObject); - await fetchSystemContract(chainObject); - await fetchForeignCoinsData(chainObject); - await fetchAthensAddresses(chainObject, hre); - await fetchChainSpecificAddresses(chainObject); + const chains = await fetchChains(); + await fetchTssData(chains, addresses); + await fetchSystemContract(addresses); + await fetchForeignCoinsData(chains, addresses); + await fetchAthensAddresses(addresses, hre); + await fetchChainSpecificAddresses(chains, addresses); + await fetchTSSUpdater(chains, addresses); - console.log(JSON.stringify(chainObject, null, 2)); + console.log(JSON.stringify(addresses, null, 2)); }; task("addresses", "").setAction(main); From 2b9db527d9185ac0ab296bc76f29890acb63be81 Mon Sep 17 00:00:00 2001 From: Denis Fadeev Date: Fri, 2 Feb 2024 14:21:00 +0400 Subject: [PATCH 06/27] fixes --- tasks/addresses.ts | 44 ++++++++++++++++++++++++-------------------- 1 file changed, 24 insertions(+), 20 deletions(-) diff --git a/tasks/addresses.ts b/tasks/addresses.ts index cbd5424b..81511c36 100644 --- a/tasks/addresses.ts +++ b/tasks/addresses.ts @@ -13,11 +13,11 @@ import { ZetaConnector__factory } from "../typechain-types"; import { zetaConnectorNonEthSol } from "../typechain-types/factories/contracts/evm"; import { getEndpoints } from "@zetachain/networks"; -const ATHENS_EVM_RPC = "https://zetachain-athens-evm.blockpi.network/v1/rpc/public"; -const ATHENS_TENDERMINT_RPC = "https://zetachain-athens.blockpi.network/lcd/v1/public"; +const EVM_RPC = "https://zetachain-athens-evm.blockpi.network/v1/rpc/public"; +const CONSENSUS_API = "https://zetachain-athens.blockpi.network/lcd/v1/public"; const fetchChains = async () => { - const URL = `${ATHENS_TENDERMINT_RPC}/zeta-chain/observer/supportedChains`; + const URL = `${CONSENSUS_API}/zeta-chain/observer/supportedChains`; try { const response: AxiosResponse = await axios.get(URL); @@ -32,7 +32,7 @@ const fetchChains = async () => { }; const fetchTssData = async (chains: any, addresses: any) => { - const URL = `${ATHENS_TENDERMINT_RPC}/zeta-chain/crosschain/get_tss_address`; + const URL = `${CONSENSUS_API}/zeta-chain/observer/get_tss_address/18332`; try { const tssResponse: AxiosResponse = await axios.get(URL); @@ -57,7 +57,7 @@ const fetchTssData = async (chains: any, addresses: any) => { }; const fetchSystemContract = async (addresses: any) => { - const URL = `${ATHENS_TENDERMINT_RPC}/zeta-chain/fungible/system_contract`; + const URL = `${CONSENSUS_API}/zeta-chain/fungible/system_contract`; try { const systemContractResponse: AxiosResponse = await axios.get(URL); @@ -85,7 +85,7 @@ const fetchSystemContract = async (addresses: any) => { }; const fetchForeignCoinsData = async (chains: any, addresses: any) => { - const URL = `${ATHENS_TENDERMINT_RPC}/zeta-chain/fungible/foreign_coins`; + const URL = `${CONSENSUS_API}/zeta-chain/fungible/foreign_coins`; try { const foreignCoinsResponse: AxiosResponse = await axios.get(URL); if (foreignCoinsResponse.status === 200) { @@ -123,7 +123,7 @@ const fetchAthensAddresses = async (addresses: any, hre: HardhatRuntimeEnvironme const systemContract = addresses.find((a: any) => { return a.chain_name === "zeta_testnet" && a.type === "systemContract"; })?.address; - const provider = new hre.ethers.providers.JsonRpcProvider(ATHENS_EVM_RPC); + const provider = new hre.ethers.providers.JsonRpcProvider(EVM_RPC); const sc = SystemContract__factory.connect(systemContract, provider); const common = { chain_id: 7001, @@ -145,33 +145,36 @@ const fetchChainSpecificAddresses = async (chains: any, addresses: any) => { await Promise.all( chains.map(async (chain: any) => { return axios - .get(`${ATHENS_TENDERMINT_RPC}/zeta-chain/observer/get_client_params_for_chain/${chain.chain_id}`) + .get(`${CONSENSUS_API}/zeta-chain/observer/get_chain_params_for_chain/${chain.chain_id}`) .then(({ data }) => { - if (data.core_params.zeta_token_contract_address) { + if (data.chain_params.zeta_token_contract_address) { addresses.push({ chain_id: chain.chain_id, chain_name: chain.chain_name, category: "messaging", type: "zetaToken", - address: data.core_params.zeta_token_contract_address, + address: data.chain_params.zeta_token_contract_address, }); } - if (data.core_params.connector_contract_address) { - addresses.push({ - chain_id: chain.chain_id, - chain_name: chain.chain_name, - category: "messaging", - type: "connector", - address: data.core_params.connector_contract_address, - }); + if (data.chain_params.connector_contract_address) { + const address = data.chain_params.connector_contract_address; + if (address != "0x0000000000000000000000000000000000000000") { + addresses.push({ + chain_id: chain.chain_id, + chain_name: chain.chain_name, + category: "messaging", + type: "connector", + address: data.chain_params.connector_contract_address, + }); + } } - if (data.core_params.erc20_custody_contract_address) { + if (data.chain_params.erc20_custody_contract_address) { addresses.push({ chain_id: chain.chain_id, category: "omnichain", chain_name: chain.chain_name, type: "erc20Custody", - address: data.core_params.erc20_custody_contract_address, + address: data.chain_params.erc20_custody_contract_address, }); } }); @@ -186,6 +189,7 @@ const fetchTSSUpdater = async (chains: any, addresses: any) => { return a.chain_name === chain.chain_name && a.type === "erc20Custody"; })?.address; if (erc20Custody) { + if (["18332", "8332"].includes(chain.chain_id)) return; const rpc = getEndpoints("evm", chain.chain_name)[0]?.url; const provider = new hre.ethers.providers.JsonRpcProvider(rpc); const custody = ERC20Custody__factory.connect(erc20Custody, provider); From 2be508702a5954a96873b0507ada8654458791b7 Mon Sep 17 00:00:00 2001 From: Denis Fadeev Date: Fri, 2 Feb 2024 17:16:53 +0400 Subject: [PATCH 07/27] refactor --- tasks/addresses.ts | 158 ++++++++++++++++++++++++--------------------- 1 file changed, 85 insertions(+), 73 deletions(-) diff --git a/tasks/addresses.ts b/tasks/addresses.ts index 81511c36..4de13c38 100644 --- a/tasks/addresses.ts +++ b/tasks/addresses.ts @@ -1,23 +1,26 @@ +import { getEndpoints } from "@zetachain/networks"; +import axios, { AxiosResponse } from "axios"; import { task } from "hardhat/config"; import { HardhatRuntimeEnvironment } from "hardhat/types"; -import axios, { AxiosResponse } from "axios"; + import { ERC20Custody__factory } from "../typechain-types/factories/contracts/evm/ERC20Custody__factory"; import { SystemContract__factory } from "../typechain-types/factories/contracts/zevm/SystemContract.sol/SystemContract__factory"; -import { - ZetaConnectorBase__factory, - ZetaConnectorEth__factory, - ZetaConnectorNonEth__factory, - ZetaConnectorZEVM__factory, -} from "@typechain-types"; -import { ZetaConnector__factory } from "../typechain-types"; -import { zetaConnectorNonEthSol } from "../typechain-types/factories/contracts/evm"; -import { getEndpoints } from "@zetachain/networks"; -const EVM_RPC = "https://zetachain-athens-evm.blockpi.network/v1/rpc/public"; -const CONSENSUS_API = "https://zetachain-athens.blockpi.network/lcd/v1/public"; +type Network = "zeta_mainnet" | "zeta_testnet"; + +const api = { + zeta_mainnet: { + evm: "https://zetachain-evm.blockpi.network/v1/rpc/public", + rpc: "https://zetachain.blockpi.network/lcd/v1/public", + }, + zeta_testnet: { + evm: "https://zetachain-athens-evm.blockpi.network/v1/rpc/public", + rpc: "https://zetachain-athens.blockpi.network/lcd/v1/public", + }, +}; -const fetchChains = async () => { - const URL = `${CONSENSUS_API}/zeta-chain/observer/supportedChains`; +const fetchChains = async (network: Network) => { + const URL = `${api[network].rpc}/zeta-chain/observer/supportedChains`; try { const response: AxiosResponse = await axios.get(URL); @@ -31,8 +34,8 @@ const fetchChains = async () => { } }; -const fetchTssData = async (chains: any, addresses: any) => { - const URL = `${CONSENSUS_API}/zeta-chain/observer/get_tss_address/18332`; +const fetchTssData = async (chains: any, addresses: any, network: Network) => { + const URL = `${api[network].rpc}/zeta-chain/observer/get_tss_address/18332`; try { const tssResponse: AxiosResponse = await axios.get(URL); @@ -41,11 +44,11 @@ const fetchTssData = async (chains: any, addresses: any) => { const { btc, eth } = tssResponse.data; if (chain.chain_name === "zeta_testnet") return; addresses.push({ + address: chain.chain_name === "btc_testnet" ? btc : eth, + category: "omnichain", chain_id: chain.chain_id, chain_name: chain.chain_name, type: "tss", - category: "omnichain", - address: chain.chain_name === "btc_testnet" ? btc : eth, }); }); } else { @@ -56,25 +59,26 @@ const fetchTssData = async (chains: any, addresses: any) => { } }; -const fetchSystemContract = async (addresses: any) => { - const URL = `${CONSENSUS_API}/zeta-chain/fungible/system_contract`; +const fetchSystemContract = async (addresses: any, network: Network) => { + const chain_id = network === "zeta_mainnet" ? 7000 : 7001; + const URL = `${api[network].rpc}/zeta-chain/fungible/system_contract`; try { const systemContractResponse: AxiosResponse = await axios.get(URL); if (systemContractResponse.status === 200) { addresses.push({ - chain_id: 7001, + address: systemContractResponse.data.SystemContract.system_contract, + category: "omnichain", + chain_id, chain_name: "zeta_testnet", type: "systemContract", - category: "omnichain", - address: systemContractResponse.data.SystemContract.system_contract, }); addresses.push({ - chain_id: 7001, + address: systemContractResponse.data.SystemContract.connector_zevm, + category: "messaging", + chain_id, chain_name: "zeta_testnet", type: "connectorZEVM", - category: "messaging", - address: systemContractResponse.data.SystemContract.connector_zevm, }); } else { console.error("Error fetching system contract:", systemContractResponse.statusText); @@ -84,31 +88,32 @@ const fetchSystemContract = async (addresses: any) => { } }; -const fetchForeignCoinsData = async (chains: any, addresses: any) => { - const URL = `${CONSENSUS_API}/zeta-chain/fungible/foreign_coins`; +const fetchForeignCoinsData = async (chains: any, addresses: any, network: Network) => { + const chain_id = network === "zeta_mainnet" ? 7000 : 7001; + const URL = `${api[network].rpc}/zeta-chain/fungible/foreign_coins`; try { const foreignCoinsResponse: AxiosResponse = await axios.get(URL); if (foreignCoinsResponse.status === 200) { foreignCoinsResponse.data.foreignCoins.forEach((token: any) => { addresses.push({ + address: token.asset, + category: "omnichain", chain_id: token.foreign_chain_id, chain_name: chains.find((c: any) => c.chain_id === token.foreign_chain_id)?.chain_name, coin_type: token.coin_type, - address: token.asset, + decimals: token.decimals, symbol: token.symbol, - zrc20: token.zrc20_contract_address, - category: "omnichain", - decimals: token.decimals, // TODO: dynamically fetch from contract (to verify) + zrc20: token.zrc20_contract_address, // TODO: dynamically fetch from contract (to verify) }); addresses.push({ - chain_id: 7001, - chain_name: "zeta_testnet", - coin_type: "ZRC20", address: token.zrc20_contract_address, - symbol: token.name, asset: token.asset, category: "omnichain", - decimals: 18, // TODO: dynamically fetch from contract + chain_id, + chain_name: "zeta_testnet", + coin_type: "ZRC20", + decimals: 18, + symbol: token.name, // TODO: dynamically fetch from contract }); }); } else { @@ -119,62 +124,63 @@ const fetchForeignCoinsData = async (chains: any, addresses: any) => { } }; -const fetchAthensAddresses = async (addresses: any, hre: HardhatRuntimeEnvironment) => { +const fetchAthensAddresses = async (addresses: any, hre: HardhatRuntimeEnvironment, network: Network) => { + const chain_id = network === "zeta_mainnet" ? 7000 : 7001; const systemContract = addresses.find((a: any) => { return a.chain_name === "zeta_testnet" && a.type === "systemContract"; })?.address; - const provider = new hre.ethers.providers.JsonRpcProvider(EVM_RPC); + const provider = new hre.ethers.providers.JsonRpcProvider(api[network].evm); const sc = SystemContract__factory.connect(systemContract, provider); const common = { - chain_id: 7001, - chain_name: "zeta_testnet", category: "omnichain", + chain_id, + chain_name: "zeta_testnet", }; try { - addresses.push({ ...common, type: "uniswapv2FactoryAddress", address: await sc.uniswapv2FactoryAddress() }); - addresses.push({ ...common, type: "wZetaContractAddress", address: await sc.wZetaContractAddress() }); - addresses.push({ ...common, type: "uniswapv2Router02Address", address: await sc.uniswapv2Router02Address() }); - addresses.push({ ...common, type: "zetaConnectorZEVMAddress", address: await sc.zetaConnectorZEVMAddress() }); - addresses.push({ ...common, type: "fungibleModuleAddress", address: await sc.FUNGIBLE_MODULE_ADDRESS() }); + addresses.push({ ...common, address: await sc.uniswapv2FactoryAddress(), type: "uniswapv2Factory" }); + addresses.push({ ...common, address: await sc.wZetaContractAddress(), type: "wZetaContract" }); + addresses.push({ ...common, address: await sc.uniswapv2Router02Address(), type: "uniswapv2Router02" }); + addresses.push({ ...common, address: await sc.zetaConnectorZEVMAddress(), type: "zetaConnectorZEVM" }); + addresses.push({ ...common, address: await sc.FUNGIBLE_MODULE_ADDRESS(), type: "fungibleModule" }); } catch (error) { console.error("Error fetching addresses from ZetaChain:", error); } }; -const fetchChainSpecificAddresses = async (chains: any, addresses: any) => { +const fetchChainSpecificAddresses = async (chains: any, addresses: any, network: Network) => { await Promise.all( chains.map(async (chain: any) => { return axios - .get(`${CONSENSUS_API}/zeta-chain/observer/get_chain_params_for_chain/${chain.chain_id}`) + .get(`${api[network].rpc}/zeta-chain/observer/get_chain_params_for_chain/${chain.chain_id}`) .then(({ data }) => { - if (data.chain_params.zeta_token_contract_address) { + const zetaToken = data.chain_params.zeta_token_contract_address; + if (zetaToken && zetaToken != "0x0000000000000000000000000000000000000000") { addresses.push({ + address: zetaToken, + category: "messaging", chain_id: chain.chain_id, chain_name: chain.chain_name, - category: "messaging", type: "zetaToken", - address: data.chain_params.zeta_token_contract_address, }); } - if (data.chain_params.connector_contract_address) { - const address = data.chain_params.connector_contract_address; - if (address != "0x0000000000000000000000000000000000000000") { - addresses.push({ - chain_id: chain.chain_id, - chain_name: chain.chain_name, - category: "messaging", - type: "connector", - address: data.chain_params.connector_contract_address, - }); - } - } - if (data.chain_params.erc20_custody_contract_address) { + const connector = data.chain_params.connector_contract_address; + if (connector && connector != "0x0000000000000000000000000000000000000000") { addresses.push({ + address: connector, + category: "messaging", chain_id: chain.chain_id, + chain_name: chain.chain_name, + type: "connector", + }); + } + const erc20Custody = data.chain_params.erc20_custody_contract_address; + if (erc20Custody && erc20Custody != "0x0000000000000000000000000000000000000000") { + addresses.push({ + address: data.chain_params.erc20_custody_contract_address, category: "omnichain", + chain_id: chain.chain_id, chain_name: chain.chain_name, type: "erc20Custody", - address: data.chain_params.erc20_custody_contract_address, }); } }); @@ -195,11 +201,11 @@ const fetchTSSUpdater = async (chains: any, addresses: any) => { const custody = ERC20Custody__factory.connect(erc20Custody, provider); return custody.TSSAddressUpdater().then((address: string) => { addresses.push({ + address, + category: "omnichain", chain_id: chain.chain_id, chain_name: chain.chain_name, - category: "omnichain", type: "tssUpdater", - address, }); }); } @@ -208,14 +214,20 @@ const fetchTSSUpdater = async (chains: any, addresses: any) => { }; const main = async (args: any, hre: HardhatRuntimeEnvironment) => { + const n = hre.network.name; + if (n !== "zeta_testnet" && n !== "zeta_mainnet") { + throw new Error(`Unsupported network: ${n}. Must be 'zeta_testnet' or 'zeta_mainnet'.`); + } + + const network: Network = n; const addresses: any = []; - const chains = await fetchChains(); - await fetchTssData(chains, addresses); - await fetchSystemContract(addresses); - await fetchForeignCoinsData(chains, addresses); - await fetchAthensAddresses(addresses, hre); - await fetchChainSpecificAddresses(chains, addresses); + const chains = await fetchChains(network); + await fetchTssData(chains, addresses, network); + await fetchSystemContract(addresses, network); + await fetchForeignCoinsData(chains, addresses, network); + await fetchAthensAddresses(addresses, hre, network); + await fetchChainSpecificAddresses(chains, addresses, network); await fetchTSSUpdater(chains, addresses); console.log(JSON.stringify(addresses, null, 2)); From c947f8f39343d6a2b877fea057131668f304a714 Mon Sep 17 00:00:00 2001 From: Denis Fadeev Date: Fri, 2 Feb 2024 17:17:15 +0400 Subject: [PATCH 08/27] lint --- data/addresses.json | 8 ++++---- hardhat.config.ts | 9 ++++----- package.json | 2 +- 3 files changed, 9 insertions(+), 10 deletions(-) diff --git a/data/addresses.json b/data/addresses.json index 3f204c42..08dc99f8 100644 --- a/data/addresses.json +++ b/data/addresses.json @@ -113,15 +113,15 @@ "bsc_testnet": { "zrc20": "0xd97B1de3619ed2c6BEb3860147E30cA8A7dC9891" }, + "btc_testnet": { + "zrc20": "0x65a45c57636f9BcCeD4fe193A602008578BcA90b" + }, "goerli_testnet": { "zrc20": "0x13A0c5930C028511Dc02665E7285134B6d11A5f4" }, "mumbai_testnet": { "zrc20": "0x48f80608B672DC30DC7e3dbBd0343c5F02C738Eb" }, - "btc_testnet": { - "zrc20": "0x65a45c57636f9BcCeD4fe193A602008578BcA90b" - }, "zeta_testnet": { "fungibleModule": "0x735b14BB79463307AAcBED86DAf3322B1e6226aB", "systemContract": "0xEdf1c3275d13489aCdC6cD6eD246E72458B8795B", @@ -129,4 +129,4 @@ "uniswapv2Router02": "0x2ca7d64A7EFE2D62A725E2B35Cf7230D6677FfEe" } } -} \ No newline at end of file +} diff --git a/hardhat.config.ts b/hardhat.config.ts index fafd83c9..7de96d4d 100644 --- a/hardhat.config.ts +++ b/hardhat.config.ts @@ -3,13 +3,12 @@ import "@nomiclabs/hardhat-etherscan"; import "@typechain/hardhat"; import "tsconfig-paths/register"; import "hardhat-abi-exporter"; +import "./tasks/addresses"; import { getHardhatConfigNetworks } from "@zetachain/networks"; import * as dotenv from "dotenv"; import type { HardhatUserConfig } from "hardhat/types"; -import "./tasks/addresses"; - dotenv.config(); const config: HardhatUserConfig = { @@ -31,22 +30,22 @@ const config: HardhatUserConfig = { { version: "0.4.19" /** For zevm/wzeta.sol */ }, { version: "0.5.10" /** For create2 factory */ }, { - version: "0.5.16", settings: { optimizer: { enabled: true, runs: 999999, }, }, + version: "0.5.16", }, { - version: "0.6.6", settings: { optimizer: { enabled: true, runs: 999999, }, - } /** For uniswap v2 */, + }, + version: "0.6.6" /** For uniswap v2 */, }, { version: "0.7.6" /** For uniswap v3 */ }, { version: "0.8.7" }, diff --git a/package.json b/package.json index 27768c18..6570cc24 100644 --- a/package.json +++ b/package.json @@ -79,4 +79,4 @@ }, "types": "./dist/lib/index.d.ts", "version": "0.0.8" -} \ No newline at end of file +} From dfc0eabb6ddcaa6bace101cc8f38d3f111642b3c Mon Sep 17 00:00:00 2001 From: Denis Fadeev Date: Fri, 2 Feb 2024 17:43:00 +0400 Subject: [PATCH 09/27] added pauser address --- tasks/addresses.ts | 31 +++++++++++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) diff --git a/tasks/addresses.ts b/tasks/addresses.ts index 4de13c38..b9b9e4f8 100644 --- a/tasks/addresses.ts +++ b/tasks/addresses.ts @@ -2,6 +2,7 @@ import { getEndpoints } from "@zetachain/networks"; import axios, { AxiosResponse } from "axios"; import { task } from "hardhat/config"; import { HardhatRuntimeEnvironment } from "hardhat/types"; +import { ZetaConnectorBase__factory } from "../typechain-types"; import { ERC20Custody__factory } from "../typechain-types/factories/contracts/evm/ERC20Custody__factory"; import { SystemContract__factory } from "../typechain-types/factories/contracts/zevm/SystemContract.sol/SystemContract__factory"; @@ -78,7 +79,7 @@ const fetchSystemContract = async (addresses: any, network: Network) => { category: "messaging", chain_id, chain_name: "zeta_testnet", - type: "connectorZEVM", + type: "connector", }); } else { console.error("Error fetching system contract:", systemContractResponse.statusText); @@ -140,7 +141,7 @@ const fetchAthensAddresses = async (addresses: any, hre: HardhatRuntimeEnvironme addresses.push({ ...common, address: await sc.uniswapv2FactoryAddress(), type: "uniswapv2Factory" }); addresses.push({ ...common, address: await sc.wZetaContractAddress(), type: "wZetaContract" }); addresses.push({ ...common, address: await sc.uniswapv2Router02Address(), type: "uniswapv2Router02" }); - addresses.push({ ...common, address: await sc.zetaConnectorZEVMAddress(), type: "zetaConnectorZEVM" }); + // addresses.push({ ...common, address: await sc.zetaConnectorZEVMAddress(), type: "zetaConnectorZEVM" }); addresses.push({ ...common, address: await sc.FUNGIBLE_MODULE_ADDRESS(), type: "fungibleModule" }); } catch (error) { console.error("Error fetching addresses from ZetaChain:", error); @@ -213,6 +214,31 @@ const fetchTSSUpdater = async (chains: any, addresses: any) => { ); }; +const fetchPauser = async (chains: any, addresses: any) => { + await Promise.all( + chains.map(async (chain: any) => { + const erc20Custody = addresses.find((a: any) => { + return a.chain_name === chain.chain_name && a.type === "connector"; + })?.address; + if (erc20Custody) { + if (["18332", "8332", "7001"].includes(chain.chain_id)) return; + const rpc = getEndpoints("evm", chain.chain_name)[0]?.url; + const provider = new hre.ethers.providers.JsonRpcProvider(rpc); + const connector = ZetaConnectorBase__factory.connect(erc20Custody, provider); + return connector.pauserAddress().then((address: string) => { + addresses.push({ + address, + category: "messaging", + chain_id: chain.chain_id, + chain_name: chain.chain_name, + type: "pauser", + }); + }); + } + }) + ); +}; + const main = async (args: any, hre: HardhatRuntimeEnvironment) => { const n = hre.network.name; if (n !== "zeta_testnet" && n !== "zeta_mainnet") { @@ -229,6 +255,7 @@ const main = async (args: any, hre: HardhatRuntimeEnvironment) => { await fetchAthensAddresses(addresses, hre, network); await fetchChainSpecificAddresses(chains, addresses, network); await fetchTSSUpdater(chains, addresses); + await fetchPauser(chains, addresses); console.log(JSON.stringify(addresses, null, 2)); }; From e590bee8651990fe527f84c9e6305b032dd3cb9a Mon Sep 17 00:00:00 2001 From: Denis Fadeev Date: Fri, 2 Feb 2024 17:43:11 +0400 Subject: [PATCH 10/27] lint --- tasks/addresses.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tasks/addresses.ts b/tasks/addresses.ts index b9b9e4f8..f93a9edd 100644 --- a/tasks/addresses.ts +++ b/tasks/addresses.ts @@ -2,8 +2,8 @@ import { getEndpoints } from "@zetachain/networks"; import axios, { AxiosResponse } from "axios"; import { task } from "hardhat/config"; import { HardhatRuntimeEnvironment } from "hardhat/types"; -import { ZetaConnectorBase__factory } from "../typechain-types"; +import { ZetaConnectorBase__factory } from "../typechain-types"; import { ERC20Custody__factory } from "../typechain-types/factories/contracts/evm/ERC20Custody__factory"; import { SystemContract__factory } from "../typechain-types/factories/contracts/zevm/SystemContract.sol/SystemContract__factory"; From da18a18a62ef77f02e257196e66034f0e68f7567 Mon Sep 17 00:00:00 2001 From: Denis Fadeev Date: Mon, 5 Feb 2024 12:41:26 +0400 Subject: [PATCH 11/27] generate addresses script --- data/addresses.json | 132 -------------- data/addresses.mainnet.json | 282 ++++++++++++++++++++++++++++++ data/addresses.testnet.json | 317 ++++++++++++++++++++++++++++++++++ package.json | 4 +- scripts/generate_addresses.sh | 6 + yarn.lock | 8 +- 6 files changed, 611 insertions(+), 138 deletions(-) delete mode 100644 data/addresses.json create mode 100644 data/addresses.mainnet.json create mode 100644 data/addresses.testnet.json create mode 100755 scripts/generate_addresses.sh diff --git a/data/addresses.json b/data/addresses.json deleted file mode 100644 index 08dc99f8..00000000 --- a/data/addresses.json +++ /dev/null @@ -1,132 +0,0 @@ -{ - "ccm": { - "bsc_mainnet": { - "connector": "", - "erc20Custody": "", - "immutableCreate2Factory": "0x095a03c6a68137fE9a566bBc3e552F299d8b886d", - "tss": "", - "tssUpdater": "", - "zetaToken": "" - }, - "bsc_testnet": { - "connector": "0x0000ecb8cdd25a18f12daa23f6422e07fbf8b9e1", - "erc20Custody": "0x0000a7db254145767262c6a81a7ee1650684258e", - "immutableCreate2Factory": "0x095a03c6a68137fE9a566bBc3e552F299d8b886d", - "tss": "0x8531a5aB847ff5B22D855633C25ED1DA3255247e", - "tssUpdater": "0x55122f7590164Ac222504436943FAB17B62F5d7d", - "zetaToken": "0x0000c9ec4042283e8139c74f4c64bcd1e0b9b54f", - "zetaTokenConsumerUniV2": "", - "zetaTokenConsumerUniV3": "0xFB2fCE3CCca19F0f764Ed8aa26C62181E3dA04C5" - }, - "btc_testnet": { - "connector": "", - "immutableCreate2Factory": "", - "tss": "tb1qy9pqmk2pd9sv63g27jt8r657wy0d9ueeh0nqur", - "tssUpdater": "", - "zetaToken": "", - "zetaTokenConsumerUniV2": "", - "zetaTokenConsumerUniV3": "" - }, - "eth_mainnet": { - "connector": "0x054197b11aA98E6d842073F9362b64b10F2c24A7", - "erc20Custody": "0xb77277Cf4c734894d4f2471492B184E5C71C32a9", - "immutableCreate2Factory": "0x095a03c6a68137fE9a566bBc3e552F299d8b886d", - "tss": "0x6F28967E382765cEF6149fa02Cd0Ba0753B01A6b", - "tssUpdater": "0xfCA0392567D5eb77681843b2608dE9C625F57948", - "zetaToken": "0x5CDf9f824526Bf2A4638BF6879591F635Bb8f0B8" - }, - "goerli_testnet": { - "connector": "0x00005e3125aba53c5652f9f0ce1a4cf91d8b15ea", - "erc20Custody": "0x000047f11c6e42293f433c82473532e869ce4ec5", - "immutableCreate2Factory": "0x095a03c6a68137fE9a566bBc3e552F299d8b886d", - "tss": "0x8531a5aB847ff5B22D855633C25ED1DA3255247e", - "tssUpdater": "0x55122f7590164Ac222504436943FAB17B62F5d7d", - "zetaToken": "0x0000c304d2934c00db1d51995b9f6996affd17c0", - "zetaTokenConsumerUniV2": "0x8eAc517b92eeE82177a83851268F13109878f8c4", - "zetaTokenConsumerUniV3": "" - }, - "mumbai_testnet": { - "connector": "0x0000ecb8cdd25a18f12daa23f6422e07fbf8b9e1", - "erc20Custody": "0x0000a7db254145767262c6a81a7ee1650684258e", - "immutableCreate2Factory": "0x095a03c6a68137fE9a566bBc3e552F299d8b886d", - "tss": "0x8531a5aB847ff5B22D855633C25ED1DA3255247e", - "tssUpdater": "0x55122f7590164Ac222504436943FAB17B62F5d7d", - "zetaToken": "0x0000c9ec4042283e8139c74f4c64bcd1e0b9b54f", - "zetaTokenConsumerUniV2": "", - "zetaTokenConsumerUniV3": "0x7e792f3736751e168864106AdbAC50152641A927" - }, - "zeta_testnet": { - "connector": "0x239e96c8f17C85c30100AC26F635Ea15f23E9c67", - "immutableCreate2Factory": "", - "tss": "0x7c125C1d515b8945841b3d5144a060115C58725F", - "tssUpdater": "0x7274d1d5dddef36aac53dd45b93487ce01ef0a55", - "zetaToken": "0x5F0b1a82749cb4E2278EC87F8BF6B618dC71a8bf", - "zetaTokenConsumerUniV2": "", - "zetaTokenConsumerUniV3": "" - } - }, - "non_zeta": { - "bsc_mainnet": { - "uniswapV2Factory": "", - "uniswapV2Router02": "", - "uniswapV3Factory": "", - "uniswapV3Router": "", - "weth9": "" - }, - "bsc_testnet": { - "uniswapV2Factory": "", - "uniswapV2Router02": "0x9Ac64Cc6e4415144C455BD8E4837Fea55603e5c3", - "uniswapV3Factory": "0x0BFbCF9fa4f9C56B0F40a671Ad40E0805A091865", - "uniswapV3Router": "0x9a489505a00cE272eAa5e07Dba6491314CaE3796", - "weth9": "0xae13d989daC2f0dEbFf460aC112a837C89BAa7cd" - }, - "eth_mainnet": { - "uniswapV2Factory": "0x5C69bEe701ef814a2B6a3EDD4B1652CB9cc5aA6f", - "uniswapV2Router02": "0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D", - "uniswapV3Factory": "0x1F98431c8aD98523631AE4a59f267346ea31F984", - "uniswapV3Router": "0xE592427A0AEce92De3Edee1F18E0157C05861564", - "weth9": "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2" - }, - "goerli_testnet": { - "uniswapV2Factory": "", - "uniswapV2Router02": "0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D", - "uniswapV3Factory": "0x1F98431c8aD98523631AE4a59f267346ea31F984", - "uniswapV3Router": "0xE592427A0AEce92De3Edee1F18E0157C05861564", - "weth9": "0xB4FBF271143F4FBf7B91A5ded31805e42b2208d6" - }, - "mumbai_testnet": { - "uniswapV2Factory": "", - "uniswapV2Router02": "0x0000ecb8cdd25a18f12daa23f6422e07fbf8b9e1", - "uniswapV3Factory": "0x1F98431c8aD98523631AE4a59f267346ea31F984", - "uniswapV3Router": "0xE592427A0AEce92De3Edee1F18E0157C05861564", - "weth9": "0x9c3C9283D3e44854697Cd22D3Faa240Cfb032889" - }, - "zeta_testnet": { - "uniswapV2Factory": "", - "uniswapV2Router02": "", - "uniswapV3Factory": "", - "uniswapV3Router": "", - "weth9": "" - } - }, - "zevm": { - "bsc_testnet": { - "zrc20": "0xd97B1de3619ed2c6BEb3860147E30cA8A7dC9891" - }, - "btc_testnet": { - "zrc20": "0x65a45c57636f9BcCeD4fe193A602008578BcA90b" - }, - "goerli_testnet": { - "zrc20": "0x13A0c5930C028511Dc02665E7285134B6d11A5f4" - }, - "mumbai_testnet": { - "zrc20": "0x48f80608B672DC30DC7e3dbBd0343c5F02C738Eb" - }, - "zeta_testnet": { - "fungibleModule": "0x735b14BB79463307AAcBED86DAf3322B1e6226aB", - "systemContract": "0xEdf1c3275d13489aCdC6cD6eD246E72458B8795B", - "uniswapv2Factory": "0x9fd96203f7b22bCF72d9DCb40ff98302376cE09c", - "uniswapv2Router02": "0x2ca7d64A7EFE2D62A725E2B35Cf7230D6677FfEe" - } - } -} diff --git a/data/addresses.mainnet.json b/data/addresses.mainnet.json new file mode 100644 index 00000000..dca80bdb --- /dev/null +++ b/data/addresses.mainnet.json @@ -0,0 +1,282 @@ +[ + { + "address": "0x70e967acFcC17c3941E87562161406d41676FD83", + "category": "omnichain", + "chain_id": "1", + "chain_name": "eth_mainnet", + "type": "tss" + }, + { + "address": "0x70e967acFcC17c3941E87562161406d41676FD83", + "category": "omnichain", + "chain_id": "56", + "chain_name": "bsc_mainnet", + "type": "tss" + }, + { + "address": "0x70e967acFcC17c3941E87562161406d41676FD83", + "category": "omnichain", + "chain_id": "8332", + "chain_name": "btc_mainnet", + "type": "tss" + }, + { + "address": "0x70e967acFcC17c3941E87562161406d41676FD83", + "category": "omnichain", + "chain_id": "7000", + "chain_name": "zeta_mainnet", + "type": "tss" + }, + { + "address": "0x91d18e54DAf4F677cB28167158d6dd21F6aB3921", + "category": "omnichain", + "chain_id": 7000, + "chain_name": "zeta_testnet", + "type": "systemContract" + }, + { + "address": "0x239e96c8f17C85c30100AC26F635Ea15f23E9c67", + "category": "messaging", + "chain_id": 7000, + "chain_name": "zeta_testnet", + "type": "connector" + }, + { + "address": "0x8ac76a51cc950d9822d68b83fe1ad97b32cd580d", + "category": "omnichain", + "chain_id": "56", + "chain_name": "bsc_mainnet", + "coin_type": "ERC20", + "decimals": 18, + "symbol": "USDC.BSC", + "zrc20": "0x05BA149A7bd6dC1F937fA9046A9e05C05f3b18b0" + }, + { + "address": "0x05BA149A7bd6dC1F937fA9046A9e05C05f3b18b0", + "asset": "0x8ac76a51cc950d9822d68b83fe1ad97b32cd580d", + "category": "omnichain", + "chain_id": 7000, + "chain_name": "zeta_testnet", + "coin_type": "ZRC20", + "decimals": 18, + "symbol": "ZetaChain ZRC20 USDC on BSC" + }, + { + "address": "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48", + "category": "omnichain", + "chain_id": "1", + "chain_name": "eth_mainnet", + "coin_type": "ERC20", + "decimals": 6, + "symbol": "USDC.ETH", + "zrc20": "0x0cbe0dF132a6c6B4a2974Fa1b7Fb953CF0Cc798a" + }, + { + "address": "0x0cbe0dF132a6c6B4a2974Fa1b7Fb953CF0Cc798a", + "asset": "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48", + "category": "omnichain", + "chain_id": 7000, + "chain_name": "zeta_testnet", + "coin_type": "ZRC20", + "decimals": 18, + "symbol": "ZetaChain ZRC20 USDC on ETH" + }, + { + "address": "", + "category": "omnichain", + "chain_id": "8332", + "chain_name": "btc_mainnet", + "coin_type": "Gas", + "decimals": 8, + "symbol": "BTC.BTC", + "zrc20": "0x13A0c5930C028511Dc02665E7285134B6d11A5f4" + }, + { + "address": "0x13A0c5930C028511Dc02665E7285134B6d11A5f4", + "asset": "", + "category": "omnichain", + "chain_id": 7000, + "chain_name": "zeta_testnet", + "coin_type": "ZRC20", + "decimals": 18, + "symbol": "ZetaChain ZRC20 BTC-btc_mainnet" + }, + { + "address": "", + "category": "omnichain", + "chain_id": "56", + "chain_name": "bsc_mainnet", + "coin_type": "Gas", + "decimals": 18, + "symbol": "BNB.BSC", + "zrc20": "0x48f80608B672DC30DC7e3dbBd0343c5F02C738Eb" + }, + { + "address": "0x48f80608B672DC30DC7e3dbBd0343c5F02C738Eb", + "asset": "", + "category": "omnichain", + "chain_id": 7000, + "chain_name": "zeta_testnet", + "coin_type": "ZRC20", + "decimals": 18, + "symbol": "ZetaChain ZRC20 BNB-bsc_mainnet" + }, + { + "address": "0xdac17f958d2ee523a2206206994597c13d831ec7", + "category": "omnichain", + "chain_id": "1", + "chain_name": "eth_mainnet", + "coin_type": "ERC20", + "decimals": 6, + "symbol": "USDT.ETH", + "zrc20": "0x7c8dDa80bbBE1254a7aACf3219EBe1481c6E01d7" + }, + { + "address": "0x7c8dDa80bbBE1254a7aACf3219EBe1481c6E01d7", + "asset": "0xdac17f958d2ee523a2206206994597c13d831ec7", + "category": "omnichain", + "chain_id": 7000, + "chain_name": "zeta_testnet", + "coin_type": "ZRC20", + "decimals": 18, + "symbol": "ZetaChain ZRC20 USDT on ETH" + }, + { + "address": "0x55d398326f99059ff775485246999027b3197955", + "category": "omnichain", + "chain_id": "56", + "chain_name": "bsc_mainnet", + "coin_type": "ERC20", + "decimals": 18, + "symbol": "USDT.BSC", + "zrc20": "0x91d4F0D54090Df2D81e834c3c8CE71C6c865e79F" + }, + { + "address": "0x91d4F0D54090Df2D81e834c3c8CE71C6c865e79F", + "asset": "0x55d398326f99059ff775485246999027b3197955", + "category": "omnichain", + "chain_id": 7000, + "chain_name": "zeta_testnet", + "coin_type": "ZRC20", + "decimals": 18, + "symbol": "ZetaChain ZRC20 USDT on BSC" + }, + { + "address": "", + "category": "omnichain", + "chain_id": "1", + "chain_name": "eth_mainnet", + "coin_type": "Gas", + "decimals": 18, + "symbol": "ETH.ETH", + "zrc20": "0xd97B1de3619ed2c6BEb3860147E30cA8A7dC9891" + }, + { + "address": "0xd97B1de3619ed2c6BEb3860147E30cA8A7dC9891", + "asset": "", + "category": "omnichain", + "chain_id": 7000, + "chain_name": "zeta_testnet", + "coin_type": "ZRC20", + "decimals": 18, + "symbol": "ZetaChain ZRC20 ETH-eth_mainnet" + }, + { + "category": "omnichain", + "chain_id": 7000, + "chain_name": "zeta_testnet", + "address": "0x9fd96203f7b22bCF72d9DCb40ff98302376cE09c", + "type": "uniswapv2Factory" + }, + { + "category": "omnichain", + "chain_id": 7000, + "chain_name": "zeta_testnet", + "address": "0x5F0b1a82749cb4E2278EC87F8BF6B618dC71a8bf", + "type": "wZetaContract" + }, + { + "category": "omnichain", + "chain_id": 7000, + "chain_name": "zeta_testnet", + "address": "0x2ca7d64A7EFE2D62A725E2B35Cf7230D6677FfEe", + "type": "uniswapv2Router02" + }, + { + "category": "omnichain", + "chain_id": 7000, + "chain_name": "zeta_testnet", + "address": "0x735b14BB79463307AAcBED86DAf3322B1e6226aB", + "type": "fungibleModule" + }, + { + "address": "0x0000028a2eB8346cd5c0267856aB7594B7a55308", + "category": "messaging", + "chain_id": "56", + "chain_name": "bsc_mainnet", + "type": "zetaToken" + }, + { + "address": "0x000063A6e758D9e2f438d430108377564cf4077D", + "category": "messaging", + "chain_id": "56", + "chain_name": "bsc_mainnet", + "type": "connector" + }, + { + "address": "0x00000fF8fA992424957F97688015814e707A0115", + "category": "omnichain", + "chain_id": "56", + "chain_name": "bsc_mainnet", + "type": "erc20Custody" + }, + { + "address": "0xf091867EC603A6628eD83D274E835539D82e9cc8", + "category": "messaging", + "chain_id": "1", + "chain_name": "eth_mainnet", + "type": "zetaToken" + }, + { + "address": "0x000007Cf399229b2f5A4D043F20E90C9C98B7C6a", + "category": "messaging", + "chain_id": "1", + "chain_name": "eth_mainnet", + "type": "connector" + }, + { + "address": "0x0000030Ec64DF25301d8414eE5a29588C4B0dE10", + "category": "omnichain", + "chain_id": "1", + "chain_name": "eth_mainnet", + "type": "erc20Custody" + }, + { + "address": "0xaeB6dDB7708467814D557e340283248be8E43124", + "category": "omnichain", + "chain_id": "1", + "chain_name": "eth_mainnet", + "type": "tssUpdater" + }, + { + "address": "0xaf28a257D292e7f0E531073f70a175b57E0261a8", + "category": "omnichain", + "chain_id": "56", + "chain_name": "bsc_mainnet", + "type": "tssUpdater" + }, + { + "address": "0xaeB6dDB7708467814D557e340283248be8E43124", + "category": "messaging", + "chain_id": "1", + "chain_name": "eth_mainnet", + "type": "pauser" + }, + { + "address": "0xaf28a257D292e7f0E531073f70a175b57E0261a8", + "category": "messaging", + "chain_id": "56", + "chain_name": "bsc_mainnet", + "type": "pauser" + } +] diff --git a/data/addresses.testnet.json b/data/addresses.testnet.json new file mode 100644 index 00000000..0105c7f9 --- /dev/null +++ b/data/addresses.testnet.json @@ -0,0 +1,317 @@ +[ + { + "address": "0x8531a5aB847ff5B22D855633C25ED1DA3255247e", + "category": "omnichain", + "chain_id": "5", + "chain_name": "goerli_testnet", + "type": "tss" + }, + { + "address": "0x8531a5aB847ff5B22D855633C25ED1DA3255247e", + "category": "omnichain", + "chain_id": "97", + "chain_name": "bsc_testnet", + "type": "tss" + }, + { + "address": "0x8531a5aB847ff5B22D855633C25ED1DA3255247e", + "category": "omnichain", + "chain_id": "80001", + "chain_name": "mumbai_testnet", + "type": "tss" + }, + { + "address": "tb1qy9pqmk2pd9sv63g27jt8r657wy0d9ueeh0nqur", + "category": "omnichain", + "chain_id": "18332", + "chain_name": "btc_testnet", + "type": "tss" + }, + { + "address": "0xEdf1c3275d13489aCdC6cD6eD246E72458B8795B", + "category": "omnichain", + "chain_id": 7001, + "chain_name": "zeta_testnet", + "type": "systemContract" + }, + { + "address": "0x239e96c8f17C85c30100AC26F635Ea15f23E9c67", + "category": "messaging", + "chain_id": 7001, + "chain_name": "zeta_testnet", + "type": "connector" + }, + { + "address": "0x07865c6e87b9f70255377e024ace6630c1eaa37f", + "category": "omnichain", + "chain_id": "5", + "chain_name": "goerli_testnet", + "coin_type": "ERC20", + "decimals": 6, + "symbol": "USDC", + "zrc20": "0x0cbe0dF132a6c6B4a2974Fa1b7Fb953CF0Cc798a" + }, + { + "address": "0x0cbe0dF132a6c6B4a2974Fa1b7Fb953CF0Cc798a", + "asset": "0x07865c6e87b9f70255377e024ace6630c1eaa37f", + "category": "omnichain", + "chain_id": 7001, + "chain_name": "zeta_testnet", + "coin_type": "ZRC20", + "decimals": 18, + "symbol": "USDC-goerli_testnet" + }, + { + "address": "", + "category": "omnichain", + "chain_id": "5", + "chain_name": "goerli_testnet", + "coin_type": "Gas", + "decimals": 18, + "symbol": "gETH", + "zrc20": "0x13A0c5930C028511Dc02665E7285134B6d11A5f4" + }, + { + "address": "0x13A0c5930C028511Dc02665E7285134B6d11A5f4", + "asset": "", + "category": "omnichain", + "chain_id": 7001, + "chain_name": "zeta_testnet", + "coin_type": "ZRC20", + "decimals": 18, + "symbol": "ETH-goerli_testnet" + }, + { + "address": "", + "category": "omnichain", + "chain_id": "80001", + "chain_name": "mumbai_testnet", + "coin_type": "Gas", + "decimals": 18, + "symbol": "tMATIC", + "zrc20": "0x48f80608B672DC30DC7e3dbBd0343c5F02C738Eb" + }, + { + "address": "0x48f80608B672DC30DC7e3dbBd0343c5F02C738Eb", + "asset": "", + "category": "omnichain", + "chain_id": 7001, + "chain_name": "zeta_testnet", + "coin_type": "ZRC20", + "decimals": 18, + "symbol": "MATIC-mumbai_testnet" + }, + { + "address": "", + "category": "omnichain", + "chain_id": "18332", + "chain_name": "btc_testnet", + "coin_type": "Gas", + "decimals": 8, + "symbol": "tBTC", + "zrc20": "0x65a45c57636f9BcCeD4fe193A602008578BcA90b" + }, + { + "address": "0x65a45c57636f9BcCeD4fe193A602008578BcA90b", + "asset": "", + "category": "omnichain", + "chain_id": 7001, + "chain_name": "zeta_testnet", + "coin_type": "ZRC20", + "decimals": 18, + "symbol": "BTC-btc_testnet-btc_testnet" + }, + { + "address": "0x64544969ed7EBf5f083679233325356EbE738930", + "category": "omnichain", + "chain_id": "97", + "chain_name": "bsc_testnet", + "coin_type": "ERC20", + "decimals": 6, + "symbol": "USDC", + "zrc20": "0x7c8dDa80bbBE1254a7aACf3219EBe1481c6E01d7" + }, + { + "address": "0x7c8dDa80bbBE1254a7aACf3219EBe1481c6E01d7", + "asset": "0x64544969ed7EBf5f083679233325356EbE738930", + "category": "omnichain", + "chain_id": 7001, + "chain_name": "zeta_testnet", + "coin_type": "ZRC20", + "decimals": 18, + "symbol": "USDC-bsc_testnet" + }, + { + "address": "0x9999f7fea5938fd3b1e26a12c3f2fb024e194f97", + "category": "omnichain", + "chain_id": "80001", + "chain_name": "mumbai_testnet", + "coin_type": "ERC20", + "decimals": 6, + "symbol": "USDC", + "zrc20": "0x91d4F0D54090Df2D81e834c3c8CE71C6c865e79F" + }, + { + "address": "0x91d4F0D54090Df2D81e834c3c8CE71C6c865e79F", + "asset": "0x9999f7fea5938fd3b1e26a12c3f2fb024e194f97", + "category": "omnichain", + "chain_id": 7001, + "chain_name": "zeta_testnet", + "coin_type": "ZRC20", + "decimals": 18, + "symbol": "USDC-mumbai_testnet" + }, + { + "address": "", + "category": "omnichain", + "chain_id": "97", + "chain_name": "bsc_testnet", + "coin_type": "Gas", + "decimals": 18, + "symbol": "tBNB", + "zrc20": "0xd97B1de3619ed2c6BEb3860147E30cA8A7dC9891" + }, + { + "address": "0xd97B1de3619ed2c6BEb3860147E30cA8A7dC9891", + "asset": "", + "category": "omnichain", + "chain_id": 7001, + "chain_name": "zeta_testnet", + "coin_type": "ZRC20", + "decimals": 18, + "symbol": "BNB-bsc_testnet" + }, + { + "category": "omnichain", + "chain_id": 7001, + "chain_name": "zeta_testnet", + "address": "0x9fd96203f7b22bCF72d9DCb40ff98302376cE09c", + "type": "uniswapv2Factory" + }, + { + "category": "omnichain", + "chain_id": 7001, + "chain_name": "zeta_testnet", + "address": "0x5F0b1a82749cb4E2278EC87F8BF6B618dC71a8bf", + "type": "wZetaContract" + }, + { + "category": "omnichain", + "chain_id": 7001, + "chain_name": "zeta_testnet", + "address": "0x2ca7d64A7EFE2D62A725E2B35Cf7230D6677FfEe", + "type": "uniswapv2Router02" + }, + { + "category": "omnichain", + "chain_id": 7001, + "chain_name": "zeta_testnet", + "address": "0x735b14BB79463307AAcBED86DAf3322B1e6226aB", + "type": "fungibleModule" + }, + { + "address": "0x0000c304d2934c00db1d51995b9f6996affd17c0", + "category": "messaging", + "chain_id": "5", + "chain_name": "goerli_testnet", + "type": "zetaToken" + }, + { + "address": "0x00005e3125aba53c5652f9f0ce1a4cf91d8b15ea", + "category": "messaging", + "chain_id": "5", + "chain_name": "goerli_testnet", + "type": "connector" + }, + { + "address": "0x000047f11c6e42293f433c82473532e869ce4ec5", + "category": "omnichain", + "chain_id": "5", + "chain_name": "goerli_testnet", + "type": "erc20Custody" + }, + { + "address": "0x0000c9ec4042283e8139c74f4c64bcd1e0b9b54f", + "category": "messaging", + "chain_id": "80001", + "chain_name": "mumbai_testnet", + "type": "zetaToken" + }, + { + "address": "0x0000ecb8cdd25a18f12daa23f6422e07fbf8b9e1", + "category": "messaging", + "chain_id": "80001", + "chain_name": "mumbai_testnet", + "type": "connector" + }, + { + "address": "0x0000a7db254145767262c6a81a7ee1650684258e", + "category": "omnichain", + "chain_id": "80001", + "chain_name": "mumbai_testnet", + "type": "erc20Custody" + }, + { + "address": "0x0000c9ec4042283e8139c74f4c64bcd1e0b9b54f", + "category": "messaging", + "chain_id": "97", + "chain_name": "bsc_testnet", + "type": "zetaToken" + }, + { + "address": "0x0000ecb8cdd25a18f12daa23f6422e07fbf8b9e1", + "category": "messaging", + "chain_id": "97", + "chain_name": "bsc_testnet", + "type": "connector" + }, + { + "address": "0x0000a7db254145767262c6a81a7ee1650684258e", + "category": "omnichain", + "chain_id": "97", + "chain_name": "bsc_testnet", + "type": "erc20Custody" + }, + { + "address": "0x55122f7590164Ac222504436943FAB17B62F5d7d", + "category": "omnichain", + "chain_id": "97", + "chain_name": "bsc_testnet", + "type": "tssUpdater" + }, + { + "address": "0x55122f7590164Ac222504436943FAB17B62F5d7d", + "category": "omnichain", + "chain_id": "5", + "chain_name": "goerli_testnet", + "type": "tssUpdater" + }, + { + "address": "0x55122f7590164Ac222504436943FAB17B62F5d7d", + "category": "omnichain", + "chain_id": "80001", + "chain_name": "mumbai_testnet", + "type": "tssUpdater" + }, + { + "address": "0x55122f7590164Ac222504436943FAB17B62F5d7d", + "category": "messaging", + "chain_id": "80001", + "chain_name": "mumbai_testnet", + "type": "pauser" + }, + { + "address": "0x55122f7590164Ac222504436943FAB17B62F5d7d", + "category": "messaging", + "chain_id": "5", + "chain_name": "goerli_testnet", + "type": "pauser" + }, + { + "address": "0x55122f7590164Ac222504436943FAB17B62F5d7d", + "category": "messaging", + "chain_id": "97", + "chain_name": "bsc_testnet", + "type": "pauser" + } +] diff --git a/package.json b/package.json index 6570cc24..61c6e323 100644 --- a/package.json +++ b/package.json @@ -22,7 +22,7 @@ "@uniswap/v2-core": "^1.0.1", "@uniswap/v2-periphery": "^1.1.0-beta.0", "@uniswap/v3-periphery": "^1.4.3", - "@zetachain/networks": "^2.4.3", + "@zetachain/networks": "4.0.0-rc1", "axios": "^1.6.5", "chai": "^4.3.6", "cpx": "^1.5.0", @@ -70,7 +70,7 @@ "scripts": { "build": "yarn compile && npx del-cli dist abi && tsc || exit 0 && npx del-cli './dist/typechain-types/**/*.js' && npx cpx './data/**/*' dist/data && npx cpx './artifacts/contracts/**/*' ./abi && npx del-cli './abi/**/*.dbg.json'", "compile": "npx hardhat compile --force", - "generate": "yarn compile && ./scripts/generate_go.sh", + "generate": "yarn compile && ./scripts/generate_go.sh || exit 0 && ./scripts/generate_addresses.sh", "lint": "npx eslint . --ext .js,.ts", "lint:fix": "npx eslint . --ext .js,.ts,.json --fix", "prepublishOnly": "yarn build", diff --git a/scripts/generate_addresses.sh b/scripts/generate_addresses.sh new file mode 100755 index 00000000..d7146033 --- /dev/null +++ b/scripts/generate_addresses.sh @@ -0,0 +1,6 @@ +#!/bin/bash + +echo "Generating protocol addresses..." + +npx hardhat addresses --network zeta_testnet > ./data/addresses.testnet.json +npx hardhat addresses --network zeta_mainnet > ./data/addresses.mainnet.json \ No newline at end of file diff --git a/yarn.lock b/yarn.lock index 8172cd4b..3fae11ab 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2076,10 +2076,10 @@ "@uniswap/v3-core" "1.0.0" base64-sol "1.0.1" -"@zetachain/networks@^2.4.3": - version "2.4.3" - resolved "https://registry.yarnpkg.com/@zetachain/networks/-/networks-2.4.3.tgz#870b2cda4b91f913be990246831378f60688d452" - integrity sha512-ZoqN8M6+59OkujZCl3FcSEgSftIN1tw5bpuFwI/2+f0SlKH+8ztAk7aF1QHmzrPqolIJKt29ogsfvIjiynXNkg== +"@zetachain/networks@4.0.0-rc1": + version "4.0.0-rc1" + resolved "https://registry.yarnpkg.com/@zetachain/networks/-/networks-4.0.0-rc1.tgz#0ec6efabaa78d7124f5adb9218f25d85e252087b" + integrity sha512-Zl8cZc5PdKI46KZqPeIu7DmpSqUkXN07L9Yxy/Lp233L9pZKWUVr7RnEq2HUaN9F6gqtxlofNtKBFopphm1pEQ== dependencies: dotenv "^16.1.4" From 54306c5c0f5c292ef815b0c3b92883b104268bbc Mon Sep 17 00:00:00 2001 From: Denis Fadeev Date: Mon, 5 Feb 2024 12:49:14 +0400 Subject: [PATCH 12/27] remove gas token entries with empty addresses --- data/addresses.mainnet.json | 63 ++++++++---------------- data/addresses.testnet.json | 97 ++++++++++++------------------------- tasks/addresses.ts | 25 +++++----- 3 files changed, 66 insertions(+), 119 deletions(-) diff --git a/data/addresses.mainnet.json b/data/addresses.mainnet.json index dca80bdb..eb796466 100644 --- a/data/addresses.mainnet.json +++ b/data/addresses.mainnet.json @@ -57,7 +57,8 @@ "category": "omnichain", "chain_id": 7000, "chain_name": "zeta_testnet", - "coin_type": "ZRC20", + "type": "ZRC20", + "coin_type": "ERC20", "decimals": 18, "symbol": "ZetaChain ZRC20 USDC on BSC" }, @@ -77,39 +78,21 @@ "category": "omnichain", "chain_id": 7000, "chain_name": "zeta_testnet", - "coin_type": "ZRC20", + "type": "ZRC20", + "coin_type": "ERC20", "decimals": 18, "symbol": "ZetaChain ZRC20 USDC on ETH" }, - { - "address": "", - "category": "omnichain", - "chain_id": "8332", - "chain_name": "btc_mainnet", - "coin_type": "Gas", - "decimals": 8, - "symbol": "BTC.BTC", - "zrc20": "0x13A0c5930C028511Dc02665E7285134B6d11A5f4" - }, { "address": "0x13A0c5930C028511Dc02665E7285134B6d11A5f4", "asset": "", "category": "omnichain", "chain_id": 7000, "chain_name": "zeta_testnet", - "coin_type": "ZRC20", - "decimals": 18, - "symbol": "ZetaChain ZRC20 BTC-btc_mainnet" - }, - { - "address": "", - "category": "omnichain", - "chain_id": "56", - "chain_name": "bsc_mainnet", + "type": "ZRC20", "coin_type": "Gas", "decimals": 18, - "symbol": "BNB.BSC", - "zrc20": "0x48f80608B672DC30DC7e3dbBd0343c5F02C738Eb" + "symbol": "ZetaChain ZRC20 BTC-btc_mainnet" }, { "address": "0x48f80608B672DC30DC7e3dbBd0343c5F02C738Eb", @@ -117,7 +100,8 @@ "category": "omnichain", "chain_id": 7000, "chain_name": "zeta_testnet", - "coin_type": "ZRC20", + "type": "ZRC20", + "coin_type": "Gas", "decimals": 18, "symbol": "ZetaChain ZRC20 BNB-bsc_mainnet" }, @@ -137,7 +121,8 @@ "category": "omnichain", "chain_id": 7000, "chain_name": "zeta_testnet", - "coin_type": "ZRC20", + "type": "ZRC20", + "coin_type": "ERC20", "decimals": 18, "symbol": "ZetaChain ZRC20 USDT on ETH" }, @@ -157,27 +142,19 @@ "category": "omnichain", "chain_id": 7000, "chain_name": "zeta_testnet", - "coin_type": "ZRC20", + "type": "ZRC20", + "coin_type": "ERC20", "decimals": 18, "symbol": "ZetaChain ZRC20 USDT on BSC" }, - { - "address": "", - "category": "omnichain", - "chain_id": "1", - "chain_name": "eth_mainnet", - "coin_type": "Gas", - "decimals": 18, - "symbol": "ETH.ETH", - "zrc20": "0xd97B1de3619ed2c6BEb3860147E30cA8A7dC9891" - }, { "address": "0xd97B1de3619ed2c6BEb3860147E30cA8A7dC9891", "asset": "", "category": "omnichain", "chain_id": 7000, "chain_name": "zeta_testnet", - "coin_type": "ZRC20", + "type": "ZRC20", + "coin_type": "Gas", "decimals": 18, "symbol": "ZetaChain ZRC20 ETH-eth_mainnet" }, @@ -252,17 +229,17 @@ "type": "erc20Custody" }, { - "address": "0xaeB6dDB7708467814D557e340283248be8E43124", + "address": "0xaf28a257D292e7f0E531073f70a175b57E0261a8", "category": "omnichain", - "chain_id": "1", - "chain_name": "eth_mainnet", + "chain_id": "56", + "chain_name": "bsc_mainnet", "type": "tssUpdater" }, { - "address": "0xaf28a257D292e7f0E531073f70a175b57E0261a8", + "address": "0xaeB6dDB7708467814D557e340283248be8E43124", "category": "omnichain", - "chain_id": "56", - "chain_name": "bsc_mainnet", + "chain_id": "1", + "chain_name": "eth_mainnet", "type": "tssUpdater" }, { diff --git a/data/addresses.testnet.json b/data/addresses.testnet.json index 0105c7f9..6fc61bce 100644 --- a/data/addresses.testnet.json +++ b/data/addresses.testnet.json @@ -57,39 +57,21 @@ "category": "omnichain", "chain_id": 7001, "chain_name": "zeta_testnet", - "coin_type": "ZRC20", + "type": "ZRC20", + "coin_type": "ERC20", "decimals": 18, "symbol": "USDC-goerli_testnet" }, - { - "address": "", - "category": "omnichain", - "chain_id": "5", - "chain_name": "goerli_testnet", - "coin_type": "Gas", - "decimals": 18, - "symbol": "gETH", - "zrc20": "0x13A0c5930C028511Dc02665E7285134B6d11A5f4" - }, { "address": "0x13A0c5930C028511Dc02665E7285134B6d11A5f4", "asset": "", "category": "omnichain", "chain_id": 7001, "chain_name": "zeta_testnet", - "coin_type": "ZRC20", - "decimals": 18, - "symbol": "ETH-goerli_testnet" - }, - { - "address": "", - "category": "omnichain", - "chain_id": "80001", - "chain_name": "mumbai_testnet", + "type": "ZRC20", "coin_type": "Gas", "decimals": 18, - "symbol": "tMATIC", - "zrc20": "0x48f80608B672DC30DC7e3dbBd0343c5F02C738Eb" + "symbol": "ETH-goerli_testnet" }, { "address": "0x48f80608B672DC30DC7e3dbBd0343c5F02C738Eb", @@ -97,27 +79,19 @@ "category": "omnichain", "chain_id": 7001, "chain_name": "zeta_testnet", - "coin_type": "ZRC20", + "type": "ZRC20", + "coin_type": "Gas", "decimals": 18, "symbol": "MATIC-mumbai_testnet" }, - { - "address": "", - "category": "omnichain", - "chain_id": "18332", - "chain_name": "btc_testnet", - "coin_type": "Gas", - "decimals": 8, - "symbol": "tBTC", - "zrc20": "0x65a45c57636f9BcCeD4fe193A602008578BcA90b" - }, { "address": "0x65a45c57636f9BcCeD4fe193A602008578BcA90b", "asset": "", "category": "omnichain", "chain_id": 7001, "chain_name": "zeta_testnet", - "coin_type": "ZRC20", + "type": "ZRC20", + "coin_type": "Gas", "decimals": 18, "symbol": "BTC-btc_testnet-btc_testnet" }, @@ -137,7 +111,8 @@ "category": "omnichain", "chain_id": 7001, "chain_name": "zeta_testnet", - "coin_type": "ZRC20", + "type": "ZRC20", + "coin_type": "ERC20", "decimals": 18, "symbol": "USDC-bsc_testnet" }, @@ -157,27 +132,19 @@ "category": "omnichain", "chain_id": 7001, "chain_name": "zeta_testnet", - "coin_type": "ZRC20", + "type": "ZRC20", + "coin_type": "ERC20", "decimals": 18, "symbol": "USDC-mumbai_testnet" }, - { - "address": "", - "category": "omnichain", - "chain_id": "97", - "chain_name": "bsc_testnet", - "coin_type": "Gas", - "decimals": 18, - "symbol": "tBNB", - "zrc20": "0xd97B1de3619ed2c6BEb3860147E30cA8A7dC9891" - }, { "address": "0xd97B1de3619ed2c6BEb3860147E30cA8A7dC9891", "asset": "", "category": "omnichain", "chain_id": 7001, "chain_name": "zeta_testnet", - "coin_type": "ZRC20", + "type": "ZRC20", + "coin_type": "Gas", "decimals": 18, "symbol": "BNB-bsc_testnet" }, @@ -210,45 +177,45 @@ "type": "fungibleModule" }, { - "address": "0x0000c304d2934c00db1d51995b9f6996affd17c0", + "address": "0x0000c9ec4042283e8139c74f4c64bcd1e0b9b54f", "category": "messaging", - "chain_id": "5", - "chain_name": "goerli_testnet", + "chain_id": "80001", + "chain_name": "mumbai_testnet", "type": "zetaToken" }, { - "address": "0x00005e3125aba53c5652f9f0ce1a4cf91d8b15ea", + "address": "0x0000ecb8cdd25a18f12daa23f6422e07fbf8b9e1", "category": "messaging", - "chain_id": "5", - "chain_name": "goerli_testnet", + "chain_id": "80001", + "chain_name": "mumbai_testnet", "type": "connector" }, { - "address": "0x000047f11c6e42293f433c82473532e869ce4ec5", + "address": "0x0000a7db254145767262c6a81a7ee1650684258e", "category": "omnichain", - "chain_id": "5", - "chain_name": "goerli_testnet", + "chain_id": "80001", + "chain_name": "mumbai_testnet", "type": "erc20Custody" }, { - "address": "0x0000c9ec4042283e8139c74f4c64bcd1e0b9b54f", + "address": "0x0000c304d2934c00db1d51995b9f6996affd17c0", "category": "messaging", - "chain_id": "80001", - "chain_name": "mumbai_testnet", + "chain_id": "5", + "chain_name": "goerli_testnet", "type": "zetaToken" }, { - "address": "0x0000ecb8cdd25a18f12daa23f6422e07fbf8b9e1", + "address": "0x00005e3125aba53c5652f9f0ce1a4cf91d8b15ea", "category": "messaging", - "chain_id": "80001", - "chain_name": "mumbai_testnet", + "chain_id": "5", + "chain_name": "goerli_testnet", "type": "connector" }, { - "address": "0x0000a7db254145767262c6a81a7ee1650684258e", + "address": "0x000047f11c6e42293f433c82473532e869ce4ec5", "category": "omnichain", - "chain_id": "80001", - "chain_name": "mumbai_testnet", + "chain_id": "5", + "chain_name": "goerli_testnet", "type": "erc20Custody" }, { diff --git a/tasks/addresses.ts b/tasks/addresses.ts index f93a9edd..9580d01f 100644 --- a/tasks/addresses.ts +++ b/tasks/addresses.ts @@ -96,23 +96,26 @@ const fetchForeignCoinsData = async (chains: any, addresses: any, network: Netwo const foreignCoinsResponse: AxiosResponse = await axios.get(URL); if (foreignCoinsResponse.status === 200) { foreignCoinsResponse.data.foreignCoins.forEach((token: any) => { - addresses.push({ - address: token.asset, - category: "omnichain", - chain_id: token.foreign_chain_id, - chain_name: chains.find((c: any) => c.chain_id === token.foreign_chain_id)?.chain_name, - coin_type: token.coin_type, - decimals: token.decimals, - symbol: token.symbol, - zrc20: token.zrc20_contract_address, // TODO: dynamically fetch from contract (to verify) - }); + if (token.coin_type !== "Gas") { + addresses.push({ + address: token.asset, + category: "omnichain", + chain_id: token.foreign_chain_id, + chain_name: chains.find((c: any) => c.chain_id === token.foreign_chain_id)?.chain_name, + coin_type: token.coin_type, + decimals: token.decimals, + symbol: token.symbol, + zrc20: token.zrc20_contract_address, // TODO: dynamically fetch from contract (to verify) + }); + } addresses.push({ address: token.zrc20_contract_address, asset: token.asset, category: "omnichain", chain_id, chain_name: "zeta_testnet", - coin_type: "ZRC20", + type: "ZRC20", + coin_type: token.coin_type, decimals: 18, symbol: token.name, // TODO: dynamically fetch from contract }); From 8d2261e940c41fa33e7d77d1e8f3a9288cc567ed Mon Sep 17 00:00:00 2001 From: Denis Fadeev Date: Mon, 5 Feb 2024 16:47:43 +0400 Subject: [PATCH 13/27] getAddress --- data/addresses.json | 156 ++++++++++++++++++++++++++++++++++++ data/addresses.mainnet.json | 120 +++++++++++---------------- data/addresses.testnet.json | 98 ++++++++++------------ lib/address.tools.ts | 12 +-- lib/addresses.ts | 21 +++++ lib/index.ts | 4 + tasks/addresses.ts | 24 ++---- 7 files changed, 283 insertions(+), 152 deletions(-) create mode 100644 data/addresses.json create mode 100644 lib/addresses.ts diff --git a/data/addresses.json b/data/addresses.json new file mode 100644 index 00000000..cd879792 --- /dev/null +++ b/data/addresses.json @@ -0,0 +1,156 @@ +{ + "ccm": { + "bsc_mainnet": { + "connector": "0x000063A6e758D9e2f438d430108377564cf4077D", + "erc20Custody": "0x00000fF8fA992424957F97688015814e707A0115", + "immutableCreate2Factory": "", + "tss": "0x70e967acFcC17c3941E87562161406d41676FD83", + "tssUpdater": "", + "zetaToken": "0x0000028a2eB8346cd5c0267856aB7594B7a55308" + }, + "bsc_testnet": { + "connector": "0x0000ecb8cdd25a18f12daa23f6422e07fbf8b9e1", + "erc20Custody": "0x0000a7db254145767262c6a81a7ee1650684258e", + "immutableCreate2Factory": "0x095a03c6a68137fE9a566bBc3e552F299d8b886d", + "tss": "0x8531a5aB847ff5B22D855633C25ED1DA3255247e", + "tssUpdater": "0x55122f7590164Ac222504436943FAB17B62F5d7d", + "zetaToken": "0x0000c9ec4042283e8139c74f4c64bcd1e0b9b54f", + "zetaTokenConsumerUniV2": "", + "zetaTokenConsumerUniV3": "0xFB2fCE3CCca19F0f764Ed8aa26C62181E3dA04C5" + }, + "btc_testnet": { + "connector": "", + "immutableCreate2Factory": "", + "tss": "tb1qy9pqmk2pd9sv63g27jt8r657wy0d9ueeh0nqur", + "tssUpdater": "", + "zetaToken": "", + "zetaTokenConsumerUniV2": "", + "zetaTokenConsumerUniV3": "" + }, + "btc_mainnet": { + "connector": "", + "immutableCreate2Factory": "", + "tss": "bc1qm24wp577nk8aacckv8np465z3dvmu7ry45el6y", + "tssUpdater": "", + "zetaToken": "", + "zetaTokenConsumerUniV2": "", + "zetaTokenConsumerUniV3": "" + }, + "eth_mainnet": { + "connector": "0x000007Cf399229b2f5A4D043F20E90C9C98B7C6a", + "erc20Custody": "0x0000030Ec64DF25301d8414eE5a29588C4B0dE10", + "immutableCreate2Factory": "", + "tss": "0x70e967acFcC17c3941E87562161406d41676FD83", + "tssUpdater": "", + "zetaToken": "0xf091867EC603A6628eD83D274E835539D82e9cc8" + }, + "goerli_testnet": { + "connector": "0x00005e3125aba53c5652f9f0ce1a4cf91d8b15ea", + "erc20Custody": "0x000047f11c6e42293f433c82473532e869ce4ec5", + "immutableCreate2Factory": "0x095a03c6a68137fE9a566bBc3e552F299d8b886d", + "tss": "0x8531a5aB847ff5B22D855633C25ED1DA3255247e", + "tssUpdater": "0x55122f7590164Ac222504436943FAB17B62F5d7d", + "zetaToken": "0x0000c304d2934c00db1d51995b9f6996affd17c0", + "zetaTokenConsumerUniV2": "0x8eAc517b92eeE82177a83851268F13109878f8c4", + "zetaTokenConsumerUniV3": "" + }, + "mumbai_testnet": { + "connector": "0x0000ecb8cdd25a18f12daa23f6422e07fbf8b9e1", + "erc20Custody": "0x0000a7db254145767262c6a81a7ee1650684258e", + "immutableCreate2Factory": "0x095a03c6a68137fE9a566bBc3e552F299d8b886d", + "tss": "0x8531a5aB847ff5B22D855633C25ED1DA3255247e", + "tssUpdater": "0x55122f7590164Ac222504436943FAB17B62F5d7d", + "zetaToken": "0x0000c9ec4042283e8139c74f4c64bcd1e0b9b54f", + "zetaTokenConsumerUniV2": "", + "zetaTokenConsumerUniV3": "0x7e792f3736751e168864106AdbAC50152641A927" + }, + "zeta_testnet": { + "connector": "0x239e96c8f17C85c30100AC26F635Ea15f23E9c67", + "immutableCreate2Factory": "", + "tss": "0x7c125C1d515b8945841b3d5144a060115C58725F", + "tssUpdater": "0x7274d1d5dddef36aac53dd45b93487ce01ef0a55", + "zetaToken": "0x5F0b1a82749cb4E2278EC87F8BF6B618dC71a8bf", + "zetaTokenConsumerUniV2": "", + "zetaTokenConsumerUniV3": "" + }, + "zeta_mainnet": { + "connector": "0x239e96c8f17C85c30100AC26F635Ea15f23E9c67", + "immutableCreate2Factory": "", + "tss": "", + "tssUpdater": "", + "zetaToken": "0x5F0b1a82749cb4E2278EC87F8BF6B618dC71a8bf", + "zetaTokenConsumerUniV2": "", + "zetaTokenConsumerUniV3": "" + } + }, + "non_zeta": { + "bsc_mainnet": { + "uniswapV2Factory": "", + "uniswapV2Router02": "", + "uniswapV3Factory": "", + "uniswapV3Router": "", + "weth9": "" + }, + "bsc_testnet": { + "uniswapV2Factory": "", + "uniswapV2Router02": "0x9Ac64Cc6e4415144C455BD8E4837Fea55603e5c3", + "uniswapV3Factory": "0x0BFbCF9fa4f9C56B0F40a671Ad40E0805A091865", + "uniswapV3Router": "0x9a489505a00cE272eAa5e07Dba6491314CaE3796", + "weth9": "0xae13d989daC2f0dEbFf460aC112a837C89BAa7cd" + }, + "eth_mainnet": { + "uniswapV2Factory": "0x5C69bEe701ef814a2B6a3EDD4B1652CB9cc5aA6f", + "uniswapV2Router02": "0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D", + "uniswapV3Factory": "0x1F98431c8aD98523631AE4a59f267346ea31F984", + "uniswapV3Router": "0xE592427A0AEce92De3Edee1F18E0157C05861564", + "weth9": "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2" + }, + "goerli_testnet": { + "uniswapV2Factory": "", + "uniswapV2Router02": "0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D", + "uniswapV3Factory": "0x1F98431c8aD98523631AE4a59f267346ea31F984", + "uniswapV3Router": "0xE592427A0AEce92De3Edee1F18E0157C05861564", + "weth9": "0xB4FBF271143F4FBf7B91A5ded31805e42b2208d6" + }, + "mumbai_testnet": { + "uniswapV2Factory": "", + "uniswapV2Router02": "0x0000ecb8cdd25a18f12daa23f6422e07fbf8b9e1", + "uniswapV3Factory": "0x1F98431c8aD98523631AE4a59f267346ea31F984", + "uniswapV3Router": "0xE592427A0AEce92De3Edee1F18E0157C05861564", + "weth9": "0x9c3C9283D3e44854697Cd22D3Faa240Cfb032889" + }, + "zeta_testnet": { + "uniswapV2Factory": "", + "uniswapV2Router02": "", + "uniswapV3Factory": "", + "uniswapV3Router": "", + "weth9": "" + } + }, + "zevm": { + "bsc_testnet": { + "zrc20": "0xd97B1de3619ed2c6BEb3860147E30cA8A7dC9891" + }, + "goerli_testnet": { + "zrc20": "0x13A0c5930C028511Dc02665E7285134B6d11A5f4" + }, + "mumbai_testnet": { + "zrc20": "0x48f80608B672DC30DC7e3dbBd0343c5F02C738Eb" + }, + "btc_testnet": { + "zrc20": "0x65a45c57636f9BcCeD4fe193A602008578BcA90b" + }, + "zeta_testnet": { + "fungibleModule": "0x735b14BB79463307AAcBED86DAf3322B1e6226aB", + "systemContract": "0xEdf1c3275d13489aCdC6cD6eD246E72458B8795B", + "uniswapv2Factory": "0x9fd96203f7b22bCF72d9DCb40ff98302376cE09c", + "uniswapv2Router02": "0x2ca7d64A7EFE2D62A725E2B35Cf7230D6677FfEe" + }, + "zeta_mainnet": { + "fungibleModule": "", + "systemContract": "0x91d18e54DAf4F677cB28167158d6dd21F6aB3921", + "uniswapv2Factory": "", + "uniswapv2Router02": "" + } + } +} \ No newline at end of file diff --git a/data/addresses.mainnet.json b/data/addresses.mainnet.json index eb796466..7cbd4aa2 100644 --- a/data/addresses.mainnet.json +++ b/data/addresses.mainnet.json @@ -41,122 +41,96 @@ "chain_name": "zeta_testnet", "type": "connector" }, - { - "address": "0x8ac76a51cc950d9822d68b83fe1ad97b32cd580d", - "category": "omnichain", - "chain_id": "56", - "chain_name": "bsc_mainnet", - "coin_type": "ERC20", - "decimals": 18, - "symbol": "USDC.BSC", - "zrc20": "0x05BA149A7bd6dC1F937fA9046A9e05C05f3b18b0" - }, { "address": "0x05BA149A7bd6dC1F937fA9046A9e05C05f3b18b0", "asset": "0x8ac76a51cc950d9822d68b83fe1ad97b32cd580d", "category": "omnichain", "chain_id": 7000, + "foreign_chain_id": "56", "chain_name": "zeta_testnet", - "type": "ZRC20", - "coin_type": "ERC20", + "type": "zrc20", + "symbol": "USDC.BSC", + "coin_type": "erc20", "decimals": 18, - "symbol": "ZetaChain ZRC20 USDC on BSC" - }, - { - "address": "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48", - "category": "omnichain", - "chain_id": "1", - "chain_name": "eth_mainnet", - "coin_type": "ERC20", - "decimals": 6, - "symbol": "USDC.ETH", - "zrc20": "0x0cbe0dF132a6c6B4a2974Fa1b7Fb953CF0Cc798a" + "description": "ZetaChain ZRC20 USDC on BSC" }, { "address": "0x0cbe0dF132a6c6B4a2974Fa1b7Fb953CF0Cc798a", "asset": "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48", "category": "omnichain", "chain_id": 7000, + "foreign_chain_id": "1", "chain_name": "zeta_testnet", - "type": "ZRC20", - "coin_type": "ERC20", + "type": "zrc20", + "symbol": "USDC.ETH", + "coin_type": "erc20", "decimals": 18, - "symbol": "ZetaChain ZRC20 USDC on ETH" + "description": "ZetaChain ZRC20 USDC on ETH" }, { "address": "0x13A0c5930C028511Dc02665E7285134B6d11A5f4", "asset": "", "category": "omnichain", "chain_id": 7000, + "foreign_chain_id": "8332", "chain_name": "zeta_testnet", - "type": "ZRC20", - "coin_type": "Gas", + "type": "zrc20", + "symbol": "BTC.BTC", + "coin_type": "gas", "decimals": 18, - "symbol": "ZetaChain ZRC20 BTC-btc_mainnet" + "description": "ZetaChain ZRC20 BTC-btc_mainnet" }, { "address": "0x48f80608B672DC30DC7e3dbBd0343c5F02C738Eb", "asset": "", "category": "omnichain", "chain_id": 7000, + "foreign_chain_id": "56", "chain_name": "zeta_testnet", - "type": "ZRC20", - "coin_type": "Gas", + "type": "zrc20", + "symbol": "BNB.BSC", + "coin_type": "gas", "decimals": 18, - "symbol": "ZetaChain ZRC20 BNB-bsc_mainnet" - }, - { - "address": "0xdac17f958d2ee523a2206206994597c13d831ec7", - "category": "omnichain", - "chain_id": "1", - "chain_name": "eth_mainnet", - "coin_type": "ERC20", - "decimals": 6, - "symbol": "USDT.ETH", - "zrc20": "0x7c8dDa80bbBE1254a7aACf3219EBe1481c6E01d7" + "description": "ZetaChain ZRC20 BNB-bsc_mainnet" }, { "address": "0x7c8dDa80bbBE1254a7aACf3219EBe1481c6E01d7", "asset": "0xdac17f958d2ee523a2206206994597c13d831ec7", "category": "omnichain", "chain_id": 7000, + "foreign_chain_id": "1", "chain_name": "zeta_testnet", - "type": "ZRC20", - "coin_type": "ERC20", - "decimals": 18, - "symbol": "ZetaChain ZRC20 USDT on ETH" - }, - { - "address": "0x55d398326f99059ff775485246999027b3197955", - "category": "omnichain", - "chain_id": "56", - "chain_name": "bsc_mainnet", - "coin_type": "ERC20", + "type": "zrc20", + "symbol": "USDT.ETH", + "coin_type": "erc20", "decimals": 18, - "symbol": "USDT.BSC", - "zrc20": "0x91d4F0D54090Df2D81e834c3c8CE71C6c865e79F" + "description": "ZetaChain ZRC20 USDT on ETH" }, { "address": "0x91d4F0D54090Df2D81e834c3c8CE71C6c865e79F", "asset": "0x55d398326f99059ff775485246999027b3197955", "category": "omnichain", "chain_id": 7000, + "foreign_chain_id": "56", "chain_name": "zeta_testnet", - "type": "ZRC20", - "coin_type": "ERC20", + "type": "zrc20", + "symbol": "USDT.BSC", + "coin_type": "erc20", "decimals": 18, - "symbol": "ZetaChain ZRC20 USDT on BSC" + "description": "ZetaChain ZRC20 USDT on BSC" }, { "address": "0xd97B1de3619ed2c6BEb3860147E30cA8A7dC9891", "asset": "", "category": "omnichain", "chain_id": 7000, + "foreign_chain_id": "1", "chain_name": "zeta_testnet", - "type": "ZRC20", - "coin_type": "Gas", + "type": "zrc20", + "symbol": "ETH.ETH", + "coin_type": "gas", "decimals": 18, - "symbol": "ZetaChain ZRC20 ETH-eth_mainnet" + "description": "ZetaChain ZRC20 ETH-eth_mainnet" }, { "category": "omnichain", @@ -228,13 +202,6 @@ "chain_name": "eth_mainnet", "type": "erc20Custody" }, - { - "address": "0xaf28a257D292e7f0E531073f70a175b57E0261a8", - "category": "omnichain", - "chain_id": "56", - "chain_name": "bsc_mainnet", - "type": "tssUpdater" - }, { "address": "0xaeB6dDB7708467814D557e340283248be8E43124", "category": "omnichain", @@ -243,11 +210,11 @@ "type": "tssUpdater" }, { - "address": "0xaeB6dDB7708467814D557e340283248be8E43124", - "category": "messaging", - "chain_id": "1", - "chain_name": "eth_mainnet", - "type": "pauser" + "address": "0xaf28a257D292e7f0E531073f70a175b57E0261a8", + "category": "omnichain", + "chain_id": "56", + "chain_name": "bsc_mainnet", + "type": "tssUpdater" }, { "address": "0xaf28a257D292e7f0E531073f70a175b57E0261a8", @@ -255,5 +222,12 @@ "chain_id": "56", "chain_name": "bsc_mainnet", "type": "pauser" + }, + { + "address": "0xaeB6dDB7708467814D557e340283248be8E43124", + "category": "messaging", + "chain_id": "1", + "chain_name": "eth_mainnet", + "type": "pauser" } ] diff --git a/data/addresses.testnet.json b/data/addresses.testnet.json index 6fc61bce..575ff9bd 100644 --- a/data/addresses.testnet.json +++ b/data/addresses.testnet.json @@ -41,112 +41,96 @@ "chain_name": "zeta_testnet", "type": "connector" }, - { - "address": "0x07865c6e87b9f70255377e024ace6630c1eaa37f", - "category": "omnichain", - "chain_id": "5", - "chain_name": "goerli_testnet", - "coin_type": "ERC20", - "decimals": 6, - "symbol": "USDC", - "zrc20": "0x0cbe0dF132a6c6B4a2974Fa1b7Fb953CF0Cc798a" - }, { "address": "0x0cbe0dF132a6c6B4a2974Fa1b7Fb953CF0Cc798a", "asset": "0x07865c6e87b9f70255377e024ace6630c1eaa37f", "category": "omnichain", "chain_id": 7001, + "foreign_chain_id": "5", "chain_name": "zeta_testnet", - "type": "ZRC20", - "coin_type": "ERC20", + "type": "zrc20", + "symbol": "USDC", + "coin_type": "erc20", "decimals": 18, - "symbol": "USDC-goerli_testnet" + "description": "USDC-goerli_testnet" }, { "address": "0x13A0c5930C028511Dc02665E7285134B6d11A5f4", "asset": "", "category": "omnichain", "chain_id": 7001, + "foreign_chain_id": "5", "chain_name": "zeta_testnet", - "type": "ZRC20", - "coin_type": "Gas", + "type": "zrc20", + "symbol": "gETH", + "coin_type": "gas", "decimals": 18, - "symbol": "ETH-goerli_testnet" + "description": "ETH-goerli_testnet" }, { "address": "0x48f80608B672DC30DC7e3dbBd0343c5F02C738Eb", "asset": "", "category": "omnichain", "chain_id": 7001, + "foreign_chain_id": "80001", "chain_name": "zeta_testnet", - "type": "ZRC20", - "coin_type": "Gas", + "type": "zrc20", + "symbol": "tMATIC", + "coin_type": "gas", "decimals": 18, - "symbol": "MATIC-mumbai_testnet" + "description": "MATIC-mumbai_testnet" }, { "address": "0x65a45c57636f9BcCeD4fe193A602008578BcA90b", "asset": "", "category": "omnichain", "chain_id": 7001, + "foreign_chain_id": "18332", "chain_name": "zeta_testnet", - "type": "ZRC20", - "coin_type": "Gas", + "type": "zrc20", + "symbol": "tBTC", + "coin_type": "gas", "decimals": 18, - "symbol": "BTC-btc_testnet-btc_testnet" - }, - { - "address": "0x64544969ed7EBf5f083679233325356EbE738930", - "category": "omnichain", - "chain_id": "97", - "chain_name": "bsc_testnet", - "coin_type": "ERC20", - "decimals": 6, - "symbol": "USDC", - "zrc20": "0x7c8dDa80bbBE1254a7aACf3219EBe1481c6E01d7" + "description": "BTC-btc_testnet-btc_testnet" }, { "address": "0x7c8dDa80bbBE1254a7aACf3219EBe1481c6E01d7", "asset": "0x64544969ed7EBf5f083679233325356EbE738930", "category": "omnichain", "chain_id": 7001, + "foreign_chain_id": "97", "chain_name": "zeta_testnet", - "type": "ZRC20", - "coin_type": "ERC20", - "decimals": 18, - "symbol": "USDC-bsc_testnet" - }, - { - "address": "0x9999f7fea5938fd3b1e26a12c3f2fb024e194f97", - "category": "omnichain", - "chain_id": "80001", - "chain_name": "mumbai_testnet", - "coin_type": "ERC20", - "decimals": 6, + "type": "zrc20", "symbol": "USDC", - "zrc20": "0x91d4F0D54090Df2D81e834c3c8CE71C6c865e79F" + "coin_type": "erc20", + "decimals": 18, + "description": "USDC-bsc_testnet" }, { "address": "0x91d4F0D54090Df2D81e834c3c8CE71C6c865e79F", "asset": "0x9999f7fea5938fd3b1e26a12c3f2fb024e194f97", "category": "omnichain", "chain_id": 7001, + "foreign_chain_id": "80001", "chain_name": "zeta_testnet", - "type": "ZRC20", - "coin_type": "ERC20", + "type": "zrc20", + "symbol": "USDC", + "coin_type": "erc20", "decimals": 18, - "symbol": "USDC-mumbai_testnet" + "description": "USDC-mumbai_testnet" }, { "address": "0xd97B1de3619ed2c6BEb3860147E30cA8A7dC9891", "asset": "", "category": "omnichain", "chain_id": 7001, + "foreign_chain_id": "97", "chain_name": "zeta_testnet", - "type": "ZRC20", - "coin_type": "Gas", + "type": "zrc20", + "symbol": "tBNB", + "coin_type": "gas", "decimals": 18, - "symbol": "BNB-bsc_testnet" + "description": "BNB-bsc_testnet" }, { "category": "omnichain", @@ -242,22 +226,22 @@ { "address": "0x55122f7590164Ac222504436943FAB17B62F5d7d", "category": "omnichain", - "chain_id": "97", - "chain_name": "bsc_testnet", + "chain_id": "80001", + "chain_name": "mumbai_testnet", "type": "tssUpdater" }, { "address": "0x55122f7590164Ac222504436943FAB17B62F5d7d", "category": "omnichain", - "chain_id": "5", - "chain_name": "goerli_testnet", + "chain_id": "97", + "chain_name": "bsc_testnet", "type": "tssUpdater" }, { "address": "0x55122f7590164Ac222504436943FAB17B62F5d7d", "category": "omnichain", - "chain_id": "80001", - "chain_name": "mumbai_testnet", + "chain_id": "5", + "chain_name": "goerli_testnet", "type": "tssUpdater" }, { diff --git a/lib/address.tools.ts b/lib/address.tools.ts index 61348de8..4fd6bec6 100644 --- a/lib/address.tools.ts +++ b/lib/address.tools.ts @@ -81,13 +81,13 @@ export const isMainnetNetwork = (network: ZetaProtocolTestNetwork): boolean => { return false; }; -export const getAddress = (address: ZetaProtocolAddress | ZetaZEVMAddress, network: ZetaProtocolNetwork): string => { - if (isZetaProtocolAddress(address)) { - return (addresses["ccm"] as any)[network][address]; - } +// export const getAddress = (address: ZetaProtocolAddress | ZetaZEVMAddress, network: ZetaProtocolNetwork): string => { +// if (isZetaProtocolAddress(address)) { +// return (addresses["ccm"] as any)[network][address]; +// } - return (addresses["zevm"] as any)[network][address]; -}; +// return (addresses["zevm"] as any)[network][address]; +// }; export const getZRC20Address = (network: ZetaProtocolNetwork): string => { return (addresses["zevm"] as any)[network]["zrc20"]; diff --git a/lib/addresses.ts b/lib/addresses.ts new file mode 100644 index 00000000..7b00257a --- /dev/null +++ b/lib/addresses.ts @@ -0,0 +1,21 @@ +import testnet from "../data/addresses.testnet.json"; +import mainnet from "../data/addresses.mainnet.json"; +import { getChainId } from "@zetachain/networks"; + +export const getAddress = (type: any, network: any, symbol?: any) => { + const networks = [...testnet, ...mainnet]; + let address; + if (type === "zrc20" && !symbol) { + // for backwards compatibility + const chainId = getChainId(network); + console.log(chainId); + address = networks.find((n: any) => { + return n.foreign_chain_id === chainId?.toString() && n.type === type && n.coin_type === "gas"; + }); + } else { + address = networks.find((n: any) => { + return n.chain_name === network && n.type === type; + }); + } + return address?.address; +}; diff --git a/lib/index.ts b/lib/index.ts index b2321035..2538dee6 100644 --- a/lib/index.ts +++ b/lib/index.ts @@ -1 +1,5 @@ export * from "./address.tools"; +export * from "./addresses"; + +export { default as testnet } from "../data/addresses.testnet.json"; +export { default as mainnet } from "../data/addresses.mainnet.json"; diff --git a/tasks/addresses.ts b/tasks/addresses.ts index 9580d01f..748cf0f3 100644 --- a/tasks/addresses.ts +++ b/tasks/addresses.ts @@ -7,6 +7,8 @@ import { ZetaConnectorBase__factory } from "../typechain-types"; import { ERC20Custody__factory } from "../typechain-types/factories/contracts/evm/ERC20Custody__factory"; import { SystemContract__factory } from "../typechain-types/factories/contracts/zevm/SystemContract.sol/SystemContract__factory"; +declare const hre: any; + type Network = "zeta_mainnet" | "zeta_testnet"; const api = { @@ -96,28 +98,18 @@ const fetchForeignCoinsData = async (chains: any, addresses: any, network: Netwo const foreignCoinsResponse: AxiosResponse = await axios.get(URL); if (foreignCoinsResponse.status === 200) { foreignCoinsResponse.data.foreignCoins.forEach((token: any) => { - if (token.coin_type !== "Gas") { - addresses.push({ - address: token.asset, - category: "omnichain", - chain_id: token.foreign_chain_id, - chain_name: chains.find((c: any) => c.chain_id === token.foreign_chain_id)?.chain_name, - coin_type: token.coin_type, - decimals: token.decimals, - symbol: token.symbol, - zrc20: token.zrc20_contract_address, // TODO: dynamically fetch from contract (to verify) - }); - } addresses.push({ address: token.zrc20_contract_address, asset: token.asset, category: "omnichain", chain_id, + foreign_chain_id: token.foreign_chain_id, chain_name: "zeta_testnet", - type: "ZRC20", - coin_type: token.coin_type, + type: "zrc20", + symbol: token.symbol, + coin_type: token.coin_type.toLowerCase(), decimals: 18, - symbol: token.name, // TODO: dynamically fetch from contract + description: token.name, // TODO: dynamically fetch from contract }); }); } else { @@ -128,7 +120,7 @@ const fetchForeignCoinsData = async (chains: any, addresses: any, network: Netwo } }; -const fetchAthensAddresses = async (addresses: any, hre: HardhatRuntimeEnvironment, network: Network) => { +const fetchAthensAddresses = async (addresses: any, hre: any, network: Network) => { const chain_id = network === "zeta_mainnet" ? 7000 : 7001; const systemContract = addresses.find((a: any) => { return a.chain_name === "zeta_testnet" && a.type === "systemContract"; From dfc900946ca0fc20e437488a16d1b25b37c945aa Mon Sep 17 00:00:00 2001 From: Denis Fadeev Date: Mon, 5 Feb 2024 16:50:02 +0400 Subject: [PATCH 14/27] remove console log --- lib/addresses.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/addresses.ts b/lib/addresses.ts index 7b00257a..2d374e16 100644 --- a/lib/addresses.ts +++ b/lib/addresses.ts @@ -8,7 +8,6 @@ export const getAddress = (type: any, network: any, symbol?: any) => { if (type === "zrc20" && !symbol) { // for backwards compatibility const chainId = getChainId(network); - console.log(chainId); address = networks.find((n: any) => { return n.foreign_chain_id === chainId?.toString() && n.type === type && n.coin_type === "gas"; }); From 30851e230bf0a3fed726307478fb552b1f576799 Mon Sep 17 00:00:00 2001 From: Denis Fadeev Date: Mon, 5 Feb 2024 18:02:35 +0400 Subject: [PATCH 15/27] types --- data/addresses.mainnet.json | 48 ++++++++++++------------ data/addresses.testnet.json | 58 ++++++++++++++--------------- lib/addresses.ts | 3 +- lib/index.ts | 1 + lib/types.ts | 4 ++ package.json | 2 +- scripts/generate_addresses.sh | 6 ++- scripts/generate_addresses_types.ts | 42 +++++++++++++++++++++ 8 files changed, 108 insertions(+), 56 deletions(-) create mode 100644 lib/types.ts create mode 100644 scripts/generate_addresses_types.ts diff --git a/data/addresses.mainnet.json b/data/addresses.mainnet.json index 7cbd4aa2..b352fb0b 100644 --- a/data/addresses.mainnet.json +++ b/data/addresses.mainnet.json @@ -161,45 +161,45 @@ "type": "fungibleModule" }, { - "address": "0x0000028a2eB8346cd5c0267856aB7594B7a55308", + "address": "0xf091867EC603A6628eD83D274E835539D82e9cc8", "category": "messaging", - "chain_id": "56", - "chain_name": "bsc_mainnet", + "chain_id": "1", + "chain_name": "eth_mainnet", "type": "zetaToken" }, { - "address": "0x000063A6e758D9e2f438d430108377564cf4077D", + "address": "0x000007Cf399229b2f5A4D043F20E90C9C98B7C6a", "category": "messaging", - "chain_id": "56", - "chain_name": "bsc_mainnet", + "chain_id": "1", + "chain_name": "eth_mainnet", "type": "connector" }, { - "address": "0x00000fF8fA992424957F97688015814e707A0115", + "address": "0x0000030Ec64DF25301d8414eE5a29588C4B0dE10", "category": "omnichain", - "chain_id": "56", - "chain_name": "bsc_mainnet", + "chain_id": "1", + "chain_name": "eth_mainnet", "type": "erc20Custody" }, { - "address": "0xf091867EC603A6628eD83D274E835539D82e9cc8", + "address": "0x0000028a2eB8346cd5c0267856aB7594B7a55308", "category": "messaging", - "chain_id": "1", - "chain_name": "eth_mainnet", + "chain_id": "56", + "chain_name": "bsc_mainnet", "type": "zetaToken" }, { - "address": "0x000007Cf399229b2f5A4D043F20E90C9C98B7C6a", + "address": "0x000063A6e758D9e2f438d430108377564cf4077D", "category": "messaging", - "chain_id": "1", - "chain_name": "eth_mainnet", + "chain_id": "56", + "chain_name": "bsc_mainnet", "type": "connector" }, { - "address": "0x0000030Ec64DF25301d8414eE5a29588C4B0dE10", + "address": "0x00000fF8fA992424957F97688015814e707A0115", "category": "omnichain", - "chain_id": "1", - "chain_name": "eth_mainnet", + "chain_id": "56", + "chain_name": "bsc_mainnet", "type": "erc20Custody" }, { @@ -217,17 +217,17 @@ "type": "tssUpdater" }, { - "address": "0xaf28a257D292e7f0E531073f70a175b57E0261a8", + "address": "0xaeB6dDB7708467814D557e340283248be8E43124", "category": "messaging", - "chain_id": "56", - "chain_name": "bsc_mainnet", + "chain_id": "1", + "chain_name": "eth_mainnet", "type": "pauser" }, { - "address": "0xaeB6dDB7708467814D557e340283248be8E43124", + "address": "0xaf28a257D292e7f0E531073f70a175b57E0261a8", "category": "messaging", - "chain_id": "1", - "chain_name": "eth_mainnet", + "chain_id": "56", + "chain_name": "bsc_mainnet", "type": "pauser" } ] diff --git a/data/addresses.testnet.json b/data/addresses.testnet.json index 575ff9bd..2975e138 100644 --- a/data/addresses.testnet.json +++ b/data/addresses.testnet.json @@ -160,27 +160,6 @@ "address": "0x735b14BB79463307AAcBED86DAf3322B1e6226aB", "type": "fungibleModule" }, - { - "address": "0x0000c9ec4042283e8139c74f4c64bcd1e0b9b54f", - "category": "messaging", - "chain_id": "80001", - "chain_name": "mumbai_testnet", - "type": "zetaToken" - }, - { - "address": "0x0000ecb8cdd25a18f12daa23f6422e07fbf8b9e1", - "category": "messaging", - "chain_id": "80001", - "chain_name": "mumbai_testnet", - "type": "connector" - }, - { - "address": "0x0000a7db254145767262c6a81a7ee1650684258e", - "category": "omnichain", - "chain_id": "80001", - "chain_name": "mumbai_testnet", - "type": "erc20Custody" - }, { "address": "0x0000c304d2934c00db1d51995b9f6996affd17c0", "category": "messaging", @@ -224,17 +203,31 @@ "type": "erc20Custody" }, { - "address": "0x55122f7590164Ac222504436943FAB17B62F5d7d", + "address": "0x0000c9ec4042283e8139c74f4c64bcd1e0b9b54f", + "category": "messaging", + "chain_id": "80001", + "chain_name": "mumbai_testnet", + "type": "zetaToken" + }, + { + "address": "0x0000ecb8cdd25a18f12daa23f6422e07fbf8b9e1", + "category": "messaging", + "chain_id": "80001", + "chain_name": "mumbai_testnet", + "type": "connector" + }, + { + "address": "0x0000a7db254145767262c6a81a7ee1650684258e", "category": "omnichain", "chain_id": "80001", "chain_name": "mumbai_testnet", - "type": "tssUpdater" + "type": "erc20Custody" }, { "address": "0x55122f7590164Ac222504436943FAB17B62F5d7d", "category": "omnichain", - "chain_id": "97", - "chain_name": "bsc_testnet", + "chain_id": "80001", + "chain_name": "mumbai_testnet", "type": "tssUpdater" }, { @@ -246,10 +239,10 @@ }, { "address": "0x55122f7590164Ac222504436943FAB17B62F5d7d", - "category": "messaging", - "chain_id": "80001", - "chain_name": "mumbai_testnet", - "type": "pauser" + "category": "omnichain", + "chain_id": "97", + "chain_name": "bsc_testnet", + "type": "tssUpdater" }, { "address": "0x55122f7590164Ac222504436943FAB17B62F5d7d", @@ -258,6 +251,13 @@ "chain_name": "goerli_testnet", "type": "pauser" }, + { + "address": "0x55122f7590164Ac222504436943FAB17B62F5d7d", + "category": "messaging", + "chain_id": "80001", + "chain_name": "mumbai_testnet", + "type": "pauser" + }, { "address": "0x55122f7590164Ac222504436943FAB17B62F5d7d", "category": "messaging", diff --git a/lib/addresses.ts b/lib/addresses.ts index 2d374e16..c429f1b7 100644 --- a/lib/addresses.ts +++ b/lib/addresses.ts @@ -1,8 +1,9 @@ import testnet from "../data/addresses.testnet.json"; import mainnet from "../data/addresses.mainnet.json"; import { getChainId } from "@zetachain/networks"; +import { ParamChainName, ParamSymbol, ParamType } from "./types"; -export const getAddress = (type: any, network: any, symbol?: any) => { +export const getAddress = (type: ParamType, network: ParamChainName, symbol?: ParamSymbol) => { const networks = [...testnet, ...mainnet]; let address; if (type === "zrc20" && !symbol) { diff --git a/lib/index.ts b/lib/index.ts index 2538dee6..a30f92d8 100644 --- a/lib/index.ts +++ b/lib/index.ts @@ -1,5 +1,6 @@ export * from "./address.tools"; export * from "./addresses"; +export * from "./types"; export { default as testnet } from "../data/addresses.testnet.json"; export { default as mainnet } from "../data/addresses.mainnet.json"; diff --git a/lib/types.ts b/lib/types.ts new file mode 100644 index 00000000..bbcd0395 --- /dev/null +++ b/lib/types.ts @@ -0,0 +1,4 @@ +export declare type ParamSymbol = "USDC.BSC" | "USDC.ETH" | "BTC.BTC" | "BNB.BSC" | "USDT.ETH" | "USDT.BSC" | "ETH.ETH" | "USDC" | "gETH" | "tMATIC" | "tBTC" | "tBNB"; +export declare type ParamChainName = "eth_mainnet" | "bsc_mainnet" | "btc_mainnet" | "zeta_mainnet" | "zeta_testnet" | "goerli_testnet" | "bsc_testnet" | "mumbai_testnet" | "btc_testnet"; +export declare type ParamType = "tss" | "systemContract" | "connector" | "zrc20" | "uniswapv2Factory" | "wZetaContract" | "uniswapv2Router02" | "fungibleModule" | "zetaToken" | "erc20Custody" | "tssUpdater" | "pauser"; + diff --git a/package.json b/package.json index 61c6e323..546fdcde 100644 --- a/package.json +++ b/package.json @@ -79,4 +79,4 @@ }, "types": "./dist/lib/index.d.ts", "version": "0.0.8" -} +} \ No newline at end of file diff --git a/scripts/generate_addresses.sh b/scripts/generate_addresses.sh index d7146033..62e81086 100755 --- a/scripts/generate_addresses.sh +++ b/scripts/generate_addresses.sh @@ -3,4 +3,8 @@ echo "Generating protocol addresses..." npx hardhat addresses --network zeta_testnet > ./data/addresses.testnet.json -npx hardhat addresses --network zeta_mainnet > ./data/addresses.mainnet.json \ No newline at end of file +npx hardhat addresses --network zeta_mainnet > ./data/addresses.mainnet.json + +echo "Generating protocol addresses types..." + +npx ts-node scripts/generate_addresses_types.ts > ./lib/types.d.ts \ No newline at end of file diff --git a/scripts/generate_addresses_types.ts b/scripts/generate_addresses_types.ts new file mode 100644 index 00000000..70909d01 --- /dev/null +++ b/scripts/generate_addresses_types.ts @@ -0,0 +1,42 @@ +import testnet from "../data/addresses.testnet.json"; +import mainnet from "../data/addresses.mainnet.json"; + +const extractUniqueValues = (data: any[], key: string): string[] => { + const allValues = data.filter((item) => item[key] !== undefined).map((item) => item[key].toString()); + return [...new Set(allValues)]; +}; + +const generateTypesForKeys = (keys: string[]) => { + const networks = [...mainnet, ...testnet]; + + let typeDefs = ""; + + keys.forEach((key) => { + const uniqueValues = extractUniqueValues(networks, key); + if (uniqueValues.length > 0) { + const isNumeric = uniqueValues.every((value) => !isNaN(Number(value))); + const formattedValues = isNumeric ? uniqueValues.join(" | ") : `"${uniqueValues.join('" | "')}"`; + + typeDefs += `export type Param${toCamelCase(key, true)} = ${formattedValues};\n`; + } + }); + + console.log(typeDefs); +}; + +// Modify this function to handle underscores and capitalize each word +const toCamelCase = (string: string, capitalizeFirst: boolean = false) => { + return string + .split("_") + .map((word, index) => { + if (index === 0) { + return capitalizeFirst ? word.charAt(0).toUpperCase() + word.slice(1) : word; + } + return word.charAt(0).toUpperCase() + word.slice(1); + }) + .join(""); +}; + +const keysToGenerate = ["symbol", "chain_name", "type"]; + +generateTypesForKeys(keysToGenerate); From 9010907cafe32e33fac36729806d9a7e46a51534 Mon Sep 17 00:00:00 2001 From: Denis Fadeev Date: Mon, 5 Feb 2024 18:03:01 +0400 Subject: [PATCH 16/27] lint --- data/addresses.json | 38 ++++++++--------- data/addresses.mainnet.json | 64 ++++++++++++++--------------- data/addresses.testnet.json | 64 ++++++++++++++--------------- lib/addresses.ts | 5 ++- lib/index.ts | 5 +-- lib/types.ts | 40 ++++++++++++++++-- package.json | 2 +- scripts/generate_addresses_types.ts | 2 +- tasks/addresses.ts | 8 ++-- 9 files changed, 130 insertions(+), 98 deletions(-) diff --git a/data/addresses.json b/data/addresses.json index cd879792..b78c7b76 100644 --- a/data/addresses.json +++ b/data/addresses.json @@ -18,19 +18,19 @@ "zetaTokenConsumerUniV2": "", "zetaTokenConsumerUniV3": "0xFB2fCE3CCca19F0f764Ed8aa26C62181E3dA04C5" }, - "btc_testnet": { + "btc_mainnet": { "connector": "", "immutableCreate2Factory": "", - "tss": "tb1qy9pqmk2pd9sv63g27jt8r657wy0d9ueeh0nqur", + "tss": "bc1qm24wp577nk8aacckv8np465z3dvmu7ry45el6y", "tssUpdater": "", "zetaToken": "", "zetaTokenConsumerUniV2": "", "zetaTokenConsumerUniV3": "" }, - "btc_mainnet": { + "btc_testnet": { "connector": "", "immutableCreate2Factory": "", - "tss": "bc1qm24wp577nk8aacckv8np465z3dvmu7ry45el6y", + "tss": "tb1qy9pqmk2pd9sv63g27jt8r657wy0d9ueeh0nqur", "tssUpdater": "", "zetaToken": "", "zetaTokenConsumerUniV2": "", @@ -64,20 +64,20 @@ "zetaTokenConsumerUniV2": "", "zetaTokenConsumerUniV3": "0x7e792f3736751e168864106AdbAC50152641A927" }, - "zeta_testnet": { + "zeta_mainnet": { "connector": "0x239e96c8f17C85c30100AC26F635Ea15f23E9c67", "immutableCreate2Factory": "", - "tss": "0x7c125C1d515b8945841b3d5144a060115C58725F", - "tssUpdater": "0x7274d1d5dddef36aac53dd45b93487ce01ef0a55", + "tss": "", + "tssUpdater": "", "zetaToken": "0x5F0b1a82749cb4E2278EC87F8BF6B618dC71a8bf", "zetaTokenConsumerUniV2": "", "zetaTokenConsumerUniV3": "" }, - "zeta_mainnet": { + "zeta_testnet": { "connector": "0x239e96c8f17C85c30100AC26F635Ea15f23E9c67", "immutableCreate2Factory": "", - "tss": "", - "tssUpdater": "", + "tss": "0x7c125C1d515b8945841b3d5144a060115C58725F", + "tssUpdater": "0x7274d1d5dddef36aac53dd45b93487ce01ef0a55", "zetaToken": "0x5F0b1a82749cb4E2278EC87F8BF6B618dC71a8bf", "zetaTokenConsumerUniV2": "", "zetaTokenConsumerUniV3": "" @@ -131,26 +131,26 @@ "bsc_testnet": { "zrc20": "0xd97B1de3619ed2c6BEb3860147E30cA8A7dC9891" }, + "btc_testnet": { + "zrc20": "0x65a45c57636f9BcCeD4fe193A602008578BcA90b" + }, "goerli_testnet": { "zrc20": "0x13A0c5930C028511Dc02665E7285134B6d11A5f4" }, "mumbai_testnet": { "zrc20": "0x48f80608B672DC30DC7e3dbBd0343c5F02C738Eb" }, - "btc_testnet": { - "zrc20": "0x65a45c57636f9BcCeD4fe193A602008578BcA90b" + "zeta_mainnet": { + "fungibleModule": "", + "systemContract": "0x91d18e54DAf4F677cB28167158d6dd21F6aB3921", + "uniswapv2Factory": "", + "uniswapv2Router02": "" }, "zeta_testnet": { "fungibleModule": "0x735b14BB79463307AAcBED86DAf3322B1e6226aB", "systemContract": "0xEdf1c3275d13489aCdC6cD6eD246E72458B8795B", "uniswapv2Factory": "0x9fd96203f7b22bCF72d9DCb40ff98302376cE09c", "uniswapv2Router02": "0x2ca7d64A7EFE2D62A725E2B35Cf7230D6677FfEe" - }, - "zeta_mainnet": { - "fungibleModule": "", - "systemContract": "0x91d18e54DAf4F677cB28167158d6dd21F6aB3921", - "uniswapv2Factory": "", - "uniswapv2Router02": "" } } -} \ No newline at end of file +} diff --git a/data/addresses.mainnet.json b/data/addresses.mainnet.json index b352fb0b..6a9f420d 100644 --- a/data/addresses.mainnet.json +++ b/data/addresses.mainnet.json @@ -46,118 +46,118 @@ "asset": "0x8ac76a51cc950d9822d68b83fe1ad97b32cd580d", "category": "omnichain", "chain_id": 7000, - "foreign_chain_id": "56", "chain_name": "zeta_testnet", - "type": "zrc20", - "symbol": "USDC.BSC", "coin_type": "erc20", "decimals": 18, - "description": "ZetaChain ZRC20 USDC on BSC" + "description": "ZetaChain ZRC20 USDC on BSC", + "foreign_chain_id": "56", + "symbol": "USDC.BSC", + "type": "zrc20" }, { "address": "0x0cbe0dF132a6c6B4a2974Fa1b7Fb953CF0Cc798a", "asset": "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48", "category": "omnichain", "chain_id": 7000, - "foreign_chain_id": "1", "chain_name": "zeta_testnet", - "type": "zrc20", - "symbol": "USDC.ETH", "coin_type": "erc20", "decimals": 18, - "description": "ZetaChain ZRC20 USDC on ETH" + "description": "ZetaChain ZRC20 USDC on ETH", + "foreign_chain_id": "1", + "symbol": "USDC.ETH", + "type": "zrc20" }, { "address": "0x13A0c5930C028511Dc02665E7285134B6d11A5f4", "asset": "", "category": "omnichain", "chain_id": 7000, - "foreign_chain_id": "8332", "chain_name": "zeta_testnet", - "type": "zrc20", - "symbol": "BTC.BTC", "coin_type": "gas", "decimals": 18, - "description": "ZetaChain ZRC20 BTC-btc_mainnet" + "description": "ZetaChain ZRC20 BTC-btc_mainnet", + "foreign_chain_id": "8332", + "symbol": "BTC.BTC", + "type": "zrc20" }, { "address": "0x48f80608B672DC30DC7e3dbBd0343c5F02C738Eb", "asset": "", "category": "omnichain", "chain_id": 7000, - "foreign_chain_id": "56", "chain_name": "zeta_testnet", - "type": "zrc20", - "symbol": "BNB.BSC", "coin_type": "gas", "decimals": 18, - "description": "ZetaChain ZRC20 BNB-bsc_mainnet" + "description": "ZetaChain ZRC20 BNB-bsc_mainnet", + "foreign_chain_id": "56", + "symbol": "BNB.BSC", + "type": "zrc20" }, { "address": "0x7c8dDa80bbBE1254a7aACf3219EBe1481c6E01d7", "asset": "0xdac17f958d2ee523a2206206994597c13d831ec7", "category": "omnichain", "chain_id": 7000, - "foreign_chain_id": "1", "chain_name": "zeta_testnet", - "type": "zrc20", - "symbol": "USDT.ETH", "coin_type": "erc20", "decimals": 18, - "description": "ZetaChain ZRC20 USDT on ETH" + "description": "ZetaChain ZRC20 USDT on ETH", + "foreign_chain_id": "1", + "symbol": "USDT.ETH", + "type": "zrc20" }, { "address": "0x91d4F0D54090Df2D81e834c3c8CE71C6c865e79F", "asset": "0x55d398326f99059ff775485246999027b3197955", "category": "omnichain", "chain_id": 7000, - "foreign_chain_id": "56", "chain_name": "zeta_testnet", - "type": "zrc20", - "symbol": "USDT.BSC", "coin_type": "erc20", "decimals": 18, - "description": "ZetaChain ZRC20 USDT on BSC" + "description": "ZetaChain ZRC20 USDT on BSC", + "foreign_chain_id": "56", + "symbol": "USDT.BSC", + "type": "zrc20" }, { "address": "0xd97B1de3619ed2c6BEb3860147E30cA8A7dC9891", "asset": "", "category": "omnichain", "chain_id": 7000, - "foreign_chain_id": "1", "chain_name": "zeta_testnet", - "type": "zrc20", - "symbol": "ETH.ETH", "coin_type": "gas", "decimals": 18, - "description": "ZetaChain ZRC20 ETH-eth_mainnet" + "description": "ZetaChain ZRC20 ETH-eth_mainnet", + "foreign_chain_id": "1", + "symbol": "ETH.ETH", + "type": "zrc20" }, { + "address": "0x9fd96203f7b22bCF72d9DCb40ff98302376cE09c", "category": "omnichain", "chain_id": 7000, "chain_name": "zeta_testnet", - "address": "0x9fd96203f7b22bCF72d9DCb40ff98302376cE09c", "type": "uniswapv2Factory" }, { + "address": "0x5F0b1a82749cb4E2278EC87F8BF6B618dC71a8bf", "category": "omnichain", "chain_id": 7000, "chain_name": "zeta_testnet", - "address": "0x5F0b1a82749cb4E2278EC87F8BF6B618dC71a8bf", "type": "wZetaContract" }, { + "address": "0x2ca7d64A7EFE2D62A725E2B35Cf7230D6677FfEe", "category": "omnichain", "chain_id": 7000, "chain_name": "zeta_testnet", - "address": "0x2ca7d64A7EFE2D62A725E2B35Cf7230D6677FfEe", "type": "uniswapv2Router02" }, { + "address": "0x735b14BB79463307AAcBED86DAf3322B1e6226aB", "category": "omnichain", "chain_id": 7000, "chain_name": "zeta_testnet", - "address": "0x735b14BB79463307AAcBED86DAf3322B1e6226aB", "type": "fungibleModule" }, { diff --git a/data/addresses.testnet.json b/data/addresses.testnet.json index 2975e138..46887818 100644 --- a/data/addresses.testnet.json +++ b/data/addresses.testnet.json @@ -46,118 +46,118 @@ "asset": "0x07865c6e87b9f70255377e024ace6630c1eaa37f", "category": "omnichain", "chain_id": 7001, - "foreign_chain_id": "5", "chain_name": "zeta_testnet", - "type": "zrc20", - "symbol": "USDC", "coin_type": "erc20", "decimals": 18, - "description": "USDC-goerli_testnet" + "description": "USDC-goerli_testnet", + "foreign_chain_id": "5", + "symbol": "USDC", + "type": "zrc20" }, { "address": "0x13A0c5930C028511Dc02665E7285134B6d11A5f4", "asset": "", "category": "omnichain", "chain_id": 7001, - "foreign_chain_id": "5", "chain_name": "zeta_testnet", - "type": "zrc20", - "symbol": "gETH", "coin_type": "gas", "decimals": 18, - "description": "ETH-goerli_testnet" + "description": "ETH-goerli_testnet", + "foreign_chain_id": "5", + "symbol": "gETH", + "type": "zrc20" }, { "address": "0x48f80608B672DC30DC7e3dbBd0343c5F02C738Eb", "asset": "", "category": "omnichain", "chain_id": 7001, - "foreign_chain_id": "80001", "chain_name": "zeta_testnet", - "type": "zrc20", - "symbol": "tMATIC", "coin_type": "gas", "decimals": 18, - "description": "MATIC-mumbai_testnet" + "description": "MATIC-mumbai_testnet", + "foreign_chain_id": "80001", + "symbol": "tMATIC", + "type": "zrc20" }, { "address": "0x65a45c57636f9BcCeD4fe193A602008578BcA90b", "asset": "", "category": "omnichain", "chain_id": 7001, - "foreign_chain_id": "18332", "chain_name": "zeta_testnet", - "type": "zrc20", - "symbol": "tBTC", "coin_type": "gas", "decimals": 18, - "description": "BTC-btc_testnet-btc_testnet" + "description": "BTC-btc_testnet-btc_testnet", + "foreign_chain_id": "18332", + "symbol": "tBTC", + "type": "zrc20" }, { "address": "0x7c8dDa80bbBE1254a7aACf3219EBe1481c6E01d7", "asset": "0x64544969ed7EBf5f083679233325356EbE738930", "category": "omnichain", "chain_id": 7001, - "foreign_chain_id": "97", "chain_name": "zeta_testnet", - "type": "zrc20", - "symbol": "USDC", "coin_type": "erc20", "decimals": 18, - "description": "USDC-bsc_testnet" + "description": "USDC-bsc_testnet", + "foreign_chain_id": "97", + "symbol": "USDC", + "type": "zrc20" }, { "address": "0x91d4F0D54090Df2D81e834c3c8CE71C6c865e79F", "asset": "0x9999f7fea5938fd3b1e26a12c3f2fb024e194f97", "category": "omnichain", "chain_id": 7001, - "foreign_chain_id": "80001", "chain_name": "zeta_testnet", - "type": "zrc20", - "symbol": "USDC", "coin_type": "erc20", "decimals": 18, - "description": "USDC-mumbai_testnet" + "description": "USDC-mumbai_testnet", + "foreign_chain_id": "80001", + "symbol": "USDC", + "type": "zrc20" }, { "address": "0xd97B1de3619ed2c6BEb3860147E30cA8A7dC9891", "asset": "", "category": "omnichain", "chain_id": 7001, - "foreign_chain_id": "97", "chain_name": "zeta_testnet", - "type": "zrc20", - "symbol": "tBNB", "coin_type": "gas", "decimals": 18, - "description": "BNB-bsc_testnet" + "description": "BNB-bsc_testnet", + "foreign_chain_id": "97", + "symbol": "tBNB", + "type": "zrc20" }, { + "address": "0x9fd96203f7b22bCF72d9DCb40ff98302376cE09c", "category": "omnichain", "chain_id": 7001, "chain_name": "zeta_testnet", - "address": "0x9fd96203f7b22bCF72d9DCb40ff98302376cE09c", "type": "uniswapv2Factory" }, { + "address": "0x5F0b1a82749cb4E2278EC87F8BF6B618dC71a8bf", "category": "omnichain", "chain_id": 7001, "chain_name": "zeta_testnet", - "address": "0x5F0b1a82749cb4E2278EC87F8BF6B618dC71a8bf", "type": "wZetaContract" }, { + "address": "0x2ca7d64A7EFE2D62A725E2B35Cf7230D6677FfEe", "category": "omnichain", "chain_id": 7001, "chain_name": "zeta_testnet", - "address": "0x2ca7d64A7EFE2D62A725E2B35Cf7230D6677FfEe", "type": "uniswapv2Router02" }, { + "address": "0x735b14BB79463307AAcBED86DAf3322B1e6226aB", "category": "omnichain", "chain_id": 7001, "chain_name": "zeta_testnet", - "address": "0x735b14BB79463307AAcBED86DAf3322B1e6226aB", "type": "fungibleModule" }, { diff --git a/lib/addresses.ts b/lib/addresses.ts index c429f1b7..7aae67d0 100644 --- a/lib/addresses.ts +++ b/lib/addresses.ts @@ -1,6 +1,7 @@ -import testnet from "../data/addresses.testnet.json"; -import mainnet from "../data/addresses.mainnet.json"; import { getChainId } from "@zetachain/networks"; + +import mainnet from "../data/addresses.mainnet.json"; +import testnet from "../data/addresses.testnet.json"; import { ParamChainName, ParamSymbol, ParamType } from "./types"; export const getAddress = (type: ParamType, network: ParamChainName, symbol?: ParamSymbol) => { diff --git a/lib/index.ts b/lib/index.ts index a30f92d8..0e1ccbec 100644 --- a/lib/index.ts +++ b/lib/index.ts @@ -1,6 +1,5 @@ +export { default as mainnet } from "../data/addresses.mainnet.json"; +export { default as testnet } from "../data/addresses.testnet.json"; export * from "./address.tools"; export * from "./addresses"; export * from "./types"; - -export { default as testnet } from "../data/addresses.testnet.json"; -export { default as mainnet } from "../data/addresses.mainnet.json"; diff --git a/lib/types.ts b/lib/types.ts index bbcd0395..722d2f93 100644 --- a/lib/types.ts +++ b/lib/types.ts @@ -1,4 +1,36 @@ -export declare type ParamSymbol = "USDC.BSC" | "USDC.ETH" | "BTC.BTC" | "BNB.BSC" | "USDT.ETH" | "USDT.BSC" | "ETH.ETH" | "USDC" | "gETH" | "tMATIC" | "tBTC" | "tBNB"; -export declare type ParamChainName = "eth_mainnet" | "bsc_mainnet" | "btc_mainnet" | "zeta_mainnet" | "zeta_testnet" | "goerli_testnet" | "bsc_testnet" | "mumbai_testnet" | "btc_testnet"; -export declare type ParamType = "tss" | "systemContract" | "connector" | "zrc20" | "uniswapv2Factory" | "wZetaContract" | "uniswapv2Router02" | "fungibleModule" | "zetaToken" | "erc20Custody" | "tssUpdater" | "pauser"; - +export declare type ParamSymbol = + | "BNB.BSC" + | "BTC.BTC" + | "ETH.ETH" + | "gETH" + | "tBNB" + | "tBTC" + | "tMATIC" + | "USDC.BSC" + | "USDC.ETH" + | "USDC" + | "USDT.BSC" + | "USDT.ETH"; +export declare type ParamChainName = + | "bsc_mainnet" + | "bsc_testnet" + | "btc_mainnet" + | "btc_testnet" + | "eth_mainnet" + | "goerli_testnet" + | "mumbai_testnet" + | "zeta_mainnet" + | "zeta_testnet"; +export declare type ParamType = + | "connector" + | "erc20Custody" + | "fungibleModule" + | "pauser" + | "systemContract" + | "tss" + | "tssUpdater" + | "uniswapv2Factory" + | "uniswapv2Router02" + | "wZetaContract" + | "zetaToken" + | "zrc20"; diff --git a/package.json b/package.json index 546fdcde..61c6e323 100644 --- a/package.json +++ b/package.json @@ -79,4 +79,4 @@ }, "types": "./dist/lib/index.d.ts", "version": "0.0.8" -} \ No newline at end of file +} diff --git a/scripts/generate_addresses_types.ts b/scripts/generate_addresses_types.ts index 70909d01..2c0622be 100644 --- a/scripts/generate_addresses_types.ts +++ b/scripts/generate_addresses_types.ts @@ -1,5 +1,5 @@ -import testnet from "../data/addresses.testnet.json"; import mainnet from "../data/addresses.mainnet.json"; +import testnet from "../data/addresses.testnet.json"; const extractUniqueValues = (data: any[], key: string): string[] => { const allValues = data.filter((item) => item[key] !== undefined).map((item) => item[key].toString()); diff --git a/tasks/addresses.ts b/tasks/addresses.ts index 748cf0f3..a3fc4d54 100644 --- a/tasks/addresses.ts +++ b/tasks/addresses.ts @@ -103,13 +103,13 @@ const fetchForeignCoinsData = async (chains: any, addresses: any, network: Netwo asset: token.asset, category: "omnichain", chain_id, - foreign_chain_id: token.foreign_chain_id, chain_name: "zeta_testnet", - type: "zrc20", - symbol: token.symbol, coin_type: token.coin_type.toLowerCase(), decimals: 18, - description: token.name, // TODO: dynamically fetch from contract + description: token.name, + foreign_chain_id: token.foreign_chain_id, + symbol: token.symbol, + type: "zrc20", // TODO: dynamically fetch from contract }); }); } else { From cf1d56e23792ec98d858948ce44edd249bc0851e Mon Sep 17 00:00:00 2001 From: Denis Fadeev Date: Mon, 5 Feb 2024 18:34:33 +0400 Subject: [PATCH 17/27] fix addresses --- data/addresses.mainnet.json | 104 +++++++++++++++--------------- data/addresses.testnet.json | 122 ++++++++++++++++++------------------ lib/addresses.ts | 5 +- tasks/addresses.ts | 20 +++--- 4 files changed, 127 insertions(+), 124 deletions(-) diff --git a/data/addresses.mainnet.json b/data/addresses.mainnet.json index 6a9f420d..db4aedd5 100644 --- a/data/addresses.mainnet.json +++ b/data/addresses.mainnet.json @@ -31,14 +31,14 @@ "address": "0x91d18e54DAf4F677cB28167158d6dd21F6aB3921", "category": "omnichain", "chain_id": 7000, - "chain_name": "zeta_testnet", + "chain_name": "zeta_mainnet", "type": "systemContract" }, { "address": "0x239e96c8f17C85c30100AC26F635Ea15f23E9c67", "category": "messaging", "chain_id": 7000, - "chain_name": "zeta_testnet", + "chain_name": "zeta_mainnet", "type": "connector" }, { @@ -46,118 +46,118 @@ "asset": "0x8ac76a51cc950d9822d68b83fe1ad97b32cd580d", "category": "omnichain", "chain_id": 7000, - "chain_name": "zeta_testnet", - "coin_type": "erc20", - "decimals": 18, - "description": "ZetaChain ZRC20 USDC on BSC", "foreign_chain_id": "56", + "chain_name": "zeta_mainnet", + "type": "zrc20", "symbol": "USDC.BSC", - "type": "zrc20" + "coin_type": "erc20", + "decimals": 18, + "description": "ZetaChain ZRC20 USDC on BSC" }, { "address": "0x0cbe0dF132a6c6B4a2974Fa1b7Fb953CF0Cc798a", "asset": "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48", "category": "omnichain", "chain_id": 7000, - "chain_name": "zeta_testnet", - "coin_type": "erc20", - "decimals": 18, - "description": "ZetaChain ZRC20 USDC on ETH", "foreign_chain_id": "1", + "chain_name": "zeta_mainnet", + "type": "zrc20", "symbol": "USDC.ETH", - "type": "zrc20" + "coin_type": "erc20", + "decimals": 18, + "description": "ZetaChain ZRC20 USDC on ETH" }, { "address": "0x13A0c5930C028511Dc02665E7285134B6d11A5f4", "asset": "", "category": "omnichain", "chain_id": 7000, - "chain_name": "zeta_testnet", - "coin_type": "gas", - "decimals": 18, - "description": "ZetaChain ZRC20 BTC-btc_mainnet", "foreign_chain_id": "8332", + "chain_name": "zeta_mainnet", + "type": "zrc20", "symbol": "BTC.BTC", - "type": "zrc20" + "coin_type": "gas", + "decimals": 18, + "description": "ZetaChain ZRC20 BTC-btc_mainnet" }, { "address": "0x48f80608B672DC30DC7e3dbBd0343c5F02C738Eb", "asset": "", "category": "omnichain", "chain_id": 7000, - "chain_name": "zeta_testnet", - "coin_type": "gas", - "decimals": 18, - "description": "ZetaChain ZRC20 BNB-bsc_mainnet", "foreign_chain_id": "56", + "chain_name": "zeta_mainnet", + "type": "zrc20", "symbol": "BNB.BSC", - "type": "zrc20" + "coin_type": "gas", + "decimals": 18, + "description": "ZetaChain ZRC20 BNB-bsc_mainnet" }, { "address": "0x7c8dDa80bbBE1254a7aACf3219EBe1481c6E01d7", "asset": "0xdac17f958d2ee523a2206206994597c13d831ec7", "category": "omnichain", "chain_id": 7000, - "chain_name": "zeta_testnet", - "coin_type": "erc20", - "decimals": 18, - "description": "ZetaChain ZRC20 USDT on ETH", "foreign_chain_id": "1", + "chain_name": "zeta_mainnet", + "type": "zrc20", "symbol": "USDT.ETH", - "type": "zrc20" + "coin_type": "erc20", + "decimals": 18, + "description": "ZetaChain ZRC20 USDT on ETH" }, { "address": "0x91d4F0D54090Df2D81e834c3c8CE71C6c865e79F", "asset": "0x55d398326f99059ff775485246999027b3197955", "category": "omnichain", "chain_id": 7000, - "chain_name": "zeta_testnet", - "coin_type": "erc20", - "decimals": 18, - "description": "ZetaChain ZRC20 USDT on BSC", "foreign_chain_id": "56", + "chain_name": "zeta_mainnet", + "type": "zrc20", "symbol": "USDT.BSC", - "type": "zrc20" + "coin_type": "erc20", + "decimals": 18, + "description": "ZetaChain ZRC20 USDT on BSC" }, { "address": "0xd97B1de3619ed2c6BEb3860147E30cA8A7dC9891", "asset": "", "category": "omnichain", "chain_id": 7000, - "chain_name": "zeta_testnet", - "coin_type": "gas", - "decimals": 18, - "description": "ZetaChain ZRC20 ETH-eth_mainnet", "foreign_chain_id": "1", + "chain_name": "zeta_mainnet", + "type": "zrc20", "symbol": "ETH.ETH", - "type": "zrc20" + "coin_type": "gas", + "decimals": 18, + "description": "ZetaChain ZRC20 ETH-eth_mainnet" }, { - "address": "0x9fd96203f7b22bCF72d9DCb40ff98302376cE09c", "category": "omnichain", "chain_id": 7000, - "chain_name": "zeta_testnet", + "chain_name": "zeta_mainnet", + "address": "0x9fd96203f7b22bCF72d9DCb40ff98302376cE09c", "type": "uniswapv2Factory" }, { - "address": "0x5F0b1a82749cb4E2278EC87F8BF6B618dC71a8bf", "category": "omnichain", "chain_id": 7000, - "chain_name": "zeta_testnet", + "chain_name": "zeta_mainnet", + "address": "0x5F0b1a82749cb4E2278EC87F8BF6B618dC71a8bf", "type": "wZetaContract" }, { - "address": "0x2ca7d64A7EFE2D62A725E2B35Cf7230D6677FfEe", "category": "omnichain", "chain_id": 7000, - "chain_name": "zeta_testnet", + "chain_name": "zeta_mainnet", + "address": "0x2ca7d64A7EFE2D62A725E2B35Cf7230D6677FfEe", "type": "uniswapv2Router02" }, { - "address": "0x735b14BB79463307AAcBED86DAf3322B1e6226aB", "category": "omnichain", "chain_id": 7000, - "chain_name": "zeta_testnet", + "chain_name": "zeta_mainnet", + "address": "0x735b14BB79463307AAcBED86DAf3322B1e6226aB", "type": "fungibleModule" }, { @@ -217,17 +217,17 @@ "type": "tssUpdater" }, { - "address": "0xaeB6dDB7708467814D557e340283248be8E43124", + "address": "0xaf28a257D292e7f0E531073f70a175b57E0261a8", "category": "messaging", - "chain_id": "1", - "chain_name": "eth_mainnet", + "chain_id": "56", + "chain_name": "bsc_mainnet", "type": "pauser" }, { - "address": "0xaf28a257D292e7f0E531073f70a175b57E0261a8", + "address": "0xaeB6dDB7708467814D557e340283248be8E43124", "category": "messaging", - "chain_id": "56", - "chain_name": "bsc_mainnet", + "chain_id": "1", + "chain_name": "eth_mainnet", "type": "pauser" } -] +] \ No newline at end of file diff --git a/data/addresses.testnet.json b/data/addresses.testnet.json index 46887818..9446aa71 100644 --- a/data/addresses.testnet.json +++ b/data/addresses.testnet.json @@ -46,141 +46,120 @@ "asset": "0x07865c6e87b9f70255377e024ace6630c1eaa37f", "category": "omnichain", "chain_id": 7001, + "foreign_chain_id": "5", "chain_name": "zeta_testnet", + "type": "zrc20", + "symbol": "USDC", "coin_type": "erc20", "decimals": 18, - "description": "USDC-goerli_testnet", - "foreign_chain_id": "5", - "symbol": "USDC", - "type": "zrc20" + "description": "USDC-goerli_testnet" }, { "address": "0x13A0c5930C028511Dc02665E7285134B6d11A5f4", "asset": "", "category": "omnichain", "chain_id": 7001, + "foreign_chain_id": "5", "chain_name": "zeta_testnet", + "type": "zrc20", + "symbol": "gETH", "coin_type": "gas", "decimals": 18, - "description": "ETH-goerli_testnet", - "foreign_chain_id": "5", - "symbol": "gETH", - "type": "zrc20" + "description": "ETH-goerli_testnet" }, { "address": "0x48f80608B672DC30DC7e3dbBd0343c5F02C738Eb", "asset": "", "category": "omnichain", "chain_id": 7001, + "foreign_chain_id": "80001", "chain_name": "zeta_testnet", + "type": "zrc20", + "symbol": "tMATIC", "coin_type": "gas", "decimals": 18, - "description": "MATIC-mumbai_testnet", - "foreign_chain_id": "80001", - "symbol": "tMATIC", - "type": "zrc20" + "description": "MATIC-mumbai_testnet" }, { "address": "0x65a45c57636f9BcCeD4fe193A602008578BcA90b", "asset": "", "category": "omnichain", "chain_id": 7001, + "foreign_chain_id": "18332", "chain_name": "zeta_testnet", + "type": "zrc20", + "symbol": "tBTC", "coin_type": "gas", "decimals": 18, - "description": "BTC-btc_testnet-btc_testnet", - "foreign_chain_id": "18332", - "symbol": "tBTC", - "type": "zrc20" + "description": "BTC-btc_testnet-btc_testnet" }, { "address": "0x7c8dDa80bbBE1254a7aACf3219EBe1481c6E01d7", "asset": "0x64544969ed7EBf5f083679233325356EbE738930", "category": "omnichain", "chain_id": 7001, + "foreign_chain_id": "97", "chain_name": "zeta_testnet", + "type": "zrc20", + "symbol": "USDC", "coin_type": "erc20", "decimals": 18, - "description": "USDC-bsc_testnet", - "foreign_chain_id": "97", - "symbol": "USDC", - "type": "zrc20" + "description": "USDC-bsc_testnet" }, { "address": "0x91d4F0D54090Df2D81e834c3c8CE71C6c865e79F", "asset": "0x9999f7fea5938fd3b1e26a12c3f2fb024e194f97", "category": "omnichain", "chain_id": 7001, + "foreign_chain_id": "80001", "chain_name": "zeta_testnet", + "type": "zrc20", + "symbol": "USDC", "coin_type": "erc20", "decimals": 18, - "description": "USDC-mumbai_testnet", - "foreign_chain_id": "80001", - "symbol": "USDC", - "type": "zrc20" + "description": "USDC-mumbai_testnet" }, { "address": "0xd97B1de3619ed2c6BEb3860147E30cA8A7dC9891", "asset": "", "category": "omnichain", "chain_id": 7001, + "foreign_chain_id": "97", "chain_name": "zeta_testnet", + "type": "zrc20", + "symbol": "tBNB", "coin_type": "gas", "decimals": 18, - "description": "BNB-bsc_testnet", - "foreign_chain_id": "97", - "symbol": "tBNB", - "type": "zrc20" + "description": "BNB-bsc_testnet" }, { - "address": "0x9fd96203f7b22bCF72d9DCb40ff98302376cE09c", "category": "omnichain", "chain_id": 7001, "chain_name": "zeta_testnet", + "address": "0x9fd96203f7b22bCF72d9DCb40ff98302376cE09c", "type": "uniswapv2Factory" }, { - "address": "0x5F0b1a82749cb4E2278EC87F8BF6B618dC71a8bf", "category": "omnichain", "chain_id": 7001, "chain_name": "zeta_testnet", + "address": "0x5F0b1a82749cb4E2278EC87F8BF6B618dC71a8bf", "type": "wZetaContract" }, { - "address": "0x2ca7d64A7EFE2D62A725E2B35Cf7230D6677FfEe", "category": "omnichain", "chain_id": 7001, "chain_name": "zeta_testnet", + "address": "0x2ca7d64A7EFE2D62A725E2B35Cf7230D6677FfEe", "type": "uniswapv2Router02" }, { - "address": "0x735b14BB79463307AAcBED86DAf3322B1e6226aB", "category": "omnichain", "chain_id": 7001, "chain_name": "zeta_testnet", + "address": "0x735b14BB79463307AAcBED86DAf3322B1e6226aB", "type": "fungibleModule" }, - { - "address": "0x0000c304d2934c00db1d51995b9f6996affd17c0", - "category": "messaging", - "chain_id": "5", - "chain_name": "goerli_testnet", - "type": "zetaToken" - }, - { - "address": "0x00005e3125aba53c5652f9f0ce1a4cf91d8b15ea", - "category": "messaging", - "chain_id": "5", - "chain_name": "goerli_testnet", - "type": "connector" - }, - { - "address": "0x000047f11c6e42293f433c82473532e869ce4ec5", - "category": "omnichain", - "chain_id": "5", - "chain_name": "goerli_testnet", - "type": "erc20Custody" - }, { "address": "0x0000c9ec4042283e8139c74f4c64bcd1e0b9b54f", "category": "messaging", @@ -224,17 +203,31 @@ "type": "erc20Custody" }, { - "address": "0x55122f7590164Ac222504436943FAB17B62F5d7d", - "category": "omnichain", - "chain_id": "80001", - "chain_name": "mumbai_testnet", - "type": "tssUpdater" + "address": "0x0000c304d2934c00db1d51995b9f6996affd17c0", + "category": "messaging", + "chain_id": "5", + "chain_name": "goerli_testnet", + "type": "zetaToken" }, { - "address": "0x55122f7590164Ac222504436943FAB17B62F5d7d", + "address": "0x00005e3125aba53c5652f9f0ce1a4cf91d8b15ea", + "category": "messaging", + "chain_id": "5", + "chain_name": "goerli_testnet", + "type": "connector" + }, + { + "address": "0x000047f11c6e42293f433c82473532e869ce4ec5", "category": "omnichain", "chain_id": "5", "chain_name": "goerli_testnet", + "type": "erc20Custody" + }, + { + "address": "0x55122f7590164Ac222504436943FAB17B62F5d7d", + "category": "omnichain", + "chain_id": "80001", + "chain_name": "mumbai_testnet", "type": "tssUpdater" }, { @@ -246,10 +239,10 @@ }, { "address": "0x55122f7590164Ac222504436943FAB17B62F5d7d", - "category": "messaging", + "category": "omnichain", "chain_id": "5", "chain_name": "goerli_testnet", - "type": "pauser" + "type": "tssUpdater" }, { "address": "0x55122f7590164Ac222504436943FAB17B62F5d7d", @@ -258,6 +251,13 @@ "chain_name": "mumbai_testnet", "type": "pauser" }, + { + "address": "0x55122f7590164Ac222504436943FAB17B62F5d7d", + "category": "messaging", + "chain_id": "5", + "chain_name": "goerli_testnet", + "type": "pauser" + }, { "address": "0x55122f7590164Ac222504436943FAB17B62F5d7d", "category": "messaging", diff --git a/lib/addresses.ts b/lib/addresses.ts index 7aae67d0..0d2127cc 100644 --- a/lib/addresses.ts +++ b/lib/addresses.ts @@ -7,6 +7,9 @@ import { ParamChainName, ParamSymbol, ParamType } from "./types"; export const getAddress = (type: ParamType, network: ParamChainName, symbol?: ParamSymbol) => { const networks = [...testnet, ...mainnet]; let address; + if (type !== "zrc20" && symbol) { + throw new Error("Symbol is only supported when ParamType is zrc20"); + } if (type === "zrc20" && !symbol) { // for backwards compatibility const chainId = getChainId(network); @@ -15,7 +18,7 @@ export const getAddress = (type: ParamType, network: ParamChainName, symbol?: Pa }); } else { address = networks.find((n: any) => { - return n.chain_name === network && n.type === type; + return n.chain_name === network && n.type === type && n.symbol === symbol; }); } return address?.address; diff --git a/tasks/addresses.ts b/tasks/addresses.ts index a3fc4d54..a76d7e62 100644 --- a/tasks/addresses.ts +++ b/tasks/addresses.ts @@ -73,14 +73,14 @@ const fetchSystemContract = async (addresses: any, network: Network) => { address: systemContractResponse.data.SystemContract.system_contract, category: "omnichain", chain_id, - chain_name: "zeta_testnet", + chain_name: network, type: "systemContract", }); addresses.push({ address: systemContractResponse.data.SystemContract.connector_zevm, category: "messaging", chain_id, - chain_name: "zeta_testnet", + chain_name: network, type: "connector", }); } else { @@ -103,13 +103,13 @@ const fetchForeignCoinsData = async (chains: any, addresses: any, network: Netwo asset: token.asset, category: "omnichain", chain_id, - chain_name: "zeta_testnet", - coin_type: token.coin_type.toLowerCase(), - decimals: 18, - description: token.name, foreign_chain_id: token.foreign_chain_id, + chain_name: network, + type: "zrc20", symbol: token.symbol, - type: "zrc20", // TODO: dynamically fetch from contract + coin_type: token.coin_type.toLowerCase(), + decimals: 18, + description: token.name, // TODO: dynamically fetch from contract }); }); } else { @@ -123,14 +123,14 @@ const fetchForeignCoinsData = async (chains: any, addresses: any, network: Netwo const fetchAthensAddresses = async (addresses: any, hre: any, network: Network) => { const chain_id = network === "zeta_mainnet" ? 7000 : 7001; const systemContract = addresses.find((a: any) => { - return a.chain_name === "zeta_testnet" && a.type === "systemContract"; + return a.chain_name === network && a.type === "systemContract"; })?.address; const provider = new hre.ethers.providers.JsonRpcProvider(api[network].evm); const sc = SystemContract__factory.connect(systemContract, provider); const common = { category: "omnichain", chain_id, - chain_name: "zeta_testnet", + chain_name: network, }; try { addresses.push({ ...common, address: await sc.uniswapv2FactoryAddress(), type: "uniswapv2Factory" }); @@ -216,7 +216,7 @@ const fetchPauser = async (chains: any, addresses: any) => { return a.chain_name === chain.chain_name && a.type === "connector"; })?.address; if (erc20Custody) { - if (["18332", "8332", "7001"].includes(chain.chain_id)) return; + if (["18332", "8332", "7001", "7000"].includes(chain.chain_id)) return; const rpc = getEndpoints("evm", chain.chain_name)[0]?.url; const provider = new hre.ethers.providers.JsonRpcProvider(rpc); const connector = ZetaConnectorBase__factory.connect(erc20Custody, provider); From 3284e131f9b23752ce01a43d47fbc3d1df5181d4 Mon Sep 17 00:00:00 2001 From: Denis Fadeev Date: Mon, 5 Feb 2024 18:39:25 +0400 Subject: [PATCH 18/27] lint --- data/addresses.mainnet.json | 66 ++++++++++++++++++------------------- data/addresses.testnet.json | 64 +++++++++++++++++------------------ tasks/addresses.ts | 8 ++--- 3 files changed, 69 insertions(+), 69 deletions(-) diff --git a/data/addresses.mainnet.json b/data/addresses.mainnet.json index db4aedd5..1be4cdd5 100644 --- a/data/addresses.mainnet.json +++ b/data/addresses.mainnet.json @@ -46,118 +46,118 @@ "asset": "0x8ac76a51cc950d9822d68b83fe1ad97b32cd580d", "category": "omnichain", "chain_id": 7000, - "foreign_chain_id": "56", "chain_name": "zeta_mainnet", - "type": "zrc20", - "symbol": "USDC.BSC", "coin_type": "erc20", "decimals": 18, - "description": "ZetaChain ZRC20 USDC on BSC" + "description": "ZetaChain ZRC20 USDC on BSC", + "foreign_chain_id": "56", + "symbol": "USDC.BSC", + "type": "zrc20" }, { "address": "0x0cbe0dF132a6c6B4a2974Fa1b7Fb953CF0Cc798a", "asset": "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48", "category": "omnichain", "chain_id": 7000, - "foreign_chain_id": "1", "chain_name": "zeta_mainnet", - "type": "zrc20", - "symbol": "USDC.ETH", "coin_type": "erc20", "decimals": 18, - "description": "ZetaChain ZRC20 USDC on ETH" + "description": "ZetaChain ZRC20 USDC on ETH", + "foreign_chain_id": "1", + "symbol": "USDC.ETH", + "type": "zrc20" }, { "address": "0x13A0c5930C028511Dc02665E7285134B6d11A5f4", "asset": "", "category": "omnichain", "chain_id": 7000, - "foreign_chain_id": "8332", "chain_name": "zeta_mainnet", - "type": "zrc20", - "symbol": "BTC.BTC", "coin_type": "gas", "decimals": 18, - "description": "ZetaChain ZRC20 BTC-btc_mainnet" + "description": "ZetaChain ZRC20 BTC-btc_mainnet", + "foreign_chain_id": "8332", + "symbol": "BTC.BTC", + "type": "zrc20" }, { "address": "0x48f80608B672DC30DC7e3dbBd0343c5F02C738Eb", "asset": "", "category": "omnichain", "chain_id": 7000, - "foreign_chain_id": "56", "chain_name": "zeta_mainnet", - "type": "zrc20", - "symbol": "BNB.BSC", "coin_type": "gas", "decimals": 18, - "description": "ZetaChain ZRC20 BNB-bsc_mainnet" + "description": "ZetaChain ZRC20 BNB-bsc_mainnet", + "foreign_chain_id": "56", + "symbol": "BNB.BSC", + "type": "zrc20" }, { "address": "0x7c8dDa80bbBE1254a7aACf3219EBe1481c6E01d7", "asset": "0xdac17f958d2ee523a2206206994597c13d831ec7", "category": "omnichain", "chain_id": 7000, - "foreign_chain_id": "1", "chain_name": "zeta_mainnet", - "type": "zrc20", - "symbol": "USDT.ETH", "coin_type": "erc20", "decimals": 18, - "description": "ZetaChain ZRC20 USDT on ETH" + "description": "ZetaChain ZRC20 USDT on ETH", + "foreign_chain_id": "1", + "symbol": "USDT.ETH", + "type": "zrc20" }, { "address": "0x91d4F0D54090Df2D81e834c3c8CE71C6c865e79F", "asset": "0x55d398326f99059ff775485246999027b3197955", "category": "omnichain", "chain_id": 7000, - "foreign_chain_id": "56", "chain_name": "zeta_mainnet", - "type": "zrc20", - "symbol": "USDT.BSC", "coin_type": "erc20", "decimals": 18, - "description": "ZetaChain ZRC20 USDT on BSC" + "description": "ZetaChain ZRC20 USDT on BSC", + "foreign_chain_id": "56", + "symbol": "USDT.BSC", + "type": "zrc20" }, { "address": "0xd97B1de3619ed2c6BEb3860147E30cA8A7dC9891", "asset": "", "category": "omnichain", "chain_id": 7000, - "foreign_chain_id": "1", "chain_name": "zeta_mainnet", - "type": "zrc20", - "symbol": "ETH.ETH", "coin_type": "gas", "decimals": 18, - "description": "ZetaChain ZRC20 ETH-eth_mainnet" + "description": "ZetaChain ZRC20 ETH-eth_mainnet", + "foreign_chain_id": "1", + "symbol": "ETH.ETH", + "type": "zrc20" }, { + "address": "0x9fd96203f7b22bCF72d9DCb40ff98302376cE09c", "category": "omnichain", "chain_id": 7000, "chain_name": "zeta_mainnet", - "address": "0x9fd96203f7b22bCF72d9DCb40ff98302376cE09c", "type": "uniswapv2Factory" }, { + "address": "0x5F0b1a82749cb4E2278EC87F8BF6B618dC71a8bf", "category": "omnichain", "chain_id": 7000, "chain_name": "zeta_mainnet", - "address": "0x5F0b1a82749cb4E2278EC87F8BF6B618dC71a8bf", "type": "wZetaContract" }, { + "address": "0x2ca7d64A7EFE2D62A725E2B35Cf7230D6677FfEe", "category": "omnichain", "chain_id": 7000, "chain_name": "zeta_mainnet", - "address": "0x2ca7d64A7EFE2D62A725E2B35Cf7230D6677FfEe", "type": "uniswapv2Router02" }, { + "address": "0x735b14BB79463307AAcBED86DAf3322B1e6226aB", "category": "omnichain", "chain_id": 7000, "chain_name": "zeta_mainnet", - "address": "0x735b14BB79463307AAcBED86DAf3322B1e6226aB", "type": "fungibleModule" }, { @@ -230,4 +230,4 @@ "chain_name": "eth_mainnet", "type": "pauser" } -] \ No newline at end of file +] diff --git a/data/addresses.testnet.json b/data/addresses.testnet.json index 9446aa71..338687f5 100644 --- a/data/addresses.testnet.json +++ b/data/addresses.testnet.json @@ -46,118 +46,118 @@ "asset": "0x07865c6e87b9f70255377e024ace6630c1eaa37f", "category": "omnichain", "chain_id": 7001, - "foreign_chain_id": "5", "chain_name": "zeta_testnet", - "type": "zrc20", - "symbol": "USDC", "coin_type": "erc20", "decimals": 18, - "description": "USDC-goerli_testnet" + "description": "USDC-goerli_testnet", + "foreign_chain_id": "5", + "symbol": "USDC", + "type": "zrc20" }, { "address": "0x13A0c5930C028511Dc02665E7285134B6d11A5f4", "asset": "", "category": "omnichain", "chain_id": 7001, - "foreign_chain_id": "5", "chain_name": "zeta_testnet", - "type": "zrc20", - "symbol": "gETH", "coin_type": "gas", "decimals": 18, - "description": "ETH-goerli_testnet" + "description": "ETH-goerli_testnet", + "foreign_chain_id": "5", + "symbol": "gETH", + "type": "zrc20" }, { "address": "0x48f80608B672DC30DC7e3dbBd0343c5F02C738Eb", "asset": "", "category": "omnichain", "chain_id": 7001, - "foreign_chain_id": "80001", "chain_name": "zeta_testnet", - "type": "zrc20", - "symbol": "tMATIC", "coin_type": "gas", "decimals": 18, - "description": "MATIC-mumbai_testnet" + "description": "MATIC-mumbai_testnet", + "foreign_chain_id": "80001", + "symbol": "tMATIC", + "type": "zrc20" }, { "address": "0x65a45c57636f9BcCeD4fe193A602008578BcA90b", "asset": "", "category": "omnichain", "chain_id": 7001, - "foreign_chain_id": "18332", "chain_name": "zeta_testnet", - "type": "zrc20", - "symbol": "tBTC", "coin_type": "gas", "decimals": 18, - "description": "BTC-btc_testnet-btc_testnet" + "description": "BTC-btc_testnet-btc_testnet", + "foreign_chain_id": "18332", + "symbol": "tBTC", + "type": "zrc20" }, { "address": "0x7c8dDa80bbBE1254a7aACf3219EBe1481c6E01d7", "asset": "0x64544969ed7EBf5f083679233325356EbE738930", "category": "omnichain", "chain_id": 7001, - "foreign_chain_id": "97", "chain_name": "zeta_testnet", - "type": "zrc20", - "symbol": "USDC", "coin_type": "erc20", "decimals": 18, - "description": "USDC-bsc_testnet" + "description": "USDC-bsc_testnet", + "foreign_chain_id": "97", + "symbol": "USDC", + "type": "zrc20" }, { "address": "0x91d4F0D54090Df2D81e834c3c8CE71C6c865e79F", "asset": "0x9999f7fea5938fd3b1e26a12c3f2fb024e194f97", "category": "omnichain", "chain_id": 7001, - "foreign_chain_id": "80001", "chain_name": "zeta_testnet", - "type": "zrc20", - "symbol": "USDC", "coin_type": "erc20", "decimals": 18, - "description": "USDC-mumbai_testnet" + "description": "USDC-mumbai_testnet", + "foreign_chain_id": "80001", + "symbol": "USDC", + "type": "zrc20" }, { "address": "0xd97B1de3619ed2c6BEb3860147E30cA8A7dC9891", "asset": "", "category": "omnichain", "chain_id": 7001, - "foreign_chain_id": "97", "chain_name": "zeta_testnet", - "type": "zrc20", - "symbol": "tBNB", "coin_type": "gas", "decimals": 18, - "description": "BNB-bsc_testnet" + "description": "BNB-bsc_testnet", + "foreign_chain_id": "97", + "symbol": "tBNB", + "type": "zrc20" }, { + "address": "0x9fd96203f7b22bCF72d9DCb40ff98302376cE09c", "category": "omnichain", "chain_id": 7001, "chain_name": "zeta_testnet", - "address": "0x9fd96203f7b22bCF72d9DCb40ff98302376cE09c", "type": "uniswapv2Factory" }, { + "address": "0x5F0b1a82749cb4E2278EC87F8BF6B618dC71a8bf", "category": "omnichain", "chain_id": 7001, "chain_name": "zeta_testnet", - "address": "0x5F0b1a82749cb4E2278EC87F8BF6B618dC71a8bf", "type": "wZetaContract" }, { + "address": "0x2ca7d64A7EFE2D62A725E2B35Cf7230D6677FfEe", "category": "omnichain", "chain_id": 7001, "chain_name": "zeta_testnet", - "address": "0x2ca7d64A7EFE2D62A725E2B35Cf7230D6677FfEe", "type": "uniswapv2Router02" }, { + "address": "0x735b14BB79463307AAcBED86DAf3322B1e6226aB", "category": "omnichain", "chain_id": 7001, "chain_name": "zeta_testnet", - "address": "0x735b14BB79463307AAcBED86DAf3322B1e6226aB", "type": "fungibleModule" }, { diff --git a/tasks/addresses.ts b/tasks/addresses.ts index a76d7e62..81c6a56c 100644 --- a/tasks/addresses.ts +++ b/tasks/addresses.ts @@ -103,13 +103,13 @@ const fetchForeignCoinsData = async (chains: any, addresses: any, network: Netwo asset: token.asset, category: "omnichain", chain_id, - foreign_chain_id: token.foreign_chain_id, chain_name: network, - type: "zrc20", - symbol: token.symbol, coin_type: token.coin_type.toLowerCase(), decimals: 18, - description: token.name, // TODO: dynamically fetch from contract + description: token.name, + foreign_chain_id: token.foreign_chain_id, + symbol: token.symbol, + type: "zrc20", // TODO: dynamically fetch from contract }); }); } else { From f34abe49cd82ecbcc077c7779266e9df1576e240 Mon Sep 17 00:00:00 2001 From: Denis Fadeev Date: Tue, 6 Feb 2024 16:20:17 +0400 Subject: [PATCH 19/27] uniswap addresses --- data/addresses.mainnet.json | 113 ++++++++++++++----- data/addresses.testnet.json | 208 +++++++++++++++++++++++++++++------ lib/types.d.ts | 4 + tasks/addresses.mainnet.json | 23 ++++ tasks/addresses.testnet.json | 58 ++++++++++ tasks/addresses.ts | 81 +++++++++++++- tasks/readme.md | 2 + 7 files changed, 424 insertions(+), 65 deletions(-) create mode 100644 lib/types.d.ts create mode 100644 tasks/addresses.mainnet.json create mode 100644 tasks/addresses.testnet.json create mode 100644 tasks/readme.md diff --git a/data/addresses.mainnet.json b/data/addresses.mainnet.json index 1be4cdd5..77eef4a0 100644 --- a/data/addresses.mainnet.json +++ b/data/addresses.mainnet.json @@ -1,4 +1,25 @@ [ + { + "address": "0x5C69bEe701ef814a2B6a3EDD4B1652CB9cc5aA6f", + "chain_name": "eth_mainnet", + "chain_id": 1, + "category": "messaging", + "type": "uniswapV2Factory" + }, + { + "address": "0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D", + "chain_name": "eth_mainnet", + "chain_id": 1, + "category": "messaging", + "type": "uniswapV2Router02" + }, + { + "address": "0xE592427A0AEce92De3Edee1F18E0157C05861564", + "chain_name": "eth_mainnet", + "chain_id": 1, + "category": "messaging", + "type": "uniswapV3Router" + }, { "address": "0x70e967acFcC17c3941E87562161406d41676FD83", "category": "omnichain", @@ -133,73 +154,73 @@ "type": "zrc20" }, { - "address": "0x9fd96203f7b22bCF72d9DCb40ff98302376cE09c", "category": "omnichain", "chain_id": 7000, "chain_name": "zeta_mainnet", - "type": "uniswapv2Factory" + "address": "0x9fd96203f7b22bCF72d9DCb40ff98302376cE09c", + "type": "uniswapV2Factory" }, { - "address": "0x5F0b1a82749cb4E2278EC87F8BF6B618dC71a8bf", "category": "omnichain", "chain_id": 7000, "chain_name": "zeta_mainnet", - "type": "wZetaContract" + "address": "0x5F0b1a82749cb4E2278EC87F8BF6B618dC71a8bf", + "type": "zetaToken" }, { - "address": "0x2ca7d64A7EFE2D62A725E2B35Cf7230D6677FfEe", "category": "omnichain", "chain_id": 7000, "chain_name": "zeta_mainnet", - "type": "uniswapv2Router02" + "address": "0x2ca7d64A7EFE2D62A725E2B35Cf7230D6677FfEe", + "type": "uniswapV2Router02" }, { - "address": "0x735b14BB79463307AAcBED86DAf3322B1e6226aB", "category": "omnichain", "chain_id": 7000, "chain_name": "zeta_mainnet", + "address": "0x735b14BB79463307AAcBED86DAf3322B1e6226aB", "type": "fungibleModule" }, { - "address": "0xf091867EC603A6628eD83D274E835539D82e9cc8", + "address": "0x0000028a2eB8346cd5c0267856aB7594B7a55308", "category": "messaging", - "chain_id": "1", - "chain_name": "eth_mainnet", + "chain_id": "56", + "chain_name": "bsc_mainnet", "type": "zetaToken" }, { - "address": "0x000007Cf399229b2f5A4D043F20E90C9C98B7C6a", + "address": "0x000063A6e758D9e2f438d430108377564cf4077D", "category": "messaging", - "chain_id": "1", - "chain_name": "eth_mainnet", + "chain_id": "56", + "chain_name": "bsc_mainnet", "type": "connector" }, { - "address": "0x0000030Ec64DF25301d8414eE5a29588C4B0dE10", + "address": "0x00000fF8fA992424957F97688015814e707A0115", "category": "omnichain", - "chain_id": "1", - "chain_name": "eth_mainnet", + "chain_id": "56", + "chain_name": "bsc_mainnet", "type": "erc20Custody" }, { - "address": "0x0000028a2eB8346cd5c0267856aB7594B7a55308", + "address": "0xf091867EC603A6628eD83D274E835539D82e9cc8", "category": "messaging", - "chain_id": "56", - "chain_name": "bsc_mainnet", + "chain_id": "1", + "chain_name": "eth_mainnet", "type": "zetaToken" }, { - "address": "0x000063A6e758D9e2f438d430108377564cf4077D", + "address": "0x000007Cf399229b2f5A4D043F20E90C9C98B7C6a", "category": "messaging", - "chain_id": "56", - "chain_name": "bsc_mainnet", + "chain_id": "1", + "chain_name": "eth_mainnet", "type": "connector" }, { - "address": "0x00000fF8fA992424957F97688015814e707A0115", + "address": "0x0000030Ec64DF25301d8414eE5a29588C4B0dE10", "category": "omnichain", - "chain_id": "56", - "chain_name": "bsc_mainnet", + "chain_id": "1", + "chain_name": "eth_mainnet", "type": "erc20Custody" }, { @@ -229,5 +250,47 @@ "chain_id": "1", "chain_name": "eth_mainnet", "type": "pauser" + }, + { + "address": "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2", + "category": "messaging", + "chain_id": 1, + "chain_name": "eth_mainnet", + "type": "weth9" + }, + { + "address": "0x5C69bEe701ef814a2B6a3EDD4B1652CB9cc5aA6f", + "category": "messaging", + "chain_id": 1, + "chain_name": "eth_mainnet", + "type": "uniswapV2Factory" + }, + { + "address": "0x5F0b1a82749cb4E2278EC87F8BF6B618dC71a8bf", + "category": "messaging", + "chain_id": 7000, + "chain_name": "zeta_mainnet", + "type": "weth9" + }, + { + "address": "0x9fd96203f7b22bCF72d9DCb40ff98302376cE09c", + "category": "messaging", + "chain_id": 7000, + "chain_name": "zeta_mainnet", + "type": "uniswapV2Factory" + }, + { + "address": "0x5C69bEe701ef814a2B6a3EDD4B1652CB9cc5aA6f", + "category": "messaging", + "chain_id": 1, + "chain_name": "eth_mainnet", + "type": "uniswapV3Factory" + }, + { + "address": "0x9fd96203f7b22bCF72d9DCb40ff98302376cE09c", + "category": "messaging", + "chain_id": 7000, + "chain_name": "zeta_mainnet", + "type": "uniswapV3Factory" } ] diff --git a/data/addresses.testnet.json b/data/addresses.testnet.json index 338687f5..293b3212 100644 --- a/data/addresses.testnet.json +++ b/data/addresses.testnet.json @@ -1,4 +1,60 @@ [ + { + "address": "0x8eAc517b92eeE82177a83851268F13109878f8c4", + "chain_name": "goerli_testnet", + "chain_id": 5, + "category": "messaging", + "type": "zetaTokenConsumerUniV2" + }, + { + "address": "0x7e792f3736751e168864106AdbAC50152641A927", + "chain_name": "mumbai_testnet", + "category": "messaging", + "chain_id": 80001, + "type": "zetaTokenConsumerUniV3" + }, + { + "address": "0x8954AfA98594b838bda56FE4C12a09D7739D179b", + "chain_name": "mumbai_testnet", + "chain_id": 80001, + "category": "messaging", + "type": "uniswapV2Router02" + }, + { + "address": "0xE592427A0AEce92De3Edee1F18E0157C05861564", + "chain_name": "mumbai_testnet", + "chain_id": 80001, + "category": "messaging", + "type": "uniswapV3Router" + }, + { + "address": "0x9Ac64Cc6e4415144C455BD8E4837Fea55603e5c3", + "chain_name": "bsc_testnet", + "chain_id": 97, + "category": "messaging", + "type": "uniswapV2Router02" + }, + { + "address": "0x9a489505a00cE272eAa5e07Dba6491314CaE3796", + "chain_name": "bsc_testnet", + "chain_id": 97, + "category": "messaging", + "type": "uniswapV3Router" + }, + { + "address": "0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D", + "chain_name": "goerli_testnet", + "chain_id": 5, + "category": "messaging", + "type": "uniswapV2Router02" + }, + { + "address": "0xE592427A0AEce92De3Edee1F18E0157C05861564", + "chain_name": "goerli_testnet", + "chain_id": 5, + "category": "messaging", + "type": "uniswapV3Router" + }, { "address": "0x8531a5aB847ff5B22D855633C25ED1DA3255247e", "category": "omnichain", @@ -133,33 +189,54 @@ "type": "zrc20" }, { - "address": "0x9fd96203f7b22bCF72d9DCb40ff98302376cE09c", "category": "omnichain", "chain_id": 7001, "chain_name": "zeta_testnet", - "type": "uniswapv2Factory" + "address": "0x9fd96203f7b22bCF72d9DCb40ff98302376cE09c", + "type": "uniswapV2Factory" }, { - "address": "0x5F0b1a82749cb4E2278EC87F8BF6B618dC71a8bf", "category": "omnichain", "chain_id": 7001, "chain_name": "zeta_testnet", - "type": "wZetaContract" + "address": "0x5F0b1a82749cb4E2278EC87F8BF6B618dC71a8bf", + "type": "zetaToken" }, { - "address": "0x2ca7d64A7EFE2D62A725E2B35Cf7230D6677FfEe", "category": "omnichain", "chain_id": 7001, "chain_name": "zeta_testnet", - "type": "uniswapv2Router02" + "address": "0x2ca7d64A7EFE2D62A725E2B35Cf7230D6677FfEe", + "type": "uniswapV2Router02" }, { - "address": "0x735b14BB79463307AAcBED86DAf3322B1e6226aB", "category": "omnichain", "chain_id": 7001, "chain_name": "zeta_testnet", + "address": "0x735b14BB79463307AAcBED86DAf3322B1e6226aB", "type": "fungibleModule" }, + { + "address": "0x0000c304d2934c00db1d51995b9f6996affd17c0", + "category": "messaging", + "chain_id": "5", + "chain_name": "goerli_testnet", + "type": "zetaToken" + }, + { + "address": "0x00005e3125aba53c5652f9f0ce1a4cf91d8b15ea", + "category": "messaging", + "chain_id": "5", + "chain_name": "goerli_testnet", + "type": "connector" + }, + { + "address": "0x000047f11c6e42293f433c82473532e869ce4ec5", + "category": "omnichain", + "chain_id": "5", + "chain_name": "goerli_testnet", + "type": "erc20Custody" + }, { "address": "0x0000c9ec4042283e8139c74f4c64bcd1e0b9b54f", "category": "messaging", @@ -203,31 +280,17 @@ "type": "erc20Custody" }, { - "address": "0x0000c304d2934c00db1d51995b9f6996affd17c0", - "category": "messaging", - "chain_id": "5", - "chain_name": "goerli_testnet", - "type": "zetaToken" - }, - { - "address": "0x00005e3125aba53c5652f9f0ce1a4cf91d8b15ea", - "category": "messaging", - "chain_id": "5", - "chain_name": "goerli_testnet", - "type": "connector" - }, - { - "address": "0x000047f11c6e42293f433c82473532e869ce4ec5", + "address": "0x55122f7590164Ac222504436943FAB17B62F5d7d", "category": "omnichain", - "chain_id": "5", - "chain_name": "goerli_testnet", - "type": "erc20Custody" + "chain_id": "80001", + "chain_name": "mumbai_testnet", + "type": "tssUpdater" }, { "address": "0x55122f7590164Ac222504436943FAB17B62F5d7d", "category": "omnichain", - "chain_id": "80001", - "chain_name": "mumbai_testnet", + "chain_id": "5", + "chain_name": "goerli_testnet", "type": "tssUpdater" }, { @@ -239,10 +302,10 @@ }, { "address": "0x55122f7590164Ac222504436943FAB17B62F5d7d", - "category": "omnichain", + "category": "messaging", "chain_id": "5", "chain_name": "goerli_testnet", - "type": "tssUpdater" + "type": "pauser" }, { "address": "0x55122f7590164Ac222504436943FAB17B62F5d7d", @@ -254,15 +317,92 @@ { "address": "0x55122f7590164Ac222504436943FAB17B62F5d7d", "category": "messaging", - "chain_id": "5", - "chain_name": "goerli_testnet", + "chain_id": "97", + "chain_name": "bsc_testnet", "type": "pauser" }, { - "address": "0x55122f7590164Ac222504436943FAB17B62F5d7d", + "address": "0x9c3C9283D3e44854697Cd22D3Faa240Cfb032889", "category": "messaging", - "chain_id": "97", + "chain_id": 80001, + "chain_name": "mumbai_testnet", + "type": "weth9" + }, + { + "address": "0x5757371414417b8C6CAad45bAeF941aBc7d3Ab32", + "category": "messaging", + "chain_id": 80001, + "chain_name": "mumbai_testnet", + "type": "uniswapV2Factory" + }, + { + "address": "0xae13d989daC2f0dEbFf460aC112a837C89BAa7cd", + "category": "messaging", + "chain_id": 97, "chain_name": "bsc_testnet", - "type": "pauser" + "type": "weth9" + }, + { + "address": "0xB7926C0430Afb07AA7DEfDE6DA862aE0Bde767bc", + "category": "messaging", + "chain_id": 97, + "chain_name": "bsc_testnet", + "type": "uniswapV2Factory" + }, + { + "address": "0xB4FBF271143F4FBf7B91A5ded31805e42b2208d6", + "category": "messaging", + "chain_id": 5, + "chain_name": "goerli_testnet", + "type": "weth9" + }, + { + "address": "0x5C69bEe701ef814a2B6a3EDD4B1652CB9cc5aA6f", + "category": "messaging", + "chain_id": 5, + "chain_name": "goerli_testnet", + "type": "uniswapV2Factory" + }, + { + "address": "0x5F0b1a82749cb4E2278EC87F8BF6B618dC71a8bf", + "category": "messaging", + "chain_id": 7001, + "chain_name": "zeta_testnet", + "type": "weth9" + }, + { + "address": "0x9fd96203f7b22bCF72d9DCb40ff98302376cE09c", + "category": "messaging", + "chain_id": 7001, + "chain_name": "zeta_testnet", + "type": "uniswapV2Factory" + }, + { + "address": "0x5757371414417b8C6CAad45bAeF941aBc7d3Ab32", + "category": "messaging", + "chain_id": 80001, + "chain_name": "mumbai_testnet", + "type": "uniswapV3Factory" + }, + { + "address": "0xB7926C0430Afb07AA7DEfDE6DA862aE0Bde767bc", + "category": "messaging", + "chain_id": 97, + "chain_name": "bsc_testnet", + "type": "uniswapV3Factory" + }, + { + "address": "0x5C69bEe701ef814a2B6a3EDD4B1652CB9cc5aA6f", + "category": "messaging", + "chain_id": 5, + "chain_name": "goerli_testnet", + "type": "uniswapV3Factory" + }, + { + "address": "0x9fd96203f7b22bCF72d9DCb40ff98302376cE09c", + "category": "messaging", + "chain_id": 7001, + "chain_name": "zeta_testnet", + "type": "uniswapV3Factory" } ] diff --git a/lib/types.d.ts b/lib/types.d.ts new file mode 100644 index 00000000..da57fc45 --- /dev/null +++ b/lib/types.d.ts @@ -0,0 +1,4 @@ +export type ParamSymbol = "USDC.BSC" | "USDC.ETH" | "BTC.BTC" | "BNB.BSC" | "USDT.ETH" | "USDT.BSC" | "ETH.ETH" | "USDC" | "gETH" | "tMATIC" | "tBTC" | "tBNB"; +export type ParamChainName = "eth_mainnet" | "bsc_mainnet" | "btc_mainnet" | "zeta_mainnet" | "goerli_testnet" | "mumbai_testnet" | "bsc_testnet" | "btc_testnet" | "zeta_testnet"; +export type ParamType = "uniswapV2Factory" | "uniswapV2Router02" | "uniswapV3Router" | "tss" | "systemContract" | "connector" | "zrc20" | "zetaToken" | "fungibleModule" | "erc20Custody" | "tssUpdater" | "pauser" | "weth9" | "uniswapV3Factory" | "zetaTokenConsumerUniV2" | "zetaTokenConsumerUniV3"; + diff --git a/tasks/addresses.mainnet.json b/tasks/addresses.mainnet.json new file mode 100644 index 00000000..e718513d --- /dev/null +++ b/tasks/addresses.mainnet.json @@ -0,0 +1,23 @@ +[ + { + "address": "0x5C69bEe701ef814a2B6a3EDD4B1652CB9cc5aA6f", + "chain_name": "eth_mainnet", + "chain_id": 1, + "category": "messaging", + "type": "uniswapV2Factory" + }, + { + "address": "0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D", + "chain_name": "eth_mainnet", + "chain_id": 1, + "category": "messaging", + "type": "uniswapV2Router02" + }, + { + "address": "0xE592427A0AEce92De3Edee1F18E0157C05861564", + "chain_name": "eth_mainnet", + "chain_id": 1, + "category": "messaging", + "type": "uniswapV3Router" + } +] \ No newline at end of file diff --git a/tasks/addresses.testnet.json b/tasks/addresses.testnet.json new file mode 100644 index 00000000..4d2eccf4 --- /dev/null +++ b/tasks/addresses.testnet.json @@ -0,0 +1,58 @@ +[ + { + "address": "0x8eAc517b92eeE82177a83851268F13109878f8c4", + "chain_name": "goerli_testnet", + "chain_id": 5, + "category": "messaging", + "type": "zetaTokenConsumerUniV2" + }, + { + "address": "0x7e792f3736751e168864106AdbAC50152641A927", + "chain_name": "mumbai_testnet", + "category": "messaging", + "chain_id": 80001, + "type": "zetaTokenConsumerUniV3" + }, + { + "address": "0x8954AfA98594b838bda56FE4C12a09D7739D179b", + "chain_name": "mumbai_testnet", + "chain_id": 80001, + "category": "messaging", + "type": "uniswapV2Router02" + }, + { + "address": "0xE592427A0AEce92De3Edee1F18E0157C05861564", + "chain_name": "mumbai_testnet", + "chain_id": 80001, + "category": "messaging", + "type": "uniswapV3Router" + }, + { + "address": "0x9Ac64Cc6e4415144C455BD8E4837Fea55603e5c3", + "chain_name": "bsc_testnet", + "chain_id": 97, + "category": "messaging", + "type": "uniswapV2Router02" + }, + { + "address": "0x9a489505a00cE272eAa5e07Dba6491314CaE3796", + "chain_name": "bsc_testnet", + "chain_id": 97, + "category": "messaging", + "type": "uniswapV3Router" + }, + { + "address": "0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D", + "chain_name": "goerli_testnet", + "chain_id": 5, + "category": "messaging", + "type": "uniswapV2Router02" + }, + { + "address": "0xE592427A0AEce92De3Edee1F18E0157C05861564", + "chain_name": "goerli_testnet", + "chain_id": 5, + "category": "messaging", + "type": "uniswapV3Router" + } +] \ No newline at end of file diff --git a/tasks/addresses.ts b/tasks/addresses.ts index 81c6a56c..bc40c890 100644 --- a/tasks/addresses.ts +++ b/tasks/addresses.ts @@ -6,6 +6,10 @@ import { HardhatRuntimeEnvironment } from "hardhat/types"; import { ZetaConnectorBase__factory } from "../typechain-types"; import { ERC20Custody__factory } from "../typechain-types/factories/contracts/evm/ERC20Custody__factory"; import { SystemContract__factory } from "../typechain-types/factories/contracts/zevm/SystemContract.sol/SystemContract__factory"; +import uniswapV2Router from "@uniswap/v2-periphery/build/IUniswapV2Router02.json"; + +import zeta_testnet_addresses from "./addresses.testnet.json"; +import zeta_mainnet_addresses from "./addresses.mainnet.json"; declare const hre: any; @@ -109,7 +113,7 @@ const fetchForeignCoinsData = async (chains: any, addresses: any, network: Netwo description: token.name, foreign_chain_id: token.foreign_chain_id, symbol: token.symbol, - type: "zrc20", // TODO: dynamically fetch from contract + type: "zrc20", }); }); } else { @@ -133,9 +137,9 @@ const fetchAthensAddresses = async (addresses: any, hre: any, network: Network) chain_name: network, }; try { - addresses.push({ ...common, address: await sc.uniswapv2FactoryAddress(), type: "uniswapv2Factory" }); - addresses.push({ ...common, address: await sc.wZetaContractAddress(), type: "wZetaContract" }); - addresses.push({ ...common, address: await sc.uniswapv2Router02Address(), type: "uniswapv2Router02" }); + addresses.push({ ...common, address: await sc.uniswapv2FactoryAddress(), type: "uniswapV2Factory" }); + addresses.push({ ...common, address: await sc.wZetaContractAddress(), type: "zetaToken" }); + addresses.push({ ...common, address: await sc.uniswapv2Router02Address(), type: "uniswapV2Router02" }); // addresses.push({ ...common, address: await sc.zetaConnectorZEVMAddress(), type: "zetaConnectorZEVM" }); addresses.push({ ...common, address: await sc.FUNGIBLE_MODULE_ADDRESS(), type: "fungibleModule" }); } catch (error) { @@ -234,14 +238,77 @@ const fetchPauser = async (chains: any, addresses: any) => { ); }; +const fetchFactoryV2 = async (addresses: any, hre: HardhatRuntimeEnvironment, network: Network) => { + const routers = addresses.filter((a: any) => a.type === "uniswapV2Router02"); + + for (const router of routers) { + const rpc = getEndpoints("evm", router.chain_name)[0]?.url; + const provider = new hre.ethers.providers.JsonRpcProvider(rpc); + const routerContract = new hre.ethers.Contract(router.address, uniswapV2Router.abi, provider); + + try { + const wethAddress = await routerContract.WETH(); + const factoryAddress = await routerContract.factory(); + + // Adding WETH and Factory addresses to the addresses array + addresses.push({ + address: wethAddress, + category: "messaging", + chain_id: router.chain_id, + chain_name: router.chain_name, + type: "weth9", + }); + + addresses.push({ + address: factoryAddress, + category: "messaging", + chain_id: router.chain_id, + chain_name: router.chain_name, + type: "uniswapV2Factory", + }); + } catch (error) { + console.error(`Error fetching factory and WETH for router v2 ${router.address}:`, error); + } + } +}; + +const fetchFactoryV3 = async (addresses: any, hre: HardhatRuntimeEnvironment, network: Network) => { + const routers = addresses.filter((a: any) => a.type === "uniswapV2Router02"); + + for (const router of routers) { + const rpc = getEndpoints("evm", router.chain_name)[0]?.url; + const provider = new hre.ethers.providers.JsonRpcProvider(rpc); + const routerContract = new hre.ethers.Contract(router.address, uniswapV2Router.abi, provider); + + try { + const factoryAddress = await routerContract.factory(); + + addresses.push({ + address: factoryAddress, + category: "messaging", + chain_id: router.chain_id, + chain_name: router.chain_name, + type: "uniswapV3Factory", + }); + } catch (error) { + console.error(`Error fetching factory for router v3 ${router.address}:`, error); + } + } +}; + const main = async (args: any, hre: HardhatRuntimeEnvironment) => { + const addresses: any = []; + const n = hre.network.name; - if (n !== "zeta_testnet" && n !== "zeta_mainnet") { + if (n === "zeta_testnet") { + addresses.push(...zeta_testnet_addresses); + } else if (n === "zeta_mainnet") { + addresses.push(...zeta_mainnet_addresses); + } else { throw new Error(`Unsupported network: ${n}. Must be 'zeta_testnet' or 'zeta_mainnet'.`); } const network: Network = n; - const addresses: any = []; const chains = await fetchChains(network); await fetchTssData(chains, addresses, network); @@ -251,6 +318,8 @@ const main = async (args: any, hre: HardhatRuntimeEnvironment) => { await fetchChainSpecificAddresses(chains, addresses, network); await fetchTSSUpdater(chains, addresses); await fetchPauser(chains, addresses); + await fetchFactoryV2(addresses, hre, network); + await fetchFactoryV3(addresses, hre, network); console.log(JSON.stringify(addresses, null, 2)); }; diff --git a/tasks/readme.md b/tasks/readme.md new file mode 100644 index 00000000..c5442530 --- /dev/null +++ b/tasks/readme.md @@ -0,0 +1,2 @@ +Addresses JSON files in this directory contain contract addresses which cannot +be fetched from the blockchain. From 0d61e01624bfe246e772c337ab92258fa7985d5d Mon Sep 17 00:00:00 2001 From: Denis Fadeev Date: Tue, 6 Feb 2024 16:22:24 +0400 Subject: [PATCH 20/27] zetaTokenConsumerUniV3 for bsc_testnet --- tasks/addresses.testnet.json | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/tasks/addresses.testnet.json b/tasks/addresses.testnet.json index 4d2eccf4..e1575e64 100644 --- a/tasks/addresses.testnet.json +++ b/tasks/addresses.testnet.json @@ -13,6 +13,13 @@ "chain_id": 80001, "type": "zetaTokenConsumerUniV3" }, + { + "address": "0xFB2fCE3CCca19F0f764Ed8aa26C62181E3dA04C5", + "chain_name": "bsc_testnet", + "category": "messaging", + "chain_id": 97, + "type": "zetaTokenConsumerUniV3" + }, { "address": "0x8954AfA98594b838bda56FE4C12a09D7739D179b", "chain_name": "mumbai_testnet", From 28c71410224896d8ff3d35bc8a2c0e597c186eac Mon Sep 17 00:00:00 2001 From: Denis Fadeev Date: Tue, 6 Feb 2024 16:23:44 +0400 Subject: [PATCH 21/27] yarn generate --- data/addresses.mainnet.json | 12 ++++---- data/addresses.testnet.json | 57 +++++++++++++++++++++---------------- 2 files changed, 38 insertions(+), 31 deletions(-) diff --git a/data/addresses.mainnet.json b/data/addresses.mainnet.json index 77eef4a0..55072278 100644 --- a/data/addresses.mainnet.json +++ b/data/addresses.mainnet.json @@ -238,17 +238,17 @@ "type": "tssUpdater" }, { - "address": "0xaf28a257D292e7f0E531073f70a175b57E0261a8", + "address": "0xaeB6dDB7708467814D557e340283248be8E43124", "category": "messaging", - "chain_id": "56", - "chain_name": "bsc_mainnet", + "chain_id": "1", + "chain_name": "eth_mainnet", "type": "pauser" }, { - "address": "0xaeB6dDB7708467814D557e340283248be8E43124", + "address": "0xaf28a257D292e7f0E531073f70a175b57E0261a8", "category": "messaging", - "chain_id": "1", - "chain_name": "eth_mainnet", + "chain_id": "56", + "chain_name": "bsc_mainnet", "type": "pauser" }, { diff --git a/data/addresses.testnet.json b/data/addresses.testnet.json index 293b3212..b8be25e1 100644 --- a/data/addresses.testnet.json +++ b/data/addresses.testnet.json @@ -13,6 +13,13 @@ "chain_id": 80001, "type": "zetaTokenConsumerUniV3" }, + { + "address": "0xFB2fCE3CCca19F0f764Ed8aa26C62181E3dA04C5", + "chain_name": "bsc_testnet", + "category": "messaging", + "chain_id": 97, + "type": "zetaTokenConsumerUniV3" + }, { "address": "0x8954AfA98594b838bda56FE4C12a09D7739D179b", "chain_name": "mumbai_testnet", @@ -216,6 +223,27 @@ "address": "0x735b14BB79463307AAcBED86DAf3322B1e6226aB", "type": "fungibleModule" }, + { + "address": "0x0000c9ec4042283e8139c74f4c64bcd1e0b9b54f", + "category": "messaging", + "chain_id": "80001", + "chain_name": "mumbai_testnet", + "type": "zetaToken" + }, + { + "address": "0x0000ecb8cdd25a18f12daa23f6422e07fbf8b9e1", + "category": "messaging", + "chain_id": "80001", + "chain_name": "mumbai_testnet", + "type": "connector" + }, + { + "address": "0x0000a7db254145767262c6a81a7ee1650684258e", + "category": "omnichain", + "chain_id": "80001", + "chain_name": "mumbai_testnet", + "type": "erc20Custody" + }, { "address": "0x0000c304d2934c00db1d51995b9f6996affd17c0", "category": "messaging", @@ -258,27 +286,6 @@ "chain_name": "bsc_testnet", "type": "erc20Custody" }, - { - "address": "0x0000c9ec4042283e8139c74f4c64bcd1e0b9b54f", - "category": "messaging", - "chain_id": "80001", - "chain_name": "mumbai_testnet", - "type": "zetaToken" - }, - { - "address": "0x0000ecb8cdd25a18f12daa23f6422e07fbf8b9e1", - "category": "messaging", - "chain_id": "80001", - "chain_name": "mumbai_testnet", - "type": "connector" - }, - { - "address": "0x0000a7db254145767262c6a81a7ee1650684258e", - "category": "omnichain", - "chain_id": "80001", - "chain_name": "mumbai_testnet", - "type": "erc20Custody" - }, { "address": "0x55122f7590164Ac222504436943FAB17B62F5d7d", "category": "omnichain", @@ -303,15 +310,15 @@ { "address": "0x55122f7590164Ac222504436943FAB17B62F5d7d", "category": "messaging", - "chain_id": "5", - "chain_name": "goerli_testnet", + "chain_id": "80001", + "chain_name": "mumbai_testnet", "type": "pauser" }, { "address": "0x55122f7590164Ac222504436943FAB17B62F5d7d", "category": "messaging", - "chain_id": "80001", - "chain_name": "mumbai_testnet", + "chain_id": "5", + "chain_name": "goerli_testnet", "type": "pauser" }, { From 5b48d1e409da1f4745e6101fbd69ca49b8b37782 Mon Sep 17 00:00:00 2001 From: Denis Fadeev Date: Tue, 6 Feb 2024 16:26:52 +0400 Subject: [PATCH 22/27] auto lint --- data/addresses.mainnet.json | 32 ++++++------- data/addresses.testnet.json | 84 +++++++++++++++++------------------ lib/types.d.ts | 44 ++++++++++++++++-- scripts/generate_addresses.sh | 4 +- tasks/addresses.mainnet.json | 14 +++--- tasks/addresses.testnet.json | 34 +++++++------- tasks/addresses.ts | 5 +-- 7 files changed, 127 insertions(+), 90 deletions(-) diff --git a/data/addresses.mainnet.json b/data/addresses.mainnet.json index 55072278..104a4b29 100644 --- a/data/addresses.mainnet.json +++ b/data/addresses.mainnet.json @@ -1,23 +1,23 @@ [ { "address": "0x5C69bEe701ef814a2B6a3EDD4B1652CB9cc5aA6f", - "chain_name": "eth_mainnet", - "chain_id": 1, "category": "messaging", + "chain_id": 1, + "chain_name": "eth_mainnet", "type": "uniswapV2Factory" }, { "address": "0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D", - "chain_name": "eth_mainnet", - "chain_id": 1, "category": "messaging", + "chain_id": 1, + "chain_name": "eth_mainnet", "type": "uniswapV2Router02" }, { "address": "0xE592427A0AEce92De3Edee1F18E0157C05861564", - "chain_name": "eth_mainnet", - "chain_id": 1, "category": "messaging", + "chain_id": 1, + "chain_name": "eth_mainnet", "type": "uniswapV3Router" }, { @@ -154,31 +154,31 @@ "type": "zrc20" }, { + "address": "0x9fd96203f7b22bCF72d9DCb40ff98302376cE09c", "category": "omnichain", "chain_id": 7000, "chain_name": "zeta_mainnet", - "address": "0x9fd96203f7b22bCF72d9DCb40ff98302376cE09c", "type": "uniswapV2Factory" }, { + "address": "0x5F0b1a82749cb4E2278EC87F8BF6B618dC71a8bf", "category": "omnichain", "chain_id": 7000, "chain_name": "zeta_mainnet", - "address": "0x5F0b1a82749cb4E2278EC87F8BF6B618dC71a8bf", "type": "zetaToken" }, { + "address": "0x2ca7d64A7EFE2D62A725E2B35Cf7230D6677FfEe", "category": "omnichain", "chain_id": 7000, "chain_name": "zeta_mainnet", - "address": "0x2ca7d64A7EFE2D62A725E2B35Cf7230D6677FfEe", "type": "uniswapV2Router02" }, { + "address": "0x735b14BB79463307AAcBED86DAf3322B1e6226aB", "category": "omnichain", "chain_id": 7000, "chain_name": "zeta_mainnet", - "address": "0x735b14BB79463307AAcBED86DAf3322B1e6226aB", "type": "fungibleModule" }, { @@ -238,17 +238,17 @@ "type": "tssUpdater" }, { - "address": "0xaeB6dDB7708467814D557e340283248be8E43124", + "address": "0xaf28a257D292e7f0E531073f70a175b57E0261a8", "category": "messaging", - "chain_id": "1", - "chain_name": "eth_mainnet", + "chain_id": "56", + "chain_name": "bsc_mainnet", "type": "pauser" }, { - "address": "0xaf28a257D292e7f0E531073f70a175b57E0261a8", + "address": "0xaeB6dDB7708467814D557e340283248be8E43124", "category": "messaging", - "chain_id": "56", - "chain_name": "bsc_mainnet", + "chain_id": "1", + "chain_name": "eth_mainnet", "type": "pauser" }, { diff --git a/data/addresses.testnet.json b/data/addresses.testnet.json index b8be25e1..2e5de1e6 100644 --- a/data/addresses.testnet.json +++ b/data/addresses.testnet.json @@ -1,65 +1,65 @@ [ { "address": "0x8eAc517b92eeE82177a83851268F13109878f8c4", - "chain_name": "goerli_testnet", - "chain_id": 5, "category": "messaging", + "chain_id": 5, + "chain_name": "goerli_testnet", "type": "zetaTokenConsumerUniV2" }, { "address": "0x7e792f3736751e168864106AdbAC50152641A927", - "chain_name": "mumbai_testnet", "category": "messaging", "chain_id": 80001, + "chain_name": "mumbai_testnet", "type": "zetaTokenConsumerUniV3" }, { "address": "0xFB2fCE3CCca19F0f764Ed8aa26C62181E3dA04C5", - "chain_name": "bsc_testnet", "category": "messaging", "chain_id": 97, + "chain_name": "bsc_testnet", "type": "zetaTokenConsumerUniV3" }, { "address": "0x8954AfA98594b838bda56FE4C12a09D7739D179b", - "chain_name": "mumbai_testnet", - "chain_id": 80001, "category": "messaging", + "chain_id": 80001, + "chain_name": "mumbai_testnet", "type": "uniswapV2Router02" }, { "address": "0xE592427A0AEce92De3Edee1F18E0157C05861564", - "chain_name": "mumbai_testnet", - "chain_id": 80001, "category": "messaging", + "chain_id": 80001, + "chain_name": "mumbai_testnet", "type": "uniswapV3Router" }, { "address": "0x9Ac64Cc6e4415144C455BD8E4837Fea55603e5c3", - "chain_name": "bsc_testnet", - "chain_id": 97, "category": "messaging", + "chain_id": 97, + "chain_name": "bsc_testnet", "type": "uniswapV2Router02" }, { "address": "0x9a489505a00cE272eAa5e07Dba6491314CaE3796", - "chain_name": "bsc_testnet", - "chain_id": 97, "category": "messaging", + "chain_id": 97, + "chain_name": "bsc_testnet", "type": "uniswapV3Router" }, { "address": "0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D", - "chain_name": "goerli_testnet", - "chain_id": 5, "category": "messaging", + "chain_id": 5, + "chain_name": "goerli_testnet", "type": "uniswapV2Router02" }, { "address": "0xE592427A0AEce92De3Edee1F18E0157C05861564", - "chain_name": "goerli_testnet", - "chain_id": 5, "category": "messaging", + "chain_id": 5, + "chain_name": "goerli_testnet", "type": "uniswapV3Router" }, { @@ -196,52 +196,52 @@ "type": "zrc20" }, { + "address": "0x9fd96203f7b22bCF72d9DCb40ff98302376cE09c", "category": "omnichain", "chain_id": 7001, "chain_name": "zeta_testnet", - "address": "0x9fd96203f7b22bCF72d9DCb40ff98302376cE09c", "type": "uniswapV2Factory" }, { + "address": "0x5F0b1a82749cb4E2278EC87F8BF6B618dC71a8bf", "category": "omnichain", "chain_id": 7001, "chain_name": "zeta_testnet", - "address": "0x5F0b1a82749cb4E2278EC87F8BF6B618dC71a8bf", "type": "zetaToken" }, { + "address": "0x2ca7d64A7EFE2D62A725E2B35Cf7230D6677FfEe", "category": "omnichain", "chain_id": 7001, "chain_name": "zeta_testnet", - "address": "0x2ca7d64A7EFE2D62A725E2B35Cf7230D6677FfEe", "type": "uniswapV2Router02" }, { + "address": "0x735b14BB79463307AAcBED86DAf3322B1e6226aB", "category": "omnichain", "chain_id": 7001, "chain_name": "zeta_testnet", - "address": "0x735b14BB79463307AAcBED86DAf3322B1e6226aB", "type": "fungibleModule" }, { "address": "0x0000c9ec4042283e8139c74f4c64bcd1e0b9b54f", "category": "messaging", - "chain_id": "80001", - "chain_name": "mumbai_testnet", + "chain_id": "97", + "chain_name": "bsc_testnet", "type": "zetaToken" }, { "address": "0x0000ecb8cdd25a18f12daa23f6422e07fbf8b9e1", "category": "messaging", - "chain_id": "80001", - "chain_name": "mumbai_testnet", + "chain_id": "97", + "chain_name": "bsc_testnet", "type": "connector" }, { "address": "0x0000a7db254145767262c6a81a7ee1650684258e", "category": "omnichain", - "chain_id": "80001", - "chain_name": "mumbai_testnet", + "chain_id": "97", + "chain_name": "bsc_testnet", "type": "erc20Custody" }, { @@ -268,57 +268,57 @@ { "address": "0x0000c9ec4042283e8139c74f4c64bcd1e0b9b54f", "category": "messaging", - "chain_id": "97", - "chain_name": "bsc_testnet", + "chain_id": "80001", + "chain_name": "mumbai_testnet", "type": "zetaToken" }, { "address": "0x0000ecb8cdd25a18f12daa23f6422e07fbf8b9e1", "category": "messaging", - "chain_id": "97", - "chain_name": "bsc_testnet", + "chain_id": "80001", + "chain_name": "mumbai_testnet", "type": "connector" }, { "address": "0x0000a7db254145767262c6a81a7ee1650684258e", "category": "omnichain", - "chain_id": "97", - "chain_name": "bsc_testnet", + "chain_id": "80001", + "chain_name": "mumbai_testnet", "type": "erc20Custody" }, { "address": "0x55122f7590164Ac222504436943FAB17B62F5d7d", "category": "omnichain", - "chain_id": "80001", - "chain_name": "mumbai_testnet", + "chain_id": "97", + "chain_name": "bsc_testnet", "type": "tssUpdater" }, { "address": "0x55122f7590164Ac222504436943FAB17B62F5d7d", "category": "omnichain", - "chain_id": "5", - "chain_name": "goerli_testnet", + "chain_id": "80001", + "chain_name": "mumbai_testnet", "type": "tssUpdater" }, { "address": "0x55122f7590164Ac222504436943FAB17B62F5d7d", "category": "omnichain", - "chain_id": "97", - "chain_name": "bsc_testnet", + "chain_id": "5", + "chain_name": "goerli_testnet", "type": "tssUpdater" }, { "address": "0x55122f7590164Ac222504436943FAB17B62F5d7d", "category": "messaging", - "chain_id": "80001", - "chain_name": "mumbai_testnet", + "chain_id": "5", + "chain_name": "goerli_testnet", "type": "pauser" }, { "address": "0x55122f7590164Ac222504436943FAB17B62F5d7d", "category": "messaging", - "chain_id": "5", - "chain_name": "goerli_testnet", + "chain_id": "80001", + "chain_name": "mumbai_testnet", "type": "pauser" }, { diff --git a/lib/types.d.ts b/lib/types.d.ts index da57fc45..6dbc5594 100644 --- a/lib/types.d.ts +++ b/lib/types.d.ts @@ -1,4 +1,40 @@ -export type ParamSymbol = "USDC.BSC" | "USDC.ETH" | "BTC.BTC" | "BNB.BSC" | "USDT.ETH" | "USDT.BSC" | "ETH.ETH" | "USDC" | "gETH" | "tMATIC" | "tBTC" | "tBNB"; -export type ParamChainName = "eth_mainnet" | "bsc_mainnet" | "btc_mainnet" | "zeta_mainnet" | "goerli_testnet" | "mumbai_testnet" | "bsc_testnet" | "btc_testnet" | "zeta_testnet"; -export type ParamType = "uniswapV2Factory" | "uniswapV2Router02" | "uniswapV3Router" | "tss" | "systemContract" | "connector" | "zrc20" | "zetaToken" | "fungibleModule" | "erc20Custody" | "tssUpdater" | "pauser" | "weth9" | "uniswapV3Factory" | "zetaTokenConsumerUniV2" | "zetaTokenConsumerUniV3"; - +export type ParamSymbol = + | "BNB.BSC" + | "BTC.BTC" + | "ETH.ETH" + | "gETH" + | "tBNB" + | "tBTC" + | "tMATIC" + | "USDC.BSC" + | "USDC.ETH" + | "USDC" + | "USDT.BSC" + | "USDT.ETH"; +export type ParamChainName = + | "bsc_mainnet" + | "bsc_testnet" + | "btc_mainnet" + | "btc_testnet" + | "eth_mainnet" + | "goerli_testnet" + | "mumbai_testnet" + | "zeta_mainnet" + | "zeta_testnet"; +export type ParamType = + | "connector" + | "erc20Custody" + | "fungibleModule" + | "pauser" + | "systemContract" + | "tss" + | "tssUpdater" + | "uniswapV2Factory" + | "uniswapV2Router02" + | "uniswapV3Factory" + | "uniswapV3Router" + | "weth9" + | "zetaToken" + | "zetaTokenConsumerUniV2" + | "zetaTokenConsumerUniV3" + | "zrc20"; diff --git a/scripts/generate_addresses.sh b/scripts/generate_addresses.sh index 62e81086..2c767fa5 100755 --- a/scripts/generate_addresses.sh +++ b/scripts/generate_addresses.sh @@ -7,4 +7,6 @@ npx hardhat addresses --network zeta_mainnet > ./data/addresses.mainnet.json echo "Generating protocol addresses types..." -npx ts-node scripts/generate_addresses_types.ts > ./lib/types.d.ts \ No newline at end of file +npx ts-node scripts/generate_addresses_types.ts > ./lib/types.d.ts + +yarn lint:fix \ No newline at end of file diff --git a/tasks/addresses.mainnet.json b/tasks/addresses.mainnet.json index e718513d..fe76c7f5 100644 --- a/tasks/addresses.mainnet.json +++ b/tasks/addresses.mainnet.json @@ -1,23 +1,23 @@ [ { "address": "0x5C69bEe701ef814a2B6a3EDD4B1652CB9cc5aA6f", - "chain_name": "eth_mainnet", - "chain_id": 1, "category": "messaging", + "chain_id": 1, + "chain_name": "eth_mainnet", "type": "uniswapV2Factory" }, { "address": "0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D", - "chain_name": "eth_mainnet", - "chain_id": 1, "category": "messaging", + "chain_id": 1, + "chain_name": "eth_mainnet", "type": "uniswapV2Router02" }, { "address": "0xE592427A0AEce92De3Edee1F18E0157C05861564", - "chain_name": "eth_mainnet", - "chain_id": 1, "category": "messaging", + "chain_id": 1, + "chain_name": "eth_mainnet", "type": "uniswapV3Router" } -] \ No newline at end of file +] diff --git a/tasks/addresses.testnet.json b/tasks/addresses.testnet.json index e1575e64..7793f0c8 100644 --- a/tasks/addresses.testnet.json +++ b/tasks/addresses.testnet.json @@ -1,65 +1,65 @@ [ { "address": "0x8eAc517b92eeE82177a83851268F13109878f8c4", - "chain_name": "goerli_testnet", - "chain_id": 5, "category": "messaging", + "chain_id": 5, + "chain_name": "goerli_testnet", "type": "zetaTokenConsumerUniV2" }, { "address": "0x7e792f3736751e168864106AdbAC50152641A927", - "chain_name": "mumbai_testnet", "category": "messaging", "chain_id": 80001, + "chain_name": "mumbai_testnet", "type": "zetaTokenConsumerUniV3" }, { "address": "0xFB2fCE3CCca19F0f764Ed8aa26C62181E3dA04C5", - "chain_name": "bsc_testnet", "category": "messaging", "chain_id": 97, + "chain_name": "bsc_testnet", "type": "zetaTokenConsumerUniV3" }, { "address": "0x8954AfA98594b838bda56FE4C12a09D7739D179b", - "chain_name": "mumbai_testnet", - "chain_id": 80001, "category": "messaging", + "chain_id": 80001, + "chain_name": "mumbai_testnet", "type": "uniswapV2Router02" }, { "address": "0xE592427A0AEce92De3Edee1F18E0157C05861564", - "chain_name": "mumbai_testnet", - "chain_id": 80001, "category": "messaging", + "chain_id": 80001, + "chain_name": "mumbai_testnet", "type": "uniswapV3Router" }, { "address": "0x9Ac64Cc6e4415144C455BD8E4837Fea55603e5c3", - "chain_name": "bsc_testnet", - "chain_id": 97, "category": "messaging", + "chain_id": 97, + "chain_name": "bsc_testnet", "type": "uniswapV2Router02" }, { "address": "0x9a489505a00cE272eAa5e07Dba6491314CaE3796", - "chain_name": "bsc_testnet", - "chain_id": 97, "category": "messaging", + "chain_id": 97, + "chain_name": "bsc_testnet", "type": "uniswapV3Router" }, { "address": "0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D", - "chain_name": "goerli_testnet", - "chain_id": 5, "category": "messaging", + "chain_id": 5, + "chain_name": "goerli_testnet", "type": "uniswapV2Router02" }, { "address": "0xE592427A0AEce92De3Edee1F18E0157C05861564", - "chain_name": "goerli_testnet", - "chain_id": 5, "category": "messaging", + "chain_id": 5, + "chain_name": "goerli_testnet", "type": "uniswapV3Router" } -] \ No newline at end of file +] diff --git a/tasks/addresses.ts b/tasks/addresses.ts index bc40c890..cb33d1b7 100644 --- a/tasks/addresses.ts +++ b/tasks/addresses.ts @@ -1,3 +1,4 @@ +import uniswapV2Router from "@uniswap/v2-periphery/build/IUniswapV2Router02.json"; import { getEndpoints } from "@zetachain/networks"; import axios, { AxiosResponse } from "axios"; import { task } from "hardhat/config"; @@ -6,10 +7,8 @@ import { HardhatRuntimeEnvironment } from "hardhat/types"; import { ZetaConnectorBase__factory } from "../typechain-types"; import { ERC20Custody__factory } from "../typechain-types/factories/contracts/evm/ERC20Custody__factory"; import { SystemContract__factory } from "../typechain-types/factories/contracts/zevm/SystemContract.sol/SystemContract__factory"; -import uniswapV2Router from "@uniswap/v2-periphery/build/IUniswapV2Router02.json"; - -import zeta_testnet_addresses from "./addresses.testnet.json"; import zeta_mainnet_addresses from "./addresses.mainnet.json"; +import zeta_testnet_addresses from "./addresses.testnet.json"; declare const hre: any; From 72b277f06230f3c43be86dcf4555b60e850670b6 Mon Sep 17 00:00:00 2001 From: Denis Fadeev Date: Tue, 6 Feb 2024 16:32:37 +0400 Subject: [PATCH 23/27] chain IDs to ints --- data/addresses.mainnet.json | 28 +++++++-------- data/addresses.testnet.json | 68 +++++++++++++++++------------------ package.json | 2 +- scripts/generate_addresses.sh | 4 +-- tasks/addresses.ts | 12 +++---- 5 files changed, 56 insertions(+), 58 deletions(-) diff --git a/data/addresses.mainnet.json b/data/addresses.mainnet.json index 104a4b29..2d771e2b 100644 --- a/data/addresses.mainnet.json +++ b/data/addresses.mainnet.json @@ -23,28 +23,28 @@ { "address": "0x70e967acFcC17c3941E87562161406d41676FD83", "category": "omnichain", - "chain_id": "1", + "chain_id": 1, "chain_name": "eth_mainnet", "type": "tss" }, { "address": "0x70e967acFcC17c3941E87562161406d41676FD83", "category": "omnichain", - "chain_id": "56", + "chain_id": 56, "chain_name": "bsc_mainnet", "type": "tss" }, { "address": "0x70e967acFcC17c3941E87562161406d41676FD83", "category": "omnichain", - "chain_id": "8332", + "chain_id": 8332, "chain_name": "btc_mainnet", "type": "tss" }, { "address": "0x70e967acFcC17c3941E87562161406d41676FD83", "category": "omnichain", - "chain_id": "7000", + "chain_id": 7000, "chain_name": "zeta_mainnet", "type": "tss" }, @@ -184,70 +184,70 @@ { "address": "0x0000028a2eB8346cd5c0267856aB7594B7a55308", "category": "messaging", - "chain_id": "56", + "chain_id": 56, "chain_name": "bsc_mainnet", "type": "zetaToken" }, { "address": "0x000063A6e758D9e2f438d430108377564cf4077D", "category": "messaging", - "chain_id": "56", + "chain_id": 56, "chain_name": "bsc_mainnet", "type": "connector" }, { "address": "0x00000fF8fA992424957F97688015814e707A0115", "category": "omnichain", - "chain_id": "56", + "chain_id": 56, "chain_name": "bsc_mainnet", "type": "erc20Custody" }, { "address": "0xf091867EC603A6628eD83D274E835539D82e9cc8", "category": "messaging", - "chain_id": "1", + "chain_id": 1, "chain_name": "eth_mainnet", "type": "zetaToken" }, { "address": "0x000007Cf399229b2f5A4D043F20E90C9C98B7C6a", "category": "messaging", - "chain_id": "1", + "chain_id": 1, "chain_name": "eth_mainnet", "type": "connector" }, { "address": "0x0000030Ec64DF25301d8414eE5a29588C4B0dE10", "category": "omnichain", - "chain_id": "1", + "chain_id": 1, "chain_name": "eth_mainnet", "type": "erc20Custody" }, { "address": "0xaeB6dDB7708467814D557e340283248be8E43124", "category": "omnichain", - "chain_id": "1", + "chain_id": 1, "chain_name": "eth_mainnet", "type": "tssUpdater" }, { "address": "0xaf28a257D292e7f0E531073f70a175b57E0261a8", "category": "omnichain", - "chain_id": "56", + "chain_id": 56, "chain_name": "bsc_mainnet", "type": "tssUpdater" }, { "address": "0xaf28a257D292e7f0E531073f70a175b57E0261a8", "category": "messaging", - "chain_id": "56", + "chain_id": 56, "chain_name": "bsc_mainnet", "type": "pauser" }, { "address": "0xaeB6dDB7708467814D557e340283248be8E43124", "category": "messaging", - "chain_id": "1", + "chain_id": 1, "chain_name": "eth_mainnet", "type": "pauser" }, diff --git a/data/addresses.testnet.json b/data/addresses.testnet.json index 2e5de1e6..a4df5b8e 100644 --- a/data/addresses.testnet.json +++ b/data/addresses.testnet.json @@ -65,28 +65,28 @@ { "address": "0x8531a5aB847ff5B22D855633C25ED1DA3255247e", "category": "omnichain", - "chain_id": "5", + "chain_id": 5, "chain_name": "goerli_testnet", "type": "tss" }, { "address": "0x8531a5aB847ff5B22D855633C25ED1DA3255247e", "category": "omnichain", - "chain_id": "97", + "chain_id": 97, "chain_name": "bsc_testnet", "type": "tss" }, { "address": "0x8531a5aB847ff5B22D855633C25ED1DA3255247e", "category": "omnichain", - "chain_id": "80001", + "chain_id": 80001, "chain_name": "mumbai_testnet", "type": "tss" }, { "address": "tb1qy9pqmk2pd9sv63g27jt8r657wy0d9ueeh0nqur", "category": "omnichain", - "chain_id": "18332", + "chain_id": 18332, "chain_name": "btc_testnet", "type": "tss" }, @@ -224,107 +224,107 @@ "type": "fungibleModule" }, { - "address": "0x0000c9ec4042283e8139c74f4c64bcd1e0b9b54f", + "address": "0x0000c304d2934c00db1d51995b9f6996affd17c0", "category": "messaging", - "chain_id": "97", - "chain_name": "bsc_testnet", + "chain_id": 5, + "chain_name": "goerli_testnet", "type": "zetaToken" }, { - "address": "0x0000ecb8cdd25a18f12daa23f6422e07fbf8b9e1", + "address": "0x00005e3125aba53c5652f9f0ce1a4cf91d8b15ea", "category": "messaging", - "chain_id": "97", - "chain_name": "bsc_testnet", + "chain_id": 5, + "chain_name": "goerli_testnet", "type": "connector" }, { - "address": "0x0000a7db254145767262c6a81a7ee1650684258e", + "address": "0x000047f11c6e42293f433c82473532e869ce4ec5", "category": "omnichain", - "chain_id": "97", - "chain_name": "bsc_testnet", + "chain_id": 5, + "chain_name": "goerli_testnet", "type": "erc20Custody" }, { - "address": "0x0000c304d2934c00db1d51995b9f6996affd17c0", + "address": "0x0000c9ec4042283e8139c74f4c64bcd1e0b9b54f", "category": "messaging", - "chain_id": "5", - "chain_name": "goerli_testnet", + "chain_id": 80001, + "chain_name": "mumbai_testnet", "type": "zetaToken" }, { - "address": "0x00005e3125aba53c5652f9f0ce1a4cf91d8b15ea", + "address": "0x0000ecb8cdd25a18f12daa23f6422e07fbf8b9e1", "category": "messaging", - "chain_id": "5", - "chain_name": "goerli_testnet", + "chain_id": 80001, + "chain_name": "mumbai_testnet", "type": "connector" }, { - "address": "0x000047f11c6e42293f433c82473532e869ce4ec5", + "address": "0x0000a7db254145767262c6a81a7ee1650684258e", "category": "omnichain", - "chain_id": "5", - "chain_name": "goerli_testnet", + "chain_id": 80001, + "chain_name": "mumbai_testnet", "type": "erc20Custody" }, { "address": "0x0000c9ec4042283e8139c74f4c64bcd1e0b9b54f", "category": "messaging", - "chain_id": "80001", - "chain_name": "mumbai_testnet", + "chain_id": 97, + "chain_name": "bsc_testnet", "type": "zetaToken" }, { "address": "0x0000ecb8cdd25a18f12daa23f6422e07fbf8b9e1", "category": "messaging", - "chain_id": "80001", - "chain_name": "mumbai_testnet", + "chain_id": 97, + "chain_name": "bsc_testnet", "type": "connector" }, { "address": "0x0000a7db254145767262c6a81a7ee1650684258e", "category": "omnichain", - "chain_id": "80001", - "chain_name": "mumbai_testnet", + "chain_id": 97, + "chain_name": "bsc_testnet", "type": "erc20Custody" }, { "address": "0x55122f7590164Ac222504436943FAB17B62F5d7d", "category": "omnichain", - "chain_id": "97", + "chain_id": 97, "chain_name": "bsc_testnet", "type": "tssUpdater" }, { "address": "0x55122f7590164Ac222504436943FAB17B62F5d7d", "category": "omnichain", - "chain_id": "80001", + "chain_id": 80001, "chain_name": "mumbai_testnet", "type": "tssUpdater" }, { "address": "0x55122f7590164Ac222504436943FAB17B62F5d7d", "category": "omnichain", - "chain_id": "5", + "chain_id": 5, "chain_name": "goerli_testnet", "type": "tssUpdater" }, { "address": "0x55122f7590164Ac222504436943FAB17B62F5d7d", "category": "messaging", - "chain_id": "5", + "chain_id": 5, "chain_name": "goerli_testnet", "type": "pauser" }, { "address": "0x55122f7590164Ac222504436943FAB17B62F5d7d", "category": "messaging", - "chain_id": "80001", + "chain_id": 80001, "chain_name": "mumbai_testnet", "type": "pauser" }, { "address": "0x55122f7590164Ac222504436943FAB17B62F5d7d", "category": "messaging", - "chain_id": "97", + "chain_id": 97, "chain_name": "bsc_testnet", "type": "pauser" }, diff --git a/package.json b/package.json index 61c6e323..3f6b4c7a 100644 --- a/package.json +++ b/package.json @@ -70,7 +70,7 @@ "scripts": { "build": "yarn compile && npx del-cli dist abi && tsc || exit 0 && npx del-cli './dist/typechain-types/**/*.js' && npx cpx './data/**/*' dist/data && npx cpx './artifacts/contracts/**/*' ./abi && npx del-cli './abi/**/*.dbg.json'", "compile": "npx hardhat compile --force", - "generate": "yarn compile && ./scripts/generate_go.sh || exit 0 && ./scripts/generate_addresses.sh", + "generate": "yarn compile && ./scripts/generate_go.sh || exit 0 && ./scripts/generate_addresses.sh && yarn lint:fix", "lint": "npx eslint . --ext .js,.ts", "lint:fix": "npx eslint . --ext .js,.ts,.json --fix", "prepublishOnly": "yarn build", diff --git a/scripts/generate_addresses.sh b/scripts/generate_addresses.sh index 2c767fa5..62e81086 100755 --- a/scripts/generate_addresses.sh +++ b/scripts/generate_addresses.sh @@ -7,6 +7,4 @@ npx hardhat addresses --network zeta_mainnet > ./data/addresses.mainnet.json echo "Generating protocol addresses types..." -npx ts-node scripts/generate_addresses_types.ts > ./lib/types.d.ts - -yarn lint:fix \ No newline at end of file +npx ts-node scripts/generate_addresses_types.ts > ./lib/types.d.ts \ No newline at end of file diff --git a/tasks/addresses.ts b/tasks/addresses.ts index cb33d1b7..56f324f8 100644 --- a/tasks/addresses.ts +++ b/tasks/addresses.ts @@ -52,7 +52,7 @@ const fetchTssData = async (chains: any, addresses: any, network: Network) => { addresses.push({ address: chain.chain_name === "btc_testnet" ? btc : eth, category: "omnichain", - chain_id: chain.chain_id, + chain_id: parseInt(chain.chain_id), chain_name: chain.chain_name, type: "tss", }); @@ -157,7 +157,7 @@ const fetchChainSpecificAddresses = async (chains: any, addresses: any, network: addresses.push({ address: zetaToken, category: "messaging", - chain_id: chain.chain_id, + chain_id: parseInt(chain.chain_id), chain_name: chain.chain_name, type: "zetaToken", }); @@ -167,7 +167,7 @@ const fetchChainSpecificAddresses = async (chains: any, addresses: any, network: addresses.push({ address: connector, category: "messaging", - chain_id: chain.chain_id, + chain_id: parseInt(chain.chain_id), chain_name: chain.chain_name, type: "connector", }); @@ -177,7 +177,7 @@ const fetchChainSpecificAddresses = async (chains: any, addresses: any, network: addresses.push({ address: data.chain_params.erc20_custody_contract_address, category: "omnichain", - chain_id: chain.chain_id, + chain_id: parseInt(chain.chain_id), chain_name: chain.chain_name, type: "erc20Custody", }); @@ -202,7 +202,7 @@ const fetchTSSUpdater = async (chains: any, addresses: any) => { addresses.push({ address, category: "omnichain", - chain_id: chain.chain_id, + chain_id: parseInt(chain.chain_id), chain_name: chain.chain_name, type: "tssUpdater", }); @@ -227,7 +227,7 @@ const fetchPauser = async (chains: any, addresses: any) => { addresses.push({ address, category: "messaging", - chain_id: chain.chain_id, + chain_id: parseInt(chain.chain_id), chain_name: chain.chain_name, type: "pauser", }); From ef14114a30285ce96730114a5bfe10ceb307f38b Mon Sep 17 00:00:00 2001 From: Denis Fadeev Date: Wed, 7 Feb 2024 13:20:22 +0400 Subject: [PATCH 24/27] fix build --- data/addresses.json | 38 +++++++++++------------ data/addresses.mainnet.json | 12 +++---- data/addresses.testnet.json | 62 ++++++++++++++++++------------------- package.json | 6 ++-- 4 files changed, 59 insertions(+), 59 deletions(-) diff --git a/data/addresses.json b/data/addresses.json index cd879792..b78c7b76 100644 --- a/data/addresses.json +++ b/data/addresses.json @@ -18,19 +18,19 @@ "zetaTokenConsumerUniV2": "", "zetaTokenConsumerUniV3": "0xFB2fCE3CCca19F0f764Ed8aa26C62181E3dA04C5" }, - "btc_testnet": { + "btc_mainnet": { "connector": "", "immutableCreate2Factory": "", - "tss": "tb1qy9pqmk2pd9sv63g27jt8r657wy0d9ueeh0nqur", + "tss": "bc1qm24wp577nk8aacckv8np465z3dvmu7ry45el6y", "tssUpdater": "", "zetaToken": "", "zetaTokenConsumerUniV2": "", "zetaTokenConsumerUniV3": "" }, - "btc_mainnet": { + "btc_testnet": { "connector": "", "immutableCreate2Factory": "", - "tss": "bc1qm24wp577nk8aacckv8np465z3dvmu7ry45el6y", + "tss": "tb1qy9pqmk2pd9sv63g27jt8r657wy0d9ueeh0nqur", "tssUpdater": "", "zetaToken": "", "zetaTokenConsumerUniV2": "", @@ -64,20 +64,20 @@ "zetaTokenConsumerUniV2": "", "zetaTokenConsumerUniV3": "0x7e792f3736751e168864106AdbAC50152641A927" }, - "zeta_testnet": { + "zeta_mainnet": { "connector": "0x239e96c8f17C85c30100AC26F635Ea15f23E9c67", "immutableCreate2Factory": "", - "tss": "0x7c125C1d515b8945841b3d5144a060115C58725F", - "tssUpdater": "0x7274d1d5dddef36aac53dd45b93487ce01ef0a55", + "tss": "", + "tssUpdater": "", "zetaToken": "0x5F0b1a82749cb4E2278EC87F8BF6B618dC71a8bf", "zetaTokenConsumerUniV2": "", "zetaTokenConsumerUniV3": "" }, - "zeta_mainnet": { + "zeta_testnet": { "connector": "0x239e96c8f17C85c30100AC26F635Ea15f23E9c67", "immutableCreate2Factory": "", - "tss": "", - "tssUpdater": "", + "tss": "0x7c125C1d515b8945841b3d5144a060115C58725F", + "tssUpdater": "0x7274d1d5dddef36aac53dd45b93487ce01ef0a55", "zetaToken": "0x5F0b1a82749cb4E2278EC87F8BF6B618dC71a8bf", "zetaTokenConsumerUniV2": "", "zetaTokenConsumerUniV3": "" @@ -131,26 +131,26 @@ "bsc_testnet": { "zrc20": "0xd97B1de3619ed2c6BEb3860147E30cA8A7dC9891" }, + "btc_testnet": { + "zrc20": "0x65a45c57636f9BcCeD4fe193A602008578BcA90b" + }, "goerli_testnet": { "zrc20": "0x13A0c5930C028511Dc02665E7285134B6d11A5f4" }, "mumbai_testnet": { "zrc20": "0x48f80608B672DC30DC7e3dbBd0343c5F02C738Eb" }, - "btc_testnet": { - "zrc20": "0x65a45c57636f9BcCeD4fe193A602008578BcA90b" + "zeta_mainnet": { + "fungibleModule": "", + "systemContract": "0x91d18e54DAf4F677cB28167158d6dd21F6aB3921", + "uniswapv2Factory": "", + "uniswapv2Router02": "" }, "zeta_testnet": { "fungibleModule": "0x735b14BB79463307AAcBED86DAf3322B1e6226aB", "systemContract": "0xEdf1c3275d13489aCdC6cD6eD246E72458B8795B", "uniswapv2Factory": "0x9fd96203f7b22bCF72d9DCb40ff98302376cE09c", "uniswapv2Router02": "0x2ca7d64A7EFE2D62A725E2B35Cf7230D6677FfEe" - }, - "zeta_mainnet": { - "fungibleModule": "", - "systemContract": "0x91d18e54DAf4F677cB28167158d6dd21F6aB3921", - "uniswapv2Factory": "", - "uniswapv2Router02": "" } } -} \ No newline at end of file +} diff --git a/data/addresses.mainnet.json b/data/addresses.mainnet.json index 2d771e2b..7fc3e4ad 100644 --- a/data/addresses.mainnet.json +++ b/data/addresses.mainnet.json @@ -238,17 +238,17 @@ "type": "tssUpdater" }, { - "address": "0xaf28a257D292e7f0E531073f70a175b57E0261a8", + "address": "0xaeB6dDB7708467814D557e340283248be8E43124", "category": "messaging", - "chain_id": 56, - "chain_name": "bsc_mainnet", + "chain_id": 1, + "chain_name": "eth_mainnet", "type": "pauser" }, { - "address": "0xaeB6dDB7708467814D557e340283248be8E43124", + "address": "0xaf28a257D292e7f0E531073f70a175b57E0261a8", "category": "messaging", - "chain_id": 1, - "chain_name": "eth_mainnet", + "chain_id": 56, + "chain_name": "bsc_mainnet", "type": "pauser" }, { diff --git a/data/addresses.testnet.json b/data/addresses.testnet.json index a4df5b8e..1aff719a 100644 --- a/data/addresses.testnet.json +++ b/data/addresses.testnet.json @@ -223,6 +223,27 @@ "chain_name": "zeta_testnet", "type": "fungibleModule" }, + { + "address": "0x0000c9ec4042283e8139c74f4c64bcd1e0b9b54f", + "category": "messaging", + "chain_id": 97, + "chain_name": "bsc_testnet", + "type": "zetaToken" + }, + { + "address": "0x0000ecb8cdd25a18f12daa23f6422e07fbf8b9e1", + "category": "messaging", + "chain_id": 97, + "chain_name": "bsc_testnet", + "type": "connector" + }, + { + "address": "0x0000a7db254145767262c6a81a7ee1650684258e", + "category": "omnichain", + "chain_id": 97, + "chain_name": "bsc_testnet", + "type": "erc20Custody" + }, { "address": "0x0000c304d2934c00db1d51995b9f6996affd17c0", "category": "messaging", @@ -265,53 +286,32 @@ "chain_name": "mumbai_testnet", "type": "erc20Custody" }, - { - "address": "0x0000c9ec4042283e8139c74f4c64bcd1e0b9b54f", - "category": "messaging", - "chain_id": 97, - "chain_name": "bsc_testnet", - "type": "zetaToken" - }, - { - "address": "0x0000ecb8cdd25a18f12daa23f6422e07fbf8b9e1", - "category": "messaging", - "chain_id": 97, - "chain_name": "bsc_testnet", - "type": "connector" - }, - { - "address": "0x0000a7db254145767262c6a81a7ee1650684258e", - "category": "omnichain", - "chain_id": 97, - "chain_name": "bsc_testnet", - "type": "erc20Custody" - }, { "address": "0x55122f7590164Ac222504436943FAB17B62F5d7d", "category": "omnichain", - "chain_id": 97, - "chain_name": "bsc_testnet", + "chain_id": 80001, + "chain_name": "mumbai_testnet", "type": "tssUpdater" }, { "address": "0x55122f7590164Ac222504436943FAB17B62F5d7d", "category": "omnichain", - "chain_id": 80001, - "chain_name": "mumbai_testnet", + "chain_id": 5, + "chain_name": "goerli_testnet", "type": "tssUpdater" }, { "address": "0x55122f7590164Ac222504436943FAB17B62F5d7d", "category": "omnichain", - "chain_id": 5, - "chain_name": "goerli_testnet", + "chain_id": 97, + "chain_name": "bsc_testnet", "type": "tssUpdater" }, { "address": "0x55122f7590164Ac222504436943FAB17B62F5d7d", "category": "messaging", - "chain_id": 5, - "chain_name": "goerli_testnet", + "chain_id": 97, + "chain_name": "bsc_testnet", "type": "pauser" }, { @@ -324,8 +324,8 @@ { "address": "0x55122f7590164Ac222504436943FAB17B62F5d7d", "category": "messaging", - "chain_id": 97, - "chain_name": "bsc_testnet", + "chain_id": 5, + "chain_name": "goerli_testnet", "type": "pauser" }, { diff --git a/package.json b/package.json index 81afe552..83fd2a42 100644 --- a/package.json +++ b/package.json @@ -7,8 +7,8 @@ "@nomicfoundation/hardhat-chai-matchers": "^1.0.6", "@nomicfoundation/hardhat-network-helpers": "^1.0.0", "@nomicfoundation/hardhat-toolbox": "^2.0.0", - "@nomiclabs/hardhat-ethers": "^2.0.5", "@nomicfoundation/hardhat-verify": "2.0.3", + "@nomiclabs/hardhat-ethers": "^2.0.5", "@nomiclabs/hardhat-waffle": "^2.0.3", "@openzeppelin/contracts": "^4.8.3", "@typechain/ethers-v5": "^10.1.0", @@ -68,9 +68,9 @@ "registry": "https://registry.npmjs.org/" }, "scripts": { - "build": "yarn compile && npx del-cli dist abi && tsc || exit 0 && npx del-cli './dist/typechain-types/**/*.js' && npx cpx './data/**/*' dist/data && npx cpx './artifacts/contracts/**/*' ./abi && npx del-cli './abi/**/*.dbg.json'", + "build": "yarn compile && npx del-cli dist abi && npx tsc || true && npx del-cli './dist/typechain-types/**/*.js' && npx cpx './data/**/*' dist/data && npx cpx './artifacts/contracts/**/*' ./abi && npx del-cli './abi/**/*.dbg.json'", "compile": "npx hardhat compile --force", - "generate": "yarn compile && ./scripts/generate_go.sh || exit 0 && ./scripts/generate_addresses.sh && yarn lint:fix", + "generate": "yarn compile && ./scripts/generate_go.sh || true && ./scripts/generate_addresses.sh && yarn lint:fix", "lint": "npx eslint . --ext .js,.ts", "lint:fix": "npx eslint . --ext .js,.ts,.json --fix", "prepublishOnly": "yarn build", From 796a5325247ed94e8e40caeddb450c14da9f9919 Mon Sep 17 00:00:00 2001 From: Denis Fadeev Date: Wed, 7 Feb 2024 17:51:42 +0400 Subject: [PATCH 25/27] yarn generate --- data/addresses.mainnet.json | 18 ++++++++-------- data/addresses.testnet.json | 20 +++++++++--------- lib/types.d.ts | 40 ----------------------------------- lib/types.ts | 16 ++++++++------ scripts/generate_addresses.sh | 2 +- 5 files changed, 30 insertions(+), 66 deletions(-) delete mode 100644 lib/types.d.ts diff --git a/data/addresses.mainnet.json b/data/addresses.mainnet.json index 7fc3e4ad..3c99e3f3 100644 --- a/data/addresses.mainnet.json +++ b/data/addresses.mainnet.json @@ -223,13 +223,6 @@ "chain_name": "eth_mainnet", "type": "erc20Custody" }, - { - "address": "0xaeB6dDB7708467814D557e340283248be8E43124", - "category": "omnichain", - "chain_id": 1, - "chain_name": "eth_mainnet", - "type": "tssUpdater" - }, { "address": "0xaf28a257D292e7f0E531073f70a175b57E0261a8", "category": "omnichain", @@ -239,10 +232,10 @@ }, { "address": "0xaeB6dDB7708467814D557e340283248be8E43124", - "category": "messaging", + "category": "omnichain", "chain_id": 1, "chain_name": "eth_mainnet", - "type": "pauser" + "type": "tssUpdater" }, { "address": "0xaf28a257D292e7f0E531073f70a175b57E0261a8", @@ -251,6 +244,13 @@ "chain_name": "bsc_mainnet", "type": "pauser" }, + { + "address": "0xaeB6dDB7708467814D557e340283248be8E43124", + "category": "messaging", + "chain_id": 1, + "chain_name": "eth_mainnet", + "type": "pauser" + }, { "address": "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2", "category": "messaging", diff --git a/data/addresses.testnet.json b/data/addresses.testnet.json index 1aff719a..020a3f6f 100644 --- a/data/addresses.testnet.json +++ b/data/addresses.testnet.json @@ -289,15 +289,15 @@ { "address": "0x55122f7590164Ac222504436943FAB17B62F5d7d", "category": "omnichain", - "chain_id": 80001, - "chain_name": "mumbai_testnet", + "chain_id": 5, + "chain_name": "goerli_testnet", "type": "tssUpdater" }, { "address": "0x55122f7590164Ac222504436943FAB17B62F5d7d", "category": "omnichain", - "chain_id": 5, - "chain_name": "goerli_testnet", + "chain_id": 80001, + "chain_name": "mumbai_testnet", "type": "tssUpdater" }, { @@ -310,22 +310,22 @@ { "address": "0x55122f7590164Ac222504436943FAB17B62F5d7d", "category": "messaging", - "chain_id": 97, - "chain_name": "bsc_testnet", + "chain_id": 80001, + "chain_name": "mumbai_testnet", "type": "pauser" }, { "address": "0x55122f7590164Ac222504436943FAB17B62F5d7d", "category": "messaging", - "chain_id": 80001, - "chain_name": "mumbai_testnet", + "chain_id": 5, + "chain_name": "goerli_testnet", "type": "pauser" }, { "address": "0x55122f7590164Ac222504436943FAB17B62F5d7d", "category": "messaging", - "chain_id": 5, - "chain_name": "goerli_testnet", + "chain_id": 97, + "chain_name": "bsc_testnet", "type": "pauser" }, { diff --git a/lib/types.d.ts b/lib/types.d.ts deleted file mode 100644 index 6dbc5594..00000000 --- a/lib/types.d.ts +++ /dev/null @@ -1,40 +0,0 @@ -export type ParamSymbol = - | "BNB.BSC" - | "BTC.BTC" - | "ETH.ETH" - | "gETH" - | "tBNB" - | "tBTC" - | "tMATIC" - | "USDC.BSC" - | "USDC.ETH" - | "USDC" - | "USDT.BSC" - | "USDT.ETH"; -export type ParamChainName = - | "bsc_mainnet" - | "bsc_testnet" - | "btc_mainnet" - | "btc_testnet" - | "eth_mainnet" - | "goerli_testnet" - | "mumbai_testnet" - | "zeta_mainnet" - | "zeta_testnet"; -export type ParamType = - | "connector" - | "erc20Custody" - | "fungibleModule" - | "pauser" - | "systemContract" - | "tss" - | "tssUpdater" - | "uniswapV2Factory" - | "uniswapV2Router02" - | "uniswapV3Factory" - | "uniswapV3Router" - | "weth9" - | "zetaToken" - | "zetaTokenConsumerUniV2" - | "zetaTokenConsumerUniV3" - | "zrc20"; diff --git a/lib/types.ts b/lib/types.ts index 722d2f93..6dbc5594 100644 --- a/lib/types.ts +++ b/lib/types.ts @@ -1,4 +1,4 @@ -export declare type ParamSymbol = +export type ParamSymbol = | "BNB.BSC" | "BTC.BTC" | "ETH.ETH" @@ -11,7 +11,7 @@ export declare type ParamSymbol = | "USDC" | "USDT.BSC" | "USDT.ETH"; -export declare type ParamChainName = +export type ParamChainName = | "bsc_mainnet" | "bsc_testnet" | "btc_mainnet" @@ -21,7 +21,7 @@ export declare type ParamChainName = | "mumbai_testnet" | "zeta_mainnet" | "zeta_testnet"; -export declare type ParamType = +export type ParamType = | "connector" | "erc20Custody" | "fungibleModule" @@ -29,8 +29,12 @@ export declare type ParamType = | "systemContract" | "tss" | "tssUpdater" - | "uniswapv2Factory" - | "uniswapv2Router02" - | "wZetaContract" + | "uniswapV2Factory" + | "uniswapV2Router02" + | "uniswapV3Factory" + | "uniswapV3Router" + | "weth9" | "zetaToken" + | "zetaTokenConsumerUniV2" + | "zetaTokenConsumerUniV3" | "zrc20"; diff --git a/scripts/generate_addresses.sh b/scripts/generate_addresses.sh index 62e81086..b51dc8cf 100755 --- a/scripts/generate_addresses.sh +++ b/scripts/generate_addresses.sh @@ -7,4 +7,4 @@ npx hardhat addresses --network zeta_mainnet > ./data/addresses.mainnet.json echo "Generating protocol addresses types..." -npx ts-node scripts/generate_addresses_types.ts > ./lib/types.d.ts \ No newline at end of file +npx ts-node scripts/generate_addresses_types.ts > ./lib/types.ts \ No newline at end of file From dc0cb117b0e13fe849663919d4f5ff5b884e4b50 Mon Sep 17 00:00:00 2001 From: Denis Fadeev Date: Thu, 8 Feb 2024 12:24:56 +0400 Subject: [PATCH 26/27] readme --- data/readme.md | 1 + 1 file changed, 1 insertion(+) create mode 100644 data/readme.md diff --git a/data/readme.md b/data/readme.md new file mode 100644 index 00000000..9a1ef0f0 --- /dev/null +++ b/data/readme.md @@ -0,0 +1 @@ +These addresses are generated automatically, do not modify them directly. From 9bf2feaf4617db4e89e5007aef0a398e6e684ffb Mon Sep 17 00:00:00 2001 From: Denis Fadeev Date: Thu, 8 Feb 2024 12:42:29 +0400 Subject: [PATCH 27/27] remove duplicate zetatoken --- data/addresses.mainnet.json | 25 +++++--------- data/addresses.testnet.json | 69 +++++++++++++++++-------------------- tasks/addresses.ts | 18 +++++----- 3 files changed, 50 insertions(+), 62 deletions(-) diff --git a/data/addresses.mainnet.json b/data/addresses.mainnet.json index 3c99e3f3..8d9af7f4 100644 --- a/data/addresses.mainnet.json +++ b/data/addresses.mainnet.json @@ -223,13 +223,6 @@ "chain_name": "eth_mainnet", "type": "erc20Custody" }, - { - "address": "0xaf28a257D292e7f0E531073f70a175b57E0261a8", - "category": "omnichain", - "chain_id": 56, - "chain_name": "bsc_mainnet", - "type": "tssUpdater" - }, { "address": "0xaeB6dDB7708467814D557e340283248be8E43124", "category": "omnichain", @@ -239,10 +232,10 @@ }, { "address": "0xaf28a257D292e7f0E531073f70a175b57E0261a8", - "category": "messaging", + "category": "omnichain", "chain_id": 56, "chain_name": "bsc_mainnet", - "type": "pauser" + "type": "tssUpdater" }, { "address": "0xaeB6dDB7708467814D557e340283248be8E43124", @@ -251,6 +244,13 @@ "chain_name": "eth_mainnet", "type": "pauser" }, + { + "address": "0xaf28a257D292e7f0E531073f70a175b57E0261a8", + "category": "messaging", + "chain_id": 56, + "chain_name": "bsc_mainnet", + "type": "pauser" + }, { "address": "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2", "category": "messaging", @@ -265,13 +265,6 @@ "chain_name": "eth_mainnet", "type": "uniswapV2Factory" }, - { - "address": "0x5F0b1a82749cb4E2278EC87F8BF6B618dC71a8bf", - "category": "messaging", - "chain_id": 7000, - "chain_name": "zeta_mainnet", - "type": "weth9" - }, { "address": "0x9fd96203f7b22bCF72d9DCb40ff98302376cE09c", "category": "messaging", diff --git a/data/addresses.testnet.json b/data/addresses.testnet.json index 020a3f6f..e697a43f 100644 --- a/data/addresses.testnet.json +++ b/data/addresses.testnet.json @@ -223,27 +223,6 @@ "chain_name": "zeta_testnet", "type": "fungibleModule" }, - { - "address": "0x0000c9ec4042283e8139c74f4c64bcd1e0b9b54f", - "category": "messaging", - "chain_id": 97, - "chain_name": "bsc_testnet", - "type": "zetaToken" - }, - { - "address": "0x0000ecb8cdd25a18f12daa23f6422e07fbf8b9e1", - "category": "messaging", - "chain_id": 97, - "chain_name": "bsc_testnet", - "type": "connector" - }, - { - "address": "0x0000a7db254145767262c6a81a7ee1650684258e", - "category": "omnichain", - "chain_id": 97, - "chain_name": "bsc_testnet", - "type": "erc20Custody" - }, { "address": "0x0000c304d2934c00db1d51995b9f6996affd17c0", "category": "messaging", @@ -287,32 +266,46 @@ "type": "erc20Custody" }, { - "address": "0x55122f7590164Ac222504436943FAB17B62F5d7d", + "address": "0x0000c9ec4042283e8139c74f4c64bcd1e0b9b54f", + "category": "messaging", + "chain_id": 97, + "chain_name": "bsc_testnet", + "type": "zetaToken" + }, + { + "address": "0x0000ecb8cdd25a18f12daa23f6422e07fbf8b9e1", + "category": "messaging", + "chain_id": 97, + "chain_name": "bsc_testnet", + "type": "connector" + }, + { + "address": "0x0000a7db254145767262c6a81a7ee1650684258e", "category": "omnichain", - "chain_id": 5, - "chain_name": "goerli_testnet", - "type": "tssUpdater" + "chain_id": 97, + "chain_name": "bsc_testnet", + "type": "erc20Custody" }, { "address": "0x55122f7590164Ac222504436943FAB17B62F5d7d", "category": "omnichain", - "chain_id": 80001, - "chain_name": "mumbai_testnet", + "chain_id": 97, + "chain_name": "bsc_testnet", "type": "tssUpdater" }, { "address": "0x55122f7590164Ac222504436943FAB17B62F5d7d", "category": "omnichain", - "chain_id": 97, - "chain_name": "bsc_testnet", + "chain_id": 5, + "chain_name": "goerli_testnet", "type": "tssUpdater" }, { "address": "0x55122f7590164Ac222504436943FAB17B62F5d7d", - "category": "messaging", + "category": "omnichain", "chain_id": 80001, "chain_name": "mumbai_testnet", - "type": "pauser" + "type": "tssUpdater" }, { "address": "0x55122f7590164Ac222504436943FAB17B62F5d7d", @@ -328,6 +321,13 @@ "chain_name": "bsc_testnet", "type": "pauser" }, + { + "address": "0x55122f7590164Ac222504436943FAB17B62F5d7d", + "category": "messaging", + "chain_id": 80001, + "chain_name": "mumbai_testnet", + "type": "pauser" + }, { "address": "0x9c3C9283D3e44854697Cd22D3Faa240Cfb032889", "category": "messaging", @@ -370,13 +370,6 @@ "chain_name": "goerli_testnet", "type": "uniswapV2Factory" }, - { - "address": "0x5F0b1a82749cb4E2278EC87F8BF6B618dC71a8bf", - "category": "messaging", - "chain_id": 7001, - "chain_name": "zeta_testnet", - "type": "weth9" - }, { "address": "0x9fd96203f7b22bCF72d9DCb40ff98302376cE09c", "category": "messaging", diff --git a/tasks/addresses.ts b/tasks/addresses.ts index 56f324f8..0fb844d4 100644 --- a/tasks/addresses.ts +++ b/tasks/addresses.ts @@ -249,14 +249,16 @@ const fetchFactoryV2 = async (addresses: any, hre: HardhatRuntimeEnvironment, ne const wethAddress = await routerContract.WETH(); const factoryAddress = await routerContract.factory(); - // Adding WETH and Factory addresses to the addresses array - addresses.push({ - address: wethAddress, - category: "messaging", - chain_id: router.chain_id, - chain_name: router.chain_name, - type: "weth9", - }); + // Skip ZetaChain as we've already added ZETA token + if (router.chain_id !== 7000 && router.chain_id !== 7001) { + addresses.push({ + address: wethAddress, + category: "messaging", + chain_id: router.chain_id, + chain_name: router.chain_name, + type: "weth9", + }); + } addresses.push({ address: factoryAddress,