|
| 1 | +import { Chain, Network, chains } from '@wormhole-foundation/sdk-base'; |
| 2 | + |
| 3 | +// This data structure is used in dashboard |
| 4 | +export type NTTContract = { |
| 5 | + [key in Network]: { [tokenName: string]: { [key in Chain]?: string } }; |
| 6 | +}; |
| 7 | + |
| 8 | +// This data structure is used in watchers |
| 9 | +export type NTTContractArray = { |
| 10 | + [key in Network]: { [key in Chain]?: string[] }; |
| 11 | +}; |
| 12 | + |
| 13 | +function convertNTTManagerContractToNTTContractArray( |
| 14 | + nttManagerContract: NTTContract |
| 15 | +): NTTContractArray { |
| 16 | + const nttContract: NTTContractArray = {} as NTTContractArray; |
| 17 | + |
| 18 | + for (const network in nttManagerContract) { |
| 19 | + nttContract[network as Network] = {}; |
| 20 | + |
| 21 | + for (const tokenName in nttManagerContract[network as Network]) { |
| 22 | + for (const chain in nttManagerContract[network as Network][tokenName]) { |
| 23 | + const tokenAddress = nttManagerContract[network as Network][tokenName][chain as Chain]; |
| 24 | + |
| 25 | + if (tokenAddress) { |
| 26 | + if (!nttContract[network as Network][chain as Chain]) { |
| 27 | + nttContract[network as Network][chain as Chain] = []; |
| 28 | + } |
| 29 | + nttContract[network as Network][chain as Chain]!.push(tokenAddress); |
| 30 | + } |
| 31 | + } |
| 32 | + } |
| 33 | + } |
| 34 | + |
| 35 | + return nttContract; |
| 36 | +} |
| 37 | + |
| 38 | +export const NTT_MANAGER_CONTRACT: NTTContract = { |
| 39 | + Mainnet: { |
| 40 | + USDC: { |
| 41 | + Ethereum: '0xeBdCe9a913d9400EE75ef31Ce8bd34462D01a1c1', |
| 42 | + Fantom: '0x68dB2f05Aa2d77DEf981fd2be32661340c9222FB', |
| 43 | + }, |
| 44 | + }, |
| 45 | + Testnet: { |
| 46 | + TEST_NTT: { |
| 47 | + Solana: 'nTTh3bZ5Aer6xboWZe39RDEft4MeVxSQ8D1EYAVLZw9', |
| 48 | + Sepolia: '0xB231aD95f2301bc82eA44c515001F0F746D637e0', |
| 49 | + ArbitrumSepolia: '0xEec94CD3083e067398256a79CcA7e740C5c8ef81', |
| 50 | + BaseSepolia: '0xB03b030b2f5B40819Df76467d67eD1C85Ff66fAD', |
| 51 | + OptimismSepolia: '0x7f430D4e7939D994C0955A01FC75D9DE33F12D11', |
| 52 | + }, |
| 53 | + }, |
| 54 | + Devnet: {}, |
| 55 | +}; |
| 56 | + |
| 57 | +export const NTT_TRANSCEIVER_CONTRACT: NTTContract = { |
| 58 | + Mainnet: { |
| 59 | + USDC: { |
| 60 | + Ethereum: '0x55f7820357FA17A1ECb48E959D5E637bFF956d6F', |
| 61 | + Fantom: '0x8b47f02E7E20174C76Af910adc0Ad8A4B0342f4c', |
| 62 | + }, |
| 63 | + }, |
| 64 | + Testnet: { |
| 65 | + TEST_NTT: { |
| 66 | + Solana: '9WNzy7xYZyL2k6JnE9dWSp7VpYkvfRN3Rhd8wHv9J9mY', |
| 67 | + Sepolia: '0x1fDC902e30b188FD2BA976B421Cb179943F57896', |
| 68 | + ArbitrumSepolia: '0x0E24D17D7467467b39Bf64A9DFf88776Bd6c74d7', |
| 69 | + BaseSepolia: '0x1e072169541f1171e427Aa44B5fd8924BEE71b0e', |
| 70 | + OptimismSepolia: '0x41265eb2863bf0238081F6AeefeF73549C82C3DD', |
| 71 | + }, |
| 72 | + }, |
| 73 | + Devnet: {}, |
| 74 | +}; |
| 75 | + |
| 76 | +export const NTT_TOKENS: NTTContract = { |
| 77 | + Mainnet: { |
| 78 | + USDC: { |
| 79 | + Ethereum: '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48', |
| 80 | + Fantom: '0x2F733095B80A04b38b0D10cC884524a3d09b836a', |
| 81 | + }, |
| 82 | + }, |
| 83 | + Testnet: { |
| 84 | + TEST_NTT: { |
| 85 | + Solana: '87r5ZS91Q2pQbFTvvneqs7y7mbtegtqMt4LDAS4g23Ax', |
| 86 | + Sepolia: '0x1d30E78B7C7fbbcef87ae6e97B5389b2e470CA4a', |
| 87 | + ArbitrumSepolia: '0x84A1Cb660B19eB0063EE5FD377eC14AAe3364d74', |
| 88 | + BaseSepolia: '0x7f430D4e7939D994C0955A01FC75D9DE33F12D11', |
| 89 | + OptimismSepolia: '0x0e15979a7a1eFAEf20312CA45A59eb141bF7E340', |
| 90 | + }, |
| 91 | + }, |
| 92 | + Devnet: {}, |
| 93 | +}; |
| 94 | + |
| 95 | +export const NTT_MANAGER_CONTRACT_ARRAY = |
| 96 | + convertNTTManagerContractToNTTContractArray(NTT_MANAGER_CONTRACT); |
| 97 | + |
| 98 | +export function NTT_SUPPORTED_CHAINS(network: Network, token: string): Chain[] { |
| 99 | + const contractDetails = NTT_MANAGER_CONTRACT[network][token]; |
| 100 | + if (!contractDetails) { |
| 101 | + return []; |
| 102 | + } |
| 103 | + |
| 104 | + return chains.filter((chain) => chain in contractDetails); |
| 105 | +} |
0 commit comments