chains.js 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. // NOTE: this file defines some examples of CAIP-2 and CAIP-10 identifiers.
  2. // The following listing does not pretend to be exhaustive or even accurate. It SHOULD NOT be used in production.
  3. const { ethers } = require('hardhat');
  4. const { mapValues } = require('./iterate');
  5. // EVM (https://axelarscan.io/resources/chains?type=evm)
  6. const ethereum = {
  7. Ethereum: '1',
  8. optimism: '10',
  9. binance: '56',
  10. Polygon: '137',
  11. Fantom: '250',
  12. fraxtal: '252',
  13. filecoin: '314',
  14. Moonbeam: '1284',
  15. centrifuge: '2031',
  16. kava: '2222',
  17. mantle: '5000',
  18. base: '8453',
  19. immutable: '13371',
  20. arbitrum: '42161',
  21. celo: '42220',
  22. Avalanche: '43114',
  23. linea: '59144',
  24. blast: '81457',
  25. scroll: '534352',
  26. aurora: '1313161554',
  27. };
  28. // Cosmos (https://axelarscan.io/resources/chains?type=cosmos)
  29. const cosmos = {
  30. Axelarnet: 'axelar-dojo-1',
  31. osmosis: 'osmosis-1',
  32. cosmoshub: 'cosmoshub-4',
  33. juno: 'juno-1',
  34. 'e-money': 'emoney-3',
  35. injective: 'injective-1',
  36. crescent: 'crescent-1',
  37. kujira: 'kaiyo-1',
  38. 'secret-snip': 'secret-4',
  39. secret: 'secret-4',
  40. sei: 'pacific-1',
  41. stargaze: 'stargaze-1',
  42. assetmantle: 'mantle-1',
  43. fetch: 'fetchhub-4',
  44. ki: 'kichain-2',
  45. evmos: 'evmos_9001-2',
  46. aura: 'xstaxy-1',
  47. comdex: 'comdex-1',
  48. persistence: 'core-1',
  49. regen: 'regen-1',
  50. umee: 'umee-1',
  51. agoric: 'agoric-3',
  52. xpla: 'dimension_37-1',
  53. acre: 'acre_9052-1',
  54. stride: 'stride-1',
  55. carbon: 'carbon-1',
  56. sommelier: 'sommelier-3',
  57. neutron: 'neutron-1',
  58. rebus: 'reb_1111-1',
  59. archway: 'archway-1',
  60. provenance: 'pio-mainnet-1',
  61. ixo: 'ixo-5',
  62. migaloo: 'migaloo-1',
  63. teritori: 'teritori-1',
  64. haqq: 'haqq_11235-1',
  65. celestia: 'celestia',
  66. ojo: 'agamotto',
  67. chihuahua: 'chihuahua-1',
  68. saga: 'ssc-1',
  69. dymension: 'dymension_1100-1',
  70. fxcore: 'fxcore',
  71. c4e: 'perun-1',
  72. bitsong: 'bitsong-2b',
  73. nolus: 'pirin-1',
  74. lava: 'lava-mainnet-1',
  75. 'terra-2': 'phoenix-1',
  76. terra: 'columbus-5',
  77. };
  78. const makeCAIP = ({ namespace, reference, account }) => ({
  79. namespace,
  80. reference,
  81. account,
  82. caip2: `${namespace}:${reference}`,
  83. caip10: `${namespace}:${reference}:${account}`,
  84. toCaip10: other => `${namespace}:${reference}:${ethers.getAddress(other.target ?? other.address ?? other)}`,
  85. });
  86. module.exports = {
  87. CHAINS: mapValues(
  88. Object.assign(
  89. mapValues(ethereum, reference => ({
  90. namespace: 'eip155',
  91. reference,
  92. account: ethers.Wallet.createRandom().address,
  93. })),
  94. mapValues(cosmos, reference => ({
  95. namespace: 'cosmos',
  96. reference,
  97. account: ethers.encodeBase58(ethers.randomBytes(32)),
  98. })),
  99. ),
  100. makeCAIP,
  101. ),
  102. getLocalCAIP: account =>
  103. ethers.provider.getNetwork().then(({ chainId }) => makeCAIP({ namespace: 'eip155', reference: chainId, account })),
  104. };