diff --git a/.changeset/large-pens-search.md b/.changeset/large-pens-search.md new file mode 100644 index 0000000000..cdaa0cca05 --- /dev/null +++ b/.changeset/large-pens-search.md @@ -0,0 +1,5 @@ +--- +"viem": minor +--- + +Added `extractChain` utility. diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md index 4f6b5f9b49..aef7fb0b9c 100644 --- a/.github/CONTRIBUTING.md +++ b/.github/CONTRIBUTING.md @@ -262,7 +262,7 @@ Example: ```ts // src/chains/definitions/example.ts -import { defineChain } from '../../utils/chain.js' +import { defineChain } from '../../utils/chain/defineChain.js' export const mainnet = /*#__PURE__*/ defineChain({ id: 1, diff --git a/site/.vitepress/sidebar.ts b/site/.vitepress/sidebar.ts index 4331488e8d..f1e1e31d96 100644 --- a/site/.vitepress/sidebar.ts +++ b/site/.vitepress/sidebar.ts @@ -645,6 +645,15 @@ export const sidebar: DefaultTheme.Sidebar = { }, ], }, + { + text: 'Chain', + items: [ + { + text: 'extractChain', + link: '/docs/utilities/extractChain', + }, + ], + }, { text: 'Data', items: [ diff --git a/site/docs/clients/chains.md b/site/docs/clients/chains.md index 66e94f4d0b..b357abd5b6 100644 --- a/site/docs/clients/chains.md +++ b/site/docs/clients/chains.md @@ -361,3 +361,7 @@ const example = defineChain( } ) ``` + +## Utilities + +- [`extractChain`](/docs/utilities/extractChain): Extracts a type-safe chain by ID. \ No newline at end of file diff --git a/site/docs/utilities/extractChain.md b/site/docs/utilities/extractChain.md new file mode 100644 index 0000000000..71845597c7 --- /dev/null +++ b/site/docs/utilities/extractChain.md @@ -0,0 +1,63 @@ +# extractChain + +Extracts a type-safe chain by ID from a set of chains. + +## Usage + +```ts +import { extractChain } from 'viem' +import { mainnet, base, optimism, zora } from 'viem/chains' + +const optimism = extractChain({ + chains: [mainnet, base, optimism, zora], + id: 10, +}) + +optimism.id +// ^? (property) id: 10 +optimism.name +// ^? (property) name: "OP Mainnet" +``` + +It is also possible to use **all chains** from the `viem/chains` module: + +```ts +import { extractChain } from 'viem' +import { mainnet, base, optimism, zora } from 'viem/chains' // [!code --] +import * as chains from 'viem/chains' // [!code ++] + +const optimism = extractChain({ + chains: [mainnet, base, optimism, zora], // [!code --] + chains: Object.values(chains), // [!code ++] + id: 10, +}) + +optimism.id +// ^? (property) id: 10 +optimism.name +// ^? (property) name: "OP Mainnet" +``` + +::: warning +By importing all chains from `viem/chains`, this will significantly increase the size of your bundle. It is only recommended to use this method where bundle size is not a concern (ie. server-side, scripts, etc). +::: + +## Returns + +- **Type:** `Chain` (inferred) + +The extracted chain. + +## Parameters + +### chains + +- **Type:** `readonly Chain[]` + +The set of chains where the chain will be extracted from. + +### id + +- **Type:** `number` + +The ID of the chain to extract. \ No newline at end of file diff --git a/src/actions/ens/getEnsAddress.ts b/src/actions/ens/getEnsAddress.ts index 3610da9640..2549430aff 100644 --- a/src/actions/ens/getEnsAddress.ts +++ b/src/actions/ens/getEnsAddress.ts @@ -20,7 +20,7 @@ import { import { type GetChainContractAddressErrorType, getChainContractAddress, -} from '../../utils/chain.js' +} from '../../utils/chain/getChainContractAddress.js' import { type TrimErrorType, trim } from '../../utils/data/trim.js' import { type ToHexErrorType, toHex } from '../../utils/encoding/toHex.js' import { isNullUniversalResolverError } from '../../utils/ens/errors.js' diff --git a/src/actions/ens/getEnsName.ts b/src/actions/ens/getEnsName.ts index 087e44b153..afa70ab43a 100644 --- a/src/actions/ens/getEnsName.ts +++ b/src/actions/ens/getEnsName.ts @@ -9,7 +9,7 @@ import type { Prettify } from '../../types/utils.js' import { type GetChainContractAddressErrorType, getChainContractAddress, -} from '../../utils/chain.js' +} from '../../utils/chain/getChainContractAddress.js' import { type ToHexErrorType, toHex } from '../../utils/encoding/toHex.js' import { isNullUniversalResolverError } from '../../utils/ens/errors.js' import { diff --git a/src/actions/ens/getEnsResolver.ts b/src/actions/ens/getEnsResolver.ts index 6db25d585f..a33726b894 100644 --- a/src/actions/ens/getEnsResolver.ts +++ b/src/actions/ens/getEnsResolver.ts @@ -8,7 +8,7 @@ import type { Prettify } from '../../types/utils.js' import { type GetChainContractAddressErrorType, getChainContractAddress, -} from '../../utils/chain.js' +} from '../../utils/chain/getChainContractAddress.js' import { type ToHexErrorType, toHex } from '../../utils/encoding/toHex.js' import { type PacketToBytesErrorType, diff --git a/src/actions/ens/getEnsText.ts b/src/actions/ens/getEnsText.ts index 831243f6bb..5429706d67 100644 --- a/src/actions/ens/getEnsText.ts +++ b/src/actions/ens/getEnsText.ts @@ -19,7 +19,7 @@ import { import { type GetChainContractAddressErrorType, getChainContractAddress, -} from '../../utils/chain.js' +} from '../../utils/chain/getChainContractAddress.js' import { type ToHexErrorType, toHex } from '../../utils/encoding/toHex.js' import { isNullUniversalResolverError } from '../../utils/ens/errors.js' import { type NamehashErrorType, namehash } from '../../utils/ens/namehash.js' diff --git a/src/actions/public/call.ts b/src/actions/public/call.ts index af4a4a9192..a6b2536746 100644 --- a/src/actions/public/call.ts +++ b/src/actions/public/call.ts @@ -37,7 +37,7 @@ import type { RequestErrorType } from '../../utils/buildRequest.js' import { type GetChainContractAddressErrorType, getChainContractAddress, -} from '../../utils/chain.js' +} from '../../utils/chain/getChainContractAddress.js' import { type NumberToHexErrorType, numberToHex, diff --git a/src/actions/public/multicall.ts b/src/actions/public/multicall.ts index 30004309d7..d4d2acd313 100644 --- a/src/actions/public/multicall.ts +++ b/src/actions/public/multicall.ts @@ -25,7 +25,7 @@ import { import { type GetChainContractAddressErrorType, getChainContractAddress, -} from '../../utils/chain.js' +} from '../../utils/chain/getChainContractAddress.js' import { type GetContractErrorReturnType, getContractError, diff --git a/src/actions/test/sendUnsignedTransaction.test.ts b/src/actions/test/sendUnsignedTransaction.test.ts index 32b5f45c60..a4c22ef81c 100644 --- a/src/actions/test/sendUnsignedTransaction.test.ts +++ b/src/actions/test/sendUnsignedTransaction.test.ts @@ -4,7 +4,7 @@ import { accounts, address } from '~test/src/constants.js' import { publicClient, testClient } from '~test/src/utils.js' import { celo } from '../../chains/index.js' import { createTestClient } from '../../clients/createTestClient.js' -import { defineChain } from '../../utils/chain.js' +import { defineChain } from '../../utils/chain/defineChain.js' import { parseEther } from '../../utils/unit/parseEther.js' import { getBalance } from '../public/getBalance.js' diff --git a/src/actions/wallet/sendTransaction.test.ts b/src/actions/wallet/sendTransaction.test.ts index 48dc54c7ac..e1d5ce1816 100644 --- a/src/actions/wallet/sendTransaction.test.ts +++ b/src/actions/wallet/sendTransaction.test.ts @@ -14,7 +14,7 @@ import { createWalletClient } from '../../clients/createWalletClient.js' import { http } from '../../clients/transports/http.js' import { type Hex } from '../../types/misc.js' import { type TransactionSerializable } from '../../types/transaction.js' -import { defineChain } from '../../utils/chain.js' +import { defineChain } from '../../utils/chain/defineChain.js' import { concatHex } from '../../utils/data/concat.js' import { hexToNumber } from '../../utils/encoding/fromHex.js' import { toHex } from '../../utils/encoding/toHex.js' diff --git a/src/actions/wallet/sendTransaction.ts b/src/actions/wallet/sendTransaction.ts index a06366fbc9..97e6ec5127 100644 --- a/src/actions/wallet/sendTransaction.ts +++ b/src/actions/wallet/sendTransaction.ts @@ -22,7 +22,7 @@ import type { RequestErrorType } from '../../utils/buildRequest.js' import { type AssertCurrentChainErrorType, assertCurrentChain, -} from '../../utils/chain.js' +} from '../../utils/chain/assertCurrentChain.js' import { type GetTransactionErrorReturnType, getTransactionError, diff --git a/src/actions/wallet/signTransaction.ts b/src/actions/wallet/signTransaction.ts index e1ece92ad5..08461aa600 100644 --- a/src/actions/wallet/signTransaction.ts +++ b/src/actions/wallet/signTransaction.ts @@ -21,7 +21,7 @@ import type { RequestErrorType } from '../../utils/buildRequest.js' import { type AssertCurrentChainErrorType, assertCurrentChain, -} from '../../utils/chain.js' +} from '../../utils/chain/assertCurrentChain.js' import type { NumberToHexErrorType } from '../../utils/encoding/toHex.js' import { type FormattedTransactionRequest, diff --git a/src/chains/definitions/arbitrum.ts b/src/chains/definitions/arbitrum.ts index 4437745230..7263a6a08c 100644 --- a/src/chains/definitions/arbitrum.ts +++ b/src/chains/definitions/arbitrum.ts @@ -1,4 +1,4 @@ -import { defineChain } from '../../utils/chain.js' +import { defineChain } from '../../utils/chain/defineChain.js' export const arbitrum = /*#__PURE__*/ defineChain({ id: 42_161, diff --git a/src/chains/definitions/arbitrumGoerli.ts b/src/chains/definitions/arbitrumGoerli.ts index 8dc7dd15df..235eda9c0f 100644 --- a/src/chains/definitions/arbitrumGoerli.ts +++ b/src/chains/definitions/arbitrumGoerli.ts @@ -1,4 +1,4 @@ -import { defineChain } from '../../utils/chain.js' +import { defineChain } from '../../utils/chain/defineChain.js' export const arbitrumGoerli = /*#__PURE__*/ defineChain({ id: 421_613, diff --git a/src/chains/definitions/arbitrumNova.ts b/src/chains/definitions/arbitrumNova.ts index 0e69cf7819..fd3caf0d7e 100644 --- a/src/chains/definitions/arbitrumNova.ts +++ b/src/chains/definitions/arbitrumNova.ts @@ -1,4 +1,4 @@ -import { defineChain } from '../../utils/chain.js' +import { defineChain } from '../../utils/chain/defineChain.js' export const arbitrumNova = /*#__PURE__*/ defineChain({ id: 42_170, diff --git a/src/chains/definitions/arbitrumSepolia.ts b/src/chains/definitions/arbitrumSepolia.ts index 85606edf97..a96ca57882 100644 --- a/src/chains/definitions/arbitrumSepolia.ts +++ b/src/chains/definitions/arbitrumSepolia.ts @@ -1,4 +1,4 @@ -import { defineChain } from '../../utils/chain.js' +import { defineChain } from '../../utils/chain/defineChain.js' export const arbitrumSepolia = /*#__PURE__*/ defineChain({ id: 421_614, diff --git a/src/chains/definitions/astarZkatana.ts b/src/chains/definitions/astarZkatana.ts index 1db7914cf3..3a74bb824c 100644 --- a/src/chains/definitions/astarZkatana.ts +++ b/src/chains/definitions/astarZkatana.ts @@ -1,4 +1,4 @@ -import { defineChain } from '../../utils/chain.js' +import { defineChain } from '../../utils/chain/defineChain.js' export const astarZkatana = /*#__PURE__*/ defineChain({ id: 1_261_120, diff --git a/src/chains/definitions/aurora.ts b/src/chains/definitions/aurora.ts index a563225e3c..b4141e768b 100644 --- a/src/chains/definitions/aurora.ts +++ b/src/chains/definitions/aurora.ts @@ -1,4 +1,4 @@ -import { defineChain } from '../../utils/chain.js' +import { defineChain } from '../../utils/chain/defineChain.js' export const aurora = /*#__PURE__*/ defineChain({ id: 1313161554, diff --git a/src/chains/definitions/auroraTestnet.ts b/src/chains/definitions/auroraTestnet.ts index 6ba84697d6..a1219f8f72 100644 --- a/src/chains/definitions/auroraTestnet.ts +++ b/src/chains/definitions/auroraTestnet.ts @@ -1,4 +1,4 @@ -import { defineChain } from '../../utils/chain.js' +import { defineChain } from '../../utils/chain/defineChain.js' export const auroraTestnet = /*#__PURE__*/ defineChain({ id: 1313161555, diff --git a/src/chains/definitions/avalanche.ts b/src/chains/definitions/avalanche.ts index 1255aac91a..bbda48435b 100644 --- a/src/chains/definitions/avalanche.ts +++ b/src/chains/definitions/avalanche.ts @@ -1,4 +1,4 @@ -import { defineChain } from '../../utils/chain.js' +import { defineChain } from '../../utils/chain/defineChain.js' export const avalanche = /*#__PURE__*/ defineChain({ id: 43_114, diff --git a/src/chains/definitions/avalancheFuji.ts b/src/chains/definitions/avalancheFuji.ts index 6870e3547c..027fc1f213 100644 --- a/src/chains/definitions/avalancheFuji.ts +++ b/src/chains/definitions/avalancheFuji.ts @@ -1,4 +1,4 @@ -import { defineChain } from '../../utils/chain.js' +import { defineChain } from '../../utils/chain/defineChain.js' export const avalancheFuji = /*#__PURE__*/ defineChain({ id: 43_113, diff --git a/src/chains/definitions/base.ts b/src/chains/definitions/base.ts index 49c9e684e4..f7456b3fca 100644 --- a/src/chains/definitions/base.ts +++ b/src/chains/definitions/base.ts @@ -1,4 +1,4 @@ -import { defineChain } from '../../utils/chain.js' +import { defineChain } from '../../utils/chain/defineChain.js' import { formattersOptimism } from '../optimism/formatters.js' export const base = /*#__PURE__*/ defineChain( diff --git a/src/chains/definitions/baseGoerli.ts b/src/chains/definitions/baseGoerli.ts index 15502fb1f8..8f560e4814 100644 --- a/src/chains/definitions/baseGoerli.ts +++ b/src/chains/definitions/baseGoerli.ts @@ -1,4 +1,4 @@ -import { defineChain } from '../../utils/chain.js' +import { defineChain } from '../../utils/chain/defineChain.js' import { formattersOptimism } from '../optimism/formatters.js' export const baseGoerli = /*#__PURE__*/ defineChain( diff --git a/src/chains/definitions/baseSepolia.ts b/src/chains/definitions/baseSepolia.ts index d0fed23c12..af38b733e7 100644 --- a/src/chains/definitions/baseSepolia.ts +++ b/src/chains/definitions/baseSepolia.ts @@ -1,4 +1,4 @@ -import { defineChain } from '../../utils/chain.js' +import { defineChain } from '../../utils/chain/defineChain.js' import { formattersOptimism } from '../optimism/formatters.js' export const baseSepolia = /*#__PURE__*/ defineChain( diff --git a/src/chains/definitions/bearNetworkChainMainnet.ts b/src/chains/definitions/bearNetworkChainMainnet.ts index 524a6c038c..501ed9f8d5 100644 --- a/src/chains/definitions/bearNetworkChainMainnet.ts +++ b/src/chains/definitions/bearNetworkChainMainnet.ts @@ -1,4 +1,4 @@ -import { defineChain } from '../../utils/chain.js' +import { defineChain } from '../../utils/chain/defineChain.js' export const bearNetworkChainMainnet = /*#__PURE__*/ defineChain({ id: 641230, diff --git a/src/chains/definitions/bearNetworkChainTestnet.ts b/src/chains/definitions/bearNetworkChainTestnet.ts index 27a4b49801..9fbffe5d53 100644 --- a/src/chains/definitions/bearNetworkChainTestnet.ts +++ b/src/chains/definitions/bearNetworkChainTestnet.ts @@ -1,4 +1,4 @@ -import { defineChain } from '../../utils/chain.js' +import { defineChain } from '../../utils/chain/defineChain.js' export const bearNetworkChainTestnet = /*#__PURE__*/ defineChain({ id: 751230, diff --git a/src/chains/definitions/boba.ts b/src/chains/definitions/boba.ts index 3d97cb7d36..e4e7783d83 100644 --- a/src/chains/definitions/boba.ts +++ b/src/chains/definitions/boba.ts @@ -1,4 +1,4 @@ -import { defineChain } from '../../utils/chain.js' +import { defineChain } from '../../utils/chain/defineChain.js' export const boba = /*#__PURE__*/ defineChain({ id: 288, diff --git a/src/chains/definitions/bronos.ts b/src/chains/definitions/bronos.ts index e574e53ba8..bf5ecf98e6 100644 --- a/src/chains/definitions/bronos.ts +++ b/src/chains/definitions/bronos.ts @@ -1,4 +1,4 @@ -import { defineChain } from '../../utils/chain.js' +import { defineChain } from '../../utils/chain/defineChain.js' export const bronos = /*#__PURE__*/ defineChain({ id: 1039, diff --git a/src/chains/definitions/bronosTestnet.ts b/src/chains/definitions/bronosTestnet.ts index 8c1b6d8676..d149a3ae7d 100644 --- a/src/chains/definitions/bronosTestnet.ts +++ b/src/chains/definitions/bronosTestnet.ts @@ -1,4 +1,4 @@ -import { defineChain } from '../../utils/chain.js' +import { defineChain } from '../../utils/chain/defineChain.js' export const bronosTestnet = /*#__PURE__*/ defineChain({ id: 1038, diff --git a/src/chains/definitions/bsc.ts b/src/chains/definitions/bsc.ts index 8fc4b4d7b0..dae6493839 100644 --- a/src/chains/definitions/bsc.ts +++ b/src/chains/definitions/bsc.ts @@ -1,4 +1,4 @@ -import { defineChain } from '../../utils/chain.js' +import { defineChain } from '../../utils/chain/defineChain.js' export const bsc = /*#__PURE__*/ defineChain({ id: 56, diff --git a/src/chains/definitions/bscTestnet.ts b/src/chains/definitions/bscTestnet.ts index ca071f200b..211a6c1599 100644 --- a/src/chains/definitions/bscTestnet.ts +++ b/src/chains/definitions/bscTestnet.ts @@ -1,4 +1,4 @@ -import { defineChain } from '../../utils/chain.js' +import { defineChain } from '../../utils/chain/defineChain.js' export const bscTestnet = /*#__PURE__*/ defineChain({ id: 97, diff --git a/src/chains/definitions/bxn.ts b/src/chains/definitions/bxn.ts index 3609703bab..c016b7b447 100644 --- a/src/chains/definitions/bxn.ts +++ b/src/chains/definitions/bxn.ts @@ -1,4 +1,4 @@ -import { defineChain } from '../../utils/chain.js' +import { defineChain } from '../../utils/chain/defineChain.js' export const bxn = /*#__PURE__*/ defineChain({ id: 4999, diff --git a/src/chains/definitions/bxnTestnet.ts b/src/chains/definitions/bxnTestnet.ts index 6ec8d3f3d0..a6a82cc4c5 100644 --- a/src/chains/definitions/bxnTestnet.ts +++ b/src/chains/definitions/bxnTestnet.ts @@ -1,4 +1,4 @@ -import { defineChain } from '../../utils/chain.js' +import { defineChain } from '../../utils/chain/defineChain.js' export const bxnTestnet = /*#__PURE__*/ defineChain({ id: 4777, diff --git a/src/chains/definitions/canto.ts b/src/chains/definitions/canto.ts index 1e479ad460..3f133f10eb 100644 --- a/src/chains/definitions/canto.ts +++ b/src/chains/definitions/canto.ts @@ -1,4 +1,4 @@ -import { defineChain } from '../../utils/chain.js' +import { defineChain } from '../../utils/chain/defineChain.js' export const canto = /*#__PURE__*/ defineChain({ id: 7_700, diff --git a/src/chains/definitions/celo.ts b/src/chains/definitions/celo.ts index 9020566c64..bb6ee0fd7c 100644 --- a/src/chains/definitions/celo.ts +++ b/src/chains/definitions/celo.ts @@ -1,4 +1,4 @@ -import { defineChain } from '../../utils/chain.js' +import { defineChain } from '../../utils/chain/defineChain.js' import { formattersCelo } from '../celo/formatters.js' import { serializersCelo } from '../celo/serializers.js' diff --git a/src/chains/definitions/celoAlfajores.ts b/src/chains/definitions/celoAlfajores.ts index ad43f2536d..decf09124e 100644 --- a/src/chains/definitions/celoAlfajores.ts +++ b/src/chains/definitions/celoAlfajores.ts @@ -1,4 +1,4 @@ -import { defineChain } from '../../utils/chain.js' +import { defineChain } from '../../utils/chain/defineChain.js' import { formattersCelo } from '../celo/formatters.js' import { serializersCelo } from '../celo/serializers.js' diff --git a/src/chains/definitions/celoCannoli.ts b/src/chains/definitions/celoCannoli.ts index d83a2cc8a7..23fdffb8b4 100644 --- a/src/chains/definitions/celoCannoli.ts +++ b/src/chains/definitions/celoCannoli.ts @@ -1,4 +1,4 @@ -import { defineChain } from '../../utils/chain.js' +import { defineChain } from '../../utils/chain/defineChain.js' import { formattersCelo } from '../celo/formatters.js' import { serializersCelo } from '../celo/serializers.js' diff --git a/src/chains/definitions/classic.ts b/src/chains/definitions/classic.ts index dd60f9c5dd..145e70371c 100644 --- a/src/chains/definitions/classic.ts +++ b/src/chains/definitions/classic.ts @@ -1,4 +1,4 @@ -import { defineChain } from '../../utils/chain.js' +import { defineChain } from '../../utils/chain/defineChain.js' export const classic = /*#__PURE__*/ defineChain({ id: 61, diff --git a/src/chains/definitions/confluxESpace.ts b/src/chains/definitions/confluxESpace.ts index e10716b843..de9ad71683 100644 --- a/src/chains/definitions/confluxESpace.ts +++ b/src/chains/definitions/confluxESpace.ts @@ -1,4 +1,4 @@ -import { defineChain } from '../../utils/chain.js' +import { defineChain } from '../../utils/chain/defineChain.js' export const confluxESpace = /*#__PURE__*/ defineChain({ id: 1_030, diff --git a/src/chains/definitions/coreDao.ts b/src/chains/definitions/coreDao.ts index c3e3971d83..b8632c8402 100644 --- a/src/chains/definitions/coreDao.ts +++ b/src/chains/definitions/coreDao.ts @@ -1,4 +1,4 @@ -import { defineChain } from '../../utils/chain.js' +import { defineChain } from '../../utils/chain/defineChain.js' export const coreDao = /*#__PURE__*/ defineChain({ id: 1116, diff --git a/src/chains/definitions/cronos.ts b/src/chains/definitions/cronos.ts index e24c93fb85..287f079502 100644 --- a/src/chains/definitions/cronos.ts +++ b/src/chains/definitions/cronos.ts @@ -1,4 +1,4 @@ -import { defineChain } from '../../utils/chain.js' +import { defineChain } from '../../utils/chain/defineChain.js' export const cronos = /*#__PURE__*/ defineChain({ id: 25, diff --git a/src/chains/definitions/cronosTestnet.ts b/src/chains/definitions/cronosTestnet.ts index 5dad145746..625385e34f 100644 --- a/src/chains/definitions/cronosTestnet.ts +++ b/src/chains/definitions/cronosTestnet.ts @@ -1,4 +1,4 @@ -import { defineChain } from '../../utils/chain.js' +import { defineChain } from '../../utils/chain/defineChain.js' export const cronosTestnet = /*#__PURE__*/ defineChain({ id: 338, diff --git a/src/chains/definitions/crossbell.ts b/src/chains/definitions/crossbell.ts index edc4d385ef..2bfe88638b 100644 --- a/src/chains/definitions/crossbell.ts +++ b/src/chains/definitions/crossbell.ts @@ -1,4 +1,4 @@ -import { defineChain } from '../../utils/chain.js' +import { defineChain } from '../../utils/chain/defineChain.js' export const crossbell = /*#__PURE__*/ defineChain({ id: 3_737, diff --git a/src/chains/definitions/dfk.ts b/src/chains/definitions/dfk.ts index b30004f62f..d9d2feb615 100644 --- a/src/chains/definitions/dfk.ts +++ b/src/chains/definitions/dfk.ts @@ -1,4 +1,4 @@ -import { defineChain } from '../../utils/chain.js' +import { defineChain } from '../../utils/chain/defineChain.js' export const dfk = /*#__PURE__*/ defineChain({ id: 53_935, diff --git a/src/chains/definitions/dogechain.ts b/src/chains/definitions/dogechain.ts index 36642a425e..abd5122c96 100644 --- a/src/chains/definitions/dogechain.ts +++ b/src/chains/definitions/dogechain.ts @@ -1,4 +1,4 @@ -import { defineChain } from '../../utils/chain.js' +import { defineChain } from '../../utils/chain/defineChain.js' export const dogechain = /*#__PURE__*/ defineChain({ id: 2_000, diff --git a/src/chains/definitions/edgeware.ts b/src/chains/definitions/edgeware.ts index 48ff2fcc36..b079aa5c39 100644 --- a/src/chains/definitions/edgeware.ts +++ b/src/chains/definitions/edgeware.ts @@ -1,4 +1,4 @@ -import { defineChain } from '../../utils/chain.js' +import { defineChain } from '../../utils/chain/defineChain.js' export const edgeware = /*#__PURE__*/ defineChain({ id: 2021, diff --git a/src/chains/definitions/edgewareTestnet.ts b/src/chains/definitions/edgewareTestnet.ts index 87cedd9c6d..b4f125edca 100644 --- a/src/chains/definitions/edgewareTestnet.ts +++ b/src/chains/definitions/edgewareTestnet.ts @@ -1,4 +1,4 @@ -import { defineChain } from '../../utils/chain.js' +import { defineChain } from '../../utils/chain/defineChain.js' export const edgewareTestnet = /*#__PURE__*/ defineChain({ id: 2022, diff --git a/src/chains/definitions/ekta.ts b/src/chains/definitions/ekta.ts index 68cbff0642..48a92a8f5a 100644 --- a/src/chains/definitions/ekta.ts +++ b/src/chains/definitions/ekta.ts @@ -1,4 +1,4 @@ -import { defineChain } from '../../utils/chain.js' +import { defineChain } from '../../utils/chain/defineChain.js' export const ekta = /*#__PURE__*/ defineChain({ id: 1994, diff --git a/src/chains/definitions/ektaTestnet.ts b/src/chains/definitions/ektaTestnet.ts index 8df4e2d7bc..fd9adb98fc 100644 --- a/src/chains/definitions/ektaTestnet.ts +++ b/src/chains/definitions/ektaTestnet.ts @@ -1,4 +1,4 @@ -import { defineChain } from '../../utils/chain.js' +import { defineChain } from '../../utils/chain/defineChain.js' export const ektaTestnet = /*#__PURE__*/ defineChain({ id: 1004, diff --git a/src/chains/definitions/eon.ts b/src/chains/definitions/eon.ts index 629bd438f2..c9bfaf6db1 100644 --- a/src/chains/definitions/eon.ts +++ b/src/chains/definitions/eon.ts @@ -1,4 +1,4 @@ -import { defineChain } from '../../utils/chain.js' +import { defineChain } from '../../utils/chain/defineChain.js' export const eon = /*#__PURE__*/ defineChain({ id: 7_332, diff --git a/src/chains/definitions/eos.ts b/src/chains/definitions/eos.ts index 2fd288affd..3641d160e2 100644 --- a/src/chains/definitions/eos.ts +++ b/src/chains/definitions/eos.ts @@ -1,4 +1,4 @@ -import { defineChain } from '../../utils/chain.js' +import { defineChain } from '../../utils/chain/defineChain.js' export const eos = /*#__PURE__*/ defineChain({ id: 17777, diff --git a/src/chains/definitions/eosTestnet.ts b/src/chains/definitions/eosTestnet.ts index c57cc27bb1..300188679c 100644 --- a/src/chains/definitions/eosTestnet.ts +++ b/src/chains/definitions/eosTestnet.ts @@ -1,4 +1,4 @@ -import { defineChain } from '../../utils/chain.js' +import { defineChain } from '../../utils/chain/defineChain.js' export const eosTestnet = /*#__PURE__*/ defineChain({ id: 15557, diff --git a/src/chains/definitions/evmos.ts b/src/chains/definitions/evmos.ts index fb7ec0c4e3..623e3222cd 100644 --- a/src/chains/definitions/evmos.ts +++ b/src/chains/definitions/evmos.ts @@ -1,4 +1,4 @@ -import { defineChain } from '../../utils/chain.js' +import { defineChain } from '../../utils/chain/defineChain.js' export const evmos = /*#__PURE__*/ defineChain({ id: 9_001, diff --git a/src/chains/definitions/evmosTestnet.ts b/src/chains/definitions/evmosTestnet.ts index 7fa37735aa..9cf702a7b2 100644 --- a/src/chains/definitions/evmosTestnet.ts +++ b/src/chains/definitions/evmosTestnet.ts @@ -1,4 +1,4 @@ -import { defineChain } from '../../utils/chain.js' +import { defineChain } from '../../utils/chain/defineChain.js' export const evmosTestnet = /*#__PURE__*/ defineChain({ id: 9_000, diff --git a/src/chains/definitions/fantom.ts b/src/chains/definitions/fantom.ts index 07b67b3521..7d6aa8bb7c 100644 --- a/src/chains/definitions/fantom.ts +++ b/src/chains/definitions/fantom.ts @@ -1,4 +1,4 @@ -import { defineChain } from '../../utils/chain.js' +import { defineChain } from '../../utils/chain/defineChain.js' export const fantom = /*#__PURE__*/ defineChain({ id: 250, diff --git a/src/chains/definitions/fantomTestnet.ts b/src/chains/definitions/fantomTestnet.ts index 8c1738e4bf..0cf399ac2d 100644 --- a/src/chains/definitions/fantomTestnet.ts +++ b/src/chains/definitions/fantomTestnet.ts @@ -1,4 +1,4 @@ -import { defineChain } from '../../utils/chain.js' +import { defineChain } from '../../utils/chain/defineChain.js' export const fantomTestnet = /*#__PURE__*/ defineChain({ id: 4_002, diff --git a/src/chains/definitions/fibo.ts b/src/chains/definitions/fibo.ts index 6976cfcebb..6ad8cc22fa 100644 --- a/src/chains/definitions/fibo.ts +++ b/src/chains/definitions/fibo.ts @@ -1,4 +1,4 @@ -import { defineChain } from '../../utils/chain.js' +import { defineChain } from '../../utils/chain/defineChain.js' export const fibo = /*#__PURE__*/ defineChain({ id: 12306, diff --git a/src/chains/definitions/filecoin.ts b/src/chains/definitions/filecoin.ts index 76de32ec4e..b2bb813312 100644 --- a/src/chains/definitions/filecoin.ts +++ b/src/chains/definitions/filecoin.ts @@ -1,4 +1,4 @@ -import { defineChain } from '../../utils/chain.js' +import { defineChain } from '../../utils/chain/defineChain.js' export const filecoin = /*#__PURE__*/ defineChain({ id: 314, diff --git a/src/chains/definitions/filecoinCalibration.ts b/src/chains/definitions/filecoinCalibration.ts index dba4d1c1c4..e456f7dd27 100644 --- a/src/chains/definitions/filecoinCalibration.ts +++ b/src/chains/definitions/filecoinCalibration.ts @@ -1,4 +1,4 @@ -import { defineChain } from '../../utils/chain.js' +import { defineChain } from '../../utils/chain/defineChain.js' export const filecoinCalibration = /*#__PURE__*/ defineChain({ id: 314_159, diff --git a/src/chains/definitions/filecoinHyperspace.ts b/src/chains/definitions/filecoinHyperspace.ts index 35f15c06ce..dc53d9bfa9 100644 --- a/src/chains/definitions/filecoinHyperspace.ts +++ b/src/chains/definitions/filecoinHyperspace.ts @@ -1,4 +1,4 @@ -import { defineChain } from '../../utils/chain.js' +import { defineChain } from '../../utils/chain/defineChain.js' export const filecoinHyperspace = /*#__PURE__*/ defineChain({ id: 314_1, diff --git a/src/chains/definitions/flare.ts b/src/chains/definitions/flare.ts index ae2772ccf5..07700edddc 100644 --- a/src/chains/definitions/flare.ts +++ b/src/chains/definitions/flare.ts @@ -1,4 +1,4 @@ -import { defineChain } from '../../utils/chain.js' +import { defineChain } from '../../utils/chain/defineChain.js' export const flare = /*#__PURE__*/ defineChain({ id: 14, diff --git a/src/chains/definitions/flareTestnet.ts b/src/chains/definitions/flareTestnet.ts index 5efec8f7e8..6367639bbe 100644 --- a/src/chains/definitions/flareTestnet.ts +++ b/src/chains/definitions/flareTestnet.ts @@ -1,4 +1,4 @@ -import { defineChain } from '../../utils/chain.js' +import { defineChain } from '../../utils/chain/defineChain.js' export const flareTestnet = /*#__PURE__*/ defineChain({ id: 114, diff --git a/src/chains/definitions/foundry.ts b/src/chains/definitions/foundry.ts index fe87279cac..986899d48b 100644 --- a/src/chains/definitions/foundry.ts +++ b/src/chains/definitions/foundry.ts @@ -1,4 +1,4 @@ -import { defineChain } from '../../utils/chain.js' +import { defineChain } from '../../utils/chain/defineChain.js' export const foundry = /*#__PURE__*/ defineChain({ id: 31_337, diff --git a/src/chains/definitions/fuse.ts b/src/chains/definitions/fuse.ts index 7bbd01f71c..a37e4c7f81 100644 --- a/src/chains/definitions/fuse.ts +++ b/src/chains/definitions/fuse.ts @@ -1,4 +1,4 @@ -import { defineChain } from '../../utils/chain.js' +import { defineChain } from '../../utils/chain/defineChain.js' export const fuse = /*#__PURE__*/ defineChain({ id: 122, diff --git a/src/chains/definitions/fuseSparknet.ts b/src/chains/definitions/fuseSparknet.ts index b9178109f0..02314aff2c 100644 --- a/src/chains/definitions/fuseSparknet.ts +++ b/src/chains/definitions/fuseSparknet.ts @@ -1,4 +1,4 @@ -import { defineChain } from '../../utils/chain.js' +import { defineChain } from '../../utils/chain/defineChain.js' export const fuseSparknet = /*#__PURE__*/ defineChain({ id: 123, diff --git a/src/chains/definitions/gnosis.ts b/src/chains/definitions/gnosis.ts index 8bfd6b6805..afb0550382 100644 --- a/src/chains/definitions/gnosis.ts +++ b/src/chains/definitions/gnosis.ts @@ -1,4 +1,4 @@ -import { defineChain } from '../../utils/chain.js' +import { defineChain } from '../../utils/chain/defineChain.js' export const gnosis = /*#__PURE__*/ defineChain({ id: 100, diff --git a/src/chains/definitions/gnosisChiado.ts b/src/chains/definitions/gnosisChiado.ts index 96a2a7c4db..c9a572e8af 100644 --- a/src/chains/definitions/gnosisChiado.ts +++ b/src/chains/definitions/gnosisChiado.ts @@ -1,4 +1,4 @@ -import { defineChain } from '../../utils/chain.js' +import { defineChain } from '../../utils/chain/defineChain.js' export const gnosisChiado = /*#__PURE__*/ defineChain({ id: 10_200, diff --git a/src/chains/definitions/gobi.ts b/src/chains/definitions/gobi.ts index b1e24d07a7..9b495c7d6a 100644 --- a/src/chains/definitions/gobi.ts +++ b/src/chains/definitions/gobi.ts @@ -1,4 +1,4 @@ -import { defineChain } from '../../utils/chain.js' +import { defineChain } from '../../utils/chain/defineChain.js' export const gobi = /*#__PURE__*/ defineChain({ id: 1_663, diff --git a/src/chains/definitions/goerli.ts b/src/chains/definitions/goerli.ts index 81a615930c..72beb4b5c4 100644 --- a/src/chains/definitions/goerli.ts +++ b/src/chains/definitions/goerli.ts @@ -1,4 +1,4 @@ -import { defineChain } from '../../utils/chain.js' +import { defineChain } from '../../utils/chain/defineChain.js' export const goerli = /*#__PURE__*/ defineChain({ id: 5, diff --git a/src/chains/definitions/haqqMainnet.ts b/src/chains/definitions/haqqMainnet.ts index aabf179ec3..aacb40aca9 100644 --- a/src/chains/definitions/haqqMainnet.ts +++ b/src/chains/definitions/haqqMainnet.ts @@ -1,4 +1,4 @@ -import { defineChain } from '../../utils/chain.js' +import { defineChain } from '../../utils/chain/defineChain.js' export const haqqMainnet = /*#__PURE__*/ defineChain({ id: 11235, diff --git a/src/chains/definitions/haqqTestedge2.ts b/src/chains/definitions/haqqTestedge2.ts index 7a7b0329ae..eb8167e580 100644 --- a/src/chains/definitions/haqqTestedge2.ts +++ b/src/chains/definitions/haqqTestedge2.ts @@ -1,4 +1,4 @@ -import { defineChain } from '../../utils/chain.js' +import { defineChain } from '../../utils/chain/defineChain.js' export const haqqTestedge2 = /*#__PURE__*/ defineChain({ id: 54211, diff --git a/src/chains/definitions/hardhat.ts b/src/chains/definitions/hardhat.ts index ad64cff262..287690bf98 100644 --- a/src/chains/definitions/hardhat.ts +++ b/src/chains/definitions/hardhat.ts @@ -1,4 +1,4 @@ -import { defineChain } from '../../utils/chain.js' +import { defineChain } from '../../utils/chain/defineChain.js' export const hardhat = /*#__PURE__*/ defineChain({ id: 31_337, diff --git a/src/chains/definitions/harmonyOne.ts b/src/chains/definitions/harmonyOne.ts index 09a5389b1a..fe9a0c9f7f 100644 --- a/src/chains/definitions/harmonyOne.ts +++ b/src/chains/definitions/harmonyOne.ts @@ -1,4 +1,4 @@ -import { defineChain } from '../../utils/chain.js' +import { defineChain } from '../../utils/chain/defineChain.js' export const harmonyOne = /*#__PURE__*/ defineChain({ id: 1_666_600_000, diff --git a/src/chains/definitions/holesky.ts b/src/chains/definitions/holesky.ts index e7284788a1..7582d9c883 100644 --- a/src/chains/definitions/holesky.ts +++ b/src/chains/definitions/holesky.ts @@ -1,4 +1,4 @@ -import { defineChain } from '../../utils/chain.js' +import { defineChain } from '../../utils/chain/defineChain.js' export const holesky = /*#__PURE__*/ defineChain({ id: 17000, diff --git a/src/chains/definitions/iotex.ts b/src/chains/definitions/iotex.ts index 9ee2ba1f15..8e9f1eee48 100644 --- a/src/chains/definitions/iotex.ts +++ b/src/chains/definitions/iotex.ts @@ -1,4 +1,4 @@ -import { defineChain } from '../../utils/chain.js' +import { defineChain } from '../../utils/chain/defineChain.js' export const iotex = /*#__PURE__*/ defineChain({ id: 4_689, diff --git a/src/chains/definitions/iotexTestnet.ts b/src/chains/definitions/iotexTestnet.ts index 3d8d34c8e3..cd6a4ac708 100644 --- a/src/chains/definitions/iotexTestnet.ts +++ b/src/chains/definitions/iotexTestnet.ts @@ -1,4 +1,4 @@ -import { defineChain } from '../../utils/chain.js' +import { defineChain } from '../../utils/chain/defineChain.js' export const iotexTestnet = /*#__PURE__*/ defineChain({ id: 4_690, diff --git a/src/chains/definitions/klaytn.ts b/src/chains/definitions/klaytn.ts index db7248aa53..672c2783c9 100644 --- a/src/chains/definitions/klaytn.ts +++ b/src/chains/definitions/klaytn.ts @@ -1,4 +1,4 @@ -import { defineChain } from '../../utils/chain.js' +import { defineChain } from '../../utils/chain/defineChain.js' export const klaytn = /*#__PURE__*/ defineChain({ id: 8_217, diff --git a/src/chains/definitions/kroma.ts b/src/chains/definitions/kroma.ts index 30c67a153c..3b9256daec 100644 --- a/src/chains/definitions/kroma.ts +++ b/src/chains/definitions/kroma.ts @@ -1,4 +1,4 @@ -import { defineChain } from '../../utils/chain.js' +import { defineChain } from '../../utils/chain/defineChain.js' export const kroma = /*#__PURE__*/ defineChain({ id: 255, diff --git a/src/chains/definitions/kromaSepolia.ts b/src/chains/definitions/kromaSepolia.ts index 89477bb827..5fe2060249 100644 --- a/src/chains/definitions/kromaSepolia.ts +++ b/src/chains/definitions/kromaSepolia.ts @@ -1,4 +1,4 @@ -import { defineChain } from '../../utils/chain.js' +import { defineChain } from '../../utils/chain/defineChain.js' export const kromaSepolia = /*#__PURE__*/ defineChain({ id: 2358, diff --git a/src/chains/definitions/linea.ts b/src/chains/definitions/linea.ts index bb568233fd..85b0cdb38c 100644 --- a/src/chains/definitions/linea.ts +++ b/src/chains/definitions/linea.ts @@ -1,4 +1,4 @@ -import { defineChain } from '../../utils/chain.js' +import { defineChain } from '../../utils/chain/defineChain.js' export const linea = /*#__PURE__*/ defineChain({ id: 59_144, diff --git a/src/chains/definitions/lineaTestnet.ts b/src/chains/definitions/lineaTestnet.ts index c2e32a452a..52ad799241 100644 --- a/src/chains/definitions/lineaTestnet.ts +++ b/src/chains/definitions/lineaTestnet.ts @@ -1,4 +1,4 @@ -import { defineChain } from '../../utils/chain.js' +import { defineChain } from '../../utils/chain/defineChain.js' export const lineaTestnet = /*#__PURE__*/ defineChain({ id: 59_140, diff --git a/src/chains/definitions/localhost.ts b/src/chains/definitions/localhost.ts index ac7642b586..d7b7a8d3a4 100644 --- a/src/chains/definitions/localhost.ts +++ b/src/chains/definitions/localhost.ts @@ -1,4 +1,4 @@ -import { defineChain } from '../../utils/chain.js' +import { defineChain } from '../../utils/chain/defineChain.js' export const localhost = /*#__PURE__*/ defineChain({ id: 1_337, diff --git a/src/chains/definitions/mainnet.ts b/src/chains/definitions/mainnet.ts index e2b15eda2b..2dfabd334d 100644 --- a/src/chains/definitions/mainnet.ts +++ b/src/chains/definitions/mainnet.ts @@ -1,4 +1,4 @@ -import { defineChain } from '../../utils/chain.js' +import { defineChain } from '../../utils/chain/defineChain.js' export const mainnet = /*#__PURE__*/ defineChain({ id: 1, diff --git a/src/chains/definitions/manta.ts b/src/chains/definitions/manta.ts index ca6cb62b20..1c21268ce6 100644 --- a/src/chains/definitions/manta.ts +++ b/src/chains/definitions/manta.ts @@ -1,4 +1,4 @@ -import { defineChain } from '../../utils/chain.js' +import { defineChain } from '../../utils/chain/defineChain.js' export const manta = /*#__PURE__*/ defineChain({ id: 169, diff --git a/src/chains/definitions/mantaTestnet.ts b/src/chains/definitions/mantaTestnet.ts index ca1a6d258b..93676221ea 100644 --- a/src/chains/definitions/mantaTestnet.ts +++ b/src/chains/definitions/mantaTestnet.ts @@ -1,4 +1,4 @@ -import { defineChain } from '../../utils/chain.js' +import { defineChain } from '../../utils/chain/defineChain.js' export const mantaTestnet = /*#__PURE__*/ defineChain({ id: 3_441_005, diff --git a/src/chains/definitions/mantle.ts b/src/chains/definitions/mantle.ts index a8b2edaebe..d48fb9b036 100644 --- a/src/chains/definitions/mantle.ts +++ b/src/chains/definitions/mantle.ts @@ -1,4 +1,4 @@ -import { defineChain } from '../../utils/chain.js' +import { defineChain } from '../../utils/chain/defineChain.js' export const mantle = /*#__PURE__*/ defineChain({ id: 5000, diff --git a/src/chains/definitions/mantleTestnet.ts b/src/chains/definitions/mantleTestnet.ts index 8ccccb8c45..80b4626f66 100644 --- a/src/chains/definitions/mantleTestnet.ts +++ b/src/chains/definitions/mantleTestnet.ts @@ -1,4 +1,4 @@ -import { defineChain } from '../../utils/chain.js' +import { defineChain } from '../../utils/chain/defineChain.js' export const mantleTestnet = /*#__PURE__*/ defineChain({ id: 5001, diff --git a/src/chains/definitions/meter.ts b/src/chains/definitions/meter.ts index d72664ecbe..8e003e4271 100644 --- a/src/chains/definitions/meter.ts +++ b/src/chains/definitions/meter.ts @@ -1,4 +1,4 @@ -import { defineChain } from '../../utils/chain.js' +import { defineChain } from '../../utils/chain/defineChain.js' export const meter = /*#__PURE__*/ defineChain({ id: 82, diff --git a/src/chains/definitions/meterTestnet.ts b/src/chains/definitions/meterTestnet.ts index 9c7d1c1ffe..dfc084238a 100644 --- a/src/chains/definitions/meterTestnet.ts +++ b/src/chains/definitions/meterTestnet.ts @@ -1,4 +1,4 @@ -import { defineChain } from '../../utils/chain.js' +import { defineChain } from '../../utils/chain/defineChain.js' export const meterTestnet = /*#__PURE__*/ defineChain({ id: 83, diff --git a/src/chains/definitions/metis.ts b/src/chains/definitions/metis.ts index 8ea076e6fc..a175d21785 100644 --- a/src/chains/definitions/metis.ts +++ b/src/chains/definitions/metis.ts @@ -1,4 +1,4 @@ -import { defineChain } from '../../utils/chain.js' +import { defineChain } from '../../utils/chain/defineChain.js' export const metis = /*#__PURE__*/ defineChain({ id: 1_088, diff --git a/src/chains/definitions/metisGoerli.ts b/src/chains/definitions/metisGoerli.ts index e712a976fc..cc8c4ccd64 100644 --- a/src/chains/definitions/metisGoerli.ts +++ b/src/chains/definitions/metisGoerli.ts @@ -1,4 +1,4 @@ -import { defineChain } from '../../utils/chain.js' +import { defineChain } from '../../utils/chain/defineChain.js' export const metisGoerli = /*#__PURE__*/ defineChain({ id: 599, diff --git a/src/chains/definitions/mev.ts b/src/chains/definitions/mev.ts index bca1cece9e..df55ce47aa 100644 --- a/src/chains/definitions/mev.ts +++ b/src/chains/definitions/mev.ts @@ -1,4 +1,4 @@ -import { defineChain } from '../../utils/chain.js' +import { defineChain } from '../../utils/chain/defineChain.js' export const mev = /*#__PURE__*/ defineChain({ id: 7518, diff --git a/src/chains/definitions/mevTestnet.ts b/src/chains/definitions/mevTestnet.ts index 02713a952e..7de779b8f8 100644 --- a/src/chains/definitions/mevTestnet.ts +++ b/src/chains/definitions/mevTestnet.ts @@ -1,4 +1,4 @@ -import { defineChain } from '../../utils/chain.js' +import { defineChain } from '../../utils/chain/defineChain.js' export const mevTestnet = /*#__PURE__*/ defineChain({ id: 4759, diff --git a/src/chains/definitions/modeTestnet.ts b/src/chains/definitions/modeTestnet.ts index c2498b0213..9e4f488456 100644 --- a/src/chains/definitions/modeTestnet.ts +++ b/src/chains/definitions/modeTestnet.ts @@ -1,4 +1,4 @@ -import { defineChain } from '../../utils/chain.js' +import { defineChain } from '../../utils/chain/defineChain.js' export const modeTestnet = /*#__PURE__*/ defineChain({ id: 919, diff --git a/src/chains/definitions/moonbaseAlpha.ts b/src/chains/definitions/moonbaseAlpha.ts index 4f7d358767..87d82385e5 100644 --- a/src/chains/definitions/moonbaseAlpha.ts +++ b/src/chains/definitions/moonbaseAlpha.ts @@ -1,4 +1,4 @@ -import { defineChain } from '../../utils/chain.js' +import { defineChain } from '../../utils/chain/defineChain.js' export const moonbaseAlpha = /*#__PURE__*/ defineChain({ id: 1287, diff --git a/src/chains/definitions/moonbeam.ts b/src/chains/definitions/moonbeam.ts index b5e43689c1..77a5f05458 100644 --- a/src/chains/definitions/moonbeam.ts +++ b/src/chains/definitions/moonbeam.ts @@ -1,4 +1,4 @@ -import { defineChain } from '../../utils/chain.js' +import { defineChain } from '../../utils/chain/defineChain.js' export const moonbeam = /*#__PURE__*/ defineChain({ id: 1284, diff --git a/src/chains/definitions/moonbeamDev.ts b/src/chains/definitions/moonbeamDev.ts index 506e6f35e8..36daeca612 100644 --- a/src/chains/definitions/moonbeamDev.ts +++ b/src/chains/definitions/moonbeamDev.ts @@ -1,4 +1,4 @@ -import { defineChain } from '../../utils/chain.js' +import { defineChain } from '../../utils/chain/defineChain.js' export const moonbeamDev = /*#__PURE__*/ defineChain({ id: 1281, diff --git a/src/chains/definitions/moonriver.ts b/src/chains/definitions/moonriver.ts index 2a0a79cd42..a45cf32973 100644 --- a/src/chains/definitions/moonriver.ts +++ b/src/chains/definitions/moonriver.ts @@ -1,4 +1,4 @@ -import { defineChain } from '../../utils/chain.js' +import { defineChain } from '../../utils/chain/defineChain.js' export const moonriver = /*#__PURE__*/ defineChain({ id: 1285, diff --git a/src/chains/definitions/neonDevnet.ts b/src/chains/definitions/neonDevnet.ts index 65f59b1160..918e3da867 100644 --- a/src/chains/definitions/neonDevnet.ts +++ b/src/chains/definitions/neonDevnet.ts @@ -1,4 +1,4 @@ -import { defineChain } from '../../utils/chain.js' +import { defineChain } from '../../utils/chain/defineChain.js' export const neonDevnet = /*#__PURE__*/ defineChain({ id: 245_022_926, diff --git a/src/chains/definitions/nexi.ts b/src/chains/definitions/nexi.ts index 80150e893c..5c45277fa9 100644 --- a/src/chains/definitions/nexi.ts +++ b/src/chains/definitions/nexi.ts @@ -1,4 +1,4 @@ -import { defineChain } from '../../utils/chain.js' +import { defineChain } from '../../utils/chain/defineChain.js' export const nexi = /*#__PURE__*/ defineChain({ id: 4242, diff --git a/src/chains/definitions/nexilix.ts b/src/chains/definitions/nexilix.ts index bdb21e1731..35215ff504 100644 --- a/src/chains/definitions/nexilix.ts +++ b/src/chains/definitions/nexilix.ts @@ -1,4 +1,4 @@ -import { defineChain } from '../../utils/chain.js' +import { defineChain } from '../../utils/chain/defineChain.js' export const nexilix = /*#__PURE__*/ defineChain({ id: 240, diff --git a/src/chains/definitions/oasys.ts b/src/chains/definitions/oasys.ts index 160a493069..5124b88926 100644 --- a/src/chains/definitions/oasys.ts +++ b/src/chains/definitions/oasys.ts @@ -1,4 +1,4 @@ -import { defineChain } from '../../utils/chain.js' +import { defineChain } from '../../utils/chain/defineChain.js' export const oasys = /*#__PURE__*/ defineChain({ id: 248, diff --git a/src/chains/definitions/okc.ts b/src/chains/definitions/okc.ts index 0177ccef9d..49720998ea 100644 --- a/src/chains/definitions/okc.ts +++ b/src/chains/definitions/okc.ts @@ -1,4 +1,4 @@ -import { defineChain } from '../../utils/chain.js' +import { defineChain } from '../../utils/chain/defineChain.js' export const okc = /*#__PURE__*/ defineChain({ id: 66, diff --git a/src/chains/definitions/opBNB.ts b/src/chains/definitions/opBNB.ts index 77daba3f54..08a3d89471 100644 --- a/src/chains/definitions/opBNB.ts +++ b/src/chains/definitions/opBNB.ts @@ -1,4 +1,4 @@ -import { defineChain } from '../../utils/chain.js' +import { defineChain } from '../../utils/chain/defineChain.js' export const opBNB = /*#__PURE__*/ defineChain({ id: 204, diff --git a/src/chains/definitions/opBNBTestnet.ts b/src/chains/definitions/opBNBTestnet.ts index 1ccabe6da6..ba8858e7e2 100644 --- a/src/chains/definitions/opBNBTestnet.ts +++ b/src/chains/definitions/opBNBTestnet.ts @@ -1,4 +1,4 @@ -import { defineChain } from '../../utils/chain.js' +import { defineChain } from '../../utils/chain/defineChain.js' export const opBNBTestnet = /*#__PURE__*/ defineChain({ id: 5611, diff --git a/src/chains/definitions/optimism.ts b/src/chains/definitions/optimism.ts index 847e48134a..41346c6ca4 100644 --- a/src/chains/definitions/optimism.ts +++ b/src/chains/definitions/optimism.ts @@ -1,4 +1,4 @@ -import { defineChain } from '../../utils/chain.js' +import { defineChain } from '../../utils/chain/defineChain.js' import { formattersOptimism } from '../optimism/formatters.js' export const optimism = /*#__PURE__*/ defineChain( diff --git a/src/chains/definitions/optimismGoerli.ts b/src/chains/definitions/optimismGoerli.ts index 1f0f0b32f0..54af9c9201 100644 --- a/src/chains/definitions/optimismGoerli.ts +++ b/src/chains/definitions/optimismGoerli.ts @@ -1,4 +1,4 @@ -import { defineChain } from '../../utils/chain.js' +import { defineChain } from '../../utils/chain/defineChain.js' import { formattersOptimism } from '../optimism/formatters.js' export const optimismGoerli = /*#__PURE__*/ defineChain( diff --git a/src/chains/definitions/optimismSepolia.ts b/src/chains/definitions/optimismSepolia.ts index 1872b4ef44..4a0ba58e66 100644 --- a/src/chains/definitions/optimismSepolia.ts +++ b/src/chains/definitions/optimismSepolia.ts @@ -1,4 +1,4 @@ -import { defineChain } from '../../utils/chain.js' +import { defineChain } from '../../utils/chain/defineChain.js' import { formattersOptimism } from '../optimism/formatters.js' export const optimismSepolia = /*#__PURE__*/ defineChain( diff --git a/src/chains/definitions/plinga.ts b/src/chains/definitions/plinga.ts index 6a898b512b..2a2c108376 100644 --- a/src/chains/definitions/plinga.ts +++ b/src/chains/definitions/plinga.ts @@ -1,4 +1,4 @@ -import { defineChain } from '../../utils/chain.js' +import { defineChain } from '../../utils/chain/defineChain.js' export const plinga = /*#__PURE__*/ defineChain({ id: 242, diff --git a/src/chains/definitions/polygon.ts b/src/chains/definitions/polygon.ts index 28d52c11d2..c7fc785f09 100644 --- a/src/chains/definitions/polygon.ts +++ b/src/chains/definitions/polygon.ts @@ -1,4 +1,4 @@ -import { defineChain } from '../../utils/chain.js' +import { defineChain } from '../../utils/chain/defineChain.js' export const polygon = /*#__PURE__*/ defineChain({ id: 137, diff --git a/src/chains/definitions/polygonMumbai.ts b/src/chains/definitions/polygonMumbai.ts index d29be3bc53..508ed9e6cf 100644 --- a/src/chains/definitions/polygonMumbai.ts +++ b/src/chains/definitions/polygonMumbai.ts @@ -1,4 +1,4 @@ -import { defineChain } from '../../utils/chain.js' +import { defineChain } from '../../utils/chain/defineChain.js' export const polygonMumbai = /*#__PURE__*/ defineChain({ id: 80_001, diff --git a/src/chains/definitions/polygonZkEvm.ts b/src/chains/definitions/polygonZkEvm.ts index 368ad9db51..db2534ca5b 100644 --- a/src/chains/definitions/polygonZkEvm.ts +++ b/src/chains/definitions/polygonZkEvm.ts @@ -1,4 +1,4 @@ -import { defineChain } from '../../utils/chain.js' +import { defineChain } from '../../utils/chain/defineChain.js' export const polygonZkEvm = /*#__PURE__*/ defineChain({ id: 1101, diff --git a/src/chains/definitions/polygonZkEvmTestnet.ts b/src/chains/definitions/polygonZkEvmTestnet.ts index 0f86ea0729..40c338b3e2 100644 --- a/src/chains/definitions/polygonZkEvmTestnet.ts +++ b/src/chains/definitions/polygonZkEvmTestnet.ts @@ -1,4 +1,4 @@ -import { defineChain } from '../../utils/chain.js' +import { defineChain } from '../../utils/chain/defineChain.js' export const polygonZkEvmTestnet = /*#__PURE__*/ defineChain({ id: 1442, diff --git a/src/chains/definitions/pulsechain.ts b/src/chains/definitions/pulsechain.ts index 2fd13e1e8c..0f4df7b717 100644 --- a/src/chains/definitions/pulsechain.ts +++ b/src/chains/definitions/pulsechain.ts @@ -1,4 +1,4 @@ -import { defineChain } from '../../utils/chain.js' +import { defineChain } from '../../utils/chain/defineChain.js' export const pulsechain = /*#__PURE__*/ defineChain({ id: 369, diff --git a/src/chains/definitions/pulsechainV4.ts b/src/chains/definitions/pulsechainV4.ts index 61b888b6e1..97298528c9 100644 --- a/src/chains/definitions/pulsechainV4.ts +++ b/src/chains/definitions/pulsechainV4.ts @@ -1,4 +1,4 @@ -import { defineChain } from '../../utils/chain.js' +import { defineChain } from '../../utils/chain/defineChain.js' export const pulsechainV4 = /*#__PURE__*/ defineChain({ id: 943, diff --git a/src/chains/definitions/qMainnet.ts b/src/chains/definitions/qMainnet.ts index ebaadb1b6a..ac96265500 100644 --- a/src/chains/definitions/qMainnet.ts +++ b/src/chains/definitions/qMainnet.ts @@ -1,4 +1,4 @@ -import { defineChain } from '../../utils/chain.js' +import { defineChain } from '../../utils/chain/defineChain.js' export const qMainnet = /*#__PURE__*/ defineChain({ id: 35441, diff --git a/src/chains/definitions/qTestnet.ts b/src/chains/definitions/qTestnet.ts index 321854efc9..60b15a861d 100644 --- a/src/chains/definitions/qTestnet.ts +++ b/src/chains/definitions/qTestnet.ts @@ -1,4 +1,4 @@ -import { defineChain } from '../../utils/chain.js' +import { defineChain } from '../../utils/chain/defineChain.js' export const qTestnet = /*#__PURE__*/ defineChain({ id: 35443, diff --git a/src/chains/definitions/rollux.ts b/src/chains/definitions/rollux.ts index 59ce0438ca..cd20aa5251 100644 --- a/src/chains/definitions/rollux.ts +++ b/src/chains/definitions/rollux.ts @@ -1,4 +1,4 @@ -import { defineChain } from '../../utils/chain.js' +import { defineChain } from '../../utils/chain/defineChain.js' export const rollux = /*#__PURE__*/ defineChain({ id: 570, diff --git a/src/chains/definitions/rolluxTestnet.ts b/src/chains/definitions/rolluxTestnet.ts index 53f3678e1d..c66514ab7a 100644 --- a/src/chains/definitions/rolluxTestnet.ts +++ b/src/chains/definitions/rolluxTestnet.ts @@ -1,4 +1,4 @@ -import { defineChain } from '../../utils/chain.js' +import { defineChain } from '../../utils/chain/defineChain.js' export const rolluxTestnet = /*#__PURE__*/ defineChain({ id: 57000, diff --git a/src/chains/definitions/ronin.ts b/src/chains/definitions/ronin.ts index 3f808b722d..9a2272f9c9 100644 --- a/src/chains/definitions/ronin.ts +++ b/src/chains/definitions/ronin.ts @@ -1,4 +1,4 @@ -import { defineChain } from '../../utils/chain.js' +import { defineChain } from '../../utils/chain/defineChain.js' export const ronin = /*#__PURE__*/ defineChain({ id: 2020, diff --git a/src/chains/definitions/saigon.ts b/src/chains/definitions/saigon.ts index b171e47955..7f33b80eb2 100644 --- a/src/chains/definitions/saigon.ts +++ b/src/chains/definitions/saigon.ts @@ -1,4 +1,4 @@ -import { defineChain } from '../../utils/chain.js' +import { defineChain } from '../../utils/chain/defineChain.js' export const saigon = /*#__PURE__*/ defineChain({ id: 2021, diff --git a/src/chains/definitions/scroll.ts b/src/chains/definitions/scroll.ts index c4e47393f7..908678891b 100644 --- a/src/chains/definitions/scroll.ts +++ b/src/chains/definitions/scroll.ts @@ -1,4 +1,4 @@ -import { defineChain } from '../../utils/chain.js' +import { defineChain } from '../../utils/chain/defineChain.js' export const scroll = /*#__PURE__*/ defineChain({ id: 534_352, diff --git a/src/chains/definitions/scrollSepolia.ts b/src/chains/definitions/scrollSepolia.ts index ad8cac2cfa..2527b11f82 100644 --- a/src/chains/definitions/scrollSepolia.ts +++ b/src/chains/definitions/scrollSepolia.ts @@ -1,4 +1,4 @@ -import { defineChain } from '../../utils/chain.js' +import { defineChain } from '../../utils/chain/defineChain.js' export const scrollSepolia = /*#__PURE__*/ defineChain({ id: 534_351, diff --git a/src/chains/definitions/scrollTestnet.ts b/src/chains/definitions/scrollTestnet.ts index f76ddd1165..3391628216 100644 --- a/src/chains/definitions/scrollTestnet.ts +++ b/src/chains/definitions/scrollTestnet.ts @@ -1,4 +1,4 @@ -import { defineChain } from '../../utils/chain.js' +import { defineChain } from '../../utils/chain/defineChain.js' export const scrollTestnet = /*#__PURE__*/ defineChain({ id: 534_353, diff --git a/src/chains/definitions/sepolia.ts b/src/chains/definitions/sepolia.ts index 8ac0c61a32..f46584b43e 100644 --- a/src/chains/definitions/sepolia.ts +++ b/src/chains/definitions/sepolia.ts @@ -1,4 +1,4 @@ -import { defineChain } from '../../utils/chain.js' +import { defineChain } from '../../utils/chain/defineChain.js' export const sepolia = /*#__PURE__*/ defineChain({ id: 11_155_111, diff --git a/src/chains/definitions/shardeumSphinx.ts b/src/chains/definitions/shardeumSphinx.ts index 97276d1a53..d87bb46b11 100644 --- a/src/chains/definitions/shardeumSphinx.ts +++ b/src/chains/definitions/shardeumSphinx.ts @@ -1,4 +1,4 @@ -import { defineChain } from '../../utils/chain.js' +import { defineChain } from '../../utils/chain/defineChain.js' export const shardeumSphinx = /*#__PURE__*/ defineChain({ id: 8082, diff --git a/src/chains/definitions/skale/brawl.ts b/src/chains/definitions/skale/brawl.ts index 9f90559c57..96abde48e6 100644 --- a/src/chains/definitions/skale/brawl.ts +++ b/src/chains/definitions/skale/brawl.ts @@ -1,4 +1,4 @@ -import { defineChain } from '../../../utils/chain.js' +import { defineChain } from '../../../utils/chain/defineChain.js' export const skaleBlockBrawlers = /*#__PURE__*/ defineChain({ id: 391_845_894, diff --git a/src/chains/definitions/skale/calypso.ts b/src/chains/definitions/skale/calypso.ts index edbae3f8ae..81b9f676a8 100644 --- a/src/chains/definitions/skale/calypso.ts +++ b/src/chains/definitions/skale/calypso.ts @@ -1,4 +1,4 @@ -import { defineChain } from '../../../utils/chain.js' +import { defineChain } from '../../../utils/chain/defineChain.js' export const skaleCalypso = /*#__PURE__*/ defineChain({ id: 1_564_830_818, diff --git a/src/chains/definitions/skale/calypsoTestnet.ts b/src/chains/definitions/skale/calypsoTestnet.ts index 52a9bdb27f..28efc297f0 100644 --- a/src/chains/definitions/skale/calypsoTestnet.ts +++ b/src/chains/definitions/skale/calypsoTestnet.ts @@ -1,4 +1,4 @@ -import { defineChain } from '../../../utils/chain.js' +import { defineChain } from '../../../utils/chain/defineChain.js' export const skaleCalypsoTestnet = /*#__PURE__*/ defineChain({ id: 344_106_930, diff --git a/src/chains/definitions/skale/chaosTestnet.ts b/src/chains/definitions/skale/chaosTestnet.ts index 31013e04d3..97791709f0 100644 --- a/src/chains/definitions/skale/chaosTestnet.ts +++ b/src/chains/definitions/skale/chaosTestnet.ts @@ -1,4 +1,4 @@ -import { defineChain } from '../../../utils/chain.js' +import { defineChain } from '../../../utils/chain/defineChain.js' export const skaleChaosTestnet = /*#__PURE__*/ defineChain({ id: 1_351_057_110, diff --git a/src/chains/definitions/skale/cryptoBlades.ts b/src/chains/definitions/skale/cryptoBlades.ts index 04bb5df4aa..fb93f67347 100644 --- a/src/chains/definitions/skale/cryptoBlades.ts +++ b/src/chains/definitions/skale/cryptoBlades.ts @@ -1,4 +1,4 @@ -import { defineChain } from '../../../utils/chain.js' +import { defineChain } from '../../../utils/chain/defineChain.js' export const skaleCryptoBlades = /*#__PURE__*/ defineChain({ id: 1_026_062_157, diff --git a/src/chains/definitions/skale/cryptoColosseum.ts b/src/chains/definitions/skale/cryptoColosseum.ts index 24999b1b98..2522b8dfe1 100644 --- a/src/chains/definitions/skale/cryptoColosseum.ts +++ b/src/chains/definitions/skale/cryptoColosseum.ts @@ -1,4 +1,4 @@ -import { defineChain } from '../../../utils/chain.js' +import { defineChain } from '../../../utils/chain/defineChain.js' export const skaleCryptoColosseum = /*#__PURE__*/ defineChain({ id: 2_046_399_126, diff --git a/src/chains/definitions/skale/europa.ts b/src/chains/definitions/skale/europa.ts index b9748ac2eb..5db88be7d3 100644 --- a/src/chains/definitions/skale/europa.ts +++ b/src/chains/definitions/skale/europa.ts @@ -1,4 +1,4 @@ -import { defineChain } from '../../../utils/chain.js' +import { defineChain } from '../../../utils/chain/defineChain.js' export const skaleEuropa = /*#__PURE__*/ defineChain({ id: 2_046_399_126, diff --git a/src/chains/definitions/skale/europaTestnet.ts b/src/chains/definitions/skale/europaTestnet.ts index 209bdf4959..adeb9fb040 100644 --- a/src/chains/definitions/skale/europaTestnet.ts +++ b/src/chains/definitions/skale/europaTestnet.ts @@ -1,4 +1,4 @@ -import { defineChain } from '../../../utils/chain.js' +import { defineChain } from '../../../utils/chain/defineChain.js' export const skaleEuropaTestnet = /*#__PURE__*/ defineChain({ id: 476_158_412, diff --git a/src/chains/definitions/skale/exorde.ts b/src/chains/definitions/skale/exorde.ts index 24116a5417..432aad01a3 100644 --- a/src/chains/definitions/skale/exorde.ts +++ b/src/chains/definitions/skale/exorde.ts @@ -1,4 +1,4 @@ -import { defineChain } from '../../../utils/chain.js' +import { defineChain } from '../../../utils/chain/defineChain.js' export const skaleExorde = /*#__PURE__*/ defineChain({ id: 2_139_927_552, diff --git a/src/chains/definitions/skale/humanProtocol.ts b/src/chains/definitions/skale/humanProtocol.ts index 31dbf3c836..afc00273f1 100644 --- a/src/chains/definitions/skale/humanProtocol.ts +++ b/src/chains/definitions/skale/humanProtocol.ts @@ -1,4 +1,4 @@ -import { defineChain } from '../../../utils/chain.js' +import { defineChain } from '../../../utils/chain/defineChain.js' export const skaleHumanProtocol = /*#__PURE__*/ defineChain({ id: 1_273_227_453, diff --git a/src/chains/definitions/skale/nebula.ts b/src/chains/definitions/skale/nebula.ts index a2dc049357..280b959dc2 100644 --- a/src/chains/definitions/skale/nebula.ts +++ b/src/chains/definitions/skale/nebula.ts @@ -1,4 +1,4 @@ -import { defineChain } from '../../../utils/chain.js' +import { defineChain } from '../../../utils/chain/defineChain.js' export const skaleNebula = /*#__PURE__*/ defineChain({ id: 1_482_601_649, diff --git a/src/chains/definitions/skale/nebulaTestnet.ts b/src/chains/definitions/skale/nebulaTestnet.ts index 894feebae7..0bf7a45a49 100644 --- a/src/chains/definitions/skale/nebulaTestnet.ts +++ b/src/chains/definitions/skale/nebulaTestnet.ts @@ -1,4 +1,4 @@ -import { defineChain } from '../../../utils/chain.js' +import { defineChain } from '../../../utils/chain/defineChain.js' export const skaleNebulaTestnet = /*#__PURE__*/ defineChain({ id: 503_129_905, diff --git a/src/chains/definitions/skale/razor.ts b/src/chains/definitions/skale/razor.ts index a1a42318df..5043519656 100644 --- a/src/chains/definitions/skale/razor.ts +++ b/src/chains/definitions/skale/razor.ts @@ -1,4 +1,4 @@ -import { defineChain } from '../../../utils/chain.js' +import { defineChain } from '../../../utils/chain/defineChain.js' export const skaleRazor = /*#__PURE__*/ defineChain({ id: 278_611_351, diff --git a/src/chains/definitions/skale/titan.ts b/src/chains/definitions/skale/titan.ts index 21b7265a87..c1783f229c 100644 --- a/src/chains/definitions/skale/titan.ts +++ b/src/chains/definitions/skale/titan.ts @@ -1,4 +1,4 @@ -import { defineChain } from '../../../utils/chain.js' +import { defineChain } from '../../../utils/chain/defineChain.js' export const skaleTitan = /*#__PURE__*/ defineChain({ id: 1_350_216_234, diff --git a/src/chains/definitions/skale/titanTestnet.ts b/src/chains/definitions/skale/titanTestnet.ts index b22dd912d2..d342806f62 100644 --- a/src/chains/definitions/skale/titanTestnet.ts +++ b/src/chains/definitions/skale/titanTestnet.ts @@ -1,4 +1,4 @@ -import { defineChain } from '../../../utils/chain.js' +import { defineChain } from '../../../utils/chain/defineChain.js' export const skaleTitanTestnet = /*#__PURE__*/ defineChain({ id: 1_517_929_550, diff --git a/src/chains/definitions/songbird.ts b/src/chains/definitions/songbird.ts index 7452048dc5..6c756b57d4 100644 --- a/src/chains/definitions/songbird.ts +++ b/src/chains/definitions/songbird.ts @@ -1,4 +1,4 @@ -import { defineChain } from '../../utils/chain.js' +import { defineChain } from '../../utils/chain/defineChain.js' export const songbird = /*#__PURE__*/ defineChain({ id: 19, diff --git a/src/chains/definitions/songbirdTestnet.ts b/src/chains/definitions/songbirdTestnet.ts index cee06a11c2..53164e9118 100644 --- a/src/chains/definitions/songbirdTestnet.ts +++ b/src/chains/definitions/songbirdTestnet.ts @@ -1,4 +1,4 @@ -import { defineChain } from '../../utils/chain.js' +import { defineChain } from '../../utils/chain/defineChain.js' export const songbirdTestnet = /*#__PURE__*/ defineChain({ id: 16, diff --git a/src/chains/definitions/syscoin.ts b/src/chains/definitions/syscoin.ts index 653fa5d4ba..3bea578d39 100644 --- a/src/chains/definitions/syscoin.ts +++ b/src/chains/definitions/syscoin.ts @@ -1,4 +1,4 @@ -import { defineChain } from '../../utils/chain.js' +import { defineChain } from '../../utils/chain/defineChain.js' export const syscoin = /*#__PURE__*/ defineChain({ id: 57, diff --git a/src/chains/definitions/syscoinTestnet.ts b/src/chains/definitions/syscoinTestnet.ts index eb866703c2..117427f2bf 100644 --- a/src/chains/definitions/syscoinTestnet.ts +++ b/src/chains/definitions/syscoinTestnet.ts @@ -1,4 +1,4 @@ -import { defineChain } from '../../utils/chain.js' +import { defineChain } from '../../utils/chain/defineChain.js' export const syscoinTestnet = /*#__PURE__*/ defineChain({ id: 5700, diff --git a/src/chains/definitions/taikoJolnir.ts b/src/chains/definitions/taikoJolnir.ts index ac39273a56..4d22390cc8 100644 --- a/src/chains/definitions/taikoJolnir.ts +++ b/src/chains/definitions/taikoJolnir.ts @@ -1,4 +1,4 @@ -import { defineChain } from '../../utils/chain.js' +import { defineChain } from '../../utils/chain/defineChain.js' export const taikoJolnir = /*#__PURE__*/ defineChain({ id: 167007, diff --git a/src/chains/definitions/taikoTestnetSepolia.ts b/src/chains/definitions/taikoTestnetSepolia.ts index 5d890d7fe3..1fd04064f9 100644 --- a/src/chains/definitions/taikoTestnetSepolia.ts +++ b/src/chains/definitions/taikoTestnetSepolia.ts @@ -1,4 +1,4 @@ -import { defineChain } from '../../utils/chain.js' +import { defineChain } from '../../utils/chain/defineChain.js' export const taikoTestnetSepolia = /*#__PURE__*/ defineChain({ id: 167005, diff --git a/src/chains/definitions/taraxa.ts b/src/chains/definitions/taraxa.ts index 2378e134c1..e9b3ec7651 100644 --- a/src/chains/definitions/taraxa.ts +++ b/src/chains/definitions/taraxa.ts @@ -1,4 +1,4 @@ -import { defineChain } from '../../utils/chain.js' +import { defineChain } from '../../utils/chain/defineChain.js' export const taraxa = /*#__PURE__*/ defineChain({ id: 841, diff --git a/src/chains/definitions/taraxaTestnet.ts b/src/chains/definitions/taraxaTestnet.ts index d4a4f4e1e5..a54589ac99 100644 --- a/src/chains/definitions/taraxaTestnet.ts +++ b/src/chains/definitions/taraxaTestnet.ts @@ -1,4 +1,4 @@ -import { defineChain } from '../../utils/chain.js' +import { defineChain } from '../../utils/chain/defineChain.js' export const taraxaTestnet = /*#__PURE__*/ defineChain({ id: 842, diff --git a/src/chains/definitions/telos.ts b/src/chains/definitions/telos.ts index 23e8ab4dcb..0906da8ccd 100644 --- a/src/chains/definitions/telos.ts +++ b/src/chains/definitions/telos.ts @@ -1,4 +1,4 @@ -import { defineChain } from '../../utils/chain.js' +import { defineChain } from '../../utils/chain/defineChain.js' export const telos = /*#__PURE__*/ defineChain({ id: 40, diff --git a/src/chains/definitions/telosTestnet.ts b/src/chains/definitions/telosTestnet.ts index 0a884763d8..73e1446d9d 100644 --- a/src/chains/definitions/telosTestnet.ts +++ b/src/chains/definitions/telosTestnet.ts @@ -1,4 +1,4 @@ -import { defineChain } from '../../utils/chain.js' +import { defineChain } from '../../utils/chain/defineChain.js' export const telosTestnet = /*#__PURE__*/ defineChain({ id: 41, diff --git a/src/chains/definitions/thunderTestnet.ts b/src/chains/definitions/thunderTestnet.ts index 5c4d1b1370..de3439e927 100644 --- a/src/chains/definitions/thunderTestnet.ts +++ b/src/chains/definitions/thunderTestnet.ts @@ -1,4 +1,4 @@ -import { defineChain } from '../../utils/chain.js' +import { defineChain } from '../../utils/chain/defineChain.js' export const thunderTestnet = /*#__PURE__*/ defineChain({ id: 997, diff --git a/src/chains/definitions/vechain.ts b/src/chains/definitions/vechain.ts index 6c12d98672..b2dc60bb58 100644 --- a/src/chains/definitions/vechain.ts +++ b/src/chains/definitions/vechain.ts @@ -1,4 +1,4 @@ -import { defineChain } from '../../utils/chain.js' +import { defineChain } from '../../utils/chain/defineChain.js' export const vechain = /*#__PURE__*/ defineChain({ id: 100009, diff --git a/src/chains/definitions/wanchain.ts b/src/chains/definitions/wanchain.ts index e2a924950a..bafd501554 100644 --- a/src/chains/definitions/wanchain.ts +++ b/src/chains/definitions/wanchain.ts @@ -1,4 +1,4 @@ -import { defineChain } from '../../utils/chain.js' +import { defineChain } from '../../utils/chain/defineChain.js' export const wanchain = /*#__PURE__*/ defineChain({ id: 888, diff --git a/src/chains/definitions/wanchainTestnet.ts b/src/chains/definitions/wanchainTestnet.ts index 9154821bec..97435e5359 100644 --- a/src/chains/definitions/wanchainTestnet.ts +++ b/src/chains/definitions/wanchainTestnet.ts @@ -1,4 +1,4 @@ -import { defineChain } from '../../utils/chain.js' +import { defineChain } from '../../utils/chain/defineChain.js' export const wanchainTestnet = /*#__PURE__*/ defineChain({ id: 999, diff --git a/src/chains/definitions/xdc.ts b/src/chains/definitions/xdc.ts index 9e47b3e81c..8a580ecdc8 100644 --- a/src/chains/definitions/xdc.ts +++ b/src/chains/definitions/xdc.ts @@ -1,4 +1,4 @@ -import { defineChain } from '../../utils/chain.js' +import { defineChain } from '../../utils/chain/defineChain.js' export const xdc = /*#__PURE__*/ defineChain({ id: 50, diff --git a/src/chains/definitions/xdcTestnet.ts b/src/chains/definitions/xdcTestnet.ts index 50d02e9ddc..167a7d7016 100644 --- a/src/chains/definitions/xdcTestnet.ts +++ b/src/chains/definitions/xdcTestnet.ts @@ -1,4 +1,4 @@ -import { defineChain } from '../../utils/chain.js' +import { defineChain } from '../../utils/chain/defineChain.js' export const xdcTestnet = /*#__PURE__*/ defineChain({ id: 51, diff --git a/src/chains/definitions/zetachainAthensTestnet.ts b/src/chains/definitions/zetachainAthensTestnet.ts index f3f63f2435..657ab2c008 100644 --- a/src/chains/definitions/zetachainAthensTestnet.ts +++ b/src/chains/definitions/zetachainAthensTestnet.ts @@ -1,4 +1,4 @@ -import { defineChain } from '../../utils/chain.js' +import { defineChain } from '../../utils/chain/defineChain.js' export const zetachainAthensTestnet = /*#__PURE__*/ defineChain({ id: 7001, diff --git a/src/chains/definitions/zhejiang.ts b/src/chains/definitions/zhejiang.ts index 08450dd7c8..9d14c9912a 100644 --- a/src/chains/definitions/zhejiang.ts +++ b/src/chains/definitions/zhejiang.ts @@ -1,4 +1,4 @@ -import { defineChain } from '../../utils/chain.js' +import { defineChain } from '../../utils/chain/defineChain.js' export const zhejiang = /*#__PURE__*/ defineChain({ id: 1_337_803, diff --git a/src/chains/definitions/zkSync.ts b/src/chains/definitions/zkSync.ts index 09d3af734d..ae3d35a7b2 100644 --- a/src/chains/definitions/zkSync.ts +++ b/src/chains/definitions/zkSync.ts @@ -1,4 +1,4 @@ -import { defineChain } from '../../utils/chain.js' +import { defineChain } from '../../utils/chain/defineChain.js' import { formattersZkSync } from '../zksync/formatters.js' import { serializersZkSync } from '../zksync/serializers.js' diff --git a/src/chains/definitions/zkSyncTestnet.ts b/src/chains/definitions/zkSyncTestnet.ts index 056922ee99..dfa9566475 100644 --- a/src/chains/definitions/zkSyncTestnet.ts +++ b/src/chains/definitions/zkSyncTestnet.ts @@ -1,4 +1,4 @@ -import { defineChain } from '../../utils/chain.js' +import { defineChain } from '../../utils/chain/defineChain.js' import { formattersZkSync } from '../zksync/formatters.js' import { serializersZkSync } from '../zksync/serializers.js' diff --git a/src/chains/definitions/zora.ts b/src/chains/definitions/zora.ts index 3002dbf972..98d39b7cc6 100644 --- a/src/chains/definitions/zora.ts +++ b/src/chains/definitions/zora.ts @@ -1,4 +1,4 @@ -import { defineChain } from '../../utils/chain.js' +import { defineChain } from '../../utils/chain/defineChain.js' import { formattersOptimism } from '../optimism/formatters.js' export const zora = /*#__PURE__*/ defineChain( diff --git a/src/chains/definitions/zoraSepolia.ts b/src/chains/definitions/zoraSepolia.ts index 877249b55c..4e4e8f2b96 100644 --- a/src/chains/definitions/zoraSepolia.ts +++ b/src/chains/definitions/zoraSepolia.ts @@ -1,4 +1,4 @@ -import { defineChain } from '../../utils/chain.js' +import { defineChain } from '../../utils/chain/defineChain.js' import { formattersOptimism } from '../optimism/formatters.js' export const zoraSepolia = /*#__PURE__*/ defineChain( diff --git a/src/chains/definitions/zoraTestnet.ts b/src/chains/definitions/zoraTestnet.ts index 2386a2d569..ad8c750e59 100644 --- a/src/chains/definitions/zoraTestnet.ts +++ b/src/chains/definitions/zoraTestnet.ts @@ -1,4 +1,4 @@ -import { defineChain } from '../../utils/chain.js' +import { defineChain } from '../../utils/chain/defineChain.js' import { formattersOptimism } from '../optimism/formatters.js' export const zoraTestnet = /*#__PURE__*/ defineChain( diff --git a/src/chains/utils/index.test.ts b/src/chains/utils/index.test.ts index 78d25dbf26..5c89abade2 100644 --- a/src/chains/utils/index.test.ts +++ b/src/chains/utils/index.test.ts @@ -5,6 +5,10 @@ import * as utils from './index.js' test('exports', () => { expect(Object.keys(utils)).toMatchInlineSnapshot(` [ + "assertCurrentChain", + "defineChain", + "extractChain", + "getChainContractAddress", "formattersCelo", "serializeTransactionCelo", "serializersCelo", diff --git a/src/chains/utils/index.ts b/src/chains/utils/index.ts index 692e492a2a..b9fbdb8b04 100644 --- a/src/chains/utils/index.ts +++ b/src/chains/utils/index.ts @@ -1,3 +1,20 @@ +export { + type AssertCurrentChainErrorType, + type AssertCurrentChainParameters, + assertCurrentChain, +} from '../../utils/chain/assertCurrentChain.js' +export { defineChain } from '../../utils/chain/defineChain.js' +export { + type ExtractChainErrorType, + type ExtractChainParameters, + type ExtractChainReturnType, + extractChain, +} from '../../utils/chain/extractChain.js' +export { + type GetChainContractAddressErrorType, + getChainContractAddress, +} from '../../utils/chain/getChainContractAddress.js' + export { formattersCelo } from '../celo/formatters.js' export { serializeTransactionCelo, diff --git a/src/index.test.ts b/src/index.test.ts index d1b65ce7de..5952135bee 100644 --- a/src/index.test.ts +++ b/src/index.test.ts @@ -318,6 +318,7 @@ test('exports', () => { "concatHex", "assertCurrentChain", "defineChain", + "extractChain", "getChainContractAddress", "encodePacked", "formatEther", diff --git a/src/index.ts b/src/index.ts index 2dead05091..320fcb8f16 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1233,11 +1233,19 @@ export { export { type AssertCurrentChainErrorType, type AssertCurrentChainParameters, - type GetChainContractAddressErrorType, assertCurrentChain, - defineChain, +} from './utils/chain/assertCurrentChain.js' +export { defineChain } from './utils/chain/defineChain.js' +export { + type ExtractChainErrorType, + type ExtractChainParameters, + type ExtractChainReturnType, + extractChain, +} from './utils/chain/extractChain.js' +export { + type GetChainContractAddressErrorType, getChainContractAddress, -} from './utils/chain.js' +} from './utils/chain/getChainContractAddress.js' export { type EncodePackedErrorType, encodePacked, diff --git a/src/types/chain.ts b/src/types/chain.ts index e555b42c82..3d247ca857 100644 --- a/src/types/chain.ts +++ b/src/types/chain.ts @@ -198,6 +198,11 @@ export type ChainEstimateFeesPerGasFnParameters< ///////////////////////////////////////////////////////////////////// // Utils +export type ExtractChain< + chains extends readonly Chain[], + chainId extends Chain['id'], +> = Extract + export type ExtractChainFormatterExclude< chain extends { formatters?: Chain['formatters'] } | undefined, type extends keyof ChainFormatters, diff --git a/src/utils/chain.test.ts b/src/utils/chain.test.ts deleted file mode 100644 index 1f2280b8db..0000000000 --- a/src/utils/chain.test.ts +++ /dev/null @@ -1,168 +0,0 @@ -import { describe, expect, test } from 'vitest' - -import { mainnet, optimism, polygon } from '../chains/index.js' - -import { - assertCurrentChain, - defineChain, - getChainContractAddress, -} from './chain.js' - -describe('assertCurrentChain', () => { - test('matching chains', () => { - assertCurrentChain({ currentChainId: mainnet.id, chain: mainnet }) - assertCurrentChain({ currentChainId: optimism.id, chain: optimism }) - }) - - test('chain mismatch', () => { - expect(() => - assertCurrentChain({ currentChainId: mainnet.id, chain: optimism }), - ).toThrowErrorMatchingInlineSnapshot(` - "The current chain of the wallet (id: 1) does not match the target chain for the transaction (id: 10 – OP Mainnet). - - Current Chain ID: 1 - Expected Chain ID: 10 – OP Mainnet - - Version: viem@1.0.2" - `) - expect(() => - assertCurrentChain({ currentChainId: optimism.id, chain: mainnet }), - ).toThrowErrorMatchingInlineSnapshot(` - "The current chain of the wallet (id: 10) does not match the target chain for the transaction (id: 1 – Ethereum). - - Current Chain ID: 10 - Expected Chain ID: 1 – Ethereum - - Version: viem@1.0.2" - `) - }) - - test('no chain', () => { - expect(() => - assertCurrentChain({ currentChainId: mainnet.id }), - ).toThrowErrorMatchingInlineSnapshot(` - "No chain was provided to the request. - Please provide a chain with the \`chain\` argument on the Action, or by supplying a \`chain\` to WalletClient. - - Version: viem@1.0.2" - `) - expect(() => - assertCurrentChain({ currentChainId: optimism.id }), - ).toThrowErrorMatchingInlineSnapshot(` - "No chain was provided to the request. - Please provide a chain with the \`chain\` argument on the Action, or by supplying a \`chain\` to WalletClient. - - Version: viem@1.0.2" - `) - }) -}) - -describe('defineChain', () => { - test('default', () => { - expect( - defineChain({ - id: 42220, - name: 'Celo', - network: 'celo', - nativeCurrency: { name: 'Celo', symbol: 'CELO', decimals: 18 }, - rpcUrls: { - public: { http: ['https://rpc.ankr.com/celo'] }, - default: { http: ['https://rpc.ankr.com/celo'] }, - }, - }), - ).toMatchInlineSnapshot(` - { - "fees": undefined, - "formatters": undefined, - "id": 42220, - "name": "Celo", - "nativeCurrency": { - "decimals": 18, - "name": "Celo", - "symbol": "CELO", - }, - "network": "celo", - "rpcUrls": { - "default": { - "http": [ - "https://rpc.ankr.com/celo", - ], - }, - "public": { - "http": [ - "https://rpc.ankr.com/celo", - ], - }, - }, - "serializers": undefined, - } - `) - }) -}) - -describe('getChainContractAddress', () => { - test('default', () => { - expect( - getChainContractAddress({ - chain: mainnet, - contract: 'multicall3', - }), - ).toMatchInlineSnapshot('"0xca11bde05977b3631167028862be2a173976ca11"') - expect( - getChainContractAddress({ - chain: polygon, - contract: 'multicall3', - }), - ).toMatchInlineSnapshot('"0xca11bde05977b3631167028862be2a173976ca11"') - expect( - getChainContractAddress({ - chain: optimism, - contract: 'multicall3', - }), - ).toMatchInlineSnapshot('"0xca11bde05977b3631167028862be2a173976ca11"') - }) - - test('no contract', () => { - expect(() => - getChainContractAddress({ - chain: { - ...mainnet, - contracts: {}, - }, - contract: 'multicall3', - }), - ).toThrowErrorMatchingInlineSnapshot(` - "Chain \\"Ethereum\\" does not support contract \\"multicall3\\". - - This could be due to any of the following: - - The chain does not have the contract \\"multicall3\\" configured. - - Version: viem@1.0.2" - `) - }) - - test('block number is less than created block number', () => { - expect(() => - getChainContractAddress({ - blockNumber: 69420n, - chain: { - ...mainnet, - contracts: { - multicall3: { - ...mainnet.contracts.multicall3, - blockCreated: 123456789, - }, - }, - }, - contract: 'multicall3', - }), - ).toThrowErrorMatchingInlineSnapshot(` - "Chain \\"Ethereum\\" does not support contract \\"multicall3\\". - - This could be due to any of the following: - - The contract \\"multicall3\\" was not deployed until block 123456789 (current block 69420). - - Version: viem@1.0.2" - `) - }) -}) diff --git a/src/utils/chain.ts b/src/utils/chain.ts deleted file mode 100644 index 693f16bd37..0000000000 --- a/src/utils/chain.ts +++ /dev/null @@ -1,91 +0,0 @@ -import { - ChainDoesNotSupportContract, - type ChainDoesNotSupportContractErrorType, - ChainMismatchError, - type ChainMismatchErrorType, - ChainNotFoundError, - type ChainNotFoundErrorType, -} from '../errors/chain.js' -import type { ErrorType } from '../errors/utils.js' -import type { - Chain, - ChainConfig, - ChainContract, - ChainFormatters, -} from '../types/chain.js' -import type { Assign } from '../types/utils.js' - -export type AssertCurrentChainParameters = { - chain?: Chain - currentChainId: number -} - -export type AssertCurrentChainErrorType = - | ChainNotFoundErrorType - | ChainMismatchErrorType - | ErrorType - -export function assertCurrentChain({ - chain, - currentChainId, -}: AssertCurrentChainParameters): void { - if (!chain) throw new ChainNotFoundError() - if (currentChainId !== chain.id) - throw new ChainMismatchError({ chain, currentChainId }) -} - -export function defineChain< - const chain extends Chain, - formatters extends ChainFormatters | undefined = undefined, ->( - chain: chain, - config: ChainConfig = {}, -): Assign> { - const { - fees = chain.fees, - formatters = chain.formatters, - serializers = chain.serializers, - } = config - return { - ...chain, - fees, - formatters, - serializers, - } as unknown as Assign> -} - -export type GetChainContractAddressErrorType = - ChainDoesNotSupportContractErrorType - -export function getChainContractAddress({ - blockNumber, - chain, - contract: name, -}: { - blockNumber?: bigint - chain: Chain - contract: string -}) { - const contract = (chain?.contracts as Record)?.[name] - if (!contract) - throw new ChainDoesNotSupportContract({ - chain, - contract: { name }, - }) - - if ( - blockNumber && - contract.blockCreated && - contract.blockCreated > blockNumber - ) - throw new ChainDoesNotSupportContract({ - blockNumber, - chain, - contract: { - name, - blockCreated: contract.blockCreated, - }, - }) - - return contract.address -} diff --git a/src/utils/chain/assertCurrentChain.test.ts b/src/utils/chain/assertCurrentChain.test.ts new file mode 100644 index 0000000000..64de38a6fa --- /dev/null +++ b/src/utils/chain/assertCurrentChain.test.ts @@ -0,0 +1,52 @@ +import { expect, test } from 'vitest' + +import { mainnet, optimism } from '../../chains/index.js' + +import { assertCurrentChain } from './assertCurrentChain.js' + +test('matching chains', () => { + assertCurrentChain({ currentChainId: mainnet.id, chain: mainnet }) + assertCurrentChain({ currentChainId: optimism.id, chain: optimism }) +}) + +test('chain mismatch', () => { + expect(() => + assertCurrentChain({ currentChainId: mainnet.id, chain: optimism }), + ).toThrowErrorMatchingInlineSnapshot(` + "The current chain of the wallet (id: 1) does not match the target chain for the transaction (id: 10 – OP Mainnet). + + Current Chain ID: 1 + Expected Chain ID: 10 – OP Mainnet + + Version: viem@1.0.2" + `) + expect(() => + assertCurrentChain({ currentChainId: optimism.id, chain: mainnet }), + ).toThrowErrorMatchingInlineSnapshot(` + "The current chain of the wallet (id: 10) does not match the target chain for the transaction (id: 1 – Ethereum). + + Current Chain ID: 10 + Expected Chain ID: 1 – Ethereum + + Version: viem@1.0.2" + `) +}) + +test('no chain', () => { + expect(() => + assertCurrentChain({ currentChainId: mainnet.id }), + ).toThrowErrorMatchingInlineSnapshot(` + "No chain was provided to the request. + Please provide a chain with the \`chain\` argument on the Action, or by supplying a \`chain\` to WalletClient. + + Version: viem@1.0.2" + `) + expect(() => + assertCurrentChain({ currentChainId: optimism.id }), + ).toThrowErrorMatchingInlineSnapshot(` + "No chain was provided to the request. + Please provide a chain with the \`chain\` argument on the Action, or by supplying a \`chain\` to WalletClient. + + Version: viem@1.0.2" + `) +}) diff --git a/src/utils/chain/assertCurrentChain.ts b/src/utils/chain/assertCurrentChain.ts new file mode 100644 index 0000000000..1c58656e1c --- /dev/null +++ b/src/utils/chain/assertCurrentChain.ts @@ -0,0 +1,27 @@ +import { + ChainMismatchError, + type ChainMismatchErrorType, + ChainNotFoundError, + type ChainNotFoundErrorType, +} from '../../errors/chain.js' +import type { ErrorType } from '../../errors/utils.js' +import type { Chain } from '../../types/chain.js' + +export type AssertCurrentChainParameters = { + chain?: Chain + currentChainId: number +} + +export type AssertCurrentChainErrorType = + | ChainNotFoundErrorType + | ChainMismatchErrorType + | ErrorType + +export function assertCurrentChain({ + chain, + currentChainId, +}: AssertCurrentChainParameters): void { + if (!chain) throw new ChainNotFoundError() + if (currentChainId !== chain.id) + throw new ChainMismatchError({ chain, currentChainId }) +} diff --git a/src/utils/chain/defineChain.test.ts b/src/utils/chain/defineChain.test.ts new file mode 100644 index 0000000000..7922e47001 --- /dev/null +++ b/src/utils/chain/defineChain.test.ts @@ -0,0 +1,44 @@ +import { expect, test } from 'vitest' + +import { defineChain } from './defineChain.js' + +test('default', () => { + expect( + defineChain({ + id: 42220, + name: 'Celo', + network: 'celo', + nativeCurrency: { name: 'Celo', symbol: 'CELO', decimals: 18 }, + rpcUrls: { + public: { http: ['https://rpc.ankr.com/celo'] }, + default: { http: ['https://rpc.ankr.com/celo'] }, + }, + }), + ).toMatchInlineSnapshot(` + { + "fees": undefined, + "formatters": undefined, + "id": 42220, + "name": "Celo", + "nativeCurrency": { + "decimals": 18, + "name": "Celo", + "symbol": "CELO", + }, + "network": "celo", + "rpcUrls": { + "default": { + "http": [ + "https://rpc.ankr.com/celo", + ], + }, + "public": { + "http": [ + "https://rpc.ankr.com/celo", + ], + }, + }, + "serializers": undefined, + } + `) +}) diff --git a/src/utils/chain/defineChain.ts b/src/utils/chain/defineChain.ts new file mode 100644 index 0000000000..cb3369340a --- /dev/null +++ b/src/utils/chain/defineChain.ts @@ -0,0 +1,22 @@ +import type { Chain, ChainConfig, ChainFormatters } from '../../types/chain.js' +import type { Assign } from '../../types/utils.js' + +export function defineChain< + const chain extends Chain, + formatters extends ChainFormatters | undefined = undefined, +>( + chain: chain, + config: ChainConfig = {}, +): Assign> { + const { + fees = chain.fees, + formatters = chain.formatters, + serializers = chain.serializers, + } = config + return { + ...chain, + fees, + formatters, + serializers, + } as unknown as Assign> +} diff --git a/src/utils/chain/extractChain.test.ts b/src/utils/chain/extractChain.test.ts new file mode 100644 index 0000000000..e87436d14a --- /dev/null +++ b/src/utils/chain/extractChain.test.ts @@ -0,0 +1,156 @@ +import { expect, test } from 'vitest' +import * as chains from '../../chains/index.js' +import { extractChain } from './extractChain.js' + +test('default', async () => { + const mainnet = extractChain({ + chains: Object.values(chains), + id: 1, + }) + expect(mainnet).toMatchInlineSnapshot(` + { + "blockExplorers": { + "default": { + "name": "Etherscan", + "url": "https://etherscan.io", + }, + "etherscan": { + "name": "Etherscan", + "url": "https://etherscan.io", + }, + }, + "contracts": { + "ensRegistry": { + "address": "0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e", + }, + "ensUniversalResolver": { + "address": "0xc0497E381f536Be9ce14B0dD3817cBcAe57d2F62", + "blockCreated": 16966585, + }, + "multicall3": { + "address": "0xca11bde05977b3631167028862be2a173976ca11", + "blockCreated": 14353601, + }, + }, + "fees": undefined, + "formatters": undefined, + "id": 1, + "name": "Ethereum", + "nativeCurrency": { + "decimals": 18, + "name": "Ether", + "symbol": "ETH", + }, + "network": "homestead", + "rpcUrls": { + "alchemy": { + "http": [ + "https://eth-mainnet.g.alchemy.com/v2", + ], + "webSocket": [ + "wss://eth-mainnet.g.alchemy.com/v2", + ], + }, + "default": { + "http": [ + "https://cloudflare-eth.com", + ], + }, + "infura": { + "http": [ + "https://mainnet.infura.io/v3", + ], + "webSocket": [ + "wss://mainnet.infura.io/ws/v3", + ], + }, + "public": { + "http": [ + "https://cloudflare-eth.com", + ], + }, + }, + "serializers": undefined, + } + `) + + const optimism = extractChain({ + chains: Object.values(chains), + id: 10, + }) + expect(optimism).toMatchInlineSnapshot(` + { + "blockExplorers": { + "default": { + "name": "Optimism Explorer", + "url": "https://explorer.optimism.io", + }, + "etherscan": { + "name": "Etherscan", + "url": "https://optimistic.etherscan.io", + }, + }, + "contracts": { + "multicall3": { + "address": "0xca11bde05977b3631167028862be2a173976ca11", + "blockCreated": 4286263, + }, + }, + "fees": undefined, + "formatters": { + "block": { + "exclude": undefined, + "format": [Function], + "type": "block", + }, + "transaction": { + "exclude": undefined, + "format": [Function], + "type": "transaction", + }, + "transactionReceipt": { + "exclude": undefined, + "format": [Function], + "type": "transactionReceipt", + }, + }, + "id": 10, + "name": "OP Mainnet", + "nativeCurrency": { + "decimals": 18, + "name": "Ether", + "symbol": "ETH", + }, + "network": "optimism", + "rpcUrls": { + "alchemy": { + "http": [ + "https://opt-mainnet.g.alchemy.com/v2", + ], + "webSocket": [ + "wss://opt-mainnet.g.alchemy.com/v2", + ], + }, + "default": { + "http": [ + "https://mainnet.optimism.io", + ], + }, + "infura": { + "http": [ + "https://optimism-mainnet.infura.io/v3", + ], + "webSocket": [ + "wss://optimism-mainnet.infura.io/ws/v3", + ], + }, + "public": { + "http": [ + "https://mainnet.optimism.io", + ], + }, + }, + "serializers": undefined, + } + `) +}) diff --git a/src/utils/chain/extractChain.ts b/src/utils/chain/extractChain.ts new file mode 100644 index 0000000000..0e9e187ffe --- /dev/null +++ b/src/utils/chain/extractChain.ts @@ -0,0 +1,33 @@ +import type { ErrorType } from '../../errors/utils.js' +import type { Chain, ExtractChain } from '../../types/chain.js' + +export type ExtractChainParameters< + chains extends readonly Chain[], + chainId extends chains[number]['id'], +> = { + chains: chains + id: chainId | chains[number]['id'] +} + +export type ExtractChainReturnType< + chains extends readonly Chain[], + chainId extends chains[number]['id'], +> = ExtractChain + +export type ExtractChainErrorType = ErrorType + +export function extractChain< + const chains extends readonly Chain[], + chainId extends chains[number]['id'], +>({ + chains, + id, +}: ExtractChainParameters): ExtractChainReturnType< + chains, + chainId +> { + return chains.find((chain) => chain.id === id) as ExtractChainReturnType< + chains, + chainId + > +} diff --git a/src/utils/chain/getChainContractAddress.test.ts b/src/utils/chain/getChainContractAddress.test.ts new file mode 100644 index 0000000000..e6d97dcf39 --- /dev/null +++ b/src/utils/chain/getChainContractAddress.test.ts @@ -0,0 +1,70 @@ +import { expect, test } from 'vitest' + +import { mainnet, optimism, polygon } from '../../chains/index.js' + +import { getChainContractAddress } from './getChainContractAddress.js' + +test('default', () => { + expect( + getChainContractAddress({ + chain: mainnet, + contract: 'multicall3', + }), + ).toMatchInlineSnapshot('"0xca11bde05977b3631167028862be2a173976ca11"') + expect( + getChainContractAddress({ + chain: polygon, + contract: 'multicall3', + }), + ).toMatchInlineSnapshot('"0xca11bde05977b3631167028862be2a173976ca11"') + expect( + getChainContractAddress({ + chain: optimism, + contract: 'multicall3', + }), + ).toMatchInlineSnapshot('"0xca11bde05977b3631167028862be2a173976ca11"') +}) + +test('no contract', () => { + expect(() => + getChainContractAddress({ + chain: { + ...mainnet, + contracts: {}, + }, + contract: 'multicall3', + }), + ).toThrowErrorMatchingInlineSnapshot(` + "Chain \\"Ethereum\\" does not support contract \\"multicall3\\". + + This could be due to any of the following: + - The chain does not have the contract \\"multicall3\\" configured. + + Version: viem@1.0.2" + `) +}) + +test('block number is less than created block number', () => { + expect(() => + getChainContractAddress({ + blockNumber: 69420n, + chain: { + ...mainnet, + contracts: { + multicall3: { + ...mainnet.contracts.multicall3, + blockCreated: 123456789, + }, + }, + }, + contract: 'multicall3', + }), + ).toThrowErrorMatchingInlineSnapshot(` + "Chain \\"Ethereum\\" does not support contract \\"multicall3\\". + + This could be due to any of the following: + - The contract \\"multicall3\\" was not deployed until block 123456789 (current block 69420). + + Version: viem@1.0.2" + `) +}) diff --git a/src/utils/chain/getChainContractAddress.ts b/src/utils/chain/getChainContractAddress.ts new file mode 100644 index 0000000000..2e887b70bb --- /dev/null +++ b/src/utils/chain/getChainContractAddress.ts @@ -0,0 +1,41 @@ +import { + ChainDoesNotSupportContract, + type ChainDoesNotSupportContractErrorType, +} from '../../errors/chain.js' +import type { Chain, ChainContract } from '../../types/chain.js' + +export type GetChainContractAddressErrorType = + ChainDoesNotSupportContractErrorType + +export function getChainContractAddress({ + blockNumber, + chain, + contract: name, +}: { + blockNumber?: bigint + chain: Chain + contract: string +}) { + const contract = (chain?.contracts as Record)?.[name] + if (!contract) + throw new ChainDoesNotSupportContract({ + chain, + contract: { name }, + }) + + if ( + blockNumber && + contract.blockCreated && + contract.blockCreated > blockNumber + ) + throw new ChainDoesNotSupportContract({ + blockNumber, + chain, + contract: { + name, + blockCreated: contract.blockCreated, + }, + }) + + return contract.address +} diff --git a/src/utils/index.test.ts b/src/utils/index.test.ts index 53d0ed6158..5bd5d4289f 100644 --- a/src/utils/index.test.ts +++ b/src/utils/index.test.ts @@ -45,6 +45,7 @@ test('exports utils', () => { "encodeFunctionResult": [Function], "encodePacked": [Function], "extract": [Function], + "extractChain": [Function], "extractFunctionName": [Function], "extractFunctionParams": [Function], "extractFunctionParts": [Function], diff --git a/src/utils/index.ts b/src/utils/index.ts index f53a32d3a6..af945efecc 100644 --- a/src/utils/index.ts +++ b/src/utils/index.ts @@ -15,13 +15,22 @@ export { } from './ccip.js' export { - type AssertCurrentChainParameters, type AssertCurrentChainErrorType, - type GetChainContractAddressErrorType, + type AssertCurrentChainParameters, assertCurrentChain, - defineChain, +} from './chain/assertCurrentChain.js' +export { defineChain } from './chain/defineChain.js' +export { + type ExtractChainErrorType, + type ExtractChainParameters, + type ExtractChainReturnType, + extractChain, +} from './chain/extractChain.js' +export { + type GetChainContractAddressErrorType, getChainContractAddress, -} from './chain.js' +} from './chain/getChainContractAddress.js' + export { arrayRegex, bytesRegex, integerRegex } from './regex.js' export {