@farcaster/create-mini-app 0.0.6 → 0.0.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.turbo/turbo-build.log +2 -2
- package/CHANGELOG.md +13 -0
- package/dist/init.d.ts.map +1 -1
- package/dist/init.js +20 -2
- package/dist/init.js.map +1 -1
- package/init.ts +22 -2
- package/package.json +3 -1
- package/templates/default/README.md +19 -0
- package/templates/default/src/App.tsx +15 -19
- package/templates/default/src/main.tsx +10 -10
- package/templates/default/src/wagmi.ts +6 -6
- package/templates/default/vite.config.ts +3 -3
- package/templates/default/node_modules/.bin/biome +0 -17
- package/templates/default/node_modules/.bin/browserslist +0 -17
- package/templates/default/node_modules/.bin/esbuild +0 -17
- package/templates/default/node_modules/.bin/terser +0 -17
- package/templates/default/node_modules/.bin/tsc +0 -17
- package/templates/default/node_modules/.bin/tsserver +0 -17
- package/templates/default/node_modules/.bin/vite +0 -17
- package/templates/default/node_modules/.bin/wagmi +0 -17
- package/templates/default/node_modules/.vite/deps/@farcaster_frame-sdk.js +0 -84
- package/templates/default/node_modules/.vite/deps/@farcaster_frame-sdk.js.map +0 -7
- package/templates/default/node_modules/.vite/deps/@farcaster_frame-wagmi-connector.js +0 -1936
- package/templates/default/node_modules/.vite/deps/@farcaster_frame-wagmi-connector.js.map +0 -7
- package/templates/default/node_modules/.vite/deps/@tanstack_react-query.js +0 -96
- package/templates/default/node_modules/.vite/deps/@tanstack_react-query.js.map +0 -7
- package/templates/default/node_modules/.vite/deps/_metadata.json +0 -139
- package/templates/default/node_modules/.vite/deps/ccip-JTEXJDV5.js +0 -17
- package/templates/default/node_modules/.vite/deps/ccip-JTEXJDV5.js.map +0 -7
- package/templates/default/node_modules/.vite/deps/ccip-LLOJAQYN.js +0 -14
- package/templates/default/node_modules/.vite/deps/ccip-LLOJAQYN.js.map +0 -7
- package/templates/default/node_modules/.vite/deps/chunk-2KW72IQL.js +0 -2601
- package/templates/default/node_modules/.vite/deps/chunk-2KW72IQL.js.map +0 -7
- package/templates/default/node_modules/.vite/deps/chunk-2ULAEEW3.js +0 -286
- package/templates/default/node_modules/.vite/deps/chunk-2ULAEEW3.js.map +0 -7
- package/templates/default/node_modules/.vite/deps/chunk-3MMZATWV.js +0 -1906
- package/templates/default/node_modules/.vite/deps/chunk-3MMZATWV.js.map +0 -7
- package/templates/default/node_modules/.vite/deps/chunk-6WYSWNQJ.js +0 -3183
- package/templates/default/node_modules/.vite/deps/chunk-6WYSWNQJ.js.map +0 -7
- package/templates/default/node_modules/.vite/deps/chunk-AJPHOYQK.js +0 -21628
- package/templates/default/node_modules/.vite/deps/chunk-AJPHOYQK.js.map +0 -7
- package/templates/default/node_modules/.vite/deps/chunk-HP7M7ER3.js +0 -2221
- package/templates/default/node_modules/.vite/deps/chunk-HP7M7ER3.js.map +0 -7
- package/templates/default/node_modules/.vite/deps/chunk-JDAHWTZP.js +0 -928
- package/templates/default/node_modules/.vite/deps/chunk-JDAHWTZP.js.map +0 -7
- package/templates/default/node_modules/.vite/deps/chunk-OOB7NECH.js +0 -58
- package/templates/default/node_modules/.vite/deps/chunk-OOB7NECH.js.map +0 -7
- package/templates/default/node_modules/.vite/deps/chunk-OYL52S4H.js +0 -190
- package/templates/default/node_modules/.vite/deps/chunk-OYL52S4H.js.map +0 -7
- package/templates/default/node_modules/.vite/deps/chunk-P2SCV6N5.js +0 -1085
- package/templates/default/node_modules/.vite/deps/chunk-P2SCV6N5.js.map +0 -7
- package/templates/default/node_modules/.vite/deps/chunk-P727YSDY.js +0 -3246
- package/templates/default/node_modules/.vite/deps/chunk-P727YSDY.js.map +0 -7
- package/templates/default/node_modules/.vite/deps/chunk-PH77EFIP.js +0 -278
- package/templates/default/node_modules/.vite/deps/chunk-PH77EFIP.js.map +0 -7
- package/templates/default/node_modules/.vite/deps/chunk-PK65EOOR.js +0 -4416
- package/templates/default/node_modules/.vite/deps/chunk-PK65EOOR.js.map +0 -7
- package/templates/default/node_modules/.vite/deps/chunk-PPRY4ZGR.js +0 -36187
- package/templates/default/node_modules/.vite/deps/chunk-PPRY4ZGR.js.map +0 -7
- package/templates/default/node_modules/.vite/deps/chunk-Q3UTC4SW.js +0 -832
- package/templates/default/node_modules/.vite/deps/chunk-Q3UTC4SW.js.map +0 -7
- package/templates/default/node_modules/.vite/deps/chunk-R2PSY44V.js +0 -815
- package/templates/default/node_modules/.vite/deps/chunk-R2PSY44V.js.map +0 -7
- package/templates/default/node_modules/.vite/deps/chunk-WOOG5QLI.js +0 -60
- package/templates/default/node_modules/.vite/deps/chunk-WOOG5QLI.js.map +0 -7
- package/templates/default/node_modules/.vite/deps/native-J7PVLWWX.js +0 -21
- package/templates/default/node_modules/.vite/deps/native-J7PVLWWX.js.map +0 -7
- package/templates/default/node_modules/.vite/deps/native-UTGEKOTD.js +0 -21
- package/templates/default/node_modules/.vite/deps/native-UTGEKOTD.js.map +0 -7
- package/templates/default/node_modules/.vite/deps/package.json +0 -3
- package/templates/default/node_modules/.vite/deps/react-dom.js +0 -7
- package/templates/default/node_modules/.vite/deps/react-dom.js.map +0 -7
- package/templates/default/node_modules/.vite/deps/react-dom_client.js +0 -39
- package/templates/default/node_modules/.vite/deps/react-dom_client.js.map +0 -7
- package/templates/default/node_modules/.vite/deps/react.js +0 -6
- package/templates/default/node_modules/.vite/deps/react.js.map +0 -7
- package/templates/default/node_modules/.vite/deps/react_jsx-dev-runtime.js +0 -913
- package/templates/default/node_modules/.vite/deps/react_jsx-dev-runtime.js.map +0 -7
- package/templates/default/node_modules/.vite/deps/react_jsx-runtime.js +0 -7
- package/templates/default/node_modules/.vite/deps/react_jsx-runtime.js.map +0 -7
- package/templates/default/node_modules/.vite/deps/secp256k1-HB6OVCEM.js +0 -14
- package/templates/default/node_modules/.vite/deps/secp256k1-HB6OVCEM.js.map +0 -7
- package/templates/default/node_modules/.vite/deps/secp256k1-YI5SRKAE.js +0 -16
- package/templates/default/node_modules/.vite/deps/secp256k1-YI5SRKAE.js.map +0 -7
- package/templates/default/node_modules/.vite/deps/wagmi.js +0 -12147
- package/templates/default/node_modules/.vite/deps/wagmi.js.map +0 -7
- package/templates/default/node_modules/.vite/deps/wagmi_chains.js +0 -16355
- package/templates/default/node_modules/.vite/deps/wagmi_chains.js.map +0 -7
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../../../../../node_modules/.pnpm/use-sync-external-store@1.4.0_react@18.3.1/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.development.js", "../../../../../../../node_modules/.pnpm/use-sync-external-store@1.4.0_react@18.3.1/node_modules/use-sync-external-store/shim/index.js", "../../../../../../../node_modules/.pnpm/use-sync-external-store@1.4.0_react@18.3.1/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.development.js", "../../../../../../../node_modules/.pnpm/use-sync-external-store@1.4.0_react@18.3.1/node_modules/use-sync-external-store/shim/with-selector.js", "../../../../../../../node_modules/.pnpm/wagmi@2.14.15_@tanstack+query-core@5.66.4_@tanstack+react-query@5.45.1_react@18.3.1__@types+r_fi3vzdagybtfmjsnztrwv6mimq/node_modules/wagmi/src/context.ts", "../../../../../../../node_modules/.pnpm/viem@2.23.15_bufferutil@4.0.9_typescript@5.8.2_utf-8-validate@5.0.10_zod@3.24.1/node_modules/viem/actions/wallet/addChain.ts", "../../../../../../../node_modules/.pnpm/viem@2.23.15_bufferutil@4.0.9_typescript@5.8.2_utf-8-validate@5.0.10_zod@3.24.1/node_modules/viem/accounts/utils/publicKeyToAddress.ts", "../../../../../../../node_modules/.pnpm/viem@2.23.15_bufferutil@4.0.9_typescript@5.8.2_utf-8-validate@5.0.10_zod@3.24.1/node_modules/viem/utils/signature/recoverPublicKey.ts", "../../../../../../../node_modules/.pnpm/viem@2.23.15_bufferutil@4.0.9_typescript@5.8.2_utf-8-validate@5.0.10_zod@3.24.1/node_modules/viem/utils/signature/recoverAddress.ts", "../../../../../../../node_modules/.pnpm/viem@2.23.15_bufferutil@4.0.9_typescript@5.8.2_utf-8-validate@5.0.10_zod@3.24.1/node_modules/viem/experimental/eip7702/utils/hashAuthorization.ts", "../../../../../../../node_modules/.pnpm/viem@2.23.15_bufferutil@4.0.9_typescript@5.8.2_utf-8-validate@5.0.10_zod@3.24.1/node_modules/viem/experimental/eip7702/utils/recoverAuthorizationAddress.ts", "../../../../../../../node_modules/.pnpm/viem@2.23.15_bufferutil@4.0.9_typescript@5.8.2_utf-8-validate@5.0.10_zod@3.24.1/node_modules/viem/utils/errors/getTransactionError.ts", "../../../../../../../node_modules/.pnpm/viem@2.23.15_bufferutil@4.0.9_typescript@5.8.2_utf-8-validate@5.0.10_zod@3.24.1/node_modules/viem/utils/getAction.ts", "../../../../../../../node_modules/.pnpm/viem@2.23.15_bufferutil@4.0.9_typescript@5.8.2_utf-8-validate@5.0.10_zod@3.24.1/node_modules/viem/actions/public/getChainId.ts", "../../../../../../../node_modules/.pnpm/viem@2.23.15_bufferutil@4.0.9_typescript@5.8.2_utf-8-validate@5.0.10_zod@3.24.1/node_modules/viem/errors/fee.ts", "../../../../../../../node_modules/.pnpm/viem@2.23.15_bufferutil@4.0.9_typescript@5.8.2_utf-8-validate@5.0.10_zod@3.24.1/node_modules/viem/errors/block.ts", "../../../../../../../node_modules/.pnpm/viem@2.23.15_bufferutil@4.0.9_typescript@5.8.2_utf-8-validate@5.0.10_zod@3.24.1/node_modules/viem/actions/public/getBlock.ts", "../../../../../../../node_modules/.pnpm/viem@2.23.15_bufferutil@4.0.9_typescript@5.8.2_utf-8-validate@5.0.10_zod@3.24.1/node_modules/viem/actions/public/getGasPrice.ts", "../../../../../../../node_modules/.pnpm/viem@2.23.15_bufferutil@4.0.9_typescript@5.8.2_utf-8-validate@5.0.10_zod@3.24.1/node_modules/viem/actions/public/estimateMaxPriorityFeePerGas.ts", "../../../../../../../node_modules/.pnpm/viem@2.23.15_bufferutil@4.0.9_typescript@5.8.2_utf-8-validate@5.0.10_zod@3.24.1/node_modules/viem/actions/public/estimateFeesPerGas.ts", "../../../../../../../node_modules/.pnpm/viem@2.23.15_bufferutil@4.0.9_typescript@5.8.2_utf-8-validate@5.0.10_zod@3.24.1/node_modules/viem/errors/estimateGas.ts", "../../../../../../../node_modules/.pnpm/viem@2.23.15_bufferutil@4.0.9_typescript@5.8.2_utf-8-validate@5.0.10_zod@3.24.1/node_modules/viem/utils/errors/getEstimateGasError.ts", "../../../../../../../node_modules/.pnpm/viem@2.23.15_bufferutil@4.0.9_typescript@5.8.2_utf-8-validate@5.0.10_zod@3.24.1/node_modules/viem/actions/public/getBalance.ts", "../../../../../../../node_modules/.pnpm/viem@2.23.15_bufferutil@4.0.9_typescript@5.8.2_utf-8-validate@5.0.10_zod@3.24.1/node_modules/viem/actions/public/estimateGas.ts", "../../../../../../../node_modules/.pnpm/viem@2.23.15_bufferutil@4.0.9_typescript@5.8.2_utf-8-validate@5.0.10_zod@3.24.1/node_modules/viem/actions/public/getTransactionCount.ts", "../../../../../../../node_modules/.pnpm/viem@2.23.15_bufferutil@4.0.9_typescript@5.8.2_utf-8-validate@5.0.10_zod@3.24.1/node_modules/viem/actions/wallet/prepareTransactionRequest.ts", "../../../../../../../node_modules/.pnpm/viem@2.23.15_bufferutil@4.0.9_typescript@5.8.2_utf-8-validate@5.0.10_zod@3.24.1/node_modules/viem/actions/wallet/sendRawTransaction.ts", "../../../../../../../node_modules/.pnpm/viem@2.23.15_bufferutil@4.0.9_typescript@5.8.2_utf-8-validate@5.0.10_zod@3.24.1/node_modules/viem/actions/wallet/sendTransaction.ts", "../../../../../../../node_modules/.pnpm/viem@2.23.15_bufferutil@4.0.9_typescript@5.8.2_utf-8-validate@5.0.10_zod@3.24.1/node_modules/viem/actions/wallet/deployContract.ts", "../../../../../../../node_modules/.pnpm/viem@2.23.15_bufferutil@4.0.9_typescript@5.8.2_utf-8-validate@5.0.10_zod@3.24.1/node_modules/viem/utils/ens/errors.ts", "../../../../../../../node_modules/.pnpm/viem@2.23.15_bufferutil@4.0.9_typescript@5.8.2_utf-8-validate@5.0.10_zod@3.24.1/node_modules/viem/utils/ens/encodedLabelToLabelhash.ts", "../../../../../../../node_modules/.pnpm/viem@2.23.15_bufferutil@4.0.9_typescript@5.8.2_utf-8-validate@5.0.10_zod@3.24.1/node_modules/viem/utils/ens/namehash.ts", "../../../../../../../node_modules/.pnpm/viem@2.23.15_bufferutil@4.0.9_typescript@5.8.2_utf-8-validate@5.0.10_zod@3.24.1/node_modules/viem/utils/ens/encodeLabelhash.ts", "../../../../../../../node_modules/.pnpm/viem@2.23.15_bufferutil@4.0.9_typescript@5.8.2_utf-8-validate@5.0.10_zod@3.24.1/node_modules/viem/utils/ens/labelhash.ts", "../../../../../../../node_modules/.pnpm/viem@2.23.15_bufferutil@4.0.9_typescript@5.8.2_utf-8-validate@5.0.10_zod@3.24.1/node_modules/viem/utils/ens/packetToBytes.ts", "../../../../../../../node_modules/.pnpm/viem@2.23.15_bufferutil@4.0.9_typescript@5.8.2_utf-8-validate@5.0.10_zod@3.24.1/node_modules/viem/utils/errors/getContractError.ts", "../../../../../../../node_modules/.pnpm/viem@2.23.15_bufferutil@4.0.9_typescript@5.8.2_utf-8-validate@5.0.10_zod@3.24.1/node_modules/viem/actions/public/readContract.ts", "../../../../../../../node_modules/.pnpm/viem@2.23.15_bufferutil@4.0.9_typescript@5.8.2_utf-8-validate@5.0.10_zod@3.24.1/node_modules/viem/actions/ens/getEnsAddress.ts", "../../../../../../../node_modules/.pnpm/viem@2.23.15_bufferutil@4.0.9_typescript@5.8.2_utf-8-validate@5.0.10_zod@3.24.1/node_modules/viem/errors/ens.ts", "../../../../../../../node_modules/.pnpm/viem@2.23.15_bufferutil@4.0.9_typescript@5.8.2_utf-8-validate@5.0.10_zod@3.24.1/node_modules/viem/utils/ens/avatar/utils.ts", "../../../../../../../node_modules/.pnpm/viem@2.23.15_bufferutil@4.0.9_typescript@5.8.2_utf-8-validate@5.0.10_zod@3.24.1/node_modules/viem/utils/ens/avatar/parseAvatarRecord.ts", "../../../../../../../node_modules/.pnpm/viem@2.23.15_bufferutil@4.0.9_typescript@5.8.2_utf-8-validate@5.0.10_zod@3.24.1/node_modules/viem/actions/ens/getEnsText.ts", "../../../../../../../node_modules/.pnpm/viem@2.23.15_bufferutil@4.0.9_typescript@5.8.2_utf-8-validate@5.0.10_zod@3.24.1/node_modules/viem/actions/ens/getEnsAvatar.ts", "../../../../../../../node_modules/.pnpm/viem@2.23.15_bufferutil@4.0.9_typescript@5.8.2_utf-8-validate@5.0.10_zod@3.24.1/node_modules/viem/actions/ens/getEnsName.ts", "../../../../../../../node_modules/.pnpm/viem@2.23.15_bufferutil@4.0.9_typescript@5.8.2_utf-8-validate@5.0.10_zod@3.24.1/node_modules/viem/actions/ens/getEnsResolver.ts", "../../../../../../../node_modules/.pnpm/viem@2.23.15_bufferutil@4.0.9_typescript@5.8.2_utf-8-validate@5.0.10_zod@3.24.1/node_modules/viem/actions/public/createAccessList.ts", "../../../../../../../node_modules/.pnpm/viem@2.23.15_bufferutil@4.0.9_typescript@5.8.2_utf-8-validate@5.0.10_zod@3.24.1/node_modules/viem/utils/filters/createFilterRequestScope.ts", "../../../../../../../node_modules/.pnpm/viem@2.23.15_bufferutil@4.0.9_typescript@5.8.2_utf-8-validate@5.0.10_zod@3.24.1/node_modules/viem/actions/public/createBlockFilter.ts", "../../../../../../../node_modules/.pnpm/viem@2.23.15_bufferutil@4.0.9_typescript@5.8.2_utf-8-validate@5.0.10_zod@3.24.1/node_modules/viem/errors/log.ts", "../../../../../../../node_modules/.pnpm/viem@2.23.15_bufferutil@4.0.9_typescript@5.8.2_utf-8-validate@5.0.10_zod@3.24.1/node_modules/viem/utils/abi/encodeEventTopics.ts", "../../../../../../../node_modules/.pnpm/viem@2.23.15_bufferutil@4.0.9_typescript@5.8.2_utf-8-validate@5.0.10_zod@3.24.1/node_modules/viem/actions/public/createContractEventFilter.ts", "../../../../../../../node_modules/.pnpm/viem@2.23.15_bufferutil@4.0.9_typescript@5.8.2_utf-8-validate@5.0.10_zod@3.24.1/node_modules/viem/actions/public/createEventFilter.ts", "../../../../../../../node_modules/.pnpm/viem@2.23.15_bufferutil@4.0.9_typescript@5.8.2_utf-8-validate@5.0.10_zod@3.24.1/node_modules/viem/actions/public/createPendingTransactionFilter.ts", "../../../../../../../node_modules/.pnpm/viem@2.23.15_bufferutil@4.0.9_typescript@5.8.2_utf-8-validate@5.0.10_zod@3.24.1/node_modules/viem/actions/public/estimateContractGas.ts", "../../../../../../../node_modules/.pnpm/viem@2.23.15_bufferutil@4.0.9_typescript@5.8.2_utf-8-validate@5.0.10_zod@3.24.1/node_modules/viem/actions/public/getBlobBaseFee.ts", "../../../../../../../node_modules/.pnpm/viem@2.23.15_bufferutil@4.0.9_typescript@5.8.2_utf-8-validate@5.0.10_zod@3.24.1/node_modules/viem/utils/promise/withCache.ts", "../../../../../../../node_modules/.pnpm/viem@2.23.15_bufferutil@4.0.9_typescript@5.8.2_utf-8-validate@5.0.10_zod@3.24.1/node_modules/viem/actions/public/getBlockNumber.ts", "../../../../../../../node_modules/.pnpm/viem@2.23.15_bufferutil@4.0.9_typescript@5.8.2_utf-8-validate@5.0.10_zod@3.24.1/node_modules/viem/actions/public/getBlockTransactionCount.ts", "../../../../../../../node_modules/.pnpm/viem@2.23.15_bufferutil@4.0.9_typescript@5.8.2_utf-8-validate@5.0.10_zod@3.24.1/node_modules/viem/utils/abi/decodeEventLog.ts", "../../../../../../../node_modules/.pnpm/viem@2.23.15_bufferutil@4.0.9_typescript@5.8.2_utf-8-validate@5.0.10_zod@3.24.1/node_modules/viem/utils/abi/parseEventLogs.ts", "../../../../../../../node_modules/.pnpm/viem@2.23.15_bufferutil@4.0.9_typescript@5.8.2_utf-8-validate@5.0.10_zod@3.24.1/node_modules/viem/actions/public/getLogs.ts", "../../../../../../../node_modules/.pnpm/viem@2.23.15_bufferutil@4.0.9_typescript@5.8.2_utf-8-validate@5.0.10_zod@3.24.1/node_modules/viem/actions/public/getContractEvents.ts", "../../../../../../../node_modules/.pnpm/viem@2.23.15_bufferutil@4.0.9_typescript@5.8.2_utf-8-validate@5.0.10_zod@3.24.1/node_modules/viem/errors/eip712.ts", "../../../../../../../node_modules/.pnpm/viem@2.23.15_bufferutil@4.0.9_typescript@5.8.2_utf-8-validate@5.0.10_zod@3.24.1/node_modules/viem/actions/public/getEip712Domain.ts", "../../../../../../../node_modules/.pnpm/viem@2.23.15_bufferutil@4.0.9_typescript@5.8.2_utf-8-validate@5.0.10_zod@3.24.1/node_modules/viem/utils/formatters/feeHistory.ts", "../../../../../../../node_modules/.pnpm/viem@2.23.15_bufferutil@4.0.9_typescript@5.8.2_utf-8-validate@5.0.10_zod@3.24.1/node_modules/viem/actions/public/getFeeHistory.ts", "../../../../../../../node_modules/.pnpm/viem@2.23.15_bufferutil@4.0.9_typescript@5.8.2_utf-8-validate@5.0.10_zod@3.24.1/node_modules/viem/actions/public/getFilterChanges.ts", "../../../../../../../node_modules/.pnpm/viem@2.23.15_bufferutil@4.0.9_typescript@5.8.2_utf-8-validate@5.0.10_zod@3.24.1/node_modules/viem/actions/public/getFilterLogs.ts", "../../../../../../../node_modules/.pnpm/viem@2.23.15_bufferutil@4.0.9_typescript@5.8.2_utf-8-validate@5.0.10_zod@3.24.1/node_modules/viem/actions/public/getStorageAt.ts", "../../../../../../../node_modules/.pnpm/viem@2.23.15_bufferutil@4.0.9_typescript@5.8.2_utf-8-validate@5.0.10_zod@3.24.1/node_modules/viem/actions/public/getTransaction.ts", "../../../../../../../node_modules/.pnpm/viem@2.23.15_bufferutil@4.0.9_typescript@5.8.2_utf-8-validate@5.0.10_zod@3.24.1/node_modules/viem/actions/public/getTransactionConfirmations.ts", "../../../../../../../node_modules/.pnpm/viem@2.23.15_bufferutil@4.0.9_typescript@5.8.2_utf-8-validate@5.0.10_zod@3.24.1/node_modules/viem/actions/public/getTransactionReceipt.ts", "../../../../../../../node_modules/.pnpm/viem@2.23.15_bufferutil@4.0.9_typescript@5.8.2_utf-8-validate@5.0.10_zod@3.24.1/node_modules/viem/actions/public/multicall.ts", "../../../../../../../node_modules/.pnpm/ox@0.6.9_typescript@5.8.2_zod@3.24.1/node_modules/ox/core/version.ts", "../../../../../../../node_modules/.pnpm/ox@0.6.9_typescript@5.8.2_zod@3.24.1/node_modules/ox/core/internal/errors.ts", "../../../../../../../node_modules/.pnpm/ox@0.6.9_typescript@5.8.2_zod@3.24.1/node_modules/ox/core/Errors.ts", "../../../../../../../node_modules/.pnpm/ox@0.6.9_typescript@5.8.2_zod@3.24.1/node_modules/ox/core/Json.ts", "../../../../../../../node_modules/.pnpm/ox@0.6.9_typescript@5.8.2_zod@3.24.1/node_modules/ox/core/internal/bytes.ts", "../../../../../../../node_modules/.pnpm/ox@0.6.9_typescript@5.8.2_zod@3.24.1/node_modules/ox/core/internal/hex.ts", "../../../../../../../node_modules/.pnpm/ox@0.6.9_typescript@5.8.2_zod@3.24.1/node_modules/ox/core/Bytes.ts", "../../../../../../../node_modules/.pnpm/ox@0.6.9_typescript@5.8.2_zod@3.24.1/node_modules/ox/core/Hex.ts", "../../../../../../../node_modules/.pnpm/ox@0.6.9_typescript@5.8.2_zod@3.24.1/node_modules/ox/core/Withdrawal.ts", "../../../../../../../node_modules/.pnpm/ox@0.6.9_typescript@5.8.2_zod@3.24.1/node_modules/ox/core/BlockOverrides.ts", "../../../../../../../node_modules/.pnpm/viem@2.23.15_bufferutil@4.0.9_typescript@5.8.2_utf-8-validate@5.0.10_zod@3.24.1/node_modules/viem/actions/public/simulateBlocks.ts", "../../../../../../../node_modules/.pnpm/ox@0.6.9_typescript@5.8.2_zod@3.24.1/node_modules/ox/core/Hash.ts", "../../../../../../../node_modules/.pnpm/ox@0.6.9_typescript@5.8.2_zod@3.24.1/node_modules/ox/core/internal/lru.ts", "../../../../../../../node_modules/.pnpm/ox@0.6.9_typescript@5.8.2_zod@3.24.1/node_modules/ox/core/Caches.ts", "../../../../../../../node_modules/.pnpm/ox@0.6.9_typescript@5.8.2_zod@3.24.1/node_modules/ox/core/Address.ts", "../../../../../../../node_modules/.pnpm/ox@0.6.9_typescript@5.8.2_zod@3.24.1/node_modules/ox/core/internal/abiItem.ts", "../../../../../../../node_modules/.pnpm/ox@0.6.9_typescript@5.8.2_zod@3.24.1/node_modules/ox/core/AbiItem.ts", "../../../../../../../node_modules/.pnpm/ox@0.6.9_typescript@5.8.2_zod@3.24.1/node_modules/ox/core/Solidity.ts", "../../../../../../../node_modules/.pnpm/ox@0.6.9_typescript@5.8.2_zod@3.24.1/node_modules/ox/core/internal/abiParameters.ts", "../../../../../../../node_modules/.pnpm/ox@0.6.9_typescript@5.8.2_zod@3.24.1/node_modules/ox/core/internal/cursor.ts", "../../../../../../../node_modules/.pnpm/ox@0.6.9_typescript@5.8.2_zod@3.24.1/node_modules/ox/core/AbiParameters.ts", "../../../../../../../node_modules/.pnpm/ox@0.6.9_typescript@5.8.2_zod@3.24.1/node_modules/ox/core/AbiConstructor.ts", "../../../../../../../node_modules/.pnpm/ox@0.6.9_typescript@5.8.2_zod@3.24.1/node_modules/ox/core/AbiFunction.ts", "../../../../../../../node_modules/.pnpm/viem@2.23.15_bufferutil@4.0.9_typescript@5.8.2_utf-8-validate@5.0.10_zod@3.24.1/node_modules/viem/constants/address.ts", "../../../../../../../node_modules/.pnpm/viem@2.23.15_bufferutil@4.0.9_typescript@5.8.2_utf-8-validate@5.0.10_zod@3.24.1/node_modules/viem/utils/promise/withDedupe.ts", "../../../../../../../node_modules/.pnpm/viem@2.23.15_bufferutil@4.0.9_typescript@5.8.2_utf-8-validate@5.0.10_zod@3.24.1/node_modules/viem/utils/wait.ts", "../../../../../../../node_modules/.pnpm/viem@2.23.15_bufferutil@4.0.9_typescript@5.8.2_utf-8-validate@5.0.10_zod@3.24.1/node_modules/viem/utils/promise/withRetry.ts", "../../../../../../../node_modules/.pnpm/viem@2.23.15_bufferutil@4.0.9_typescript@5.8.2_utf-8-validate@5.0.10_zod@3.24.1/node_modules/viem/utils/buildRequest.ts", "../../../../../../../node_modules/.pnpm/viem@2.23.15_bufferutil@4.0.9_typescript@5.8.2_utf-8-validate@5.0.10_zod@3.24.1/node_modules/viem/utils/promise/withTimeout.ts", "../../../../../../../node_modules/.pnpm/viem@2.23.15_bufferutil@4.0.9_typescript@5.8.2_utf-8-validate@5.0.10_zod@3.24.1/node_modules/viem/utils/rpc/id.ts", "../../../../../../../node_modules/.pnpm/viem@2.23.15_bufferutil@4.0.9_typescript@5.8.2_utf-8-validate@5.0.10_zod@3.24.1/node_modules/viem/utils/rpc/http.ts", "../../../../../../../node_modules/.pnpm/viem@2.23.15_bufferutil@4.0.9_typescript@5.8.2_utf-8-validate@5.0.10_zod@3.24.1/node_modules/viem/utils/rpc/socket.ts", "../../../../../../../node_modules/.pnpm/viem@2.23.15_bufferutil@4.0.9_typescript@5.8.2_utf-8-validate@5.0.10_zod@3.24.1/node_modules/viem/utils/rpc/webSocket.ts", "../../../../../../../node_modules/.pnpm/viem@2.23.15_bufferutil@4.0.9_typescript@5.8.2_utf-8-validate@5.0.10_zod@3.24.1/node_modules/viem/utils/rpc/compat.ts", "../../../../../../../node_modules/.pnpm/viem@2.23.15_bufferutil@4.0.9_typescript@5.8.2_utf-8-validate@5.0.10_zod@3.24.1/node_modules/viem/errors/typedData.ts", "../../../../../../../node_modules/.pnpm/viem@2.23.15_bufferutil@4.0.9_typescript@5.8.2_utf-8-validate@5.0.10_zod@3.24.1/node_modules/viem/utils/signature/hashTypedData.ts", "../../../../../../../node_modules/.pnpm/viem@2.23.15_bufferutil@4.0.9_typescript@5.8.2_utf-8-validate@5.0.10_zod@3.24.1/node_modules/viem/utils/typedData.ts", "../../../../../../../node_modules/.pnpm/viem@2.23.15_bufferutil@4.0.9_typescript@5.8.2_utf-8-validate@5.0.10_zod@3.24.1/node_modules/viem/constants/strings.ts", "../../../../../../../node_modules/.pnpm/viem@2.23.15_bufferutil@4.0.9_typescript@5.8.2_utf-8-validate@5.0.10_zod@3.24.1/node_modules/viem/utils/signature/toPrefixedMessage.ts", "../../../../../../../node_modules/.pnpm/viem@2.23.15_bufferutil@4.0.9_typescript@5.8.2_utf-8-validate@5.0.10_zod@3.24.1/node_modules/viem/utils/signature/hashMessage.ts", "../../../../../../../node_modules/.pnpm/viem@2.23.15_bufferutil@4.0.9_typescript@5.8.2_utf-8-validate@5.0.10_zod@3.24.1/node_modules/viem/constants/bytes.ts", "../../../../../../../node_modules/.pnpm/viem@2.23.15_bufferutil@4.0.9_typescript@5.8.2_utf-8-validate@5.0.10_zod@3.24.1/node_modules/viem/utils/signature/isErc6492Signature.ts", "../../../../../../../node_modules/.pnpm/viem@2.23.15_bufferutil@4.0.9_typescript@5.8.2_utf-8-validate@5.0.10_zod@3.24.1/node_modules/viem/utils/signature/serializeErc6492Signature.ts", "../../../../../../../node_modules/.pnpm/viem@2.23.15_bufferutil@4.0.9_typescript@5.8.2_utf-8-validate@5.0.10_zod@3.24.1/node_modules/viem/utils/nonceManager.ts", "../../../../../../../node_modules/.pnpm/viem@2.23.15_bufferutil@4.0.9_typescript@5.8.2_utf-8-validate@5.0.10_zod@3.24.1/node_modules/viem/actions/public/simulateCalls.ts", "../../../../../../../node_modules/.pnpm/viem@2.23.15_bufferutil@4.0.9_typescript@5.8.2_utf-8-validate@5.0.10_zod@3.24.1/node_modules/viem/utils/observe.ts", "../../../../../../../node_modules/.pnpm/viem@2.23.15_bufferutil@4.0.9_typescript@5.8.2_utf-8-validate@5.0.10_zod@3.24.1/node_modules/viem/utils/poll.ts", "../../../../../../../node_modules/.pnpm/viem@2.23.15_bufferutil@4.0.9_typescript@5.8.2_utf-8-validate@5.0.10_zod@3.24.1/node_modules/viem/actions/public/watchBlocks.ts", "../../../../../../../node_modules/.pnpm/viem@2.23.15_bufferutil@4.0.9_typescript@5.8.2_utf-8-validate@5.0.10_zod@3.24.1/node_modules/viem/actions/public/watchBlockNumber.ts", "../../../../../../../node_modules/.pnpm/viem@2.23.15_bufferutil@4.0.9_typescript@5.8.2_utf-8-validate@5.0.10_zod@3.24.1/node_modules/viem/actions/public/uninstallFilter.ts", "../../../../../../../node_modules/.pnpm/viem@2.23.15_bufferutil@4.0.9_typescript@5.8.2_utf-8-validate@5.0.10_zod@3.24.1/node_modules/viem/actions/public/watchEvent.ts", "../../../../../../../node_modules/.pnpm/viem@2.23.15_bufferutil@4.0.9_typescript@5.8.2_utf-8-validate@5.0.10_zod@3.24.1/node_modules/viem/actions/public/watchPendingTransactions.ts", "../../../../../../../node_modules/.pnpm/viem@2.23.15_bufferutil@4.0.9_typescript@5.8.2_utf-8-validate@5.0.10_zod@3.24.1/node_modules/viem/actions/wallet/getAddresses.ts", "../../../../../../../node_modules/.pnpm/viem@2.23.15_bufferutil@4.0.9_typescript@5.8.2_utf-8-validate@5.0.10_zod@3.24.1/node_modules/viem/actions/wallet/getPermissions.ts", "../../../../../../../node_modules/.pnpm/viem@2.23.15_bufferutil@4.0.9_typescript@5.8.2_utf-8-validate@5.0.10_zod@3.24.1/node_modules/viem/utils/formatters/proof.ts", "../../../../../../../node_modules/.pnpm/viem@2.23.15_bufferutil@4.0.9_typescript@5.8.2_utf-8-validate@5.0.10_zod@3.24.1/node_modules/viem/actions/public/getProof.ts", "../../../../../../../node_modules/.pnpm/viem@2.23.15_bufferutil@4.0.9_typescript@5.8.2_utf-8-validate@5.0.10_zod@3.24.1/node_modules/viem/actions/public/waitForTransactionReceipt.ts", "../../../../../../../node_modules/.pnpm/viem@2.23.15_bufferutil@4.0.9_typescript@5.8.2_utf-8-validate@5.0.10_zod@3.24.1/node_modules/viem/actions/wallet/requestAddresses.ts", "../../../../../../../node_modules/.pnpm/viem@2.23.15_bufferutil@4.0.9_typescript@5.8.2_utf-8-validate@5.0.10_zod@3.24.1/node_modules/viem/actions/wallet/requestPermissions.ts", "../../../../../../../node_modules/.pnpm/viem@2.23.15_bufferutil@4.0.9_typescript@5.8.2_utf-8-validate@5.0.10_zod@3.24.1/node_modules/viem/actions/wallet/signTransaction.ts", "../../../../../../../node_modules/.pnpm/viem@2.23.15_bufferutil@4.0.9_typescript@5.8.2_utf-8-validate@5.0.10_zod@3.24.1/node_modules/viem/actions/wallet/signMessage.ts", "../../../../../../../node_modules/.pnpm/viem@2.23.15_bufferutil@4.0.9_typescript@5.8.2_utf-8-validate@5.0.10_zod@3.24.1/node_modules/viem/actions/wallet/signTypedData.ts", "../../../../../../../node_modules/.pnpm/viem@2.23.15_bufferutil@4.0.9_typescript@5.8.2_utf-8-validate@5.0.10_zod@3.24.1/node_modules/viem/actions/public/simulateContract.ts", "../../../../../../../node_modules/.pnpm/viem@2.23.15_bufferutil@4.0.9_typescript@5.8.2_utf-8-validate@5.0.10_zod@3.24.1/node_modules/viem/actions/wallet/switchChain.ts", "../../../../../../../node_modules/.pnpm/viem@2.23.15_bufferutil@4.0.9_typescript@5.8.2_utf-8-validate@5.0.10_zod@3.24.1/node_modules/viem/utils/signature/serializeSignature.ts", "../../../../../../../node_modules/.pnpm/viem@2.23.15_bufferutil@4.0.9_typescript@5.8.2_utf-8-validate@5.0.10_zod@3.24.1/node_modules/viem/actions/public/verifyHash.ts", "../../../../../../../node_modules/.pnpm/viem@2.23.15_bufferutil@4.0.9_typescript@5.8.2_utf-8-validate@5.0.10_zod@3.24.1/node_modules/viem/actions/public/verifyMessage.ts", "../../../../../../../node_modules/.pnpm/viem@2.23.15_bufferutil@4.0.9_typescript@5.8.2_utf-8-validate@5.0.10_zod@3.24.1/node_modules/viem/actions/public/verifyTypedData.ts", "../../../../../../../node_modules/.pnpm/viem@2.23.15_bufferutil@4.0.9_typescript@5.8.2_utf-8-validate@5.0.10_zod@3.24.1/node_modules/viem/actions/wallet/watchAsset.ts", "../../../../../../../node_modules/.pnpm/viem@2.23.15_bufferutil@4.0.9_typescript@5.8.2_utf-8-validate@5.0.10_zod@3.24.1/node_modules/viem/actions/public/watchContractEvent.ts", "../../../../../../../node_modules/.pnpm/viem@2.23.15_bufferutil@4.0.9_typescript@5.8.2_utf-8-validate@5.0.10_zod@3.24.1/node_modules/viem/actions/wallet/writeContract.ts", "../../../../../../../node_modules/.pnpm/@wagmi+core@2.16.7_@tanstack+query-core@5.66.4_@types+react@18.3.18_react@18.3.1_typescript@5_ai33gbiqsbbo6g2x247kphgnka/node_modules/@wagmi/core/src/utils/getAction.ts", "../../../../../../../node_modules/.pnpm/@wagmi+core@2.16.7_@tanstack+query-core@5.66.4_@types+react@18.3.18_react@18.3.1_typescript@5_ai33gbiqsbbo6g2x247kphgnka/node_modules/@wagmi/core/src/actions/call.ts", "../../../../../../../node_modules/.pnpm/@wagmi+core@2.16.7_@tanstack+query-core@5.66.4_@types+react@18.3.18_react@18.3.1_typescript@5_ai33gbiqsbbo6g2x247kphgnka/node_modules/@wagmi/core/src/version.ts", "../../../../../../../node_modules/.pnpm/@wagmi+core@2.16.7_@tanstack+query-core@5.66.4_@types+react@18.3.18_react@18.3.1_typescript@5_ai33gbiqsbbo6g2x247kphgnka/node_modules/@wagmi/core/src/utils/getVersion.ts", "../../../../../../../node_modules/.pnpm/@wagmi+core@2.16.7_@tanstack+query-core@5.66.4_@types+react@18.3.18_react@18.3.1_typescript@5_ai33gbiqsbbo6g2x247kphgnka/node_modules/@wagmi/core/src/errors/base.ts", "../../../../../../../node_modules/.pnpm/@wagmi+core@2.16.7_@tanstack+query-core@5.66.4_@types+react@18.3.18_react@18.3.1_typescript@5_ai33gbiqsbbo6g2x247kphgnka/node_modules/@wagmi/core/src/errors/config.ts", "../../../../../../../node_modules/.pnpm/@wagmi+core@2.16.7_@tanstack+query-core@5.66.4_@types+react@18.3.18_react@18.3.1_typescript@5_ai33gbiqsbbo6g2x247kphgnka/node_modules/@wagmi/core/src/actions/connect.ts", "../../../../../../../node_modules/.pnpm/viem@2.23.15_bufferutil@4.0.9_typescript@5.8.2_utf-8-validate@5.0.10_zod@3.24.1/node_modules/viem/utils/uid.ts", "../../../../../../../node_modules/.pnpm/viem@2.23.15_bufferutil@4.0.9_typescript@5.8.2_utf-8-validate@5.0.10_zod@3.24.1/node_modules/viem/clients/createClient.ts", "../../../../../../../node_modules/.pnpm/viem@2.23.15_bufferutil@4.0.9_typescript@5.8.2_utf-8-validate@5.0.10_zod@3.24.1/node_modules/viem/clients/transports/createTransport.ts", "../../../../../../../node_modules/.pnpm/viem@2.23.15_bufferutil@4.0.9_typescript@5.8.2_utf-8-validate@5.0.10_zod@3.24.1/node_modules/viem/clients/transports/custom.ts", "../../../../../../../node_modules/.pnpm/viem@2.23.15_bufferutil@4.0.9_typescript@5.8.2_utf-8-validate@5.0.10_zod@3.24.1/node_modules/viem/clients/transports/fallback.ts", "../../../../../../../node_modules/.pnpm/viem@2.23.15_bufferutil@4.0.9_typescript@5.8.2_utf-8-validate@5.0.10_zod@3.24.1/node_modules/viem/errors/transport.ts", "../../../../../../../node_modules/.pnpm/viem@2.23.15_bufferutil@4.0.9_typescript@5.8.2_utf-8-validate@5.0.10_zod@3.24.1/node_modules/viem/clients/transports/http.ts", "../../../../../../../node_modules/.pnpm/viem@2.23.15_bufferutil@4.0.9_typescript@5.8.2_utf-8-validate@5.0.10_zod@3.24.1/node_modules/viem/utils/siwe/parseSiweMessage.ts", "../../../../../../../node_modules/.pnpm/viem@2.23.15_bufferutil@4.0.9_typescript@5.8.2_utf-8-validate@5.0.10_zod@3.24.1/node_modules/viem/utils/siwe/validateSiweMessage.ts", "../../../../../../../node_modules/.pnpm/viem@2.23.15_bufferutil@4.0.9_typescript@5.8.2_utf-8-validate@5.0.10_zod@3.24.1/node_modules/viem/actions/siwe/verifySiweMessage.ts", "../../../../../../../node_modules/.pnpm/viem@2.23.15_bufferutil@4.0.9_typescript@5.8.2_utf-8-validate@5.0.10_zod@3.24.1/node_modules/viem/clients/decorators/public.ts", "../../../../../../../node_modules/.pnpm/viem@2.23.15_bufferutil@4.0.9_typescript@5.8.2_utf-8-validate@5.0.10_zod@3.24.1/node_modules/viem/clients/decorators/wallet.ts", "../../../../../../../node_modules/.pnpm/viem@2.23.15_bufferutil@4.0.9_typescript@5.8.2_utf-8-validate@5.0.10_zod@3.24.1/node_modules/viem/clients/transports/webSocket.ts", "../../../../../../../node_modules/.pnpm/@wagmi+core@2.16.7_@tanstack+query-core@5.66.4_@types+react@18.3.18_react@18.3.1_typescript@5_ai33gbiqsbbo6g2x247kphgnka/node_modules/@wagmi/core/src/actions/getConnectorClient.ts", "../../../../../../../node_modules/.pnpm/@wagmi+core@2.16.7_@tanstack+query-core@5.66.4_@types+react@18.3.18_react@18.3.1_typescript@5_ai33gbiqsbbo6g2x247kphgnka/node_modules/@wagmi/core/src/actions/deployContract.ts", "../../../../../../../node_modules/.pnpm/@wagmi+core@2.16.7_@tanstack+query-core@5.66.4_@types+react@18.3.18_react@18.3.1_typescript@5_ai33gbiqsbbo6g2x247kphgnka/node_modules/@wagmi/core/src/actions/disconnect.ts", "../../../../../../../node_modules/.pnpm/@wagmi+core@2.16.7_@tanstack+query-core@5.66.4_@types+react@18.3.18_react@18.3.1_typescript@5_ai33gbiqsbbo6g2x247kphgnka/node_modules/@wagmi/core/src/actions/estimateGas.ts", "../../../../../../../node_modules/.pnpm/@wagmi+core@2.16.7_@tanstack+query-core@5.66.4_@types+react@18.3.18_react@18.3.1_typescript@5_ai33gbiqsbbo6g2x247kphgnka/node_modules/@wagmi/core/src/utils/getUnit.ts", "../../../../../../../node_modules/.pnpm/@wagmi+core@2.16.7_@tanstack+query-core@5.66.4_@types+react@18.3.18_react@18.3.1_typescript@5_ai33gbiqsbbo6g2x247kphgnka/node_modules/@wagmi/core/src/actions/estimateFeesPerGas.ts", "../../../../../../../node_modules/.pnpm/@wagmi+core@2.16.7_@tanstack+query-core@5.66.4_@types+react@18.3.18_react@18.3.1_typescript@5_ai33gbiqsbbo6g2x247kphgnka/node_modules/@wagmi/core/src/actions/estimateMaxPriorityFeePerGas.ts", "../../../../../../../node_modules/.pnpm/@wagmi+core@2.16.7_@tanstack+query-core@5.66.4_@types+react@18.3.18_react@18.3.1_typescript@5_ai33gbiqsbbo6g2x247kphgnka/node_modules/@wagmi/core/src/actions/getAccount.ts", "../../../../../../../node_modules/.pnpm/@wagmi+core@2.16.7_@tanstack+query-core@5.66.4_@types+react@18.3.18_react@18.3.1_typescript@5_ai33gbiqsbbo6g2x247kphgnka/node_modules/@wagmi/core/src/actions/multicall.ts", "../../../../../../../node_modules/.pnpm/@wagmi+core@2.16.7_@tanstack+query-core@5.66.4_@types+react@18.3.18_react@18.3.1_typescript@5_ai33gbiqsbbo6g2x247kphgnka/node_modules/@wagmi/core/src/actions/readContract.ts", "../../../../../../../node_modules/.pnpm/@wagmi+core@2.16.7_@tanstack+query-core@5.66.4_@types+react@18.3.18_react@18.3.1_typescript@5_ai33gbiqsbbo6g2x247kphgnka/node_modules/@wagmi/core/src/actions/readContracts.ts", "../../../../../../../node_modules/.pnpm/@wagmi+core@2.16.7_@tanstack+query-core@5.66.4_@types+react@18.3.18_react@18.3.1_typescript@5_ai33gbiqsbbo6g2x247kphgnka/node_modules/@wagmi/core/src/actions/getBalance.ts", "../../../../../../../node_modules/.pnpm/@wagmi+core@2.16.7_@tanstack+query-core@5.66.4_@types+react@18.3.18_react@18.3.1_typescript@5_ai33gbiqsbbo6g2x247kphgnka/node_modules/@wagmi/core/src/actions/getBlock.ts", "../../../../../../../node_modules/.pnpm/@wagmi+core@2.16.7_@tanstack+query-core@5.66.4_@types+react@18.3.18_react@18.3.1_typescript@5_ai33gbiqsbbo6g2x247kphgnka/node_modules/@wagmi/core/src/actions/getBlockNumber.ts", "../../../../../../../node_modules/.pnpm/@wagmi+core@2.16.7_@tanstack+query-core@5.66.4_@types+react@18.3.18_react@18.3.1_typescript@5_ai33gbiqsbbo6g2x247kphgnka/node_modules/@wagmi/core/src/actions/getBlockTransactionCount.ts", "../../../../../../../node_modules/.pnpm/@wagmi+core@2.16.7_@tanstack+query-core@5.66.4_@types+react@18.3.18_react@18.3.1_typescript@5_ai33gbiqsbbo6g2x247kphgnka/node_modules/@wagmi/core/src/actions/getBytecode.ts", "../../../../../../../node_modules/.pnpm/@wagmi+core@2.16.7_@tanstack+query-core@5.66.4_@types+react@18.3.18_react@18.3.1_typescript@5_ai33gbiqsbbo6g2x247kphgnka/node_modules/@wagmi/core/src/actions/getChainId.ts", "../../../../../../../node_modules/.pnpm/@wagmi+core@2.16.7_@tanstack+query-core@5.66.4_@types+react@18.3.18_react@18.3.1_typescript@5_ai33gbiqsbbo6g2x247kphgnka/node_modules/@wagmi/core/src/utils/deepEqual.ts", "../../../../../../../node_modules/.pnpm/@wagmi+core@2.16.7_@tanstack+query-core@5.66.4_@types+react@18.3.18_react@18.3.1_typescript@5_ai33gbiqsbbo6g2x247kphgnka/node_modules/@wagmi/core/src/actions/getChains.ts", "../../../../../../../node_modules/.pnpm/@wagmi+core@2.16.7_@tanstack+query-core@5.66.4_@types+react@18.3.18_react@18.3.1_typescript@5_ai33gbiqsbbo6g2x247kphgnka/node_modules/@wagmi/core/src/actions/getClient.ts", "../../../../../../../node_modules/.pnpm/@wagmi+core@2.16.7_@tanstack+query-core@5.66.4_@types+react@18.3.18_react@18.3.1_typescript@5_ai33gbiqsbbo6g2x247kphgnka/node_modules/@wagmi/core/src/actions/getConnections.ts", "../../../../../../../node_modules/.pnpm/@wagmi+core@2.16.7_@tanstack+query-core@5.66.4_@types+react@18.3.18_react@18.3.1_typescript@5_ai33gbiqsbbo6g2x247kphgnka/node_modules/@wagmi/core/src/actions/getConnectors.ts", "../../../../../../../node_modules/.pnpm/@wagmi+core@2.16.7_@tanstack+query-core@5.66.4_@types+react@18.3.18_react@18.3.1_typescript@5_ai33gbiqsbbo6g2x247kphgnka/node_modules/@wagmi/core/src/actions/getEnsAddress.ts", "../../../../../../../node_modules/.pnpm/@wagmi+core@2.16.7_@tanstack+query-core@5.66.4_@types+react@18.3.18_react@18.3.1_typescript@5_ai33gbiqsbbo6g2x247kphgnka/node_modules/@wagmi/core/src/actions/getEnsAvatar.ts", "../../../../../../../node_modules/.pnpm/@wagmi+core@2.16.7_@tanstack+query-core@5.66.4_@types+react@18.3.18_react@18.3.1_typescript@5_ai33gbiqsbbo6g2x247kphgnka/node_modules/@wagmi/core/src/actions/getEnsName.ts", "../../../../../../../node_modules/.pnpm/@wagmi+core@2.16.7_@tanstack+query-core@5.66.4_@types+react@18.3.18_react@18.3.1_typescript@5_ai33gbiqsbbo6g2x247kphgnka/node_modules/@wagmi/core/src/actions/getEnsResolver.ts", "../../../../../../../node_modules/.pnpm/@wagmi+core@2.16.7_@tanstack+query-core@5.66.4_@types+react@18.3.18_react@18.3.1_typescript@5_ai33gbiqsbbo6g2x247kphgnka/node_modules/@wagmi/core/src/actions/getEnsText.ts", "../../../../../../../node_modules/.pnpm/@wagmi+core@2.16.7_@tanstack+query-core@5.66.4_@types+react@18.3.18_react@18.3.1_typescript@5_ai33gbiqsbbo6g2x247kphgnka/node_modules/@wagmi/core/src/actions/getFeeHistory.ts", "../../../../../../../node_modules/.pnpm/@wagmi+core@2.16.7_@tanstack+query-core@5.66.4_@types+react@18.3.18_react@18.3.1_typescript@5_ai33gbiqsbbo6g2x247kphgnka/node_modules/@wagmi/core/src/actions/getGasPrice.ts", "../../../../../../../node_modules/.pnpm/@wagmi+core@2.16.7_@tanstack+query-core@5.66.4_@types+react@18.3.18_react@18.3.1_typescript@5_ai33gbiqsbbo6g2x247kphgnka/node_modules/@wagmi/core/src/actions/getProof.ts", "../../../../../../../node_modules/.pnpm/@wagmi+core@2.16.7_@tanstack+query-core@5.66.4_@types+react@18.3.18_react@18.3.1_typescript@5_ai33gbiqsbbo6g2x247kphgnka/node_modules/@wagmi/core/src/actions/getPublicClient.ts", "../../../../../../../node_modules/.pnpm/@wagmi+core@2.16.7_@tanstack+query-core@5.66.4_@types+react@18.3.18_react@18.3.1_typescript@5_ai33gbiqsbbo6g2x247kphgnka/node_modules/@wagmi/core/src/actions/getStorageAt.ts", "../../../../../../../node_modules/.pnpm/@wagmi+core@2.16.7_@tanstack+query-core@5.66.4_@types+react@18.3.18_react@18.3.1_typescript@5_ai33gbiqsbbo6g2x247kphgnka/node_modules/@wagmi/core/src/actions/getToken.ts", "../../../../../../../node_modules/.pnpm/@wagmi+core@2.16.7_@tanstack+query-core@5.66.4_@types+react@18.3.18_react@18.3.1_typescript@5_ai33gbiqsbbo6g2x247kphgnka/node_modules/@wagmi/core/src/actions/getTransaction.ts", "../../../../../../../node_modules/.pnpm/@wagmi+core@2.16.7_@tanstack+query-core@5.66.4_@types+react@18.3.18_react@18.3.1_typescript@5_ai33gbiqsbbo6g2x247kphgnka/node_modules/@wagmi/core/src/actions/getTransactionConfirmations.ts", "../../../../../../../node_modules/.pnpm/@wagmi+core@2.16.7_@tanstack+query-core@5.66.4_@types+react@18.3.18_react@18.3.1_typescript@5_ai33gbiqsbbo6g2x247kphgnka/node_modules/@wagmi/core/src/actions/getTransactionCount.ts", "../../../../../../../node_modules/.pnpm/@wagmi+core@2.16.7_@tanstack+query-core@5.66.4_@types+react@18.3.18_react@18.3.1_typescript@5_ai33gbiqsbbo6g2x247kphgnka/node_modules/@wagmi/core/src/actions/getTransactionReceipt.ts", "../../../../../../../node_modules/.pnpm/@wagmi+core@2.16.7_@tanstack+query-core@5.66.4_@types+react@18.3.18_react@18.3.1_typescript@5_ai33gbiqsbbo6g2x247kphgnka/node_modules/@wagmi/core/src/actions/getWalletClient.ts", "../../../../../../../node_modules/.pnpm/@wagmi+core@2.16.7_@tanstack+query-core@5.66.4_@types+react@18.3.18_react@18.3.1_typescript@5_ai33gbiqsbbo6g2x247kphgnka/node_modules/@wagmi/core/src/actions/prepareTransactionRequest.ts", "../../../../../../../node_modules/.pnpm/@wagmi+core@2.16.7_@tanstack+query-core@5.66.4_@types+react@18.3.18_react@18.3.1_typescript@5_ai33gbiqsbbo6g2x247kphgnka/node_modules/@wagmi/core/src/actions/reconnect.ts", "../../../../../../../node_modules/.pnpm/@wagmi+core@2.16.7_@tanstack+query-core@5.66.4_@types+react@18.3.18_react@18.3.1_typescript@5_ai33gbiqsbbo6g2x247kphgnka/node_modules/@wagmi/core/src/actions/sendTransaction.ts", "../../../../../../../node_modules/.pnpm/@wagmi+core@2.16.7_@tanstack+query-core@5.66.4_@types+react@18.3.18_react@18.3.1_typescript@5_ai33gbiqsbbo6g2x247kphgnka/node_modules/@wagmi/core/src/actions/signMessage.ts", "../../../../../../../node_modules/.pnpm/@wagmi+core@2.16.7_@tanstack+query-core@5.66.4_@types+react@18.3.18_react@18.3.1_typescript@5_ai33gbiqsbbo6g2x247kphgnka/node_modules/@wagmi/core/src/actions/signTypedData.ts", "../../../../../../../node_modules/.pnpm/@wagmi+core@2.16.7_@tanstack+query-core@5.66.4_@types+react@18.3.18_react@18.3.1_typescript@5_ai33gbiqsbbo6g2x247kphgnka/node_modules/@wagmi/core/src/actions/simulateContract.ts", "../../../../../../../node_modules/.pnpm/@wagmi+core@2.16.7_@tanstack+query-core@5.66.4_@types+react@18.3.18_react@18.3.1_typescript@5_ai33gbiqsbbo6g2x247kphgnka/node_modules/@wagmi/core/src/actions/switchAccount.ts", "../../../../../../../node_modules/.pnpm/@wagmi+core@2.16.7_@tanstack+query-core@5.66.4_@types+react@18.3.18_react@18.3.1_typescript@5_ai33gbiqsbbo6g2x247kphgnka/node_modules/@wagmi/core/src/errors/connector.ts", "../../../../../../../node_modules/.pnpm/@wagmi+core@2.16.7_@tanstack+query-core@5.66.4_@types+react@18.3.18_react@18.3.1_typescript@5_ai33gbiqsbbo6g2x247kphgnka/node_modules/@wagmi/core/src/actions/switchChain.ts", "../../../../../../../node_modules/.pnpm/@wagmi+core@2.16.7_@tanstack+query-core@5.66.4_@types+react@18.3.18_react@18.3.1_typescript@5_ai33gbiqsbbo6g2x247kphgnka/node_modules/@wagmi/core/src/actions/verifyMessage.ts", "../../../../../../../node_modules/.pnpm/@wagmi+core@2.16.7_@tanstack+query-core@5.66.4_@types+react@18.3.18_react@18.3.1_typescript@5_ai33gbiqsbbo6g2x247kphgnka/node_modules/@wagmi/core/src/actions/verifyTypedData.ts", "../../../../../../../node_modules/.pnpm/@wagmi+core@2.16.7_@tanstack+query-core@5.66.4_@types+react@18.3.18_react@18.3.1_typescript@5_ai33gbiqsbbo6g2x247kphgnka/node_modules/@wagmi/core/src/actions/watchAccount.ts", "../../../../../../../node_modules/.pnpm/@wagmi+core@2.16.7_@tanstack+query-core@5.66.4_@types+react@18.3.18_react@18.3.1_typescript@5_ai33gbiqsbbo6g2x247kphgnka/node_modules/@wagmi/core/src/actions/watchAsset.ts", "../../../../../../../node_modules/.pnpm/@wagmi+core@2.16.7_@tanstack+query-core@5.66.4_@types+react@18.3.18_react@18.3.1_typescript@5_ai33gbiqsbbo6g2x247kphgnka/node_modules/@wagmi/core/src/actions/watchBlocks.ts", "../../../../../../../node_modules/.pnpm/@wagmi+core@2.16.7_@tanstack+query-core@5.66.4_@types+react@18.3.18_react@18.3.1_typescript@5_ai33gbiqsbbo6g2x247kphgnka/node_modules/@wagmi/core/src/actions/watchBlockNumber.ts", "../../../../../../../node_modules/.pnpm/@wagmi+core@2.16.7_@tanstack+query-core@5.66.4_@types+react@18.3.18_react@18.3.1_typescript@5_ai33gbiqsbbo6g2x247kphgnka/node_modules/@wagmi/core/src/actions/watchChainId.ts", "../../../../../../../node_modules/.pnpm/@wagmi+core@2.16.7_@tanstack+query-core@5.66.4_@types+react@18.3.18_react@18.3.1_typescript@5_ai33gbiqsbbo6g2x247kphgnka/node_modules/@wagmi/core/src/actions/watchClient.ts", "../../../../../../../node_modules/.pnpm/@wagmi+core@2.16.7_@tanstack+query-core@5.66.4_@types+react@18.3.18_react@18.3.1_typescript@5_ai33gbiqsbbo6g2x247kphgnka/node_modules/@wagmi/core/src/actions/watchConnections.ts", "../../../../../../../node_modules/.pnpm/@wagmi+core@2.16.7_@tanstack+query-core@5.66.4_@types+react@18.3.18_react@18.3.1_typescript@5_ai33gbiqsbbo6g2x247kphgnka/node_modules/@wagmi/core/src/actions/watchConnectors.ts", "../../../../../../../node_modules/.pnpm/@wagmi+core@2.16.7_@tanstack+query-core@5.66.4_@types+react@18.3.18_react@18.3.1_typescript@5_ai33gbiqsbbo6g2x247kphgnka/node_modules/@wagmi/core/src/actions/watchContractEvent.ts", "../../../../../../../node_modules/.pnpm/@wagmi+core@2.16.7_@tanstack+query-core@5.66.4_@types+react@18.3.18_react@18.3.1_typescript@5_ai33gbiqsbbo6g2x247kphgnka/node_modules/@wagmi/core/src/actions/watchPendingTransactions.ts", "../../../../../../../node_modules/.pnpm/@wagmi+core@2.16.7_@tanstack+query-core@5.66.4_@types+react@18.3.18_react@18.3.1_typescript@5_ai33gbiqsbbo6g2x247kphgnka/node_modules/@wagmi/core/src/actions/watchPublicClient.ts", "../../../../../../../node_modules/.pnpm/@wagmi+core@2.16.7_@tanstack+query-core@5.66.4_@types+react@18.3.18_react@18.3.1_typescript@5_ai33gbiqsbbo6g2x247kphgnka/node_modules/@wagmi/core/src/actions/waitForTransactionReceipt.ts", "../../../../../../../node_modules/.pnpm/@wagmi+core@2.16.7_@tanstack+query-core@5.66.4_@types+react@18.3.18_react@18.3.1_typescript@5_ai33gbiqsbbo6g2x247kphgnka/node_modules/@wagmi/core/src/actions/writeContract.ts", "../../../../../../../node_modules/.pnpm/@wagmi+core@2.16.7_@tanstack+query-core@5.66.4_@types+react@18.3.18_react@18.3.1_typescript@5_ai33gbiqsbbo6g2x247kphgnka/node_modules/@wagmi/core/src/connectors/createConnector.ts", "../../../../../../../node_modules/.pnpm/@wagmi+core@2.16.7_@tanstack+query-core@5.66.4_@types+react@18.3.18_react@18.3.1_typescript@5_ai33gbiqsbbo6g2x247kphgnka/node_modules/@wagmi/core/src/connectors/injected.ts", "../../../../../../../node_modules/.pnpm/@wagmi+core@2.16.7_@tanstack+query-core@5.66.4_@types+react@18.3.18_react@18.3.1_typescript@5_ai33gbiqsbbo6g2x247kphgnka/node_modules/@wagmi/core/src/connectors/mock.ts", "../../../../../../../node_modules/.pnpm/zustand@5.0.0_@types+react@18.3.18_react@18.3.1_use-sync-external-store@1.4.0_react@18.3.1_/node_modules/zustand/esm/middleware.mjs", "../../../../../../../node_modules/.pnpm/zustand@5.0.0_@types+react@18.3.18_react@18.3.1_use-sync-external-store@1.4.0_react@18.3.1_/node_modules/zustand/esm/vanilla.mjs", "../../../../../../../node_modules/.pnpm/@wagmi+core@2.16.7_@tanstack+query-core@5.66.4_@types+react@18.3.18_react@18.3.1_typescript@5_ai33gbiqsbbo6g2x247kphgnka/node_modules/@wagmi/core/src/createEmitter.ts", "../../../../../../../node_modules/.pnpm/@wagmi+core@2.16.7_@tanstack+query-core@5.66.4_@types+react@18.3.18_react@18.3.1_typescript@5_ai33gbiqsbbo6g2x247kphgnka/node_modules/@wagmi/core/src/utils/deserialize.ts", "../../../../../../../node_modules/.pnpm/@wagmi+core@2.16.7_@tanstack+query-core@5.66.4_@types+react@18.3.18_react@18.3.1_typescript@5_ai33gbiqsbbo6g2x247kphgnka/node_modules/@wagmi/core/src/utils/serialize.ts", "../../../../../../../node_modules/.pnpm/@wagmi+core@2.16.7_@tanstack+query-core@5.66.4_@types+react@18.3.18_react@18.3.1_typescript@5_ai33gbiqsbbo6g2x247kphgnka/node_modules/@wagmi/core/src/createStorage.ts", "../../../../../../../node_modules/.pnpm/@wagmi+core@2.16.7_@tanstack+query-core@5.66.4_@types+react@18.3.18_react@18.3.1_typescript@5_ai33gbiqsbbo6g2x247kphgnka/node_modules/@wagmi/core/src/utils/uid.ts", "../../../../../../../node_modules/.pnpm/@wagmi+core@2.16.7_@tanstack+query-core@5.66.4_@types+react@18.3.18_react@18.3.1_typescript@5_ai33gbiqsbbo6g2x247kphgnka/node_modules/@wagmi/core/src/createConfig.ts", "../../../../../../../node_modules/.pnpm/@wagmi+core@2.16.7_@tanstack+query-core@5.66.4_@types+react@18.3.18_react@18.3.1_typescript@5_ai33gbiqsbbo6g2x247kphgnka/node_modules/@wagmi/core/src/hydrate.ts", "../../../../../../../node_modules/.pnpm/@wagmi+core@2.16.7_@tanstack+query-core@5.66.4_@types+react@18.3.18_react@18.3.1_typescript@5_ai33gbiqsbbo6g2x247kphgnka/node_modules/@wagmi/core/src/transports/connector.ts", "../../../../../../../node_modules/.pnpm/@wagmi+core@2.16.7_@tanstack+query-core@5.66.4_@types+react@18.3.18_react@18.3.1_typescript@5_ai33gbiqsbbo6g2x247kphgnka/node_modules/@wagmi/core/src/transports/fallback.ts", "../../../../../../../node_modules/.pnpm/@wagmi+core@2.16.7_@tanstack+query-core@5.66.4_@types+react@18.3.18_react@18.3.1_typescript@5_ai33gbiqsbbo6g2x247kphgnka/node_modules/@wagmi/core/src/utils/cookie.ts", "../../../../../../../node_modules/.pnpm/@wagmi+core@2.16.7_@tanstack+query-core@5.66.4_@types+react@18.3.18_react@18.3.1_typescript@5_ai33gbiqsbbo6g2x247kphgnka/node_modules/@wagmi/core/src/utils/normalizeChainId.ts", "../../../../../../../node_modules/.pnpm/wagmi@2.14.15_@tanstack+query-core@5.66.4_@tanstack+react-query@5.45.1_react@18.3.1__@types+r_fi3vzdagybtfmjsnztrwv6mimq/node_modules/wagmi/src/hydrate.ts", "../../../../../../../node_modules/.pnpm/wagmi@2.14.15_@tanstack+query-core@5.66.4_@tanstack+react-query@5.45.1_react@18.3.1__@types+r_fi3vzdagybtfmjsnztrwv6mimq/node_modules/wagmi/src/version.ts", "../../../../../../../node_modules/.pnpm/wagmi@2.14.15_@tanstack+query-core@5.66.4_@tanstack+react-query@5.45.1_react@18.3.1__@types+r_fi3vzdagybtfmjsnztrwv6mimq/node_modules/wagmi/src/utils/getVersion.ts", "../../../../../../../node_modules/.pnpm/wagmi@2.14.15_@tanstack+query-core@5.66.4_@tanstack+react-query@5.45.1_react@18.3.1__@types+r_fi3vzdagybtfmjsnztrwv6mimq/node_modules/wagmi/src/errors/base.ts", "../../../../../../../node_modules/.pnpm/wagmi@2.14.15_@tanstack+query-core@5.66.4_@tanstack+react-query@5.45.1_react@18.3.1__@types+r_fi3vzdagybtfmjsnztrwv6mimq/node_modules/wagmi/src/errors/context.ts", "../../../../../../../node_modules/.pnpm/wagmi@2.14.15_@tanstack+query-core@5.66.4_@tanstack+react-query@5.45.1_react@18.3.1__@types+r_fi3vzdagybtfmjsnztrwv6mimq/node_modules/wagmi/src/hooks/useConfig.ts", "../../../../../../../node_modules/.pnpm/@wagmi+core@2.16.7_@tanstack+query-core@5.66.4_@types+react@18.3.18_react@18.3.1_typescript@5_ai33gbiqsbbo6g2x247kphgnka/node_modules/@wagmi/core/src/actions/watchChains.ts", "../../../../../../../node_modules/.pnpm/wagmi@2.14.15_@tanstack+query-core@5.66.4_@tanstack+react-query@5.45.1_react@18.3.1__@types+r_fi3vzdagybtfmjsnztrwv6mimq/node_modules/wagmi/src/hooks/useSyncExternalStoreWithTracked.ts", "../../../../../../../node_modules/.pnpm/wagmi@2.14.15_@tanstack+query-core@5.66.4_@tanstack+react-query@5.45.1_react@18.3.1__@types+r_fi3vzdagybtfmjsnztrwv6mimq/node_modules/wagmi/src/hooks/useAccount.ts", "../../../../../../../node_modules/.pnpm/wagmi@2.14.15_@tanstack+query-core@5.66.4_@tanstack+react-query@5.45.1_react@18.3.1__@types+r_fi3vzdagybtfmjsnztrwv6mimq/node_modules/wagmi/src/hooks/useAccountEffect.ts", "../../../../../../../node_modules/.pnpm/@tanstack+query-core@5.66.4/node_modules/@tanstack/query-core/src/subscribable.ts", "../../../../../../../node_modules/.pnpm/@tanstack+query-core@5.66.4/node_modules/@tanstack/query-core/src/utils.ts", "../../../../../../../node_modules/.pnpm/@tanstack+query-core@5.66.4/node_modules/@tanstack/query-core/src/focusManager.ts", "../../../../../../../node_modules/.pnpm/@tanstack+query-core@5.66.4/node_modules/@tanstack/query-core/src/onlineManager.ts", "../../../../../../../node_modules/.pnpm/@tanstack+query-core@5.66.4/node_modules/@tanstack/query-core/src/notifyManager.ts", "../../../../../../../node_modules/.pnpm/@tanstack+query-core@5.66.4/node_modules/@tanstack/query-core/src/types.ts", "../../../../../../../node_modules/.pnpm/@wagmi+core@2.16.7_@tanstack+query-core@5.66.4_@types+react@18.3.18_react@18.3.1_typescript@5_ai33gbiqsbbo6g2x247kphgnka/node_modules/@wagmi/core/src/query/utils.ts", "../../../../../../../node_modules/.pnpm/@wagmi+core@2.16.7_@tanstack+query-core@5.66.4_@types+react@18.3.18_react@18.3.1_typescript@5_ai33gbiqsbbo6g2x247kphgnka/node_modules/@wagmi/core/src/query/call.ts", "../../../../../../../node_modules/.pnpm/@wagmi+core@2.16.7_@tanstack+query-core@5.66.4_@types+react@18.3.18_react@18.3.1_typescript@5_ai33gbiqsbbo6g2x247kphgnka/node_modules/@wagmi/core/src/query/connect.ts", "../../../../../../../node_modules/.pnpm/@wagmi+core@2.16.7_@tanstack+query-core@5.66.4_@types+react@18.3.18_react@18.3.1_typescript@5_ai33gbiqsbbo6g2x247kphgnka/node_modules/@wagmi/core/src/query/deployContract.ts", "../../../../../../../node_modules/.pnpm/@wagmi+core@2.16.7_@tanstack+query-core@5.66.4_@types+react@18.3.18_react@18.3.1_typescript@5_ai33gbiqsbbo6g2x247kphgnka/node_modules/@wagmi/core/src/query/disconnect.ts", "../../../../../../../node_modules/.pnpm/@wagmi+core@2.16.7_@tanstack+query-core@5.66.4_@types+react@18.3.18_react@18.3.1_typescript@5_ai33gbiqsbbo6g2x247kphgnka/node_modules/@wagmi/core/src/query/estimateFeesPerGas.ts", "../../../../../../../node_modules/.pnpm/@wagmi+core@2.16.7_@tanstack+query-core@5.66.4_@types+react@18.3.18_react@18.3.1_typescript@5_ai33gbiqsbbo6g2x247kphgnka/node_modules/@wagmi/core/src/query/estimateGas.ts", "../../../../../../../node_modules/.pnpm/@wagmi+core@2.16.7_@tanstack+query-core@5.66.4_@types+react@18.3.18_react@18.3.1_typescript@5_ai33gbiqsbbo6g2x247kphgnka/node_modules/@wagmi/core/src/query/estimateMaxPriorityFeePerGas.ts", "../../../../../../../node_modules/.pnpm/@wagmi+core@2.16.7_@tanstack+query-core@5.66.4_@types+react@18.3.18_react@18.3.1_typescript@5_ai33gbiqsbbo6g2x247kphgnka/node_modules/@wagmi/core/src/query/getBalance.ts", "../../../../../../../node_modules/.pnpm/@wagmi+core@2.16.7_@tanstack+query-core@5.66.4_@types+react@18.3.18_react@18.3.1_typescript@5_ai33gbiqsbbo6g2x247kphgnka/node_modules/@wagmi/core/src/query/getBlock.ts", "../../../../../../../node_modules/.pnpm/@wagmi+core@2.16.7_@tanstack+query-core@5.66.4_@types+react@18.3.18_react@18.3.1_typescript@5_ai33gbiqsbbo6g2x247kphgnka/node_modules/@wagmi/core/src/query/getBlockNumber.ts", "../../../../../../../node_modules/.pnpm/@wagmi+core@2.16.7_@tanstack+query-core@5.66.4_@types+react@18.3.18_react@18.3.1_typescript@5_ai33gbiqsbbo6g2x247kphgnka/node_modules/@wagmi/core/src/query/getBlockTransactionCount.ts", "../../../../../../../node_modules/.pnpm/@wagmi+core@2.16.7_@tanstack+query-core@5.66.4_@types+react@18.3.18_react@18.3.1_typescript@5_ai33gbiqsbbo6g2x247kphgnka/node_modules/@wagmi/core/src/query/getBytecode.ts", "../../../../../../../node_modules/.pnpm/@wagmi+core@2.16.7_@tanstack+query-core@5.66.4_@types+react@18.3.18_react@18.3.1_typescript@5_ai33gbiqsbbo6g2x247kphgnka/node_modules/@wagmi/core/src/query/getConnectorClient.ts", "../../../../../../../node_modules/.pnpm/@wagmi+core@2.16.7_@tanstack+query-core@5.66.4_@types+react@18.3.18_react@18.3.1_typescript@5_ai33gbiqsbbo6g2x247kphgnka/node_modules/@wagmi/core/src/query/getEnsAddress.ts", "../../../../../../../node_modules/.pnpm/@wagmi+core@2.16.7_@tanstack+query-core@5.66.4_@types+react@18.3.18_react@18.3.1_typescript@5_ai33gbiqsbbo6g2x247kphgnka/node_modules/@wagmi/core/src/query/getEnsAvatar.ts", "../../../../../../../node_modules/.pnpm/@wagmi+core@2.16.7_@tanstack+query-core@5.66.4_@types+react@18.3.18_react@18.3.1_typescript@5_ai33gbiqsbbo6g2x247kphgnka/node_modules/@wagmi/core/src/query/getEnsName.ts", "../../../../../../../node_modules/.pnpm/@wagmi+core@2.16.7_@tanstack+query-core@5.66.4_@types+react@18.3.18_react@18.3.1_typescript@5_ai33gbiqsbbo6g2x247kphgnka/node_modules/@wagmi/core/src/query/getEnsResolver.ts", "../../../../../../../node_modules/.pnpm/@wagmi+core@2.16.7_@tanstack+query-core@5.66.4_@types+react@18.3.18_react@18.3.1_typescript@5_ai33gbiqsbbo6g2x247kphgnka/node_modules/@wagmi/core/src/query/getEnsText.ts", "../../../../../../../node_modules/.pnpm/@wagmi+core@2.16.7_@tanstack+query-core@5.66.4_@types+react@18.3.18_react@18.3.1_typescript@5_ai33gbiqsbbo6g2x247kphgnka/node_modules/@wagmi/core/src/query/getFeeHistory.ts", "../../../../../../../node_modules/.pnpm/@wagmi+core@2.16.7_@tanstack+query-core@5.66.4_@types+react@18.3.18_react@18.3.1_typescript@5_ai33gbiqsbbo6g2x247kphgnka/node_modules/@wagmi/core/src/query/getGasPrice.ts", "../../../../../../../node_modules/.pnpm/@wagmi+core@2.16.7_@tanstack+query-core@5.66.4_@types+react@18.3.18_react@18.3.1_typescript@5_ai33gbiqsbbo6g2x247kphgnka/node_modules/@wagmi/core/src/query/getProof.ts", "../../../../../../../node_modules/.pnpm/@wagmi+core@2.16.7_@tanstack+query-core@5.66.4_@types+react@18.3.18_react@18.3.1_typescript@5_ai33gbiqsbbo6g2x247kphgnka/node_modules/@wagmi/core/src/query/getStorageAt.ts", "../../../../../../../node_modules/.pnpm/@wagmi+core@2.16.7_@tanstack+query-core@5.66.4_@types+react@18.3.18_react@18.3.1_typescript@5_ai33gbiqsbbo6g2x247kphgnka/node_modules/@wagmi/core/src/query/getToken.ts", "../../../../../../../node_modules/.pnpm/@wagmi+core@2.16.7_@tanstack+query-core@5.66.4_@types+react@18.3.18_react@18.3.1_typescript@5_ai33gbiqsbbo6g2x247kphgnka/node_modules/@wagmi/core/src/query/getTransaction.ts", "../../../../../../../node_modules/.pnpm/@wagmi+core@2.16.7_@tanstack+query-core@5.66.4_@types+react@18.3.18_react@18.3.1_typescript@5_ai33gbiqsbbo6g2x247kphgnka/node_modules/@wagmi/core/src/query/getTransactionConfirmations.ts", "../../../../../../../node_modules/.pnpm/@wagmi+core@2.16.7_@tanstack+query-core@5.66.4_@types+react@18.3.18_react@18.3.1_typescript@5_ai33gbiqsbbo6g2x247kphgnka/node_modules/@wagmi/core/src/query/getTransactionCount.ts", "../../../../../../../node_modules/.pnpm/@wagmi+core@2.16.7_@tanstack+query-core@5.66.4_@types+react@18.3.18_react@18.3.1_typescript@5_ai33gbiqsbbo6g2x247kphgnka/node_modules/@wagmi/core/src/query/getTransactionReceipt.ts", "../../../../../../../node_modules/.pnpm/@wagmi+core@2.16.7_@tanstack+query-core@5.66.4_@types+react@18.3.18_react@18.3.1_typescript@5_ai33gbiqsbbo6g2x247kphgnka/node_modules/@wagmi/core/src/query/getWalletClient.ts", "../../../../../../../node_modules/.pnpm/@wagmi+core@2.16.7_@tanstack+query-core@5.66.4_@types+react@18.3.18_react@18.3.1_typescript@5_ai33gbiqsbbo6g2x247kphgnka/node_modules/@wagmi/core/src/query/infiniteReadContracts.ts", "../../../../../../../node_modules/.pnpm/@wagmi+core@2.16.7_@tanstack+query-core@5.66.4_@types+react@18.3.18_react@18.3.1_typescript@5_ai33gbiqsbbo6g2x247kphgnka/node_modules/@wagmi/core/src/query/prepareTransactionRequest.ts", "../../../../../../../node_modules/.pnpm/@wagmi+core@2.16.7_@tanstack+query-core@5.66.4_@types+react@18.3.18_react@18.3.1_typescript@5_ai33gbiqsbbo6g2x247kphgnka/node_modules/@wagmi/core/src/query/readContract.ts", "../../../../../../../node_modules/.pnpm/@wagmi+core@2.16.7_@tanstack+query-core@5.66.4_@types+react@18.3.18_react@18.3.1_typescript@5_ai33gbiqsbbo6g2x247kphgnka/node_modules/@wagmi/core/src/query/readContracts.ts", "../../../../../../../node_modules/.pnpm/@wagmi+core@2.16.7_@tanstack+query-core@5.66.4_@types+react@18.3.18_react@18.3.1_typescript@5_ai33gbiqsbbo6g2x247kphgnka/node_modules/@wagmi/core/src/query/reconnect.ts", "../../../../../../../node_modules/.pnpm/@wagmi+core@2.16.7_@tanstack+query-core@5.66.4_@types+react@18.3.18_react@18.3.1_typescript@5_ai33gbiqsbbo6g2x247kphgnka/node_modules/@wagmi/core/src/query/sendTransaction.ts", "../../../../../../../node_modules/.pnpm/@wagmi+core@2.16.7_@tanstack+query-core@5.66.4_@types+react@18.3.18_react@18.3.1_typescript@5_ai33gbiqsbbo6g2x247kphgnka/node_modules/@wagmi/core/src/query/signMessage.ts", "../../../../../../../node_modules/.pnpm/@wagmi+core@2.16.7_@tanstack+query-core@5.66.4_@types+react@18.3.18_react@18.3.1_typescript@5_ai33gbiqsbbo6g2x247kphgnka/node_modules/@wagmi/core/src/query/signTypedData.ts", "../../../../../../../node_modules/.pnpm/@wagmi+core@2.16.7_@tanstack+query-core@5.66.4_@types+react@18.3.18_react@18.3.1_typescript@5_ai33gbiqsbbo6g2x247kphgnka/node_modules/@wagmi/core/src/query/switchAccount.ts", "../../../../../../../node_modules/.pnpm/@wagmi+core@2.16.7_@tanstack+query-core@5.66.4_@types+react@18.3.18_react@18.3.1_typescript@5_ai33gbiqsbbo6g2x247kphgnka/node_modules/@wagmi/core/src/query/simulateContract.ts", "../../../../../../../node_modules/.pnpm/@wagmi+core@2.16.7_@tanstack+query-core@5.66.4_@types+react@18.3.18_react@18.3.1_typescript@5_ai33gbiqsbbo6g2x247kphgnka/node_modules/@wagmi/core/src/query/switchChain.ts", "../../../../../../../node_modules/.pnpm/@wagmi+core@2.16.7_@tanstack+query-core@5.66.4_@types+react@18.3.18_react@18.3.1_typescript@5_ai33gbiqsbbo6g2x247kphgnka/node_modules/@wagmi/core/src/query/verifyMessage.ts", "../../../../../../../node_modules/.pnpm/@wagmi+core@2.16.7_@tanstack+query-core@5.66.4_@types+react@18.3.18_react@18.3.1_typescript@5_ai33gbiqsbbo6g2x247kphgnka/node_modules/@wagmi/core/src/query/verifyTypedData.ts", "../../../../../../../node_modules/.pnpm/@wagmi+core@2.16.7_@tanstack+query-core@5.66.4_@types+react@18.3.18_react@18.3.1_typescript@5_ai33gbiqsbbo6g2x247kphgnka/node_modules/@wagmi/core/src/query/waitForTransactionReceipt.ts", "../../../../../../../node_modules/.pnpm/@wagmi+core@2.16.7_@tanstack+query-core@5.66.4_@types+react@18.3.18_react@18.3.1_typescript@5_ai33gbiqsbbo6g2x247kphgnka/node_modules/@wagmi/core/src/query/watchAsset.ts", "../../../../../../../node_modules/.pnpm/@wagmi+core@2.16.7_@tanstack+query-core@5.66.4_@types+react@18.3.18_react@18.3.1_typescript@5_ai33gbiqsbbo6g2x247kphgnka/node_modules/@wagmi/core/src/query/writeContract.ts", "../../../../../../../node_modules/.pnpm/wagmi@2.14.15_@tanstack+query-core@5.66.4_@tanstack+react-query@5.45.1_react@18.3.1__@types+r_fi3vzdagybtfmjsnztrwv6mimq/node_modules/wagmi/src/utils/query.ts", "../../../../../../../node_modules/.pnpm/wagmi@2.14.15_@tanstack+query-core@5.66.4_@tanstack+react-query@5.45.1_react@18.3.1__@types+r_fi3vzdagybtfmjsnztrwv6mimq/node_modules/wagmi/src/hooks/useChainId.ts", "../../../../../../../node_modules/.pnpm/wagmi@2.14.15_@tanstack+query-core@5.66.4_@tanstack+react-query@5.45.1_react@18.3.1__@types+r_fi3vzdagybtfmjsnztrwv6mimq/node_modules/wagmi/src/hooks/useBalance.ts", "../../../../../../../node_modules/.pnpm/wagmi@2.14.15_@tanstack+query-core@5.66.4_@tanstack+react-query@5.45.1_react@18.3.1__@types+r_fi3vzdagybtfmjsnztrwv6mimq/node_modules/wagmi/src/hooks/useWatchBlocks.ts", "../../../../../../../node_modules/.pnpm/wagmi@2.14.15_@tanstack+query-core@5.66.4_@tanstack+react-query@5.45.1_react@18.3.1__@types+r_fi3vzdagybtfmjsnztrwv6mimq/node_modules/wagmi/src/hooks/useBlock.ts", "../../../../../../../node_modules/.pnpm/wagmi@2.14.15_@tanstack+query-core@5.66.4_@tanstack+react-query@5.45.1_react@18.3.1__@types+r_fi3vzdagybtfmjsnztrwv6mimq/node_modules/wagmi/src/hooks/useWatchBlockNumber.ts", "../../../../../../../node_modules/.pnpm/wagmi@2.14.15_@tanstack+query-core@5.66.4_@tanstack+react-query@5.45.1_react@18.3.1__@types+r_fi3vzdagybtfmjsnztrwv6mimq/node_modules/wagmi/src/hooks/useBlockNumber.ts", "../../../../../../../node_modules/.pnpm/wagmi@2.14.15_@tanstack+query-core@5.66.4_@tanstack+react-query@5.45.1_react@18.3.1__@types+r_fi3vzdagybtfmjsnztrwv6mimq/node_modules/wagmi/src/hooks/useBlockTransactionCount.ts", "../../../../../../../node_modules/.pnpm/wagmi@2.14.15_@tanstack+query-core@5.66.4_@tanstack+react-query@5.45.1_react@18.3.1__@types+r_fi3vzdagybtfmjsnztrwv6mimq/node_modules/wagmi/src/hooks/useBytecode.ts", "../../../../../../../node_modules/.pnpm/wagmi@2.14.15_@tanstack+query-core@5.66.4_@tanstack+react-query@5.45.1_react@18.3.1__@types+r_fi3vzdagybtfmjsnztrwv6mimq/node_modules/wagmi/src/hooks/useCall.ts", "../../../../../../../node_modules/.pnpm/wagmi@2.14.15_@tanstack+query-core@5.66.4_@tanstack+react-query@5.45.1_react@18.3.1__@types+r_fi3vzdagybtfmjsnztrwv6mimq/node_modules/wagmi/src/hooks/useChains.ts", "../../../../../../../node_modules/.pnpm/wagmi@2.14.15_@tanstack+query-core@5.66.4_@tanstack+react-query@5.45.1_react@18.3.1__@types+r_fi3vzdagybtfmjsnztrwv6mimq/node_modules/wagmi/src/hooks/useClient.ts", "../../../../../../../node_modules/.pnpm/wagmi@2.14.15_@tanstack+query-core@5.66.4_@tanstack+react-query@5.45.1_react@18.3.1__@types+r_fi3vzdagybtfmjsnztrwv6mimq/node_modules/wagmi/src/hooks/useConnect.ts", "../../../../../../../node_modules/.pnpm/wagmi@2.14.15_@tanstack+query-core@5.66.4_@tanstack+react-query@5.45.1_react@18.3.1__@types+r_fi3vzdagybtfmjsnztrwv6mimq/node_modules/wagmi/src/hooks/useConnectors.ts", "../../../../../../../node_modules/.pnpm/wagmi@2.14.15_@tanstack+query-core@5.66.4_@tanstack+react-query@5.45.1_react@18.3.1__@types+r_fi3vzdagybtfmjsnztrwv6mimq/node_modules/wagmi/src/hooks/useConnections.ts", "../../../../../../../node_modules/.pnpm/wagmi@2.14.15_@tanstack+query-core@5.66.4_@tanstack+react-query@5.45.1_react@18.3.1__@types+r_fi3vzdagybtfmjsnztrwv6mimq/node_modules/wagmi/src/hooks/useConnectorClient.ts", "../../../../../../../node_modules/.pnpm/wagmi@2.14.15_@tanstack+query-core@5.66.4_@tanstack+react-query@5.45.1_react@18.3.1__@types+r_fi3vzdagybtfmjsnztrwv6mimq/node_modules/wagmi/src/hooks/useDeployContract.ts", "../../../../../../../node_modules/.pnpm/wagmi@2.14.15_@tanstack+query-core@5.66.4_@tanstack+react-query@5.45.1_react@18.3.1__@types+r_fi3vzdagybtfmjsnztrwv6mimq/node_modules/wagmi/src/hooks/useDisconnect.ts", "../../../../../../../node_modules/.pnpm/wagmi@2.14.15_@tanstack+query-core@5.66.4_@tanstack+react-query@5.45.1_react@18.3.1__@types+r_fi3vzdagybtfmjsnztrwv6mimq/node_modules/wagmi/src/hooks/useEnsAddress.ts", "../../../../../../../node_modules/.pnpm/wagmi@2.14.15_@tanstack+query-core@5.66.4_@tanstack+react-query@5.45.1_react@18.3.1__@types+r_fi3vzdagybtfmjsnztrwv6mimq/node_modules/wagmi/src/hooks/useEnsAvatar.ts", "../../../../../../../node_modules/.pnpm/wagmi@2.14.15_@tanstack+query-core@5.66.4_@tanstack+react-query@5.45.1_react@18.3.1__@types+r_fi3vzdagybtfmjsnztrwv6mimq/node_modules/wagmi/src/hooks/useEnsName.ts", "../../../../../../../node_modules/.pnpm/wagmi@2.14.15_@tanstack+query-core@5.66.4_@tanstack+react-query@5.45.1_react@18.3.1__@types+r_fi3vzdagybtfmjsnztrwv6mimq/node_modules/wagmi/src/hooks/useEnsResolver.ts", "../../../../../../../node_modules/.pnpm/wagmi@2.14.15_@tanstack+query-core@5.66.4_@tanstack+react-query@5.45.1_react@18.3.1__@types+r_fi3vzdagybtfmjsnztrwv6mimq/node_modules/wagmi/src/hooks/useEnsText.ts", "../../../../../../../node_modules/.pnpm/wagmi@2.14.15_@tanstack+query-core@5.66.4_@tanstack+react-query@5.45.1_react@18.3.1__@types+r_fi3vzdagybtfmjsnztrwv6mimq/node_modules/wagmi/src/hooks/useEstimateFeesPerGas.ts", "../../../../../../../node_modules/.pnpm/wagmi@2.14.15_@tanstack+query-core@5.66.4_@tanstack+react-query@5.45.1_react@18.3.1__@types+r_fi3vzdagybtfmjsnztrwv6mimq/node_modules/wagmi/src/hooks/useEstimateGas.ts", "../../../../../../../node_modules/.pnpm/wagmi@2.14.15_@tanstack+query-core@5.66.4_@tanstack+react-query@5.45.1_react@18.3.1__@types+r_fi3vzdagybtfmjsnztrwv6mimq/node_modules/wagmi/src/hooks/useEstimateMaxPriorityFeePerGas.ts", "../../../../../../../node_modules/.pnpm/wagmi@2.14.15_@tanstack+query-core@5.66.4_@tanstack+react-query@5.45.1_react@18.3.1__@types+r_fi3vzdagybtfmjsnztrwv6mimq/node_modules/wagmi/src/hooks/useFeeHistory.ts", "../../../../../../../node_modules/.pnpm/wagmi@2.14.15_@tanstack+query-core@5.66.4_@tanstack+react-query@5.45.1_react@18.3.1__@types+r_fi3vzdagybtfmjsnztrwv6mimq/node_modules/wagmi/src/hooks/useGasPrice.ts", "../../../../../../../node_modules/.pnpm/wagmi@2.14.15_@tanstack+query-core@5.66.4_@tanstack+react-query@5.45.1_react@18.3.1__@types+r_fi3vzdagybtfmjsnztrwv6mimq/node_modules/wagmi/src/hooks/useInfiniteReadContracts.ts", "../../../../../../../node_modules/.pnpm/wagmi@2.14.15_@tanstack+query-core@5.66.4_@tanstack+react-query@5.45.1_react@18.3.1__@types+r_fi3vzdagybtfmjsnztrwv6mimq/node_modules/wagmi/src/hooks/usePrepareTransactionRequest.ts", "../../../../../../../node_modules/.pnpm/wagmi@2.14.15_@tanstack+query-core@5.66.4_@tanstack+react-query@5.45.1_react@18.3.1__@types+r_fi3vzdagybtfmjsnztrwv6mimq/node_modules/wagmi/src/hooks/useProof.ts", "../../../../../../../node_modules/.pnpm/wagmi@2.14.15_@tanstack+query-core@5.66.4_@tanstack+react-query@5.45.1_react@18.3.1__@types+r_fi3vzdagybtfmjsnztrwv6mimq/node_modules/wagmi/src/hooks/usePublicClient.ts", "../../../../../../../node_modules/.pnpm/wagmi@2.14.15_@tanstack+query-core@5.66.4_@tanstack+react-query@5.45.1_react@18.3.1__@types+r_fi3vzdagybtfmjsnztrwv6mimq/node_modules/wagmi/src/hooks/useReadContract.ts", "../../../../../../../node_modules/.pnpm/wagmi@2.14.15_@tanstack+query-core@5.66.4_@tanstack+react-query@5.45.1_react@18.3.1__@types+r_fi3vzdagybtfmjsnztrwv6mimq/node_modules/wagmi/src/hooks/useReadContracts.ts", "../../../../../../../node_modules/.pnpm/wagmi@2.14.15_@tanstack+query-core@5.66.4_@tanstack+react-query@5.45.1_react@18.3.1__@types+r_fi3vzdagybtfmjsnztrwv6mimq/node_modules/wagmi/src/hooks/useReconnect.ts", "../../../../../../../node_modules/.pnpm/wagmi@2.14.15_@tanstack+query-core@5.66.4_@tanstack+react-query@5.45.1_react@18.3.1__@types+r_fi3vzdagybtfmjsnztrwv6mimq/node_modules/wagmi/src/hooks/useSendTransaction.ts", "../../../../../../../node_modules/.pnpm/wagmi@2.14.15_@tanstack+query-core@5.66.4_@tanstack+react-query@5.45.1_react@18.3.1__@types+r_fi3vzdagybtfmjsnztrwv6mimq/node_modules/wagmi/src/hooks/useSignMessage.ts", "../../../../../../../node_modules/.pnpm/wagmi@2.14.15_@tanstack+query-core@5.66.4_@tanstack+react-query@5.45.1_react@18.3.1__@types+r_fi3vzdagybtfmjsnztrwv6mimq/node_modules/wagmi/src/hooks/useSignTypedData.ts", "../../../../../../../node_modules/.pnpm/wagmi@2.14.15_@tanstack+query-core@5.66.4_@tanstack+react-query@5.45.1_react@18.3.1__@types+r_fi3vzdagybtfmjsnztrwv6mimq/node_modules/wagmi/src/hooks/useSimulateContract.ts", "../../../../../../../node_modules/.pnpm/wagmi@2.14.15_@tanstack+query-core@5.66.4_@tanstack+react-query@5.45.1_react@18.3.1__@types+r_fi3vzdagybtfmjsnztrwv6mimq/node_modules/wagmi/src/hooks/useStorageAt.ts", "../../../../../../../node_modules/.pnpm/wagmi@2.14.15_@tanstack+query-core@5.66.4_@tanstack+react-query@5.45.1_react@18.3.1__@types+r_fi3vzdagybtfmjsnztrwv6mimq/node_modules/wagmi/src/hooks/useSwitchAccount.ts", "../../../../../../../node_modules/.pnpm/wagmi@2.14.15_@tanstack+query-core@5.66.4_@tanstack+react-query@5.45.1_react@18.3.1__@types+r_fi3vzdagybtfmjsnztrwv6mimq/node_modules/wagmi/src/hooks/useSwitchChain.ts", "../../../../../../../node_modules/.pnpm/wagmi@2.14.15_@tanstack+query-core@5.66.4_@tanstack+react-query@5.45.1_react@18.3.1__@types+r_fi3vzdagybtfmjsnztrwv6mimq/node_modules/wagmi/src/hooks/useToken.ts", "../../../../../../../node_modules/.pnpm/wagmi@2.14.15_@tanstack+query-core@5.66.4_@tanstack+react-query@5.45.1_react@18.3.1__@types+r_fi3vzdagybtfmjsnztrwv6mimq/node_modules/wagmi/src/hooks/useTransaction.ts", "../../../../../../../node_modules/.pnpm/wagmi@2.14.15_@tanstack+query-core@5.66.4_@tanstack+react-query@5.45.1_react@18.3.1__@types+r_fi3vzdagybtfmjsnztrwv6mimq/node_modules/wagmi/src/hooks/useTransactionConfirmations.ts", "../../../../../../../node_modules/.pnpm/wagmi@2.14.15_@tanstack+query-core@5.66.4_@tanstack+react-query@5.45.1_react@18.3.1__@types+r_fi3vzdagybtfmjsnztrwv6mimq/node_modules/wagmi/src/hooks/useTransactionCount.ts", "../../../../../../../node_modules/.pnpm/wagmi@2.14.15_@tanstack+query-core@5.66.4_@tanstack+react-query@5.45.1_react@18.3.1__@types+r_fi3vzdagybtfmjsnztrwv6mimq/node_modules/wagmi/src/hooks/useTransactionReceipt.ts", "../../../../../../../node_modules/.pnpm/wagmi@2.14.15_@tanstack+query-core@5.66.4_@tanstack+react-query@5.45.1_react@18.3.1__@types+r_fi3vzdagybtfmjsnztrwv6mimq/node_modules/wagmi/src/hooks/useVerifyMessage.ts", "../../../../../../../node_modules/.pnpm/wagmi@2.14.15_@tanstack+query-core@5.66.4_@tanstack+react-query@5.45.1_react@18.3.1__@types+r_fi3vzdagybtfmjsnztrwv6mimq/node_modules/wagmi/src/hooks/useVerifyTypedData.ts", "../../../../../../../node_modules/.pnpm/wagmi@2.14.15_@tanstack+query-core@5.66.4_@tanstack+react-query@5.45.1_react@18.3.1__@types+r_fi3vzdagybtfmjsnztrwv6mimq/node_modules/wagmi/src/hooks/useWalletClient.ts", "../../../../../../../node_modules/.pnpm/wagmi@2.14.15_@tanstack+query-core@5.66.4_@tanstack+react-query@5.45.1_react@18.3.1__@types+r_fi3vzdagybtfmjsnztrwv6mimq/node_modules/wagmi/src/hooks/useWaitForTransactionReceipt.ts", "../../../../../../../node_modules/.pnpm/wagmi@2.14.15_@tanstack+query-core@5.66.4_@tanstack+react-query@5.45.1_react@18.3.1__@types+r_fi3vzdagybtfmjsnztrwv6mimq/node_modules/wagmi/src/hooks/useWatchAsset.ts", "../../../../../../../node_modules/.pnpm/wagmi@2.14.15_@tanstack+query-core@5.66.4_@tanstack+react-query@5.45.1_react@18.3.1__@types+r_fi3vzdagybtfmjsnztrwv6mimq/node_modules/wagmi/src/hooks/useWatchContractEvent.ts", "../../../../../../../node_modules/.pnpm/wagmi@2.14.15_@tanstack+query-core@5.66.4_@tanstack+react-query@5.45.1_react@18.3.1__@types+r_fi3vzdagybtfmjsnztrwv6mimq/node_modules/wagmi/src/hooks/useWatchPendingTransactions.ts", "../../../../../../../node_modules/.pnpm/wagmi@2.14.15_@tanstack+query-core@5.66.4_@tanstack+react-query@5.45.1_react@18.3.1__@types+r_fi3vzdagybtfmjsnztrwv6mimq/node_modules/wagmi/src/hooks/useWriteContract.ts"],
|
|
4
|
-
"sourcesContent": ["/**\n * @license React\n * use-sync-external-store-shim.development.js\n *\n * Copyright (c) Meta Platforms, Inc. and affiliates.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\n\"use strict\";\n\"production\" !== process.env.NODE_ENV &&\n (function () {\n function is(x, y) {\n return (x === y && (0 !== x || 1 / x === 1 / y)) || (x !== x && y !== y);\n }\n function useSyncExternalStore$2(subscribe, getSnapshot) {\n didWarnOld18Alpha ||\n void 0 === React.startTransition ||\n ((didWarnOld18Alpha = !0),\n console.error(\n \"You are using an outdated, pre-release alpha of React 18 that does not support useSyncExternalStore. The use-sync-external-store shim will not work correctly. Upgrade to a newer pre-release.\"\n ));\n var value = getSnapshot();\n if (!didWarnUncachedGetSnapshot) {\n var cachedValue = getSnapshot();\n objectIs(value, cachedValue) ||\n (console.error(\n \"The result of getSnapshot should be cached to avoid an infinite loop\"\n ),\n (didWarnUncachedGetSnapshot = !0));\n }\n cachedValue = useState({\n inst: { value: value, getSnapshot: getSnapshot }\n });\n var inst = cachedValue[0].inst,\n forceUpdate = cachedValue[1];\n useLayoutEffect(\n function () {\n inst.value = value;\n inst.getSnapshot = getSnapshot;\n checkIfSnapshotChanged(inst) && forceUpdate({ inst: inst });\n },\n [subscribe, value, getSnapshot]\n );\n useEffect(\n function () {\n checkIfSnapshotChanged(inst) && forceUpdate({ inst: inst });\n return subscribe(function () {\n checkIfSnapshotChanged(inst) && forceUpdate({ inst: inst });\n });\n },\n [subscribe]\n );\n useDebugValue(value);\n return value;\n }\n function checkIfSnapshotChanged(inst) {\n var latestGetSnapshot = inst.getSnapshot;\n inst = inst.value;\n try {\n var nextValue = latestGetSnapshot();\n return !objectIs(inst, nextValue);\n } catch (error) {\n return !0;\n }\n }\n function useSyncExternalStore$1(subscribe, getSnapshot) {\n return getSnapshot();\n }\n \"undefined\" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ &&\n \"function\" ===\n typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart &&\n __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());\n var React = require(\"react\"),\n objectIs = \"function\" === typeof Object.is ? Object.is : is,\n useState = React.useState,\n useEffect = React.useEffect,\n useLayoutEffect = React.useLayoutEffect,\n useDebugValue = React.useDebugValue,\n didWarnOld18Alpha = !1,\n didWarnUncachedGetSnapshot = !1,\n shim =\n \"undefined\" === typeof window ||\n \"undefined\" === typeof window.document ||\n \"undefined\" === typeof window.document.createElement\n ? useSyncExternalStore$1\n : useSyncExternalStore$2;\n exports.useSyncExternalStore =\n void 0 !== React.useSyncExternalStore ? React.useSyncExternalStore : shim;\n \"undefined\" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ &&\n \"function\" ===\n typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop &&\n __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error());\n })();\n", "'use strict';\n\nif (process.env.NODE_ENV === 'production') {\n module.exports = require('../cjs/use-sync-external-store-shim.production.js');\n} else {\n module.exports = require('../cjs/use-sync-external-store-shim.development.js');\n}\n", "/**\n * @license React\n * use-sync-external-store-shim/with-selector.development.js\n *\n * Copyright (c) Meta Platforms, Inc. and affiliates.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\n\"use strict\";\n\"production\" !== process.env.NODE_ENV &&\n (function () {\n function is(x, y) {\n return (x === y && (0 !== x || 1 / x === 1 / y)) || (x !== x && y !== y);\n }\n \"undefined\" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ &&\n \"function\" ===\n typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart &&\n __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());\n var React = require(\"react\"),\n shim = require(\"use-sync-external-store/shim\"),\n objectIs = \"function\" === typeof Object.is ? Object.is : is,\n useSyncExternalStore = shim.useSyncExternalStore,\n useRef = React.useRef,\n useEffect = React.useEffect,\n useMemo = React.useMemo,\n useDebugValue = React.useDebugValue;\n exports.useSyncExternalStoreWithSelector = function (\n subscribe,\n getSnapshot,\n getServerSnapshot,\n selector,\n isEqual\n ) {\n var instRef = useRef(null);\n if (null === instRef.current) {\n var inst = { hasValue: !1, value: null };\n instRef.current = inst;\n } else inst = instRef.current;\n instRef = useMemo(\n function () {\n function memoizedSelector(nextSnapshot) {\n if (!hasMemo) {\n hasMemo = !0;\n memoizedSnapshot = nextSnapshot;\n nextSnapshot = selector(nextSnapshot);\n if (void 0 !== isEqual && inst.hasValue) {\n var currentSelection = inst.value;\n if (isEqual(currentSelection, nextSnapshot))\n return (memoizedSelection = currentSelection);\n }\n return (memoizedSelection = nextSnapshot);\n }\n currentSelection = memoizedSelection;\n if (objectIs(memoizedSnapshot, nextSnapshot))\n return currentSelection;\n var nextSelection = selector(nextSnapshot);\n if (void 0 !== isEqual && isEqual(currentSelection, nextSelection))\n return (memoizedSnapshot = nextSnapshot), currentSelection;\n memoizedSnapshot = nextSnapshot;\n return (memoizedSelection = nextSelection);\n }\n var hasMemo = !1,\n memoizedSnapshot,\n memoizedSelection,\n maybeGetServerSnapshot =\n void 0 === getServerSnapshot ? null : getServerSnapshot;\n return [\n function () {\n return memoizedSelector(getSnapshot());\n },\n null === maybeGetServerSnapshot\n ? void 0\n : function () {\n return memoizedSelector(maybeGetServerSnapshot());\n }\n ];\n },\n [getSnapshot, getServerSnapshot, selector, isEqual]\n );\n var value = useSyncExternalStore(subscribe, instRef[0], instRef[1]);\n useEffect(\n function () {\n inst.hasValue = !0;\n inst.value = value;\n },\n [value]\n );\n useDebugValue(value);\n return value;\n };\n \"undefined\" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ &&\n \"function\" ===\n typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop &&\n __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error());\n })();\n", "'use strict';\n\nif (process.env.NODE_ENV === 'production') {\n module.exports = require('../cjs/use-sync-external-store-shim/with-selector.production.js');\n} else {\n module.exports = require('../cjs/use-sync-external-store-shim/with-selector.development.js');\n}\n", "'use client'\n\nimport type { ResolvedRegister, State } from '@wagmi/core'\nimport { createContext, createElement } from 'react'\nimport { Hydrate } from './hydrate.js'\n\nexport const WagmiContext = createContext<\n ResolvedRegister['config'] | undefined\n>(undefined)\n\nexport type WagmiProviderProps = {\n config: ResolvedRegister['config']\n initialState?: State | undefined\n reconnectOnMount?: boolean | undefined\n}\n\nexport function WagmiProvider(\n parameters: React.PropsWithChildren<WagmiProviderProps>,\n) {\n const { children, config } = parameters\n\n const props = { value: config }\n return createElement(\n Hydrate,\n parameters,\n createElement(WagmiContext.Provider, props, children),\n )\n}\n", "import type { Account } from '../../accounts/types.js'\nimport type { Client } from '../../clients/createClient.js'\nimport type { Transport } from '../../clients/transports/createTransport.js'\nimport type { ErrorType } from '../../errors/utils.js'\nimport type { Chain } from '../../types/chain.js'\nimport type { RequestErrorType } from '../../utils/buildRequest.js'\nimport {\n type NumberToHexErrorType,\n numberToHex,\n} from '../../utils/encoding/toHex.js'\n\nexport type AddChainParameters = {\n /** The chain to add to the wallet. */\n chain: Chain\n}\n\nexport type AddChainErrorType =\n | RequestErrorType\n | NumberToHexErrorType\n | ErrorType\n\n/**\n * Adds an EVM chain to the wallet.\n *\n * - Docs: https://viem.sh/docs/actions/wallet/addChain\n * - JSON-RPC Methods: [`eth_addEthereumChain`](https://eips.ethereum.org/EIPS/eip-3085)\n *\n * @param client - Client to use\n * @param parameters - {@link AddChainParameters}\n *\n * @example\n * import { createWalletClient, custom } from 'viem'\n * import { optimism } from 'viem/chains'\n * import { addChain } from 'viem/wallet'\n *\n * const client = createWalletClient({\n * transport: custom(window.ethereum),\n * })\n * await addChain(client, { chain: optimism })\n */\nexport async function addChain<\n chain extends Chain | undefined,\n account extends Account | undefined,\n>(client: Client<Transport, chain, account>, { chain }: AddChainParameters) {\n const { id, name, nativeCurrency, rpcUrls, blockExplorers } = chain\n await client.request(\n {\n method: 'wallet_addEthereumChain',\n params: [\n {\n chainId: numberToHex(id),\n chainName: name,\n nativeCurrency,\n rpcUrls: rpcUrls.default.http,\n blockExplorerUrls: blockExplorers\n ? Object.values(blockExplorers).map(({ url }) => url)\n : undefined,\n },\n ],\n },\n { dedupe: true, retryCount: 0 },\n )\n}\n", "import type { Address } from 'abitype'\n\nimport type { ErrorType } from '../../errors/utils.js'\nimport type { Hex } from '../../types/misc.js'\nimport {\n type ChecksumAddressErrorType,\n checksumAddress,\n} from '../../utils/address/getAddress.js'\nimport {\n type Keccak256ErrorType,\n keccak256,\n} from '../../utils/hash/keccak256.js'\n\nexport type PublicKeyToAddressErrorType =\n | ChecksumAddressErrorType\n | Keccak256ErrorType\n | ErrorType\n\n/**\n * @description Converts an ECDSA public key to an address.\n *\n * @param publicKey The public key to convert.\n *\n * @returns The address.\n */\nexport function publicKeyToAddress(publicKey: Hex): Address {\n const address = keccak256(`0x${publicKey.substring(4)}`).substring(26)\n return checksumAddress(`0x${address}`) as Address\n}\n", "import type { ErrorType } from '../../errors/utils.js'\nimport type { ByteArray, Hex, Signature } from '../../types/misc.js'\nimport { type IsHexErrorType, isHex } from '../data/isHex.js'\nimport {\n type HexToNumberErrorType,\n hexToBigInt,\n hexToNumber,\n} from '../encoding/fromHex.js'\nimport { toHex } from '../encoding/toHex.js'\n\nexport type RecoverPublicKeyParameters = {\n hash: Hex | ByteArray\n signature: Hex | ByteArray | Signature\n}\n\nexport type RecoverPublicKeyReturnType = Hex\n\nexport type RecoverPublicKeyErrorType =\n | HexToNumberErrorType\n | IsHexErrorType\n | ErrorType\n\nexport async function recoverPublicKey({\n hash,\n signature,\n}: RecoverPublicKeyParameters): Promise<RecoverPublicKeyReturnType> {\n const hashHex = isHex(hash) ? hash : toHex(hash)\n\n const { secp256k1 } = await import('@noble/curves/secp256k1')\n const signature_ = (() => {\n // typeof signature: `Signature`\n if (typeof signature === 'object' && 'r' in signature && 's' in signature) {\n const { r, s, v, yParity } = signature\n const yParityOrV = Number(yParity ?? v)!\n const recoveryBit = toRecoveryBit(yParityOrV)\n return new secp256k1.Signature(\n hexToBigInt(r),\n hexToBigInt(s),\n ).addRecoveryBit(recoveryBit)\n }\n\n // typeof signature: `Hex | ByteArray`\n const signatureHex = isHex(signature) ? signature : toHex(signature)\n const yParityOrV = hexToNumber(`0x${signatureHex.slice(130)}`)\n const recoveryBit = toRecoveryBit(yParityOrV)\n return secp256k1.Signature.fromCompact(\n signatureHex.substring(2, 130),\n ).addRecoveryBit(recoveryBit)\n })()\n\n const publicKey = signature_\n .recoverPublicKey(hashHex.substring(2))\n .toHex(false)\n return `0x${publicKey}`\n}\n\nfunction toRecoveryBit(yParityOrV: number) {\n if (yParityOrV === 0 || yParityOrV === 1) return yParityOrV\n if (yParityOrV === 27) return 0\n if (yParityOrV === 28) return 1\n throw new Error('Invalid yParityOrV value')\n}\n", "import type { Address } from 'abitype'\n\nimport { publicKeyToAddress } from '../../accounts/utils/publicKeyToAddress.js'\nimport type { ByteArray, Hex, Signature } from '../../types/misc.js'\n\nimport type { ErrorType } from '../../errors/utils.js'\nimport { recoverPublicKey } from './recoverPublicKey.js'\n\nexport type RecoverAddressParameters = {\n hash: Hex | ByteArray\n signature: Hex | ByteArray | Signature\n}\n\nexport type RecoverAddressReturnType = Address\n\nexport type RecoverAddressErrorType = ErrorType\n\nexport async function recoverAddress({\n hash,\n signature,\n}: RecoverAddressParameters): Promise<RecoverAddressReturnType> {\n return publicKeyToAddress(await recoverPublicKey({ hash: hash, signature }))\n}\n", "import type { ErrorType } from '../../../errors/utils.js'\nimport type { ByteArray, Hex } from '../../../types/misc.js'\nimport {\n type ConcatHexErrorType,\n concatHex,\n} from '../../../utils/data/concat.js'\nimport {\n type HexToBytesErrorType,\n hexToBytes,\n} from '../../../utils/encoding/toBytes.js'\nimport {\n type NumberToHexErrorType,\n numberToHex,\n} from '../../../utils/encoding/toHex.js'\nimport { type ToRlpErrorType, toRlp } from '../../../utils/encoding/toRlp.js'\nimport {\n type Keccak256ErrorType,\n keccak256,\n} from '../../../utils/hash/keccak256.js'\nimport type { Authorization } from '../types/authorization.js'\n\ntype To = 'hex' | 'bytes'\n\nexport type HashAuthorizationParameters<to extends To> = Authorization & {\n /** Output format. @default \"hex\" */\n to?: to | To | undefined\n}\n\nexport type HashAuthorizationReturnType<to extends To> =\n | (to extends 'bytes' ? ByteArray : never)\n | (to extends 'hex' ? Hex : never)\n\nexport type HashAuthorizationErrorType =\n | Keccak256ErrorType\n | ConcatHexErrorType\n | ToRlpErrorType\n | NumberToHexErrorType\n | HexToBytesErrorType\n | ErrorType\n\n/**\n * Computes an Authorization hash in [EIP-7702 format](https://eips.ethereum.org/EIPS/eip-7702): `keccak256('0x05' || rlp([chain_id, address, nonce]))`.\n */\nexport function hashAuthorization<to extends To = 'hex'>(\n parameters: HashAuthorizationParameters<to>,\n): HashAuthorizationReturnType<to> {\n const { chainId, contractAddress, nonce, to } = parameters\n const hash = keccak256(\n concatHex([\n '0x05',\n toRlp([\n chainId ? numberToHex(chainId) : '0x',\n contractAddress,\n nonce ? numberToHex(nonce) : '0x',\n ]),\n ]),\n )\n if (to === 'bytes') return hexToBytes(hash) as HashAuthorizationReturnType<to>\n return hash as HashAuthorizationReturnType<to>\n}\n", "import type { Address } from 'abitype'\n\nimport type { ErrorType } from '../../../errors/utils.js'\nimport type { ByteArray, Hex, Signature } from '../../../types/misc.js'\nimport type { OneOf } from '../../../types/utils.js'\nimport {\n type RecoverAddressErrorType,\n recoverAddress,\n} from '../../../utils/signature/recoverAddress.js'\nimport type {\n Authorization,\n SignedAuthorization,\n} from '../types/authorization.js'\nimport {\n type HashAuthorizationErrorType,\n hashAuthorization,\n} from './hashAuthorization.js'\n\nexport type RecoverAuthorizationAddressParameters<\n authorization extends OneOf<Authorization | SignedAuthorization> = OneOf<\n Authorization | SignedAuthorization\n >,\n //\n _signature = Hex | ByteArray | OneOf<Signature | SignedAuthorization>,\n> = {\n /**\n * The Authorization object.\n *\n * - If an unsigned `authorization` is provided, the `signature` property is required.\n * - If a signed `authorization` is provided, the `signature` property does not need to be provided.\n */\n authorization: authorization | OneOf<Authorization | SignedAuthorization>\n} & (authorization extends SignedAuthorization\n ? {\n /** Signature of the Authorization. Not required if the `authorization` is signed. */\n signature?: _signature | undefined\n }\n : {\n /** Signature of the Authorization. Not required if the `authorization` is signed. */\n signature: _signature\n })\n\nexport type RecoverAuthorizationAddressReturnType = Address\n\nexport type RecoverAuthorizationAddressErrorType =\n | HashAuthorizationErrorType\n | RecoverAddressErrorType\n | ErrorType\n\nexport async function recoverAuthorizationAddress<\n const authorization extends OneOf<Authorization | SignedAuthorization>,\n>(\n parameters: RecoverAuthorizationAddressParameters<authorization>,\n): Promise<RecoverAuthorizationAddressReturnType> {\n const { authorization, signature } = parameters\n\n return recoverAddress({\n hash: hashAuthorization(authorization as Authorization),\n signature: (signature ?? authorization) as Signature,\n })\n}\n", "import type { Account } from '../../accounts/types.js'\nimport type { SendTransactionParameters } from '../../actions/wallet/sendTransaction.js'\nimport type { BaseError } from '../../errors/base.js'\nimport { UnknownNodeError } from '../../errors/node.js'\nimport {\n TransactionExecutionError,\n type TransactionExecutionErrorType,\n} from '../../errors/transaction.js'\nimport type { ErrorType } from '../../errors/utils.js'\nimport type { Chain } from '../../types/chain.js'\n\nimport {\n type GetNodeErrorParameters,\n type GetNodeErrorReturnType,\n getNodeError,\n} from './getNodeError.js'\n\nexport type GetTransactionErrorParameters = Omit<\n SendTransactionParameters,\n 'account' | 'chain'\n> & {\n account: Account | null\n chain?: Chain | undefined\n docsPath?: string | undefined\n}\n\nexport type GetTransactionErrorReturnType<cause = ErrorType> = Omit<\n TransactionExecutionErrorType,\n 'cause'\n> & { cause: cause | GetNodeErrorReturnType }\n\nexport function getTransactionError<err extends ErrorType<string>>(\n err: err,\n { docsPath, ...args }: GetTransactionErrorParameters,\n): GetTransactionErrorReturnType<err> {\n const cause = (() => {\n const cause = getNodeError(\n err as {} as BaseError,\n args as GetNodeErrorParameters,\n )\n if (cause instanceof UnknownNodeError) return err as {} as BaseError\n return cause\n })()\n return new TransactionExecutionError(cause, {\n docsPath,\n ...args,\n }) as GetTransactionErrorReturnType<err>\n}\n", "import type { Client } from '../clients/createClient.js'\nimport type { PublicActions } from '../clients/decorators/public.js'\nimport type { WalletActions } from '../clients/decorators/wallet.js'\nimport type { Transport } from '../clients/transports/createTransport.js'\nimport type { Account } from '../types/account.js'\nimport type { Chain } from '../types/chain.js'\nimport type { RpcSchema } from '../types/eip1193.js'\n\n/**\n * Retrieves and returns an action from the client (if exists), and falls\n * back to the tree-shakable action.\n *\n * Useful for extracting overridden actions from a client (ie. if a consumer\n * wants to override the `sendTransaction` implementation).\n */\nexport function getAction<\n transport extends Transport,\n chain extends Chain | undefined,\n account extends Account | undefined,\n rpcSchema extends RpcSchema | undefined,\n extended extends { [key: string]: unknown },\n client extends Client<transport, chain, account, rpcSchema, extended>,\n parameters,\n returnType,\n>(\n client: client,\n actionFn: (_: any, parameters: parameters) => returnType,\n // Some minifiers drop `Function.prototype.name`, or replace it with short letters,\n // meaning that `actionFn.name` will not always work. For that case, the consumer\n // needs to pass the name explicitly.\n name: keyof PublicActions | keyof WalletActions | (string & {}),\n): (parameters: parameters) => returnType {\n const action_implicit = client[actionFn.name]\n if (typeof action_implicit === 'function')\n return action_implicit as (params: parameters) => returnType\n\n const action_explicit = client[name]\n if (typeof action_explicit === 'function')\n return action_explicit as (params: parameters) => returnType\n\n return (params) => actionFn(client, params)\n}\n", "import type { Account } from '../../accounts/types.js'\nimport type { Client } from '../../clients/createClient.js'\nimport type { Transport } from '../../clients/transports/createTransport.js'\nimport type { ErrorType } from '../../errors/utils.js'\nimport type { Chain } from '../../types/chain.js'\nimport type { RequestErrorType } from '../../utils/buildRequest.js'\nimport {\n type HexToNumberErrorType,\n hexToNumber,\n} from '../../utils/encoding/fromHex.js'\n\nexport type GetChainIdReturnType = number\n\nexport type GetChainIdErrorType =\n | HexToNumberErrorType\n | RequestErrorType\n | ErrorType\n\n/**\n * Returns the chain ID associated with the current network.\n *\n * - Docs: https://viem.sh/docs/actions/public/getChainId\n * - JSON-RPC Methods: [`eth_chainId`](https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_chainid)\n *\n * @param client - Client to use\n * @returns The current chain ID. {@link GetChainIdReturnType}\n *\n * @example\n * import { createPublicClient, http } from 'viem'\n * import { mainnet } from 'viem/chains'\n * import { getChainId } from 'viem/public'\n *\n * const client = createPublicClient({\n * chain: mainnet,\n * transport: http(),\n * })\n * const chainId = await getChainId(client)\n * // 1\n */\nexport async function getChainId<\n chain extends Chain | undefined,\n account extends Account | undefined,\n>(client: Client<Transport, chain, account>): Promise<GetChainIdReturnType> {\n const chainIdHex = await client.request(\n {\n method: 'eth_chainId',\n },\n { dedupe: true },\n )\n return hexToNumber(chainIdHex)\n}\n", "import { formatGwei } from '../utils/unit/formatGwei.js'\nimport { BaseError } from './base.js'\n\nexport type BaseFeeScalarErrorType = BaseFeeScalarError & {\n name: 'BaseFeeScalarError'\n}\nexport class BaseFeeScalarError extends BaseError {\n constructor() {\n super('`baseFeeMultiplier` must be greater than 1.', {\n name: 'BaseFeeScalarError',\n })\n }\n}\n\nexport type Eip1559FeesNotSupportedErrorType = Eip1559FeesNotSupportedError & {\n name: 'Eip1559FeesNotSupportedError'\n}\nexport class Eip1559FeesNotSupportedError extends BaseError {\n constructor() {\n super('Chain does not support EIP-1559 fees.', {\n name: 'Eip1559FeesNotSupportedError',\n })\n }\n}\n\nexport type MaxFeePerGasTooLowErrorType = MaxFeePerGasTooLowError & {\n name: 'MaxFeePerGasTooLowError'\n}\nexport class MaxFeePerGasTooLowError extends BaseError {\n constructor({ maxPriorityFeePerGas }: { maxPriorityFeePerGas: bigint }) {\n super(\n `\\`maxFeePerGas\\` cannot be less than the \\`maxPriorityFeePerGas\\` (${formatGwei(\n maxPriorityFeePerGas,\n )} gwei).`,\n { name: 'MaxFeePerGasTooLowError' },\n )\n }\n}\n", "import type { Hash } from '../types/misc.js'\n\nimport { BaseError } from './base.js'\n\nexport type BlockNotFoundErrorType = BlockNotFoundError & {\n name: 'BlockNotFoundError'\n}\nexport class BlockNotFoundError extends BaseError {\n constructor({\n blockHash,\n blockNumber,\n }: {\n blockHash?: Hash | undefined\n blockNumber?: bigint | undefined\n }) {\n let identifier = 'Block'\n if (blockHash) identifier = `Block at hash \"${blockHash}\"`\n if (blockNumber) identifier = `Block at number \"${blockNumber}\"`\n super(`${identifier} could not be found.`, { name: 'BlockNotFoundError' })\n }\n}\n", "import type { Account } from '../../accounts/types.js'\nimport type { Client } from '../../clients/createClient.js'\nimport type { Transport } from '../../clients/transports/createTransport.js'\nimport {\n BlockNotFoundError,\n type BlockNotFoundErrorType,\n} from '../../errors/block.js'\nimport type { ErrorType } from '../../errors/utils.js'\nimport type { BlockTag } from '../../types/block.js'\nimport type { Chain } from '../../types/chain.js'\nimport type { Hash } from '../../types/misc.js'\nimport type { RpcBlock } from '../../types/rpc.js'\nimport type { Prettify } from '../../types/utils.js'\nimport type { RequestErrorType } from '../../utils/buildRequest.js'\nimport {\n type NumberToHexErrorType,\n numberToHex,\n} from '../../utils/encoding/toHex.js'\nimport {\n type FormattedBlock,\n formatBlock,\n} from '../../utils/formatters/block.js'\n\nexport type GetBlockParameters<\n includeTransactions extends boolean = false,\n blockTag extends BlockTag = 'latest',\n> = {\n /** Whether or not to include transaction data in the response. */\n includeTransactions?: includeTransactions | undefined\n} & (\n | {\n /** Hash of the block. */\n blockHash?: Hash | undefined\n blockNumber?: undefined\n blockTag?: undefined\n }\n | {\n blockHash?: undefined\n /** The block number. */\n blockNumber?: bigint | undefined\n blockTag?: undefined\n }\n | {\n blockHash?: undefined\n blockNumber?: undefined\n /**\n * The block tag.\n * @default 'latest'\n */\n blockTag?: blockTag | BlockTag | undefined\n }\n)\n\nexport type GetBlockReturnType<\n chain extends Chain | undefined = undefined,\n includeTransactions extends boolean = false,\n blockTag extends BlockTag = 'latest',\n> = Prettify<FormattedBlock<chain, includeTransactions, blockTag>>\n\nexport type GetBlockErrorType =\n | BlockNotFoundErrorType\n | NumberToHexErrorType\n | RequestErrorType\n | ErrorType\n\n/**\n * Returns information about a block at a block number, hash, or tag.\n *\n * - Docs: https://viem.sh/docs/actions/public/getBlock\n * - Examples: https://stackblitz.com/github/wevm/viem/tree/main/examples/blocks_fetching-blocks\n * - JSON-RPC Methods:\n * - Calls [`eth_getBlockByNumber`](https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_getblockbynumber) for `blockNumber` & `blockTag`.\n * - Calls [`eth_getBlockByHash`](https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_getblockbyhash) for `blockHash`.\n *\n * @param client - Client to use\n * @param parameters - {@link GetBlockParameters}\n * @returns Information about the block. {@link GetBlockReturnType}\n *\n * @example\n * import { createPublicClient, http } from 'viem'\n * import { mainnet } from 'viem/chains'\n * import { getBlock } from 'viem/public'\n *\n * const client = createPublicClient({\n * chain: mainnet,\n * transport: http(),\n * })\n * const block = await getBlock(client)\n */\nexport async function getBlock<\n chain extends Chain | undefined,\n account extends Account | undefined,\n includeTransactions extends boolean = false,\n blockTag extends BlockTag = 'latest',\n>(\n client: Client<Transport, chain, account>,\n {\n blockHash,\n blockNumber,\n blockTag: blockTag_,\n includeTransactions: includeTransactions_,\n }: GetBlockParameters<includeTransactions, blockTag> = {},\n): Promise<GetBlockReturnType<chain, includeTransactions, blockTag>> {\n const blockTag = blockTag_ ?? 'latest'\n const includeTransactions = includeTransactions_ ?? false\n\n const blockNumberHex =\n blockNumber !== undefined ? numberToHex(blockNumber) : undefined\n\n let block: RpcBlock | null = null\n if (blockHash) {\n block = await client.request(\n {\n method: 'eth_getBlockByHash',\n params: [blockHash, includeTransactions],\n },\n { dedupe: true },\n )\n } else {\n block = await client.request(\n {\n method: 'eth_getBlockByNumber',\n params: [blockNumberHex || blockTag, includeTransactions],\n },\n { dedupe: Boolean(blockNumberHex) },\n )\n }\n\n if (!block) throw new BlockNotFoundError({ blockHash, blockNumber })\n\n const format = client.chain?.formatters?.block?.format || formatBlock\n return format(block)\n}\n", "import type { Account } from '../../accounts/types.js'\nimport type { Client } from '../../clients/createClient.js'\nimport type { Transport } from '../../clients/transports/createTransport.js'\nimport type { ErrorType } from '../../errors/utils.js'\nimport type { Chain } from '../../types/chain.js'\nimport type { RequestErrorType } from '../../utils/buildRequest.js'\n\nexport type GetGasPriceReturnType = bigint\n\nexport type GetGasPriceErrorType = RequestErrorType | ErrorType\n\n/**\n * Returns the current price of gas (in wei).\n *\n * - Docs: https://viem.sh/docs/actions/public/getGasPrice\n * - JSON-RPC Methods: [`eth_gasPrice`](https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_gasprice)\n *\n * @param client - Client to use\n * @returns The gas price (in wei). {@link GetGasPriceReturnType}\n *\n * @example\n * import { createPublicClient, http } from 'viem'\n * import { mainnet } from 'viem/chains'\n * import { getGasPrice } from 'viem/public'\n *\n * const client = createPublicClient({\n * chain: mainnet,\n * transport: http(),\n * })\n * const gasPrice = await getGasPrice(client)\n */\nexport async function getGasPrice<\n chain extends Chain | undefined,\n account extends Account | undefined,\n>(client: Client<Transport, chain, account>): Promise<GetGasPriceReturnType> {\n const gasPrice = await client.request({\n method: 'eth_gasPrice',\n })\n return BigInt(gasPrice)\n}\n", "import type { Client } from '../../clients/createClient.js'\nimport type { Transport } from '../../clients/transports/createTransport.js'\nimport {\n Eip1559FeesNotSupportedError,\n type Eip1559FeesNotSupportedErrorType,\n} from '../../errors/fee.js'\nimport type { ErrorType } from '../../errors/utils.js'\nimport type { Account } from '../../types/account.js'\nimport type { Block } from '../../types/block.js'\nimport type { Chain, ChainFeesFnParameters } from '../../types/chain.js'\nimport type { GetChainParameter } from '../../types/chain.js'\nimport type { RequestErrorType } from '../../utils/buildRequest.js'\nimport {\n type HexToBigIntErrorType,\n hexToBigInt,\n} from '../../utils/encoding/fromHex.js'\nimport { getAction } from '../../utils/getAction.js'\nimport type { PrepareTransactionRequestParameters } from '../wallet/prepareTransactionRequest.js'\nimport { type GetBlockErrorType, getBlock } from './getBlock.js'\nimport { type GetGasPriceErrorType, getGasPrice } from './getGasPrice.js'\n\nexport type EstimateMaxPriorityFeePerGasParameters<\n chain extends Chain | undefined = Chain | undefined,\n chainOverride extends Chain | undefined = Chain | undefined,\n> = GetChainParameter<chain, chainOverride>\n\nexport type EstimateMaxPriorityFeePerGasReturnType = bigint\n\nexport type EstimateMaxPriorityFeePerGasErrorType =\n | GetBlockErrorType\n | HexToBigIntErrorType\n | RequestErrorType\n | GetBlockErrorType\n | GetGasPriceErrorType\n | Eip1559FeesNotSupportedErrorType\n | ErrorType\n\n/**\n * Returns an estimate for the max priority fee per gas (in wei) for a\n * transaction to be likely included in the next block.\n * Defaults to [`chain.fees.defaultPriorityFee`](/docs/clients/chains#fees-defaultpriorityfee) if set.\n *\n * - Docs: https://viem.sh/docs/actions/public/estimateMaxPriorityFeePerGas\n *\n * @param client - Client to use\n * @returns An estimate (in wei) for the max priority fee per gas. {@link EstimateMaxPriorityFeePerGasReturnType}\n *\n * @example\n * import { createPublicClient, http } from 'viem'\n * import { mainnet } from 'viem/chains'\n * import { estimateMaxPriorityFeePerGas } from 'viem/actions'\n *\n * const client = createPublicClient({\n * chain: mainnet,\n * transport: http(),\n * })\n * const maxPriorityFeePerGas = await estimateMaxPriorityFeePerGas(client)\n * // 10000000n\n */\nexport async function estimateMaxPriorityFeePerGas<\n chain extends Chain | undefined,\n chainOverride extends Chain | undefined,\n>(\n client: Client<Transport, chain>,\n args?:\n | EstimateMaxPriorityFeePerGasParameters<chain, chainOverride>\n | undefined,\n): Promise<EstimateMaxPriorityFeePerGasReturnType> {\n return internal_estimateMaxPriorityFeePerGas(client, args as any)\n}\n\nexport async function internal_estimateMaxPriorityFeePerGas<\n chain extends Chain | undefined,\n chainOverride extends Chain | undefined,\n>(\n client: Client<Transport, chain>,\n args: EstimateMaxPriorityFeePerGasParameters<chain, chainOverride> & {\n block?: Block | undefined\n request?:\n | PrepareTransactionRequestParameters<\n chain,\n Account | undefined,\n chainOverride\n >\n | undefined\n },\n): Promise<EstimateMaxPriorityFeePerGasReturnType> {\n const { block: block_, chain = client.chain, request } = args || {}\n\n try {\n const maxPriorityFeePerGas =\n chain?.fees?.maxPriorityFeePerGas ?? chain?.fees?.defaultPriorityFee\n\n if (typeof maxPriorityFeePerGas === 'function') {\n const block =\n block_ || (await getAction(client, getBlock, 'getBlock')({}))\n const maxPriorityFeePerGas_ = await maxPriorityFeePerGas({\n block,\n client,\n request,\n } as ChainFeesFnParameters)\n if (maxPriorityFeePerGas_ === null) throw new Error()\n return maxPriorityFeePerGas_\n }\n\n if (typeof maxPriorityFeePerGas !== 'undefined') return maxPriorityFeePerGas\n\n const maxPriorityFeePerGasHex = await client.request({\n method: 'eth_maxPriorityFeePerGas',\n })\n return hexToBigInt(maxPriorityFeePerGasHex)\n } catch {\n // If the RPC Provider does not support `eth_maxPriorityFeePerGas`\n // fall back to calculating it manually via `gasPrice - baseFeePerGas`.\n // See: https://github.com/ethereum/pm/issues/328#:~:text=eth_maxPriorityFeePerGas%20after%20London%20will%20effectively%20return%20eth_gasPrice%20%2D%20baseFee\n const [block, gasPrice] = await Promise.all([\n block_\n ? Promise.resolve(block_)\n : getAction(client, getBlock, 'getBlock')({}),\n getAction(client, getGasPrice, 'getGasPrice')({}),\n ])\n\n if (typeof block.baseFeePerGas !== 'bigint')\n throw new Eip1559FeesNotSupportedError()\n\n const maxPriorityFeePerGas = gasPrice - block.baseFeePerGas\n\n if (maxPriorityFeePerGas < 0n) return 0n\n return maxPriorityFeePerGas\n }\n}\n", "import type { Client } from '../../clients/createClient.js'\nimport type { Transport } from '../../clients/transports/createTransport.js'\nimport {\n BaseFeeScalarError,\n type BaseFeeScalarErrorType,\n Eip1559FeesNotSupportedError,\n type Eip1559FeesNotSupportedErrorType,\n} from '../../errors/fee.js'\nimport type { ErrorType } from '../../errors/utils.js'\nimport type { Account } from '../../types/account.js'\nimport type { Block } from '../../types/block.js'\nimport type {\n Chain,\n ChainEstimateFeesPerGasFnParameters,\n ChainFeesFnParameters,\n GetChainParameter,\n} from '../../types/chain.js'\nimport type {\n FeeValuesEIP1559,\n FeeValuesLegacy,\n FeeValuesType,\n} from '../../types/fee.js'\nimport { getAction } from '../../utils/getAction.js'\nimport type { PrepareTransactionRequestParameters } from '../wallet/prepareTransactionRequest.js'\nimport {\n type EstimateMaxPriorityFeePerGasErrorType,\n internal_estimateMaxPriorityFeePerGas,\n} from './estimateMaxPriorityFeePerGas.js'\nimport { getBlock } from './getBlock.js'\nimport { type GetGasPriceErrorType, getGasPrice } from './getGasPrice.js'\n\nexport type EstimateFeesPerGasParameters<\n chain extends Chain | undefined = Chain | undefined,\n chainOverride extends Chain | undefined = Chain | undefined,\n type extends FeeValuesType = FeeValuesType,\n> = {\n /**\n * The type of fee values to return.\n *\n * - `legacy`: Returns the legacy gas price.\n * - `eip1559`: Returns the max fee per gas and max priority fee per gas.\n *\n * @default 'eip1559'\n */\n type?: type | FeeValuesType | undefined\n} & GetChainParameter<chain, chainOverride>\n\nexport type EstimateFeesPerGasReturnType<\n type extends FeeValuesType = FeeValuesType,\n> =\n | (type extends 'legacy' ? FeeValuesLegacy : never)\n | (type extends 'eip1559' ? FeeValuesEIP1559 : never)\n\nexport type EstimateFeesPerGasErrorType =\n | BaseFeeScalarErrorType\n | EstimateMaxPriorityFeePerGasErrorType\n | GetGasPriceErrorType\n | Eip1559FeesNotSupportedErrorType\n | ErrorType\n\n/**\n * Returns an estimate for the fees per gas (in wei) for a\n * transaction to be likely included in the next block.\n * Defaults to [`chain.fees.estimateFeesPerGas`](/docs/clients/chains#fees-estimatefeespergas) if set.\n *\n * - Docs: https://viem.sh/docs/actions/public/estimateFeesPerGas\n *\n * @param client - Client to use\n * @param parameters - {@link EstimateFeesPerGasParameters}\n * @returns An estimate (in wei) for the fees per gas. {@link EstimateFeesPerGasReturnType}\n *\n * @example\n * import { createPublicClient, http } from 'viem'\n * import { mainnet } from 'viem/chains'\n * import { estimateFeesPerGas } from 'viem/actions'\n *\n * const client = createPublicClient({\n * chain: mainnet,\n * transport: http(),\n * })\n * const maxPriorityFeePerGas = await estimateFeesPerGas(client)\n * // { maxFeePerGas: ..., maxPriorityFeePerGas: ... }\n */\nexport async function estimateFeesPerGas<\n chain extends Chain | undefined,\n chainOverride extends Chain | undefined,\n type extends FeeValuesType = 'eip1559',\n>(\n client: Client<Transport, chain>,\n args?: EstimateFeesPerGasParameters<chain, chainOverride, type> | undefined,\n): Promise<EstimateFeesPerGasReturnType<type>> {\n return internal_estimateFeesPerGas(client, args as any)\n}\n\nexport async function internal_estimateFeesPerGas<\n chain extends Chain | undefined,\n chainOverride extends Chain | undefined,\n type extends FeeValuesType = 'eip1559',\n>(\n client: Client<Transport, chain>,\n args: EstimateFeesPerGasParameters<chain, chainOverride, type> & {\n block?: Block | undefined\n request?: PrepareTransactionRequestParameters<Chain, Account> | undefined\n },\n): Promise<EstimateFeesPerGasReturnType<type>> {\n const {\n block: block_,\n chain = client.chain,\n request,\n type = 'eip1559',\n } = args || {}\n\n const baseFeeMultiplier = await (async () => {\n if (typeof chain?.fees?.baseFeeMultiplier === 'function')\n return chain.fees.baseFeeMultiplier({\n block: block_ as Block,\n client,\n request,\n } as ChainFeesFnParameters)\n return chain?.fees?.baseFeeMultiplier ?? 1.2\n })()\n if (baseFeeMultiplier < 1) throw new BaseFeeScalarError()\n\n const decimals = baseFeeMultiplier.toString().split('.')[1]?.length ?? 0\n const denominator = 10 ** decimals\n const multiply = (base: bigint) =>\n (base * BigInt(Math.ceil(baseFeeMultiplier * denominator))) /\n BigInt(denominator)\n\n const block = block_\n ? block_\n : await getAction(client, getBlock, 'getBlock')({})\n\n if (typeof chain?.fees?.estimateFeesPerGas === 'function') {\n const fees = (await chain.fees.estimateFeesPerGas({\n block: block_ as Block,\n client,\n multiply,\n request,\n type,\n } as ChainEstimateFeesPerGasFnParameters)) as unknown as EstimateFeesPerGasReturnType<type>\n\n if (fees !== null) return fees\n }\n\n if (type === 'eip1559') {\n if (typeof block.baseFeePerGas !== 'bigint')\n throw new Eip1559FeesNotSupportedError()\n\n const maxPriorityFeePerGas =\n typeof request?.maxPriorityFeePerGas === 'bigint'\n ? request.maxPriorityFeePerGas\n : await internal_estimateMaxPriorityFeePerGas(\n client as Client<Transport, Chain>,\n {\n block: block as Block,\n chain,\n request,\n },\n )\n\n const baseFeePerGas = multiply(block.baseFeePerGas)\n const maxFeePerGas =\n request?.maxFeePerGas ?? baseFeePerGas + maxPriorityFeePerGas\n\n return {\n maxFeePerGas,\n maxPriorityFeePerGas,\n } as EstimateFeesPerGasReturnType<type>\n }\n\n const gasPrice =\n request?.gasPrice ??\n multiply(await getAction(client, getGasPrice, 'getGasPrice')({}))\n return {\n gasPrice,\n } as EstimateFeesPerGasReturnType<type>\n}\n", "import type { Account } from '../accounts/types.js'\nimport type { EstimateGasParameters } from '../actions/public/estimateGas.js'\nimport type { Chain } from '../types/chain.js'\nimport { formatEther } from '../utils/unit/formatEther.js'\nimport { formatGwei } from '../utils/unit/formatGwei.js'\n\nimport { BaseError } from './base.js'\nimport { prettyPrint } from './transaction.js'\n\nexport type EstimateGasExecutionErrorType = EstimateGasExecutionError & {\n name: 'EstimateGasExecutionError'\n}\nexport class EstimateGasExecutionError extends BaseError {\n override cause: BaseError\n\n constructor(\n cause: BaseError,\n {\n account,\n docsPath,\n chain,\n data,\n gas,\n gasPrice,\n maxFeePerGas,\n maxPriorityFeePerGas,\n nonce,\n to,\n value,\n }: Omit<EstimateGasParameters<any>, 'account'> & {\n account?: Account | undefined\n chain?: Chain | undefined\n docsPath?: string | undefined\n },\n ) {\n const prettyArgs = prettyPrint({\n from: account?.address,\n to,\n value:\n typeof value !== 'undefined' &&\n `${formatEther(value)} ${chain?.nativeCurrency?.symbol || 'ETH'}`,\n data,\n gas,\n gasPrice:\n typeof gasPrice !== 'undefined' && `${formatGwei(gasPrice)} gwei`,\n maxFeePerGas:\n typeof maxFeePerGas !== 'undefined' &&\n `${formatGwei(maxFeePerGas)} gwei`,\n maxPriorityFeePerGas:\n typeof maxPriorityFeePerGas !== 'undefined' &&\n `${formatGwei(maxPriorityFeePerGas)} gwei`,\n nonce,\n })\n\n super(cause.shortMessage, {\n cause,\n docsPath,\n metaMessages: [\n ...(cause.metaMessages ? [...cause.metaMessages, ' '] : []),\n 'Estimate Gas Arguments:',\n prettyArgs,\n ].filter(Boolean) as string[],\n name: 'EstimateGasExecutionError',\n })\n this.cause = cause\n }\n}\n", "import type { Account } from '../../accounts/types.js'\nimport type { EstimateGasParameters } from '../../actions/public/estimateGas.js'\nimport type { BaseError } from '../../errors/base.js'\nimport {\n EstimateGasExecutionError,\n type EstimateGasExecutionErrorType,\n} from '../../errors/estimateGas.js'\nimport { UnknownNodeError } from '../../errors/node.js'\nimport type { ErrorType } from '../../errors/utils.js'\nimport type { Chain } from '../../types/chain.js'\n\nimport {\n type GetNodeErrorParameters,\n type GetNodeErrorReturnType,\n getNodeError,\n} from './getNodeError.js'\n\nexport type GetEstimateGasErrorReturnType<cause = ErrorType> = Omit<\n EstimateGasExecutionErrorType,\n 'cause'\n> & { cause: cause | GetNodeErrorReturnType }\n\nexport function getEstimateGasError<err extends ErrorType<string>>(\n err: err,\n {\n docsPath,\n ...args\n }: Omit<EstimateGasParameters, 'account'> & {\n account?: Account | undefined\n chain?: Chain | undefined\n docsPath?: string | undefined\n },\n): GetEstimateGasErrorReturnType<err> {\n const cause = (() => {\n const cause = getNodeError(\n err as {} as BaseError,\n args as GetNodeErrorParameters,\n )\n if (cause instanceof UnknownNodeError) return err as {} as BaseError\n return cause\n })()\n return new EstimateGasExecutionError(cause, {\n docsPath,\n ...args,\n }) as GetEstimateGasErrorReturnType<err>\n}\n", "import type { Address } from 'abitype'\n\nimport type { Client } from '../../clients/createClient.js'\nimport type { Transport } from '../../clients/transports/createTransport.js'\nimport type { ErrorType } from '../../errors/utils.js'\nimport type { BlockTag } from '../../types/block.js'\nimport type { Chain } from '../../types/chain.js'\nimport type { RequestErrorType } from '../../utils/buildRequest.js'\nimport {\n type NumberToHexErrorType,\n numberToHex,\n} from '../../utils/encoding/toHex.js'\n\nexport type GetBalanceParameters = {\n /** The address of the account. */\n address: Address\n} & (\n | {\n /** The balance of the account at a block number. */\n blockNumber?: bigint | undefined\n blockTag?: undefined\n }\n | {\n blockNumber?: undefined\n /** The balance of the account at a block tag. */\n blockTag?: BlockTag | undefined\n }\n)\n\nexport type GetBalanceReturnType = bigint\n\nexport type GetBalanceErrorType =\n | NumberToHexErrorType\n | RequestErrorType\n | ErrorType\n\n/**\n * Returns the balance of an address in wei.\n *\n * - Docs: https://viem.sh/docs/actions/public/getBalance\n * - JSON-RPC Methods: [`eth_getBalance`](https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_getbalance)\n *\n * You can convert the balance to ether units with [`formatEther`](https://viem.sh/docs/utilities/formatEther).\n *\n * ```ts\n * const balance = await getBalance(client, {\n * address: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e',\n * blockTag: 'safe'\n * })\n * const balanceAsEther = formatEther(balance)\n * // \"6.942\"\n * ```\n *\n * @param client - Client to use\n * @param parameters - {@link GetBalanceParameters}\n * @returns The balance of the address in wei. {@link GetBalanceReturnType}\n *\n * @example\n * import { createPublicClient, http } from 'viem'\n * import { mainnet } from 'viem/chains'\n * import { getBalance } from 'viem/public'\n *\n * const client = createPublicClient({\n * chain: mainnet,\n * transport: http(),\n * })\n * const balance = await getBalance(client, {\n * address: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e',\n * })\n * // 10000000000000000000000n (wei)\n */\nexport async function getBalance<chain extends Chain | undefined>(\n client: Client<Transport, chain>,\n { address, blockNumber, blockTag = 'latest' }: GetBalanceParameters,\n): Promise<GetBalanceReturnType> {\n const blockNumberHex = blockNumber ? numberToHex(blockNumber) : undefined\n\n const balance = await client.request({\n method: 'eth_getBalance',\n params: [address, blockNumberHex || blockTag],\n })\n return BigInt(balance)\n}\n", "import type { Address } from 'abitype'\nimport type { Account } from '../../accounts/types.js'\nimport {\n type ParseAccountErrorType,\n parseAccount,\n} from '../../accounts/utils/parseAccount.js'\nimport type { Client } from '../../clients/createClient.js'\nimport type { Transport } from '../../clients/transports/createTransport.js'\nimport { BaseError } from '../../errors/base.js'\nimport {\n type RecoverAuthorizationAddressErrorType,\n recoverAuthorizationAddress,\n} from '../../experimental/eip7702/utils/recoverAuthorizationAddress.js'\nimport type { BlockTag } from '../../types/block.js'\nimport type { Chain } from '../../types/chain.js'\nimport type { StateOverride } from '../../types/stateOverride.js'\nimport type { TransactionRequest } from '../../types/transaction.js'\nimport type { UnionOmit } from '../../types/utils.js'\nimport type { RequestErrorType } from '../../utils/buildRequest.js'\nimport {\n type NumberToHexErrorType,\n numberToHex,\n} from '../../utils/encoding/toHex.js'\nimport {\n type GetEstimateGasErrorReturnType,\n getEstimateGasError,\n} from '../../utils/errors/getEstimateGasError.js'\nimport { extract } from '../../utils/formatters/extract.js'\nimport {\n type FormattedTransactionRequest,\n formatTransactionRequest,\n} from '../../utils/formatters/transactionRequest.js'\nimport { serializeStateOverride } from '../../utils/stateOverride.js'\nimport {\n type AssertRequestErrorType,\n type AssertRequestParameters,\n assertRequest,\n} from '../../utils/transaction/assertRequest.js'\nimport {\n type PrepareTransactionRequestParameters,\n prepareTransactionRequest,\n} from '../wallet/prepareTransactionRequest.js'\nimport { getBalance } from './getBalance.js'\n\nexport type EstimateGasParameters<\n chain extends Chain | undefined = Chain | undefined,\n> = UnionOmit<FormattedEstimateGas<chain>, 'from'> & {\n account?: Account | Address | undefined\n stateOverride?: StateOverride | undefined\n} & (\n | {\n /** The balance of the account at a block number. */\n blockNumber?: bigint | undefined\n blockTag?: undefined\n }\n | {\n blockNumber?: undefined\n /**\n * The balance of the account at a block tag.\n * @default 'latest'\n */\n blockTag?: BlockTag | undefined\n }\n )\ntype FormattedEstimateGas<chain extends Chain | undefined = Chain | undefined> =\n FormattedTransactionRequest<chain>\n\nexport type EstimateGasReturnType = bigint\n\nexport type EstimateGasErrorType = GetEstimateGasErrorReturnType<\n | ParseAccountErrorType\n | NumberToHexErrorType\n | RequestErrorType\n | RecoverAuthorizationAddressErrorType\n | AssertRequestErrorType\n>\n\n/**\n * Estimates the gas necessary to complete a transaction without submitting it to the network.\n *\n * - Docs: https://viem.sh/docs/actions/public/estimateGas\n * - JSON-RPC Methods: [`eth_estimateGas`](https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_estimategas)\n *\n * @param client - Client to use\n * @param parameters - {@link EstimateGasParameters}\n * @returns The gas estimate (in wei). {@link EstimateGasReturnType}\n *\n * @example\n * import { createPublicClient, http, parseEther } from 'viem'\n * import { mainnet } from 'viem/chains'\n * import { estimateGas } from 'viem/public'\n *\n * const client = createPublicClient({\n * chain: mainnet,\n * transport: http(),\n * })\n * const gasEstimate = await estimateGas(client, {\n * account: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e',\n * to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8',\n * value: parseEther('1'),\n * })\n */\nexport async function estimateGas<\n chain extends Chain | undefined,\n account extends Account | undefined = undefined,\n>(\n client: Client<Transport, chain, account>,\n args: EstimateGasParameters<chain>,\n): Promise<EstimateGasReturnType> {\n const { account: account_ = client.account } = args\n const account = account_ ? parseAccount(account_) : undefined\n\n try {\n const {\n accessList,\n authorizationList,\n blobs,\n blobVersionedHashes,\n blockNumber,\n blockTag,\n data,\n gas,\n gasPrice,\n maxFeePerBlobGas,\n maxFeePerGas,\n maxPriorityFeePerGas,\n nonce,\n value,\n stateOverride,\n ...rest\n } = (await prepareTransactionRequest(client, {\n ...args,\n parameters:\n // Some RPC Providers do not compute versioned hashes from blobs. We will need\n // to compute them.\n account?.type === 'local' ? undefined : ['blobVersionedHashes'],\n } as PrepareTransactionRequestParameters)) as EstimateGasParameters\n\n const blockNumberHex = blockNumber ? numberToHex(blockNumber) : undefined\n const block = blockNumberHex || blockTag\n\n const rpcStateOverride = serializeStateOverride(stateOverride)\n\n const to = await (async () => {\n // If `to` exists on the parameters, use that.\n if (rest.to) return rest.to\n\n // If no `to` exists, and we are sending a EIP-7702 transaction, use the\n // address of the first authorization in the list.\n if (authorizationList && authorizationList.length > 0)\n return await recoverAuthorizationAddress({\n authorization: authorizationList[0],\n }).catch(() => {\n throw new BaseError(\n '`to` is required. Could not infer from `authorizationList`',\n )\n })\n\n // Otherwise, we are sending a deployment transaction.\n return undefined\n })()\n\n assertRequest(args as AssertRequestParameters)\n\n const chainFormat = client.chain?.formatters?.transactionRequest?.format\n const format = chainFormat || formatTransactionRequest\n\n const request = format({\n // Pick out extra data that might exist on the chain's transaction request type.\n ...extract(rest, { format: chainFormat }),\n from: account?.address,\n accessList,\n authorizationList,\n blobs,\n blobVersionedHashes,\n data,\n gas,\n gasPrice,\n maxFeePerBlobGas,\n maxFeePerGas,\n maxPriorityFeePerGas,\n nonce,\n to,\n value,\n } as TransactionRequest)\n\n function estimateGas_rpc(parameters: {\n block: any\n request: any\n rpcStateOverride: any\n }) {\n const { block, request, rpcStateOverride } = parameters\n return client.request({\n method: 'eth_estimateGas',\n params: rpcStateOverride\n ? [request, block ?? 'latest', rpcStateOverride]\n : block\n ? [request, block]\n : [request],\n })\n }\n\n let estimate = BigInt(\n await estimateGas_rpc({ block, request, rpcStateOverride }),\n )\n\n // TODO(7702): Remove this once https://github.com/ethereum/execution-apis/issues/561 is resolved.\n // Authorization list schema is not implemented on JSON-RPC spec yet, so we need to\n // manually estimate the gas.\n if (authorizationList) {\n const value = await getBalance(client, { address: request.from })\n const estimates = await Promise.all(\n authorizationList.map(async (authorization) => {\n const { contractAddress } = authorization\n const estimate = await estimateGas_rpc({\n block,\n request: {\n authorizationList: undefined,\n data,\n from: account?.address,\n to: contractAddress,\n value: numberToHex(value),\n },\n rpcStateOverride,\n }).catch(() => 100_000n)\n return 2n * BigInt(estimate)\n }),\n )\n estimate += estimates.reduce((acc, curr) => acc + curr, 0n)\n }\n\n return estimate\n } catch (err) {\n throw getEstimateGasError(err as BaseError, {\n ...args,\n account,\n chain: client.chain,\n })\n }\n}\n", "import type { Address } from 'abitype'\n\nimport type { Account } from '../../accounts/types.js'\nimport type { Client } from '../../clients/createClient.js'\nimport type { Transport } from '../../clients/transports/createTransport.js'\nimport type { ErrorType } from '../../errors/utils.js'\nimport type { BlockTag } from '../../types/block.js'\nimport type { Chain } from '../../types/chain.js'\nimport type { RequestErrorType } from '../../utils/buildRequest.js'\nimport {\n type HexToNumberErrorType,\n hexToNumber,\n} from '../../utils/encoding/fromHex.js'\nimport {\n type NumberToHexErrorType,\n numberToHex,\n} from '../../utils/encoding/toHex.js'\n\nexport type GetTransactionCountParameters = {\n /** The account address. */\n address: Address\n} & (\n | {\n /** The block number. */\n blockNumber?: bigint | undefined\n blockTag?: undefined\n }\n | {\n blockNumber?: undefined\n /** The block tag. Defaults to 'latest'. */\n blockTag?: BlockTag | undefined\n }\n)\nexport type GetTransactionCountReturnType = number\n\nexport type GetTransactionCountErrorType =\n | RequestErrorType\n | NumberToHexErrorType\n | HexToNumberErrorType\n | ErrorType\n\n/**\n * Returns the number of [Transactions](https://viem.sh/docs/glossary/terms#transaction) an Account has sent.\n *\n * - Docs: https://viem.sh/docs/actions/public/getTransactionCount\n * - JSON-RPC Methods: [`eth_getTransactionCount`](https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_gettransactioncount)\n *\n * @param client - Client to use\n * @param parameters - {@link GetTransactionCountParameters}\n * @returns The number of transactions an account has sent. {@link GetTransactionCountReturnType}\n *\n * @example\n * import { createPublicClient, http } from 'viem'\n * import { mainnet } from 'viem/chains'\n * import { getTransactionCount } from 'viem/public'\n *\n * const client = createPublicClient({\n * chain: mainnet,\n * transport: http(),\n * })\n * const transactionCount = await getTransactionCount(client, {\n * address: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e',\n * })\n */\nexport async function getTransactionCount<\n chain extends Chain | undefined,\n account extends Account | undefined,\n>(\n client: Client<Transport, chain, account>,\n { address, blockTag = 'latest', blockNumber }: GetTransactionCountParameters,\n): Promise<GetTransactionCountReturnType> {\n const count = await client.request(\n {\n method: 'eth_getTransactionCount',\n params: [address, blockNumber ? numberToHex(blockNumber) : blockTag],\n },\n { dedupe: Boolean(blockNumber) },\n )\n return hexToNumber(count)\n}\n", "import type { Address } from 'abitype'\nimport type { Account } from '../../accounts/types.js'\nimport {\n type ParseAccountErrorType,\n parseAccount,\n} from '../../accounts/utils/parseAccount.js'\nimport {\n type EstimateFeesPerGasErrorType,\n internal_estimateFeesPerGas,\n} from '../../actions/public/estimateFeesPerGas.js'\nimport {\n type EstimateGasErrorType,\n type EstimateGasParameters,\n estimateGas,\n} from '../../actions/public/estimateGas.js'\nimport {\n type GetBlockErrorType,\n getBlock as getBlock_,\n} from '../../actions/public/getBlock.js'\nimport {\n type GetTransactionCountErrorType,\n getTransactionCount,\n} from '../../actions/public/getTransactionCount.js'\nimport type { Client } from '../../clients/createClient.js'\nimport type { Transport } from '../../clients/transports/createTransport.js'\nimport type { AccountNotFoundErrorType } from '../../errors/account.js'\nimport {\n Eip1559FeesNotSupportedError,\n MaxFeePerGasTooLowError,\n} from '../../errors/fee.js'\nimport type { DeriveAccount, GetAccountParameter } from '../../types/account.js'\nimport type { Block } from '../../types/block.js'\nimport type { Chain, DeriveChain } from '../../types/chain.js'\nimport type { GetChainParameter } from '../../types/chain.js'\nimport type { GetTransactionRequestKzgParameter } from '../../types/kzg.js'\nimport type {\n TransactionRequest,\n TransactionRequestEIP1559,\n TransactionRequestEIP2930,\n TransactionRequestEIP4844,\n TransactionRequestEIP7702,\n TransactionRequestLegacy,\n TransactionSerializable,\n} from '../../types/transaction.js'\nimport type {\n ExactPartial,\n IsNever,\n Prettify,\n UnionOmit,\n UnionRequiredBy,\n} from '../../types/utils.js'\nimport { blobsToCommitments } from '../../utils/blob/blobsToCommitments.js'\nimport { blobsToProofs } from '../../utils/blob/blobsToProofs.js'\nimport { commitmentsToVersionedHashes } from '../../utils/blob/commitmentsToVersionedHashes.js'\nimport { toBlobSidecars } from '../../utils/blob/toBlobSidecars.js'\nimport type { FormattedTransactionRequest } from '../../utils/formatters/transactionRequest.js'\nimport { getAction } from '../../utils/getAction.js'\nimport type { NonceManager } from '../../utils/nonceManager.js'\nimport {\n type AssertRequestErrorType,\n type AssertRequestParameters,\n assertRequest,\n} from '../../utils/transaction/assertRequest.js'\nimport {\n type GetTransactionType,\n getTransactionType,\n} from '../../utils/transaction/getTransactionType.js'\nimport { getChainId as getChainId_ } from '../public/getChainId.js'\n\nexport const defaultParameters = [\n 'blobVersionedHashes',\n 'chainId',\n 'fees',\n 'gas',\n 'nonce',\n 'type',\n] as const\n\n/** @internal */\nexport const eip1559NetworkCache = /*#__PURE__*/ new Map<string, boolean>()\n\nexport type PrepareTransactionRequestParameterType =\n | 'blobVersionedHashes'\n | 'chainId'\n | 'fees'\n | 'gas'\n | 'nonce'\n | 'sidecars'\n | 'type'\ntype ParameterTypeToParameters<\n parameterType extends PrepareTransactionRequestParameterType,\n> = parameterType extends 'fees'\n ? 'maxFeePerGas' | 'maxPriorityFeePerGas' | 'gasPrice'\n : parameterType\n\nexport type PrepareTransactionRequestRequest<\n chain extends Chain | undefined = Chain | undefined,\n chainOverride extends Chain | undefined = Chain | undefined,\n ///\n _derivedChain extends Chain | undefined = DeriveChain<chain, chainOverride>,\n> = UnionOmit<FormattedTransactionRequest<_derivedChain>, 'from'> &\n GetTransactionRequestKzgParameter & {\n /**\n * Nonce manager to use for the transaction request.\n */\n nonceManager?: NonceManager | undefined\n /**\n * Parameters to prepare for the transaction request.\n *\n * @default ['blobVersionedHashes', 'chainId', 'fees', 'gas', 'nonce', 'type']\n */\n parameters?: readonly PrepareTransactionRequestParameterType[] | undefined\n }\n\nexport type PrepareTransactionRequestParameters<\n chain extends Chain | undefined = Chain | undefined,\n account extends Account | undefined = Account | undefined,\n chainOverride extends Chain | undefined = Chain | undefined,\n accountOverride extends Account | Address | undefined =\n | Account\n | Address\n | undefined,\n request extends PrepareTransactionRequestRequest<\n chain,\n chainOverride\n > = PrepareTransactionRequestRequest<chain, chainOverride>,\n> = request &\n GetAccountParameter<account, accountOverride, false, true> &\n GetChainParameter<chain, chainOverride> &\n GetTransactionRequestKzgParameter<request> & { chainId?: number | undefined }\n\nexport type PrepareTransactionRequestReturnType<\n chain extends Chain | undefined = Chain | undefined,\n account extends Account | undefined = Account | undefined,\n chainOverride extends Chain | undefined = Chain | undefined,\n accountOverride extends Account | Address | undefined =\n | Account\n | Address\n | undefined,\n request extends PrepareTransactionRequestRequest<\n chain,\n chainOverride\n > = PrepareTransactionRequestRequest<chain, chainOverride>,\n ///\n _derivedAccount extends Account | Address | undefined = DeriveAccount<\n account,\n accountOverride\n >,\n _derivedChain extends Chain | undefined = DeriveChain<chain, chainOverride>,\n _transactionType = request['type'] extends string | undefined\n ? request['type']\n : GetTransactionType<request> extends 'legacy'\n ? unknown\n : GetTransactionType<request>,\n _transactionRequest extends TransactionRequest =\n | (_transactionType extends 'legacy' ? TransactionRequestLegacy : never)\n | (_transactionType extends 'eip1559' ? TransactionRequestEIP1559 : never)\n | (_transactionType extends 'eip2930' ? TransactionRequestEIP2930 : never)\n | (_transactionType extends 'eip4844' ? TransactionRequestEIP4844 : never)\n | (_transactionType extends 'eip7702' ? TransactionRequestEIP7702 : never),\n> = Prettify<\n UnionRequiredBy<\n Extract<\n UnionOmit<FormattedTransactionRequest<_derivedChain>, 'from'> &\n (_derivedChain extends Chain\n ? { chain: _derivedChain }\n : { chain?: undefined }) &\n (_derivedAccount extends Account\n ? { account: _derivedAccount; from: Address }\n : { account?: undefined; from?: undefined }),\n IsNever<_transactionRequest> extends true\n ? unknown\n : ExactPartial<_transactionRequest>\n > & { chainId?: number | undefined },\n ParameterTypeToParameters<\n request['parameters'] extends readonly PrepareTransactionRequestParameterType[]\n ? request['parameters'][number]\n : (typeof defaultParameters)[number]\n >\n > &\n (unknown extends request['kzg'] ? {} : Pick<request, 'kzg'>)\n>\n\nexport type PrepareTransactionRequestErrorType =\n | AccountNotFoundErrorType\n | AssertRequestErrorType\n | ParseAccountErrorType\n | GetBlockErrorType\n | GetTransactionCountErrorType\n | EstimateGasErrorType\n | EstimateFeesPerGasErrorType\n\n/**\n * Prepares a transaction request for signing.\n *\n * - Docs: https://viem.sh/docs/actions/wallet/prepareTransactionRequest\n *\n * @param args - {@link PrepareTransactionRequestParameters}\n * @returns The transaction request. {@link PrepareTransactionRequestReturnType}\n *\n * @example\n * import { createWalletClient, custom } from 'viem'\n * import { mainnet } from 'viem/chains'\n * import { prepareTransactionRequest } from 'viem/actions'\n *\n * const client = createWalletClient({\n * chain: mainnet,\n * transport: custom(window.ethereum),\n * })\n * const request = await prepareTransactionRequest(client, {\n * account: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e',\n * to: '0x0000000000000000000000000000000000000000',\n * value: 1n,\n * })\n *\n * @example\n * // Account Hoisting\n * import { createWalletClient, http } from 'viem'\n * import { privateKeyToAccount } from 'viem/accounts'\n * import { mainnet } from 'viem/chains'\n * import { prepareTransactionRequest } from 'viem/actions'\n *\n * const client = createWalletClient({\n * account: privateKeyToAccount('0x…'),\n * chain: mainnet,\n * transport: custom(window.ethereum),\n * })\n * const request = await prepareTransactionRequest(client, {\n * to: '0x0000000000000000000000000000000000000000',\n * value: 1n,\n * })\n */\nexport async function prepareTransactionRequest<\n chain extends Chain | undefined,\n account extends Account | undefined,\n const request extends PrepareTransactionRequestRequest<chain, chainOverride>,\n accountOverride extends Account | Address | undefined = undefined,\n chainOverride extends Chain | undefined = undefined,\n>(\n client: Client<Transport, chain, account>,\n args: PrepareTransactionRequestParameters<\n chain,\n account,\n chainOverride,\n accountOverride,\n request\n >,\n): Promise<\n PrepareTransactionRequestReturnType<\n chain,\n account,\n chainOverride,\n accountOverride,\n request\n >\n> {\n const {\n account: account_ = client.account,\n blobs,\n chain,\n gas,\n kzg,\n nonce,\n nonceManager,\n parameters = defaultParameters,\n type,\n } = args\n const account = account_ ? parseAccount(account_) : account_\n\n const request = { ...args, ...(account ? { from: account?.address } : {}) }\n\n let block: Block | undefined\n async function getBlock(): Promise<Block> {\n if (block) return block\n block = await getAction(\n client,\n getBlock_,\n 'getBlock',\n )({ blockTag: 'latest' })\n return block\n }\n\n let chainId: number | undefined\n async function getChainId(): Promise<number> {\n if (chainId) return chainId\n if (chain) return chain.id\n if (typeof args.chainId !== 'undefined') return args.chainId\n const chainId_ = await getAction(client, getChainId_, 'getChainId')({})\n chainId = chainId_\n return chainId\n }\n\n if (parameters.includes('nonce') && typeof nonce === 'undefined' && account) {\n if (nonceManager) {\n const chainId = await getChainId()\n request.nonce = await nonceManager.consume({\n address: account.address,\n chainId,\n client,\n })\n } else {\n request.nonce = await getAction(\n client,\n getTransactionCount,\n 'getTransactionCount',\n )({\n address: account.address,\n blockTag: 'pending',\n })\n }\n }\n\n if (\n (parameters.includes('blobVersionedHashes') ||\n parameters.includes('sidecars')) &&\n blobs &&\n kzg\n ) {\n const commitments = blobsToCommitments({ blobs, kzg })\n\n if (parameters.includes('blobVersionedHashes')) {\n const versionedHashes = commitmentsToVersionedHashes({\n commitments,\n to: 'hex',\n })\n request.blobVersionedHashes = versionedHashes\n }\n if (parameters.includes('sidecars')) {\n const proofs = blobsToProofs({ blobs, commitments, kzg })\n const sidecars = toBlobSidecars({\n blobs,\n commitments,\n proofs,\n to: 'hex',\n })\n request.sidecars = sidecars\n }\n }\n\n if (parameters.includes('chainId')) request.chainId = await getChainId()\n\n if (\n (parameters.includes('fees') || parameters.includes('type')) &&\n typeof type === 'undefined'\n ) {\n try {\n request.type = getTransactionType(\n request as TransactionSerializable,\n ) as any\n } catch {\n let isEip1559Network = eip1559NetworkCache.get(client.uid)\n if (typeof isEip1559Network === 'undefined') {\n const block = await getBlock()\n isEip1559Network = typeof block?.baseFeePerGas === 'bigint'\n eip1559NetworkCache.set(client.uid, isEip1559Network)\n }\n request.type = isEip1559Network ? 'eip1559' : 'legacy'\n }\n }\n\n if (parameters.includes('fees')) {\n // TODO(4844): derive blob base fees once https://github.com/ethereum/execution-apis/pull/486 is merged.\n\n if (request.type !== 'legacy' && request.type !== 'eip2930') {\n // EIP-1559 fees\n if (\n typeof request.maxFeePerGas === 'undefined' ||\n typeof request.maxPriorityFeePerGas === 'undefined'\n ) {\n const block = await getBlock()\n const { maxFeePerGas, maxPriorityFeePerGas } =\n await internal_estimateFeesPerGas(client, {\n block: block as Block,\n chain,\n request: request as PrepareTransactionRequestParameters,\n })\n\n if (\n typeof args.maxPriorityFeePerGas === 'undefined' &&\n args.maxFeePerGas &&\n args.maxFeePerGas < maxPriorityFeePerGas\n )\n throw new MaxFeePerGasTooLowError({\n maxPriorityFeePerGas,\n })\n\n request.maxPriorityFeePerGas = maxPriorityFeePerGas\n request.maxFeePerGas = maxFeePerGas\n }\n } else {\n // Legacy fees\n if (\n typeof args.maxFeePerGas !== 'undefined' ||\n typeof args.maxPriorityFeePerGas !== 'undefined'\n )\n throw new Eip1559FeesNotSupportedError()\n\n if (typeof args.gasPrice === 'undefined') {\n const block = await getBlock()\n const { gasPrice: gasPrice_ } = await internal_estimateFeesPerGas(\n client,\n {\n block: block as Block,\n chain,\n request: request as PrepareTransactionRequestParameters,\n type: 'legacy',\n },\n )\n request.gasPrice = gasPrice_\n }\n }\n }\n\n if (parameters.includes('gas') && typeof gas === 'undefined')\n request.gas = await getAction(\n client,\n estimateGas,\n 'estimateGas',\n )({\n ...request,\n account: account\n ? { address: account.address, type: 'json-rpc' }\n : account,\n } as EstimateGasParameters)\n\n assertRequest(request as AssertRequestParameters)\n\n delete request.parameters\n\n return request as any\n}\n", "import type { Client } from '../../clients/createClient.js'\nimport type { Transport } from '../../clients/transports/createTransport.js'\nimport type { ErrorType } from '../../errors/utils.js'\nimport type { Chain } from '../../types/chain.js'\nimport type { Hash } from '../../types/misc.js'\nimport type { TransactionSerializedGeneric } from '../../types/transaction.js'\nimport type { RequestErrorType } from '../../utils/buildRequest.js'\n\nexport type SendRawTransactionParameters = {\n /** The signed serialized transaction. */\n serializedTransaction: TransactionSerializedGeneric\n}\n\nexport type SendRawTransactionReturnType = Hash\n\nexport type SendRawTransactionErrorType = RequestErrorType | ErrorType\n\n/**\n * Sends a **signed** transaction to the network\n *\n * - Docs: https://viem.sh/docs/actions/wallet/sendRawTransaction\n * - JSON-RPC Method: [`eth_sendRawTransaction`](https://ethereum.github.io/execution-apis/api-documentation/)\n *\n * @param client - Client to use\n * @param parameters - {@link SendRawTransactionParameters}\n * @returns The transaction hash. {@link SendRawTransactionReturnType}\n *\n * @example\n * import { createWalletClient, custom } from 'viem'\n * import { mainnet } from 'viem/chains'\n * import { sendRawTransaction } from 'viem/wallet'\n *\n * const client = createWalletClient({\n * chain: mainnet,\n * transport: custom(window.ethereum),\n * })\n *\n * const hash = await sendRawTransaction(client, {\n * serializedTransaction: '0x02f850018203118080825208808080c080a04012522854168b27e5dc3d5839bab5e6b39e1a0ffd343901ce1622e3d64b48f1a04e00902ae0502c4728cbf12156290df99c3ed7de85b1dbfe20b5c36931733a33'\n * })\n */\nexport async function sendRawTransaction<chain extends Chain | undefined>(\n client: Client<Transport, chain>,\n { serializedTransaction }: SendRawTransactionParameters,\n): Promise<SendRawTransactionReturnType> {\n return client.request(\n {\n method: 'eth_sendRawTransaction',\n params: [serializedTransaction],\n },\n { retryCount: 0 },\n )\n}\n", "import type { Address } from 'abitype'\n\nimport type { Account } from '../../accounts/types.js'\nimport {\n type ParseAccountErrorType,\n parseAccount,\n} from '../../accounts/utils/parseAccount.js'\nimport type { SignTransactionErrorType } from '../../accounts/utils/signTransaction.js'\nimport type { Client } from '../../clients/createClient.js'\nimport type { Transport } from '../../clients/transports/createTransport.js'\nimport {\n AccountNotFoundError,\n type AccountNotFoundErrorType,\n AccountTypeNotSupportedError,\n type AccountTypeNotSupportedErrorType,\n} from '../../errors/account.js'\nimport { BaseError } from '../../errors/base.js'\nimport type { ErrorType } from '../../errors/utils.js'\nimport {\n type RecoverAuthorizationAddressErrorType,\n recoverAuthorizationAddress,\n} from '../../experimental/eip7702/utils/recoverAuthorizationAddress.js'\nimport type { GetAccountParameter } from '../../types/account.js'\nimport type { Chain, DeriveChain } from '../../types/chain.js'\nimport type { GetChainParameter } from '../../types/chain.js'\nimport type { GetTransactionRequestKzgParameter } from '../../types/kzg.js'\nimport type { Hash } from '../../types/misc.js'\nimport type { TransactionRequest } from '../../types/transaction.js'\nimport type { UnionOmit } from '../../types/utils.js'\nimport type { RequestErrorType } from '../../utils/buildRequest.js'\nimport {\n type AssertCurrentChainErrorType,\n assertCurrentChain,\n} from '../../utils/chain/assertCurrentChain.js'\nimport {\n type GetTransactionErrorReturnType,\n getTransactionError,\n} from '../../utils/errors/getTransactionError.js'\nimport { extract } from '../../utils/formatters/extract.js'\nimport {\n type FormattedTransactionRequest,\n formatTransactionRequest,\n} from '../../utils/formatters/transactionRequest.js'\nimport { getAction } from '../../utils/getAction.js'\nimport { LruMap } from '../../utils/lru.js'\nimport {\n type AssertRequestErrorType,\n type AssertRequestParameters,\n assertRequest,\n} from '../../utils/transaction/assertRequest.js'\nimport { type GetChainIdErrorType, getChainId } from '../public/getChainId.js'\nimport {\n type PrepareTransactionRequestErrorType,\n defaultParameters,\n prepareTransactionRequest,\n} from './prepareTransactionRequest.js'\nimport {\n type SendRawTransactionErrorType,\n sendRawTransaction,\n} from './sendRawTransaction.js'\n\nconst supportsWalletNamespace = new LruMap<boolean>(128)\n\nexport type SendTransactionRequest<\n chain extends Chain | undefined = Chain | undefined,\n chainOverride extends Chain | undefined = Chain | undefined,\n ///\n _derivedChain extends Chain | undefined = DeriveChain<chain, chainOverride>,\n> = UnionOmit<FormattedTransactionRequest<_derivedChain>, 'from'> &\n GetTransactionRequestKzgParameter\n\nexport type SendTransactionParameters<\n chain extends Chain | undefined = Chain | undefined,\n account extends Account | undefined = Account | undefined,\n chainOverride extends Chain | undefined = Chain | undefined,\n request extends SendTransactionRequest<\n chain,\n chainOverride\n > = SendTransactionRequest<chain, chainOverride>,\n> = request &\n GetAccountParameter<account, Account | Address, true, true> &\n GetChainParameter<chain, chainOverride> &\n GetTransactionRequestKzgParameter<request>\n\nexport type SendTransactionReturnType = Hash\n\nexport type SendTransactionErrorType =\n | ParseAccountErrorType\n | GetTransactionErrorReturnType<\n | AccountNotFoundErrorType\n | AccountTypeNotSupportedErrorType\n | AssertCurrentChainErrorType\n | AssertRequestErrorType\n | GetChainIdErrorType\n | PrepareTransactionRequestErrorType\n | SendRawTransactionErrorType\n | RecoverAuthorizationAddressErrorType\n | SignTransactionErrorType\n | RequestErrorType\n >\n | ErrorType\n\n/**\n * Creates, signs, and sends a new transaction to the network.\n *\n * - Docs: https://viem.sh/docs/actions/wallet/sendTransaction\n * - Examples: https://stackblitz.com/github/wevm/viem/tree/main/examples/transactions_sending-transactions\n * - JSON-RPC Methods:\n * - JSON-RPC Accounts: [`eth_sendTransaction`](https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_sendtransaction)\n * - Local Accounts: [`eth_sendRawTransaction`](https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_sendrawtransaction)\n *\n * @param client - Client to use\n * @param parameters - {@link SendTransactionParameters}\n * @returns The [Transaction](https://viem.sh/docs/glossary/terms#transaction) hash. {@link SendTransactionReturnType}\n *\n * @example\n * import { createWalletClient, custom } from 'viem'\n * import { mainnet } from 'viem/chains'\n * import { sendTransaction } from 'viem/wallet'\n *\n * const client = createWalletClient({\n * chain: mainnet,\n * transport: custom(window.ethereum),\n * })\n * const hash = await sendTransaction(client, {\n * account: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e',\n * to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8',\n * value: 1000000000000000000n,\n * })\n *\n * @example\n * // Account Hoisting\n * import { createWalletClient, http } from 'viem'\n * import { privateKeyToAccount } from 'viem/accounts'\n * import { mainnet } from 'viem/chains'\n * import { sendTransaction } from 'viem/wallet'\n *\n * const client = createWalletClient({\n * account: privateKeyToAccount('0x…'),\n * chain: mainnet,\n * transport: http(),\n * })\n * const hash = await sendTransaction(client, {\n * to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8',\n * value: 1000000000000000000n,\n * })\n */\nexport async function sendTransaction<\n chain extends Chain | undefined,\n account extends Account | undefined,\n const request extends SendTransactionRequest<chain, chainOverride>,\n chainOverride extends Chain | undefined = undefined,\n>(\n client: Client<Transport, chain, account>,\n parameters: SendTransactionParameters<chain, account, chainOverride, request>,\n): Promise<SendTransactionReturnType> {\n const {\n account: account_ = client.account,\n chain = client.chain,\n accessList,\n authorizationList,\n blobs,\n data,\n gas,\n gasPrice,\n maxFeePerBlobGas,\n maxFeePerGas,\n maxPriorityFeePerGas,\n nonce,\n value,\n ...rest\n } = parameters\n\n if (typeof account_ === 'undefined')\n throw new AccountNotFoundError({\n docsPath: '/docs/actions/wallet/sendTransaction',\n })\n const account = account_ ? parseAccount(account_) : null\n\n try {\n assertRequest(parameters as AssertRequestParameters)\n\n const to = await (async () => {\n // If `to` exists on the parameters, use that.\n if (parameters.to) return parameters.to\n\n // If `to` is null, we are sending a deployment transaction.\n if (parameters.to === null) return undefined\n\n // If no `to` exists, and we are sending a EIP-7702 transaction, use the\n // address of the first authorization in the list.\n if (authorizationList && authorizationList.length > 0)\n return await recoverAuthorizationAddress({\n authorization: authorizationList[0],\n }).catch(() => {\n throw new BaseError(\n '`to` is required. Could not infer from `authorizationList`.',\n )\n })\n\n // Otherwise, we are sending a deployment transaction.\n return undefined\n })()\n\n if (account?.type === 'json-rpc' || account === null) {\n let chainId: number | undefined\n if (chain !== null) {\n chainId = await getAction(client, getChainId, 'getChainId')({})\n assertCurrentChain({\n currentChainId: chainId,\n chain,\n })\n }\n\n const chainFormat = client.chain?.formatters?.transactionRequest?.format\n const format = chainFormat || formatTransactionRequest\n\n const request = format({\n // Pick out extra data that might exist on the chain's transaction request type.\n ...extract(rest, { format: chainFormat }),\n accessList,\n authorizationList,\n blobs,\n chainId,\n data,\n from: account?.address,\n gas,\n gasPrice,\n maxFeePerBlobGas,\n maxFeePerGas,\n maxPriorityFeePerGas,\n nonce,\n to,\n value,\n } as TransactionRequest)\n\n const isWalletNamespaceSupported = supportsWalletNamespace.get(client.uid)\n const method = isWalletNamespaceSupported\n ? 'wallet_sendTransaction'\n : 'eth_sendTransaction'\n\n try {\n return await client.request(\n {\n method,\n params: [request],\n },\n { retryCount: 0 },\n )\n } catch (e) {\n if (isWalletNamespaceSupported === false) throw e\n\n const error = e as BaseError\n // If the transport does not support the method or input, attempt to use the\n // `wallet_sendTransaction` method.\n if (\n error.name === 'InvalidInputRpcError' ||\n error.name === 'InvalidParamsRpcError' ||\n error.name === 'MethodNotFoundRpcError' ||\n error.name === 'MethodNotSupportedRpcError'\n ) {\n return await client\n .request(\n {\n method: 'wallet_sendTransaction',\n params: [request],\n },\n { retryCount: 0 },\n )\n .then((hash) => {\n supportsWalletNamespace.set(client.uid, true)\n return hash\n })\n .catch((e) => {\n const walletNamespaceError = e as BaseError\n if (\n walletNamespaceError.name === 'MethodNotFoundRpcError' ||\n walletNamespaceError.name === 'MethodNotSupportedRpcError'\n ) {\n supportsWalletNamespace.set(client.uid, false)\n throw error\n }\n\n throw walletNamespaceError\n })\n }\n\n throw error\n }\n }\n\n if (account?.type === 'local') {\n // Prepare the request for signing (assign appropriate fees, etc.)\n const request = await getAction(\n client,\n prepareTransactionRequest,\n 'prepareTransactionRequest',\n )({\n account,\n accessList,\n authorizationList,\n blobs,\n chain,\n data,\n gas,\n gasPrice,\n maxFeePerBlobGas,\n maxFeePerGas,\n maxPriorityFeePerGas,\n nonce,\n nonceManager: account.nonceManager,\n parameters: [...defaultParameters, 'sidecars'],\n value,\n ...rest,\n to,\n } as any)\n\n const serializer = chain?.serializers?.transaction\n const serializedTransaction = (await account.signTransaction(request, {\n serializer,\n })) as Hash\n return await getAction(\n client,\n sendRawTransaction,\n 'sendRawTransaction',\n )({\n serializedTransaction,\n })\n }\n\n if (account?.type === 'smart')\n throw new AccountTypeNotSupportedError({\n metaMessages: [\n 'Consider using the `sendUserOperation` Action instead.',\n ],\n docsPath: '/docs/actions/bundler/sendUserOperation',\n type: 'smart',\n })\n\n throw new AccountTypeNotSupportedError({\n docsPath: '/docs/actions/wallet/sendTransaction',\n type: (account as any)?.type,\n })\n } catch (err) {\n if (err instanceof AccountTypeNotSupportedError) throw err\n throw getTransactionError(err as BaseError, {\n ...parameters,\n account,\n chain: parameters.chain || undefined,\n })\n }\n}\n", "import type { Abi } from 'abitype'\n\nimport type { Account } from '../../accounts/types.js'\nimport type { Client } from '../../clients/createClient.js'\nimport type { Transport } from '../../clients/transports/createTransport.js'\nimport type { Chain } from '../../types/chain.js'\nimport type { GetChainParameter } from '../../types/chain.js'\nimport type { ContractConstructorArgs } from '../../types/contract.js'\nimport type { Hex } from '../../types/misc.js'\nimport type { UnionEvaluate, UnionOmit } from '../../types/utils.js'\nimport { encodeDeployData } from '../../utils/abi/encodeDeployData.js'\n\nimport type { ErrorType } from '../../errors/utils.js'\nimport {\n type SendTransactionErrorType,\n type SendTransactionParameters,\n type SendTransactionReturnType,\n sendTransaction,\n} from './sendTransaction.js'\n\nexport type DeployContractParameters<\n abi extends Abi | readonly unknown[] = Abi,\n chain extends Chain | undefined = Chain | undefined,\n account extends Account | undefined = Account | undefined,\n chainOverride extends Chain | undefined = Chain | undefined,\n ///\n allArgs = ContractConstructorArgs<abi>,\n> = UnionOmit<\n SendTransactionParameters<chain, account, chainOverride>,\n 'accessList' | 'chain' | 'to' | 'data'\n> &\n GetChainParameter<chain, chainOverride> &\n UnionEvaluate<\n readonly [] extends allArgs\n ? { args?: allArgs | undefined }\n : { args: allArgs }\n > & {\n abi: abi\n bytecode: Hex\n }\n\nexport type DeployContractReturnType = SendTransactionReturnType\n\nexport type DeployContractErrorType = SendTransactionErrorType | ErrorType\n\n/**\n * Deploys a contract to the network, given bytecode and constructor arguments.\n *\n * - Docs: https://viem.sh/docs/contract/deployContract\n * - Examples: https://stackblitz.com/github/wevm/viem/tree/main/examples/contracts_deploying-contracts\n *\n * @param client - Client to use\n * @param parameters - {@link DeployContractParameters}\n * @returns The [Transaction](https://viem.sh/docs/glossary/terms#transaction) hash. {@link DeployContractReturnType}\n *\n * @example\n * import { createWalletClient, http } from 'viem'\n * import { privateKeyToAccount } from 'viem/accounts'\n * import { mainnet } from 'viem/chains'\n * import { deployContract } from 'viem/contract'\n *\n * const client = createWalletClient({\n * account: privateKeyToAccount('0x…'),\n * chain: mainnet,\n * transport: http(),\n * })\n * const hash = await deployContract(client, {\n * abi: [],\n * account: '0x…,\n * bytecode: '0x608060405260405161083e38038061083e833981016040819052610...',\n * })\n */\nexport function deployContract<\n const abi extends Abi | readonly unknown[],\n chain extends Chain | undefined,\n account extends Account | undefined,\n chainOverride extends Chain | undefined,\n>(\n walletClient: Client<Transport, chain, account>,\n parameters: DeployContractParameters<abi, chain, account, chainOverride>,\n): Promise<DeployContractReturnType> {\n const { abi, args, bytecode, ...request } =\n parameters as DeployContractParameters\n const calldata = encodeDeployData({ abi, args, bytecode })\n return sendTransaction(walletClient, {\n ...request,\n ...(request.authorizationList ? { to: null } : {}),\n data: calldata,\n } as unknown as SendTransactionParameters<chain, account, chainOverride>)\n}\n", "import { panicReasons } from '../../constants/solidity.js'\nimport { BaseError } from '../../errors/base.js'\nimport { ContractFunctionRevertedError } from '../../errors/contract.js'\nimport type { ErrorType } from '../../errors/utils.js'\n\n/** @internal */\nexport type IsNullUniversalResolverErrorErrorType = ErrorType\n\n/*\n * @description Checks if error is a valid null result UniversalResolver error\n */\nexport function isNullUniversalResolverError(\n err: unknown,\n callType: 'resolve' | 'reverse',\n): boolean {\n if (!(err instanceof BaseError)) return false\n const cause = err.walk((e) => e instanceof ContractFunctionRevertedError)\n if (!(cause instanceof ContractFunctionRevertedError)) return false\n if (cause.data?.errorName === 'ResolverNotFound') return true\n if (cause.data?.errorName === 'ResolverWildcardNotSupported') return true\n if (cause.data?.errorName === 'ResolverNotContract') return true\n if (cause.data?.errorName === 'ResolverError') return true\n if (cause.data?.errorName === 'HttpError') return true\n // Backwards compatibility for older UniversalResolver contracts\n if (\n cause.reason?.includes(\n 'Wildcard on non-extended resolvers is not supported',\n )\n )\n return true\n // No primary name set for address.\n if (callType === 'reverse' && cause.reason === panicReasons[50]) return true\n return false\n}\n", "import type { ErrorType } from '../../errors/utils.js'\nimport type { Hex } from '../../types/misc.js'\nimport { type IsHexErrorType, isHex } from '../data/isHex.js'\n\nexport type EncodedLabelToLabelhashErrorType = IsHexErrorType | ErrorType\n\nexport function encodedLabelToLabelhash(label: string): Hex | null {\n if (label.length !== 66) return null\n if (label.indexOf('[') !== 0) return null\n if (label.indexOf(']') !== 65) return null\n const hash = `0x${label.slice(1, 65)}`\n if (!isHex(hash)) return null\n return hash\n}\n", "import type { ErrorType } from '../../errors/utils.js'\nimport { type ConcatErrorType, concat } from '../data/concat.js'\nimport {\n type StringToBytesErrorType,\n type ToBytesErrorType,\n stringToBytes,\n toBytes,\n} from '../encoding/toBytes.js'\nimport { type BytesToHexErrorType, bytesToHex } from '../encoding/toHex.js'\nimport { type Keccak256ErrorType, keccak256 } from '../hash/keccak256.js'\nimport {\n type EncodedLabelToLabelhashErrorType,\n encodedLabelToLabelhash,\n} from './encodedLabelToLabelhash.js'\n\nexport type NamehashErrorType =\n | BytesToHexErrorType\n | EncodedLabelToLabelhashErrorType\n | ToBytesErrorType\n | Keccak256ErrorType\n | StringToBytesErrorType\n | ConcatErrorType\n | ErrorType\n\n/**\n * @description Hashes ENS name\n *\n * - Since ENS names prohibit certain forbidden characters (e.g. underscore) and have other validation rules, you likely want to [normalize ENS names](https://docs.ens.domains/contract-api-reference/name-processing#normalising-names) with [UTS-46 normalization](https://unicode.org/reports/tr46) before passing them to `namehash`. You can use the built-in [`normalize`](https://viem.sh/docs/ens/utilities/normalize) function for this.\n *\n * @example\n * namehash('wevm.eth')\n * '0xf246651c1b9a6b141d19c2604e9a58f567973833990f830d882534a747801359'\n *\n * @link https://eips.ethereum.org/EIPS/eip-137\n */\nexport function namehash(name: string) {\n let result = new Uint8Array(32).fill(0)\n if (!name) return bytesToHex(result)\n\n const labels = name.split('.')\n // Iterate in reverse order building up hash\n for (let i = labels.length - 1; i >= 0; i -= 1) {\n const hashFromEncodedLabel = encodedLabelToLabelhash(labels[i])\n const hashed = hashFromEncodedLabel\n ? toBytes(hashFromEncodedLabel)\n : keccak256(stringToBytes(labels[i]), 'bytes')\n result = keccak256(concat([result, hashed]), 'bytes')\n }\n\n return bytesToHex(result)\n}\n", "import type { ErrorType } from '../../errors/utils.js'\nimport type { Hex } from '../../types/misc.js'\n\nexport type EncodeLabelhashErrorType = ErrorType\n\nexport function encodeLabelhash(hash: Hex): `[${string}]` {\n return `[${hash.slice(2)}]`\n}\n", "import type { ErrorType } from '../../errors/utils.js'\nimport {\n type StringToBytesErrorType,\n stringToBytes,\n} from '../encoding/toBytes.js'\nimport { type BytesToHexErrorType, bytesToHex } from '../encoding/toHex.js'\nimport { type Keccak256ErrorType, keccak256 } from '../hash/keccak256.js'\nimport {\n type EncodedLabelToLabelhashErrorType,\n encodedLabelToLabelhash,\n} from './encodedLabelToLabelhash.js'\n\nexport type LabelhashErrorType =\n | BytesToHexErrorType\n | EncodedLabelToLabelhashErrorType\n | Keccak256ErrorType\n | StringToBytesErrorType\n | ErrorType\n\n/**\n * @description Hashes ENS label\n *\n * - Since ENS labels prohibit certain forbidden characters (e.g. underscore) and have other validation rules, you likely want to [normalize ENS labels](https://docs.ens.domains/contract-api-reference/name-processing#normalising-names) with [UTS-46 normalization](https://unicode.org/reports/tr46) before passing them to `labelhash`. You can use the built-in [`normalize`](https://viem.sh/docs/ens/utilities/normalize) function for this.\n *\n * @example\n * labelhash('eth')\n * '0x4f5b812789fc606be1b3b16908db13fc7a9adf7ca72641f84d75b47069d3d7f0'\n */\nexport function labelhash(label: string) {\n const result = new Uint8Array(32).fill(0)\n if (!label) return bytesToHex(result)\n return encodedLabelToLabelhash(label) || keccak256(stringToBytes(label))\n}\n", "// Adapted from https://github.com/mafintosh/dns-packet\nimport type { ErrorType } from '../../errors/utils.js'\nimport type { ByteArray } from '../../types/misc.js'\nimport {\n type StringToBytesErrorType,\n stringToBytes,\n} from '../encoding/toBytes.js'\nimport {\n type EncodeLabelhashErrorType,\n encodeLabelhash,\n} from './encodeLabelhash.js'\nimport { type LabelhashErrorType, labelhash } from './labelhash.js'\n\nexport type PacketToBytesErrorType =\n | EncodeLabelhashErrorType\n | LabelhashErrorType\n | StringToBytesErrorType\n | ErrorType\n\n/*\n * @description Encodes a DNS packet into a ByteArray containing a UDP payload.\n *\n * @example\n * packetToBytes('awkweb.eth')\n * '0x0661776b7765620365746800'\n *\n * @see https://docs.ens.domains/resolution/names#dns\n *\n */\nexport function packetToBytes(packet: string): ByteArray {\n // strip leading and trailing `.`\n const value = packet.replace(/^\\.|\\.$/gm, '')\n if (value.length === 0) return new Uint8Array(1)\n\n const bytes = new Uint8Array(stringToBytes(value).byteLength + 2)\n\n let offset = 0\n const list = value.split('.')\n for (let i = 0; i < list.length; i++) {\n let encoded = stringToBytes(list[i])\n // if the length is > 255, make the encoded label value a labelhash\n // this is compatible with the universal resolver\n if (encoded.byteLength > 255)\n encoded = stringToBytes(encodeLabelhash(labelhash(list[i])))\n bytes[offset] = encoded.length\n bytes.set(encoded, offset + 1)\n offset += encoded.length + 1\n }\n\n if (bytes.byteLength !== offset + 1) return bytes.slice(0, offset + 1)\n\n return bytes\n}\n", "import type { Abi, Address } from 'abitype'\n\nimport { AbiDecodingZeroDataError } from '../../errors/abi.js'\nimport { BaseError } from '../../errors/base.js'\nimport {\n ContractFunctionExecutionError,\n type ContractFunctionExecutionErrorType,\n ContractFunctionRevertedError,\n type ContractFunctionRevertedErrorType,\n ContractFunctionZeroDataError,\n type ContractFunctionZeroDataErrorType,\n RawContractError,\n} from '../../errors/contract.js'\nimport { RpcRequestError } from '../../errors/request.js'\nimport { InternalRpcError } from '../../errors/rpc.js'\nimport type { ErrorType } from '../../errors/utils.js'\n\nconst EXECUTION_REVERTED_ERROR_CODE = 3\n\nexport type GetContractErrorReturnType<cause = ErrorType> = Omit<\n ContractFunctionExecutionErrorType,\n 'cause'\n> & {\n cause:\n | cause\n | ContractFunctionZeroDataErrorType\n | ContractFunctionRevertedErrorType\n}\n\nexport function getContractError<err extends ErrorType<string>>(\n err: err,\n {\n abi,\n address,\n args,\n docsPath,\n functionName,\n sender,\n }: {\n abi: Abi\n args: any\n address?: Address | undefined\n docsPath?: string | undefined\n functionName: string\n sender?: Address | undefined\n },\n): GetContractErrorReturnType {\n const error = (\n err instanceof RawContractError\n ? err\n : err instanceof BaseError\n ? err.walk((err) => 'data' in (err as Error)) || err.walk()\n : {}\n ) as BaseError\n const { code, data, details, message, shortMessage } =\n error as RawContractError\n\n const cause = (() => {\n if (err instanceof AbiDecodingZeroDataError)\n return new ContractFunctionZeroDataError({ functionName })\n if (\n [EXECUTION_REVERTED_ERROR_CODE, InternalRpcError.code].includes(code) &&\n (data || details || message || shortMessage)\n ) {\n return new ContractFunctionRevertedError({\n abi,\n data: typeof data === 'object' ? data.data : data,\n functionName,\n message:\n error instanceof RpcRequestError\n ? details\n : (shortMessage ?? message),\n })\n }\n return err\n })()\n\n return new ContractFunctionExecutionError(cause as BaseError, {\n abi,\n args,\n contractAddress: address,\n docsPath,\n functionName,\n sender,\n }) as GetContractErrorReturnType\n}\n", "import type { Abi } from 'abitype'\n\nimport type { Client } from '../../clients/createClient.js'\nimport type { Transport } from '../../clients/transports/createTransport.js'\nimport type { BaseError } from '../../errors/base.js'\nimport type { Chain } from '../../types/chain.js'\nimport type {\n ContractFunctionArgs,\n ContractFunctionName,\n ContractFunctionParameters,\n ContractFunctionReturnType,\n} from '../../types/contract.js'\nimport type { UnionEvaluate } from '../../types/utils.js'\nimport {\n type DecodeFunctionResultErrorType,\n decodeFunctionResult,\n} from '../../utils/abi/decodeFunctionResult.js'\nimport {\n type EncodeFunctionDataErrorType,\n type EncodeFunctionDataParameters,\n encodeFunctionData,\n} from '../../utils/abi/encodeFunctionData.js'\nimport {\n type GetContractErrorReturnType,\n getContractError,\n} from '../../utils/errors/getContractError.js'\nimport { getAction } from '../../utils/getAction.js'\n\nimport { type CallErrorType, type CallParameters, call } from './call.js'\n\nexport type ReadContractParameters<\n abi extends Abi | readonly unknown[] = Abi,\n functionName extends ContractFunctionName<\n abi,\n 'pure' | 'view'\n > = ContractFunctionName<abi, 'pure' | 'view'>,\n args extends ContractFunctionArgs<\n abi,\n 'pure' | 'view',\n functionName\n > = ContractFunctionArgs<abi, 'pure' | 'view', functionName>,\n> = UnionEvaluate<\n Pick<\n CallParameters,\n | 'account'\n | 'blockNumber'\n | 'blockTag'\n | 'factory'\n | 'factoryData'\n | 'stateOverride'\n >\n> &\n ContractFunctionParameters<abi, 'pure' | 'view', functionName, args, boolean>\n\nexport type ReadContractReturnType<\n abi extends Abi | readonly unknown[] = Abi,\n functionName extends ContractFunctionName<\n abi,\n 'pure' | 'view'\n > = ContractFunctionName<abi, 'pure' | 'view'>,\n args extends ContractFunctionArgs<\n abi,\n 'pure' | 'view',\n functionName\n > = ContractFunctionArgs<abi, 'pure' | 'view', functionName>,\n> = ContractFunctionReturnType<abi, 'pure' | 'view', functionName, args>\n\nexport type ReadContractErrorType = GetContractErrorReturnType<\n CallErrorType | EncodeFunctionDataErrorType | DecodeFunctionResultErrorType\n>\n\n/**\n * Calls a read-only function on a contract, and returns the response.\n *\n * - Docs: https://viem.sh/docs/contract/readContract\n * - Examples: https://stackblitz.com/github/wevm/viem/tree/main/examples/contracts_reading-contracts\n *\n * A \"read-only\" function (constant function) on a Solidity contract is denoted by a `view` or `pure` keyword. They can only read the state of the contract, and cannot make any changes to it. Since read-only methods do not change the state of the contract, they do not require any gas to be executed, and can be called by any user without the need to pay for gas.\n *\n * Internally, uses a [Public Client](https://viem.sh/docs/clients/public) to call the [`call` action](https://viem.sh/docs/actions/public/call) with [ABI-encoded `data`](https://viem.sh/docs/contract/encodeFunctionData).\n *\n * @param client - Client to use\n * @param parameters - {@link ReadContractParameters}\n * @returns The response from the contract. Type is inferred. {@link ReadContractReturnType}\n *\n * @example\n * import { createPublicClient, http, parseAbi } from 'viem'\n * import { mainnet } from 'viem/chains'\n * import { readContract } from 'viem/contract'\n *\n * const client = createPublicClient({\n * chain: mainnet,\n * transport: http(),\n * })\n * const result = await readContract(client, {\n * address: '0xFBA3912Ca04dd458c843e2EE08967fC04f3579c2',\n * abi: parseAbi(['function balanceOf(address) view returns (uint256)']),\n * functionName: 'balanceOf',\n * args: ['0xA0Cf798816D4b9b9866b5330EEa46a18382f251e'],\n * })\n * // 424122n\n */\nexport async function readContract<\n chain extends Chain | undefined,\n const abi extends Abi | readonly unknown[],\n functionName extends ContractFunctionName<abi, 'pure' | 'view'>,\n const args extends ContractFunctionArgs<abi, 'pure' | 'view', functionName>,\n>(\n client: Client<Transport, chain>,\n parameters: ReadContractParameters<abi, functionName, args>,\n): Promise<ReadContractReturnType<abi, functionName, args>> {\n const { abi, address, args, functionName, ...rest } =\n parameters as ReadContractParameters\n const calldata = encodeFunctionData({\n abi,\n args,\n functionName,\n } as EncodeFunctionDataParameters)\n try {\n const { data } = await getAction(\n client,\n call,\n 'call',\n )({\n ...(rest as CallParameters),\n data: calldata,\n to: address!,\n })\n return decodeFunctionResult({\n abi,\n args,\n functionName,\n data: data || '0x',\n }) as ReadContractReturnType<abi, functionName>\n } catch (error) {\n throw getContractError(error as BaseError, {\n abi,\n address,\n args,\n docsPath: '/docs/contract/readContract',\n functionName,\n })\n }\n}\n", "import type { Address } from 'abitype'\n\nimport type { Client } from '../../clients/createClient.js'\nimport type { Transport } from '../../clients/transports/createTransport.js'\nimport {\n addressResolverAbi,\n universalResolverResolveAbi,\n} from '../../constants/abis.js'\nimport type { ErrorType } from '../../errors/utils.js'\nimport type { Chain } from '../../types/chain.js'\nimport type { Prettify } from '../../types/utils.js'\nimport {\n type DecodeFunctionResultErrorType,\n decodeFunctionResult,\n} from '../../utils/abi/decodeFunctionResult.js'\nimport {\n type EncodeFunctionDataErrorType,\n encodeFunctionData,\n} from '../../utils/abi/encodeFunctionData.js'\nimport {\n type GetChainContractAddressErrorType,\n getChainContractAddress,\n} from '../../utils/chain/getChainContractAddress.js'\nimport { type TrimErrorType, trim } from '../../utils/data/trim.js'\nimport { type ToHexErrorType, toHex } from '../../utils/encoding/toHex.js'\nimport { isNullUniversalResolverError } from '../../utils/ens/errors.js'\nimport { type NamehashErrorType, namehash } from '../../utils/ens/namehash.js'\nimport {\n type PacketToBytesErrorType,\n packetToBytes,\n} from '../../utils/ens/packetToBytes.js'\nimport { getAction } from '../../utils/getAction.js'\nimport {\n type ReadContractParameters,\n readContract,\n} from '../public/readContract.js'\n\nexport type GetEnsAddressParameters = Prettify<\n Pick<ReadContractParameters, 'blockNumber' | 'blockTag'> & {\n /** ENSIP-9 compliant coinType used to resolve addresses for other chains */\n coinType?: number | undefined\n /** Universal Resolver gateway URLs to use for resolving CCIP-read requests. */\n gatewayUrls?: string[] | undefined\n /** Name to get the address for. */\n name: string\n /** Whether or not to throw errors propagated from the ENS Universal Resolver Contract. */\n strict?: boolean | undefined\n /** Address of ENS Universal Resolver Contract. */\n universalResolverAddress?: Address | undefined\n }\n>\n\nexport type GetEnsAddressReturnType = Address | null\n\nexport type GetEnsAddressErrorType =\n | GetChainContractAddressErrorType\n | EncodeFunctionDataErrorType\n | NamehashErrorType\n | ToHexErrorType\n | PacketToBytesErrorType\n | DecodeFunctionResultErrorType\n | TrimErrorType\n | ErrorType\n\n/**\n * Gets address for ENS name.\n *\n * - Docs: https://viem.sh/docs/ens/actions/getEnsAddress\n * - Examples: https://stackblitz.com/github/wevm/viem/tree/main/examples/ens\n *\n * Calls `resolve(bytes, bytes)` on ENS Universal Resolver Contract.\n *\n * Since ENS names prohibit certain forbidden characters (e.g. underscore) and have other validation rules, you likely want to [normalize ENS names](https://docs.ens.domains/contract-api-reference/name-processing#normalising-names) with [UTS-46 normalization](https://unicode.org/reports/tr46) before passing them to `getEnsAddress`. You can use the built-in [`normalize`](https://viem.sh/docs/ens/utilities/normalize) function for this.\n *\n * @param client - Client to use\n * @param parameters - {@link GetEnsAddressParameters}\n * @returns Address for ENS name or `null` if not found. {@link GetEnsAddressReturnType}\n *\n * @example\n * import { createPublicClient, http } from 'viem'\n * import { mainnet } from 'viem/chains'\n * import { getEnsAddress, normalize } from 'viem/ens'\n *\n * const client = createPublicClient({\n * chain: mainnet,\n * transport: http(),\n * })\n * const ensAddress = await getEnsAddress(client, {\n * name: normalize('wevm.eth'),\n * })\n * // '0xd2135CfB216b74109775236E36d4b433F1DF507B'\n */\nexport async function getEnsAddress<chain extends Chain | undefined>(\n client: Client<Transport, chain>,\n {\n blockNumber,\n blockTag,\n coinType,\n name,\n gatewayUrls,\n strict,\n universalResolverAddress: universalResolverAddress_,\n }: GetEnsAddressParameters,\n): Promise<GetEnsAddressReturnType> {\n let universalResolverAddress = universalResolverAddress_\n if (!universalResolverAddress) {\n if (!client.chain)\n throw new Error(\n 'client chain not configured. universalResolverAddress is required.',\n )\n\n universalResolverAddress = getChainContractAddress({\n blockNumber,\n chain: client.chain,\n contract: 'ensUniversalResolver',\n })\n }\n\n try {\n const functionData = encodeFunctionData({\n abi: addressResolverAbi,\n functionName: 'addr',\n ...(coinType != null\n ? { args: [namehash(name), BigInt(coinType)] }\n : { args: [namehash(name)] }),\n })\n\n const readContractParameters = {\n address: universalResolverAddress,\n abi: universalResolverResolveAbi,\n functionName: 'resolve',\n args: [toHex(packetToBytes(name)), functionData],\n blockNumber,\n blockTag,\n } as const\n\n const readContractAction = getAction(client, readContract, 'readContract')\n\n const res = gatewayUrls\n ? await readContractAction({\n ...readContractParameters,\n args: [...readContractParameters.args, gatewayUrls],\n })\n : await readContractAction(readContractParameters)\n\n if (res[0] === '0x') return null\n\n const address = decodeFunctionResult({\n abi: addressResolverAbi,\n args: coinType != null ? [namehash(name), BigInt(coinType)] : undefined,\n functionName: 'addr',\n data: res[0],\n })\n\n if (address === '0x') return null\n if (trim(address) === '0x00') return null\n return address\n } catch (err) {\n if (strict) throw err\n if (isNullUniversalResolverError(err, 'resolve')) return null\n throw err\n }\n}\n", "import { BaseError } from './base.js'\n\nexport type EnsAvatarInvalidMetadataErrorType =\n EnsAvatarInvalidMetadataError & {\n name: 'EnsAvatarInvalidMetadataError'\n }\nexport class EnsAvatarInvalidMetadataError extends BaseError {\n constructor({ data }: { data: any }) {\n super(\n 'Unable to extract image from metadata. The metadata may be malformed or invalid.',\n {\n metaMessages: [\n '- Metadata must be a JSON object with at least an `image`, `image_url` or `image_data` property.',\n '',\n `Provided data: ${JSON.stringify(data)}`,\n ],\n name: 'EnsAvatarInvalidMetadataError',\n },\n )\n }\n}\n\nexport type EnsAvatarInvalidNftUriErrorType = EnsAvatarInvalidNftUriError & {\n name: 'EnsAvatarInvalidNftUriError'\n}\nexport class EnsAvatarInvalidNftUriError extends BaseError {\n constructor({ reason }: { reason: string }) {\n super(`ENS NFT avatar URI is invalid. ${reason}`, {\n name: 'EnsAvatarInvalidNftUriError',\n })\n }\n}\n\nexport type EnsAvatarUriResolutionErrorType = EnsAvatarUriResolutionError & {\n name: 'EnsAvatarUriResolutionError'\n}\nexport class EnsAvatarUriResolutionError extends BaseError {\n constructor({ uri }: { uri: string }) {\n super(\n `Unable to resolve ENS avatar URI \"${uri}\". The URI may be malformed, invalid, or does not respond with a valid image.`,\n { name: 'EnsAvatarUriResolutionError' },\n )\n }\n}\n\nexport type EnsAvatarUnsupportedNamespaceErrorType =\n EnsAvatarUnsupportedNamespaceError & {\n name: 'EnsAvatarUnsupportedNamespaceError'\n }\nexport class EnsAvatarUnsupportedNamespaceError extends BaseError {\n constructor({ namespace }: { namespace: string }) {\n super(\n `ENS NFT avatar namespace \"${namespace}\" is not supported. Must be \"erc721\" or \"erc1155\".`,\n { name: 'EnsAvatarUnsupportedNamespaceError' },\n )\n }\n}\n", "import type { Address } from 'abitype'\n\nimport {\n type ReadContractErrorType,\n readContract,\n} from '../../../actions/public/readContract.js'\nimport type { Client } from '../../../clients/createClient.js'\nimport type { Transport } from '../../../clients/transports/createTransport.js'\nimport {\n EnsAvatarInvalidMetadataError,\n type EnsAvatarInvalidMetadataErrorType,\n EnsAvatarInvalidNftUriError,\n type EnsAvatarInvalidNftUriErrorType,\n EnsAvatarUnsupportedNamespaceError,\n type EnsAvatarUnsupportedNamespaceErrorType,\n EnsAvatarUriResolutionError,\n type EnsAvatarUriResolutionErrorType,\n} from '../../../errors/ens.js'\nimport type { ErrorType } from '../../../errors/utils.js'\nimport type { Chain } from '../../../types/chain.js'\nimport type { AssetGatewayUrls } from '../../../types/ens.js'\n\ntype UriItem = {\n uri: string\n isOnChain: boolean\n isEncoded: boolean\n}\n\nconst networkRegex =\n /(?<protocol>https?:\\/\\/[^\\/]*|ipfs:\\/|ipns:\\/|ar:\\/)?(?<root>\\/)?(?<subpath>ipfs\\/|ipns\\/)?(?<target>[\\w\\-.]+)(?<subtarget>\\/.*)?/\nconst ipfsHashRegex =\n /^(Qm[1-9A-HJ-NP-Za-km-z]{44,}|b[A-Za-z2-7]{58,}|B[A-Z2-7]{58,}|z[1-9A-HJ-NP-Za-km-z]{48,}|F[0-9A-F]{50,})(\\/(?<target>[\\w\\-.]+))?(?<subtarget>\\/.*)?$/\nconst base64Regex = /^data:([a-zA-Z\\-/+]*);base64,([^\"].*)/\nconst dataURIRegex = /^data:([a-zA-Z\\-/+]*)?(;[a-zA-Z0-9].*?)?(,)/\n\ntype IsImageUriErrorType = ErrorType\n\n/** @internal */\nexport async function isImageUri(uri: string) {\n try {\n const res = await fetch(uri, { method: 'HEAD' })\n // retrieve content type header to check if content is image\n if (res.status === 200) {\n const contentType = res.headers.get('content-type')\n return contentType?.startsWith('image/')\n }\n return false\n } catch (error: any) {\n // if error is not cors related then fail\n if (typeof error === 'object' && typeof error.response !== 'undefined') {\n return false\n }\n // fail in NodeJS, since the error is not cors but any other network issue\n // biome-ignore lint/suspicious/noPrototypeBuiltins:\n if (!globalThis.hasOwnProperty('Image')) return false\n // in case of cors, use image api to validate if given url is an actual image\n return new Promise((resolve) => {\n const img = new Image()\n img.onload = () => {\n resolve(true)\n }\n img.onerror = () => {\n resolve(false)\n }\n img.src = uri\n })\n }\n}\n\ntype GetGatewayErrorType = ErrorType\n\n/** @internal */\nexport function getGateway(custom: string | undefined, defaultGateway: string) {\n if (!custom) return defaultGateway\n if (custom.endsWith('/')) return custom.slice(0, -1)\n return custom\n}\n\nexport type ResolveAvatarUriErrorType =\n | GetGatewayErrorType\n | EnsAvatarUriResolutionErrorType\n | ErrorType\n\nexport function resolveAvatarUri({\n uri,\n gatewayUrls,\n}: {\n uri: string\n gatewayUrls?: AssetGatewayUrls | undefined\n}): UriItem {\n const isEncoded = base64Regex.test(uri)\n if (isEncoded) return { uri, isOnChain: true, isEncoded }\n\n const ipfsGateway = getGateway(gatewayUrls?.ipfs, 'https://ipfs.io')\n const arweaveGateway = getGateway(gatewayUrls?.arweave, 'https://arweave.net')\n\n const networkRegexMatch = uri.match(networkRegex)\n const {\n protocol,\n subpath,\n target,\n subtarget = '',\n } = networkRegexMatch?.groups || {}\n\n const isIPNS = protocol === 'ipns:/' || subpath === 'ipns/'\n const isIPFS =\n protocol === 'ipfs:/' || subpath === 'ipfs/' || ipfsHashRegex.test(uri)\n\n if (uri.startsWith('http') && !isIPNS && !isIPFS) {\n let replacedUri = uri\n if (gatewayUrls?.arweave)\n replacedUri = uri.replace(/https:\\/\\/arweave.net/g, gatewayUrls?.arweave)\n return { uri: replacedUri, isOnChain: false, isEncoded: false }\n }\n\n if ((isIPNS || isIPFS) && target) {\n return {\n uri: `${ipfsGateway}/${isIPNS ? 'ipns' : 'ipfs'}/${target}${subtarget}`,\n isOnChain: false,\n isEncoded: false,\n }\n }\n\n if (protocol === 'ar:/' && target) {\n return {\n uri: `${arweaveGateway}/${target}${subtarget || ''}`,\n isOnChain: false,\n isEncoded: false,\n }\n }\n\n let parsedUri = uri.replace(dataURIRegex, '')\n if (parsedUri.startsWith('<svg')) {\n // if svg, base64 encode\n parsedUri = `data:image/svg+xml;base64,${btoa(parsedUri)}`\n }\n\n if (parsedUri.startsWith('data:') || parsedUri.startsWith('{')) {\n return {\n uri: parsedUri,\n isOnChain: true,\n isEncoded: false,\n }\n }\n\n throw new EnsAvatarUriResolutionError({ uri })\n}\n\nexport type GetJsonImageErrorType =\n | EnsAvatarInvalidMetadataErrorType\n | ErrorType\n\nexport function getJsonImage(data: any) {\n // validation check for json data, must include one of theses properties\n if (\n typeof data !== 'object' ||\n (!('image' in data) && !('image_url' in data) && !('image_data' in data))\n ) {\n throw new EnsAvatarInvalidMetadataError({ data })\n }\n\n return data.image || data.image_url || data.image_data\n}\n\nexport type GetMetadataAvatarUriErrorType =\n | EnsAvatarUriResolutionErrorType\n | ParseAvatarUriErrorType\n | GetJsonImageErrorType\n | ErrorType\n\nexport async function getMetadataAvatarUri({\n gatewayUrls,\n uri,\n}: {\n gatewayUrls?: AssetGatewayUrls | undefined\n uri: string\n}): Promise<string> {\n try {\n const res = await fetch(uri).then((res) => res.json())\n const image = await parseAvatarUri({\n gatewayUrls,\n uri: getJsonImage(res),\n })\n return image\n } catch {\n throw new EnsAvatarUriResolutionError({ uri })\n }\n}\n\nexport type ParseAvatarUriErrorType =\n | ResolveAvatarUriErrorType\n | IsImageUriErrorType\n | EnsAvatarUriResolutionErrorType\n | ErrorType\n\nexport async function parseAvatarUri({\n gatewayUrls,\n uri,\n}: {\n gatewayUrls?: AssetGatewayUrls | undefined\n uri: string\n}): Promise<string> {\n const { uri: resolvedURI, isOnChain } = resolveAvatarUri({ uri, gatewayUrls })\n if (isOnChain) return resolvedURI\n\n // check if resolvedURI is an image, if it is return the url\n const isImage = await isImageUri(resolvedURI)\n if (isImage) return resolvedURI\n\n throw new EnsAvatarUriResolutionError({ uri })\n}\n\ntype ParsedNft = {\n chainID: number\n namespace: string\n contractAddress: Address\n tokenID: string\n}\n\nexport type ParseNftUriErrorType = EnsAvatarInvalidNftUriErrorType | ErrorType\n\nexport function parseNftUri(uri_: string): ParsedNft {\n let uri = uri_\n // parse valid nft spec (CAIP-22/CAIP-29)\n // @see: https://github.com/ChainAgnostic/CAIPs/tree/master/CAIPs\n if (uri.startsWith('did:nft:')) {\n // convert DID to CAIP\n uri = uri.replace('did:nft:', '').replace(/_/g, '/')\n }\n\n const [reference, asset_namespace, tokenID] = uri.split('/')\n const [eip_namespace, chainID] = reference.split(':')\n const [erc_namespace, contractAddress] = asset_namespace.split(':')\n\n if (!eip_namespace || eip_namespace.toLowerCase() !== 'eip155')\n throw new EnsAvatarInvalidNftUriError({ reason: 'Only EIP-155 supported' })\n if (!chainID)\n throw new EnsAvatarInvalidNftUriError({ reason: 'Chain ID not found' })\n if (!contractAddress)\n throw new EnsAvatarInvalidNftUriError({\n reason: 'Contract address not found',\n })\n if (!tokenID)\n throw new EnsAvatarInvalidNftUriError({ reason: 'Token ID not found' })\n if (!erc_namespace)\n throw new EnsAvatarInvalidNftUriError({ reason: 'ERC namespace not found' })\n\n return {\n chainID: Number.parseInt(chainID),\n namespace: erc_namespace.toLowerCase(),\n contractAddress: contractAddress as Address,\n tokenID,\n }\n}\n\nexport type GetNftTokenUriErrorType =\n | ReadContractErrorType\n | EnsAvatarUnsupportedNamespaceErrorType\n | ErrorType\n\nexport async function getNftTokenUri<chain extends Chain | undefined>(\n client: Client<Transport, chain>,\n { nft }: { nft: ParsedNft },\n) {\n if (nft.namespace === 'erc721') {\n return readContract(client, {\n address: nft.contractAddress,\n abi: [\n {\n name: 'tokenURI',\n type: 'function',\n stateMutability: 'view',\n inputs: [{ name: 'tokenId', type: 'uint256' }],\n outputs: [{ name: '', type: 'string' }],\n },\n ],\n functionName: 'tokenURI',\n args: [BigInt(nft.tokenID)],\n })\n }\n if (nft.namespace === 'erc1155') {\n return readContract(client, {\n address: nft.contractAddress,\n abi: [\n {\n name: 'uri',\n type: 'function',\n stateMutability: 'view',\n inputs: [{ name: '_id', type: 'uint256' }],\n outputs: [{ name: '', type: 'string' }],\n },\n ],\n functionName: 'uri',\n args: [BigInt(nft.tokenID)],\n })\n }\n throw new EnsAvatarUnsupportedNamespaceError({ namespace: nft.namespace })\n}\n", "import type { Client } from '../../../clients/createClient.js'\nimport type { Transport } from '../../../clients/transports/createTransport.js'\nimport type { ErrorType } from '../../../errors/utils.js'\nimport type { Chain } from '../../../types/chain.js'\nimport type { AssetGatewayUrls } from '../../../types/ens.js'\n\nimport {\n type GetJsonImageErrorType,\n type GetMetadataAvatarUriErrorType,\n type GetNftTokenUriErrorType,\n type ParseAvatarUriErrorType,\n type ParseNftUriErrorType,\n type ResolveAvatarUriErrorType,\n getJsonImage,\n getMetadataAvatarUri,\n getNftTokenUri,\n parseAvatarUri,\n parseNftUri,\n resolveAvatarUri,\n} from './utils.js'\n\nexport type ParseAvatarRecordErrorType =\n | ParseNftAvatarUriErrorType\n | ParseAvatarUriErrorType\n | ErrorType\n\n/*\n * @description Parses an ENS avatar record.\n *\n * @example\n * parseAvatarRecord('eip155:1/erc1155:0xb32979486938aa9694bfc898f35dbed459f44424/10063')\n * 'https://ipfs.io/ipfs/QmSP4nq9fnN9dAiCj42ug9Wa79rqmQerZXZch82VqpiH7U/image.gif'\n *\n * @see https://docs.ens.domains/web/avatars\n *\n */\nexport async function parseAvatarRecord<chain extends Chain | undefined>(\n client: Client<Transport, chain>,\n {\n gatewayUrls,\n record,\n }: {\n gatewayUrls?: AssetGatewayUrls | undefined\n record: string\n },\n): Promise<string> {\n if (/eip155:/i.test(record))\n return parseNftAvatarUri(client, { gatewayUrls, record })\n return parseAvatarUri({ uri: record, gatewayUrls })\n}\n\ntype ParseNftAvatarUriErrorType =\n | ParseNftUriErrorType\n | GetNftTokenUriErrorType\n | ResolveAvatarUriErrorType\n | ParseAvatarUriErrorType\n | GetJsonImageErrorType\n | GetMetadataAvatarUriErrorType\n | ErrorType\n\nasync function parseNftAvatarUri<chain extends Chain | undefined>(\n client: Client<Transport, chain>,\n {\n gatewayUrls,\n record,\n }: {\n gatewayUrls?: AssetGatewayUrls | undefined\n record: string\n },\n): Promise<string> {\n // parse NFT URI into properties\n const nft = parseNftUri(record)\n // fetch tokenURI from the NFT contract\n const nftUri = await getNftTokenUri(client, { nft })\n // resolve the URI from the fetched tokenURI\n const {\n uri: resolvedNftUri,\n isOnChain,\n isEncoded,\n } = resolveAvatarUri({ uri: nftUri, gatewayUrls })\n\n // if the resolved URI is on chain, return the data\n if (\n isOnChain &&\n (resolvedNftUri.includes('data:application/json;base64,') ||\n resolvedNftUri.startsWith('{'))\n ) {\n const encodedJson = isEncoded\n ? // if it is encoded, decode it\n atob(resolvedNftUri.replace('data:application/json;base64,', ''))\n : // if it isn't encoded assume it is a JSON string, but it could be anything (it will error if it is)\n resolvedNftUri\n\n const decoded = JSON.parse(encodedJson)\n return parseAvatarUri({ uri: getJsonImage(decoded), gatewayUrls })\n }\n\n let uriTokenId = nft.tokenID\n if (nft.namespace === 'erc1155')\n uriTokenId = uriTokenId.replace('0x', '').padStart(64, '0')\n\n return getMetadataAvatarUri({\n gatewayUrls,\n uri: resolvedNftUri.replace(/(?:0x)?{id}/, uriTokenId),\n })\n}\n", "import type { Address } from 'abitype'\n\nimport type { Client } from '../../clients/createClient.js'\nimport type { Transport } from '../../clients/transports/createTransport.js'\nimport {\n textResolverAbi,\n universalResolverResolveAbi,\n} from '../../constants/abis.js'\nimport type { Chain } from '../../types/chain.js'\nimport type { Prettify } from '../../types/utils.js'\nimport {\n type DecodeFunctionResultErrorType,\n decodeFunctionResult,\n} from '../../utils/abi/decodeFunctionResult.js'\nimport {\n type EncodeFunctionDataErrorType,\n encodeFunctionData,\n} from '../../utils/abi/encodeFunctionData.js'\nimport {\n type GetChainContractAddressErrorType,\n getChainContractAddress,\n} from '../../utils/chain/getChainContractAddress.js'\nimport { type ToHexErrorType, toHex } from '../../utils/encoding/toHex.js'\nimport { isNullUniversalResolverError } from '../../utils/ens/errors.js'\nimport { type NamehashErrorType, namehash } from '../../utils/ens/namehash.js'\nimport {\n type PacketToBytesErrorType,\n packetToBytes,\n} from '../../utils/ens/packetToBytes.js'\nimport { getAction } from '../../utils/getAction.js'\nimport {\n type ReadContractErrorType,\n type ReadContractParameters,\n readContract,\n} from '../public/readContract.js'\n\nexport type GetEnsTextParameters = Prettify<\n Pick<ReadContractParameters, 'blockNumber' | 'blockTag'> & {\n /** ENS name to get Text for. */\n name: string\n /** Universal Resolver gateway URLs to use for resolving CCIP-read requests. */\n gatewayUrls?: string[] | undefined\n /** Text record to retrieve. */\n key: string\n /** Whether or not to throw errors propagated from the ENS Universal Resolver Contract. */\n strict?: boolean | undefined\n /** Address of ENS Universal Resolver Contract. */\n universalResolverAddress?: Address | undefined\n }\n>\n\nexport type GetEnsTextReturnType = string | null\n\nexport type GetEnsTextErrorType =\n | GetChainContractAddressErrorType\n | ReadContractErrorType\n | ToHexErrorType\n | PacketToBytesErrorType\n | EncodeFunctionDataErrorType\n | NamehashErrorType\n | DecodeFunctionResultErrorType\n\n/**\n * Gets a text record for specified ENS name.\n *\n * - Docs: https://viem.sh/docs/ens/actions/getEnsResolver\n * - Examples: https://stackblitz.com/github/wevm/viem/tree/main/examples/ens\n *\n * Calls `resolve(bytes, bytes)` on ENS Universal Resolver Contract.\n *\n * Since ENS names prohibit certain forbidden characters (e.g. underscore) and have other validation rules, you likely want to [normalize ENS names](https://docs.ens.domains/contract-api-reference/name-processing#normalising-names) with [UTS-46 normalization](https://unicode.org/reports/tr46) before passing them to `getEnsAddress`. You can use the built-in [`normalize`](https://viem.sh/docs/ens/utilities/normalize) function for this.\n *\n * @param client - Client to use\n * @param parameters - {@link GetEnsTextParameters}\n * @returns Address for ENS resolver. {@link GetEnsTextReturnType}\n *\n * @example\n * import { createPublicClient, http } from 'viem'\n * import { mainnet } from 'viem/chains'\n * import { getEnsText, normalize } from 'viem/ens'\n *\n * const client = createPublicClient({\n * chain: mainnet,\n * transport: http(),\n * })\n * const twitterRecord = await getEnsText(client, {\n * name: normalize('wevm.eth'),\n * key: 'com.twitter',\n * })\n * // 'wevm_dev'\n */\nexport async function getEnsText<chain extends Chain | undefined>(\n client: Client<Transport, chain>,\n {\n blockNumber,\n blockTag,\n name,\n key,\n gatewayUrls,\n strict,\n universalResolverAddress: universalResolverAddress_,\n }: GetEnsTextParameters,\n): Promise<GetEnsTextReturnType> {\n let universalResolverAddress = universalResolverAddress_\n if (!universalResolverAddress) {\n if (!client.chain)\n throw new Error(\n 'client chain not configured. universalResolverAddress is required.',\n )\n\n universalResolverAddress = getChainContractAddress({\n blockNumber,\n chain: client.chain,\n contract: 'ensUniversalResolver',\n })\n }\n\n try {\n const readContractParameters = {\n address: universalResolverAddress,\n abi: universalResolverResolveAbi,\n functionName: 'resolve',\n args: [\n toHex(packetToBytes(name)),\n encodeFunctionData({\n abi: textResolverAbi,\n functionName: 'text',\n args: [namehash(name), key],\n }),\n ],\n blockNumber,\n blockTag,\n } as const\n\n const readContractAction = getAction(client, readContract, 'readContract')\n\n const res = gatewayUrls\n ? await readContractAction({\n ...readContractParameters,\n args: [...readContractParameters.args, gatewayUrls],\n })\n : await readContractAction(readContractParameters)\n\n if (res[0] === '0x') return null\n\n const record = decodeFunctionResult({\n abi: textResolverAbi,\n functionName: 'text',\n data: res[0],\n })\n\n return record === '' ? null : record\n } catch (err) {\n if (strict) throw err\n if (isNullUniversalResolverError(err, 'resolve')) return null\n throw err\n }\n}\n", "import type { Client } from '../../clients/createClient.js'\nimport type { Transport } from '../../clients/transports/createTransport.js'\nimport type { ErrorType } from '../../errors/utils.js'\nimport type { Chain } from '../../types/chain.js'\nimport type { AssetGatewayUrls } from '../../types/ens.js'\nimport type { Prettify } from '../../types/utils.js'\nimport {\n type ParseAvatarRecordErrorType,\n parseAvatarRecord,\n} from '../../utils/ens/avatar/parseAvatarRecord.js'\nimport { getAction } from '../../utils/getAction.js'\n\nimport {\n type GetEnsTextErrorType,\n type GetEnsTextParameters,\n getEnsText,\n} from './getEnsText.js'\n\nexport type GetEnsAvatarParameters = Prettify<\n Omit<GetEnsTextParameters, 'key'> & {\n /** Gateway urls to resolve IPFS and/or Arweave assets. */\n assetGatewayUrls?: AssetGatewayUrls | undefined\n }\n>\n\nexport type GetEnsAvatarReturnType = string | null\n\nexport type GetEnsAvatarErrorType =\n | GetEnsTextErrorType\n | ParseAvatarRecordErrorType\n | ErrorType\n\n/**\n * Gets the avatar of an ENS name.\n *\n * - Docs: https://viem.sh/docs/ens/actions/getEnsAvatar\n * - Examples: https://stackblitz.com/github/wevm/viem/tree/main/examples/ens\n *\n * Calls [`getEnsText`](https://viem.sh/docs/ens/actions/getEnsText) with `key` set to `'avatar'`.\n *\n * Since ENS names prohibit certain forbidden characters (e.g. underscore) and have other validation rules, you likely want to [normalize ENS names](https://docs.ens.domains/contract-api-reference/name-processing#normalising-names) with [UTS-46 normalization](https://unicode.org/reports/tr46) before passing them to `getEnsAddress`. You can use the built-in [`normalize`](https://viem.sh/docs/ens/utilities/normalize) function for this.\n *\n * @param client - Client to use\n * @param parameters - {@link GetEnsAvatarParameters}\n * @returns Avatar URI or `null` if not found. {@link GetEnsAvatarReturnType}\n *\n * @example\n * import { createPublicClient, http } from 'viem'\n * import { mainnet } from 'viem/chains'\n * import { getEnsAvatar, normalize } from 'viem/ens'\n *\n * const client = createPublicClient({\n * chain: mainnet,\n * transport: http(),\n * })\n * const ensAvatar = await getEnsAvatar(client, {\n * name: normalize('wevm.eth'),\n * })\n * // 'https://ipfs.io/ipfs/Qma8mnp6xV3J2cRNf3mTth5C8nV11CAnceVinc3y8jSbio'\n */\nexport async function getEnsAvatar<chain extends Chain | undefined>(\n client: Client<Transport, chain>,\n {\n blockNumber,\n blockTag,\n assetGatewayUrls,\n name,\n gatewayUrls,\n strict,\n universalResolverAddress,\n }: GetEnsAvatarParameters,\n): Promise<GetEnsAvatarReturnType> {\n const record = await getAction(\n client,\n getEnsText,\n 'getEnsText',\n )({\n blockNumber,\n blockTag,\n key: 'avatar',\n name,\n universalResolverAddress,\n gatewayUrls,\n strict,\n })\n if (!record) return null\n try {\n return await parseAvatarRecord(client, {\n record,\n gatewayUrls: assetGatewayUrls,\n })\n } catch {\n return null\n }\n}\n", "import type { Address } from 'abitype'\n\nimport type { Client } from '../../clients/createClient.js'\nimport type { Transport } from '../../clients/transports/createTransport.js'\nimport { universalResolverReverseAbi } from '../../constants/abis.js'\nimport type { ErrorType } from '../../errors/utils.js'\nimport type { Chain } from '../../types/chain.js'\nimport type { Prettify } from '../../types/utils.js'\nimport {\n type GetChainContractAddressErrorType,\n getChainContractAddress,\n} from '../../utils/chain/getChainContractAddress.js'\nimport { type ToHexErrorType, toHex } from '../../utils/encoding/toHex.js'\nimport { isNullUniversalResolverError } from '../../utils/ens/errors.js'\nimport {\n type PacketToBytesErrorType,\n packetToBytes,\n} from '../../utils/ens/packetToBytes.js'\nimport { getAction } from '../../utils/getAction.js'\nimport {\n type ReadContractErrorType,\n type ReadContractParameters,\n readContract,\n} from '../public/readContract.js'\n\nexport type GetEnsNameParameters = Prettify<\n Pick<ReadContractParameters, 'blockNumber' | 'blockTag'> & {\n /** Address to get ENS name for. */\n address: Address\n /** Universal Resolver gateway URLs to use for resolving CCIP-read requests. */\n gatewayUrls?: string[] | undefined\n /** Whether or not to throw errors propagated from the ENS Universal Resolver Contract. */\n strict?: boolean | undefined\n /** Address of ENS Universal Resolver Contract. */\n universalResolverAddress?: Address | undefined\n }\n>\n\nexport type GetEnsNameReturnType = string | null\n\nexport type GetEnsNameErrorType =\n | GetChainContractAddressErrorType\n | ReadContractErrorType\n | ToHexErrorType\n | PacketToBytesErrorType\n | ErrorType\n\n/**\n * Gets primary name for specified address.\n *\n * - Docs: https://viem.sh/docs/ens/actions/getEnsName\n * - Examples: https://stackblitz.com/github/wevm/viem/tree/main/examples/ens\n *\n * Calls `reverse(bytes)` on ENS Universal Resolver Contract to \"reverse resolve\" the address to the primary ENS name.\n *\n * @param client - Client to use\n * @param parameters - {@link GetEnsNameParameters}\n * @returns Name or `null` if not found. {@link GetEnsNameReturnType}\n *\n * @example\n * import { createPublicClient, http } from 'viem'\n * import { mainnet } from 'viem/chains'\n * import { getEnsName } from 'viem/ens'\n *\n * const client = createPublicClient({\n * chain: mainnet,\n * transport: http(),\n * })\n * const ensName = await getEnsName(client, {\n * address: '0xd2135CfB216b74109775236E36d4b433F1DF507B',\n * })\n * // 'wevm.eth'\n */\nexport async function getEnsName<chain extends Chain | undefined>(\n client: Client<Transport, chain>,\n {\n address,\n blockNumber,\n blockTag,\n gatewayUrls,\n strict,\n universalResolverAddress: universalResolverAddress_,\n }: GetEnsNameParameters,\n): Promise<GetEnsNameReturnType> {\n let universalResolverAddress = universalResolverAddress_\n if (!universalResolverAddress) {\n if (!client.chain)\n throw new Error(\n 'client chain not configured. universalResolverAddress is required.',\n )\n\n universalResolverAddress = getChainContractAddress({\n blockNumber,\n chain: client.chain,\n contract: 'ensUniversalResolver',\n })\n }\n\n const reverseNode = `${address.toLowerCase().substring(2)}.addr.reverse`\n try {\n const readContractParameters = {\n address: universalResolverAddress,\n abi: universalResolverReverseAbi,\n functionName: 'reverse',\n args: [toHex(packetToBytes(reverseNode))],\n blockNumber,\n blockTag,\n } as const\n\n const readContractAction = getAction(client, readContract, 'readContract')\n\n const [name, resolvedAddress] = gatewayUrls\n ? await readContractAction({\n ...readContractParameters,\n args: [...readContractParameters.args, gatewayUrls],\n })\n : await readContractAction(readContractParameters)\n\n if (address.toLowerCase() !== resolvedAddress.toLowerCase()) return null\n return name\n } catch (err) {\n if (strict) throw err\n if (isNullUniversalResolverError(err, 'reverse')) return null\n throw err\n }\n}\n", "import type { Address } from 'abitype'\n\nimport type { Client } from '../../clients/createClient.js'\nimport type { Transport } from '../../clients/transports/createTransport.js'\nimport type { ErrorType } from '../../errors/utils.js'\nimport type { Chain } from '../../types/chain.js'\nimport type { Prettify } from '../../types/utils.js'\nimport {\n type GetChainContractAddressErrorType,\n getChainContractAddress,\n} from '../../utils/chain/getChainContractAddress.js'\nimport { type ToHexErrorType, toHex } from '../../utils/encoding/toHex.js'\nimport {\n type PacketToBytesErrorType,\n packetToBytes,\n} from '../../utils/ens/packetToBytes.js'\nimport { getAction } from '../../utils/getAction.js'\nimport {\n type ReadContractParameters,\n readContract,\n} from '../public/readContract.js'\n\nexport type GetEnsResolverParameters = Prettify<\n Pick<ReadContractParameters, 'blockNumber' | 'blockTag'> & {\n /** Name to get the address for. */\n name: string\n /** Address of ENS Universal Resolver Contract. */\n universalResolverAddress?: Address | undefined\n }\n>\n\nexport type GetEnsResolverReturnType = Address\n\nexport type GetEnsResolverErrorType =\n | GetChainContractAddressErrorType\n | ToHexErrorType\n | PacketToBytesErrorType\n | ErrorType\n\n/**\n * Gets resolver for ENS name.\n *\n * - Docs: https://viem.sh/docs/ens/actions/getEnsResolver\n * - Examples: https://stackblitz.com/github/wevm/viem/tree/main/examples/ens\n *\n * Calls `findResolver(bytes)` on ENS Universal Resolver Contract to retrieve the resolver of an ENS name.\n *\n * Since ENS names prohibit certain forbidden characters (e.g. underscore) and have other validation rules, you likely want to [normalize ENS names](https://docs.ens.domains/contract-api-reference/name-processing#normalising-names) with [UTS-46 normalization](https://unicode.org/reports/tr46) before passing them to `getEnsAddress`. You can use the built-in [`normalize`](https://viem.sh/docs/ens/utilities/normalize) function for this.\n *\n * @param client - Client to use\n * @param parameters - {@link GetEnsResolverParameters}\n * @returns Address for ENS resolver. {@link GetEnsResolverReturnType}\n *\n * @example\n * import { createPublicClient, http } from 'viem'\n * import { mainnet } from 'viem/chains'\n * import { getEnsResolver, normalize } from 'viem/ens'\n *\n * const client = createPublicClient({\n * chain: mainnet,\n * transport: http(),\n * })\n * const resolverAddress = await getEnsResolver(client, {\n * name: normalize('wevm.eth'),\n * })\n * // '0x4976fb03C32e5B8cfe2b6cCB31c09Ba78EBaBa41'\n */\nexport async function getEnsResolver<chain extends Chain | undefined>(\n client: Client<Transport, chain>,\n {\n blockNumber,\n blockTag,\n name,\n universalResolverAddress: universalResolverAddress_,\n }: GetEnsResolverParameters,\n) {\n let universalResolverAddress = universalResolverAddress_\n if (!universalResolverAddress) {\n if (!client.chain)\n throw new Error(\n 'client chain not configured. universalResolverAddress is required.',\n )\n\n universalResolverAddress = getChainContractAddress({\n blockNumber,\n chain: client.chain,\n contract: 'ensUniversalResolver',\n })\n }\n\n const [resolverAddress] = await getAction(\n client,\n readContract,\n 'readContract',\n )({\n address: universalResolverAddress,\n abi: [\n {\n inputs: [{ type: 'bytes' }],\n name: 'findResolver',\n outputs: [{ type: 'address' }, { type: 'bytes32' }],\n stateMutability: 'view',\n type: 'function',\n },\n ],\n functionName: 'findResolver',\n args: [toHex(packetToBytes(name))],\n blockNumber,\n blockTag,\n })\n return resolverAddress\n}\n", "import type { Address } from 'abitype'\n\nimport type { Account } from '../../accounts/types.js'\nimport {\n type ParseAccountErrorType,\n parseAccount,\n} from '../../accounts/utils/parseAccount.js'\nimport type { Client } from '../../clients/createClient.js'\nimport type { Transport } from '../../clients/transports/createTransport.js'\nimport type { ErrorType } from '../../errors/utils.js'\nimport type { BlockTag } from '../../types/block.js'\nimport type { Chain } from '../../types/chain.js'\nimport type { RpcTransactionRequest } from '../../types/rpc.js'\nimport type { AccessList, TransactionRequest } from '../../types/transaction.js'\nimport type { ExactPartial, Prettify, UnionOmit } from '../../types/utils.js'\nimport type { RequestErrorType } from '../../utils/buildRequest.js'\nimport {\n type NumberToHexErrorType,\n numberToHex,\n} from '../../utils/encoding/toHex.js'\nimport {\n type GetCallErrorReturnType,\n getCallError,\n} from '../../utils/errors/getCallError.js'\nimport { extract } from '../../utils/formatters/extract.js'\nimport {\n type FormatTransactionRequestErrorType,\n type FormattedTransactionRequest,\n formatTransactionRequest,\n} from '../../utils/formatters/transactionRequest.js'\nimport { assertRequest } from '../../utils/transaction/assertRequest.js'\nimport type {\n AssertRequestErrorType,\n AssertRequestParameters,\n} from '../../utils/transaction/assertRequest.js'\n\nexport type CreateAccessListParameters<\n chain extends Chain | undefined = Chain | undefined,\n> = UnionOmit<\n FormattedTransactionRequest<chain>,\n 'from' | 'nonce' | 'accessList'\n> & {\n /** Account attached to the call (msg.sender). */\n account?: Account | Address | undefined\n} & (\n | {\n /** The balance of the account at a block number. */\n blockNumber?: bigint | undefined\n blockTag?: undefined\n }\n | {\n blockNumber?: undefined\n /**\n * The balance of the account at a block tag.\n * @default 'latest'\n */\n blockTag?: BlockTag | undefined\n }\n )\n\nexport type CreateAccessListReturnType = Prettify<{\n accessList: AccessList\n gasUsed: bigint\n}>\n\nexport type CreateAccessListErrorType = GetCallErrorReturnType<\n | ParseAccountErrorType\n | AssertRequestErrorType\n | NumberToHexErrorType\n | FormatTransactionRequestErrorType\n | RequestErrorType\n>\n\n/**\n * Creates an EIP-2930 access list.\n *\n * - Docs: https://viem.sh/docs/actions/public/createAccessList\n * - JSON-RPC Methods: `eth_createAccessList`\n *\n * @param client - Client to use\n * @param parameters - {@link CreateAccessListParameters}\n * @returns The access list. {@link CreateAccessListReturnType}\n *\n * @example\n * import { createPublicClient, http } from 'viem'\n * import { mainnet } from 'viem/chains'\n * import { createAccessList } from 'viem/public'\n *\n * const client = createPublicClient({\n * chain: mainnet,\n * transport: http(),\n * })\n * const data = await createAccessList(client, {\n * account: '0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266',\n * data: '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',\n * to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8',\n * })\n */\nexport async function createAccessList<chain extends Chain | undefined>(\n client: Client<Transport, chain>,\n args: CreateAccessListParameters<chain>,\n): Promise<CreateAccessListReturnType> {\n const {\n account: account_ = client.account,\n blockNumber,\n blockTag = 'latest',\n blobs,\n data,\n gas,\n gasPrice,\n maxFeePerBlobGas,\n maxFeePerGas,\n maxPriorityFeePerGas,\n to,\n value,\n ...rest\n } = args\n const account = account_ ? parseAccount(account_) : undefined\n\n try {\n assertRequest(args as AssertRequestParameters)\n\n const blockNumberHex = blockNumber ? numberToHex(blockNumber) : undefined\n const block = blockNumberHex || blockTag\n\n const chainFormat = client.chain?.formatters?.transactionRequest?.format\n const format = chainFormat || formatTransactionRequest\n\n const request = format({\n // Pick out extra data that might exist on the chain's transaction request type.\n ...extract(rest, { format: chainFormat }),\n from: account?.address,\n blobs,\n data,\n gas,\n gasPrice,\n maxFeePerBlobGas,\n maxFeePerGas,\n maxPriorityFeePerGas,\n to,\n value,\n } as TransactionRequest) as TransactionRequest\n\n const response = await client.request({\n method: 'eth_createAccessList',\n params: [request as ExactPartial<RpcTransactionRequest>, block],\n })\n return {\n accessList: response.accessList,\n gasUsed: BigInt(response.gasUsed),\n }\n } catch (err) {\n throw getCallError(err as ErrorType, {\n ...args,\n account,\n chain: client.chain,\n })\n }\n}\n", "import type { Client } from '../../clients/createClient.js'\nimport type { Transport } from '../../clients/transports/createTransport.js'\nimport type { OnResponseFn } from '../../clients/transports/fallback.js'\nimport type { Chain } from '../../types/chain.js'\nimport type { PublicRpcSchema } from '../../types/eip1193.js'\nimport type { EIP1193RequestFn } from '../../types/eip1193.js'\nimport type { Hex } from '../../types/misc.js'\nimport type { Filter } from '../../types/utils.js'\n\ntype CreateFilterRequestScopeParameters = {\n method:\n | 'eth_newFilter'\n | 'eth_newPendingTransactionFilter'\n | 'eth_newBlockFilter'\n}\n\ntype FilterRpcSchema = Filter<\n PublicRpcSchema,\n { Method: 'eth_getFilterLogs' | 'eth_getFilterChanges' }\n>\n\ntype CreateFilterRequestScopeReturnType = (\n id: Hex,\n) => EIP1193RequestFn<FilterRpcSchema>\n\n/**\n * Scopes `request` to the filter ID. If the client is a fallback, it will\n * listen for responses and scope the child transport `request` function\n * to the successful filter ID.\n */\nexport function createFilterRequestScope<chain extends Chain | undefined>(\n client: Client<Transport, chain>,\n { method }: CreateFilterRequestScopeParameters,\n): CreateFilterRequestScopeReturnType {\n const requestMap: Record<Hex, EIP1193RequestFn> = {}\n\n if (client.transport.type === 'fallback')\n client.transport.onResponse?.(\n ({\n method: method_,\n response: id,\n status,\n transport,\n }: Parameters<OnResponseFn>[0]) => {\n if (status === 'success' && method === method_)\n requestMap[id as Hex] = transport.request\n },\n )\n\n return ((id) =>\n requestMap[id] || client.request) as CreateFilterRequestScopeReturnType\n}\n", "import type { Client } from '../../clients/createClient.js'\nimport type { Transport } from '../../clients/transports/createTransport.js'\nimport type { ErrorType } from '../../errors/utils.js'\nimport type { Chain } from '../../types/chain.js'\nimport type { Filter } from '../../types/filter.js'\nimport type { RequestErrorType } from '../../utils/buildRequest.js'\nimport { createFilterRequestScope } from '../../utils/filters/createFilterRequestScope.js'\n\nexport type CreateBlockFilterReturnType = Filter<'block'>\n\nexport type CreateBlockFilterErrorType = RequestErrorType | ErrorType\n\n/**\n * Creates a [`Filter`](https://viem.sh/docs/glossary/types#filter) to listen for new block hashes that can be used with [`getFilterChanges`](https://viem.sh/docs/actions/public/getFilterChanges).\n *\n * - Docs: https://viem.sh/docs/actions/public/createBlockFilter\n * - JSON-RPC Methods: [`eth_newBlockFilter`](https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_newBlockFilter)\n *\n * @param client - Client to use\n * @returns [`Filter`](https://viem.sh/docs/glossary/types#filter). {@link CreateBlockFilterReturnType}\n *\n * @example\n * import { createPublicClient, http } from 'viem'\n * import { mainnet } from 'viem/chains'\n * import { createBlockFilter } from 'viem/public'\n *\n * const client = createPublicClient({\n * chain: mainnet,\n * transport: http(),\n * })\n * const filter = await createBlockFilter(client)\n * // { id: \"0x345a6572337856574a76364e457a4366\", type: 'block' }\n */\nexport async function createBlockFilter<chain extends Chain | undefined>(\n client: Client<Transport, chain>,\n): Promise<CreateBlockFilterReturnType> {\n const getRequest = createFilterRequestScope(client, {\n method: 'eth_newBlockFilter',\n })\n const id = await client.request({\n method: 'eth_newBlockFilter',\n })\n return { id, request: getRequest(id), type: 'block' }\n}\n", "import { BaseError } from './base.js'\n\nexport type FilterTypeNotSupportedErrorType = FilterTypeNotSupportedError & {\n name: 'FilterTypeNotSupportedError'\n}\nexport class FilterTypeNotSupportedError extends BaseError {\n constructor(type: string) {\n super(`Filter type \"${type}\" is not supported.`, {\n name: 'FilterTypeNotSupportedError',\n })\n }\n}\n", "import type {\n Abi,\n AbiParameter,\n AbiParameterToPrimitiveType,\n ExtractAbiEvents,\n} from 'abitype'\n\nimport {\n AbiEventNotFoundError,\n type AbiEventNotFoundErrorType,\n} from '../../errors/abi.js'\nimport {\n FilterTypeNotSupportedError,\n type FilterTypeNotSupportedErrorType,\n} from '../../errors/log.js'\nimport type { ErrorType } from '../../errors/utils.js'\nimport type {\n ContractEventArgs,\n ContractEventName,\n EventDefinition,\n} from '../../types/contract.js'\nimport type { Hex } from '../../types/misc.js'\nimport type { IsNarrowable, UnionEvaluate } from '../../types/utils.js'\nimport { type ToBytesErrorType, toBytes } from '../encoding/toBytes.js'\nimport { type Keccak256ErrorType, keccak256 } from '../hash/keccak256.js'\nimport {\n type ToEventSelectorErrorType,\n toEventSelector,\n} from '../hash/toEventSelector.js'\nimport {\n type EncodeAbiParametersErrorType,\n encodeAbiParameters,\n} from './encodeAbiParameters.js'\nimport { type FormatAbiItemErrorType, formatAbiItem } from './formatAbiItem.js'\nimport { type GetAbiItemErrorType, getAbiItem } from './getAbiItem.js'\n\nconst docsPath = '/docs/contract/encodeEventTopics'\n\nexport type EncodeEventTopicsParameters<\n abi extends Abi | readonly unknown[] = Abi,\n eventName extends ContractEventName<abi> | undefined = ContractEventName<abi>,\n ///\n hasEvents = abi extends Abi\n ? Abi extends abi\n ? true\n : [ExtractAbiEvents<abi>] extends [never]\n ? false\n : true\n : true,\n allArgs = ContractEventArgs<\n abi,\n eventName extends ContractEventName<abi>\n ? eventName\n : ContractEventName<abi>\n >,\n allErrorNames = ContractEventName<abi>,\n> = {\n abi: abi\n args?: allArgs | undefined\n} & UnionEvaluate<\n IsNarrowable<abi, Abi> extends true\n ? abi['length'] extends 1\n ? { eventName?: eventName | allErrorNames | undefined }\n : { eventName: eventName | allErrorNames }\n : { eventName?: eventName | allErrorNames | undefined }\n> &\n (hasEvents extends true ? unknown : never)\n\nexport type EncodeEventTopicsReturnType = [Hex, ...(Hex | Hex[] | null)[]]\n\nexport type EncodeEventTopicsErrorType =\n | AbiEventNotFoundErrorType\n | EncodeArgErrorType\n | FormatAbiItemErrorType\n | GetAbiItemErrorType\n | ToEventSelectorErrorType\n | ErrorType\n\nexport function encodeEventTopics<\n const abi extends Abi | readonly unknown[],\n eventName extends ContractEventName<abi> | undefined = undefined,\n>(\n parameters: EncodeEventTopicsParameters<abi, eventName>,\n): EncodeEventTopicsReturnType {\n const { abi, eventName, args } = parameters as EncodeEventTopicsParameters\n\n let abiItem = abi[0]\n if (eventName) {\n const item = getAbiItem({ abi, name: eventName })\n if (!item) throw new AbiEventNotFoundError(eventName, { docsPath })\n abiItem = item\n }\n\n if (abiItem.type !== 'event')\n throw new AbiEventNotFoundError(undefined, { docsPath })\n\n const definition = formatAbiItem(abiItem)\n const signature = toEventSelector(definition as EventDefinition)\n\n let topics: (Hex | Hex[] | null)[] = []\n if (args && 'inputs' in abiItem) {\n const indexedInputs = abiItem.inputs?.filter(\n (param) => 'indexed' in param && param.indexed,\n )\n const args_ = Array.isArray(args)\n ? args\n : Object.values(args).length > 0\n ? (indexedInputs?.map((x: any) => (args as any)[x.name]) ?? [])\n : []\n\n if (args_.length > 0) {\n topics =\n indexedInputs?.map((param, i) => {\n if (Array.isArray(args_[i]))\n return args_[i].map((_: any, j: number) =>\n encodeArg({ param, value: args_[i][j] }),\n )\n return typeof args_[i] !== 'undefined' && args_[i] !== null\n ? encodeArg({ param, value: args_[i] })\n : null\n }) ?? []\n }\n }\n return [signature, ...topics]\n}\n\nexport type EncodeArgErrorType =\n | Keccak256ErrorType\n | ToBytesErrorType\n | EncodeAbiParametersErrorType\n | FilterTypeNotSupportedErrorType\n | ErrorType\n\nfunction encodeArg({\n param,\n value,\n}: { param: AbiParameter; value: AbiParameterToPrimitiveType<AbiParameter> }) {\n if (param.type === 'string' || param.type === 'bytes')\n return keccak256(toBytes(value as string))\n if (param.type === 'tuple' || param.type.match(/^(.*)\\[(\\d+)?\\]$/))\n throw new FilterTypeNotSupportedError(param.type)\n return encodeAbiParameters([param], [value])\n}\n", "import type { Abi, Address } from 'abitype'\n\nimport type { Client } from '../../clients/createClient.js'\nimport type { Transport } from '../../clients/transports/createTransport.js'\nimport type { ErrorType } from '../../errors/utils.js'\nimport type { BlockNumber, BlockTag } from '../../types/block.js'\nimport type { Chain } from '../../types/chain.js'\nimport type {\n ContractEventName,\n MaybeExtractEventArgsFromAbi,\n} from '../../types/contract.js'\nimport type { Filter } from '../../types/filter.js'\nimport type { Hex } from '../../types/misc.js'\nimport {\n type EncodeEventTopicsErrorType,\n type EncodeEventTopicsParameters,\n encodeEventTopics,\n} from '../../utils/abi/encodeEventTopics.js'\nimport type { RequestErrorType } from '../../utils/buildRequest.js'\nimport {\n type NumberToHexErrorType,\n numberToHex,\n} from '../../utils/encoding/toHex.js'\nimport { createFilterRequestScope } from '../../utils/filters/createFilterRequestScope.js'\n\nexport type CreateContractEventFilterParameters<\n abi extends Abi | readonly unknown[] = Abi,\n eventName extends ContractEventName<abi> | undefined = undefined,\n args extends\n | MaybeExtractEventArgsFromAbi<abi, eventName>\n | undefined = undefined,\n strict extends boolean | undefined = undefined,\n fromBlock extends BlockNumber | BlockTag | undefined = undefined,\n toBlock extends BlockNumber | BlockTag | undefined = undefined,\n> = {\n address?: Address | Address[] | undefined\n abi: abi\n eventName?: eventName | ContractEventName<abi> | undefined\n fromBlock?: fromBlock | BlockNumber | BlockTag | undefined\n /**\n * Whether or not the logs must match the indexed/non-indexed arguments in the event ABI item.\n * @default false\n */\n strict?: strict | boolean | undefined\n toBlock?: toBlock | BlockNumber | BlockTag | undefined\n} & (undefined extends eventName\n ? {\n args?: undefined\n }\n : MaybeExtractEventArgsFromAbi<abi, eventName> extends infer eventFilterArgs\n ? {\n args?:\n | eventFilterArgs\n | (args extends eventFilterArgs ? args : never)\n | undefined\n }\n : {\n args?: undefined\n })\n\nexport type CreateContractEventFilterReturnType<\n abi extends Abi | readonly unknown[] = Abi,\n eventName extends ContractEventName<abi> | undefined = undefined,\n args extends\n | MaybeExtractEventArgsFromAbi<abi, eventName>\n | undefined = undefined,\n strict extends boolean | undefined = undefined,\n fromBlock extends BlockNumber | BlockTag | undefined = undefined,\n toBlock extends BlockNumber | BlockTag | undefined = undefined,\n> = Filter<'event', abi, eventName, args, strict, fromBlock, toBlock>\n\nexport type CreateContractEventFilterErrorType =\n | EncodeEventTopicsErrorType\n | RequestErrorType\n | NumberToHexErrorType\n | ErrorType\n\n/**\n * Creates a Filter to retrieve event logs that can be used with [`getFilterChanges`](https://viem.sh/docs/actions/public/getFilterChanges) or [`getFilterLogs`](https://viem.sh/docs/actions/public/getFilterLogs).\n *\n * - Docs: https://viem.sh/docs/contract/createContractEventFilter\n *\n * @param client - Client to use\n * @param parameters - {@link CreateContractEventFilterParameters}\n * @returns [`Filter`](https://viem.sh/docs/glossary/types#filter). {@link CreateContractEventFilterReturnType}\n *\n * @example\n * import { createPublicClient, http, parseAbi } from 'viem'\n * import { mainnet } from 'viem/chains'\n * import { createContractEventFilter } from 'viem/contract'\n *\n * const client = createPublicClient({\n * chain: mainnet,\n * transport: http(),\n * })\n * const filter = await createContractEventFilter(client, {\n * abi: parseAbi(['event Transfer(address indexed, address indexed, uint256)']),\n * })\n */\nexport async function createContractEventFilter<\n chain extends Chain | undefined,\n const abi extends Abi | readonly unknown[],\n eventName extends ContractEventName<abi> | undefined,\n args extends MaybeExtractEventArgsFromAbi<abi, eventName> | undefined,\n strict extends boolean | undefined = undefined,\n fromBlock extends BlockNumber | BlockTag | undefined = undefined,\n toBlock extends BlockNumber | BlockTag | undefined = undefined,\n>(\n client: Client<Transport, chain>,\n parameters: CreateContractEventFilterParameters<\n abi,\n eventName,\n args,\n strict,\n fromBlock,\n toBlock\n >,\n): Promise<\n CreateContractEventFilterReturnType<\n abi,\n eventName,\n args,\n strict,\n fromBlock,\n toBlock\n >\n> {\n const { address, abi, args, eventName, fromBlock, strict, toBlock } =\n parameters as CreateContractEventFilterParameters\n\n const getRequest = createFilterRequestScope(client, {\n method: 'eth_newFilter',\n })\n\n const topics = eventName\n ? encodeEventTopics({\n abi,\n args,\n eventName,\n } as unknown as EncodeEventTopicsParameters)\n : undefined\n const id: Hex = await client.request({\n method: 'eth_newFilter',\n params: [\n {\n address,\n fromBlock:\n typeof fromBlock === 'bigint' ? numberToHex(fromBlock) : fromBlock,\n toBlock: typeof toBlock === 'bigint' ? numberToHex(toBlock) : toBlock,\n topics,\n },\n ],\n })\n\n return {\n abi,\n args,\n eventName,\n id,\n request: getRequest(id),\n strict: Boolean(strict),\n type: 'event',\n } as unknown as CreateContractEventFilterReturnType<\n abi,\n eventName,\n args,\n strict,\n fromBlock,\n toBlock\n >\n}\n", "import type { AbiEvent, Address } from 'abitype'\n\nimport type { Client } from '../../clients/createClient.js'\nimport type { Transport } from '../../clients/transports/createTransport.js'\nimport type { ErrorType } from '../../errors/utils.js'\nimport type { BlockNumber, BlockTag } from '../../types/block.js'\nimport type { Chain } from '../../types/chain.js'\nimport type {\n MaybeAbiEventName,\n MaybeExtractEventArgsFromAbi,\n} from '../../types/contract.js'\nimport type { Filter } from '../../types/filter.js'\nimport type { Hex, LogTopic } from '../../types/misc.js'\nimport type { Prettify } from '../../types/utils.js'\nimport {\n type EncodeEventTopicsErrorType,\n type EncodeEventTopicsParameters,\n encodeEventTopics,\n} from '../../utils/abi/encodeEventTopics.js'\nimport type { RequestErrorType } from '../../utils/buildRequest.js'\nimport {\n type NumberToHexErrorType,\n numberToHex,\n} from '../../utils/encoding/toHex.js'\nimport { createFilterRequestScope } from '../../utils/filters/createFilterRequestScope.js'\n\nexport type CreateEventFilterParameters<\n abiEvent extends AbiEvent | undefined = undefined,\n abiEvents extends\n | readonly AbiEvent[]\n | readonly unknown[]\n | undefined = abiEvent extends AbiEvent ? [abiEvent] : undefined,\n strict extends boolean | undefined = undefined,\n fromBlock extends BlockNumber | BlockTag | undefined = undefined,\n toBlock extends BlockNumber | BlockTag | undefined = undefined,\n //\n _eventName extends string | undefined = MaybeAbiEventName<abiEvent>,\n _args extends\n | MaybeExtractEventArgsFromAbi<abiEvents, _eventName>\n | undefined = undefined,\n> = {\n address?: Address | Address[] | undefined\n fromBlock?: fromBlock | BlockNumber | BlockTag | undefined\n toBlock?: toBlock | BlockNumber | BlockTag | undefined\n} & (MaybeExtractEventArgsFromAbi<\n abiEvents,\n _eventName\n> extends infer eventFilterArgs\n ?\n | {\n args:\n | eventFilterArgs\n | (_args extends eventFilterArgs ? _args : never)\n event: abiEvent\n events?: undefined\n /**\n * Whether or not the logs must match the indexed/non-indexed arguments on `event`.\n * @default false\n */\n strict?: strict | undefined\n }\n | {\n args?: undefined\n event?: abiEvent | undefined\n events?: undefined\n /**\n * Whether or not the logs must match the indexed/non-indexed arguments on `event`.\n * @default false\n */\n strict?: strict | undefined\n }\n | {\n args?: undefined\n event?: undefined\n events: abiEvents | undefined\n /**\n * Whether or not the logs must match the indexed/non-indexed arguments on `event`.\n * @default false\n */\n strict?: strict | undefined\n }\n | {\n args?: undefined\n event?: undefined\n events?: undefined\n strict?: undefined\n }\n : {\n args?: undefined\n event?: undefined\n events?: undefined\n strict?: undefined\n })\n\nexport type CreateEventFilterReturnType<\n abiEvent extends AbiEvent | undefined = undefined,\n abiEvents extends\n | readonly AbiEvent[]\n | readonly unknown[]\n | undefined = abiEvent extends AbiEvent ? [abiEvent] : undefined,\n strict extends boolean | undefined = undefined,\n fromBlock extends BlockNumber | BlockTag | undefined = undefined,\n toBlock extends BlockNumber | BlockTag | undefined = undefined,\n _eventName extends string | undefined = MaybeAbiEventName<abiEvent>,\n _args extends\n | MaybeExtractEventArgsFromAbi<abiEvents, _eventName>\n | undefined = undefined,\n> = Prettify<\n Filter<'event', abiEvents, _eventName, _args, strict, fromBlock, toBlock>\n>\n\nexport type CreateEventFilterErrorType =\n | EncodeEventTopicsErrorType\n | RequestErrorType\n | NumberToHexErrorType\n | ErrorType\n\n/**\n * Creates a [`Filter`](https://viem.sh/docs/glossary/types#filter) to listen for new events that can be used with [`getFilterChanges`](https://viem.sh/docs/actions/public/getFilterChanges).\n *\n * - Docs: https://viem.sh/docs/actions/public/createEventFilter\n * - JSON-RPC Methods: [`eth_newFilter`](https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_newfilter)\n *\n * @param client - Client to use\n * @param parameters - {@link CreateEventFilterParameters}\n * @returns [`Filter`](https://viem.sh/docs/glossary/types#filter). {@link CreateEventFilterReturnType}\n *\n * @example\n * import { createPublicClient, http } from 'viem'\n * import { mainnet } from 'viem/chains'\n * import { createEventFilter } from 'viem/public'\n *\n * const client = createPublicClient({\n * chain: mainnet,\n * transport: http(),\n * })\n * const filter = await createEventFilter(client, {\n * address: '0xfba3912ca04dd458c843e2ee08967fc04f3579c2',\n * })\n */\nexport async function createEventFilter<\n chain extends Chain | undefined,\n const abiEvent extends AbiEvent | undefined = undefined,\n const abiEvents extends\n | readonly AbiEvent[]\n | readonly unknown[]\n | undefined = abiEvent extends AbiEvent ? [abiEvent] : undefined,\n strict extends boolean | undefined = undefined,\n fromBlock extends BlockNumber<bigint> | BlockTag | undefined = undefined,\n toBlock extends BlockNumber<bigint> | BlockTag | undefined = undefined,\n _eventName extends string | undefined = MaybeAbiEventName<abiEvent>,\n _args extends\n | MaybeExtractEventArgsFromAbi<abiEvents, _eventName>\n | undefined = undefined,\n>(\n client: Client<Transport, chain>,\n {\n address,\n args,\n event,\n events: events_,\n fromBlock,\n strict,\n toBlock,\n }: CreateEventFilterParameters<\n abiEvent,\n abiEvents,\n strict,\n fromBlock,\n toBlock,\n _eventName,\n _args\n > = {} as any,\n): Promise<\n CreateEventFilterReturnType<\n abiEvent,\n abiEvents,\n strict,\n fromBlock,\n toBlock,\n _eventName,\n _args\n >\n> {\n const events = events_ ?? (event ? [event] : undefined)\n\n const getRequest = createFilterRequestScope(client, {\n method: 'eth_newFilter',\n })\n\n let topics: LogTopic[] = []\n if (events) {\n const encoded = (events as AbiEvent[]).flatMap((event) =>\n encodeEventTopics({\n abi: [event],\n eventName: (event as AbiEvent).name,\n args,\n } as EncodeEventTopicsParameters),\n )\n // TODO: Clean up type casting\n topics = [encoded as LogTopic]\n if (event) topics = topics[0] as LogTopic[]\n }\n\n const id: Hex = await client.request({\n method: 'eth_newFilter',\n params: [\n {\n address,\n fromBlock:\n typeof fromBlock === 'bigint' ? numberToHex(fromBlock) : fromBlock,\n toBlock: typeof toBlock === 'bigint' ? numberToHex(toBlock) : toBlock,\n ...(topics.length ? { topics } : {}),\n },\n ],\n })\n\n return {\n abi: events,\n args,\n eventName: event ? (event as AbiEvent).name : undefined,\n fromBlock,\n id,\n request: getRequest(id),\n strict: Boolean(strict),\n toBlock,\n type: 'event',\n } as unknown as CreateEventFilterReturnType<\n abiEvent,\n abiEvents,\n strict,\n fromBlock,\n toBlock,\n _eventName,\n _args\n >\n}\n", "import type { Client } from '../../clients/createClient.js'\nimport type { Transport } from '../../clients/transports/createTransport.js'\nimport type { ErrorType } from '../../errors/utils.js'\nimport type { Chain } from '../../types/chain.js'\nimport type { Filter } from '../../types/filter.js'\nimport type { RequestErrorType } from '../../utils/buildRequest.js'\nimport { createFilterRequestScope } from '../../utils/filters/createFilterRequestScope.js'\n\nexport type CreatePendingTransactionFilterReturnType = Filter<'transaction'>\n\nexport type CreatePendingTransactionFilterErrorType =\n | RequestErrorType\n | ErrorType\n\n/**\n * Creates a Filter to listen for new pending transaction hashes that can be used with [`getFilterChanges`](https://viem.sh/docs/actions/public/getFilterChanges).\n *\n * - Docs: https://viem.sh/docs/actions/public/createPendingTransactionFilter\n * - JSON-RPC Methods: [`eth_newPendingTransactionFilter`](https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_newpendingtransactionfilter)\n *\n * @param client - Client to use\n * @returns [`Filter`](https://viem.sh/docs/glossary/types#filter). {@link CreateBlockFilterReturnType}\n *\n * @example\n * import { createPublicClient, http } from 'viem'\n * import { mainnet } from 'viem/chains'\n * import { createPendingTransactionFilter } from 'viem/public'\n *\n * const client = createPublicClient({\n * chain: mainnet,\n * transport: http(),\n * })\n * const filter = await createPendingTransactionFilter(client)\n * // { id: \"0x345a6572337856574a76364e457a4366\", type: 'transaction' }\n */\nexport async function createPendingTransactionFilter<\n transport extends Transport,\n chain extends Chain | undefined,\n>(\n client: Client<transport, chain>,\n): Promise<CreatePendingTransactionFilterReturnType> {\n const getRequest = createFilterRequestScope(client, {\n method: 'eth_newPendingTransactionFilter',\n })\n const id = await client.request({\n method: 'eth_newPendingTransactionFilter',\n })\n return { id, request: getRequest(id), type: 'transaction' }\n}\n", "import type { Abi } from 'abitype'\n\nimport type { Account } from '../../accounts/types.js'\nimport {\n type ParseAccountErrorType,\n parseAccount,\n} from '../../accounts/utils/parseAccount.js'\nimport type { Client } from '../../clients/createClient.js'\nimport type { Transport } from '../../clients/transports/createTransport.js'\nimport type { BaseError } from '../../errors/base.js'\nimport type { Chain } from '../../types/chain.js'\nimport type {\n ContractFunctionArgs,\n ContractFunctionName,\n ContractFunctionParameters,\n GetValue,\n} from '../../types/contract.js'\nimport type { Hex } from '../../types/misc.js'\nimport type { UnionOmit } from '../../types/utils.js'\nimport {\n type EncodeFunctionDataErrorType,\n type EncodeFunctionDataParameters,\n encodeFunctionData,\n} from '../../utils/abi/encodeFunctionData.js'\nimport {\n type GetContractErrorReturnType,\n getContractError,\n} from '../../utils/errors/getContractError.js'\nimport { getAction } from '../../utils/getAction.js'\nimport {\n type EstimateGasErrorType,\n type EstimateGasParameters,\n estimateGas,\n} from './estimateGas.js'\n\nexport type EstimateContractGasParameters<\n abi extends Abi | readonly unknown[] = Abi,\n functionName extends ContractFunctionName<\n abi,\n 'nonpayable' | 'payable'\n > = ContractFunctionName<abi, 'nonpayable' | 'payable'>,\n args extends ContractFunctionArgs<\n abi,\n 'nonpayable' | 'payable',\n functionName\n > = ContractFunctionArgs<abi, 'nonpayable' | 'payable', functionName>,\n chain extends Chain | undefined = Chain | undefined,\n> = ContractFunctionParameters<\n abi,\n 'nonpayable' | 'payable',\n functionName,\n args\n> &\n UnionOmit<EstimateGasParameters<chain>, 'data' | 'to' | 'value'> &\n GetValue<\n abi,\n functionName,\n EstimateGasParameters<chain> extends EstimateGasParameters\n ? EstimateGasParameters<chain>['value']\n : EstimateGasParameters['value']\n > & {\n /** Data to append to the end of the calldata. Useful for adding a [\"domain\" tag](https://opensea.notion.site/opensea/Seaport-Order-Attributions-ec2d69bf455041a5baa490941aad307f). */\n dataSuffix?: Hex | undefined\n }\n\nexport type EstimateContractGasReturnType = bigint\n\nexport type EstimateContractGasErrorType = GetContractErrorReturnType<\n EncodeFunctionDataErrorType | EstimateGasErrorType | ParseAccountErrorType\n>\n\n/**\n * Estimates the gas required to successfully execute a contract write function call.\n *\n * - Docs: https://viem.sh/docs/contract/estimateContractGas\n *\n * Internally, uses a [Public Client](https://viem.sh/docs/clients/public) to call the [`estimateGas` action](https://viem.sh/docs/actions/public/estimateGas) with [ABI-encoded `data`](https://viem.sh/docs/contract/encodeFunctionData).\n *\n * @param client - Client to use\n * @param parameters - {@link EstimateContractGasParameters}\n * @returns The gas estimate (in wei). {@link EstimateContractGasReturnType}\n *\n * @example\n * import { createPublicClient, http, parseAbi } from 'viem'\n * import { mainnet } from 'viem/chains'\n * import { estimateContractGas } from 'viem/contract'\n *\n * const client = createPublicClient({\n * chain: mainnet,\n * transport: http(),\n * })\n * const gas = await estimateContractGas(client, {\n * address: '0xFBA3912Ca04dd458c843e2EE08967fC04f3579c2',\n * abi: parseAbi(['function mint() public']),\n * functionName: 'mint',\n * account: '0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266',\n * })\n */\nexport async function estimateContractGas<\n const abi extends Abi | readonly unknown[],\n functionName extends ContractFunctionName<abi, 'nonpayable' | 'payable'>,\n args extends ContractFunctionArgs<abi, 'pure' | 'view', functionName>,\n chain extends Chain | undefined,\n account extends Account | undefined = undefined,\n>(\n client: Client<Transport, chain, account>,\n parameters: EstimateContractGasParameters<abi, functionName, args, chain>,\n): Promise<EstimateContractGasReturnType> {\n const { abi, address, args, functionName, dataSuffix, ...request } =\n parameters as EstimateContractGasParameters\n const data = encodeFunctionData({\n abi,\n args,\n functionName,\n } as EncodeFunctionDataParameters)\n try {\n const gas = await getAction(\n client,\n estimateGas,\n 'estimateGas',\n )({\n data: `${data}${dataSuffix ? dataSuffix.replace('0x', '') : ''}`,\n to: address,\n ...request,\n } as unknown as EstimateGasParameters)\n return gas\n } catch (error) {\n const account = request.account ? parseAccount(request.account) : undefined\n throw getContractError(error as BaseError, {\n abi,\n address,\n args,\n docsPath: '/docs/contract/estimateContractGas',\n functionName,\n sender: account?.address,\n })\n }\n}\n", "import type { Account } from '../../accounts/types.js'\nimport type { Client } from '../../clients/createClient.js'\nimport type { Transport } from '../../clients/transports/createTransport.js'\nimport type { ErrorType } from '../../errors/utils.js'\nimport type { Chain } from '../../types/chain.js'\nimport type { RequestErrorType } from '../../utils/buildRequest.js'\n\nexport type GetBlobBaseFeeReturnType = bigint\n\nexport type GetBlobBaseFeeErrorType = RequestErrorType | ErrorType\n\n/**\n * Returns the base fee per blob gas in wei.\n *\n * - Docs: https://viem.sh/docs/actions/public/getBlobBaseFee\n * - JSON-RPC Methods: [`eth_blobBaseFee`](https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_blobBaseFee)\n *\n * @param client - Client to use\n * @returns The blob base fee (in wei). {@link GetBlobBaseFeeReturnType}\n *\n * @example\n * import { createPublicClient, http } from 'viem'\n * import { mainnet } from 'viem/chains'\n * import { getBlobBaseFee } from 'viem/public'\n *\n * const client = createPublicClient({\n * chain: mainnet,\n * transport: http(),\n * })\n * const blobBaseFee = await getBlobBaseFee(client)\n */\nexport async function getBlobBaseFee<\n chain extends Chain | undefined,\n account extends Account | undefined,\n>(\n client: Client<Transport, chain, account>,\n): Promise<GetBlobBaseFeeReturnType> {\n const baseFee = await client.request({\n method: 'eth_blobBaseFee',\n })\n return BigInt(baseFee)\n}\n", "import type { ErrorType } from '../../errors/utils.js'\n\n/** @internal */\nexport const promiseCache = /*#__PURE__*/ new Map()\n/** @internal */\nexport const responseCache = /*#__PURE__*/ new Map()\n\nexport type GetCacheErrorType = ErrorType\n\nexport function getCache<data>(cacheKey: string) {\n const buildCache = <data>(cacheKey: string, cache: Map<string, data>) => ({\n clear: () => cache.delete(cacheKey),\n get: () => cache.get(cacheKey),\n set: (data: data) => cache.set(cacheKey, data),\n })\n\n const promise = buildCache<Promise<data>>(cacheKey, promiseCache)\n const response = buildCache<{ created: Date; data: data }>(\n cacheKey,\n responseCache,\n )\n\n return {\n clear: () => {\n promise.clear()\n response.clear()\n },\n promise,\n response,\n }\n}\n\ntype WithCacheParameters = {\n /** The key to cache the data against. */\n cacheKey: string\n /** The time that cached data will remain in memory. Default: Infinity (no expiry) */\n cacheTime?: number | undefined\n}\n\n/**\n * @description Returns the result of a given promise, and caches the result for\n * subsequent invocations against a provided cache key.\n */\nexport async function withCache<data>(\n fn: () => Promise<data>,\n { cacheKey, cacheTime = Number.POSITIVE_INFINITY }: WithCacheParameters,\n) {\n const cache = getCache<data>(cacheKey)\n\n // If a response exists in the cache, and it's not expired, return it\n // and do not invoke the promise.\n // If the max age is 0, the cache is disabled.\n const response = cache.response.get()\n if (response && cacheTime > 0) {\n const age = new Date().getTime() - response.created.getTime()\n if (age < cacheTime) return response.data\n }\n\n let promise = cache.promise.get()\n if (!promise) {\n promise = fn()\n\n // Store the promise in the cache so that subsequent invocations\n // will wait for the same promise to resolve (deduping).\n cache.promise.set(promise)\n }\n\n try {\n const data = await promise\n\n // Store the response in the cache so that subsequent invocations\n // will return the same response.\n cache.response.set({ created: new Date(), data })\n\n return data\n } finally {\n // Clear the promise cache so that subsequent invocations will\n // invoke the promise again.\n cache.promise.clear()\n }\n}\n", "import type { Client } from '../../clients/createClient.js'\nimport type { Transport } from '../../clients/transports/createTransport.js'\nimport type { ErrorType } from '../../errors/utils.js'\nimport type { Chain } from '../../types/chain.js'\nimport type { RequestErrorType } from '../../utils/buildRequest.js'\nimport {\n type GetCacheErrorType,\n getCache,\n withCache,\n} from '../../utils/promise/withCache.js'\n\nexport type GetBlockNumberParameters = {\n /** Time (in ms) that cached block number will remain in memory. */\n cacheTime?: number | undefined\n}\n\nexport type GetBlockNumberReturnType = bigint\n\nexport type GetBlockNumberErrorType = RequestErrorType | ErrorType\n\nconst cacheKey = (id: string) => `blockNumber.${id}`\n\n/** @internal */\nexport type GetBlockNumberCacheErrorType = GetCacheErrorType | ErrorType\n\n/** @internal */\nexport function getBlockNumberCache(id: string) {\n return getCache(cacheKey(id))\n}\n\n/**\n * Returns the number of the most recent block seen.\n *\n * - Docs: https://viem.sh/docs/actions/public/getBlockNumber\n * - Examples: https://stackblitz.com/github/wevm/viem/tree/main/examples/blocks_fetching-blocks\n * - JSON-RPC Methods: [`eth_blockNumber`](https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_blocknumber)\n *\n * @param client - Client to use\n * @param parameters - {@link GetBlockNumberParameters}\n * @returns The number of the block. {@link GetBlockNumberReturnType}\n *\n * @example\n * import { createPublicClient, http } from 'viem'\n * import { mainnet } from 'viem/chains'\n * import { getBlockNumber } from 'viem/public'\n *\n * const client = createPublicClient({\n * chain: mainnet,\n * transport: http(),\n * })\n * const blockNumber = await getBlockNumber(client)\n * // 69420n\n */\nexport async function getBlockNumber<chain extends Chain | undefined>(\n client: Client<Transport, chain>,\n { cacheTime = client.cacheTime }: GetBlockNumberParameters = {},\n): Promise<GetBlockNumberReturnType> {\n const blockNumberHex = await withCache(\n () =>\n client.request({\n method: 'eth_blockNumber',\n }),\n { cacheKey: cacheKey(client.uid), cacheTime },\n )\n return BigInt(blockNumberHex)\n}\n", "import type { Client } from '../../clients/createClient.js'\nimport type { Transport } from '../../clients/transports/createTransport.js'\nimport type { ErrorType } from '../../errors/utils.js'\nimport type { BlockTag } from '../../types/block.js'\nimport type { Chain } from '../../types/chain.js'\nimport type { Hash } from '../../types/misc.js'\nimport type { Quantity } from '../../types/rpc.js'\nimport type { RequestErrorType } from '../../utils/buildRequest.js'\nimport {\n type HexToNumberErrorType,\n hexToNumber,\n} from '../../utils/encoding/fromHex.js'\nimport {\n type NumberToHexErrorType,\n numberToHex,\n} from '../../utils/encoding/toHex.js'\n\nexport type GetBlockTransactionCountParameters =\n | {\n /** Hash of the block. */\n blockHash?: Hash | undefined\n blockNumber?: undefined\n blockTag?: undefined\n }\n | {\n blockHash?: undefined\n /** The block number. */\n blockNumber?: bigint | undefined\n blockTag?: undefined\n }\n | {\n blockHash?: undefined\n blockNumber?: undefined\n /** The block tag. Defaults to 'latest'. */\n blockTag?: BlockTag | undefined\n }\n\nexport type GetBlockTransactionCountReturnType = number\n\nexport type GetBlockTransactionCountErrorType =\n | NumberToHexErrorType\n | HexToNumberErrorType\n | RequestErrorType\n | ErrorType\n\n/**\n * Returns the number of Transactions at a block number, hash, or tag.\n *\n * - Docs: https://viem.sh/docs/actions/public/getBlockTransactionCount\n * - JSON-RPC Methods:\n * - Calls [`eth_getBlockTransactionCountByNumber`](https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_getblocktransactioncountbynumber) for `blockNumber` & `blockTag`.\n * - Calls [`eth_getBlockTransactionCountByHash`](https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_getblocktransactioncountbyhash) for `blockHash`.\n *\n * @param client - Client to use\n * @param parameters - {@link GetBlockTransactionCountParameters}\n * @returns The block transaction count. {@link GetBlockTransactionCountReturnType}\n *\n * @example\n * import { createPublicClient, http } from 'viem'\n * import { mainnet } from 'viem/chains'\n * import { getBlockTransactionCount } from 'viem/public'\n *\n * const client = createPublicClient({\n * chain: mainnet,\n * transport: http(),\n * })\n * const count = await getBlockTransactionCount(client)\n */\nexport async function getBlockTransactionCount<chain extends Chain | undefined>(\n client: Client<Transport, chain>,\n {\n blockHash,\n blockNumber,\n blockTag = 'latest',\n }: GetBlockTransactionCountParameters = {},\n): Promise<GetBlockTransactionCountReturnType> {\n const blockNumberHex =\n blockNumber !== undefined ? numberToHex(blockNumber) : undefined\n\n let count: Quantity\n if (blockHash) {\n count = await client.request(\n {\n method: 'eth_getBlockTransactionCountByHash',\n params: [blockHash],\n },\n { dedupe: true },\n )\n } else {\n count = await client.request(\n {\n method: 'eth_getBlockTransactionCountByNumber',\n params: [blockNumberHex || blockTag],\n },\n { dedupe: Boolean(blockNumberHex) },\n )\n }\n\n return hexToNumber(count)\n}\n", "import type { Abi, AbiParameter } from 'abitype'\n\nimport {\n AbiDecodingDataSizeTooSmallError,\n type AbiDecodingDataSizeTooSmallErrorType,\n AbiEventSignatureEmptyTopicsError,\n type AbiEventSignatureEmptyTopicsErrorType,\n AbiEventSignatureNotFoundError,\n type AbiEventSignatureNotFoundErrorType,\n DecodeLogDataMismatch,\n type DecodeLogDataMismatchErrorType,\n DecodeLogTopicsMismatch,\n type DecodeLogTopicsMismatchErrorType,\n} from '../../errors/abi.js'\nimport type { ErrorType } from '../../errors/utils.js'\nimport type {\n ContractEventArgsFromTopics,\n ContractEventName,\n EventDefinition,\n} from '../../types/contract.js'\nimport type { Hex } from '../../types/misc.js'\nimport type {\n IsNarrowable,\n Prettify,\n UnionEvaluate,\n} from '../../types/utils.js'\nimport { size } from '../data/size.js'\nimport {\n type ToEventSelectorErrorType,\n toEventSelector,\n} from '../hash/toEventSelector.js'\n\nimport { PositionOutOfBoundsError } from '../../errors/cursor.js'\nimport {\n type DecodeAbiParametersErrorType,\n decodeAbiParameters,\n} from './decodeAbiParameters.js'\nimport { type FormatAbiItemErrorType, formatAbiItem } from './formatAbiItem.js'\n\nexport type DecodeEventLogParameters<\n abi extends Abi | readonly unknown[] = Abi,\n eventName extends ContractEventName<abi> | undefined = ContractEventName<abi>,\n topics extends Hex[] = Hex[],\n data extends Hex | undefined = undefined,\n strict extends boolean = true,\n> = {\n abi: abi\n data?: data | undefined\n eventName?: eventName | ContractEventName<abi> | undefined\n strict?: strict | boolean | undefined\n topics: [signature: Hex, ...args: topics] | []\n}\n\nexport type DecodeEventLogReturnType<\n abi extends Abi | readonly unknown[] = Abi,\n eventName extends ContractEventName<abi> | undefined = ContractEventName<abi>,\n topics extends Hex[] = Hex[],\n data extends Hex | undefined = undefined,\n strict extends boolean = true,\n ///\n allEventNames extends\n ContractEventName<abi> = eventName extends ContractEventName<abi>\n ? eventName\n : ContractEventName<abi>,\n> = IsNarrowable<abi, Abi> extends true\n ? {\n [name in allEventNames]: Prettify<\n {\n eventName: name\n } & UnionEvaluate<\n ContractEventArgsFromTopics<abi, name, strict> extends infer allArgs\n ? topics extends readonly []\n ? data extends undefined\n ? { args?: undefined }\n : { args?: allArgs | undefined }\n : { args: allArgs }\n : never\n >\n >\n }[allEventNames]\n : {\n eventName: eventName\n args: readonly unknown[] | undefined\n }\n\nexport type DecodeEventLogErrorType =\n | AbiDecodingDataSizeTooSmallErrorType\n | AbiEventSignatureEmptyTopicsErrorType\n | AbiEventSignatureNotFoundErrorType\n | DecodeAbiParametersErrorType\n | DecodeLogTopicsMismatchErrorType\n | DecodeLogDataMismatchErrorType\n | FormatAbiItemErrorType\n | ToEventSelectorErrorType\n | ErrorType\n\nconst docsPath = '/docs/contract/decodeEventLog'\n\nexport function decodeEventLog<\n const abi extends Abi | readonly unknown[],\n eventName extends ContractEventName<abi> | undefined = undefined,\n topics extends Hex[] = Hex[],\n data extends Hex | undefined = undefined,\n strict extends boolean = true,\n>(\n parameters: DecodeEventLogParameters<abi, eventName, topics, data, strict>,\n): DecodeEventLogReturnType<abi, eventName, topics, data, strict> {\n const {\n abi,\n data,\n strict: strict_,\n topics,\n } = parameters as DecodeEventLogParameters\n\n const strict = strict_ ?? true\n const [signature, ...argTopics] = topics\n if (!signature) throw new AbiEventSignatureEmptyTopicsError({ docsPath })\n\n const abiItem = (() => {\n if (abi.length === 1) return abi[0]\n return abi.find(\n (x) =>\n x.type === 'event' &&\n signature === toEventSelector(formatAbiItem(x) as EventDefinition),\n )\n })()\n\n if (!(abiItem && 'name' in abiItem) || abiItem.type !== 'event')\n throw new AbiEventSignatureNotFoundError(signature, { docsPath })\n\n const { name, inputs } = abiItem\n const isUnnamed = inputs?.some((x) => !('name' in x && x.name))\n\n let args: any = isUnnamed ? [] : {}\n\n // Decode topics (indexed args).\n const indexedInputs = inputs.filter((x) => 'indexed' in x && x.indexed)\n for (let i = 0; i < indexedInputs.length; i++) {\n const param = indexedInputs[i]\n const topic = argTopics[i]\n if (!topic)\n throw new DecodeLogTopicsMismatch({\n abiItem,\n param: param as AbiParameter & { indexed: boolean },\n })\n args[isUnnamed ? i : param.name || i] = decodeTopic({ param, value: topic })\n }\n\n // Decode data (non-indexed args).\n const nonIndexedInputs = inputs.filter((x) => !('indexed' in x && x.indexed))\n if (nonIndexedInputs.length > 0) {\n if (data && data !== '0x') {\n try {\n const decodedData = decodeAbiParameters(nonIndexedInputs, data)\n if (decodedData) {\n if (isUnnamed) args = [...args, ...decodedData]\n else {\n for (let i = 0; i < nonIndexedInputs.length; i++) {\n args[nonIndexedInputs[i].name!] = decodedData[i]\n }\n }\n }\n } catch (err) {\n if (strict) {\n if (\n err instanceof AbiDecodingDataSizeTooSmallError ||\n err instanceof PositionOutOfBoundsError\n )\n throw new DecodeLogDataMismatch({\n abiItem,\n data: data,\n params: nonIndexedInputs,\n size: size(data),\n })\n throw err\n }\n }\n } else if (strict) {\n throw new DecodeLogDataMismatch({\n abiItem,\n data: '0x',\n params: nonIndexedInputs,\n size: 0,\n })\n }\n }\n\n return {\n eventName: name,\n args: Object.values(args).length > 0 ? args : undefined,\n } as unknown as DecodeEventLogReturnType<abi, eventName, topics, data, strict>\n}\n\nfunction decodeTopic({ param, value }: { param: AbiParameter; value: Hex }) {\n if (\n param.type === 'string' ||\n param.type === 'bytes' ||\n param.type === 'tuple' ||\n param.type.match(/^(.*)\\[(\\d+)?\\]$/)\n )\n return value\n const decodedArg = decodeAbiParameters([param], value) || []\n return decodedArg[0]\n}\n", "// TODO(v3): checksum address.\n\nimport type { Abi, AbiEvent, AbiEventParameter, Address } from 'abitype'\nimport {\n AbiEventSignatureNotFoundError,\n DecodeLogDataMismatch,\n DecodeLogTopicsMismatch,\n} from '../../errors/abi.js'\nimport type { ErrorType } from '../../errors/utils.js'\nimport type { ContractEventName, GetEventArgs } from '../../types/contract.js'\nimport type { Log } from '../../types/log.js'\nimport type { RpcLog } from '../../types/rpc.js'\nimport { isAddressEqual } from '../address/isAddressEqual.js'\nimport { toBytes } from '../encoding/toBytes.js'\nimport { keccak256 } from '../hash/keccak256.js'\nimport { toEventSelector } from '../hash/toEventSelector.js'\nimport {\n type DecodeEventLogErrorType,\n decodeEventLog,\n} from './decodeEventLog.js'\n\nexport type ParseEventLogsParameters<\n abi extends Abi | readonly unknown[] = Abi,\n eventName extends\n | ContractEventName<abi>\n | ContractEventName<abi>[]\n | undefined = ContractEventName<abi>,\n strict extends boolean | undefined = boolean | undefined,\n ///\n allArgs = GetEventArgs<\n abi,\n eventName extends ContractEventName<abi>\n ? eventName\n : ContractEventName<abi>,\n {\n EnableUnion: true\n IndexedOnly: false\n Required: false\n }\n >,\n> = {\n /** Contract ABI. */\n abi: abi\n /** Arguments for the event. */\n args?: allArgs | undefined\n /** Contract event. */\n eventName?:\n | eventName\n | ContractEventName<abi>\n | ContractEventName<abi>[]\n | undefined\n /** List of logs. */\n logs: (Log | RpcLog)[]\n strict?: strict | boolean | undefined\n}\n\nexport type ParseEventLogsReturnType<\n abi extends Abi | readonly unknown[] = Abi,\n eventName extends\n | ContractEventName<abi>\n | ContractEventName<abi>[]\n | undefined = ContractEventName<abi>,\n strict extends boolean | undefined = boolean | undefined,\n ///\n derivedEventName extends\n | ContractEventName<abi>\n | undefined = eventName extends ContractEventName<abi>[]\n ? eventName[number]\n : eventName,\n> = Log<bigint, number, false, undefined, strict, abi, derivedEventName>[]\n\nexport type ParseEventLogsErrorType = DecodeEventLogErrorType | ErrorType\n\n/**\n * Extracts & decodes logs matching the provided signature(s) (`abi` + optional `eventName`)\n * from a set of opaque logs.\n *\n * @param parameters - {@link ParseEventLogsParameters}\n * @returns The logs. {@link ParseEventLogsReturnType}\n *\n * @example\n * import { createClient, http } from 'viem'\n * import { mainnet } from 'viem/chains'\n * import { parseEventLogs } from 'viem/op-stack'\n *\n * const client = createClient({\n * chain: mainnet,\n * transport: http(),\n * })\n *\n * const receipt = await getTransactionReceipt(client, {\n * hash: '0xec23b2ba4bc59ba61554507c1b1bc91649e6586eb2dd00c728e8ed0db8bb37ea',\n * })\n *\n * const logs = parseEventLogs({ logs: receipt.logs })\n * // [{ args: { ... }, eventName: 'TransactionDeposited', ... }, ...]\n */\nexport function parseEventLogs<\n abi extends Abi | readonly unknown[],\n strict extends boolean | undefined = true,\n eventName extends\n | ContractEventName<abi>\n | ContractEventName<abi>[]\n | undefined = undefined,\n>(\n parameters: ParseEventLogsParameters<abi, eventName, strict>,\n): ParseEventLogsReturnType<abi, eventName, strict> {\n const { abi, args, logs, strict = true } = parameters\n\n const eventName = (() => {\n if (!parameters.eventName) return undefined\n if (Array.isArray(parameters.eventName)) return parameters.eventName\n return [parameters.eventName as string]\n })()\n\n return logs\n .map((log) => {\n try {\n const abiItem = (abi as Abi).find(\n (abiItem) =>\n abiItem.type === 'event' &&\n log.topics[0] === toEventSelector(abiItem),\n ) as AbiEvent\n if (!abiItem) return null\n\n const event = decodeEventLog({\n ...log,\n abi: [abiItem],\n strict,\n })\n\n // Check that the decoded event name matches the provided event name.\n if (eventName && !eventName.includes(event.eventName)) return null\n\n // Check that the decoded event args match the provided args.\n if (\n !includesArgs({\n args: event.args,\n inputs: abiItem.inputs,\n matchArgs: args,\n })\n )\n return null\n\n return { ...event, ...log }\n } catch (err) {\n let eventName: string | undefined\n let isUnnamed: boolean | undefined\n\n if (err instanceof AbiEventSignatureNotFoundError) return null\n if (\n err instanceof DecodeLogDataMismatch ||\n err instanceof DecodeLogTopicsMismatch\n ) {\n // If strict mode is on, and log data/topics do not match event definition, skip.\n if (strict) return null\n eventName = err.abiItem.name\n isUnnamed = err.abiItem.inputs?.some((x) => !('name' in x && x.name))\n }\n\n // Set args to empty if there is an error decoding (e.g. indexed/non-indexed params mismatch).\n return { ...log, args: isUnnamed ? [] : {}, eventName }\n }\n })\n .filter(Boolean) as unknown as ParseEventLogsReturnType<\n abi,\n eventName,\n strict\n >\n}\n\nfunction includesArgs(parameters: {\n args: unknown\n inputs: AbiEvent['inputs']\n matchArgs: unknown\n}) {\n const { args, inputs, matchArgs } = parameters\n\n if (!matchArgs) return true\n if (!args) return false\n\n function isEqual(input: AbiEventParameter, value: unknown, arg: unknown) {\n try {\n if (input.type === 'address')\n return isAddressEqual(value as Address, arg as Address)\n if (input.type === 'string' || input.type === 'bytes')\n return keccak256(toBytes(value as string)) === arg\n return value === arg\n } catch {\n return false\n }\n }\n\n if (Array.isArray(args) && Array.isArray(matchArgs)) {\n return matchArgs.every((value, index) => {\n if (value === null || value === undefined) return true\n const input = inputs[index]\n if (!input) return false\n const value_ = Array.isArray(value) ? value : [value]\n return value_.some((value) => isEqual(input, value, args[index]))\n })\n }\n\n if (\n typeof args === 'object' &&\n !Array.isArray(args) &&\n typeof matchArgs === 'object' &&\n !Array.isArray(matchArgs)\n )\n return Object.entries(matchArgs).every(([key, value]) => {\n if (value === null || value === undefined) return true\n const input = inputs.find((input) => input.name === key)\n if (!input) return false\n const value_ = Array.isArray(value) ? value : [value]\n return value_.some((value) =>\n isEqual(input, value, (args as Record<string, unknown>)[key]),\n )\n })\n\n return false\n}\n", "import type { AbiEvent, Address } from 'abitype'\n\nimport type { Client } from '../../clients/createClient.js'\nimport type { Transport } from '../../clients/transports/createTransport.js'\nimport type { ErrorType } from '../../errors/utils.js'\nimport type { BlockNumber, BlockTag } from '../../types/block.js'\nimport type { Chain } from '../../types/chain.js'\nimport type {\n MaybeAbiEventName,\n MaybeExtractEventArgsFromAbi,\n} from '../../types/contract.js'\nimport type { Log } from '../../types/log.js'\nimport type { Hash, LogTopic } from '../../types/misc.js'\nimport type { RpcLog } from '../../types/rpc.js'\nimport type { DecodeEventLogErrorType } from '../../utils/abi/decodeEventLog.js'\nimport {\n type EncodeEventTopicsErrorType,\n type EncodeEventTopicsParameters,\n encodeEventTopics,\n} from '../../utils/abi/encodeEventTopics.js'\nimport { parseEventLogs } from '../../utils/abi/parseEventLogs.js'\nimport type { RequestErrorType } from '../../utils/buildRequest.js'\nimport {\n type NumberToHexErrorType,\n numberToHex,\n} from '../../utils/encoding/toHex.js'\nimport {\n type FormatLogErrorType,\n formatLog,\n} from '../../utils/formatters/log.js'\n\nexport type GetLogsParameters<\n abiEvent extends AbiEvent | undefined = undefined,\n abiEvents extends\n | readonly AbiEvent[]\n | readonly unknown[]\n | undefined = abiEvent extends AbiEvent ? [abiEvent] : undefined,\n strict extends boolean | undefined = undefined,\n fromBlock extends BlockNumber | BlockTag | undefined = undefined,\n toBlock extends BlockNumber | BlockTag | undefined = undefined,\n //\n _eventName extends string | undefined = MaybeAbiEventName<abiEvent>,\n> = {\n /** Address or list of addresses from which logs originated */\n address?: Address | Address[] | undefined\n} & (\n | {\n event: abiEvent\n events?: undefined\n args?: MaybeExtractEventArgsFromAbi<abiEvents, _eventName> | undefined\n /**\n * Whether or not the logs must match the indexed/non-indexed arguments on `event`.\n * @default false\n */\n strict?: strict | undefined\n }\n | {\n event?: undefined\n events: abiEvents\n args?: undefined\n /**\n * Whether or not the logs must match the indexed/non-indexed arguments on `event`.\n * @default false\n */\n strict?: strict | undefined\n }\n | {\n event?: undefined\n events?: undefined\n args?: undefined\n strict?: undefined\n }\n) &\n (\n | {\n /** Block number or tag after which to include logs */\n fromBlock?: fromBlock | BlockNumber | BlockTag | undefined\n /** Block number or tag before which to include logs */\n toBlock?: toBlock | BlockNumber | BlockTag | undefined\n blockHash?: undefined\n }\n | {\n fromBlock?: undefined\n toBlock?: undefined\n /** Hash of block to include logs from */\n blockHash?: Hash | undefined\n }\n )\n\nexport type GetLogsReturnType<\n abiEvent extends AbiEvent | undefined = undefined,\n abiEvents extends\n | readonly AbiEvent[]\n | readonly unknown[]\n | undefined = abiEvent extends AbiEvent ? [abiEvent] : undefined,\n strict extends boolean | undefined = undefined,\n fromBlock extends BlockNumber | BlockTag | undefined = undefined,\n toBlock extends BlockNumber | BlockTag | undefined = undefined,\n //\n _eventName extends string | undefined = MaybeAbiEventName<abiEvent>,\n _pending extends boolean =\n | (fromBlock extends 'pending' ? true : false)\n | (toBlock extends 'pending' ? true : false),\n> = Log<bigint, number, _pending, abiEvent, strict, abiEvents, _eventName>[]\n\nexport type GetLogsErrorType =\n | DecodeEventLogErrorType\n | EncodeEventTopicsErrorType\n | FormatLogErrorType\n | NumberToHexErrorType\n | RequestErrorType\n | ErrorType\n\n/**\n * Returns a list of event logs matching the provided parameters.\n *\n * - Docs: https://viem.sh/docs/actions/public/getLogs\n * - Examples: https://stackblitz.com/github/wevm/viem/tree/main/examples/logs_event-logs\n * - JSON-RPC Methods: [`eth_getLogs`](https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_getlogs)\n *\n * @param client - Client to use\n * @param parameters - {@link GetLogsParameters}\n * @returns A list of event logs. {@link GetLogsReturnType}\n *\n * @example\n * import { createPublicClient, http, parseAbiItem } from 'viem'\n * import { mainnet } from 'viem/chains'\n * import { getLogs } from 'viem/public'\n *\n * const client = createPublicClient({\n * chain: mainnet,\n * transport: http(),\n * })\n * const logs = await getLogs(client)\n */\nexport async function getLogs<\n chain extends Chain | undefined,\n const abiEvent extends AbiEvent | undefined = undefined,\n const abiEvents extends\n | readonly AbiEvent[]\n | readonly unknown[]\n | undefined = abiEvent extends AbiEvent ? [abiEvent] : undefined,\n strict extends boolean | undefined = undefined,\n fromBlock extends BlockNumber | BlockTag | undefined = undefined,\n toBlock extends BlockNumber | BlockTag | undefined = undefined,\n>(\n client: Client<Transport, chain>,\n {\n address,\n blockHash,\n fromBlock,\n toBlock,\n event,\n events: events_,\n args,\n strict: strict_,\n }: GetLogsParameters<abiEvent, abiEvents, strict, fromBlock, toBlock> = {},\n): Promise<GetLogsReturnType<abiEvent, abiEvents, strict, fromBlock, toBlock>> {\n const strict = strict_ ?? false\n const events = events_ ?? (event ? [event] : undefined)\n\n let topics: LogTopic[] = []\n if (events) {\n const encoded = (events as AbiEvent[]).flatMap((event) =>\n encodeEventTopics({\n abi: [event],\n eventName: (event as AbiEvent).name,\n args: events_ ? undefined : args,\n } as EncodeEventTopicsParameters),\n )\n // TODO: Clean up type casting\n topics = [encoded as LogTopic]\n if (event) topics = topics[0] as LogTopic[]\n }\n\n let logs: RpcLog[]\n if (blockHash) {\n logs = await client.request({\n method: 'eth_getLogs',\n params: [{ address, topics, blockHash }],\n })\n } else {\n logs = await client.request({\n method: 'eth_getLogs',\n params: [\n {\n address,\n topics,\n fromBlock:\n typeof fromBlock === 'bigint' ? numberToHex(fromBlock) : fromBlock,\n toBlock: typeof toBlock === 'bigint' ? numberToHex(toBlock) : toBlock,\n },\n ],\n })\n }\n\n const formattedLogs = logs.map((log) => formatLog(log))\n if (!events)\n return formattedLogs as GetLogsReturnType<\n abiEvent,\n abiEvents,\n strict,\n fromBlock,\n toBlock\n >\n return parseEventLogs({\n abi: events,\n args: args as any,\n logs: formattedLogs,\n strict,\n }) as unknown as GetLogsReturnType<\n abiEvent,\n abiEvents,\n strict,\n fromBlock,\n toBlock\n >\n}\n", "import type { Abi, Address } from 'abitype'\n\nimport type { Client } from '../../clients/createClient.js'\nimport type { Transport } from '../../clients/transports/createTransport.js'\nimport type { ErrorType } from '../../errors/utils.js'\nimport type { BlockNumber, BlockTag } from '../../types/block.js'\nimport type { Chain } from '../../types/chain.js'\nimport type {\n ContractEventArgs,\n ContractEventName,\n} from '../../types/contract.js'\nimport type { Log } from '../../types/log.js'\nimport type { Hash } from '../../types/misc.js'\nimport {\n type GetAbiItemErrorType,\n type GetAbiItemParameters,\n getAbiItem,\n} from '../../utils/abi/getAbiItem.js'\nimport { getAction } from '../../utils/getAction.js'\nimport {\n type GetLogsErrorType,\n type GetLogsParameters,\n getLogs,\n} from './getLogs.js'\n\nexport type GetContractEventsParameters<\n abi extends Abi | readonly unknown[] = Abi,\n eventName extends ContractEventName<abi> | undefined =\n | ContractEventName<abi>\n | undefined,\n strict extends boolean | undefined = undefined,\n fromBlock extends BlockNumber | BlockTag | undefined = undefined,\n toBlock extends BlockNumber | BlockTag | undefined = undefined,\n> = {\n /** The address of the contract. */\n address?: Address | Address[] | undefined\n /** Contract ABI. */\n abi: abi\n args?:\n | ContractEventArgs<\n abi,\n eventName extends ContractEventName<abi>\n ? eventName\n : ContractEventName<abi>\n >\n | undefined\n /** Contract event. */\n eventName?: eventName | ContractEventName<abi> | undefined\n /**\n * Whether or not the logs must match the indexed/non-indexed arguments on `event`.\n * @default false\n */\n strict?: strict | boolean | undefined\n} & (\n | {\n /** Block number or tag after which to include logs */\n fromBlock?: fromBlock | BlockNumber | BlockTag | undefined\n /** Block number or tag before which to include logs */\n toBlock?: toBlock | BlockNumber | BlockTag | undefined\n blockHash?: undefined\n }\n | {\n fromBlock?: undefined\n toBlock?: undefined\n /** Hash of block to include logs from */\n blockHash?: Hash | undefined\n }\n)\n\nexport type GetContractEventsReturnType<\n abi extends Abi | readonly unknown[] = readonly unknown[],\n eventName extends ContractEventName<abi> | undefined =\n | ContractEventName<abi>\n | undefined,\n strict extends boolean | undefined = undefined,\n fromBlock extends BlockNumber | BlockTag | undefined = undefined,\n toBlock extends BlockNumber | BlockTag | undefined = undefined,\n ///\n isPending extends boolean =\n | (fromBlock extends 'pending' ? true : false)\n | (toBlock extends 'pending' ? true : false),\n> = Log<bigint, number, isPending, undefined, strict, abi, eventName>[]\n\nexport type GetContractEventsErrorType =\n | GetAbiItemErrorType\n | GetLogsErrorType\n | ErrorType\n\n/**\n * Returns a list of event logs emitted by a contract.\n *\n * - Docs: https://viem.sh/docs/contract/getContractEvents#getcontractevents\n * - JSON-RPC Methods: [`eth_getLogs`](https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_getlogs)\n *\n * @param client - Client to use\n * @param parameters - {@link GetContractEventsParameters}\n * @returns A list of event logs. {@link GetContractEventsReturnType}\n *\n * @example\n * import { createClient, http } from 'viem'\n * import { mainnet } from 'viem/chains'\n * import { getContractEvents } from 'viem/public'\n * import { wagmiAbi } from './abi'\n *\n * const client = createClient({\n * chain: mainnet,\n * transport: http(),\n * })\n * const logs = await getContractEvents(client, {\n * address: '0xFBA3912Ca04dd458c843e2EE08967fC04f3579c2',\n * abi: wagmiAbi,\n * eventName: 'Transfer'\n * })\n */\nexport async function getContractEvents<\n chain extends Chain | undefined,\n const abi extends Abi | readonly unknown[],\n eventName extends ContractEventName<abi> | undefined = undefined,\n strict extends boolean | undefined = undefined,\n fromBlock extends BlockNumber | BlockTag | undefined = undefined,\n toBlock extends BlockNumber | BlockTag | undefined = undefined,\n>(\n client: Client<Transport, chain>,\n parameters: GetContractEventsParameters<\n abi,\n eventName,\n strict,\n fromBlock,\n toBlock\n >,\n): Promise<\n GetContractEventsReturnType<abi, eventName, strict, fromBlock, toBlock>\n> {\n const {\n abi,\n address,\n args,\n blockHash,\n eventName,\n fromBlock,\n toBlock,\n strict,\n } = parameters\n const event = eventName\n ? getAbiItem({ abi, name: eventName } as GetAbiItemParameters)\n : undefined\n const events = !event\n ? (abi as Abi).filter((x) => x.type === 'event')\n : undefined\n return getAction(\n client,\n getLogs,\n 'getLogs',\n )({\n address,\n args,\n blockHash,\n event,\n events,\n fromBlock,\n toBlock,\n strict,\n } as {} as GetLogsParameters) as unknown as GetContractEventsReturnType<\n abi,\n eventName,\n strict,\n fromBlock,\n toBlock\n >\n}\n", "import type { Address } from 'abitype'\nimport { BaseError } from './base.js'\n\nexport type Eip712DomainNotFoundErrorType = Eip712DomainNotFoundError & {\n name: 'Eip712DomainNotFoundError'\n}\nexport class Eip712DomainNotFoundError extends BaseError {\n constructor({ address }: { address: Address }) {\n super(`No EIP-712 domain found on contract \"${address}\".`, {\n metaMessages: [\n 'Ensure that:',\n `- The contract is deployed at the address \"${address}\".`,\n '- `eip712Domain()` function exists on the contract.',\n '- `eip712Domain()` function matches signature to ERC-5267 specification.',\n ],\n name: 'Eip712DomainNotFoundError',\n })\n }\n}\n", "import type { Address, TypedDataDomain } from 'abitype'\nimport type { Client } from '../../clients/createClient.js'\nimport type { Transport } from '../../clients/transports/createTransport.js'\nimport {\n Eip712DomainNotFoundError,\n type Eip712DomainNotFoundErrorType,\n} from '../../errors/eip712.js'\nimport type { ErrorType } from '../../errors/utils.js'\nimport type { Hex } from '../../types/misc.js'\nimport type { RequiredBy } from '../../types/utils.js'\nimport { getAction } from '../../utils/getAction.js'\nimport {\n type ReadContractErrorType,\n type ReadContractParameters,\n readContract,\n} from './readContract.js'\n\nexport type GetEip712DomainParameters = {\n address: Address\n} & Pick<ReadContractParameters, 'factory' | 'factoryData'>\n\nexport type GetEip712DomainReturnType = {\n domain: RequiredBy<\n TypedDataDomain,\n 'chainId' | 'name' | 'verifyingContract' | 'salt' | 'version'\n >\n fields: Hex\n extensions: readonly bigint[]\n}\n\nexport type GetEip712DomainErrorType =\n | Eip712DomainNotFoundErrorType\n | ReadContractErrorType\n | ErrorType\n\n/**\n * Reads the EIP-712 domain from a contract, based on the ERC-5267 specification.\n *\n * @param client - A {@link Client} instance.\n * @param parameters - The parameters of the action. {@link GetEip712DomainParameters}\n * @returns The EIP-712 domain, fields, and extensions. {@link GetEip712DomainReturnType}\n *\n * @example\n * ```ts\n * import { createPublicClient, http, getEip712Domain } from 'viem'\n * import { mainnet } from 'viem/chains'\n *\n * const client = createPublicClient({\n * chain: mainnet,\n * transport: http(),\n * })\n *\n * const domain = await getEip712Domain(client, {\n * address: '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48',\n * })\n * // {\n * // domain: {\n * // name: 'ExampleContract',\n * // version: '1',\n * // chainId: 1,\n * // verifyingContract: '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48',\n * // },\n * // fields: '0x0f',\n * // extensions: [],\n * // }\n * ```\n */\nexport async function getEip712Domain(\n client: Client<Transport>,\n parameters: GetEip712DomainParameters,\n): Promise<GetEip712DomainReturnType> {\n const { address, factory, factoryData } = parameters\n\n try {\n const [\n fields,\n name,\n version,\n chainId,\n verifyingContract,\n salt,\n extensions,\n ] = await getAction(\n client,\n readContract,\n 'readContract',\n )({\n abi,\n address,\n functionName: 'eip712Domain',\n factory,\n factoryData,\n })\n\n return {\n domain: {\n name,\n version,\n chainId: Number(chainId),\n verifyingContract,\n salt,\n },\n extensions,\n fields,\n }\n } catch (e) {\n const error = e as ReadContractErrorType\n if (\n error.name === 'ContractFunctionExecutionError' &&\n error.cause.name === 'ContractFunctionZeroDataError'\n ) {\n throw new Eip712DomainNotFoundError({ address })\n }\n throw error\n }\n}\n\nconst abi = [\n {\n inputs: [],\n name: 'eip712Domain',\n outputs: [\n { name: 'fields', type: 'bytes1' },\n { name: 'name', type: 'string' },\n { name: 'version', type: 'string' },\n { name: 'chainId', type: 'uint256' },\n { name: 'verifyingContract', type: 'address' },\n { name: 'salt', type: 'bytes32' },\n { name: 'extensions', type: 'uint256[]' },\n ],\n stateMutability: 'view',\n type: 'function',\n },\n] as const\n", "import type { ErrorType } from '../../errors/utils.js'\nimport type { FeeHistory } from '../../types/fee.js'\nimport type { RpcFeeHistory } from '../../types/rpc.js'\n\nexport type FormatFeeHistoryErrorType = ErrorType\n\nexport function formatFeeHistory(feeHistory: RpcFeeHistory): FeeHistory {\n return {\n baseFeePerGas: feeHistory.baseFeePerGas.map((value) => BigInt(value)),\n gasUsedRatio: feeHistory.gasUsedRatio,\n oldestBlock: BigInt(feeHistory.oldestBlock),\n reward: feeHistory.reward?.map((reward) =>\n reward.map((value) => BigInt(value)),\n ),\n }\n}\n", "import type { Client } from '../../clients/createClient.js'\nimport type { Transport } from '../../clients/transports/createTransport.js'\nimport type { BlockTag } from '../../types/block.js'\nimport type { Chain } from '../../types/chain.js'\nimport type { FeeHistory } from '../../types/fee.js'\nimport type { RequestErrorType } from '../../utils/buildRequest.js'\nimport {\n type NumberToHexErrorType,\n numberToHex,\n} from '../../utils/encoding/toHex.js'\nimport {\n type FormatFeeHistoryErrorType,\n formatFeeHistory,\n} from '../../utils/formatters/feeHistory.js'\n\nexport type GetFeeHistoryParameters = {\n /**\n * Number of blocks in the requested range. Between 1 and 1024 blocks can be requested in a single query. Less than requested may be returned if not all blocks are available.\n */\n blockCount: number\n /**\n * A monotonically increasing list of percentile values to sample from each block's effective priority fees per gas in ascending order, weighted by gas used.\n */\n rewardPercentiles: number[]\n} & (\n | {\n blockNumber?: undefined\n /**\n * Highest number block of the requested range.\n * @default 'latest'\n */\n blockTag?: BlockTag | undefined\n }\n | {\n /** Highest number block of the requested range. */\n blockNumber?: bigint | undefined\n blockTag?: undefined\n }\n)\nexport type GetFeeHistoryReturnType = FeeHistory\n\nexport type GetFeeHistoryErrorType =\n | NumberToHexErrorType\n | RequestErrorType\n | FormatFeeHistoryErrorType\n\n/**\n * Returns a collection of historical gas information.\n *\n * - Docs: https://viem.sh/docs/actions/public/getFeeHistory\n * - JSON-RPC Methods: [`eth_feeHistory`](https://docs.alchemy.com/reference/eth-feehistory)\n *\n * @param client - Client to use\n * @param parameters - {@link GetFeeHistoryParameters}\n * @returns The gas estimate (in wei). {@link GetFeeHistoryReturnType}\n *\n * @example\n * import { createPublicClient, http } from 'viem'\n * import { mainnet } from 'viem/chains'\n * import { getFeeHistory } from 'viem/public'\n *\n * const client = createPublicClient({\n * chain: mainnet,\n * transport: http(),\n * })\n * const feeHistory = await getFeeHistory(client, {\n * blockCount: 4,\n * rewardPercentiles: [25, 75],\n * })\n */\nexport async function getFeeHistory<chain extends Chain | undefined>(\n client: Client<Transport, chain>,\n {\n blockCount,\n blockNumber,\n blockTag = 'latest',\n rewardPercentiles,\n }: GetFeeHistoryParameters,\n): Promise<GetFeeHistoryReturnType> {\n const blockNumberHex = blockNumber ? numberToHex(blockNumber) : undefined\n const feeHistory = await client.request(\n {\n method: 'eth_feeHistory',\n params: [\n numberToHex(blockCount),\n blockNumberHex || blockTag,\n rewardPercentiles,\n ],\n },\n { dedupe: Boolean(blockNumberHex) },\n )\n return formatFeeHistory(feeHistory)\n}\n", "import type { Abi, AbiEvent, ExtractAbiEvent } from 'abitype'\n\nimport type { Client } from '../../clients/createClient.js'\nimport type { Transport } from '../../clients/transports/createTransport.js'\nimport type { ErrorType } from '../../errors/utils.js'\nimport type { RpcLog } from '../../index.js'\nimport type { BlockNumber, BlockTag } from '../../types/block.js'\nimport type { Chain } from '../../types/chain.js'\nimport type { Filter, FilterType } from '../../types/filter.js'\nimport type { Log } from '../../types/log.js'\nimport type { Hash } from '../../types/misc.js'\nimport type { DecodeEventLogErrorType } from '../../utils/abi/decodeEventLog.js'\nimport { parseEventLogs } from '../../utils/abi/parseEventLogs.js'\nimport type { RequestErrorType } from '../../utils/buildRequest.js'\nimport {\n type FormatLogErrorType,\n formatLog,\n} from '../../utils/formatters/log.js'\n\nexport type GetFilterChangesParameters<\n filterType extends FilterType = FilterType,\n abi extends Abi | readonly unknown[] | undefined = undefined,\n eventName extends string | undefined = undefined,\n strict extends boolean | undefined = undefined,\n fromBlock extends BlockNumber | BlockTag | undefined = undefined,\n toBlock extends BlockNumber | BlockTag | undefined = undefined,\n> = {\n filter: Filter<filterType, abi, eventName, any, strict, fromBlock, toBlock>\n}\n\nexport type GetFilterChangesReturnType<\n filterType extends FilterType = FilterType,\n abi extends Abi | readonly unknown[] | undefined = undefined,\n eventName extends string | undefined = undefined,\n strict extends boolean | undefined = undefined,\n fromBlock extends BlockNumber | BlockTag | undefined = undefined,\n toBlock extends BlockNumber | BlockTag | undefined = undefined,\n _AbiEvent extends AbiEvent | undefined = abi extends Abi\n ? eventName extends string\n ? ExtractAbiEvent<abi, eventName>\n : undefined\n : undefined,\n _Pending extends boolean =\n | (fromBlock extends 'pending' ? true : false)\n | (toBlock extends 'pending' ? true : false),\n> = filterType extends 'event'\n ? Log<bigint, number, _Pending, _AbiEvent, strict, abi, eventName>[]\n : Hash[]\n\nexport type GetFilterChangesErrorType =\n | RequestErrorType\n | DecodeEventLogErrorType\n | FormatLogErrorType\n | ErrorType\n\n/**\n * Returns a list of logs or hashes based on a [Filter](/docs/glossary/terms#filter) since the last time it was called.\n *\n * - Docs: https://viem.sh/docs/actions/public/getFilterChanges\n * - JSON-RPC Methods: [`eth_getFilterChanges`](https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_getfilterchanges)\n *\n * A Filter can be created from the following actions:\n *\n * - [`createBlockFilter`](https://viem.sh/docs/actions/public/createBlockFilter)\n * - [`createContractEventFilter`](https://viem.sh/docs/contract/createContractEventFilter)\n * - [`createEventFilter`](https://viem.sh/docs/actions/public/createEventFilter)\n * - [`createPendingTransactionFilter`](https://viem.sh/docs/actions/public/createPendingTransactionFilter)\n *\n * Depending on the type of filter, the return value will be different:\n *\n * - If the filter was created with `createContractEventFilter` or `createEventFilter`, it returns a list of logs.\n * - If the filter was created with `createPendingTransactionFilter`, it returns a list of transaction hashes.\n * - If the filter was created with `createBlockFilter`, it returns a list of block hashes.\n *\n * @param client - Client to use\n * @param parameters - {@link GetFilterChangesParameters}\n * @returns Logs or hashes. {@link GetFilterChangesReturnType}\n *\n * @example\n * // Blocks\n * import { createPublicClient, http } from 'viem'\n * import { mainnet } from 'viem/chains'\n * import { createBlockFilter, getFilterChanges } from 'viem/public'\n *\n * const client = createPublicClient({\n * chain: mainnet,\n * transport: http(),\n * })\n * const filter = await createBlockFilter(client)\n * const hashes = await getFilterChanges(client, { filter })\n *\n * @example\n * // Contract Events\n * import { createPublicClient, http, parseAbi } from 'viem'\n * import { mainnet } from 'viem/chains'\n * import { createContractEventFilter, getFilterChanges } from 'viem/public'\n *\n * const client = createPublicClient({\n * chain: mainnet,\n * transport: http(),\n * })\n * const filter = await createContractEventFilter(client, {\n * address: '0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',\n * abi: parseAbi(['event Transfer(address indexed, address indexed, uint256)']),\n * eventName: 'Transfer',\n * })\n * const logs = await getFilterChanges(client, { filter })\n *\n * @example\n * // Raw Events\n * import { createPublicClient, http, parseAbiItem } from 'viem'\n * import { mainnet } from 'viem/chains'\n * import { createEventFilter, getFilterChanges } from 'viem/public'\n *\n * const client = createPublicClient({\n * chain: mainnet,\n * transport: http(),\n * })\n * const filter = await createEventFilter(client, {\n * address: '0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',\n * event: parseAbiItem('event Transfer(address indexed, address indexed, uint256)'),\n * })\n * const logs = await getFilterChanges(client, { filter })\n *\n * @example\n * // Transactions\n * import { createPublicClient, http } from 'viem'\n * import { mainnet } from 'viem/chains'\n * import { createPendingTransactionFilter, getFilterChanges } from 'viem/public'\n *\n * const client = createPublicClient({\n * chain: mainnet,\n * transport: http(),\n * })\n * const filter = await createPendingTransactionFilter(client)\n * const hashes = await getFilterChanges(client, { filter })\n */\nexport async function getFilterChanges<\n transport extends Transport,\n chain extends Chain | undefined,\n filterType extends FilterType,\n const abi extends Abi | readonly unknown[] | undefined,\n eventName extends string | undefined,\n strict extends boolean | undefined = undefined,\n fromBlock extends BlockNumber | BlockTag | undefined = undefined,\n toBlock extends BlockNumber | BlockTag | undefined = undefined,\n>(\n _client: Client<transport, chain>,\n {\n filter,\n }: GetFilterChangesParameters<\n filterType,\n abi,\n eventName,\n strict,\n fromBlock,\n toBlock\n >,\n): Promise<\n GetFilterChangesReturnType<\n filterType,\n abi,\n eventName,\n strict,\n fromBlock,\n toBlock\n >\n> {\n const strict = 'strict' in filter && filter.strict\n\n const logs = await filter.request({\n method: 'eth_getFilterChanges',\n params: [filter.id],\n })\n\n if (typeof logs[0] === 'string')\n return logs as GetFilterChangesReturnType<\n filterType,\n abi,\n eventName,\n strict,\n fromBlock,\n toBlock\n >\n\n const formattedLogs = logs.map((log) => formatLog(log as RpcLog))\n if (!('abi' in filter) || !filter.abi)\n return formattedLogs as GetFilterChangesReturnType<\n filterType,\n abi,\n eventName,\n strict,\n fromBlock,\n toBlock\n >\n return parseEventLogs({\n abi: filter.abi,\n logs: formattedLogs,\n strict,\n }) as unknown as GetFilterChangesReturnType<\n filterType,\n abi,\n eventName,\n strict,\n fromBlock,\n toBlock\n >\n}\n", "import type { Abi, AbiEvent, ExtractAbiEvent } from 'abitype'\n\nimport type { Client } from '../../clients/createClient.js'\nimport type { Transport } from '../../clients/transports/createTransport.js'\n\nimport type { ErrorType } from '../../errors/utils.js'\nimport type { BlockNumber, BlockTag } from '../../types/block.js'\nimport type { Chain } from '../../types/chain.js'\nimport type { Filter } from '../../types/filter.js'\nimport type { Log } from '../../types/log.js'\nimport type { DecodeEventLogErrorType } from '../../utils/abi/decodeEventLog.js'\nimport { parseEventLogs } from '../../utils/abi/parseEventLogs.js'\nimport type { RequestErrorType } from '../../utils/buildRequest.js'\nimport {\n type FormatLogErrorType,\n formatLog,\n} from '../../utils/formatters/log.js'\n\nexport type GetFilterLogsParameters<\n abi extends Abi | readonly unknown[] | undefined = undefined,\n eventName extends string | undefined = undefined,\n strict extends boolean | undefined = undefined,\n fromBlock extends BlockNumber | BlockTag | undefined = undefined,\n toBlock extends BlockNumber | BlockTag | undefined = undefined,\n> = {\n filter: Filter<'event', abi, eventName, any, strict, fromBlock, toBlock>\n}\nexport type GetFilterLogsReturnType<\n abi extends Abi | readonly unknown[] | undefined = undefined,\n eventName extends string | undefined = undefined,\n strict extends boolean | undefined = undefined,\n fromBlock extends BlockNumber | BlockTag | undefined = undefined,\n toBlock extends BlockNumber | BlockTag | undefined = undefined,\n _AbiEvent extends AbiEvent | undefined = abi extends Abi\n ? eventName extends string\n ? ExtractAbiEvent<abi, eventName>\n : undefined\n : undefined,\n _Pending extends boolean =\n | (fromBlock extends 'pending' ? true : false)\n | (toBlock extends 'pending' ? true : false),\n> = Log<bigint, number, _Pending, _AbiEvent, strict, abi, eventName>[]\n\nexport type GetFilterLogsErrorType =\n | RequestErrorType\n | DecodeEventLogErrorType\n | FormatLogErrorType\n | ErrorType\n\n/**\n * Returns a list of event logs since the filter was created.\n *\n * - Docs: https://viem.sh/docs/actions/public/getFilterLogs\n * - JSON-RPC Methods: [`eth_getFilterLogs`](https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_getfilterlogs)\n *\n * `getFilterLogs` is only compatible with **event filters**.\n *\n * @param client - Client to use\n * @param parameters - {@link GetFilterLogsParameters}\n * @returns A list of event logs. {@link GetFilterLogsReturnType}\n *\n * @example\n * import { createPublicClient, http, parseAbiItem } from 'viem'\n * import { mainnet } from 'viem/chains'\n * import { createEventFilter, getFilterLogs } from 'viem/public'\n *\n * const client = createPublicClient({\n * chain: mainnet,\n * transport: http(),\n * })\n * const filter = await createEventFilter(client, {\n * address: '0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',\n * event: parseAbiItem('event Transfer(address indexed, address indexed, uint256)'),\n * })\n * const logs = await getFilterLogs(client, { filter })\n */\nexport async function getFilterLogs<\n chain extends Chain | undefined,\n const abi extends Abi | readonly unknown[] | undefined,\n eventName extends string | undefined,\n strict extends boolean | undefined = undefined,\n fromBlock extends BlockNumber | BlockTag | undefined = undefined,\n toBlock extends BlockNumber | BlockTag | undefined = undefined,\n>(\n _client: Client<Transport, chain>,\n {\n filter,\n }: GetFilterLogsParameters<abi, eventName, strict, fromBlock, toBlock>,\n): Promise<\n GetFilterLogsReturnType<abi, eventName, strict, fromBlock, toBlock>\n> {\n const strict = filter.strict ?? false\n\n const logs = await filter.request({\n method: 'eth_getFilterLogs',\n params: [filter.id],\n })\n\n const formattedLogs = logs.map((log) => formatLog(log))\n if (!filter.abi)\n return formattedLogs as GetFilterLogsReturnType<\n abi,\n eventName,\n strict,\n fromBlock,\n toBlock\n >\n return parseEventLogs({\n abi: filter.abi,\n logs: formattedLogs,\n strict,\n }) as unknown as GetFilterLogsReturnType<\n abi,\n eventName,\n strict,\n fromBlock,\n toBlock\n >\n}\n", "import type { Address } from 'abitype'\n\nimport type { Client } from '../../clients/createClient.js'\nimport type { Transport } from '../../clients/transports/createTransport.js'\nimport type { ErrorType } from '../../errors/utils.js'\nimport type { BlockTag } from '../../types/block.js'\nimport type { Chain } from '../../types/chain.js'\nimport type { Hex } from '../../types/misc.js'\nimport type { RequestErrorType } from '../../utils/buildRequest.js'\nimport {\n type NumberToHexErrorType,\n numberToHex,\n} from '../../utils/encoding/toHex.js'\n\nexport type GetStorageAtParameters = {\n address: Address\n slot: Hex\n} & (\n | {\n blockNumber?: undefined\n blockTag?: BlockTag | undefined\n }\n | {\n blockNumber?: bigint | undefined\n blockTag?: undefined\n }\n)\n\nexport type GetStorageAtReturnType = Hex | undefined\n\nexport type GetStorageAtErrorType =\n | NumberToHexErrorType\n | RequestErrorType\n | ErrorType\n\n/**\n * Returns the value from a storage slot at a given address.\n *\n * - Docs: https://viem.sh/docs/contract/getStorageAt\n * - JSON-RPC Methods: [`eth_getStorageAt`](https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_getstorageat)\n *\n * @param client - Client to use\n * @param parameters - {@link GetStorageAtParameters}\n * @returns The value of the storage slot. {@link GetStorageAtReturnType}\n *\n * @example\n * import { createPublicClient, http } from 'viem'\n * import { mainnet } from 'viem/chains'\n * import { getStorageAt } from 'viem/contract'\n *\n * const client = createPublicClient({\n * chain: mainnet,\n * transport: http(),\n * })\n * const code = await getStorageAt(client, {\n * address: '0xFBA3912Ca04dd458c843e2EE08967fC04f3579c2',\n * slot: toHex(0),\n * })\n */\nexport async function getStorageAt<chain extends Chain | undefined>(\n client: Client<Transport, chain>,\n { address, blockNumber, blockTag = 'latest', slot }: GetStorageAtParameters,\n): Promise<GetStorageAtReturnType> {\n const blockNumberHex =\n blockNumber !== undefined ? numberToHex(blockNumber) : undefined\n const data = await client.request({\n method: 'eth_getStorageAt',\n params: [address, slot, blockNumberHex || blockTag],\n })\n return data\n}\n", "import type { Client } from '../../clients/createClient.js'\nimport type { Transport } from '../../clients/transports/createTransport.js'\nimport {\n TransactionNotFoundError,\n type TransactionNotFoundErrorType,\n} from '../../errors/transaction.js'\nimport type { ErrorType } from '../../errors/utils.js'\nimport type { BlockTag } from '../../types/block.js'\nimport type { Chain } from '../../types/chain.js'\nimport type { Hash } from '../../types/misc.js'\nimport type { RpcTransaction } from '../../types/rpc.js'\nimport type { Prettify } from '../../types/utils.js'\nimport type { RequestErrorType } from '../../utils/buildRequest.js'\nimport {\n type NumberToHexErrorType,\n numberToHex,\n} from '../../utils/encoding/toHex.js'\nimport {\n type FormattedTransaction,\n formatTransaction,\n} from '../../utils/formatters/transaction.js'\n\nexport type GetTransactionParameters<blockTag extends BlockTag = 'latest'> =\n | {\n /** The block hash */\n blockHash: Hash\n blockNumber?: undefined\n blockTag?: undefined\n hash?: undefined\n /** The index of the transaction on the block. */\n index: number\n }\n | {\n blockHash?: undefined\n /** The block number */\n blockNumber: bigint\n blockTag?: undefined\n hash?: undefined\n /** The index of the transaction on the block. */\n index: number\n }\n | {\n blockHash?: undefined\n blockNumber?: undefined\n /** The block tag. */\n blockTag: blockTag | BlockTag\n hash?: undefined\n /** The index of the transaction on the block. */\n index: number\n }\n | {\n blockHash?: undefined\n blockNumber?: undefined\n blockTag?: undefined\n /** The hash of the transaction. */\n hash: Hash\n index?: number | undefined\n }\n\nexport type GetTransactionReturnType<\n chain extends Chain | undefined = undefined,\n blockTag extends BlockTag = 'latest',\n> = Prettify<FormattedTransaction<chain, blockTag>>\n\nexport type GetTransactionErrorType =\n | TransactionNotFoundErrorType\n | NumberToHexErrorType\n | RequestErrorType\n | ErrorType\n\n/**\n * Returns information about a [Transaction](https://viem.sh/docs/glossary/terms#transaction) given a hash or block identifier.\n *\n * - Docs: https://viem.sh/docs/actions/public/getTransaction\n * - Example: https://stackblitz.com/github/wevm/viem/tree/main/examples/transactions_fetching-transactions\n * - JSON-RPC Methods: [`eth_getTransactionByHash`](https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_getTransactionByHash)\n *\n * @param client - Client to use\n * @param parameters - {@link GetTransactionParameters}\n * @returns The transaction information. {@link GetTransactionReturnType}\n *\n * @example\n * import { createPublicClient, http } from 'viem'\n * import { mainnet } from 'viem/chains'\n * import { getTransaction } from 'viem/public'\n *\n * const client = createPublicClient({\n * chain: mainnet,\n * transport: http(),\n * })\n * const transaction = await getTransaction(client, {\n * hash: '0x4ca7ee652d57678f26e887c149ab0735f41de37bcad58c9f6d3ed5824f15b74d',\n * })\n */\nexport async function getTransaction<\n chain extends Chain | undefined,\n blockTag extends BlockTag = 'latest',\n>(\n client: Client<Transport, chain>,\n {\n blockHash,\n blockNumber,\n blockTag: blockTag_,\n hash,\n index,\n }: GetTransactionParameters<blockTag>,\n): Promise<GetTransactionReturnType<chain, blockTag>> {\n const blockTag = blockTag_ || 'latest'\n\n const blockNumberHex =\n blockNumber !== undefined ? numberToHex(blockNumber) : undefined\n\n let transaction: RpcTransaction | null = null\n if (hash) {\n transaction = await client.request(\n {\n method: 'eth_getTransactionByHash',\n params: [hash],\n },\n { dedupe: true },\n )\n } else if (blockHash) {\n transaction = await client.request(\n {\n method: 'eth_getTransactionByBlockHashAndIndex',\n params: [blockHash, numberToHex(index)],\n },\n { dedupe: true },\n )\n } else if (blockNumberHex || blockTag) {\n transaction = await client.request(\n {\n method: 'eth_getTransactionByBlockNumberAndIndex',\n params: [blockNumberHex || blockTag, numberToHex(index)],\n },\n { dedupe: Boolean(blockNumberHex) },\n )\n }\n\n if (!transaction)\n throw new TransactionNotFoundError({\n blockHash,\n blockNumber,\n blockTag,\n hash,\n index,\n })\n\n const format =\n client.chain?.formatters?.transaction?.format || formatTransaction\n return format(transaction)\n}\n", "import type { Client } from '../../clients/createClient.js'\nimport type { Transport } from '../../clients/transports/createTransport.js'\nimport type { ErrorType } from '../../errors/utils.js'\nimport type { Chain } from '../../types/chain.js'\nimport type { Hash } from '../../types/misc.js'\nimport type { FormattedTransactionReceipt } from '../../utils/formatters/transactionReceipt.js'\nimport { getAction } from '../../utils/getAction.js'\n\nimport {\n type GetBlockNumberErrorType,\n getBlockNumber,\n} from './getBlockNumber.js'\nimport {\n type GetTransactionErrorType,\n getTransaction,\n} from './getTransaction.js'\n\nexport type GetTransactionConfirmationsParameters<\n chain extends Chain | undefined = Chain,\n> =\n | {\n /** The transaction hash. */\n hash: Hash\n transactionReceipt?: undefined\n }\n | {\n hash?: undefined\n /** The transaction receipt. */\n transactionReceipt: FormattedTransactionReceipt<chain>\n }\n\nexport type GetTransactionConfirmationsReturnType = bigint\n\nexport type GetTransactionConfirmationsErrorType =\n | GetBlockNumberErrorType\n | GetTransactionErrorType\n | ErrorType\n\n/**\n * Returns the number of blocks passed (confirmations) since the transaction was processed on a block.\n *\n * - Docs: https://viem.sh/docs/actions/public/getTransactionConfirmations\n * - Example: https://stackblitz.com/github/wevm/viem/tree/main/examples/transactions_fetching-transactions\n * - JSON-RPC Methods: [`eth_getTransactionConfirmations`](https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_getTransactionConfirmations)\n *\n * @param client - Client to use\n * @param parameters - {@link GetTransactionConfirmationsParameters}\n * @returns The number of blocks passed since the transaction was processed. If confirmations is 0, then the Transaction has not been confirmed & processed yet. {@link GetTransactionConfirmationsReturnType}\n *\n * @example\n * import { createPublicClient, http } from 'viem'\n * import { mainnet } from 'viem/chains'\n * import { getTransactionConfirmations } from 'viem/public'\n *\n * const client = createPublicClient({\n * chain: mainnet,\n * transport: http(),\n * })\n * const confirmations = await getTransactionConfirmations(client, {\n * hash: '0x4ca7ee652d57678f26e887c149ab0735f41de37bcad58c9f6d3ed5824f15b74d',\n * })\n */\nexport async function getTransactionConfirmations<\n chain extends Chain | undefined,\n>(\n client: Client<Transport, chain>,\n { hash, transactionReceipt }: GetTransactionConfirmationsParameters<chain>,\n): Promise<GetTransactionConfirmationsReturnType> {\n const [blockNumber, transaction] = await Promise.all([\n getAction(client, getBlockNumber, 'getBlockNumber')({}),\n hash\n ? getAction(client, getTransaction, 'getTransaction')({ hash })\n : undefined,\n ])\n const transactionBlockNumber =\n transactionReceipt?.blockNumber || transaction?.blockNumber\n if (!transactionBlockNumber) return 0n\n return blockNumber - transactionBlockNumber! + 1n\n}\n", "import type { Client } from '../../clients/createClient.js'\nimport type { Transport } from '../../clients/transports/createTransport.js'\nimport {\n TransactionReceiptNotFoundError,\n type TransactionReceiptNotFoundErrorType,\n} from '../../errors/transaction.js'\nimport type { ErrorType } from '../../errors/utils.js'\nimport type { Chain } from '../../types/chain.js'\nimport type { Hash } from '../../types/misc.js'\nimport type { RequestErrorType } from '../../utils/buildRequest.js'\nimport {\n type FormattedTransactionReceipt,\n formatTransactionReceipt,\n} from '../../utils/formatters/transactionReceipt.js'\n\nexport type GetTransactionReceiptParameters = {\n /** The hash of the transaction. */\n hash: Hash\n}\n\nexport type GetTransactionReceiptReturnType<\n chain extends Chain | undefined = undefined,\n> = FormattedTransactionReceipt<chain>\n\nexport type GetTransactionReceiptErrorType =\n | RequestErrorType\n | TransactionReceiptNotFoundErrorType\n | ErrorType\n\n/**\n * Returns the [Transaction Receipt](https://viem.sh/docs/glossary/terms#transaction-receipt) given a [Transaction](https://viem.sh/docs/glossary/terms#transaction) hash.\n *\n * - Docs: https://viem.sh/docs/actions/public/getTransactionReceipt\n * - Example: https://stackblitz.com/github/wevm/viem/tree/main/examples/transactions_fetching-transactions\n * - JSON-RPC Methods: [`eth_getTransactionReceipt`](https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_gettransactionreceipt)\n *\n * @param client - Client to use\n * @param parameters - {@link GetTransactionReceiptParameters}\n * @returns The transaction receipt. {@link GetTransactionReceiptReturnType}\n *\n * @example\n * import { createPublicClient, http } from 'viem'\n * import { mainnet } from 'viem/chains'\n * import { getTransactionReceipt } from 'viem/public'\n *\n * const client = createPublicClient({\n * chain: mainnet,\n * transport: http(),\n * })\n * const transactionReceipt = await getTransactionReceipt(client, {\n * hash: '0x4ca7ee652d57678f26e887c149ab0735f41de37bcad58c9f6d3ed5824f15b74d',\n * })\n */\nexport async function getTransactionReceipt<chain extends Chain | undefined>(\n client: Client<Transport, chain>,\n { hash }: GetTransactionReceiptParameters,\n) {\n const receipt = await client.request(\n {\n method: 'eth_getTransactionReceipt',\n params: [hash],\n },\n { dedupe: true },\n )\n\n if (!receipt) throw new TransactionReceiptNotFoundError({ hash })\n\n const format =\n client.chain?.formatters?.transactionReceipt?.format ||\n formatTransactionReceipt\n return format(receipt) as GetTransactionReceiptReturnType<chain>\n}\n", "import type { AbiStateMutability, Address, Narrow } from 'abitype'\n\nimport type { Client } from '../../clients/createClient.js'\nimport type { Transport } from '../../clients/transports/createTransport.js'\nimport { multicall3Abi } from '../../constants/abis.js'\nimport { AbiDecodingZeroDataError } from '../../errors/abi.js'\nimport { BaseError } from '../../errors/base.js'\nimport { RawContractError } from '../../errors/contract.js'\nimport type { Chain } from '../../types/chain.js'\nimport type { ContractFunctionParameters } from '../../types/contract.js'\nimport type { Hex } from '../../types/misc.js'\nimport type {\n MulticallContracts,\n MulticallResults,\n} from '../../types/multicall.js'\nimport {\n type DecodeFunctionResultErrorType,\n decodeFunctionResult,\n} from '../../utils/abi/decodeFunctionResult.js'\nimport {\n type EncodeFunctionDataErrorType,\n encodeFunctionData,\n} from '../../utils/abi/encodeFunctionData.js'\nimport {\n type GetChainContractAddressErrorType,\n getChainContractAddress,\n} from '../../utils/chain/getChainContractAddress.js'\nimport {\n type GetContractErrorReturnType,\n getContractError,\n} from '../../utils/errors/getContractError.js'\n\nimport type { ErrorType } from '../../errors/utils.js'\nimport { getAction } from '../../utils/getAction.js'\nimport type { CallParameters } from './call.js'\nimport { type ReadContractErrorType, readContract } from './readContract.js'\n\nexport type MulticallParameters<\n contracts extends readonly unknown[] = readonly ContractFunctionParameters[],\n allowFailure extends boolean = true,\n options extends {\n optional?: boolean\n properties?: Record<string, any>\n } = {},\n> = Pick<CallParameters, 'blockNumber' | 'blockTag' | 'stateOverride'> & {\n allowFailure?: allowFailure | boolean | undefined\n batchSize?: number | undefined\n contracts: MulticallContracts<\n Narrow<contracts>,\n { mutability: AbiStateMutability } & options\n >\n multicallAddress?: Address | undefined\n}\n\nexport type MulticallReturnType<\n contracts extends readonly unknown[] = readonly ContractFunctionParameters[],\n allowFailure extends boolean = true,\n options extends {\n error?: Error\n } = { error: Error },\n> = MulticallResults<\n Narrow<contracts>,\n allowFailure,\n { mutability: AbiStateMutability } & options\n>\n\nexport type MulticallErrorType =\n | GetChainContractAddressErrorType\n | ReadContractErrorType\n | GetContractErrorReturnType<\n EncodeFunctionDataErrorType | DecodeFunctionResultErrorType\n >\n | ErrorType\n\n/**\n * Similar to [`readContract`](https://viem.sh/docs/contract/readContract), but batches up multiple functions on a contract in a single RPC call via the [`multicall3` contract](https://github.com/mds1/multicall).\n *\n * - Docs: https://viem.sh/docs/contract/multicall\n *\n * @param client - Client to use\n * @param parameters - {@link MulticallParameters}\n * @returns An array of results with accompanying status. {@link MulticallReturnType}\n *\n * @example\n * import { createPublicClient, http, parseAbi } from 'viem'\n * import { mainnet } from 'viem/chains'\n * import { multicall } from 'viem/contract'\n *\n * const client = createPublicClient({\n * chain: mainnet,\n * transport: http(),\n * })\n * const abi = parseAbi([\n * 'function balanceOf(address) view returns (uint256)',\n * 'function totalSupply() view returns (uint256)',\n * ])\n * const results = await multicall(client, {\n * contracts: [\n * {\n * address: '0xFBA3912Ca04dd458c843e2EE08967fC04f3579c2',\n * abi,\n * functionName: 'balanceOf',\n * args: ['0xA0Cf798816D4b9b9866b5330EEa46a18382f251e'],\n * },\n * {\n * address: '0xFBA3912Ca04dd458c843e2EE08967fC04f3579c2',\n * abi,\n * functionName: 'totalSupply',\n * },\n * ],\n * })\n * // [{ result: 424122n, status: 'success' }, { result: 1000000n, status: 'success' }]\n */\nexport async function multicall<\n const contracts extends readonly unknown[],\n chain extends Chain | undefined,\n allowFailure extends boolean = true,\n>(\n client: Client<Transport, chain>,\n parameters: MulticallParameters<contracts, allowFailure>,\n): Promise<MulticallReturnType<contracts, allowFailure>> {\n const {\n allowFailure = true,\n batchSize: batchSize_,\n blockNumber,\n blockTag,\n multicallAddress: multicallAddress_,\n stateOverride,\n } = parameters\n const contracts = parameters.contracts as ContractFunctionParameters[]\n\n const batchSize =\n batchSize_ ??\n ((typeof client.batch?.multicall === 'object' &&\n client.batch.multicall.batchSize) ||\n 1_024)\n\n let multicallAddress = multicallAddress_\n if (!multicallAddress) {\n if (!client.chain)\n throw new Error(\n 'client chain not configured. multicallAddress is required.',\n )\n\n multicallAddress = getChainContractAddress({\n blockNumber,\n chain: client.chain,\n contract: 'multicall3',\n })\n }\n\n type Aggregate3Calls = {\n allowFailure: boolean\n callData: Hex\n target: Address\n }[]\n\n const chunkedCalls: Aggregate3Calls[] = [[]]\n let currentChunk = 0\n let currentChunkSize = 0\n for (let i = 0; i < contracts.length; i++) {\n const { abi, address, args, functionName } = contracts[i]\n try {\n const callData = encodeFunctionData({ abi, args, functionName })\n\n currentChunkSize += (callData.length - 2) / 2\n // Check to see if we need to create a new chunk.\n if (\n // Check if batching is enabled.\n batchSize > 0 &&\n // Check if the current size of the batch exceeds the size limit.\n currentChunkSize > batchSize &&\n // Check if the current chunk is not already empty.\n chunkedCalls[currentChunk].length > 0\n ) {\n currentChunk++\n currentChunkSize = (callData.length - 2) / 2\n chunkedCalls[currentChunk] = []\n }\n\n chunkedCalls[currentChunk] = [\n ...chunkedCalls[currentChunk],\n {\n allowFailure: true,\n callData,\n target: address,\n },\n ]\n } catch (err) {\n const error = getContractError(err as BaseError, {\n abi,\n address,\n args,\n docsPath: '/docs/contract/multicall',\n functionName,\n })\n if (!allowFailure) throw error\n chunkedCalls[currentChunk] = [\n ...chunkedCalls[currentChunk],\n {\n allowFailure: true,\n callData: '0x' as Hex,\n target: address,\n },\n ]\n }\n }\n\n const aggregate3Results = await Promise.allSettled(\n chunkedCalls.map((calls) =>\n getAction(\n client,\n readContract,\n 'readContract',\n )({\n abi: multicall3Abi,\n address: multicallAddress!,\n args: [calls],\n blockNumber,\n blockTag,\n functionName: 'aggregate3',\n stateOverride,\n }),\n ),\n )\n\n const results = []\n for (let i = 0; i < aggregate3Results.length; i++) {\n const result = aggregate3Results[i]\n\n // If an error occurred in a `readContract` invocation (ie. network error),\n // then append the failure reason to each contract result.\n if (result.status === 'rejected') {\n if (!allowFailure) throw result.reason\n for (let j = 0; j < chunkedCalls[i].length; j++) {\n results.push({\n status: 'failure',\n error: result.reason,\n result: undefined,\n })\n }\n continue\n }\n\n // If the `readContract` call was successful, then decode the results.\n const aggregate3Result = result.value\n for (let j = 0; j < aggregate3Result.length; j++) {\n // Extract the response from `readContract`\n const { returnData, success } = aggregate3Result[j]\n\n // Extract the request call data from the original call.\n const { callData } = chunkedCalls[i][j]\n\n // Extract the contract config for this call from the `contracts` argument\n // for decoding.\n const { abi, address, functionName, args } = contracts[\n results.length\n ] as ContractFunctionParameters\n\n try {\n if (callData === '0x') throw new AbiDecodingZeroDataError()\n if (!success) throw new RawContractError({ data: returnData })\n const result = decodeFunctionResult({\n abi,\n args,\n data: returnData,\n functionName,\n })\n results.push(allowFailure ? { result, status: 'success' } : result)\n } catch (err) {\n const error = getContractError(err as BaseError, {\n abi,\n address,\n args,\n docsPath: '/docs/contract/multicall',\n functionName,\n })\n if (!allowFailure) throw error\n results.push({ error, result: undefined, status: 'failure' })\n }\n }\n }\n\n if (results.length !== contracts.length)\n throw new BaseError('multicall results mismatch')\n return results as MulticallReturnType<contracts, allowFailure>\n}\n", "/** @internal */\nexport const version = '0.1.1'\n", "import { version } from '../version.js'\n\n/** @internal */\nexport function getUrl(url: string) {\n return url\n}\n\n/** @internal */\nexport function getVersion() {\n return version\n}\n\n/** @internal */\nexport function prettyPrint(args: unknown) {\n if (!args) return ''\n const entries = Object.entries(args)\n .map(([key, value]) => {\n if (value === undefined || value === false) return null\n return [key, value]\n })\n .filter(Boolean) as [string, string][]\n const maxLength = entries.reduce((acc, [key]) => Math.max(acc, key.length), 0)\n return entries\n .map(([key, value]) => ` ${`${key}:`.padEnd(maxLength + 1)} ${value}`)\n .join('\\n')\n}\n", "import { getVersion } from './internal/errors.js'\n\nexport type GlobalErrorType<name extends string = 'Error'> = Error & {\n name: name\n}\n\n/**\n * Base error class inherited by all errors thrown by ox.\n *\n * @example\n * ```ts\n * import { Errors } from 'ox'\n * throw new Errors.BaseError('An error occurred')\n * ```\n */\nexport class BaseError<\n cause extends Error | undefined = undefined,\n> extends Error {\n details: string\n docs?: string | undefined\n docsPath?: string | undefined\n shortMessage: string\n\n override cause: cause\n override name = 'BaseError'\n\n version = `ox@${getVersion()}`\n\n constructor(shortMessage: string, options: BaseError.Options<cause> = {}) {\n const details = (() => {\n if (options.cause instanceof BaseError) {\n if (options.cause.details) return options.cause.details\n if (options.cause.shortMessage) return options.cause.shortMessage\n }\n if (options.cause?.message) return options.cause.message\n return options.details!\n })()\n const docsPath = (() => {\n if (options.cause instanceof BaseError)\n return options.cause.docsPath || options.docsPath\n return options.docsPath\n })()\n\n const docsBaseUrl = 'https://oxlib.sh'\n const docs = `${docsBaseUrl}${docsPath ?? ''}`\n\n const message = [\n shortMessage || 'An error occurred.',\n ...(options.metaMessages ? ['', ...options.metaMessages] : []),\n ...(details || docsPath\n ? [\n '',\n details ? `Details: ${details}` : undefined,\n docsPath ? `See: ${docs}` : undefined,\n ]\n : []),\n ]\n .filter((x) => typeof x === 'string')\n .join('\\n')\n\n super(message, options.cause ? { cause: options.cause } : undefined)\n\n this.cause = options.cause as any\n this.details = details\n this.docs = docs\n this.docsPath = docsPath\n this.shortMessage = shortMessage\n }\n\n walk(): Error\n walk(fn: (err: unknown) => boolean): Error | null\n walk(fn?: any): any {\n return walk(this, fn)\n }\n}\n\nexport declare namespace BaseError {\n type Options<cause extends Error | undefined = Error | undefined> = {\n cause?: cause | undefined\n details?: string | undefined\n docsPath?: string | undefined\n metaMessages?: (string | undefined)[] | undefined\n }\n}\n\n/** @internal */\nfunction walk(\n err: unknown,\n fn?: ((err: unknown) => boolean) | undefined,\n): unknown {\n if (fn?.(err)) return err\n if (err && typeof err === 'object' && 'cause' in err && err.cause)\n return walk(err.cause, fn)\n return fn ? null : err\n}\n", "import type * as Errors from './Errors.js'\n\nconst bigIntSuffix = '#__bigint'\n\n/**\n * Parses a JSON string, with support for `bigint`.\n *\n * @example\n * ```ts twoslash\n * import { Json } from 'ox'\n *\n * const json = Json.parse('{\"foo\":\"bar\",\"baz\":\"69420694206942069420694206942069420694206942069420#__bigint\"}')\n * // @log: {\n * // @log: foo: 'bar',\n * // @log: baz: 69420694206942069420694206942069420694206942069420n\n * // @log: }\n * ```\n *\n * @param string - The value to parse.\n * @param reviver - A function that transforms the results.\n * @returns The parsed value.\n */\nexport function parse(\n string: string,\n reviver?: ((this: any, key: string, value: any) => any) | undefined,\n) {\n return JSON.parse(string, (key, value_) => {\n const value = value_\n if (typeof value === 'string' && value.endsWith(bigIntSuffix))\n return BigInt(value.slice(0, -bigIntSuffix.length))\n return typeof reviver === 'function' ? reviver(key, value) : value\n })\n}\n\nexport declare namespace parse {\n type ErrorType = Errors.GlobalErrorType\n}\n\n/**\n * Stringifies a value to its JSON representation, with support for `bigint`.\n *\n * @example\n * ```ts twoslash\n * import { Json } from 'ox'\n *\n * const json = Json.stringify({\n * foo: 'bar',\n * baz: 69420694206942069420694206942069420694206942069420n,\n * })\n * // @log: '{\"foo\":\"bar\",\"baz\":\"69420694206942069420694206942069420694206942069420#__bigint\"}'\n * ```\n *\n * @param value - The value to stringify.\n * @param replacer - A function that transforms the results. It is passed the key and value of the property, and must return the value to be used in the JSON string. If this function returns `undefined`, the property is not included in the resulting JSON string.\n * @param space - A string or number that determines the indentation of the JSON string. If it is a number, it indicates the number of spaces to use as indentation; if it is a string (e.g. `'\\t'`), it uses the string as the indentation character.\n * @returns The JSON string.\n */\nexport function stringify(\n value: any,\n replacer?: ((this: any, key: string, value: any) => any) | null | undefined,\n space?: string | number | undefined,\n) {\n return JSON.stringify(\n value,\n (key, value) => {\n if (typeof replacer === 'function') return replacer(key, value)\n if (typeof value === 'bigint') return value.toString() + bigIntSuffix\n return value\n },\n space,\n )\n}\n\nexport declare namespace stringify {\n type ErrorType = Errors.GlobalErrorType\n}\n", "import * as Bytes from '../Bytes.js'\nimport type * as Errors from '../Errors.js'\n\n/** @internal */\nexport function assertSize(bytes: Bytes.Bytes, size_: number): void {\n if (Bytes.size(bytes) > size_)\n throw new Bytes.SizeOverflowError({\n givenSize: Bytes.size(bytes),\n maxSize: size_,\n })\n}\n\n/** @internal */\nexport declare namespace assertSize {\n type ErrorType =\n | Bytes.size.ErrorType\n | Bytes.SizeOverflowError\n | Errors.GlobalErrorType\n}\n\n/** @internal */\nexport function assertStartOffset(\n value: Bytes.Bytes,\n start?: number | undefined,\n) {\n if (typeof start === 'number' && start > 0 && start > Bytes.size(value) - 1)\n throw new Bytes.SliceOffsetOutOfBoundsError({\n offset: start,\n position: 'start',\n size: Bytes.size(value),\n })\n}\n\nexport declare namespace assertStartOffset {\n export type ErrorType =\n | Bytes.SliceOffsetOutOfBoundsError\n | Bytes.size.ErrorType\n | Errors.GlobalErrorType\n}\n\n/** @internal */\nexport function assertEndOffset(\n value: Bytes.Bytes,\n start?: number | undefined,\n end?: number | undefined,\n) {\n if (\n typeof start === 'number' &&\n typeof end === 'number' &&\n Bytes.size(value) !== end - start\n ) {\n throw new Bytes.SliceOffsetOutOfBoundsError({\n offset: end,\n position: 'end',\n size: Bytes.size(value),\n })\n }\n}\n\n/** @internal */\nexport declare namespace assertEndOffset {\n type ErrorType =\n | Bytes.SliceOffsetOutOfBoundsError\n | Bytes.size.ErrorType\n | Errors.GlobalErrorType\n}\n\n/** @internal */\nexport const charCodeMap = {\n zero: 48,\n nine: 57,\n A: 65,\n F: 70,\n a: 97,\n f: 102,\n} as const\n\n/** @internal */\nexport function charCodeToBase16(char: number) {\n if (char >= charCodeMap.zero && char <= charCodeMap.nine)\n return char - charCodeMap.zero\n if (char >= charCodeMap.A && char <= charCodeMap.F)\n return char - (charCodeMap.A - 10)\n if (char >= charCodeMap.a && char <= charCodeMap.f)\n return char - (charCodeMap.a - 10)\n return undefined\n}\n\n/** @internal */\nexport function pad(bytes: Bytes.Bytes, options: pad.Options = {}) {\n const { dir, size = 32 } = options\n if (size === 0) return bytes\n if (bytes.length > size)\n throw new Bytes.SizeExceedsPaddingSizeError({\n size: bytes.length,\n targetSize: size,\n type: 'Bytes',\n })\n const paddedBytes = new Uint8Array(size)\n for (let i = 0; i < size; i++) {\n const padEnd = dir === 'right'\n paddedBytes[padEnd ? i : size - i - 1] =\n bytes[padEnd ? i : bytes.length - i - 1]!\n }\n return paddedBytes\n}\n\n/** @internal */\nexport declare namespace pad {\n type Options = {\n dir?: 'left' | 'right' | undefined\n size?: number | undefined\n }\n\n type ReturnType = Bytes.Bytes\n\n type ErrorType = Bytes.SizeExceedsPaddingSizeError | Errors.GlobalErrorType\n}\n\n/** @internal */\nexport function trim(\n value: Bytes.Bytes,\n options: trim.Options = {},\n): trim.ReturnType {\n const { dir = 'left' } = options\n\n let data = value\n\n let sliceLength = 0\n for (let i = 0; i < data.length - 1; i++) {\n if (data[dir === 'left' ? i : data.length - i - 1]!.toString() === '0')\n sliceLength++\n else break\n }\n data =\n dir === 'left'\n ? data.slice(sliceLength)\n : data.slice(0, data.length - sliceLength)\n\n return data as trim.ReturnType\n}\n\n/** @internal */\nexport declare namespace trim {\n type Options = {\n dir?: 'left' | 'right' | undefined\n }\n\n type ReturnType = Bytes.Bytes\n\n type ErrorType = Errors.GlobalErrorType\n}\n", "import type * as Errors from '../Errors.js'\nimport * as Hex from '../Hex.js'\n\n/** @internal */\nexport function assertSize(hex: Hex.Hex, size_: number): void {\n if (Hex.size(hex) > size_)\n throw new Hex.SizeOverflowError({\n givenSize: Hex.size(hex),\n maxSize: size_,\n })\n}\n\n/** @internal */\nexport declare namespace assertSize {\n type ErrorType =\n | Hex.size.ErrorType\n | Hex.SizeOverflowError\n | Errors.GlobalErrorType\n}\n\n/** @internal */\nexport function assertStartOffset(value: Hex.Hex, start?: number | undefined) {\n if (typeof start === 'number' && start > 0 && start > Hex.size(value) - 1)\n throw new Hex.SliceOffsetOutOfBoundsError({\n offset: start,\n position: 'start',\n size: Hex.size(value),\n })\n}\n\nexport declare namespace assertStartOffset {\n type ErrorType =\n | Hex.SliceOffsetOutOfBoundsError\n | Hex.size.ErrorType\n | Errors.GlobalErrorType\n}\n\n/** @internal */\nexport function assertEndOffset(\n value: Hex.Hex,\n start?: number | undefined,\n end?: number | undefined,\n) {\n if (\n typeof start === 'number' &&\n typeof end === 'number' &&\n Hex.size(value) !== end - start\n ) {\n throw new Hex.SliceOffsetOutOfBoundsError({\n offset: end,\n position: 'end',\n size: Hex.size(value),\n })\n }\n}\n\nexport declare namespace assertEndOffset {\n type ErrorType =\n | Hex.SliceOffsetOutOfBoundsError\n | Hex.size.ErrorType\n | Errors.GlobalErrorType\n}\n\n/** @internal */\nexport function pad(hex_: Hex.Hex, options: pad.Options = {}) {\n const { dir, size = 32 } = options\n\n if (size === 0) return hex_\n\n const hex = hex_.replace('0x', '')\n if (hex.length > size * 2)\n throw new Hex.SizeExceedsPaddingSizeError({\n size: Math.ceil(hex.length / 2),\n targetSize: size,\n type: 'Hex',\n })\n\n return `0x${hex[dir === 'right' ? 'padEnd' : 'padStart'](size * 2, '0')}` as Hex.Hex\n}\n\n/** @internal */\nexport declare namespace pad {\n type Options = {\n dir?: 'left' | 'right' | undefined\n size?: number | undefined\n }\n type ErrorType = Hex.SizeExceedsPaddingSizeError | Errors.GlobalErrorType\n}\n\n/** @internal */\nexport function trim(\n value: Hex.Hex,\n options: trim.Options = {},\n): trim.ReturnType {\n const { dir = 'left' } = options\n\n let data = value.replace('0x', '')\n\n let sliceLength = 0\n for (let i = 0; i < data.length - 1; i++) {\n if (data[dir === 'left' ? i : data.length - i - 1]!.toString() === '0')\n sliceLength++\n else break\n }\n data =\n dir === 'left'\n ? data.slice(sliceLength)\n : data.slice(0, data.length - sliceLength)\n\n if (data === '0') return '0x'\n if (dir === 'right' && data.length % 2 === 1) return `0x${data}0`\n return `0x${data}` as trim.ReturnType\n}\n\n/** @internal */\nexport declare namespace trim {\n type Options = {\n dir?: 'left' | 'right' | undefined\n }\n\n type ReturnType = Hex.Hex\n\n type ErrorType = Errors.GlobalErrorType\n}\n", "import { equalBytes } from '@noble/curves/abstract/utils'\nimport * as Errors from './Errors.js'\nimport * as Hex from './Hex.js'\nimport * as Json from './Json.js'\nimport * as internal from './internal/bytes.js'\nimport * as internal_hex from './internal/hex.js'\n\nconst decoder = /*#__PURE__*/ new TextDecoder()\nconst encoder = /*#__PURE__*/ new TextEncoder()\n\n/** Root type for a Bytes array. */\nexport type Bytes = Uint8Array\n\n/**\n * Asserts if the given value is {@link ox#Bytes.Bytes}.\n *\n * @example\n * ```ts twoslash\n * import { Bytes } from 'ox'\n *\n * Bytes.assert('abc')\n * // @error: Bytes.InvalidBytesTypeError:\n * // @error: Value `\"abc\"` of type `string` is an invalid Bytes value.\n * // @error: Bytes values must be of type `Uint8Array`.\n * ```\n *\n * @param value - Value to assert.\n */\nexport function assert(value: unknown): asserts value is Bytes {\n if (value instanceof Uint8Array) return\n if (!value) throw new InvalidBytesTypeError(value)\n if (typeof value !== 'object') throw new InvalidBytesTypeError(value)\n if (!('BYTES_PER_ELEMENT' in value)) throw new InvalidBytesTypeError(value)\n if (value.BYTES_PER_ELEMENT !== 1 || value.constructor.name !== 'Uint8Array')\n throw new InvalidBytesTypeError(value)\n}\n\nexport declare namespace assert {\n type ErrorType = InvalidBytesTypeError | Errors.GlobalErrorType\n}\n\n/**\n * Concatenates two or more {@link ox#Bytes.Bytes}.\n *\n * @example\n * ```ts twoslash\n * import { Bytes } from 'ox'\n *\n * const bytes = Bytes.concat(\n * Bytes.from([1]),\n * Bytes.from([69]),\n * Bytes.from([420, 69]),\n * )\n * // @log: Uint8Array [ 1, 69, 420, 69 ]\n * ```\n *\n * @param values - Values to concatenate.\n * @returns Concatenated {@link ox#Bytes.Bytes}.\n */\nexport function concat(...values: readonly Bytes[]): Bytes {\n let length = 0\n for (const arr of values) {\n length += arr.length\n }\n const result = new Uint8Array(length)\n for (let i = 0, index = 0; i < values.length; i++) {\n const arr = values[i]\n result.set(arr!, index)\n index += arr!.length\n }\n return result\n}\n\nexport declare namespace concat {\n type ErrorType = Errors.GlobalErrorType\n}\n\n/**\n * Instantiates a {@link ox#Bytes.Bytes} value from a `Uint8Array`, a hex string, or an array of unsigned 8-bit integers.\n *\n * :::tip\n *\n * To instantiate from a **Boolean**, **String**, or **Number**, use one of the following:\n *\n * - `Bytes.fromBoolean`\n *\n * - `Bytes.fromString`\n *\n * - `Bytes.fromNumber`\n *\n * :::\n *\n * @example\n * ```ts twoslash\n * // @noErrors\n * import { Bytes } from 'ox'\n *\n * const data = Bytes.from([255, 124, 5, 4])\n * // @log: Uint8Array([255, 124, 5, 4])\n *\n * const data = Bytes.from('0xdeadbeef')\n * // @log: Uint8Array([222, 173, 190, 239])\n * ```\n *\n * @param value - Value to convert.\n * @returns A {@link ox#Bytes.Bytes} instance.\n */\nexport function from(value: Hex.Hex | Bytes | readonly number[]): Bytes {\n if (value instanceof Uint8Array) return value\n if (typeof value === 'string') return fromHex(value)\n return fromArray(value)\n}\n\nexport declare namespace from {\n type ErrorType =\n | fromHex.ErrorType\n | fromArray.ErrorType\n | Errors.GlobalErrorType\n}\n\n/**\n * Converts an array of unsigned 8-bit integers into {@link ox#Bytes.Bytes}.\n *\n * @example\n * ```ts twoslash\n * import { Bytes } from 'ox'\n *\n * const data = Bytes.fromArray([255, 124, 5, 4])\n * // @log: Uint8Array([255, 124, 5, 4])\n * ```\n *\n * @param value - Value to convert.\n * @returns A {@link ox#Bytes.Bytes} instance.\n */\nexport function fromArray(value: readonly number[] | Uint8Array): Bytes {\n return value instanceof Uint8Array ? value : new Uint8Array(value)\n}\n\nexport declare namespace fromArray {\n type ErrorType = Errors.GlobalErrorType\n}\n\n/**\n * Encodes a boolean value into {@link ox#Bytes.Bytes}.\n *\n * @example\n * ```ts twoslash\n * import { Bytes } from 'ox'\n *\n * const data = Bytes.fromBoolean(true)\n * // @log: Uint8Array([1])\n * ```\n *\n * @example\n * ```ts twoslash\n * import { Bytes } from 'ox'\n *\n * const data = Bytes.fromBoolean(true, { size: 32 })\n * // @log: Uint8Array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1])\n * ```\n *\n * @param value - Boolean value to encode.\n * @param options - Encoding options.\n * @returns Encoded {@link ox#Bytes.Bytes}.\n */\nexport function fromBoolean(value: boolean, options: fromBoolean.Options = {}) {\n const { size } = options\n const bytes = new Uint8Array(1)\n bytes[0] = Number(value)\n if (typeof size === 'number') {\n internal.assertSize(bytes, size)\n return padLeft(bytes, size)\n }\n return bytes\n}\n\nexport declare namespace fromBoolean {\n type Options = {\n /** Size of the output bytes. */\n size?: number | undefined\n }\n\n type ErrorType =\n | internal.assertSize.ErrorType\n | padLeft.ErrorType\n | Errors.GlobalErrorType\n}\n\n/**\n * Encodes a {@link ox#Hex.Hex} value into {@link ox#Bytes.Bytes}.\n *\n * @example\n * ```ts twoslash\n * import { Bytes } from 'ox'\n *\n * const data = Bytes.fromHex('0x48656c6c6f20776f726c6421')\n * // @log: Uint8Array([72, 101, 108, 108, 111, 32, 87, 111, 114, 108, 100, 33])\n * ```\n *\n * @example\n * ```ts twoslash\n * import { Bytes } from 'ox'\n *\n * const data = Bytes.fromHex('0x48656c6c6f20776f726c6421', { size: 32 })\n * // @log: Uint8Array([72, 101, 108, 108, 111, 32, 87, 111, 114, 108, 100, 33, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0])\n * ```\n *\n * @param value - {@link ox#Hex.Hex} value to encode.\n * @param options - Encoding options.\n * @returns Encoded {@link ox#Bytes.Bytes}.\n */\nexport function fromHex(value: Hex.Hex, options: fromHex.Options = {}): Bytes {\n const { size } = options\n\n let hex = value\n if (size) {\n internal_hex.assertSize(value, size)\n hex = Hex.padRight(value, size)\n }\n\n let hexString = hex.slice(2) as string\n if (hexString.length % 2) hexString = `0${hexString}`\n\n const length = hexString.length / 2\n const bytes = new Uint8Array(length)\n for (let index = 0, j = 0; index < length; index++) {\n const nibbleLeft = internal.charCodeToBase16(hexString.charCodeAt(j++))\n const nibbleRight = internal.charCodeToBase16(hexString.charCodeAt(j++))\n if (nibbleLeft === undefined || nibbleRight === undefined) {\n throw new Errors.BaseError(\n `Invalid byte sequence (\"${hexString[j - 2]}${hexString[j - 1]}\" in \"${hexString}\").`,\n )\n }\n bytes[index] = nibbleLeft * 16 + nibbleRight\n }\n return bytes\n}\n\nexport declare namespace fromHex {\n type Options = {\n /** Size of the output bytes. */\n size?: number | undefined\n }\n\n type ErrorType =\n | internal_hex.assertSize.ErrorType\n | Hex.padRight.ErrorType\n | Errors.GlobalErrorType\n}\n\n/**\n * Encodes a number value into {@link ox#Bytes.Bytes}.\n *\n * @example\n * ```ts twoslash\n * import { Bytes } from 'ox'\n *\n * const data = Bytes.fromNumber(420)\n * // @log: Uint8Array([1, 164])\n * ```\n *\n * @example\n * ```ts twoslash\n * import { Bytes } from 'ox'\n *\n * const data = Bytes.fromNumber(420, { size: 4 })\n * // @log: Uint8Array([0, 0, 1, 164])\n * ```\n *\n * @param value - Number value to encode.\n * @param options - Encoding options.\n * @returns Encoded {@link ox#Bytes.Bytes}.\n */\nexport function fromNumber(\n value: bigint | number,\n options?: fromNumber.Options | undefined,\n) {\n const hex = Hex.fromNumber(value, options)\n return fromHex(hex)\n}\n\nexport declare namespace fromNumber {\n export type Options = Hex.fromNumber.Options\n\n export type ErrorType =\n | Hex.fromNumber.ErrorType\n | fromHex.ErrorType\n | Errors.GlobalErrorType\n}\n\n/**\n * Encodes a string into {@link ox#Bytes.Bytes}.\n *\n * @example\n * ```ts twoslash\n * import { Bytes } from 'ox'\n *\n * const data = Bytes.fromString('Hello world!')\n * // @log: Uint8Array([72, 101, 108, 108, 111, 32, 119, 111, 114, 108, 100, 33])\n * ```\n *\n * @example\n * ```ts twoslash\n * import { Bytes } from 'ox'\n *\n * const data = Bytes.fromString('Hello world!', { size: 32 })\n * // @log: Uint8Array([72, 101, 108, 108, 111, 32, 87, 111, 114, 108, 100, 33, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0])\n * ```\n *\n * @param value - String to encode.\n * @param options - Encoding options.\n * @returns Encoded {@link ox#Bytes.Bytes}.\n */\nexport function fromString(\n value: string,\n options: fromString.Options = {},\n): Bytes {\n const { size } = options\n\n const bytes = encoder.encode(value)\n if (typeof size === 'number') {\n internal.assertSize(bytes, size)\n return padRight(bytes, size)\n }\n return bytes\n}\n\nexport declare namespace fromString {\n type Options = {\n /** Size of the output bytes. */\n size?: number | undefined\n }\n\n type ErrorType =\n | internal.assertSize.ErrorType\n | padRight.ErrorType\n | Errors.GlobalErrorType\n}\n\n/**\n * Checks if two {@link ox#Bytes.Bytes} values are equal.\n *\n * @example\n * ```ts twoslash\n * import { Bytes } from 'ox'\n *\n * Bytes.isEqual(Bytes.from([1]), Bytes.from([1]))\n * // @log: true\n *\n * Bytes.isEqual(Bytes.from([1]), Bytes.from([2]))\n * // @log: false\n * ```\n *\n * @param bytesA - First {@link ox#Bytes.Bytes} value.\n * @param bytesB - Second {@link ox#Bytes.Bytes} value.\n * @returns `true` if the two values are equal, otherwise `false`.\n */\nexport function isEqual(bytesA: Bytes, bytesB: Bytes) {\n return equalBytes(bytesA, bytesB)\n}\n\nexport declare namespace isEqual {\n type ErrorType = Errors.GlobalErrorType\n}\n\n/**\n * Pads a {@link ox#Bytes.Bytes} value to the left with zero bytes until it reaches the given `size` (default: 32 bytes).\n *\n * @example\n * ```ts twoslash\n * import { Bytes } from 'ox'\n *\n * Bytes.padLeft(Bytes.from([1]), 4)\n * // @log: Uint8Array([0, 0, 0, 1])\n * ```\n *\n * @param value - {@link ox#Bytes.Bytes} value to pad.\n * @param size - Size to pad the {@link ox#Bytes.Bytes} value to.\n * @returns Padded {@link ox#Bytes.Bytes} value.\n */\nexport function padLeft(\n value: Bytes,\n size?: number | undefined,\n): padLeft.ReturnType {\n return internal.pad(value, { dir: 'left', size })\n}\n\nexport declare namespace padLeft {\n type ReturnType = internal.pad.ReturnType\n type ErrorType = internal.pad.ErrorType | Errors.GlobalErrorType\n}\n\n/**\n * Pads a {@link ox#Bytes.Bytes} value to the right with zero bytes until it reaches the given `size` (default: 32 bytes).\n *\n * @example\n * ```ts twoslash\n * import { Bytes } from 'ox'\n *\n * Bytes.padRight(Bytes.from([1]), 4)\n * // @log: Uint8Array([1, 0, 0, 0])\n * ```\n *\n * @param value - {@link ox#Bytes.Bytes} value to pad.\n * @param size - Size to pad the {@link ox#Bytes.Bytes} value to.\n * @returns Padded {@link ox#Bytes.Bytes} value.\n */\nexport function padRight(\n value: Bytes,\n size?: number | undefined,\n): padRight.ReturnType {\n return internal.pad(value, { dir: 'right', size })\n}\n\nexport declare namespace padRight {\n type ReturnType = internal.pad.ReturnType\n type ErrorType = internal.pad.ErrorType | Errors.GlobalErrorType\n}\n\n/**\n * Generates random {@link ox#Bytes.Bytes} of the specified length.\n *\n * @example\n * ```ts twoslash\n * import { Bytes } from 'ox'\n *\n * const bytes = Bytes.random(32)\n * // @log: Uint8Array([... x32])\n * ```\n *\n * @param length - Length of the random {@link ox#Bytes.Bytes} to generate.\n * @returns Random {@link ox#Bytes.Bytes} of the specified length.\n */\nexport function random(length: number): Bytes {\n return crypto.getRandomValues(new Uint8Array(length))\n}\n\nexport declare namespace random {\n type ErrorType = Errors.GlobalErrorType\n}\n\n/**\n * Retrieves the size of a {@link ox#Bytes.Bytes} value.\n *\n * @example\n * ```ts twoslash\n * import { Bytes } from 'ox'\n *\n * Bytes.size(Bytes.from([1, 2, 3, 4]))\n * // @log: 4\n * ```\n *\n * @param value - {@link ox#Bytes.Bytes} value.\n * @returns Size of the {@link ox#Bytes.Bytes} value.\n */\nexport function size(value: Bytes): number {\n return value.length\n}\n\nexport declare namespace size {\n export type ErrorType = Errors.GlobalErrorType\n}\n\n/**\n * Returns a section of a {@link ox#Bytes.Bytes} value given a start/end bytes offset.\n *\n * @example\n * ```ts twoslash\n * import { Bytes } from 'ox'\n *\n * Bytes.slice(\n * Bytes.from([1, 2, 3, 4, 5, 6, 7, 8, 9]),\n * 1,\n * 4,\n * )\n * // @log: Uint8Array([2, 3, 4])\n * ```\n *\n * @param value - The {@link ox#Bytes.Bytes} value.\n * @param start - Start offset.\n * @param end - End offset.\n * @param options - Slice options.\n * @returns Sliced {@link ox#Bytes.Bytes} value.\n */\nexport function slice(\n value: Bytes,\n start?: number | undefined,\n end?: number | undefined,\n options: slice.Options = {},\n): Bytes {\n const { strict } = options\n internal.assertStartOffset(value, start)\n const value_ = value.slice(start, end)\n if (strict) internal.assertEndOffset(value_, start, end)\n return value_\n}\n\nexport declare namespace slice {\n type Options = {\n /** Asserts that the sliced value is the same size as the given start/end offsets. */\n strict?: boolean | undefined\n }\n\n export type ErrorType =\n | internal.assertStartOffset.ErrorType\n | internal.assertEndOffset.ErrorType\n | Errors.GlobalErrorType\n}\n\n/**\n * Decodes a {@link ox#Bytes.Bytes} into a bigint.\n *\n * @example\n * ```ts\n * import { Bytes } from 'ox'\n *\n * Bytes.toBigInt(Bytes.from([1, 164]))\n * // @log: 420n\n * ```\n *\n * @param bytes - The {@link ox#Bytes.Bytes} to decode.\n * @param options - Decoding options.\n * @returns Decoded bigint.\n */\nexport function toBigInt(bytes: Bytes, options: toBigInt.Options = {}): bigint {\n const { size } = options\n if (typeof size !== 'undefined') internal.assertSize(bytes, size)\n const hex = Hex.fromBytes(bytes, options)\n return Hex.toBigInt(hex, options)\n}\n\nexport declare namespace toBigInt {\n type Options = {\n /** Whether or not the number of a signed representation. */\n signed?: boolean | undefined\n /** Size of the bytes. */\n size?: number | undefined\n }\n\n type ErrorType =\n | Hex.fromBytes.ErrorType\n | Hex.toBigInt.ErrorType\n | Errors.GlobalErrorType\n}\n\n/**\n * Decodes a {@link ox#Bytes.Bytes} into a boolean.\n *\n * @example\n * ```ts\n * import { Bytes } from 'ox'\n *\n * Bytes.toBoolean(Bytes.from([1]))\n * // @log: true\n * ```\n *\n * @param bytes - The {@link ox#Bytes.Bytes} to decode.\n * @param options - Decoding options.\n * @returns Decoded boolean.\n */\nexport function toBoolean(\n bytes: Bytes,\n options: toBoolean.Options = {},\n): boolean {\n const { size } = options\n let bytes_ = bytes\n if (typeof size !== 'undefined') {\n internal.assertSize(bytes_, size)\n bytes_ = trimLeft(bytes_)\n }\n if (bytes_.length > 1 || bytes_[0]! > 1)\n throw new InvalidBytesBooleanError(bytes_)\n return Boolean(bytes_[0])\n}\n\nexport declare namespace toBoolean {\n type Options = {\n /** Size of the bytes. */\n size?: number | undefined\n }\n\n type ErrorType =\n | internal.assertSize.ErrorType\n | trimLeft.ErrorType\n | Errors.GlobalErrorType\n}\n\n/**\n * Encodes a {@link ox#Bytes.Bytes} value into a {@link ox#Hex.Hex} value.\n *\n * @example\n * ```ts twoslash\n * import { Bytes } from 'ox'\n *\n * Bytes.toHex(Bytes.from([72, 101, 108, 108, 111, 32, 87, 111, 114, 108, 100, 33]))\n * // '0x48656c6c6f20576f726c6421'\n * ```\n *\n * @param value - The {@link ox#Bytes.Bytes} to decode.\n * @param options - Options.\n * @returns Decoded {@link ox#Hex.Hex} value.\n */\nexport function toHex(value: Bytes, options: toHex.Options = {}): Hex.Hex {\n return Hex.fromBytes(value, options)\n}\n\nexport declare namespace toHex {\n type Options = {\n /** Size of the bytes. */\n size?: number | undefined\n }\n\n type ErrorType = Hex.fromBytes.ErrorType | Errors.GlobalErrorType\n}\n\n/**\n * Decodes a {@link ox#Bytes.Bytes} into a number.\n *\n * @example\n * ```ts twoslash\n * import { Bytes } from 'ox'\n *\n * Bytes.toNumber(Bytes.from([1, 164]))\n * // @log: 420\n * ```\n */\nexport function toNumber(bytes: Bytes, options: toNumber.Options = {}): number {\n const { size } = options\n if (typeof size !== 'undefined') internal.assertSize(bytes, size)\n const hex = Hex.fromBytes(bytes, options)\n return Hex.toNumber(hex, options)\n}\n\nexport declare namespace toNumber {\n type Options = {\n /** Whether or not the number of a signed representation. */\n signed?: boolean | undefined\n /** Size of the bytes. */\n size?: number | undefined\n }\n\n type ErrorType =\n | Hex.fromBytes.ErrorType\n | Hex.toNumber.ErrorType\n | Errors.GlobalErrorType\n}\n\n/**\n * Decodes a {@link ox#Bytes.Bytes} into a string.\n *\n * @example\n * ```ts twoslash\n * import { Bytes } from 'ox'\n *\n * const data = Bytes.toString(Bytes.from([72, 101, 108, 108, 111, 32, 87, 111, 114, 108, 100, 33]))\n * // @log: 'Hello world'\n * ```\n *\n * @param bytes - The {@link ox#Bytes.Bytes} to decode.\n * @param options - Options.\n * @returns Decoded string.\n */\nexport function toString(bytes: Bytes, options: toString.Options = {}): string {\n const { size } = options\n\n let bytes_ = bytes\n if (typeof size !== 'undefined') {\n internal.assertSize(bytes_, size)\n bytes_ = trimRight(bytes_)\n }\n return decoder.decode(bytes_)\n}\n\nexport declare namespace toString {\n export type Options = {\n /** Size of the bytes. */\n size?: number | undefined\n }\n\n export type ErrorType =\n | internal.assertSize.ErrorType\n | trimRight.ErrorType\n | Errors.GlobalErrorType\n}\n\n/**\n * Trims leading zeros from a {@link ox#Bytes.Bytes} value.\n *\n * @example\n * ```ts twoslash\n * import { Bytes } from 'ox'\n *\n * Bytes.trimLeft(Bytes.from([0, 0, 0, 0, 1, 2, 3]))\n * // @log: Uint8Array([1, 2, 3])\n * ```\n *\n * @param value - {@link ox#Bytes.Bytes} value.\n * @returns Trimmed {@link ox#Bytes.Bytes} value.\n */\nexport function trimLeft(value: Bytes): Bytes {\n return internal.trim(value, { dir: 'left' })\n}\n\nexport declare namespace trimLeft {\n type ErrorType = internal.trim.ErrorType | Errors.GlobalErrorType\n}\n\n/**\n * Trims trailing zeros from a {@link ox#Bytes.Bytes} value.\n *\n * @example\n * ```ts twoslash\n * import { Bytes } from 'ox'\n *\n * Bytes.trimRight(Bytes.from([1, 2, 3, 0, 0, 0, 0]))\n * // @log: Uint8Array([1, 2, 3])\n * ```\n *\n * @param value - {@link ox#Bytes.Bytes} value.\n * @returns Trimmed {@link ox#Bytes.Bytes} value.\n */\nexport function trimRight(value: Bytes): Bytes {\n return internal.trim(value, { dir: 'right' })\n}\n\nexport declare namespace trimRight {\n export type ErrorType = internal.trim.ErrorType | Errors.GlobalErrorType\n}\n\n/**\n * Checks if the given value is {@link ox#Bytes.Bytes}.\n *\n * @example\n * ```ts twoslash\n * import { Bytes } from 'ox'\n *\n * Bytes.validate('0x')\n * // @log: false\n *\n * Bytes.validate(Bytes.from([1, 2, 3]))\n * // @log: true\n * ```\n *\n * @param value - Value to check.\n * @returns `true` if the value is {@link ox#Bytes.Bytes}, otherwise `false`.\n */\nexport function validate(value: unknown): value is Bytes {\n try {\n assert(value)\n return true\n } catch {\n return false\n }\n}\n\nexport declare namespace validate {\n export type ErrorType = Errors.GlobalErrorType\n}\n\n/**\n * Thrown when the bytes value cannot be represented as a boolean.\n *\n * @example\n * ```ts twoslash\n * import { Bytes } from 'ox'\n *\n * Bytes.toBoolean(Bytes.from([5]))\n * // @error: Bytes.InvalidBytesBooleanError: Bytes value `[5]` is not a valid boolean.\n * // @error: The bytes array must contain a single byte of either a `0` or `1` value.\n * ```\n */\nexport class InvalidBytesBooleanError extends Errors.BaseError {\n override readonly name = 'Bytes.InvalidBytesBooleanError'\n\n constructor(bytes: Bytes) {\n super(`Bytes value \\`${bytes}\\` is not a valid boolean.`, {\n metaMessages: [\n 'The bytes array must contain a single byte of either a `0` or `1` value.',\n ],\n })\n }\n}\n\n/**\n * Thrown when a value cannot be converted to bytes.\n *\n * @example\n * ```ts twoslash\n * // @noErrors\n * import { Bytes } from 'ox'\n *\n * Bytes.from('foo')\n * // @error: Bytes.InvalidBytesTypeError: Value `foo` of type `string` is an invalid Bytes value.\n * ```\n */\nexport class InvalidBytesTypeError extends Errors.BaseError {\n override readonly name = 'Bytes.InvalidBytesTypeError'\n\n constructor(value: unknown) {\n super(\n `Value \\`${typeof value === 'object' ? Json.stringify(value) : value}\\` of type \\`${typeof value}\\` is an invalid Bytes value.`,\n {\n metaMessages: ['Bytes values must be of type `Bytes`.'],\n },\n )\n }\n}\n\n/**\n * Thrown when a size exceeds the maximum allowed size.\n *\n * @example\n * ```ts twoslash\n * import { Bytes } from 'ox'\n *\n * Bytes.fromString('Hello World!', { size: 8 })\n * // @error: Bytes.SizeOverflowError: Size cannot exceed `8` bytes. Given size: `12` bytes.\n * ```\n */\nexport class SizeOverflowError extends Errors.BaseError {\n override readonly name = 'Bytes.SizeOverflowError'\n\n constructor({ givenSize, maxSize }: { givenSize: number; maxSize: number }) {\n super(\n `Size cannot exceed \\`${maxSize}\\` bytes. Given size: \\`${givenSize}\\` bytes.`,\n )\n }\n}\n\n/**\n * Thrown when a slice offset is out-of-bounds.\n *\n * @example\n * ```ts twoslash\n * import { Bytes } from 'ox'\n *\n * Bytes.slice(Bytes.from([1, 2, 3]), 4)\n * // @error: Bytes.SliceOffsetOutOfBoundsError: Slice starting at offset `4` is out-of-bounds (size: `3`).\n * ```\n */\nexport class SliceOffsetOutOfBoundsError extends Errors.BaseError {\n override readonly name = 'Bytes.SliceOffsetOutOfBoundsError'\n\n constructor({\n offset,\n position,\n size,\n }: { offset: number; position: 'start' | 'end'; size: number }) {\n super(\n `Slice ${\n position === 'start' ? 'starting' : 'ending'\n } at offset \\`${offset}\\` is out-of-bounds (size: \\`${size}\\`).`,\n )\n }\n}\n\n/**\n * Thrown when a the padding size exceeds the maximum allowed size.\n *\n * @example\n * ```ts twoslash\n * import { Bytes } from 'ox'\n *\n * Bytes.padLeft(Bytes.fromString('Hello World!'), 8)\n * // @error: [Bytes.SizeExceedsPaddingSizeError: Bytes size (`12`) exceeds padding size (`8`).\n * ```\n */\nexport class SizeExceedsPaddingSizeError extends Errors.BaseError {\n override readonly name = 'Bytes.SizeExceedsPaddingSizeError'\n\n constructor({\n size,\n targetSize,\n type,\n }: {\n size: number\n targetSize: number\n type: 'Hex' | 'Bytes'\n }) {\n super(\n `${type.charAt(0).toUpperCase()}${type\n .slice(1)\n .toLowerCase()} size (\\`${size}\\`) exceeds padding size (\\`${targetSize}\\`).`,\n )\n }\n}\n", "import { equalBytes } from '@noble/curves/abstract/utils'\nimport * as Bytes from './Bytes.js'\nimport * as Errors from './Errors.js'\nimport * as Json from './Json.js'\nimport * as internal_bytes from './internal/bytes.js'\nimport * as internal from './internal/hex.js'\n\nconst encoder = /*#__PURE__*/ new TextEncoder()\n\nconst hexes = /*#__PURE__*/ Array.from({ length: 256 }, (_v, i) =>\n i.toString(16).padStart(2, '0'),\n)\n\n/** Root type for a Hex string. */\nexport type Hex = `0x${string}`\n\n/**\n * Asserts if the given value is {@link ox#Hex.Hex}.\n *\n * @example\n * ```ts twoslash\n * import { Hex } from 'ox'\n *\n * Hex.assert('abc')\n * // @error: InvalidHexValueTypeError:\n * // @error: Value `\"abc\"` of type `string` is an invalid hex type.\n * // @error: Hex types must be represented as `\"0x\\${string}\"`.\n * ```\n *\n * @param value - The value to assert.\n * @param options - Options.\n */\nexport function assert(\n value: unknown,\n options: assert.Options = {},\n): asserts value is Hex {\n const { strict = false } = options\n if (!value) throw new InvalidHexTypeError(value)\n if (typeof value !== 'string') throw new InvalidHexTypeError(value)\n if (strict) {\n if (!/^0x[0-9a-fA-F]*$/.test(value)) throw new InvalidHexValueError(value)\n }\n if (!value.startsWith('0x')) throw new InvalidHexValueError(value)\n}\n\nexport declare namespace assert {\n type Options = {\n /** Checks if the {@link ox#Hex.Hex} value contains invalid hexadecimal characters. @default false */\n strict?: boolean | undefined\n }\n\n type ErrorType =\n | InvalidHexTypeError\n | InvalidHexValueError\n | Errors.GlobalErrorType\n}\n\n/**\n * Concatenates two or more {@link ox#Hex.Hex}.\n *\n * @example\n * ```ts twoslash\n * import { Hex } from 'ox'\n *\n * Hex.concat('0x123', '0x456')\n * // @log: '0x123456'\n * ```\n *\n * @param values - The {@link ox#Hex.Hex} values to concatenate.\n * @returns The concatenated {@link ox#Hex.Hex} value.\n */\nexport function concat(...values: readonly Hex[]): Hex {\n return `0x${(values as Hex[]).reduce((acc, x) => acc + x.replace('0x', ''), '')}`\n}\n\nexport declare namespace concat {\n type ErrorType = Errors.GlobalErrorType\n}\n\n/**\n * Instantiates a {@link ox#Hex.Hex} value from a hex string or {@link ox#Bytes.Bytes} value.\n *\n * :::tip\n *\n * To instantiate from a **Boolean**, **String**, or **Number**, use one of the following:\n *\n * - `Hex.fromBoolean`\n *\n * - `Hex.fromString`\n *\n * - `Hex.fromNumber`\n *\n * :::\n *\n * @example\n * ```ts twoslash\n * import { Bytes, Hex } from 'ox'\n *\n * Hex.from('0x48656c6c6f20576f726c6421')\n * // @log: '0x48656c6c6f20576f726c6421'\n *\n * Hex.from(Bytes.from([72, 101, 108, 108, 111, 32, 87, 111, 114, 108, 100, 33]))\n * // @log: '0x48656c6c6f20576f726c6421'\n * ```\n *\n * @param value - The {@link ox#Bytes.Bytes} value to encode.\n * @returns The encoded {@link ox#Hex.Hex} value.\n */\nexport function from(value: Hex | Bytes.Bytes | readonly number[]): Hex {\n if (value instanceof Uint8Array) return fromBytes(value)\n if (Array.isArray(value)) return fromBytes(new Uint8Array(value))\n return value as never\n}\n\nexport declare namespace from {\n type Options = {\n /** The size (in bytes) of the output hex value. */\n size?: number | undefined\n }\n\n type ErrorType = fromBytes.ErrorType | Errors.GlobalErrorType\n}\n\n/**\n * Encodes a boolean into a {@link ox#Hex.Hex} value.\n *\n * @example\n * ```ts twoslash\n * import { Hex } from 'ox'\n *\n * Hex.fromBoolean(true)\n * // @log: '0x1'\n *\n * Hex.fromBoolean(false)\n * // @log: '0x0'\n *\n * Hex.fromBoolean(true, { size: 32 })\n * // @log: '0x0000000000000000000000000000000000000000000000000000000000000001'\n * ```\n *\n * @param value - The boolean value to encode.\n * @param options - Options.\n * @returns The encoded {@link ox#Hex.Hex} value.\n */\nexport function fromBoolean(\n value: boolean,\n options: fromBoolean.Options = {},\n): Hex {\n const hex: Hex = `0x${Number(value)}`\n if (typeof options.size === 'number') {\n internal.assertSize(hex, options.size)\n return padLeft(hex, options.size)\n }\n return hex\n}\n\nexport declare namespace fromBoolean {\n type Options = {\n /** The size (in bytes) of the output hex value. */\n size?: number | undefined\n }\n\n type ErrorType =\n | internal.assertSize.ErrorType\n | padLeft.ErrorType\n | Errors.GlobalErrorType\n}\n\n/**\n * Encodes a {@link ox#Bytes.Bytes} value into a {@link ox#Hex.Hex} value.\n *\n * @example\n * ```ts twoslash\n * import { Bytes, Hex } from 'ox'\n *\n * Hex.fromBytes(Bytes.from([72, 101, 108, 108, 111, 32, 87, 111, 114, 108, 100, 33]))\n * // @log: '0x48656c6c6f20576f726c6421'\n * ```\n *\n * @param value - The {@link ox#Bytes.Bytes} value to encode.\n * @param options - Options.\n * @returns The encoded {@link ox#Hex.Hex} value.\n */\nexport function fromBytes(\n value: Bytes.Bytes,\n options: fromBytes.Options = {},\n): Hex {\n let string = ''\n for (let i = 0; i < value.length; i++) string += hexes[value[i]!]\n const hex = `0x${string}` as const\n\n if (typeof options.size === 'number') {\n internal.assertSize(hex, options.size)\n return padRight(hex, options.size)\n }\n return hex\n}\n\nexport declare namespace fromBytes {\n type Options = {\n /** The size (in bytes) of the output hex value. */\n size?: number | undefined\n }\n\n type ErrorType =\n | internal.assertSize.ErrorType\n | padRight.ErrorType\n | Errors.GlobalErrorType\n}\n\n/**\n * Encodes a number or bigint into a {@link ox#Hex.Hex} value.\n *\n * @example\n * ```ts twoslash\n * import { Hex } from 'ox'\n *\n * Hex.fromNumber(420)\n * // @log: '0x1a4'\n *\n * Hex.fromNumber(420, { size: 32 })\n * // @log: '0x00000000000000000000000000000000000000000000000000000000000001a4'\n * ```\n *\n * @param value - The number or bigint value to encode.\n * @param options - Options.\n * @returns The encoded {@link ox#Hex.Hex} value.\n */\nexport function fromNumber(\n value: number | bigint,\n options: fromNumber.Options = {},\n): Hex {\n const { signed, size } = options\n\n const value_ = BigInt(value)\n\n let maxValue: bigint | number | undefined\n if (size) {\n if (signed) maxValue = (1n << (BigInt(size) * 8n - 1n)) - 1n\n else maxValue = 2n ** (BigInt(size) * 8n) - 1n\n } else if (typeof value === 'number') {\n maxValue = BigInt(Number.MAX_SAFE_INTEGER)\n }\n\n const minValue = typeof maxValue === 'bigint' && signed ? -maxValue - 1n : 0\n\n if ((maxValue && value_ > maxValue) || value_ < minValue) {\n const suffix = typeof value === 'bigint' ? 'n' : ''\n throw new IntegerOutOfRangeError({\n max: maxValue ? `${maxValue}${suffix}` : undefined,\n min: `${minValue}${suffix}`,\n signed,\n size,\n value: `${value}${suffix}`,\n })\n }\n\n const stringValue = (\n signed && value_ < 0 ? (1n << BigInt(size * 8)) + BigInt(value_) : value_\n ).toString(16)\n\n const hex = `0x${stringValue}` as Hex\n if (size) return padLeft(hex, size) as Hex\n return hex\n}\n\nexport declare namespace fromNumber {\n type Options =\n | {\n /** Whether or not the number of a signed representation. */\n signed?: boolean | undefined\n /** The size (in bytes) of the output hex value. */\n size: number\n }\n | {\n signed?: undefined\n /** The size (in bytes) of the output hex value. */\n size?: number | undefined\n }\n\n type ErrorType =\n | IntegerOutOfRangeError\n | padLeft.ErrorType\n | Errors.GlobalErrorType\n}\n\n/**\n * Encodes a string into a {@link ox#Hex.Hex} value.\n *\n * @example\n * ```ts twoslash\n * import { Hex } from 'ox'\n * Hex.fromString('Hello World!')\n * // '0x48656c6c6f20576f726c6421'\n *\n * Hex.fromString('Hello World!', { size: 32 })\n * // '0x48656c6c6f20576f726c64210000000000000000000000000000000000000000'\n * ```\n *\n * @param value - The string value to encode.\n * @param options - Options.\n * @returns The encoded {@link ox#Hex.Hex} value.\n */\nexport function fromString(\n value: string,\n options: fromString.Options = {},\n): Hex {\n return fromBytes(encoder.encode(value), options)\n}\n\nexport declare namespace fromString {\n type Options = {\n /** The size (in bytes) of the output hex value. */\n size?: number | undefined\n }\n\n type ErrorType = fromBytes.ErrorType | Errors.GlobalErrorType\n}\n\n/**\n * Checks if two {@link ox#Hex.Hex} values are equal.\n *\n * @example\n * ```ts twoslash\n * import { Hex } from 'ox'\n *\n * Hex.isEqual('0xdeadbeef', '0xdeadbeef')\n * // @log: true\n *\n * Hex.isEqual('0xda', '0xba')\n * // @log: false\n * ```\n *\n * @param hexA - The first {@link ox#Hex.Hex} value.\n * @param hexB - The second {@link ox#Hex.Hex} value.\n * @returns `true` if the two {@link ox#Hex.Hex} values are equal, `false` otherwise.\n */\nexport function isEqual(hexA: Hex, hexB: Hex) {\n return equalBytes(Bytes.fromHex(hexA), Bytes.fromHex(hexB))\n}\n\nexport declare namespace isEqual {\n type ErrorType = Bytes.fromHex.ErrorType | Errors.GlobalErrorType\n}\n\n/**\n * Pads a {@link ox#Hex.Hex} value to the left with zero bytes until it reaches the given `size` (default: 32 bytes).\n *\n * @example\n * ```ts twoslash\n * import { Hex } from 'ox'\n *\n * Hex.padLeft('0x1234', 4)\n * // @log: '0x00001234'\n * ```\n *\n * @param value - The {@link ox#Hex.Hex} value to pad.\n * @param size - The size (in bytes) of the output hex value.\n * @returns The padded {@link ox#Hex.Hex} value.\n */\nexport function padLeft(\n value: Hex,\n size?: number | undefined,\n): padLeft.ReturnType {\n return internal.pad(value, { dir: 'left', size })\n}\n\nexport declare namespace padLeft {\n type ReturnType = Hex\n type ErrorType = internal.pad.ErrorType | Errors.GlobalErrorType\n}\n\n/**\n * Pads a {@link ox#Hex.Hex} value to the right with zero bytes until it reaches the given `size` (default: 32 bytes).\n *\n * @example\n * ```ts\n * import { Hex } from 'ox'\n *\n * Hex.padRight('0x1234', 4)\n * // @log: '0x12340000'\n * ```\n *\n * @param value - The {@link ox#Hex.Hex} value to pad.\n * @param size - The size (in bytes) of the output hex value.\n * @returns The padded {@link ox#Hex.Hex} value.\n */\nexport function padRight(\n value: Hex,\n size?: number | undefined,\n): padRight.ReturnType {\n return internal.pad(value, { dir: 'right', size })\n}\n\nexport declare namespace padRight {\n type ReturnType = Hex\n type ErrorType = internal.pad.ErrorType | Errors.GlobalErrorType\n}\n\n/**\n * Generates a random {@link ox#Hex.Hex} value of the specified length.\n *\n * @example\n * ```ts twoslash\n * import { Hex } from 'ox'\n *\n * const hex = Hex.random(32)\n * // @log: '0x...'\n * ```\n *\n * @returns Random {@link ox#Hex.Hex} value.\n */\nexport function random(length: number): Hex {\n return fromBytes(Bytes.random(length))\n}\n\nexport declare namespace random {\n type ErrorType = Errors.GlobalErrorType\n}\n\n/**\n * Returns a section of a {@link ox#Bytes.Bytes} value given a start/end bytes offset.\n *\n * @example\n * ```ts twoslash\n * import { Hex } from 'ox'\n *\n * Hex.slice('0x0123456789', 1, 4)\n * // @log: '0x234567'\n * ```\n *\n * @param value - The {@link ox#Hex.Hex} value to slice.\n * @param start - The start offset (in bytes).\n * @param end - The end offset (in bytes).\n * @param options - Options.\n * @returns The sliced {@link ox#Hex.Hex} value.\n */\nexport function slice(\n value: Hex,\n start?: number | undefined,\n end?: number | undefined,\n options: slice.Options = {},\n): Hex {\n const { strict } = options\n internal.assertStartOffset(value, start)\n const value_ = `0x${value\n .replace('0x', '')\n .slice((start ?? 0) * 2, (end ?? value.length) * 2)}` as const\n if (strict) internal.assertEndOffset(value_, start, end)\n return value_\n}\n\nexport declare namespace slice {\n type Options = {\n /** Asserts that the sliced value is the same size as the given start/end offsets. */\n strict?: boolean | undefined\n }\n\n type ErrorType =\n | internal.assertStartOffset.ErrorType\n | internal.assertEndOffset.ErrorType\n | Errors.GlobalErrorType\n}\n\n/**\n * Retrieves the size of a {@link ox#Hex.Hex} value (in bytes).\n *\n * @example\n * ```ts twoslash\n * import { Hex } from 'ox'\n *\n * Hex.size('0xdeadbeef')\n * // @log: 4\n * ```\n *\n * @param value - The {@link ox#Hex.Hex} value to get the size of.\n * @returns The size of the {@link ox#Hex.Hex} value (in bytes).\n */\nexport function size(value: Hex): number {\n return Math.ceil((value.length - 2) / 2)\n}\n\nexport declare namespace size {\n export type ErrorType = Errors.GlobalErrorType\n}\n\n/**\n * Trims leading zeros from a {@link ox#Hex.Hex} value.\n *\n * @example\n * ```ts twoslash\n * import { Hex } from 'ox'\n *\n * Hex.trimLeft('0x00000000deadbeef')\n * // @log: '0xdeadbeef'\n * ```\n *\n * @param value - The {@link ox#Hex.Hex} value to trim.\n * @returns The trimmed {@link ox#Hex.Hex} value.\n */\nexport function trimLeft(value: Hex): trimLeft.ReturnType {\n return internal.trim(value, { dir: 'left' })\n}\n\nexport declare namespace trimLeft {\n type ReturnType = Hex\n\n type ErrorType = internal.trim.ErrorType | Errors.GlobalErrorType\n}\n\n/**\n * Trims trailing zeros from a {@link ox#Hex.Hex} value.\n *\n * @example\n * ```ts twoslash\n * import { Hex } from 'ox'\n *\n * Hex.trimRight('0xdeadbeef00000000')\n * // @log: '0xdeadbeef'\n * ```\n *\n * @param value - The {@link ox#Hex.Hex} value to trim.\n * @returns The trimmed {@link ox#Hex.Hex} value.\n */\nexport function trimRight(value: Hex): trimRight.ReturnType {\n return internal.trim(value, { dir: 'right' })\n}\n\nexport declare namespace trimRight {\n type ReturnType = Hex\n\n type ErrorType = internal.trim.ErrorType | Errors.GlobalErrorType\n}\n\n/**\n * Decodes a {@link ox#Hex.Hex} value into a BigInt.\n *\n * @example\n * ```ts twoslash\n * import { Hex } from 'ox'\n *\n * Hex.toBigInt('0x1a4')\n * // @log: 420n\n *\n * Hex.toBigInt('0x00000000000000000000000000000000000000000000000000000000000001a4', { size: 32 })\n * // @log: 420n\n * ```\n *\n * @param hex - The {@link ox#Hex.Hex} value to decode.\n * @param options - Options.\n * @returns The decoded BigInt.\n */\nexport function toBigInt(hex: Hex, options: toBigInt.Options = {}): bigint {\n const { signed } = options\n\n if (options.size) internal.assertSize(hex, options.size)\n\n const value = BigInt(hex)\n if (!signed) return value\n\n const size = (hex.length - 2) / 2\n\n const max_unsigned = (1n << (BigInt(size) * 8n)) - 1n\n const max_signed = max_unsigned >> 1n\n\n if (value <= max_signed) return value\n return value - max_unsigned - 1n\n}\n\nexport declare namespace toBigInt {\n type Options = {\n /** Whether or not the number of a signed representation. */\n signed?: boolean | undefined\n /** Size (in bytes) of the hex value. */\n size?: number | undefined\n }\n\n type ErrorType = internal.assertSize.ErrorType | Errors.GlobalErrorType\n}\n\n/**\n * Decodes a {@link ox#Hex.Hex} value into a boolean.\n *\n * @example\n * ```ts twoslash\n * import { Hex } from 'ox'\n *\n * Hex.toBoolean('0x01')\n * // @log: true\n *\n * Hex.toBoolean('0x0000000000000000000000000000000000000000000000000000000000000001', { size: 32 })\n * // @log: true\n * ```\n *\n * @param hex - The {@link ox#Hex.Hex} value to decode.\n * @param options - Options.\n * @returns The decoded boolean.\n */\nexport function toBoolean(hex: Hex, options: toBoolean.Options = {}): boolean {\n if (options.size) internal.assertSize(hex, options.size)\n const hex_ = trimLeft(hex)\n if (hex_ === '0x') return false\n if (hex_ === '0x1') return true\n throw new InvalidHexBooleanError(hex)\n}\n\nexport declare namespace toBoolean {\n type Options = {\n /** Size (in bytes) of the hex value. */\n size?: number | undefined\n }\n\n type ErrorType =\n | internal.assertSize.ErrorType\n | trimLeft.ErrorType\n | InvalidHexBooleanError\n | Errors.GlobalErrorType\n}\n\n/**\n * Decodes a {@link ox#Hex.Hex} value into a {@link ox#Bytes.Bytes}.\n *\n * @example\n * ```ts twoslash\n * import { Hex } from 'ox'\n *\n * const data = Hex.toBytes('0x48656c6c6f20776f726c6421')\n * // @log: Uint8Array([72, 101, 108, 108, 111, 32, 87, 111, 114, 108, 100, 33])\n * ```\n *\n * @param hex - The {@link ox#Hex.Hex} value to decode.\n * @param options - Options.\n * @returns The decoded {@link ox#Bytes.Bytes}.\n */\nexport function toBytes(hex: Hex, options: toBytes.Options = {}): Bytes.Bytes {\n return Bytes.fromHex(hex, options)\n}\n\nexport declare namespace toBytes {\n type Options = {\n /** Size (in bytes) of the hex value. */\n size?: number | undefined\n }\n\n type ErrorType = Bytes.fromHex.ErrorType | Errors.GlobalErrorType\n}\n\n/**\n * Decodes a {@link ox#Hex.Hex} value into a number.\n *\n * @example\n * ```ts twoslash\n * import { Hex } from 'ox'\n *\n * Hex.toNumber('0x1a4')\n * // @log: 420\n *\n * Hex.toNumber('0x00000000000000000000000000000000000000000000000000000000000001a4', { size: 32 })\n * // @log: 420\n * ```\n *\n * @param hex - The {@link ox#Hex.Hex} value to decode.\n * @param options - Options.\n * @returns The decoded number.\n */\nexport function toNumber(hex: Hex, options: toNumber.Options = {}): number {\n const { signed, size } = options\n if (!signed && !size) return Number(hex)\n return Number(toBigInt(hex, options))\n}\n\nexport declare namespace toNumber {\n type Options = toBigInt.Options\n\n type ErrorType = toBigInt.ErrorType | Errors.GlobalErrorType\n}\n\n/**\n * Decodes a {@link ox#Hex.Hex} value into a string.\n *\n * @example\n * ```ts twoslash\n * import { Hex } from 'ox'\n *\n * Hex.toString('0x48656c6c6f20576f726c6421')\n * // @log: 'Hello world!'\n *\n * Hex.toString('0x48656c6c6f20576f726c64210000000000000000000000000000000000000000', {\n * size: 32,\n * })\n * // @log: 'Hello world'\n * ```\n *\n * @param hex - The {@link ox#Hex.Hex} value to decode.\n * @param options - Options.\n * @returns The decoded string.\n */\nexport function toString(hex: Hex, options: toString.Options = {}): string {\n const { size } = options\n\n let bytes = Bytes.fromHex(hex)\n if (size) {\n internal_bytes.assertSize(bytes, size)\n bytes = Bytes.trimRight(bytes)\n }\n return new TextDecoder().decode(bytes)\n}\n\nexport declare namespace toString {\n type Options = {\n /** Size (in bytes) of the hex value. */\n size?: number | undefined\n }\n\n type ErrorType =\n | internal_bytes.assertSize.ErrorType\n | Bytes.fromHex.ErrorType\n | Bytes.trimRight.ErrorType\n | Errors.GlobalErrorType\n}\n\n/**\n * Checks if the given value is {@link ox#Hex.Hex}.\n *\n * @example\n * ```ts twoslash\n * import { Bytes, Hex } from 'ox'\n *\n * Hex.validate('0xdeadbeef')\n * // @log: true\n *\n * Hex.validate(Bytes.from([1, 2, 3]))\n * // @log: false\n * ```\n *\n * @param value - The value to check.\n * @param options - Options.\n * @returns `true` if the value is a {@link ox#Hex.Hex}, `false` otherwise.\n */\nexport function validate(\n value: unknown,\n options: validate.Options = {},\n): value is Hex {\n const { strict = false } = options\n try {\n assert(value, { strict })\n return true\n } catch {\n return false\n }\n}\n\nexport declare namespace validate {\n type Options = {\n /** Checks if the {@link ox#Hex.Hex} value contains invalid hexadecimal characters. @default false */\n strict?: boolean | undefined\n }\n\n type ErrorType = Errors.GlobalErrorType\n}\n\n/**\n * Thrown when the provided integer is out of range, and cannot be represented as a hex value.\n *\n * @example\n * ```ts twoslash\n * import { Hex } from 'ox'\n *\n * Hex.fromNumber(420182738912731283712937129)\n * // @error: Hex.IntegerOutOfRangeError: Number \\`4.2018273891273126e+26\\` is not in safe unsigned integer range (`0` to `9007199254740991`)\n * ```\n */\nexport class IntegerOutOfRangeError extends Errors.BaseError {\n override readonly name = 'Hex.IntegerOutOfRangeError'\n\n constructor({\n max,\n min,\n signed,\n size,\n value,\n }: {\n max?: string | undefined\n min: string\n signed?: boolean | undefined\n size?: number | undefined\n value: string\n }) {\n super(\n `Number \\`${value}\\` is not in safe${\n size ? ` ${size * 8}-bit` : ''\n }${signed ? ' signed' : ' unsigned'} integer range ${max ? `(\\`${min}\\` to \\`${max}\\`)` : `(above \\`${min}\\`)`}`,\n )\n }\n}\n\n/**\n * Thrown when the provided hex value cannot be represented as a boolean.\n *\n * @example\n * ```ts twoslash\n * import { Hex } from 'ox'\n *\n * Hex.toBoolean('0xa')\n * // @error: Hex.InvalidHexBooleanError: Hex value `\"0xa\"` is not a valid boolean.\n * // @error: The hex value must be `\"0x0\"` (false) or `\"0x1\"` (true).\n * ```\n */\nexport class InvalidHexBooleanError extends Errors.BaseError {\n override readonly name = 'Hex.InvalidHexBooleanError'\n\n constructor(hex: Hex) {\n super(`Hex value \\`\"${hex}\"\\` is not a valid boolean.`, {\n metaMessages: [\n 'The hex value must be `\"0x0\"` (false) or `\"0x1\"` (true).',\n ],\n })\n }\n}\n\n/**\n * Thrown when the provided value is not a valid hex type.\n *\n * @example\n * ```ts twoslash\n * import { Hex } from 'ox'\n *\n * Hex.assert(1)\n * // @error: Hex.InvalidHexTypeError: Value `1` of type `number` is an invalid hex type.\n * ```\n */\nexport class InvalidHexTypeError extends Errors.BaseError {\n override readonly name = 'Hex.InvalidHexTypeError'\n\n constructor(value: unknown) {\n super(\n `Value \\`${typeof value === 'object' ? Json.stringify(value) : value}\\` of type \\`${typeof value}\\` is an invalid hex type.`,\n {\n metaMessages: ['Hex types must be represented as `\"0x${string}\"`.'],\n },\n )\n }\n}\n\n/**\n * Thrown when the provided hex value is invalid.\n *\n * @example\n * ```ts twoslash\n * import { Hex } from 'ox'\n *\n * Hex.assert('0x0123456789abcdefg')\n * // @error: Hex.InvalidHexValueError: Value `0x0123456789abcdefg` is an invalid hex value.\n * // @error: Hex values must start with `\"0x\"` and contain only hexadecimal characters (0-9, a-f, A-F).\n * ```\n */\nexport class InvalidHexValueError extends Errors.BaseError {\n override readonly name = 'Hex.InvalidHexValueError'\n\n constructor(value: unknown) {\n super(`Value \\`${value}\\` is an invalid hex value.`, {\n metaMessages: [\n 'Hex values must start with `\"0x\"` and contain only hexadecimal characters (0-9, a-f, A-F).',\n ],\n })\n }\n}\n\n/**\n * Thrown when the provided hex value is an odd length.\n *\n * @example\n * ```ts twoslash\n * import { Bytes } from 'ox'\n *\n * Bytes.fromHex('0xabcde')\n * // @error: Hex.InvalidLengthError: Hex value `\"0xabcde\"` is an odd length (5 nibbles).\n * ```\n */\nexport class InvalidLengthError extends Errors.BaseError {\n override readonly name = 'Hex.InvalidLengthError'\n\n constructor(value: Hex) {\n super(\n `Hex value \\`\"${value}\"\\` is an odd length (${value.length - 2} nibbles).`,\n {\n metaMessages: ['It must be an even length.'],\n },\n )\n }\n}\n\n/**\n * Thrown when the size of the value exceeds the expected max size.\n *\n * @example\n * ```ts twoslash\n * import { Hex } from 'ox'\n *\n * Hex.fromString('Hello World!', { size: 8 })\n * // @error: Hex.SizeOverflowError: Size cannot exceed `8` bytes. Given size: `12` bytes.\n * ```\n */\nexport class SizeOverflowError extends Errors.BaseError {\n override readonly name = 'Hex.SizeOverflowError'\n\n constructor({ givenSize, maxSize }: { givenSize: number; maxSize: number }) {\n super(\n `Size cannot exceed \\`${maxSize}\\` bytes. Given size: \\`${givenSize}\\` bytes.`,\n )\n }\n}\n\n/**\n * Thrown when the slice offset exceeds the bounds of the value.\n *\n * @example\n * ```ts twoslash\n * import { Hex } from 'ox'\n *\n * Hex.slice('0x0123456789', 6)\n * // @error: Hex.SliceOffsetOutOfBoundsError: Slice starting at offset `6` is out-of-bounds (size: `5`).\n * ```\n */\nexport class SliceOffsetOutOfBoundsError extends Errors.BaseError {\n override readonly name = 'Hex.SliceOffsetOutOfBoundsError'\n\n constructor({\n offset,\n position,\n size,\n }: { offset: number; position: 'start' | 'end'; size: number }) {\n super(\n `Slice ${\n position === 'start' ? 'starting' : 'ending'\n } at offset \\`${offset}\\` is out-of-bounds (size: \\`${size}\\`).`,\n )\n }\n}\n\n/**\n * Thrown when the size of the value exceeds the pad size.\n *\n * @example\n * ```ts twoslash\n * import { Hex } from 'ox'\n *\n * Hex.padLeft('0x1a4e12a45a21323123aaa87a897a897a898a6567a578a867a98778a667a85a875a87a6a787a65a675a6a9', 32)\n * // @error: Hex.SizeExceedsPaddingSizeError: Hex size (`43`) exceeds padding size (`32`).\n * ```\n */\nexport class SizeExceedsPaddingSizeError extends Errors.BaseError {\n override readonly name = 'Hex.SizeExceedsPaddingSizeError'\n\n constructor({\n size,\n targetSize,\n type,\n }: {\n size: number\n targetSize: number\n type: 'Hex' | 'Bytes'\n }) {\n super(\n `${type.charAt(0).toUpperCase()}${type\n .slice(1)\n .toLowerCase()} size (\\`${size}\\`) exceeds padding size (\\`${targetSize}\\`).`,\n )\n }\n}\n", "import type * as Errors from './Errors.js'\nimport * as Hex from './Hex.js'\n\n/** A Withdrawal as defined in the [Execution API specification](https://github.com/ethereum/execution-apis/blob/main/src/schemas/withdrawal.yaml). */\nexport type Withdrawal<bigintType = bigint, numberType = number> = {\n address: Hex.Hex\n amount: bigintType\n index: numberType\n validatorIndex: numberType\n}\n\n/** An RPC Withdrawal as defined in the [Execution API specification](https://github.com/ethereum/execution-apis/blob/main/src/schemas/withdrawal.yaml). */\nexport type Rpc = Withdrawal<Hex.Hex, Hex.Hex>\n\n/**\n * Converts a {@link ox#Withdrawal.Rpc} to an {@link ox#Withdrawal.Withdrawal}.\n *\n * @example\n * ```ts twoslash\n * import { Withdrawal } from 'ox'\n *\n * const withdrawal = Withdrawal.fromRpc({\n * address: '0x00000000219ab540356cBB839Cbe05303d7705Fa',\n * amount: '0x620323',\n * index: '0x0',\n * validatorIndex: '0x1',\n * })\n * // @log: {\n * // @log: address: '0x00000000219ab540356cBB839Cbe05303d7705Fa',\n * // @log: amount: 6423331n,\n * // @log: index: 0,\n * // @log: validatorIndex: 1\n * // @log: }\n * ```\n *\n * @param withdrawal - The RPC withdrawal to convert.\n * @returns An instantiated {@link ox#Withdrawal.Withdrawal}.\n */\nexport function fromRpc(withdrawal: Rpc): Withdrawal {\n return {\n ...withdrawal,\n amount: BigInt(withdrawal.amount),\n index: Number(withdrawal.index),\n validatorIndex: Number(withdrawal.validatorIndex),\n }\n}\n\nexport declare namespace fromRpc {\n export type ErrorType = Errors.GlobalErrorType\n}\n\n/**\n * Converts a {@link ox#Withdrawal.Withdrawal} to an {@link ox#Withdrawal.Rpc}.\n *\n * @example\n * ```ts twoslash\n * import { Withdrawal } from 'ox'\n *\n * const withdrawal = Withdrawal.toRpc({\n * address: '0x00000000219ab540356cBB839Cbe05303d7705Fa',\n * amount: 6423331n,\n * index: 0,\n * validatorIndex: 1,\n * })\n * // @log: {\n * // @log: address: '0x00000000219ab540356cBB839Cbe05303d7705Fa',\n * // @log: amount: '0x620323',\n * // @log: index: '0x0',\n * // @log: validatorIndex: '0x1',\n * // @log: }\n * ```\n *\n * @param withdrawal - The Withdrawal to convert.\n * @returns An RPC Withdrawal.\n */\nexport function toRpc(withdrawal: Withdrawal): Rpc {\n return {\n address: withdrawal.address,\n amount: Hex.fromNumber(withdrawal.amount),\n index: Hex.fromNumber(withdrawal.index),\n validatorIndex: Hex.fromNumber(withdrawal.validatorIndex),\n }\n}\n\nexport declare namespace toRpc {\n export type ErrorType = Errors.GlobalErrorType\n}\n", "import type * as Address from './Address.js'\nimport * as Hex from './Hex.js'\nimport * as Withdrawal from './Withdrawal.js'\n\n/**\n * Block overrides.\n */\nexport type BlockOverrides<bigintType = bigint, numberType = number> = {\n /** Base fee per gas. */\n baseFeePerGas?: bigintType | undefined\n /** Blob base fee. */\n blobBaseFee?: bigintType | undefined\n /** Fee recipient (also known as coinbase). */\n feeRecipient?: Address.Address | undefined\n /** Gas limit. */\n gasLimit?: bigintType | undefined\n /** Block number. */\n number?: bigintType | undefined\n /** The previous value of randomness beacon. */\n prevRandao?: bigintType | undefined\n /** Block timestamp. */\n time?: bigintType | undefined\n /** Withdrawals made by validators. */\n withdrawals?: Withdrawal.Withdrawal<bigintType, numberType>[] | undefined\n}\n\n/**\n * RPC block overrides.\n */\nexport type Rpc = BlockOverrides<Hex.Hex, Hex.Hex>\n\n/**\n * Converts an {@link ox#BlockOverrides.Rpc} to an {@link ox#BlockOverrides.BlockOverrides}.\n *\n * @example\n * ```ts twoslash\n * import { BlockOverrides } from 'ox'\n *\n * const blockOverrides = BlockOverrides.fromRpc({\n * baseFeePerGas: '0x1',\n * blobBaseFee: '0x2',\n * feeRecipient: '0x0000000000000000000000000000000000000000',\n * gasLimit: '0x4',\n * number: '0x5',\n * prevRandao: '0x6',\n * time: '0x1234567890',\n * withdrawals: [\n * {\n * address: '0x0000000000000000000000000000000000000000',\n * amount: '0x1',\n * index: '0x0',\n * validatorIndex: '0x1',\n * },\n * ],\n * })\n * ```\n *\n * @param rpcBlockOverrides - The RPC block overrides to convert.\n * @returns An instantiated {@link ox#BlockOverrides.BlockOverrides}.\n */\nexport function fromRpc(rpcBlockOverrides: Rpc): BlockOverrides {\n return {\n ...(rpcBlockOverrides.baseFeePerGas && {\n baseFeePerGas: BigInt(rpcBlockOverrides.baseFeePerGas),\n }),\n ...(rpcBlockOverrides.blobBaseFee && {\n blobBaseFee: BigInt(rpcBlockOverrides.blobBaseFee),\n }),\n ...(rpcBlockOverrides.feeRecipient && {\n feeRecipient: rpcBlockOverrides.feeRecipient,\n }),\n ...(rpcBlockOverrides.gasLimit && {\n gasLimit: BigInt(rpcBlockOverrides.gasLimit),\n }),\n ...(rpcBlockOverrides.number && {\n number: BigInt(rpcBlockOverrides.number),\n }),\n ...(rpcBlockOverrides.prevRandao && {\n prevRandao: BigInt(rpcBlockOverrides.prevRandao),\n }),\n ...(rpcBlockOverrides.time && {\n time: BigInt(rpcBlockOverrides.time),\n }),\n ...(rpcBlockOverrides.withdrawals && {\n withdrawals: rpcBlockOverrides.withdrawals.map(Withdrawal.fromRpc),\n }),\n }\n}\n\n/**\n * Converts an {@link ox#BlockOverrides.BlockOverrides} to an {@link ox#BlockOverrides.Rpc}.\n *\n * @example\n * ```ts twoslash\n * import { BlockOverrides } from 'ox'\n *\n * const blockOverrides = BlockOverrides.toRpc({\n * baseFeePerGas: 1n,\n * blobBaseFee: 2n,\n * feeRecipient: '0x0000000000000000000000000000000000000000',\n * gasLimit: 4n,\n * number: 5n,\n * prevRandao: 6n,\n * time: 78187493520n,\n * withdrawals: [\n * {\n * address: '0x0000000000000000000000000000000000000000',\n * amount: 1n,\n * index: 0,\n * validatorIndex: 1,\n * },\n * ],\n * })\n * ```\n *\n * @param blockOverrides - The block overrides to convert.\n * @returns An instantiated {@link ox#BlockOverrides.Rpc}.\n */\nexport function toRpc(blockOverrides: BlockOverrides): Rpc {\n return {\n ...(typeof blockOverrides.baseFeePerGas === 'bigint' && {\n baseFeePerGas: Hex.fromNumber(blockOverrides.baseFeePerGas),\n }),\n ...(typeof blockOverrides.blobBaseFee === 'bigint' && {\n blobBaseFee: Hex.fromNumber(blockOverrides.blobBaseFee),\n }),\n ...(typeof blockOverrides.feeRecipient === 'string' && {\n feeRecipient: blockOverrides.feeRecipient,\n }),\n ...(typeof blockOverrides.gasLimit === 'bigint' && {\n gasLimit: Hex.fromNumber(blockOverrides.gasLimit),\n }),\n ...(typeof blockOverrides.number === 'bigint' && {\n number: Hex.fromNumber(blockOverrides.number),\n }),\n ...(typeof blockOverrides.prevRandao === 'bigint' && {\n prevRandao: Hex.fromNumber(blockOverrides.prevRandao),\n }),\n ...(typeof blockOverrides.time === 'bigint' && {\n time: Hex.fromNumber(blockOverrides.time),\n }),\n ...(blockOverrides.withdrawals && {\n withdrawals: blockOverrides.withdrawals.map(Withdrawal.toRpc),\n }),\n }\n}\n", "import type { Abi, AbiStateMutability, Address, Narrow } from 'abitype'\nimport * as BlockOverrides from 'ox/BlockOverrides'\n\nimport {\n type ParseAccountErrorType,\n parseAccount,\n} from '../../accounts/utils/parseAccount.js'\nimport type { Client } from '../../clients/createClient.js'\nimport type { Transport } from '../../clients/transports/createTransport.js'\nimport { AbiDecodingZeroDataError } from '../../errors/abi.js'\nimport type { BaseError } from '../../errors/base.js'\nimport { RawContractError } from '../../errors/contract.js'\nimport { UnknownNodeError } from '../../errors/node.js'\nimport type { ErrorType } from '../../errors/utils.js'\nimport type { Account } from '../../types/account.js'\nimport type { Block, BlockTag } from '../../types/block.js'\nimport type { Call, Calls } from '../../types/calls.js'\nimport type { Chain } from '../../types/chain.js'\nimport type { Log } from '../../types/log.js'\nimport type { Hex } from '../../types/misc.js'\nimport type { MulticallResults } from '../../types/multicall.js'\nimport type { StateOverride } from '../../types/stateOverride.js'\nimport type { TransactionRequest } from '../../types/transaction.js'\nimport type { ExactPartial, UnionOmit } from '../../types/utils.js'\nimport {\n type DecodeFunctionResultErrorType,\n decodeFunctionResult,\n} from '../../utils/abi/decodeFunctionResult.js'\nimport {\n type EncodeFunctionDataErrorType,\n encodeFunctionData,\n} from '../../utils/abi/encodeFunctionData.js'\nimport {\n type NumberToHexErrorType,\n numberToHex,\n} from '../../utils/encoding/toHex.js'\nimport { getContractError } from '../../utils/errors/getContractError.js'\nimport {\n type GetNodeErrorReturnType,\n getNodeError,\n} from '../../utils/errors/getNodeError.js'\nimport {\n type FormatBlockErrorType,\n formatBlock,\n} from '../../utils/formatters/block.js'\nimport { formatLog } from '../../utils/formatters/log.js'\nimport {\n type FormatTransactionRequestErrorType,\n formatTransactionRequest,\n} from '../../utils/formatters/transactionRequest.js'\nimport {\n type SerializeStateOverrideErrorType,\n serializeStateOverride,\n} from '../../utils/stateOverride.js'\nimport {\n type AssertRequestErrorType,\n assertRequest,\n} from '../../utils/transaction/assertRequest.js'\n\ntype CallExtraProperties = ExactPartial<\n UnionOmit<\n TransactionRequest,\n 'blobs' | 'data' | 'kzg' | 'to' | 'sidecars' | 'value'\n >\n> & {\n /** Account attached to the call (msg.sender). */\n account?: Account | Address | undefined\n}\n\nexport type SimulateBlocksParameters<\n calls extends readonly unknown[] = readonly unknown[],\n> = {\n /** Blocks to simulate. */\n blocks: readonly {\n /** Block overrides. */\n blockOverrides?: BlockOverrides.BlockOverrides | undefined\n /** Calls to execute. */\n calls: Calls<Narrow<calls>, CallExtraProperties>\n /** State overrides. */\n stateOverrides?: StateOverride | undefined\n }[]\n /** Whether to return the full transactions. */\n returnFullTransactions?: boolean | undefined\n /** Whether to trace transfers. */\n traceTransfers?: boolean | undefined\n /** Whether to enable validation mode. */\n validation?: boolean | undefined\n} & (\n | {\n /** The balance of the account at a block number. */\n blockNumber?: bigint | undefined\n blockTag?: undefined\n }\n | {\n blockNumber?: undefined\n /**\n * The balance of the account at a block tag.\n * @default 'latest'\n */\n blockTag?: BlockTag | undefined\n }\n)\n\nexport type SimulateBlocksReturnType<\n calls extends readonly unknown[] = readonly unknown[],\n> = readonly (Block & {\n calls: MulticallResults<\n Narrow<calls>,\n true,\n {\n extraProperties: {\n data: Hex\n gasUsed: bigint\n logs?: Log[] | undefined\n }\n error: Error\n mutability: AbiStateMutability\n }\n >\n})[]\n\nexport type SimulateBlocksErrorType =\n | AssertRequestErrorType\n | DecodeFunctionResultErrorType\n | EncodeFunctionDataErrorType\n | FormatBlockErrorType\n | FormatTransactionRequestErrorType\n | GetNodeErrorReturnType\n | ParseAccountErrorType\n | SerializeStateOverrideErrorType\n | NumberToHexErrorType\n | ErrorType\n\n/**\n * Simulates a set of calls on block(s) with optional block and state overrides.\n *\n * @example\n * ```ts\n * import { createClient, http, parseEther } from 'viem'\n * import { simulate } from 'viem/actions'\n * import { mainnet } from 'viem/chains'\n *\n * const client = createClient({\n * chain: mainnet,\n * transport: http(),\n * })\n *\n * const result = await simulate(client, {\n * blocks: [{\n * blockOverrides: {\n * number: 69420n,\n * },\n * calls: [{\n * {\n * account: '0x5a0b54d5dc17e482fe8b0bdca5320161b95fb929',\n * data: '0xdeadbeef',\n * to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8',\n * },\n * {\n * account: '0x5a0b54d5dc17e482fe8b0bdca5320161b95fb929',\n * to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8',\n * value: parseEther('1'),\n * },\n * }],\n * stateOverrides: [{\n * address: '0x5a0b54d5dc17e482fe8b0bdca5320161b95fb929',\n * balance: parseEther('10'),\n * }],\n * }]\n * })\n * ```\n *\n * @param client - Client to use.\n * @param parameters - {@link SimulateBlocksParameters}\n * @returns Simulated blocks. {@link SimulateBlocksReturnType}\n */\nexport async function simulateBlocks<\n chain extends Chain | undefined,\n const calls extends readonly unknown[],\n>(\n client: Client<Transport, chain>,\n parameters: SimulateBlocksParameters<calls>,\n): Promise<SimulateBlocksReturnType<calls>> {\n const {\n blockNumber,\n blockTag = 'latest',\n blocks,\n returnFullTransactions,\n traceTransfers,\n validation,\n } = parameters\n\n try {\n const blockStateCalls = []\n for (const block of blocks) {\n const blockOverrides = block.blockOverrides\n ? BlockOverrides.toRpc(block.blockOverrides)\n : undefined\n const calls = block.calls.map((call_) => {\n const call = call_ as Call<unknown, CallExtraProperties>\n const account = call.account ? parseAccount(call.account) : undefined\n const request = {\n ...call,\n data: call.abi ? encodeFunctionData(call) : call.data,\n from: call.from ?? account?.address,\n } as const\n assertRequest(request)\n return formatTransactionRequest(request)\n })\n const stateOverrides = block.stateOverrides\n ? serializeStateOverride(block.stateOverrides)\n : undefined\n\n blockStateCalls.push({\n blockOverrides,\n calls,\n stateOverrides,\n })\n }\n\n const blockNumberHex = blockNumber ? numberToHex(blockNumber) : undefined\n const block = blockNumberHex || blockTag\n\n const result = await client.request({\n method: 'eth_simulateV1',\n params: [\n { blockStateCalls, returnFullTransactions, traceTransfers, validation },\n block,\n ],\n })\n\n return result.map((block, i) => ({\n ...formatBlock(block),\n calls: block.calls.map((call, j) => {\n const { abi, args, functionName, to } = blocks[i].calls[j] as Call<\n unknown,\n CallExtraProperties\n >\n\n const data = call.error?.data ?? call.returnData\n const gasUsed = BigInt(call.gasUsed)\n const logs = call.logs?.map((log) => formatLog(log))\n const status = call.status === '0x1' ? 'success' : 'failure'\n\n const result =\n abi && status === 'success' && data !== '0x'\n ? decodeFunctionResult({\n abi,\n data,\n functionName,\n })\n : null\n\n const error = (() => {\n if (status === 'success') return undefined\n\n let error = undefined\n if (call.error?.data === '0x') error = new AbiDecodingZeroDataError()\n else if (call.error) error = new RawContractError(call.error)\n\n if (!error) return undefined\n return getContractError(error, {\n abi: (abi ?? []) as Abi,\n address: to,\n args,\n functionName: functionName ?? '<unknown>',\n })\n })()\n\n return {\n data,\n gasUsed,\n logs,\n status,\n ...(status === 'success'\n ? {\n result,\n }\n : {\n error,\n }),\n }\n }),\n })) as unknown as SimulateBlocksReturnType<calls>\n } catch (e) {\n const cause = e as BaseError\n const error = getNodeError(cause, {})\n if (error instanceof UnknownNodeError) throw cause\n throw error\n }\n}\n", "import { ripemd160 as noble_ripemd160 } from '@noble/hashes/ripemd160'\nimport { keccak_256 as noble_keccak256 } from '@noble/hashes/sha3'\nimport { sha256 as noble_sha256 } from '@noble/hashes/sha256'\nimport * as Bytes from './Bytes.js'\nimport type * as Errors from './Errors.js'\nimport * as Hex from './Hex.js'\n\n/**\n * Calculates the [Keccak256](https://en.wikipedia.org/wiki/SHA-3) hash of a {@link ox#Bytes.Bytes} or {@link ox#Hex.Hex} value.\n *\n * This function is a re-export of `keccak_256` from [`@noble/hashes`](https://github.com/paulmillr/noble-hashes), an audited & minimal JS hashing library.\n *\n * @example\n * ```ts twoslash\n * import { Hash } from 'ox'\n *\n * Hash.keccak256('0xdeadbeef')\n * // @log: '0xd4fd4e189132273036449fc9e11198c739161b4c0116a9a2dccdfa1c492006f1'\n * ```\n *\n * @example\n * ### Calculate Hash of a String\n *\n * ```ts twoslash\n * import { Hash, Hex } from 'ox'\n *\n * Hash.keccak256(Hex.fromString('hello world'))\n * // @log: '0x3ea2f1d0abf3fc66cf29eebb70cbd4e7fe762ef8a09bcc06c8edf641230afec0'\n * ```\n *\n * @example\n * ### Configure Return Type\n *\n * ```ts twoslash\n * import { Hash } from 'ox'\n *\n * Hash.keccak256('0xdeadbeef', { as: 'Bytes' })\n * // @log: Uint8Array [...]\n * ```\n *\n * @param value - {@link ox#Bytes.Bytes} or {@link ox#Hex.Hex} value.\n * @param options - Options.\n * @returns Keccak256 hash.\n */\nexport function keccak256<\n value extends Hex.Hex | Bytes.Bytes,\n as extends 'Hex' | 'Bytes' =\n | (value extends Hex.Hex ? 'Hex' : never)\n | (value extends Bytes.Bytes ? 'Bytes' : never),\n>(\n value: value | Hex.Hex | Bytes.Bytes,\n options: keccak256.Options<as> = {},\n): keccak256.ReturnType<as> {\n const { as = typeof value === 'string' ? 'Hex' : 'Bytes' } = options\n const bytes = noble_keccak256(Bytes.from(value))\n if (as === 'Bytes') return bytes as never\n return Hex.fromBytes(bytes) as never\n}\n\nexport declare namespace keccak256 {\n type Options<as extends 'Hex' | 'Bytes' = 'Hex' | 'Bytes'> = {\n /** The return type. @default 'Hex' */\n as?: as | 'Hex' | 'Bytes' | undefined\n }\n\n type ReturnType<as extends 'Hex' | 'Bytes' = 'Hex' | 'Bytes'> =\n | (as extends 'Bytes' ? Bytes.Bytes : never)\n | (as extends 'Hex' ? Hex.Hex : never)\n\n type ErrorType =\n | Bytes.from.ErrorType\n | Hex.fromBytes.ErrorType\n | Errors.GlobalErrorType\n}\n\n/**\n * Calculates the [Ripemd160](https://en.wikipedia.org/wiki/RIPEMD) hash of a {@link ox#Bytes.Bytes} or {@link ox#Hex.Hex} value.\n *\n * This function is a re-export of `ripemd160` from [`@noble/hashes`](https://github.com/paulmillr/noble-hashes), an audited & minimal JS hashing library.\n *\n * @example\n * ```ts twoslash\n * import { Hash } from 'ox'\n *\n * Hash.ripemd160('0xdeadbeef')\n * // '0x226821c2f5423e11fe9af68bd285c249db2e4b5a'\n * ```\n *\n * @param value - {@link ox#Bytes.Bytes} or {@link ox#Hex.Hex} value.\n * @param options - Options.\n * @returns Ripemd160 hash.\n */\nexport function ripemd160<\n value extends Hex.Hex | Bytes.Bytes,\n as extends 'Hex' | 'Bytes' =\n | (value extends Hex.Hex ? 'Hex' : never)\n | (value extends Bytes.Bytes ? 'Bytes' : never),\n>(\n value: value | Hex.Hex | Bytes.Bytes,\n options: ripemd160.Options<as> = {},\n): ripemd160.ReturnType<as> {\n const { as = typeof value === 'string' ? 'Hex' : 'Bytes' } = options\n const bytes = noble_ripemd160(Bytes.from(value))\n if (as === 'Bytes') return bytes as never\n return Hex.fromBytes(bytes) as never\n}\n\nexport declare namespace ripemd160 {\n type Options<as extends 'Hex' | 'Bytes' = 'Hex' | 'Bytes'> = {\n /** The return type. @default 'Hex' */\n as?: as | 'Hex' | 'Bytes' | undefined\n }\n\n type ReturnType<as extends 'Hex' | 'Bytes' = 'Hex' | 'Bytes'> =\n | (as extends 'Bytes' ? Bytes.Bytes : never)\n | (as extends 'Hex' ? Hex.Hex : never)\n\n type ErrorType =\n | Bytes.from.ErrorType\n | Hex.fromBytes.ErrorType\n | Errors.GlobalErrorType\n}\n\n/**\n * Calculates the [Sha256](https://en.wikipedia.org/wiki/SHA-256) hash of a {@link ox#Bytes.Bytes} or {@link ox#Hex.Hex} value.\n *\n * This function is a re-export of `sha256` from [`@noble/hashes`](https://github.com/paulmillr/noble-hashes), an audited & minimal JS hashing library.\n *\n * @example\n * ```ts twoslash\n * import { Hash } from 'ox'\n *\n * Hash.sha256('0xdeadbeef')\n * // '0x5f78c33274e43fa9de5659265c1d917e25c03722dcb0b8d27db8d5feaa813953'\n * ```\n *\n * @param value - {@link ox#Bytes.Bytes} or {@link ox#Hex.Hex} value.\n * @param options - Options.\n * @returns Sha256 hash.\n */\nexport function sha256<\n value extends Hex.Hex | Bytes.Bytes,\n as extends 'Hex' | 'Bytes' =\n | (value extends Hex.Hex ? 'Hex' : never)\n | (value extends Bytes.Bytes ? 'Bytes' : never),\n>(\n value: value | Hex.Hex | Bytes.Bytes,\n options: sha256.Options<as> = {},\n): sha256.ReturnType<as> {\n const { as = typeof value === 'string' ? 'Hex' : 'Bytes' } = options\n const bytes = noble_sha256(Bytes.from(value))\n if (as === 'Bytes') return bytes as never\n return Hex.fromBytes(bytes) as never\n}\n\nexport declare namespace sha256 {\n type Options<as extends 'Hex' | 'Bytes' = 'Hex'> = {\n /** The return type. @default 'Hex' */\n as?: as | 'Hex' | 'Bytes' | undefined\n }\n\n type ReturnType<as extends 'Hex' | 'Bytes' = 'Hex'> =\n | (as extends 'Bytes' ? Bytes.Bytes : never)\n | (as extends 'Hex' ? Hex.Hex : never)\n\n type ErrorType =\n | Bytes.from.ErrorType\n | Hex.fromBytes.ErrorType\n | Errors.GlobalErrorType\n}\n\n/**\n * Checks if a string is a valid hash value.\n *\n * @example\n * ```ts twoslash\n * import { Hash } from 'ox'\n *\n * Hash.validate('0x')\n * // @log: false\n *\n * Hash.validate('0x3ea2f1d0abf3fc66cf29eebb70cbd4e7fe762ef8a09bcc06c8edf641230afec0')\n * // @log: true\n * ```\n *\n * @param value - Value to check.\n * @returns Whether the value is a valid hash.\n */\nexport function validate(value: string): value is Hex.Hex {\n return Hex.validate(value) && Hex.size(value) === 32\n}\n\nexport declare namespace validate {\n type ErrorType =\n | Hex.validate.ErrorType\n | Hex.size.ErrorType\n | Errors.GlobalErrorType\n}\n", "/**\n * @internal\n *\n * Map with a LRU (Least recently used) policy.\n * @see https://en.wikipedia.org/wiki/Cache_replacement_policies#LRU\n */\nexport class LruMap<value = unknown> extends Map<string, value> {\n maxSize: number\n\n constructor(size: number) {\n super()\n this.maxSize = size\n }\n\n override get(key: string) {\n const value = super.get(key)\n\n if (super.has(key) && value !== undefined) {\n this.delete(key)\n super.set(key, value)\n }\n\n return value\n }\n\n override set(key: string, value: value) {\n super.set(key, value)\n if (this.maxSize && this.size > this.maxSize) {\n const firstKey = this.keys().next().value\n if (firstKey) this.delete(firstKey)\n }\n return this\n }\n}\n", "import type * as Address from './Address.js'\nimport { LruMap } from './internal/lru.js'\n\nconst caches = {\n checksum: /*#__PURE__*/ new LruMap<Address.Address>(8192),\n}\n\nexport const checksum = caches.checksum\n\n/**\n * Clears all global caches.\n *\n * @example\n * ```ts\n * import { Caches } from 'ox'\n * Caches.clear()\n * ```\n */\nexport function clear() {\n for (const cache of Object.values(caches)) cache.clear()\n}\n", "import type { Address as abitype_Address } from 'abitype'\nimport * as Bytes from './Bytes.js'\nimport * as Caches from './Caches.js'\nimport * as Errors from './Errors.js'\nimport * as Hash from './Hash.js'\nimport * as PublicKey from './PublicKey.js'\n\nconst addressRegex = /*#__PURE__*/ /^0x[a-fA-F0-9]{40}$/\n\n/** Root type for Address. */\nexport type Address = abitype_Address\n\n/**\n * Asserts that the given value is a valid {@link ox#Address.Address}.\n *\n * @example\n * ```ts twoslash\n * import { Address } from 'ox'\n *\n * Address.assert('0xA0Cf798816D4b9b9866b5330EEa46a18382f251e')\n * ```\n *\n * @example\n * ```ts twoslash\n * import { Address } from 'ox'\n *\n * Address.assert('0xdeadbeef')\n * // @error: InvalidAddressError: Address \"0xdeadbeef\" is invalid.\n * ```\n *\n * @param value - Value to assert if it is a valid address.\n * @param options - Assertion options.\n */\nexport function assert(\n value: string,\n options: assert.Options = {},\n): asserts value is Address {\n const { strict = true } = options\n\n if (!addressRegex.test(value))\n throw new InvalidAddressError({\n address: value,\n cause: new InvalidInputError(),\n })\n\n if (strict) {\n if (value.toLowerCase() === value) return\n if (checksum(value as Address) !== value)\n throw new InvalidAddressError({\n address: value,\n cause: new InvalidChecksumError(),\n })\n }\n}\n\nexport declare namespace assert {\n type Options = {\n /**\n * Enables strict mode. Whether or not to compare the address against its checksum.\n *\n * @default true\n */\n strict?: boolean | undefined\n }\n\n type ErrorType = InvalidAddressError | Errors.GlobalErrorType\n}\n\n/**\n * Computes the checksum address for the given {@link ox#Address.Address}.\n *\n * @example\n * ```ts twoslash\n * import { Address } from 'ox'\n *\n * Address.checksum('0xa0cf798816d4b9b9866b5330eea46a18382f251e')\n * // @log: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e'\n * ```\n *\n * @param address - The address to compute the checksum for.\n * @returns The checksummed address.\n */\nexport function checksum(address: string): Address {\n if (Caches.checksum.has(address)) return Caches.checksum.get(address)!\n\n assert(address, { strict: false })\n\n const hexAddress = address.substring(2).toLowerCase()\n const hash = Hash.keccak256(Bytes.fromString(hexAddress), { as: 'Bytes' })\n\n const characters = hexAddress.split('')\n for (let i = 0; i < 40; i += 2) {\n if (hash[i >> 1]! >> 4 >= 8 && characters[i]) {\n characters[i] = characters[i]!.toUpperCase()\n }\n if ((hash[i >> 1]! & 0x0f) >= 8 && characters[i + 1]) {\n characters[i + 1] = characters[i + 1]!.toUpperCase()\n }\n }\n\n const result = `0x${characters.join('')}` as const\n Caches.checksum.set(address, result)\n return result\n}\n\nexport declare namespace checksum {\n type ErrorType =\n | assert.ErrorType\n | Hash.keccak256.ErrorType\n | Bytes.fromString.ErrorType\n | Errors.GlobalErrorType\n}\n\n/**\n * Converts a stringified address to a typed (checksummed) {@link ox#Address.Address}.\n *\n * @example\n * ```ts twoslash\n * import { Address } from 'ox'\n *\n * Address.from('0xa0cf798816d4b9b9866b5330eea46a18382f251e')\n * // @log: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e'\n * ```\n *\n * @example\n * ```ts twoslash\n * import { Address } from 'ox'\n *\n * Address.from('0xa0cf798816d4b9b9866b5330eea46a18382f251e', {\n * checksum: false\n * })\n * // @log: '0xa0cf798816d4b9b9866b5330eea46a18382f251e'\n * ```\n *\n * @example\n * ```ts twoslash\n * import { Address } from 'ox'\n *\n * Address.from('hello')\n * // @error: InvalidAddressError: Address \"0xa\" is invalid.\n * ```\n *\n * @param address - An address string to convert to a typed Address.\n * @param options - Conversion options.\n * @returns The typed Address.\n */\nexport function from(address: string, options: from.Options = {}): Address {\n const { checksum: checksumVal = false } = options\n assert(address)\n if (checksumVal) return checksum(address)\n return address as Address\n}\n\nexport declare namespace from {\n type Options = {\n /**\n * Whether to checksum the address.\n *\n * @default false\n */\n checksum?: boolean | undefined\n }\n\n type ErrorType =\n | assert.ErrorType\n | checksum.ErrorType\n | Errors.GlobalErrorType\n}\n\n/**\n * Converts an ECDSA public key to an {@link ox#Address.Address}.\n *\n * @example\n * ```ts twoslash\n * import { Address, PublicKey } from 'ox'\n *\n * const publicKey = PublicKey.from(\n * '0x048318535b54105d4a7aae60c08fc45f9687181b4fdfc625bd1a753fa7397fed753547f11ca8696646f2f3acb08e31016afac23e630c5d11f59f61fef57b0d2aa5',\n * )\n * const address = Address.fromPublicKey(publicKey)\n * // @log: '0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266'\n * ```\n *\n * @param publicKey - The ECDSA public key to convert to an {@link ox#Address.Address}.\n * @param options - Conversion options.\n * @returns The {@link ox#Address.Address} corresponding to the public key.\n */\nexport function fromPublicKey(\n publicKey: PublicKey.PublicKey,\n options: fromPublicKey.Options = {},\n): Address {\n const address = Hash.keccak256(\n `0x${PublicKey.toHex(publicKey).slice(4)}`,\n ).substring(26)\n return from(`0x${address}`, options)\n}\n\nexport declare namespace fromPublicKey {\n type Options = {\n /**\n * Whether to checksum the address.\n *\n * @default false\n */\n checksum?: boolean | undefined\n }\n\n type ErrorType =\n | Hash.keccak256.ErrorType\n | PublicKey.toHex.ErrorType\n | Errors.GlobalErrorType\n}\n\n/**\n * Checks if two {@link ox#Address.Address} are equal.\n *\n * @example\n * ```ts twoslash\n * import { Address } from 'ox'\n *\n * Address.isEqual(\n * '0xa0cf798816d4b9b9866b5330eea46a18382f251e',\n * '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e'\n * )\n * // @log: true\n * ```\n *\n * @example\n * ```ts twoslash\n * import { Address } from 'ox'\n *\n * Address.isEqual(\n * '0xa0cf798816d4b9b9866b5330eea46a18382f251e',\n * '0xA0Cf798816D4b9b9866b5330EEa46a18382f251f'\n * )\n * // @log: false\n * ```\n *\n * @param addressA - The first address to compare.\n * @param addressB - The second address to compare.\n * @returns Whether the addresses are equal.\n */\nexport function isEqual(addressA: Address, addressB: Address): boolean {\n assert(addressA, { strict: false })\n assert(addressB, { strict: false })\n return addressA.toLowerCase() === addressB.toLowerCase()\n}\n\nexport declare namespace isEqual {\n type ErrorType = assert.ErrorType | Errors.GlobalErrorType\n}\n\n/**\n * Checks if the given address is a valid {@link ox#Address.Address}.\n *\n * @example\n * ```ts twoslash\n * import { Address } from 'ox'\n *\n * Address.validate('0xA0Cf798816D4b9b9866b5330EEa46a18382f251e')\n * // @log: true\n * ```\n *\n * @example\n * ```ts twoslash\n * import { Address } from 'ox'\n *\n * Address.validate('0xdeadbeef')\n * // @log: false\n * ```\n *\n * @param address - Value to check if it is a valid address.\n * @param options - Check options.\n * @returns Whether the address is a valid address.\n */\nexport function validate(\n address: string,\n options: validate.Options = {},\n): address is Address {\n const { strict = true } = options ?? {}\n try {\n assert(address, { strict })\n return true\n } catch {\n return false\n }\n}\n\nexport declare namespace validate {\n type Options = {\n /**\n * Enables strict mode. Whether or not to compare the address against its checksum.\n *\n * @default true\n */\n strict?: boolean | undefined\n }\n}\n\n/**\n * Thrown when an address is invalid.\n *\n * @example\n * ```ts twoslash\n * import { Address } from 'ox'\n *\n * Address.from('0x123')\n * // @error: Address.InvalidAddressError: Address `0x123` is invalid.\n * ```\n */\nexport class InvalidAddressError<\n cause extends InvalidInputError | InvalidChecksumError =\n | InvalidInputError\n | InvalidChecksumError,\n> extends Errors.BaseError<cause> {\n override readonly name = 'Address.InvalidAddressError'\n\n constructor({ address, cause }: { address: string; cause: cause }) {\n super(`Address \"${address}\" is invalid.`, {\n cause,\n })\n }\n}\n\n/** Thrown when an address is not a 20 byte (40 hexadecimal character) value. */\nexport class InvalidInputError extends Errors.BaseError {\n override readonly name = 'Address.InvalidInputError'\n\n constructor() {\n super('Address is not a 20 byte (40 hexadecimal character) value.')\n }\n}\n\n/** Thrown when an address does not match its checksum counterpart. */\nexport class InvalidChecksumError extends Errors.BaseError {\n override readonly name = 'Address.InvalidChecksumError'\n\n constructor() {\n super('Address does not match its checksum counterpart.')\n }\n}\n", "import type * as abitype from 'abitype'\nimport type * as Abi from '../Abi.js'\nimport type * as AbiItem from '../AbiItem.js'\nimport type * as AbiParameters from '../AbiParameters.js'\nimport * as Address from '../Address.js'\nimport * as Errors from '../Errors.js'\nimport type {\n Compute,\n IsNever,\n IsUnion,\n TypeErrorMessage,\n UnionToTuple,\n} from './types.js'\n\n/** @internal */\nexport type ExtractArgs<\n abi extends Abi.Abi | readonly unknown[] = Abi.Abi,\n name extends AbiItem.Name<abi> = AbiItem.Name<abi>,\n> = abitype.AbiParametersToPrimitiveTypes<\n AbiItem.FromAbi<abi extends Abi.Abi ? abi : Abi.Abi, name>['inputs'],\n 'inputs'\n> extends infer args\n ? [args] extends [never]\n ? readonly unknown[]\n : args\n : readonly unknown[]\n\n/** @internal */\nexport type ExtractForArgs<\n abi extends Abi.Abi,\n name extends AbiItem.Name<abi>,\n args extends ExtractArgs<abi, name>,\n> = IsUnion<name> extends true\n ? {\n [key in keyof abi]: abi[key] extends { name: name } ? abi[key] : never\n }[number]\n : AbiItem.FromAbi<abi, name> extends infer abiItem extends AbiItem.AbiItem & {\n inputs: readonly abitype.AbiParameter[]\n }\n ? IsUnion<abiItem> extends true // narrow overloads using `args` by converting to tuple and filtering out overloads that don't match\n ? UnionToTuple<abiItem> extends infer abiItems extends\n readonly (AbiItem.AbiItem & {\n inputs: readonly abitype.AbiParameter[]\n })[]\n ? IsNever<TupleToUnion<abiItems, abi, name, args>> extends true\n ? Compute<\n abiItems[0] & {\n readonly overloads: UnionToTuple<\n Exclude<abiItems[number], abiItems[0]>\n >\n }\n >\n : TupleToUnion<abiItems, abi, name, args> // convert back to union (removes `never` tuple entries: `['foo', never, 'bar'][number]` => `'foo' | 'bar'`)\n : never\n : abiItem\n : never\n\n/** @internal */\nexport type TupleToUnion<\n abiItems extends readonly {\n inputs: readonly abitype.AbiParameter[]\n }[],\n abi extends Abi.Abi,\n name extends AbiItem.Name<abi>,\n args extends ExtractArgs<abi, name>,\n> = {\n [k in keyof abiItems]: (\n readonly [] extends args\n ? readonly [] // fallback to `readonly []` if `args` has no value (e.g. `args` property not provided)\n : args\n ) extends abitype.AbiParametersToPrimitiveTypes<\n abiItems[k]['inputs'],\n 'inputs'\n >\n ? abiItems[k]\n : never\n}[number]\n\n/** @internal */\nexport type ErrorSignature<\n name extends string = string,\n parameters extends string = string,\n> = `error ${name}(${parameters})`\n\n/** @internal */\nexport type IsErrorSignature<signature extends string> =\n signature extends ErrorSignature<infer name> ? IsName<name> : false\n\n/** @internal */\nexport type EventSignature<\n name extends string = string,\n parameters extends string = string,\n> = `event ${name}(${parameters})`\n\n/** @internal */\nexport type IsEventSignature<signature extends string> =\n signature extends EventSignature<infer name> ? IsName<name> : false\n\n/** @internal */\nexport type FunctionSignature<\n name extends string = string,\n tail extends string = string,\n> = `function ${name}(${tail}`\nexport type IsFunctionSignature<signature> =\n signature extends FunctionSignature<infer name>\n ? IsName<name> extends true\n ? signature extends ValidFunctionSignatures\n ? true\n : // Check that `Parameters` is not absorbing other types (e.g. `returns`)\n signature extends `function ${string}(${infer parameters})`\n ? parameters extends InvalidFunctionParameters\n ? false\n : true\n : false\n : false\n : false\n/** @internal */\nexport type Scope = 'public' | 'external' // `internal` or `private` functions wouldn't make it to ABI so can ignore\n\n/** @internal */\nexport type Returns = `returns (${string})` | `returns(${string})`\n\n// Almost all valid function signatures, except `function ${string}(${infer parameters})` since `parameters` can absorb returns\n/** @internal */\nexport type ValidFunctionSignatures =\n | `function ${string}()`\n // basic\n | `function ${string}() ${Returns}`\n | `function ${string}() ${abitype.AbiStateMutability}`\n | `function ${string}() ${Scope}`\n // combinations\n | `function ${string}() ${abitype.AbiStateMutability} ${Returns}`\n | `function ${string}() ${Scope} ${Returns}`\n | `function ${string}() ${Scope} ${abitype.AbiStateMutability}`\n | `function ${string}() ${Scope} ${abitype.AbiStateMutability} ${Returns}`\n // Parameters\n | `function ${string}(${string}) ${Returns}`\n | `function ${string}(${string}) ${abitype.AbiStateMutability}`\n | `function ${string}(${string}) ${Scope}`\n | `function ${string}(${string}) ${abitype.AbiStateMutability} ${Returns}`\n | `function ${string}(${string}) ${Scope} ${Returns}`\n | `function ${string}(${string}) ${Scope} ${abitype.AbiStateMutability}`\n | `function ${string}(${string}) ${Scope} ${abitype.AbiStateMutability} ${Returns}`\n\n/** @internal */\nexport type StructSignature<\n name extends string = string,\n properties extends string = string,\n> = `struct ${name} {${properties}}`\n\n/** @internal */\nexport type IsStructSignature<signature extends string> =\n signature extends StructSignature<infer name> ? IsName<name> : false\n\n/** @internal */\nexport type ConstructorSignature<tail extends string = string> =\n `constructor(${tail}`\n\n/** @internal */\nexport type IsConstructorSignature<signature> =\n signature extends ConstructorSignature\n ? signature extends ValidConstructorSignatures\n ? true\n : false\n : false\n\n/** @internal */\nexport type ValidConstructorSignatures =\n | `constructor(${string})`\n | `constructor(${string}) payable`\n\n/** @internal */\nexport type FallbackSignature<abiStateMutability extends '' | ' payable' = ''> =\n `fallback() external${abiStateMutability}`\n\n/** @internal */\nexport type ReceiveSignature = 'receive() external payable'\n\n// TODO: Maybe use this for signature validation one day\n// https://twitter.com/devanshj__/status/1610423724708343808\n/** @internal */\nexport type IsSignature<type extends string> =\n | (IsErrorSignature<type> extends true ? true : never)\n | (IsEventSignature<type> extends true ? true : never)\n | (IsFunctionSignature<type> extends true ? true : never)\n | (IsStructSignature<type> extends true ? true : never)\n | (IsConstructorSignature<type> extends true ? true : never)\n | (type extends FallbackSignature ? true : never)\n | (type extends ReceiveSignature ? true : never) extends infer condition\n ? [condition] extends [never]\n ? false\n : true\n : false\n\n/** @internal */\nexport type Signature<\n string1 extends string,\n string2 extends string | unknown = unknown,\n> = IsSignature<string1> extends true\n ? string1\n : string extends string1 // if exactly `string` (not narrowed), then pass through as valid\n ? string1\n : TypeErrorMessage<`Signature \"${string1}\" is invalid${string2 extends string\n ? ` at position ${string2}`\n : ''}.`>\n\n/** @internal */\nexport type Signatures<signatures extends readonly string[]> = {\n [key in keyof signatures]: Signature<signatures[key], key>\n}\n\n/** @internal */\nexport type IsName<name extends string> = name extends ''\n ? false\n : ValidateName<name> extends name\n ? true\n : false\n\n/** @internal */\nexport type ValidateName<\n name extends string,\n checkCharacters extends boolean = false,\n> = name extends `${string}${' '}${string}`\n ? TypeErrorMessage<`Identifier \"${name}\" cannot contain whitespace.`>\n : IsSolidityKeyword<name> extends true\n ? TypeErrorMessage<`\"${name}\" is a protected Solidity keyword.`>\n : name extends `${number}`\n ? TypeErrorMessage<`Identifier \"${name}\" cannot be a number string.`>\n : name extends `${number}${string}`\n ? TypeErrorMessage<`Identifier \"${name}\" cannot start with a number.`>\n : checkCharacters extends true\n ? IsValidCharacter<name> extends true\n ? name\n : TypeErrorMessage<`\"${name}\" contains invalid character.`>\n : name\n\n/** @internal */\nexport type IsSolidityKeyword<type extends string> =\n type extends SolidityKeywords ? true : false\n\n/** @internal */\nexport type SolidityKeywords =\n | 'after'\n | 'alias'\n | 'anonymous'\n | 'apply'\n | 'auto'\n | 'byte'\n | 'calldata'\n | 'case'\n | 'catch'\n | 'constant'\n | 'copyof'\n | 'default'\n | 'defined'\n | 'error'\n | 'event'\n | 'external'\n | 'false'\n | 'final'\n | 'function'\n | 'immutable'\n | 'implements'\n | 'in'\n | 'indexed'\n | 'inline'\n | 'internal'\n | 'let'\n | 'mapping'\n | 'match'\n | 'memory'\n | 'mutable'\n | 'null'\n | 'of'\n | 'override'\n | 'partial'\n | 'private'\n | 'promise'\n | 'public'\n | 'pure'\n | 'reference'\n | 'relocatable'\n | 'return'\n | 'returns'\n | 'sizeof'\n | 'static'\n | 'storage'\n | 'struct'\n | 'super'\n | 'supports'\n | 'switch'\n | 'this'\n | 'true'\n | 'try'\n | 'typedef'\n | 'typeof'\n | 'var'\n | 'view'\n | 'virtual'\n | `address${`[${string}]` | ''}`\n | `bool${`[${string}]` | ''}`\n | `string${`[${string}]` | ''}`\n | `tuple${`[${string}]` | ''}`\n | `bytes${number | ''}${`[${string}]` | ''}`\n | `${'u' | ''}int${number | ''}${`[${string}]` | ''}`\n\n/** @internal */\nexport type IsValidCharacter<character extends string> =\n character extends `${ValidCharacters}${infer tail}`\n ? tail extends ''\n ? true\n : IsValidCharacter<tail>\n : false\n\n// biome-ignore format: no formatting\n/** @internal */\nexport type ValidCharacters =\n // uppercase letters\n | 'A' | 'B' | 'C' | 'D' | 'E' | 'F' | 'G' | 'H' | 'I' | 'J' | 'K' | 'L' | 'M' | 'N' | 'O' | 'P' | 'Q' | 'R' | 'S' | 'T' | 'U' | 'V' | 'W' | 'X' | 'Y' | 'Z'\n // lowercase letters\n | 'a' | 'b' | 'c' | 'd' | 'e' | 'f' | 'g' | 'h' | 'i' | 'j' | 'k' | 'l' | 'm' | 'n' | 'o' | 'p' | 'q' | 'r' | 's' | 't' | 'u' | 'v' | 'w' | 'x' | 'y' | 'z'\n // numbers\n | '0' | '1' | '2' | '3' | '4' | '5' | '6' | '7' | '8' | '9'\n // special characters\n | '_' | '$'\n\n// Template string inference can absorb `returns`:\n// type Result = `function foo(string) return s (uint256)` extends `function ${string}(${infer Parameters})` ? Parameters : never\n// // ^? type Result = \"string ) return s (uint256\"\n// So we need to validate against `returns` keyword with all combinations of whitespace\n/** @internal */\nexport type InvalidFunctionParameters =\n | `${string}${MangledReturns} (${string}`\n | `${string}) ${MangledReturns}${string}`\n | `${string})${string}${MangledReturns}${string}(${string}`\n\n// r_e_t_u_r_n_s\n/** @internal */\nexport type MangledReturns =\n // Single\n | `r${string}eturns`\n | `re${string}turns`\n | `ret${string}urns`\n | `retu${string}rns`\n | `retur${string}ns`\n | `return${string}s`\n // Double\n // `r_e*`\n | `r${string}e${string}turns`\n | `r${string}et${string}urns`\n | `r${string}etu${string}rns`\n | `r${string}etur${string}ns`\n | `r${string}eturn${string}s`\n // `re_t*`\n | `re${string}t${string}urns`\n | `re${string}tu${string}rns`\n | `re${string}tur${string}ns`\n | `re${string}turn${string}s`\n // `ret_u*`\n | `ret${string}u${string}rns`\n | `ret${string}ur${string}ns`\n | `ret${string}urn${string}s`\n // `retu_r*`\n | `retu${string}r${string}ns`\n | `retu${string}rn${string}s`\n // `retur_n*`\n | `retur${string}n${string}s`\n // Triple\n // `r_e_t*`\n | `r${string}e${string}t${string}urns`\n | `r${string}e${string}tu${string}rns`\n | `r${string}e${string}tur${string}ns`\n | `r${string}e${string}turn${string}s`\n // `re_t_u*`\n | `re${string}t${string}u${string}rns`\n | `re${string}t${string}ur${string}ns`\n | `re${string}t${string}urn${string}s`\n // `ret_u_r*`\n | `ret${string}u${string}r${string}ns`\n | `ret${string}u${string}rn${string}s`\n // `retu_r_n*`\n | `retu${string}r${string}n${string}s`\n // Quadruple\n // `r_e_t_u*`\n | `r${string}e${string}t${string}u${string}rns`\n | `r${string}e${string}t${string}ur${string}ns`\n | `r${string}e${string}t${string}urn${string}s`\n // `re_t_u_r*`\n | `re${string}t${string}u${string}r${string}ns`\n | `re${string}t${string}u${string}rn${string}s`\n // `ret_u_r_n*`\n | `ret${string}u${string}r${string}n${string}s`\n // Quintuple\n // `r_e_t_u_r*`\n | `r${string}e${string}t${string}u${string}r${string}ns`\n | `r${string}e${string}t${string}u${string}rn${string}s`\n // `re_t_u_r_n*`\n | `re${string}t${string}u${string}r${string}n${string}s`\n // Sextuple\n // `r_e_t_u_r_n_s`\n | `r${string}e${string}t${string}u${string}r${string}n${string}s`\n\n/** @internal */\nexport type Widen<type> =\n | ([unknown] extends [type] ? unknown : never)\n | (type extends Function ? type : never)\n | (type extends abitype.ResolvedRegister['bigIntType'] ? bigint : never)\n | (type extends boolean ? boolean : never)\n | (type extends abitype.ResolvedRegister['intType'] ? number : never)\n | (type extends string\n ? type extends abitype.ResolvedRegister['addressType']\n ? abitype.ResolvedRegister['addressType']\n : type extends abitype.ResolvedRegister['bytesType']['inputs']\n ? abitype.ResolvedRegister['bytesType']\n : string\n : never)\n | (type extends readonly [] ? readonly [] : never)\n | (type extends Record<string, unknown>\n ? { [K in keyof type]: Widen<type[K]> }\n : never)\n | (type extends { length: number }\n ? {\n [K in keyof type]: Widen<type[K]>\n } extends infer Val extends readonly unknown[]\n ? readonly [...Val]\n : never\n : never)\n\n/** @internal */\nexport function normalizeSignature(signature: string): string {\n let active = true\n let current = ''\n let level = 0\n let result = ''\n let valid = false\n\n for (let i = 0; i < signature.length; i++) {\n const char = signature[i]!\n\n // If the character is a separator, we want to reactivate.\n if (['(', ')', ','].includes(char)) active = true\n\n // If the character is a \"level\" token, we want to increment/decrement.\n if (char === '(') level++\n if (char === ')') level--\n\n // If we aren't active, we don't want to mutate the result.\n if (!active) continue\n\n // If level === 0, we are at the definition level.\n if (level === 0) {\n if (char === ' ' && ['event', 'function', 'error', ''].includes(result))\n result = ''\n else {\n result += char\n\n // If we are at the end of the definition, we must be finished.\n if (char === ')') {\n valid = true\n break\n }\n }\n\n continue\n }\n\n // Ignore spaces\n if (char === ' ') {\n // If the previous character is a separator, and the current section isn't empty, we want to deactivate.\n if (signature[i - 1] !== ',' && current !== ',' && current !== ',(') {\n current = ''\n active = false\n }\n continue\n }\n\n result += char\n current += char\n }\n\n if (!valid) throw new Errors.BaseError('Unable to normalize signature.')\n\n return result\n}\n\n/** @internal */\nexport declare namespace normalizeSignature {\n export type ErrorType = Errors.BaseError | Errors.GlobalErrorType\n}\n\n/** @internal */\nexport function isArgOfType(\n arg: unknown,\n abiParameter: AbiParameters.Parameter,\n): boolean {\n const argType = typeof arg\n const abiParameterType = abiParameter.type\n switch (abiParameterType) {\n case 'address':\n return Address.validate(arg as Address.Address, { strict: false })\n case 'bool':\n return argType === 'boolean'\n case 'function':\n return argType === 'string'\n case 'string':\n return argType === 'string'\n default: {\n if (abiParameterType === 'tuple' && 'components' in abiParameter)\n return Object.values(abiParameter.components).every(\n (component, index) => {\n return isArgOfType(\n Object.values(arg as unknown[] | Record<string, unknown>)[index],\n component as AbiParameters.Parameter,\n )\n },\n )\n\n // `(u)int<M>`: (un)signed integer type of `M` bits, `0 < M <= 256`, `M % 8 == 0`\n // https://regexr.com/6v8hp\n if (\n /^u?int(8|16|24|32|40|48|56|64|72|80|88|96|104|112|120|128|136|144|152|160|168|176|184|192|200|208|216|224|232|240|248|256)?$/.test(\n abiParameterType,\n )\n )\n return argType === 'number' || argType === 'bigint'\n\n // `bytes<M>`: binary type of `M` bytes, `0 < M <= 32`\n // https://regexr.com/6va55\n if (/^bytes([1-9]|1[0-9]|2[0-9]|3[0-2])?$/.test(abiParameterType))\n return argType === 'string' || arg instanceof Uint8Array\n\n // fixed-length (`<type>[M]`) and dynamic (`<type>[]`) arrays\n // https://regexr.com/6va6i\n if (/[a-z]+[1-9]{0,3}(\\[[0-9]{0,}\\])+$/.test(abiParameterType)) {\n return (\n Array.isArray(arg) &&\n arg.every((x: unknown) =>\n isArgOfType(x, {\n ...abiParameter,\n // Pop off `[]` or `[M]` from end of type\n type: abiParameterType.replace(/(\\[[0-9]{0,}\\])$/, ''),\n } as AbiParameters.Parameter),\n )\n )\n }\n\n return false\n }\n }\n}\n\n/** @internal */\nexport function getAmbiguousTypes(\n sourceParameters: readonly AbiParameters.Parameter[],\n targetParameters: readonly AbiParameters.Parameter[],\n args: ExtractArgs,\n): AbiParameters.Parameter['type'][] | undefined {\n for (const parameterIndex in sourceParameters) {\n const sourceParameter = sourceParameters[parameterIndex]!\n const targetParameter = targetParameters[parameterIndex]!\n\n if (\n sourceParameter.type === 'tuple' &&\n targetParameter.type === 'tuple' &&\n 'components' in sourceParameter &&\n 'components' in targetParameter\n )\n return getAmbiguousTypes(\n sourceParameter.components,\n targetParameter.components,\n (args as any)[parameterIndex],\n )\n\n const types = [sourceParameter.type, targetParameter.type]\n\n const ambiguous = (() => {\n if (types.includes('address') && types.includes('bytes20')) return true\n if (types.includes('address') && types.includes('string'))\n return Address.validate(args[parameterIndex] as Address.Address, {\n strict: false,\n })\n if (types.includes('address') && types.includes('bytes'))\n return Address.validate(args[parameterIndex] as Address.Address, {\n strict: false,\n })\n return false\n })()\n\n if (ambiguous) return types\n }\n\n return\n}\n", "import * as abitype from 'abitype'\nimport type * as Abi from './Abi.js'\nimport * as Errors from './Errors.js'\nimport * as Hash from './Hash.js'\nimport * as Hex from './Hex.js'\nimport * as internal from './internal/abiItem.js'\nimport type { UnionCompute } from './internal/types.js'\n\n/** Root type for an item on an {@link ox#Abi.Abi}. */\nexport type AbiItem = Abi.Abi[number]\n\n/**\n * Extracts an {@link ox#AbiItem.AbiItem} item from an {@link ox#Abi.Abi}, given a name.\n *\n * @example\n * ```ts twoslash\n * import { Abi, AbiItem } from 'ox'\n *\n * const abi = Abi.from([\n * 'error Foo(string)',\n * 'function foo(string)',\n * 'event Bar(uint256)',\n * ])\n *\n * type Foo = AbiItem.FromAbi<typeof abi, 'Foo'>\n * // ^?\n *\n *\n *\n *\n *\n *\n *\n *\n * ```\n */\nexport type FromAbi<\n abi extends Abi.Abi,\n name extends ExtractNames<abi>,\n> = Extract<abi[number], { name: name }>\n\n/**\n * Extracts the names of all {@link ox#AbiItem.AbiItem} items in an {@link ox#Abi.Abi}.\n *\n * @example\n * ```ts twoslash\n * import { Abi, AbiItem } from 'ox'\n *\n * const abi = Abi.from([\n * 'error Foo(string)',\n * 'function foo(string)',\n * 'event Bar(uint256)',\n * ])\n *\n * type names = AbiItem.Name<typeof abi>\n * // ^?\n *\n * ```\n */\nexport type Name<abi extends Abi.Abi | readonly unknown[] = Abi.Abi> =\n abi extends Abi.Abi ? ExtractNames<abi> : string\n\nexport type ExtractNames<abi extends Abi.Abi> = Extract<\n abi[number],\n { name: string }\n>['name']\n\n/**\n * Formats an {@link ox#AbiItem.AbiItem} into a **Human Readable ABI Item**.\n *\n * @example\n * ```ts twoslash\n * import { AbiItem } from 'ox'\n *\n * const formatted = AbiItem.format({\n * type: 'function',\n * name: 'approve',\n * stateMutability: 'nonpayable',\n * inputs: [\n * {\n * name: 'spender',\n * type: 'address',\n * },\n * {\n * name: 'amount',\n * type: 'uint256',\n * },\n * ],\n * outputs: [{ type: 'bool' }],\n * })\n *\n * formatted\n * // ^?\n *\n *\n * ```\n *\n * @param abiItem - The ABI Item to format.\n * @returns The formatted ABI Item .\n */\nexport function format<const abiItem extends AbiItem>(\n abiItem: abiItem | AbiItem,\n): abitype.FormatAbiItem<abiItem> {\n return abitype.formatAbiItem(abiItem) as never\n}\n\nexport declare namespace format {\n type ErrorType = Errors.GlobalErrorType\n}\n\n/**\n * Parses an arbitrary **JSON ABI Item** or **Human Readable ABI Item** into a typed {@link ox#AbiItem.AbiItem}.\n *\n * @example\n * ### JSON ABIs\n *\n * ```ts twoslash\n * import { AbiItem } from 'ox'\n *\n * const abiItem = AbiItem.from({\n * type: 'function',\n * name: 'approve',\n * stateMutability: 'nonpayable',\n * inputs: [\n * {\n * name: 'spender',\n * type: 'address',\n * },\n * {\n * name: 'amount',\n * type: 'uint256',\n * },\n * ],\n * outputs: [{ type: 'bool' }],\n * })\n *\n * abiItem\n * //^?\n *\n *\n *\n *\n *\n *\n *\n *\n *\n *\n *\n *\n * ```\n *\n * @example\n * ### Human Readable ABIs\n *\n * A Human Readable ABI can be parsed into a typed ABI object:\n *\n * ```ts twoslash\n * import { AbiItem } from 'ox'\n *\n * const abiItem = AbiItem.from(\n * 'function approve(address spender, uint256 amount) returns (bool)' // [!code hl]\n * )\n *\n * abiItem\n * //^?\n *\n *\n *\n *\n *\n *\n *\n *\n *\n *\n *\n *\n *\n * ```\n *\n * @example\n * It is possible to specify `struct`s along with your definitions:\n *\n * ```ts twoslash\n * import { AbiItem } from 'ox'\n *\n * const abiItem = AbiItem.from([\n * 'struct Foo { address spender; uint256 amount; }', // [!code hl]\n * 'function approve(Foo foo) returns (bool)',\n * ])\n *\n * abiItem\n * //^?\n *\n *\n *\n *\n *\n *\n *\n *\n *\n *\n *\n *\n * ```\n *\n *\n *\n * @param abiItem - The ABI Item to parse.\n * @returns The typed ABI Item.\n */\nexport function from<\n const abiItem extends AbiItem | string | readonly string[],\n>(\n abiItem: (abiItem | AbiItem | string | readonly string[]) &\n (\n | (abiItem extends string ? internal.Signature<abiItem> : never)\n | (abiItem extends readonly string[]\n ? internal.Signatures<abiItem>\n : never)\n | AbiItem\n ),\n options: from.Options = {},\n): from.ReturnType<abiItem> {\n const { prepare = true } = options\n const item = (() => {\n if (Array.isArray(abiItem)) return abitype.parseAbiItem(abiItem)\n if (typeof abiItem === 'string')\n return abitype.parseAbiItem(abiItem as never)\n return abiItem\n })() as AbiItem\n return {\n ...item,\n ...(prepare ? { hash: getSignatureHash(item) } : {}),\n } as never\n}\n\nexport declare namespace from {\n type Options = {\n /**\n * Whether or not to prepare the extracted item (optimization for encoding performance).\n * When `true`, the `hash` property is computed and included in the returned value.\n *\n * @default true\n */\n prepare?: boolean | undefined\n }\n\n type ReturnType<abiItem extends AbiItem | string | readonly string[]> =\n abiItem extends string\n ? abitype.ParseAbiItem<abiItem>\n : abiItem extends readonly string[]\n ? abitype.ParseAbiItem<abiItem>\n : abiItem\n\n type ErrorType = Errors.GlobalErrorType\n}\n\n/**\n * Extracts an {@link ox#AbiItem.AbiItem} from an {@link ox#Abi.Abi} given a name and optional arguments.\n *\n * @example\n * ABI Items can be extracted by their name using the `name` option:\n *\n * ```ts twoslash\n * import { Abi, AbiItem } from 'ox'\n *\n * const abi = Abi.from([\n * 'function foo()',\n * 'event Transfer(address owner, address to, uint256 tokenId)',\n * 'function bar(string a) returns (uint256 x)',\n * ])\n *\n * const item = AbiItem.fromAbi(abi, 'Transfer') // [!code focus]\n * // ^?\n *\n *\n *\n *\n *\n *\n * ```\n *\n * @example\n * ### Extracting by Selector\n *\n * ABI Items can be extract by their selector when {@link ox#Hex.Hex} is provided to `name`.\n *\n * ```ts twoslash\n * import { Abi, AbiItem } from 'ox'\n *\n * const abi = Abi.from([\n * 'function foo()',\n * 'event Transfer(address owner, address to, uint256 tokenId)',\n * 'function bar(string a) returns (uint256 x)',\n * ])\n * const item = AbiItem.fromAbi(abi, '0x095ea7b3') // [!code focus]\n * // ^?\n *\n *\n *\n *\n *\n *\n *\n *\n *\n *\n *\n *\n *\n * ```\n *\n * :::note\n *\n * Extracting via a hex selector is useful when extracting an ABI Item from an `eth_call` RPC response,\n * a Transaction `input`, or from Event Log `topics`.\n *\n * :::\n *\n * @param abi - The ABI to extract from.\n * @param name - The name (or selector) of the ABI item to extract.\n * @param options - Extraction options.\n * @returns The ABI item.\n */\nexport function fromAbi<\n const abi extends Abi.Abi | readonly unknown[],\n name extends Name<abi>,\n const args extends internal.ExtractArgs<abi, name> | undefined = undefined,\n //\n allNames = Name<abi>,\n>(\n abi: abi | Abi.Abi | readonly unknown[],\n name: Hex.Hex | (name extends allNames ? name : never),\n options?: fromAbi.Options<abi, name, args>,\n): fromAbi.ReturnType<abi, name, args> {\n const { args = [], prepare = true } = (options ??\n {}) as unknown as fromAbi.Options\n\n const isSelector = Hex.validate(name, { strict: false })\n const abiItems = (abi as Abi.Abi).filter((abiItem) => {\n if (isSelector) {\n if (abiItem.type === 'function' || abiItem.type === 'error')\n return getSelector(abiItem) === Hex.slice(name, 0, 4)\n if (abiItem.type === 'event') return getSignatureHash(abiItem) === name\n return false\n }\n return 'name' in abiItem && abiItem.name === name\n })\n\n if (abiItems.length === 0) throw new NotFoundError({ name: name as string })\n if (abiItems.length === 1)\n return {\n ...abiItems[0],\n ...(prepare ? { hash: getSignatureHash(abiItems[0]!) } : {}),\n } as never\n\n let matchedAbiItem: AbiItem | undefined = undefined\n for (const abiItem of abiItems) {\n if (!('inputs' in abiItem)) continue\n if (!args || args.length === 0) {\n if (!abiItem.inputs || abiItem.inputs.length === 0)\n return {\n ...abiItem,\n ...(prepare ? { hash: getSignatureHash(abiItem) } : {}),\n } as never\n continue\n }\n if (!abiItem.inputs) continue\n if (abiItem.inputs.length === 0) continue\n if (abiItem.inputs.length !== args.length) continue\n const matched = args.every((arg, index) => {\n const abiParameter = 'inputs' in abiItem && abiItem.inputs![index]\n if (!abiParameter) return false\n return internal.isArgOfType(arg, abiParameter)\n })\n if (matched) {\n // Check for ambiguity against already matched parameters (e.g. `address` vs `bytes20`).\n if (\n matchedAbiItem &&\n 'inputs' in matchedAbiItem &&\n matchedAbiItem.inputs\n ) {\n const ambiguousTypes = internal.getAmbiguousTypes(\n abiItem.inputs,\n matchedAbiItem.inputs,\n args as readonly unknown[],\n )\n if (ambiguousTypes)\n throw new AmbiguityError(\n {\n abiItem,\n type: ambiguousTypes[0]!,\n },\n {\n abiItem: matchedAbiItem,\n type: ambiguousTypes[1]!,\n },\n )\n }\n\n matchedAbiItem = abiItem\n }\n }\n\n const abiItem = (() => {\n if (matchedAbiItem) return matchedAbiItem\n const [abiItem, ...overloads] = abiItems\n return { ...abiItem!, overloads }\n })()\n\n if (!abiItem) throw new NotFoundError({ name: name as string })\n return {\n ...abiItem,\n ...(prepare ? { hash: getSignatureHash(abiItem) } : {}),\n } as never\n}\n\nexport declare namespace fromAbi {\n type Options<\n abi extends Abi.Abi | readonly unknown[] = Abi.Abi,\n name extends Name<abi> = Name<abi>,\n args extends\n | internal.ExtractArgs<abi, name>\n | undefined = internal.ExtractArgs<abi, name>,\n ///\n allArgs = internal.ExtractArgs<abi, name>,\n > = {\n /**\n * Whether or not to prepare the extracted item (optimization for encoding performance).\n * When `true`, the `hash` property is computed and included in the returned value.\n *\n * @default true\n */\n prepare?: boolean | undefined\n } & UnionCompute<\n readonly [] extends allArgs\n ? {\n args?:\n | allArgs // show all options\n // infer value, widen inferred value of `args` conditionally to match `allArgs`\n | (abi extends Abi.Abi\n ? args extends allArgs\n ? internal.Widen<args>\n : never\n : never)\n | undefined\n }\n : {\n args?:\n | allArgs // show all options\n | (internal.Widen<args> & (args extends allArgs ? unknown : never)) // infer value, widen inferred value of `args` match `allArgs` (e.g. avoid union `args: readonly [123n] | readonly [bigint]`)\n | undefined\n }\n >\n\n type ReturnType<\n abi extends Abi.Abi | readonly unknown[] = Abi.Abi,\n name extends Name<abi> = Name<abi>,\n args extends\n | internal.ExtractArgs<abi, name>\n | undefined = internal.ExtractArgs<abi, name>,\n fallback = AbiItem,\n > = abi extends Abi.Abi\n ? Abi.Abi extends abi\n ? fallback\n : internal.ExtractForArgs<\n abi,\n name,\n args extends internal.ExtractArgs<abi, name>\n ? args\n : internal.ExtractArgs<abi, name>\n >\n : fallback\n\n type ErrorType = Errors.GlobalErrorType\n}\n\n/**\n * Computes the [4-byte selector](https://solidity-by-example.org/function-selector/) for an {@link ox#AbiItem.AbiItem}.\n *\n * Useful for computing function selectors for calldata.\n *\n * @example\n * ```ts twoslash\n * import { AbiItem } from 'ox'\n *\n * const selector = AbiItem.getSelector('function ownerOf(uint256 tokenId)')\n * // @log: '0x6352211e'\n * ```\n *\n * @example\n * ```ts twoslash\n * import { AbiItem } from 'ox'\n *\n * const selector = AbiItem.getSelector({\n * inputs: [{ type: 'uint256' }],\n * name: 'ownerOf',\n * outputs: [],\n * stateMutability: 'view',\n * type: 'function'\n * })\n * // @log: '0x6352211e'\n * ```\n *\n * @param abiItem - The ABI item to compute the selector for. Can be a signature or an ABI item for an error, event, function, etc.\n * @returns The first 4 bytes of the {@link ox#Hash.(keccak256:function)} hash of the function signature.\n */\nexport function getSelector(abiItem: string | AbiItem): Hex.Hex {\n return Hex.slice(getSignatureHash(abiItem), 0, 4)\n}\n\nexport declare namespace getSelector {\n type ErrorType =\n | getSignatureHash.ErrorType\n | Hex.slice.ErrorType\n | Errors.GlobalErrorType\n}\n\n/**\n * Computes the stringified signature for a given {@link ox#AbiItem.AbiItem}.\n *\n * @example\n * ```ts twoslash\n * import { AbiItem } from 'ox'\n *\n * const signature = AbiItem.getSignature('function ownerOf(uint256 tokenId)')\n * // @log: 'ownerOf(uint256)'\n * ```\n *\n * @example\n * ```ts twoslash\n * import { AbiItem } from 'ox'\n *\n * const signature = AbiItem.getSignature({\n * name: 'ownerOf',\n * type: 'function',\n * inputs: [{ name: 'tokenId', type: 'uint256' }],\n * outputs: [],\n * stateMutability: 'view',\n * })\n * // @log: 'ownerOf(uint256)'\n * ```\n *\n * @param abiItem - The ABI Item to compute the signature for.\n * @returns The stringified signature of the ABI Item.\n */\nexport function getSignature(abiItem: string | AbiItem): string {\n const signature = (() => {\n if (typeof abiItem === 'string') return abiItem\n return abitype.formatAbiItem(abiItem)\n })()\n return internal.normalizeSignature(signature)\n}\n\nexport declare namespace getSignature {\n type ErrorType =\n | internal.normalizeSignature.ErrorType\n | Errors.GlobalErrorType\n}\n\n/**\n * Computes the signature hash for an {@link ox#AbiItem.AbiItem}.\n *\n * Useful for computing Event Topic values.\n *\n * @example\n * ```ts twoslash\n * import { AbiItem } from 'ox'\n *\n * const hash = AbiItem.getSignatureHash('event Transfer(address indexed from, address indexed to, uint256 amount)')\n * // @log: '0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef'\n * ```\n *\n * @example\n * ```ts twoslash\n * import { AbiItem } from 'ox'\n *\n * const hash = AbiItem.getSignatureHash({\n * name: 'Transfer',\n * type: 'event',\n * inputs: [\n * { name: 'from', type: 'address', indexed: true },\n * { name: 'to', type: 'address', indexed: true },\n * { name: 'amount', type: 'uint256', indexed: false },\n * ],\n * })\n * // @log: '0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef'\n * ```\n *\n * @param abiItem - The ABI Item to compute the signature hash for.\n * @returns The {@link ox#Hash.(keccak256:function)} hash of the ABI item's signature.\n */\nexport function getSignatureHash(abiItem: string | AbiItem): Hex.Hex {\n if (typeof abiItem !== 'string' && 'hash' in abiItem && abiItem.hash)\n return abiItem.hash as Hex.Hex\n return Hash.keccak256(Hex.fromString(getSignature(abiItem)))\n}\n\nexport declare namespace getSignatureHash {\n type ErrorType =\n | getSignature.ErrorType\n | Hash.keccak256.ErrorType\n | Hex.fromString.ErrorType\n | Errors.GlobalErrorType\n}\n\n/**\n * Throws when ambiguous types are found on overloaded ABI items.\n *\n * @example\n * ```ts twoslash\n * import { Abi, AbiFunction } from 'ox'\n *\n * const foo = Abi.from(['function foo(address)', 'function foo(bytes20)'])\n * AbiFunction.fromAbi(foo, 'foo', {\n * args: ['0xA0Cf798816D4b9b9866b5330EEa46a18382f251e'],\n * })\n * // @error: AbiItem.AmbiguityError: Found ambiguous types in overloaded ABI Items.\n * // @error: `bytes20` in `foo(bytes20)`, and\n * // @error: `address` in `foo(address)`\n * // @error: These types encode differently and cannot be distinguished at runtime.\n * // @error: Remove one of the ambiguous items in the ABI.\n * ```\n *\n * ### Solution\n *\n * Remove one of the ambiguous types from the ABI.\n *\n * ```ts twoslash\n * import { Abi, AbiFunction } from 'ox'\n *\n * const foo = Abi.from([\n * 'function foo(address)',\n * 'function foo(bytes20)' // [!code --]\n * ])\n * AbiFunction.fromAbi(foo, 'foo', {\n * args: ['0xA0Cf798816D4b9b9866b5330EEa46a18382f251e'],\n * })\n * // @error: AbiItem.AmbiguityError: Found ambiguous types in overloaded ABI Items.\n * // @error: `bytes20` in `foo(bytes20)`, and\n * // @error: `address` in `foo(address)`\n * // @error: These types encode differently and cannot be distinguished at runtime.\n * // @error: Remove one of the ambiguous items in the ABI.\n * ```\n */\nexport class AmbiguityError extends Errors.BaseError {\n override readonly name = 'AbiItem.AmbiguityError'\n constructor(\n x: { abiItem: Abi.Abi[number]; type: string },\n y: { abiItem: Abi.Abi[number]; type: string },\n ) {\n super('Found ambiguous types in overloaded ABI Items.', {\n metaMessages: [\n // TODO: abitype to add support for signature-formatted ABI items.\n `\\`${x.type}\\` in \\`${internal.normalizeSignature(abitype.formatAbiItem(x.abiItem))}\\`, and`,\n `\\`${y.type}\\` in \\`${internal.normalizeSignature(abitype.formatAbiItem(y.abiItem))}\\``,\n '',\n 'These types encode differently and cannot be distinguished at runtime.',\n 'Remove one of the ambiguous items in the ABI.',\n ],\n })\n }\n}\n\n/**\n * Throws when an ABI item is not found in the ABI.\n *\n * @example\n * ```ts twoslash\n * // @noErrors\n * import { Abi, AbiFunction } from 'ox'\n *\n * const foo = Abi.from([\n * 'function foo(address)',\n * 'function bar(uint)'\n * ])\n * AbiFunction.fromAbi(foo, 'baz')\n * // @error: AbiItem.NotFoundError: ABI function with name \"baz\" not found.\n * ```\n *\n * ### Solution\n *\n * Ensure the ABI item exists on the ABI.\n *\n * ```ts twoslash\n * // @noErrors\n * import { Abi, AbiFunction } from 'ox'\n *\n * const foo = Abi.from([\n * 'function foo(address)',\n * 'function bar(uint)',\n * 'function baz(bool)' // [!code ++]\n * ])\n * AbiFunction.fromAbi(foo, 'baz')\n * ```\n */\nexport class NotFoundError extends Errors.BaseError {\n override readonly name = 'AbiItem.NotFoundError'\n constructor({\n name,\n data,\n type = 'item',\n }: {\n name?: string | undefined\n data?: Hex.Hex | undefined\n type?: string | undefined\n }) {\n const selector = (() => {\n if (name) return ` with name \"${name}\"`\n if (data) return ` with data \"${data}\"`\n return ''\n })()\n super(`ABI ${type}${selector} not found.`)\n }\n}\n\n/**\n * Throws when the selector size is invalid.\n *\n * @example\n * ```ts twoslash\n * import { Abi, AbiFunction } from 'ox'\n *\n * const foo = Abi.from([\n * 'function foo(address)',\n * 'function bar(uint)'\n * ])\n * AbiFunction.fromAbi(foo, '0xaaa')\n * // @error: AbiItem.InvalidSelectorSizeError: Selector size is invalid. Expected 4 bytes. Received 2 bytes (\"0xaaa\").\n * ```\n *\n * ### Solution\n *\n * Ensure the selector size is 4 bytes.\n *\n * ```ts twoslash\n * // @noErrors\n * import { Abi, AbiFunction } from 'ox'\n *\n * const foo = Abi.from([\n * 'function foo(address)',\n * 'function bar(uint)'\n * ])\n * AbiFunction.fromAbi(foo, '0x7af82b1a')\n * ```\n */\nexport class InvalidSelectorSizeError extends Errors.BaseError {\n override readonly name = 'AbiItem.InvalidSelectorSizeError'\n constructor({ data }: { data: Hex.Hex }) {\n super(\n `Selector size is invalid. Expected 4 bytes. Received ${Hex.size(data)} bytes (\"${data}\").`,\n )\n }\n}\n", "export const arrayRegex = /^(.*)\\[([0-9]*)\\]$/\n\n// `bytes<M>`: binary type of `M` bytes, `0 < M <= 32`\n// https://regexr.com/6va55\nexport const bytesRegex = /^bytes([1-9]|1[0-9]|2[0-9]|3[0-2])?$/\n\n// `(u)int<M>`: (un)signed integer type of `M` bits, `0 < M <= 256`, `M % 8 == 0`\n// https://regexr.com/6v8hp\nexport const integerRegex =\n /^(u?int)(8|16|24|32|40|48|56|64|72|80|88|96|104|112|120|128|136|144|152|160|168|176|184|192|200|208|216|224|232|240|248|256)?$/\n\nexport const maxInt8 = 2n ** (8n - 1n) - 1n\nexport const maxInt16 = 2n ** (16n - 1n) - 1n\nexport const maxInt24 = 2n ** (24n - 1n) - 1n\nexport const maxInt32 = 2n ** (32n - 1n) - 1n\nexport const maxInt40 = 2n ** (40n - 1n) - 1n\nexport const maxInt48 = 2n ** (48n - 1n) - 1n\nexport const maxInt56 = 2n ** (56n - 1n) - 1n\nexport const maxInt64 = 2n ** (64n - 1n) - 1n\nexport const maxInt72 = 2n ** (72n - 1n) - 1n\nexport const maxInt80 = 2n ** (80n - 1n) - 1n\nexport const maxInt88 = 2n ** (88n - 1n) - 1n\nexport const maxInt96 = 2n ** (96n - 1n) - 1n\nexport const maxInt104 = 2n ** (104n - 1n) - 1n\nexport const maxInt112 = 2n ** (112n - 1n) - 1n\nexport const maxInt120 = 2n ** (120n - 1n) - 1n\nexport const maxInt128 = 2n ** (128n - 1n) - 1n\nexport const maxInt136 = 2n ** (136n - 1n) - 1n\nexport const maxInt144 = 2n ** (144n - 1n) - 1n\nexport const maxInt152 = 2n ** (152n - 1n) - 1n\nexport const maxInt160 = 2n ** (160n - 1n) - 1n\nexport const maxInt168 = 2n ** (168n - 1n) - 1n\nexport const maxInt176 = 2n ** (176n - 1n) - 1n\nexport const maxInt184 = 2n ** (184n - 1n) - 1n\nexport const maxInt192 = 2n ** (192n - 1n) - 1n\nexport const maxInt200 = 2n ** (200n - 1n) - 1n\nexport const maxInt208 = 2n ** (208n - 1n) - 1n\nexport const maxInt216 = 2n ** (216n - 1n) - 1n\nexport const maxInt224 = 2n ** (224n - 1n) - 1n\nexport const maxInt232 = 2n ** (232n - 1n) - 1n\nexport const maxInt240 = 2n ** (240n - 1n) - 1n\nexport const maxInt248 = 2n ** (248n - 1n) - 1n\nexport const maxInt256 = 2n ** (256n - 1n) - 1n\n\nexport const minInt8 = -(2n ** (8n - 1n))\nexport const minInt16 = -(2n ** (16n - 1n))\nexport const minInt24 = -(2n ** (24n - 1n))\nexport const minInt32 = -(2n ** (32n - 1n))\nexport const minInt40 = -(2n ** (40n - 1n))\nexport const minInt48 = -(2n ** (48n - 1n))\nexport const minInt56 = -(2n ** (56n - 1n))\nexport const minInt64 = -(2n ** (64n - 1n))\nexport const minInt72 = -(2n ** (72n - 1n))\nexport const minInt80 = -(2n ** (80n - 1n))\nexport const minInt88 = -(2n ** (88n - 1n))\nexport const minInt96 = -(2n ** (96n - 1n))\nexport const minInt104 = -(2n ** (104n - 1n))\nexport const minInt112 = -(2n ** (112n - 1n))\nexport const minInt120 = -(2n ** (120n - 1n))\nexport const minInt128 = -(2n ** (128n - 1n))\nexport const minInt136 = -(2n ** (136n - 1n))\nexport const minInt144 = -(2n ** (144n - 1n))\nexport const minInt152 = -(2n ** (152n - 1n))\nexport const minInt160 = -(2n ** (160n - 1n))\nexport const minInt168 = -(2n ** (168n - 1n))\nexport const minInt176 = -(2n ** (176n - 1n))\nexport const minInt184 = -(2n ** (184n - 1n))\nexport const minInt192 = -(2n ** (192n - 1n))\nexport const minInt200 = -(2n ** (200n - 1n))\nexport const minInt208 = -(2n ** (208n - 1n))\nexport const minInt216 = -(2n ** (216n - 1n))\nexport const minInt224 = -(2n ** (224n - 1n))\nexport const minInt232 = -(2n ** (232n - 1n))\nexport const minInt240 = -(2n ** (240n - 1n))\nexport const minInt248 = -(2n ** (248n - 1n))\nexport const minInt256 = -(2n ** (256n - 1n))\n\nexport const maxUint8 = 2n ** 8n - 1n\nexport const maxUint16 = 2n ** 16n - 1n\nexport const maxUint24 = 2n ** 24n - 1n\nexport const maxUint32 = 2n ** 32n - 1n\nexport const maxUint40 = 2n ** 40n - 1n\nexport const maxUint48 = 2n ** 48n - 1n\nexport const maxUint56 = 2n ** 56n - 1n\nexport const maxUint64 = 2n ** 64n - 1n\nexport const maxUint72 = 2n ** 72n - 1n\nexport const maxUint80 = 2n ** 80n - 1n\nexport const maxUint88 = 2n ** 88n - 1n\nexport const maxUint96 = 2n ** 96n - 1n\nexport const maxUint104 = 2n ** 104n - 1n\nexport const maxUint112 = 2n ** 112n - 1n\nexport const maxUint120 = 2n ** 120n - 1n\nexport const maxUint128 = 2n ** 128n - 1n\nexport const maxUint136 = 2n ** 136n - 1n\nexport const maxUint144 = 2n ** 144n - 1n\nexport const maxUint152 = 2n ** 152n - 1n\nexport const maxUint160 = 2n ** 160n - 1n\nexport const maxUint168 = 2n ** 168n - 1n\nexport const maxUint176 = 2n ** 176n - 1n\nexport const maxUint184 = 2n ** 184n - 1n\nexport const maxUint192 = 2n ** 192n - 1n\nexport const maxUint200 = 2n ** 200n - 1n\nexport const maxUint208 = 2n ** 208n - 1n\nexport const maxUint216 = 2n ** 216n - 1n\nexport const maxUint224 = 2n ** 224n - 1n\nexport const maxUint232 = 2n ** 232n - 1n\nexport const maxUint240 = 2n ** 240n - 1n\nexport const maxUint248 = 2n ** 248n - 1n\nexport const maxUint256 = 2n ** 256n - 1n\n", "import type {\n AbiParameter,\n AbiParameterKind,\n AbiParameterToPrimitiveType,\n AbiParametersToPrimitiveTypes,\n} from 'abitype'\nimport * as AbiParameters from '../AbiParameters.js'\nimport * as Address from '../Address.js'\nimport * as Bytes from '../Bytes.js'\nimport * as Errors from '../Errors.js'\nimport * as Hex from '../Hex.js'\nimport { integerRegex } from '../Solidity.js'\nimport type * as Cursor from './cursor.js'\nimport type { Compute, IsNarrowable, UnionToIntersection } from './types.js'\n\n/** @internal */\nexport type ParameterToPrimitiveType<\n abiParameter extends AbiParameter | { name: string; type: unknown },\n abiParameterKind extends AbiParameterKind = AbiParameterKind,\n> = AbiParameterToPrimitiveType<abiParameter, abiParameterKind>\n\n/** @internal */\nexport type PreparedParameter = { dynamic: boolean; encoded: Hex.Hex }\n\n/** @internal */\nexport type ToObject<\n parameters extends readonly AbiParameter[],\n kind extends AbiParameterKind = AbiParameterKind,\n> = IsNarrowable<parameters, AbiParameters.AbiParameters> extends true\n ? Compute<\n UnionToIntersection<\n {\n [index in keyof parameters]: parameters[index] extends {\n name: infer name extends string\n }\n ? {\n [key in name]: AbiParameterToPrimitiveType<\n parameters[index],\n kind\n >\n }\n : {\n [key in index]: AbiParameterToPrimitiveType<\n parameters[index],\n kind\n >\n }\n }[number]\n >\n >\n : unknown\n\n/** @internal */\nexport type ToPrimitiveTypes<\n abiParameters extends readonly AbiParameter[],\n abiParameterKind extends AbiParameterKind = AbiParameterKind,\n> = AbiParametersToPrimitiveTypes<abiParameters, abiParameterKind>\n\n/** @internal */\nexport type Tuple = ParameterToPrimitiveType<TupleAbiParameter>\n\n/** @internal */\nexport function decodeParameter(\n cursor: Cursor.Cursor,\n param: AbiParameters.Parameter,\n options: { checksumAddress?: boolean | undefined; staticPosition: number },\n) {\n const { checksumAddress, staticPosition } = options\n const arrayComponents = getArrayComponents(param.type)\n if (arrayComponents) {\n const [length, type] = arrayComponents\n return decodeArray(\n cursor,\n { ...param, type },\n { checksumAddress, length, staticPosition },\n )\n }\n if (param.type === 'tuple')\n return decodeTuple(cursor, param as TupleAbiParameter, {\n checksumAddress,\n staticPosition,\n })\n if (param.type === 'address')\n return decodeAddress(cursor, { checksum: checksumAddress })\n if (param.type === 'bool') return decodeBool(cursor)\n if (param.type.startsWith('bytes'))\n return decodeBytes(cursor, param, { staticPosition })\n if (param.type.startsWith('uint') || param.type.startsWith('int'))\n return decodeNumber(cursor, param)\n if (param.type === 'string') return decodeString(cursor, { staticPosition })\n throw new AbiParameters.InvalidTypeError(param.type)\n}\n\nexport declare namespace decodeParameter {\n type ErrorType =\n | decodeArray.ErrorType\n | decodeTuple.ErrorType\n | decodeAddress.ErrorType\n | decodeBool.ErrorType\n | decodeBytes.ErrorType\n | decodeNumber.ErrorType\n | decodeString.ErrorType\n | AbiParameters.InvalidTypeError\n | Errors.GlobalErrorType\n}\n\nconst sizeOfLength = 32\nconst sizeOfOffset = 32\n\n/** @internal */\nexport function decodeAddress(\n cursor: Cursor.Cursor,\n options: { checksum?: boolean | undefined } = {},\n) {\n const { checksum = false } = options\n const value = cursor.readBytes(32)\n const wrap = (address: Hex.Hex) =>\n checksum ? Address.checksum(address) : address\n return [wrap(Hex.fromBytes(Bytes.slice(value, -20))), 32]\n}\n\nexport declare namespace decodeAddress {\n type ErrorType =\n | Hex.fromBytes.ErrorType\n | Bytes.slice.ErrorType\n | Errors.GlobalErrorType\n}\n\n/** @internal */\nexport function decodeArray(\n cursor: Cursor.Cursor,\n param: AbiParameters.Parameter,\n options: {\n checksumAddress?: boolean | undefined\n length: number | null\n staticPosition: number\n },\n) {\n const { checksumAddress, length, staticPosition } = options\n\n // If the length of the array is not known in advance (dynamic array),\n // this means we will need to wonder off to the pointer and decode.\n if (!length) {\n // Dealing with a dynamic type, so get the offset of the array data.\n const offset = Bytes.toNumber(cursor.readBytes(sizeOfOffset))\n\n // Start is the static position of current slot + offset.\n const start = staticPosition + offset\n const startOfData = start + sizeOfLength\n\n // Get the length of the array from the offset.\n cursor.setPosition(start)\n const length = Bytes.toNumber(cursor.readBytes(sizeOfLength))\n\n // Check if the array has any dynamic children.\n const dynamicChild = hasDynamicChild(param)\n\n let consumed = 0\n const value: unknown[] = []\n for (let i = 0; i < length; ++i) {\n // If any of the children is dynamic, then all elements will be offset pointer, thus size of one slot (32 bytes).\n // Otherwise, elements will be the size of their encoding (consumed bytes).\n cursor.setPosition(startOfData + (dynamicChild ? i * 32 : consumed))\n const [data, consumed_] = decodeParameter(cursor, param, {\n checksumAddress,\n staticPosition: startOfData,\n })\n consumed += consumed_\n value.push(data)\n }\n\n // As we have gone wondering, restore to the original position + next slot.\n cursor.setPosition(staticPosition + 32)\n return [value, 32]\n }\n\n // If the length of the array is known in advance,\n // and the length of an element deeply nested in the array is not known,\n // we need to decode the offset of the array data.\n if (hasDynamicChild(param)) {\n // Dealing with dynamic types, so get the offset of the array data.\n const offset = Bytes.toNumber(cursor.readBytes(sizeOfOffset))\n\n // Start is the static position of current slot + offset.\n const start = staticPosition + offset\n\n const value: unknown[] = []\n for (let i = 0; i < length; ++i) {\n // Move cursor along to the next slot (next offset pointer).\n cursor.setPosition(start + i * 32)\n const [data] = decodeParameter(cursor, param, {\n checksumAddress,\n staticPosition: start,\n })\n value.push(data)\n }\n\n // As we have gone wondering, restore to the original position + next slot.\n cursor.setPosition(staticPosition + 32)\n return [value, 32]\n }\n\n // If the length of the array is known in advance and the array is deeply static,\n // then we can just decode each element in sequence.\n let consumed = 0\n const value: unknown[] = []\n for (let i = 0; i < length; ++i) {\n const [data, consumed_] = decodeParameter(cursor, param, {\n checksumAddress,\n staticPosition: staticPosition + consumed,\n })\n consumed += consumed_\n value.push(data)\n }\n return [value, consumed]\n}\n\nexport declare namespace decodeArray {\n type ErrorType = Bytes.toNumber.ErrorType | Errors.GlobalErrorType\n}\n\n/** @internal */\nexport function decodeBool(cursor: Cursor.Cursor) {\n return [Bytes.toBoolean(cursor.readBytes(32), { size: 32 }), 32]\n}\n\nexport declare namespace decodeBool {\n type ErrorType = Bytes.toBoolean.ErrorType | Errors.GlobalErrorType\n}\n\n/** @internal */\nexport function decodeBytes(\n cursor: Cursor.Cursor,\n param: AbiParameters.Parameter,\n { staticPosition }: { staticPosition: number },\n) {\n const [_, size] = param.type.split('bytes')\n if (!size) {\n // Dealing with dynamic types, so get the offset of the bytes data.\n const offset = Bytes.toNumber(cursor.readBytes(32))\n\n // Set position of the cursor to start of bytes data.\n cursor.setPosition(staticPosition + offset)\n\n const length = Bytes.toNumber(cursor.readBytes(32))\n\n // If there is no length, we have zero data.\n if (length === 0) {\n // As we have gone wondering, restore to the original position + next slot.\n cursor.setPosition(staticPosition + 32)\n return ['0x', 32]\n }\n\n const data = cursor.readBytes(length)\n\n // As we have gone wondering, restore to the original position + next slot.\n cursor.setPosition(staticPosition + 32)\n return [Hex.fromBytes(data), 32]\n }\n\n const value = Hex.fromBytes(cursor.readBytes(Number.parseInt(size), 32))\n return [value, 32]\n}\n\nexport declare namespace decodeBytes {\n type ErrorType =\n | Hex.fromBytes.ErrorType\n | Bytes.toNumber.ErrorType\n | Errors.GlobalErrorType\n}\n\n/** @internal */\nexport function decodeNumber(\n cursor: Cursor.Cursor,\n param: AbiParameters.Parameter,\n) {\n const signed = param.type.startsWith('int')\n const size = Number.parseInt(param.type.split('int')[1] || '256')\n const value = cursor.readBytes(32)\n return [\n size > 48\n ? Bytes.toBigInt(value, { signed })\n : Bytes.toNumber(value, { signed }),\n 32,\n ]\n}\n\nexport declare namespace decodeNumber {\n type ErrorType =\n | Bytes.toNumber.ErrorType\n | Bytes.toBigInt.ErrorType\n | Errors.GlobalErrorType\n}\n\n/** @internal */\nexport type TupleAbiParameter = AbiParameters.Parameter & {\n components: readonly AbiParameters.Parameter[]\n}\n\n/** @internal */\nexport function decodeTuple(\n cursor: Cursor.Cursor,\n param: TupleAbiParameter,\n options: { checksumAddress?: boolean | undefined; staticPosition: number },\n) {\n const { checksumAddress, staticPosition } = options\n\n // Tuples can have unnamed components (i.e. they are arrays), so we must\n // determine whether the tuple is named or unnamed. In the case of a named\n // tuple, the value will be an object where each property is the name of the\n // component. In the case of an unnamed tuple, the value will be an array.\n const hasUnnamedChild =\n param.components.length === 0 || param.components.some(({ name }) => !name)\n\n // Initialize the value to an object or an array, depending on whether the\n // tuple is named or unnamed.\n const value: any = hasUnnamedChild ? [] : {}\n let consumed = 0\n\n // If the tuple has a dynamic child, we must first decode the offset to the\n // tuple data.\n if (hasDynamicChild(param)) {\n // Dealing with dynamic types, so get the offset of the tuple data.\n const offset = Bytes.toNumber(cursor.readBytes(sizeOfOffset))\n\n // Start is the static position of referencing slot + offset.\n const start = staticPosition + offset\n\n for (let i = 0; i < param.components.length; ++i) {\n const component = param.components[i]!\n cursor.setPosition(start + consumed)\n const [data, consumed_] = decodeParameter(cursor, component, {\n checksumAddress,\n staticPosition: start,\n })\n consumed += consumed_\n value[hasUnnamedChild ? i : component?.name!] = data\n }\n\n // As we have gone wondering, restore to the original position + next slot.\n cursor.setPosition(staticPosition + 32)\n return [value, 32]\n }\n\n // If the tuple has static children, we can just decode each component\n // in sequence.\n for (let i = 0; i < param.components.length; ++i) {\n const component = param.components[i]!\n const [data, consumed_] = decodeParameter(cursor, component, {\n checksumAddress,\n staticPosition,\n })\n value[hasUnnamedChild ? i : component?.name!] = data\n consumed += consumed_\n }\n return [value, consumed]\n}\n\nexport declare namespace decodeTuple {\n type ErrorType = Bytes.toNumber.ErrorType | Errors.GlobalErrorType\n}\n\n/** @internal */\nexport function decodeString(\n cursor: Cursor.Cursor,\n { staticPosition }: { staticPosition: number },\n) {\n // Get offset to start of string data.\n const offset = Bytes.toNumber(cursor.readBytes(32))\n\n // Start is the static position of current slot + offset.\n const start = staticPosition + offset\n cursor.setPosition(start)\n\n const length = Bytes.toNumber(cursor.readBytes(32))\n\n // If there is no length, we have zero data (empty string).\n if (length === 0) {\n cursor.setPosition(staticPosition + 32)\n return ['', 32]\n }\n\n const data = cursor.readBytes(length, 32)\n const value = Bytes.toString(Bytes.trimLeft(data))\n\n // As we have gone wondering, restore to the original position + next slot.\n cursor.setPosition(staticPosition + 32)\n\n return [value, 32]\n}\n\nexport declare namespace decodeString {\n type ErrorType =\n | Bytes.toNumber.ErrorType\n | Bytes.toString.ErrorType\n | Bytes.trimLeft.ErrorType\n | Errors.GlobalErrorType\n}\n\n/** @internal */\nexport function prepareParameters<\n const parameters extends AbiParameters.AbiParameters,\n>({\n checksumAddress,\n parameters,\n values,\n}: {\n checksumAddress?: boolean | undefined\n parameters: parameters\n values: parameters extends AbiParameters.AbiParameters\n ? ToPrimitiveTypes<parameters>\n : never\n}) {\n const preparedParameters: PreparedParameter[] = []\n for (let i = 0; i < parameters.length; i++) {\n preparedParameters.push(\n prepareParameter({\n checksumAddress,\n parameter: parameters[i]!,\n value: values[i],\n }),\n )\n }\n return preparedParameters\n}\n\n/** @internal */\nexport declare namespace prepareParameters {\n type ErrorType = prepareParameter.ErrorType | Errors.GlobalErrorType\n}\n\n/** @internal */\nexport function prepareParameter<\n const parameter extends AbiParameters.Parameter,\n>({\n checksumAddress = false,\n parameter: parameter_,\n value,\n}: {\n parameter: parameter\n value: parameter extends AbiParameters.Parameter\n ? ParameterToPrimitiveType<parameter>\n : never\n checksumAddress?: boolean | undefined\n}): PreparedParameter {\n const parameter = parameter_ as AbiParameters.Parameter\n\n const arrayComponents = getArrayComponents(parameter.type)\n if (arrayComponents) {\n const [length, type] = arrayComponents\n return encodeArray(value, {\n checksumAddress,\n length,\n parameter: {\n ...parameter,\n type,\n },\n })\n }\n if (parameter.type === 'tuple') {\n return encodeTuple(value as unknown as Tuple, {\n checksumAddress,\n parameter: parameter as TupleAbiParameter,\n })\n }\n if (parameter.type === 'address') {\n return encodeAddress(value as unknown as Hex.Hex, {\n checksum: checksumAddress,\n })\n }\n if (parameter.type === 'bool') {\n return encodeBoolean(value as unknown as boolean)\n }\n if (parameter.type.startsWith('uint') || parameter.type.startsWith('int')) {\n const signed = parameter.type.startsWith('int')\n const [, , size = '256'] = integerRegex.exec(parameter.type) ?? []\n return encodeNumber(value as unknown as number, {\n signed,\n size: Number(size),\n })\n }\n if (parameter.type.startsWith('bytes')) {\n return encodeBytes(value as unknown as Hex.Hex, { type: parameter.type })\n }\n if (parameter.type === 'string') {\n return encodeString(value as unknown as string)\n }\n throw new AbiParameters.InvalidTypeError(parameter.type)\n}\n\n/** @internal */\nexport declare namespace prepareParameter {\n type ErrorType =\n | encodeArray.ErrorType\n | encodeTuple.ErrorType\n | encodeAddress.ErrorType\n | encodeBoolean.ErrorType\n | encodeBytes.ErrorType\n | encodeString.ErrorType\n | AbiParameters.InvalidTypeError\n | Errors.GlobalErrorType\n}\n\n/** @internal */\nexport function encode(preparedParameters: PreparedParameter[]): Hex.Hex {\n // 1. Compute the size of the static part of the parameters.\n let staticSize = 0\n for (let i = 0; i < preparedParameters.length; i++) {\n const { dynamic, encoded } = preparedParameters[i]!\n if (dynamic) staticSize += 32\n else staticSize += Hex.size(encoded)\n }\n\n // 2. Split the parameters into static and dynamic parts.\n const staticParameters: Hex.Hex[] = []\n const dynamicParameters: Hex.Hex[] = []\n let dynamicSize = 0\n for (let i = 0; i < preparedParameters.length; i++) {\n const { dynamic, encoded } = preparedParameters[i]!\n if (dynamic) {\n staticParameters.push(\n Hex.fromNumber(staticSize + dynamicSize, { size: 32 }),\n )\n dynamicParameters.push(encoded)\n dynamicSize += Hex.size(encoded)\n } else {\n staticParameters.push(encoded)\n }\n }\n\n // 3. Concatenate static and dynamic parts.\n return Hex.concat(...staticParameters, ...dynamicParameters)\n}\n\n/** @internal */\nexport declare namespace encode {\n type ErrorType =\n | Hex.concat.ErrorType\n | Hex.fromNumber.ErrorType\n | Hex.size.ErrorType\n | Errors.GlobalErrorType\n}\n\n/** @internal */\nexport function encodeAddress(\n value: Hex.Hex,\n options: { checksum: boolean },\n): PreparedParameter {\n const { checksum = false } = options\n Address.assert(value, { strict: checksum })\n return {\n dynamic: false,\n encoded: Hex.padLeft(value.toLowerCase() as Hex.Hex),\n }\n}\n\n/** @internal */\nexport declare namespace encodeAddress {\n type ErrorType =\n | Address.assert.ErrorType\n | Hex.padLeft.ErrorType\n | Errors.GlobalErrorType\n}\n\n/** @internal */\nexport function encodeArray<const parameter extends AbiParameters.Parameter>(\n value: ParameterToPrimitiveType<parameter>,\n options: {\n checksumAddress?: boolean | undefined\n length: number | null\n parameter: parameter\n },\n): PreparedParameter {\n const { checksumAddress, length, parameter } = options\n\n const dynamic = length === null\n\n if (!Array.isArray(value)) throw new AbiParameters.InvalidArrayError(value)\n if (!dynamic && value.length !== length)\n throw new AbiParameters.ArrayLengthMismatchError({\n expectedLength: length!,\n givenLength: value.length,\n type: `${parameter.type}[${length}]`,\n })\n\n let dynamicChild = false\n const preparedParameters: PreparedParameter[] = []\n for (let i = 0; i < value.length; i++) {\n const preparedParam = prepareParameter({\n checksumAddress,\n parameter,\n value: value[i],\n })\n if (preparedParam.dynamic) dynamicChild = true\n preparedParameters.push(preparedParam)\n }\n\n if (dynamic || dynamicChild) {\n const data = encode(preparedParameters)\n if (dynamic) {\n const length = Hex.fromNumber(preparedParameters.length, { size: 32 })\n return {\n dynamic: true,\n encoded:\n preparedParameters.length > 0 ? Hex.concat(length, data) : length,\n }\n }\n if (dynamicChild) return { dynamic: true, encoded: data }\n }\n return {\n dynamic: false,\n encoded: Hex.concat(...preparedParameters.map(({ encoded }) => encoded)),\n }\n}\n\n/** @internal */\nexport declare namespace encodeArray {\n type ErrorType =\n | AbiParameters.InvalidArrayError\n | AbiParameters.ArrayLengthMismatchError\n | Hex.concat.ErrorType\n | Hex.fromNumber.ErrorType\n | Errors.GlobalErrorType\n}\n\n/** @internal */\nexport function encodeBytes(\n value: Hex.Hex,\n { type }: { type: string },\n): PreparedParameter {\n const [, parametersize] = type.split('bytes')\n const bytesSize = Hex.size(value)\n if (!parametersize) {\n let value_ = value\n // If the size is not divisible by 32 bytes, pad the end\n // with empty bytes to the ceiling 32 bytes.\n if (bytesSize % 32 !== 0)\n value_ = Hex.padRight(value_, Math.ceil((value.length - 2) / 2 / 32) * 32)\n return {\n dynamic: true,\n encoded: Hex.concat(\n Hex.padLeft(Hex.fromNumber(bytesSize, { size: 32 })),\n value_,\n ),\n }\n }\n if (bytesSize !== Number.parseInt(parametersize))\n throw new AbiParameters.BytesSizeMismatchError({\n expectedSize: Number.parseInt(parametersize),\n value,\n })\n return { dynamic: false, encoded: Hex.padRight(value) }\n}\n\n/** @internal */\nexport declare namespace encodeBytes {\n type ErrorType =\n | Hex.padLeft.ErrorType\n | Hex.padRight.ErrorType\n | Hex.fromNumber.ErrorType\n | Hex.slice.ErrorType\n | Errors.GlobalErrorType\n}\n\n/** @internal */\nexport function encodeBoolean(value: boolean): PreparedParameter {\n if (typeof value !== 'boolean')\n throw new Errors.BaseError(\n `Invalid boolean value: \"${value}\" (type: ${typeof value}). Expected: \\`true\\` or \\`false\\`.`,\n )\n return { dynamic: false, encoded: Hex.padLeft(Hex.fromBoolean(value)) }\n}\n\n/** @internal */\nexport declare namespace encodeBoolean {\n type ErrorType =\n | Hex.padLeft.ErrorType\n | Hex.fromBoolean.ErrorType\n | Errors.GlobalErrorType\n}\n\n/** @internal */\nexport function encodeNumber(\n value: number,\n { signed, size }: { signed: boolean; size: number },\n): PreparedParameter {\n if (typeof size === 'number') {\n const max = 2n ** (BigInt(size) - (signed ? 1n : 0n)) - 1n\n const min = signed ? -max - 1n : 0n\n if (value > max || value < min)\n throw new Hex.IntegerOutOfRangeError({\n max: max.toString(),\n min: min.toString(),\n signed,\n size: size / 8,\n value: value.toString(),\n })\n }\n return {\n dynamic: false,\n encoded: Hex.fromNumber(value, {\n size: 32,\n signed,\n }),\n }\n}\n\n/** @internal */\nexport declare namespace encodeNumber {\n type ErrorType = Hex.fromNumber.ErrorType | Errors.GlobalErrorType\n}\n\n/** @internal */\nexport function encodeString(value: string): PreparedParameter {\n const hexValue = Hex.fromString(value)\n const partsLength = Math.ceil(Hex.size(hexValue) / 32)\n const parts: Hex.Hex[] = []\n for (let i = 0; i < partsLength; i++) {\n parts.push(Hex.padRight(Hex.slice(hexValue, i * 32, (i + 1) * 32)))\n }\n return {\n dynamic: true,\n encoded: Hex.concat(\n Hex.padRight(Hex.fromNumber(Hex.size(hexValue), { size: 32 })),\n ...parts,\n ),\n }\n}\n\n/** @internal */\nexport declare namespace encodeString {\n type ErrorType =\n | Hex.fromNumber.ErrorType\n | Hex.padRight.ErrorType\n | Hex.slice.ErrorType\n | Hex.size.ErrorType\n | Errors.GlobalErrorType\n}\n\n/** @internal */\nexport function encodeTuple<\n const parameter extends AbiParameters.Parameter & {\n components: readonly AbiParameters.Parameter[]\n },\n>(\n value: ParameterToPrimitiveType<parameter>,\n options: {\n checksumAddress?: boolean | undefined\n parameter: parameter\n },\n): PreparedParameter {\n const { checksumAddress, parameter } = options\n\n let dynamic = false\n const preparedParameters: PreparedParameter[] = []\n for (let i = 0; i < parameter.components.length; i++) {\n const param_ = parameter.components[i]!\n const index = Array.isArray(value) ? i : param_.name\n const preparedParam = prepareParameter({\n checksumAddress,\n parameter: param_,\n value: (value as any)[index!] as readonly unknown[],\n })\n preparedParameters.push(preparedParam)\n if (preparedParam.dynamic) dynamic = true\n }\n return {\n dynamic,\n encoded: dynamic\n ? encode(preparedParameters)\n : Hex.concat(...preparedParameters.map(({ encoded }) => encoded)),\n }\n}\n\n/** @internal */\nexport declare namespace encodeTuple {\n type ErrorType = Hex.concat.ErrorType | Errors.GlobalErrorType\n}\n\n/** @internal */\nexport function getArrayComponents(\n type: string,\n): [length: number | null, innerType: string] | undefined {\n const matches = type.match(/^(.*)\\[(\\d+)?\\]$/)\n return matches\n ? // Return `null` if the array is dynamic.\n [matches[2]! ? Number(matches[2]!) : null, matches[1]!]\n : undefined\n}\n\n/** @internal */\nexport function hasDynamicChild(param: AbiParameters.Parameter) {\n const { type } = param\n if (type === 'string') return true\n if (type === 'bytes') return true\n if (type.endsWith('[]')) return true\n\n if (type === 'tuple') return (param as any).components?.some(hasDynamicChild)\n\n const arrayComponents = getArrayComponents(param.type)\n if (\n arrayComponents &&\n hasDynamicChild({\n ...param,\n type: arrayComponents[1],\n } as AbiParameters.Parameter)\n )\n return true\n\n return false\n}\n", "import type { Bytes } from '../Bytes.js'\nimport * as Errors from '../Errors.js'\n\n/** @internal */\nexport type Cursor = {\n bytes: Bytes\n dataView: DataView\n position: number\n positionReadCount: Map<number, number>\n recursiveReadCount: number\n recursiveReadLimit: number\n remaining: number\n assertReadLimit(position?: number): void\n assertPosition(position: number): void\n decrementPosition(offset: number): void\n getReadCount(position?: number): number\n incrementPosition(offset: number): void\n inspectByte(position?: number): Bytes[number]\n inspectBytes(length: number, position?: number): Bytes\n inspectUint8(position?: number): number\n inspectUint16(position?: number): number\n inspectUint24(position?: number): number\n inspectUint32(position?: number): number\n pushByte(byte: Bytes[number]): void\n pushBytes(bytes: Bytes): void\n pushUint8(value: number): void\n pushUint16(value: number): void\n pushUint24(value: number): void\n pushUint32(value: number): void\n readByte(): Bytes[number]\n readBytes(length: number, size?: number): Bytes\n readUint8(): number\n readUint16(): number\n readUint24(): number\n readUint32(): number\n setPosition(position: number): () => void\n _touch(): void\n}\n\nconst staticCursor: Cursor = /*#__PURE__*/ {\n bytes: new Uint8Array(),\n dataView: new DataView(new ArrayBuffer(0)),\n position: 0,\n positionReadCount: new Map(),\n recursiveReadCount: 0,\n recursiveReadLimit: Number.POSITIVE_INFINITY,\n assertReadLimit() {\n if (this.recursiveReadCount >= this.recursiveReadLimit)\n throw new RecursiveReadLimitExceededError({\n count: this.recursiveReadCount + 1,\n limit: this.recursiveReadLimit,\n })\n },\n assertPosition(position) {\n if (position < 0 || position > this.bytes.length - 1)\n throw new PositionOutOfBoundsError({\n length: this.bytes.length,\n position,\n })\n },\n decrementPosition(offset) {\n if (offset < 0) throw new NegativeOffsetError({ offset })\n const position = this.position - offset\n this.assertPosition(position)\n this.position = position\n },\n getReadCount(position) {\n return this.positionReadCount.get(position || this.position) || 0\n },\n incrementPosition(offset) {\n if (offset < 0) throw new NegativeOffsetError({ offset })\n const position = this.position + offset\n this.assertPosition(position)\n this.position = position\n },\n inspectByte(position_) {\n const position = position_ ?? this.position\n this.assertPosition(position)\n return this.bytes[position]!\n },\n inspectBytes(length, position_) {\n const position = position_ ?? this.position\n this.assertPosition(position + length - 1)\n return this.bytes.subarray(position, position + length)\n },\n inspectUint8(position_) {\n const position = position_ ?? this.position\n this.assertPosition(position)\n return this.bytes[position]!\n },\n inspectUint16(position_) {\n const position = position_ ?? this.position\n this.assertPosition(position + 1)\n return this.dataView.getUint16(position)\n },\n inspectUint24(position_) {\n const position = position_ ?? this.position\n this.assertPosition(position + 2)\n return (\n (this.dataView.getUint16(position) << 8) +\n this.dataView.getUint8(position + 2)\n )\n },\n inspectUint32(position_) {\n const position = position_ ?? this.position\n this.assertPosition(position + 3)\n return this.dataView.getUint32(position)\n },\n pushByte(byte: Bytes[number]) {\n this.assertPosition(this.position)\n this.bytes[this.position] = byte\n this.position++\n },\n pushBytes(bytes: Bytes) {\n this.assertPosition(this.position + bytes.length - 1)\n this.bytes.set(bytes, this.position)\n this.position += bytes.length\n },\n pushUint8(value: number) {\n this.assertPosition(this.position)\n this.bytes[this.position] = value\n this.position++\n },\n pushUint16(value: number) {\n this.assertPosition(this.position + 1)\n this.dataView.setUint16(this.position, value)\n this.position += 2\n },\n pushUint24(value: number) {\n this.assertPosition(this.position + 2)\n this.dataView.setUint16(this.position, value >> 8)\n this.dataView.setUint8(this.position + 2, value & ~4294967040)\n this.position += 3\n },\n pushUint32(value: number) {\n this.assertPosition(this.position + 3)\n this.dataView.setUint32(this.position, value)\n this.position += 4\n },\n readByte() {\n this.assertReadLimit()\n this._touch()\n const value = this.inspectByte()\n this.position++\n return value\n },\n readBytes(length, size) {\n this.assertReadLimit()\n this._touch()\n const value = this.inspectBytes(length)\n this.position += size ?? length\n return value\n },\n readUint8() {\n this.assertReadLimit()\n this._touch()\n const value = this.inspectUint8()\n this.position += 1\n return value\n },\n readUint16() {\n this.assertReadLimit()\n this._touch()\n const value = this.inspectUint16()\n this.position += 2\n return value\n },\n readUint24() {\n this.assertReadLimit()\n this._touch()\n const value = this.inspectUint24()\n this.position += 3\n return value\n },\n readUint32() {\n this.assertReadLimit()\n this._touch()\n const value = this.inspectUint32()\n this.position += 4\n return value\n },\n get remaining() {\n return this.bytes.length - this.position\n },\n setPosition(position) {\n const oldPosition = this.position\n this.assertPosition(position)\n this.position = position\n return () => (this.position = oldPosition)\n },\n _touch() {\n if (this.recursiveReadLimit === Number.POSITIVE_INFINITY) return\n const count = this.getReadCount()\n this.positionReadCount.set(this.position, count + 1)\n if (count > 0) this.recursiveReadCount++\n },\n}\n\n/** @internal */\nexport function create(\n bytes: Bytes,\n { recursiveReadLimit = 8_192 }: create.Config = {},\n): Cursor {\n const cursor: Cursor = Object.create(staticCursor)\n cursor.bytes = bytes\n cursor.dataView = new DataView(\n bytes.buffer,\n bytes.byteOffset,\n bytes.byteLength,\n )\n cursor.positionReadCount = new Map()\n cursor.recursiveReadLimit = recursiveReadLimit\n return cursor\n}\n\n/** @internal */\nexport declare namespace create {\n type Config = { recursiveReadLimit?: number | undefined }\n\n type ErrorType = Errors.GlobalErrorType\n}\n\n/** @internal */\nexport class NegativeOffsetError extends Errors.BaseError {\n override readonly name = 'Cursor.NegativeOffsetError'\n\n constructor({ offset }: { offset: number }) {\n super(`Offset \\`${offset}\\` cannot be negative.`)\n }\n}\n\n/** @internal */\nexport class PositionOutOfBoundsError extends Errors.BaseError {\n override readonly name = 'Cursor.PositionOutOfBoundsError'\n\n constructor({ length, position }: { length: number; position: number }) {\n super(\n `Position \\`${position}\\` is out of bounds (\\`0 < position < ${length}\\`).`,\n )\n }\n}\n\n/** @internal */\nexport class RecursiveReadLimitExceededError extends Errors.BaseError {\n override readonly name = 'Cursor.RecursiveReadLimitExceededError'\n\n constructor({ count, limit }: { count: number; limit: number }) {\n super(\n `Recursive read limit of \\`${limit}\\` exceeded (recursive read count: \\`${count}\\`).`,\n )\n }\n}\n", "import * as abitype from 'abitype'\nimport * as Address from './Address.js'\nimport * as Bytes from './Bytes.js'\nimport * as Errors from './Errors.js'\nimport * as Hex from './Hex.js'\nimport * as Solidity from './Solidity.js'\nimport * as internal from './internal/abiParameters.js'\nimport * as Cursor from './internal/cursor.js'\n\n/** Root type for ABI parameters. */\nexport type AbiParameters = readonly abitype.AbiParameter[]\n\n/** A parameter on an {@link ox#AbiParameters.AbiParameters}. */\nexport type Parameter = abitype.AbiParameter\n\n/** A packed ABI type. */\nexport type PackedAbiType =\n | abitype.SolidityAddress\n | abitype.SolidityBool\n | abitype.SolidityBytes\n | abitype.SolidityInt\n | abitype.SolidityString\n | abitype.SolidityArrayWithoutTuple\n\n/**\n * Decodes ABI-encoded data into its respective primitive values based on ABI Parameters.\n *\n * @example\n * ```ts twoslash\n * import { AbiParameters } from 'ox'\n *\n * const data = AbiParameters.decode(\n * AbiParameters.from(['string', 'uint', 'bool']),\n * '0x000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000001a4000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000057761676d69000000000000000000000000000000000000000000000000000000',\n * )\n * // @log: ['wagmi', 420n, true]\n * ```\n *\n * @example\n * ### JSON Parameters\n *\n * You can pass **JSON ABI** Parameters:\n *\n * ```ts twoslash\n * import { AbiParameters } from 'ox'\n *\n * const data = AbiParameters.decode(\n * [\n * { name: 'x', type: 'string' },\n * { name: 'y', type: 'uint' },\n * { name: 'z', type: 'bool' },\n * ],\n * '0x000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000001a4000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000057761676d69000000000000000000000000000000000000000000000000000000',\n * )\n * // @log: ['wagmi', 420n, true]\n * ```\n *\n * @param parameters - The set of ABI parameters to decode, in the shape of the `inputs` or `outputs` attribute of an ABI Item. These parameters must include valid [ABI types](https://docs.soliditylang.org/en/latest/types.html).\n * @param data - ABI encoded data.\n * @param options - Decoding options.\n * @returns Array of decoded values.\n */\nexport function decode<\n const parameters extends AbiParameters,\n as extends 'Object' | 'Array' = 'Array',\n>(\n parameters: parameters,\n data: Bytes.Bytes | Hex.Hex,\n options?: decode.Options<as>,\n): decode.ReturnType<parameters, as>\n\n// eslint-disable-next-line jsdoc/require-jsdoc\nexport function decode(\n parameters: AbiParameters,\n data: Bytes.Bytes | Hex.Hex,\n options: {\n as?: 'Array' | 'Object' | undefined\n checksumAddress?: boolean | undefined\n } = {},\n): readonly unknown[] | Record<string, unknown> {\n const { as = 'Array', checksumAddress = false } = options\n\n const bytes = typeof data === 'string' ? Bytes.fromHex(data) : data\n const cursor = Cursor.create(bytes)\n\n if (Bytes.size(bytes) === 0 && parameters.length > 0)\n throw new ZeroDataError()\n if (Bytes.size(bytes) && Bytes.size(bytes) < 32)\n throw new DataSizeTooSmallError({\n data: typeof data === 'string' ? data : Hex.fromBytes(data),\n parameters: parameters as readonly Parameter[],\n size: Bytes.size(bytes),\n })\n\n let consumed = 0\n const values: any = as === 'Array' ? [] : {}\n for (let i = 0; i < parameters.length; ++i) {\n const param = parameters[i] as Parameter\n cursor.setPosition(consumed)\n const [data, consumed_] = internal.decodeParameter(cursor, param, {\n checksumAddress,\n staticPosition: 0,\n })\n consumed += consumed_\n if (as === 'Array') values.push(data)\n else values[param.name ?? i] = data\n }\n return values\n}\n\nexport declare namespace decode {\n type Options<as extends 'Object' | 'Array'> = {\n /**\n * Whether the decoded values should be returned as an `Object` or `Array`.\n *\n * @default \"Array\"\n */\n as?: as | 'Object' | 'Array' | undefined\n /**\n * Whether decoded addresses should be checksummed.\n *\n * @default false\n */\n checksumAddress?: boolean | undefined\n }\n\n type ReturnType<\n parameters extends AbiParameters = AbiParameters,\n as extends 'Object' | 'Array' = 'Array',\n > = parameters extends readonly []\n ? as extends 'Object'\n ? {}\n : []\n : as extends 'Object'\n ? internal.ToObject<parameters>\n : internal.ToPrimitiveTypes<parameters>\n\n type ErrorType =\n | Bytes.fromHex.ErrorType\n | internal.decodeParameter.ErrorType\n | ZeroDataError\n | DataSizeTooSmallError\n | Errors.GlobalErrorType\n}\n\n/**\n * Encodes primitive values into ABI encoded data as per the [Application Binary Interface (ABI) Specification](https://docs.soliditylang.org/en/latest/abi-spec).\n *\n * @example\n * ```ts twoslash\n * import { AbiParameters } from 'ox'\n *\n * const data = AbiParameters.encode(\n * AbiParameters.from(['string', 'uint', 'bool']),\n * ['wagmi', 420n, true],\n * )\n * ```\n *\n * @example\n * ### JSON Parameters\n *\n * Specify **JSON ABI** Parameters as schema:\n *\n * ```ts twoslash\n * import { AbiParameters } from 'ox'\n *\n * const data = AbiParameters.encode(\n * [\n * { type: 'string', name: 'name' },\n * { type: 'uint', name: 'age' },\n * { type: 'bool', name: 'isOwner' },\n * ],\n * ['wagmi', 420n, true],\n * )\n * ```\n *\n * @param parameters - The set of ABI parameters to encode, in the shape of the `inputs` or `outputs` attribute of an ABI Item. These parameters must include valid [ABI types](https://docs.soliditylang.org/en/latest/types.html).\n * @param values - The set of primitive values that correspond to the ABI types defined in `parameters`.\n * @returns ABI encoded data.\n */\nexport function encode<\n const parameters extends AbiParameters | readonly unknown[],\n>(\n parameters: parameters,\n values: parameters extends AbiParameters\n ? internal.ToPrimitiveTypes<parameters>\n : never,\n options?: encode.Options,\n): Hex.Hex {\n const { checksumAddress = false } = options ?? {}\n\n if (parameters.length !== values.length)\n throw new LengthMismatchError({\n expectedLength: parameters.length as number,\n givenLength: values.length as any,\n })\n // Prepare the parameters to determine dynamic types to encode.\n const preparedParameters = internal.prepareParameters({\n checksumAddress,\n parameters: parameters as readonly Parameter[],\n values: values as any,\n })\n const data = internal.encode(preparedParameters)\n if (data.length === 0) return '0x'\n return data\n}\n\nexport declare namespace encode {\n type ErrorType =\n | LengthMismatchError\n | internal.encode.ErrorType\n | internal.prepareParameters.ErrorType\n | Errors.GlobalErrorType\n\n type Options = {\n /**\n * Whether addresses should be checked against their checksum.\n *\n * @default false\n */\n checksumAddress?: boolean | undefined\n }\n}\n\n/**\n * Encodes an array of primitive values to a [packed ABI encoding](https://docs.soliditylang.org/en/latest/abi-spec.html#non-standard-packed-mode).\n *\n * @example\n * ```ts twoslash\n * import { AbiParameters } from 'ox'\n *\n * const encoded = AbiParameters.encodePacked(\n * ['address', 'string'],\n * ['0xd8da6bf26964af9d7eed9e03e53415d37aa96045', 'hello world'],\n * )\n * // @log: '0xd8da6bf26964af9d7eed9e03e53415d37aa9604568656c6c6f20776f726c64'\n * ```\n *\n * @param types - Set of ABI types to pack encode.\n * @param values - The set of primitive values that correspond to the ABI types defined in `types`.\n * @returns The encoded packed data.\n */\nexport function encodePacked<\n const packedAbiTypes extends readonly PackedAbiType[] | readonly unknown[],\n>(types: packedAbiTypes, values: encodePacked.Values<packedAbiTypes>): Hex.Hex {\n if (types.length !== values.length)\n throw new LengthMismatchError({\n expectedLength: types.length as number,\n givenLength: values.length as number,\n })\n\n const data: Hex.Hex[] = []\n for (let i = 0; i < (types as unknown[]).length; i++) {\n const type = types[i]\n const value = values[i]\n data.push(encodePacked.encode(type, value))\n }\n return Hex.concat(...data)\n}\n\nexport namespace encodePacked {\n export type ErrorType =\n | Hex.concat.ErrorType\n | LengthMismatchError\n | Errors.GlobalErrorType\n\n export type Values<\n packedAbiTypes extends readonly PackedAbiType[] | readonly unknown[],\n > = {\n [key in keyof packedAbiTypes]: packedAbiTypes[key] extends abitype.AbiType\n ? abitype.AbiParameterToPrimitiveType<{ type: packedAbiTypes[key] }>\n : unknown\n }\n\n // eslint-disable-next-line jsdoc/require-jsdoc\n export function encode<const packedAbiType extends PackedAbiType | unknown>(\n type: packedAbiType,\n value: Values<[packedAbiType]>[0],\n isArray = false,\n ): Hex.Hex {\n if (type === 'address') {\n const address = value as Address.Address\n Address.assert(address)\n return Hex.padLeft(\n address.toLowerCase() as Hex.Hex,\n isArray ? 32 : 0,\n ) as Address.Address\n }\n if (type === 'string') return Hex.fromString(value as string)\n if (type === 'bytes') return value as Hex.Hex\n if (type === 'bool')\n return Hex.padLeft(Hex.fromBoolean(value as boolean), isArray ? 32 : 1)\n\n const intMatch = (type as string).match(Solidity.integerRegex)\n if (intMatch) {\n const [_type, baseType, bits = '256'] = intMatch\n const size = Number.parseInt(bits) / 8\n return Hex.fromNumber(value as number, {\n size: isArray ? 32 : size,\n signed: baseType === 'int',\n })\n }\n\n const bytesMatch = (type as string).match(Solidity.bytesRegex)\n if (bytesMatch) {\n const [_type, size] = bytesMatch\n if (Number.parseInt(size!) !== ((value as Hex.Hex).length - 2) / 2)\n throw new BytesSizeMismatchError({\n expectedSize: Number.parseInt(size!),\n value: value as Hex.Hex,\n })\n return Hex.padRight(value as Hex.Hex, isArray ? 32 : 0) as Hex.Hex\n }\n\n const arrayMatch = (type as string).match(Solidity.arrayRegex)\n if (arrayMatch && Array.isArray(value)) {\n const [_type, childType] = arrayMatch\n const data: Hex.Hex[] = []\n for (let i = 0; i < value.length; i++) {\n data.push(encode(childType, value[i], true))\n }\n if (data.length === 0) return '0x'\n return Hex.concat(...data)\n }\n\n throw new InvalidTypeError(type as string)\n }\n}\n\n/**\n * Formats {@link ox#AbiParameters.AbiParameters} into **Human Readable ABI Parameters**.\n *\n * @example\n * ```ts twoslash\n * import { AbiParameters } from 'ox'\n *\n * const formatted = AbiParameters.format([\n * {\n * name: 'spender',\n * type: 'address',\n * },\n * {\n * name: 'amount',\n * type: 'uint256',\n * },\n * ])\n *\n * formatted\n * // ^?\n *\n *\n * ```\n *\n * @param parameters - The ABI Parameters to format.\n * @returns The formatted ABI Parameters .\n */\nexport function format<\n const parameters extends readonly [\n Parameter | abitype.AbiEventParameter,\n ...(readonly (Parameter | abitype.AbiEventParameter)[]),\n ],\n>(\n parameters:\n | parameters\n | readonly [\n Parameter | abitype.AbiEventParameter,\n ...(readonly (Parameter | abitype.AbiEventParameter)[]),\n ],\n): abitype.FormatAbiParameters<parameters> {\n return abitype.formatAbiParameters(parameters)\n}\n\nexport declare namespace format {\n type ErrorType = Errors.GlobalErrorType\n}\n\n/**\n * Parses arbitrary **JSON ABI Parameters** or **Human Readable ABI Parameters** into typed {@link ox#AbiParameters.AbiParameters}.\n *\n * @example\n * ### JSON Parameters\n *\n * ```ts twoslash\n * import { AbiParameters } from 'ox'\n *\n * const parameters = AbiParameters.from([\n * {\n * name: 'spender',\n * type: 'address',\n * },\n * {\n * name: 'amount',\n * type: 'uint256',\n * },\n * ])\n *\n * parameters\n * //^?\n *\n *\n *\n *\n *\n *\n *\n * ```\n *\n * @example\n * ### Human Readable Parameters\n *\n * Human Readable ABI Parameters can be parsed into a typed {@link ox#AbiParameters.AbiParameters}:\n *\n * ```ts twoslash\n * import { AbiParameters } from 'ox'\n *\n * const parameters = AbiParameters.from('address spender, uint256 amount')\n *\n * parameters\n * //^?\n *\n *\n *\n *\n *\n *\n *\n * ```\n *\n * @example\n * It is possible to specify `struct`s along with your definitions:\n *\n * ```ts twoslash\n * import { AbiParameters } from 'ox'\n *\n * const parameters = AbiParameters.from([\n * 'struct Foo { address spender; uint256 amount; }', // [!code hl]\n * 'Foo foo, address bar',\n * ])\n *\n * parameters\n * //^?\n *\n *\n *\n *\n *\n *\n *\n *\n *\n *\n *\n *\n * ```\n *\n *\n *\n * @param parameters - The ABI Parameters to parse.\n * @returns The typed ABI Parameters.\n */\nexport function from<\n const parameters extends AbiParameters | string | readonly string[],\n>(\n parameters: parameters | AbiParameters | string | readonly string[],\n): from.ReturnType<parameters> {\n if (Array.isArray(parameters) && typeof parameters[0] === 'string')\n return abitype.parseAbiParameters(parameters) as never\n if (typeof parameters === 'string')\n return abitype.parseAbiParameters(parameters) as never\n return parameters as never\n}\n\nexport declare namespace from {\n type ReturnType<\n parameters extends AbiParameters | string | readonly string[],\n > = parameters extends string\n ? abitype.ParseAbiParameters<parameters>\n : parameters extends readonly string[]\n ? abitype.ParseAbiParameters<parameters>\n : parameters\n\n type ErrorType = Errors.GlobalErrorType\n}\n\n/**\n * Throws when the data size is too small for the given parameters.\n *\n * @example\n * ```ts twoslash\n * import { AbiParameters } from 'ox'\n *\n * AbiParameters.decode([{ type: 'uint256' }], '0x010f')\n * // ↑ ❌ 2 bytes\n * // @error: AbiParameters.DataSizeTooSmallError: Data size of 2 bytes is too small for given parameters.\n * // @error: Params: (uint256)\n * // @error: Data: 0x010f (2 bytes)\n * ```\n *\n * ### Solution\n *\n * Pass a valid data size.\n *\n * ```ts twoslash\n * import { AbiParameters } from 'ox'\n *\n * AbiParameters.decode([{ type: 'uint256' }], '0x00000000000000000000000000000000000000000000000000000000000010f')\n * // ↑ ✅ 32 bytes\n * ```\n */\nexport class DataSizeTooSmallError extends Errors.BaseError {\n override readonly name = 'AbiParameters.DataSizeTooSmallError'\n constructor({\n data,\n parameters,\n size,\n }: { data: Hex.Hex; parameters: readonly Parameter[]; size: number }) {\n super(`Data size of ${size} bytes is too small for given parameters.`, {\n metaMessages: [\n `Params: (${abitype.formatAbiParameters(parameters as readonly [Parameter])})`,\n `Data: ${data} (${size} bytes)`,\n ],\n })\n }\n}\n\n/**\n * Throws when zero data is provided, but data is expected.\n *\n * @example\n * ```ts twoslash\n * import { AbiParameters } from 'ox'\n *\n * AbiParameters.decode([{ type: 'uint256' }], '0x')\n * // ↑ ❌ zero data\n * // @error: AbiParameters.DataSizeTooSmallError: Data size of 2 bytes is too small for given parameters.\n * // @error: Params: (uint256)\n * // @error: Data: 0x010f (2 bytes)\n * ```\n *\n * ### Solution\n *\n * Pass valid data.\n *\n * ```ts twoslash\n * import { AbiParameters } from 'ox'\n *\n * AbiParameters.decode([{ type: 'uint256' }], '0x00000000000000000000000000000000000000000000000000000000000010f')\n * // ↑ ✅ 32 bytes\n * ```\n */\nexport class ZeroDataError extends Errors.BaseError {\n override readonly name = 'AbiParameters.ZeroDataError'\n constructor() {\n super('Cannot decode zero data (\"0x\") with ABI parameters.')\n }\n}\n\n/**\n * The length of the array value does not match the length specified in the corresponding ABI parameter.\n *\n * ### Example\n *\n * ```ts twoslash\n * // @noErrors\n * import { AbiParameters } from 'ox'\n * // ---cut---\n * AbiParameters.encode(AbiParameters.from('uint256[3]'), [[69n, 420n]])\n * // ↑ expected: 3 ↑ ❌ length: 2\n * // @error: AbiParameters.ArrayLengthMismatchError: ABI encoding array length mismatch\n * // @error: for type `uint256[3]`. Expected: `3`. Given: `2`.\n * ```\n *\n * ### Solution\n *\n * Pass an array of the correct length.\n *\n * ```ts twoslash\n * import { AbiParameters } from 'ox'\n * // ---cut---\n * AbiParameters.encode(AbiParameters.from(['uint256[3]']), [[69n, 420n, 69n]])\n * // ↑ ✅ length: 3\n * ```\n */\nexport class ArrayLengthMismatchError extends Errors.BaseError {\n override readonly name = 'AbiParameters.ArrayLengthMismatchError'\n constructor({\n expectedLength,\n givenLength,\n type,\n }: { expectedLength: number; givenLength: number; type: string }) {\n super(\n `Array length mismatch for type \\`${type}\\`. Expected: \\`${expectedLength}\\`. Given: \\`${givenLength}\\`.`,\n )\n }\n}\n\n/**\n * The size of the bytes value does not match the size specified in the corresponding ABI parameter.\n *\n * ### Example\n *\n * ```ts twoslash\n * // @noErrors\n * import { AbiParameters } from 'ox'\n * // ---cut---\n * AbiParameters.encode(AbiParameters.from('bytes8'), [['0xdeadbeefdeadbeefdeadbeef']])\n * // ↑ expected: 8 bytes ↑ ❌ size: 12 bytes\n * // @error: BytesSizeMismatchError: Size of bytes \"0xdeadbeefdeadbeefdeadbeef\"\n * // @error: (bytes12) does not match expected size (bytes8).\n * ```\n *\n * ### Solution\n *\n * Pass a bytes value of the correct size.\n *\n * ```ts twoslash\n * import { AbiParameters } from 'ox'\n * // ---cut---\n * AbiParameters.encode(AbiParameters.from(['bytes8']), ['0xdeadbeefdeadbeef'])\n * // ↑ ✅ size: 8 bytes\n * ```\n */\nexport class BytesSizeMismatchError extends Errors.BaseError {\n override readonly name = 'AbiParameters.BytesSizeMismatchError'\n constructor({\n expectedSize,\n value,\n }: { expectedSize: number; value: Hex.Hex }) {\n super(\n `Size of bytes \"${value}\" (bytes${Hex.size(\n value,\n )}) does not match expected size (bytes${expectedSize}).`,\n )\n }\n}\n\n/**\n * The length of the values to encode does not match the length of the ABI parameters.\n *\n * ### Example\n *\n * ```ts twoslash\n * // @noErrors\n * import { AbiParameters } from 'ox'\n * // ---cut---\n * AbiParameters.encode(AbiParameters.from(['string', 'uint256']), ['hello'])\n * // @error: LengthMismatchError: ABI encoding params/values length mismatch.\n * // @error: Expected length (params): 2\n * // @error: Given length (values): 1\n * ```\n *\n * ### Solution\n *\n * Pass the correct number of values to encode.\n *\n * ### Solution\n *\n * Pass a [valid ABI type](https://docs.soliditylang.org/en/develop/abi-spec.html#types).\n */\nexport class LengthMismatchError extends Errors.BaseError {\n override readonly name = 'AbiParameters.LengthMismatchError'\n constructor({\n expectedLength,\n givenLength,\n }: { expectedLength: number; givenLength: number }) {\n super(\n [\n 'ABI encoding parameters/values length mismatch.',\n `Expected length (parameters): ${expectedLength}`,\n `Given length (values): ${givenLength}`,\n ].join('\\n'),\n )\n }\n}\n\n/**\n * The value provided is not a valid array as specified in the corresponding ABI parameter.\n *\n * ### Example\n *\n * ```ts twoslash\n * // @noErrors\n * import { AbiParameters } from 'ox'\n * // ---cut---\n * AbiParameters.encode(AbiParameters.from(['uint256[3]']), [69])\n * ```\n *\n * ### Solution\n *\n * Pass an array value.\n */\nexport class InvalidArrayError extends Errors.BaseError {\n override readonly name = 'AbiParameters.InvalidArrayError'\n constructor(value: unknown) {\n super(`Value \\`${value}\\` is not a valid array.`)\n }\n}\n\n/**\n * Throws when the ABI parameter type is invalid.\n *\n * @example\n * ```ts twoslash\n * import { AbiParameters } from 'ox'\n *\n * AbiParameters.decode([{ type: 'lol' }], '0x00000000000000000000000000000000000000000000000000000000000010f')\n * // ↑ ❌ invalid type\n * // @error: AbiParameters.InvalidTypeError: Type `lol` is not a valid ABI Type.\n * ```\n */\nexport class InvalidTypeError extends Errors.BaseError {\n override readonly name = 'AbiParameters.InvalidTypeError'\n constructor(type: string) {\n super(`Type \\`${type}\\` is not a valid ABI Type.`)\n }\n}\n", "import * as abitype from 'abitype'\nimport type * as Abi from './Abi.js'\nimport * as AbiItem from './AbiItem.js'\nimport * as AbiParameters from './AbiParameters.js'\nimport type * as Errors from './Errors.js'\nimport * as Hex from './Hex.js'\nimport type * as internal from './internal/abiConstructor.js'\nimport type { IsNarrowable } from './internal/types.js'\n\n/** Root type for an {@link ox#AbiItem.AbiItem} with a `constructor` type. */\nexport type AbiConstructor = abitype.AbiConstructor\n\n/** @internal */\nexport function decode<const abiConstructor extends AbiConstructor>(\n abiConstructor: abiConstructor,\n options: decode.Options,\n): decode.ReturnType<abiConstructor>\n/**\n * ABI-decodes the provided constructor input (`inputs`).\n *\n * @example\n * ```ts twoslash\n * import { AbiConstructor } from 'ox'\n *\n * const constructor = AbiConstructor.from('constructor(address, uint256)')\n *\n * const bytecode = '0x...'\n *\n * const data = AbiConstructor.encode(constructor, {\n * bytecode,\n * args: ['0xd8da6bf26964af9d7eed9e03e53415d37aa96045', 123n],\n * })\n *\n * const decoded = AbiConstructor.decode(constructor, { // [!code focus]\n * bytecode, // [!code focus]\n * data, // [!code focus]\n * }) // [!code focus]\n * ```\n *\n * @param abiConstructor - The ABI Constructor to decode.\n * @param options - Decoding options.\n * @returns The decoded constructor inputs.\n */\nexport function decode(\n abiConstructor: AbiConstructor,\n options: decode.Options,\n): readonly unknown[] | undefined\n/** @internal */\nexport function decode(\n abiConstructor: AbiConstructor,\n options: decode.Options,\n): decode.ReturnType {\n const { bytecode } = options\n if (abiConstructor.inputs.length === 0) return undefined\n const data = options.data.replace(bytecode, '0x') as Hex.Hex\n return AbiParameters.decode(abiConstructor.inputs, data)\n}\n\nexport declare namespace decode {\n interface Options {\n /** The bytecode of the contract. */\n bytecode: Hex.Hex\n /** The encoded constructor. */\n data: Hex.Hex\n }\n\n type ReturnType<abiConstructor extends AbiConstructor = AbiConstructor> =\n | (abiConstructor['inputs']['length'] extends 0\n ? undefined\n : abitype.AbiParametersToPrimitiveTypes<abiConstructor['inputs']>)\n | (IsNarrowable<abiConstructor, AbiConstructor> extends true\n ? never\n : undefined)\n\n type ErrorType = Errors.GlobalErrorType\n}\n\n/**\n * ABI-encodes the provided constructor input (`inputs`).\n *\n * @example\n * ```ts twoslash\n * import { AbiConstructor } from 'ox'\n *\n * const constructor = AbiConstructor.from('constructor(address, uint256)')\n *\n * const data = AbiConstructor.encode(constructor, {\n * bytecode: '0x...',\n * args: ['0xd8da6bf26964af9d7eed9e03e53415d37aa96045', 123n],\n * })\n * ```\n *\n * @example\n * ### End-to-end\n *\n * Below is an end-to-end example of using `AbiConstructor.encode` to encode the constructor of a contract and deploy it.\n *\n * ```ts twoslash\n * import 'ox/window'\n * import { AbiConstructor, Hex } from 'ox'\n *\n * // 1. Instantiate the ABI Constructor.\n * const constructor = AbiConstructor.from(\n * 'constructor(address owner, uint256 amount)',\n * )\n *\n * // 2. Encode the ABI Constructor.\n * const data = AbiConstructor.encode(constructor, {\n * bytecode: '0x...',\n * args: ['0xd8da6bf26964af9d7eed9e03e53415d37aa96045', 123n],\n * })\n *\n * // 3. Deploy the contract.\n * const hash = await window.ethereum!.request({\n * method: 'eth_sendTransaction',\n * params: [{ data }],\n * })\n * ```\n *\n * :::note\n *\n * For simplicity, the above example uses `window.ethereum.request`, but you can use any\n * type of JSON-RPC interface.\n *\n * :::\n *\n * @param abiConstructor - The ABI Constructor to encode.\n * @param options - Encoding options.\n * @returns The encoded constructor.\n */\nexport function encode<const abiConstructor extends AbiConstructor>(\n abiConstructor: abiConstructor,\n options: encode.Options<abiConstructor>,\n): encode.ReturnType {\n const { bytecode, args } = options\n return Hex.concat(\n bytecode,\n abiConstructor.inputs?.length && args?.length\n ? AbiParameters.encode(abiConstructor.inputs, args as readonly unknown[])\n : '0x',\n )\n}\n\nexport declare namespace encode {\n type Options<\n abiConstructor extends AbiConstructor = AbiConstructor,\n ///\n args extends abitype.AbiParametersToPrimitiveTypes<\n abiConstructor['inputs']\n > = abitype.AbiParametersToPrimitiveTypes<abiConstructor['inputs']>,\n > = {\n /** The bytecode of the contract. */\n bytecode: Hex.Hex\n /** The constructor arguments to encode. */\n args?: args | undefined\n } & (readonly [] extends args\n ? {}\n : {\n /** The constructor arguments to encode. */\n args: args\n })\n\n type ReturnType = Hex.Hex\n\n type ErrorType =\n | Hex.concat.ErrorType\n | AbiParameters.encode.ErrorType\n | Errors.GlobalErrorType\n}\n\n/** @internal */\nexport function format<const abiConstructor extends AbiConstructor>(\n abiConstructor: abiConstructor,\n): format.ReturnType<abiConstructor>\n/**\n * Formats an {@link ox#AbiConstructor.AbiConstructor} into a **Human Readable ABI Function**.\n *\n * @example\n * ```ts twoslash\n * import { AbiConstructor } from 'ox'\n *\n * const formatted = AbiConstructor.format({\n * inputs: [\n * { name: 'owner', type: 'address' },\n * ],\n * payable: false,\n * stateMutability: 'nonpayable',\n * type: 'constructor',\n * })\n *\n * formatted\n * // ^?\n *\n *\n * ```\n *\n * @param abiConstructor - The ABI Constructor to format.\n * @returns The formatted ABI Constructor.\n */\nexport function format(abiConstructor: AbiConstructor): string\n/** @internal */\nexport function format(abiConstructor: AbiConstructor): format.ReturnType {\n return abitype.formatAbiItem(abiConstructor)\n}\n\nexport declare namespace format {\n type ReturnType<abiConstructor extends AbiConstructor = AbiConstructor> =\n abitype.FormatAbiItem<abiConstructor>\n\n type ErrorType = Errors.GlobalErrorType\n}\n\n/** @internal */\nexport function from<\n const abiConstructor extends AbiConstructor | string | readonly string[],\n>(\n abiConstructor: (abiConstructor | string | readonly string[]) &\n (\n | (abiConstructor extends string\n ? internal.Signature<abiConstructor>\n : never)\n | (abiConstructor extends readonly string[]\n ? internal.Signatures<abiConstructor>\n : never)\n | AbiConstructor\n ),\n): from.ReturnType<abiConstructor>\n/**\n * Parses an arbitrary **JSON ABI Constructor** or **Human Readable ABI Constructor** into a typed {@link ox#AbiConstructor.AbiConstructor}.\n *\n * @example\n * ### JSON ABIs\n *\n * ```ts twoslash\n * import { AbiConstructor } from 'ox'\n *\n * const constructor = AbiConstructor.from({\n * inputs: [\n * { name: 'owner', type: 'address' },\n * ],\n * payable: false,\n * stateMutability: 'nonpayable',\n * type: 'constructor',\n * })\n *\n * constructor\n * //^?\n *\n *\n *\n *\n *\n *\n *\n *\n *\n *\n *\n *\n * ```\n *\n * @example\n * ### Human Readable ABIs\n *\n * A Human Readable ABI can be parsed into a typed ABI object:\n *\n * ```ts twoslash\n * import { AbiConstructor } from 'ox'\n *\n * const constructor = AbiConstructor.from(\n * 'constructor(address owner)' // [!code hl]\n * )\n *\n * constructor\n * //^?\n *\n *\n *\n *\n *\n *\n *\n *\n *\n *\n *\n *\n *\n * ```\n *\n * @example\n * It is possible to specify `struct`s along with your definitions:\n *\n * ```ts twoslash\n * import { AbiConstructor } from 'ox'\n *\n * const constructor = AbiConstructor.from([\n * 'struct Foo { address owner; uint256 amount; }', // [!code hl]\n * 'constructor(Foo foo)',\n * ])\n *\n * constructor\n * //^?\n *\n *\n *\n *\n *\n *\n *\n *\n *\n *\n *\n *\n * ```\n *\n *\n *\n * @param abiConstructor - The ABI Constructor to parse.\n * @returns Typed ABI Constructor.\n */\nexport function from(\n abiConstructor: AbiConstructor | string | readonly string[],\n): AbiConstructor\n/** @internal */\nexport function from(\n abiConstructor: AbiConstructor | string | readonly string[],\n): from.ReturnType {\n return AbiItem.from(abiConstructor as AbiConstructor)\n}\n\nexport declare namespace from {\n type ReturnType<\n abiConstructor extends\n | AbiConstructor\n | string\n | readonly string[] = AbiConstructor,\n > = AbiItem.from.ReturnType<abiConstructor>\n\n type ErrorType = AbiItem.from.ErrorType | Errors.GlobalErrorType\n}\n\n/** @internal */\nexport function fromAbi<const abi extends Abi.Abi | readonly unknown[]>(\n abi: abi | Abi.Abi | readonly unknown[],\n): fromAbi.ReturnType<abi>\n/**\n * Extracts an {@link ox#AbiConstructor.AbiConstructor} from an {@link ox#Abi.Abi} given a name and optional arguments.\n *\n * @example\n * ### Extracting by Name\n *\n * ABI Events can be extracted by their name using the `name` option:\n *\n * ```ts twoslash\n * import { Abi, AbiConstructor } from 'ox'\n *\n * const abi = Abi.from([\n * 'constructor(address owner)',\n * 'function foo()',\n * 'event Transfer(address owner, address to, uint256 tokenId)',\n * 'function bar(string a) returns (uint256 x)',\n * ])\n *\n * const item = AbiConstructor.fromAbi(abi) // [!code focus]\n * // ^?\n *\n *\n *\n *\n *\n *\n * ```\n *\n * @returns The ABI constructor.\n */\nexport function fromAbi(abi: Abi.Abi | readonly unknown[]): AbiConstructor\n/** @internal */\nexport function fromAbi(abi: Abi.Abi | readonly unknown[]): fromAbi.ReturnType {\n const item = (abi as Abi.Abi).find((item) => item.type === 'constructor')\n if (!item) throw new AbiItem.NotFoundError({ name: 'constructor' })\n return item\n}\n\nexport declare namespace fromAbi {\n type ReturnType<abi extends Abi.Abi | readonly unknown[] = Abi.Abi> = Extract<\n abi[number],\n { type: 'constructor' }\n >\n\n type ErrorType = AbiItem.NotFoundError | Errors.GlobalErrorType\n}\n", "import * as abitype from 'abitype'\nimport type * as Abi from './Abi.js'\nimport * as AbiItem from './AbiItem.js'\nimport * as AbiParameters from './AbiParameters.js'\nimport type * as Errors from './Errors.js'\nimport * as Hex from './Hex.js'\nimport type * as internal from './internal/abiFunction.js'\nimport type * as AbiItem_internal from './internal/abiItem.js'\nimport type * as AbiParameters_internal from './internal/abiParameters.js'\nimport type { IsNarrowable } from './internal/types.js'\n\n/** Root type for an {@link ox#AbiItem.AbiItem} with a `function` type. */\nexport type AbiFunction = abitype.AbiFunction & {\n hash?: Hex.Hex | undefined\n overloads?: readonly AbiFunction[] | undefined\n}\n\n/**\n * Extracts an {@link ox#AbiFunction.AbiFunction} item from an {@link ox#Abi.Abi}, given a name.\n *\n * @example\n * ```ts twoslash\n * import { Abi, AbiFunction } from 'ox'\n *\n * const abi = Abi.from([\n * 'function foo(string)',\n * 'function bar(uint256)',\n * ])\n *\n * type Foo = AbiFunction.FromAbi<typeof abi, 'foo'>\n * // ^?\n *\n *\n *\n *\n *\n *\n *\n *\n * ```\n */\nexport type FromAbi<\n abi extends Abi.Abi,\n name extends ExtractNames<abi>,\n> = abitype.ExtractAbiFunction<abi, name>\n\n/**\n * Extracts the names of all {@link ox#AbiFunction.AbiFunction} items in an {@link ox#Abi.Abi}.\n *\n * @example\n * ```ts twoslash\n * import { Abi, AbiFunction } from 'ox'\n *\n * const abi = Abi.from([\n * 'function foo(string)',\n * 'function bar(uint256)',\n * ])\n *\n * type names = AbiFunction.Name<typeof abi>\n * // ^?\n *\n *\n * ```\n */\nexport type Name<abi extends Abi.Abi | readonly unknown[] = Abi.Abi> =\n abi extends Abi.Abi ? ExtractNames<abi> : string\n\nexport type ExtractNames<\n abi extends Abi.Abi,\n abiStateMutability extends\n abitype.AbiStateMutability = abitype.AbiStateMutability,\n> = abitype.ExtractAbiFunctionNames<abi, abiStateMutability>\n\n/**\n * ABI-decodes function arguments according to the ABI Item's input types (`inputs`).\n *\n * @example\n * ```ts twoslash\n * import { AbiFunction } from 'ox'\n *\n * const approve = AbiFunction.from('function approve(address, uint256)')\n *\n * const data = AbiFunction.encodeData(\n * approve,\n * ['0xd8da6bf26964af9d7eed9e03e53415d37aa96045', 69420n]\n * )\n * // '0x095ea7b3000000000000000000000000d8da6bf26964af9d7eed9e03e53415d37aa960450000000000000000000000000000000000000000000000000000000000010f2c'\n *\n * const input = AbiFunction.decodeData(approve, data) // [!code focus]\n * // @log: ['0xd8da6bf26964af9d7eed9e03e53415d37aa96045', 69420n]\n * ```\n *\n * @param abiFunction - The ABI Item to decode.\n * @param data - The data to decode.\n */\nexport function decodeData<const abiItem extends AbiFunction>(\n abiFunction: abiItem | AbiFunction,\n data: Hex.Hex,\n): decodeData.ReturnType<abiItem> {\n const { overloads } = abiFunction\n\n if (Hex.size(data) < 4) throw new AbiItem.InvalidSelectorSizeError({ data })\n if (abiFunction.inputs.length === 0) return undefined\n\n const item = overloads\n ? fromAbi([abiFunction, ...overloads], data as never)\n : abiFunction\n\n if (Hex.size(data) <= 4) return undefined\n return AbiParameters.decode(item.inputs, Hex.slice(data, 4))\n}\n\nexport declare namespace decodeData {\n type ReturnType<abiFunction extends AbiFunction = AbiFunction> = IsNarrowable<\n abiFunction,\n AbiFunction\n > extends true\n ? abiFunction['inputs'] extends readonly []\n ? undefined\n :\n | AbiParameters_internal.ToPrimitiveTypes<abiFunction['inputs']>\n | (abiFunction['overloads'] extends readonly AbiFunction[]\n ? AbiParameters_internal.ToPrimitiveTypes<\n abiFunction['overloads'][number]['inputs']\n >\n : never)\n : unknown\n\n type ErrorType =\n | fromAbi.ErrorType\n | AbiParameters.decode.ErrorType\n | Hex.size.ErrorType\n | Hex.slice.ErrorType\n | Errors.GlobalErrorType\n}\n\n/**\n * ABI-decodes a function's result according to the ABI Item's output types (`outputs`).\n *\n * :::tip\n *\n * This function is typically used to decode contract function return values (e.g. the response of an `eth_call` or the `input` property of a Transaction).\n *\n * See the [End-to-end Example](#end-to-end).\n *\n * :::\n *\n * @example\n * ```ts twoslash\n * import { AbiFunction } from 'ox'\n *\n * const data = '0x000000000000000000000000000000000000000000000000000000000000002a'\n *\n * const totalSupply = AbiFunction.from('function totalSupply() returns (uint256)')\n *\n * const output = AbiFunction.decodeResult(totalSupply, data)\n * // @log: 42n\n * ```\n *\n * @example\n * You can extract an ABI Function from a JSON ABI with {@link ox#AbiFunction.(fromAbi:function)}:\n *\n * ```ts twoslash\n * // @noErrors\n * import { Abi, AbiFunction } from 'ox'\n *\n * const data = '0x000000000000000000000000000000000000000000000000000000000000002a'\n *\n * const erc20Abi = Abi.from([...]) // [!code hl]\n * const totalSupply = AbiFunction.fromAbi(erc20Abi, 'totalSupply') // [!code hl]\n *\n * const output = AbiFunction.decodeResult(totalSupply, data)\n * // @log: 42n\n * ```\n *\n * @example\n * ### End-to-end\n *\n * Below is an end-to-end example of using `AbiFunction.decodeResult` to decode the result of a `balanceOf` contract call on the [Wagmi Mint Example contract](https://etherscan.io/address/0xfba3912ca04dd458c843e2ee08967fc04f3579c2).\n *\n * ```ts twoslash\n * import 'ox/window'\n * import { Abi, AbiFunction } from 'ox'\n *\n * // 1. Extract the Function from the Contract's ABI.\n * const abi = Abi.from([\n * // ...\n * {\n * name: 'balanceOf',\n * type: 'function',\n * inputs: [{ name: 'account', type: 'address' }],\n * outputs: [{ name: 'balance', type: 'uint256' }],\n * stateMutability: 'view',\n * },\n * // ...\n * ])\n * const balanceOf = AbiFunction.fromAbi(abi, 'balanceOf')\n *\n * // 2. Encode the Function Input.\n * const data = AbiFunction.encodeData(\n * balanceOf,\n * ['0xd2135CfB216b74109775236E36d4b433F1DF507B']\n * )\n *\n * // 3. Perform the Contract Call.\n * const response = await window.ethereum!.request({\n * method: 'eth_call',\n * params: [\n * {\n * data,\n * to: '0xfba3912ca04dd458c843e2ee08967fc04f3579c2',\n * },\n * ],\n * })\n *\n * // 4. Decode the Function Output. // [!code focus]\n * const balance = AbiFunction.decodeResult(balanceOf, response) // [!code focus]\n * // @log: 42n\n * ```\n *\n * :::note\n *\n * For simplicity, the above example uses `window.ethereum.request`, but you can use any\n * type of JSON-RPC interface.\n *\n * :::\n *\n * @param abiFunction - ABI Function to decode\n * @param data - ABI-encoded function output\n * @param options - Decoding options\n * @returns Decoded function output\n */\nexport function decodeResult<\n const abiFunction extends AbiFunction,\n as extends 'Object' | 'Array' = 'Array',\n>(\n abiFunction: abiFunction | AbiFunction,\n data: Hex.Hex,\n options: decodeResult.Options<as> = {},\n): decodeResult.ReturnType<abiFunction, as> {\n const values = AbiParameters.decode(abiFunction.outputs, data, options)\n if (values && Object.keys(values).length === 0) return undefined\n if (values && Object.keys(values).length === 1) {\n if (Array.isArray(values)) return values[0]\n return Object.values(values)[0]\n }\n return values\n}\n\nexport declare namespace decodeResult {\n type Options<as extends 'Object' | 'Array'> = {\n /**\n * Whether the decoded values should be returned as an `Object` or `Array`.\n *\n * @default \"Array\"\n */\n as?: as | 'Array' | 'Object' | undefined\n }\n\n type ReturnType<\n abiFunction extends AbiFunction = AbiFunction,\n as extends 'Object' | 'Array' = 'Array',\n > = IsNarrowable<abiFunction, AbiFunction> extends true\n ? abiFunction['outputs'] extends readonly []\n ? undefined\n : abiFunction['outputs'] extends readonly [\n infer type extends abitype.AbiParameter,\n ]\n ? abitype.AbiParameterToPrimitiveType<type>\n : AbiParameters.decode.ReturnType<\n abiFunction['outputs'],\n as\n > extends infer types\n ? types extends readonly []\n ? undefined\n : types extends readonly [infer type]\n ? type\n : types\n : never\n : unknown\n\n type ErrorType = AbiParameters.decode.ErrorType | Errors.GlobalErrorType\n}\n\n/**\n * ABI-encodes function arguments (`inputs`), prefixed with the 4 byte function selector.\n *\n * :::tip\n *\n * This function is typically used to encode a contract function and its arguments for contract calls (e.g. `data` parameter of an `eth_call` or `eth_sendTransaction`).\n *\n * See the [End-to-end Example](#end-to-end).\n *\n * :::\n *\n * @example\n * ```ts twoslash\n * import { AbiFunction } from 'ox'\n *\n * const approve = AbiFunction.from('function approve(address, uint256)')\n *\n * const data = AbiFunction.encodeData( // [!code focus]\n * approve, // [!code focus]\n * ['0xd8da6bf26964af9d7eed9e03e53415d37aa96045', 69420n] // [!code focus]\n * ) // [!code focus]\n * // @log: '0x095ea7b3000000000000000000000000d8da6bf26964af9d7eed9e03e53415d37aa960450000000000000000000000000000000000000000000000000000000000010f2c'\n * ```\n *\n * @example\n * You can extract an ABI Function from a JSON ABI with {@link ox#AbiFunction.(fromAbi:function)}:\n *\n * ```ts twoslash\n * // @noErrors\n * import { Abi, AbiFunction } from 'ox'\n *\n * const erc20Abi = Abi.from([...]) // [!code hl]\n * const approve = AbiFunction.fromAbi(erc20Abi, 'approve') // [!code hl]\n *\n * const data = AbiFunction.encodeData(\n * approve,\n * ['0xd8da6bf26964af9d7eed9e03e53415d37aa96045', 69420n]\n * )\n * // @log: '0x095ea7b3000000000000000000000000d8da6bf26964af9d7eed9e03e53415d37aa960450000000000000000000000000000000000000000000000000000000000010f2c'\n * ```\n *\n * @example\n * ### End-to-end\n *\n * Below is an end-to-end example of using `AbiFunction.encodeData` to encode the input of a `balanceOf` contract call on the [Wagmi Mint Example contract](https://etherscan.io/address/0xfba3912ca04dd458c843e2ee08967fc04f3579c2).\n *\n * ```ts twoslash\n * import 'ox/window'\n * import { Abi, AbiFunction } from 'ox'\n *\n * // 1. Extract the Function from the Contract's ABI.\n * const abi = Abi.from([\n * // ...\n * {\n * name: 'balanceOf',\n * type: 'function',\n * inputs: [{ name: 'account', type: 'address' }],\n * outputs: [{ name: 'balance', type: 'uint256' }],\n * stateMutability: 'view',\n * },\n * // ...\n * ])\n * const balanceOf = AbiFunction.fromAbi(abi, 'balanceOf')\n *\n * // 2. Encode the Function Input. // [!code focus]\n * const data = AbiFunction.encodeData( // [!code focus]\n * balanceOf, // [!code focus]\n * ['0xd2135CfB216b74109775236E36d4b433F1DF507B'] // [!code focus]\n * ) // [!code focus]\n *\n * // 3. Perform the Contract Call.\n * const response = await window.ethereum!.request({\n * method: 'eth_call',\n * params: [\n * {\n * data,\n * to: '0xfba3912ca04dd458c843e2ee08967fc04f3579c2',\n * },\n * ],\n * })\n *\n * // 4. Decode the Function Output.\n * const balance = AbiFunction.decodeResult(balanceOf, response)\n * ```\n *\n * :::note\n *\n * For simplicity, the above example uses `window.ethereum.request`, but you can use any\n * type of JSON-RPC interface.\n *\n * :::\n *\n * @param abiFunction - ABI Function to encode\n * @param args - Function arguments\n * @returns ABI-encoded function name and arguments\n */\nexport function encodeData<const abiFunction extends AbiFunction>(\n abiFunction: abiFunction | AbiFunction,\n ...args: encodeData.Args<abiFunction>\n): Hex.Hex {\n const { overloads } = abiFunction\n\n const item = overloads\n ? (fromAbi([abiFunction as AbiFunction, ...overloads], abiFunction.name, {\n args: (args as any)[0],\n }) as AbiFunction)\n : abiFunction\n\n const selector = getSelector(item)\n\n const data =\n args.length > 0\n ? AbiParameters.encode(item.inputs, (args as any)[0])\n : undefined\n\n return data ? Hex.concat(selector, data) : selector\n}\n\nexport declare namespace encodeData {\n type Args<abiFunction extends AbiFunction = AbiFunction> = IsNarrowable<\n abiFunction,\n AbiFunction\n > extends true\n ?\n | (abitype.AbiParametersToPrimitiveTypes<\n abiFunction['inputs']\n > extends readonly []\n ? []\n : [abitype.AbiParametersToPrimitiveTypes<abiFunction['inputs']>])\n | (abiFunction['overloads'] extends readonly AbiFunction[]\n ? [\n abitype.AbiParametersToPrimitiveTypes<\n abiFunction['overloads'][number]['inputs']\n >,\n ]\n : [])\n : readonly unknown[]\n\n type ErrorType = Errors.GlobalErrorType\n}\n\n/**\n * ABI-encodes a function's result (`outputs`).\n *\n * @example\n * ```ts twoslash\n * import { AbiFunction } from 'ox'\n *\n * const totalSupply = AbiFunction.from('function totalSupply() returns (uint256)')\n * const output = AbiFunction.decodeResult(totalSupply, '0x000000000000000000000000000000000000000000000000000000000000002a')\n * // 42n\n *\n * const data = AbiFunction.encodeResult(totalSupply, 42n) // [!code focus]\n * // @log: '0x000000000000000000000000000000000000000000000000000000000000002a'\n * ```\n *\n * @param abiFunction - The ABI item to encode the function output for.\n * @param output - The function output to encode.\n * @param options - Encoding options.\n * @returns The encoded function output.\n */\nexport function encodeResult<\n const abiFunction extends AbiFunction,\n as extends 'Object' | 'Array' = 'Array',\n>(\n abiFunction: abiFunction | AbiFunction,\n output: encodeResult.Output<abiFunction, as>,\n options: encodeResult.Options<as> = {},\n): Hex.Hex {\n const { as = 'Array' } = options\n\n const values = (() => {\n if (abiFunction.outputs.length === 1) return [output]\n if (Array.isArray(output)) return output\n if (as === 'Object') return Object.values(output as any)\n return [output]\n })()\n\n return AbiParameters.encode(abiFunction.outputs, values)\n}\n\nexport declare namespace encodeResult {\n type Output<\n abiFunction extends AbiFunction = AbiFunction,\n as extends 'Object' | 'Array' = 'Array',\n > = abiFunction['outputs'] extends readonly []\n ? never\n : abiFunction['outputs']['length'] extends 1\n ? AbiParameters_internal.ToPrimitiveTypes<abiFunction['outputs']>[0]\n : as extends 'Object'\n ? AbiParameters_internal.ToObject<abiFunction['outputs']>\n : AbiParameters_internal.ToPrimitiveTypes<abiFunction['outputs']>\n\n type Options<as extends 'Object' | 'Array'> = {\n as?: as | 'Object' | 'Array' | undefined\n }\n\n type ErrorType = AbiParameters.encode.ErrorType | Errors.GlobalErrorType\n}\n\n/**\n * Formats an {@link ox#AbiFunction.AbiFunction} into a **Human Readable ABI Function**.\n *\n * @example\n * ```ts twoslash\n * import { AbiFunction } from 'ox'\n *\n * const formatted = AbiFunction.format({\n * type: 'function',\n * name: 'approve',\n * stateMutability: 'nonpayable',\n * inputs: [\n * {\n * name: 'spender',\n * type: 'address',\n * },\n * {\n * name: 'amount',\n * type: 'uint256',\n * },\n * ],\n * outputs: [{ type: 'bool' }],\n * })\n *\n * formatted\n * // ^?\n *\n *\n * ```\n *\n * @param abiFunction - The ABI Function to format.\n * @returns The formatted ABI Function.\n */\nexport function format<const abiFunction extends AbiFunction>(\n abiFunction: abiFunction | AbiFunction,\n): abitype.FormatAbiItem<abiFunction> {\n return abitype.formatAbiItem(abiFunction) as never\n}\n\nexport declare namespace format {\n type ErrorType = Errors.GlobalErrorType\n}\n\n/**\n * Parses an arbitrary **JSON ABI Function** or **Human Readable ABI Function** into a typed {@link ox#AbiFunction.AbiFunction}.\n *\n * @example\n * ### JSON ABIs\n *\n * ```ts twoslash\n * import { AbiFunction } from 'ox'\n *\n * const approve = AbiFunction.from({\n * type: 'function',\n * name: 'approve',\n * stateMutability: 'nonpayable',\n * inputs: [\n * {\n * name: 'spender',\n * type: 'address',\n * },\n * {\n * name: 'amount',\n * type: 'uint256',\n * },\n * ],\n * outputs: [{ type: 'bool' }],\n * })\n *\n * approve\n * //^?\n *\n *\n *\n *\n *\n *\n *\n *\n *\n *\n *\n *\n * ```\n *\n * @example\n * ### Human Readable ABIs\n *\n * A Human Readable ABI can be parsed into a typed ABI object:\n *\n * ```ts twoslash\n * import { AbiFunction } from 'ox'\n *\n * const approve = AbiFunction.from(\n * 'function approve(address spender, uint256 amount) returns (bool)' // [!code hl]\n * )\n *\n * approve\n * //^?\n *\n *\n *\n *\n *\n *\n *\n *\n *\n *\n *\n *\n *\n * ```\n *\n * @example\n * It is possible to specify `struct`s along with your definitions:\n *\n * ```ts twoslash\n * import { AbiFunction } from 'ox'\n *\n * const approve = AbiFunction.from([\n * 'struct Foo { address spender; uint256 amount; }', // [!code hl]\n * 'function approve(Foo foo) returns (bool)',\n * ])\n *\n * approve\n * //^?\n *\n *\n *\n *\n *\n *\n *\n *\n *\n *\n *\n *\n * ```\n *\n *\n *\n * @param abiFunction - The ABI Function to parse.\n * @returns Typed ABI Function.\n */\nexport function from<\n const abiFunction extends AbiFunction | string | readonly string[],\n>(\n abiFunction: (abiFunction | AbiFunction | string | readonly string[]) &\n (\n | (abiFunction extends string ? internal.Signature<abiFunction> : never)\n | (abiFunction extends readonly string[]\n ? internal.Signatures<abiFunction>\n : never)\n | AbiFunction\n ),\n options: from.Options = {},\n): from.ReturnType<abiFunction> {\n return AbiItem.from(abiFunction as AbiFunction, options) as never\n}\n\nexport declare namespace from {\n type Options = {\n /**\n * Whether or not to prepare the extracted function (optimization for encoding performance).\n * When `true`, the `hash` property is computed and included in the returned value.\n *\n * @default true\n */\n prepare?: boolean | undefined\n }\n\n type ReturnType<\n abiFunction extends AbiFunction | string | readonly string[],\n > = AbiItem.from.ReturnType<abiFunction>\n\n type ErrorType = AbiItem.from.ErrorType | Errors.GlobalErrorType\n}\n\n/**\n * Extracts an {@link ox#AbiFunction.AbiFunction} from an {@link ox#Abi.Abi} given a name and optional arguments.\n *\n * @example\n * ### Extracting by Name\n *\n * ABI Functions can be extracted by their name using the `name` option:\n *\n * ```ts twoslash\n * import { Abi, AbiFunction } from 'ox'\n *\n * const abi = Abi.from([\n * 'function foo()',\n * 'event Transfer(address owner, address to, uint256 tokenId)',\n * 'function bar(string a) returns (uint256 x)',\n * ])\n *\n * const item = AbiFunction.fromAbi(abi, 'foo') // [!code focus]\n * // ^?\n *\n *\n *\n *\n *\n *\n * ```\n *\n * @example\n * ### Extracting by Selector\n *\n * ABI Functions can be extract by their selector when {@link ox#Hex.Hex} is provided to `name`.\n *\n * ```ts twoslash\n * import { Abi, AbiFunction } from 'ox'\n *\n * const abi = Abi.from([\n * 'function foo()',\n * 'event Transfer(address owner, address to, uint256 tokenId)',\n * 'function bar(string a) returns (uint256 x)',\n * ])\n * const item = AbiFunction.fromAbi(abi, '0x095ea7b3') // [!code focus]\n * // ^?\n *\n *\n *\n *\n *\n *\n *\n *\n *\n * ```\n *\n * :::note\n *\n * Extracting via a hex selector is useful when extracting an ABI Function from an `eth_call` RPC response or\n * from a Transaction `input`.\n *\n * :::\n *\n * @param abi - The ABI to extract from.\n * @param name - The name (or selector) of the ABI item to extract.\n * @param options - Extraction options.\n * @returns The ABI item.\n */\nexport function fromAbi<\n const abi extends Abi.Abi | readonly unknown[],\n name extends Name<abi>,\n const args extends\n | AbiItem_internal.ExtractArgs<abi, name>\n | undefined = undefined,\n //\n allNames = Name<abi>,\n>(\n abi: abi | Abi.Abi | readonly unknown[],\n name: Hex.Hex | (name extends allNames ? name : never),\n options?: AbiItem.fromAbi.Options<\n abi,\n name,\n args,\n AbiItem_internal.ExtractArgs<abi, name>\n >,\n): AbiItem.fromAbi.ReturnType<abi, name, args, AbiFunction> {\n const item = AbiItem.fromAbi(abi, name, options as any)\n if (item.type !== 'function')\n throw new AbiItem.NotFoundError({ name, type: 'function' })\n return item as never\n}\n\nexport declare namespace fromAbi {\n type ErrorType = AbiItem.fromAbi.ErrorType | Errors.GlobalErrorType\n}\n\n/**\n * Computes the [4-byte selector](https://solidity-by-example.org/function-selector/) for an {@link ox#AbiFunction.AbiFunction}.\n *\n * Useful for computing function selectors for calldata.\n *\n * @example\n * ```ts twoslash\n * import { AbiFunction } from 'ox'\n *\n * const selector = AbiFunction.getSelector('function ownerOf(uint256 tokenId)')\n * // @log: '0x6352211e'\n * ```\n *\n * @example\n * ```ts twoslash\n * import { AbiFunction } from 'ox'\n *\n * const selector = AbiFunction.getSelector({\n * inputs: [{ type: 'uint256' }],\n * name: 'ownerOf',\n * outputs: [],\n * stateMutability: 'view',\n * type: 'function'\n * })\n * // @log: '0x6352211e'\n * ```\n *\n * @param abiItem - The ABI item to compute the selector for.\n * @returns The first 4 bytes of the {@link ox#Hash.(keccak256:function)} hash of the function signature.\n */\nexport function getSelector(abiItem: string | AbiFunction): Hex.Hex {\n return AbiItem.getSelector(abiItem)\n}\n\nexport declare namespace getSelector {\n type ErrorType = AbiItem.getSelector.ErrorType | Errors.GlobalErrorType\n}\n", "export const entryPoint06Address =\n '0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789' as const\nexport const entryPoint07Address =\n '0x0000000071727De22E5E9d8BAf0edAc6f37da032' as const\n\nexport const ethAddress = '0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee' as const\n\nexport const zeroAddress = '0x0000000000000000000000000000000000000000' as const\n", "import { LruMap } from '../lru.js'\n\n/** @internal */\nexport const promiseCache = /*#__PURE__*/ new LruMap<Promise<any>>(8192)\n\ntype WithDedupeOptions = {\n enabled?: boolean | undefined\n id?: string | undefined\n}\n\n/** Deduplicates in-flight promises. */\nexport function withDedupe<data>(\n fn: () => Promise<data>,\n { enabled = true, id }: WithDedupeOptions,\n): Promise<data> {\n if (!enabled || !id) return fn()\n if (promiseCache.get(id)) return promiseCache.get(id)!\n const promise = fn().finally(() => promiseCache.delete(id))\n promiseCache.set(id, promise)\n return promise\n}\n", "export async function wait(time: number) {\n return new Promise((res) => setTimeout(res, time))\n}\n", "import type { ErrorType } from '../../errors/utils.js'\nimport { wait } from '../wait.js'\n\nexport type WithRetryParameters = {\n // The delay (in ms) between retries.\n delay?:\n | ((config: { count: number; error: Error }) => number)\n | number\n | undefined\n // The max number of times to retry.\n retryCount?: number | undefined\n // Whether or not to retry when an error is thrown.\n shouldRetry?:\n | (({\n count,\n error,\n }: {\n count: number\n error: Error\n }) => Promise<boolean> | boolean)\n | undefined\n}\n\nexport type WithRetryErrorType = ErrorType\n\nexport function withRetry<data>(\n fn: () => Promise<data>,\n {\n delay: delay_ = 100,\n retryCount = 2,\n shouldRetry = () => true,\n }: WithRetryParameters = {},\n) {\n return new Promise<data>((resolve, reject) => {\n const attemptRetry = async ({ count = 0 } = {}) => {\n const retry = async ({ error }: { error: Error }) => {\n const delay =\n typeof delay_ === 'function' ? delay_({ count, error }) : delay_\n if (delay) await wait(delay)\n attemptRetry({ count: count + 1 })\n }\n\n try {\n const data = await fn()\n resolve(data)\n } catch (err) {\n if (\n count < retryCount &&\n (await shouldRetry({ count, error: err as Error }))\n )\n return retry({ error: err as Error })\n reject(err)\n }\n }\n attemptRetry()\n })\n}\n", "import { BaseError } from '../errors/base.js'\nimport {\n HttpRequestError,\n type HttpRequestErrorType,\n type RpcRequestErrorType,\n type TimeoutErrorType,\n type WebSocketRequestErrorType,\n} from '../errors/request.js'\nimport {\n ChainDisconnectedError,\n type ChainDisconnectedErrorType,\n InternalRpcError,\n type InternalRpcErrorType,\n InvalidInputRpcError,\n type InvalidInputRpcErrorType,\n InvalidParamsRpcError,\n type InvalidParamsRpcErrorType,\n InvalidRequestRpcError,\n type InvalidRequestRpcErrorType,\n JsonRpcVersionUnsupportedError,\n type JsonRpcVersionUnsupportedErrorType,\n LimitExceededRpcError,\n type LimitExceededRpcErrorType,\n MethodNotFoundRpcError,\n type MethodNotFoundRpcErrorType,\n MethodNotSupportedRpcError,\n type MethodNotSupportedRpcErrorType,\n ParseRpcError,\n type ParseRpcErrorType,\n ProviderDisconnectedError,\n type ProviderDisconnectedErrorType,\n type ProviderRpcErrorCode,\n ResourceNotFoundRpcError,\n type ResourceNotFoundRpcErrorType,\n ResourceUnavailableRpcError,\n type ResourceUnavailableRpcErrorType,\n type RpcError,\n type RpcErrorCode,\n type RpcErrorType,\n SwitchChainError,\n type SwitchChainErrorType,\n TransactionRejectedRpcError,\n type TransactionRejectedRpcErrorType,\n UnauthorizedProviderError,\n type UnauthorizedProviderErrorType,\n UnknownRpcError,\n type UnknownRpcErrorType,\n UnsupportedProviderMethodError,\n type UnsupportedProviderMethodErrorType,\n UserRejectedRequestError,\n type UserRejectedRequestErrorType,\n} from '../errors/rpc.js'\nimport type { ErrorType } from '../errors/utils.js'\nimport type {\n EIP1193RequestFn,\n EIP1193RequestOptions,\n} from '../types/eip1193.js'\nimport { stringToHex } from './encoding/toHex.js'\nimport type { CreateBatchSchedulerErrorType } from './promise/createBatchScheduler.js'\nimport { withDedupe } from './promise/withDedupe.js'\nimport { type WithRetryErrorType, withRetry } from './promise/withRetry.js'\nimport type { GetSocketRpcClientErrorType } from './rpc/socket.js'\nimport { stringify } from './stringify.js'\n\nexport type RequestErrorType =\n | ChainDisconnectedErrorType\n | CreateBatchSchedulerErrorType\n | HttpRequestErrorType\n | InternalRpcErrorType\n | InvalidInputRpcErrorType\n | InvalidParamsRpcErrorType\n | InvalidRequestRpcErrorType\n | GetSocketRpcClientErrorType\n | JsonRpcVersionUnsupportedErrorType\n | LimitExceededRpcErrorType\n | MethodNotFoundRpcErrorType\n | MethodNotSupportedRpcErrorType\n | ParseRpcErrorType\n | ProviderDisconnectedErrorType\n | ResourceNotFoundRpcErrorType\n | ResourceUnavailableRpcErrorType\n | RpcErrorType\n | RpcRequestErrorType\n | SwitchChainErrorType\n | TimeoutErrorType\n | TransactionRejectedRpcErrorType\n | UnauthorizedProviderErrorType\n | UnknownRpcErrorType\n | UnsupportedProviderMethodErrorType\n | UserRejectedRequestErrorType\n | WebSocketRequestErrorType\n | WithRetryErrorType\n | ErrorType\n\nexport function buildRequest<request extends (args: any) => Promise<any>>(\n request: request,\n options: EIP1193RequestOptions = {},\n): EIP1193RequestFn {\n return async (args, overrideOptions = {}) => {\n const {\n dedupe = false,\n methods,\n retryDelay = 150,\n retryCount = 3,\n uid,\n } = {\n ...options,\n ...overrideOptions,\n }\n\n const { method } = args\n if (methods?.exclude?.includes(method))\n throw new MethodNotSupportedRpcError(new Error('method not supported'), {\n method,\n })\n if (methods?.include && !methods.include.includes(method))\n throw new MethodNotSupportedRpcError(new Error('method not supported'), {\n method,\n })\n\n const requestId = dedupe\n ? stringToHex(`${uid}.${stringify(args)}`)\n : undefined\n return withDedupe(\n () =>\n withRetry(\n async () => {\n try {\n return await request(args)\n } catch (err_) {\n const err = err_ as unknown as RpcError<\n RpcErrorCode | ProviderRpcErrorCode\n >\n switch (err.code) {\n // -32700\n case ParseRpcError.code:\n throw new ParseRpcError(err)\n // -32600\n case InvalidRequestRpcError.code:\n throw new InvalidRequestRpcError(err)\n // -32601\n case MethodNotFoundRpcError.code:\n throw new MethodNotFoundRpcError(err, { method: args.method })\n // -32602\n case InvalidParamsRpcError.code:\n throw new InvalidParamsRpcError(err)\n // -32603\n case InternalRpcError.code:\n throw new InternalRpcError(err)\n // -32000\n case InvalidInputRpcError.code:\n throw new InvalidInputRpcError(err)\n // -32001\n case ResourceNotFoundRpcError.code:\n throw new ResourceNotFoundRpcError(err)\n // -32002\n case ResourceUnavailableRpcError.code:\n throw new ResourceUnavailableRpcError(err)\n // -32003\n case TransactionRejectedRpcError.code:\n throw new TransactionRejectedRpcError(err)\n // -32004\n case MethodNotSupportedRpcError.code:\n throw new MethodNotSupportedRpcError(err, {\n method: args.method,\n })\n // -32005\n case LimitExceededRpcError.code:\n throw new LimitExceededRpcError(err)\n // -32006\n case JsonRpcVersionUnsupportedError.code:\n throw new JsonRpcVersionUnsupportedError(err)\n // 4001\n case UserRejectedRequestError.code:\n throw new UserRejectedRequestError(err)\n // 4100\n case UnauthorizedProviderError.code:\n throw new UnauthorizedProviderError(err)\n // 4200\n case UnsupportedProviderMethodError.code:\n throw new UnsupportedProviderMethodError(err)\n // 4900\n case ProviderDisconnectedError.code:\n throw new ProviderDisconnectedError(err)\n // 4901\n case ChainDisconnectedError.code:\n throw new ChainDisconnectedError(err)\n // 4902\n case SwitchChainError.code:\n throw new SwitchChainError(err)\n // CAIP-25: User Rejected Error\n // https://docs.walletconnect.com/2.0/specs/clients/sign/error-codes#rejected-caip-25\n case 5000:\n throw new UserRejectedRequestError(err)\n default:\n if (err_ instanceof BaseError) throw err_\n throw new UnknownRpcError(err as Error)\n }\n }\n },\n {\n delay: ({ count, error }) => {\n // If we find a Retry-After header, let's retry after the given time.\n if (error && error instanceof HttpRequestError) {\n const retryAfter = error?.headers?.get('Retry-After')\n if (retryAfter?.match(/\\d/))\n return Number.parseInt(retryAfter) * 1000\n }\n\n // Otherwise, let's retry with an exponential backoff.\n return ~~(1 << count) * retryDelay\n },\n retryCount,\n shouldRetry: ({ error }) => shouldRetry(error),\n },\n ),\n { enabled: dedupe, id: requestId },\n )\n }\n}\n\n/** @internal */\nexport function shouldRetry(error: Error) {\n if ('code' in error && typeof error.code === 'number') {\n if (error.code === -1) return true // Unknown error\n if (error.code === LimitExceededRpcError.code) return true\n if (error.code === InternalRpcError.code) return true\n return false\n }\n if (error instanceof HttpRequestError && error.status) {\n // Forbidden\n if (error.status === 403) return true\n // Request Timeout\n if (error.status === 408) return true\n // Request Entity Too Large\n if (error.status === 413) return true\n // Too Many Requests\n if (error.status === 429) return true\n // Internal Server Error\n if (error.status === 500) return true\n // Bad Gateway\n if (error.status === 502) return true\n // Service Unavailable\n if (error.status === 503) return true\n // Gateway Timeout\n if (error.status === 504) return true\n return false\n }\n return true\n}\n", "import type { ErrorType } from '../../errors/utils.js'\n\nexport type WithTimeoutErrorType = ErrorType\n\nexport function withTimeout<data>(\n fn: ({\n signal,\n }: { signal: AbortController['signal'] | null }) => Promise<data>,\n {\n errorInstance = new Error('timed out'),\n timeout,\n signal,\n }: {\n // The error instance to throw when the timeout is reached.\n errorInstance?: Error | undefined\n // The timeout (in ms).\n timeout: number\n // Whether or not the timeout should use an abort signal.\n signal?: boolean | undefined\n },\n): Promise<data> {\n return new Promise((resolve, reject) => {\n ;(async () => {\n let timeoutId!: NodeJS.Timeout\n try {\n const controller = new AbortController()\n if (timeout > 0) {\n timeoutId = setTimeout(() => {\n if (signal) {\n controller.abort()\n } else {\n reject(errorInstance)\n }\n }, timeout) as NodeJS.Timeout // need to cast because bun globals.d.ts overrides @types/node\n }\n resolve(await fn({ signal: controller?.signal || null }))\n } catch (err) {\n if ((err as Error)?.name === 'AbortError') reject(errorInstance)\n reject(err)\n } finally {\n clearTimeout(timeoutId)\n }\n })()\n })\n}\n", "function createIdStore() {\n return {\n current: 0,\n take() {\n return this.current++\n },\n reset() {\n this.current = 0\n },\n }\n}\n\nexport const idCache = /*#__PURE__*/ createIdStore()\n", "import {\n HttpRequestError,\n type HttpRequestErrorType as HttpRequestErrorType_,\n TimeoutError,\n type TimeoutErrorType,\n} from '../../errors/request.js'\nimport type { ErrorType } from '../../errors/utils.js'\nimport type { RpcRequest, RpcResponse } from '../../types/rpc.js'\nimport type { MaybePromise } from '../../types/utils.js'\nimport {\n type WithTimeoutErrorType,\n withTimeout,\n} from '../promise/withTimeout.js'\nimport { stringify } from '../stringify.js'\nimport { idCache } from './id.js'\n\nexport type HttpRpcClientOptions = {\n /** Request configuration to pass to `fetch`. */\n fetchOptions?: Omit<RequestInit, 'body'> | undefined\n /** A callback to handle the request. */\n onRequest?:\n | ((\n request: Request,\n init: RequestInit,\n ) => MaybePromise<\n void | undefined | (RequestInit & { url?: string | undefined })\n >)\n | undefined\n /** A callback to handle the response. */\n onResponse?: ((response: Response) => Promise<void> | void) | undefined\n /** The timeout (in ms) for the request. */\n timeout?: number | undefined\n}\n\nexport type HttpRequestParameters<\n body extends RpcRequest | RpcRequest[] = RpcRequest,\n> = {\n /** The RPC request body. */\n body: body\n /** Request configuration to pass to `fetch`. */\n fetchOptions?: HttpRpcClientOptions['fetchOptions'] | undefined\n /** A callback to handle the response. */\n onRequest?:\n | ((\n request: Request,\n init: RequestInit,\n ) => MaybePromise<\n void | undefined | (RequestInit & { url?: string | undefined })\n >)\n | undefined\n /** A callback to handle the response. */\n onResponse?: ((response: Response) => Promise<void> | void) | undefined\n /** The timeout (in ms) for the request. */\n timeout?: HttpRpcClientOptions['timeout'] | undefined\n}\n\nexport type HttpRequestReturnType<\n body extends RpcRequest | RpcRequest[] = RpcRequest,\n> = body extends RpcRequest[] ? RpcResponse[] : RpcResponse\n\nexport type HttpRequestErrorType =\n | HttpRequestErrorType_\n | TimeoutErrorType\n | WithTimeoutErrorType\n | ErrorType\n\nexport type HttpRpcClient = {\n request<body extends RpcRequest | RpcRequest[]>(\n params: HttpRequestParameters<body>,\n ): Promise<HttpRequestReturnType<body>>\n}\n\nexport function getHttpRpcClient(\n url: string,\n options: HttpRpcClientOptions = {},\n): HttpRpcClient {\n return {\n async request(params) {\n const {\n body,\n onRequest = options.onRequest,\n onResponse = options.onResponse,\n timeout = options.timeout ?? 10_000,\n } = params\n\n const fetchOptions = {\n ...(options.fetchOptions ?? {}),\n ...(params.fetchOptions ?? {}),\n }\n\n const { headers, method, signal: signal_ } = fetchOptions\n\n try {\n const response = await withTimeout(\n async ({ signal }) => {\n const init: RequestInit = {\n ...fetchOptions,\n body: Array.isArray(body)\n ? stringify(\n body.map((body) => ({\n jsonrpc: '2.0',\n id: body.id ?? idCache.take(),\n ...body,\n })),\n )\n : stringify({\n jsonrpc: '2.0',\n id: body.id ?? idCache.take(),\n ...body,\n }),\n headers: {\n 'Content-Type': 'application/json',\n ...headers,\n },\n method: method || 'POST',\n signal: signal_ || (timeout > 0 ? signal : null),\n }\n const request = new Request(url, init)\n const args = (await onRequest?.(request, init)) ?? { ...init, url }\n const response = await fetch(args.url ?? url, args)\n return response\n },\n {\n errorInstance: new TimeoutError({ body, url }),\n timeout,\n signal: true,\n },\n )\n\n if (onResponse) await onResponse(response)\n\n let data: any\n if (\n response.headers.get('Content-Type')?.startsWith('application/json')\n )\n data = await response.json()\n else {\n data = await response.text()\n try {\n data = JSON.parse(data || '{}')\n } catch (err) {\n if (response.ok) throw err\n data = { error: data }\n }\n }\n\n if (!response.ok) {\n throw new HttpRequestError({\n body,\n details: stringify(data.error) || response.statusText,\n headers: response.headers,\n status: response.status,\n url,\n })\n }\n\n return data\n } catch (err) {\n if (err instanceof HttpRequestError) throw err\n if (err instanceof TimeoutError) throw err\n throw new HttpRequestError({\n body,\n cause: err as Error,\n url,\n })\n }\n },\n }\n}\n", "import { SocketClosedError, TimeoutError } from '../../errors/request.js'\nimport type { ErrorType } from '../../errors/utils.js'\nimport type { RpcRequest, RpcResponse } from '../../types/rpc.js'\nimport {\n type CreateBatchSchedulerErrorType,\n createBatchScheduler,\n} from '../promise/createBatchScheduler.js'\nimport { withTimeout } from '../promise/withTimeout.js'\nimport { idCache } from './id.js'\n\ntype Id = string | number\ntype CallbackFn = {\n onResponse: (message: any) => void\n onError?: ((error?: Error | Event | undefined) => void) | undefined\n}\ntype CallbackMap = Map<Id, CallbackFn>\n\nexport type GetSocketParameters = {\n onClose: () => void\n onError: (error?: Error | Event | undefined) => void\n onOpen: () => void\n onResponse: (data: RpcResponse) => void\n}\n\nexport type Socket<socket extends {}> = socket & {\n close(): void\n ping?: (() => void) | undefined\n request(params: { body: RpcRequest }): void\n}\n\nexport type SocketRpcClient<socket extends {}> = {\n close(): void\n socket: Socket<socket>\n request(params: {\n body: RpcRequest\n onError?: ((error?: Error | Event | undefined) => void) | undefined\n onResponse: (message: RpcResponse) => void\n }): void\n requestAsync(params: {\n body: RpcRequest\n timeout?: number | undefined\n }): Promise<RpcResponse>\n requests: CallbackMap\n subscriptions: CallbackMap\n url: string\n}\n\nexport type GetSocketRpcClientParameters<socket extends {} = {}> = {\n getSocket(params: GetSocketParameters): Promise<Socket<socket>>\n /**\n * Whether or not to send keep-alive messages.\n * @default true\n */\n keepAlive?:\n | boolean\n | {\n /**\n * The interval (in ms) to send keep-alive messages.\n * @default 30_000\n */\n interval?: number | undefined\n }\n | undefined\n key?: string\n /**\n * Whether or not to attempt to reconnect on socket failure or closure.\n * @default true\n */\n reconnect?:\n | boolean\n | {\n /**\n * The maximum number of reconnection attempts.\n * @default 5\n */\n attempts?: number | undefined\n /**\n * The delay (in ms) between reconnection attempts.\n * @default 2_000\n */\n delay?: number | undefined\n }\n | undefined\n url: string\n}\n\nexport type GetSocketRpcClientErrorType =\n | CreateBatchSchedulerErrorType\n | ErrorType\n\nexport const socketClientCache = /*#__PURE__*/ new Map<\n string,\n SocketRpcClient<Socket<{}>>\n>()\n\nexport async function getSocketRpcClient<socket extends {}>(\n parameters: GetSocketRpcClientParameters<socket>,\n): Promise<SocketRpcClient<socket>> {\n const {\n getSocket,\n keepAlive = true,\n key = 'socket',\n reconnect = true,\n url,\n } = parameters\n const { interval: keepAliveInterval = 30_000 } =\n typeof keepAlive === 'object' ? keepAlive : {}\n const { attempts = 5, delay = 2_000 } =\n typeof reconnect === 'object' ? reconnect : {}\n\n let socketClient = socketClientCache.get(`${key}:${url}`)\n\n // If the socket already exists, return it.\n if (socketClient) return socketClient as {} as SocketRpcClient<socket>\n\n let reconnectCount = 0\n const { schedule } = createBatchScheduler<\n undefined,\n [SocketRpcClient<socket>]\n >({\n id: `${key}:${url}`,\n fn: async () => {\n // Set up a cache for incoming \"synchronous\" requests.\n const requests = new Map<Id, CallbackFn>()\n\n // Set up a cache for subscriptions (eth_subscribe).\n const subscriptions = new Map<Id, CallbackFn>()\n\n let error: Error | Event | undefined\n let socket: Socket<{}>\n let keepAliveTimer: ReturnType<typeof setInterval> | undefined\n\n // Set up socket implementation.\n async function setup() {\n const result = await getSocket({\n onClose() {\n // Notify all requests and subscriptions of the closure error.\n for (const request of requests.values())\n request.onError?.(new SocketClosedError({ url }))\n for (const subscription of subscriptions.values())\n subscription.onError?.(new SocketClosedError({ url }))\n\n // Clear all requests and subscriptions.\n requests.clear()\n subscriptions.clear()\n\n // Attempt to reconnect.\n if (reconnect && reconnectCount < attempts)\n setTimeout(async () => {\n reconnectCount++\n await setup().catch(console.error)\n }, delay)\n },\n onError(error_) {\n error = error_\n\n // Notify all requests and subscriptions of the error.\n for (const request of requests.values()) request.onError?.(error)\n for (const subscription of subscriptions.values())\n subscription.onError?.(error)\n\n // Clear all requests and subscriptions.\n requests.clear()\n subscriptions.clear()\n\n // Make sure socket is definitely closed.\n socketClient?.close()\n\n // Attempt to reconnect.\n if (reconnect && reconnectCount < attempts)\n setTimeout(async () => {\n reconnectCount++\n await setup().catch(console.error)\n }, delay)\n },\n onOpen() {\n error = undefined\n reconnectCount = 0\n },\n onResponse(data) {\n const isSubscription = data.method === 'eth_subscription'\n const id = isSubscription ? data.params.subscription : data.id\n const cache = isSubscription ? subscriptions : requests\n const callback = cache.get(id)\n if (callback) callback.onResponse(data)\n if (!isSubscription) cache.delete(id)\n },\n })\n\n socket = result\n\n if (keepAlive) {\n if (keepAliveTimer) clearInterval(keepAliveTimer)\n keepAliveTimer = setInterval(() => socket.ping?.(), keepAliveInterval)\n }\n\n return result\n }\n await setup()\n error = undefined\n\n // Create a new socket instance.\n socketClient = {\n close() {\n keepAliveTimer && clearInterval(keepAliveTimer)\n socket.close()\n socketClientCache.delete(`${key}:${url}`)\n },\n get socket() {\n return socket\n },\n request({ body, onError, onResponse }) {\n if (error && onError) onError(error)\n\n const id = body.id ?? idCache.take()\n\n const callback = (response: RpcResponse) => {\n if (typeof response.id === 'number' && id !== response.id) return\n\n // If we are subscribing to a topic, we want to set up a listener for incoming\n // messages.\n if (\n body.method === 'eth_subscribe' &&\n typeof response.result === 'string'\n )\n subscriptions.set(response.result, {\n onResponse: callback,\n onError,\n })\n\n // If we are unsubscribing from a topic, we want to remove the listener.\n if (body.method === 'eth_unsubscribe')\n subscriptions.delete(body.params?.[0])\n\n onResponse(response)\n }\n\n requests.set(id, { onResponse: callback, onError })\n try {\n socket.request({\n body: {\n jsonrpc: '2.0',\n id,\n ...body,\n },\n })\n } catch (error) {\n onError?.(error as Error)\n }\n },\n requestAsync({ body, timeout = 10_000 }) {\n return withTimeout(\n () =>\n new Promise<RpcResponse>((onResponse, onError) =>\n this.request({\n body,\n onError,\n onResponse,\n }),\n ),\n {\n errorInstance: new TimeoutError({ body, url }),\n timeout,\n },\n )\n },\n requests,\n subscriptions,\n url,\n }\n socketClientCache.set(`${key}:${url}`, socketClient)\n\n return [socketClient as {} as SocketRpcClient<socket>]\n },\n })\n\n const [_, [socketClient_]] = await schedule()\n return socketClient_\n}\n", "import type { MessageEvent } from 'isows'\n\nimport {\n SocketClosedError,\n WebSocketRequestError,\n} from '../../errors/request.js'\nimport type { RpcRequest } from '../../types/rpc.js'\nimport {\n type GetSocketRpcClientParameters,\n type Socket,\n type SocketRpcClient,\n getSocketRpcClient,\n} from './socket.js'\n\nexport type GetWebSocketRpcClientOptions = Pick<\n GetSocketRpcClientParameters,\n 'keepAlive' | 'reconnect'\n>\n\nexport async function getWebSocketRpcClient(\n url: string,\n options: GetWebSocketRpcClientOptions | undefined = {},\n): Promise<SocketRpcClient<WebSocket>> {\n const { keepAlive, reconnect } = options\n\n return getSocketRpcClient({\n async getSocket({ onClose, onError, onOpen, onResponse }) {\n const WebSocket = await import('isows').then((module) => module.WebSocket)\n const socket = new WebSocket(url)\n\n function onClose_() {\n socket.removeEventListener('close', onClose_)\n socket.removeEventListener('message', onMessage)\n socket.removeEventListener('error', onError)\n socket.removeEventListener('open', onOpen)\n onClose()\n }\n function onMessage({ data }: MessageEvent) {\n try {\n const _data = JSON.parse(data)\n onResponse(_data)\n } catch (error) {\n onError(error as Error)\n }\n }\n\n // Setup event listeners for RPC & subscription responses.\n socket.addEventListener('close', onClose_)\n socket.addEventListener('message', onMessage)\n socket.addEventListener('error', onError)\n socket.addEventListener('open', onOpen)\n\n // Wait for the socket to open.\n if (socket.readyState === WebSocket.CONNECTING) {\n await new Promise((resolve, reject) => {\n if (!socket) return\n socket.onopen = resolve\n socket.onerror = reject\n })\n }\n\n const { close: close_ } = socket\n\n return Object.assign(socket, {\n close() {\n close_.bind(socket)()\n onClose_()\n },\n ping() {\n try {\n if (\n socket.readyState === socket.CLOSED ||\n socket.readyState === socket.CLOSING\n )\n throw new WebSocketRequestError({\n url: socket.url,\n cause: new SocketClosedError({ url: socket.url }),\n })\n\n const body: RpcRequest = {\n jsonrpc: '2.0',\n method: 'net_version',\n params: [],\n }\n socket.send(JSON.stringify(body))\n } catch (error) {\n onError(error as Error)\n }\n },\n request({ body }) {\n if (\n socket.readyState === socket.CLOSED ||\n socket.readyState === socket.CLOSING\n )\n throw new WebSocketRequestError({\n body,\n url: socket.url,\n cause: new SocketClosedError({ url: socket.url }),\n })\n\n return socket.send(JSON.stringify(body))\n },\n } as Socket<WebSocket>)\n },\n keepAlive,\n reconnect,\n url,\n })\n}\n", "// TODO(v3): This file is here for backwards compatibility, and to prevent breaking changes.\n// These APIs will be removed in v3.\n\n/* c8 ignore start */\nimport type {\n TimeoutErrorType,\n WebSocketRequestError,\n} from '../../errors/request.js'\nimport type { ErrorType } from '../../errors/utils.js'\nimport type { RpcResponse } from '../../types/rpc.js'\nimport type { WithTimeoutErrorType } from '../promise/withTimeout.js'\nimport { type HttpRequestParameters, getHttpRpcClient } from './http.js'\nimport type { SocketRpcClient } from './socket.js'\nimport { getWebSocketRpcClient } from './webSocket.js'\n\nexport type WebSocketOptions = Parameters<\n SocketRpcClient<WebSocket>['request']\n>[0]\nexport type WebSocketReturnType = SocketRpcClient<WebSocket>\nexport type WebSocketErrorType = WebSocketRequestError | ErrorType\n\nfunction webSocket(\n socketClient: SocketRpcClient<WebSocket>,\n { body, onError, onResponse }: WebSocketOptions,\n): WebSocketReturnType {\n socketClient.request({\n body,\n onError,\n onResponse,\n })\n return socketClient\n}\n\nexport type WebSocketAsyncOptions = Parameters<\n SocketRpcClient<WebSocket>['requestAsync']\n>[0]\nexport type WebSocketAsyncReturnType = RpcResponse\nexport type WebSocketAsyncErrorType =\n | WebSocketErrorType\n | TimeoutErrorType\n | WithTimeoutErrorType\n | ErrorType\n\nasync function webSocketAsync(\n socketClient: SocketRpcClient<WebSocket>,\n { body, timeout = 10_000 }: WebSocketAsyncOptions,\n): Promise<WebSocketAsyncReturnType> {\n return socketClient.requestAsync({\n body,\n timeout,\n })\n}\n\n/**\n * @deprecated use `getSocketClient` instead.\n *\n * ```diff\n * -import { getSocket } from 'viem/utils'\n * +import { getSocketClient } from 'viem/utils'\n *\n * -const socket = await getSocket(url)\n * +const socketClient = await getSocketClient(url)\n * +const socket = socketClient.socket\n * ```\n */\nexport async function getSocket(url: string) {\n const client = await getWebSocketRpcClient(url)\n return Object.assign(client.socket, {\n requests: client.requests,\n subscriptions: client.subscriptions,\n })\n}\n\nexport const rpc = {\n /**\n * @deprecated use `getHttpRpcClient` instead.\n *\n * ```diff\n * -import { rpc } from 'viem/utils'\n * +import { getHttpRpcClient } from 'viem/utils'\n *\n * -rpc.http(url, params)\n * +const httpClient = getHttpRpcClient(url)\n * +httpClient.request(params)\n * ```\n */\n http(url: string, params: HttpRequestParameters) {\n return getHttpRpcClient(url).request(params)\n },\n /**\n * @deprecated use `getWebSocketRpcClient` instead.\n *\n * ```diff\n * -import { rpc } from 'viem/utils'\n * +import { getWebSocketRpcClient } from 'viem/utils'\n *\n * -rpc.webSocket(url, params)\n * +const webSocketClient = getWebSocketRpcClient(url)\n * +webSocketClient.request(params)\n * ```\n */\n webSocket,\n /**\n * @deprecated use `getWebSocketRpcClient` instead.\n *\n * ```diff\n * -import { rpc } from 'viem/utils'\n * +import { getWebSocketRpcClient } from 'viem/utils'\n *\n * -const response = await rpc.webSocketAsync(url, params)\n * +const webSocketClient = getWebSocketRpcClient(url)\n * +const response = await webSocketClient.requestAsync(params)\n * ```\n */\n webSocketAsync,\n}\n/* c8 ignore end */\n", "import type { TypedData } from 'abitype'\n\nimport { stringify } from '../utils/stringify.js'\nimport { BaseError } from './base.js'\n\nexport type InvalidDomainErrorType = InvalidDomainError & {\n name: 'InvalidDomainError'\n}\nexport class InvalidDomainError extends BaseError {\n constructor({ domain }: { domain: unknown }) {\n super(`Invalid domain \"${stringify(domain)}\".`, {\n metaMessages: ['Must be a valid EIP-712 domain.'],\n })\n }\n}\n\nexport type InvalidPrimaryTypeErrorType = InvalidPrimaryTypeError & {\n name: 'InvalidPrimaryTypeError'\n}\nexport class InvalidPrimaryTypeError extends BaseError {\n constructor({\n primaryType,\n types,\n }: { primaryType: string; types: TypedData | Record<string, unknown> }) {\n super(\n `Invalid primary type \\`${primaryType}\\` must be one of \\`${JSON.stringify(Object.keys(types))}\\`.`,\n {\n docsPath: '/api/glossary/Errors#typeddatainvalidprimarytypeerror',\n metaMessages: ['Check that the primary type is a key in `types`.'],\n },\n )\n }\n}\n\nexport type InvalidStructTypeErrorType = InvalidStructTypeError & {\n name: 'InvalidStructTypeError'\n}\nexport class InvalidStructTypeError extends BaseError {\n constructor({ type }: { type: string }) {\n super(`Struct type \"${type}\" is invalid.`, {\n metaMessages: ['Struct type must not be a Solidity type.'],\n name: 'InvalidStructTypeError',\n })\n }\n}\n", "// Implementation forked and adapted from https://github.com/MetaMask/eth-sig-util/blob/main/src/sign-typed-data.ts\n\nimport type { AbiParameter, TypedData, TypedDataDomain } from 'abitype'\n\nimport type { ErrorType } from '../../errors/utils.js'\nimport type { Hex } from '../../types/misc.js'\nimport type { TypedDataDefinition } from '../../types/typedData.js'\nimport {\n type EncodeAbiParametersErrorType,\n encodeAbiParameters,\n} from '../abi/encodeAbiParameters.js'\nimport { concat } from '../data/concat.js'\nimport { type ToHexErrorType, toHex } from '../encoding/toHex.js'\nimport { type Keccak256ErrorType, keccak256 } from '../hash/keccak256.js'\nimport {\n type GetTypesForEIP712DomainErrorType,\n type ValidateTypedDataErrorType,\n getTypesForEIP712Domain,\n validateTypedData,\n} from '../typedData.js'\n\ntype MessageTypeProperty = {\n name: string\n type: string\n}\n\nexport type HashTypedDataParameters<\n typedData extends TypedData | Record<string, unknown> = TypedData,\n primaryType extends keyof typedData | 'EIP712Domain' = keyof typedData,\n> = TypedDataDefinition<typedData, primaryType>\n\nexport type HashTypedDataReturnType = Hex\n\nexport type HashTypedDataErrorType =\n | GetTypesForEIP712DomainErrorType\n | HashDomainErrorType\n | HashStructErrorType\n | ValidateTypedDataErrorType\n | ErrorType\n\nexport function hashTypedData<\n const typedData extends TypedData | Record<string, unknown>,\n primaryType extends keyof typedData | 'EIP712Domain',\n>(\n parameters: HashTypedDataParameters<typedData, primaryType>,\n): HashTypedDataReturnType {\n const {\n domain = {},\n message,\n primaryType,\n } = parameters as HashTypedDataParameters\n const types = {\n EIP712Domain: getTypesForEIP712Domain({ domain }),\n ...parameters.types,\n }\n\n // Need to do a runtime validation check on addresses, byte ranges, integer ranges, etc\n // as we can't statically check this with TypeScript.\n validateTypedData({\n domain,\n message,\n primaryType,\n types,\n })\n\n const parts: Hex[] = ['0x1901']\n if (domain)\n parts.push(\n hashDomain({\n domain,\n types: types as Record<string, MessageTypeProperty[]>,\n }),\n )\n\n if (primaryType !== 'EIP712Domain')\n parts.push(\n hashStruct({\n data: message,\n primaryType,\n types: types as Record<string, MessageTypeProperty[]>,\n }),\n )\n\n return keccak256(concat(parts))\n}\n\nexport type HashDomainErrorType = HashStructErrorType | ErrorType\n\nexport function hashDomain({\n domain,\n types,\n}: {\n domain: TypedDataDomain\n types: Record<string, MessageTypeProperty[]>\n}) {\n return hashStruct({\n data: domain,\n primaryType: 'EIP712Domain',\n types,\n })\n}\n\nexport type HashStructErrorType =\n | EncodeDataErrorType\n | Keccak256ErrorType\n | ErrorType\n\nexport function hashStruct({\n data,\n primaryType,\n types,\n}: {\n data: Record<string, unknown>\n primaryType: string\n types: Record<string, readonly MessageTypeProperty[]>\n}) {\n const encoded = encodeData({\n data,\n primaryType,\n types,\n })\n return keccak256(encoded)\n}\n\ntype EncodeDataErrorType =\n | EncodeAbiParametersErrorType\n | EncodeFieldErrorType\n | HashTypeErrorType\n | ErrorType\n\nfunction encodeData({\n data,\n primaryType,\n types,\n}: {\n data: Record<string, unknown>\n primaryType: string\n types: Record<string, readonly MessageTypeProperty[]>\n}) {\n const encodedTypes: AbiParameter[] = [{ type: 'bytes32' }]\n const encodedValues: unknown[] = [hashType({ primaryType, types })]\n\n for (const field of types[primaryType]) {\n const [type, value] = encodeField({\n types,\n name: field.name,\n type: field.type,\n value: data[field.name],\n })\n encodedTypes.push(type)\n encodedValues.push(value)\n }\n\n return encodeAbiParameters(encodedTypes, encodedValues)\n}\n\ntype HashTypeErrorType =\n | ToHexErrorType\n | EncodeTypeErrorType\n | Keccak256ErrorType\n | ErrorType\n\nfunction hashType({\n primaryType,\n types,\n}: {\n primaryType: string\n types: Record<string, readonly MessageTypeProperty[]>\n}) {\n const encodedHashType = toHex(encodeType({ primaryType, types }))\n return keccak256(encodedHashType)\n}\n\ntype EncodeTypeErrorType = FindTypeDependenciesErrorType\n\nexport function encodeType({\n primaryType,\n types,\n}: {\n primaryType: string\n types: Record<string, readonly MessageTypeProperty[]>\n}) {\n let result = ''\n const unsortedDeps = findTypeDependencies({ primaryType, types })\n unsortedDeps.delete(primaryType)\n\n const deps = [primaryType, ...Array.from(unsortedDeps).sort()]\n for (const type of deps) {\n result += `${type}(${types[type]\n .map(({ name, type: t }) => `${t} ${name}`)\n .join(',')})`\n }\n\n return result\n}\n\ntype FindTypeDependenciesErrorType = ErrorType\n\nfunction findTypeDependencies(\n {\n primaryType: primaryType_,\n types,\n }: {\n primaryType: string\n types: Record<string, readonly MessageTypeProperty[]>\n },\n results: Set<string> = new Set(),\n): Set<string> {\n const match = primaryType_.match(/^\\w*/u)\n const primaryType = match?.[0]!\n if (results.has(primaryType) || types[primaryType] === undefined) {\n return results\n }\n\n results.add(primaryType)\n\n for (const field of types[primaryType]) {\n findTypeDependencies({ primaryType: field.type, types }, results)\n }\n return results\n}\n\ntype EncodeFieldErrorType =\n | Keccak256ErrorType\n | EncodeAbiParametersErrorType\n | ToHexErrorType\n | ErrorType\n\nfunction encodeField({\n types,\n name,\n type,\n value,\n}: {\n types: Record<string, readonly MessageTypeProperty[]>\n name: string\n type: string\n value: any\n}): [type: AbiParameter, value: any] {\n if (types[type] !== undefined) {\n return [\n { type: 'bytes32' },\n keccak256(encodeData({ data: value, primaryType: type, types })),\n ]\n }\n\n if (type === 'bytes') {\n const prepend = value.length % 2 ? '0' : ''\n value = `0x${prepend + value.slice(2)}`\n return [{ type: 'bytes32' }, keccak256(value)]\n }\n\n if (type === 'string') return [{ type: 'bytes32' }, keccak256(toHex(value))]\n\n if (type.lastIndexOf(']') === type.length - 1) {\n const parsedType = type.slice(0, type.lastIndexOf('['))\n const typeValuePairs = (value as [AbiParameter, any][]).map((item) =>\n encodeField({\n name,\n type: parsedType,\n types,\n value: item,\n }),\n )\n return [\n { type: 'bytes32' },\n keccak256(\n encodeAbiParameters(\n typeValuePairs.map(([t]) => t),\n typeValuePairs.map(([, v]) => v),\n ),\n ),\n ]\n }\n\n return [{ type }, value]\n}\n", "import type { TypedData, TypedDataDomain, TypedDataParameter } from 'abitype'\n\nimport { BytesSizeMismatchError } from '../errors/abi.js'\nimport { InvalidAddressError } from '../errors/address.js'\nimport {\n InvalidDomainError,\n InvalidPrimaryTypeError,\n InvalidStructTypeError,\n} from '../errors/typedData.js'\nimport type { ErrorType } from '../errors/utils.js'\nimport type { Hex } from '../types/misc.js'\nimport type { TypedDataDefinition } from '../types/typedData.js'\nimport { type IsAddressErrorType, isAddress } from './address/isAddress.js'\nimport { type SizeErrorType, size } from './data/size.js'\nimport { type NumberToHexErrorType, numberToHex } from './encoding/toHex.js'\nimport { bytesRegex, integerRegex } from './regex.js'\nimport {\n type HashDomainErrorType,\n hashDomain,\n} from './signature/hashTypedData.js'\nimport { stringify } from './stringify.js'\n\nexport type SerializeTypedDataErrorType =\n | HashDomainErrorType\n | IsAddressErrorType\n | NumberToHexErrorType\n | SizeErrorType\n | ErrorType\n\nexport function serializeTypedData<\n const typedData extends TypedData | Record<string, unknown>,\n primaryType extends keyof typedData | 'EIP712Domain',\n>(parameters: TypedDataDefinition<typedData, primaryType>) {\n const {\n domain: domain_,\n message: message_,\n primaryType,\n types,\n } = parameters as unknown as TypedDataDefinition\n\n const normalizeData = (\n struct: readonly TypedDataParameter[],\n data_: Record<string, unknown>,\n ) => {\n const data = { ...data_ }\n for (const param of struct) {\n const { name, type } = param\n if (type === 'address') data[name] = (data[name] as string).toLowerCase()\n }\n return data\n }\n\n const domain = (() => {\n if (!types.EIP712Domain) return {}\n if (!domain_) return {}\n return normalizeData(types.EIP712Domain, domain_)\n })()\n\n const message = (() => {\n if (primaryType === 'EIP712Domain') return undefined\n return normalizeData(types[primaryType], message_)\n })()\n\n return stringify({ domain, message, primaryType, types })\n}\n\nexport type ValidateTypedDataErrorType =\n | HashDomainErrorType\n | IsAddressErrorType\n | NumberToHexErrorType\n | SizeErrorType\n | ErrorType\n\nexport function validateTypedData<\n const typedData extends TypedData | Record<string, unknown>,\n primaryType extends keyof typedData | 'EIP712Domain',\n>(parameters: TypedDataDefinition<typedData, primaryType>) {\n const { domain, message, primaryType, types } =\n parameters as unknown as TypedDataDefinition\n\n const validateData = (\n struct: readonly TypedDataParameter[],\n data: Record<string, unknown>,\n ) => {\n for (const param of struct) {\n const { name, type } = param\n const value = data[name]\n\n const integerMatch = type.match(integerRegex)\n if (\n integerMatch &&\n (typeof value === 'number' || typeof value === 'bigint')\n ) {\n const [_type, base, size_] = integerMatch\n // If number cannot be cast to a sized hex value, it is out of range\n // and will throw.\n numberToHex(value, {\n signed: base === 'int',\n size: Number.parseInt(size_) / 8,\n })\n }\n\n if (type === 'address' && typeof value === 'string' && !isAddress(value))\n throw new InvalidAddressError({ address: value })\n\n const bytesMatch = type.match(bytesRegex)\n if (bytesMatch) {\n const [_type, size_] = bytesMatch\n if (size_ && size(value as Hex) !== Number.parseInt(size_))\n throw new BytesSizeMismatchError({\n expectedSize: Number.parseInt(size_),\n givenSize: size(value as Hex),\n })\n }\n\n const struct = types[type]\n if (struct) {\n validateReference(type)\n validateData(struct, value as Record<string, unknown>)\n }\n }\n }\n\n // Validate domain types.\n if (types.EIP712Domain && domain) {\n if (typeof domain !== 'object') throw new InvalidDomainError({ domain })\n validateData(types.EIP712Domain, domain)\n }\n\n // Validate message types.\n if (primaryType !== 'EIP712Domain') {\n if (types[primaryType]) validateData(types[primaryType], message)\n else throw new InvalidPrimaryTypeError({ primaryType, types })\n }\n}\n\nexport type GetTypesForEIP712DomainErrorType = ErrorType\n\nexport function getTypesForEIP712Domain({\n domain,\n}: { domain?: TypedDataDomain | undefined }): TypedDataParameter[] {\n return [\n typeof domain?.name === 'string' && { name: 'name', type: 'string' },\n domain?.version && { name: 'version', type: 'string' },\n (typeof domain?.chainId === 'number' ||\n typeof domain?.chainId === 'bigint') && {\n name: 'chainId',\n type: 'uint256',\n },\n domain?.verifyingContract && {\n name: 'verifyingContract',\n type: 'address',\n },\n domain?.salt && { name: 'salt', type: 'bytes32' },\n ].filter(Boolean) as TypedDataParameter[]\n}\n\nexport type DomainSeparatorErrorType =\n | GetTypesForEIP712DomainErrorType\n | HashDomainErrorType\n | ErrorType\n\nexport function domainSeparator({ domain }: { domain: TypedDataDomain }): Hex {\n return hashDomain({\n domain,\n types: {\n EIP712Domain: getTypesForEIP712Domain({ domain }),\n },\n })\n}\n\n/** @internal */\nfunction validateReference(type: string) {\n // Struct type must not be a Solidity type.\n if (\n type === 'address' ||\n type === 'bool' ||\n type === 'string' ||\n type.startsWith('bytes') ||\n type.startsWith('uint') ||\n type.startsWith('int')\n )\n throw new InvalidStructTypeError({ type })\n}\n", "export const presignMessagePrefix = '\\x19Ethereum Signed Message:\\n'\n", "import { presignMessagePrefix } from '../../constants/strings.js'\nimport type { ErrorType } from '../../errors/utils.js'\nimport type { Hex, SignableMessage } from '../../types/misc.js'\nimport { type ConcatErrorType, concat } from '../data/concat.js'\nimport { size } from '../data/size.js'\nimport {\n type BytesToHexErrorType,\n type StringToHexErrorType,\n bytesToHex,\n stringToHex,\n} from '../encoding/toHex.js'\n\nexport type ToPrefixedMessageErrorType =\n | ConcatErrorType\n | StringToHexErrorType\n | BytesToHexErrorType\n | ErrorType\n\nexport function toPrefixedMessage(message_: SignableMessage): Hex {\n const message = (() => {\n if (typeof message_ === 'string') return stringToHex(message_)\n if (typeof message_.raw === 'string') return message_.raw\n return bytesToHex(message_.raw)\n })()\n const prefix = stringToHex(`${presignMessagePrefix}${size(message)}`)\n return concat([prefix, message])\n}\n", "import type { ErrorType } from '../../errors/utils.js'\nimport type { ByteArray, Hex, SignableMessage } from '../../types/misc.js'\nimport { type Keccak256ErrorType, keccak256 } from '../hash/keccak256.js'\nimport { toPrefixedMessage } from './toPrefixedMessage.js'\n\ntype To = 'hex' | 'bytes'\n\nexport type HashMessageReturnType<to extends To> =\n | (to extends 'bytes' ? ByteArray : never)\n | (to extends 'hex' ? Hex : never)\n\nexport type HashMessageErrorType = Keccak256ErrorType | ErrorType\n\nexport function hashMessage<to extends To = 'hex'>(\n message: SignableMessage,\n to_?: to | undefined,\n): HashMessageReturnType<to> {\n return keccak256(toPrefixedMessage(message), to_)\n}\n", "export const erc6492MagicBytes =\n '0x6492649264926492649264926492649264926492649264926492649264926492' as const\n\nexport const zeroHash =\n '0x0000000000000000000000000000000000000000000000000000000000000000' as const\n", "import { erc6492MagicBytes } from '../../constants/bytes.js'\nimport type { ErrorType } from '../../errors/utils.js'\nimport type { Hex } from '../../types/misc.js'\nimport { type SliceHexErrorType, sliceHex } from '../data/slice.js'\n\nexport type IsErc6492SignatureParameters = Hex\nexport type IsErc6492SignatureReturnType = boolean\nexport type IsErc6492SignatureErrorType = SliceHexErrorType | ErrorType\n\n/** Whether or not the signature is an ERC-6492 formatted signature. */\nexport function isErc6492Signature(\n signature: IsErc6492SignatureParameters,\n): IsErc6492SignatureReturnType {\n return sliceHex(signature, -32) === erc6492MagicBytes\n}\n", "import type { Address } from 'abitype'\nimport { erc6492MagicBytes } from '../../constants/bytes.js'\nimport type { ErrorType } from '../../errors/utils.js'\nimport type { ByteArray, Hex } from '../../types/misc.js'\nimport { encodeAbiParameters } from '../abi/encodeAbiParameters.js'\nimport { concatHex } from '../data/concat.js'\nimport { hexToBytes } from '../encoding/toBytes.js'\n\ntype To = 'bytes' | 'hex'\n\nexport type SerializeErc6492SignatureParameters<to extends To = 'hex'> = {\n /** The ERC-4337 Account Factory address to use for counterfactual verification. */\n address: Address\n /** Calldata to pass to deploy account (if not deployed) for counterfactual verification. */\n data: Hex\n /** The original signature. */\n signature: Hex\n to?: to | To | undefined\n}\n\nexport type SerializeErc6492SignatureReturnType<to extends To = 'hex'> =\n | (to extends 'hex' ? Hex : never)\n | (to extends 'bytes' ? ByteArray : never)\n\nexport type SerializeErc6492SignatureErrorType = ErrorType\n\n/**\n * @description Serializes a ERC-6492 flavoured signature into hex format.\n *\n * @param signature ERC-6492 signature in object format.\n * @returns ERC-6492 signature in hex format.\n *\n * @example\n * serializeSignature({ address: '0x...', data: '0x...', signature: '0x...' })\n * // '0x000000000000000000000000cafebabecafebabecafebabecafebabecafebabe000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000004deadbeef000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000041a461f509887bd19e312c0c58467ce8ff8e300d3c1a90b608a760c5b80318eaf15fe57c96f9175d6cd4daad4663763baa7e78836e067d0163e9a2ccf2ff753f5b1b000000000000000000000000000000000000000000000000000000000000006492649264926492649264926492649264926492649264926492649264926492'\n */\nexport function serializeErc6492Signature<to extends To = 'hex'>(\n parameters: SerializeErc6492SignatureParameters<to>,\n): SerializeErc6492SignatureReturnType<to> {\n const { address, data, signature, to = 'hex' } = parameters\n const signature_ = concatHex([\n encodeAbiParameters(\n [{ type: 'address' }, { type: 'bytes' }, { type: 'bytes' }],\n [address, data, signature],\n ),\n erc6492MagicBytes,\n ])\n\n if (to === 'hex') return signature_ as SerializeErc6492SignatureReturnType<to>\n return hexToBytes(signature_) as SerializeErc6492SignatureReturnType<to>\n}\n", "import type { Address } from 'abitype'\n\nimport { getTransactionCount } from '../actions/public/getTransactionCount.js'\nimport type { Client } from '../clients/createClient.js'\nimport type { MaybePromise } from '../types/utils.js'\nimport { LruMap } from './lru.js'\n\nexport type CreateNonceManagerParameters = {\n source: NonceManagerSource\n}\n\ntype FunctionParameters = {\n address: Address\n chainId: number\n}\n\nexport type NonceManager = {\n /** Get and increment a nonce. */\n consume: (\n parameters: FunctionParameters & { client: Client },\n ) => Promise<number>\n /** Increment a nonce. */\n increment: (chainId: FunctionParameters) => void\n /** Get a nonce. */\n get: (chainId: FunctionParameters & { client: Client }) => Promise<number>\n /** Reset a nonce. */\n reset: (chainId: FunctionParameters) => void\n}\n\n/**\n * Creates a nonce manager for auto-incrementing transaction nonces.\n *\n * - Docs: https://viem.sh/docs/accounts/createNonceManager\n *\n * @example\n * ```ts\n * const nonceManager = createNonceManager({\n * source: jsonRpc(),\n * })\n * ```\n */\nexport function createNonceManager(\n parameters: CreateNonceManagerParameters,\n): NonceManager {\n const { source } = parameters\n\n const deltaMap = new Map()\n const nonceMap = new LruMap<number>(8192)\n const promiseMap = new Map<string, Promise<number>>()\n\n const getKey = ({ address, chainId }: FunctionParameters) =>\n `${address}.${chainId}`\n\n return {\n async consume({ address, chainId, client }) {\n const key = getKey({ address, chainId })\n const promise = this.get({ address, chainId, client })\n\n this.increment({ address, chainId })\n const nonce = await promise\n\n await source.set({ address, chainId }, nonce)\n nonceMap.set(key, nonce)\n\n return nonce\n },\n async increment({ address, chainId }) {\n const key = getKey({ address, chainId })\n const delta = deltaMap.get(key) ?? 0\n deltaMap.set(key, delta + 1)\n },\n async get({ address, chainId, client }) {\n const key = getKey({ address, chainId })\n\n let promise = promiseMap.get(key)\n if (!promise) {\n promise = (async () => {\n try {\n const nonce = await source.get({ address, chainId, client })\n const previousNonce = nonceMap.get(key) ?? 0\n if (previousNonce > 0 && nonce <= previousNonce)\n return previousNonce + 1\n nonceMap.delete(key)\n return nonce\n } finally {\n this.reset({ address, chainId })\n }\n })()\n promiseMap.set(key, promise)\n }\n\n const delta = deltaMap.get(key) ?? 0\n return delta + (await promise)\n },\n reset({ address, chainId }) {\n const key = getKey({ address, chainId })\n deltaMap.delete(key)\n promiseMap.delete(key)\n },\n }\n}\n\n////////////////////////////////////////////////////////////////////////////////////////////\n// Sources\n\nexport type NonceManagerSource = {\n /** Get a nonce. */\n get(parameters: FunctionParameters & { client: Client }): MaybePromise<number>\n /** Set a nonce. */\n set(parameters: FunctionParameters, nonce: number): MaybePromise<void>\n}\n\n/** JSON-RPC source for a nonce manager. */\nexport function jsonRpc(): NonceManagerSource {\n return {\n async get(parameters) {\n const { address, client } = parameters\n return getTransactionCount(client, {\n address,\n blockTag: 'pending',\n })\n },\n set() {},\n }\n}\n\n////////////////////////////////////////////////////////////////////////////////////////////\n// Default\n\n/** Default Nonce Manager with a JSON-RPC source. */\nexport const nonceManager = /*#__PURE__*/ createNonceManager({\n source: jsonRpc(),\n})\n", "import type { AbiStateMutability, Address, Narrow } from 'abitype'\nimport * as AbiConstructor from 'ox/AbiConstructor'\nimport * as AbiFunction from 'ox/AbiFunction'\n\nimport { parseAccount } from '../../accounts/utils/parseAccount.js'\nimport type { Client } from '../../clients/createClient.js'\nimport type { Transport } from '../../clients/transports/createTransport.js'\nimport { ethAddress, zeroAddress } from '../../constants/address.js'\nimport { deploylessCallViaBytecodeBytecode } from '../../constants/contracts.js'\nimport { BaseError } from '../../errors/base.js'\nimport type { ErrorType } from '../../errors/utils.js'\nimport type { Account } from '../../types/account.js'\nimport type { Block } from '../../types/block.js'\nimport type { Call, Calls } from '../../types/calls.js'\nimport type { Chain } from '../../types/chain.js'\nimport type { Log } from '../../types/log.js'\nimport type { Hex } from '../../types/misc.js'\nimport type { MulticallResults } from '../../types/multicall.js'\nimport type { StateOverride } from '../../types/stateOverride.js'\nimport type { Mutable } from '../../types/utils.js'\nimport {\n type EncodeFunctionDataErrorType,\n encodeFunctionData,\n} from '../../utils/abi/encodeFunctionData.js'\nimport { hexToBigInt } from '../../utils/index.js'\nimport {\n type CreateAccessListErrorType,\n createAccessList,\n} from './createAccessList.js'\nimport {\n type SimulateBlocksErrorType,\n type SimulateBlocksParameters,\n simulateBlocks,\n} from './simulateBlocks.js'\n\nconst getBalanceCode =\n '0x6080604052348015600e575f80fd5b5061016d8061001c5f395ff3fe608060405234801561000f575f80fd5b5060043610610029575f3560e01c8063f8b2cb4f1461002d575b5f80fd5b610047600480360381019061004291906100db565b61005d565b604051610054919061011e565b60405180910390f35b5f8173ffffffffffffffffffffffffffffffffffffffff16319050919050565b5f80fd5b5f73ffffffffffffffffffffffffffffffffffffffff82169050919050565b5f6100aa82610081565b9050919050565b6100ba816100a0565b81146100c4575f80fd5b50565b5f813590506100d5816100b1565b92915050565b5f602082840312156100f0576100ef61007d565b5b5f6100fd848285016100c7565b91505092915050565b5f819050919050565b61011881610106565b82525050565b5f6020820190506101315f83018461010f565b9291505056fea26469706673582212203b9fe929fe995c7cf9887f0bdba8a36dd78e8b73f149b17d2d9ad7cd09d2dc6264736f6c634300081a0033'\n\nexport type SimulateCallsParameters<\n calls extends readonly unknown[] = readonly unknown[],\n account extends Account | Address | undefined = Account | Address | undefined,\n> = Omit<SimulateBlocksParameters, 'blocks' | 'returnFullTransactions'> & {\n /** Account attached to the calls (msg.sender). */\n account?: account | undefined\n /** Calls to simulate. */\n calls: Calls<Narrow<calls>>\n /** State overrides. */\n stateOverrides?: StateOverride | undefined\n /** Whether to trace asset changes. */\n traceAssetChanges?: boolean | undefined\n}\n\nexport type SimulateCallsReturnType<\n calls extends readonly unknown[] = readonly unknown[],\n> = {\n /** Asset changes. */\n assetChanges: readonly {\n token: {\n address: Address\n decimals?: number | undefined\n symbol?: string | undefined\n }\n value: { pre: bigint; post: bigint; diff: bigint }\n }[]\n /** Block results. */\n block: Block\n /** Call results. */\n results: MulticallResults<\n Narrow<calls>,\n true,\n {\n extraProperties: {\n data: Hex\n gasUsed: bigint\n logs?: Log[] | undefined\n }\n error: Error\n mutability: AbiStateMutability\n }\n >\n}\n\nexport type SimulateCallsErrorType =\n | AbiFunction.encodeData.ErrorType\n | AbiFunction.from.ErrorType\n | CreateAccessListErrorType\n | EncodeFunctionDataErrorType\n | SimulateBlocksErrorType\n | ErrorType\n\n/**\n * Simulates execution of a batch of calls.\n *\n * @param client - Client to use\n * @param parameters - {@link SimulateCallsParameters}\n * @returns Results. {@link SimulateCallsReturnType}\n *\n * @example\n * ```ts\n * import { createPublicClient, http, parseEther } from 'viem'\n * import { mainnet } from 'viem/chains'\n * import { simulateCalls } from 'viem/actions'\n *\n * const client = createPublicClient({\n * chain: mainnet,\n * transport: http(),\n * })\n *\n * const result = await simulateCalls(client, {\n * account: '0x5a0b54d5dc17e482fe8b0bdca5320161b95fb929',\n * calls: [{\n * {\n * data: '0xdeadbeef',\n * to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8',\n * },\n * {\n * to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8',\n * value: parseEther('1'),\n * },\n * ]\n * })\n * ```\n */\nexport async function simulateCalls<\n const calls extends readonly unknown[],\n chain extends Chain | undefined,\n account extends Account | Address | undefined = undefined,\n>(\n client: Client<Transport, chain>,\n parameters: SimulateCallsParameters<calls, account>,\n): Promise<SimulateCallsReturnType<calls>> {\n const {\n blockNumber,\n blockTag,\n calls,\n stateOverrides,\n traceAssetChanges,\n traceTransfers,\n validation,\n } = parameters\n\n const account = parameters.account\n ? parseAccount(parameters.account)\n : undefined\n\n if (traceAssetChanges && !account)\n throw new BaseError(\n '`account` is required when `traceAssetChanges` is true',\n )\n\n // Derive bytecode to extract ETH balance via a contract call.\n const getBalanceData = account\n ? AbiConstructor.encode(AbiConstructor.from('constructor(bytes, bytes)'), {\n bytecode: deploylessCallViaBytecodeBytecode,\n args: [\n getBalanceCode,\n AbiFunction.encodeData(\n AbiFunction.from('function getBalance(address)'),\n [account.address],\n ),\n ],\n })\n : undefined\n\n // Fetch ERC20/721 addresses that were \"touched\" from the calls.\n const assetAddresses = traceAssetChanges\n ? await Promise.all(\n parameters.calls.map(async (call: any) => {\n if (!call.data && !call.abi) return\n const { accessList } = await createAccessList(client, {\n account: account!.address,\n ...call,\n data: call.abi ? encodeFunctionData(call) : call.data,\n })\n return accessList.map(({ address, storageKeys }) =>\n storageKeys.length > 0 ? address : null,\n )\n }),\n ).then((x) => x.flat().filter(Boolean))\n : []\n\n const resultsStateOverrides = stateOverrides?.map((override) => {\n if (override.address === account?.address)\n return {\n ...override,\n nonce: 0,\n }\n return override\n })\n\n const blocks = await simulateBlocks(client, {\n blockNumber,\n blockTag: blockTag as undefined,\n blocks: [\n ...(traceAssetChanges\n ? [\n // ETH pre balances\n {\n calls: [{ data: getBalanceData }],\n stateOverrides,\n },\n\n // Asset pre balances\n {\n calls: assetAddresses.map((address, i) => ({\n abi: [\n AbiFunction.from(\n 'function balanceOf(address) returns (uint256)',\n ),\n ],\n functionName: 'balanceOf',\n args: [account!.address],\n to: address,\n from: zeroAddress,\n nonce: i,\n })),\n stateOverrides: [\n {\n address: zeroAddress,\n nonce: 0,\n },\n ],\n },\n ]\n : []),\n\n {\n calls: [...calls, {}].map((call, index) => ({\n ...(call as Call),\n from: account?.address,\n nonce: index,\n })) as any,\n stateOverrides: resultsStateOverrides,\n },\n\n ...(traceAssetChanges\n ? [\n // ETH post balances\n {\n calls: [{ data: getBalanceData }],\n },\n\n // Asset post balances\n {\n calls: assetAddresses.map((address, i) => ({\n abi: [\n AbiFunction.from(\n 'function balanceOf(address) returns (uint256)',\n ),\n ],\n functionName: 'balanceOf',\n args: [account!.address],\n to: address,\n from: zeroAddress,\n nonce: i,\n })),\n stateOverrides: [\n {\n address: zeroAddress,\n nonce: 0,\n },\n ],\n },\n\n // Decimals\n {\n calls: assetAddresses.map((address, i) => ({\n to: address,\n abi: [\n AbiFunction.from('function decimals() returns (uint256)'),\n ],\n functionName: 'decimals',\n from: zeroAddress,\n nonce: i,\n })),\n stateOverrides: [\n {\n address: zeroAddress,\n nonce: 0,\n },\n ],\n },\n\n // Token URI\n {\n calls: assetAddresses.map((address, i) => ({\n to: address,\n abi: [\n AbiFunction.from(\n 'function tokenURI(uint256) returns (string)',\n ),\n ],\n functionName: 'tokenURI',\n args: [0n],\n from: zeroAddress,\n nonce: i,\n })),\n stateOverrides: [\n {\n address: zeroAddress,\n nonce: 0,\n },\n ],\n },\n\n // Symbols\n {\n calls: assetAddresses.map((address, i) => ({\n to: address,\n abi: [AbiFunction.from('function symbol() returns (string)')],\n functionName: 'symbol',\n from: zeroAddress,\n nonce: i,\n })),\n stateOverrides: [\n {\n address: zeroAddress,\n nonce: 0,\n },\n ],\n },\n ]\n : []),\n ],\n traceTransfers,\n validation,\n })\n\n const block_results = traceAssetChanges ? blocks[2] : blocks[0]\n const [\n block_ethPre,\n block_assetsPre,\n ,\n block_ethPost,\n block_assetsPost,\n block_decimals,\n block_tokenURI,\n block_symbols,\n ] = traceAssetChanges ? blocks : []\n\n // Extract call results from the simulation.\n const { calls: block_calls, ...block } = block_results\n const results = block_calls.slice(0, -1) ?? []\n\n // Extract pre-execution ETH and asset balances.\n const ethPre = block_ethPre?.calls ?? []\n const assetsPre = block_assetsPre?.calls ?? []\n const balancesPre = [...ethPre, ...assetsPre].map((call) =>\n call.status === 'success' ? hexToBigInt(call.data) : null,\n )\n\n // Extract post-execution ETH and asset balances.\n const ethPost = block_ethPost?.calls ?? []\n const assetsPost = block_assetsPost?.calls ?? []\n const balancesPost = [...ethPost, ...assetsPost].map((call) =>\n call.status === 'success' ? hexToBigInt(call.data) : null,\n )\n\n // Extract asset symbols & decimals.\n const decimals = (block_decimals?.calls ?? []).map((x) =>\n x.status === 'success' ? x.result : null,\n ) as (number | null)[]\n const symbols = (block_symbols?.calls ?? []).map((x) =>\n x.status === 'success' ? x.result : null,\n ) as (string | null)[]\n const tokenURI = (block_tokenURI?.calls ?? []).map((x) =>\n x.status === 'success' ? x.result : null,\n ) as (string | null)[]\n\n const changes: Mutable<SimulateCallsReturnType<calls>['assetChanges']> = []\n for (const [i, balancePost] of balancesPost.entries()) {\n const balancePre = balancesPre[i]\n\n if (typeof balancePost !== 'bigint') continue\n if (typeof balancePre !== 'bigint') continue\n\n const decimals_ = decimals[i - 1]\n const symbol_ = symbols[i - 1]\n const tokenURI_ = tokenURI[i - 1]\n\n const token = (() => {\n if (i === 0)\n return {\n address: ethAddress,\n decimals: 18,\n symbol: 'ETH',\n }\n\n return {\n address: assetAddresses[i - 1]! as Address,\n decimals: tokenURI_ || decimals_ ? Number(decimals_ ?? 1) : undefined,\n symbol: symbol_ ?? undefined,\n }\n })()\n\n if (changes.some((change) => change.token.address === token.address))\n continue\n\n changes.push({\n token,\n value: {\n pre: balancePre,\n post: balancePost,\n diff: balancePost - balancePre,\n },\n })\n }\n\n return {\n assetChanges: changes,\n block,\n results,\n } as unknown as SimulateCallsReturnType<calls>\n}\n", "import type { ErrorType } from '../errors/utils.js'\nimport type { MaybePromise } from '../types/utils.js'\n\ntype Callback = ((...args: any[]) => any) | undefined\ntype Callbacks = Record<string, Callback>\n\nexport type ObserveErrorType = ErrorType\n\n/** @internal */\nexport const listenersCache = /*#__PURE__*/ new Map<\n string,\n { id: number; fns: Callbacks }[]\n>()\n/** @internal */\nexport const cleanupCache = /*#__PURE__*/ new Map<string, () => void>()\n\ntype EmitFunction<callbacks extends Callbacks> = (\n emit: callbacks,\n) => MaybePromise<void | (() => void)>\n\nlet callbackCount = 0\n\n/**\n * @description Sets up an observer for a given function. If another function\n * is set up under the same observer id, the function will only be called once\n * for both instances of the observer.\n */\nexport function observe<callbacks extends Callbacks>(\n observerId: string,\n callbacks: callbacks,\n fn: EmitFunction<callbacks>,\n) {\n const callbackId = ++callbackCount\n\n const getListeners = () => listenersCache.get(observerId) || []\n\n const unsubscribe = () => {\n const listeners = getListeners()\n listenersCache.set(\n observerId,\n listeners.filter((cb: any) => cb.id !== callbackId),\n )\n }\n\n const unwatch = () => {\n const listeners = getListeners()\n if (!listeners.some((cb: any) => cb.id === callbackId)) return\n const cleanup = cleanupCache.get(observerId)\n if (listeners.length === 1 && cleanup) cleanup()\n unsubscribe()\n }\n\n const listeners = getListeners()\n listenersCache.set(observerId, [\n ...listeners,\n { id: callbackId, fns: callbacks },\n ])\n\n if (listeners && listeners.length > 0) return unwatch\n\n const emit: callbacks = {} as callbacks\n for (const key in callbacks) {\n emit[key] = ((\n ...args: Parameters<NonNullable<callbacks[keyof callbacks]>>\n ) => {\n const listeners = getListeners()\n if (listeners.length === 0) return\n for (const listener of listeners) listener.fns[key]?.(...args)\n }) as callbacks[Extract<keyof callbacks, string>]\n }\n\n const cleanup = fn(emit)\n if (typeof cleanup === 'function') cleanupCache.set(observerId, cleanup)\n\n return unwatch\n}\n", "import type { ErrorType } from '../errors/utils.js'\nimport { wait } from './wait.js'\n\ntype PollOptions<data> = {\n // Whether or not to emit when the polling starts.\n emitOnBegin?: boolean | undefined\n // The initial wait time (in ms) before polling.\n initialWaitTime?: ((data: data | void) => Promise<number>) | undefined\n // The interval (in ms).\n interval: number\n}\n\nexport type PollErrorType = ErrorType\n\n/**\n * @description Polls a function at a specified interval.\n */\nexport function poll<data>(\n fn: ({ unpoll }: { unpoll: () => void }) => Promise<data | void>,\n { emitOnBegin, initialWaitTime, interval }: PollOptions<data>,\n) {\n let active = true\n\n const unwatch = () => (active = false)\n\n const watch = async () => {\n let data: data | void = undefined\n if (emitOnBegin) data = await fn({ unpoll: unwatch })\n\n const initialWait = (await initialWaitTime?.(data)) ?? interval\n await wait(initialWait)\n\n const poll = async () => {\n if (!active) return\n await fn({ unpoll: unwatch })\n await wait(interval)\n poll()\n }\n\n poll()\n }\n watch()\n\n return unwatch\n}\n", "import type { Client } from '../../clients/createClient.js'\nimport type { Transport } from '../../clients/transports/createTransport.js'\nimport type { ErrorType } from '../../errors/utils.js'\nimport type { BlockTag } from '../../types/block.js'\nimport type { Chain } from '../../types/chain.js'\nimport type { HasTransportType } from '../../types/transport.js'\nimport { getAction } from '../../utils/getAction.js'\nimport { observe } from '../../utils/observe.js'\nimport { type PollErrorType, poll } from '../../utils/poll.js'\nimport { type StringifyErrorType, stringify } from '../../utils/stringify.js'\n\nimport { type GetBlockReturnType, getBlock } from './getBlock.js'\n\nexport type OnBlockParameter<\n chain extends Chain | undefined = Chain,\n includeTransactions extends boolean = false,\n blockTag extends BlockTag = 'latest',\n> = GetBlockReturnType<chain, includeTransactions, blockTag>\n\nexport type OnBlock<\n chain extends Chain | undefined = Chain,\n includeTransactions extends boolean = false,\n blockTag extends BlockTag = 'latest',\n> = (\n block: OnBlockParameter<chain, includeTransactions, blockTag>,\n prevBlock: OnBlockParameter<chain, includeTransactions, blockTag> | undefined,\n) => void\n\nexport type WatchBlocksParameters<\n transport extends Transport = Transport,\n chain extends Chain | undefined = Chain,\n includeTransactions extends boolean = false,\n blockTag extends BlockTag = 'latest',\n> = {\n /** The callback to call when a new block is received. */\n onBlock: OnBlock<chain, includeTransactions, blockTag>\n /** The callback to call when an error occurred when trying to get for a new block. */\n onError?: ((error: Error) => void) | undefined\n} & (\n | (HasTransportType<transport, 'webSocket'> extends true\n ? {\n blockTag?: undefined\n emitMissed?: undefined\n emitOnBegin?: undefined\n includeTransactions?: undefined\n /** Whether or not the WebSocket Transport should poll the JSON-RPC, rather than using `eth_subscribe`. */\n poll?: false | undefined\n pollingInterval?: undefined\n }\n : never)\n | {\n /** The block tag. Defaults to \"latest\". */\n blockTag?: blockTag | BlockTag | undefined\n /** Whether or not to emit the missed blocks to the callback. */\n emitMissed?: boolean | undefined\n /** Whether or not to emit the block to the callback when the subscription opens. */\n emitOnBegin?: boolean | undefined\n /** Whether or not to include transaction data in the response. */\n includeTransactions?: includeTransactions | undefined\n poll?: true | undefined\n /** Polling frequency (in ms). Defaults to the client's pollingInterval config. */\n pollingInterval?: number | undefined\n }\n)\n\nexport type WatchBlocksReturnType = () => void\n\nexport type WatchBlocksErrorType =\n | StringifyErrorType\n | PollErrorType\n | ErrorType\n\n/**\n * Watches and returns information for incoming blocks.\n *\n * - Docs: https://viem.sh/docs/actions/public/watchBlocks\n * - Examples: https://stackblitz.com/github/wevm/viem/tree/main/examples/blocks_watching-blocks\n * - JSON-RPC Methods:\n * - When `poll: true`, calls [`eth_getBlockByNumber`](https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_getBlockByNumber) on a polling interval.\n * - When `poll: false` & WebSocket Transport, uses a WebSocket subscription via [`eth_subscribe`](https://docs.alchemy.com/reference/eth-subscribe-polygon) and the `\"newHeads\"` event.\n *\n * @param client - Client to use\n * @param parameters - {@link WatchBlocksParameters}\n * @returns A function that can be invoked to stop watching for new block numbers. {@link WatchBlocksReturnType}\n *\n * @example\n * import { createPublicClient, watchBlocks, http } from 'viem'\n * import { mainnet } from 'viem/chains'\n *\n * const client = createPublicClient({\n * chain: mainnet,\n * transport: http(),\n * })\n * const unwatch = watchBlocks(client, {\n * onBlock: (block) => console.log(block),\n * })\n */\nexport function watchBlocks<\n transport extends Transport,\n chain extends Chain | undefined,\n includeTransactions extends boolean = false,\n blockTag extends BlockTag = 'latest',\n>(\n client: Client<transport, chain>,\n {\n blockTag = 'latest',\n emitMissed = false,\n emitOnBegin = false,\n onBlock,\n onError,\n includeTransactions: includeTransactions_,\n poll: poll_,\n pollingInterval = client.pollingInterval,\n }: WatchBlocksParameters<transport, chain, includeTransactions, blockTag>,\n): WatchBlocksReturnType {\n const enablePolling = (() => {\n if (typeof poll_ !== 'undefined') return poll_\n if (client.transport.type === 'webSocket') return false\n if (\n client.transport.type === 'fallback' &&\n client.transport.transports[0].config.type === 'webSocket'\n )\n return false\n return true\n })()\n const includeTransactions = includeTransactions_ ?? false\n\n let prevBlock:\n | GetBlockReturnType<chain, false | includeTransactions, 'latest'>\n | undefined\n\n const pollBlocks = () => {\n const observerId = stringify([\n 'watchBlocks',\n client.uid,\n blockTag,\n emitMissed,\n emitOnBegin,\n includeTransactions,\n pollingInterval,\n ])\n\n return observe(observerId, { onBlock, onError }, (emit) =>\n poll(\n async () => {\n try {\n const block = await getAction(\n client,\n getBlock,\n 'getBlock',\n )({\n blockTag,\n includeTransactions,\n })\n if (block.number && prevBlock?.number) {\n // If the current block number is the same as the previous,\n // we can skip.\n if (block.number === prevBlock.number) return\n\n // If we have missed out on some previous blocks, and the\n // `emitMissed` flag is truthy, let's emit those blocks.\n if (block.number - prevBlock.number > 1 && emitMissed) {\n for (let i = prevBlock?.number + 1n; i < block.number; i++) {\n const block = (await getAction(\n client,\n getBlock,\n 'getBlock',\n )({\n blockNumber: i,\n includeTransactions,\n })) as GetBlockReturnType<chain>\n emit.onBlock(block as any, prevBlock as any)\n prevBlock = block\n }\n }\n }\n\n if (\n // If no previous block exists, emit.\n !prevBlock?.number ||\n // If the block tag is \"pending\" with no block number, emit.\n (blockTag === 'pending' && !block?.number) ||\n // If the next block number is greater than the previous block number, emit.\n // We don't want to emit blocks in the past.\n (block.number && block.number > prevBlock.number)\n ) {\n emit.onBlock(block as any, prevBlock as any)\n prevBlock = block as any\n }\n } catch (err) {\n emit.onError?.(err as Error)\n }\n },\n {\n emitOnBegin,\n interval: pollingInterval,\n },\n ),\n )\n }\n\n const subscribeBlocks = () => {\n let active = true\n let emitFetched = true\n let unsubscribe = () => (active = false)\n ;(async () => {\n try {\n if (emitOnBegin) {\n getAction(\n client,\n getBlock,\n 'getBlock',\n )({\n blockTag,\n includeTransactions,\n }).then((block) => {\n if (!active) return\n if (!emitFetched) return\n onBlock(block as any, undefined)\n emitFetched = false\n })\n }\n\n const transport = (() => {\n if (client.transport.type === 'fallback') {\n const transport = client.transport.transports.find(\n (transport: ReturnType<Transport>) =>\n transport.config.type === 'webSocket',\n )\n if (!transport) return client.transport\n return transport.value\n }\n return client.transport\n })()\n\n const { unsubscribe: unsubscribe_ } = await transport.subscribe({\n params: ['newHeads'],\n async onData(data: any) {\n if (!active) return\n const block = (await getAction(\n client,\n getBlock,\n 'getBlock',\n )({\n blockNumber: data.blockNumber,\n includeTransactions,\n }).catch(() => {})) as GetBlockReturnType<chain>\n if (!active) return\n onBlock(block as any, prevBlock as any)\n emitFetched = false\n prevBlock = block\n },\n onError(error: Error) {\n onError?.(error)\n },\n })\n unsubscribe = unsubscribe_\n if (!active) unsubscribe()\n } catch (err) {\n onError?.(err as Error)\n }\n })()\n return () => unsubscribe()\n }\n\n return enablePolling ? pollBlocks() : subscribeBlocks()\n}\n", "import type { Client } from '../../clients/createClient.js'\nimport type { Transport } from '../../clients/transports/createTransport.js'\nimport type { ErrorType } from '../../errors/utils.js'\nimport type { Chain } from '../../types/chain.js'\nimport type { HasTransportType } from '../../types/transport.js'\nimport { hexToBigInt } from '../../utils/encoding/fromHex.js'\nimport { getAction } from '../../utils/getAction.js'\nimport { observe } from '../../utils/observe.js'\nimport { type PollErrorType, poll } from '../../utils/poll.js'\nimport { stringify } from '../../utils/stringify.js'\n\nimport {\n type GetBlockNumberReturnType,\n getBlockNumber,\n} from './getBlockNumber.js'\n\nexport type OnBlockNumberParameter = GetBlockNumberReturnType\nexport type OnBlockNumberFn = (\n blockNumber: OnBlockNumberParameter,\n prevBlockNumber: OnBlockNumberParameter | undefined,\n) => void\n\nexport type WatchBlockNumberParameters<\n transport extends Transport = Transport,\n> = {\n /** The callback to call when a new block number is received. */\n onBlockNumber: OnBlockNumberFn\n /** The callback to call when an error occurred when trying to get for a new block. */\n onError?: ((error: Error) => void) | undefined\n} & (\n | (HasTransportType<transport, 'webSocket'> extends true\n ? {\n emitMissed?: undefined\n emitOnBegin?: undefined\n /** Whether or not the WebSocket Transport should poll the JSON-RPC, rather than using `eth_subscribe`. */\n poll?: false | undefined\n pollingInterval?: undefined\n }\n : never)\n | {\n /** Whether or not to emit the missed block numbers to the callback. */\n emitMissed?: boolean | undefined\n /** Whether or not to emit the latest block number to the callback when the subscription opens. */\n emitOnBegin?: boolean | undefined\n poll?: true | undefined\n /** Polling frequency (in ms). Defaults to Client's pollingInterval config. */\n pollingInterval?: number | undefined\n }\n)\n\nexport type WatchBlockNumberReturnType = () => void\n\nexport type WatchBlockNumberErrorType = PollErrorType | ErrorType\n\n/**\n * Watches and returns incoming block numbers.\n *\n * - Docs: https://viem.sh/docs/actions/public/watchBlockNumber\n * - Examples: https://stackblitz.com/github/wevm/viem/tree/main/examples/blocks_watching-blocks\n * - JSON-RPC Methods:\n * - When `poll: true`, calls [`eth_blockNumber`](https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_blocknumber) on a polling interval.\n * - When `poll: false` & WebSocket Transport, uses a WebSocket subscription via [`eth_subscribe`](https://docs.alchemy.com/reference/eth-subscribe-polygon) and the `\"newHeads\"` event.\n *\n * @param client - Client to use\n * @param parameters - {@link WatchBlockNumberParameters}\n * @returns A function that can be invoked to stop watching for new block numbers. {@link WatchBlockNumberReturnType}\n *\n * @example\n * import { createPublicClient, watchBlockNumber, http } from 'viem'\n * import { mainnet } from 'viem/chains'\n *\n * const client = createPublicClient({\n * chain: mainnet,\n * transport: http(),\n * })\n * const unwatch = watchBlockNumber(client, {\n * onBlockNumber: (blockNumber) => console.log(blockNumber),\n * })\n */\nexport function watchBlockNumber<\n chain extends Chain | undefined,\n transport extends Transport,\n>(\n client: Client<transport, chain>,\n {\n emitOnBegin = false,\n emitMissed = false,\n onBlockNumber,\n onError,\n poll: poll_,\n pollingInterval = client.pollingInterval,\n }: WatchBlockNumberParameters<transport>,\n): WatchBlockNumberReturnType {\n const enablePolling = (() => {\n if (typeof poll_ !== 'undefined') return poll_\n if (client.transport.type === 'webSocket') return false\n if (\n client.transport.type === 'fallback' &&\n client.transport.transports[0].config.type === 'webSocket'\n )\n return false\n return true\n })()\n\n let prevBlockNumber: GetBlockNumberReturnType | undefined\n\n const pollBlockNumber = () => {\n const observerId = stringify([\n 'watchBlockNumber',\n client.uid,\n emitOnBegin,\n emitMissed,\n pollingInterval,\n ])\n\n return observe(observerId, { onBlockNumber, onError }, (emit) =>\n poll(\n async () => {\n try {\n const blockNumber = await getAction(\n client,\n getBlockNumber,\n 'getBlockNumber',\n )({ cacheTime: 0 })\n\n if (prevBlockNumber) {\n // If the current block number is the same as the previous,\n // we can skip.\n if (blockNumber === prevBlockNumber) return\n\n // If we have missed out on some previous blocks, and the\n // `emitMissed` flag is truthy, let's emit those blocks.\n if (blockNumber - prevBlockNumber > 1 && emitMissed) {\n for (let i = prevBlockNumber + 1n; i < blockNumber; i++) {\n emit.onBlockNumber(i, prevBlockNumber)\n prevBlockNumber = i\n }\n }\n }\n\n // If the next block number is greater than the previous,\n // it is not in the past, and we can emit the new block number.\n if (!prevBlockNumber || blockNumber > prevBlockNumber) {\n emit.onBlockNumber(blockNumber, prevBlockNumber)\n prevBlockNumber = blockNumber\n }\n } catch (err) {\n emit.onError?.(err as Error)\n }\n },\n {\n emitOnBegin,\n interval: pollingInterval,\n },\n ),\n )\n }\n\n const subscribeBlockNumber = () => {\n const observerId = stringify([\n 'watchBlockNumber',\n client.uid,\n emitOnBegin,\n emitMissed,\n ])\n\n return observe(observerId, { onBlockNumber, onError }, (emit) => {\n let active = true\n let unsubscribe = () => (active = false)\n ;(async () => {\n try {\n const transport = (() => {\n if (client.transport.type === 'fallback') {\n const transport = client.transport.transports.find(\n (transport: ReturnType<Transport>) =>\n transport.config.type === 'webSocket',\n )\n if (!transport) return client.transport\n return transport.value\n }\n return client.transport\n })()\n\n const { unsubscribe: unsubscribe_ } = await transport.subscribe({\n params: ['newHeads'],\n onData(data: any) {\n if (!active) return\n const blockNumber = hexToBigInt(data.result?.number)\n emit.onBlockNumber(blockNumber, prevBlockNumber)\n prevBlockNumber = blockNumber\n },\n onError(error: Error) {\n emit.onError?.(error)\n },\n })\n unsubscribe = unsubscribe_\n if (!active) unsubscribe()\n } catch (err) {\n onError?.(err as Error)\n }\n })()\n return () => unsubscribe()\n })\n }\n\n return enablePolling ? pollBlockNumber() : subscribeBlockNumber()\n}\n", "import type { Client } from '../../clients/createClient.js'\nimport type { Transport } from '../../clients/transports/createTransport.js'\nimport type { ErrorType } from '../../errors/utils.js'\nimport type { Chain } from '../../types/chain.js'\nimport type { Filter } from '../../types/filter.js'\nimport type { RequestErrorType } from '../../utils/buildRequest.js'\n\nexport type UninstallFilterParameters = {\n filter: Filter<any>\n}\nexport type UninstallFilterReturnType = boolean\n\nexport type UninstallFilterErrorType = RequestErrorType | ErrorType\n\n/**\n * Destroys a [`Filter`](https://viem.sh/docs/glossary/types#filter).\n *\n * - Docs: https://viem.sh/docs/actions/public/uninstallFilter\n * - JSON-RPC Methods: [`eth_uninstallFilter`](https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_uninstallFilter)\n *\n * Destroys a Filter that was created from one of the following Actions:\n * - [`createBlockFilter`](https://viem.sh/docs/actions/public/createBlockFilter)\n * - [`createEventFilter`](https://viem.sh/docs/actions/public/createEventFilter)\n * - [`createPendingTransactionFilter`](https://viem.sh/docs/actions/public/createPendingTransactionFilter)\n *\n * @param client - Client to use\n * @param parameters - {@link UninstallFilterParameters}\n * @returns A boolean indicating if the Filter was successfully uninstalled. {@link UninstallFilterReturnType}\n *\n * @example\n * import { createPublicClient, http } from 'viem'\n * import { mainnet } from 'viem/chains'\n * import { createPendingTransactionFilter, uninstallFilter } from 'viem/public'\n *\n * const filter = await createPendingTransactionFilter(client)\n * const uninstalled = await uninstallFilter(client, { filter })\n * // true\n */\nexport async function uninstallFilter<\n transport extends Transport,\n chain extends Chain | undefined,\n>(\n _client: Client<transport, chain>,\n { filter }: UninstallFilterParameters,\n): Promise<UninstallFilterReturnType> {\n return filter.request({\n method: 'eth_uninstallFilter',\n params: [filter.id],\n })\n}\n", "import type { AbiEvent, Address } from 'abitype'\n\nimport type { Client } from '../../clients/createClient.js'\nimport type { Transport } from '../../clients/transports/createTransport.js'\nimport type { Chain } from '../../types/chain.js'\nimport type {\n MaybeAbiEventName,\n MaybeExtractEventArgsFromAbi,\n} from '../../types/contract.js'\nimport type { Filter } from '../../types/filter.js'\nimport type { Log } from '../../types/log.js'\nimport type { LogTopic } from '../../types/misc.js'\nimport type { GetPollOptions } from '../../types/transport.js'\nimport {\n type EncodeEventTopicsParameters,\n encodeEventTopics,\n} from '../../utils/abi/encodeEventTopics.js'\nimport { type ObserveErrorType, observe } from '../../utils/observe.js'\nimport { poll } from '../../utils/poll.js'\nimport { type StringifyErrorType, stringify } from '../../utils/stringify.js'\n\nimport {\n DecodeLogDataMismatch,\n DecodeLogTopicsMismatch,\n} from '../../errors/abi.js'\nimport { InvalidInputRpcError } from '../../errors/rpc.js'\nimport type { ErrorType } from '../../errors/utils.js'\nimport type { BlockNumber } from '../../types/block.js'\nimport { decodeEventLog } from '../../utils/abi/decodeEventLog.js'\nimport { formatLog } from '../../utils/formatters/log.js'\nimport { getAction } from '../../utils/getAction.js'\nimport {\n type CreateEventFilterParameters,\n createEventFilter,\n} from './createEventFilter.js'\nimport { getBlockNumber } from './getBlockNumber.js'\nimport { getFilterChanges } from './getFilterChanges.js'\nimport { type GetLogsParameters, getLogs } from './getLogs.js'\nimport { uninstallFilter } from './uninstallFilter.js'\n\nexport type WatchEventOnLogsParameter<\n abiEvent extends AbiEvent | undefined = undefined,\n abiEvents extends\n | readonly AbiEvent[]\n | readonly unknown[]\n | undefined = abiEvent extends AbiEvent ? [abiEvent] : undefined,\n strict extends boolean | undefined = undefined,\n eventName extends string | undefined = MaybeAbiEventName<abiEvent>,\n> = Log<bigint, number, false, abiEvent, strict, abiEvents, eventName>[]\nexport type WatchEventOnLogsFn<\n abiEvent extends AbiEvent | undefined = undefined,\n abiEvents extends\n | readonly AbiEvent[]\n | readonly unknown[]\n | undefined = abiEvent extends AbiEvent ? [abiEvent] : undefined,\n strict extends boolean | undefined = undefined,\n //\n _eventName extends string | undefined = MaybeAbiEventName<abiEvent>,\n> = (\n logs: WatchEventOnLogsParameter<abiEvent, abiEvents, strict, _eventName>,\n) => void\n\nexport type WatchEventParameters<\n abiEvent extends AbiEvent | undefined = undefined,\n abiEvents extends\n | readonly AbiEvent[]\n | readonly unknown[]\n | undefined = abiEvent extends AbiEvent ? [abiEvent] : undefined,\n strict extends boolean | undefined = undefined,\n transport extends Transport = Transport,\n //\n _eventName extends string | undefined = MaybeAbiEventName<abiEvent>,\n> = {\n /** The address of the contract. */\n address?: Address | Address[] | undefined\n /** Block to start listening from. */\n fromBlock?: BlockNumber<bigint> | undefined\n /** The callback to call when an error occurred when trying to get for a new block. */\n onError?: ((error: Error) => void) | undefined\n /** The callback to call when new event logs are received. */\n onLogs: WatchEventOnLogsFn<abiEvent, abiEvents, strict, _eventName>\n} & GetPollOptions<transport> &\n (\n | {\n event: abiEvent\n events?: undefined\n args?: MaybeExtractEventArgsFromAbi<abiEvents, _eventName> | undefined\n /**\n * Whether or not the logs must match the indexed/non-indexed arguments on `event`.\n * @default false\n */\n strict?: strict | undefined\n }\n | {\n event?: undefined\n events?: abiEvents | undefined\n args?: undefined\n /**\n * Whether or not the logs must match the indexed/non-indexed arguments on `event`.\n * @default false\n */\n strict?: strict | undefined\n }\n | {\n event?: undefined\n events?: undefined\n args?: undefined\n strict?: undefined\n }\n )\n\nexport type WatchEventReturnType = () => void\n\nexport type WatchEventErrorType =\n | StringifyErrorType\n | ObserveErrorType\n | ErrorType\n\n/**\n * Watches and returns emitted [Event Logs](https://viem.sh/docs/glossary/terms#event-log).\n *\n * - Docs: https://viem.sh/docs/actions/public/watchEvent\n * - JSON-RPC Methods:\n * - **RPC Provider supports `eth_newFilter`:**\n * - Calls [`eth_newFilter`](https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_newfilter) to create a filter (called on initialize).\n * - On a polling interval, it will call [`eth_getFilterChanges`](https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_getfilterchanges).\n * - **RPC Provider does not support `eth_newFilter`:**\n * - Calls [`eth_getLogs`](https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_getlogs) for each block between the polling interval.\n *\n * This Action will batch up all the Event Logs found within the [`pollingInterval`](https://viem.sh/docs/actions/public/watchEvent#pollinginterval-optional), and invoke them via [`onLogs`](https://viem.sh/docs/actions/public/watchEvent#onLogs).\n *\n * `watchEvent` will attempt to create an [Event Filter](https://viem.sh/docs/actions/public/createEventFilter) and listen to changes to the Filter per polling interval, however, if the RPC Provider does not support Filters (e.g. `eth_newFilter`), then `watchEvent` will fall back to using [`getLogs`](https://viem.sh/docs/actions/public/getLogs) instead.\n *\n * @param client - Client to use\n * @param parameters - {@link WatchEventParameters}\n * @returns A function that can be invoked to stop watching for new Event Logs. {@link WatchEventReturnType}\n *\n * @example\n * import { createPublicClient, http } from 'viem'\n * import { mainnet } from 'viem/chains'\n * import { watchEvent } from 'viem/public'\n *\n * const client = createPublicClient({\n * chain: mainnet,\n * transport: http(),\n * })\n * const unwatch = watchEvent(client, {\n * onLogs: (logs) => console.log(logs),\n * })\n */\nexport function watchEvent<\n chain extends Chain | undefined,\n const abiEvent extends AbiEvent | undefined = undefined,\n const abiEvents extends\n | readonly AbiEvent[]\n | readonly unknown[]\n | undefined = abiEvent extends AbiEvent ? [abiEvent] : undefined,\n strict extends boolean | undefined = undefined,\n transport extends Transport = Transport,\n _eventName extends string | undefined = undefined,\n>(\n client: Client<transport, chain>,\n {\n address,\n args,\n batch = true,\n event,\n events,\n fromBlock,\n onError,\n onLogs,\n poll: poll_,\n pollingInterval = client.pollingInterval,\n strict: strict_,\n }: WatchEventParameters<abiEvent, abiEvents, strict, transport>,\n): WatchEventReturnType {\n const enablePolling = (() => {\n if (typeof poll_ !== 'undefined') return poll_\n if (typeof fromBlock === 'bigint') return true\n if (client.transport.type === 'webSocket') return false\n if (\n client.transport.type === 'fallback' &&\n client.transport.transports[0].config.type === 'webSocket'\n )\n return false\n return true\n })()\n const strict = strict_ ?? false\n\n const pollEvent = () => {\n const observerId = stringify([\n 'watchEvent',\n address,\n args,\n batch,\n client.uid,\n event,\n pollingInterval,\n fromBlock,\n ])\n\n return observe(observerId, { onLogs, onError }, (emit) => {\n let previousBlockNumber: bigint\n if (fromBlock !== undefined) previousBlockNumber = fromBlock - 1n\n let filter: Filter<'event', abiEvents, _eventName, any>\n let initialized = false\n\n const unwatch = poll(\n async () => {\n if (!initialized) {\n try {\n filter = (await getAction(\n client,\n createEventFilter as any,\n 'createEventFilter',\n )({\n address,\n args,\n event: event!,\n events,\n strict,\n fromBlock,\n } as unknown as CreateEventFilterParameters)) as unknown as Filter<\n 'event',\n abiEvents,\n _eventName\n >\n } catch {}\n initialized = true\n return\n }\n\n try {\n let logs: Log[]\n if (filter) {\n logs = await getAction(\n client,\n getFilterChanges,\n 'getFilterChanges',\n )({ filter })\n } else {\n // If the filter doesn't exist, we will fall back to use `getLogs`.\n // The fall back exists because some RPC Providers do not support filters.\n\n // Fetch the block number to use for `getLogs`.\n const blockNumber = await getAction(\n client,\n getBlockNumber,\n 'getBlockNumber',\n )({})\n\n // If the block number has changed, we will need to fetch the logs.\n // If the block number doesn't exist, we are yet to reach the first poll interval,\n // so do not emit any logs.\n if (previousBlockNumber && previousBlockNumber !== blockNumber) {\n logs = await getAction(\n client,\n getLogs,\n 'getLogs',\n )({\n address,\n args,\n event: event!,\n events,\n fromBlock: previousBlockNumber + 1n,\n toBlock: blockNumber,\n } as unknown as GetLogsParameters)\n } else {\n logs = []\n }\n previousBlockNumber = blockNumber\n }\n\n if (logs.length === 0) return\n if (batch) emit.onLogs(logs as any)\n else for (const log of logs) emit.onLogs([log] as any)\n } catch (err) {\n // If a filter has been set and gets uninstalled, providers will throw an InvalidInput error.\n // Reinitialize the filter when this occurs\n if (filter && err instanceof InvalidInputRpcError)\n initialized = false\n emit.onError?.(err as Error)\n }\n },\n {\n emitOnBegin: true,\n interval: pollingInterval,\n },\n )\n\n return async () => {\n if (filter)\n await getAction(\n client,\n uninstallFilter,\n 'uninstallFilter',\n )({ filter })\n unwatch()\n }\n })\n }\n\n const subscribeEvent = () => {\n let active = true\n let unsubscribe = () => (active = false)\n ;(async () => {\n try {\n const transport = (() => {\n if (client.transport.type === 'fallback') {\n const transport = client.transport.transports.find(\n (transport: ReturnType<Transport>) =>\n transport.config.type === 'webSocket',\n )\n if (!transport) return client.transport\n return transport.value\n }\n return client.transport\n })()\n\n const events_ = events ?? (event ? [event] : undefined)\n let topics: LogTopic[] = []\n if (events_) {\n const encoded = (events_ as AbiEvent[]).flatMap((event) =>\n encodeEventTopics({\n abi: [event],\n eventName: (event as AbiEvent).name,\n args,\n } as EncodeEventTopicsParameters),\n )\n // TODO: Clean up type casting\n topics = [encoded as LogTopic]\n if (event) topics = topics[0] as LogTopic[]\n }\n\n const { unsubscribe: unsubscribe_ } = await transport.subscribe({\n params: ['logs', { address, topics }],\n onData(data: any) {\n if (!active) return\n const log = data.result\n try {\n const { eventName, args } = decodeEventLog({\n abi: events_ ?? [],\n data: log.data,\n topics: log.topics,\n strict,\n })\n const formatted = formatLog(log, { args, eventName })\n onLogs([formatted] as any)\n } catch (err) {\n let eventName: string | undefined\n let isUnnamed: boolean | undefined\n if (\n err instanceof DecodeLogDataMismatch ||\n err instanceof DecodeLogTopicsMismatch\n ) {\n // If strict mode is on, and log data/topics do not match event definition, skip.\n if (strict_) return\n eventName = err.abiItem.name\n isUnnamed = err.abiItem.inputs?.some(\n (x) => !('name' in x && x.name),\n )\n }\n\n // Set args to empty if there is an error decoding (e.g. indexed/non-indexed params mismatch).\n const formatted = formatLog(log, {\n args: isUnnamed ? [] : {},\n eventName,\n })\n onLogs([formatted] as any)\n }\n },\n onError(error: Error) {\n onError?.(error)\n },\n })\n unsubscribe = unsubscribe_\n if (!active) unsubscribe()\n } catch (err) {\n onError?.(err as Error)\n }\n })()\n return () => unsubscribe()\n }\n\n return enablePolling ? pollEvent() : subscribeEvent()\n}\n", "import type { Client } from '../../clients/createClient.js'\nimport type { Transport } from '../../clients/transports/createTransport.js'\nimport type { ErrorType } from '../../errors/utils.js'\nimport type { Chain } from '../../types/chain.js'\nimport type { Filter } from '../../types/filter.js'\nimport type { Hash } from '../../types/misc.js'\nimport type { GetPollOptions } from '../../types/transport.js'\nimport { getAction } from '../../utils/getAction.js'\nimport { type ObserveErrorType, observe } from '../../utils/observe.js'\nimport { poll } from '../../utils/poll.js'\nimport { type StringifyErrorType, stringify } from '../../utils/stringify.js'\n\nimport { createPendingTransactionFilter } from './createPendingTransactionFilter.js'\nimport { getFilterChanges } from './getFilterChanges.js'\nimport { uninstallFilter } from './uninstallFilter.js'\n\nexport type OnTransactionsParameter = Hash[]\nexport type OnTransactionsFn = (transactions: OnTransactionsParameter) => void\n\nexport type WatchPendingTransactionsParameters<\n transport extends Transport = Transport,\n> = {\n /** The callback to call when an error occurred when trying to get for a new block. */\n onError?: ((error: Error) => void) | undefined\n /** The callback to call when new transactions are received. */\n onTransactions: OnTransactionsFn\n} & GetPollOptions<transport>\n\nexport type WatchPendingTransactionsReturnType = () => void\n\nexport type WatchPendingTransactionsErrorType =\n | StringifyErrorType\n | ObserveErrorType\n | ErrorType\n\n/**\n * Watches and returns pending transaction hashes.\n *\n * - Docs: https://viem.sh/docs/actions/public/watchPendingTransactions\n * - JSON-RPC Methods:\n * - When `poll: true`\n * - Calls [`eth_newPendingTransactionFilter`](https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_newpendingtransactionfilter) to initialize the filter.\n * - Calls [`eth_getFilterChanges`](https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_getFilterChanges) on a polling interval.\n * - When `poll: false` & WebSocket Transport, uses a WebSocket subscription via [`eth_subscribe`](https://docs.alchemy.com/reference/eth-subscribe-polygon) and the `\"newPendingTransactions\"` event.\n *\n * This Action will batch up all the pending transactions found within the [`pollingInterval`](https://viem.sh/docs/actions/public/watchPendingTransactions#pollinginterval-optional), and invoke them via [`onTransactions`](https://viem.sh/docs/actions/public/watchPendingTransactions#ontransactions).\n *\n * @param client - Client to use\n * @param parameters - {@link WatchPendingTransactionsParameters}\n * @returns A function that can be invoked to stop watching for new pending transaction hashes. {@link WatchPendingTransactionsReturnType}\n *\n * @example\n * import { createPublicClient, http } from 'viem'\n * import { mainnet } from 'viem/chains'\n * import { watchPendingTransactions } from 'viem/public'\n *\n * const client = createPublicClient({\n * chain: mainnet,\n * transport: http(),\n * })\n * const unwatch = await watchPendingTransactions(client, {\n * onTransactions: (hashes) => console.log(hashes),\n * })\n */\nexport function watchPendingTransactions<\n transport extends Transport,\n chain extends Chain | undefined,\n>(\n client: Client<transport, chain>,\n {\n batch = true,\n onError,\n onTransactions,\n poll: poll_,\n pollingInterval = client.pollingInterval,\n }: WatchPendingTransactionsParameters<transport>,\n) {\n const enablePolling =\n typeof poll_ !== 'undefined' ? poll_ : client.transport.type !== 'webSocket'\n\n const pollPendingTransactions = () => {\n const observerId = stringify([\n 'watchPendingTransactions',\n client.uid,\n batch,\n pollingInterval,\n ])\n return observe(observerId, { onTransactions, onError }, (emit) => {\n let filter: Filter<'transaction'>\n\n const unwatch = poll(\n async () => {\n try {\n if (!filter) {\n try {\n filter = await getAction(\n client,\n createPendingTransactionFilter,\n 'createPendingTransactionFilter',\n )({})\n return\n } catch (err) {\n unwatch()\n throw err\n }\n }\n\n const hashes = await getAction(\n client,\n getFilterChanges,\n 'getFilterChanges',\n )({ filter })\n if (hashes.length === 0) return\n if (batch) emit.onTransactions(hashes)\n else for (const hash of hashes) emit.onTransactions([hash])\n } catch (err) {\n emit.onError?.(err as Error)\n }\n },\n {\n emitOnBegin: true,\n interval: pollingInterval,\n },\n )\n\n return async () => {\n if (filter)\n await getAction(\n client,\n uninstallFilter,\n 'uninstallFilter',\n )({ filter })\n unwatch()\n }\n })\n }\n\n const subscribePendingTransactions = () => {\n let active = true\n let unsubscribe = () => (active = false)\n ;(async () => {\n try {\n const { unsubscribe: unsubscribe_ } = await client.transport.subscribe({\n params: ['newPendingTransactions'],\n onData(data: any) {\n if (!active) return\n const transaction = data.result\n onTransactions([transaction])\n },\n onError(error: Error) {\n onError?.(error)\n },\n })\n unsubscribe = unsubscribe_\n if (!active) unsubscribe()\n } catch (err) {\n onError?.(err as Error)\n }\n })()\n return () => unsubscribe()\n }\n\n return enablePolling\n ? pollPendingTransactions()\n : subscribePendingTransactions()\n}\n", "import type { Address } from 'abitype'\n\nimport type { Account } from '../../accounts/types.js'\nimport type { Client } from '../../clients/createClient.js'\nimport type { Transport } from '../../clients/transports/createTransport.js'\nimport type { ErrorType } from '../../errors/utils.js'\nimport type { Chain } from '../../types/chain.js'\nimport {\n type ChecksumAddressErrorType,\n checksumAddress,\n} from '../../utils/address/getAddress.js'\nimport type { RequestErrorType } from '../../utils/buildRequest.js'\n\nexport type GetAddressesReturnType = Address[]\n\nexport type GetAddressesErrorType =\n | RequestErrorType\n | ChecksumAddressErrorType\n | ErrorType\n\n/**\n * Returns a list of account addresses owned by the wallet or client.\n *\n * - Docs: https://viem.sh/docs/actions/wallet/getAddresses\n * - JSON-RPC Methods: [`eth_accounts`](https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_accounts)\n *\n * @param client - Client to use\n * @returns List of account addresses owned by the wallet or client. {@link GetAddressesReturnType}\n *\n * @example\n * import { createWalletClient, custom } from 'viem'\n * import { mainnet } from 'viem/chains'\n * import { getAddresses } from 'viem/wallet'\n *\n * const client = createWalletClient({\n * chain: mainnet,\n * transport: custom(window.ethereum),\n * })\n * const accounts = await getAddresses(client)\n */\nexport async function getAddresses<\n chain extends Chain | undefined,\n account extends Account | undefined = undefined,\n>(client: Client<Transport, chain, account>): Promise<GetAddressesReturnType> {\n if (client.account?.type === 'local') return [client.account.address]\n const addresses = await client.request(\n { method: 'eth_accounts' },\n { dedupe: true },\n )\n return addresses.map((address) => checksumAddress(address))\n}\n", "import type { Account } from '../../accounts/types.js'\nimport type { Client } from '../../clients/createClient.js'\nimport type { Transport } from '../../clients/transports/createTransport.js'\nimport type { ErrorType } from '../../errors/utils.js'\nimport type { Chain } from '../../types/chain.js'\nimport type { WalletPermission } from '../../types/eip1193.js'\nimport type { RequestErrorType } from '../../utils/buildRequest.js'\n\nexport type GetPermissionsReturnType = WalletPermission[]\n\nexport type GetPermissionsErrorType = RequestErrorType | ErrorType\n\n/**\n * Gets the wallets current permissions.\n *\n * - Docs: https://viem.sh/docs/actions/wallet/getPermissions\n * - JSON-RPC Methods: [`wallet_getPermissions`](https://eips.ethereum.org/EIPS/eip-2255)\n *\n * @param client - Client to use\n * @returns The wallet permissions. {@link GetPermissionsReturnType}\n *\n * @example\n * import { createWalletClient, custom } from 'viem'\n * import { mainnet } from 'viem/chains'\n * import { getPermissions } from 'viem/wallet'\n *\n * const client = createWalletClient({\n * chain: mainnet,\n * transport: custom(window.ethereum),\n * })\n * const permissions = await getPermissions(client)\n */\nexport async function getPermissions<\n chain extends Chain | undefined,\n account extends Account | undefined = undefined,\n>(client: Client<Transport, chain, account>) {\n const permissions = await client.request(\n { method: 'wallet_getPermissions' },\n { dedupe: true },\n )\n return permissions\n}\n", "import type { ErrorType } from '../../errors/utils.js'\nimport type { Proof } from '../../types/proof.js'\nimport type { RpcProof } from '../../types/rpc.js'\nimport type { ExactPartial } from '../../types/utils.js'\nimport { hexToNumber } from '../index.js'\n\nexport type FormatProofErrorType = ErrorType\n\nfunction formatStorageProof(storageProof: RpcProof['storageProof']) {\n return storageProof.map((proof) => ({\n ...proof,\n value: BigInt(proof.value),\n }))\n}\n\nexport function formatProof(proof: ExactPartial<RpcProof>) {\n return {\n ...proof,\n balance: proof.balance ? BigInt(proof.balance) : undefined,\n nonce: proof.nonce ? hexToNumber(proof.nonce) : undefined,\n storageProof: proof.storageProof\n ? formatStorageProof(proof.storageProof)\n : undefined,\n } as Proof\n}\n", "import type { Address } from 'abitype'\nimport type { Client } from '../../clients/createClient.js'\nimport type { Transport } from '../../clients/transports/createTransport.js'\nimport type { ErrorType } from '../../errors/utils.js'\nimport type { BlockTag } from '../../types/block.js'\nimport type { Chain } from '../../types/chain.js'\nimport type { Hash } from '../../types/misc.js'\nimport type { Proof } from '../../types/proof.js'\nimport type { RequestErrorType } from '../../utils/buildRequest.js'\nimport {\n type NumberToHexErrorType,\n numberToHex,\n} from '../../utils/encoding/toHex.js'\nimport {\n type FormatProofErrorType,\n formatProof,\n} from '../../utils/formatters/proof.js'\n\nexport type GetProofParameters = {\n /** Account address. */\n address: Address\n /** Array of storage-keys that should be proofed and included. */\n storageKeys: Hash[]\n} & (\n | {\n /** The block number. */\n blockNumber?: bigint | undefined\n blockTag?: undefined\n }\n | {\n blockNumber?: undefined\n /**\n * The block tag.\n * @default 'latest'\n */\n blockTag?: BlockTag | undefined\n }\n)\n\nexport type GetProofReturnType = Proof\n\nexport type GetProofErrorType =\n | NumberToHexErrorType\n | FormatProofErrorType\n | RequestErrorType\n | ErrorType\n\n/**\n * Returns the account and storage values of the specified account including the Merkle-proof.\n *\n * - Docs: https://viem.sh/docs/actions/public/getProof\n * - JSON-RPC Methods:\n * - Calls [`eth_getProof`](https://eips.ethereum.org/EIPS/eip-1186)\n *\n * @param client - Client to use\n * @param parameters - {@link GetProofParameters}\n * @returns Proof data. {@link GetProofReturnType}\n *\n * @example\n * import { createPublicClient, http } from 'viem'\n * import { mainnet } from 'viem/chains'\n * import { getProof } from 'viem/public'\n *\n * const client = createPublicClient({\n * chain: mainnet,\n * transport: http(),\n * })\n * const block = await getProof(client, {\n * address: '0x...',\n * storageKeys: ['0x...'],\n * })\n */\nexport async function getProof<chain extends Chain | undefined>(\n client: Client<Transport, chain>,\n {\n address,\n blockNumber,\n blockTag: blockTag_,\n storageKeys,\n }: GetProofParameters,\n): Promise<GetProofReturnType> {\n const blockTag = blockTag_ ?? 'latest'\n\n const blockNumberHex =\n blockNumber !== undefined ? numberToHex(blockNumber) : undefined\n\n const proof = await client.request({\n method: 'eth_getProof',\n params: [address, storageKeys, blockNumberHex || blockTag],\n })\n\n return formatProof(proof)\n}\n", "import type { Client } from '../../clients/createClient.js'\nimport type { Transport } from '../../clients/transports/createTransport.js'\nimport { BlockNotFoundError } from '../../errors/block.js'\nimport {\n TransactionNotFoundError,\n TransactionReceiptNotFoundError,\n WaitForTransactionReceiptTimeoutError,\n type WaitForTransactionReceiptTimeoutErrorType,\n} from '../../errors/transaction.js'\nimport type { ErrorType } from '../../errors/utils.js'\nimport type { Chain } from '../../types/chain.js'\nimport type { Hash } from '../../types/misc.js'\nimport type { Transaction } from '../../types/transaction.js'\nimport { getAction } from '../../utils/getAction.js'\nimport { type ObserveErrorType, observe } from '../../utils/observe.js'\nimport { withResolvers } from '../../utils/promise/withResolvers.js'\nimport {\n type WithRetryParameters,\n withRetry,\n} from '../../utils/promise/withRetry.js'\nimport { stringify } from '../../utils/stringify.js'\n\nimport { type GetBlockErrorType, getBlock } from './getBlock.js'\nimport {\n type GetTransactionErrorType,\n type GetTransactionReturnType,\n getTransaction,\n} from './getTransaction.js'\nimport {\n type GetTransactionReceiptErrorType,\n type GetTransactionReceiptReturnType,\n getTransactionReceipt,\n} from './getTransactionReceipt.js'\nimport {\n type WatchBlockNumberErrorType,\n watchBlockNumber,\n} from './watchBlockNumber.js'\n\nexport type ReplacementReason = 'cancelled' | 'replaced' | 'repriced'\nexport type ReplacementReturnType<\n chain extends Chain | undefined = Chain | undefined,\n> = {\n reason: ReplacementReason\n replacedTransaction: Transaction\n transaction: Transaction\n transactionReceipt: GetTransactionReceiptReturnType<chain>\n}\n\nexport type WaitForTransactionReceiptReturnType<\n chain extends Chain | undefined = Chain | undefined,\n> = GetTransactionReceiptReturnType<chain>\n\nexport type WaitForTransactionReceiptParameters<\n chain extends Chain | undefined = Chain | undefined,\n> = {\n /**\n * The number of confirmations (blocks that have passed) to wait before resolving.\n * @default 1\n */\n confirmations?: number | undefined\n /** The hash of the transaction. */\n hash: Hash\n /** Optional callback to emit if the transaction has been replaced. */\n onReplaced?: ((response: ReplacementReturnType<chain>) => void) | undefined\n /**\n * Polling frequency (in ms). Defaults to the client's pollingInterval config.\n * @default client.pollingInterval\n */\n pollingInterval?: number | undefined\n /**\n * Number of times to retry if the transaction or block is not found.\n * @default 6 (exponential backoff)\n */\n retryCount?: WithRetryParameters['retryCount'] | undefined\n /**\n * Time to wait (in ms) between retries.\n * @default `({ count }) => ~~(1 << count) * 200` (exponential backoff)\n */\n retryDelay?: WithRetryParameters['delay'] | undefined\n /**\n * Optional timeout (in milliseconds) to wait before stopping polling.\n * @default 180_000\n */\n timeout?: number | undefined\n}\n\nexport type WaitForTransactionReceiptErrorType =\n | ObserveErrorType\n | GetBlockErrorType\n | GetTransactionErrorType\n | GetTransactionReceiptErrorType\n | WatchBlockNumberErrorType\n | WaitForTransactionReceiptTimeoutErrorType\n | ErrorType\n\n/**\n * Waits for the [Transaction](https://viem.sh/docs/glossary/terms#transaction) to be included on a [Block](https://viem.sh/docs/glossary/terms#block) (one confirmation), and then returns the [Transaction Receipt](https://viem.sh/docs/glossary/terms#transaction-receipt).\n *\n * - Docs: https://viem.sh/docs/actions/public/waitForTransactionReceipt\n * - Example: https://stackblitz.com/github/wevm/viem/tree/main/examples/transactions_sending-transactions\n * - JSON-RPC Methods:\n * - Polls [`eth_getTransactionReceipt`](https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_getTransactionReceipt) on each block until it has been processed.\n * - If a Transaction has been replaced:\n * - Calls [`eth_getBlockByNumber`](https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_getblockbynumber) and extracts the transactions\n * - Checks if one of the Transactions is a replacement\n * - If so, calls [`eth_getTransactionReceipt`](https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_getTransactionReceipt).\n *\n * The `waitForTransactionReceipt` action additionally supports Replacement detection (e.g. sped up Transactions).\n *\n * Transactions can be replaced when a user modifies their transaction in their wallet (to speed up or cancel). Transactions are replaced when they are sent from the same nonce.\n *\n * There are 3 types of Transaction Replacement reasons:\n *\n * - `repriced`: The gas price has been modified (e.g. different `maxFeePerGas`)\n * - `cancelled`: The Transaction has been cancelled (e.g. `value === 0n`)\n * - `replaced`: The Transaction has been replaced (e.g. different `value` or `data`)\n *\n * @param client - Client to use\n * @param parameters - {@link WaitForTransactionReceiptParameters}\n * @returns The transaction receipt. {@link WaitForTransactionReceiptReturnType}\n *\n * @example\n * import { createPublicClient, waitForTransactionReceipt, http } from 'viem'\n * import { mainnet } from 'viem/chains'\n *\n * const client = createPublicClient({\n * chain: mainnet,\n * transport: http(),\n * })\n * const transactionReceipt = await waitForTransactionReceipt(client, {\n * hash: '0x4ca7ee652d57678f26e887c149ab0735f41de37bcad58c9f6d3ed5824f15b74d',\n * })\n */\nexport async function waitForTransactionReceipt<\n chain extends Chain | undefined,\n>(\n client: Client<Transport, chain>,\n {\n confirmations = 1,\n hash,\n onReplaced,\n pollingInterval = client.pollingInterval,\n retryCount = 6,\n retryDelay = ({ count }) => ~~(1 << count) * 200, // exponential backoff\n timeout = 180_000,\n }: WaitForTransactionReceiptParameters<chain>,\n): Promise<WaitForTransactionReceiptReturnType<chain>> {\n const observerId = stringify(['waitForTransactionReceipt', client.uid, hash])\n\n let transaction: GetTransactionReturnType<chain> | undefined\n let replacedTransaction: GetTransactionReturnType<chain> | undefined\n let receipt: GetTransactionReceiptReturnType<chain>\n let retrying = false\n\n const { promise, resolve, reject } =\n withResolvers<WaitForTransactionReceiptReturnType<chain>>()\n\n const timer = timeout\n ? setTimeout(\n () => reject(new WaitForTransactionReceiptTimeoutError({ hash })),\n timeout,\n )\n : undefined\n\n const _unobserve = observe(\n observerId,\n { onReplaced, resolve, reject },\n (emit) => {\n const _unwatch = getAction(\n client,\n watchBlockNumber,\n 'watchBlockNumber',\n )({\n emitMissed: true,\n emitOnBegin: true,\n poll: true,\n pollingInterval,\n async onBlockNumber(blockNumber_) {\n const done = (fn: () => void) => {\n clearTimeout(timer)\n _unwatch()\n fn()\n _unobserve()\n }\n\n let blockNumber = blockNumber_\n\n if (retrying) return\n\n try {\n // If we already have a valid receipt, let's check if we have enough\n // confirmations. If we do, then we can resolve.\n if (receipt) {\n if (\n confirmations > 1 &&\n (!receipt.blockNumber ||\n blockNumber - receipt.blockNumber + 1n < confirmations)\n )\n return\n\n done(() => emit.resolve(receipt))\n return\n }\n\n // Get the transaction to check if it's been replaced.\n // We need to retry as some RPC Providers may be slow to sync\n // up mined transactions.\n if (!transaction) {\n retrying = true\n await withRetry(\n async () => {\n transaction = (await getAction(\n client,\n getTransaction,\n 'getTransaction',\n )({ hash })) as GetTransactionReturnType<chain>\n if (transaction.blockNumber)\n blockNumber = transaction.blockNumber\n },\n {\n delay: retryDelay,\n retryCount,\n },\n )\n retrying = false\n }\n\n // Get the receipt to check if it's been processed.\n receipt = await getAction(\n client,\n getTransactionReceipt,\n 'getTransactionReceipt',\n )({ hash })\n\n // Check if we have enough confirmations. If not, continue polling.\n if (\n confirmations > 1 &&\n (!receipt.blockNumber ||\n blockNumber - receipt.blockNumber + 1n < confirmations)\n )\n return\n\n done(() => emit.resolve(receipt))\n } catch (err) {\n // If the receipt is not found, the transaction will be pending.\n // We need to check if it has potentially been replaced.\n if (\n err instanceof TransactionNotFoundError ||\n err instanceof TransactionReceiptNotFoundError\n ) {\n if (!transaction) {\n retrying = false\n return\n }\n\n try {\n replacedTransaction = transaction\n\n // Let's retrieve the transactions from the current block.\n // We need to retry as some RPC Providers may be slow to sync\n // up mined blocks.\n retrying = true\n const block = await withRetry(\n () =>\n getAction(\n client,\n getBlock,\n 'getBlock',\n )({\n blockNumber,\n includeTransactions: true,\n }),\n {\n delay: retryDelay,\n retryCount,\n shouldRetry: ({ error }) =>\n error instanceof BlockNotFoundError,\n },\n )\n retrying = false\n\n const replacementTransaction = (\n block.transactions as {} as Transaction[]\n ).find(\n ({ from, nonce }) =>\n from === replacedTransaction!.from &&\n nonce === replacedTransaction!.nonce,\n )\n\n // If we couldn't find a replacement transaction, continue polling.\n if (!replacementTransaction) return\n\n // If we found a replacement transaction, return it's receipt.\n receipt = await getAction(\n client,\n getTransactionReceipt,\n 'getTransactionReceipt',\n )({\n hash: replacementTransaction.hash,\n })\n\n // Check if we have enough confirmations. If not, continue polling.\n if (\n confirmations > 1 &&\n (!receipt.blockNumber ||\n blockNumber - receipt.blockNumber + 1n < confirmations)\n )\n return\n\n let reason: ReplacementReason = 'replaced'\n if (\n replacementTransaction.to === replacedTransaction.to &&\n replacementTransaction.value === replacedTransaction.value &&\n replacementTransaction.input === replacedTransaction.input\n ) {\n reason = 'repriced'\n } else if (\n replacementTransaction.from === replacementTransaction.to &&\n replacementTransaction.value === 0n\n ) {\n reason = 'cancelled'\n }\n\n done(() => {\n emit.onReplaced?.({\n reason,\n replacedTransaction: replacedTransaction! as any,\n transaction: replacementTransaction,\n transactionReceipt: receipt,\n })\n emit.resolve(receipt)\n })\n } catch (err_) {\n done(() => emit.reject(err_))\n }\n } else {\n done(() => emit.reject(err))\n }\n }\n },\n })\n },\n )\n\n return promise\n}\n", "import type { Address } from 'abitype'\n\nimport type { Account } from '../../accounts/types.js'\nimport type { Client } from '../../clients/createClient.js'\nimport type { Transport } from '../../clients/transports/createTransport.js'\nimport type { ErrorType } from '../../errors/utils.js'\nimport type { Chain } from '../../types/chain.js'\nimport { getAddress } from '../../utils/address/getAddress.js'\nimport type { RequestErrorType } from '../../utils/buildRequest.js'\n\nexport type RequestAddressesReturnType = Address[]\n\nexport type RequestAddressesErrorType = RequestErrorType | ErrorType\n\n/**\n * Requests a list of accounts managed by a wallet.\n *\n * - Docs: https://viem.sh/docs/actions/wallet/requestAddresses\n * - JSON-RPC Methods: [`eth_requestAccounts`](https://eips.ethereum.org/EIPS/eip-1102)\n *\n * Sends a request to the wallet, asking for permission to access the user's accounts. After the user accepts the request, it will return a list of accounts (addresses).\n *\n * This API can be useful for dapps that need to access the user's accounts in order to execute transactions or interact with smart contracts.\n *\n * @param client - Client to use\n * @returns List of accounts managed by a wallet {@link RequestAddressesReturnType}\n *\n * @example\n * import { createWalletClient, custom } from 'viem'\n * import { mainnet } from 'viem/chains'\n * import { requestAddresses } from 'viem/wallet'\n *\n * const client = createWalletClient({\n * chain: mainnet,\n * transport: custom(window.ethereum),\n * })\n * const accounts = await requestAddresses(client)\n */\nexport async function requestAddresses<\n chain extends Chain | undefined,\n account extends Account | undefined = undefined,\n>(\n client: Client<Transport, chain, account>,\n): Promise<RequestAddressesReturnType> {\n const addresses = await client.request(\n { method: 'eth_requestAccounts' },\n { dedupe: true, retryCount: 0 },\n )\n return addresses.map((address) => getAddress(address))\n}\n", "import type { Account } from '../../accounts/types.js'\nimport type { Client } from '../../clients/createClient.js'\nimport type { Transport } from '../../clients/transports/createTransport.js'\nimport type { ErrorType } from '../../errors/utils.js'\nimport type { Chain } from '../../types/chain.js'\nimport type { WalletPermission } from '../../types/eip1193.js'\nimport type { Prettify } from '../../types/utils.js'\nimport type { RequestErrorType } from '../../utils/buildRequest.js'\n\nexport type RequestPermissionsParameters = Prettify<\n {\n eth_accounts: Record<string, any>\n } & {\n [key: string]: Record<string, any>\n }\n>\nexport type RequestPermissionsReturnType = WalletPermission[]\n\nexport type RequestPermissionsErrorType = RequestErrorType | ErrorType\n\n/**\n * Requests permissions for a wallet.\n *\n * - Docs: https://viem.sh/docs/actions/wallet/requestPermissions\n * - JSON-RPC Methods: [`wallet_requestPermissions`](https://eips.ethereum.org/EIPS/eip-2255)\n *\n * @param client - Client to use\n * @param parameters - {@link RequestPermissionsParameters}\n * @returns The wallet permissions. {@link RequestPermissionsReturnType}\n *\n * @example\n * import { createWalletClient, custom } from 'viem'\n * import { mainnet } from 'viem/chains'\n * import { requestPermissions } from 'viem/wallet'\n *\n * const client = createWalletClient({\n * chain: mainnet,\n * transport: custom(window.ethereum),\n * })\n * const permissions = await requestPermissions(client, {\n * eth_accounts: {}\n * })\n */\nexport async function requestPermissions<\n chain extends Chain | undefined,\n account extends Account | undefined = undefined,\n>(\n client: Client<Transport, chain, account>,\n permissions: RequestPermissionsParameters,\n) {\n return client.request(\n {\n method: 'wallet_requestPermissions',\n params: [permissions],\n },\n { retryCount: 0 },\n )\n}\n", "import type { Account } from '../../accounts/types.js'\nimport {\n type ParseAccountErrorType,\n parseAccount,\n} from '../../accounts/utils/parseAccount.js'\nimport type { SignTransactionErrorType as SignTransactionErrorType_account } from '../../accounts/utils/signTransaction.js'\nimport type { Client } from '../../clients/createClient.js'\nimport type { Transport } from '../../clients/transports/createTransport.js'\nimport { AccountNotFoundError } from '../../errors/account.js'\nimport type { ErrorType } from '../../errors/utils.js'\nimport type { GetAccountParameter } from '../../types/account.js'\nimport type {\n Chain,\n DeriveChain,\n GetChainParameter,\n} from '../../types/chain.js'\nimport type { GetTransactionRequestKzgParameter } from '../../types/kzg.js'\nimport type { RpcTransactionRequest } from '../../types/rpc.js'\nimport type {\n TransactionRequest,\n TransactionSerializable,\n TransactionSerialized,\n} from '../../types/transaction.js'\nimport type { UnionOmit } from '../../types/utils.js'\nimport type { RequestErrorType } from '../../utils/buildRequest.js'\nimport {\n type AssertCurrentChainErrorType,\n assertCurrentChain,\n} from '../../utils/chain/assertCurrentChain.js'\nimport { numberToHex } from '../../utils/encoding/toHex.js'\nimport type { NumberToHexErrorType } from '../../utils/encoding/toHex.js'\nimport {\n type FormattedTransactionRequest,\n formatTransactionRequest,\n} from '../../utils/formatters/transactionRequest.js'\nimport { getAction } from '../../utils/getAction.js'\nimport {\n type AssertRequestErrorType,\n assertRequest,\n} from '../../utils/transaction/assertRequest.js'\nimport type { GetTransactionType } from '../../utils/transaction/getTransactionType.js'\nimport { type GetChainIdErrorType, getChainId } from '../public/getChainId.js'\n\nexport type SignTransactionRequest<\n chain extends Chain | undefined = Chain | undefined,\n chainOverride extends Chain | undefined = Chain | undefined,\n ///\n _derivedChain extends Chain | undefined = DeriveChain<chain, chainOverride>,\n> = UnionOmit<FormattedTransactionRequest<_derivedChain>, 'from'>\n\nexport type SignTransactionParameters<\n chain extends Chain | undefined,\n account extends Account | undefined,\n chainOverride extends Chain | undefined = Chain | undefined,\n request extends SignTransactionRequest<\n chain,\n chainOverride\n > = SignTransactionRequest<chain, chainOverride>,\n> = request &\n GetAccountParameter<account> &\n GetChainParameter<chain, chainOverride> &\n GetTransactionRequestKzgParameter<request>\n\nexport type SignTransactionReturnType<\n request extends SignTransactionRequest = SignTransactionRequest,\n> = TransactionSerialized<GetTransactionType<request>>\n\nexport type SignTransactionErrorType =\n | ParseAccountErrorType\n | AssertRequestErrorType\n | GetChainIdErrorType\n | AssertCurrentChainErrorType\n | SignTransactionErrorType_account\n | NumberToHexErrorType\n | RequestErrorType\n | ErrorType\n\n/**\n * Signs a transaction.\n *\n * - Docs: https://viem.sh/docs/actions/wallet/signTransaction\n * - JSON-RPC Methods:\n * - JSON-RPC Accounts: [`eth_signTransaction`](https://ethereum.github.io/execution-apis/api-documentation/)\n * - Local Accounts: Signs locally. No JSON-RPC request.\n *\n * @param args - {@link SignTransactionParameters}\n * @returns The signed serialized transaction. {@link SignTransactionReturnType}\n *\n * @example\n * import { createWalletClient, custom } from 'viem'\n * import { mainnet } from 'viem/chains'\n * import { signTransaction } from 'viem/actions'\n *\n * const client = createWalletClient({\n * chain: mainnet,\n * transport: custom(window.ethereum),\n * })\n * const signature = await signTransaction(client, {\n * account: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e',\n * to: '0x0000000000000000000000000000000000000000',\n * value: 1n,\n * })\n *\n * @example\n * // Account Hoisting\n * import { createWalletClient, http } from 'viem'\n * import { privateKeyToAccount } from 'viem/accounts'\n * import { mainnet } from 'viem/chains'\n * import { signTransaction } from 'viem/actions'\n *\n * const client = createWalletClient({\n * account: privateKeyToAccount('0x…'),\n * chain: mainnet,\n * transport: custom(window.ethereum),\n * })\n * const signature = await signTransaction(client, {\n * to: '0x0000000000000000000000000000000000000000',\n * value: 1n,\n * })\n */\nexport async function signTransaction<\n chain extends Chain | undefined,\n account extends Account | undefined,\n chainOverride extends Chain | undefined = undefined,\n const request extends SignTransactionRequest<\n chain,\n chainOverride\n > = SignTransactionRequest<chain, chainOverride>,\n>(\n client: Client<Transport, chain, account>,\n parameters: SignTransactionParameters<chain, account, chainOverride, request>,\n): Promise<SignTransactionReturnType<request>> {\n const {\n account: account_ = client.account,\n chain = client.chain,\n ...transaction\n } = parameters\n\n if (!account_)\n throw new AccountNotFoundError({\n docsPath: '/docs/actions/wallet/signTransaction',\n })\n const account = parseAccount(account_)\n\n assertRequest({\n account,\n ...parameters,\n })\n\n const chainId = await getAction(client, getChainId, 'getChainId')({})\n if (chain !== null)\n assertCurrentChain({\n currentChainId: chainId,\n chain,\n })\n\n const formatters = chain?.formatters || client.chain?.formatters\n const format =\n formatters?.transactionRequest?.format || formatTransactionRequest\n\n if (account.signTransaction)\n return account.signTransaction(\n {\n ...transaction,\n chainId,\n } as TransactionSerializable,\n { serializer: client.chain?.serializers?.transaction },\n ) as Promise<SignTransactionReturnType<request>>\n\n return await client.request(\n {\n method: 'eth_signTransaction',\n params: [\n {\n ...format(transaction as unknown as TransactionRequest),\n chainId: numberToHex(chainId),\n from: account.address,\n } as unknown as RpcTransactionRequest,\n ],\n },\n { retryCount: 0 },\n )\n}\n", "import type { Account } from '../../accounts/types.js'\nimport {\n type ParseAccountErrorType,\n parseAccount,\n} from '../../accounts/utils/parseAccount.js'\nimport type { SignMessageErrorType as SignMessageErrorType_account } from '../../accounts/utils/signMessage.js'\nimport type { Client } from '../../clients/createClient.js'\nimport type { Transport } from '../../clients/transports/createTransport.js'\nimport { AccountNotFoundError } from '../../errors/account.js'\nimport type { ErrorType } from '../../errors/utils.js'\nimport type { GetAccountParameter } from '../../types/account.js'\nimport type { Chain } from '../../types/chain.js'\nimport type { Hex, SignableMessage } from '../../types/misc.js'\nimport type { RequestErrorType } from '../../utils/buildRequest.js'\nimport {\n type ToHexErrorType,\n stringToHex,\n toHex,\n} from '../../utils/encoding/toHex.js'\n\nexport type SignMessageParameters<\n account extends Account | undefined = Account | undefined,\n> = GetAccountParameter<account> & {\n message: SignableMessage\n}\n\nexport type SignMessageReturnType = Hex\n\nexport type SignMessageErrorType =\n | ParseAccountErrorType\n | RequestErrorType\n | SignMessageErrorType_account\n | ToHexErrorType\n | ErrorType\n\n/**\n * Calculates an Ethereum-specific signature in [EIP-191 format](https://eips.ethereum.org/EIPS/eip-191): `keccak256(\"\\x19Ethereum Signed Message:\\n\" + len(message) + message))`.\n *\n * - Docs: https://viem.sh/docs/actions/wallet/signMessage\n * - JSON-RPC Methods:\n * - JSON-RPC Accounts: [`personal_sign`](https://docs.metamask.io/guide/signing-data#personal-sign)\n * - Local Accounts: Signs locally. No JSON-RPC request.\n *\n * With the calculated signature, you can:\n * - use [`verifyMessage`](https://viem.sh/docs/utilities/verifyMessage) to verify the signature,\n * - use [`recoverMessageAddress`](https://viem.sh/docs/utilities/recoverMessageAddress) to recover the signing address from a signature.\n *\n * @param client - Client to use\n * @param parameters - {@link SignMessageParameters}\n * @returns The signed message. {@link SignMessageReturnType}\n *\n * @example\n * import { createWalletClient, custom } from 'viem'\n * import { mainnet } from 'viem/chains'\n * import { signMessage } from 'viem/wallet'\n *\n * const client = createWalletClient({\n * chain: mainnet,\n * transport: custom(window.ethereum),\n * })\n * const signature = await signMessage(client, {\n * account: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e',\n * message: 'hello world',\n * })\n *\n * @example\n * // Account Hoisting\n * import { createWalletClient, custom } from 'viem'\n * import { privateKeyToAccount } from 'viem/accounts'\n * import { mainnet } from 'viem/chains'\n * import { signMessage } from 'viem/wallet'\n *\n * const client = createWalletClient({\n * account: privateKeyToAccount('0x…'),\n * chain: mainnet,\n * transport: custom(window.ethereum),\n * })\n * const signature = await signMessage(client, {\n * message: 'hello world',\n * })\n */\nexport async function signMessage<\n chain extends Chain | undefined,\n account extends Account | undefined,\n>(\n client: Client<Transport, chain, account>,\n {\n account: account_ = client.account,\n message,\n }: SignMessageParameters<account>,\n): Promise<SignMessageReturnType> {\n if (!account_)\n throw new AccountNotFoundError({\n docsPath: '/docs/actions/wallet/signMessage',\n })\n const account = parseAccount(account_)\n\n if (account.signMessage) return account.signMessage({ message })\n\n const message_ = (() => {\n if (typeof message === 'string') return stringToHex(message)\n if (message.raw instanceof Uint8Array) return toHex(message.raw)\n return message.raw\n })()\n\n return client.request(\n {\n method: 'personal_sign',\n params: [message_, account.address],\n },\n { retryCount: 0 },\n )\n}\n", "import type { TypedData } from 'abitype'\n\nimport type { Account } from '../../accounts/types.js'\nimport {\n type ParseAccountErrorType,\n parseAccount,\n} from '../../accounts/utils/parseAccount.js'\nimport type { SignTypedDataErrorType as SignTypedDataErrorType_account } from '../../accounts/utils/signTypedData.js'\nimport type { Client } from '../../clients/createClient.js'\nimport type { Transport } from '../../clients/transports/createTransport.js'\nimport {\n AccountNotFoundError,\n type AccountNotFoundErrorType,\n} from '../../errors/account.js'\nimport type { ErrorType } from '../../errors/utils.js'\nimport type { GetAccountParameter } from '../../types/account.js'\nimport type { Chain } from '../../types/chain.js'\nimport type { Hex } from '../../types/misc.js'\nimport type { TypedDataDefinition } from '../../types/typedData.js'\nimport type { RequestErrorType } from '../../utils/buildRequest.js'\nimport type { IsHexErrorType } from '../../utils/data/isHex.js'\nimport type { StringifyErrorType } from '../../utils/stringify.js'\nimport {\n type GetTypesForEIP712DomainErrorType,\n type SerializeTypedDataErrorType,\n type ValidateTypedDataErrorType,\n getTypesForEIP712Domain,\n serializeTypedData,\n validateTypedData,\n} from '../../utils/typedData.js'\n\nexport type SignTypedDataParameters<\n typedData extends TypedData | Record<string, unknown> = TypedData,\n primaryType extends keyof typedData | 'EIP712Domain' = keyof typedData,\n account extends Account | undefined = undefined,\n ///\n primaryTypes = typedData extends TypedData ? keyof typedData : string,\n> = TypedDataDefinition<typedData, primaryType, primaryTypes> &\n GetAccountParameter<account>\n\nexport type SignTypedDataReturnType = Hex\n\nexport type SignTypedDataErrorType =\n | AccountNotFoundErrorType\n | ParseAccountErrorType\n | GetTypesForEIP712DomainErrorType\n | ValidateTypedDataErrorType\n | StringifyErrorType\n | SignTypedDataErrorType_account\n | IsHexErrorType\n | RequestErrorType\n | SerializeTypedDataErrorType\n | ErrorType\n\n/**\n * Signs typed data and calculates an Ethereum-specific signature in [https://eips.ethereum.org/EIPS/eip-712](https://eips.ethereum.org/EIPS/eip-712): `sign(keccak256(\"\\x19\\x01\" ‖ domainSeparator ‖ hashStruct(message)))`\n *\n * - Docs: https://viem.sh/docs/actions/wallet/signTypedData\n * - JSON-RPC Methods:\n * - JSON-RPC Accounts: [`eth_signTypedData_v4`](https://docs.metamask.io/guide/signing-data#signtypeddata-v4)\n * - Local Accounts: Signs locally. No JSON-RPC request.\n *\n * @param client - Client to use\n * @param parameters - {@link SignTypedDataParameters}\n * @returns The signed data. {@link SignTypedDataReturnType}\n *\n * @example\n * import { createWalletClient, custom } from 'viem'\n * import { mainnet } from 'viem/chains'\n * import { signTypedData } from 'viem/wallet'\n *\n * const client = createWalletClient({\n * chain: mainnet,\n * transport: custom(window.ethereum),\n * })\n * const signature = await signTypedData(client, {\n * account: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e',\n * domain: {\n * name: 'Ether Mail',\n * version: '1',\n * chainId: 1,\n * verifyingContract: '0xCcCCccccCCCCcCCCCCCcCcCccCcCCCcCcccccccC',\n * },\n * types: {\n * Person: [\n * { name: 'name', type: 'string' },\n * { name: 'wallet', type: 'address' },\n * ],\n * Mail: [\n * { name: 'from', type: 'Person' },\n * { name: 'to', type: 'Person' },\n * { name: 'contents', type: 'string' },\n * ],\n * },\n * primaryType: 'Mail',\n * message: {\n * from: {\n * name: 'Cow',\n * wallet: '0xCD2a3d9F938E13CD947Ec05AbC7FE734Df8DD826',\n * },\n * to: {\n * name: 'Bob',\n * wallet: '0xbBbBBBBbbBBBbbbBbbBbbbbBBbBbbbbBbBbbBBbB',\n * },\n * contents: 'Hello, Bob!',\n * },\n * })\n *\n * @example\n * // Account Hoisting\n * import { createWalletClient, http } from 'viem'\n * import { privateKeyToAccount } from 'viem/accounts'\n * import { mainnet } from 'viem/chains'\n * import { signTypedData } from 'viem/wallet'\n *\n * const client = createWalletClient({\n * account: privateKeyToAccount('0x…'),\n * chain: mainnet,\n * transport: http(),\n * })\n * const signature = await signTypedData(client, {\n * domain: {\n * name: 'Ether Mail',\n * version: '1',\n * chainId: 1,\n * verifyingContract: '0xCcCCccccCCCCcCCCCCCcCcCccCcCCCcCcccccccC',\n * },\n * types: {\n * Person: [\n * { name: 'name', type: 'string' },\n * { name: 'wallet', type: 'address' },\n * ],\n * Mail: [\n * { name: 'from', type: 'Person' },\n * { name: 'to', type: 'Person' },\n * { name: 'contents', type: 'string' },\n * ],\n * },\n * primaryType: 'Mail',\n * message: {\n * from: {\n * name: 'Cow',\n * wallet: '0xCD2a3d9F938E13CD947Ec05AbC7FE734Df8DD826',\n * },\n * to: {\n * name: 'Bob',\n * wallet: '0xbBbBBBBbbBBBbbbBbbBbbbbBBbBbbbbBbBbbBBbB',\n * },\n * contents: 'Hello, Bob!',\n * },\n * })\n */\nexport async function signTypedData<\n const typedData extends TypedData | Record<string, unknown>,\n primaryType extends keyof typedData | 'EIP712Domain',\n chain extends Chain | undefined,\n account extends Account | undefined,\n>(\n client: Client<Transport, chain, account>,\n parameters: SignTypedDataParameters<typedData, primaryType, account>,\n): Promise<SignTypedDataReturnType> {\n const {\n account: account_ = client.account,\n domain,\n message,\n primaryType,\n } = parameters as unknown as SignTypedDataParameters\n\n if (!account_)\n throw new AccountNotFoundError({\n docsPath: '/docs/actions/wallet/signTypedData',\n })\n const account = parseAccount(account_)\n\n const types = {\n EIP712Domain: getTypesForEIP712Domain({ domain }),\n ...parameters.types,\n }\n\n // Need to do a runtime validation check on addresses, byte ranges, integer ranges, etc\n // as we can't statically check this with TypeScript.\n validateTypedData({ domain, message, primaryType, types })\n\n if (account.signTypedData)\n return account.signTypedData({ domain, message, primaryType, types })\n\n const typedData = serializeTypedData({ domain, message, primaryType, types })\n return client.request(\n {\n method: 'eth_signTypedData_v4',\n params: [account.address, typedData],\n },\n { retryCount: 0 },\n )\n}\n", "import type { Abi, AbiFunction, AbiStateMutability, Address } from 'abitype'\n\nimport {\n type ParseAccountErrorType,\n parseAccount,\n} from '../../accounts/utils/parseAccount.js'\nimport type { Client } from '../../clients/createClient.js'\nimport type { Transport } from '../../clients/transports/createTransport.js'\nimport type { BaseError } from '../../errors/base.js'\nimport type { ErrorType } from '../../errors/utils.js'\nimport type { Account, ParseAccount } from '../../types/account.js'\nimport type { Chain, DeriveChain } from '../../types/chain.js'\nimport type {\n ContractFunctionArgs,\n ContractFunctionName,\n ContractFunctionParameters,\n ContractFunctionReturnType,\n ExtractAbiFunctionForArgs,\n} from '../../types/contract.js'\nimport type { Hex } from '../../types/misc.js'\nimport type {\n IsNarrowable,\n NoInfer,\n Prettify,\n UnionEvaluate,\n UnionOmit,\n} from '../../types/utils.js'\nimport {\n type DecodeFunctionResultErrorType,\n decodeFunctionResult,\n} from '../../utils/abi/decodeFunctionResult.js'\nimport {\n type EncodeFunctionDataErrorType,\n encodeFunctionData,\n} from '../../utils/abi/encodeFunctionData.js'\nimport {\n type GetContractErrorReturnType,\n getContractError,\n} from '../../utils/errors/getContractError.js'\nimport type { WriteContractParameters } from '../wallet/writeContract.js'\n\nimport type { TransactionRequest } from '../../types/transaction.js'\nimport { getAction } from '../../utils/getAction.js'\nimport { type CallErrorType, type CallParameters, call } from './call.js'\n\nexport type GetMutabilityAwareValue<\n abi extends Abi | readonly unknown[],\n mutability extends AbiStateMutability = AbiStateMutability,\n functionName extends ContractFunctionName<\n abi,\n mutability\n > = ContractFunctionName<abi, mutability>,\n valueType = TransactionRequest['value'],\n args extends ContractFunctionArgs<\n abi,\n mutability,\n functionName\n > = ContractFunctionArgs<abi, mutability, functionName>,\n abiFunction extends AbiFunction = abi extends Abi\n ? ExtractAbiFunctionForArgs<abi, mutability, functionName, args>\n : AbiFunction,\n _Narrowable extends boolean = IsNarrowable<abi, Abi>,\n> = _Narrowable extends true\n ? abiFunction['stateMutability'] extends 'payable'\n ? { value?: NoInfer<valueType> | undefined }\n : abiFunction['payable'] extends true\n ? { value?: NoInfer<valueType> | undefined }\n : { value?: undefined }\n : { value?: NoInfer<valueType> | undefined }\n\nexport type SimulateContractParameters<\n abi extends Abi | readonly unknown[] = Abi,\n functionName extends ContractFunctionName<\n abi,\n 'nonpayable' | 'payable'\n > = ContractFunctionName<abi, 'nonpayable' | 'payable'>,\n args extends ContractFunctionArgs<\n abi,\n 'nonpayable' | 'payable',\n functionName\n > = ContractFunctionArgs<abi, 'nonpayable' | 'payable', functionName>,\n chain extends Chain | undefined = Chain | undefined,\n chainOverride extends Chain | undefined = Chain | undefined,\n accountOverride extends Account | Address | null | undefined = undefined,\n ///\n derivedChain extends Chain | undefined = DeriveChain<chain, chainOverride>,\n> = {\n account?: accountOverride | null | undefined\n chain?: chainOverride | undefined\n /** Data to append to the end of the calldata. Useful for adding a [\"domain\" tag](https://opensea.notion.site/opensea/Seaport-Order-Attributions-ec2d69bf455041a5baa490941aad307f). */\n dataSuffix?: Hex | undefined\n} & ContractFunctionParameters<\n abi,\n 'nonpayable' | 'payable',\n functionName,\n args\n> &\n UnionOmit<\n CallParameters<derivedChain>,\n | 'account'\n | 'batch'\n | 'code'\n | 'to'\n | 'data'\n | 'factory'\n | 'factoryData'\n | 'value'\n > &\n GetMutabilityAwareValue<\n abi,\n 'nonpayable' | 'payable',\n functionName,\n CallParameters<derivedChain> extends CallParameters\n ? CallParameters<derivedChain>['value']\n : CallParameters['value'],\n args\n >\n\nexport type SimulateContractReturnType<\n out abi extends Abi | readonly unknown[] = Abi,\n in out functionName extends ContractFunctionName<\n abi,\n 'nonpayable' | 'payable'\n > = ContractFunctionName<abi, 'nonpayable' | 'payable'>,\n in out args extends ContractFunctionArgs<\n abi,\n 'nonpayable' | 'payable',\n functionName\n > = ContractFunctionArgs<abi, 'nonpayable' | 'payable', functionName>,\n /** @ts-expect-error cast variance */\n out chain extends Chain | undefined = Chain | undefined,\n out account extends Account | undefined = Account | undefined,\n out chainOverride extends Chain | undefined = Chain | undefined,\n out accountOverride extends Account | Address | null | undefined =\n | Account\n | Address\n | null\n | undefined,\n ///\n in out minimizedAbi extends Abi = readonly [\n ExtractAbiFunctionForArgs<\n abi extends Abi ? abi : Abi,\n 'nonpayable' | 'payable',\n functionName,\n args\n >,\n ],\n out resolvedAccount extends\n | Account\n | null\n | undefined = accountOverride extends Account | Address | null\n ? ParseAccount<accountOverride>\n : account,\n> = {\n result: ContractFunctionReturnType<\n minimizedAbi,\n 'nonpayable' | 'payable',\n functionName,\n args\n >\n request: Prettify<\n UnionEvaluate<\n UnionOmit<\n WriteContractParameters<\n minimizedAbi,\n functionName,\n args,\n chain,\n undefined,\n chainOverride\n >,\n 'account' | 'abi' | 'args' | 'chain' | 'functionName'\n >\n > &\n ContractFunctionParameters<\n minimizedAbi,\n 'nonpayable' | 'payable',\n functionName,\n args\n > & {\n chain: DeriveChain<chain, chainOverride>\n } & (resolvedAccount extends Account | null\n ? { account: resolvedAccount }\n : { account?: undefined })\n >\n}\n\nexport type SimulateContractErrorType =\n | ParseAccountErrorType\n | EncodeFunctionDataErrorType\n | GetContractErrorReturnType<CallErrorType | DecodeFunctionResultErrorType>\n | ErrorType\n\n/**\n * Simulates/validates a contract interaction. This is useful for retrieving **return data** and **revert reasons** of contract write functions.\n *\n * - Docs: https://viem.sh/docs/contract/simulateContract\n * - Examples: https://stackblitz.com/github/wevm/viem/tree/main/examples/contracts_writing-to-contracts\n *\n * This function does not require gas to execute and _**does not**_ change the state of the blockchain. It is almost identical to [`readContract`](https://viem.sh/docs/contract/readContract), but also supports contract write functions.\n *\n * Internally, uses a [Public Client](https://viem.sh/docs/clients/public) to call the [`call` action](https://viem.sh/docs/actions/public/call) with [ABI-encoded `data`](https://viem.sh/docs/contract/encodeFunctionData).\n *\n * @param client - Client to use\n * @param parameters - {@link SimulateContractParameters}\n * @returns The simulation result and write request. {@link SimulateContractReturnType}\n *\n * @example\n * import { createPublicClient, http } from 'viem'\n * import { mainnet } from 'viem/chains'\n * import { simulateContract } from 'viem/contract'\n *\n * const client = createPublicClient({\n * chain: mainnet,\n * transport: http(),\n * })\n * const result = await simulateContract(client, {\n * address: '0xFBA3912Ca04dd458c843e2EE08967fC04f3579c2',\n * abi: parseAbi(['function mint(uint32) view returns (uint32)']),\n * functionName: 'mint',\n * args: ['69420'],\n * account: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e',\n * })\n */\nexport async function simulateContract<\n chain extends Chain | undefined,\n account extends Account | undefined,\n const abi extends Abi | readonly unknown[],\n functionName extends ContractFunctionName<abi, 'nonpayable' | 'payable'>,\n const args extends ContractFunctionArgs<\n abi,\n 'nonpayable' | 'payable',\n functionName\n >,\n chainOverride extends Chain | undefined = undefined,\n accountOverride extends Account | Address | null | undefined = undefined,\n>(\n client: Client<Transport, chain, account>,\n parameters: SimulateContractParameters<\n abi,\n functionName,\n args,\n chain,\n chainOverride,\n accountOverride\n >,\n): Promise<\n SimulateContractReturnType<\n abi,\n functionName,\n args,\n chain,\n account,\n chainOverride,\n accountOverride\n >\n> {\n const { abi, address, args, dataSuffix, functionName, ...callRequest } =\n parameters as SimulateContractParameters\n\n const account = callRequest.account\n ? parseAccount(callRequest.account)\n : client.account\n const calldata = encodeFunctionData({ abi, args, functionName })\n try {\n const { data } = await getAction(\n client,\n call,\n 'call',\n )({\n batch: false,\n data: `${calldata}${dataSuffix ? dataSuffix.replace('0x', '') : ''}`,\n to: address,\n ...callRequest,\n account,\n })\n const result = decodeFunctionResult({\n abi,\n args,\n functionName,\n data: data || '0x',\n })\n const minimizedAbi = abi.filter(\n (abiItem) =>\n 'name' in abiItem && abiItem.name === parameters.functionName,\n )\n return {\n result,\n request: {\n abi: minimizedAbi,\n address,\n args,\n dataSuffix,\n functionName,\n ...callRequest,\n account,\n },\n } as unknown as SimulateContractReturnType<\n abi,\n functionName,\n args,\n chain,\n account,\n chainOverride,\n accountOverride\n >\n } catch (error) {\n throw getContractError(error as BaseError, {\n abi,\n address,\n args,\n docsPath: '/docs/contract/simulateContract',\n functionName,\n sender: account?.address,\n })\n }\n}\n", "import type { Account } from '../../accounts/types.js'\nimport type { Client } from '../../clients/createClient.js'\nimport type { Transport } from '../../clients/transports/createTransport.js'\nimport type { ErrorType } from '../../errors/utils.js'\nimport type { Chain } from '../../types/chain.js'\nimport type { RequestErrorType } from '../../utils/buildRequest.js'\nimport {\n type NumberToHexErrorType,\n numberToHex,\n} from '../../utils/encoding/toHex.js'\n\nexport type SwitchChainParameters = {\n /** ID of Chain to switch to */\n id: Chain['id']\n}\n\nexport type SwitchChainErrorType =\n | NumberToHexErrorType\n | RequestErrorType\n | ErrorType\n\n/**\n * Switch the target chain in a wallet.\n *\n * - Docs: https://viem.sh/docs/actions/wallet/switchChain\n * - JSON-RPC Methods: [`eth_switchEthereumChain`](https://eips.ethereum.org/EIPS/eip-3326)\n *\n * @param client - Client to use\n * @param parameters - {@link SwitchChainParameters}\n *\n * @example\n * import { createWalletClient, custom } from 'viem'\n * import { mainnet, optimism } from 'viem/chains'\n * import { switchChain } from 'viem/wallet'\n *\n * const client = createWalletClient({\n * chain: mainnet,\n * transport: custom(window.ethereum),\n * })\n * await switchChain(client, { id: optimism.id })\n */\nexport async function switchChain<\n chain extends Chain | undefined,\n account extends Account | undefined = undefined,\n>(client: Client<Transport, chain, account>, { id }: SwitchChainParameters) {\n await client.request(\n {\n method: 'wallet_switchEthereumChain',\n params: [\n {\n chainId: numberToHex(id),\n },\n ],\n },\n { retryCount: 0 },\n )\n}\n", "import { secp256k1 } from '@noble/curves/secp256k1'\n\nimport type { ErrorType } from '../../errors/utils.js'\nimport type { ByteArray, Hex, Signature } from '../../types/misc.js'\nimport { type HexToBigIntErrorType, hexToBigInt } from '../encoding/fromHex.js'\nimport { hexToBytes } from '../encoding/toBytes.js'\nimport type { ToHexErrorType } from '../encoding/toHex.js'\n\ntype To = 'bytes' | 'hex'\n\nexport type SerializeSignatureParameters<to extends To = 'hex'> = Signature & {\n to?: to | To | undefined\n}\n\nexport type SerializeSignatureReturnType<to extends To = 'hex'> =\n | (to extends 'hex' ? Hex : never)\n | (to extends 'bytes' ? ByteArray : never)\n\nexport type SerializeSignatureErrorType =\n | HexToBigIntErrorType\n | ToHexErrorType\n | ErrorType\n\n/**\n * @description Converts a signature into hex format.\n *\n * @param signature The signature to convert.\n * @returns The signature in hex format.\n *\n * @example\n * serializeSignature({\n * r: '0x6e100a352ec6ad1b70802290e18aeed190704973570f3b8ed42cb9808e2ea6bf',\n * s: '0x4a90a229a244495b41890987806fcbd2d5d23fc0dbe5f5256c2613c039d76db8',\n * yParity: 1\n * })\n * // \"0x6e100a352ec6ad1b70802290e18aeed190704973570f3b8ed42cb9808e2ea6bf4a90a229a244495b41890987806fcbd2d5d23fc0dbe5f5256c2613c039d76db81c\"\n */\nexport function serializeSignature<to extends To = 'hex'>({\n r,\n s,\n to = 'hex',\n v,\n yParity,\n}: SerializeSignatureParameters<to>): SerializeSignatureReturnType<to> {\n const yParity_ = (() => {\n if (yParity === 0 || yParity === 1) return yParity\n if (v && (v === 27n || v === 28n || v >= 35n)) return v % 2n === 0n ? 1 : 0\n throw new Error('Invalid `v` or `yParity` value')\n })()\n const signature = `0x${new secp256k1.Signature(\n hexToBigInt(r),\n hexToBigInt(s),\n ).toCompactHex()}${yParity_ === 0 ? '1b' : '1c'}` as const\n\n if (to === 'hex') return signature as SerializeSignatureReturnType<to>\n return hexToBytes(signature) as SerializeSignatureReturnType<to>\n}\n", "import type { Address } from 'abitype'\n\nimport type { Client } from '../../clients/createClient.js'\nimport type { Transport } from '../../clients/transports/createTransport.js'\nimport { universalSignatureValidatorAbi } from '../../constants/abis.js'\nimport { universalSignatureValidatorByteCode } from '../../constants/contracts.js'\nimport { CallExecutionError } from '../../errors/contract.js'\nimport type { InvalidHexBooleanError } from '../../errors/encoding.js'\nimport type { ErrorType } from '../../errors/utils.js'\nimport type { Chain } from '../../types/chain.js'\nimport type { ByteArray, Hex, Signature } from '../../types/misc.js'\nimport type { OneOf } from '../../types/utils.js'\nimport {\n type EncodeDeployDataErrorType,\n encodeDeployData,\n} from '../../utils/abi/encodeDeployData.js'\nimport { getAddress } from '../../utils/address/getAddress.js'\nimport { isAddressEqual } from '../../utils/address/isAddressEqual.js'\nimport { type IsHexErrorType, isHex } from '../../utils/data/isHex.js'\nimport { type ToHexErrorType, bytesToHex } from '../../utils/encoding/toHex.js'\nimport { getAction } from '../../utils/getAction.js'\nimport { encodeFunctionData, hexToBool } from '../../utils/index.js'\nimport { isErc6492Signature } from '../../utils/signature/isErc6492Signature.js'\nimport { recoverAddress } from '../../utils/signature/recoverAddress.js'\nimport { serializeErc6492Signature } from '../../utils/signature/serializeErc6492Signature.js'\nimport { serializeSignature } from '../../utils/signature/serializeSignature.js'\nimport { type CallErrorType, type CallParameters, call } from './call.js'\n\nexport type VerifyHashParameters = Pick<\n CallParameters,\n 'blockNumber' | 'blockTag'\n> & {\n /** The address that signed the original message. */\n address: Address\n /** The hash to be verified. */\n hash: Hex\n /** The signature that was generated by signing the message with the address's private key. */\n signature: Hex | ByteArray | Signature\n universalSignatureVerifierAddress?: Address | undefined\n} & OneOf<{ factory: Address; factoryData: Hex } | {}>\n\nexport type VerifyHashReturnType = boolean\n\nexport type VerifyHashErrorType =\n | CallErrorType\n | IsHexErrorType\n | ToHexErrorType\n | InvalidHexBooleanError\n | EncodeDeployDataErrorType\n | ErrorType\n\n/**\n * Verifies a message hash onchain using ERC-6492.\n *\n * @param client - Client to use.\n * @param parameters - {@link VerifyHashParameters}\n * @returns Whether or not the signature is valid. {@link VerifyHashReturnType}\n */\nexport async function verifyHash<chain extends Chain | undefined>(\n client: Client<Transport, chain>,\n parameters: VerifyHashParameters,\n): Promise<VerifyHashReturnType> {\n const {\n address,\n factory,\n factoryData,\n hash,\n signature,\n universalSignatureVerifierAddress = client.chain?.contracts\n ?.universalSignatureVerifier?.address,\n ...rest\n } = parameters\n\n const signatureHex = (() => {\n if (isHex(signature)) return signature\n if (typeof signature === 'object' && 'r' in signature && 's' in signature)\n return serializeSignature(signature)\n return bytesToHex(signature)\n })()\n\n const wrappedSignature = await (async () => {\n // If no `factory` or `factoryData` is provided, it is assumed that the\n // address is not a Smart Account, or the Smart Account is already deployed.\n if (!factory && !factoryData) return signatureHex\n\n // If the signature is already wrapped, return the signature.\n if (isErc6492Signature(signatureHex)) return signatureHex\n\n // If the Smart Account is not deployed, wrap the signature with a 6492 wrapper\n // to perform counterfactual validation.\n return serializeErc6492Signature({\n address: factory!,\n data: factoryData!,\n signature: signatureHex,\n })\n })()\n\n try {\n const args = universalSignatureVerifierAddress\n ? ({\n to: universalSignatureVerifierAddress,\n data: encodeFunctionData({\n abi: universalSignatureValidatorAbi,\n functionName: 'isValidSig',\n args: [address, hash, wrappedSignature],\n }),\n ...rest,\n } as unknown as CallParameters)\n : ({\n data: encodeDeployData({\n abi: universalSignatureValidatorAbi,\n args: [address, hash, wrappedSignature],\n bytecode: universalSignatureValidatorByteCode,\n }),\n ...rest,\n } as unknown as CallParameters)\n\n const { data } = await getAction(client, call, 'call')(args)\n\n return hexToBool(data ?? '0x0')\n } catch (error) {\n // Fallback attempt to verify the signature via ECDSA recovery.\n try {\n const verified = isAddressEqual(\n getAddress(address),\n await recoverAddress({ hash, signature }),\n )\n if (verified) return true\n } catch {}\n\n if (error instanceof CallExecutionError) {\n // if the execution fails, the signature was not valid and an internal method inside of the validator reverted\n // this can happen for many reasons, for example if signer can not be recovered from the signature\n // or if the signature has no valid format\n return false\n }\n\n throw error\n }\n}\n", "import type { Address } from 'abitype'\n\nimport type { Client } from '../../clients/createClient.js'\nimport type { Transport } from '../../clients/transports/createTransport.js'\nimport type { ErrorType } from '../../errors/utils.js'\nimport type { Chain } from '../../types/chain.js'\nimport type {\n ByteArray,\n Hex,\n SignableMessage,\n Signature,\n} from '../../types/misc.js'\nimport type { Prettify } from '../../types/utils.js'\nimport { hashMessage } from '../../utils/signature/hashMessage.js'\nimport type { HashMessageErrorType } from '../../utils/signature/hashMessage.js'\nimport {\n type VerifyHashErrorType,\n type VerifyHashParameters,\n verifyHash,\n} from './verifyHash.js'\n\nexport type VerifyMessageParameters = Prettify<\n Omit<VerifyHashParameters, 'hash'> & {\n /** The address that signed the original message. */\n address: Address\n /** The message to be verified. */\n message: SignableMessage\n /** The signature that was generated by signing the message with the address's private key. */\n signature: Hex | ByteArray | Signature\n }\n>\n\nexport type VerifyMessageReturnType = boolean\n\nexport type VerifyMessageErrorType =\n | HashMessageErrorType\n | VerifyHashErrorType\n | ErrorType\n\n/**\n * Verify that a message was signed by the provided address.\n *\n * Compatible with Smart Contract Accounts & Externally Owned Accounts via [ERC-6492](https://eips.ethereum.org/EIPS/eip-6492).\n *\n * - Docs {@link https://viem.sh/docs/actions/public/verifyMessage}\n *\n * @param client - Client to use.\n * @param parameters - {@link VerifyMessageParameters}\n * @returns Whether or not the signature is valid. {@link VerifyMessageReturnType}\n */\nexport async function verifyMessage<chain extends Chain | undefined>(\n client: Client<Transport, chain>,\n {\n address,\n message,\n factory,\n factoryData,\n signature,\n ...callRequest\n }: VerifyMessageParameters,\n): Promise<VerifyMessageReturnType> {\n const hash = hashMessage(message)\n return verifyHash(client, {\n address,\n factory: factory!,\n factoryData: factoryData!,\n hash,\n signature,\n ...callRequest,\n })\n}\n", "import type { Address, TypedData } from 'abitype'\n\nimport type { Client } from '../../clients/createClient.js'\nimport type { Transport } from '../../clients/transports/createTransport.js'\nimport type { ErrorType } from '../../errors/utils.js'\nimport type { Chain } from '../../types/chain.js'\nimport type { ByteArray, Hex, Signature } from '../../types/misc.js'\nimport type { TypedDataDefinition } from '../../types/typedData.js'\nimport {\n type HashTypedDataErrorType,\n hashTypedData,\n} from '../../utils/signature/hashTypedData.js'\nimport {\n type VerifyHashErrorType,\n type VerifyHashParameters,\n verifyHash,\n} from './verifyHash.js'\n\nexport type VerifyTypedDataParameters<\n typedData extends TypedData | Record<string, unknown> = TypedData,\n primaryType extends keyof typedData | 'EIP712Domain' = keyof typedData,\n> = Omit<VerifyHashParameters, 'hash'> &\n TypedDataDefinition<typedData, primaryType> & {\n /** The address to verify the typed data for. */\n address: Address\n /** The signature to verify */\n signature: Hex | ByteArray | Signature\n }\n\nexport type VerifyTypedDataReturnType = boolean\n\nexport type VerifyTypedDataErrorType =\n | HashTypedDataErrorType\n | VerifyHashErrorType\n | ErrorType\n\n/**\n * Verify that typed data was signed by the provided address.\n *\n * - Docs {@link https://viem.sh/docs/actions/public/verifyTypedData}\n *\n * @param client - Client to use.\n * @param parameters - {@link VerifyTypedDataParameters}\n * @returns Whether or not the signature is valid. {@link VerifyTypedDataReturnType}\n */\nexport async function verifyTypedData<\n const typedData extends TypedData | Record<string, unknown>,\n primaryType extends keyof typedData | 'EIP712Domain',\n chain extends Chain | undefined,\n>(\n client: Client<Transport, chain>,\n parameters: VerifyTypedDataParameters<typedData, primaryType>,\n): Promise<VerifyTypedDataReturnType> {\n const {\n address,\n factory,\n factoryData,\n signature,\n message,\n primaryType,\n types,\n domain,\n ...callRequest\n } = parameters as VerifyTypedDataParameters\n const hash = hashTypedData({ message, primaryType, types, domain })\n return verifyHash(client, {\n address,\n factory: factory!,\n factoryData: factoryData!,\n hash,\n signature,\n ...callRequest,\n })\n}\n", "import type { Account } from '../../accounts/types.js'\nimport type { Client } from '../../clients/createClient.js'\nimport type { Transport } from '../../clients/transports/createTransport.js'\nimport type { ErrorType } from '../../errors/utils.js'\nimport type { Chain } from '../../types/chain.js'\nimport type { WatchAssetParams } from '../../types/eip1193.js'\nimport type { RequestErrorType } from '../../utils/buildRequest.js'\n\nexport type WatchAssetParameters = WatchAssetParams\nexport type WatchAssetReturnType = boolean\nexport type WatchAssetErrorType = RequestErrorType | ErrorType\n\n/**\n * Adds an EVM chain to the wallet.\n *\n * - Docs: https://viem.sh/docs/actions/wallet/watchAsset\n * - JSON-RPC Methods: [`eth_switchEthereumChain`](https://eips.ethereum.org/EIPS/eip-747)\n *\n * @param client - Client to use\n * @param parameters - {@link WatchAssetParameters}\n * @returns Boolean indicating if the token was successfully added. {@link WatchAssetReturnType}\n *\n * @example\n * import { createWalletClient, custom } from 'viem'\n * import { mainnet } from 'viem/chains'\n * import { watchAsset } from 'viem/wallet'\n *\n * const client = createWalletClient({\n * chain: mainnet,\n * transport: custom(window.ethereum),\n * })\n * const success = await watchAsset(client, {\n * type: 'ERC20',\n * options: {\n * address: '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',\n * decimals: 18,\n * symbol: 'WETH',\n * },\n * })\n */\nexport async function watchAsset<\n chain extends Chain | undefined,\n account extends Account | undefined = undefined,\n>(\n client: Client<Transport, chain, account>,\n params: WatchAssetParameters,\n): Promise<WatchAssetReturnType> {\n const added = await client.request(\n {\n method: 'wallet_watchAsset',\n params,\n },\n { retryCount: 0 },\n )\n return added\n}\n", "import type { Abi, Address, ExtractAbiEvent } from 'abitype'\n\nimport type { Client } from '../../clients/createClient.js'\nimport type { Transport } from '../../clients/transports/createTransport.js'\nimport type { Chain } from '../../types/chain.js'\nimport type { Filter } from '../../types/filter.js'\nimport type { Log } from '../../types/log.js'\n\nimport {\n DecodeLogDataMismatch,\n DecodeLogTopicsMismatch,\n} from '../../errors/abi.js'\nimport { InvalidInputRpcError } from '../../errors/rpc.js'\nimport type { ErrorType } from '../../errors/utils.js'\nimport type { BlockNumber } from '../../types/block.js'\nimport type {\n ContractEventArgs,\n ContractEventName,\n} from '../../types/contract.js'\nimport type { LogTopic } from '../../types/misc.js'\nimport type { GetPollOptions } from '../../types/transport.js'\nimport { decodeEventLog } from '../../utils/abi/decodeEventLog.js'\nimport {\n type EncodeEventTopicsParameters,\n encodeEventTopics,\n} from '../../utils/abi/encodeEventTopics.js'\nimport { formatLog } from '../../utils/formatters/log.js'\nimport { getAction } from '../../utils/getAction.js'\nimport { type ObserveErrorType, observe } from '../../utils/observe.js'\nimport { poll } from '../../utils/poll.js'\nimport { type StringifyErrorType, stringify } from '../../utils/stringify.js'\nimport { createContractEventFilter } from './createContractEventFilter.js'\nimport { getBlockNumber } from './getBlockNumber.js'\nimport {\n type GetContractEventsParameters,\n getContractEvents,\n} from './getContractEvents.js'\nimport { getFilterChanges } from './getFilterChanges.js'\nimport { uninstallFilter } from './uninstallFilter.js'\n\nexport type WatchContractEventOnLogsParameter<\n abi extends Abi | readonly unknown[] = Abi,\n eventName extends ContractEventName<abi> = ContractEventName<abi>,\n strict extends boolean | undefined = undefined,\n> = abi extends Abi\n ? Abi extends abi\n ? Log[]\n : Log<bigint, number, false, ExtractAbiEvent<abi, eventName>, strict>[]\n : Log[]\n\nexport type WatchContractEventOnLogsFn<\n abi extends Abi | readonly unknown[] = Abi,\n eventName extends ContractEventName<abi> = ContractEventName<abi>,\n strict extends boolean | undefined = undefined,\n> = (logs: WatchContractEventOnLogsParameter<abi, eventName, strict>) => void\n\nexport type WatchContractEventParameters<\n abi extends Abi | readonly unknown[] = Abi,\n eventName extends ContractEventName<abi> | undefined = ContractEventName<abi>,\n strict extends boolean | undefined = undefined,\n transport extends Transport = Transport,\n> = {\n /** The address of the contract. */\n address?: Address | Address[] | undefined\n /** Contract ABI. */\n abi: abi\n args?:\n | ContractEventArgs<\n abi,\n eventName extends ContractEventName<abi>\n ? eventName\n : ContractEventName<abi>\n >\n | undefined\n /** Contract event. */\n eventName?: eventName | ContractEventName<abi> | undefined\n /** Block to start listening from. */\n fromBlock?: BlockNumber<bigint> | undefined\n /** The callback to call when an error occurred when trying to get for a new block. */\n onError?: ((error: Error) => void) | undefined\n /** The callback to call when new event logs are received. */\n onLogs: WatchContractEventOnLogsFn<\n abi,\n eventName extends ContractEventName<abi>\n ? eventName\n : ContractEventName<abi>,\n strict\n >\n /**\n * Whether or not the logs must match the indexed/non-indexed arguments on `event`.\n * @default false\n */\n strict?: strict | boolean | undefined\n} & GetPollOptions<transport>\n\nexport type WatchContractEventReturnType = () => void\n\nexport type WatchContractEventErrorType =\n | StringifyErrorType\n | ObserveErrorType\n | ErrorType\n\n/**\n * Watches and returns emitted contract event logs.\n *\n * - Docs: https://viem.sh/docs/contract/watchContractEvent\n *\n * This Action will batch up all the event logs found within the [`pollingInterval`](https://viem.sh/docs/contract/watchContractEvent#pollinginterval-optional), and invoke them via [`onLogs`](https://viem.sh/docs/contract/watchContractEvent#onLogs).\n *\n * `watchContractEvent` will attempt to create an [Event Filter](https://viem.sh/docs/contract/createContractEventFilter) and listen to changes to the Filter per polling interval, however, if the RPC Provider does not support Filters (e.g. `eth_newFilter`), then `watchContractEvent` will fall back to using [`getLogs`](https://viem.sh/docs/actions/public/getLogs) instead.\n *\n * @param client - Client to use\n * @param parameters - {@link WatchContractEventParameters}\n * @returns A function that can be invoked to stop watching for new event logs. {@link WatchContractEventReturnType}\n *\n * @example\n * import { createPublicClient, http, parseAbi } from 'viem'\n * import { mainnet } from 'viem/chains'\n * import { watchContractEvent } from 'viem/contract'\n *\n * const client = createPublicClient({\n * chain: mainnet,\n * transport: http(),\n * })\n * const unwatch = watchContractEvent(client, {\n * address: '0xFBA3912Ca04dd458c843e2EE08967fC04f3579c2',\n * abi: parseAbi(['event Transfer(address indexed from, address indexed to, uint256 value)']),\n * eventName: 'Transfer',\n * args: { from: '0xc961145a54C96E3aE9bAA048c4F4D6b04C13916b' },\n * onLogs: (logs) => console.log(logs),\n * })\n */\nexport function watchContractEvent<\n chain extends Chain | undefined,\n const abi extends Abi | readonly unknown[],\n eventName extends ContractEventName<abi> | undefined = undefined,\n strict extends boolean | undefined = undefined,\n transport extends Transport = Transport,\n>(\n client: Client<transport, chain>,\n parameters: WatchContractEventParameters<abi, eventName, strict, transport>,\n): WatchContractEventReturnType {\n const {\n abi,\n address,\n args,\n batch = true,\n eventName,\n fromBlock,\n onError,\n onLogs,\n poll: poll_,\n pollingInterval = client.pollingInterval,\n strict: strict_,\n } = parameters\n\n const enablePolling = (() => {\n if (typeof poll_ !== 'undefined') return poll_\n if (typeof fromBlock === 'bigint') return true\n if (client.transport.type === 'webSocket') return false\n if (\n client.transport.type === 'fallback' &&\n client.transport.transports[0].config.type === 'webSocket'\n )\n return false\n return true\n })()\n\n const pollContractEvent = () => {\n const strict = strict_ ?? false\n const observerId = stringify([\n 'watchContractEvent',\n address,\n args,\n batch,\n client.uid,\n eventName,\n pollingInterval,\n strict,\n fromBlock,\n ])\n\n return observe(observerId, { onLogs, onError }, (emit) => {\n let previousBlockNumber: bigint\n if (fromBlock !== undefined) previousBlockNumber = fromBlock - 1n\n let filter: Filter<'event', abi, eventName> | undefined\n let initialized = false\n\n const unwatch = poll(\n async () => {\n if (!initialized) {\n try {\n filter = (await getAction(\n client,\n createContractEventFilter,\n 'createContractEventFilter',\n )({\n abi,\n address,\n args: args as any,\n eventName: eventName as any,\n strict: strict as any,\n fromBlock,\n })) as Filter<'event', abi, eventName>\n } catch {}\n initialized = true\n return\n }\n\n try {\n let logs: Log[]\n if (filter) {\n logs = await getAction(\n client,\n getFilterChanges,\n 'getFilterChanges',\n )({ filter })\n } else {\n // If the filter doesn't exist, we will fall back to use `getLogs`.\n // The fall back exists because some RPC Providers do not support filters.\n\n // Fetch the block number to use for `getLogs`.\n const blockNumber = await getAction(\n client,\n getBlockNumber,\n 'getBlockNumber',\n )({})\n\n // If the block number has changed, we will need to fetch the logs.\n // If the block number doesn't exist, we are yet to reach the first poll interval,\n // so do not emit any logs.\n if (previousBlockNumber && previousBlockNumber < blockNumber) {\n logs = await getAction(\n client,\n getContractEvents,\n 'getContractEvents',\n )({\n abi,\n address,\n args,\n eventName,\n fromBlock: previousBlockNumber + 1n,\n toBlock: blockNumber,\n strict,\n } as {} as GetContractEventsParameters)\n } else {\n logs = []\n }\n previousBlockNumber = blockNumber\n }\n\n if (logs.length === 0) return\n if (batch) emit.onLogs(logs as any)\n else for (const log of logs) emit.onLogs([log] as any)\n } catch (err) {\n // If a filter has been set and gets uninstalled, providers will throw an InvalidInput error.\n // Reinitialize the filter when this occurs\n if (filter && err instanceof InvalidInputRpcError)\n initialized = false\n emit.onError?.(err as Error)\n }\n },\n {\n emitOnBegin: true,\n interval: pollingInterval,\n },\n )\n\n return async () => {\n if (filter)\n await getAction(\n client,\n uninstallFilter,\n 'uninstallFilter',\n )({ filter })\n unwatch()\n }\n })\n }\n\n const subscribeContractEvent = () => {\n const strict = strict_ ?? false\n const observerId = stringify([\n 'watchContractEvent',\n address,\n args,\n batch,\n client.uid,\n eventName,\n pollingInterval,\n strict,\n ])\n\n let active = true\n let unsubscribe = () => (active = false)\n return observe(observerId, { onLogs, onError }, (emit) => {\n ;(async () => {\n try {\n const transport = (() => {\n if (client.transport.type === 'fallback') {\n const transport = client.transport.transports.find(\n (transport: ReturnType<Transport>) =>\n transport.config.type === 'webSocket',\n )\n if (!transport) return client.transport\n return transport.value\n }\n return client.transport\n })()\n\n const topics: LogTopic[] = eventName\n ? encodeEventTopics({\n abi: abi,\n eventName: eventName,\n args,\n } as EncodeEventTopicsParameters)\n : []\n\n const { unsubscribe: unsubscribe_ } = await transport.subscribe({\n params: ['logs', { address, topics }],\n onData(data: any) {\n if (!active) return\n const log = data.result\n try {\n const { eventName, args } = decodeEventLog({\n abi: abi,\n data: log.data,\n topics: log.topics as any,\n strict: strict_,\n })\n const formatted = formatLog(log, {\n args,\n eventName: eventName as string,\n })\n emit.onLogs([formatted] as any)\n } catch (err) {\n let eventName: string | undefined\n let isUnnamed: boolean | undefined\n if (\n err instanceof DecodeLogDataMismatch ||\n err instanceof DecodeLogTopicsMismatch\n ) {\n // If strict mode is on, and log data/topics do not match event definition, skip.\n if (strict_) return\n eventName = err.abiItem.name\n isUnnamed = err.abiItem.inputs?.some(\n (x) => !('name' in x && x.name),\n )\n }\n\n // Set args to empty if there is an error decoding (e.g. indexed/non-indexed params mismatch).\n const formatted = formatLog(log, {\n args: isUnnamed ? [] : {},\n eventName,\n })\n emit.onLogs([formatted] as any)\n }\n },\n onError(error: Error) {\n emit.onError?.(error)\n },\n })\n unsubscribe = unsubscribe_\n if (!active) unsubscribe()\n } catch (err) {\n onError?.(err as Error)\n }\n })()\n return () => unsubscribe()\n })\n }\n\n return enablePolling ? pollContractEvent() : subscribeContractEvent()\n}\n", "import type { Abi, Address } from 'abitype'\n\nimport type { Account } from '../../accounts/types.js'\nimport {\n type ParseAccountErrorType,\n parseAccount,\n} from '../../accounts/utils/parseAccount.js'\nimport type { Client } from '../../clients/createClient.js'\nimport type { Transport } from '../../clients/transports/createTransport.js'\nimport {\n AccountNotFoundError,\n type AccountNotFoundErrorType,\n} from '../../errors/account.js'\nimport type { BaseError } from '../../errors/base.js'\nimport type { ErrorType } from '../../errors/utils.js'\nimport type { GetAccountParameter } from '../../types/account.js'\nimport type {\n Chain,\n DeriveChain,\n GetChainParameter,\n} from '../../types/chain.js'\nimport type {\n ContractFunctionArgs,\n ContractFunctionName,\n ContractFunctionParameters,\n} from '../../types/contract.js'\nimport type { Hex } from '../../types/misc.js'\nimport type { Prettify, UnionEvaluate, UnionOmit } from '../../types/utils.js'\nimport {\n type EncodeFunctionDataErrorType,\n type EncodeFunctionDataParameters,\n encodeFunctionData,\n} from '../../utils/abi/encodeFunctionData.js'\nimport {\n type GetContractErrorReturnType,\n getContractError,\n} from '../../utils/errors/getContractError.js'\nimport type { FormattedTransactionRequest } from '../../utils/formatters/transactionRequest.js'\nimport { getAction } from '../../utils/getAction.js'\nimport type { GetMutabilityAwareValue } from '../public/simulateContract.js'\nimport {\n type SendTransactionErrorType,\n type SendTransactionReturnType,\n sendTransaction,\n} from './sendTransaction.js'\n\nexport type WriteContractParameters<\n abi extends Abi | readonly unknown[] = Abi,\n functionName extends ContractFunctionName<\n abi,\n 'nonpayable' | 'payable'\n > = ContractFunctionName<abi, 'nonpayable' | 'payable'>,\n args extends ContractFunctionArgs<\n abi,\n 'nonpayable' | 'payable',\n functionName\n > = ContractFunctionArgs<abi, 'nonpayable' | 'payable', functionName>,\n chain extends Chain | undefined = Chain | undefined,\n account extends Account | undefined = Account | undefined,\n chainOverride extends Chain | undefined = Chain | undefined,\n ///\n allFunctionNames = ContractFunctionName<abi, 'nonpayable' | 'payable'>,\n derivedChain extends Chain | undefined = DeriveChain<chain, chainOverride>,\n> = ContractFunctionParameters<\n abi,\n 'nonpayable' | 'payable',\n functionName,\n args,\n false,\n allFunctionNames\n> &\n GetChainParameter<chain, chainOverride> &\n Prettify<\n GetAccountParameter<account, Account | Address, true, true> &\n GetMutabilityAwareValue<\n abi,\n 'nonpayable' | 'payable',\n functionName,\n FormattedTransactionRequest<derivedChain>['value'],\n args\n > & {\n /** Data to append to the end of the calldata. Useful for adding a [\"domain\" tag](https://opensea.notion.site/opensea/Seaport-Order-Attributions-ec2d69bf455041a5baa490941aad307f). */\n dataSuffix?: Hex | undefined\n }\n > &\n UnionEvaluate<\n UnionOmit<\n FormattedTransactionRequest<derivedChain>,\n 'data' | 'from' | 'to' | 'value'\n >\n >\n\nexport type WriteContractReturnType = SendTransactionReturnType\n\nexport type WriteContractErrorType =\n | EncodeFunctionDataErrorType\n | AccountNotFoundErrorType\n | ParseAccountErrorType\n | GetContractErrorReturnType<SendTransactionErrorType>\n | ErrorType\n\n/**\n * Executes a write function on a contract.\n *\n * - Docs: https://viem.sh/docs/contract/writeContract\n * - Examples: https://stackblitz.com/github/wevm/viem/tree/main/examples/contracts_writing-to-contracts\n *\n * A \"write\" function on a Solidity contract modifies the state of the blockchain. These types of functions require gas to be executed, and hence a [Transaction](https://viem.sh/docs/glossary/terms) is needed to be broadcast in order to change the state.\n *\n * Internally, uses a [Wallet Client](https://viem.sh/docs/clients/wallet) to call the [`sendTransaction` action](https://viem.sh/docs/actions/wallet/sendTransaction) with [ABI-encoded `data`](https://viem.sh/docs/contract/encodeFunctionData).\n *\n * __Warning: The `write` internally sends a transaction – it does not validate if the contract write will succeed (the contract may throw an error). It is highly recommended to [simulate the contract write with `contract.simulate`](https://viem.sh/docs/contract/writeContract#usage) before you execute it.__\n *\n * @param client - Client to use\n * @param parameters - {@link WriteContractParameters}\n * @returns A [Transaction Hash](https://viem.sh/docs/glossary/terms#hash). {@link WriteContractReturnType}\n *\n * @example\n * import { createWalletClient, custom, parseAbi } from 'viem'\n * import { mainnet } from 'viem/chains'\n * import { writeContract } from 'viem/contract'\n *\n * const client = createWalletClient({\n * chain: mainnet,\n * transport: custom(window.ethereum),\n * })\n * const hash = await writeContract(client, {\n * address: '0xFBA3912Ca04dd458c843e2EE08967fC04f3579c2',\n * abi: parseAbi(['function mint(uint32 tokenId) nonpayable']),\n * functionName: 'mint',\n * args: [69420],\n * })\n *\n * @example\n * // With Validation\n * import { createWalletClient, http, parseAbi } from 'viem'\n * import { mainnet } from 'viem/chains'\n * import { simulateContract, writeContract } from 'viem/contract'\n *\n * const client = createWalletClient({\n * chain: mainnet,\n * transport: http(),\n * })\n * const { request } = await simulateContract(client, {\n * address: '0xFBA3912Ca04dd458c843e2EE08967fC04f3579c2',\n * abi: parseAbi(['function mint(uint32 tokenId) nonpayable']),\n * functionName: 'mint',\n * args: [69420],\n * }\n * const hash = await writeContract(client, request)\n */\nexport async function writeContract<\n chain extends Chain | undefined,\n account extends Account | undefined,\n const abi extends Abi | readonly unknown[],\n functionName extends ContractFunctionName<abi, 'nonpayable' | 'payable'>,\n args extends ContractFunctionArgs<\n abi,\n 'nonpayable' | 'payable',\n functionName\n >,\n chainOverride extends Chain | undefined,\n>(\n client: Client<Transport, chain, account>,\n parameters: WriteContractParameters<\n abi,\n functionName,\n args,\n chain,\n account,\n chainOverride\n >,\n): Promise<WriteContractReturnType> {\n const {\n abi,\n account: account_ = client.account,\n address,\n args,\n dataSuffix,\n functionName,\n ...request\n } = parameters as WriteContractParameters\n\n if (typeof account_ === 'undefined')\n throw new AccountNotFoundError({\n docsPath: '/docs/contract/writeContract',\n })\n const account = account_ ? parseAccount(account_) : null\n\n const data = encodeFunctionData({\n abi,\n args,\n functionName,\n } as EncodeFunctionDataParameters)\n\n try {\n return await getAction(\n client,\n sendTransaction,\n 'sendTransaction',\n )({\n data: `${data}${dataSuffix ? dataSuffix.replace('0x', '') : ''}`,\n to: address,\n account,\n ...request,\n })\n } catch (error) {\n throw getContractError(error as BaseError, {\n abi,\n address,\n args,\n docsPath: '/docs/contract/writeContract',\n functionName,\n sender: account?.address,\n })\n }\n}\n", "import type {\n Account,\n Chain,\n Client,\n PublicActions,\n RpcSchema,\n Transport,\n WalletActions,\n} from 'viem'\n\n/**\n * Retrieves and returns an action from the client (if exists), and falls\n * back to the tree-shakable action.\n *\n * Useful for extracting overridden actions from a client (ie. if a consumer\n * wants to override the `sendTransaction` implementation).\n */\nexport function getAction<\n transport extends Transport,\n chain extends Chain | undefined,\n account extends Account | undefined,\n rpcSchema extends RpcSchema | undefined,\n extended extends { [key: string]: unknown },\n client extends Client<transport, chain, account, rpcSchema, extended>,\n parameters,\n returnType,\n>(\n client: client,\n actionFn: (_: any, parameters: parameters) => returnType,\n // Some minifiers drop `Function.prototype.name`, or replace it with short letters,\n // meaning that `actionFn.name` will not always work. For that case, the consumer\n // needs to pass the name explicitly.\n name: keyof PublicActions | keyof WalletActions,\n): (parameters: parameters) => returnType {\n const action_implicit = client[actionFn.name]\n if (typeof action_implicit === 'function')\n return action_implicit as (params: parameters) => returnType\n\n const action_explicit = client[name]\n if (typeof action_explicit === 'function')\n return action_explicit as (params: parameters) => returnType\n\n return (params) => actionFn(client, params)\n}\n", "import type {\n CallErrorType as viem_CallErrorType,\n CallParameters as viem_CallParameters,\n CallReturnType as viem_CallReturnType,\n} from 'viem'\nimport { call as viem_call } from 'viem/actions'\n\nimport type { Config } from '../createConfig.js'\nimport type { ChainIdParameter } from '../types/properties.js'\nimport { getAction } from '../utils/getAction.js'\n\nexport type CallParameters<config extends Config = Config> =\n viem_CallParameters & ChainIdParameter<config>\n\nexport type CallReturnType = viem_CallReturnType\n\nexport type CallErrorType = viem_CallErrorType\n\nexport async function call<config extends Config>(\n config: config,\n parameters: CallParameters<config>,\n): Promise<CallReturnType> {\n const { chainId, ...rest } = parameters\n const client = config.getClient({ chainId })\n const action = getAction(client, viem_call, 'call')\n return action(rest)\n}\n", "export const version = '2.16.7'\n", "import { version } from '../version.js'\n\nexport const getVersion = () => `@wagmi/core@${version}`\n", "import type { Compute, OneOf } from '../types/utils.js'\nimport { getVersion } from '../utils/getVersion.js'\n\nexport type ErrorType<name extends string = 'Error'> = Error & { name: name }\n\ntype BaseErrorOptions = Compute<\n OneOf<{ details?: string | undefined } | { cause: BaseError | Error }> & {\n docsPath?: string | undefined\n docsSlug?: string | undefined\n metaMessages?: string[] | undefined\n }\n>\n\nexport type BaseErrorType = BaseError & { name: 'WagmiCoreError' }\nexport class BaseError extends Error {\n details: string\n docsPath?: string | undefined\n metaMessages?: string[] | undefined\n shortMessage: string\n\n override name = 'WagmiCoreError'\n get docsBaseUrl() {\n return 'https://wagmi.sh/core'\n }\n get version() {\n return getVersion()\n }\n\n constructor(shortMessage: string, options: BaseErrorOptions = {}) {\n super()\n\n const details =\n options.cause instanceof BaseError\n ? options.cause.details\n : options.cause?.message\n ? options.cause.message\n : options.details!\n const docsPath =\n options.cause instanceof BaseError\n ? options.cause.docsPath || options.docsPath\n : options.docsPath\n\n this.message = [\n shortMessage || 'An error occurred.',\n '',\n ...(options.metaMessages ? [...options.metaMessages, ''] : []),\n ...(docsPath\n ? [\n `Docs: ${this.docsBaseUrl}${docsPath}.html${\n options.docsSlug ? `#${options.docsSlug}` : ''\n }`,\n ]\n : []),\n ...(details ? [`Details: ${details}`] : []),\n `Version: ${this.version}`,\n ].join('\\n')\n\n if (options.cause) this.cause = options.cause\n this.details = details\n this.docsPath = docsPath\n this.metaMessages = options.metaMessages\n this.shortMessage = shortMessage\n }\n\n walk(fn?: (err: unknown) => boolean) {\n return this.#walk(this, fn)\n }\n\n #walk(err: unknown, fn?: (err: unknown) => boolean): unknown {\n if (fn?.(err)) return err\n if ((err as Error).cause) return this.#walk((err as Error).cause, fn)\n return err\n }\n}\n", "import type { Address } from 'viem'\n\nimport type { Connector } from '../createConfig.js'\nimport { BaseError } from './base.js'\n\nexport type ChainNotConfiguredErrorType = ChainNotConfiguredError & {\n name: 'ChainNotConfiguredError'\n}\nexport class ChainNotConfiguredError extends BaseError {\n override name = 'ChainNotConfiguredError'\n constructor() {\n super('Chain not configured.')\n }\n}\n\nexport type ConnectorAlreadyConnectedErrorType =\n ConnectorAlreadyConnectedError & {\n name: 'ConnectorAlreadyConnectedError'\n }\nexport class ConnectorAlreadyConnectedError extends BaseError {\n override name = 'ConnectorAlreadyConnectedError'\n constructor() {\n super('Connector already connected.')\n }\n}\n\nexport type ConnectorNotConnectedErrorType = ConnectorNotConnectedError & {\n name: 'ConnectorNotConnectedError'\n}\nexport class ConnectorNotConnectedError extends BaseError {\n override name = 'ConnectorNotConnectedError'\n constructor() {\n super('Connector not connected.')\n }\n}\n\nexport type ConnectorNotFoundErrorType = ConnectorNotFoundError & {\n name: 'ConnectorNotFoundError'\n}\nexport class ConnectorNotFoundError extends BaseError {\n override name = 'ConnectorNotFoundError'\n constructor() {\n super('Connector not found.')\n }\n}\n\nexport type ConnectorAccountNotFoundErrorType =\n ConnectorAccountNotFoundError & {\n name: 'ConnectorAccountNotFoundError'\n }\nexport class ConnectorAccountNotFoundError extends BaseError {\n override name = 'ConnectorAccountNotFoundError'\n constructor({\n address,\n connector,\n }: {\n address: Address\n connector: Connector\n }) {\n super(`Account \"${address}\" not found for connector \"${connector.name}\".`)\n }\n}\n\nexport type ConnectorChainMismatchErrorType = ConnectorAccountNotFoundError & {\n name: 'ConnectorChainMismatchError'\n}\nexport class ConnectorChainMismatchError extends BaseError {\n override name = 'ConnectorChainMismatchError'\n constructor({\n connectionChainId,\n connectorChainId,\n }: {\n connectionChainId: number\n connectorChainId: number\n }) {\n super(\n `The current chain of the connector (id: ${connectorChainId}) does not match the connection's chain (id: ${connectionChainId}).`,\n {\n metaMessages: [\n `Current Chain ID: ${connectorChainId}`,\n `Expected Chain ID: ${connectionChainId}`,\n ],\n },\n )\n }\n}\n\nexport type ConnectorUnavailableReconnectingErrorType =\n ConnectorUnavailableReconnectingError & {\n name: 'ConnectorUnavailableReconnectingError'\n }\nexport class ConnectorUnavailableReconnectingError extends BaseError {\n override name = 'ConnectorUnavailableReconnectingError'\n constructor({ connector }: { connector: { name: string } }) {\n super(`Connector \"${connector.name}\" unavailable while reconnecting.`, {\n details: [\n 'During the reconnection step, the only connector methods guaranteed to be available are: `id`, `name`, `type`, `uid`.',\n 'All other methods are not guaranteed to be available until reconnection completes and connectors are fully restored.',\n 'This error commonly occurs for connectors that asynchronously inject after reconnection has already started.',\n ].join(' '),\n })\n }\n}\n", "import type {\n Address,\n ResourceUnavailableRpcErrorType,\n UserRejectedRequestErrorType,\n} from 'viem'\n\nimport type { CreateConnectorFn } from '../connectors/createConnector.js'\nimport type { Config, Connector } from '../createConfig.js'\nimport type { BaseErrorType, ErrorType } from '../errors/base.js'\nimport {\n ConnectorAlreadyConnectedError,\n type ConnectorAlreadyConnectedErrorType,\n} from '../errors/config.js'\nimport type { ChainIdParameter } from '../types/properties.js'\nimport type { Compute } from '../types/utils.js'\n\nexport type ConnectParameters<\n config extends Config = Config,\n connector extends Connector | CreateConnectorFn =\n | Connector\n | CreateConnectorFn,\n ///\n parameters extends unknown | undefined =\n | (connector extends CreateConnectorFn\n ? Omit<\n NonNullable<Parameters<ReturnType<connector>['connect']>[0]>,\n 'isReconnecting'\n >\n : never)\n | (connector extends Connector\n ? Omit<\n NonNullable<Parameters<connector['connect']>[0]>,\n 'isReconnecting'\n >\n : never),\n> = Compute<\n ChainIdParameter<config> & {\n connector: connector | CreateConnectorFn\n }\n> &\n parameters\n\nexport type ConnectReturnType<config extends Config = Config> = {\n accounts: readonly [Address, ...Address[]]\n chainId:\n | config['chains'][number]['id']\n | (number extends config['chains'][number]['id'] ? number : number & {})\n}\n\nexport type ConnectErrorType =\n | ConnectorAlreadyConnectedErrorType\n // connector.connect()\n | UserRejectedRequestErrorType\n | ResourceUnavailableRpcErrorType\n // base\n | BaseErrorType\n | ErrorType\n\n/** https://wagmi.sh/core/api/actions/connect */\nexport async function connect<\n config extends Config,\n connector extends Connector | CreateConnectorFn,\n>(\n config: config,\n parameters: ConnectParameters<config, connector>,\n): Promise<ConnectReturnType<config>> {\n // \"Register\" connector if not already created\n let connector: Connector\n if (typeof parameters.connector === 'function') {\n connector = config._internal.connectors.setup(parameters.connector)\n } else connector = parameters.connector\n\n // Check if connector is already connected\n if (connector.uid === config.state.current)\n throw new ConnectorAlreadyConnectedError()\n\n try {\n config.setState((x) => ({ ...x, status: 'connecting' }))\n connector.emitter.emit('message', { type: 'connecting' })\n\n const { connector: _, ...rest } = parameters\n const data = await connector.connect(rest)\n const accounts = data.accounts as readonly [Address, ...Address[]]\n\n connector.emitter.off('connect', config._internal.events.connect)\n connector.emitter.on('change', config._internal.events.change)\n connector.emitter.on('disconnect', config._internal.events.disconnect)\n\n await config.storage?.setItem('recentConnectorId', connector.id)\n config.setState((x) => ({\n ...x,\n connections: new Map(x.connections).set(connector.uid, {\n accounts,\n chainId: data.chainId,\n connector: connector,\n }),\n current: connector.uid,\n status: 'connected',\n }))\n\n return { accounts, chainId: data.chainId }\n } catch (error) {\n config.setState((x) => ({\n ...x,\n // Keep existing connector connected in case of error\n status: x.current ? 'connected' : 'disconnected',\n }))\n throw error\n }\n}\n", "const size = 256\nlet index = size\nlet buffer: string\n\nexport function uid(length = 11) {\n if (!buffer || index + length > size * 2) {\n buffer = ''\n index = 0\n for (let i = 0; i < size; i++) {\n buffer += ((256 + Math.random() * 256) | 0).toString(16).substring(1)\n }\n }\n return buffer.substring(index, index++ + length)\n}\n", "import type { Address } from 'abitype'\n\nimport type { JsonRpcAccount } from '../accounts/types.js'\nimport {\n type ParseAccountErrorType,\n parseAccount,\n} from '../accounts/utils/parseAccount.js'\nimport type { ErrorType } from '../errors/utils.js'\nimport type { Account } from '../types/account.js'\nimport type { Chain } from '../types/chain.js'\nimport type {\n EIP1193RequestFn,\n EIP1474Methods,\n RpcSchema,\n} from '../types/eip1193.js'\nimport type { ExactPartial, Prettify } from '../types/utils.js'\nimport type {\n CcipRequestParameters,\n CcipRequestReturnType,\n} from '../utils/ccip.js'\nimport { uid } from '../utils/uid.js'\nimport type { PublicActions } from './decorators/public.js'\nimport type { WalletActions } from './decorators/wallet.js'\nimport type { Transport } from './transports/createTransport.js'\n\nexport type ClientConfig<\n transport extends Transport = Transport,\n chain extends Chain | undefined = Chain | undefined,\n accountOrAddress extends Account | Address | undefined =\n | Account\n | Address\n | undefined,\n rpcSchema extends RpcSchema | undefined = undefined,\n> = {\n /** The Account to use for the Client. This will be used for Actions that require an account as an argument. */\n account?: accountOrAddress | Account | Address | undefined\n /** Flags for batch settings. */\n batch?:\n | {\n /** Toggle to enable `eth_call` multicall aggregation. */\n multicall?: boolean | Prettify<MulticallBatchOptions> | undefined\n }\n | undefined\n /**\n * Time (in ms) that cached data will remain in memory.\n * @default 4_000\n */\n cacheTime?: number | undefined\n /**\n * [CCIP Read](https://eips.ethereum.org/EIPS/eip-3668) configuration.\n * If `false`, the client will not support offchain CCIP lookups.\n */\n ccipRead?:\n | {\n /**\n * A function that will be called to make the offchain CCIP lookup request.\n * @see https://eips.ethereum.org/EIPS/eip-3668#client-lookup-protocol\n */\n request?: (\n parameters: CcipRequestParameters,\n ) => Promise<CcipRequestReturnType>\n }\n | false\n | undefined\n /** Chain for the client. */\n chain?: Chain | undefined | chain\n /** A key for the client. */\n key?: string | undefined\n /** A name for the client. */\n name?: string | undefined\n /**\n * Frequency (in ms) for polling enabled actions & events.\n * @default 4_000\n */\n pollingInterval?: number | undefined\n /**\n * Typed JSON-RPC schema for the client.\n */\n rpcSchema?: rpcSchema | undefined\n /** The RPC transport */\n transport: transport\n /** The type of client. */\n type?: string | undefined\n}\n\n// Actions that are used internally by other Actions (ie. `call` is used by `readContract`).\n// They are allowed to be extended, but must conform to their parameter & return type interfaces.\n// Example: an extended `call` action must accept `CallParameters` as parameters,\n// and conform to the `CallReturnType` return type.\ntype ExtendableProtectedActions<\n transport extends Transport = Transport,\n chain extends Chain | undefined = Chain | undefined,\n account extends Account | undefined = Account | undefined,\n> = Pick<\n PublicActions<transport, chain, account>,\n | 'call'\n | 'createContractEventFilter'\n | 'createEventFilter'\n | 'estimateContractGas'\n | 'estimateGas'\n | 'getBlock'\n | 'getBlockNumber'\n | 'getChainId'\n | 'getContractEvents'\n | 'getEnsText'\n | 'getFilterChanges'\n | 'getGasPrice'\n | 'getLogs'\n | 'getTransaction'\n | 'getTransactionCount'\n | 'getTransactionReceipt'\n | 'prepareTransactionRequest'\n | 'readContract'\n | 'sendRawTransaction'\n | 'simulateContract'\n | 'uninstallFilter'\n | 'watchBlockNumber'\n | 'watchContractEvent'\n> &\n Pick<WalletActions<chain, account>, 'sendTransaction' | 'writeContract'>\n\n// TODO: Move `transport` to slot index 2 since `chain` and `account` used more frequently.\n// Otherwise, we end up with a lot of `Client<Transport, chain, account>` in actions.\nexport type Client<\n transport extends Transport = Transport,\n chain extends Chain | undefined = Chain | undefined,\n account extends Account | undefined = Account | undefined,\n rpcSchema extends RpcSchema | undefined = undefined,\n extended extends Extended | undefined = Extended | undefined,\n> = Client_Base<transport, chain, account, rpcSchema> &\n (extended extends Extended ? extended : unknown) & {\n extend: <\n const client extends Extended &\n ExactPartial<ExtendableProtectedActions<transport, chain, account>>,\n >(\n fn: (\n client: Client<transport, chain, account, rpcSchema, extended>,\n ) => client,\n ) => Client<\n transport,\n chain,\n account,\n rpcSchema,\n Prettify<client> & (extended extends Extended ? extended : unknown)\n >\n }\n\ntype Client_Base<\n transport extends Transport = Transport,\n chain extends Chain | undefined = Chain | undefined,\n account extends Account | undefined = Account | undefined,\n rpcSchema extends RpcSchema | undefined = undefined,\n> = {\n /** The Account of the Client. */\n account: account\n /** Flags for batch settings. */\n batch?: ClientConfig['batch'] | undefined\n /** Time (in ms) that cached data will remain in memory. */\n cacheTime: number\n /** [CCIP Read](https://eips.ethereum.org/EIPS/eip-3668) configuration. */\n ccipRead?: ClientConfig['ccipRead'] | undefined\n /** Chain for the client. */\n chain: chain\n /** A key for the client. */\n key: string\n /** A name for the client. */\n name: string\n /** Frequency (in ms) for polling enabled actions & events. Defaults to 4_000 milliseconds. */\n pollingInterval: number\n /** Request function wrapped with friendly error handling */\n request: EIP1193RequestFn<\n rpcSchema extends undefined ? EIP1474Methods : rpcSchema\n >\n /** The RPC transport */\n transport: ReturnType<transport>['config'] & ReturnType<transport>['value']\n /** The type of client. */\n type: string\n /** A unique ID for the client. */\n uid: string\n}\n\ntype Extended = Prettify<\n // disallow redefining base properties\n { [_ in keyof Client_Base]?: undefined } & {\n [key: string]: unknown\n }\n>\n\nexport type MulticallBatchOptions = {\n /** The maximum size (in bytes) for each calldata chunk. @default 1_024 */\n batchSize?: number | undefined\n /** The maximum number of milliseconds to wait before sending a batch. @default 0 */\n wait?: number | undefined\n}\n\nexport type CreateClientErrorType = ParseAccountErrorType | ErrorType\n\nexport function createClient<\n transport extends Transport,\n chain extends Chain | undefined = undefined,\n accountOrAddress extends Account | Address | undefined = undefined,\n rpcSchema extends RpcSchema | undefined = undefined,\n>(\n parameters: ClientConfig<transport, chain, accountOrAddress, rpcSchema>,\n): Prettify<\n Client<\n transport,\n chain,\n accountOrAddress extends Address\n ? Prettify<JsonRpcAccount<accountOrAddress>>\n : accountOrAddress,\n rpcSchema\n >\n>\n\nexport function createClient(parameters: ClientConfig): Client {\n const {\n batch,\n cacheTime = parameters.pollingInterval ?? 4_000,\n ccipRead,\n key = 'base',\n name = 'Base Client',\n pollingInterval = 4_000,\n type = 'base',\n } = parameters\n\n const chain = parameters.chain\n const account = parameters.account\n ? parseAccount(parameters.account)\n : undefined\n const { config, request, value } = parameters.transport({\n chain,\n pollingInterval,\n })\n const transport = { ...config, ...value }\n\n const client = {\n account,\n batch,\n cacheTime,\n ccipRead,\n chain,\n key,\n name,\n pollingInterval,\n request,\n transport,\n type,\n uid: uid(),\n }\n\n function extend(base: typeof client) {\n type ExtendFn = (base: typeof client) => unknown\n return (extendFn: ExtendFn) => {\n const extended = extendFn(base) as Extended\n for (const key in client) delete extended[key]\n const combined = { ...base, ...extended }\n return Object.assign(combined, { extend: extend(combined as any) })\n }\n }\n\n return Object.assign(client, { extend: extend(client) as any })\n}\n\n/**\n * Defines a typed JSON-RPC schema for the client.\n * Note: This is a runtime noop function.\n */\nexport function rpcSchema<rpcSchema extends RpcSchema>(): rpcSchema {\n return null as any\n}\n", "import type { ErrorType } from '../../errors/utils.js'\nimport type { Chain } from '../../types/chain.js'\nimport type { EIP1193RequestFn } from '../../types/eip1193.js'\nimport type { OneOf } from '../../types/utils.js'\nimport { buildRequest } from '../../utils/buildRequest.js'\nimport { uid as uid_ } from '../../utils/uid.js'\nimport type { ClientConfig } from '../createClient.js'\n\nexport type TransportConfig<\n type extends string = string,\n eip1193RequestFn extends EIP1193RequestFn = EIP1193RequestFn,\n> = {\n /** The name of the transport. */\n name: string\n /** The key of the transport. */\n key: string\n /** Methods to include or exclude from executing RPC requests. */\n methods?:\n | OneOf<\n | {\n include?: string[] | undefined\n }\n | {\n exclude?: string[] | undefined\n }\n >\n | undefined\n /** The JSON-RPC request function that matches the EIP-1193 request spec. */\n request: eip1193RequestFn\n /** The base delay (in ms) between retries. */\n retryDelay?: number | undefined\n /** The max number of times to retry. */\n retryCount?: number | undefined\n /** The timeout (in ms) for requests. */\n timeout?: number | undefined\n /** The type of the transport. */\n type: type\n}\n\nexport type Transport<\n type extends string = string,\n rpcAttributes = Record<string, any>,\n eip1193RequestFn extends EIP1193RequestFn = EIP1193RequestFn,\n> = <chain extends Chain | undefined = Chain>({\n chain,\n}: {\n chain?: chain | undefined\n pollingInterval?: ClientConfig['pollingInterval'] | undefined\n retryCount?: TransportConfig['retryCount'] | undefined\n timeout?: TransportConfig['timeout'] | undefined\n}) => {\n config: TransportConfig<type>\n request: eip1193RequestFn\n value?: rpcAttributes | undefined\n}\n\nexport type CreateTransportErrorType = ErrorType\n\n/**\n * @description Creates an transport intended to be used with a client.\n */\nexport function createTransport<\n type extends string,\n rpcAttributes extends Record<string, any>,\n>(\n {\n key,\n methods,\n name,\n request,\n retryCount = 3,\n retryDelay = 150,\n timeout,\n type,\n }: TransportConfig<type>,\n value?: rpcAttributes | undefined,\n): ReturnType<Transport<type, rpcAttributes>> {\n const uid = uid_()\n return {\n config: {\n key,\n methods,\n name,\n request,\n retryCount,\n retryDelay,\n timeout,\n type,\n },\n request: buildRequest(request, { methods, retryCount, retryDelay, uid }),\n value,\n }\n}\n", "import type { ErrorType } from '../../errors/utils.js'\nimport {\n type CreateTransportErrorType,\n type Transport,\n type TransportConfig,\n createTransport,\n} from './createTransport.js'\n\ntype EthereumProvider = { request(...args: any): Promise<any> }\n\nexport type CustomTransportConfig = {\n /** The key of the transport. */\n key?: TransportConfig['key'] | undefined\n /** Methods to include or exclude from executing RPC requests. */\n methods?: TransportConfig['methods'] | undefined\n /** The name of the transport. */\n name?: TransportConfig['name'] | undefined\n /** The max number of times to retry. */\n retryCount?: TransportConfig['retryCount'] | undefined\n /** The base delay (in ms) between retries. */\n retryDelay?: TransportConfig['retryDelay'] | undefined\n}\n\nexport type CustomTransport = Transport<\n 'custom',\n {},\n EthereumProvider['request']\n>\n\nexport type CustomTransportErrorType = CreateTransportErrorType | ErrorType\n\n/**\n * @description Creates a custom transport given an EIP-1193 compliant `request` attribute.\n */\nexport function custom<provider extends EthereumProvider>(\n provider: provider,\n config: CustomTransportConfig = {},\n): CustomTransport {\n const {\n key = 'custom',\n methods,\n name = 'Custom Provider',\n retryDelay,\n } = config\n return ({ retryCount: defaultRetryCount }) =>\n createTransport({\n key,\n methods,\n name,\n request: provider.request.bind(provider),\n retryCount: config.retryCount ?? defaultRetryCount,\n retryDelay,\n type: 'custom',\n })\n}\n", "import { ExecutionRevertedError } from '../../errors/node.js'\nimport {\n TransactionRejectedRpcError,\n UserRejectedRequestError,\n} from '../../errors/rpc.js'\nimport type { ErrorType } from '../../errors/utils.js'\nimport type { Chain } from '../../types/chain.js'\nimport { wait } from '../../utils/wait.js'\n\nimport {\n type CreateTransportErrorType,\n type Transport,\n type TransportConfig,\n createTransport,\n} from './createTransport.js'\n// TODO: Narrow `method` & `params` types.\nexport type OnResponseFn = (\n args: {\n method: string\n params: unknown[]\n transport: ReturnType<Transport>\n } & (\n | {\n error?: undefined\n response: unknown\n status: 'success'\n }\n | {\n error: Error\n response?: undefined\n status: 'error'\n }\n ),\n) => void\n\ntype RankOptions = {\n /**\n * The polling interval (in ms) at which the ranker should ping the RPC URL.\n * @default client.pollingInterval\n */\n interval?: number | undefined\n /**\n * Ping method to determine latency.\n */\n ping?: (parameters: { transport: ReturnType<Transport> }) =>\n | Promise<unknown>\n | undefined\n /**\n * The number of previous samples to perform ranking on.\n * @default 10\n */\n sampleCount?: number | undefined\n /**\n * Timeout when sampling transports.\n * @default 1_000\n */\n timeout?: number | undefined\n /**\n * Weights to apply to the scores. Weight values are proportional.\n */\n weights?:\n | {\n /**\n * The weight to apply to the latency score.\n * @default 0.3\n */\n latency?: number | undefined\n /**\n * The weight to apply to the stability score.\n * @default 0.7\n */\n stability?: number | undefined\n }\n | undefined\n}\n\nexport type FallbackTransportConfig = {\n /** The key of the Fallback transport. */\n key?: TransportConfig['key'] | undefined\n /** The name of the Fallback transport. */\n name?: TransportConfig['name'] | undefined\n /** Toggle to enable ranking, or rank options. */\n rank?: boolean | RankOptions | undefined\n /** The max number of times to retry. */\n retryCount?: TransportConfig['retryCount'] | undefined\n /** The base delay (in ms) between retries. */\n retryDelay?: TransportConfig['retryDelay'] | undefined\n /** Callback on whether an error should throw or try the next transport in the fallback. */\n shouldThrow?: (error: Error) => boolean | undefined\n}\n\nexport type FallbackTransport<\n transports extends readonly Transport[] = readonly Transport[],\n> = Transport<\n 'fallback',\n {\n onResponse: (fn: OnResponseFn) => void\n transports: {\n [key in keyof transports]: ReturnType<transports[key]>\n }\n }\n>\n\nexport type FallbackTransportErrorType = CreateTransportErrorType | ErrorType\n\nexport function fallback<const transports extends readonly Transport[]>(\n transports_: transports,\n config: FallbackTransportConfig = {},\n): FallbackTransport<transports> {\n const {\n key = 'fallback',\n name = 'Fallback',\n rank = false,\n shouldThrow: shouldThrow_ = shouldThrow,\n retryCount,\n retryDelay,\n } = config\n return (({ chain, pollingInterval = 4_000, timeout, ...rest }) => {\n let transports = transports_\n\n let onResponse: OnResponseFn = () => {}\n\n const transport = createTransport(\n {\n key,\n name,\n async request({ method, params }) {\n let includes: boolean | undefined\n\n const fetch = async (i = 0): Promise<any> => {\n const transport = transports[i]({\n ...rest,\n chain,\n retryCount: 0,\n timeout,\n })\n try {\n const response = await transport.request({\n method,\n params,\n } as any)\n\n onResponse({\n method,\n params: params as unknown[],\n response,\n transport,\n status: 'success',\n })\n\n return response\n } catch (err) {\n onResponse({\n error: err as Error,\n method,\n params: params as unknown[],\n transport,\n status: 'error',\n })\n\n if (shouldThrow_(err as Error)) throw err\n\n // If we've reached the end of the fallbacks, throw the error.\n if (i === transports.length - 1) throw err\n\n // Check if at least one other transport includes the method\n includes ??= transports.slice(i + 1).some((transport) => {\n const { include, exclude } =\n transport({ chain }).config.methods || {}\n if (include) return include.includes(method)\n if (exclude) return !exclude.includes(method)\n return true\n })\n if (!includes) throw err\n\n // Otherwise, try the next fallback.\n return fetch(i + 1)\n }\n }\n return fetch()\n },\n retryCount,\n retryDelay,\n type: 'fallback',\n },\n {\n onResponse: (fn: OnResponseFn) => (onResponse = fn),\n transports: transports.map((fn) => fn({ chain, retryCount: 0 })),\n },\n )\n\n if (rank) {\n const rankOptions = (typeof rank === 'object' ? rank : {}) as RankOptions\n rankTransports({\n chain,\n interval: rankOptions.interval ?? pollingInterval,\n onTransports: (transports_) => (transports = transports_ as transports),\n ping: rankOptions.ping,\n sampleCount: rankOptions.sampleCount,\n timeout: rankOptions.timeout,\n transports,\n weights: rankOptions.weights,\n })\n }\n return transport\n }) as FallbackTransport<transports>\n}\n\nexport function shouldThrow(error: Error) {\n if ('code' in error && typeof error.code === 'number') {\n if (\n error.code === TransactionRejectedRpcError.code ||\n error.code === UserRejectedRequestError.code ||\n ExecutionRevertedError.nodeMessage.test(error.message) ||\n error.code === 5000 // CAIP UserRejectedRequestError\n )\n return true\n }\n return false\n}\n\n/** @internal */\nexport function rankTransports({\n chain,\n interval = 4_000,\n onTransports,\n ping,\n sampleCount = 10,\n timeout = 1_000,\n transports,\n weights = {},\n}: {\n chain?: Chain | undefined\n interval: RankOptions['interval']\n onTransports: (transports: readonly Transport[]) => void\n ping?: RankOptions['ping'] | undefined\n sampleCount?: RankOptions['sampleCount'] | undefined\n timeout?: RankOptions['timeout'] | undefined\n transports: readonly Transport[]\n weights?: RankOptions['weights'] | undefined\n}) {\n const { stability: stabilityWeight = 0.7, latency: latencyWeight = 0.3 } =\n weights\n\n type SampleData = { latency: number; success: number }\n type Sample = SampleData[]\n const samples: Sample[] = []\n\n const rankTransports_ = async () => {\n // 1. Take a sample from each Transport.\n const sample: Sample = await Promise.all(\n transports.map(async (transport) => {\n const transport_ = transport({ chain, retryCount: 0, timeout })\n\n const start = Date.now()\n let end: number\n let success: number\n try {\n await (ping\n ? ping({ transport: transport_ })\n : transport_.request({ method: 'net_listening' }))\n success = 1\n } catch {\n success = 0\n } finally {\n end = Date.now()\n }\n const latency = end - start\n return { latency, success }\n }),\n )\n\n // 2. Store the sample. If we have more than `sampleCount` samples, remove\n // the oldest sample.\n samples.push(sample)\n if (samples.length > sampleCount) samples.shift()\n\n // 3. Calculate the max latency from samples.\n const maxLatency = Math.max(\n ...samples.map((sample) =>\n Math.max(...sample.map(({ latency }) => latency)),\n ),\n )\n\n // 4. Calculate the score for each Transport.\n const scores = transports\n .map((_, i) => {\n const latencies = samples.map((sample) => sample[i].latency)\n const meanLatency =\n latencies.reduce((acc, latency) => acc + latency, 0) /\n latencies.length\n const latencyScore = 1 - meanLatency / maxLatency\n\n const successes = samples.map((sample) => sample[i].success)\n const stabilityScore =\n successes.reduce((acc, success) => acc + success, 0) /\n successes.length\n\n if (stabilityScore === 0) return [0, i]\n return [\n latencyWeight * latencyScore + stabilityWeight * stabilityScore,\n i,\n ]\n })\n .sort((a, b) => b[0] - a[0])\n\n // 5. Sort the Transports by score.\n onTransports(scores.map(([, i]) => transports[i]))\n\n // 6. Wait, and then rank again.\n await wait(interval)\n rankTransports_()\n }\n rankTransports_()\n}\n", "import { BaseError } from './base.js'\n\nexport type UrlRequiredErrorType = UrlRequiredError & {\n name: 'UrlRequiredError'\n}\nexport class UrlRequiredError extends BaseError {\n constructor() {\n super(\n 'No URL was provided to the Transport. Please provide a valid RPC URL to the Transport.',\n {\n docsPath: '/docs/clients/intro',\n name: 'UrlRequiredError',\n },\n )\n }\n}\n", "import { RpcRequestError } from '../../errors/request.js'\nimport {\n UrlRequiredError,\n type UrlRequiredErrorType,\n} from '../../errors/transport.js'\nimport type { ErrorType } from '../../errors/utils.js'\nimport type { EIP1193RequestFn, RpcSchema } from '../../types/eip1193.js'\nimport type { RpcRequest } from '../../types/rpc.js'\nimport { createBatchScheduler } from '../../utils/promise/createBatchScheduler.js'\nimport {\n type HttpRpcClientOptions,\n getHttpRpcClient,\n} from '../../utils/rpc/http.js'\n\nimport {\n type CreateTransportErrorType,\n type Transport,\n type TransportConfig,\n createTransport,\n} from './createTransport.js'\n\nexport type HttpTransportConfig<\n rpcSchema extends RpcSchema | undefined = undefined,\n raw extends boolean = false,\n> = {\n /**\n * Whether to enable Batch JSON-RPC.\n * @link https://www.jsonrpc.org/specification#batch\n */\n batch?:\n | boolean\n | {\n /** The maximum number of JSON-RPC requests to send in a batch. @default 1_000 */\n batchSize?: number | undefined\n /** The maximum number of milliseconds to wait before sending a batch. @default 0 */\n wait?: number | undefined\n }\n | undefined\n /**\n * Request configuration to pass to `fetch`.\n * @link https://developer.mozilla.org/en-US/docs/Web/API/fetch\n */\n fetchOptions?: HttpRpcClientOptions['fetchOptions'] | undefined\n /** A callback to handle the response from `fetch`. */\n onFetchRequest?: HttpRpcClientOptions['onRequest'] | undefined\n /** A callback to handle the response from `fetch`. */\n onFetchResponse?: HttpRpcClientOptions['onResponse'] | undefined\n /** The key of the HTTP transport. */\n key?: TransportConfig['key'] | undefined\n /** Methods to include or exclude from executing RPC requests. */\n methods?: TransportConfig['methods'] | undefined\n /** The name of the HTTP transport. */\n name?: TransportConfig['name'] | undefined\n /** Whether to return JSON RPC errors as responses instead of throwing. */\n raw?: raw | boolean | undefined\n /** The max number of times to retry. */\n retryCount?: TransportConfig['retryCount'] | undefined\n /** The base delay (in ms) between retries. */\n retryDelay?: TransportConfig['retryDelay'] | undefined\n /** Typed JSON-RPC schema for the transport. */\n rpcSchema?: rpcSchema | RpcSchema | undefined\n /** The timeout (in ms) for the HTTP request. Default: 10_000 */\n timeout?: TransportConfig['timeout'] | undefined\n}\n\nexport type HttpTransport<\n rpcSchema extends RpcSchema | undefined = undefined,\n raw extends boolean = false,\n> = Transport<\n 'http',\n {\n fetchOptions?: HttpTransportConfig['fetchOptions'] | undefined\n url?: string | undefined\n },\n EIP1193RequestFn<rpcSchema, raw>\n>\n\nexport type HttpTransportErrorType =\n | CreateTransportErrorType\n | UrlRequiredErrorType\n | ErrorType\n\n/**\n * @description Creates a HTTP transport that connects to a JSON-RPC API.\n */\nexport function http<\n rpcSchema extends RpcSchema | undefined = undefined,\n raw extends boolean = false,\n>(\n /** URL of the JSON-RPC API. Defaults to the chain's public RPC URL. */\n url?: string | undefined,\n config: HttpTransportConfig<rpcSchema, raw> = {},\n): HttpTransport<rpcSchema, raw> {\n const {\n batch,\n fetchOptions,\n key = 'http',\n methods,\n name = 'HTTP JSON-RPC',\n onFetchRequest,\n onFetchResponse,\n retryDelay,\n raw,\n } = config\n return ({ chain, retryCount: retryCount_, timeout: timeout_ }) => {\n const { batchSize = 1000, wait = 0 } =\n typeof batch === 'object' ? batch : {}\n const retryCount = config.retryCount ?? retryCount_\n const timeout = timeout_ ?? config.timeout ?? 10_000\n const url_ = url || chain?.rpcUrls.default.http[0]\n if (!url_) throw new UrlRequiredError()\n\n const rpcClient = getHttpRpcClient(url_, {\n fetchOptions,\n onRequest: onFetchRequest,\n onResponse: onFetchResponse,\n timeout,\n })\n\n return createTransport(\n {\n key,\n methods,\n name,\n async request({ method, params }) {\n const body = { method, params }\n\n const { schedule } = createBatchScheduler({\n id: url_,\n wait,\n shouldSplitBatch(requests) {\n return requests.length > batchSize\n },\n fn: (body: RpcRequest[]) =>\n rpcClient.request({\n body,\n }),\n sort: (a, b) => a.id - b.id,\n })\n\n const fn = async (body: RpcRequest) =>\n batch\n ? schedule(body)\n : [\n await rpcClient.request({\n body,\n }),\n ]\n\n const [{ error, result }] = await fn(body)\n\n if (raw) return { error, result }\n if (error)\n throw new RpcRequestError({\n body,\n error,\n url: url_,\n })\n return result\n },\n retryCount,\n retryDelay,\n timeout,\n type: 'http',\n },\n {\n fetchOptions,\n url: url_,\n },\n )\n }\n}\n", "import type { Address } from 'abitype'\n\nimport type { ExactPartial, Prettify } from '../../types/utils.js'\nimport type { SiweMessage } from './types.js'\n\n/**\n * @description Parses EIP-4361 formatted message into message fields object.\n *\n * @see https://eips.ethereum.org/EIPS/eip-4361\n *\n * @returns EIP-4361 fields object\n */\nexport function parseSiweMessage(\n message: string,\n): Prettify<ExactPartial<SiweMessage>> {\n const { scheme, statement, ...prefix } = (message.match(prefixRegex)\n ?.groups ?? {}) as {\n address: Address\n domain: string\n scheme?: string\n statement?: string\n }\n const { chainId, expirationTime, issuedAt, notBefore, requestId, ...suffix } =\n (message.match(suffixRegex)?.groups ?? {}) as {\n chainId: string\n expirationTime?: string\n issuedAt?: string\n nonce: string\n notBefore?: string\n requestId?: string\n uri: string\n version: '1'\n }\n const resources = message.split('Resources:')[1]?.split('\\n- ').slice(1)\n return {\n ...prefix,\n ...suffix,\n ...(chainId ? { chainId: Number(chainId) } : {}),\n ...(expirationTime ? { expirationTime: new Date(expirationTime) } : {}),\n ...(issuedAt ? { issuedAt: new Date(issuedAt) } : {}),\n ...(notBefore ? { notBefore: new Date(notBefore) } : {}),\n ...(requestId ? { requestId } : {}),\n ...(resources ? { resources } : {}),\n ...(scheme ? { scheme } : {}),\n ...(statement ? { statement } : {}),\n }\n}\n\n// https://regexr.com/80gdj\nconst prefixRegex =\n /^(?:(?<scheme>[a-zA-Z][a-zA-Z0-9+-.]*):\\/\\/)?(?<domain>[a-zA-Z0-9+-.]*(?::[0-9]{1,5})?) (?:wants you to sign in with your Ethereum account:\\n)(?<address>0x[a-fA-F0-9]{40})\\n\\n(?:(?<statement>.*)\\n\\n)?/\n\n// https://regexr.com/80gf9\nconst suffixRegex =\n /(?:URI: (?<uri>.+))\\n(?:Version: (?<version>.+))\\n(?:Chain ID: (?<chainId>\\d+))\\n(?:Nonce: (?<nonce>[a-zA-Z0-9]+))\\n(?:Issued At: (?<issuedAt>.+))(?:\\nExpiration Time: (?<expirationTime>.+))?(?:\\nNot Before: (?<notBefore>.+))?(?:\\nRequest ID: (?<requestId>.+))?/\n", "import type { Address } from 'abitype'\n\nimport type { ExactPartial } from '../../types/utils.js'\nimport { isAddressEqual } from '../address/isAddressEqual.js'\nimport type { SiweMessage } from './types.js'\n\nexport type ValidateSiweMessageParameters = {\n /**\n * Ethereum address to check against.\n */\n address?: Address | undefined\n /**\n * [RFC 3986](https://www.rfc-editor.org/rfc/rfc3986) authority to check against.\n */\n domain?: string | undefined\n /**\n * EIP-4361 message fields.\n */\n message: ExactPartial<SiweMessage>\n /**\n * Random string to check against.\n */\n nonce?: string | undefined\n /**\n * [RFC 3986](https://www.rfc-editor.org/rfc/rfc3986#section-3.1) URI scheme to check against.\n */\n scheme?: string | undefined\n /**\n * Current time to check optional `expirationTime` and `notBefore` fields.\n *\n * @default new Date()\n */\n time?: Date | undefined\n}\n\nexport type ValidateSiweMessageReturnType = boolean\n\n/**\n * @description Validates EIP-4361 message.\n *\n * @see https://eips.ethereum.org/EIPS/eip-4361\n */\nexport function validateSiweMessage(\n parameters: ValidateSiweMessageParameters,\n): ValidateSiweMessageReturnType {\n const {\n address,\n domain,\n message,\n nonce,\n scheme,\n time = new Date(),\n } = parameters\n\n if (domain && message.domain !== domain) return false\n if (nonce && message.nonce !== nonce) return false\n if (scheme && message.scheme !== scheme) return false\n\n if (message.expirationTime && time >= message.expirationTime) return false\n if (message.notBefore && time < message.notBefore) return false\n\n try {\n if (!message.address) return false\n if (address && !isAddressEqual(message.address, address)) return false\n } catch {\n return false\n }\n\n return true\n}\n", "import type { Client } from '../../clients/createClient.js'\nimport type { Transport } from '../../clients/transports/createTransport.js'\nimport type { ErrorType } from '../../errors/utils.js'\nimport type { Chain } from '../../types/chain.js'\nimport type { Hex } from '../../types/misc.js'\nimport type { Prettify } from '../../types/utils.js'\nimport { hashMessage } from '../../utils/signature/hashMessage.js'\nimport type { HashMessageErrorType } from '../../utils/signature/hashMessage.js'\nimport { parseSiweMessage } from '../../utils/siwe/parseSiweMessage.js'\nimport {\n type ValidateSiweMessageParameters,\n validateSiweMessage,\n} from '../../utils/siwe/validateSiweMessage.js'\nimport {\n type VerifyHashErrorType,\n type VerifyHashParameters,\n verifyHash,\n} from '../public/verifyHash.js'\n\nexport type VerifySiweMessageParameters = Prettify<\n Pick<VerifyHashParameters, 'blockNumber' | 'blockTag'> &\n Pick<\n ValidateSiweMessageParameters,\n 'address' | 'domain' | 'nonce' | 'scheme' | 'time'\n > & {\n /**\n * EIP-4361 formatted message.\n */\n message: string\n /**\n * Signature to check against.\n */\n signature: Hex\n }\n>\n\nexport type VerifySiweMessageReturnType = boolean\n\nexport type VerifySiweMessageErrorType =\n | HashMessageErrorType\n | VerifyHashErrorType\n | ErrorType\n\n/**\n * Verifies [EIP-4361](https://eips.ethereum.org/EIPS/eip-4361) formatted message was signed.\n *\n * Compatible with Smart Contract Accounts & Externally Owned Accounts via [ERC-6492](https://eips.ethereum.org/EIPS/eip-6492).\n *\n * - Docs {@link https://viem.sh/docs/siwe/actions/verifySiweMessage}\n *\n * @param client - Client to use.\n * @param parameters - {@link VerifySiweMessageParameters}\n * @returns Whether or not the signature is valid. {@link VerifySiweMessageReturnType}\n */\nexport async function verifySiweMessage<chain extends Chain | undefined>(\n client: Client<Transport, chain>,\n parameters: VerifySiweMessageParameters,\n): Promise<VerifySiweMessageReturnType> {\n const {\n address,\n domain,\n message,\n nonce,\n scheme,\n signature,\n time = new Date(),\n ...callRequest\n } = parameters\n\n const parsed = parseSiweMessage(message)\n if (!parsed.address) return false\n\n const isValid = validateSiweMessage({\n address,\n domain,\n message: parsed,\n nonce,\n scheme,\n time,\n })\n if (!isValid) return false\n\n const hash = hashMessage(message)\n return verifyHash(client, {\n address: parsed.address,\n hash,\n signature,\n ...callRequest,\n })\n}\n", "import type { Abi, AbiEvent, Address } from 'abitype'\n\nimport {\n type GetEnsAddressParameters,\n type GetEnsAddressReturnType,\n getEnsAddress,\n} from '../../actions/ens/getEnsAddress.js'\nimport {\n type GetEnsAvatarParameters,\n type GetEnsAvatarReturnType,\n getEnsAvatar,\n} from '../../actions/ens/getEnsAvatar.js'\nimport {\n type GetEnsNameParameters,\n type GetEnsNameReturnType,\n getEnsName,\n} from '../../actions/ens/getEnsName.js'\nimport {\n type GetEnsResolverParameters,\n type GetEnsResolverReturnType,\n getEnsResolver,\n} from '../../actions/ens/getEnsResolver.js'\nimport {\n type GetEnsTextParameters,\n type GetEnsTextReturnType,\n getEnsText,\n} from '../../actions/ens/getEnsText.js'\nimport {\n type CallParameters,\n type CallReturnType,\n call,\n} from '../../actions/public/call.js'\nimport {\n type CreateAccessListParameters,\n type CreateAccessListReturnType,\n createAccessList,\n} from '../../actions/public/createAccessList.js'\nimport {\n type CreateBlockFilterReturnType,\n createBlockFilter,\n} from '../../actions/public/createBlockFilter.js'\nimport {\n type CreateContractEventFilterParameters,\n type CreateContractEventFilterReturnType,\n createContractEventFilter,\n} from '../../actions/public/createContractEventFilter.js'\nimport {\n type CreateEventFilterParameters,\n type CreateEventFilterReturnType,\n createEventFilter,\n} from '../../actions/public/createEventFilter.js'\nimport {\n type CreatePendingTransactionFilterReturnType,\n createPendingTransactionFilter,\n} from '../../actions/public/createPendingTransactionFilter.js'\nimport {\n type EstimateContractGasParameters,\n type EstimateContractGasReturnType,\n estimateContractGas,\n} from '../../actions/public/estimateContractGas.js'\nimport {\n type EstimateFeesPerGasParameters,\n type EstimateFeesPerGasReturnType,\n estimateFeesPerGas,\n} from '../../actions/public/estimateFeesPerGas.js'\nimport {\n type EstimateGasParameters,\n type EstimateGasReturnType,\n estimateGas,\n} from '../../actions/public/estimateGas.js'\nimport {\n type EstimateMaxPriorityFeePerGasParameters,\n type EstimateMaxPriorityFeePerGasReturnType,\n estimateMaxPriorityFeePerGas,\n} from '../../actions/public/estimateMaxPriorityFeePerGas.js'\nimport {\n type GetBalanceParameters,\n type GetBalanceReturnType,\n getBalance,\n} from '../../actions/public/getBalance.js'\nimport {\n type GetBlobBaseFeeReturnType,\n getBlobBaseFee,\n} from '../../actions/public/getBlobBaseFee.js'\nimport {\n type GetBlockParameters,\n type GetBlockReturnType,\n getBlock,\n} from '../../actions/public/getBlock.js'\nimport {\n type GetBlockNumberParameters,\n type GetBlockNumberReturnType,\n getBlockNumber,\n} from '../../actions/public/getBlockNumber.js'\nimport {\n type GetBlockTransactionCountParameters,\n type GetBlockTransactionCountReturnType,\n getBlockTransactionCount,\n} from '../../actions/public/getBlockTransactionCount.js'\nimport {\n type GetChainIdReturnType,\n getChainId,\n} from '../../actions/public/getChainId.js'\nimport {\n type GetCodeParameters,\n type GetCodeReturnType,\n getCode,\n} from '../../actions/public/getCode.js'\nimport {\n type GetContractEventsParameters,\n type GetContractEventsReturnType,\n getContractEvents,\n} from '../../actions/public/getContractEvents.js'\nimport {\n type GetEip712DomainParameters,\n type GetEip712DomainReturnType,\n getEip712Domain,\n} from '../../actions/public/getEip712Domain.js'\nimport {\n type GetFeeHistoryParameters,\n type GetFeeHistoryReturnType,\n getFeeHistory,\n} from '../../actions/public/getFeeHistory.js'\nimport {\n type GetFilterChangesParameters,\n type GetFilterChangesReturnType,\n getFilterChanges,\n} from '../../actions/public/getFilterChanges.js'\nimport {\n type GetFilterLogsParameters,\n type GetFilterLogsReturnType,\n getFilterLogs,\n} from '../../actions/public/getFilterLogs.js'\nimport {\n type GetGasPriceReturnType,\n getGasPrice,\n} from '../../actions/public/getGasPrice.js'\nimport {\n type GetLogsParameters,\n type GetLogsReturnType,\n getLogs,\n} from '../../actions/public/getLogs.js'\nimport {\n type GetProofParameters,\n type GetProofReturnType,\n getProof,\n} from '../../actions/public/getProof.js'\nimport {\n type GetStorageAtParameters,\n type GetStorageAtReturnType,\n getStorageAt,\n} from '../../actions/public/getStorageAt.js'\nimport {\n type GetTransactionParameters,\n type GetTransactionReturnType,\n getTransaction,\n} from '../../actions/public/getTransaction.js'\nimport {\n type GetTransactionConfirmationsParameters,\n type GetTransactionConfirmationsReturnType,\n getTransactionConfirmations,\n} from '../../actions/public/getTransactionConfirmations.js'\nimport {\n type GetTransactionCountParameters,\n type GetTransactionCountReturnType,\n getTransactionCount,\n} from '../../actions/public/getTransactionCount.js'\nimport {\n type GetTransactionReceiptParameters,\n type GetTransactionReceiptReturnType,\n getTransactionReceipt,\n} from '../../actions/public/getTransactionReceipt.js'\nimport {\n type MulticallParameters,\n type MulticallReturnType,\n multicall,\n} from '../../actions/public/multicall.js'\nimport {\n type ReadContractParameters,\n type ReadContractReturnType,\n readContract,\n} from '../../actions/public/readContract.js'\nimport {\n type SimulateBlocksParameters,\n type SimulateBlocksReturnType,\n simulateBlocks,\n} from '../../actions/public/simulateBlocks.js'\nimport {\n type SimulateCallsParameters,\n type SimulateCallsReturnType,\n simulateCalls,\n} from '../../actions/public/simulateCalls.js'\nimport {\n type SimulateContractParameters,\n type SimulateContractReturnType,\n simulateContract,\n} from '../../actions/public/simulateContract.js'\nimport {\n type UninstallFilterParameters,\n type UninstallFilterReturnType,\n uninstallFilter,\n} from '../../actions/public/uninstallFilter.js'\nimport {\n type VerifyMessageParameters,\n type VerifyMessageReturnType,\n verifyMessage,\n} from '../../actions/public/verifyMessage.js'\nimport {\n type VerifyTypedDataParameters,\n type VerifyTypedDataReturnType,\n verifyTypedData,\n} from '../../actions/public/verifyTypedData.js'\nimport {\n type WaitForTransactionReceiptParameters,\n type WaitForTransactionReceiptReturnType,\n waitForTransactionReceipt,\n} from '../../actions/public/waitForTransactionReceipt.js'\nimport {\n type WatchBlockNumberParameters,\n type WatchBlockNumberReturnType,\n watchBlockNumber,\n} from '../../actions/public/watchBlockNumber.js'\nimport {\n type WatchBlocksParameters,\n type WatchBlocksReturnType,\n watchBlocks,\n} from '../../actions/public/watchBlocks.js'\nimport {\n type WatchContractEventParameters,\n type WatchContractEventReturnType,\n watchContractEvent,\n} from '../../actions/public/watchContractEvent.js'\nimport {\n type WatchEventParameters,\n type WatchEventReturnType,\n watchEvent,\n} from '../../actions/public/watchEvent.js'\nimport {\n type WatchPendingTransactionsParameters,\n type WatchPendingTransactionsReturnType,\n watchPendingTransactions,\n} from '../../actions/public/watchPendingTransactions.js'\nimport {\n type VerifySiweMessageParameters,\n type VerifySiweMessageReturnType,\n verifySiweMessage,\n} from '../../actions/siwe/verifySiweMessage.js'\nimport {\n type PrepareTransactionRequestParameters,\n type PrepareTransactionRequestRequest,\n type PrepareTransactionRequestReturnType,\n prepareTransactionRequest,\n} from '../../actions/wallet/prepareTransactionRequest.js'\nimport {\n type SendRawTransactionParameters,\n type SendRawTransactionReturnType,\n sendRawTransaction,\n} from '../../actions/wallet/sendRawTransaction.js'\nimport type { Account } from '../../types/account.js'\nimport type { BlockNumber, BlockTag } from '../../types/block.js'\nimport type { Chain } from '../../types/chain.js'\nimport type {\n ContractEventName,\n ContractFunctionArgs,\n ContractFunctionName,\n MaybeAbiEventName,\n MaybeExtractEventArgsFromAbi,\n} from '../../types/contract.js'\nimport type { FeeValuesType } from '../../types/fee.js'\nimport type { FilterType } from '../../types/filter.js'\nimport type { Client } from '../createClient.js'\nimport type { Transport } from '../transports/createTransport.js'\n\nexport type PublicActions<\n transport extends Transport = Transport,\n chain extends Chain | undefined = Chain | undefined,\n account extends Account | undefined = Account | undefined,\n> = {\n /**\n * Executes a new message call immediately without submitting a transaction to the network.\n *\n * - Docs: https://viem.sh/docs/actions/public/call\n * - JSON-RPC Methods: [`eth_call`](https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_call)\n *\n * @param args - {@link CallParameters}\n * @returns The call data. {@link CallReturnType}\n *\n * @example\n * import { createPublicClient, http } from 'viem'\n * import { mainnet } from 'viem/chains'\n *\n * const client = createPublicClient({\n * chain: mainnet,\n * transport: http(),\n * })\n * const data = await client.call({\n * account: '0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266',\n * data: '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',\n * to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8',\n * })\n */\n call: (parameters: CallParameters<chain>) => Promise<CallReturnType>\n /**\n * Creates an EIP-2930 access list that you can include in a transaction.\n *\n * - Docs: https://viem.sh/docs/actions/public/createAccessList\n * - JSON-RPC Methods: `eth_createAccessList`\n *\n * @param args - {@link CreateAccessListParameters}\n * @returns The call data. {@link CreateAccessListReturnType}\n *\n * @example\n * import { createPublicClient, http } from 'viem'\n * import { mainnet } from 'viem/chains'\n *\n * const client = createPublicClient({\n * chain: mainnet,\n * transport: http(),\n * })\n *\n * const data = await client.createAccessList({\n * data: '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',\n * to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8',\n * })\n */\n createAccessList: (\n parameters: CreateAccessListParameters<chain>,\n ) => Promise<CreateAccessListReturnType>\n /**\n * Creates a Filter to listen for new block hashes that can be used with [`getFilterChanges`](https://viem.sh/docs/actions/public/getFilterChanges).\n *\n * - Docs: https://viem.sh/docs/actions/public/createBlockFilter\n * - JSON-RPC Methods: [`eth_newBlockFilter`](https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_newBlockFilter)\n *\n * @returns Filter. {@link CreateBlockFilterReturnType}\n *\n * @example\n * import { createPublicClient, createBlockFilter, http } from 'viem'\n * import { mainnet } from 'viem/chains'\n *\n * const client = createPublicClient({\n * chain: mainnet,\n * transport: http(),\n * })\n * const filter = await createBlockFilter(client)\n * // { id: \"0x345a6572337856574a76364e457a4366\", type: 'block' }\n */\n createBlockFilter: () => Promise<CreateBlockFilterReturnType>\n /**\n * Creates a Filter to retrieve event logs that can be used with [`getFilterChanges`](https://viem.sh/docs/actions/public/getFilterChanges) or [`getFilterLogs`](https://viem.sh/docs/actions/public/getFilterLogs).\n *\n * - Docs: https://viem.sh/docs/contract/createContractEventFilter\n *\n * @param args - {@link CreateContractEventFilterParameters}\n * @returns [`Filter`](https://viem.sh/docs/glossary/types#filter). {@link CreateContractEventFilterReturnType}\n *\n * @example\n * import { createPublicClient, http, parseAbi } from 'viem'\n * import { mainnet } from 'viem/chains'\n *\n * const client = createPublicClient({\n * chain: mainnet,\n * transport: http(),\n * })\n * const filter = await client.createContractEventFilter({\n * abi: parseAbi(['event Transfer(address indexed, address indexed, uint256)']),\n * })\n */\n createContractEventFilter: <\n const abi extends Abi | readonly unknown[],\n eventName extends ContractEventName<abi> | undefined,\n args extends MaybeExtractEventArgsFromAbi<abi, eventName> | undefined,\n strict extends boolean | undefined = undefined,\n fromBlock extends BlockNumber | BlockTag | undefined = undefined,\n toBlock extends BlockNumber | BlockTag | undefined = undefined,\n >(\n args: CreateContractEventFilterParameters<\n abi,\n eventName,\n args,\n strict,\n fromBlock,\n toBlock\n >,\n ) => Promise<\n CreateContractEventFilterReturnType<\n abi,\n eventName,\n args,\n strict,\n fromBlock,\n toBlock\n >\n >\n /**\n * Creates a [`Filter`](https://viem.sh/docs/glossary/types#filter) to listen for new events that can be used with [`getFilterChanges`](https://viem.sh/docs/actions/public/getFilterChanges).\n *\n * - Docs: https://viem.sh/docs/actions/public/createEventFilter\n * - JSON-RPC Methods: [`eth_newFilter`](https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_newfilter)\n *\n * @param args - {@link CreateEventFilterParameters}\n * @returns [`Filter`](https://viem.sh/docs/glossary/types#filter). {@link CreateEventFilterReturnType}\n *\n * @example\n * import { createPublicClient, http } from 'viem'\n * import { mainnet } from 'viem/chains'\n *\n * const client = createPublicClient({\n * chain: mainnet,\n * transport: http(),\n * })\n * const filter = await client.createEventFilter({\n * address: '0xfba3912ca04dd458c843e2ee08967fc04f3579c2',\n * })\n */\n createEventFilter: <\n const abiEvent extends AbiEvent | undefined = undefined,\n const abiEvents extends\n | readonly AbiEvent[]\n | readonly unknown[]\n | undefined = abiEvent extends AbiEvent ? [abiEvent] : undefined,\n strict extends boolean | undefined = undefined,\n fromBlock extends BlockNumber | BlockTag | undefined = undefined,\n toBlock extends BlockNumber | BlockTag | undefined = undefined,\n _EventName extends string | undefined = MaybeAbiEventName<abiEvent>,\n _Args extends\n | MaybeExtractEventArgsFromAbi<abiEvents, _EventName>\n | undefined = undefined,\n >(\n args?:\n | CreateEventFilterParameters<\n abiEvent,\n abiEvents,\n strict,\n fromBlock,\n toBlock,\n _EventName,\n _Args\n >\n | undefined,\n ) => Promise<\n CreateEventFilterReturnType<\n abiEvent,\n abiEvents,\n strict,\n fromBlock,\n toBlock,\n _EventName,\n _Args\n >\n >\n /**\n * Creates a Filter to listen for new pending transaction hashes that can be used with [`getFilterChanges`](https://viem.sh/docs/actions/public/getFilterChanges).\n *\n * - Docs: https://viem.sh/docs/actions/public/createPendingTransactionFilter\n * - JSON-RPC Methods: [`eth_newPendingTransactionFilter`](https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_newpendingtransactionfilter)\n *\n * @returns [`Filter`](https://viem.sh/docs/glossary/types#filter). {@link CreateBlockFilterReturnType}\n *\n * @example\n * import { createPublicClient, http } from 'viem'\n * import { mainnet } from 'viem/chains'\n *\n * const client = createPublicClient({\n * chain: mainnet,\n * transport: http(),\n * })\n * const filter = await client.createPendingTransactionFilter()\n * // { id: \"0x345a6572337856574a76364e457a4366\", type: 'transaction' }\n */\n createPendingTransactionFilter: () => Promise<CreatePendingTransactionFilterReturnType>\n /**\n * Estimates the gas required to successfully execute a contract write function call.\n *\n * - Docs: https://viem.sh/docs/contract/estimateContractGas\n *\n * @remarks\n * Internally, uses a [Public Client](https://viem.sh/docs/clients/public) to call the [`estimateGas` action](https://viem.sh/docs/actions/public/estimateGas) with [ABI-encoded `data`](https://viem.sh/docs/contract/encodeFunctionData).\n *\n * @param args - {@link EstimateContractGasParameters}\n * @returns The gas estimate (in wei). {@link EstimateContractGasReturnType}\n *\n * @example\n * import { createPublicClient, http, parseAbi } from 'viem'\n * import { mainnet } from 'viem/chains'\n *\n * const client = createPublicClient({\n * chain: mainnet,\n * transport: http(),\n * })\n * const gas = await client.estimateContractGas({\n * address: '0xFBA3912Ca04dd458c843e2EE08967fC04f3579c2',\n * abi: parseAbi(['function mint() public']),\n * functionName: 'mint',\n * account: '0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266',\n * })\n */\n estimateContractGas: <\n chain extends Chain | undefined,\n const abi extends Abi | readonly unknown[],\n functionName extends ContractFunctionName<abi, 'nonpayable' | 'payable'>,\n args extends ContractFunctionArgs<\n abi,\n 'nonpayable' | 'payable',\n functionName\n >,\n >(\n args: EstimateContractGasParameters<abi, functionName, args, chain>,\n ) => Promise<EstimateContractGasReturnType>\n /**\n * Estimates the gas necessary to complete a transaction without submitting it to the network.\n *\n * - Docs: https://viem.sh/docs/actions/public/estimateGas\n * - JSON-RPC Methods: [`eth_estimateGas`](https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_estimategas)\n *\n * @param args - {@link EstimateGasParameters}\n * @returns The gas estimate (in wei). {@link EstimateGasReturnType}\n *\n * @example\n * import { createPublicClient, http, parseEther } from 'viem'\n * import { mainnet } from 'viem/chains'\n *\n * const client = createPublicClient({\n * chain: mainnet,\n * transport: http(),\n * })\n * const gasEstimate = await client.estimateGas({\n * account: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e',\n * to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8',\n * value: parseEther('1'),\n * })\n */\n estimateGas: (\n args: EstimateGasParameters<chain>,\n ) => Promise<EstimateGasReturnType>\n /**\n * Returns the balance of an address in wei.\n *\n * - Docs: https://viem.sh/docs/actions/public/getBalance\n * - JSON-RPC Methods: [`eth_getBalance`](https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_getbalance)\n *\n * @remarks\n * You can convert the balance to ether units with [`formatEther`](https://viem.sh/docs/utilities/formatEther).\n *\n * ```ts\n * const balance = await getBalance(client, {\n * address: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e',\n * blockTag: 'safe'\n * })\n * const balanceAsEther = formatEther(balance)\n * // \"6.942\"\n * ```\n *\n * @param args - {@link GetBalanceParameters}\n * @returns The balance of the address in wei. {@link GetBalanceReturnType}\n *\n * @example\n * import { createPublicClient, http } from 'viem'\n * import { mainnet } from 'viem/chains'\n *\n * const client = createPublicClient({\n * chain: mainnet,\n * transport: http(),\n * })\n * const balance = await client.getBalance({\n * address: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e',\n * })\n * // 10000000000000000000000n (wei)\n */\n getBalance: (args: GetBalanceParameters) => Promise<GetBalanceReturnType>\n /**\n * Returns the base fee per blob gas in wei.\n *\n * - Docs: https://viem.sh/docs/actions/public/getBlobBaseFee\n * - JSON-RPC Methods: [`eth_blobBaseFee`](https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_blobBaseFee)\n *\n * @param client - Client to use\n * @returns The blob base fee (in wei). {@link GetBlobBaseFeeReturnType}\n *\n * @example\n * import { createPublicClient, http } from 'viem'\n * import { mainnet } from 'viem/chains'\n * import { getBlobBaseFee } from 'viem/public'\n *\n * const client = createPublicClient({\n * chain: mainnet,\n * transport: http(),\n * })\n * const blobBaseFee = await client.getBlobBaseFee()\n */\n getBlobBaseFee: () => Promise<GetBlobBaseFeeReturnType>\n /**\n * Returns information about a block at a block number, hash, or tag.\n *\n * - Docs: https://viem.sh/docs/actions/public/getBlock\n * - Examples: https://stackblitz.com/github/wevm/viem/tree/main/examples/blocks_fetching-blocks\n * - JSON-RPC Methods:\n * - Calls [`eth_getBlockByNumber`](https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_getblockbynumber) for `blockNumber` & `blockTag`.\n * - Calls [`eth_getBlockByHash`](https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_getblockbyhash) for `blockHash`.\n *\n * @param args - {@link GetBlockParameters}\n * @returns Information about the block. {@link GetBlockReturnType}\n *\n * @example\n * import { createPublicClient, http } from 'viem'\n * import { mainnet } from 'viem/chains'\n *\n * const client = createPublicClient({\n * chain: mainnet,\n * transport: http(),\n * })\n * const block = await client.getBlock()\n */\n getBlock: <\n includeTransactions extends boolean = false,\n blockTag extends BlockTag = 'latest',\n >(\n args?: GetBlockParameters<includeTransactions, blockTag> | undefined,\n ) => Promise<GetBlockReturnType<chain, includeTransactions, blockTag>>\n /**\n * Returns the number of the most recent block seen.\n *\n * - Docs: https://viem.sh/docs/actions/public/getBlockNumber\n * - Examples: https://stackblitz.com/github/wevm/viem/tree/main/examples/blocks_fetching-blocks\n * - JSON-RPC Methods: [`eth_blockNumber`](https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_blocknumber)\n *\n * @param args - {@link GetBlockNumberParameters}\n * @returns The number of the block. {@link GetBlockNumberReturnType}\n *\n * @example\n * import { createPublicClient, http } from 'viem'\n * import { mainnet } from 'viem/chains'\n *\n * const client = createPublicClient({\n * chain: mainnet,\n * transport: http(),\n * })\n * const blockNumber = await client.getBlockNumber()\n * // 69420n\n */\n getBlockNumber: (\n args?: GetBlockNumberParameters | undefined,\n ) => Promise<GetBlockNumberReturnType>\n /**\n * Returns the number of Transactions at a block number, hash, or tag.\n *\n * - Docs: https://viem.sh/docs/actions/public/getBlockTransactionCount\n * - JSON-RPC Methods:\n * - Calls [`eth_getBlockTransactionCountByNumber`](https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_getblocktransactioncountbynumber) for `blockNumber` & `blockTag`.\n * - Calls [`eth_getBlockTransactionCountByHash`](https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_getblocktransactioncountbyhash) for `blockHash`.\n *\n * @param args - {@link GetBlockTransactionCountParameters}\n * @returns The block transaction count. {@link GetBlockTransactionCountReturnType}\n *\n * @example\n * import { createPublicClient, http } from 'viem'\n * import { mainnet } from 'viem/chains'\n *\n * const client = createPublicClient({\n * chain: mainnet,\n * transport: http(),\n * })\n * const count = await client.getBlockTransactionCount()\n */\n getBlockTransactionCount: (\n args?: GetBlockTransactionCountParameters | undefined,\n ) => Promise<GetBlockTransactionCountReturnType>\n /** @deprecated Use `getCode` instead. */\n getBytecode: (args: GetCodeParameters) => Promise<GetCodeReturnType>\n /**\n * Returns the chain ID associated with the current network.\n *\n * - Docs: https://viem.sh/docs/actions/public/getChainId\n * - JSON-RPC Methods: [`eth_chainId`](https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_chainid)\n *\n * @returns The current chain ID. {@link GetChainIdReturnType}\n *\n * @example\n * import { createPublicClient, http } from 'viem'\n * import { mainnet } from 'viem/chains'\n *\n * const client = createPublicClient({\n * chain: mainnet,\n * transport: http(),\n * })\n * const chainId = await client.getChainId()\n * // 1\n */\n getChainId: () => Promise<GetChainIdReturnType>\n /**\n * Retrieves the bytecode at an address.\n *\n * - Docs: https://viem.sh/docs/contract/getCode\n * - JSON-RPC Methods: [`eth_getCode`](https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_getcode)\n *\n * @param args - {@link GetBytecodeParameters}\n * @returns The contract's bytecode. {@link GetBytecodeReturnType}\n *\n * @example\n * import { createPublicClient, http } from 'viem'\n * import { mainnet } from 'viem/chains'\n *\n * const client = createPublicClient({\n * chain: mainnet,\n * transport: http(),\n * })\n * const code = await client.getCode({\n * address: '0xFBA3912Ca04dd458c843e2EE08967fC04f3579c2',\n * })\n */\n getCode: (args: GetCodeParameters) => Promise<GetCodeReturnType>\n /**\n * Returns a list of event logs emitted by a contract.\n *\n * - Docs: https://viem.sh/docs/actions/public/getContractEvents\n * - JSON-RPC Methods: [`eth_getLogs`](https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_getlogs)\n *\n * @param client - Client to use\n * @param parameters - {@link GetContractEventsParameters}\n * @returns A list of event logs. {@link GetContractEventsReturnType}\n *\n * @example\n * import { createPublicClient, http } from 'viem'\n * import { mainnet } from 'viem/chains'\n * import { wagmiAbi } from './abi'\n *\n * const client = createPublicClient({\n * chain: mainnet,\n * transport: http(),\n * })\n * const logs = await client.getContractEvents(client, {\n * address: '0xFBA3912Ca04dd458c843e2EE08967fC04f3579c2',\n * abi: wagmiAbi,\n * eventName: 'Transfer'\n * })\n */\n getContractEvents: <\n const abi extends Abi | readonly unknown[],\n eventName extends ContractEventName<abi> | undefined = undefined,\n strict extends boolean | undefined = undefined,\n fromBlock extends BlockNumber | BlockTag | undefined = undefined,\n toBlock extends BlockNumber | BlockTag | undefined = undefined,\n >(\n args: GetContractEventsParameters<\n abi,\n eventName,\n strict,\n fromBlock,\n toBlock\n >,\n ) => Promise<\n GetContractEventsReturnType<abi, eventName, strict, fromBlock, toBlock>\n >\n /**\n * Reads the EIP-712 domain from a contract, based on the ERC-5267 specification.\n *\n * @param client - A {@link Client} instance.\n * @param parameters - The parameters of the action. {@link GetEip712DomainParameters}\n * @returns The EIP-712 domain, fields, and extensions. {@link GetEip712DomainReturnType}\n *\n * @example\n * ```ts\n * import { createPublicClient, http } from 'viem'\n * import { mainnet } from 'viem/chains'\n *\n * const client = createPublicClient({\n * chain: mainnet,\n * transport: http(),\n * })\n *\n * const domain = await client.getEip712Domain({\n * address: '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48',\n * })\n * // {\n * // domain: {\n * // name: 'ExampleContract',\n * // version: '1',\n * // chainId: 1,\n * // verifyingContract: '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48',\n * // },\n * // fields: '0x0f',\n * // extensions: [],\n * // }\n * ```\n */\n getEip712Domain: (\n args: GetEip712DomainParameters,\n ) => Promise<GetEip712DomainReturnType>\n /**\n * Gets address for ENS name.\n *\n * - Docs: https://viem.sh/docs/ens/actions/getEnsAddress\n * - Examples: https://stackblitz.com/github/wevm/viem/tree/main/examples/ens\n *\n * @remarks\n * Calls `resolve(bytes, bytes)` on ENS Universal Resolver Contract.\n *\n * Since ENS names prohibit certain forbidden characters (e.g. underscore) and have other validation rules, you likely want to [normalize ENS names](https://docs.ens.domains/contract-api-reference/name-processing#normalising-names) with [UTS-46 normalization](https://unicode.org/reports/tr46) before passing them to `getEnsAddress`. You can use the built-in [`normalize`](https://viem.sh/docs/ens/utilities/normalize) function for this.\n *\n * @param args - {@link GetEnsAddressParameters}\n * @returns Address for ENS name or `null` if not found. {@link GetEnsAddressReturnType}\n *\n * @example\n * import { createPublicClient, http } from 'viem'\n * import { mainnet } from 'viem/chains'\n * import { normalize } from 'viem/ens'\n *\n * const client = createPublicClient({\n * chain: mainnet,\n * transport: http(),\n * })\n * const ensAddress = await client.getEnsAddress({\n * name: normalize('wevm.eth'),\n * })\n * // '0xd2135CfB216b74109775236E36d4b433F1DF507B'\n */\n getEnsAddress: (\n args: GetEnsAddressParameters,\n ) => Promise<GetEnsAddressReturnType>\n /**\n * Gets the avatar of an ENS name.\n *\n * - Docs: https://viem.sh/docs/ens/actions/getEnsAvatar\n * - Examples: https://stackblitz.com/github/wevm/viem/tree/main/examples/ens\n *\n * @remarks\n * Calls [`getEnsText`](https://viem.sh/docs/ens/actions/getEnsText) with `key` set to `'avatar'`.\n *\n * Since ENS names prohibit certain forbidden characters (e.g. underscore) and have other validation rules, you likely want to [normalize ENS names](https://docs.ens.domains/contract-api-reference/name-processing#normalising-names) with [UTS-46 normalization](https://unicode.org/reports/tr46) before passing them to `getEnsAddress`. You can use the built-in [`normalize`](https://viem.sh/docs/ens/utilities/normalize) function for this.\n *\n * @param args - {@link GetEnsAvatarParameters}\n * @returns Avatar URI or `null` if not found. {@link GetEnsAvatarReturnType}\n *\n * @example\n * import { createPublicClient, http } from 'viem'\n * import { mainnet } from 'viem/chains'\n * import { normalize } from 'viem/ens'\n *\n * const client = createPublicClient({\n * chain: mainnet,\n * transport: http(),\n * })\n * const ensAvatar = await client.getEnsAvatar({\n * name: normalize('wevm.eth'),\n * })\n * // 'https://ipfs.io/ipfs/Qma8mnp6xV3J2cRNf3mTth5C8nV11CAnceVinc3y8jSbio'\n */\n getEnsAvatar: (\n args: GetEnsAvatarParameters,\n ) => Promise<GetEnsAvatarReturnType>\n /**\n * Gets primary name for specified address.\n *\n * - Docs: https://viem.sh/docs/ens/actions/getEnsName\n * - Examples: https://stackblitz.com/github/wevm/viem/tree/main/examples/ens\n *\n * @remarks\n * Calls `reverse(bytes)` on ENS Universal Resolver Contract to \"reverse resolve\" the address to the primary ENS name.\n *\n * @param args - {@link GetEnsNameParameters}\n * @returns Name or `null` if not found. {@link GetEnsNameReturnType}\n *\n * @example\n * import { createPublicClient, http } from 'viem'\n * import { mainnet } from 'viem/chains'\n *\n * const client = createPublicClient({\n * chain: mainnet,\n * transport: http(),\n * })\n * const ensName = await client.getEnsName({\n * address: '0xd2135CfB216b74109775236E36d4b433F1DF507B',\n * })\n * // 'wevm.eth'\n */\n getEnsName: (args: GetEnsNameParameters) => Promise<GetEnsNameReturnType>\n /**\n * Gets resolver for ENS name.\n *\n * - Docs: https://viem.sh/docs/ens/actions/getEnsResolver\n * - Examples: https://stackblitz.com/github/wevm/viem/tree/main/examples/ens\n *\n * @remarks\n * Calls `findResolver(bytes)` on ENS Universal Resolver Contract to retrieve the resolver of an ENS name.\n *\n * Since ENS names prohibit certain forbidden characters (e.g. underscore) and have other validation rules, you likely want to [normalize ENS names](https://docs.ens.domains/contract-api-reference/name-processing#normalising-names) with [UTS-46 normalization](https://unicode.org/reports/tr46) before passing them to `getEnsAddress`. You can use the built-in [`normalize`](https://viem.sh/docs/ens/utilities/normalize) function for this.\n *\n * @param args - {@link GetEnsResolverParameters}\n * @returns Address for ENS resolver. {@link GetEnsResolverReturnType}\n *\n * @example\n * import { createPublicClient, http } from 'viem'\n * import { mainnet } from 'viem/chains'\n * import { normalize } from 'viem/ens'\n *\n * const client = createPublicClient({\n * chain: mainnet,\n * transport: http(),\n * })\n * const resolverAddress = await client.getEnsResolver({\n * name: normalize('wevm.eth'),\n * })\n * // '0x4976fb03C32e5B8cfe2b6cCB31c09Ba78EBaBa41'\n */\n getEnsResolver: (\n args: GetEnsResolverParameters,\n ) => Promise<GetEnsResolverReturnType>\n /**\n * Gets a text record for specified ENS name.\n *\n * - Docs: https://viem.sh/docs/ens/actions/getEnsResolver\n * - Examples: https://stackblitz.com/github/wevm/viem/tree/main/examples/ens\n *\n * @remarks\n * Calls `resolve(bytes, bytes)` on ENS Universal Resolver Contract.\n *\n * Since ENS names prohibit certain forbidden characters (e.g. underscore) and have other validation rules, you likely want to [normalize ENS names](https://docs.ens.domains/contract-api-reference/name-processing#normalising-names) with [UTS-46 normalization](https://unicode.org/reports/tr46) before passing them to `getEnsAddress`. You can use the built-in [`normalize`](https://viem.sh/docs/ens/utilities/normalize) function for this.\n *\n * @param args - {@link GetEnsTextParameters}\n * @returns Address for ENS resolver. {@link GetEnsTextReturnType}\n *\n * @example\n * import { createPublicClient, http } from 'viem'\n * import { mainnet } from 'viem/chains'\n * import { normalize } from 'viem/ens'\n *\n * const client = createPublicClient({\n * chain: mainnet,\n * transport: http(),\n * })\n * const twitterRecord = await client.getEnsText({\n * name: normalize('wevm.eth'),\n * key: 'com.twitter',\n * })\n * // 'wevm_dev'\n */\n getEnsText: (args: GetEnsTextParameters) => Promise<GetEnsTextReturnType>\n /**\n * Returns a collection of historical gas information.\n *\n * - Docs: https://viem.sh/docs/actions/public/getFeeHistory\n * - JSON-RPC Methods: [`eth_feeHistory`](https://docs.alchemy.com/reference/eth-feehistory)\n *\n * @param args - {@link GetFeeHistoryParameters}\n * @returns The gas estimate (in wei). {@link GetFeeHistoryReturnType}\n *\n * @example\n * import { createPublicClient, http } from 'viem'\n * import { mainnet } from 'viem/chains'\n *\n * const client = createPublicClient({\n * chain: mainnet,\n * transport: http(),\n * })\n * const feeHistory = await client.getFeeHistory({\n * blockCount: 4,\n * rewardPercentiles: [25, 75],\n * })\n */\n getFeeHistory: (\n args: GetFeeHistoryParameters,\n ) => Promise<GetFeeHistoryReturnType>\n /**\n * Returns an estimate for the fees per gas for a transaction to be included\n * in the next block.\n *\n * - Docs: https://viem.sh/docs/actions/public/estimateFeesPerGas\n *\n * @param client - Client to use\n * @param parameters - {@link EstimateFeesPerGasParameters}\n * @returns An estimate (in wei) for the fees per gas. {@link EstimateFeesPerGasReturnType}\n *\n * @example\n * import { createPublicClient, http } from 'viem'\n * import { mainnet } from 'viem/chains'\n *\n * const client = createPublicClient({\n * chain: mainnet,\n * transport: http(),\n * })\n * const maxPriorityFeePerGas = await client.estimateFeesPerGas()\n * // { maxFeePerGas: ..., maxPriorityFeePerGas: ... }\n */\n estimateFeesPerGas: <\n chainOverride extends Chain | undefined = undefined,\n type extends FeeValuesType = 'eip1559',\n >(\n args?: EstimateFeesPerGasParameters<chain, chainOverride, type> | undefined,\n ) => Promise<EstimateFeesPerGasReturnType<type>>\n /**\n * Returns a list of logs or hashes based on a [Filter](/docs/glossary/terms#filter) since the last time it was called.\n *\n * - Docs: https://viem.sh/docs/actions/public/getFilterChanges\n * - JSON-RPC Methods: [`eth_getFilterChanges`](https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_getfilterchanges)\n *\n * @remarks\n * A Filter can be created from the following actions:\n *\n * - [`createBlockFilter`](https://viem.sh/docs/actions/public/createBlockFilter)\n * - [`createContractEventFilter`](https://viem.sh/docs/contract/createContractEventFilter)\n * - [`createEventFilter`](https://viem.sh/docs/actions/public/createEventFilter)\n * - [`createPendingTransactionFilter`](https://viem.sh/docs/actions/public/createPendingTransactionFilter)\n *\n * Depending on the type of filter, the return value will be different:\n *\n * - If the filter was created with `createContractEventFilter` or `createEventFilter`, it returns a list of logs.\n * - If the filter was created with `createPendingTransactionFilter`, it returns a list of transaction hashes.\n * - If the filter was created with `createBlockFilter`, it returns a list of block hashes.\n *\n * @param args - {@link GetFilterChangesParameters}\n * @returns Logs or hashes. {@link GetFilterChangesReturnType}\n *\n * @example\n * // Blocks\n * import { createPublicClient, http } from 'viem'\n * import { mainnet } from 'viem/chains'\n *\n * const client = createPublicClient({\n * chain: mainnet,\n * transport: http(),\n * })\n * const filter = await client.createBlockFilter()\n * const hashes = await client.getFilterChanges({ filter })\n *\n * @example\n * // Contract Events\n * import { createPublicClient, http, parseAbi } from 'viem'\n * import { mainnet } from 'viem/chains'\n *\n * const client = createPublicClient({\n * chain: mainnet,\n * transport: http(),\n * })\n * const filter = await client.createContractEventFilter({\n * address: '0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',\n * abi: parseAbi(['event Transfer(address indexed, address indexed, uint256)']),\n * eventName: 'Transfer',\n * })\n * const logs = await client.getFilterChanges({ filter })\n *\n * @example\n * // Raw Events\n * import { createPublicClient, http, parseAbiItem } from 'viem'\n * import { mainnet } from 'viem/chains'\n *\n * const client = createPublicClient({\n * chain: mainnet,\n * transport: http(),\n * })\n * const filter = await client.createEventFilter({\n * address: '0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',\n * event: parseAbiItem('event Transfer(address indexed, address indexed, uint256)'),\n * })\n * const logs = await client.getFilterChanges({ filter })\n *\n * @example\n * // Transactions\n * import { createPublicClient, http } from 'viem'\n * import { mainnet } from 'viem/chains'\n *\n * const client = createPublicClient({\n * chain: mainnet,\n * transport: http(),\n * })\n * const filter = await client.createPendingTransactionFilter()\n * const hashes = await client.getFilterChanges({ filter })\n */\n getFilterChanges: <\n filterType extends FilterType,\n const abi extends Abi | readonly unknown[] | undefined,\n eventName extends string | undefined,\n strict extends boolean | undefined = undefined,\n fromBlock extends BlockNumber | BlockTag | undefined = undefined,\n toBlock extends BlockNumber | BlockTag | undefined = undefined,\n >(\n args: GetFilterChangesParameters<\n filterType,\n abi,\n eventName,\n strict,\n fromBlock,\n toBlock\n >,\n ) => Promise<\n GetFilterChangesReturnType<\n filterType,\n abi,\n eventName,\n strict,\n fromBlock,\n toBlock\n >\n >\n /**\n * Returns a list of event logs since the filter was created.\n *\n * - Docs: https://viem.sh/docs/actions/public/getFilterLogs\n * - JSON-RPC Methods: [`eth_getFilterLogs`](https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_getfilterlogs)\n *\n * @remarks\n * `getFilterLogs` is only compatible with **event filters**.\n *\n * @param args - {@link GetFilterLogsParameters}\n * @returns A list of event logs. {@link GetFilterLogsReturnType}\n *\n * @example\n * import { createPublicClient, http, parseAbiItem } from 'viem'\n * import { mainnet } from 'viem/chains'\n *\n * const client = createPublicClient({\n * chain: mainnet,\n * transport: http(),\n * })\n * const filter = await client.createEventFilter({\n * address: '0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',\n * event: parseAbiItem('event Transfer(address indexed, address indexed, uint256)'),\n * })\n * const logs = await client.getFilterLogs({ filter })\n */\n getFilterLogs: <\n const abi extends Abi | readonly unknown[] | undefined,\n eventName extends string | undefined,\n strict extends boolean | undefined = undefined,\n fromBlock extends BlockNumber | BlockTag | undefined = undefined,\n toBlock extends BlockNumber | BlockTag | undefined = undefined,\n >(\n args: GetFilterLogsParameters<abi, eventName, strict, fromBlock, toBlock>,\n ) => Promise<\n GetFilterLogsReturnType<abi, eventName, strict, fromBlock, toBlock>\n >\n /**\n * Returns the current price of gas (in wei).\n *\n * - Docs: https://viem.sh/docs/actions/public/getGasPrice\n * - JSON-RPC Methods: [`eth_gasPrice`](https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_gasprice)\n *\n * @returns The gas price (in wei). {@link GetGasPriceReturnType}\n *\n * @example\n * import { createPublicClient, http } from 'viem'\n * import { mainnet } from 'viem/chains'\n *\n * const client = createPublicClient({\n * chain: mainnet,\n * transport: http(),\n * })\n * const gasPrice = await client.getGasPrice()\n */\n getGasPrice: () => Promise<GetGasPriceReturnType>\n /**\n * Returns a list of event logs matching the provided parameters.\n *\n * - Docs: https://viem.sh/docs/actions/public/getLogs\n * - Examples: https://stackblitz.com/github/wevm/viem/tree/main/examples/logs_event-logs\n * - JSON-RPC Methods: [`eth_getLogs`](https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_getlogs)\n *\n * @param args - {@link GetLogsParameters}\n * @returns A list of event logs. {@link GetLogsReturnType}\n *\n * @example\n * import { createPublicClient, http, parseAbiItem } from 'viem'\n * import { mainnet } from 'viem/chains'\n *\n * const client = createPublicClient({\n * chain: mainnet,\n * transport: http(),\n * })\n * const logs = await client.getLogs()\n */\n getLogs: <\n const abiEvent extends AbiEvent | undefined = undefined,\n const abiEvents extends\n | readonly AbiEvent[]\n | readonly unknown[]\n | undefined = abiEvent extends AbiEvent ? [abiEvent] : undefined,\n strict extends boolean | undefined = undefined,\n fromBlock extends BlockNumber | BlockTag | undefined = undefined,\n toBlock extends BlockNumber | BlockTag | undefined = undefined,\n >(\n args?:\n | GetLogsParameters<abiEvent, abiEvents, strict, fromBlock, toBlock>\n | undefined,\n ) => Promise<\n GetLogsReturnType<abiEvent, abiEvents, strict, fromBlock, toBlock>\n >\n /**\n * Returns the account and storage values of the specified account including the Merkle-proof.\n *\n * - Docs: https://viem.sh/docs/actions/public/getProof\n * - JSON-RPC Methods:\n * - Calls [`eth_getProof`](https://eips.ethereum.org/EIPS/eip-1186)\n *\n * @param client - Client to use\n * @param parameters - {@link GetProofParameters}\n * @returns Proof data. {@link GetProofReturnType}\n *\n * @example\n * import { createPublicClient, http } from 'viem'\n * import { mainnet } from 'viem/chains'\n *\n * const client = createPublicClient({\n * chain: mainnet,\n * transport: http(),\n * })\n * const block = await client.getProof({\n * address: '0x...',\n * storageKeys: ['0x...'],\n * })\n */\n getProof: (args: GetProofParameters) => Promise<GetProofReturnType>\n /**\n * Returns an estimate for the max priority fee per gas (in wei) for a transaction\n * to be included in the next block.\n *\n * - Docs: https://viem.sh/docs/actions/public/estimateMaxPriorityFeePerGas\n *\n * @param client - Client to use\n * @returns An estimate (in wei) for the max priority fee per gas. {@link EstimateMaxPriorityFeePerGasReturnType}\n *\n * @example\n * import { createPublicClient, http } from 'viem'\n * import { mainnet } from 'viem/chains'\n *\n * const client = createPublicClient({\n * chain: mainnet,\n * transport: http(),\n * })\n * const maxPriorityFeePerGas = await client.estimateMaxPriorityFeePerGas()\n * // 10000000n\n */\n estimateMaxPriorityFeePerGas: <\n chainOverride extends Chain | undefined = undefined,\n >(\n args?:\n | EstimateMaxPriorityFeePerGasParameters<chain, chainOverride>\n | undefined,\n ) => Promise<EstimateMaxPriorityFeePerGasReturnType>\n /**\n * Returns the value from a storage slot at a given address.\n *\n * - Docs: https://viem.sh/docs/contract/getStorageAt\n * - JSON-RPC Methods: [`eth_getStorageAt`](https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_getstorageat)\n *\n * @param args - {@link GetStorageAtParameters}\n * @returns The value of the storage slot. {@link GetStorageAtReturnType}\n *\n * @example\n * import { createPublicClient, http } from 'viem'\n * import { mainnet } from 'viem/chains'\n * import { getStorageAt } from 'viem/contract'\n *\n * const client = createPublicClient({\n * chain: mainnet,\n * transport: http(),\n * })\n * const code = await client.getStorageAt({\n * address: '0xFBA3912Ca04dd458c843e2EE08967fC04f3579c2',\n * slot: toHex(0),\n * })\n */\n getStorageAt: (\n args: GetStorageAtParameters,\n ) => Promise<GetStorageAtReturnType>\n /**\n * Returns information about a [Transaction](https://viem.sh/docs/glossary/terms#transaction) given a hash or block identifier.\n *\n * - Docs: https://viem.sh/docs/actions/public/getTransaction\n * - Example: https://stackblitz.com/github/wevm/viem/tree/main/examples/transactions_fetching-transactions\n * - JSON-RPC Methods: [`eth_getTransactionByHash`](https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_getTransactionByHash)\n *\n * @param args - {@link GetTransactionParameters}\n * @returns The transaction information. {@link GetTransactionReturnType}\n *\n * @example\n * import { createPublicClient, http } from 'viem'\n * import { mainnet } from 'viem/chains'\n *\n * const client = createPublicClient({\n * chain: mainnet,\n * transport: http(),\n * })\n * const transaction = await client.getTransaction({\n * hash: '0x4ca7ee652d57678f26e887c149ab0735f41de37bcad58c9f6d3ed5824f15b74d',\n * })\n */\n getTransaction: <blockTag extends BlockTag = 'latest'>(\n args: GetTransactionParameters<blockTag>,\n ) => Promise<GetTransactionReturnType<chain, blockTag>>\n /**\n * Returns the number of blocks passed (confirmations) since the transaction was processed on a block.\n *\n * - Docs: https://viem.sh/docs/actions/public/getTransactionConfirmations\n * - Example: https://stackblitz.com/github/wevm/viem/tree/main/examples/transactions_fetching-transactions\n * - JSON-RPC Methods: [`eth_getTransactionConfirmations`](https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_getTransactionConfirmations)\n *\n * @param args - {@link GetTransactionConfirmationsParameters}\n * @returns The number of blocks passed since the transaction was processed. If confirmations is 0, then the Transaction has not been confirmed & processed yet. {@link GetTransactionConfirmationsReturnType}\n *\n * @example\n * import { createPublicClient, http } from 'viem'\n * import { mainnet } from 'viem/chains'\n *\n * const client = createPublicClient({\n * chain: mainnet,\n * transport: http(),\n * })\n * const confirmations = await client.getTransactionConfirmations({\n * hash: '0x4ca7ee652d57678f26e887c149ab0735f41de37bcad58c9f6d3ed5824f15b74d',\n * })\n */\n getTransactionConfirmations: (\n args: GetTransactionConfirmationsParameters<chain>,\n ) => Promise<GetTransactionConfirmationsReturnType>\n /**\n * Returns the number of [Transactions](https://viem.sh/docs/glossary/terms#transaction) an Account has broadcast / sent.\n *\n * - Docs: https://viem.sh/docs/actions/public/getTransactionCount\n * - JSON-RPC Methods: [`eth_getTransactionCount`](https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_gettransactioncount)\n *\n * @param args - {@link GetTransactionCountParameters}\n * @returns The number of transactions an account has sent. {@link GetTransactionCountReturnType}\n *\n * @example\n * import { createPublicClient, http } from 'viem'\n * import { mainnet } from 'viem/chains'\n *\n * const client = createPublicClient({\n * chain: mainnet,\n * transport: http(),\n * })\n * const transactionCount = await client.getTransactionCount({\n * address: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e',\n * })\n */\n getTransactionCount: (\n args: GetTransactionCountParameters,\n ) => Promise<GetTransactionCountReturnType>\n /**\n * Returns the [Transaction Receipt](https://viem.sh/docs/glossary/terms#transaction-receipt) given a [Transaction](https://viem.sh/docs/glossary/terms#transaction) hash.\n *\n * - Docs: https://viem.sh/docs/actions/public/getTransactionReceipt\n * - Example: https://stackblitz.com/github/wevm/viem/tree/main/examples/transactions_fetching-transactions\n * - JSON-RPC Methods: [`eth_getTransactionReceipt`](https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_getTransactionReceipt)\n *\n * @param args - {@link GetTransactionReceiptParameters}\n * @returns The transaction receipt. {@link GetTransactionReceiptReturnType}\n *\n * @example\n * import { createPublicClient, http } from 'viem'\n * import { mainnet } from 'viem/chains'\n *\n * const client = createPublicClient({\n * chain: mainnet,\n * transport: http(),\n * })\n * const transactionReceipt = await client.getTransactionReceipt({\n * hash: '0x4ca7ee652d57678f26e887c149ab0735f41de37bcad58c9f6d3ed5824f15b74d',\n * })\n */\n getTransactionReceipt: (\n args: GetTransactionReceiptParameters,\n ) => Promise<GetTransactionReceiptReturnType<chain>>\n /**\n * Similar to [`readContract`](https://viem.sh/docs/contract/readContract), but batches up multiple functions on a contract in a single RPC call via the [`multicall3` contract](https://github.com/mds1/multicall).\n *\n * - Docs: https://viem.sh/docs/contract/multicall\n *\n * @param args - {@link MulticallParameters}\n * @returns An array of results with accompanying status. {@link MulticallReturnType}\n *\n * @example\n * import { createPublicClient, http, parseAbi } from 'viem'\n * import { mainnet } from 'viem/chains'\n *\n * const client = createPublicClient({\n * chain: mainnet,\n * transport: http(),\n * })\n * const abi = parseAbi([\n * 'function balanceOf(address) view returns (uint256)',\n * 'function totalSupply() view returns (uint256)',\n * ])\n * const result = await client.multicall({\n * contracts: [\n * {\n * address: '0xFBA3912Ca04dd458c843e2EE08967fC04f3579c2',\n * abi,\n * functionName: 'balanceOf',\n * args: ['0xA0Cf798816D4b9b9866b5330EEa46a18382f251e'],\n * },\n * {\n * address: '0xFBA3912Ca04dd458c843e2EE08967fC04f3579c2',\n * abi,\n * functionName: 'totalSupply',\n * },\n * ],\n * })\n * // [{ result: 424122n, status: 'success' }, { result: 1000000n, status: 'success' }]\n */\n multicall: <\n const contracts extends readonly unknown[],\n allowFailure extends boolean = true,\n >(\n args: MulticallParameters<contracts, allowFailure>,\n ) => Promise<MulticallReturnType<contracts, allowFailure>>\n /**\n * Prepares a transaction request for signing.\n *\n * - Docs: https://viem.sh/docs/actions/wallet/prepareTransactionRequest\n *\n * @param args - {@link PrepareTransactionRequestParameters}\n * @returns The transaction request. {@link PrepareTransactionRequestReturnType}\n *\n * @example\n * import { createWalletClient, custom } from 'viem'\n * import { mainnet } from 'viem/chains'\n *\n * const client = createWalletClient({\n * chain: mainnet,\n * transport: custom(window.ethereum),\n * })\n * const request = await client.prepareTransactionRequest({\n * account: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e',\n * to: '0x0000000000000000000000000000000000000000',\n * value: 1n,\n * })\n *\n * @example\n * // Account Hoisting\n * import { createWalletClient, http } from 'viem'\n * import { privateKeyToAccount } from 'viem/accounts'\n * import { mainnet } from 'viem/chains'\n *\n * const client = createWalletClient({\n * account: privateKeyToAccount('0x…'),\n * chain: mainnet,\n * transport: custom(window.ethereum),\n * })\n * const request = await client.prepareTransactionRequest({\n * to: '0x0000000000000000000000000000000000000000',\n * value: 1n,\n * })\n */\n prepareTransactionRequest: <\n const request extends PrepareTransactionRequestRequest<\n chain,\n chainOverride\n >,\n chainOverride extends Chain | undefined = undefined,\n accountOverride extends Account | Address | undefined = undefined,\n >(\n args: PrepareTransactionRequestParameters<\n chain,\n account,\n chainOverride,\n accountOverride,\n request\n >,\n ) => Promise<\n PrepareTransactionRequestReturnType<\n chain,\n account,\n chainOverride,\n accountOverride,\n request\n >\n >\n /**\n * Calls a read-only function on a contract, and returns the response.\n *\n * - Docs: https://viem.sh/docs/contract/readContract\n * - Examples: https://stackblitz.com/github/wevm/viem/tree/main/examples/contracts_reading-contracts\n *\n * @remarks\n * A \"read-only\" function (constant function) on a Solidity contract is denoted by a `view` or `pure` keyword. They can only read the state of the contract, and cannot make any changes to it. Since read-only methods do not change the state of the contract, they do not require any gas to be executed, and can be called by any user without the need to pay for gas.\n *\n * Internally, uses a [Public Client](https://viem.sh/docs/clients/public) to call the [`call` action](https://viem.sh/docs/actions/public/call) with [ABI-encoded `data`](https://viem.sh/docs/contract/encodeFunctionData).\n *\n * @param args - {@link ReadContractParameters}\n * @returns The response from the contract. Type is inferred. {@link ReadContractReturnType}\n *\n * @example\n * import { createPublicClient, http, parseAbi } from 'viem'\n * import { mainnet } from 'viem/chains'\n * import { readContract } from 'viem/contract'\n *\n * const client = createPublicClient({\n * chain: mainnet,\n * transport: http(),\n * })\n * const result = await client.readContract({\n * address: '0xFBA3912Ca04dd458c843e2EE08967fC04f3579c2',\n * abi: parseAbi(['function balanceOf(address) view returns (uint256)']),\n * functionName: 'balanceOf',\n * args: ['0xA0Cf798816D4b9b9866b5330EEa46a18382f251e'],\n * })\n * // 424122n\n */\n readContract: <\n const abi extends Abi | readonly unknown[],\n functionName extends ContractFunctionName<abi, 'pure' | 'view'>,\n const args extends ContractFunctionArgs<abi, 'pure' | 'view', functionName>,\n >(\n args: ReadContractParameters<abi, functionName, args>,\n ) => Promise<ReadContractReturnType<abi, functionName, args>>\n /**\n * Sends a **signed** transaction to the network\n *\n * - Docs: https://viem.sh/docs/actions/wallet/sendRawTransaction\n * - JSON-RPC Method: [`eth_sendRawTransaction`](https://ethereum.github.io/execution-apis/api-documentation/)\n *\n * @param client - Client to use\n * @param parameters - {@link SendRawTransactionParameters}\n * @returns The transaction hash. {@link SendRawTransactionReturnType}\n *\n * @example\n * import { createWalletClient, custom } from 'viem'\n * import { mainnet } from 'viem/chains'\n * import { sendRawTransaction } from 'viem/wallet'\n *\n * const client = createWalletClient({\n * chain: mainnet,\n * transport: custom(window.ethereum),\n * })\n *\n * const hash = await client.sendRawTransaction({\n * serializedTransaction: '0x02f850018203118080825208808080c080a04012522854168b27e5dc3d5839bab5e6b39e1a0ffd343901ce1622e3d64b48f1a04e00902ae0502c4728cbf12156290df99c3ed7de85b1dbfe20b5c36931733a33'\n * })\n */\n sendRawTransaction: (\n args: SendRawTransactionParameters,\n ) => Promise<SendRawTransactionReturnType>\n /**\n * @deprecated Use `simulateBlocks` instead.\n */\n simulate: <const calls extends readonly unknown[]>(\n args: SimulateBlocksParameters<calls>,\n ) => Promise<SimulateBlocksReturnType<calls>>\n /**\n * Simulates a set of calls on block(s) with optional block and state overrides.\n *\n * @example\n * ```ts\n * import { createPublicClient, http, parseEther } from 'viem'\n * import { mainnet } from 'viem/chains'\n *\n * const client = createPublicClient({\n * chain: mainnet,\n * transport: http(),\n * })\n *\n * const result = await client.simulateBlocks({\n * blocks: [{\n * blockOverrides: {\n * number: 69420n,\n * },\n * calls: [{\n * {\n * account: '0x5a0b54d5dc17e482fe8b0bdca5320161b95fb929',\n * data: '0xdeadbeef',\n * to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8',\n * },\n * {\n * account: '0x5a0b54d5dc17e482fe8b0bdca5320161b95fb929',\n * to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8',\n * value: parseEther('1'),\n * },\n * }],\n * stateOverrides: [{\n * address: '0x5a0b54d5dc17e482fe8b0bdca5320161b95fb929',\n * balance: parseEther('10'),\n * }],\n * }]\n * })\n * ```\n *\n * @param client - Client to use.\n * @param parameters - {@link SimulateParameters}\n * @returns Simulated blocks. {@link SimulateReturnType}\n */\n simulateBlocks: <const calls extends readonly unknown[]>(\n args: SimulateBlocksParameters<calls>,\n ) => Promise<SimulateBlocksReturnType<calls>>\n /**\n * Simulates a set of calls.\n *\n * @example\n * ```ts\n * import { createPublicClient, http, parseEther } from 'viem'\n * import { mainnet } from 'viem/chains'\n *\n * const client = createPublicClient({\n * chain: mainnet,\n * transport: http(),\n * })\n *\n * const result = await client.simulateCalls({\n * account: '0x5a0b54d5dc17e482fe8b0bdca5320161b95fb929',\n * calls: [{\n * {\n * data: '0xdeadbeef',\n * to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8',\n * },\n * {\n * to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8',\n * value: parseEther('1'),\n * },\n * ]\n * })\n * ```\n *\n * @param client - Client to use.\n * @param parameters - {@link SimulateCallsParameters}\n * @returns Results. {@link SimulateCallsReturnType}\n */\n simulateCalls: <const calls extends readonly unknown[]>(\n args: SimulateCallsParameters<calls>,\n ) => Promise<SimulateCallsReturnType<calls>>\n /**\n * Simulates/validates a contract interaction. This is useful for retrieving **return data** and **revert reasons** of contract write functions.\n *\n * - Docs: https://viem.sh/docs/contract/simulateContract\n * - Examples: https://stackblitz.com/github/wevm/viem/tree/main/examples/contracts_writing-to-contracts\n *\n * @remarks\n * This function does not require gas to execute and _**does not**_ change the state of the blockchain. It is almost identical to [`readContract`](https://viem.sh/docs/contract/readContract), but also supports contract write functions.\n *\n * Internally, uses a [Public Client](https://viem.sh/docs/clients/public) to call the [`call` action](https://viem.sh/docs/actions/public/call) with [ABI-encoded `data`](https://viem.sh/docs/contract/encodeFunctionData).\n *\n * @param args - {@link SimulateContractParameters}\n * @returns The simulation result and write request. {@link SimulateContractReturnType}\n *\n * @example\n * import { createPublicClient, http } from 'viem'\n * import { mainnet } from 'viem/chains'\n *\n * const client = createPublicClient({\n * chain: mainnet,\n * transport: http(),\n * })\n * const result = await client.simulateContract({\n * address: '0xFBA3912Ca04dd458c843e2EE08967fC04f3579c2',\n * abi: parseAbi(['function mint(uint32) view returns (uint32)']),\n * functionName: 'mint',\n * args: ['69420'],\n * account: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e',\n * })\n */\n simulateContract: <\n const abi extends Abi | readonly unknown[],\n functionName extends ContractFunctionName<abi, 'nonpayable' | 'payable'>,\n const args extends ContractFunctionArgs<\n abi,\n 'nonpayable' | 'payable',\n functionName\n >,\n chainOverride extends Chain | undefined,\n accountOverride extends Account | Address | undefined = undefined,\n >(\n args: SimulateContractParameters<\n abi,\n functionName,\n args,\n chain,\n chainOverride,\n accountOverride\n >,\n ) => Promise<\n SimulateContractReturnType<\n abi,\n functionName,\n args,\n chain,\n account,\n chainOverride,\n accountOverride\n >\n >\n /**\n * Verify that a message was signed by the provided address.\n *\n * Compatible with Smart Contract Accounts & Externally Owned Accounts via [ERC-6492](https://eips.ethereum.org/EIPS/eip-6492).\n *\n * - Docs {@link https://viem.sh/docs/actions/public/verifyMessage}\n *\n * @param parameters - {@link VerifyMessageParameters}\n * @returns Whether or not the signature is valid. {@link VerifyMessageReturnType}\n */\n verifyMessage: (\n args: VerifyMessageParameters,\n ) => Promise<VerifyMessageReturnType>\n /**\n * Verifies [EIP-4361](https://eips.ethereum.org/EIPS/eip-4361) formatted message was signed.\n *\n * Compatible with Smart Contract Accounts & Externally Owned Accounts via [ERC-6492](https://eips.ethereum.org/EIPS/eip-6492).\n *\n * - Docs {@link https://viem.sh/docs/siwe/actions/verifySiweMessage}\n *\n * @param parameters - {@link VerifySiweMessageParameters}\n * @returns Whether or not the signature is valid. {@link VerifySiweMessageReturnType}\n */\n verifySiweMessage: (\n args: VerifySiweMessageParameters,\n ) => Promise<VerifySiweMessageReturnType>\n /**\n * Verify that typed data was signed by the provided address.\n *\n * - Docs {@link https://viem.sh/docs/actions/public/verifyTypedData}\n *\n * @param parameters - {@link VerifyTypedDataParameters}\n * @returns Whether or not the signature is valid. {@link VerifyTypedDataReturnType}\n */\n verifyTypedData: (\n args: VerifyTypedDataParameters,\n ) => Promise<VerifyTypedDataReturnType>\n /**\n * Destroys a Filter that was created from one of the following Actions:\n *\n * - [`createBlockFilter`](https://viem.sh/docs/actions/public/createBlockFilter)\n * - [`createEventFilter`](https://viem.sh/docs/actions/public/createEventFilter)\n * - [`createPendingTransactionFilter`](https://viem.sh/docs/actions/public/createPendingTransactionFilter)\n *\n * - Docs: https://viem.sh/docs/actions/public/uninstallFilter\n * - JSON-RPC Methods: [`eth_uninstallFilter`](https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_uninstallFilter)\n *\n * @param args - {@link UninstallFilterParameters}\n * @returns A boolean indicating if the Filter was successfully uninstalled. {@link UninstallFilterReturnType}\n *\n * @example\n * import { createPublicClient, http } from 'viem'\n * import { mainnet } from 'viem/chains'\n * import { createPendingTransactionFilter, uninstallFilter } from 'viem/public'\n *\n * const filter = await client.createPendingTransactionFilter()\n * const uninstalled = await client.uninstallFilter({ filter })\n * // true\n */\n uninstallFilter: (\n args: UninstallFilterParameters,\n ) => Promise<UninstallFilterReturnType>\n /**\n * Waits for the [Transaction](https://viem.sh/docs/glossary/terms#transaction) to be included on a [Block](https://viem.sh/docs/glossary/terms#block) (one confirmation), and then returns the [Transaction Receipt](https://viem.sh/docs/glossary/terms#transaction-receipt). If the Transaction reverts, then the action will throw an error.\n *\n * - Docs: https://viem.sh/docs/actions/public/waitForTransactionReceipt\n * - Example: https://stackblitz.com/github/wevm/viem/tree/main/examples/transactions_sending-transactions\n * - JSON-RPC Methods:\n * - Polls [`eth_getTransactionReceipt`](https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_getTransactionReceipt) on each block until it has been processed.\n * - If a Transaction has been replaced:\n * - Calls [`eth_getBlockByNumber`](https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_getblockbynumber) and extracts the transactions\n * - Checks if one of the Transactions is a replacement\n * - If so, calls [`eth_getTransactionReceipt`](https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_getTransactionReceipt).\n *\n * @remarks\n * The `waitForTransactionReceipt` action additionally supports Replacement detection (e.g. sped up Transactions).\n *\n * Transactions can be replaced when a user modifies their transaction in their wallet (to speed up or cancel). Transactions are replaced when they are sent from the same nonce.\n *\n * There are 3 types of Transaction Replacement reasons:\n *\n * - `repriced`: The gas price has been modified (e.g. different `maxFeePerGas`)\n * - `cancelled`: The Transaction has been cancelled (e.g. `value === 0n`)\n * - `replaced`: The Transaction has been replaced (e.g. different `value` or `data`)\n *\n * @param args - {@link WaitForTransactionReceiptParameters}\n * @returns The transaction receipt. {@link WaitForTransactionReceiptReturnType}\n *\n * @example\n * import { createPublicClient, http } from 'viem'\n * import { mainnet } from 'viem/chains'\n *\n * const client = createPublicClient({\n * chain: mainnet,\n * transport: http(),\n * })\n * const transactionReceipt = await client.waitForTransactionReceipt({\n * hash: '0x4ca7ee652d57678f26e887c149ab0735f41de37bcad58c9f6d3ed5824f15b74d',\n * })\n */\n waitForTransactionReceipt: (\n args: WaitForTransactionReceiptParameters<chain>,\n ) => Promise<WaitForTransactionReceiptReturnType<chain>>\n /**\n * Watches and returns incoming block numbers.\n *\n * - Docs: https://viem.sh/docs/actions/public/watchBlockNumber\n * - Examples: https://stackblitz.com/github/wevm/viem/tree/main/examples/blocks_watching-blocks\n * - JSON-RPC Methods:\n * - When `poll: true`, calls [`eth_blockNumber`](https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_blocknumber) on a polling interval.\n * - When `poll: false` & WebSocket Transport, uses a WebSocket subscription via [`eth_subscribe`](https://docs.alchemy.com/reference/eth-subscribe-polygon) and the `\"newHeads\"` event.\n *\n * @param args - {@link WatchBlockNumberParameters}\n * @returns A function that can be invoked to stop watching for new block numbers. {@link WatchBlockNumberReturnType}\n *\n * @example\n * import { createPublicClient, http } from 'viem'\n * import { mainnet } from 'viem/chains'\n *\n * const client = createPublicClient({\n * chain: mainnet,\n * transport: http(),\n * })\n * const unwatch = await client.watchBlockNumber({\n * onBlockNumber: (blockNumber) => console.log(blockNumber),\n * })\n */\n watchBlockNumber: (\n args: WatchBlockNumberParameters,\n ) => WatchBlockNumberReturnType\n /**\n * Watches and returns information for incoming blocks.\n *\n * - Docs: https://viem.sh/docs/actions/public/watchBlocks\n * - Examples: https://stackblitz.com/github/wevm/viem/tree/main/examples/blocks_watching-blocks\n * - JSON-RPC Methods:\n * - When `poll: true`, calls [`eth_getBlockByNumber`](https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_getBlockByNumber) on a polling interval.\n * - When `poll: false` & WebSocket Transport, uses a WebSocket subscription via [`eth_subscribe`](https://docs.alchemy.com/reference/eth-subscribe-polygon) and the `\"newHeads\"` event.\n *\n * @param args - {@link WatchBlocksParameters}\n * @returns A function that can be invoked to stop watching for new block numbers. {@link WatchBlocksReturnType}\n *\n * @example\n * import { createPublicClient, http } from 'viem'\n * import { mainnet } from 'viem/chains'\n *\n * const client = createPublicClient({\n * chain: mainnet,\n * transport: http(),\n * })\n * const unwatch = await client.watchBlocks({\n * onBlock: (block) => console.log(block),\n * })\n */\n watchBlocks: <\n includeTransactions extends boolean = false,\n blockTag extends BlockTag = 'latest',\n >(\n args: WatchBlocksParameters<\n transport,\n chain,\n includeTransactions,\n blockTag\n >,\n ) => WatchBlocksReturnType\n /**\n * Watches and returns emitted contract event logs.\n *\n * - Docs: https://viem.sh/docs/contract/watchContractEvent\n *\n * @remarks\n * This Action will batch up all the event logs found within the [`pollingInterval`](https://viem.sh/docs/contract/watchContractEvent#pollinginterval-optional), and invoke them via [`onLogs`](https://viem.sh/docs/contract/watchContractEvent#onLogs).\n *\n * `watchContractEvent` will attempt to create an [Event Filter](https://viem.sh/docs/contract/createContractEventFilter) and listen to changes to the Filter per polling interval, however, if the RPC Provider does not support Filters (e.g. `eth_newFilter`), then `watchContractEvent` will fall back to using [`getLogs`](https://viem.sh/docs/actions/public/getLogs) instead.\n *\n * @param args - {@link WatchContractEventParameters}\n * @returns A function that can be invoked to stop watching for new event logs. {@link WatchContractEventReturnType}\n *\n * @example\n * import { createPublicClient, http, parseAbi } from 'viem'\n * import { mainnet } from 'viem/chains'\n *\n * const client = createPublicClient({\n * chain: mainnet,\n * transport: http(),\n * })\n * const unwatch = client.watchContractEvent({\n * address: '0xFBA3912Ca04dd458c843e2EE08967fC04f3579c2',\n * abi: parseAbi(['event Transfer(address indexed from, address indexed to, uint256 value)']),\n * eventName: 'Transfer',\n * args: { from: '0xc961145a54C96E3aE9bAA048c4F4D6b04C13916b' },\n * onLogs: (logs) => console.log(logs),\n * })\n */\n watchContractEvent: <\n const abi extends Abi | readonly unknown[],\n eventName extends ContractEventName<abi>,\n strict extends boolean | undefined = undefined,\n >(\n args: WatchContractEventParameters<abi, eventName, strict, transport>,\n ) => WatchContractEventReturnType\n /**\n * Watches and returns emitted [Event Logs](https://viem.sh/docs/glossary/terms#event-log).\n *\n * - Docs: https://viem.sh/docs/actions/public/watchEvent\n * - JSON-RPC Methods:\n * - **RPC Provider supports `eth_newFilter`:**\n * - Calls [`eth_newFilter`](https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_newfilter) to create a filter (called on initialize).\n * - On a polling interval, it will call [`eth_getFilterChanges`](https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_getfilterchanges).\n * - **RPC Provider does not support `eth_newFilter`:**\n * - Calls [`eth_getLogs`](https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_getlogs) for each block between the polling interval.\n *\n * @remarks\n * This Action will batch up all the Event Logs found within the [`pollingInterval`](https://viem.sh/docs/actions/public/watchEvent#pollinginterval-optional), and invoke them via [`onLogs`](https://viem.sh/docs/actions/public/watchEvent#onLogs).\n *\n * `watchEvent` will attempt to create an [Event Filter](https://viem.sh/docs/actions/public/createEventFilter) and listen to changes to the Filter per polling interval, however, if the RPC Provider does not support Filters (e.g. `eth_newFilter`), then `watchEvent` will fall back to using [`getLogs`](https://viem.sh/docs/actions/public/getLogs) instead.\n *\n * @param args - {@link WatchEventParameters}\n * @returns A function that can be invoked to stop watching for new Event Logs. {@link WatchEventReturnType}\n *\n * @example\n * import { createPublicClient, http } from 'viem'\n * import { mainnet } from 'viem/chains'\n *\n * const client = createPublicClient({\n * chain: mainnet,\n * transport: http(),\n * })\n * const unwatch = client.watchEvent({\n * onLogs: (logs) => console.log(logs),\n * })\n */\n watchEvent: <\n const abiEvent extends AbiEvent | undefined = undefined,\n const abiEvents extends\n | readonly AbiEvent[]\n | readonly unknown[]\n | undefined = abiEvent extends AbiEvent ? [abiEvent] : undefined,\n strict extends boolean | undefined = undefined,\n >(\n args: WatchEventParameters<abiEvent, abiEvents, strict, transport>,\n ) => WatchEventReturnType\n /**\n * Watches and returns pending transaction hashes.\n *\n * - Docs: https://viem.sh/docs/actions/public/watchPendingTransactions\n * - JSON-RPC Methods:\n * - When `poll: true`\n * - Calls [`eth_newPendingTransactionFilter`](https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_newpendingtransactionfilter) to initialize the filter.\n * - Calls [`eth_getFilterChanges`](https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_getFilterChanges) on a polling interval.\n * - When `poll: false` & WebSocket Transport, uses a WebSocket subscription via [`eth_subscribe`](https://docs.alchemy.com/reference/eth-subscribe-polygon) and the `\"newPendingTransactions\"` event.\n *\n * @remarks\n * This Action will batch up all the pending transactions found within the [`pollingInterval`](https://viem.sh/docs/actions/public/watchPendingTransactions#pollinginterval-optional), and invoke them via [`onTransactions`](https://viem.sh/docs/actions/public/watchPendingTransactions#ontransactions).\n *\n * @param args - {@link WatchPendingTransactionsParameters}\n * @returns A function that can be invoked to stop watching for new pending transaction hashes. {@link WatchPendingTransactionsReturnType}\n *\n * @example\n * import { createPublicClient, http } from 'viem'\n * import { mainnet } from 'viem/chains'\n *\n * const client = createPublicClient({\n * chain: mainnet,\n * transport: http(),\n * })\n * const unwatch = await client.watchPendingTransactions({\n * onTransactions: (hashes) => console.log(hashes),\n * })\n */\n watchPendingTransactions: (\n args: WatchPendingTransactionsParameters<transport>,\n ) => WatchPendingTransactionsReturnType\n}\n\nexport function publicActions<\n transport extends Transport = Transport,\n chain extends Chain | undefined = Chain | undefined,\n account extends Account | undefined = Account | undefined,\n>(\n client: Client<transport, chain, account>,\n): PublicActions<transport, chain, account> {\n return {\n call: (args) => call(client, args),\n createAccessList: (args) => createAccessList(client, args),\n createBlockFilter: () => createBlockFilter(client),\n createContractEventFilter: (args) =>\n createContractEventFilter(client, args),\n createEventFilter: (args) => createEventFilter(client, args),\n createPendingTransactionFilter: () =>\n createPendingTransactionFilter(client),\n estimateContractGas: (args) => estimateContractGas(client, args as any),\n estimateGas: (args) => estimateGas(client, args),\n getBalance: (args) => getBalance(client, args),\n getBlobBaseFee: () => getBlobBaseFee(client),\n getBlock: (args) => getBlock(client, args),\n getBlockNumber: (args) => getBlockNumber(client, args),\n getBlockTransactionCount: (args) => getBlockTransactionCount(client, args),\n getBytecode: (args) => getCode(client, args),\n getChainId: () => getChainId(client),\n getCode: (args) => getCode(client, args),\n getContractEvents: (args) => getContractEvents(client, args),\n getEip712Domain: (args) => getEip712Domain(client, args),\n getEnsAddress: (args) => getEnsAddress(client, args),\n getEnsAvatar: (args) => getEnsAvatar(client, args),\n getEnsName: (args) => getEnsName(client, args),\n getEnsResolver: (args) => getEnsResolver(client, args),\n getEnsText: (args) => getEnsText(client, args),\n getFeeHistory: (args) => getFeeHistory(client, args),\n estimateFeesPerGas: (args) => estimateFeesPerGas(client, args),\n getFilterChanges: (args) => getFilterChanges(client, args),\n getFilterLogs: (args) => getFilterLogs(client, args),\n getGasPrice: () => getGasPrice(client),\n getLogs: (args) => getLogs(client, args as any),\n getProof: (args) => getProof(client, args),\n estimateMaxPriorityFeePerGas: (args) =>\n estimateMaxPriorityFeePerGas(client, args),\n getStorageAt: (args) => getStorageAt(client, args),\n getTransaction: (args) => getTransaction(client, args),\n getTransactionConfirmations: (args) =>\n getTransactionConfirmations(client, args),\n getTransactionCount: (args) => getTransactionCount(client, args),\n getTransactionReceipt: (args) => getTransactionReceipt(client, args),\n multicall: (args) => multicall(client, args),\n prepareTransactionRequest: (args) =>\n prepareTransactionRequest(client as any, args as any) as any,\n readContract: (args) => readContract(client, args),\n sendRawTransaction: (args) => sendRawTransaction(client, args),\n simulate: (args) => simulateBlocks(client, args),\n simulateBlocks: (args) => simulateBlocks(client, args),\n simulateCalls: (args) => simulateCalls(client, args),\n simulateContract: (args) => simulateContract(client, args),\n verifyMessage: (args) => verifyMessage(client, args),\n verifySiweMessage: (args) => verifySiweMessage(client, args),\n verifyTypedData: (args) => verifyTypedData(client, args),\n uninstallFilter: (args) => uninstallFilter(client, args),\n waitForTransactionReceipt: (args) =>\n waitForTransactionReceipt(client, args),\n watchBlocks: (args) => watchBlocks(client, args),\n watchBlockNumber: (args) => watchBlockNumber(client, args),\n watchContractEvent: (args) => watchContractEvent(client, args),\n watchEvent: (args) => watchEvent(client, args),\n watchPendingTransactions: (args) => watchPendingTransactions(client, args),\n }\n}\n", "import type { Abi, Address, TypedData } from 'abitype'\n\nimport type { Account } from '../../accounts/types.js'\nimport {\n type GetChainIdReturnType,\n getChainId,\n} from '../../actions/public/getChainId.js'\nimport {\n type AddChainParameters,\n addChain,\n} from '../../actions/wallet/addChain.js'\nimport {\n type DeployContractParameters,\n type DeployContractReturnType,\n deployContract,\n} from '../../actions/wallet/deployContract.js'\nimport {\n type GetAddressesReturnType,\n getAddresses,\n} from '../../actions/wallet/getAddresses.js'\nimport {\n type GetPermissionsReturnType,\n getPermissions,\n} from '../../actions/wallet/getPermissions.js'\nimport {\n type PrepareTransactionRequestParameters,\n type PrepareTransactionRequestRequest,\n type PrepareTransactionRequestReturnType,\n prepareTransactionRequest,\n} from '../../actions/wallet/prepareTransactionRequest.js'\nimport {\n type RequestAddressesReturnType,\n requestAddresses,\n} from '../../actions/wallet/requestAddresses.js'\nimport {\n type RequestPermissionsParameters,\n type RequestPermissionsReturnType,\n requestPermissions,\n} from '../../actions/wallet/requestPermissions.js'\nimport {\n type SendRawTransactionParameters,\n type SendRawTransactionReturnType,\n sendRawTransaction,\n} from '../../actions/wallet/sendRawTransaction.js'\nimport {\n type SendTransactionParameters,\n type SendTransactionRequest,\n type SendTransactionReturnType,\n sendTransaction,\n} from '../../actions/wallet/sendTransaction.js'\nimport {\n type SignMessageParameters,\n type SignMessageReturnType,\n signMessage,\n} from '../../actions/wallet/signMessage.js'\nimport {\n type SignTransactionParameters,\n type SignTransactionRequest,\n type SignTransactionReturnType,\n signTransaction,\n} from '../../actions/wallet/signTransaction.js'\nimport {\n type SignTypedDataParameters,\n type SignTypedDataReturnType,\n signTypedData,\n} from '../../actions/wallet/signTypedData.js'\nimport {\n type SwitchChainParameters,\n switchChain,\n} from '../../actions/wallet/switchChain.js'\nimport {\n type WatchAssetParameters,\n type WatchAssetReturnType,\n watchAsset,\n} from '../../actions/wallet/watchAsset.js'\nimport {\n type WriteContractParameters,\n type WriteContractReturnType,\n writeContract,\n} from '../../actions/wallet/writeContract.js'\nimport type { Chain } from '../../types/chain.js'\nimport type {\n ContractFunctionArgs,\n ContractFunctionName,\n} from '../../types/contract.js'\nimport type { Client } from '../createClient.js'\nimport type { Transport } from '../transports/createTransport.js'\n\nexport type WalletActions<\n chain extends Chain | undefined = Chain | undefined,\n account extends Account | undefined = Account | undefined,\n> = {\n /**\n * Adds an EVM chain to the wallet.\n *\n * - Docs: https://viem.sh/docs/actions/wallet/addChain\n * - JSON-RPC Methods: [`eth_addEthereumChain`](https://eips.ethereum.org/EIPS/eip-3085)\n *\n * @param args - {@link AddChainParameters}\n *\n * @example\n * import { createWalletClient, custom } from 'viem'\n * import { optimism } from 'viem/chains'\n *\n * const client = createWalletClient({\n * transport: custom(window.ethereum),\n * })\n * await client.addChain({ chain: optimism })\n */\n addChain: (args: AddChainParameters) => Promise<void>\n /**\n * Deploys a contract to the network, given bytecode and constructor arguments.\n *\n * - Docs: https://viem.sh/docs/contract/deployContract\n * - Examples: https://stackblitz.com/github/wevm/viem/tree/main/examples/contracts_deploying-contracts\n *\n * @param args - {@link DeployContractParameters}\n * @returns The [Transaction](https://viem.sh/docs/glossary/terms#transaction) hash. {@link DeployContractReturnType}\n *\n * @example\n * import { createWalletClient, http } from 'viem'\n * import { privateKeyToAccount } from 'viem/accounts'\n * import { mainnet } from 'viem/chains'\n *\n * const client = createWalletClient({\n * account: privateKeyToAccount('0x…'),\n * chain: mainnet,\n * transport: http(),\n * })\n * const hash = await client.deployContract({\n * abi: [],\n * account: '0x…,\n * bytecode: '0x608060405260405161083e38038061083e833981016040819052610...',\n * })\n */\n deployContract: <\n const abi extends Abi | readonly unknown[],\n chainOverride extends Chain | undefined,\n >(\n args: DeployContractParameters<abi, chain, account, chainOverride>,\n ) => Promise<DeployContractReturnType>\n /**\n * Returns a list of account addresses owned by the wallet or client.\n *\n * - Docs: https://viem.sh/docs/actions/wallet/getAddresses\n * - JSON-RPC Methods: [`eth_accounts`](https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_accounts)\n *\n * @returns List of account addresses owned by the wallet or client. {@link GetAddressesReturnType}\n *\n * @example\n * import { createWalletClient, custom } from 'viem'\n * import { mainnet } from 'viem/chains'\n *\n * const client = createWalletClient({\n * chain: mainnet,\n * transport: custom(window.ethereum),\n * })\n * const accounts = await client.getAddresses()\n */\n getAddresses: () => Promise<GetAddressesReturnType>\n /**\n * Returns the chain ID associated with the current network.\n *\n * - Docs: https://viem.sh/docs/actions/public/getChainId\n * - JSON-RPC Methods: [`eth_chainId`](https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_chainid)\n *\n * @returns The current chain ID. {@link GetChainIdReturnType}\n *\n * @example\n * import { createWalletClient, http } from 'viem'\n * import { mainnet } from 'viem/chains'\n *\n * const client = createWalletClient({\n * chain: mainnet,\n * transport: custom(window.ethereum),\n * })\n * const chainId = await client.getChainId()\n * // 1\n */\n getChainId: () => Promise<GetChainIdReturnType>\n /**\n * Gets the wallets current permissions.\n *\n * - Docs: https://viem.sh/docs/actions/wallet/getPermissions\n * - JSON-RPC Methods: [`wallet_getPermissions`](https://eips.ethereum.org/EIPS/eip-2255)\n *\n * @returns The wallet permissions. {@link GetPermissionsReturnType}\n *\n * @example\n * import { createWalletClient, custom } from 'viem'\n * import { mainnet } from 'viem/chains'\n *\n * const client = createWalletClient({\n * chain: mainnet,\n * transport: custom(window.ethereum),\n * })\n * const permissions = await client.getPermissions()\n */\n getPermissions: () => Promise<GetPermissionsReturnType>\n /**\n * Prepares a transaction request for signing.\n *\n * - Docs: https://viem.sh/docs/actions/wallet/prepareTransactionRequest\n *\n * @param args - {@link PrepareTransactionRequestParameters}\n * @returns The transaction request. {@link PrepareTransactionRequestReturnType}\n *\n * @example\n * import { createWalletClient, custom } from 'viem'\n * import { mainnet } from 'viem/chains'\n *\n * const client = createWalletClient({\n * chain: mainnet,\n * transport: custom(window.ethereum),\n * })\n * const request = await client.prepareTransactionRequest({\n * account: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e',\n * to: '0x0000000000000000000000000000000000000000',\n * value: 1n,\n * })\n *\n * @example\n * // Account Hoisting\n * import { createWalletClient, http } from 'viem'\n * import { privateKeyToAccount } from 'viem/accounts'\n * import { mainnet } from 'viem/chains'\n *\n * const client = createWalletClient({\n * account: privateKeyToAccount('0x…'),\n * chain: mainnet,\n * transport: custom(window.ethereum),\n * })\n * const request = await client.prepareTransactionRequest({\n * to: '0x0000000000000000000000000000000000000000',\n * value: 1n,\n * })\n */\n prepareTransactionRequest: <\n const request extends PrepareTransactionRequestRequest<\n chain,\n chainOverride\n >,\n chainOverride extends Chain | undefined = undefined,\n accountOverride extends Account | Address | undefined = undefined,\n >(\n args: PrepareTransactionRequestParameters<\n chain,\n account,\n chainOverride,\n accountOverride,\n request\n >,\n ) => Promise<\n PrepareTransactionRequestReturnType<\n chain,\n account,\n chainOverride,\n accountOverride,\n request\n >\n >\n /**\n * Requests a list of accounts managed by a wallet.\n *\n * - Docs: https://viem.sh/docs/actions/wallet/requestAddresses\n * - JSON-RPC Methods: [`eth_requestAccounts`](https://eips.ethereum.org/EIPS/eip-1102)\n *\n * Sends a request to the wallet, asking for permission to access the user's accounts. After the user accepts the request, it will return a list of accounts (addresses).\n *\n * This API can be useful for dapps that need to access the user's accounts in order to execute transactions or interact with smart contracts.\n *\n * @returns List of accounts managed by a wallet {@link RequestAddressesReturnType}\n *\n * @example\n * import { createWalletClient, custom } from 'viem'\n * import { mainnet } from 'viem/chains'\n *\n * const client = createWalletClient({\n * chain: mainnet,\n * transport: custom(window.ethereum),\n * })\n * const accounts = await client.requestAddresses()\n */\n requestAddresses: () => Promise<RequestAddressesReturnType>\n /**\n * Requests permissions for a wallet.\n *\n * - Docs: https://viem.sh/docs/actions/wallet/requestPermissions\n * - JSON-RPC Methods: [`wallet_requestPermissions`](https://eips.ethereum.org/EIPS/eip-2255)\n *\n * @param args - {@link RequestPermissionsParameters}\n * @returns The wallet permissions. {@link RequestPermissionsReturnType}\n *\n * @example\n * import { createWalletClient, custom } from 'viem'\n * import { mainnet } from 'viem/chains'\n *\n * const client = createWalletClient({\n * chain: mainnet,\n * transport: custom(window.ethereum),\n * })\n * const permissions = await client.requestPermissions({\n * eth_accounts: {}\n * })\n */\n requestPermissions: (\n args: RequestPermissionsParameters,\n ) => Promise<RequestPermissionsReturnType>\n /**\n * Sends a **signed** transaction to the network\n *\n * - Docs: https://viem.sh/docs/actions/wallet/sendRawTransaction\n * - JSON-RPC Method: [`eth_sendRawTransaction`](https://ethereum.github.io/execution-apis/api-documentation/)\n *\n * @param client - Client to use\n * @param parameters - {@link SendRawTransactionParameters}\n * @returns The transaction hash. {@link SendRawTransactionReturnType}\n *\n * @example\n * import { createWalletClient, custom } from 'viem'\n * import { mainnet } from 'viem/chains'\n * import { sendRawTransaction } from 'viem/wallet'\n *\n * const client = createWalletClient({\n * chain: mainnet,\n * transport: custom(window.ethereum),\n * })\n *\n * const hash = await client.sendRawTransaction({\n * serializedTransaction: '0x02f850018203118080825208808080c080a04012522854168b27e5dc3d5839bab5e6b39e1a0ffd343901ce1622e3d64b48f1a04e00902ae0502c4728cbf12156290df99c3ed7de85b1dbfe20b5c36931733a33'\n * })\n */\n sendRawTransaction: (\n args: SendRawTransactionParameters,\n ) => Promise<SendRawTransactionReturnType>\n /**\n * Creates, signs, and sends a new transaction to the network.\n *\n * - Docs: https://viem.sh/docs/actions/wallet/sendTransaction\n * - Examples: https://stackblitz.com/github/wevm/viem/tree/main/examples/transactions_sending-transactions\n * - JSON-RPC Methods:\n * - JSON-RPC Accounts: [`eth_sendTransaction`](https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_sendtransaction)\n * - Local Accounts: [`eth_sendRawTransaction`](https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_sendrawtransaction)\n *\n * @param args - {@link SendTransactionParameters}\n * @returns The [Transaction](https://viem.sh/docs/glossary/terms#transaction) hash. {@link SendTransactionReturnType}\n *\n * @example\n * import { createWalletClient, custom } from 'viem'\n * import { mainnet } from 'viem/chains'\n *\n * const client = createWalletClient({\n * chain: mainnet,\n * transport: custom(window.ethereum),\n * })\n * const hash = await client.sendTransaction({\n * account: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e',\n * to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8',\n * value: 1000000000000000000n,\n * })\n *\n * @example\n * // Account Hoisting\n * import { createWalletClient, http } from 'viem'\n * import { privateKeyToAccount } from 'viem/accounts'\n * import { mainnet } from 'viem/chains'\n *\n * const client = createWalletClient({\n * account: privateKeyToAccount('0x…'),\n * chain: mainnet,\n * transport: http(),\n * })\n * const hash = await client.sendTransaction({\n * to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8',\n * value: 1000000000000000000n,\n * })\n */\n sendTransaction: <\n const request extends SendTransactionRequest<chain, chainOverride>,\n chainOverride extends Chain | undefined = undefined,\n >(\n args: SendTransactionParameters<chain, account, chainOverride, request>,\n ) => Promise<SendTransactionReturnType>\n /**\n * Calculates an Ethereum-specific signature in [EIP-191 format](https://eips.ethereum.org/EIPS/eip-191): `keccak256(\"\\x19Ethereum Signed Message:\\n\" + len(message) + message))`.\n *\n * - Docs: https://viem.sh/docs/actions/wallet/signMessage\n * - JSON-RPC Methods:\n * - JSON-RPC Accounts: [`personal_sign`](https://docs.metamask.io/guide/signing-data#personal-sign)\n * - Local Accounts: Signs locally. No JSON-RPC request.\n *\n * With the calculated signature, you can:\n * - use [`verifyMessage`](https://viem.sh/docs/utilities/verifyMessage) to verify the signature,\n * - use [`recoverMessageAddress`](https://viem.sh/docs/utilities/recoverMessageAddress) to recover the signing address from a signature.\n *\n * @param args - {@link SignMessageParameters}\n * @returns The signed message. {@link SignMessageReturnType}\n *\n * @example\n * import { createWalletClient, custom } from 'viem'\n * import { mainnet } from 'viem/chains'\n *\n * const client = createWalletClient({\n * chain: mainnet,\n * transport: custom(window.ethereum),\n * })\n * const signature = await client.signMessage({\n * account: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e',\n * message: 'hello world',\n * })\n *\n * @example\n * // Account Hoisting\n * import { createWalletClient, http } from 'viem'\n * import { privateKeyToAccount } from 'viem/accounts'\n * import { mainnet } from 'viem/chains'\n *\n * const client = createWalletClient({\n * account: privateKeyToAccount('0x…'),\n * chain: mainnet,\n * transport: http(),\n * })\n * const signature = await client.signMessage({\n * message: 'hello world',\n * })\n */\n signMessage: (\n args: SignMessageParameters<account>,\n ) => Promise<SignMessageReturnType>\n /**\n * Signs a transaction.\n *\n * - Docs: https://viem.sh/docs/actions/wallet/signTransaction\n * - JSON-RPC Methods:\n * - JSON-RPC Accounts: [`eth_signTransaction`](https://ethereum.github.io/execution-apis/api-documentation/)\n * - Local Accounts: Signs locally. No JSON-RPC request.\n *\n * @param args - {@link SignTransactionParameters}\n * @returns The signed message. {@link SignTransactionReturnType}\n *\n * @example\n * import { createWalletClient, custom } from 'viem'\n * import { mainnet } from 'viem/chains'\n *\n * const client = createWalletClient({\n * chain: mainnet,\n * transport: custom(window.ethereum),\n * })\n * const request = await client.prepareTransactionRequest({\n * account: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e',\n * to: '0x0000000000000000000000000000000000000000',\n * value: 1n,\n * })\n * const signature = await client.signTransaction(request)\n *\n * @example\n * // Account Hoisting\n * import { createWalletClient, http } from 'viem'\n * import { privateKeyToAccount } from 'viem/accounts'\n * import { mainnet } from 'viem/chains'\n *\n * const client = createWalletClient({\n * account: privateKeyToAccount('0x…'),\n * chain: mainnet,\n * transport: custom(window.ethereum),\n * })\n * const request = await client.prepareTransactionRequest({\n * to: '0x0000000000000000000000000000000000000000',\n * value: 1n,\n * })\n * const signature = await client.signTransaction(request)\n */\n signTransaction: <\n chainOverride extends Chain | undefined,\n const request extends SignTransactionRequest<\n chain,\n chainOverride\n > = SignTransactionRequest<chain, chainOverride>,\n >(\n args: SignTransactionParameters<chain, account, chainOverride, request>,\n ) => Promise<SignTransactionReturnType<request>>\n /**\n * Signs typed data and calculates an Ethereum-specific signature in [EIP-191 format](https://eips.ethereum.org/EIPS/eip-191): `keccak256(\"\\x19Ethereum Signed Message:\\n\" + len(message) + message))`.\n *\n * - Docs: https://viem.sh/docs/actions/wallet/signTypedData\n * - JSON-RPC Methods:\n * - JSON-RPC Accounts: [`eth_signTypedData_v4`](https://docs.metamask.io/guide/signing-data#signtypeddata-v4)\n * - Local Accounts: Signs locally. No JSON-RPC request.\n *\n * @param client - Client to use\n * @param args - {@link SignTypedDataParameters}\n * @returns The signed data. {@link SignTypedDataReturnType}\n *\n * @example\n * import { createWalletClient, custom } from 'viem'\n * import { mainnet } from 'viem/chains'\n *\n * const client = createWalletClient({\n * chain: mainnet,\n * transport: custom(window.ethereum),\n * })\n * const signature = await client.signTypedData({\n * account: '0xA0Cf798816D4b9b9866b5330EEa46a18382f251e',\n * domain: {\n * name: 'Ether Mail',\n * version: '1',\n * chainId: 1,\n * verifyingContract: '0xCcCCccccCCCCcCCCCCCcCcCccCcCCCcCcccccccC',\n * },\n * types: {\n * Person: [\n * { name: 'name', type: 'string' },\n * { name: 'wallet', type: 'address' },\n * ],\n * Mail: [\n * { name: 'from', type: 'Person' },\n * { name: 'to', type: 'Person' },\n * { name: 'contents', type: 'string' },\n * ],\n * },\n * primaryType: 'Mail',\n * message: {\n * from: {\n * name: 'Cow',\n * wallet: '0xCD2a3d9F938E13CD947Ec05AbC7FE734Df8DD826',\n * },\n * to: {\n * name: 'Bob',\n * wallet: '0xbBbBBBBbbBBBbbbBbbBbbbbBBbBbbbbBbBbbBBbB',\n * },\n * contents: 'Hello, Bob!',\n * },\n * })\n *\n * @example\n * // Account Hoisting\n * import { createWalletClient, http } from 'viem'\n * import { privateKeyToAccount } from 'viem/accounts'\n * import { mainnet } from 'viem/chains'\n *\n * const client = createWalletClient({\n * account: privateKeyToAccount('0x…'),\n * chain: mainnet,\n * transport: http(),\n * })\n * const signature = await client.signTypedData({\n * domain: {\n * name: 'Ether Mail',\n * version: '1',\n * chainId: 1,\n * verifyingContract: '0xCcCCccccCCCCcCCCCCCcCcCccCcCCCcCcccccccC',\n * },\n * types: {\n * Person: [\n * { name: 'name', type: 'string' },\n * { name: 'wallet', type: 'address' },\n * ],\n * Mail: [\n * { name: 'from', type: 'Person' },\n * { name: 'to', type: 'Person' },\n * { name: 'contents', type: 'string' },\n * ],\n * },\n * primaryType: 'Mail',\n * message: {\n * from: {\n * name: 'Cow',\n * wallet: '0xCD2a3d9F938E13CD947Ec05AbC7FE734Df8DD826',\n * },\n * to: {\n * name: 'Bob',\n * wallet: '0xbBbBBBBbbBBBbbbBbbBbbbbBBbBbbbbBbBbbBBbB',\n * },\n * contents: 'Hello, Bob!',\n * },\n * })\n */\n signTypedData: <\n const typedData extends TypedData | { [key: string]: unknown },\n primaryType extends string,\n >(\n args: SignTypedDataParameters<typedData, primaryType, account>,\n ) => Promise<SignTypedDataReturnType>\n /**\n * Switch the target chain in a wallet.\n *\n * - Docs: https://viem.sh/docs/actions/wallet/switchChain\n * - JSON-RPC Methods: [`eth_switchEthereumChain`](https://eips.ethereum.org/EIPS/eip-3326)\n *\n * @param args - {@link SwitchChainParameters}\n *\n * @example\n * import { createWalletClient, custom } from 'viem'\n * import { mainnet, optimism } from 'viem/chains'\n *\n * const client = createWalletClient({\n * chain: mainnet,\n * transport: custom(window.ethereum),\n * })\n * await client.switchChain({ id: optimism.id })\n */\n switchChain: (args: SwitchChainParameters) => Promise<void>\n /**\n * Adds an EVM chain to the wallet.\n *\n * - Docs: https://viem.sh/docs/actions/wallet/watchAsset\n * - JSON-RPC Methods: [`eth_switchEthereumChain`](https://eips.ethereum.org/EIPS/eip-747)\n *\n * @param args - {@link WatchAssetParameters}\n * @returns Boolean indicating if the token was successfully added. {@link WatchAssetReturnType}\n *\n * @example\n * import { createWalletClient, custom } from 'viem'\n * import { mainnet } from 'viem/chains'\n *\n * const client = createWalletClient({\n * chain: mainnet,\n * transport: custom(window.ethereum),\n * })\n * const success = await client.watchAsset({\n * type: 'ERC20',\n * options: {\n * address: '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',\n * decimals: 18,\n * symbol: 'WETH',\n * },\n * })\n */\n watchAsset: (args: WatchAssetParameters) => Promise<WatchAssetReturnType>\n /**\n * Executes a write function on a contract.\n *\n * - Docs: https://viem.sh/docs/contract/writeContract\n * - Examples: https://stackblitz.com/github/wevm/viem/tree/main/examples/contracts_writing-to-contracts\n *\n * A \"write\" function on a Solidity contract modifies the state of the blockchain. These types of functions require gas to be executed, and hence a [Transaction](https://viem.sh/docs/glossary/terms) is needed to be broadcast in order to change the state.\n *\n * Internally, uses a [Wallet Client](https://viem.sh/docs/clients/wallet) to call the [`sendTransaction` action](https://viem.sh/docs/actions/wallet/sendTransaction) with [ABI-encoded `data`](https://viem.sh/docs/contract/encodeFunctionData).\n *\n * __Warning: The `write` internally sends a transaction – it does not validate if the contract write will succeed (the contract may throw an error). It is highly recommended to [simulate the contract write with `contract.simulate`](https://viem.sh/docs/contract/writeContract#usage) before you execute it.__\n *\n * @param args - {@link WriteContractParameters}\n * @returns A [Transaction Hash](https://viem.sh/docs/glossary/terms#hash). {@link WriteContractReturnType}\n *\n * @example\n * import { createWalletClient, custom, parseAbi } from 'viem'\n * import { mainnet } from 'viem/chains'\n *\n * const client = createWalletClient({\n * chain: mainnet,\n * transport: custom(window.ethereum),\n * })\n * const hash = await client.writeContract({\n * address: '0xFBA3912Ca04dd458c843e2EE08967fC04f3579c2',\n * abi: parseAbi(['function mint(uint32 tokenId) nonpayable']),\n * functionName: 'mint',\n * args: [69420],\n * })\n *\n * @example\n * // With Validation\n * import { createWalletClient, custom, parseAbi } from 'viem'\n * import { mainnet } from 'viem/chains'\n *\n * const client = createWalletClient({\n * chain: mainnet,\n * transport: custom(window.ethereum),\n * })\n * const { request } = await client.simulateContract({\n * address: '0xFBA3912Ca04dd458c843e2EE08967fC04f3579c2',\n * abi: parseAbi(['function mint(uint32 tokenId) nonpayable']),\n * functionName: 'mint',\n * args: [69420],\n * }\n * const hash = await client.writeContract(request)\n */\n writeContract: <\n const abi extends Abi | readonly unknown[],\n functionName extends ContractFunctionName<abi, 'payable' | 'nonpayable'>,\n args extends ContractFunctionArgs<\n abi,\n 'payable' | 'nonpayable',\n functionName\n >,\n chainOverride extends Chain | undefined = undefined,\n >(\n args: WriteContractParameters<\n abi,\n functionName,\n args,\n chain,\n account,\n chainOverride\n >,\n ) => Promise<WriteContractReturnType>\n}\n\nexport function walletActions<\n transport extends Transport,\n chain extends Chain | undefined = Chain | undefined,\n account extends Account | undefined = Account | undefined,\n>(client: Client<transport, chain, account>): WalletActions<chain, account> {\n return {\n addChain: (args) => addChain(client, args),\n deployContract: (args) => deployContract(client, args),\n getAddresses: () => getAddresses(client),\n getChainId: () => getChainId(client),\n getPermissions: () => getPermissions(client),\n prepareTransactionRequest: (args) =>\n prepareTransactionRequest(client as any, args as any) as any,\n requestAddresses: () => requestAddresses(client),\n requestPermissions: (args) => requestPermissions(client, args),\n sendRawTransaction: (args) => sendRawTransaction(client, args),\n sendTransaction: (args) => sendTransaction(client, args),\n signMessage: (args) => signMessage(client, args),\n signTransaction: (args) => signTransaction(client, args),\n signTypedData: (args) => signTypedData(client, args),\n switchChain: (args) => switchChain(client, args),\n watchAsset: (args) => watchAsset(client, args),\n writeContract: (args) => writeContract(client, args as any),\n }\n}\n", "import { RpcRequestError } from '../../errors/request.js'\nimport {\n UrlRequiredError,\n type UrlRequiredErrorType,\n} from '../../errors/transport.js'\nimport type { ErrorType } from '../../errors/utils.js'\nimport type { Hash } from '../../types/misc.js'\nimport type { RpcResponse } from '../../types/rpc.js'\nimport { getSocket } from '../../utils/rpc/compat.js'\nimport type { SocketRpcClient } from '../../utils/rpc/socket.js'\nimport {\n type GetWebSocketRpcClientOptions,\n getWebSocketRpcClient,\n} from '../../utils/rpc/webSocket.js'\nimport {\n type CreateTransportErrorType,\n type Transport,\n type TransportConfig,\n createTransport,\n} from './createTransport.js'\n\ntype WebSocketTransportSubscribeParameters = {\n onData: (data: RpcResponse) => void\n onError?: ((error: any) => void) | undefined\n}\n\ntype WebSocketTransportSubscribeReturnType = {\n subscriptionId: Hash\n unsubscribe: () => Promise<RpcResponse<boolean>>\n}\n\ntype WebSocketTransportSubscribe = {\n subscribe(\n args: WebSocketTransportSubscribeParameters & {\n /**\n * @description Add information about compiled contracts\n * @link https://hardhat.org/hardhat-network/docs/reference#hardhat_addcompilationresult\n */\n params: ['newHeads']\n },\n ): Promise<WebSocketTransportSubscribeReturnType>\n}\n\nexport type WebSocketTransportConfig = {\n /**\n * Whether or not to send keep-alive ping messages.\n * @default true\n */\n keepAlive?: GetWebSocketRpcClientOptions['keepAlive'] | undefined\n /** The key of the WebSocket transport. */\n key?: TransportConfig['key'] | undefined\n /** Methods to include or exclude from executing RPC requests. */\n methods?: TransportConfig['methods'] | undefined\n /** The name of the WebSocket transport. */\n name?: TransportConfig['name'] | undefined\n /**\n * Whether or not to attempt to reconnect on socket failure.\n * @default true\n */\n reconnect?: GetWebSocketRpcClientOptions['reconnect'] | undefined\n /** The max number of times to retry. */\n retryCount?: TransportConfig['retryCount'] | undefined\n /** The base delay (in ms) between retries. */\n retryDelay?: TransportConfig['retryDelay'] | undefined\n /** The timeout (in ms) for async WebSocket requests. Default: 10_000 */\n timeout?: TransportConfig['timeout'] | undefined\n}\n\nexport type WebSocketTransport = Transport<\n 'webSocket',\n {\n /**\n * @deprecated use `getRpcClient` instead.\n */\n getSocket(): Promise<WebSocket>\n getRpcClient(): Promise<SocketRpcClient<WebSocket>>\n subscribe: WebSocketTransportSubscribe['subscribe']\n }\n>\n\nexport type WebSocketTransportErrorType =\n | CreateTransportErrorType\n | UrlRequiredErrorType\n | ErrorType\n\n/**\n * @description Creates a WebSocket transport that connects to a JSON-RPC API.\n */\nexport function webSocket(\n /** URL of the JSON-RPC API. Defaults to the chain's public RPC URL. */\n url?: string,\n config: WebSocketTransportConfig = {},\n): WebSocketTransport {\n const {\n keepAlive,\n key = 'webSocket',\n methods,\n name = 'WebSocket JSON-RPC',\n reconnect,\n retryDelay,\n } = config\n return ({ chain, retryCount: retryCount_, timeout: timeout_ }) => {\n const retryCount = config.retryCount ?? retryCount_\n const timeout = timeout_ ?? config.timeout ?? 10_000\n const url_ = url || chain?.rpcUrls.default.webSocket?.[0]\n if (!url_) throw new UrlRequiredError()\n return createTransport(\n {\n key,\n methods,\n name,\n async request({ method, params }) {\n const body = { method, params }\n const rpcClient = await getWebSocketRpcClient(url_, {\n keepAlive,\n reconnect,\n })\n const { error, result } = await rpcClient.requestAsync({\n body,\n timeout,\n })\n if (error)\n throw new RpcRequestError({\n body,\n error,\n url: url_,\n })\n return result\n },\n retryCount,\n retryDelay,\n timeout,\n type: 'webSocket',\n },\n {\n getSocket() {\n return getSocket(url_)\n },\n getRpcClient() {\n return getWebSocketRpcClient(url_)\n },\n async subscribe({ params, onData, onError }: any) {\n const rpcClient = await getWebSocketRpcClient(url_)\n const { result: subscriptionId } = await new Promise<any>(\n (resolve, reject) =>\n rpcClient.request({\n body: {\n method: 'eth_subscribe',\n params,\n },\n onError(error) {\n reject(error)\n onError?.(error)\n return\n },\n onResponse(response) {\n if (response.error) {\n reject(response.error)\n onError?.(response.error)\n return\n }\n\n if (typeof response.id === 'number') {\n resolve(response)\n return\n }\n if (response.method !== 'eth_subscription') return\n onData(response.params)\n },\n }),\n )\n return {\n subscriptionId,\n async unsubscribe() {\n return new Promise<any>((resolve) =>\n rpcClient.request({\n body: {\n method: 'eth_unsubscribe',\n params: [subscriptionId],\n },\n onResponse: resolve,\n }),\n )\n },\n }\n },\n },\n )\n }\n}\n", "import {\n type Account,\n type Address,\n type BaseErrorType,\n type Client,\n createClient,\n custom,\n} from 'viem'\nimport { getAddress, parseAccount } from 'viem/utils'\n\nimport type { Config, Connection } from '../createConfig.js'\nimport type { ErrorType } from '../errors/base.js'\nimport {\n ConnectorAccountNotFoundError,\n type ConnectorAccountNotFoundErrorType,\n ConnectorChainMismatchError,\n type ConnectorChainMismatchErrorType,\n ConnectorNotConnectedError,\n type ConnectorNotConnectedErrorType,\n ConnectorUnavailableReconnectingError,\n type ConnectorUnavailableReconnectingErrorType,\n} from '../errors/config.js'\nimport type {\n ChainIdParameter,\n ConnectorParameter,\n} from '../types/properties.js'\nimport type { Compute } from '../types/utils.js'\n\nexport type GetConnectorClientParameters<\n config extends Config = Config,\n chainId extends\n config['chains'][number]['id'] = config['chains'][number]['id'],\n> = Compute<\n ChainIdParameter<config, chainId> &\n ConnectorParameter & {\n /**\n * Account to use for the client.\n *\n * - `Account | Address`: An Account MUST exist on the connector.\n * - `null`: Account MAY NOT exist on the connector. This is useful for\n * actions that can infer the account from the connector (e.g. sending a\n * call without a connected account – the user will be prompted to select\n * an account within the wallet).\n */\n account?: Address | Account | null | undefined\n }\n>\n\nexport type GetConnectorClientReturnType<\n config extends Config = Config,\n chainId extends\n config['chains'][number]['id'] = config['chains'][number]['id'],\n> = Compute<\n Client<\n config['_internal']['transports'][chainId],\n Extract<config['chains'][number], { id: chainId }>,\n Account\n >\n>\n\nexport type GetConnectorClientErrorType =\n | ConnectorAccountNotFoundErrorType\n | ConnectorChainMismatchErrorType\n | ConnectorNotConnectedErrorType\n | ConnectorUnavailableReconnectingErrorType\n // base\n | BaseErrorType\n | ErrorType\n\n/** https://wagmi.sh/core/api/actions/getConnectorClient */\nexport async function getConnectorClient<\n config extends Config,\n chainId extends config['chains'][number]['id'],\n>(\n config: config,\n parameters: GetConnectorClientParameters<config, chainId> = {},\n): Promise<GetConnectorClientReturnType<config, chainId>> {\n // Get connection\n let connection: Connection | undefined\n if (parameters.connector) {\n const { connector } = parameters\n if (\n config.state.status === 'reconnecting' &&\n !connector.getAccounts &&\n !connector.getChainId\n )\n throw new ConnectorUnavailableReconnectingError({ connector })\n\n const [accounts, chainId] = await Promise.all([\n connector.getAccounts().catch((e) => {\n if (parameters.account === null) return []\n throw e\n }),\n connector.getChainId(),\n ])\n connection = {\n accounts: accounts as readonly [Address, ...Address[]],\n chainId,\n connector,\n }\n } else connection = config.state.connections.get(config.state.current!)\n if (!connection) throw new ConnectorNotConnectedError()\n\n const chainId = parameters.chainId ?? connection.chainId\n\n // Check connector using same chainId as connection\n const connectorChainId = await connection.connector.getChainId()\n if (connectorChainId !== connection.chainId)\n throw new ConnectorChainMismatchError({\n connectionChainId: connection.chainId,\n connectorChainId,\n })\n\n // If connector has custom `getClient` implementation\n type Return = GetConnectorClientReturnType<config, chainId>\n const connector = connection.connector\n if (connector.getClient)\n return connector.getClient({ chainId }) as unknown as Return\n\n // Default using `custom` transport\n const account = parseAccount(parameters.account ?? connection.accounts[0]!)\n if (account) account.address = getAddress(account.address) // TODO: Checksum address as part of `parseAccount`?\n\n // If account was provided, check that it exists on the connector\n if (\n parameters.account &&\n !connection.accounts.some(\n (x) => x.toLowerCase() === account.address.toLowerCase(),\n )\n )\n throw new ConnectorAccountNotFoundError({\n address: account.address,\n connector,\n })\n\n const chain = config.chains.find((chain) => chain.id === chainId)\n const provider = (await connection.connector.getProvider({ chainId })) as {\n request(...args: any): Promise<any>\n }\n\n return createClient({\n account,\n chain,\n name: 'Connector Client',\n transport: (opts) => custom(provider)({ ...opts, retryCount: 0 }),\n }) as Return\n}\n", "import type { Abi, Account, Chain, Client, ContractConstructorArgs } from 'viem'\nimport {\n type DeployContractErrorType as viem_DeployContractErrorType,\n type DeployContractParameters as viem_DeployContractParameters,\n type DeployContractReturnType as viem_DeployContractReturnType,\n deployContract as viem_deployContract,\n} from 'viem/actions'\nimport type { Config } from '../createConfig.js'\nimport type { BaseErrorType, ErrorType } from '../errors/base.js'\nimport type { SelectChains } from '../types/chain.js'\nimport type {\n ChainIdParameter,\n ConnectorParameter,\n} from '../types/properties.js'\nimport type { Compute } from '../types/utils.js'\nimport { getAction } from '../utils/getAction.js'\nimport {\n type GetConnectorClientErrorType,\n getConnectorClient,\n} from './getConnectorClient.js'\n\nexport type DeployContractParameters<\n abi extends Abi | readonly unknown[] = Abi,\n config extends Config = Config,\n chainId extends\n config['chains'][number]['id'] = config['chains'][number]['id'],\n ///\n allArgs = ContractConstructorArgs<abi>,\n chains extends readonly Chain[] = SelectChains<config, chainId>,\n> = {\n [key in keyof chains]: Compute<\n Omit<\n viem_DeployContractParameters<\n abi,\n chains[key],\n Account,\n chains[key],\n allArgs\n >,\n 'chain'\n > &\n ChainIdParameter<config, chainId> &\n ConnectorParameter\n >\n}[number]\n\nexport type DeployContractReturnType = viem_DeployContractReturnType\n\nexport type DeployContractErrorType =\n // getConnectorClient()\n | GetConnectorClientErrorType\n // base\n | BaseErrorType\n | ErrorType\n // viem\n | viem_DeployContractErrorType\n\n/** https://wagmi.sh/core/api/actions/deployContract */\nexport async function deployContract<\n config extends Config,\n const abi extends Abi | readonly unknown[],\n chainId extends config['chains'][number]['id'],\n>(\n config: config,\n parameters: DeployContractParameters<abi, config, chainId>,\n): Promise<DeployContractReturnType> {\n const { account, chainId, connector, ...rest } = parameters\n\n let client: Client\n if (typeof account === 'object' && account?.type === 'local')\n client = config.getClient({ chainId })\n else\n client = await getConnectorClient(config, {\n account: account ?? undefined,\n chainId,\n connector,\n })\n\n const action = getAction(client, viem_deployContract, 'deployContract')\n const hash = await action({\n ...(rest as any),\n ...(account ? { account } : {}),\n chain: chainId ? { id: chainId } : null,\n })\n\n return hash\n}\n", "import type { Config, Connection, Connector } from '../createConfig.js'\nimport type { BaseErrorType, ErrorType } from '../errors/base.js'\nimport type {\n ConnectorNotConnectedErrorType,\n ConnectorNotFoundErrorType,\n} from '../errors/config.js'\nimport type { ConnectorParameter } from '../types/properties.js'\n\nexport type DisconnectParameters = ConnectorParameter\n\nexport type DisconnectReturnType = void\n\nexport type DisconnectErrorType =\n | ConnectorNotFoundErrorType\n | ConnectorNotConnectedErrorType\n // base\n | BaseErrorType\n | ErrorType\n\n/** https://wagmi.sh/core/api/actions/disconnect */\nexport async function disconnect(\n config: Config,\n parameters: DisconnectParameters = {},\n): Promise<DisconnectReturnType> {\n let connector: Connector | undefined\n if (parameters.connector) connector = parameters.connector\n else {\n const { connections, current } = config.state\n const connection = connections.get(current!)\n connector = connection?.connector\n }\n\n const connections = config.state.connections\n\n if (connector) {\n await connector.disconnect()\n connector.emitter.off('change', config._internal.events.change)\n connector.emitter.off('disconnect', config._internal.events.disconnect)\n connector.emitter.on('connect', config._internal.events.connect)\n\n connections.delete(connector.uid)\n }\n\n config.setState((x) => {\n // if no connections exist, move to disconnected state\n if (connections.size === 0)\n return {\n ...x,\n connections: new Map(),\n current: null,\n status: 'disconnected',\n }\n\n // switch over to another connection\n const nextConnection = connections.values().next().value as Connection\n return {\n ...x,\n connections: new Map(connections),\n current: nextConnection.connector.uid,\n }\n })\n\n // Set recent connector if exists\n {\n const current = config.state.current\n if (!current) return\n const connector = config.state.connections.get(current)?.connector\n if (!connector) return\n await config.storage?.setItem('recentConnectorId', connector.id)\n }\n}\n", "import type { Account, Address, Chain } from 'viem'\nimport {\n type EstimateGasErrorType as viem_EstimateGasErrorType,\n type EstimateGasParameters as viem_EstimateGasParameters,\n type EstimateGasReturnType as viem_EstimateGasReturnType,\n estimateGas as viem_estimateGas,\n} from 'viem/actions'\n\nimport type { Config } from '../createConfig.js'\nimport type { BaseErrorType, ErrorType } from '../errors/base.js'\nimport type { SelectChains } from '../types/chain.js'\nimport type {\n ChainIdParameter,\n ConnectorParameter,\n} from '../types/properties.js'\nimport type { UnionCompute, UnionLooseOmit } from '../types/utils.js'\nimport { getAction } from '../utils/getAction.js'\nimport {\n type GetConnectorClientErrorType,\n getConnectorClient,\n} from './getConnectorClient.js'\n\nexport type EstimateGasParameters<\n config extends Config = Config,\n chainId extends\n | config['chains'][number]['id']\n | undefined = config['chains'][number]['id'],\n ///\n chains extends readonly Chain[] = SelectChains<config, chainId>,\n> = {\n [key in keyof chains]: UnionCompute<\n UnionLooseOmit<viem_EstimateGasParameters<chains[key]>, 'chain'> &\n ChainIdParameter<config, chainId> &\n ConnectorParameter\n >\n}[number]\n\nexport type EstimateGasReturnType = viem_EstimateGasReturnType\n\nexport type EstimateGasErrorType =\n // getConnectorClient()\n | GetConnectorClientErrorType\n // base\n | BaseErrorType\n | ErrorType\n // viem\n | viem_EstimateGasErrorType\n\n/** https://wagmi.sh/core/api/actions/estimateGas */\nexport async function estimateGas<\n config extends Config,\n chainId extends config['chains'][number]['id'] | undefined = undefined,\n>(\n config: config,\n parameters: EstimateGasParameters<config, chainId>,\n): Promise<EstimateGasReturnType> {\n const { chainId, connector, ...rest } = parameters\n\n let account: Address | Account\n if (parameters.account) account = parameters.account\n else {\n const connectorClient = await getConnectorClient(config, {\n account: parameters.account,\n chainId,\n connector,\n })\n account = connectorClient.account\n }\n\n const client = config.getClient({ chainId })\n const action = getAction(client, viem_estimateGas, 'estimateGas')\n return action({ ...(rest as viem_EstimateGasParameters), account })\n}\n", "import { weiUnits } from 'viem'\n\nimport type { Unit } from '../types/unit.js'\n\nexport function getUnit(unit: Unit) {\n if (typeof unit === 'number') return unit\n if (unit === 'wei') return 0\n return Math.abs(weiUnits[unit])\n}\n", "import {\n type Chain,\n type FeeValuesEIP1559,\n type FeeValuesLegacy,\n type FeeValuesType,\n formatUnits,\n} from 'viem'\nimport {\n type EstimateFeesPerGasErrorType as viem_EstimateFeesPerGasErrorType,\n type EstimateFeesPerGasParameters as viem_EstimateFeesPerGasParameters,\n type EstimateFeesPerGasReturnType as viem_EstimateFeesPerGasReturnType,\n estimateFeesPerGas as viem_estimateFeesPerGas,\n} from 'viem/actions'\n\nimport type { Config } from '../createConfig.js'\nimport type { ChainIdParameter } from '../types/properties.js'\nimport type { Unit } from '../types/unit.js'\nimport type { Compute } from '../types/utils.js'\nimport type { UnionCompute, UnionLooseOmit } from '../types/utils.js'\nimport { getAction } from '../utils/getAction.js'\nimport { getUnit } from '../utils/getUnit.js'\n\nexport type EstimateFeesPerGasParameters<\n type extends FeeValuesType = FeeValuesType,\n config extends Config = Config,\n> = UnionCompute<\n UnionLooseOmit<\n viem_EstimateFeesPerGasParameters<Chain, Chain, type>,\n 'chain'\n > &\n ChainIdParameter<config> & {\n /** @deprecated */\n formatUnits?: Unit | undefined\n }\n>\n\nexport type EstimateFeesPerGasReturnType<\n type extends FeeValuesType = FeeValuesType,\n> = Compute<\n viem_EstimateFeesPerGasReturnType<type> & {\n /** @deprecated */\n formatted: UnionCompute<\n | (type extends 'legacy' ? FeeValuesLegacy<string> : never)\n | (type extends 'eip1559' ? FeeValuesEIP1559<string> : never)\n >\n }\n>\n\nexport type EstimateFeesPerGasErrorType = viem_EstimateFeesPerGasErrorType\n\nexport async function estimateFeesPerGas<\n config extends Config,\n type extends FeeValuesType = 'eip1559',\n>(\n config: config,\n parameters: EstimateFeesPerGasParameters<type, config> = {},\n): Promise<EstimateFeesPerGasReturnType<type>> {\n const { chainId, formatUnits: units = 'gwei', ...rest } = parameters\n\n const client = config.getClient({ chainId })\n const action = getAction(\n client,\n viem_estimateFeesPerGas,\n 'estimateFeesPerGas',\n )\n\n const { gasPrice, maxFeePerGas, maxPriorityFeePerGas } = await action({\n ...rest,\n chain: client.chain,\n })\n\n const unit = getUnit(units)\n const formatted = {\n gasPrice: gasPrice ? formatUnits(gasPrice, unit) : undefined,\n maxFeePerGas: maxFeePerGas ? formatUnits(maxFeePerGas, unit) : undefined,\n maxPriorityFeePerGas: maxPriorityFeePerGas\n ? formatUnits(maxPriorityFeePerGas, unit)\n : undefined,\n }\n\n return {\n formatted,\n gasPrice,\n maxFeePerGas,\n maxPriorityFeePerGas,\n } as EstimateFeesPerGasReturnType<type>\n}\n", "import type { Chain } from 'viem'\nimport {\n type EstimateMaxPriorityFeePerGasErrorType as viem_EstimateMaxPriorityFeePerGasErrorType,\n type EstimateMaxPriorityFeePerGasParameters as viem_EstimateMaxPriorityFeePerGasParameters,\n type EstimateMaxPriorityFeePerGasReturnType as viem_EstimateMaxPriorityFeePerGasReturnType,\n estimateMaxPriorityFeePerGas as viem_estimateMaxPriorityFeePerGas,\n} from 'viem/actions'\n\nimport type { Config } from '../createConfig.js'\nimport type { ChainIdParameter } from '../types/properties.js'\nimport type { Compute, UnionLooseOmit } from '../types/utils.js'\nimport { getAction } from '../utils/getAction.js'\n\nexport type EstimateMaxPriorityFeePerGasParameters<\n config extends Config = Config,\n chainId extends\n config['chains'][number]['id'] = config['chains'][number]['id'],\n> = Compute<\n UnionLooseOmit<\n viem_EstimateMaxPriorityFeePerGasParameters<Chain, Chain> &\n ChainIdParameter<config, chainId>,\n 'chain'\n >\n>\n\nexport type EstimateMaxPriorityFeePerGasReturnType =\n viem_EstimateMaxPriorityFeePerGasReturnType\n\nexport type EstimateMaxPriorityFeePerGasErrorType =\n viem_EstimateMaxPriorityFeePerGasErrorType\n\n/** https://wagmi.sh/core/api/actions/estimateMaxPriorityFeePerGas */\nexport async function estimateMaxPriorityFeePerGas<\n config extends Config,\n chainId extends\n config['chains'][number]['id'] = config['chains'][number]['id'],\n>(\n config: config,\n parameters: EstimateMaxPriorityFeePerGasParameters<config, chainId> = {},\n): Promise<EstimateMaxPriorityFeePerGasReturnType> {\n const { chainId } = parameters\n const client = config.getClient({ chainId })\n const action = getAction(\n client,\n viem_estimateMaxPriorityFeePerGas,\n 'estimateMaxPriorityFeePerGas',\n )\n return action({ chain: client.chain })\n}\n", "import type { Address, Chain } from 'viem'\n\nimport type { Config, Connector } from '../createConfig.js'\n\nexport type GetAccountReturnType<\n config extends Config = Config,\n ///\n chain = Config extends config ? Chain : config['chains'][number],\n> =\n | {\n address: Address\n addresses: readonly [Address, ...Address[]]\n chain: chain | undefined\n chainId: number\n connector: Connector\n isConnected: true\n isConnecting: false\n isDisconnected: false\n isReconnecting: false\n status: 'connected'\n }\n | {\n address: Address | undefined\n addresses: readonly Address[] | undefined\n chain: chain | undefined\n chainId: number | undefined\n connector: Connector | undefined\n isConnected: boolean\n isConnecting: false\n isDisconnected: false\n isReconnecting: true\n status: 'reconnecting'\n }\n | {\n address: Address | undefined\n addresses: readonly Address[] | undefined\n chain: chain | undefined\n chainId: number | undefined\n connector: Connector | undefined\n isConnected: false\n isReconnecting: false\n isConnecting: true\n isDisconnected: false\n status: 'connecting'\n }\n | {\n address: undefined\n addresses: undefined\n chain: undefined\n chainId: undefined\n connector: undefined\n isConnected: false\n isReconnecting: false\n isConnecting: false\n isDisconnected: true\n status: 'disconnected'\n }\n\n/** https://wagmi.sh/core/api/actions/getAccount */\nexport function getAccount<config extends Config>(\n config: config,\n): GetAccountReturnType<config> {\n const uid = config.state.current!\n const connection = config.state.connections.get(uid)\n const addresses = connection?.accounts\n const address = addresses?.[0]\n const chain = config.chains.find(\n (chain) => chain.id === connection?.chainId,\n ) as GetAccountReturnType<config>['chain']\n const status = config.state.status\n\n switch (status) {\n case 'connected':\n return {\n address: address!,\n addresses: addresses!,\n chain,\n chainId: connection?.chainId!,\n connector: connection?.connector!,\n isConnected: true,\n isConnecting: false,\n isDisconnected: false,\n isReconnecting: false,\n status,\n }\n case 'reconnecting':\n return {\n address,\n addresses,\n chain,\n chainId: connection?.chainId,\n connector: connection?.connector,\n isConnected: !!address,\n isConnecting: false,\n isDisconnected: false,\n isReconnecting: true,\n status,\n }\n case 'connecting':\n return {\n address,\n addresses,\n chain,\n chainId: connection?.chainId,\n connector: connection?.connector,\n isConnected: false,\n isConnecting: true,\n isDisconnected: false,\n isReconnecting: false,\n status,\n }\n case 'disconnected':\n return {\n address: undefined,\n addresses: undefined,\n chain: undefined,\n chainId: undefined,\n connector: undefined,\n isConnected: false,\n isConnecting: false,\n isDisconnected: true,\n isReconnecting: false,\n status,\n }\n }\n}\n", "import type {\n ContractFunctionParameters,\n MulticallErrorType as viem_MulticallErrorType,\n MulticallParameters as viem_MulticallParameters,\n MulticallReturnType as viem_MulticallReturnType,\n} from 'viem'\nimport { multicall as viem_multicall } from 'viem/actions'\n\nimport type { Config } from '../createConfig.js'\nimport type { ChainIdParameter } from '../types/properties.js'\nimport { getAction } from '../utils/getAction.js'\n\nexport type MulticallParameters<\n contracts extends readonly unknown[] = readonly ContractFunctionParameters[],\n allowFailure extends boolean = true,\n config extends Config = Config,\n> = viem_MulticallParameters<contracts, allowFailure> & ChainIdParameter<config>\n\nexport type MulticallReturnType<\n contracts extends readonly unknown[] = readonly ContractFunctionParameters[],\n allowFailure extends boolean = true,\n> = viem_MulticallReturnType<contracts, allowFailure>\n\nexport type MulticallErrorType = viem_MulticallErrorType\n\nexport async function multicall<\n config extends Config,\n const contracts extends readonly ContractFunctionParameters[],\n allowFailure extends boolean = true,\n>(\n config: config,\n parameters: MulticallParameters<contracts, allowFailure, config>,\n): Promise<MulticallReturnType<contracts, allowFailure>> {\n const { allowFailure = true, chainId, contracts, ...rest } = parameters\n const client = config.getClient({ chainId })\n const action = getAction(client, viem_multicall, 'multicall')\n return action({\n allowFailure,\n contracts,\n ...rest,\n }) as Promise<MulticallReturnType<contracts, allowFailure>>\n}\n", "import type { Abi } from 'viem'\nimport type { ContractFunctionArgs, ContractFunctionName } from 'viem'\nimport {\n type ReadContractErrorType as viem_ReadContractErrorType,\n type ReadContractParameters as viem_ReadContractParameters,\n type ReadContractReturnType as viem_ReadContractReturnType,\n readContract as viem_readContract,\n} from 'viem/actions'\n\nimport type { Config } from '../createConfig.js'\nimport type { ChainIdParameter } from '../types/properties.js'\nimport { getAction } from '../utils/getAction.js'\n\nexport type ReadContractParameters<\n abi extends Abi | readonly unknown[] = Abi,\n functionName extends ContractFunctionName<\n abi,\n 'pure' | 'view'\n > = ContractFunctionName<abi, 'pure' | 'view'>,\n args extends ContractFunctionArgs<\n abi,\n 'pure' | 'view',\n functionName\n > = ContractFunctionArgs<abi, 'pure' | 'view', functionName>,\n config extends Config = Config,\n> = viem_ReadContractParameters<abi, functionName, args> &\n ChainIdParameter<config>\n\nexport type ReadContractReturnType<\n abi extends Abi | readonly unknown[] = Abi,\n functionName extends ContractFunctionName<\n abi,\n 'pure' | 'view'\n > = ContractFunctionName<abi, 'pure' | 'view'>,\n args extends ContractFunctionArgs<\n abi,\n 'pure' | 'view',\n functionName\n > = ContractFunctionArgs<abi, 'pure' | 'view', functionName>,\n> = viem_ReadContractReturnType<abi, functionName, args>\n\nexport type ReadContractErrorType = viem_ReadContractErrorType\n\n/** https://wagmi.sh/core/api/actions/readContract */\nexport function readContract<\n config extends Config,\n const abi extends Abi | readonly unknown[],\n functionName extends ContractFunctionName<abi, 'pure' | 'view'>,\n args extends ContractFunctionArgs<abi, 'pure' | 'view', functionName>,\n>(\n config: config,\n parameters: ReadContractParameters<abi, functionName, args, config>,\n): Promise<ReadContractReturnType<abi, functionName, args>> {\n const { chainId, ...rest } = parameters\n const client = config.getClient({ chainId })\n const action = getAction(client, viem_readContract, 'readContract')\n return action(rest as any)\n}\n", "import type {\n ContractFunctionParameters,\n MulticallParameters as viem_MulticallParameters,\n MulticallReturnType as viem_MulticallReturnType,\n} from 'viem'\nimport { ContractFunctionExecutionError } from 'viem'\n\nimport type { Config } from '../createConfig.js'\nimport type { ChainIdParameter } from '../types/properties.js'\nimport { type MulticallErrorType, multicall } from './multicall.js'\nimport { type ReadContractErrorType, readContract } from './readContract.js'\n\nexport type ReadContractsParameters<\n contracts extends readonly unknown[] = readonly ContractFunctionParameters[],\n allowFailure extends boolean = true,\n config extends Config = Config,\n> = viem_MulticallParameters<\n contracts,\n allowFailure,\n { properties: ChainIdParameter<config> }\n>\n\nexport type ReadContractsReturnType<\n contracts extends readonly unknown[] = readonly ContractFunctionParameters[],\n allowFailure extends boolean = true,\n> = viem_MulticallReturnType<contracts, allowFailure>\n\nexport type ReadContractsErrorType = MulticallErrorType | ReadContractErrorType\n\nexport async function readContracts<\n config extends Config,\n const contracts extends readonly ContractFunctionParameters[],\n allowFailure extends boolean = true,\n>(\n config: config,\n parameters: ReadContractsParameters<contracts, allowFailure, config>,\n): Promise<ReadContractsReturnType<contracts, allowFailure>> {\n const { allowFailure = true, blockNumber, blockTag, ...rest } = parameters\n const contracts = parameters.contracts as (ContractFunctionParameters & {\n chainId?: number | undefined\n })[]\n\n try {\n const contractsByChainId: {\n [chainId: number]: {\n contract: ContractFunctionParameters\n index: number\n }[]\n } = {}\n for (const [index, contract] of contracts.entries()) {\n const chainId = contract.chainId ?? config.state.chainId\n if (!contractsByChainId[chainId]) contractsByChainId[chainId] = []\n contractsByChainId[chainId]?.push({ contract, index })\n }\n const promises = () =>\n Object.entries(contractsByChainId).map(([chainId, contracts]) =>\n multicall(config, {\n ...rest,\n allowFailure,\n blockNumber,\n blockTag,\n chainId: Number.parseInt(chainId),\n contracts: contracts.map(({ contract }) => contract),\n }),\n )\n\n const multicallResults = (await Promise.all(promises())).flat()\n // Reorder the contract results back to the order they were\n // provided in.\n const resultIndexes = Object.values(contractsByChainId).flatMap(\n (contracts) => contracts.map(({ index }) => index),\n )\n return multicallResults.reduce((results, result, index) => {\n if (results) (results as unknown[])[resultIndexes[index]!] = result\n return results\n }, [] as unknown[]) as ReadContractsReturnType<contracts, allowFailure>\n } catch (error) {\n if (error instanceof ContractFunctionExecutionError) throw error\n\n const promises = () =>\n contracts.map((contract) =>\n readContract(config, { ...contract, blockNumber, blockTag }),\n )\n if (allowFailure)\n return (await Promise.allSettled(promises())).map((result) => {\n if (result.status === 'fulfilled')\n return { result: result.value, status: 'success' }\n return { error: result.reason, result: undefined, status: 'failure' }\n }) as ReadContractsReturnType<contracts, allowFailure>\n\n return (await Promise.all(promises())) as ReadContractsReturnType<\n contracts,\n allowFailure\n >\n }\n}\n", "import { type Address, type Hex, formatUnits, hexToString, trim } from 'viem'\nimport {\n type GetBalanceErrorType as viem_GetBalanceErrorType,\n type GetBalanceParameters as viem_GetBalanceParameters,\n getBalance as viem_getBalance,\n} from 'viem/actions'\n\nimport type { Config } from '../createConfig.js'\nimport type { ChainIdParameter } from '../types/properties.js'\nimport type { Unit } from '../types/unit.js'\nimport type { Compute } from '../types/utils.js'\nimport { getAction } from '../utils/getAction.js'\nimport { getUnit } from '../utils/getUnit.js'\nimport { type ReadContractsErrorType, readContracts } from './readContracts.js'\n\nexport type GetBalanceParameters<config extends Config = Config> = Compute<\n ChainIdParameter<config> &\n viem_GetBalanceParameters & {\n /** @deprecated */\n token?: Address | undefined\n /** @deprecated */\n unit?: Unit | undefined\n }\n>\n\nexport type GetBalanceReturnType = {\n decimals: number\n /** @deprecated */\n formatted: string\n symbol: string\n value: bigint\n}\n\nexport type GetBalanceErrorType = viem_GetBalanceErrorType\n\n/** https://wagmi.sh/core/api/actions/getBalance */\nexport async function getBalance<config extends Config>(\n config: config,\n parameters: GetBalanceParameters<config>,\n): Promise<GetBalanceReturnType> {\n const {\n address,\n blockNumber,\n blockTag,\n chainId,\n token: tokenAddress,\n unit = 'ether',\n } = parameters\n\n if (tokenAddress) {\n try {\n return await getTokenBalance(config, {\n balanceAddress: address,\n chainId,\n symbolType: 'string',\n tokenAddress,\n })\n } catch (error) {\n // In the chance that there is an error upon decoding the contract result,\n // it could be likely that the contract data is represented as bytes32 instead\n // of a string.\n if (\n (error as ReadContractsErrorType).name ===\n 'ContractFunctionExecutionError'\n ) {\n const balance = await getTokenBalance(config, {\n balanceAddress: address,\n chainId,\n symbolType: 'bytes32',\n tokenAddress,\n })\n const symbol = hexToString(\n trim(balance.symbol as Hex, { dir: 'right' }),\n )\n return { ...balance, symbol }\n }\n throw error\n }\n }\n\n const client = config.getClient({ chainId })\n const action = getAction(client, viem_getBalance, 'getBalance')\n const value = await action(\n blockNumber ? { address, blockNumber } : { address, blockTag },\n )\n const chain = config.chains.find((x) => x.id === chainId) ?? client.chain!\n return {\n decimals: chain.nativeCurrency.decimals,\n formatted: formatUnits(value, getUnit(unit)),\n symbol: chain.nativeCurrency.symbol,\n value,\n }\n}\n\ntype GetTokenBalanceParameters = {\n balanceAddress: Address\n chainId?: number | undefined\n symbolType: 'bytes32' | 'string'\n tokenAddress: Address\n unit?: Unit | undefined\n}\n\nasync function getTokenBalance(\n config: Config,\n parameters: GetTokenBalanceParameters,\n) {\n const { balanceAddress, chainId, symbolType, tokenAddress, unit } = parameters\n const contract = {\n abi: [\n {\n type: 'function',\n name: 'balanceOf',\n stateMutability: 'view',\n inputs: [{ type: 'address' }],\n outputs: [{ type: 'uint256' }],\n },\n {\n type: 'function',\n name: 'decimals',\n stateMutability: 'view',\n inputs: [],\n outputs: [{ type: 'uint8' }],\n },\n {\n type: 'function',\n name: 'symbol',\n stateMutability: 'view',\n inputs: [],\n outputs: [{ type: symbolType }],\n },\n ],\n address: tokenAddress,\n } as const\n const [value, decimals, symbol] = await readContracts(config, {\n allowFailure: false,\n contracts: [\n {\n ...contract,\n functionName: 'balanceOf',\n args: [balanceAddress],\n chainId,\n },\n { ...contract, functionName: 'decimals', chainId },\n { ...contract, functionName: 'symbol', chainId },\n ] as const,\n })\n const formatted = formatUnits(value ?? '0', getUnit(unit ?? decimals))\n return { decimals, formatted, symbol, value }\n}\n", "import type { BlockTag, Chain } from 'viem'\nimport {\n type GetBlockErrorType as viem_GetBlockErrorType,\n type GetBlockParameters as viem_GetBlockParameters,\n type GetBlockReturnType as viem_GetBlockReturnType,\n getBlock as viem_getBlock,\n} from 'viem/actions'\n\nimport type { Config } from '../createConfig.js'\nimport type { SelectChains } from '../types/chain.js'\nimport type { ChainIdParameter } from '../types/properties.js'\nimport type { Compute, IsNarrowable } from '../types/utils.js'\nimport { getAction } from '../utils/getAction.js'\n\nexport type GetBlockParameters<\n includeTransactions extends boolean = false,\n blockTag extends BlockTag = 'latest',\n config extends Config = Config,\n chainId extends\n config['chains'][number]['id'] = config['chains'][number]['id'],\n> = Compute<\n viem_GetBlockParameters<includeTransactions, blockTag> &\n ChainIdParameter<config, chainId>\n>\n\nexport type GetBlockReturnType<\n includeTransactions extends boolean = false,\n blockTag extends BlockTag = 'latest',\n config extends Config = Config,\n chainId extends\n config['chains'][number]['id'] = config['chains'][number]['id'],\n ///\n chains extends readonly Chain[] = SelectChains<config, chainId>,\n> = Compute<\n {\n [key in keyof chains]: viem_GetBlockReturnType<\n IsNarrowable<chains[key], Chain> extends true ? chains[key] : undefined,\n includeTransactions,\n blockTag\n > & { chainId: chains[key]['id'] }\n }[number]\n>\n\nexport type GetBlockErrorType = viem_GetBlockErrorType\n\n/** https://wagmi.sh/core/actions/getBlock */\nexport async function getBlock<\n config extends Config,\n chainId extends config['chains'][number]['id'],\n includeTransactions extends boolean = false,\n blockTag extends BlockTag = 'latest',\n>(\n config: config,\n parameters: GetBlockParameters<\n includeTransactions,\n blockTag,\n config,\n chainId\n > = {},\n): Promise<GetBlockReturnType<includeTransactions, blockTag, config, chainId>> {\n const { chainId, ...rest } = parameters\n const client = config.getClient({ chainId })\n const action = getAction(client, viem_getBlock, 'getBlock')\n const block = await action(rest)\n return {\n ...(block as unknown as GetBlockReturnType<\n includeTransactions,\n blockTag,\n config,\n chainId\n >),\n chainId: client.chain.id,\n }\n}\n", "import {\n type GetBlockNumberErrorType as viem_GetBlockNumberErrorType,\n type GetBlockNumberParameters as viem_GetBlockNumberParameters,\n type GetBlockNumberReturnType as viem_GetBlockNumberReturnType,\n getBlockNumber as viem_getBlockNumber,\n} from 'viem/actions'\n\nimport type { Config } from '../createConfig.js'\nimport type { ChainIdParameter } from '../types/properties.js'\nimport type { Compute } from '../types/utils.js'\nimport { getAction } from '../utils/getAction.js'\n\nexport type GetBlockNumberParameters<\n config extends Config = Config,\n chainId extends\n config['chains'][number]['id'] = config['chains'][number]['id'],\n> = Compute<viem_GetBlockNumberParameters & ChainIdParameter<config, chainId>>\n\nexport type GetBlockNumberReturnType = viem_GetBlockNumberReturnType\n\nexport type GetBlockNumberErrorType = viem_GetBlockNumberErrorType\n\n/** https://wagmi.sh/core/api/actions/getBlockNumber */\nexport function getBlockNumber<\n config extends Config,\n chainId extends\n config['chains'][number]['id'] = config['chains'][number]['id'],\n>(\n config: config,\n parameters: GetBlockNumberParameters<config, chainId> = {},\n): Promise<GetBlockNumberReturnType> {\n const { chainId, ...rest } = parameters\n const client = config.getClient({ chainId })\n const action = getAction(client, viem_getBlockNumber, 'getBlockNumber')\n return action(rest)\n}\n", "import {\n type GetBlockTransactionCountErrorType as viem_GetBlockTransactionCountErrorType,\n type GetBlockTransactionCountParameters as viem_GetBlockTransactionCountParameters,\n type GetBlockTransactionCountReturnType as viem_GetBlockTransactionCountReturnType,\n getBlockTransactionCount as viem_getBlockTransactionCount,\n} from 'viem/actions'\n\nimport type { Config } from '../createConfig.js'\nimport type { ChainIdParameter } from '../types/properties.js'\nimport type { UnionCompute } from '../types/utils.js'\nimport { getAction } from '../utils/getAction.js'\n\nexport type GetBlockTransactionCountParameters<\n config extends Config = Config,\n chainId extends\n config['chains'][number]['id'] = config['chains'][number]['id'],\n> = UnionCompute<\n viem_GetBlockTransactionCountParameters & ChainIdParameter<config, chainId>\n>\n\nexport type GetBlockTransactionCountReturnType =\n viem_GetBlockTransactionCountReturnType\n\nexport type GetBlockTransactionCountErrorType =\n viem_GetBlockTransactionCountErrorType\n\n/** https://wagmi.sh/core/api/actions/getBlockTransactionCount */\nexport function getBlockTransactionCount<\n config extends Config,\n chainId extends\n config['chains'][number]['id'] = config['chains'][number]['id'],\n>(\n config: config,\n parameters: GetBlockTransactionCountParameters<config, chainId> = {},\n): Promise<GetBlockTransactionCountReturnType> {\n const { chainId, ...rest } = parameters\n const client = config.getClient({ chainId })\n const action = getAction(\n client,\n viem_getBlockTransactionCount,\n 'getBlockTransactionCount',\n )\n return action(rest)\n}\n", "import {\n type GetBytecodeErrorType as viem_GetBytecodeErrorType,\n type GetBytecodeParameters as viem_GetBytecodeParameters,\n type GetBytecodeReturnType as viem_GetBytecodeReturnType,\n getBytecode as viem_getBytecode,\n} from 'viem/actions'\n\nimport type { Config } from '../createConfig.js'\nimport type { ChainIdParameter } from '../types/properties.js'\nimport type { Compute } from '../types/utils.js'\nimport { getAction } from '../utils/getAction.js'\n\nexport type GetBytecodeParameters<config extends Config = Config> = Compute<\n viem_GetBytecodeParameters & ChainIdParameter<config>\n>\n\nexport type GetBytecodeReturnType = viem_GetBytecodeReturnType\n\nexport type GetBytecodeErrorType = viem_GetBytecodeErrorType\n\n/** https://wagmi.sh/core/api/actions/getBytecode */\nexport async function getBytecode<config extends Config>(\n config: config,\n parameters: GetBytecodeParameters<config>,\n): Promise<GetBytecodeReturnType> {\n const { chainId, ...rest } = parameters\n const client = config.getClient({ chainId })\n const action = getAction(client, viem_getBytecode, 'getBytecode')\n return action(rest)\n}\n", "import type { Config } from '../createConfig.js'\n\nexport type GetChainIdReturnType<config extends Config = Config> =\n config['chains'][number]['id']\n\n/** https://wagmi.sh/core/api/actions/getChainId */\nexport function getChainId<config extends Config>(\n config: config,\n): GetChainIdReturnType<config> {\n return config.state.chainId\n}\n", "/** Forked from https://github.com/epoberezkin/fast-deep-equal */\n\nexport function deepEqual(a: any, b: any) {\n if (a === b) return true\n\n if (a && b && typeof a === 'object' && typeof b === 'object') {\n if (a.constructor !== b.constructor) return false\n\n let length: number\n let i: number\n\n if (Array.isArray(a) && Array.isArray(b)) {\n length = a.length\n if (length !== b.length) return false\n for (i = length; i-- !== 0; ) if (!deepEqual(a[i], b[i])) return false\n return true\n }\n\n if (a.valueOf !== Object.prototype.valueOf)\n return a.valueOf() === b.valueOf()\n if (a.toString !== Object.prototype.toString)\n return a.toString() === b.toString()\n\n const keys = Object.keys(a)\n length = keys.length\n if (length !== Object.keys(b).length) return false\n\n for (i = length; i-- !== 0; )\n if (!Object.prototype.hasOwnProperty.call(b, keys[i]!)) return false\n\n for (i = length; i-- !== 0; ) {\n const key = keys[i]\n\n if (key && !deepEqual(a[key], b[key])) return false\n }\n\n return true\n }\n\n // true if both NaN, false otherwise\n // biome-ignore lint/suspicious/noSelfCompare: <explanation>\n return a !== a && b !== b\n}\n", "import type { Chain } from 'viem'\nimport type { Config } from '../createConfig.js'\nimport { deepEqual } from '../utils/deepEqual.js'\n\nexport type GetChainsReturnType<config extends Config = Config> = readonly [\n ...config['chains'],\n ...Chain[],\n]\n\nlet previousChains: readonly Chain[] = []\n\n/** https://wagmi.sh/core/api/actions/getChains */\nexport function getChains<config extends Config>(\n config: config,\n): GetChainsReturnType<config> {\n const chains = config.chains\n if (deepEqual(previousChains, chains))\n return previousChains as GetChainsReturnType<config>\n previousChains = chains\n return chains as unknown as GetChainsReturnType<config>\n}\n", "import type { Client } from 'viem'\n\nimport type { Config } from '../createConfig.js'\nimport type { ChainIdParameter } from '../types/properties.js'\nimport type { Compute, IsNarrowable } from '../types/utils.js'\n\nexport type GetClientParameters<\n config extends Config = Config,\n chainId extends\n | config['chains'][number]['id']\n | number\n | undefined = config['chains'][number]['id'],\n> = ChainIdParameter<config, chainId>\n\nexport type GetClientReturnType<\n config extends Config = Config,\n chainId extends\n | config['chains'][number]['id']\n | undefined = config['chains'][number]['id'],\n ///\n resolvedChainId extends\n | config['chains'][number]['id']\n | undefined = IsNarrowable<\n config['chains'][number]['id'],\n number\n > extends true\n ? IsNarrowable<chainId, number> extends true\n ? chainId\n : config['chains'][number]['id']\n : config['chains'][number]['id'] | undefined,\n> = resolvedChainId extends config['chains'][number]['id']\n ? Compute<\n Client<\n config['_internal']['transports'][resolvedChainId],\n Extract<config['chains'][number], { id: resolvedChainId }>\n >\n >\n : undefined\n\nexport function getClient<\n config extends Config,\n chainId extends config['chains'][number]['id'] | number | undefined,\n>(\n config: config,\n parameters: GetClientParameters<config, chainId> = {},\n): GetClientReturnType<config, chainId> {\n let client = undefined\n try {\n client = config.getClient(parameters)\n } catch {}\n return client as GetClientReturnType<config, chainId>\n}\n", "import type { Config, Connection } from '../createConfig.js'\nimport type { Compute } from '../types/utils.js'\nimport { deepEqual } from '../utils/deepEqual.js'\n\nexport type GetConnectionsReturnType = Compute<Connection>[]\n\nlet previousConnections: Connection[] = []\n\n/** https://wagmi.sh/core/api/actions/getConnections */\nexport function getConnections(config: Config): GetConnectionsReturnType {\n const connections = [...config.state.connections.values()]\n if (config.state.status === 'reconnecting') return previousConnections\n if (deepEqual(previousConnections, connections)) return previousConnections\n previousConnections = connections\n return connections\n}\n", "import type { Config, Connector } from '../createConfig.js'\nimport { deepEqual } from '../utils/deepEqual.js'\n\nexport type GetConnectorsReturnType<config extends Config = Config> =\n config['connectors']\n\nlet previousConnectors: readonly Connector[] = []\n\n/** https://wagmi.sh/core/api/actions/getConnectors */\nexport function getConnectors<config extends Config>(\n config: config,\n): GetConnectorsReturnType<config> {\n const connectors = config.connectors\n if (deepEqual(previousConnectors, connectors)) return previousConnectors\n previousConnectors = connectors\n return connectors\n}\n", "import {\n type GetEnsAddressErrorType as viem_GetEnsAddressErrorType,\n type GetEnsAddressParameters as viem_GetEnsAddressParameters,\n type GetEnsAddressReturnType as viem_GetEnsAddressReturnType,\n getEnsAddress as viem_getEnsAddress,\n} from 'viem/actions'\n\nimport type { Config } from '../createConfig.js'\nimport type { ChainIdParameter } from '../types/properties.js'\nimport type { Compute } from '../types/utils.js'\nimport { getAction } from '../utils/getAction.js'\n\nexport type GetEnsAddressParameters<config extends Config = Config> = Compute<\n viem_GetEnsAddressParameters & ChainIdParameter<config>\n>\n\nexport type GetEnsAddressReturnType = viem_GetEnsAddressReturnType\n\nexport type GetEnsAddressErrorType = viem_GetEnsAddressErrorType\n\n/** https://wagmi.sh/core/api/actions/getEnsAddress */\nexport function getEnsAddress<config extends Config>(\n config: config,\n parameters: GetEnsAddressParameters<config>,\n): Promise<GetEnsAddressReturnType> {\n const { chainId, ...rest } = parameters\n const client = config.getClient({ chainId })\n const action = getAction(client, viem_getEnsAddress, 'getEnsAddress')\n return action(rest)\n}\n", "import {\n type GetEnsAvatarErrorType as viem_GetEnsAvatarErrorType,\n type GetEnsAvatarParameters as viem_GetEnsAvatarParameters,\n type GetEnsAvatarReturnType as viem_GetEnsAvatarReturnType,\n getEnsAvatar as viem_getEnsAvatar,\n} from 'viem/actions'\n\nimport type { Config } from '../createConfig.js'\nimport type { ChainIdParameter } from '../types/properties.js'\nimport type { Compute } from '../types/utils.js'\nimport { getAction } from '../utils/getAction.js'\n\nexport type GetEnsAvatarParameters<config extends Config = Config> = Compute<\n viem_GetEnsAvatarParameters & ChainIdParameter<config>\n>\n\nexport type GetEnsAvatarReturnType = viem_GetEnsAvatarReturnType\n\nexport type GetEnsAvatarErrorType = viem_GetEnsAvatarErrorType\n\n/** https://wagmi.sh/core/api/actions/getEnsAvatar */\nexport function getEnsAvatar<config extends Config>(\n config: config,\n parameters: GetEnsAvatarParameters<config>,\n): Promise<GetEnsAvatarReturnType> {\n const { chainId, ...rest } = parameters\n const client = config.getClient({ chainId })\n const action = getAction(client, viem_getEnsAvatar, 'getEnsAvatar')\n return action(rest)\n}\n", "import {\n type GetEnsNameErrorType as viem_GetEnsNameErrorType,\n type GetEnsNameParameters as viem_GetEnsNameParameters,\n type GetEnsNameReturnType as viem_GetEnsNameReturnType,\n getEnsName as viem_getEnsName,\n} from 'viem/actions'\n\nimport type { Config } from '../createConfig.js'\nimport type { ChainIdParameter } from '../types/properties.js'\nimport type { Compute } from '../types/utils.js'\nimport { getAction } from '../utils/getAction.js'\n\nexport type GetEnsNameParameters<config extends Config = Config> = Compute<\n viem_GetEnsNameParameters & ChainIdParameter<config>\n>\n\nexport type GetEnsNameReturnType = viem_GetEnsNameReturnType\n\nexport type GetEnsNameErrorType = viem_GetEnsNameErrorType\n\n/** https://wagmi.sh/core/api/actions/getEnsName */\nexport function getEnsName<config extends Config>(\n config: config,\n parameters: GetEnsNameParameters<config>,\n): Promise<GetEnsNameReturnType> {\n const { chainId, ...rest } = parameters\n const client = config.getClient({ chainId })\n const action = getAction(client, viem_getEnsName, 'getEnsName')\n return action(rest)\n}\n", "import {\n type GetEnsResolverErrorType as viem_GetEnsResolverErrorType,\n type GetEnsResolverParameters as viem_GetEnsResolverParameters,\n type GetEnsResolverReturnType as viem_GetEnsResolverReturnType,\n getEnsResolver as viem_getEnsResolver,\n} from 'viem/actions'\n\nimport type { Config } from '../createConfig.js'\nimport type { ChainIdParameter } from '../types/properties.js'\nimport type { Compute } from '../types/utils.js'\nimport { getAction } from '../utils/getAction.js'\n\nexport type GetEnsResolverParameters<config extends Config = Config> = Compute<\n viem_GetEnsResolverParameters & ChainIdParameter<config>\n>\n\nexport type GetEnsResolverReturnType = viem_GetEnsResolverReturnType\n\nexport type GetEnsResolverErrorType = viem_GetEnsResolverErrorType\n\n/** https://wagmi.sh/core/api/actions/getEnsResolver */\nexport function getEnsResolver<config extends Config>(\n config: config,\n parameters: GetEnsResolverParameters<config>,\n): Promise<GetEnsResolverReturnType> {\n const { chainId, ...rest } = parameters\n const client = config.getClient({ chainId })\n const action = getAction(client, viem_getEnsResolver, 'getEnsResolver')\n return action(rest)\n}\n", "import {\n type GetEnsTextErrorType as viem_GetEnsTextErrorType,\n type GetEnsTextParameters as viem_GetEnsTextParameters,\n type GetEnsTextReturnType as viem_GetEnsTextReturnType,\n getEnsText as viem_getEnsText,\n} from 'viem/actions'\n\nimport type { Config } from '../createConfig.js'\nimport type { ChainIdParameter } from '../types/properties.js'\nimport type { Compute } from '../types/utils.js'\nimport { getAction } from '../utils/getAction.js'\n\nexport type GetEnsTextParameters<config extends Config = Config> = Compute<\n viem_GetEnsTextParameters & ChainIdParameter<config>\n>\n\nexport type GetEnsTextReturnType = viem_GetEnsTextReturnType\n\nexport type GetEnsTextErrorType = viem_GetEnsTextErrorType\n\n/** https://wagmi.sh/core/api/actions/getEnsText */\nexport function getEnsText<config extends Config>(\n config: config,\n parameters: GetEnsTextParameters<config>,\n): Promise<GetEnsTextReturnType> {\n const { chainId, ...rest } = parameters\n const client = config.getClient({ chainId })\n const action = getAction(client, viem_getEnsText, 'getEnsText')\n return action(rest)\n}\n", "import {\n type GetFeeHistoryErrorType as viem_GetFeeHistoryErrorType,\n type GetFeeHistoryParameters as viem_GetFeeHistoryParameters,\n type GetFeeHistoryReturnType as viem_GetFeeHistoryReturnType,\n getFeeHistory as viem_getFeeHistory,\n} from 'viem/actions'\n\nimport type { Config } from '../createConfig.js'\nimport type { ChainIdParameter } from '../types/properties.js'\nimport type { Compute } from '../types/utils.js'\nimport { getAction } from '../utils/getAction.js'\n\nexport type GetFeeHistoryParameters<\n config extends Config = Config,\n chainId extends\n config['chains'][number]['id'] = config['chains'][number]['id'],\n> = Compute<viem_GetFeeHistoryParameters & ChainIdParameter<config, chainId>>\n\nexport type GetFeeHistoryReturnType = viem_GetFeeHistoryReturnType\n\nexport type GetFeeHistoryErrorType = viem_GetFeeHistoryErrorType\n\n/** https://wagmi.sh/core/api/actions/getFeeHistory */\nexport function getFeeHistory<\n config extends Config,\n chainId extends\n config['chains'][number]['id'] = config['chains'][number]['id'],\n>(\n config: config,\n parameters: GetFeeHistoryParameters<config, chainId>,\n): Promise<GetFeeHistoryReturnType> {\n const { chainId, ...rest } = parameters\n const client = config.getClient({ chainId })\n const action = getAction(client, viem_getFeeHistory, 'getFeeHistory')\n return action(rest)\n}\n", "import {\n type GetGasPriceErrorType as viem_GetGasPriceErrorType,\n type GetGasPriceReturnType as viem_GetGasPriceReturnType,\n getGasPrice as viem_getGasPrice,\n} from 'viem/actions'\n\nimport type { Config } from '../createConfig.js'\nimport type { ChainIdParameter } from '../types/properties.js'\nimport type { Compute } from '../types/utils.js'\nimport { getAction } from '../utils/getAction.js'\n\nexport type GetGasPriceParameters<\n config extends Config = Config,\n chainId extends\n config['chains'][number]['id'] = config['chains'][number]['id'],\n> = Compute<ChainIdParameter<config, chainId>>\n\nexport type GetGasPriceReturnType = viem_GetGasPriceReturnType\n\nexport type GetGasPriceErrorType = viem_GetGasPriceErrorType\n\n/** https://wagmi.sh/core/api/actions/getGasPrice */\nexport function getGasPrice<\n config extends Config,\n chainId extends\n config['chains'][number]['id'] = config['chains'][number]['id'],\n>(\n config: config,\n parameters: GetGasPriceParameters<config, chainId> = {},\n): Promise<GetGasPriceReturnType> {\n const { chainId } = parameters\n const client = config.getClient({ chainId })\n const action = getAction(client, viem_getGasPrice, 'getGasPrice')\n return action({})\n}\n", "import {\n type GetProofErrorType as viem_GetProofErrorType,\n type GetProofParameters as viem_GetProofParameters,\n type GetProofReturnType as viem_GetProofReturnType,\n getProof as viem_getProof,\n} from 'viem/actions'\n\nimport type { Config } from '../createConfig.js'\nimport type { ChainIdParameter } from '../types/properties.js'\nimport type { Compute } from '../types/utils.js'\nimport { getAction } from '../utils/getAction.js'\n\nexport type GetProofParameters<config extends Config = Config> = Compute<\n viem_GetProofParameters & ChainIdParameter<config>\n>\n\nexport type GetProofReturnType = viem_GetProofReturnType\n\nexport type GetProofErrorType = viem_GetProofErrorType\n\n/** https://wagmi.sh/core/api/actions/getProof */\nexport async function getProof<config extends Config>(\n config: config,\n parameters: GetProofParameters<config>,\n): Promise<GetProofReturnType> {\n const { chainId, ...rest } = parameters\n const client = config.getClient({ chainId })\n const action = getAction(client, viem_getProof, 'getProof')\n return action(rest)\n}\n", "import { type Client, type PublicClient, publicActions } from 'viem'\n\nimport type { Config } from '../createConfig.js'\nimport type { ChainIdParameter } from '../types/properties.js'\nimport type { Compute, IsNarrowable } from '../types/utils.js'\nimport { getClient } from './getClient.js'\n\nexport type GetPublicClientParameters<\n config extends Config = Config,\n chainId extends\n | config['chains'][number]['id']\n | undefined = config['chains'][number]['id'],\n> = ChainIdParameter<config, chainId>\n\nexport type GetPublicClientReturnType<\n config extends Config = Config,\n chainId extends\n | config['chains'][number]['id']\n | undefined = config['chains'][number]['id'],\n ///\n resolvedChainId extends\n | config['chains'][number]['id']\n | undefined = IsNarrowable<\n config['chains'][number]['id'],\n number\n > extends true\n ? IsNarrowable<chainId, number> extends true\n ? chainId\n : config['chains'][number]['id']\n : config['chains'][number]['id'] | undefined,\n> = resolvedChainId extends config['chains'][number]['id']\n ? Compute<\n PublicClient<\n config['_internal']['transports'][resolvedChainId],\n Extract<config['chains'][number], { id: resolvedChainId }>\n >\n >\n : undefined\n\nexport function getPublicClient<\n config extends Config,\n chainId extends config['chains'][number]['id'] | number | undefined,\n>(\n config: config,\n parameters: GetPublicClientParameters<config, chainId> = {},\n): GetPublicClientReturnType<config, chainId> {\n const client = getClient(config, parameters)\n return (client as Client)?.extend(publicActions) as GetPublicClientReturnType<\n config,\n chainId\n >\n}\n", "import {\n type GetStorageAtErrorType as viem_GetStorageAtErrorType,\n type GetStorageAtParameters as viem_GetStorageAtParameters,\n type GetStorageAtReturnType as viem_GetStorageAtReturnType,\n getStorageAt as viem_getStorageAt,\n} from 'viem/actions'\n\nimport type { Config } from '../createConfig.js'\nimport type { ChainIdParameter } from '../types/properties.js'\nimport type { Compute } from '../types/utils.js'\nimport { getAction } from '../utils/getAction.js'\n\nexport type GetStorageAtParameters<config extends Config = Config> = Compute<\n viem_GetStorageAtParameters & ChainIdParameter<config>\n>\n\nexport type GetStorageAtReturnType = viem_GetStorageAtReturnType\n\nexport type GetStorageAtErrorType = viem_GetStorageAtErrorType\n\n/** https://wagmi.sh/core/api/actions/getStorageAt */\nexport async function getStorageAt<config extends Config>(\n config: config,\n parameters: GetStorageAtParameters<config>,\n): Promise<GetStorageAtReturnType> {\n const { chainId, ...rest } = parameters\n const client = config.getClient({ chainId })\n const action = getAction(client, viem_getStorageAt, 'getStorageAt')\n return action(rest)\n}\n", "import type { Address, Hex } from 'viem'\nimport {\n ContractFunctionExecutionError,\n formatUnits,\n hexToString,\n trim,\n} from 'viem'\n\nimport type { Config } from '../createConfig.js'\nimport type { ChainIdParameter } from '../types/properties.js'\nimport type { Unit } from '../types/unit.js'\nimport type { Compute } from '../types/utils.js'\nimport { getUnit } from '../utils/getUnit.js'\nimport { type ReadContractsErrorType, readContracts } from './readContracts.js'\n\nexport type GetTokenParameters<config extends Config = Config> = Compute<\n ChainIdParameter<config> & {\n address: Address\n formatUnits?: Unit | undefined\n }\n>\n\nexport type GetTokenReturnType = {\n address: Address\n decimals: number\n name: string | undefined\n symbol: string | undefined\n totalSupply: {\n formatted: string\n value: bigint\n }\n}\n\nexport type GetTokenErrorType = ReadContractsErrorType\n\n/** @deprecated */\nexport async function getToken<config extends Config>(\n config: config,\n parameters: GetTokenParameters<config>,\n): Promise<GetTokenReturnType> {\n const { address, chainId, formatUnits: unit = 18 } = parameters\n\n function getAbi<type extends 'bytes32' | 'string'>(type: type) {\n return [\n {\n type: 'function',\n name: 'decimals',\n stateMutability: 'view',\n inputs: [],\n outputs: [{ type: 'uint8' }],\n },\n {\n type: 'function',\n name: 'name',\n stateMutability: 'view',\n inputs: [],\n outputs: [{ type }],\n },\n {\n type: 'function',\n name: 'symbol',\n stateMutability: 'view',\n inputs: [],\n outputs: [{ type }],\n },\n {\n type: 'function',\n name: 'totalSupply',\n stateMutability: 'view',\n inputs: [],\n outputs: [{ type: 'uint256' }],\n },\n ] as const\n }\n\n try {\n const abi = getAbi('string')\n const contractConfig = { address, abi, chainId } as const\n const [decimals, name, symbol, totalSupply] = await readContracts(config, {\n allowFailure: true,\n contracts: [\n { ...contractConfig, functionName: 'decimals' },\n { ...contractConfig, functionName: 'name' },\n { ...contractConfig, functionName: 'symbol' },\n { ...contractConfig, functionName: 'totalSupply' },\n ] as const,\n })\n\n // throw if `name` or `symbol` failed\n if (name.error instanceof ContractFunctionExecutionError) throw name.error\n if (symbol.error instanceof ContractFunctionExecutionError)\n throw symbol.error\n\n // `decimals` and `totalSupply` are required\n if (decimals.error) throw decimals.error\n if (totalSupply.error) throw totalSupply.error\n\n return {\n address,\n decimals: decimals.result,\n name: name.result,\n symbol: symbol.result,\n totalSupply: {\n formatted: formatUnits(totalSupply.result!, getUnit(unit)),\n value: totalSupply.result,\n },\n }\n } catch (error) {\n // In the chance that there is an error upon decoding the contract result,\n // it could be likely that the contract data is represented as bytes32 instead\n // of a string.\n if (error instanceof ContractFunctionExecutionError) {\n const abi = getAbi('bytes32')\n const contractConfig = { address, abi, chainId } as const\n const [decimals, name, symbol, totalSupply] = await readContracts(\n config,\n {\n allowFailure: false,\n contracts: [\n { ...contractConfig, functionName: 'decimals' },\n { ...contractConfig, functionName: 'name' },\n { ...contractConfig, functionName: 'symbol' },\n { ...contractConfig, functionName: 'totalSupply' },\n ] as const,\n },\n )\n return {\n address,\n decimals,\n name: hexToString(trim(name as Hex, { dir: 'right' })),\n symbol: hexToString(trim(symbol as Hex, { dir: 'right' })),\n totalSupply: {\n formatted: formatUnits(totalSupply, getUnit(unit)),\n value: totalSupply,\n },\n }\n }\n\n throw error\n }\n}\n", "import type { Chain } from 'viem'\nimport {\n type GetTransactionErrorType as viem_GetTransactionErrorType,\n type GetTransactionParameters as viem_GetTransactionParameters,\n type GetTransactionReturnType as viem_GetTransactionReturnType,\n getTransaction as viem_getTransaction,\n} from 'viem/actions'\n\nimport type { Config } from '../createConfig.js'\nimport type { SelectChains } from '../types/chain.js'\nimport type { ChainIdParameter } from '../types/properties.js'\nimport type { Compute, IsNarrowable } from '../types/utils.js'\nimport { getAction } from '../utils/getAction.js'\n\nexport type GetTransactionParameters<\n config extends Config = Config,\n chainId extends\n config['chains'][number]['id'] = config['chains'][number]['id'],\n> = Compute<viem_GetTransactionParameters & ChainIdParameter<config, chainId>>\n\nexport type GetTransactionReturnType<\n config extends Config = Config,\n chainId extends\n config['chains'][number]['id'] = config['chains'][number]['id'],\n ///\n chains extends readonly Chain[] = SelectChains<config, chainId>,\n> = Compute<\n {\n [key in keyof chains]: viem_GetTransactionReturnType<\n IsNarrowable<chains[key], Chain> extends true ? chains[key] : undefined\n > & { chainId: chains[key]['id'] }\n }[number]\n>\n\nexport type GetTransactionErrorType = viem_GetTransactionErrorType\n\n/** https://wagmi.sh/core/api/actions/getTransaction */\nexport function getTransaction<\n config extends Config,\n chainId extends config['chains'][number]['id'],\n>(\n config: config,\n parameters: GetTransactionParameters<config, chainId>,\n): Promise<GetTransactionReturnType<config, chainId>> {\n const { chainId, ...rest } = parameters\n const client = config.getClient({ chainId })\n const action = getAction(client, viem_getTransaction, 'getTransaction')\n return action(rest) as unknown as Promise<\n GetTransactionReturnType<config, chainId>\n >\n}\n", "import type { Chain } from 'viem'\nimport {\n type GetTransactionConfirmationsErrorType as viem_GetTransactionConfirmationsErrorType,\n type GetTransactionConfirmationsParameters as viem_GetTransactionConfirmationsParameters,\n type GetTransactionConfirmationsReturnType as viem_GetTransactionConfirmationsReturnType,\n getTransactionConfirmations as viem_getTransactionConfirmations,\n} from 'viem/actions'\n\nimport type { Config } from '../createConfig.js'\nimport type { SelectChains } from '../types/chain.js'\nimport type { ChainIdParameter } from '../types/properties.js'\nimport { getAction } from '../utils/getAction.js'\n\nexport type GetTransactionConfirmationsParameters<\n config extends Config = Config,\n chainId extends\n | config['chains'][number]['id']\n | undefined = config['chains'][number]['id'],\n ///\n chains extends readonly Chain[] = SelectChains<config, chainId>,\n> = {\n [key in keyof chains]: viem_GetTransactionConfirmationsParameters<\n chains[key]\n > &\n ChainIdParameter<config, chainId>\n}[number]\n\nexport type GetTransactionConfirmationsReturnType =\n viem_GetTransactionConfirmationsReturnType\n\nexport type GetTransactionConfirmationsErrorType =\n viem_GetTransactionConfirmationsErrorType\n\n/** https://wagmi.sh/core/api/actions/getTransactionConfirmations */\nexport function getTransactionConfirmations<\n config extends Config,\n chainId extends\n | config['chains'][number]['id']\n | undefined = config['chains'][number]['id'],\n>(\n config: config,\n parameters: GetTransactionConfirmationsParameters<config, chainId>,\n): Promise<GetTransactionConfirmationsReturnType> {\n const { chainId, ...rest } = parameters\n const client = config.getClient({ chainId })\n const action = getAction(\n client,\n viem_getTransactionConfirmations,\n 'getTransactionConfirmations',\n )\n return action(rest as viem_GetTransactionConfirmationsParameters)\n}\n", "import {\n type GetTransactionCountErrorType as viem_GetTransactionCountErrorType,\n type GetTransactionCountParameters as viem_GetTransactionCountParameters,\n type GetTransactionCountReturnType as viem_GetTransactionCountReturnType,\n getTransactionCount as viem_getTransactionCount,\n} from 'viem/actions'\n\nimport type { Config } from '../createConfig.js'\nimport type { ChainIdParameter } from '../types/properties.js'\nimport type { Compute } from '../types/utils.js'\nimport { getAction } from '../utils/getAction.js'\n\nexport type GetTransactionCountParameters<config extends Config = Config> =\n Compute<ChainIdParameter<config> & viem_GetTransactionCountParameters>\n\nexport type GetTransactionCountReturnType = viem_GetTransactionCountReturnType\n\nexport type GetTransactionCountErrorType = viem_GetTransactionCountErrorType\n\n/** https://wagmi.sh/core/api/actions/getTransactionCount */\nexport async function getTransactionCount<config extends Config>(\n config: config,\n parameters: GetTransactionCountParameters<config>,\n): Promise<GetTransactionCountReturnType> {\n const { address, blockNumber, blockTag, chainId } = parameters\n\n const client = config.getClient({ chainId })\n const action = getAction(\n client,\n viem_getTransactionCount,\n 'getTransactionCount',\n )\n return action(blockNumber ? { address, blockNumber } : { address, blockTag })\n}\n", "import type { Chain } from 'viem'\nimport {\n type GetTransactionReceiptErrorType as viem_GetTransactionReceiptErrorType,\n type GetTransactionReceiptParameters as viem_GetTransactionReceiptParameters,\n type GetTransactionReceiptReturnType as viem_GetTransactionReceiptReturnType,\n getTransactionReceipt as viem_getTransactionReceipt,\n} from 'viem/actions'\n\nimport type { Config } from '../createConfig.js'\nimport type { SelectChains } from '../types/chain.js'\nimport type { ChainIdParameter } from '../types/properties.js'\nimport type { Compute, IsNarrowable } from '../types/utils.js'\nimport { getAction } from '../utils/getAction.js'\n\nexport type GetTransactionReceiptParameters<\n config extends Config = Config,\n chainId extends\n config['chains'][number]['id'] = config['chains'][number]['id'],\n> = Compute<\n viem_GetTransactionReceiptParameters & ChainIdParameter<config, chainId>\n>\n\nexport type GetTransactionReceiptReturnType<\n config extends Config = Config,\n chainId extends\n config['chains'][number]['id'] = config['chains'][number]['id'],\n ///\n chains extends readonly Chain[] = SelectChains<config, chainId>,\n> = Compute<\n {\n [key in keyof chains]: viem_GetTransactionReceiptReturnType<\n IsNarrowable<chains[key], Chain> extends true ? chains[key] : undefined\n > & { chainId: chains[key]['id'] }\n }[number]\n>\n\nexport type GetTransactionReceiptErrorType = viem_GetTransactionReceiptErrorType\n\n/** https://wagmi.sh/core/api/actions/getTransactionReceipt */\nexport async function getTransactionReceipt<\n config extends Config,\n chainId extends config['chains'][number]['id'],\n>(\n config: config,\n parameters: GetTransactionReceiptParameters<config>,\n): Promise<GetTransactionReceiptReturnType<config, chainId>> {\n const { chainId, ...rest } = parameters\n const client = config.getClient({ chainId })\n const action = getAction(\n client,\n viem_getTransactionReceipt,\n 'getTransactionReceipt',\n )\n return action(rest) as unknown as Promise<\n GetTransactionReceiptReturnType<config, chainId>\n >\n}\n", "import { type Account, type WalletClient, walletActions } from 'viem'\n\nimport type { Config } from '../createConfig.js'\nimport type { BaseErrorType, ErrorType } from '../errors/base.js'\nimport type { Compute } from '../types/utils.js'\nimport {\n type GetConnectorClientErrorType,\n type GetConnectorClientParameters,\n getConnectorClient,\n} from './getConnectorClient.js'\n\nexport type GetWalletClientParameters<\n config extends Config = Config,\n chainId extends\n config['chains'][number]['id'] = config['chains'][number]['id'],\n> = GetConnectorClientParameters<Config, chainId>\n\nexport type GetWalletClientReturnType<\n config extends Config = Config,\n chainId extends\n config['chains'][number]['id'] = config['chains'][number]['id'],\n> = Compute<\n WalletClient<\n config['_internal']['transports'][chainId],\n Extract<config['chains'][number], { id: chainId }>,\n Account\n >\n>\n\nexport type GetWalletClientErrorType =\n // getConnectorClient()\n | GetConnectorClientErrorType\n // base\n | BaseErrorType\n | ErrorType\n\nexport async function getWalletClient<\n config extends Config,\n chainId extends config['chains'][number]['id'],\n>(\n config: config,\n parameters: GetWalletClientParameters<config, chainId> = {},\n): Promise<GetWalletClientReturnType<config, chainId>> {\n const client = await getConnectorClient(config, parameters)\n // @ts-ignore\n return client.extend(walletActions) as unknown as GetWalletClientReturnType<\n config,\n chainId\n >\n}\n", "import type {\n Account,\n Address,\n Chain,\n PrepareTransactionRequestErrorType as viem_PrepareTransactionRequestErrorType,\n PrepareTransactionRequestParameters as viem_PrepareTransactionRequestParameters,\n PrepareTransactionRequestRequest as viem_PrepareTransactionRequestRequest,\n PrepareTransactionRequestReturnType as viem_PrepareTransactionRequestReturnType,\n} from 'viem'\nimport { prepareTransactionRequest as viem_prepareTransactionRequest } from 'viem/actions'\n\nimport type { Config } from '../createConfig.js'\nimport type { SelectChains } from '../types/chain.js'\nimport type { ChainIdParameter } from '../types/properties.js'\nimport type {\n Compute,\n IsNarrowable,\n UnionCompute,\n UnionStrictOmit,\n} from '../types/utils.js'\nimport { getAction } from '../utils/getAction.js'\nimport { getAccount } from './getAccount.js'\n\nexport type PrepareTransactionRequestParameters<\n config extends Config = Config,\n chainId extends\n | config['chains'][number]['id']\n | undefined = config['chains'][number]['id'],\n request extends viem_PrepareTransactionRequestRequest<\n SelectChains<config, chainId>[0],\n SelectChains<config, chainId>[0]\n > = viem_PrepareTransactionRequestRequest<\n SelectChains<config, chainId>[0],\n SelectChains<config, chainId>[0]\n >,\n ///\n chains extends readonly Chain[] = SelectChains<config, chainId>,\n> = {\n [key in keyof chains]: UnionCompute<\n UnionStrictOmit<\n viem_PrepareTransactionRequestParameters<\n chains[key],\n Account,\n chains[key],\n Account | Address,\n request extends viem_PrepareTransactionRequestRequest<\n chains[key],\n chains[key]\n >\n ? request\n : never\n >,\n 'chain'\n > &\n ChainIdParameter<config, chainId> & {\n to: Address\n }\n >\n}[number]\n\nexport type PrepareTransactionRequestReturnType<\n config extends Config = Config,\n chainId extends\n | config['chains'][number]['id']\n | undefined = config['chains'][number]['id'],\n request extends viem_PrepareTransactionRequestRequest<\n SelectChains<config, chainId>[0],\n SelectChains<config, chainId>[0]\n > = viem_PrepareTransactionRequestRequest<\n SelectChains<config, chainId>[0],\n SelectChains<config, chainId>[0]\n >,\n ///\n chains extends readonly Chain[] = SelectChains<config, chainId>,\n> = {\n [key in keyof chains]: Compute<\n viem_PrepareTransactionRequestReturnType<\n IsNarrowable<chains[key], Chain> extends true ? chains[key] : undefined,\n Account,\n chains[key],\n Account,\n request extends viem_PrepareTransactionRequestRequest<\n IsNarrowable<chains[key], Chain> extends true ? chains[key] : undefined,\n chains[key]\n >\n ? request\n : never\n >\n > & {\n chainId: chains[key]['id']\n }\n}[number]\n\nexport type PrepareTransactionRequestErrorType =\n viem_PrepareTransactionRequestErrorType\n\n/** https://wagmi.sh/core/api/actions/prepareTransactionRequest */\nexport async function prepareTransactionRequest<\n config extends Config,\n chainId extends config['chains'][number]['id'] | undefined,\n const request extends viem_PrepareTransactionRequestRequest<\n SelectChains<config, chainId>['0'],\n SelectChains<config, chainId>['0']\n >,\n>(\n config: config,\n parameters: PrepareTransactionRequestParameters<config, chainId, request>,\n): Promise<PrepareTransactionRequestReturnType<config, chainId, request>> {\n const { account: account_, chainId, ...rest } = parameters\n\n const account = account_ ?? getAccount(config).address\n const client = config.getClient({ chainId })\n\n const action = getAction(\n client,\n viem_prepareTransactionRequest,\n 'prepareTransactionRequest',\n )\n return action({\n ...rest,\n ...(account ? { account } : {}),\n } as unknown as viem_PrepareTransactionRequestParameters) as unknown as Promise<\n PrepareTransactionRequestReturnType<config, chainId, request>\n >\n}\n", "import type { Address } from 'viem'\n\nimport type { CreateConnectorFn } from '../connectors/createConnector.js'\nimport type { Config, Connection, Connector } from '../createConfig.js'\nimport type { ErrorType } from '../errors/base.js'\nimport type { Compute } from '../types/utils.js'\n\nexport type ReconnectParameters = {\n /** Connectors to attempt reconnect with */\n connectors?: readonly (CreateConnectorFn | Connector)[] | undefined\n}\n\nexport type ReconnectReturnType = Compute<Connection>[]\n\nexport type ReconnectErrorType = ErrorType\n\nlet isReconnecting = false\n\n/** https://wagmi.sh/core/api/actions/reconnect */\nexport async function reconnect(\n config: Config,\n parameters: ReconnectParameters = {},\n): Promise<ReconnectReturnType> {\n // If already reconnecting, do nothing\n if (isReconnecting) return []\n isReconnecting = true\n\n config.setState((x) => ({\n ...x,\n status: x.current ? 'reconnecting' : 'connecting',\n }))\n\n const connectors: Connector[] = []\n if (parameters.connectors?.length) {\n for (const connector_ of parameters.connectors) {\n let connector: Connector\n // \"Register\" connector if not already created\n if (typeof connector_ === 'function')\n connector = config._internal.connectors.setup(connector_)\n else connector = connector_\n connectors.push(connector)\n }\n } else connectors.push(...config.connectors)\n\n // Try recently-used connectors first\n let recentConnectorId: string | null | undefined\n try {\n recentConnectorId = await config.storage?.getItem('recentConnectorId')\n } catch {}\n const scores: Record<string, number> = {}\n for (const [, connection] of config.state.connections) {\n scores[connection.connector.id] = 1\n }\n if (recentConnectorId) scores[recentConnectorId] = 0\n const sorted =\n Object.keys(scores).length > 0\n ? // .toSorted()\n [...connectors].sort(\n (a, b) => (scores[a.id] ?? 10) - (scores[b.id] ?? 10),\n )\n : connectors\n\n // Iterate through each connector and try to connect\n let connected = false\n const connections: Connection[] = []\n const providers: unknown[] = []\n for (const connector of sorted) {\n const provider = await connector.getProvider().catch(() => undefined)\n if (!provider) continue\n\n // If we already have an instance of this connector's provider,\n // then we have already checked it (ie. injected connectors can\n // share the same `window.ethereum` instance, so we don't want to\n // connect to it again).\n if (providers.some((x) => x === provider)) continue\n\n const isAuthorized = await connector.isAuthorized()\n if (!isAuthorized) continue\n\n const data = await connector\n .connect({ isReconnecting: true })\n .catch(() => null)\n if (!data) continue\n\n connector.emitter.off('connect', config._internal.events.connect)\n connector.emitter.on('change', config._internal.events.change)\n connector.emitter.on('disconnect', config._internal.events.disconnect)\n\n config.setState((x) => {\n const connections = new Map(connected ? x.connections : new Map()).set(\n connector.uid,\n { accounts: data.accounts, chainId: data.chainId, connector },\n )\n return {\n ...x,\n current: connected ? x.current : connector.uid,\n connections,\n }\n })\n connections.push({\n accounts: data.accounts as readonly [Address, ...Address[]],\n chainId: data.chainId,\n connector,\n })\n providers.push(provider)\n connected = true\n }\n\n // Prevent overwriting connected status from race condition\n if (\n config.state.status === 'reconnecting' ||\n config.state.status === 'connecting'\n ) {\n // If connecting didn't succeed, set to disconnected\n if (!connected)\n config.setState((x) => ({\n ...x,\n connections: new Map(),\n current: null,\n status: 'disconnected',\n }))\n else config.setState((x) => ({ ...x, status: 'connected' }))\n }\n\n isReconnecting = false\n return connections\n}\n", "import type {\n Account,\n Chain,\n Client,\n TransactionRequest,\n SendTransactionErrorType as viem_SendTransactionErrorType,\n SendTransactionParameters as viem_SendTransactionParameters,\n SendTransactionReturnType as viem_SendTransactionReturnType,\n} from 'viem'\nimport { sendTransaction as viem_sendTransaction } from 'viem/actions'\n\nimport type { Config } from '../createConfig.js'\nimport type { BaseErrorType, ErrorType } from '../errors/base.js'\nimport type { SelectChains } from '../types/chain.js'\nimport type {\n ChainIdParameter,\n ConnectorParameter,\n} from '../types/properties.js'\nimport type { Compute } from '../types/utils.js'\nimport { getAction } from '../utils/getAction.js'\nimport {\n type GetConnectorClientErrorType,\n getConnectorClient,\n} from './getConnectorClient.js'\n\nexport type SendTransactionParameters<\n config extends Config = Config,\n chainId extends\n config['chains'][number]['id'] = config['chains'][number]['id'],\n ///\n chains extends readonly Chain[] = SelectChains<config, chainId>,\n> = {\n [key in keyof chains]: Compute<\n Omit<\n viem_SendTransactionParameters<chains[key], Account, chains[key]>,\n 'chain' | 'gas'\n > &\n ChainIdParameter<config, chainId> &\n ConnectorParameter\n >\n}[number] & {\n /** Gas provided for transaction execution. */\n gas?: TransactionRequest['gas'] | null\n}\n\nexport type SendTransactionReturnType = viem_SendTransactionReturnType\n\nexport type SendTransactionErrorType =\n // getConnectorClient()\n | GetConnectorClientErrorType\n // base\n | BaseErrorType\n | ErrorType\n // viem\n | viem_SendTransactionErrorType\n\n/** https://wagmi.sh/core/api/actions/sendTransaction */\nexport async function sendTransaction<\n config extends Config,\n chainId extends config['chains'][number]['id'],\n>(\n config: config,\n parameters: SendTransactionParameters<config, chainId>,\n): Promise<SendTransactionReturnType> {\n const { account, chainId, connector, ...rest } = parameters\n\n let client: Client\n if (typeof account === 'object' && account?.type === 'local')\n client = config.getClient({ chainId })\n else\n client = await getConnectorClient(config, {\n account: account ?? undefined,\n chainId,\n connector,\n })\n\n const action = getAction(client, viem_sendTransaction, 'sendTransaction')\n const hash = await action({\n ...(rest as any),\n ...(account ? { account } : {}),\n chain: chainId ? { id: chainId } : null,\n gas: rest.gas ?? undefined,\n })\n\n return hash\n}\n", "import type { Account, Client } from 'viem'\nimport {\n type SignMessageErrorType as viem_SignMessageErrorType,\n type SignMessageParameters as viem_SignMessageParameters,\n type SignMessageReturnType as viem_SignMessageReturnType,\n signMessage as viem_signMessage,\n} from 'viem/actions'\n\nimport type { Config } from '../createConfig.js'\nimport type { BaseErrorType, ErrorType } from '../errors/base.js'\nimport type { ConnectorParameter } from '../types/properties.js'\nimport type { Compute } from '../types/utils.js'\nimport { getAction } from '../utils/getAction.js'\nimport {\n type GetConnectorClientErrorType,\n getConnectorClient,\n} from './getConnectorClient.js'\n\nexport type SignMessageParameters = Compute<\n viem_SignMessageParameters<Account> & ConnectorParameter\n>\n\nexport type SignMessageReturnType = viem_SignMessageReturnType\n\nexport type SignMessageErrorType =\n // getConnectorClient()\n | GetConnectorClientErrorType\n // base\n | BaseErrorType\n | ErrorType\n // viem\n | viem_SignMessageErrorType\n\n/** https://wagmi.sh/core/api/actions/signMessage */\nexport async function signMessage(\n config: Config,\n parameters: SignMessageParameters,\n): Promise<SignMessageReturnType> {\n const { account, connector, ...rest } = parameters\n\n let client: Client\n if (typeof account === 'object' && account.type === 'local')\n client = config.getClient()\n else client = await getConnectorClient(config, { account, connector })\n\n const action = getAction(client, viem_signMessage, 'signMessage')\n return action({\n ...rest,\n ...(account ? { account } : {}),\n } as viem_SignMessageParameters<Account>)\n}\n", "import type { Account, Client, TypedData } from 'viem'\nimport {\n type SignMessageErrorType as viem_SignMessageErrorType,\n type SignTypedDataParameters as viem_SignTypedDataParameters,\n type SignTypedDataReturnType as viem_SignTypedDataReturnType,\n signTypedData as viem_signTypedData,\n} from 'viem/actions'\n\nimport type { Config } from '../createConfig.js'\nimport type { BaseErrorType, ErrorType } from '../errors/base.js'\nimport type { ConnectorParameter } from '../types/properties.js'\nimport type { UnionCompute } from '../types/utils.js'\nimport { getAction } from '../utils/getAction.js'\nimport {\n type GetConnectorClientErrorType,\n getConnectorClient,\n} from './getConnectorClient.js'\n\nexport type SignTypedDataParameters<\n typedData extends TypedData | Record<string, unknown> = TypedData,\n primaryType extends keyof typedData | 'EIP712Domain' = keyof typedData,\n ///\n primaryTypes = typedData extends TypedData ? keyof typedData : string,\n> = UnionCompute<\n viem_SignTypedDataParameters<typedData, primaryType, Account, primaryTypes> &\n ConnectorParameter\n>\n\nexport type SignTypedDataReturnType = viem_SignTypedDataReturnType\n\nexport type SignTypedDataErrorType =\n // getConnectorClient()\n | GetConnectorClientErrorType\n // base\n | BaseErrorType\n | ErrorType\n // viem\n | viem_SignMessageErrorType\n\n/** https://wagmi.sh/core/api/actions/signTypedData */\nexport async function signTypedData<\n const typedData extends TypedData | Record<string, unknown>,\n primaryType extends keyof typedData | 'EIP712Domain',\n>(\n config: Config,\n parameters: SignTypedDataParameters<typedData, primaryType>,\n): Promise<SignTypedDataReturnType> {\n const { account, connector, ...rest } = parameters\n\n let client: Client\n if (typeof account === 'object' && account.type === 'local')\n client = config.getClient()\n else client = await getConnectorClient(config, { account, connector })\n\n const action = getAction(client, viem_signTypedData, 'signTypedData')\n return action({\n ...rest,\n ...(account ? { account } : {}),\n } as unknown as viem_SignTypedDataParameters)\n}\n", "import type {\n Abi,\n Account,\n Address,\n Chain,\n ContractFunctionArgs,\n ContractFunctionName,\n} from 'viem'\nimport {\n type SimulateContractErrorType as viem_SimulateContractErrorType,\n type SimulateContractParameters as viem_SimulateContractParameters,\n type SimulateContractReturnType as viem_SimulateContractReturnType,\n simulateContract as viem_simulateContract,\n} from 'viem/actions'\n\nimport type { Config } from '../createConfig.js'\nimport type { BaseErrorType, ErrorType } from '../errors/base.js'\nimport type { SelectChains } from '../types/chain.js'\nimport type {\n ChainIdParameter,\n ConnectorParameter,\n} from '../types/properties.js'\nimport type {\n Compute,\n PartialBy,\n UnionCompute,\n UnionStrictOmit,\n} from '../types/utils.js'\nimport { getAction } from '../utils/getAction.js'\nimport {\n type GetConnectorClientErrorType,\n getConnectorClient,\n} from './getConnectorClient.js'\n\nexport type SimulateContractParameters<\n abi extends Abi | readonly unknown[] = Abi,\n functionName extends ContractFunctionName<\n abi,\n 'nonpayable' | 'payable'\n > = ContractFunctionName<abi, 'nonpayable' | 'payable'>,\n args extends ContractFunctionArgs<\n abi,\n 'nonpayable' | 'payable',\n functionName\n > = ContractFunctionArgs<abi, 'nonpayable' | 'payable', functionName>,\n config extends Config = Config,\n chainId extends\n | config['chains'][number]['id']\n | undefined = config['chains'][number]['id'],\n ///\n chains extends readonly Chain[] = SelectChains<config, chainId>,\n> = {\n [key in keyof chains]: UnionCompute<\n UnionStrictOmit<\n viem_SimulateContractParameters<\n abi,\n functionName,\n args,\n chains[key],\n chains[key],\n Account | Address\n >,\n 'chain'\n >\n > &\n ChainIdParameter<config, chainId> &\n ConnectorParameter\n}[number]\n\nexport type SimulateContractReturnType<\n abi extends Abi | readonly unknown[] = Abi,\n functionName extends ContractFunctionName<\n abi,\n 'nonpayable' | 'payable'\n > = ContractFunctionName<abi, 'nonpayable' | 'payable'>,\n args extends ContractFunctionArgs<\n abi,\n 'nonpayable' | 'payable',\n functionName\n > = ContractFunctionArgs<abi, 'nonpayable' | 'payable', functionName>,\n config extends Config = Config,\n chainId extends\n | config['chains'][number]['id']\n | undefined = config['chains'][number]['id'],\n ///\n chains extends readonly Chain[] = SelectChains<config, chainId>,\n> = {\n [key in keyof chains]: viem_SimulateContractReturnType<\n abi,\n functionName,\n args,\n chains[key],\n Account,\n chains[key]\n > & {\n chainId: chains[key]['id']\n request: Compute<\n PartialBy<\n { chainId: chainId; chain: chains[key] },\n chainId extends config['chains'][number]['id'] ? never : 'chainId'\n >\n >\n }\n}[number]\n\nexport type SimulateContractErrorType =\n // getConnectorClient()\n | GetConnectorClientErrorType\n // base\n | BaseErrorType\n | ErrorType\n // viem\n | viem_SimulateContractErrorType\n\n/** https://wagmi.sh/core/api/actions/simulateContract */\nexport async function simulateContract<\n config extends Config,\n const abi extends Abi | readonly unknown[],\n functionName extends ContractFunctionName<abi, 'nonpayable' | 'payable'>,\n args extends ContractFunctionArgs<\n abi,\n 'nonpayable' | 'payable',\n functionName\n >,\n chainId extends config['chains'][number]['id'] | undefined = undefined,\n>(\n config: config,\n parameters: SimulateContractParameters<\n abi,\n functionName,\n args,\n config,\n chainId\n >,\n): Promise<\n SimulateContractReturnType<abi, functionName, args, config, chainId>\n> {\n const { abi, chainId, connector, ...rest } =\n parameters as SimulateContractParameters\n\n let account: Address | Account\n if (parameters.account) account = parameters.account\n else {\n const connectorClient = await getConnectorClient(config, {\n chainId,\n connector,\n })\n account = connectorClient.account\n }\n\n const client = config.getClient({ chainId })\n const action = getAction(client, viem_simulateContract, 'simulateContract')\n const { result, request } = await action({ ...rest, abi, account })\n\n return {\n chainId: client.chain.id,\n result,\n request: { ...request, chainId },\n } as unknown as SimulateContractReturnType<\n abi,\n functionName,\n args,\n config,\n chainId\n >\n}\n", "import type { Address } from 'viem'\n\nimport type { Config, Connector } from '../createConfig.js'\nimport type { BaseError, ErrorType } from '../errors/base.js'\nimport {\n ConnectorNotConnectedError,\n type ConnectorNotConnectedErrorType,\n} from '../errors/config.js'\n\nexport type SwitchAccountParameters = {\n connector: Connector\n}\n\nexport type SwitchAccountReturnType<config extends Config = Config> = {\n accounts: readonly [Address, ...Address[]]\n chainId:\n | config['chains'][number]['id']\n | (number extends config['chains'][number]['id'] ? number : number & {})\n}\n\nexport type SwitchAccountErrorType =\n | ConnectorNotConnectedErrorType\n | BaseError\n | ErrorType\n\n/** https://wagmi.sh/core/api/actions/switchAccount */\nexport async function switchAccount<config extends Config>(\n config: config,\n parameters: SwitchAccountParameters,\n): Promise<SwitchAccountReturnType<config>> {\n const { connector } = parameters\n\n const connection = config.state.connections.get(connector.uid)\n if (!connection) throw new ConnectorNotConnectedError()\n\n await config.storage?.setItem('recentConnectorId', connector.id)\n config.setState((x) => ({\n ...x,\n current: connector.uid,\n }))\n return {\n accounts: connection.accounts,\n chainId: connection.chainId,\n }\n}\n", "import type { Connector } from '../createConfig.js'\nimport { BaseError } from './base.js'\n\nexport type ProviderNotFoundErrorType = ProviderNotFoundError & {\n name: 'ProviderNotFoundError'\n}\nexport class ProviderNotFoundError extends BaseError {\n override name = 'ProviderNotFoundError'\n constructor() {\n super('Provider not found.')\n }\n}\n\nexport type SwitchChainNotSupportedErrorType = SwitchChainNotSupportedError & {\n name: 'SwitchChainNotSupportedError'\n}\nexport class SwitchChainNotSupportedError extends BaseError {\n override name = 'SwitchChainNotSupportedError'\n\n constructor({ connector }: { connector: Connector }) {\n super(`\"${connector.name}\" does not support programmatic chain switching.`)\n }\n}\n", "import type {\n AddEthereumChainParameter,\n UserRejectedRequestErrorType,\n SwitchChainErrorType as viem_SwitchChainErrorType,\n} from 'viem'\n\nimport type { Config } from '../createConfig.js'\nimport type { BaseErrorType, ErrorType } from '../errors/base.js'\nimport {\n ChainNotConfiguredError,\n type ChainNotConfiguredErrorType,\n} from '../errors/config.js'\nimport {\n type ProviderNotFoundErrorType,\n SwitchChainNotSupportedError,\n type SwitchChainNotSupportedErrorType,\n} from '../errors/connector.js'\nimport type { ConnectorParameter } from '../types/properties.js'\nimport type { Compute, ExactPartial } from '../types/utils.js'\n\nexport type SwitchChainParameters<\n config extends Config = Config,\n chainId extends\n config['chains'][number]['id'] = config['chains'][number]['id'],\n> = Compute<\n ConnectorParameter & {\n chainId: chainId | config['chains'][number]['id']\n addEthereumChainParameter?:\n | Compute<ExactPartial<Omit<AddEthereumChainParameter, 'chainId'>>>\n | undefined\n }\n>\n\nexport type SwitchChainReturnType<\n config extends Config = Config,\n chainId extends\n config['chains'][number]['id'] = config['chains'][number]['id'],\n> = Extract<\n config['chains'][number],\n { id: Config extends config ? number : chainId }\n>\n\nexport type SwitchChainErrorType =\n | SwitchChainNotSupportedErrorType\n | ChainNotConfiguredErrorType\n // connector.switchChain()\n | ProviderNotFoundErrorType\n | UserRejectedRequestErrorType\n // base\n | BaseErrorType\n | ErrorType\n // viem\n | viem_SwitchChainErrorType\n\n/** https://wagmi.sh/core/api/actions/switchChain */\nexport async function switchChain<\n config extends Config,\n chainId extends config['chains'][number]['id'],\n>(\n config: config,\n parameters: SwitchChainParameters<config, chainId>,\n): Promise<SwitchChainReturnType<config, chainId>> {\n const { addEthereumChainParameter, chainId } = parameters\n\n const connection = config.state.connections.get(\n parameters.connector?.uid ?? config.state.current!,\n )\n if (connection) {\n const connector = connection.connector\n if (!connector.switchChain)\n throw new SwitchChainNotSupportedError({ connector })\n const chain = await connector.switchChain({\n addEthereumChainParameter,\n chainId,\n })\n return chain as SwitchChainReturnType<config, chainId>\n }\n\n const chain = config.chains.find((x) => x.id === chainId)\n if (!chain) throw new ChainNotConfiguredError()\n config.setState((x) => ({ ...x, chainId }))\n return chain as SwitchChainReturnType<config, chainId>\n}\n", "import {\n type VerifyMessageErrorType as viem_VerifyMessageErrorType,\n type VerifyMessageParameters as viem_VerifyMessageParameters,\n type VerifyMessageReturnType as viem_VerifyMessageReturnType,\n verifyMessage as viem_verifyMessage,\n} from 'viem/actions'\n\nimport type { Config } from '../createConfig.js'\nimport type { ChainIdParameter } from '../types/properties.js'\nimport type { Compute } from '../types/utils.js'\nimport { getAction } from '../utils/getAction.js'\n\nexport type VerifyMessageParameters<config extends Config = Config> = Compute<\n viem_VerifyMessageParameters & ChainIdParameter<config>\n>\n\nexport type VerifyMessageReturnType = viem_VerifyMessageReturnType\n\nexport type VerifyMessageErrorType = viem_VerifyMessageErrorType\n\n/** https://wagmi.sh/core/api/actions/verifyMessage */\nexport async function verifyMessage<config extends Config>(\n config: config,\n parameters: VerifyMessageParameters<config>,\n): Promise<VerifyMessageReturnType> {\n const { chainId, ...rest } = parameters\n const client = config.getClient({ chainId })\n const action = getAction(client, viem_verifyMessage, 'verifyMessage')\n return action(rest)\n}\n", "import type { TypedData } from 'viem'\nimport {\n type VerifyTypedDataErrorType as viem_VerifyTypedDataErrorType,\n type VerifyTypedDataParameters as viem_VerifyTypedDataParameters,\n type VerifyTypedDataReturnType as viem_VerifyTypedDataReturnType,\n verifyTypedData as viem_verifyTypedData,\n} from 'viem/actions'\n\nimport type { Config } from '../createConfig.js'\nimport type { ChainIdParameter } from '../types/properties.js'\nimport type { Compute } from '../types/utils.js'\nimport { getAction } from '../utils/getAction.js'\n\nexport type VerifyTypedDataParameters<\n typedData extends TypedData | Record<string, unknown> = TypedData,\n primaryType extends keyof typedData | 'EIP712Domain' = keyof typedData,\n config extends Config = Config,\n> = Compute<\n viem_VerifyTypedDataParameters<typedData, primaryType> &\n ChainIdParameter<config>\n>\n\nexport type VerifyTypedDataReturnType = viem_VerifyTypedDataReturnType\n\nexport type VerifyTypedDataErrorType = viem_VerifyTypedDataErrorType\n\n/** https://wagmi.sh/core/api/actions/verifyTypedData */\nexport async function verifyTypedData<\n config extends Config,\n const typedData extends TypedData | Record<string, unknown>,\n primaryType extends keyof typedData | 'EIP712Domain',\n>(\n config: config,\n parameters: VerifyTypedDataParameters<typedData, primaryType, config>,\n): Promise<VerifyTypedDataReturnType> {\n const { chainId, ...rest } = parameters\n const client = config.getClient({ chainId })\n const action = getAction(client, viem_verifyTypedData, 'verifyTypedData')\n return action(rest as viem_VerifyTypedDataParameters)\n}\n", "import type { Config } from '../createConfig.js'\nimport { deepEqual } from '../utils/deepEqual.js'\nimport { type GetAccountReturnType, getAccount } from './getAccount.js'\n\nexport type WatchAccountParameters<config extends Config = Config> = {\n onChange(\n account: GetAccountReturnType<config>,\n prevAccount: GetAccountReturnType<config>,\n ): void\n}\n\nexport type WatchAccountReturnType = () => void\n\n/** https://wagmi.sh/core/api/actions/watchAccount */\nexport function watchAccount<config extends Config>(\n config: config,\n parameters: WatchAccountParameters<config>,\n): WatchAccountReturnType {\n const { onChange } = parameters\n\n return config.subscribe(() => getAccount(config), onChange, {\n equalityFn(a, b) {\n const { connector: aConnector, ...aRest } = a\n const { connector: bConnector, ...bRest } = b\n return (\n deepEqual(aRest, bRest) &&\n // check connector separately\n aConnector?.id === bConnector?.id &&\n aConnector?.uid === bConnector?.uid\n )\n },\n })\n}\n", "import {\n type WatchAssetErrorType as viem_WatchAssetErrorType,\n type WatchAssetParameters as viem_WatchAssetParameters,\n type WatchAssetReturnType as viem_WatchAssetReturnType,\n watchAsset as viem_watchAsset,\n} from 'viem/actions'\n\nimport type { Config } from '../createConfig.js'\nimport type { BaseErrorType, ErrorType } from '../errors/base.js'\nimport type { ConnectorParameter } from '../types/properties.js'\nimport type { Compute } from '../types/utils.js'\nimport { getAction } from '../utils/getAction.js'\nimport {\n type GetConnectorClientErrorType,\n getConnectorClient,\n} from './getConnectorClient.js'\n\nexport type WatchAssetParameters = Compute<\n viem_WatchAssetParameters & ConnectorParameter\n>\n\nexport type WatchAssetReturnType = viem_WatchAssetReturnType\n\nexport type WatchAssetErrorType =\n // getConnectorClient()\n | GetConnectorClientErrorType\n // base\n | BaseErrorType\n | ErrorType\n // viem\n | viem_WatchAssetErrorType\n\n/** https://wagmi.sh/core/api/actions/watchAsset */\nexport async function watchAsset(\n config: Config,\n parameters: WatchAssetParameters,\n): Promise<WatchAssetReturnType> {\n const { connector, ...rest } = parameters\n\n const client = await getConnectorClient(config, { connector })\n\n const action = getAction(client, viem_watchAsset, 'watchAsset')\n return action(rest as viem_WatchAssetParameters)\n}\n", "import {\n type WatchBlocksParameters as viem_WatchBlocksParameters,\n type WatchBlocksReturnType as viem_WatchBlocksReturnType,\n watchBlocks as viem_watchBlocks,\n} from 'viem/actions'\n\nimport type { BlockTag, Chain, Transport, WebSocketTransport } from 'viem'\nimport type { Config } from '../createConfig.js'\nimport type { SelectChains } from '../types/chain.js'\nimport type {\n ChainIdParameter,\n SyncConnectedChainParameter,\n} from '../types/properties.js'\nimport type { IsNarrowable, UnionCompute } from '../types/utils.js'\nimport { getAction } from '../utils/getAction.js'\n\nexport type WatchBlocksParameters<\n includeTransactions extends boolean = false,\n blockTag extends BlockTag = 'latest',\n config extends Config = Config,\n chainId extends\n config['chains'][number]['id'] = config['chains'][number]['id'],\n ///\n chains extends readonly Chain[] = SelectChains<config, chainId>,\n> = {\n [key in keyof chains]: UnionCompute<\n viem_WatchBlocksParameters<\n config['_internal']['transports'][chains[key]['id']] extends infer transport extends\n Transport\n ? Transport extends transport\n ? WebSocketTransport\n : transport\n : WebSocketTransport,\n IsNarrowable<chains[key], Chain> extends true ? chains[key] : undefined,\n includeTransactions,\n blockTag\n > &\n ChainIdParameter<config, chainId> &\n SyncConnectedChainParameter\n >\n}[number]\n\nexport type WatchBlocksReturnType = viem_WatchBlocksReturnType\n\n// TODO: wrap in viem's `observe` to avoid duplicate invocations.\n/** https://wagmi.sh/core/actions/watchBlocks */\nexport function watchBlocks<\n config extends Config,\n chainId extends\n config['chains'][number]['id'] = config['chains'][number]['id'],\n includeTransactions extends boolean = false,\n blockTag extends BlockTag = 'latest',\n>(\n config: config,\n parameters: WatchBlocksParameters<\n includeTransactions,\n blockTag,\n config,\n chainId\n >,\n): WatchBlocksReturnType {\n const { syncConnectedChain = config._internal.syncConnectedChain, ...rest } =\n parameters as WatchBlocksParameters\n\n let unwatch: WatchBlocksReturnType | undefined\n const listener = (chainId: number | undefined) => {\n if (unwatch) unwatch()\n\n const client = config.getClient({ chainId })\n const action = getAction(client, viem_watchBlocks, 'watchBlocks')\n unwatch = action(rest as viem_WatchBlocksParameters)\n return unwatch\n }\n\n // set up listener for block number changes\n const unlisten = listener(parameters.chainId)\n\n // set up subscriber for connected chain changes\n let unsubscribe: (() => void) | undefined\n if (syncConnectedChain && !parameters.chainId)\n unsubscribe = config.subscribe(\n ({ chainId }) => chainId,\n async (chainId) => listener(chainId),\n )\n\n return () => {\n unlisten?.()\n unsubscribe?.()\n }\n}\n", "import {\n type WatchBlockNumberParameters as viem_WatchBlockNumberParameters,\n type WatchBlockNumberReturnType as viem_WatchBlockNumberReturnType,\n watchBlockNumber as viem_watchBlockNumber,\n} from 'viem/actions'\n\nimport type { Chain, Transport, WebSocketTransport } from 'viem'\nimport type { Config } from '../createConfig.js'\nimport type { SelectChains } from '../types/chain.js'\nimport type {\n ChainIdParameter,\n SyncConnectedChainParameter,\n} from '../types/properties.js'\nimport type { UnionCompute } from '../types/utils.js'\nimport { getAction } from '../utils/getAction.js'\n\nexport type WatchBlockNumberParameters<\n config extends Config = Config,\n chainId extends\n config['chains'][number]['id'] = config['chains'][number]['id'],\n ///\n chains extends readonly Chain[] = SelectChains<config, chainId>,\n> = {\n [key in keyof chains]: UnionCompute<\n viem_WatchBlockNumberParameters<\n config['_internal']['transports'][chains[key]['id']] extends infer transport extends\n Transport\n ? Transport extends transport\n ? WebSocketTransport\n : transport\n : WebSocketTransport\n > &\n ChainIdParameter<config, chainId> &\n SyncConnectedChainParameter\n >\n}[number]\n\nexport type WatchBlockNumberReturnType = viem_WatchBlockNumberReturnType\n\n// TODO: wrap in viem's `observe` to avoid duplicate invocations.\n/** https://wagmi.sh/core/api/actions/watchBlockNumber */\nexport function watchBlockNumber<\n config extends Config,\n chainId extends\n config['chains'][number]['id'] = config['chains'][number]['id'],\n>(\n config: config,\n parameters: WatchBlockNumberParameters<config, chainId>,\n): WatchBlockNumberReturnType {\n const { syncConnectedChain = config._internal.syncConnectedChain, ...rest } =\n parameters as WatchBlockNumberParameters\n\n let unwatch: WatchBlockNumberReturnType | undefined\n const listener = (chainId: number | undefined) => {\n if (unwatch) unwatch()\n\n const client = config.getClient({ chainId })\n const action = getAction(client, viem_watchBlockNumber, 'watchBlockNumber')\n unwatch = action(rest as viem_WatchBlockNumberParameters)\n return unwatch\n }\n\n // set up listener for block number changes\n const unlisten = listener(parameters.chainId)\n\n // set up subscriber for connected chain changes\n let unsubscribe: (() => void) | undefined\n if (syncConnectedChain && !parameters.chainId)\n unsubscribe = config.subscribe(\n ({ chainId }) => chainId,\n async (chainId) => listener(chainId),\n )\n\n return () => {\n unlisten?.()\n unsubscribe?.()\n }\n}\n", "import type { Config } from '../createConfig.js'\nimport type { GetChainIdReturnType } from './getChainId.js'\n\nexport type WatchChainIdParameters<config extends Config = Config> = {\n onChange(\n chainId: GetChainIdReturnType<config>,\n prevChainId: GetChainIdReturnType<config>,\n ): void\n}\n\nexport type WatchChainIdReturnType = () => void\n\n/** https://wagmi.sh/core/api/actions/watchChainId */\nexport function watchChainId<config extends Config>(\n config: config,\n parameters: WatchChainIdParameters<config>,\n): WatchChainIdReturnType {\n const { onChange } = parameters\n return config.subscribe((state) => state.chainId, onChange)\n}\n", "import type { Config } from '../createConfig.js'\nimport { type GetClientReturnType, getClient } from './getClient.js'\n\nexport type WatchClientParameters<\n config extends Config = Config,\n chainId extends\n config['chains'][number]['id'] = config['chains'][number]['id'],\n> = {\n onChange(\n publicClient: GetClientReturnType<config, chainId>,\n prevClient: GetClientReturnType<config, chainId>,\n ): void\n}\n\nexport type WatchClientReturnType = () => void\n\n/** https://wagmi.sh/core/api/actions/watchClient */\nexport function watchClient<\n config extends Config,\n chainId extends config['chains'][number]['id'],\n>(\n config: config,\n parameters: WatchClientParameters<config, chainId>,\n): WatchClientReturnType {\n const { onChange } = parameters\n return config.subscribe(\n () => getClient(config) as GetClientReturnType<config, chainId>,\n onChange,\n {\n equalityFn(a, b) {\n return a?.uid === b?.uid\n },\n },\n )\n}\n", "import type { Config } from '../createConfig.js'\nimport { deepEqual } from '../utils/deepEqual.js'\nimport {\n type GetConnectionsReturnType,\n getConnections,\n} from './getConnections.js'\n\nexport type WatchConnectionsParameters = {\n onChange(\n connections: GetConnectionsReturnType,\n prevConnections: GetConnectionsReturnType,\n ): void\n}\n\nexport type WatchConnectionsReturnType = () => void\n\n/** https://wagmi.sh/core/api/actions/watchConnections */\nexport function watchConnections(\n config: Config,\n parameters: WatchConnectionsParameters,\n): WatchConnectionsReturnType {\n const { onChange } = parameters\n return config.subscribe(() => getConnections(config), onChange, {\n equalityFn: deepEqual,\n })\n}\n", "import type { Config } from '../createConfig.js'\nimport type { GetConnectorsReturnType } from './getConnectors.js'\n\nexport type WatchConnectorsParameters<config extends Config = Config> = {\n onChange(\n connections: GetConnectorsReturnType<config>,\n prevConnectors: GetConnectorsReturnType<config>,\n ): void\n}\n\nexport type WatchConnectorsReturnType = () => void\n\n/** https://wagmi.sh/core/api/actions/watchConnectors */\nexport function watchConnectors<config extends Config>(\n config: config,\n parameters: WatchConnectorsParameters<config>,\n): WatchConnectorsReturnType {\n const { onChange } = parameters\n return config._internal.connectors.subscribe((connectors, prevConnectors) => {\n onChange(Object.values(connectors), prevConnectors)\n })\n}\n", "import type {\n Abi,\n Chain,\n ContractEventName,\n Transport,\n WebSocketTransport,\n} from 'viem'\nimport {\n type WatchContractEventParameters as viem_WatchContractEventParameters,\n type WatchContractEventReturnType as viem_WatchContractEventReturnType,\n watchContractEvent as viem_watchContractEvent,\n} from 'viem/actions'\n\nimport type { Config } from '../createConfig.js'\nimport type { SelectChains } from '../types/chain.js'\nimport type {\n ChainIdParameter,\n SyncConnectedChainParameter,\n} from '../types/properties.js'\nimport type { UnionCompute } from '../types/utils.js'\nimport { getAction } from '../utils/getAction.js'\n\nexport type WatchContractEventParameters<\n abi extends Abi | readonly unknown[] = Abi,\n eventName extends ContractEventName<abi> | undefined = ContractEventName<abi>,\n strict extends boolean | undefined = undefined,\n config extends Config = Config,\n chainId extends\n config['chains'][number]['id'] = config['chains'][number]['id'],\n ///\n chains extends readonly Chain[] = SelectChains<config, chainId>,\n> = {\n [key in keyof chains]: UnionCompute<\n viem_WatchContractEventParameters<\n abi,\n eventName,\n strict,\n config['_internal']['transports'][chains[key]['id']] extends infer transport extends\n Transport\n ? Transport extends transport\n ? WebSocketTransport\n : transport\n : WebSocketTransport\n > &\n ChainIdParameter<config, chainId> &\n SyncConnectedChainParameter\n >\n}[number]\n\nexport type WatchContractEventReturnType = viem_WatchContractEventReturnType\n\n// TODO: wrap in viem's `observe` to avoid duplicate invocations.\n/** https://wagmi.sh/core/api/actions/watchContractEvent */\nexport function watchContractEvent<\n config extends Config,\n chainId extends config['chains'][number]['id'],\n const abi extends Abi | readonly unknown[],\n eventName extends ContractEventName<abi> | undefined,\n strict extends boolean | undefined = undefined,\n>(\n config: config,\n parameters: WatchContractEventParameters<\n abi,\n eventName,\n strict,\n config,\n chainId\n >,\n) {\n const { syncConnectedChain = config._internal.syncConnectedChain, ...rest } =\n parameters\n\n let unwatch: WatchContractEventReturnType | undefined\n const listener = (chainId: number | undefined) => {\n if (unwatch) unwatch()\n\n const client = config.getClient({ chainId })\n const action = getAction(\n client,\n viem_watchContractEvent,\n 'watchContractEvent',\n )\n unwatch = action(rest as unknown as viem_WatchContractEventParameters)\n return unwatch\n }\n\n // set up listener for transaction changes\n const unlisten = listener(parameters.chainId)\n\n // set up subscriber for connected chain changes\n let unsubscribe: (() => void) | undefined\n if (syncConnectedChain && !parameters.chainId)\n unsubscribe = config.subscribe(\n ({ chainId }) => chainId,\n async (chainId) => listener(chainId),\n )\n\n return () => {\n unlisten?.()\n unsubscribe?.()\n }\n}\n", "import type { Chain, Transport, WebSocketTransport } from 'viem'\nimport {\n type WatchPendingTransactionsParameters as viem_WatchPendingTransactionsParameters,\n type WatchPendingTransactionsReturnType as viem_WatchPendingTransactionsReturnType,\n watchPendingTransactions as viem_watchPendingTransactions,\n} from 'viem/actions'\n\nimport type { Config } from '../createConfig.js'\nimport type { SelectChains } from '../types/chain.js'\nimport type {\n ChainIdParameter,\n SyncConnectedChainParameter,\n} from '../types/properties.js'\nimport type { UnionCompute } from '../types/utils.js'\nimport { getAction } from '../utils/getAction.js'\n\nexport type WatchPendingTransactionsParameters<\n config extends Config = Config,\n chainId extends\n config['chains'][number]['id'] = config['chains'][number]['id'],\n ///\n chains extends readonly Chain[] = SelectChains<config, chainId>,\n> = {\n [key in keyof chains]: UnionCompute<\n viem_WatchPendingTransactionsParameters<\n config['_internal']['transports'][chains[key]['id']] extends infer transport extends\n Transport\n ? Transport extends transport\n ? WebSocketTransport\n : transport\n : WebSocketTransport\n > &\n ChainIdParameter<config, chainId> &\n SyncConnectedChainParameter\n >\n}[number]\n\nexport type WatchPendingTransactionsReturnType =\n viem_WatchPendingTransactionsReturnType\n\n// TODO: wrap in viem's `observe` to avoid duplicate invocations.\n/** https://wagmi.sh/core/api/actions/watchPendingTransactions */\nexport function watchPendingTransactions<\n config extends Config,\n chainId extends config['chains'][number]['id'],\n>(\n config: config,\n parameters: WatchPendingTransactionsParameters<config, chainId>,\n) {\n const { syncConnectedChain = config._internal.syncConnectedChain, ...rest } =\n parameters\n\n let unwatch: WatchPendingTransactionsReturnType | undefined\n const listener = (chainId: number | undefined) => {\n if (unwatch) unwatch()\n\n const client = config.getClient({ chainId })\n const action = getAction(\n client,\n viem_watchPendingTransactions,\n 'watchPendingTransactions',\n )\n unwatch = action(rest as viem_WatchPendingTransactionsParameters)\n return unwatch\n }\n\n // set up listener for transaction changes\n const unlisten = listener(parameters.chainId)\n\n // set up subscriber for connected chain changes\n let unsubscribe: (() => void) | undefined\n if (syncConnectedChain && !parameters.chainId)\n unsubscribe = config.subscribe(\n ({ chainId }) => chainId,\n async (chainId) => listener(chainId),\n )\n\n return () => {\n unlisten?.()\n unsubscribe?.()\n }\n}\n", "import type { Config } from '../createConfig.js'\nimport {\n type GetPublicClientReturnType,\n getPublicClient,\n} from './getPublicClient.js'\n\nexport type WatchPublicClientParameters<\n config extends Config = Config,\n chainId extends\n config['chains'][number]['id'] = config['chains'][number]['id'],\n> = {\n onChange(\n publicClient: GetPublicClientReturnType<config, chainId>,\n prevPublicClient: GetPublicClientReturnType<config, chainId>,\n ): void\n}\n\nexport type WatchPublicClientReturnType = () => void\n\n/** https://wagmi.sh/core/api/actions/watchPublicClient */\nexport function watchPublicClient<\n config extends Config,\n chainId extends config['chains'][number]['id'],\n>(\n config: config,\n parameters: WatchPublicClientParameters<config, chainId>,\n): WatchPublicClientReturnType {\n const { onChange } = parameters\n return config.subscribe(\n () => getPublicClient(config) as GetPublicClientReturnType<config, chainId>,\n onChange,\n {\n equalityFn(a, b) {\n return a?.uid === b?.uid\n },\n },\n )\n}\n", "import type { Chain } from 'viem'\nimport { hexToString } from 'viem'\nimport {\n call,\n getTransaction,\n type WaitForTransactionReceiptErrorType as viem_WaitForTransactionReceiptErrorType,\n type WaitForTransactionReceiptParameters as viem_WaitForTransactionReceiptParameters,\n type WaitForTransactionReceiptReturnType as viem_WaitForTransactionReceiptReturnType,\n waitForTransactionReceipt as viem_waitForTransactionReceipt,\n} from 'viem/actions'\n\nimport type { Config } from '../createConfig.js'\nimport type { SelectChains } from '../types/chain.js'\nimport type { ChainIdParameter } from '../types/properties.js'\nimport type { Compute, IsNarrowable } from '../types/utils.js'\nimport { getAction } from '../utils/getAction.js'\n\nexport type WaitForTransactionReceiptParameters<\n config extends Config = Config,\n chainId extends\n config['chains'][number]['id'] = config['chains'][number]['id'],\n> = Compute<\n viem_WaitForTransactionReceiptParameters & ChainIdParameter<config, chainId>\n>\n\nexport type WaitForTransactionReceiptReturnType<\n config extends Config = Config,\n chainId extends\n config['chains'][number]['id'] = config['chains'][number]['id'],\n ///\n chains extends readonly Chain[] = SelectChains<config, chainId>,\n> = Compute<\n {\n [key in keyof chains]: viem_WaitForTransactionReceiptReturnType<\n IsNarrowable<chains[key], Chain> extends true ? chains[key] : undefined\n > & { chainId: chains[key]['id'] }\n }[number]\n>\n\nexport type WaitForTransactionReceiptErrorType =\n viem_WaitForTransactionReceiptErrorType\n\nexport async function waitForTransactionReceipt<\n config extends Config,\n chainId extends config['chains'][number]['id'],\n>(\n config: config,\n parameters: WaitForTransactionReceiptParameters<config, chainId>,\n): Promise<WaitForTransactionReceiptReturnType<config, chainId>> {\n const { chainId, timeout = 0, ...rest } = parameters\n\n const client = config.getClient({ chainId })\n const action = getAction(\n client,\n viem_waitForTransactionReceipt,\n 'waitForTransactionReceipt',\n )\n const receipt = await action({ ...rest, timeout })\n\n if (receipt.status === 'reverted') {\n const action_getTransaction = getAction(\n client,\n getTransaction,\n 'getTransaction',\n )\n const txn = await action_getTransaction({ hash: receipt.transactionHash })\n const action_call = getAction(client, call, 'call')\n const code = await action_call({\n ...(txn as any),\n data: txn.input,\n gasPrice: txn.type !== 'eip1559' ? txn.gasPrice : undefined,\n maxFeePerGas: txn.type === 'eip1559' ? txn.maxFeePerGas : undefined,\n maxPriorityFeePerGas:\n txn.type === 'eip1559' ? txn.maxPriorityFeePerGas : undefined,\n })\n const reason = code?.data\n ? hexToString(`0x${code.data.substring(138)}`)\n : 'unknown reason'\n throw new Error(reason)\n }\n\n return {\n ...receipt,\n chainId: client.chain.id,\n } as WaitForTransactionReceiptReturnType<config, chainId>\n}\n", "import type {\n Abi,\n Account,\n Chain,\n Client,\n ContractFunctionArgs,\n ContractFunctionName,\n} from 'viem'\nimport {\n type WriteContractErrorType as viem_WriteContractErrorType,\n type WriteContractParameters as viem_WriteContractParameters,\n type WriteContractReturnType as viem_WriteContractReturnType,\n writeContract as viem_writeContract,\n} from 'viem/actions'\n\nimport type { Config } from '../createConfig.js'\nimport type { BaseErrorType, ErrorType } from '../errors/base.js'\nimport type { SelectChains } from '../types/chain.js'\nimport type {\n ChainIdParameter,\n ConnectorParameter,\n} from '../types/properties.js'\nimport type { Compute, UnionCompute } from '../types/utils.js'\nimport { getAction } from '../utils/getAction.js'\nimport {\n type GetConnectorClientErrorType,\n getConnectorClient,\n} from './getConnectorClient.js'\n\nexport type WriteContractParameters<\n abi extends Abi | readonly unknown[] = Abi,\n functionName extends ContractFunctionName<\n abi,\n 'nonpayable' | 'payable'\n > = ContractFunctionName<abi, 'nonpayable' | 'payable'>,\n args extends ContractFunctionArgs<\n abi,\n 'nonpayable' | 'payable',\n functionName\n > = ContractFunctionArgs<abi, 'nonpayable' | 'payable', functionName>,\n config extends Config = Config,\n chainId extends\n config['chains'][number]['id'] = config['chains'][number]['id'],\n ///\n allFunctionNames = ContractFunctionName<abi, 'nonpayable' | 'payable'>,\n chains extends readonly Chain[] = SelectChains<config, chainId>,\n> = UnionCompute<\n {\n // TODO: Should use `UnionStrictOmit<..., 'chain'>` on `viem_WriteContractParameters` result instead\n // temp workaround that doesn't affect runtime behavior for for https://github.com/wevm/wagmi/issues/3981\n [key in keyof chains]: viem_WriteContractParameters<\n abi,\n functionName,\n args,\n chains[key],\n Account,\n chains[key],\n allFunctionNames\n >\n }[number] &\n Compute<ChainIdParameter<config, chainId>> &\n ConnectorParameter & {\n /** @deprecated */\n __mode?: 'prepared'\n }\n>\n\nexport type WriteContractReturnType = viem_WriteContractReturnType\n\nexport type WriteContractErrorType =\n // getConnectorClient()\n | GetConnectorClientErrorType\n // base\n | BaseErrorType\n | ErrorType\n // viem\n | viem_WriteContractErrorType\n\n/** https://wagmi.sh/core/api/actions/writeContract */\nexport async function writeContract<\n config extends Config,\n const abi extends Abi | readonly unknown[],\n functionName extends ContractFunctionName<abi, 'nonpayable' | 'payable'>,\n args extends ContractFunctionArgs<\n abi,\n 'nonpayable' | 'payable',\n functionName\n >,\n chainId extends config['chains'][number]['id'],\n>(\n config: config,\n parameters: WriteContractParameters<abi, functionName, args, config, chainId>,\n): Promise<WriteContractReturnType> {\n const { account, chainId, connector, ...request } = parameters\n\n let client: Client\n if (typeof account === 'object' && account?.type === 'local')\n client = config.getClient({ chainId })\n else\n client = await getConnectorClient(config, {\n account: account ?? undefined,\n chainId,\n connector,\n })\n\n const action = getAction(client, viem_writeContract, 'writeContract')\n const hash = await action({\n ...(request as any),\n ...(account ? { account } : {}),\n chain: chainId ? { id: chainId } : null,\n })\n\n return hash\n}\n", "import type {\n AddEthereumChainParameter,\n Address,\n Chain,\n Client,\n ProviderConnectInfo,\n ProviderMessage,\n} from 'viem'\n\nimport type { Transport } from '../createConfig.js'\nimport type { Emitter } from '../createEmitter.js'\nimport type { Storage } from '../createStorage.js'\nimport type { Compute, ExactPartial, StrictOmit } from '../types/utils.js'\n\nexport type ConnectorEventMap = {\n change: {\n accounts?: readonly Address[] | undefined\n chainId?: number | undefined\n }\n connect: { accounts: readonly Address[]; chainId: number }\n disconnect: never\n error: { error: Error }\n message: { type: string; data?: unknown | undefined }\n}\n\nexport type CreateConnectorFn<\n provider = unknown,\n properties extends Record<string, unknown> = Record<string, unknown>,\n storageItem extends Record<string, unknown> = Record<string, unknown>,\n> = (config: {\n chains: readonly [Chain, ...Chain[]]\n emitter: Emitter<ConnectorEventMap>\n storage?: Compute<Storage<storageItem>> | null | undefined\n transports?: Record<number, Transport> | undefined\n}) => Compute<\n {\n readonly icon?: string | undefined\n readonly id: string\n readonly name: string\n readonly rdns?: string | readonly string[] | undefined\n /** @deprecated */\n readonly supportsSimulation?: boolean | undefined\n readonly type: string\n\n setup?(): Promise<void>\n connect(\n parameters?:\n | { chainId?: number | undefined; isReconnecting?: boolean | undefined }\n | undefined,\n ): Promise<{\n accounts: readonly Address[]\n chainId: number\n }>\n disconnect(): Promise<void>\n getAccounts(): Promise<readonly Address[]>\n getChainId(): Promise<number>\n getProvider(\n parameters?: { chainId?: number | undefined } | undefined,\n ): Promise<provider>\n getClient?(\n parameters?: { chainId?: number | undefined } | undefined,\n ): Promise<Client>\n isAuthorized(): Promise<boolean>\n switchChain?(\n parameters: Compute<{\n addEthereumChainParameter?:\n | ExactPartial<StrictOmit<AddEthereumChainParameter, 'chainId'>>\n | undefined\n chainId: number\n }>,\n ): Promise<Chain>\n\n onAccountsChanged(accounts: string[]): void\n onChainChanged(chainId: string): void\n onConnect?(connectInfo: ProviderConnectInfo): void\n onDisconnect(error?: Error | undefined): void\n onMessage?(message: ProviderMessage): void\n } & properties\n>\n\nexport function createConnector<\n provider,\n properties extends Record<string, unknown> = Record<string, unknown>,\n storageItem extends Record<string, unknown> = Record<string, unknown>,\n ///\n createConnectorFn extends CreateConnectorFn<\n provider,\n properties,\n storageItem\n > = CreateConnectorFn<provider, properties, storageItem>,\n>(createConnectorFn: createConnectorFn) {\n return createConnectorFn\n}\n", "import {\n type AddEthereumChainParameter,\n type Address,\n type EIP1193Provider,\n type ProviderConnectInfo,\n type ProviderRpcError,\n ResourceUnavailableRpcError,\n type RpcError,\n SwitchChainError,\n UserRejectedRequestError,\n getAddress,\n numberToHex,\n withRetry,\n withTimeout,\n} from 'viem'\n\nimport type { Connector } from '../createConfig.js'\nimport { ChainNotConfiguredError } from '../errors/config.js'\nimport { ProviderNotFoundError } from '../errors/connector.js'\nimport type { Compute } from '../types/utils.js'\nimport { createConnector } from './createConnector.js'\n\nexport type InjectedParameters = {\n /**\n * Some injected providers do not support programmatic disconnect.\n * This flag simulates the disconnect behavior by keeping track of connection status in storage.\n * @default true\n */\n shimDisconnect?: boolean | undefined\n /**\n * [EIP-1193](https://eips.ethereum.org/EIPS/eip-1193) Ethereum Provider to target\n */\n target?: TargetId | Target | (() => Target | undefined) | undefined\n unstable_shimAsyncInject?: boolean | number | undefined\n}\n\ninjected.type = 'injected' as const\nexport function injected(parameters: InjectedParameters = {}) {\n const { shimDisconnect = true, unstable_shimAsyncInject } = parameters\n\n function getTarget(): Compute<Target & { id: string }> {\n const target = parameters.target\n if (typeof target === 'function') {\n const result = target()\n if (result) return result\n }\n\n if (typeof target === 'object') return target\n\n if (typeof target === 'string')\n return {\n ...(targetMap[target as keyof typeof targetMap] ?? {\n id: target,\n name: `${target[0]!.toUpperCase()}${target.slice(1)}`,\n provider: `is${target[0]!.toUpperCase()}${target.slice(1)}`,\n }),\n }\n\n return {\n id: 'injected',\n name: 'Injected',\n provider(window) {\n return window?.ethereum\n },\n }\n }\n\n type Provider = WalletProvider | undefined\n type Properties = {\n onConnect(connectInfo: ProviderConnectInfo): void\n }\n type StorageItem = {\n [_ in 'injected.connected' | `${string}.disconnected`]: true\n }\n\n let accountsChanged: Connector['onAccountsChanged'] | undefined\n let chainChanged: Connector['onChainChanged'] | undefined\n let connect: Connector['onConnect'] | undefined\n let disconnect: Connector['onDisconnect'] | undefined\n\n return createConnector<Provider, Properties, StorageItem>((config) => ({\n get icon() {\n return getTarget().icon\n },\n get id() {\n return getTarget().id\n },\n get name() {\n return getTarget().name\n },\n /** @deprecated */\n get supportsSimulation() {\n return true\n },\n type: injected.type,\n async setup() {\n const provider = await this.getProvider()\n // Only start listening for events if `target` is set, otherwise `injected()` will also receive events\n if (provider?.on && parameters.target) {\n if (!connect) {\n connect = this.onConnect.bind(this)\n provider.on('connect', connect)\n }\n\n // We shouldn't need to listen for `'accountsChanged'` here since the `'connect'` event should suffice (and wallet shouldn't be connected yet).\n // Some wallets, like MetaMask, do not implement the `'connect'` event and overload `'accountsChanged'` instead.\n if (!accountsChanged) {\n accountsChanged = this.onAccountsChanged.bind(this)\n provider.on('accountsChanged', accountsChanged)\n }\n }\n },\n async connect({ chainId, isReconnecting } = {}) {\n const provider = await this.getProvider()\n if (!provider) throw new ProviderNotFoundError()\n\n let accounts: readonly Address[] = []\n if (isReconnecting) accounts = await this.getAccounts().catch(() => [])\n else if (shimDisconnect) {\n // Attempt to show another prompt for selecting account if `shimDisconnect` flag is enabled\n try {\n const permissions = await provider.request({\n method: 'wallet_requestPermissions',\n params: [{ eth_accounts: {} }],\n })\n accounts = (permissions[0]?.caveats?.[0]?.value as string[])?.map(\n (x) => getAddress(x),\n )\n // `'wallet_requestPermissions'` can return a different order of accounts than `'eth_accounts'`\n // switch to `'eth_accounts'` ordering if more than one account is connected\n // https://github.com/wevm/wagmi/issues/4140\n if (accounts.length > 0) {\n const sortedAccounts = await this.getAccounts()\n accounts = sortedAccounts\n }\n } catch (err) {\n const error = err as RpcError\n // Not all injected providers support `wallet_requestPermissions` (e.g. MetaMask iOS).\n // Only bubble up error if user rejects request\n if (error.code === UserRejectedRequestError.code)\n throw new UserRejectedRequestError(error)\n // Or prompt is already open\n if (error.code === ResourceUnavailableRpcError.code) throw error\n }\n }\n\n try {\n if (!accounts?.length && !isReconnecting) {\n const requestedAccounts = await provider.request({\n method: 'eth_requestAccounts',\n })\n accounts = requestedAccounts.map((x) => getAddress(x))\n }\n\n // Manage EIP-1193 event listeners\n // https://eips.ethereum.org/EIPS/eip-1193#events\n if (connect) {\n provider.removeListener('connect', connect)\n connect = undefined\n }\n if (!accountsChanged) {\n accountsChanged = this.onAccountsChanged.bind(this)\n provider.on('accountsChanged', accountsChanged)\n }\n if (!chainChanged) {\n chainChanged = this.onChainChanged.bind(this)\n provider.on('chainChanged', chainChanged)\n }\n if (!disconnect) {\n disconnect = this.onDisconnect.bind(this)\n provider.on('disconnect', disconnect)\n }\n\n // Switch to chain if provided\n let currentChainId = await this.getChainId()\n if (chainId && currentChainId !== chainId) {\n const chain = await this.switchChain!({ chainId }).catch((error) => {\n if (error.code === UserRejectedRequestError.code) throw error\n return { id: currentChainId }\n })\n currentChainId = chain?.id ?? currentChainId\n }\n\n // Remove disconnected shim if it exists\n if (shimDisconnect)\n await config.storage?.removeItem(`${this.id}.disconnected`)\n\n // Add connected shim if no target exists\n if (!parameters.target)\n await config.storage?.setItem('injected.connected', true)\n\n return { accounts, chainId: currentChainId }\n } catch (err) {\n const error = err as RpcError\n if (error.code === UserRejectedRequestError.code)\n throw new UserRejectedRequestError(error)\n if (error.code === ResourceUnavailableRpcError.code)\n throw new ResourceUnavailableRpcError(error)\n throw error\n }\n },\n async disconnect() {\n const provider = await this.getProvider()\n if (!provider) throw new ProviderNotFoundError()\n\n // Manage EIP-1193 event listeners\n if (chainChanged) {\n provider.removeListener('chainChanged', chainChanged)\n chainChanged = undefined\n }\n if (disconnect) {\n provider.removeListener('disconnect', disconnect)\n disconnect = undefined\n }\n if (!connect) {\n connect = this.onConnect.bind(this)\n provider.on('connect', connect)\n }\n\n // Experimental support for MetaMask disconnect\n // https://github.com/MetaMask/metamask-improvement-proposals/blob/main/MIPs/mip-2.md\n try {\n // Adding timeout as not all wallets support this method and can hang\n // https://github.com/wevm/wagmi/issues/4064\n await withTimeout(\n () =>\n // TODO: Remove explicit type for viem@3\n provider.request<{\n Method: 'wallet_revokePermissions'\n Parameters: [permissions: { eth_accounts: Record<string, any> }]\n ReturnType: null\n }>({\n // `'wallet_revokePermissions'` added in `viem@2.10.3`\n method: 'wallet_revokePermissions',\n params: [{ eth_accounts: {} }],\n }),\n { timeout: 100 },\n )\n } catch {}\n\n // Add shim signalling connector is disconnected\n if (shimDisconnect) {\n await config.storage?.setItem(`${this.id}.disconnected`, true)\n }\n\n if (!parameters.target)\n await config.storage?.removeItem('injected.connected')\n },\n async getAccounts() {\n const provider = await this.getProvider()\n if (!provider) throw new ProviderNotFoundError()\n const accounts = await provider.request({ method: 'eth_accounts' })\n return accounts.map((x) => getAddress(x))\n },\n async getChainId() {\n const provider = await this.getProvider()\n if (!provider) throw new ProviderNotFoundError()\n const hexChainId = await provider.request({ method: 'eth_chainId' })\n return Number(hexChainId)\n },\n async getProvider() {\n if (typeof window === 'undefined') return undefined\n\n let provider: Provider\n const target = getTarget()\n if (typeof target.provider === 'function')\n provider = target.provider(window as Window | undefined)\n else if (typeof target.provider === 'string')\n provider = findProvider(window, target.provider)\n else provider = target.provider\n\n // Some wallets do not conform to EIP-1193 (e.g. Trust Wallet)\n // https://github.com/wevm/wagmi/issues/3526#issuecomment-1912683002\n if (provider && !provider.removeListener) {\n // Try using `off` handler if it exists, otherwise noop\n if ('off' in provider && typeof provider.off === 'function')\n provider.removeListener =\n provider.off as typeof provider.removeListener\n else provider.removeListener = () => {}\n }\n\n return provider\n },\n async isAuthorized() {\n try {\n const isDisconnected =\n shimDisconnect &&\n // If shim exists in storage, connector is disconnected\n (await config.storage?.getItem(`${this.id}.disconnected`))\n if (isDisconnected) return false\n\n // Don't allow injected connector to connect if no target is set and it hasn't already connected\n // (e.g. flag in storage is not set). This prevents a targetless injected connector from connecting\n // automatically whenever there is a targeted connector configured.\n if (!parameters.target) {\n const connected = await config.storage?.getItem('injected.connected')\n if (!connected) return false\n }\n\n const provider = await this.getProvider()\n if (!provider) {\n if (\n unstable_shimAsyncInject !== undefined &&\n unstable_shimAsyncInject !== false\n ) {\n // If no provider is found, check for async injection\n // https://github.com/wevm/references/issues/167\n // https://github.com/MetaMask/detect-provider\n const handleEthereum = async () => {\n if (typeof window !== 'undefined')\n window.removeEventListener(\n 'ethereum#initialized',\n handleEthereum,\n )\n const provider = await this.getProvider()\n return !!provider\n }\n const timeout =\n typeof unstable_shimAsyncInject === 'number'\n ? unstable_shimAsyncInject\n : 1_000\n const res = await Promise.race([\n ...(typeof window !== 'undefined'\n ? [\n new Promise<boolean>((resolve) =>\n window.addEventListener(\n 'ethereum#initialized',\n () => resolve(handleEthereum()),\n { once: true },\n ),\n ),\n ]\n : []),\n new Promise<boolean>((resolve) =>\n setTimeout(() => resolve(handleEthereum()), timeout),\n ),\n ])\n if (res) return true\n }\n\n throw new ProviderNotFoundError()\n }\n\n // Use retry strategy as some injected wallets (e.g. MetaMask) fail to\n // immediately resolve JSON-RPC requests on page load.\n const accounts = await withRetry(() => this.getAccounts())\n return !!accounts.length\n } catch {\n return false\n }\n },\n async switchChain({ addEthereumChainParameter, chainId }) {\n const provider = await this.getProvider()\n if (!provider) throw new ProviderNotFoundError()\n\n const chain = config.chains.find((x) => x.id === chainId)\n if (!chain) throw new SwitchChainError(new ChainNotConfiguredError())\n\n const promise = new Promise<void>((resolve) => {\n const listener = ((data) => {\n if ('chainId' in data && data.chainId === chainId) {\n config.emitter.off('change', listener)\n resolve()\n }\n }) satisfies Parameters<typeof config.emitter.on>[1]\n config.emitter.on('change', listener)\n })\n\n try {\n await Promise.all([\n provider\n .request({\n method: 'wallet_switchEthereumChain',\n params: [{ chainId: numberToHex(chainId) }],\n })\n // During `'wallet_switchEthereumChain'`, MetaMask makes a `'net_version'` RPC call to the target chain.\n // If this request fails, MetaMask does not emit the `'chainChanged'` event, but will still switch the chain.\n // To counter this behavior, we request and emit the current chain ID to confirm the chain switch either via\n // this callback or an externally emitted `'chainChanged'` event.\n // https://github.com/MetaMask/metamask-extension/issues/24247\n .then(async () => {\n const currentChainId = await this.getChainId()\n if (currentChainId === chainId)\n config.emitter.emit('change', { chainId })\n }),\n promise,\n ])\n return chain\n } catch (err) {\n const error = err as RpcError\n\n // Indicates chain is not added to provider\n if (\n error.code === 4902 ||\n // Unwrapping for MetaMask Mobile\n // https://github.com/MetaMask/metamask-mobile/issues/2944#issuecomment-976988719\n (error as ProviderRpcError<{ originalError?: { code: number } }>)\n ?.data?.originalError?.code === 4902\n ) {\n try {\n const { default: blockExplorer, ...blockExplorers } =\n chain.blockExplorers ?? {}\n let blockExplorerUrls: string[] | undefined\n if (addEthereumChainParameter?.blockExplorerUrls)\n blockExplorerUrls = addEthereumChainParameter.blockExplorerUrls\n else if (blockExplorer)\n blockExplorerUrls = [\n blockExplorer.url,\n ...Object.values(blockExplorers).map((x) => x.url),\n ]\n\n let rpcUrls: readonly string[]\n if (addEthereumChainParameter?.rpcUrls?.length)\n rpcUrls = addEthereumChainParameter.rpcUrls\n else rpcUrls = [chain.rpcUrls.default?.http[0] ?? '']\n\n const addEthereumChain = {\n blockExplorerUrls,\n chainId: numberToHex(chainId),\n chainName: addEthereumChainParameter?.chainName ?? chain.name,\n iconUrls: addEthereumChainParameter?.iconUrls,\n nativeCurrency:\n addEthereumChainParameter?.nativeCurrency ??\n chain.nativeCurrency,\n rpcUrls,\n } satisfies AddEthereumChainParameter\n\n await Promise.all([\n provider\n .request({\n method: 'wallet_addEthereumChain',\n params: [addEthereumChain],\n })\n .then(async () => {\n const currentChainId = await this.getChainId()\n if (currentChainId === chainId)\n config.emitter.emit('change', { chainId })\n else\n throw new UserRejectedRequestError(\n new Error('User rejected switch after adding network.'),\n )\n }),\n promise,\n ])\n\n return chain\n } catch (error) {\n throw new UserRejectedRequestError(error as Error)\n }\n }\n\n if (error.code === UserRejectedRequestError.code)\n throw new UserRejectedRequestError(error)\n throw new SwitchChainError(error)\n }\n },\n async onAccountsChanged(accounts) {\n // Disconnect if there are no accounts\n if (accounts.length === 0) this.onDisconnect()\n // Connect if emitter is listening for connect event (e.g. is disconnected and connects through wallet interface)\n else if (config.emitter.listenerCount('connect')) {\n const chainId = (await this.getChainId()).toString()\n this.onConnect({ chainId })\n // Remove disconnected shim if it exists\n if (shimDisconnect)\n await config.storage?.removeItem(`${this.id}.disconnected`)\n }\n // Regular change event\n else\n config.emitter.emit('change', {\n accounts: accounts.map((x) => getAddress(x)),\n })\n },\n onChainChanged(chain) {\n const chainId = Number(chain)\n config.emitter.emit('change', { chainId })\n },\n async onConnect(connectInfo) {\n const accounts = await this.getAccounts()\n if (accounts.length === 0) return\n\n const chainId = Number(connectInfo.chainId)\n config.emitter.emit('connect', { accounts, chainId })\n\n // Manage EIP-1193 event listeners\n const provider = await this.getProvider()\n if (provider) {\n if (connect) {\n provider.removeListener('connect', connect)\n connect = undefined\n }\n if (!accountsChanged) {\n accountsChanged = this.onAccountsChanged.bind(this)\n provider.on('accountsChanged', accountsChanged)\n }\n if (!chainChanged) {\n chainChanged = this.onChainChanged.bind(this)\n provider.on('chainChanged', chainChanged)\n }\n if (!disconnect) {\n disconnect = this.onDisconnect.bind(this)\n provider.on('disconnect', disconnect)\n }\n }\n },\n async onDisconnect(error) {\n const provider = await this.getProvider()\n\n // If MetaMask emits a `code: 1013` error, wait for reconnection before disconnecting\n // https://github.com/MetaMask/providers/pull/120\n if (error && (error as RpcError<1013>).code === 1013) {\n if (provider && !!(await this.getAccounts()).length) return\n }\n\n // No need to remove `${this.id}.disconnected` from storage because `onDisconnect` is typically\n // only called when the wallet is disconnected through the wallet's interface, meaning the wallet\n // actually disconnected and we don't need to simulate it.\n config.emitter.emit('disconnect')\n\n // Manage EIP-1193 event listeners\n if (provider) {\n if (chainChanged) {\n provider.removeListener('chainChanged', chainChanged)\n chainChanged = undefined\n }\n if (disconnect) {\n provider.removeListener('disconnect', disconnect)\n disconnect = undefined\n }\n if (!connect) {\n connect = this.onConnect.bind(this)\n provider.on('connect', connect)\n }\n }\n },\n }))\n}\n\nconst targetMap = {\n coinbaseWallet: {\n id: 'coinbaseWallet',\n name: 'Coinbase Wallet',\n provider(window) {\n if (window?.coinbaseWalletExtension) return window.coinbaseWalletExtension\n return findProvider(window, 'isCoinbaseWallet')\n },\n },\n metaMask: {\n id: 'metaMask',\n name: 'MetaMask',\n provider(window) {\n return findProvider(window, (provider) => {\n if (!provider.isMetaMask) return false\n // Brave tries to make itself look like MetaMask\n // Could also try RPC `web3_clientVersion` if following is unreliable\n if (provider.isBraveWallet && !provider._events && !provider._state)\n return false\n // Other wallets that try to look like MetaMask\n const flags = [\n 'isApexWallet',\n 'isAvalanche',\n 'isBitKeep',\n 'isBlockWallet',\n 'isKuCoinWallet',\n 'isMathWallet',\n 'isOkxWallet',\n 'isOKExWallet',\n 'isOneInchIOSWallet',\n 'isOneInchAndroidWallet',\n 'isOpera',\n 'isPhantom',\n 'isPortal',\n 'isRabby',\n 'isTokenPocket',\n 'isTokenary',\n 'isUniswapWallet',\n 'isZerion',\n ] satisfies WalletProviderFlags[]\n for (const flag of flags) if (provider[flag]) return false\n return true\n })\n },\n },\n phantom: {\n id: 'phantom',\n name: 'Phantom',\n provider(window) {\n if (window?.phantom?.ethereum) return window.phantom?.ethereum\n return findProvider(window, 'isPhantom')\n },\n },\n} as const satisfies TargetMap\n\ntype TargetMap = { [_ in TargetId]?: Target | undefined }\n\ntype Target = {\n icon?: string | undefined\n id: string\n name: string\n provider:\n | WalletProviderFlags\n | WalletProvider\n | ((window?: Window | undefined) => WalletProvider | undefined)\n}\n\n/** @deprecated */\ntype TargetId = Compute<WalletProviderFlags> extends `is${infer name}`\n ? name extends `${infer char}${infer rest}`\n ? `${Lowercase<char>}${rest}`\n : never\n : never\n\n/**\n * @deprecated As of 2024/10/16, we are no longer accepting new provider flags as EIP-6963 should be used instead.\n */\ntype WalletProviderFlags =\n | 'isApexWallet'\n | 'isAvalanche'\n | 'isBackpack'\n | 'isBifrost'\n | 'isBitKeep'\n | 'isBitski'\n | 'isBlockWallet'\n | 'isBraveWallet'\n | 'isCoinbaseWallet'\n | 'isDawn'\n | 'isEnkrypt'\n | 'isExodus'\n | 'isFrame'\n | 'isFrontier'\n | 'isGamestop'\n | 'isHyperPay'\n | 'isImToken'\n | 'isKuCoinWallet'\n | 'isMathWallet'\n | 'isMetaMask'\n | 'isOkxWallet'\n | 'isOKExWallet'\n | 'isOneInchAndroidWallet'\n | 'isOneInchIOSWallet'\n | 'isOpera'\n | 'isPhantom'\n | 'isPortal'\n | 'isRabby'\n | 'isRainbow'\n | 'isStatus'\n | 'isTally'\n | 'isTokenPocket'\n | 'isTokenary'\n | 'isTrust'\n | 'isTrustWallet'\n | 'isUniswapWallet'\n | 'isXDEFI'\n | 'isZerion'\n\ntype WalletProvider = Compute<\n EIP1193Provider & {\n [key in WalletProviderFlags]?: true | undefined\n } & {\n providers?: WalletProvider[] | undefined\n /** Only exists in MetaMask as of 2022/04/03 */\n _events?: { connect?: (() => void) | undefined } | undefined\n /** Only exists in MetaMask as of 2022/04/03 */\n _state?:\n | {\n accounts?: string[]\n initialized?: boolean\n isConnected?: boolean\n isPermanentlyDisconnected?: boolean\n isUnlocked?: boolean\n }\n | undefined\n }\n>\n\ntype Window = {\n coinbaseWalletExtension?: WalletProvider | undefined\n ethereum?: WalletProvider | undefined\n phantom?: { ethereum: WalletProvider } | undefined\n}\n\nfunction findProvider(\n window: globalThis.Window | Window | undefined,\n select?: WalletProviderFlags | ((provider: WalletProvider) => boolean),\n) {\n function isProvider(provider: WalletProvider) {\n if (typeof select === 'function') return select(provider)\n if (typeof select === 'string') return provider[select]\n return true\n }\n\n const ethereum = (window as Window).ethereum\n if (ethereum?.providers)\n return ethereum.providers.find((provider) => isProvider(provider))\n if (ethereum && isProvider(ethereum)) return ethereum\n return undefined\n}\n", "import {\n type Address,\n type EIP1193RequestFn,\n type Hex,\n RpcRequestError,\n SwitchChainError,\n type Transport,\n UserRejectedRequestError,\n type WalletCallReceipt,\n type WalletRpcSchema,\n custom,\n fromHex,\n getAddress,\n keccak256,\n numberToHex,\n stringToHex,\n} from 'viem'\nimport { rpc } from 'viem/utils'\n\nimport {\n ChainNotConfiguredError,\n ConnectorNotConnectedError,\n} from '../errors/config.js'\nimport { createConnector } from './createConnector.js'\n\nexport type MockParameters = {\n accounts: readonly [Address, ...Address[]]\n features?:\n | {\n defaultConnected?: boolean | undefined\n connectError?: boolean | Error | undefined\n switchChainError?: boolean | Error | undefined\n signMessageError?: boolean | Error | undefined\n signTypedDataError?: boolean | Error | undefined\n reconnect?: boolean | undefined\n watchAssetError?: boolean | Error | undefined\n }\n | undefined\n}\n\nmock.type = 'mock' as const\nexport function mock(parameters: MockParameters) {\n const transactionCache = new Map<Hex, Hex[]>()\n const features =\n parameters.features ??\n ({ defaultConnected: false } satisfies MockParameters['features'])\n\n type Provider = ReturnType<\n Transport<'custom', unknown, EIP1193RequestFn<WalletRpcSchema>>\n >\n type Properties = {\n connect(parameters?: {\n chainId?: number | undefined\n isReconnecting?: boolean | undefined\n foo?: string | undefined\n }): Promise<{\n accounts: readonly Address[]\n chainId: number\n }>\n }\n let connected = features.defaultConnected\n let connectedChainId: number\n\n return createConnector<Provider, Properties>((config) => ({\n id: 'mock',\n name: 'Mock Connector',\n type: mock.type,\n async setup() {\n connectedChainId = config.chains[0].id\n },\n async connect({ chainId } = {}) {\n if (features.connectError) {\n if (typeof features.connectError === 'boolean')\n throw new UserRejectedRequestError(new Error('Failed to connect.'))\n throw features.connectError\n }\n\n const provider = await this.getProvider()\n const accounts = await provider.request({\n method: 'eth_requestAccounts',\n })\n\n let currentChainId = await this.getChainId()\n if (chainId && currentChainId !== chainId) {\n const chain = await this.switchChain!({ chainId })\n currentChainId = chain.id\n }\n\n connected = true\n\n return {\n accounts: accounts.map((x) => getAddress(x)),\n chainId: currentChainId,\n }\n },\n async disconnect() {\n connected = false\n },\n async getAccounts() {\n if (!connected) throw new ConnectorNotConnectedError()\n const provider = await this.getProvider()\n const accounts = await provider.request({ method: 'eth_accounts' })\n return accounts.map((x) => getAddress(x))\n },\n async getChainId() {\n const provider = await this.getProvider()\n const hexChainId = await provider.request({ method: 'eth_chainId' })\n return fromHex(hexChainId, 'number')\n },\n async isAuthorized() {\n if (!features.reconnect) return false\n if (!connected) return false\n const accounts = await this.getAccounts()\n return !!accounts.length\n },\n async switchChain({ chainId }) {\n const provider = await this.getProvider()\n const chain = config.chains.find((x) => x.id === chainId)\n if (!chain) throw new SwitchChainError(new ChainNotConfiguredError())\n\n await provider.request({\n method: 'wallet_switchEthereumChain',\n params: [{ chainId: numberToHex(chainId) }],\n })\n return chain\n },\n onAccountsChanged(accounts) {\n if (accounts.length === 0) this.onDisconnect()\n else\n config.emitter.emit('change', {\n accounts: accounts.map((x) => getAddress(x)),\n })\n },\n onChainChanged(chain) {\n const chainId = Number(chain)\n config.emitter.emit('change', { chainId })\n },\n async onDisconnect(_error) {\n config.emitter.emit('disconnect')\n connected = false\n },\n async getProvider({ chainId } = {}) {\n const chain =\n config.chains.find((x) => x.id === chainId) ?? config.chains[0]\n const url = chain.rpcUrls.default.http[0]!\n\n const request: EIP1193RequestFn = async ({ method, params }) => {\n // eth methods\n if (method === 'eth_chainId') return numberToHex(connectedChainId)\n if (method === 'eth_requestAccounts') return parameters.accounts\n if (method === 'eth_signTypedData_v4')\n if (features.signTypedDataError) {\n if (typeof features.signTypedDataError === 'boolean')\n throw new UserRejectedRequestError(\n new Error('Failed to sign typed data.'),\n )\n throw features.signTypedDataError\n }\n\n // wallet methods\n if (method === 'wallet_switchEthereumChain') {\n if (features.switchChainError) {\n if (typeof features.switchChainError === 'boolean')\n throw new UserRejectedRequestError(\n new Error('Failed to switch chain.'),\n )\n throw features.switchChainError\n }\n type Params = [{ chainId: Hex }]\n connectedChainId = fromHex((params as Params)[0].chainId, 'number')\n this.onChainChanged(connectedChainId.toString())\n return\n }\n\n if (method === 'wallet_watchAsset') {\n if (features.watchAssetError) {\n if (typeof features.watchAssetError === 'boolean')\n throw new UserRejectedRequestError(\n new Error('Failed to switch chain.'),\n )\n throw features.watchAssetError\n }\n return connected\n }\n\n if (method === 'wallet_getCapabilities')\n return {\n '0x2105': {\n paymasterService: {\n supported:\n (params as [Hex])[0] ===\n '0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266',\n },\n sessionKeys: {\n supported: true,\n },\n },\n '0x14A34': {\n paymasterService: {\n supported:\n (params as [Hex])[0] ===\n '0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266',\n },\n },\n }\n\n if (method === 'wallet_sendCalls') {\n const hashes = []\n const calls = (params as any)[0].calls\n for (const call of calls) {\n const { result, error } = await rpc.http(url, {\n body: {\n method: 'eth_sendTransaction',\n params: [call],\n },\n })\n if (error)\n throw new RpcRequestError({\n body: { method, params },\n error,\n url,\n })\n hashes.push(result)\n }\n const id = keccak256(stringToHex(JSON.stringify(calls)))\n transactionCache.set(id, hashes)\n return id\n }\n\n if (method === 'wallet_getCallsStatus') {\n const hashes = transactionCache.get((params as any)[0])\n if (!hashes) return null\n const receipts = await Promise.all(\n hashes.map(async (hash) => {\n const { result, error } = await rpc.http(url, {\n body: {\n method: 'eth_getTransactionReceipt',\n params: [hash],\n id: 0,\n },\n })\n if (error)\n throw new RpcRequestError({\n body: { method, params },\n error,\n url,\n })\n if (!result) return null\n return {\n blockHash: result.blockHash,\n blockNumber: result.blockNumber,\n gasUsed: result.gasUsed,\n logs: result.logs,\n status: result.status,\n transactionHash: result.transactionHash,\n } satisfies WalletCallReceipt\n }),\n )\n if (receipts.some((x) => !x))\n return { status: 'PENDING', receipts: [] }\n return { status: 'CONFIRMED', receipts }\n }\n\n if (method === 'wallet_showCallsStatus') return\n\n // other methods\n if (method === 'personal_sign') {\n if (features.signMessageError) {\n if (typeof features.signMessageError === 'boolean')\n throw new UserRejectedRequestError(\n new Error('Failed to sign message.'),\n )\n throw features.signMessageError\n }\n // Change `personal_sign` to `eth_sign` and swap params\n method = 'eth_sign'\n type Params = [data: Hex, address: Address]\n params = [(params as Params)[1], (params as Params)[0]]\n }\n\n const body = { method, params }\n const { error, result } = await rpc.http(url, { body })\n if (error) throw new RpcRequestError({ body, error, url })\n\n return result\n }\n return custom({ request })({ retryCount: 0 })\n },\n }))\n}\n", "const reduxImpl = (reducer, initial) => (set, _get, api) => {\n api.dispatch = (action) => {\n set((state) => reducer(state, action), false, action);\n return action;\n };\n api.dispatchFromDevtools = true;\n return { dispatch: (...a) => api.dispatch(...a), ...initial };\n};\nconst redux = reduxImpl;\n\nconst trackedConnections = /* @__PURE__ */ new Map();\nconst getTrackedConnectionState = (name) => {\n const api = trackedConnections.get(name);\n if (!api) return {};\n return Object.fromEntries(\n Object.entries(api.stores).map(([key, api2]) => [key, api2.getState()])\n );\n};\nconst extractConnectionInformation = (store, extensionConnector, options) => {\n if (store === void 0) {\n return {\n type: \"untracked\",\n connection: extensionConnector.connect(options)\n };\n }\n const existingConnection = trackedConnections.get(options.name);\n if (existingConnection) {\n return { type: \"tracked\", store, ...existingConnection };\n }\n const newConnection = {\n connection: extensionConnector.connect(options),\n stores: {}\n };\n trackedConnections.set(options.name, newConnection);\n return { type: \"tracked\", store, ...newConnection };\n};\nconst devtoolsImpl = (fn, devtoolsOptions = {}) => (set, get, api) => {\n const { enabled, anonymousActionType, store, ...options } = devtoolsOptions;\n let extensionConnector;\n try {\n extensionConnector = (enabled != null ? enabled : (import.meta.env ? import.meta.env.MODE : void 0) !== \"production\") && window.__REDUX_DEVTOOLS_EXTENSION__;\n } catch (e) {\n }\n if (!extensionConnector) {\n return fn(set, get, api);\n }\n const { connection, ...connectionInformation } = extractConnectionInformation(store, extensionConnector, options);\n let isRecording = true;\n api.setState = (state, replace, nameOrAction) => {\n const r = set(state, replace);\n if (!isRecording) return r;\n const action = nameOrAction === void 0 ? { type: anonymousActionType || \"anonymous\" } : typeof nameOrAction === \"string\" ? { type: nameOrAction } : nameOrAction;\n if (store === void 0) {\n connection == null ? void 0 : connection.send(action, get());\n return r;\n }\n connection == null ? void 0 : connection.send(\n {\n ...action,\n type: `${store}/${action.type}`\n },\n {\n ...getTrackedConnectionState(options.name),\n [store]: api.getState()\n }\n );\n return r;\n };\n const setStateFromDevtools = (...a) => {\n const originalIsRecording = isRecording;\n isRecording = false;\n set(...a);\n isRecording = originalIsRecording;\n };\n const initialState = fn(api.setState, get, api);\n if (connectionInformation.type === \"untracked\") {\n connection == null ? void 0 : connection.init(initialState);\n } else {\n connectionInformation.stores[connectionInformation.store] = api;\n connection == null ? void 0 : connection.init(\n Object.fromEntries(\n Object.entries(connectionInformation.stores).map(([key, store2]) => [\n key,\n key === connectionInformation.store ? initialState : store2.getState()\n ])\n )\n );\n }\n if (api.dispatchFromDevtools && typeof api.dispatch === \"function\") {\n let didWarnAboutReservedActionType = false;\n const originalDispatch = api.dispatch;\n api.dispatch = (...a) => {\n if ((import.meta.env ? import.meta.env.MODE : void 0) !== \"production\" && a[0].type === \"__setState\" && !didWarnAboutReservedActionType) {\n console.warn(\n '[zustand devtools middleware] \"__setState\" action type is reserved to set state from the devtools. Avoid using it.'\n );\n didWarnAboutReservedActionType = true;\n }\n originalDispatch(...a);\n };\n }\n connection.subscribe((message) => {\n var _a;\n switch (message.type) {\n case \"ACTION\":\n if (typeof message.payload !== \"string\") {\n console.error(\n \"[zustand devtools middleware] Unsupported action format\"\n );\n return;\n }\n return parseJsonThen(\n message.payload,\n (action) => {\n if (action.type === \"__setState\") {\n if (store === void 0) {\n setStateFromDevtools(action.state);\n return;\n }\n if (Object.keys(action.state).length !== 1) {\n console.error(\n `\n [zustand devtools middleware] Unsupported __setState action format.\n When using 'store' option in devtools(), the 'state' should have only one key, which is a value of 'store' that was passed in devtools(),\n and value of this only key should be a state object. Example: { \"type\": \"__setState\", \"state\": { \"abc123Store\": { \"foo\": \"bar\" } } }\n `\n );\n }\n const stateFromDevtools = action.state[store];\n if (stateFromDevtools === void 0 || stateFromDevtools === null) {\n return;\n }\n if (JSON.stringify(api.getState()) !== JSON.stringify(stateFromDevtools)) {\n setStateFromDevtools(stateFromDevtools);\n }\n return;\n }\n if (!api.dispatchFromDevtools) return;\n if (typeof api.dispatch !== \"function\") return;\n api.dispatch(action);\n }\n );\n case \"DISPATCH\":\n switch (message.payload.type) {\n case \"RESET\":\n setStateFromDevtools(initialState);\n if (store === void 0) {\n return connection == null ? void 0 : connection.init(api.getState());\n }\n return connection == null ? void 0 : connection.init(getTrackedConnectionState(options.name));\n case \"COMMIT\":\n if (store === void 0) {\n connection == null ? void 0 : connection.init(api.getState());\n return;\n }\n return connection == null ? void 0 : connection.init(getTrackedConnectionState(options.name));\n case \"ROLLBACK\":\n return parseJsonThen(message.state, (state) => {\n if (store === void 0) {\n setStateFromDevtools(state);\n connection == null ? void 0 : connection.init(api.getState());\n return;\n }\n setStateFromDevtools(state[store]);\n connection == null ? void 0 : connection.init(getTrackedConnectionState(options.name));\n });\n case \"JUMP_TO_STATE\":\n case \"JUMP_TO_ACTION\":\n return parseJsonThen(message.state, (state) => {\n if (store === void 0) {\n setStateFromDevtools(state);\n return;\n }\n if (JSON.stringify(api.getState()) !== JSON.stringify(state[store])) {\n setStateFromDevtools(state[store]);\n }\n });\n case \"IMPORT_STATE\": {\n const { nextLiftedState } = message.payload;\n const lastComputedState = (_a = nextLiftedState.computedStates.slice(-1)[0]) == null ? void 0 : _a.state;\n if (!lastComputedState) return;\n if (store === void 0) {\n setStateFromDevtools(lastComputedState);\n } else {\n setStateFromDevtools(lastComputedState[store]);\n }\n connection == null ? void 0 : connection.send(\n null,\n // FIXME no-any\n nextLiftedState\n );\n return;\n }\n case \"PAUSE_RECORDING\":\n return isRecording = !isRecording;\n }\n return;\n }\n });\n return initialState;\n};\nconst devtools = devtoolsImpl;\nconst parseJsonThen = (stringified, f) => {\n let parsed;\n try {\n parsed = JSON.parse(stringified);\n } catch (e) {\n console.error(\n \"[zustand devtools middleware] Could not parse the received json\",\n e\n );\n }\n if (parsed !== void 0) f(parsed);\n};\n\nconst subscribeWithSelectorImpl = (fn) => (set, get, api) => {\n const origSubscribe = api.subscribe;\n api.subscribe = (selector, optListener, options) => {\n let listener = selector;\n if (optListener) {\n const equalityFn = (options == null ? void 0 : options.equalityFn) || Object.is;\n let currentSlice = selector(api.getState());\n listener = (state) => {\n const nextSlice = selector(state);\n if (!equalityFn(currentSlice, nextSlice)) {\n const previousSlice = currentSlice;\n optListener(currentSlice = nextSlice, previousSlice);\n }\n };\n if (options == null ? void 0 : options.fireImmediately) {\n optListener(currentSlice, currentSlice);\n }\n }\n return origSubscribe(listener);\n };\n const initialState = fn(set, get, api);\n return initialState;\n};\nconst subscribeWithSelector = subscribeWithSelectorImpl;\n\nconst combine = (initialState, create) => (...a) => Object.assign({}, initialState, create(...a));\n\nfunction createJSONStorage(getStorage, options) {\n let storage;\n try {\n storage = getStorage();\n } catch (e) {\n return;\n }\n const persistStorage = {\n getItem: (name) => {\n var _a;\n const parse = (str2) => {\n if (str2 === null) {\n return null;\n }\n return JSON.parse(str2, options == null ? void 0 : options.reviver);\n };\n const str = (_a = storage.getItem(name)) != null ? _a : null;\n if (str instanceof Promise) {\n return str.then(parse);\n }\n return parse(str);\n },\n setItem: (name, newValue) => storage.setItem(\n name,\n JSON.stringify(newValue, options == null ? void 0 : options.replacer)\n ),\n removeItem: (name) => storage.removeItem(name)\n };\n return persistStorage;\n}\nconst toThenable = (fn) => (input) => {\n try {\n const result = fn(input);\n if (result instanceof Promise) {\n return result;\n }\n return {\n then(onFulfilled) {\n return toThenable(onFulfilled)(result);\n },\n catch(_onRejected) {\n return this;\n }\n };\n } catch (e) {\n return {\n then(_onFulfilled) {\n return this;\n },\n catch(onRejected) {\n return toThenable(onRejected)(e);\n }\n };\n }\n};\nconst persistImpl = (config, baseOptions) => (set, get, api) => {\n let options = {\n storage: createJSONStorage(() => localStorage),\n partialize: (state) => state,\n version: 0,\n merge: (persistedState, currentState) => ({\n ...currentState,\n ...persistedState\n }),\n ...baseOptions\n };\n let hasHydrated = false;\n const hydrationListeners = /* @__PURE__ */ new Set();\n const finishHydrationListeners = /* @__PURE__ */ new Set();\n let storage = options.storage;\n if (!storage) {\n return config(\n (...args) => {\n console.warn(\n `[zustand persist middleware] Unable to update item '${options.name}', the given storage is currently unavailable.`\n );\n set(...args);\n },\n get,\n api\n );\n }\n const setItem = () => {\n const state = options.partialize({ ...get() });\n return storage.setItem(options.name, {\n state,\n version: options.version\n });\n };\n const savedSetState = api.setState;\n api.setState = (state, replace) => {\n savedSetState(state, replace);\n void setItem();\n };\n const configResult = config(\n (...args) => {\n set(...args);\n void setItem();\n },\n get,\n api\n );\n api.getInitialState = () => configResult;\n let stateFromStorage;\n const hydrate = () => {\n var _a, _b;\n if (!storage) return;\n hasHydrated = false;\n hydrationListeners.forEach((cb) => {\n var _a2;\n return cb((_a2 = get()) != null ? _a2 : configResult);\n });\n const postRehydrationCallback = ((_b = options.onRehydrateStorage) == null ? void 0 : _b.call(options, (_a = get()) != null ? _a : configResult)) || void 0;\n return toThenable(storage.getItem.bind(storage))(options.name).then((deserializedStorageValue) => {\n if (deserializedStorageValue) {\n if (typeof deserializedStorageValue.version === \"number\" && deserializedStorageValue.version !== options.version) {\n if (options.migrate) {\n return [\n true,\n options.migrate(\n deserializedStorageValue.state,\n deserializedStorageValue.version\n )\n ];\n }\n console.error(\n `State loaded from storage couldn't be migrated since no migrate function was provided`\n );\n } else {\n return [false, deserializedStorageValue.state];\n }\n }\n return [false, void 0];\n }).then((migrationResult) => {\n var _a2;\n const [migrated, migratedState] = migrationResult;\n stateFromStorage = options.merge(\n migratedState,\n (_a2 = get()) != null ? _a2 : configResult\n );\n set(stateFromStorage, true);\n if (migrated) {\n return setItem();\n }\n }).then(() => {\n postRehydrationCallback == null ? void 0 : postRehydrationCallback(stateFromStorage, void 0);\n stateFromStorage = get();\n hasHydrated = true;\n finishHydrationListeners.forEach((cb) => cb(stateFromStorage));\n }).catch((e) => {\n postRehydrationCallback == null ? void 0 : postRehydrationCallback(void 0, e);\n });\n };\n api.persist = {\n setOptions: (newOptions) => {\n options = {\n ...options,\n ...newOptions\n };\n if (newOptions.storage) {\n storage = newOptions.storage;\n }\n },\n clearStorage: () => {\n storage == null ? void 0 : storage.removeItem(options.name);\n },\n getOptions: () => options,\n rehydrate: () => hydrate(),\n hasHydrated: () => hasHydrated,\n onHydrate: (cb) => {\n hydrationListeners.add(cb);\n return () => {\n hydrationListeners.delete(cb);\n };\n },\n onFinishHydration: (cb) => {\n finishHydrationListeners.add(cb);\n return () => {\n finishHydrationListeners.delete(cb);\n };\n }\n };\n if (!options.skipHydration) {\n hydrate();\n }\n return stateFromStorage || configResult;\n};\nconst persist = persistImpl;\n\nexport { combine, createJSONStorage, devtools, persist, redux, subscribeWithSelector };\n", "const createStoreImpl = (createState) => {\n let state;\n const listeners = /* @__PURE__ */ new Set();\n const setState = (partial, replace) => {\n const nextState = typeof partial === \"function\" ? partial(state) : partial;\n if (!Object.is(nextState, state)) {\n const previousState = state;\n state = (replace != null ? replace : typeof nextState !== \"object\" || nextState === null) ? nextState : Object.assign({}, state, nextState);\n listeners.forEach((listener) => listener(state, previousState));\n }\n };\n const getState = () => state;\n const getInitialState = () => initialState;\n const subscribe = (listener) => {\n listeners.add(listener);\n return () => listeners.delete(listener);\n };\n const api = { setState, getState, getInitialState, subscribe };\n const initialState = state = createState(setState, getState, api);\n return api;\n};\nconst createStore = (createState) => createState ? createStoreImpl(createState) : createStoreImpl;\n\nexport { createStore };\n", "import { EventEmitter } from 'eventemitter3'\n\ntype EventMap = Record<string, object | never>\ntype EventKey<eventMap extends EventMap> = string & keyof eventMap\ntype EventFn<parameters extends unknown[] = any[]> = (\n ...parameters: parameters\n) => void\nexport type EventData<\n eventMap extends EventMap,\n eventName extends keyof eventMap,\n> = (eventMap[eventName] extends [never] ? unknown : eventMap[eventName]) & {\n uid: string\n}\n\nexport class Emitter<eventMap extends EventMap> {\n _emitter = new EventEmitter()\n\n constructor(public uid: string) {}\n\n on<key extends EventKey<eventMap>>(\n eventName: key,\n fn: EventFn<\n eventMap[key] extends [never]\n ? [{ uid: string }]\n : [data: eventMap[key] & { uid: string }]\n >,\n ) {\n this._emitter.on(eventName, fn as EventFn)\n }\n\n once<key extends EventKey<eventMap>>(\n eventName: key,\n fn: EventFn<\n eventMap[key] extends [never]\n ? [{ uid: string }]\n : [data: eventMap[key] & { uid: string }]\n >,\n ) {\n this._emitter.once(eventName, fn as EventFn)\n }\n\n off<key extends EventKey<eventMap>>(\n eventName: key,\n fn: EventFn<\n eventMap[key] extends [never]\n ? [{ uid: string }]\n : [data: eventMap[key] & { uid: string }]\n >,\n ) {\n this._emitter.off(eventName, fn as EventFn)\n }\n\n emit<key extends EventKey<eventMap>>(\n eventName: key,\n ...params: eventMap[key] extends [never] ? [] : [data: eventMap[key]]\n ) {\n const data = params[0]\n this._emitter.emit(eventName, { uid: this.uid, ...data })\n }\n\n listenerCount<key extends EventKey<eventMap>>(eventName: key) {\n return this._emitter.listenerCount(eventName)\n }\n}\n\nexport function createEmitter<eventMap extends EventMap>(uid: string) {\n return new Emitter<eventMap>(uid)\n}\n", "type Reviver = (key: string, value: any) => any\n\nexport function deserialize<type>(value: string, reviver?: Reviver): type {\n return JSON.parse(value, (key, value_) => {\n let value = value_\n if (value?.__type === 'bigint') value = BigInt(value.value)\n if (value?.__type === 'Map') value = new Map(value.value)\n return reviver?.(key, value) ?? value\n })\n}\n", "/**\n * Get the reference key for the circular value\n *\n * @param keys the keys to build the reference key from\n * @param cutoff the maximum number of keys to include\n * @returns the reference key\n */\nfunction getReferenceKey(keys: string[], cutoff: number) {\n return keys.slice(0, cutoff).join('.') || '.'\n}\n\n/**\n * Faster `Array.prototype.indexOf` implementation build for slicing / splicing\n *\n * @param array the array to match the value in\n * @param value the value to match\n * @returns the matching index, or -1\n */\nfunction getCutoff(array: any[], value: any) {\n const { length } = array\n\n for (let index = 0; index < length; ++index) {\n if (array[index] === value) {\n return index + 1\n }\n }\n\n return 0\n}\n\ntype StandardReplacer = (key: string, value: any) => any\ntype CircularReplacer = (key: string, value: any, referenceKey: string) => any\n\n/**\n * Create a replacer method that handles circular values\n *\n * @param [replacer] a custom replacer to use for non-circular values\n * @param [circularReplacer] a custom replacer to use for circular methods\n * @returns the value to stringify\n */\nfunction createReplacer(\n replacer?: StandardReplacer | null | undefined,\n circularReplacer?: CircularReplacer | null | undefined,\n): StandardReplacer {\n const hasReplacer = typeof replacer === 'function'\n const hasCircularReplacer = typeof circularReplacer === 'function'\n\n const cache: any[] = []\n const keys: string[] = []\n\n return function replace(this: any, key: string, value: any) {\n if (typeof value === 'object') {\n if (cache.length) {\n const thisCutoff = getCutoff(cache, this)\n\n if (thisCutoff === 0) {\n cache[cache.length] = this\n } else {\n cache.splice(thisCutoff)\n keys.splice(thisCutoff)\n }\n\n keys[keys.length] = key\n\n const valueCutoff = getCutoff(cache, value)\n\n if (valueCutoff !== 0) {\n return hasCircularReplacer\n ? circularReplacer.call(\n this,\n key,\n value,\n getReferenceKey(keys, valueCutoff),\n )\n : `[ref=${getReferenceKey(keys, valueCutoff)}]`\n }\n } else {\n cache[0] = value\n keys[0] = key\n }\n }\n\n return hasReplacer ? replacer.call(this, key, value) : value\n }\n}\n\n/**\n * Stringifier that handles circular values\n *\n * Forked from https://github.com/planttheidea/fast-stringify\n *\n * @param value to stringify\n * @param [replacer] a custom replacer function for handling standard values\n * @param [indent] the number of spaces to indent the output by\n * @param [circularReplacer] a custom replacer function for handling circular values\n * @returns the stringified output\n */\nexport function serialize(\n value: any,\n replacer?: StandardReplacer | null | undefined,\n indent?: number | null | undefined,\n circularReplacer?: CircularReplacer | null | undefined,\n) {\n return JSON.stringify(\n value,\n createReplacer((key, value_) => {\n let value = value_\n if (typeof value === 'bigint')\n value = { __type: 'bigint', value: value_.toString() }\n if (value instanceof Map)\n value = { __type: 'Map', value: Array.from(value_.entries()) }\n return replacer?.(key, value) ?? value\n }, circularReplacer),\n indent ?? undefined,\n )\n}\n", "import type { PartializedState } from './createConfig.js'\nimport type { Compute } from './types/utils.js'\nimport { deserialize as deserialize_ } from './utils/deserialize.js'\nimport { serialize as serialize_ } from './utils/serialize.js'\n\n// key-values for loose autocomplete and typing\nexport type StorageItemMap = {\n recentConnectorId: string\n state: PartializedState\n}\n\nexport type Storage<\n itemMap extends Record<string, unknown> = Record<string, unknown>,\n ///\n storageItemMap extends StorageItemMap = StorageItemMap & itemMap,\n> = {\n key: string\n getItem<\n key extends keyof storageItemMap,\n value extends storageItemMap[key],\n defaultValue extends value | null | undefined,\n >(\n key: key,\n defaultValue?: defaultValue | undefined,\n ):\n | (defaultValue extends null ? value | null : value)\n | Promise<defaultValue extends null ? value | null : value>\n setItem<\n key extends keyof storageItemMap,\n value extends storageItemMap[key] | null,\n >(key: key, value: value): void | Promise<void>\n removeItem(key: keyof storageItemMap): void | Promise<void>\n}\n\nexport type BaseStorage = {\n getItem(\n key: string,\n ): string | null | undefined | Promise<string | null | undefined>\n setItem(key: string, value: string): void | Promise<void>\n removeItem(key: string): void | Promise<void>\n}\n\nexport type CreateStorageParameters = {\n deserialize?: (<type>(value: string) => type | unknown) | undefined\n key?: string | undefined\n serialize?: (<type>(value: type | any) => string) | undefined\n storage?: Compute<BaseStorage> | undefined\n}\n\nexport function createStorage<\n itemMap extends Record<string, unknown> = Record<string, unknown>,\n storageItemMap extends StorageItemMap = StorageItemMap & itemMap,\n>(parameters: CreateStorageParameters): Compute<Storage<storageItemMap>> {\n const {\n deserialize = deserialize_,\n key: prefix = 'wagmi',\n serialize = serialize_,\n storage = noopStorage,\n } = parameters\n\n function unwrap<type>(value: type): type | Promise<type> {\n if (value instanceof Promise) return value.then((x) => x).catch(() => null)\n return value\n }\n\n return {\n ...storage,\n key: prefix,\n async getItem(key, defaultValue) {\n const value = storage.getItem(`${prefix}.${key as string}`)\n const unwrapped = await unwrap(value)\n if (unwrapped) return deserialize(unwrapped) ?? null\n return (defaultValue ?? null) as any\n },\n async setItem(key, value) {\n const storageKey = `${prefix}.${key as string}`\n if (value === null) await unwrap(storage.removeItem(storageKey))\n else await unwrap(storage.setItem(storageKey, serialize(value)))\n },\n async removeItem(key) {\n await unwrap(storage.removeItem(`${prefix}.${key as string}`))\n },\n }\n}\n\nexport const noopStorage = {\n getItem: () => null,\n setItem: () => {},\n removeItem: () => {},\n} satisfies BaseStorage\n\nexport function getDefaultStorage() {\n const storage = (() => {\n if (typeof window !== 'undefined' && window.localStorage)\n return window.localStorage\n return noopStorage\n })()\n return {\n getItem(key) {\n return storage.getItem(key)\n },\n removeItem(key) {\n storage.removeItem(key)\n },\n setItem(key, value) {\n try {\n storage.setItem(key, value)\n // silence errors by default (QuotaExceededError, SecurityError, etc.)\n } catch {}\n },\n } satisfies BaseStorage\n}\n", "const size = 256\nlet index = size\nlet buffer: string\n\nexport function uid(length = 11) {\n if (!buffer || index + length > size * 2) {\n buffer = ''\n index = 0\n for (let i = 0; i < size; i++) {\n buffer += ((256 + Math.random() * 256) | 0).toString(16).substring(1)\n }\n }\n return buffer.substring(index, index++ + length)\n}\n", "import {\n type EIP6963ProviderDetail,\n type Store as MipdStore,\n createStore as createMipd,\n} from 'mipd'\nimport {\n type Address,\n type Chain,\n type Client,\n type EIP1193RequestFn,\n createClient,\n type ClientConfig as viem_ClientConfig,\n type Transport as viem_Transport,\n} from 'viem'\nimport { persist, subscribeWithSelector } from 'zustand/middleware'\nimport { type Mutate, type StoreApi, createStore } from 'zustand/vanilla'\n\nimport type {\n ConnectorEventMap,\n CreateConnectorFn,\n} from './connectors/createConnector.js'\nimport { injected } from './connectors/injected.js'\nimport { type Emitter, type EventData, createEmitter } from './createEmitter.js'\nimport {\n type Storage,\n createStorage,\n getDefaultStorage,\n} from './createStorage.js'\nimport { ChainNotConfiguredError } from './errors/config.js'\nimport type {\n Compute,\n ExactPartial,\n LooseOmit,\n OneOf,\n RemoveUndefined,\n} from './types/utils.js'\nimport { uid } from './utils/uid.js'\nimport { version } from './version.js'\n\nexport function createConfig<\n const chains extends readonly [Chain, ...Chain[]],\n transports extends Record<chains[number]['id'], Transport>,\n const connectorFns extends readonly CreateConnectorFn[],\n>(\n parameters: CreateConfigParameters<chains, transports, connectorFns>,\n): Config<chains, transports, connectorFns> {\n const {\n multiInjectedProviderDiscovery = true,\n storage = createStorage({\n storage: getDefaultStorage(),\n }),\n syncConnectedChain = true,\n ssr = false,\n ...rest\n } = parameters\n\n /////////////////////////////////////////////////////////////////////////////////////////////////\n // Set up connectors, clients, etc.\n /////////////////////////////////////////////////////////////////////////////////////////////////\n\n const mipd =\n typeof window !== 'undefined' && multiInjectedProviderDiscovery\n ? createMipd()\n : undefined\n\n const chains = createStore(() => rest.chains)\n const connectors = createStore(() => {\n const collection = []\n const rdnsSet = new Set<string>()\n for (const connectorFns of rest.connectors ?? []) {\n const connector = setup(connectorFns)\n collection.push(connector)\n if (!ssr && connector.rdns) {\n const rdnsValues =\n typeof connector.rdns === 'string' ? [connector.rdns] : connector.rdns\n for (const rdns of rdnsValues) {\n rdnsSet.add(rdns)\n }\n }\n }\n if (!ssr && mipd) {\n const providers = mipd.getProviders()\n for (const provider of providers) {\n if (rdnsSet.has(provider.info.rdns)) continue\n collection.push(setup(providerDetailToConnector(provider)))\n }\n }\n return collection\n })\n function setup(connectorFn: CreateConnectorFn): Connector {\n // Set up emitter with uid and add to connector so they are \"linked\" together.\n const emitter = createEmitter<ConnectorEventMap>(uid())\n const connector = {\n ...connectorFn({\n emitter,\n chains: chains.getState(),\n storage,\n transports: rest.transports,\n }),\n emitter,\n uid: emitter.uid,\n }\n\n // Start listening for `connect` events on connector setup\n // This allows connectors to \"connect\" themselves without user interaction (e.g. MetaMask's \"Manually connect to current site\")\n emitter.on('connect', connect)\n connector.setup?.()\n\n return connector\n }\n function providerDetailToConnector(providerDetail: EIP6963ProviderDetail) {\n const { info } = providerDetail\n const provider = providerDetail.provider as any\n return injected({ target: { ...info, id: info.rdns, provider } })\n }\n\n const clients = new Map<number, Client<Transport, chains[number]>>()\n function getClient<chainId extends chains[number]['id']>(\n config: { chainId?: chainId | chains[number]['id'] | undefined } = {},\n ): Client<Transport, Extract<chains[number], { id: chainId }>> {\n const chainId = config.chainId ?? store.getState().chainId\n const chain = chains.getState().find((x) => x.id === chainId)\n\n // chainId specified and not configured\n if (config.chainId && !chain) throw new ChainNotConfiguredError()\n\n // If the target chain is not configured, use the client of the current chain.\n type Return = Client<Transport, Extract<chains[number], { id: chainId }>>\n {\n const client = clients.get(store.getState().chainId)\n if (client && !chain) return client as Return\n if (!chain) throw new ChainNotConfiguredError()\n }\n\n // If a memoized client exists for a chain id, use that.\n {\n const client = clients.get(chainId)\n if (client) return client as Return\n }\n\n let client: Client<Transport, chains[number]>\n if (rest.client) client = rest.client({ chain })\n else {\n const chainId = chain.id as chains[number]['id']\n const chainIds = chains.getState().map((x) => x.id)\n // Grab all properties off `rest` and resolve for use in `createClient`\n const properties: Partial<viem_ClientConfig> = {}\n const entries = Object.entries(rest) as [keyof typeof rest, any][]\n\n for (const [key, value] of entries) {\n if (\n key === 'chains' ||\n key === 'client' ||\n key === 'connectors' ||\n key === 'transports'\n )\n continue\n\n if (typeof value === 'object') {\n // check if value is chainId-specific since some values can be objects\n // e.g. { batch: { multicall: { batchSize: 1024 } } }\n if (chainId in value) properties[key] = value[chainId]\n else {\n // check if value is chainId-specific, but does not have value for current chainId\n const hasChainSpecificValue = chainIds.some((x) => x in value)\n if (hasChainSpecificValue) continue\n properties[key] = value\n }\n } else properties[key] = value\n }\n\n client = createClient({\n ...properties,\n chain,\n batch: properties.batch ?? { multicall: true },\n transport: (parameters) =>\n rest.transports[chainId]({ ...parameters, connectors }),\n })\n }\n\n clients.set(chainId, client)\n return client as Return\n }\n\n /////////////////////////////////////////////////////////////////////////////////////////////////\n // Create store\n /////////////////////////////////////////////////////////////////////////////////////////////////\n\n function getInitialState(): State {\n return {\n chainId: chains.getState()[0].id,\n connections: new Map<string, Connection>(),\n current: null,\n status: 'disconnected',\n }\n }\n\n let currentVersion: number\n const prefix = '0.0.0-canary-'\n if (version.startsWith(prefix))\n currentVersion = Number.parseInt(version.replace(prefix, ''))\n // use package major version to version store\n else currentVersion = Number.parseInt(version.split('.')[0] ?? '0')\n\n const store = createStore(\n subscribeWithSelector(\n // only use persist middleware if storage exists\n storage\n ? persist(getInitialState, {\n migrate(persistedState, version) {\n if (version === currentVersion) return persistedState as State\n\n const initialState = getInitialState()\n const chainId = validatePersistedChainId(\n persistedState,\n initialState.chainId,\n )\n return { ...initialState, chainId }\n },\n name: 'store',\n partialize(state) {\n // Only persist \"critical\" store properties to preserve storage size.\n return {\n connections: {\n __type: 'Map',\n value: Array.from(state.connections.entries()).map(\n ([key, connection]) => {\n const { id, name, type, uid } = connection.connector\n const connector = { id, name, type, uid }\n return [key, { ...connection, connector }]\n },\n ),\n } as unknown as PartializedState['connections'],\n chainId: state.chainId,\n current: state.current,\n } satisfies PartializedState\n },\n merge(persistedState, currentState) {\n // `status` should not be persisted as it messes with reconnection\n if (\n typeof persistedState === 'object' &&\n persistedState &&\n 'status' in persistedState\n )\n delete persistedState.status\n // Make sure persisted `chainId` is valid\n const chainId = validatePersistedChainId(\n persistedState,\n currentState.chainId,\n )\n return {\n ...currentState,\n ...(persistedState as object),\n chainId,\n }\n },\n skipHydration: ssr,\n storage: storage as Storage<Record<string, unknown>>,\n version: currentVersion,\n })\n : getInitialState,\n ),\n )\n store.setState(getInitialState())\n\n function validatePersistedChainId(\n persistedState: unknown,\n defaultChainId: number,\n ) {\n return persistedState &&\n typeof persistedState === 'object' &&\n 'chainId' in persistedState &&\n typeof persistedState.chainId === 'number' &&\n chains.getState().some((x) => x.id === persistedState.chainId)\n ? persistedState.chainId\n : defaultChainId\n }\n\n /////////////////////////////////////////////////////////////////////////////////////////////////\n // Subscribe to changes\n /////////////////////////////////////////////////////////////////////////////////////////////////\n\n // Update default chain when connector chain changes\n if (syncConnectedChain)\n store.subscribe(\n ({ connections, current }) =>\n current ? connections.get(current)?.chainId : undefined,\n (chainId) => {\n // If chain is not configured, then don't switch over to it.\n const isChainConfigured = chains\n .getState()\n .some((x) => x.id === chainId)\n if (!isChainConfigured) return\n\n return store.setState((x) => ({\n ...x,\n chainId: chainId ?? x.chainId,\n }))\n },\n )\n\n // EIP-6963 subscribe for new wallet providers\n mipd?.subscribe((providerDetails) => {\n const connectorIdSet = new Set<string>()\n const connectorRdnsSet = new Set<string>()\n for (const connector of connectors.getState()) {\n connectorIdSet.add(connector.id)\n if (connector.rdns) {\n const rdnsValues =\n typeof connector.rdns === 'string' ? [connector.rdns] : connector.rdns\n for (const rdns of rdnsValues) {\n connectorRdnsSet.add(rdns)\n }\n }\n }\n\n const newConnectors: Connector[] = []\n for (const providerDetail of providerDetails) {\n if (connectorRdnsSet.has(providerDetail.info.rdns)) continue\n const connector = setup(providerDetailToConnector(providerDetail))\n if (connectorIdSet.has(connector.id)) continue\n newConnectors.push(connector)\n }\n\n if (storage && !store.persist.hasHydrated()) return\n connectors.setState((x) => [...x, ...newConnectors], true)\n })\n\n /////////////////////////////////////////////////////////////////////////////////////////////////\n // Emitter listeners\n /////////////////////////////////////////////////////////////////////////////////////////////////\n\n function change(data: EventData<ConnectorEventMap, 'change'>) {\n store.setState((x) => {\n const connection = x.connections.get(data.uid)\n if (!connection) return x\n return {\n ...x,\n connections: new Map(x.connections).set(data.uid, {\n accounts:\n (data.accounts as readonly [Address, ...Address[]]) ??\n connection.accounts,\n chainId: data.chainId ?? connection.chainId,\n connector: connection.connector,\n }),\n }\n })\n }\n function connect(data: EventData<ConnectorEventMap, 'connect'>) {\n // Disable handling if reconnecting/connecting\n if (\n store.getState().status === 'connecting' ||\n store.getState().status === 'reconnecting'\n )\n return\n\n store.setState((x) => {\n const connector = connectors.getState().find((x) => x.uid === data.uid)\n if (!connector) return x\n\n if (connector.emitter.listenerCount('connect'))\n connector.emitter.off('connect', change)\n if (!connector.emitter.listenerCount('change'))\n connector.emitter.on('change', change)\n if (!connector.emitter.listenerCount('disconnect'))\n connector.emitter.on('disconnect', disconnect)\n\n return {\n ...x,\n connections: new Map(x.connections).set(data.uid, {\n accounts: data.accounts as readonly [Address, ...Address[]],\n chainId: data.chainId,\n connector: connector,\n }),\n current: data.uid,\n status: 'connected',\n }\n })\n }\n function disconnect(data: EventData<ConnectorEventMap, 'disconnect'>) {\n store.setState((x) => {\n const connection = x.connections.get(data.uid)\n if (connection) {\n const connector = connection.connector\n if (connector.emitter.listenerCount('change'))\n connection.connector.emitter.off('change', change)\n if (connector.emitter.listenerCount('disconnect'))\n connection.connector.emitter.off('disconnect', disconnect)\n if (!connector.emitter.listenerCount('connect'))\n connection.connector.emitter.on('connect', connect)\n }\n\n x.connections.delete(data.uid)\n\n if (x.connections.size === 0)\n return {\n ...x,\n connections: new Map(),\n current: null,\n status: 'disconnected',\n }\n\n const nextConnection = x.connections.values().next().value as Connection\n return {\n ...x,\n connections: new Map(x.connections),\n current: nextConnection.connector.uid,\n }\n })\n }\n\n return {\n get chains() {\n return chains.getState() as chains\n },\n get connectors() {\n return connectors.getState() as Connector<connectorFns[number]>[]\n },\n storage,\n\n getClient,\n get state() {\n return store.getState() as unknown as State<chains>\n },\n setState(value) {\n let newState: State\n if (typeof value === 'function') newState = value(store.getState() as any)\n else newState = value\n\n // Reset state if it got set to something not matching the base state\n const initialState = getInitialState()\n if (typeof newState !== 'object') newState = initialState\n const isCorrupt = Object.keys(initialState).some((x) => !(x in newState))\n if (isCorrupt) newState = initialState\n\n store.setState(newState, true)\n },\n subscribe(selector, listener, options) {\n return store.subscribe(\n selector as unknown as (state: State) => any,\n listener,\n options\n ? ({\n ...options,\n fireImmediately: options.emitImmediately,\n // Workaround cast since Zustand does not support `'exactOptionalPropertyTypes'`\n } as RemoveUndefined<typeof options>)\n : undefined,\n )\n },\n\n _internal: {\n mipd,\n store,\n ssr: Boolean(ssr),\n syncConnectedChain,\n transports: rest.transports as transports,\n chains: {\n setState(value) {\n const nextChains = (\n typeof value === 'function' ? value(chains.getState()) : value\n ) as chains\n if (nextChains.length === 0) return\n return chains.setState(nextChains, true)\n },\n subscribe(listener) {\n return chains.subscribe(listener)\n },\n },\n connectors: {\n providerDetailToConnector,\n setup: setup as <connectorFn extends CreateConnectorFn>(\n connectorFn: connectorFn,\n ) => Connector<connectorFn>,\n setState(value) {\n return connectors.setState(\n typeof value === 'function' ? value(connectors.getState()) : value,\n true,\n )\n },\n subscribe(listener) {\n return connectors.subscribe(listener)\n },\n },\n events: { change, connect, disconnect },\n },\n }\n}\n\n/////////////////////////////////////////////////////////////////////////////////////////////////\n// Types\n/////////////////////////////////////////////////////////////////////////////////////////////////\n\nexport type CreateConfigParameters<\n chains extends readonly [Chain, ...Chain[]] = readonly [Chain, ...Chain[]],\n transports extends Record<chains[number]['id'], Transport> = Record<\n chains[number]['id'],\n Transport\n >,\n connectorFns extends\n readonly CreateConnectorFn[] = readonly CreateConnectorFn[],\n> = Compute<\n {\n chains: chains\n connectors?: connectorFns | undefined\n multiInjectedProviderDiscovery?: boolean | undefined\n storage?: Storage | null | undefined\n ssr?: boolean | undefined\n syncConnectedChain?: boolean | undefined\n } & OneOf<\n | ({ transports: transports } & {\n [key in keyof ClientConfig]?:\n | ClientConfig[key]\n | { [_ in chains[number]['id']]?: ClientConfig[key] | undefined }\n | undefined\n })\n | {\n client(parameters: { chain: chains[number] }): Client<\n transports[chains[number]['id']],\n chains[number]\n >\n }\n >\n>\n\nexport type Config<\n chains extends readonly [Chain, ...Chain[]] = readonly [Chain, ...Chain[]],\n transports extends Record<chains[number]['id'], Transport> = Record<\n chains[number]['id'],\n Transport\n >,\n connectorFns extends\n readonly CreateConnectorFn[] = readonly CreateConnectorFn[],\n> = {\n readonly chains: chains\n readonly connectors: readonly Connector<connectorFns[number]>[]\n readonly storage: Storage | null\n\n readonly state: State<chains>\n setState<tchains extends readonly [Chain, ...Chain[]] = chains>(\n value: State<tchains> | ((state: State<tchains>) => State<tchains>),\n ): void\n subscribe<state>(\n selector: (state: State<chains>) => state,\n listener: (state: state, previousState: state) => void,\n options?:\n | {\n emitImmediately?: boolean | undefined\n equalityFn?: ((a: state, b: state) => boolean) | undefined\n }\n | undefined,\n ): () => void\n\n getClient<chainId extends chains[number]['id']>(parameters?: {\n chainId?: chainId | chains[number]['id'] | undefined\n }): Client<transports[chainId], Extract<chains[number], { id: chainId }>>\n\n /**\n * Not part of versioned API, proceed with caution.\n * @internal\n */\n _internal: Internal<chains, transports>\n}\n\ntype Internal<\n chains extends readonly [Chain, ...Chain[]] = readonly [Chain, ...Chain[]],\n transports extends Record<chains[number]['id'], Transport> = Record<\n chains[number]['id'],\n Transport\n >,\n> = {\n readonly mipd: MipdStore | undefined\n readonly store: Mutate<StoreApi<any>, [['zustand/persist', any]]>\n readonly ssr: boolean\n readonly syncConnectedChain: boolean\n readonly transports: transports\n\n chains: {\n setState(\n value:\n | readonly [Chain, ...Chain[]]\n | ((\n state: readonly [Chain, ...Chain[]],\n ) => readonly [Chain, ...Chain[]]),\n ): void\n subscribe(\n listener: (\n state: readonly [Chain, ...Chain[]],\n prevState: readonly [Chain, ...Chain[]],\n ) => void,\n ): () => void\n }\n connectors: {\n providerDetailToConnector(\n providerDetail: EIP6963ProviderDetail,\n ): CreateConnectorFn\n setup<connectorFn extends CreateConnectorFn>(\n connectorFn: connectorFn,\n ): Connector<connectorFn>\n setState(value: Connector[] | ((state: Connector[]) => Connector[])): void\n subscribe(\n listener: (state: Connector[], prevState: Connector[]) => void,\n ): () => void\n }\n events: {\n change(data: EventData<ConnectorEventMap, 'change'>): void\n connect(data: EventData<ConnectorEventMap, 'connect'>): void\n disconnect(data: EventData<ConnectorEventMap, 'disconnect'>): void\n }\n}\n\nexport type State<\n chains extends readonly [Chain, ...Chain[]] = readonly [Chain, ...Chain[]],\n> = {\n chainId: chains[number]['id']\n connections: Map<string, Connection>\n current: string | null\n status: 'connected' | 'connecting' | 'disconnected' | 'reconnecting'\n}\n\nexport type PartializedState = Compute<\n ExactPartial<Pick<State, 'chainId' | 'connections' | 'current' | 'status'>>\n>\n\nexport type Connection = {\n accounts: readonly [Address, ...Address[]]\n chainId: number\n connector: Connector\n}\n\nexport type Connector<\n createConnectorFn extends CreateConnectorFn = CreateConnectorFn,\n> = ReturnType<createConnectorFn> & {\n emitter: Emitter<ConnectorEventMap>\n uid: string\n}\n\nexport type Transport<\n type extends string = string,\n rpcAttributes = Record<string, any>,\n eip1193RequestFn extends EIP1193RequestFn = EIP1193RequestFn,\n> = (\n params: Parameters<\n viem_Transport<type, rpcAttributes, eip1193RequestFn>\n >[0] & {\n connectors?: StoreApi<Connector[]> | undefined\n },\n) => ReturnType<viem_Transport<type, rpcAttributes, eip1193RequestFn>>\n\ntype ClientConfig = LooseOmit<\n viem_ClientConfig,\n 'account' | 'chain' | 'key' | 'name' | 'transport' | 'type'\n>\n", "import { reconnect } from './actions/reconnect.js'\nimport type { Config, State } from './createConfig.js'\n\ntype HydrateParameters = {\n initialState?: State | undefined\n reconnectOnMount?: boolean | undefined\n}\n\nexport function hydrate(config: Config, parameters: HydrateParameters) {\n const { initialState, reconnectOnMount } = parameters\n\n if (initialState && !config._internal.store.persist.hasHydrated())\n config.setState({\n ...initialState,\n chainId: config.chains.some((x) => x.id === initialState.chainId)\n ? initialState.chainId\n : config.chains[0].id,\n connections: reconnectOnMount ? initialState.connections : new Map(),\n status: reconnectOnMount ? 'reconnecting' : 'disconnected',\n })\n\n return {\n async onMount() {\n if (config._internal.ssr) {\n await config._internal.store.persist.rehydrate()\n if (config._internal.mipd) {\n config._internal.connectors.setState((connectors) => {\n const rdnsSet = new Set<string>()\n for (const connector of connectors ?? []) {\n if (connector.rdns) {\n const rdnsValues = Array.isArray(connector.rdns)\n ? connector.rdns\n : [connector.rdns]\n for (const rdns of rdnsValues) {\n rdnsSet.add(rdns)\n }\n }\n }\n const mipdConnectors = []\n const providers = config._internal.mipd?.getProviders() ?? []\n for (const provider of providers) {\n if (rdnsSet.has(provider.info.rdns)) continue\n const connectorFn =\n config._internal.connectors.providerDetailToConnector(provider)\n const connector = config._internal.connectors.setup(connectorFn)\n mipdConnectors.push(connector)\n }\n return [...connectors, ...mipdConnectors]\n })\n }\n }\n\n if (reconnectOnMount) reconnect(config)\n else if (config.storage)\n // Reset connections that may have been hydrated from storage.\n config.setState((x) => ({\n ...x,\n connections: new Map(),\n }))\n },\n }\n}\n", "import {\n ChainDisconnectedError,\n type EIP1193Parameters,\n type EIP1193Provider,\n type EIP1193RequestFn,\n ProviderDisconnectedError,\n type TransportConfig,\n type WalletRpcSchema,\n createTransport,\n hexToNumber,\n withRetry,\n withTimeout,\n} from 'viem'\n\nimport type { Connector, Transport } from '../createConfig.js'\n\nexport type ConnectorTransportConfig = {\n /** The key of the transport. */\n key?: TransportConfig['key'] | undefined\n /** The name of the transport. */\n name?: TransportConfig['name'] | undefined\n /** The max number of times to retry. */\n retryCount?: TransportConfig['retryCount'] | undefined\n /** The base delay (in ms) between retries. */\n retryDelay?: TransportConfig['retryDelay'] | undefined\n}\n\nexport type ConnectorTransport = Transport\n\nexport function unstable_connector(\n connector: Pick<Connector, 'type'>,\n config: ConnectorTransportConfig = {},\n): Transport<'connector'> {\n const { type } = connector\n const { key = 'connector', name = 'Connector', retryDelay } = config\n\n return (parameters) => {\n const { chain, connectors } = parameters\n const retryCount = config.retryCount ?? parameters.retryCount\n\n const request: EIP1193RequestFn = async ({ method, params }) => {\n const connector = connectors?.getState().find((c) => c.type === type)\n if (!connector)\n throw new ProviderDisconnectedError(\n new Error(\n `Could not find connector of type \"${type}\" in \\`connectors\\` passed to \\`createConfig\\`.`,\n ),\n )\n\n const provider = (await connector.getProvider({\n chainId: chain?.id,\n })) as EIP1193Provider | undefined\n if (!provider)\n throw new ProviderDisconnectedError(\n new Error('Provider is disconnected.'),\n )\n\n // We are applying a retry & timeout strategy here as some injected wallets (e.g. MetaMask) fail to\n // immediately resolve a JSON-RPC request on page load.\n const chainId = hexToNumber(\n await withRetry(() =>\n withTimeout(() => provider.request({ method: 'eth_chainId' }), {\n timeout: 100,\n }),\n ),\n )\n if (chain && chainId !== chain.id)\n throw new ChainDisconnectedError(\n new Error(\n `The current chain of the connector (id: ${chainId}) does not match the target chain for the request (id: ${chain.id} – ${chain.name}).`,\n ),\n )\n\n const body = { method, params } as EIP1193Parameters<WalletRpcSchema>\n return provider.request(body)\n }\n\n return createTransport({\n key,\n name,\n request,\n retryCount,\n retryDelay,\n type: 'connector',\n })\n }\n}\n", "import { fallback as viem_fallback } from 'viem'\n\nimport type { Transport } from '../createConfig.js'\n\nexport function fallback(\n transports: Transport[],\n config?: Parameters<typeof viem_fallback>[1],\n) {\n return viem_fallback(transports, config)\n}\n", "import type { Config, State } from '../createConfig.js'\nimport type { BaseStorage } from '../createStorage.js'\nimport { deserialize } from './deserialize.js'\n\nexport const cookieStorage = {\n getItem(key) {\n if (typeof window === 'undefined') return null\n const value = parseCookie(document.cookie, key)\n return value ?? null\n },\n setItem(key, value) {\n if (typeof window === 'undefined') return\n document.cookie = `${key}=${value};path=/;samesite=Lax`\n },\n removeItem(key) {\n if (typeof window === 'undefined') return\n document.cookie = `${key}=;max-age=-1;path=/`\n },\n} satisfies BaseStorage\n\nexport function cookieToInitialState(config: Config, cookie?: string | null) {\n if (!cookie) return undefined\n const key = `${config.storage?.key}.store`\n const parsed = parseCookie(cookie, key)\n if (!parsed) return undefined\n return deserialize<{ state: State }>(parsed).state\n}\n\nexport function parseCookie(cookie: string, key: string) {\n const keyValue = cookie.split('; ').find((x) => x.startsWith(`${key}=`))\n if (!keyValue) return undefined\n return keyValue.substring(key.length + 1)\n}\n", "/** @deprecated use `Number` instead */\nexport function normalizeChainId(chainId: bigint | number | string | unknown) {\n if (typeof chainId === 'string')\n return Number.parseInt(\n chainId,\n chainId.trim().substring(0, 2) === '0x' ? 16 : 10,\n )\n if (typeof chainId === 'bigint') return Number(chainId)\n if (typeof chainId === 'number') return chainId\n throw new Error(\n `Cannot normalize chainId \"${chainId}\" of type \"${typeof chainId}\"`,\n )\n}\n", "'use client'\n\nimport { type ResolvedRegister, type State, hydrate } from '@wagmi/core'\nimport { type ReactElement, useEffect, useRef } from 'react'\n\nexport type HydrateProps = {\n config: ResolvedRegister['config']\n initialState?: State | undefined\n reconnectOnMount?: boolean | undefined\n}\n\nexport function Hydrate(parameters: React.PropsWithChildren<HydrateProps>) {\n const { children, config, initialState, reconnectOnMount = true } = parameters\n\n const { onMount } = hydrate(config, {\n initialState,\n reconnectOnMount,\n })\n\n // Hydrate for non-SSR\n if (!config._internal.ssr) onMount()\n\n // Hydrate for SSR\n const active = useRef(true)\n // biome-ignore lint/correctness/useExhaustiveDependencies: `queryKey` not required\n useEffect(() => {\n if (!active.current) return\n if (!config._internal.ssr) return\n onMount()\n return () => {\n active.current = false\n }\n }, [])\n\n return children as ReactElement\n}\n", "export const version = '2.14.15'\n", "import { version } from '../version.js'\n\nexport const getVersion = () => `wagmi@${version}`\n", "import { BaseError as CoreError } from '@wagmi/core'\n\nimport { getVersion } from '../utils/getVersion.js'\n\nexport type BaseErrorType = BaseError & { name: 'WagmiError' }\nexport class BaseError extends CoreError {\n override name = 'WagmiError'\n override get docsBaseUrl() {\n return 'https://wagmi.sh/react'\n }\n override get version() {\n return getVersion()\n }\n}\n", "import { BaseError } from './base.js'\n\nexport type WagmiProviderNotFoundErrorType = WagmiProviderNotFoundError & {\n name: 'WagmiProviderNotFoundError'\n}\nexport class WagmiProviderNotFoundError extends BaseError {\n override name = 'WagmiProviderNotFoundError'\n constructor() {\n super('`useConfig` must be used within `WagmiProvider`.', {\n docsPath: '/api/WagmiProvider',\n })\n }\n}\n", "'use client'\n\nimport type { Config, ResolvedRegister } from '@wagmi/core'\nimport { useContext } from 'react'\n\nimport { WagmiContext } from '../context.js'\nimport { WagmiProviderNotFoundError } from '../errors/context.js'\nimport type { ConfigParameter } from '../types/properties.js'\n\nexport type UseConfigParameters<config extends Config = Config> =\n ConfigParameter<config>\n\nexport type UseConfigReturnType<config extends Config = Config> = config\n\n/** https://wagmi.sh/react/api/hooks/useConfig */\nexport function useConfig<config extends Config = ResolvedRegister['config']>(\n parameters: UseConfigParameters<config> = {},\n): UseConfigReturnType<config> {\n const config = parameters.config ?? useContext(WagmiContext)\n if (!config) throw new WagmiProviderNotFoundError()\n return config as UseConfigReturnType<config>\n}\n", "import type { Config } from '../createConfig.js'\nimport type { GetChainsReturnType } from './getChains.js'\n\nexport type WatchChainsParameters<config extends Config = Config> = {\n onChange(\n chains: GetChainsReturnType<config>,\n prevChains: GetChainsReturnType<config>,\n ): void\n}\n\nexport type WatchChainsReturnType = () => void\n\n/**\n * @internal\n * We don't expose this because as far as consumers know, you can't chainge (lol) `config.chains` at runtime.\n * Setting `config.chains` via `config._internal.chains.setState(...)` is an extremely advanced use case that's not worth documenting or supporting in the public API at this time.\n */\nexport function watchChains<config extends Config>(\n config: config,\n parameters: WatchChainsParameters<config>,\n): WatchChainsReturnType {\n const { onChange } = parameters\n return config._internal.chains.subscribe((chains, prevChains) => {\n onChange(\n chains as unknown as GetChainsReturnType<config>,\n prevChains as unknown as GetChainsReturnType<config>,\n )\n })\n}\n", "'use client'\n\nimport { deepEqual } from '@wagmi/core/internal'\nimport { useMemo, useRef } from 'react'\nimport { useSyncExternalStoreWithSelector } from 'use-sync-external-store/shim/with-selector.js'\n\nconst isPlainObject = (obj: unknown) =>\n typeof obj === 'object' && !Array.isArray(obj)\n\nexport function useSyncExternalStoreWithTracked<\n snapshot extends selection,\n selection = snapshot,\n>(\n subscribe: (onStoreChange: () => void) => () => void,\n getSnapshot: () => snapshot,\n getServerSnapshot: undefined | null | (() => snapshot) = getSnapshot,\n isEqual: (a: selection, b: selection) => boolean = deepEqual,\n) {\n const trackedKeys = useRef<string[]>([])\n const result = useSyncExternalStoreWithSelector(\n subscribe,\n getSnapshot,\n getServerSnapshot,\n (x) => x,\n (a, b) => {\n if (isPlainObject(a) && isPlainObject(b) && trackedKeys.current.length) {\n for (const key of trackedKeys.current) {\n const equal = isEqual(\n (a as { [_a: string]: any })[key],\n (b as { [_b: string]: any })[key],\n )\n if (!equal) return false\n }\n return true\n }\n return isEqual(a, b)\n },\n )\n\n return useMemo(() => {\n if (isPlainObject(result)) {\n const trackedResult = { ...result }\n let properties = {}\n for (const [key, value] of Object.entries(\n trackedResult as { [key: string]: any },\n )) {\n properties = {\n ...properties,\n [key]: {\n configurable: false,\n enumerable: true,\n get: () => {\n if (!trackedKeys.current.includes(key)) {\n trackedKeys.current.push(key)\n }\n return value\n },\n },\n }\n }\n Object.defineProperties(trackedResult, properties)\n return trackedResult\n }\n\n return result\n }, [result])\n}\n", "'use client'\n\nimport {\n type Config,\n type GetAccountReturnType,\n type ResolvedRegister,\n getAccount,\n watchAccount,\n} from '@wagmi/core'\n\nimport type { ConfigParameter } from '../types/properties.js'\nimport { useConfig } from './useConfig.js'\nimport { useSyncExternalStoreWithTracked } from './useSyncExternalStoreWithTracked.js'\n\nexport type UseAccountParameters<config extends Config = Config> =\n ConfigParameter<config>\n\nexport type UseAccountReturnType<config extends Config = Config> =\n GetAccountReturnType<config>\n\n/** https://wagmi.sh/react/api/hooks/useAccount */\nexport function useAccount<config extends Config = ResolvedRegister['config']>(\n parameters: UseAccountParameters<config> = {},\n): UseAccountReturnType<config> {\n const config = useConfig(parameters)\n\n return useSyncExternalStoreWithTracked(\n (onChange) => watchAccount(config, { onChange }),\n () => getAccount(config),\n )\n}\n", "'use client'\n\nimport { type GetAccountReturnType, watchAccount } from '@wagmi/core'\nimport type { Compute } from '@wagmi/core/internal'\nimport { useEffect } from 'react'\n\nimport type { ConfigParameter } from '../types/properties.js'\nimport { useConfig } from './useConfig.js'\n\nexport type UseAccountEffectParameters = Compute<\n {\n onConnect?(\n data: Compute<\n Pick<\n Extract<GetAccountReturnType, { status: 'connected' }>,\n 'address' | 'addresses' | 'chain' | 'chainId' | 'connector'\n > & {\n isReconnected: boolean\n }\n >,\n ): void\n onDisconnect?(): void\n } & ConfigParameter\n>\n\n/** https://wagmi.sh/react/api/hooks/useAccountEffect */\nexport function useAccountEffect(parameters: UseAccountEffectParameters = {}) {\n const { onConnect, onDisconnect } = parameters\n\n const config = useConfig(parameters)\n\n useEffect(() => {\n return watchAccount(config, {\n onChange(data, prevData) {\n if (\n (prevData.status === 'reconnecting' ||\n (prevData.status === 'connecting' &&\n prevData.address === undefined)) &&\n data.status === 'connected'\n ) {\n const { address, addresses, chain, chainId, connector } = data\n const isReconnected =\n prevData.status === 'reconnecting' ||\n // if `previousAccount.status` is `undefined`, the connector connected immediately.\n prevData.status === undefined\n onConnect?.({\n address,\n addresses,\n chain,\n chainId,\n connector,\n isReconnected,\n })\n } else if (\n prevData.status === 'connected' &&\n data.status === 'disconnected'\n )\n onDisconnect?.()\n },\n })\n }, [config, onConnect, onDisconnect])\n}\n", "export class Subscribable<TListener extends Function> {\n protected listeners = new Set<TListener>()\n\n constructor() {\n this.subscribe = this.subscribe.bind(this)\n }\n\n subscribe(listener: TListener): () => void {\n this.listeners.add(listener)\n\n this.onSubscribe()\n\n return () => {\n this.listeners.delete(listener)\n this.onUnsubscribe()\n }\n }\n\n hasListeners(): boolean {\n return this.listeners.size > 0\n }\n\n protected onSubscribe(): void {\n // Do nothing\n }\n\n protected onUnsubscribe(): void {\n // Do nothing\n }\n}\n", "import type {\n DefaultError,\n Enabled,\n FetchStatus,\n MutationKey,\n MutationStatus,\n QueryFunction,\n QueryKey,\n QueryOptions,\n StaleTime,\n} from './types'\nimport type { Mutation } from './mutation'\nimport type { FetchOptions, Query } from './query'\n\n// TYPES\n\nexport interface QueryFilters<\n TQueryFnData = unknown,\n TError = DefaultError,\n TData = TQueryFnData,\n TQueryKey extends QueryKey = QueryKey,\n> {\n /**\n * Filter to active queries, inactive queries or all queries\n */\n type?: QueryTypeFilter\n /**\n * Match query key exactly\n */\n exact?: boolean\n /**\n * Include queries matching this predicate function\n */\n predicate?: (query: Query<TQueryFnData, TError, TData, TQueryKey>) => boolean\n /**\n * Include queries matching this query key\n */\n queryKey?: TQueryKey\n /**\n * Include or exclude stale queries\n */\n stale?: boolean\n /**\n * Include queries matching their fetchStatus\n */\n fetchStatus?: FetchStatus\n}\n\nexport interface MutationFilters<\n TData = unknown,\n TError = DefaultError,\n TVariables = unknown,\n TContext = unknown,\n> {\n /**\n * Match mutation key exactly\n */\n exact?: boolean\n /**\n * Include mutations matching this predicate function\n */\n predicate?: (\n mutation: Mutation<TData, TError, TVariables, TContext>,\n ) => boolean\n /**\n * Include mutations matching this mutation key\n */\n mutationKey?: MutationKey\n /**\n * Filter by mutation status\n */\n status?: MutationStatus\n}\n\nexport type Updater<TInput, TOutput> = TOutput | ((input: TInput) => TOutput)\n\nexport type QueryTypeFilter = 'all' | 'active' | 'inactive'\n\n// UTILS\n\nexport const isServer = typeof window === 'undefined' || 'Deno' in globalThis\n\nexport function noop(): void\nexport function noop(): undefined\nexport function noop() {}\n\nexport function functionalUpdate<TInput, TOutput>(\n updater: Updater<TInput, TOutput>,\n input: TInput,\n): TOutput {\n return typeof updater === 'function'\n ? (updater as (_: TInput) => TOutput)(input)\n : updater\n}\n\nexport function isValidTimeout(value: unknown): value is number {\n return typeof value === 'number' && value >= 0 && value !== Infinity\n}\n\nexport function timeUntilStale(updatedAt: number, staleTime?: number): number {\n return Math.max(updatedAt + (staleTime || 0) - Date.now(), 0)\n}\n\nexport function resolveStaleTime<\n TQueryFnData = unknown,\n TError = DefaultError,\n TData = TQueryFnData,\n TQueryKey extends QueryKey = QueryKey,\n>(\n staleTime: undefined | StaleTime<TQueryFnData, TError, TData, TQueryKey>,\n query: Query<TQueryFnData, TError, TData, TQueryKey>,\n): number | undefined {\n return typeof staleTime === 'function' ? staleTime(query) : staleTime\n}\n\nexport function resolveEnabled<\n TQueryFnData = unknown,\n TError = DefaultError,\n TData = TQueryFnData,\n TQueryKey extends QueryKey = QueryKey,\n>(\n enabled: undefined | Enabled<TQueryFnData, TError, TData, TQueryKey>,\n query: Query<TQueryFnData, TError, TData, TQueryKey>,\n): boolean | undefined {\n return typeof enabled === 'function' ? enabled(query) : enabled\n}\n\nexport function matchQuery(\n filters: QueryFilters,\n query: Query<any, any, any, any>,\n): boolean {\n const {\n type = 'all',\n exact,\n fetchStatus,\n predicate,\n queryKey,\n stale,\n } = filters\n\n if (queryKey) {\n if (exact) {\n if (query.queryHash !== hashQueryKeyByOptions(queryKey, query.options)) {\n return false\n }\n } else if (!partialMatchKey(query.queryKey, queryKey)) {\n return false\n }\n }\n\n if (type !== 'all') {\n const isActive = query.isActive()\n if (type === 'active' && !isActive) {\n return false\n }\n if (type === 'inactive' && isActive) {\n return false\n }\n }\n\n if (typeof stale === 'boolean' && query.isStale() !== stale) {\n return false\n }\n\n if (fetchStatus && fetchStatus !== query.state.fetchStatus) {\n return false\n }\n\n if (predicate && !predicate(query)) {\n return false\n }\n\n return true\n}\n\nexport function matchMutation(\n filters: MutationFilters,\n mutation: Mutation<any, any>,\n): boolean {\n const { exact, status, predicate, mutationKey } = filters\n if (mutationKey) {\n if (!mutation.options.mutationKey) {\n return false\n }\n if (exact) {\n if (hashKey(mutation.options.mutationKey) !== hashKey(mutationKey)) {\n return false\n }\n } else if (!partialMatchKey(mutation.options.mutationKey, mutationKey)) {\n return false\n }\n }\n\n if (status && mutation.state.status !== status) {\n return false\n }\n\n if (predicate && !predicate(mutation)) {\n return false\n }\n\n return true\n}\n\nexport function hashQueryKeyByOptions<TQueryKey extends QueryKey = QueryKey>(\n queryKey: TQueryKey,\n options?: Pick<QueryOptions<any, any, any, any>, 'queryKeyHashFn'>,\n): string {\n const hashFn = options?.queryKeyHashFn || hashKey\n return hashFn(queryKey)\n}\n\n/**\n * Default query & mutation keys hash function.\n * Hashes the value into a stable hash.\n */\nexport function hashKey(queryKey: QueryKey | MutationKey): string {\n return JSON.stringify(queryKey, (_, val) =>\n isPlainObject(val)\n ? Object.keys(val)\n .sort()\n .reduce((result, key) => {\n result[key] = val[key]\n return result\n }, {} as any)\n : val,\n )\n}\n\n/**\n * Checks if key `b` partially matches with key `a`.\n */\nexport function partialMatchKey(a: QueryKey, b: QueryKey): boolean\nexport function partialMatchKey(a: any, b: any): boolean {\n if (a === b) {\n return true\n }\n\n if (typeof a !== typeof b) {\n return false\n }\n\n if (a && b && typeof a === 'object' && typeof b === 'object') {\n return !Object.keys(b).some((key) => !partialMatchKey(a[key], b[key]))\n }\n\n return false\n}\n\n/**\n * This function returns `a` if `b` is deeply equal.\n * If not, it will replace any deeply equal children of `b` with those of `a`.\n * This can be used for structural sharing between JSON values for example.\n */\nexport function replaceEqualDeep<T>(a: unknown, b: T): T\nexport function replaceEqualDeep(a: any, b: any): any {\n if (a === b) {\n return a\n }\n\n const array = isPlainArray(a) && isPlainArray(b)\n\n if (array || (isPlainObject(a) && isPlainObject(b))) {\n const aItems = array ? a : Object.keys(a)\n const aSize = aItems.length\n const bItems = array ? b : Object.keys(b)\n const bSize = bItems.length\n const copy: any = array ? [] : {}\n\n let equalItems = 0\n\n for (let i = 0; i < bSize; i++) {\n const key = array ? i : bItems[i]\n if (\n ((!array && aItems.includes(key)) || array) &&\n a[key] === undefined &&\n b[key] === undefined\n ) {\n copy[key] = undefined\n equalItems++\n } else {\n copy[key] = replaceEqualDeep(a[key], b[key])\n if (copy[key] === a[key] && a[key] !== undefined) {\n equalItems++\n }\n }\n }\n\n return aSize === bSize && equalItems === aSize ? a : copy\n }\n\n return b\n}\n\n/**\n * Shallow compare objects.\n */\nexport function shallowEqualObjects<T extends Record<string, any>>(\n a: T,\n b: T | undefined,\n): boolean {\n if (!b || Object.keys(a).length !== Object.keys(b).length) {\n return false\n }\n\n for (const key in a) {\n if (a[key] !== b[key]) {\n return false\n }\n }\n\n return true\n}\n\nexport function isPlainArray(value: unknown) {\n return Array.isArray(value) && value.length === Object.keys(value).length\n}\n\n// Copied from: https://github.com/jonschlinkert/is-plain-object\n// eslint-disable-next-line @typescript-eslint/no-wrapper-object-types\nexport function isPlainObject(o: any): o is Object {\n if (!hasObjectPrototype(o)) {\n return false\n }\n\n // If has no constructor\n const ctor = o.constructor\n if (ctor === undefined) {\n return true\n }\n\n // If has modified prototype\n const prot = ctor.prototype\n if (!hasObjectPrototype(prot)) {\n return false\n }\n\n // If constructor does not have an Object-specific method\n if (!prot.hasOwnProperty('isPrototypeOf')) {\n return false\n }\n\n // Handles Objects created by Object.create(<arbitrary prototype>)\n if (Object.getPrototypeOf(o) !== Object.prototype) {\n return false\n }\n\n // Most likely a plain Object\n return true\n}\n\nfunction hasObjectPrototype(o: any): boolean {\n return Object.prototype.toString.call(o) === '[object Object]'\n}\n\nexport function sleep(timeout: number): Promise<void> {\n return new Promise((resolve) => {\n setTimeout(resolve, timeout)\n })\n}\n\nexport function replaceData<\n TData,\n TOptions extends QueryOptions<any, any, any, any>,\n>(prevData: TData | undefined, data: TData, options: TOptions): TData {\n if (typeof options.structuralSharing === 'function') {\n return options.structuralSharing(prevData, data) as TData\n } else if (options.structuralSharing !== false) {\n if (process.env.NODE_ENV !== 'production') {\n try {\n return replaceEqualDeep(prevData, data)\n } catch (error) {\n console.error(\n `Structural sharing requires data to be JSON serializable. To fix this, turn off structuralSharing or return JSON-serializable data from your queryFn. [${options.queryHash}]: ${error}`,\n )\n }\n }\n // Structurally share data between prev and new data if needed\n return replaceEqualDeep(prevData, data)\n }\n return data\n}\n\nexport function keepPreviousData<T>(\n previousData: T | undefined,\n): T | undefined {\n return previousData\n}\n\nexport function addToEnd<T>(items: Array<T>, item: T, max = 0): Array<T> {\n const newItems = [...items, item]\n return max && newItems.length > max ? newItems.slice(1) : newItems\n}\n\nexport function addToStart<T>(items: Array<T>, item: T, max = 0): Array<T> {\n const newItems = [item, ...items]\n return max && newItems.length > max ? newItems.slice(0, -1) : newItems\n}\n\nexport const skipToken = Symbol()\nexport type SkipToken = typeof skipToken\n\nexport function ensureQueryFn<\n TQueryFnData = unknown,\n TQueryKey extends QueryKey = QueryKey,\n>(\n options: {\n queryFn?: QueryFunction<TQueryFnData, TQueryKey> | SkipToken\n queryHash?: string\n },\n fetchOptions?: FetchOptions<TQueryFnData>,\n): QueryFunction<TQueryFnData, TQueryKey> {\n if (process.env.NODE_ENV !== 'production') {\n if (options.queryFn === skipToken) {\n console.error(\n `Attempted to invoke queryFn when set to skipToken. This is likely a configuration error. Query hash: '${options.queryHash}'`,\n )\n }\n }\n\n // if we attempt to retry a fetch that was triggered from an initialPromise\n // when we don't have a queryFn yet, we can't retry, so we just return the already rejected initialPromise\n // if an observer has already mounted, we will be able to retry with that queryFn\n if (!options.queryFn && fetchOptions?.initialPromise) {\n return () => fetchOptions.initialPromise!\n }\n\n if (!options.queryFn || options.queryFn === skipToken) {\n return () =>\n Promise.reject(new Error(`Missing queryFn: '${options.queryHash}'`))\n }\n\n return options.queryFn\n}\n", "import { Subscribable } from './subscribable'\nimport { isServer } from './utils'\n\ntype Listener = (focused: boolean) => void\n\ntype SetupFn = (\n setFocused: (focused?: boolean) => void,\n) => (() => void) | undefined\n\nexport class FocusManager extends Subscribable<Listener> {\n #focused?: boolean\n #cleanup?: () => void\n\n #setup: SetupFn\n\n constructor() {\n super()\n this.#setup = (onFocus) => {\n // addEventListener does not exist in React Native, but window does\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition\n if (!isServer && window.addEventListener) {\n const listener = () => onFocus()\n // Listen to visibilitychange\n window.addEventListener('visibilitychange', listener, false)\n\n return () => {\n // Be sure to unsubscribe if a new handler is set\n window.removeEventListener('visibilitychange', listener)\n }\n }\n return\n }\n }\n\n protected onSubscribe(): void {\n if (!this.#cleanup) {\n this.setEventListener(this.#setup)\n }\n }\n\n protected onUnsubscribe() {\n if (!this.hasListeners()) {\n this.#cleanup?.()\n this.#cleanup = undefined\n }\n }\n\n setEventListener(setup: SetupFn): void {\n this.#setup = setup\n this.#cleanup?.()\n this.#cleanup = setup((focused) => {\n if (typeof focused === 'boolean') {\n this.setFocused(focused)\n } else {\n this.onFocus()\n }\n })\n }\n\n setFocused(focused?: boolean): void {\n const changed = this.#focused !== focused\n if (changed) {\n this.#focused = focused\n this.onFocus()\n }\n }\n\n onFocus(): void {\n const isFocused = this.isFocused()\n this.listeners.forEach((listener) => {\n listener(isFocused)\n })\n }\n\n isFocused(): boolean {\n if (typeof this.#focused === 'boolean') {\n return this.#focused\n }\n\n // document global can be unavailable in react native\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition\n return globalThis.document?.visibilityState !== 'hidden'\n }\n}\n\nexport const focusManager = new FocusManager()\n", "import { Subscribable } from './subscribable'\nimport { isServer } from './utils'\n\ntype Listener = (online: boolean) => void\ntype SetupFn = (setOnline: Listener) => (() => void) | undefined\n\nexport class OnlineManager extends Subscribable<Listener> {\n #online = true\n #cleanup?: () => void\n\n #setup: SetupFn\n\n constructor() {\n super()\n this.#setup = (onOnline) => {\n // addEventListener does not exist in React Native, but window does\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition\n if (!isServer && window.addEventListener) {\n const onlineListener = () => onOnline(true)\n const offlineListener = () => onOnline(false)\n // Listen to online\n window.addEventListener('online', onlineListener, false)\n window.addEventListener('offline', offlineListener, false)\n\n return () => {\n // Be sure to unsubscribe if a new handler is set\n window.removeEventListener('online', onlineListener)\n window.removeEventListener('offline', offlineListener)\n }\n }\n\n return\n }\n }\n\n protected onSubscribe(): void {\n if (!this.#cleanup) {\n this.setEventListener(this.#setup)\n }\n }\n\n protected onUnsubscribe() {\n if (!this.hasListeners()) {\n this.#cleanup?.()\n this.#cleanup = undefined\n }\n }\n\n setEventListener(setup: SetupFn): void {\n this.#setup = setup\n this.#cleanup?.()\n this.#cleanup = setup(this.setOnline.bind(this))\n }\n\n setOnline(online: boolean): void {\n const changed = this.#online !== online\n\n if (changed) {\n this.#online = online\n this.listeners.forEach((listener) => {\n listener(online)\n })\n }\n }\n\n isOnline(): boolean {\n return this.#online\n }\n}\n\nexport const onlineManager = new OnlineManager()\n", "// TYPES\n\ntype NotifyCallback = () => void\n\ntype NotifyFunction = (callback: () => void) => void\n\ntype BatchNotifyFunction = (callback: () => void) => void\n\ntype BatchCallsCallback<T extends Array<unknown>> = (...args: T) => void\n\ntype ScheduleFunction = (callback: () => void) => void\n\nexport function createNotifyManager() {\n let queue: Array<NotifyCallback> = []\n let transactions = 0\n let notifyFn: NotifyFunction = (callback) => {\n callback()\n }\n let batchNotifyFn: BatchNotifyFunction = (callback: () => void) => {\n callback()\n }\n let scheduleFn: ScheduleFunction = (cb) => setTimeout(cb, 0)\n\n const schedule = (callback: NotifyCallback): void => {\n if (transactions) {\n queue.push(callback)\n } else {\n scheduleFn(() => {\n notifyFn(callback)\n })\n }\n }\n const flush = (): void => {\n const originalQueue = queue\n queue = []\n if (originalQueue.length) {\n scheduleFn(() => {\n batchNotifyFn(() => {\n originalQueue.forEach((callback) => {\n notifyFn(callback)\n })\n })\n })\n }\n }\n\n return {\n batch: <T>(callback: () => T): T => {\n let result\n transactions++\n try {\n result = callback()\n } finally {\n transactions--\n if (!transactions) {\n flush()\n }\n }\n return result\n },\n /**\n * All calls to the wrapped function will be batched.\n */\n batchCalls: <T extends Array<unknown>>(\n callback: BatchCallsCallback<T>,\n ): BatchCallsCallback<T> => {\n return (...args) => {\n schedule(() => {\n callback(...args)\n })\n }\n },\n schedule,\n /**\n * Use this method to set a custom notify function.\n * This can be used to for example wrap notifications with `React.act` while running tests.\n */\n setNotifyFunction: (fn: NotifyFunction) => {\n notifyFn = fn\n },\n /**\n * Use this method to set a custom function to batch notifications together into a single tick.\n * By default React Query will use the batch function provided by ReactDOM or React Native.\n */\n setBatchNotifyFunction: (fn: BatchNotifyFunction) => {\n batchNotifyFn = fn\n },\n setScheduler: (fn: ScheduleFunction) => {\n scheduleFn = fn\n },\n } as const\n}\n\n// SINGLETON\nexport const notifyManager = createNotifyManager()\n", "/* istanbul ignore file */\n\nimport type { QueryClient } from './queryClient'\nimport type { DehydrateOptions, HydrateOptions } from './hydration'\nimport type { MutationState } from './mutation'\nimport type { FetchDirection, Query, QueryBehavior } from './query'\nimport type { RetryDelayValue, RetryValue } from './retryer'\nimport type { QueryFilters, QueryTypeFilter, SkipToken } from './utils'\nimport type { QueryCache } from './queryCache'\nimport type { MutationCache } from './mutationCache'\n\nexport type OmitKeyof<\n TObject,\n TKey extends TStrictly extends 'safely'\n ?\n | keyof TObject\n | (string & Record<never, never>)\n | (number & Record<never, never>)\n | (symbol & Record<never, never>)\n : keyof TObject,\n TStrictly extends 'strictly' | 'safely' = 'strictly',\n> = Omit<TObject, TKey>\n\nexport type Override<TTargetA, TTargetB> = {\n [AKey in keyof TTargetA]: AKey extends keyof TTargetB\n ? TTargetB[AKey]\n : TTargetA[AKey]\n}\n\nexport type NoInfer<T> = [T][T extends any ? 0 : never]\n\nexport interface Register {\n // defaultError: Error\n // queryMeta: Record<string, unknown>\n // mutationMeta: Record<string, unknown>\n // queryKey: ReadonlyArray<unknown>\n // mutationKey: ReadonlyArray<unknown>\n}\n\nexport type DefaultError = Register extends {\n defaultError: infer TError\n}\n ? TError\n : Error\n\nexport type QueryKey = Register extends {\n queryKey: infer TQueryKey\n}\n ? TQueryKey extends ReadonlyArray<unknown>\n ? TQueryKey\n : TQueryKey extends Array<unknown>\n ? TQueryKey\n : ReadonlyArray<unknown>\n : ReadonlyArray<unknown>\n\nexport const dataTagSymbol = Symbol('dataTagSymbol')\nexport type dataTagSymbol = typeof dataTagSymbol\nexport const dataTagErrorSymbol = Symbol('dataTagErrorSymbol')\nexport type dataTagErrorSymbol = typeof dataTagErrorSymbol\nexport const unsetMarker = Symbol('unsetMarker')\nexport type UnsetMarker = typeof unsetMarker\nexport type AnyDataTag = {\n [dataTagSymbol]: any\n [dataTagErrorSymbol]: any\n}\nexport type DataTag<\n TType,\n TValue,\n TError = UnsetMarker,\n> = TType extends AnyDataTag\n ? TType\n : TType & {\n [dataTagSymbol]: TValue\n [dataTagErrorSymbol]: TError\n }\n\nexport type QueryFunction<\n T = unknown,\n TQueryKey extends QueryKey = QueryKey,\n TPageParam = never,\n> = (context: QueryFunctionContext<TQueryKey, TPageParam>) => T | Promise<T>\n\nexport type StaleTime<\n TQueryFnData = unknown,\n TError = DefaultError,\n TData = TQueryFnData,\n TQueryKey extends QueryKey = QueryKey,\n> = number | ((query: Query<TQueryFnData, TError, TData, TQueryKey>) => number)\n\nexport type Enabled<\n TQueryFnData = unknown,\n TError = DefaultError,\n TData = TQueryFnData,\n TQueryKey extends QueryKey = QueryKey,\n> =\n | boolean\n | ((query: Query<TQueryFnData, TError, TData, TQueryKey>) => boolean)\n\nexport type QueryPersister<\n T = unknown,\n TQueryKey extends QueryKey = QueryKey,\n TPageParam = never,\n> = [TPageParam] extends [never]\n ? (\n queryFn: QueryFunction<T, TQueryKey, never>,\n context: QueryFunctionContext<TQueryKey>,\n query: Query,\n ) => T | Promise<T>\n : (\n queryFn: QueryFunction<T, TQueryKey, TPageParam>,\n context: QueryFunctionContext<TQueryKey>,\n query: Query,\n ) => T | Promise<T>\n\nexport type QueryFunctionContext<\n TQueryKey extends QueryKey = QueryKey,\n TPageParam = never,\n> = [TPageParam] extends [never]\n ? {\n client: QueryClient\n queryKey: TQueryKey\n signal: AbortSignal\n meta: QueryMeta | undefined\n pageParam?: unknown\n /**\n * @deprecated\n * if you want access to the direction, you can add it to the pageParam\n */\n direction?: unknown\n }\n : {\n client: QueryClient\n queryKey: TQueryKey\n signal: AbortSignal\n pageParam: TPageParam\n /**\n * @deprecated\n * if you want access to the direction, you can add it to the pageParam\n */\n direction: FetchDirection\n meta: QueryMeta | undefined\n }\n\nexport type InitialDataFunction<T> = () => T | undefined\n\ntype NonFunctionGuard<T> = T extends Function ? never : T\n\nexport type PlaceholderDataFunction<\n TQueryFnData = unknown,\n TError = DefaultError,\n TQueryData = TQueryFnData,\n TQueryKey extends QueryKey = QueryKey,\n> = (\n previousData: TQueryData | undefined,\n previousQuery: Query<TQueryFnData, TError, TQueryData, TQueryKey> | undefined,\n) => TQueryData | undefined\n\nexport type QueriesPlaceholderDataFunction<TQueryData> = (\n previousData: undefined,\n previousQuery: undefined,\n) => TQueryData | undefined\n\nexport type QueryKeyHashFunction<TQueryKey extends QueryKey> = (\n queryKey: TQueryKey,\n) => string\n\nexport type GetPreviousPageParamFunction<TPageParam, TQueryFnData = unknown> = (\n firstPage: TQueryFnData,\n allPages: Array<TQueryFnData>,\n firstPageParam: TPageParam,\n allPageParams: Array<TPageParam>,\n) => TPageParam | undefined | null\n\nexport type GetNextPageParamFunction<TPageParam, TQueryFnData = unknown> = (\n lastPage: TQueryFnData,\n allPages: Array<TQueryFnData>,\n lastPageParam: TPageParam,\n allPageParams: Array<TPageParam>,\n) => TPageParam | undefined | null\n\nexport interface InfiniteData<TData, TPageParam = unknown> {\n pages: Array<TData>\n pageParams: Array<TPageParam>\n}\n\nexport type QueryMeta = Register extends {\n queryMeta: infer TQueryMeta\n}\n ? TQueryMeta extends Record<string, unknown>\n ? TQueryMeta\n : Record<string, unknown>\n : Record<string, unknown>\n\nexport type NetworkMode = 'online' | 'always' | 'offlineFirst'\n\nexport type NotifyOnChangeProps =\n | Array<keyof InfiniteQueryObserverResult>\n | 'all'\n | undefined\n | (() => Array<keyof InfiniteQueryObserverResult> | 'all' | undefined)\n\nexport interface QueryOptions<\n TQueryFnData = unknown,\n TError = DefaultError,\n TData = TQueryFnData,\n TQueryKey extends QueryKey = QueryKey,\n TPageParam = never,\n> {\n /**\n * If `false`, failed queries will not retry by default.\n * If `true`, failed queries will retry infinitely., failureCount: num\n * If set to an integer number, e.g. 3, failed queries will retry until the failed query count meets that number.\n * If set to a function `(failureCount, error) => boolean` failed queries will retry until the function returns false.\n */\n retry?: RetryValue<TError>\n retryDelay?: RetryDelayValue<TError>\n networkMode?: NetworkMode\n /**\n * The time in milliseconds that unused/inactive cache data remains in memory.\n * When a query's cache becomes unused or inactive, that cache data will be garbage collected after this duration.\n * When different garbage collection times are specified, the longest one will be used.\n * Setting it to `Infinity` will disable garbage collection.\n */\n gcTime?: number\n queryFn?: QueryFunction<TQueryFnData, TQueryKey, TPageParam> | SkipToken\n persister?: QueryPersister<\n NoInfer<TQueryFnData>,\n NoInfer<TQueryKey>,\n NoInfer<TPageParam>\n >\n queryHash?: string\n queryKey?: TQueryKey\n queryKeyHashFn?: QueryKeyHashFunction<TQueryKey>\n initialData?: TData | InitialDataFunction<TData>\n initialDataUpdatedAt?: number | (() => number | undefined)\n behavior?: QueryBehavior<TQueryFnData, TError, TData, TQueryKey>\n /**\n * Set this to `false` to disable structural sharing between query results.\n * Set this to a function which accepts the old and new data and returns resolved data of the same type to implement custom structural sharing logic.\n * Defaults to `true`.\n */\n structuralSharing?:\n | boolean\n | ((oldData: unknown | undefined, newData: unknown) => unknown)\n _defaulted?: boolean\n /**\n * Additional payload to be stored on each query.\n * Use this property to pass information that can be used in other places.\n */\n meta?: QueryMeta\n /**\n * Maximum number of pages to store in the data of an infinite query.\n */\n maxPages?: number\n}\n\nexport interface InitialPageParam<TPageParam = unknown> {\n initialPageParam: TPageParam\n}\n\nexport interface InfiniteQueryPageParamsOptions<\n TQueryFnData = unknown,\n TPageParam = unknown,\n> extends InitialPageParam<TPageParam> {\n /**\n * This function can be set to automatically get the previous cursor for infinite queries.\n * The result will also be used to determine the value of `hasPreviousPage`.\n */\n getPreviousPageParam?: GetPreviousPageParamFunction<TPageParam, TQueryFnData>\n /**\n * This function can be set to automatically get the next cursor for infinite queries.\n * The result will also be used to determine the value of `hasNextPage`.\n */\n getNextPageParam: GetNextPageParamFunction<TPageParam, TQueryFnData>\n}\n\nexport type ThrowOnError<\n TQueryFnData,\n TError,\n TQueryData,\n TQueryKey extends QueryKey,\n> =\n | boolean\n | ((\n error: TError,\n query: Query<TQueryFnData, TError, TQueryData, TQueryKey>,\n ) => boolean)\n\nexport interface QueryObserverOptions<\n TQueryFnData = unknown,\n TError = DefaultError,\n TData = TQueryFnData,\n TQueryData = TQueryFnData,\n TQueryKey extends QueryKey = QueryKey,\n TPageParam = never,\n> extends WithRequired<\n QueryOptions<TQueryFnData, TError, TQueryData, TQueryKey, TPageParam>,\n 'queryKey'\n > {\n /**\n * Set this to `false` or a function that returns `false` to disable automatic refetching when the query mounts or changes query keys.\n * To refetch the query, use the `refetch` method returned from the `useQuery` instance.\n * Accepts a boolean or function that returns a boolean.\n * Defaults to `true`.\n */\n enabled?: Enabled<TQueryFnData, TError, TQueryData, TQueryKey>\n /**\n * The time in milliseconds after data is considered stale.\n * If set to `Infinity`, the data will never be considered stale.\n * If set to a function, the function will be executed with the query to compute a `staleTime`.\n * Defaults to `0`.\n */\n staleTime?: StaleTime<TQueryFnData, TError, TQueryData, TQueryKey>\n /**\n * If set to a number, the query will continuously refetch at this frequency in milliseconds.\n * If set to a function, the function will be executed with the latest data and query to compute a frequency\n * Defaults to `false`.\n */\n refetchInterval?:\n | number\n | false\n | ((\n query: Query<TQueryFnData, TError, TQueryData, TQueryKey>,\n ) => number | false | undefined)\n /**\n * If set to `true`, the query will continue to refetch while their tab/window is in the background.\n * Defaults to `false`.\n */\n refetchIntervalInBackground?: boolean\n /**\n * If set to `true`, the query will refetch on window focus if the data is stale.\n * If set to `false`, the query will not refetch on window focus.\n * If set to `'always'`, the query will always refetch on window focus.\n * If set to a function, the function will be executed with the latest data and query to compute the value.\n * Defaults to `true`.\n */\n refetchOnWindowFocus?:\n | boolean\n | 'always'\n | ((\n query: Query<TQueryFnData, TError, TQueryData, TQueryKey>,\n ) => boolean | 'always')\n /**\n * If set to `true`, the query will refetch on reconnect if the data is stale.\n * If set to `false`, the query will not refetch on reconnect.\n * If set to `'always'`, the query will always refetch on reconnect.\n * If set to a function, the function will be executed with the latest data and query to compute the value.\n * Defaults to the value of `networkOnline` (`true`)\n */\n refetchOnReconnect?:\n | boolean\n | 'always'\n | ((\n query: Query<TQueryFnData, TError, TQueryData, TQueryKey>,\n ) => boolean | 'always')\n /**\n * If set to `true`, the query will refetch on mount if the data is stale.\n * If set to `false`, will disable additional instances of a query to trigger background refetch.\n * If set to `'always'`, the query will always refetch on mount.\n * If set to a function, the function will be executed with the latest data and query to compute the value\n * Defaults to `true`.\n */\n refetchOnMount?:\n | boolean\n | 'always'\n | ((\n query: Query<TQueryFnData, TError, TQueryData, TQueryKey>,\n ) => boolean | 'always')\n /**\n * If set to `false`, the query will not be retried on mount if it contains an error.\n * Defaults to `true`.\n */\n retryOnMount?: boolean\n /**\n * If set, the component will only re-render if any of the listed properties change.\n * When set to `['data', 'error']`, the component will only re-render when the `data` or `error` properties change.\n * When set to `'all'`, the component will re-render whenever a query is updated.\n * When set to a function, the function will be executed to compute the list of properties.\n * By default, access to properties will be tracked, and the component will only re-render when one of the tracked properties change.\n */\n notifyOnChangeProps?: NotifyOnChangeProps\n /**\n * Whether errors should be thrown instead of setting the `error` property.\n * If set to `true` or `suspense` is `true`, all errors will be thrown to the error boundary.\n * If set to `false` and `suspense` is `false`, errors are returned as state.\n * If set to a function, it will be passed the error and the query, and it should return a boolean indicating whether to show the error in an error boundary (`true`) or return the error as state (`false`).\n * Defaults to `false`.\n */\n throwOnError?: ThrowOnError<TQueryFnData, TError, TQueryData, TQueryKey>\n /**\n * This option can be used to transform or select a part of the data returned by the query function.\n */\n select?: (data: TQueryData) => TData\n /**\n * If set to `true`, the query will suspend when `status === 'pending'`\n * and throw errors when `status === 'error'`.\n * Defaults to `false`.\n */\n suspense?: boolean\n /**\n * If set, this value will be used as the placeholder data for this particular query observer while the query is still in the `loading` data and no initialData has been provided.\n */\n placeholderData?:\n | NonFunctionGuard<TQueryData>\n | PlaceholderDataFunction<\n NonFunctionGuard<TQueryData>,\n TError,\n NonFunctionGuard<TQueryData>,\n TQueryKey\n >\n\n _optimisticResults?: 'optimistic' | 'isRestoring'\n\n /**\n * Enable prefetching during rendering\n */\n experimental_prefetchInRender?: boolean\n}\n\nexport type WithRequired<TTarget, TKey extends keyof TTarget> = TTarget & {\n [_ in TKey]: {}\n}\nexport type Optional<TTarget, TKey extends keyof TTarget> = Pick<\n Partial<TTarget>,\n TKey\n> &\n OmitKeyof<TTarget, TKey>\n\nexport type DefaultedQueryObserverOptions<\n TQueryFnData = unknown,\n TError = DefaultError,\n TData = TQueryFnData,\n TQueryData = TQueryFnData,\n TQueryKey extends QueryKey = QueryKey,\n> = WithRequired<\n QueryObserverOptions<TQueryFnData, TError, TData, TQueryData, TQueryKey>,\n 'throwOnError' | 'refetchOnReconnect' | 'queryHash'\n>\n\nexport interface InfiniteQueryObserverOptions<\n TQueryFnData = unknown,\n TError = DefaultError,\n TData = TQueryFnData,\n TQueryData = TQueryFnData,\n TQueryKey extends QueryKey = QueryKey,\n TPageParam = unknown,\n> extends QueryObserverOptions<\n TQueryFnData,\n TError,\n TData,\n InfiniteData<TQueryData, TPageParam>,\n TQueryKey,\n TPageParam\n >,\n InfiniteQueryPageParamsOptions<TQueryFnData, TPageParam> {}\n\nexport type DefaultedInfiniteQueryObserverOptions<\n TQueryFnData = unknown,\n TError = DefaultError,\n TData = TQueryFnData,\n TQueryData = TQueryFnData,\n TQueryKey extends QueryKey = QueryKey,\n TPageParam = unknown,\n> = WithRequired<\n InfiniteQueryObserverOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryData,\n TQueryKey,\n TPageParam\n >,\n 'throwOnError' | 'refetchOnReconnect' | 'queryHash'\n>\n\nexport interface FetchQueryOptions<\n TQueryFnData = unknown,\n TError = DefaultError,\n TData = TQueryFnData,\n TQueryKey extends QueryKey = QueryKey,\n TPageParam = never,\n> extends WithRequired<\n QueryOptions<TQueryFnData, TError, TData, TQueryKey, TPageParam>,\n 'queryKey'\n > {\n initialPageParam?: never\n /**\n * The time in milliseconds after data is considered stale.\n * If the data is fresh it will be returned from the cache.\n */\n staleTime?: StaleTime<TQueryFnData, TError, TData, TQueryKey>\n}\n\nexport interface EnsureQueryDataOptions<\n TQueryFnData = unknown,\n TError = DefaultError,\n TData = TQueryFnData,\n TQueryKey extends QueryKey = QueryKey,\n TPageParam = never,\n> extends FetchQueryOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryKey,\n TPageParam\n > {\n revalidateIfStale?: boolean\n}\n\nexport type EnsureInfiniteQueryDataOptions<\n TQueryFnData = unknown,\n TError = DefaultError,\n TData = TQueryFnData,\n TQueryKey extends QueryKey = QueryKey,\n TPageParam = unknown,\n> = FetchInfiniteQueryOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryKey,\n TPageParam\n> & {\n revalidateIfStale?: boolean\n}\n\ntype FetchInfiniteQueryPages<TQueryFnData = unknown, TPageParam = unknown> =\n | { pages?: never }\n | {\n pages: number\n getNextPageParam: GetNextPageParamFunction<TPageParam, TQueryFnData>\n }\n\nexport type FetchInfiniteQueryOptions<\n TQueryFnData = unknown,\n TError = DefaultError,\n TData = TQueryFnData,\n TQueryKey extends QueryKey = QueryKey,\n TPageParam = unknown,\n> = Omit<\n FetchQueryOptions<\n TQueryFnData,\n TError,\n InfiniteData<TData, TPageParam>,\n TQueryKey,\n TPageParam\n >,\n 'initialPageParam'\n> &\n InitialPageParam<TPageParam> &\n FetchInfiniteQueryPages<TQueryFnData, TPageParam>\n\nexport interface ResultOptions {\n throwOnError?: boolean\n}\n\nexport interface RefetchOptions extends ResultOptions {\n /**\n * If set to `true`, a currently running request will be cancelled before a new request is made\n *\n * If set to `false`, no refetch will be made if there is already a request running.\n *\n * Defaults to `true`.\n */\n cancelRefetch?: boolean\n}\n\nexport interface InvalidateQueryFilters<\n TQueryFnData = unknown,\n TError = DefaultError,\n TData = TQueryFnData,\n TQueryKey extends QueryKey = QueryKey,\n> extends QueryFilters<TQueryFnData, TError, TData, TQueryKey> {\n refetchType?: QueryTypeFilter | 'none'\n}\n\nexport interface RefetchQueryFilters<\n TQueryFnData = unknown,\n TError = DefaultError,\n TData = TQueryFnData,\n TQueryKey extends QueryKey = QueryKey,\n> extends QueryFilters<TQueryFnData, TError, TData, TQueryKey> {}\n\nexport interface InvalidateOptions extends RefetchOptions {}\nexport interface ResetOptions extends RefetchOptions {}\n\nexport interface FetchNextPageOptions extends ResultOptions {\n /**\n * If set to `true`, calling `fetchNextPage` repeatedly will invoke `queryFn` every time,\n * whether the previous invocation has resolved or not. Also, the result from previous invocations will be ignored.\n *\n * If set to `false`, calling `fetchNextPage` repeatedly won't have any effect until the first invocation has resolved.\n *\n * Defaults to `true`.\n */\n cancelRefetch?: boolean\n}\n\nexport interface FetchPreviousPageOptions extends ResultOptions {\n /**\n * If set to `true`, calling `fetchPreviousPage` repeatedly will invoke `queryFn` every time,\n * whether the previous invocation has resolved or not. Also, the result from previous invocations will be ignored.\n *\n * If set to `false`, calling `fetchPreviousPage` repeatedly won't have any effect until the first invocation has resolved.\n *\n * Defaults to `true`.\n */\n cancelRefetch?: boolean\n}\n\nexport type QueryStatus = 'pending' | 'error' | 'success'\nexport type FetchStatus = 'fetching' | 'paused' | 'idle'\n\nexport interface QueryObserverBaseResult<\n TData = unknown,\n TError = DefaultError,\n> {\n /**\n * The last successfully resolved data for the query.\n */\n data: TData | undefined\n /**\n * The timestamp for when the query most recently returned the `status` as `\"success\"`.\n */\n dataUpdatedAt: number\n /**\n * The error object for the query, if an error was thrown.\n * - Defaults to `null`.\n */\n error: TError | null\n /**\n * The timestamp for when the query most recently returned the `status` as `\"error\"`.\n */\n errorUpdatedAt: number\n /**\n * The failure count for the query.\n * - Incremented every time the query fails.\n * - Reset to `0` when the query succeeds.\n */\n failureCount: number\n /**\n * The failure reason for the query retry.\n * - Reset to `null` when the query succeeds.\n */\n failureReason: TError | null\n /**\n * The sum of all errors.\n */\n errorUpdateCount: number\n /**\n * A derived boolean from the `status` variable, provided for convenience.\n * - `true` if the query attempt resulted in an error.\n */\n isError: boolean\n /**\n * Will be `true` if the query has been fetched.\n */\n isFetched: boolean\n /**\n * Will be `true` if the query has been fetched after the component mounted.\n * - This property can be used to not show any previously cached data.\n */\n isFetchedAfterMount: boolean\n /**\n * A derived boolean from the `fetchStatus` variable, provided for convenience.\n * - `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch.\n */\n isFetching: boolean\n /**\n * Is `true` whenever the first fetch for a query is in-flight.\n * - Is the same as `isFetching && isPending`.\n */\n isLoading: boolean\n /**\n * Will be `pending` if there's no cached data and no query attempt was finished yet.\n */\n isPending: boolean\n /**\n * Will be `true` if the query failed while fetching for the first time.\n */\n isLoadingError: boolean\n /**\n * @deprecated `isInitialLoading` is being deprecated in favor of `isLoading`\n * and will be removed in the next major version.\n */\n isInitialLoading: boolean\n /**\n * A derived boolean from the `fetchStatus` variable, provided for convenience.\n * - The query wanted to fetch, but has been `paused`.\n */\n isPaused: boolean\n /**\n * Will be `true` if the data shown is the placeholder data.\n */\n isPlaceholderData: boolean\n /**\n * Will be `true` if the query failed while refetching.\n */\n isRefetchError: boolean\n /**\n * Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`.\n * - Is the same as `isFetching && !isPending`.\n */\n isRefetching: boolean\n /**\n * Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`.\n */\n isStale: boolean\n /**\n * A derived boolean from the `status` variable, provided for convenience.\n * - `true` if the query has received a response with no errors and is ready to display its data.\n */\n isSuccess: boolean\n /**\n * A function to manually refetch the query.\n */\n refetch: (\n options?: RefetchOptions,\n ) => Promise<QueryObserverResult<TData, TError>>\n /**\n * The status of the query.\n * - Will be:\n * - `pending` if there's no cached data and no query attempt was finished yet.\n * - `error` if the query attempt resulted in an error.\n * - `success` if the query has received a response with no errors and is ready to display its data.\n */\n status: QueryStatus\n /**\n * The fetch status of the query.\n * - `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch.\n * - `paused`: The query wanted to fetch, but has been `paused`.\n * - `idle`: The query is not fetching.\n * - See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information.\n */\n fetchStatus: FetchStatus\n /**\n * A stable promise that will be resolved with the data of the query.\n * Requires the `experimental_prefetchInRender` feature flag to be enabled.\n * @example\n *\n * ### Enabling the feature flag\n * ```ts\n * const client = new QueryClient({\n * defaultOptions: {\n * queries: {\n * experimental_prefetchInRender: true,\n * },\n * },\n * })\n * ```\n *\n * ### Usage\n * ```tsx\n * import { useQuery } from '@tanstack/react-query'\n * import React from 'react'\n * import { fetchTodos, type Todo } from './api'\n *\n * function TodoList({ query }: { query: UseQueryResult<Todo[], Error> }) {\n * const data = React.use(query.promise)\n *\n * return (\n * <ul>\n * {data.map(todo => (\n * <li key={todo.id}>{todo.title}</li>\n * ))}\n * </ul>\n * )\n * }\n *\n * export function App() {\n * const query = useQuery({ queryKey: ['todos'], queryFn: fetchTodos })\n *\n * return (\n * <>\n * <h1>Todos</h1>\n * <React.Suspense fallback={<div>Loading...</div>}>\n * <TodoList query={query} />\n * </React.Suspense>\n * </>\n * )\n * }\n * ```\n */\n promise: Promise<TData>\n}\n\nexport interface QueryObserverPendingResult<\n TData = unknown,\n TError = DefaultError,\n> extends QueryObserverBaseResult<TData, TError> {\n data: undefined\n error: null\n isError: false\n isPending: true\n isLoadingError: false\n isRefetchError: false\n isSuccess: false\n isPlaceholderData: false\n status: 'pending'\n}\n\nexport interface QueryObserverLoadingResult<\n TData = unknown,\n TError = DefaultError,\n> extends QueryObserverBaseResult<TData, TError> {\n data: undefined\n error: null\n isError: false\n isPending: true\n isLoading: true\n isLoadingError: false\n isRefetchError: false\n isSuccess: false\n isPlaceholderData: false\n status: 'pending'\n}\n\nexport interface QueryObserverLoadingErrorResult<\n TData = unknown,\n TError = DefaultError,\n> extends QueryObserverBaseResult<TData, TError> {\n data: undefined\n error: TError\n isError: true\n isPending: false\n isLoading: false\n isLoadingError: true\n isRefetchError: false\n isSuccess: false\n isPlaceholderData: false\n status: 'error'\n}\n\nexport interface QueryObserverRefetchErrorResult<\n TData = unknown,\n TError = DefaultError,\n> extends QueryObserverBaseResult<TData, TError> {\n data: TData\n error: TError\n isError: true\n isPending: false\n isLoading: false\n isLoadingError: false\n isRefetchError: true\n isSuccess: false\n isPlaceholderData: false\n status: 'error'\n}\n\nexport interface QueryObserverSuccessResult<\n TData = unknown,\n TError = DefaultError,\n> extends QueryObserverBaseResult<TData, TError> {\n data: TData\n error: null\n isError: false\n isPending: false\n isLoading: false\n isLoadingError: false\n isRefetchError: false\n isSuccess: true\n isPlaceholderData: false\n status: 'success'\n}\n\nexport interface QueryObserverPlaceholderResult<\n TData = unknown,\n TError = DefaultError,\n> extends QueryObserverBaseResult<TData, TError> {\n data: TData\n isError: false\n error: null\n isPending: false\n isLoading: false\n isLoadingError: false\n isRefetchError: false\n isSuccess: true\n isPlaceholderData: true\n status: 'success'\n}\n\nexport type DefinedQueryObserverResult<\n TData = unknown,\n TError = DefaultError,\n> =\n | QueryObserverRefetchErrorResult<TData, TError>\n | QueryObserverSuccessResult<TData, TError>\n\nexport type QueryObserverResult<TData = unknown, TError = DefaultError> =\n | DefinedQueryObserverResult<TData, TError>\n | QueryObserverLoadingErrorResult<TData, TError>\n | QueryObserverLoadingResult<TData, TError>\n | QueryObserverPendingResult<TData, TError>\n | QueryObserverPlaceholderResult<TData, TError>\n\nexport interface InfiniteQueryObserverBaseResult<\n TData = unknown,\n TError = DefaultError,\n> extends QueryObserverBaseResult<TData, TError> {\n /**\n * This function allows you to fetch the next \"page\" of results.\n */\n fetchNextPage: (\n options?: FetchNextPageOptions,\n ) => Promise<InfiniteQueryObserverResult<TData, TError>>\n /**\n * This function allows you to fetch the previous \"page\" of results.\n */\n fetchPreviousPage: (\n options?: FetchPreviousPageOptions,\n ) => Promise<InfiniteQueryObserverResult<TData, TError>>\n /**\n * Will be `true` if there is a next page to be fetched (known via the `getNextPageParam` option).\n */\n hasNextPage: boolean\n /**\n * Will be `true` if there is a previous page to be fetched (known via the `getPreviousPageParam` option).\n */\n hasPreviousPage: boolean\n /**\n * Will be `true` if the query failed while fetching the next page.\n */\n isFetchNextPageError: boolean\n /**\n * Will be `true` while fetching the next page with `fetchNextPage`.\n */\n isFetchingNextPage: boolean\n /**\n * Will be `true` if the query failed while fetching the previous page.\n */\n isFetchPreviousPageError: boolean\n /**\n * Will be `true` while fetching the previous page with `fetchPreviousPage`.\n */\n isFetchingPreviousPage: boolean\n}\n\nexport interface InfiniteQueryObserverPendingResult<\n TData = unknown,\n TError = DefaultError,\n> extends InfiniteQueryObserverBaseResult<TData, TError> {\n data: undefined\n error: null\n isError: false\n isPending: true\n isLoadingError: false\n isRefetchError: false\n isFetchNextPageError: false\n isFetchPreviousPageError: false\n isSuccess: false\n isPlaceholderData: false\n status: 'pending'\n}\n\nexport interface InfiniteQueryObserverLoadingResult<\n TData = unknown,\n TError = DefaultError,\n> extends InfiniteQueryObserverBaseResult<TData, TError> {\n data: undefined\n error: null\n isError: false\n isPending: true\n isLoading: true\n isLoadingError: false\n isRefetchError: false\n isFetchNextPageError: false\n isFetchPreviousPageError: false\n isSuccess: false\n isPlaceholderData: false\n status: 'pending'\n}\n\nexport interface InfiniteQueryObserverLoadingErrorResult<\n TData = unknown,\n TError = DefaultError,\n> extends InfiniteQueryObserverBaseResult<TData, TError> {\n data: undefined\n error: TError\n isError: true\n isPending: false\n isLoading: false\n isLoadingError: true\n isRefetchError: false\n isFetchNextPageError: false\n isFetchPreviousPageError: false\n isSuccess: false\n isPlaceholderData: false\n status: 'error'\n}\n\nexport interface InfiniteQueryObserverRefetchErrorResult<\n TData = unknown,\n TError = DefaultError,\n> extends InfiniteQueryObserverBaseResult<TData, TError> {\n data: TData\n error: TError\n isError: true\n isPending: false\n isLoading: false\n isLoadingError: false\n isRefetchError: true\n isSuccess: false\n isPlaceholderData: false\n status: 'error'\n}\n\nexport interface InfiniteQueryObserverSuccessResult<\n TData = unknown,\n TError = DefaultError,\n> extends InfiniteQueryObserverBaseResult<TData, TError> {\n data: TData\n error: null\n isError: false\n isPending: false\n isLoading: false\n isLoadingError: false\n isRefetchError: false\n isFetchNextPageError: false\n isFetchPreviousPageError: false\n isSuccess: true\n isPlaceholderData: false\n status: 'success'\n}\n\nexport interface InfiniteQueryObserverPlaceholderResult<\n TData = unknown,\n TError = DefaultError,\n> extends InfiniteQueryObserverBaseResult<TData, TError> {\n data: TData\n isError: false\n error: null\n isPending: false\n isLoading: false\n isLoadingError: false\n isRefetchError: false\n isSuccess: true\n isPlaceholderData: true\n isFetchNextPageError: false\n isFetchPreviousPageError: false\n status: 'success'\n}\n\nexport type DefinedInfiniteQueryObserverResult<\n TData = unknown,\n TError = DefaultError,\n> =\n | InfiniteQueryObserverRefetchErrorResult<TData, TError>\n | InfiniteQueryObserverSuccessResult<TData, TError>\n\nexport type InfiniteQueryObserverResult<\n TData = unknown,\n TError = DefaultError,\n> =\n | DefinedInfiniteQueryObserverResult<TData, TError>\n | InfiniteQueryObserverLoadingErrorResult<TData, TError>\n | InfiniteQueryObserverLoadingResult<TData, TError>\n | InfiniteQueryObserverPendingResult<TData, TError>\n | InfiniteQueryObserverPlaceholderResult<TData, TError>\n\nexport type MutationKey = Register extends {\n mutationKey: infer TMutationKey\n}\n ? TMutationKey extends Array<unknown>\n ? TMutationKey\n : TMutationKey extends Array<unknown>\n ? TMutationKey\n : ReadonlyArray<unknown>\n : ReadonlyArray<unknown>\n\nexport type MutationStatus = 'idle' | 'pending' | 'success' | 'error'\n\nexport type MutationScope = {\n id: string\n}\n\nexport type MutationMeta = Register extends {\n mutationMeta: infer TMutationMeta\n}\n ? TMutationMeta extends Record<string, unknown>\n ? TMutationMeta\n : Record<string, unknown>\n : Record<string, unknown>\n\nexport type MutationFunction<TData = unknown, TVariables = unknown> = (\n variables: TVariables,\n) => Promise<TData>\n\nexport interface MutationOptions<\n TData = unknown,\n TError = DefaultError,\n TVariables = void,\n TContext = unknown,\n> {\n mutationFn?: MutationFunction<TData, TVariables>\n mutationKey?: MutationKey\n onMutate?: (\n variables: TVariables,\n ) => Promise<TContext | undefined> | TContext | undefined\n onSuccess?: (\n data: TData,\n variables: TVariables,\n context: TContext,\n ) => Promise<unknown> | unknown\n onError?: (\n error: TError,\n variables: TVariables,\n context: TContext | undefined,\n ) => Promise<unknown> | unknown\n onSettled?: (\n data: TData | undefined,\n error: TError | null,\n variables: TVariables,\n context: TContext | undefined,\n ) => Promise<unknown> | unknown\n retry?: RetryValue<TError>\n retryDelay?: RetryDelayValue<TError>\n networkMode?: NetworkMode\n gcTime?: number\n _defaulted?: boolean\n meta?: MutationMeta\n scope?: MutationScope\n}\n\nexport interface MutationObserverOptions<\n TData = unknown,\n TError = DefaultError,\n TVariables = void,\n TContext = unknown,\n> extends MutationOptions<TData, TError, TVariables, TContext> {\n throwOnError?: boolean | ((error: TError) => boolean)\n}\n\nexport interface MutateOptions<\n TData = unknown,\n TError = DefaultError,\n TVariables = void,\n TContext = unknown,\n> {\n onSuccess?: (data: TData, variables: TVariables, context: TContext) => void\n onError?: (\n error: TError,\n variables: TVariables,\n context: TContext | undefined,\n ) => void\n onSettled?: (\n data: TData | undefined,\n error: TError | null,\n variables: TVariables,\n context: TContext | undefined,\n ) => void\n}\n\nexport type MutateFunction<\n TData = unknown,\n TError = DefaultError,\n TVariables = void,\n TContext = unknown,\n> = (\n variables: TVariables,\n options?: MutateOptions<TData, TError, TVariables, TContext>,\n) => Promise<TData>\n\nexport interface MutationObserverBaseResult<\n TData = unknown,\n TError = DefaultError,\n TVariables = void,\n TContext = unknown,\n> extends MutationState<TData, TError, TVariables, TContext> {\n /**\n * The last successfully resolved data for the mutation.\n */\n data: TData | undefined\n /**\n * The variables object passed to the `mutationFn`.\n */\n variables: TVariables | undefined\n /**\n * The error object for the mutation, if an error was encountered.\n * - Defaults to `null`.\n */\n error: TError | null\n /**\n * A boolean variable derived from `status`.\n * - `true` if the last mutation attempt resulted in an error.\n */\n isError: boolean\n /**\n * A boolean variable derived from `status`.\n * - `true` if the mutation is in its initial state prior to executing.\n */\n isIdle: boolean\n /**\n * A boolean variable derived from `status`.\n * - `true` if the mutation is currently executing.\n */\n isPending: boolean\n /**\n * A boolean variable derived from `status`.\n * - `true` if the last mutation attempt was successful.\n */\n isSuccess: boolean\n /**\n * The status of the mutation.\n * - Will be:\n * - `idle` initial status prior to the mutation function executing.\n * - `pending` if the mutation is currently executing.\n * - `error` if the last mutation attempt resulted in an error.\n * - `success` if the last mutation attempt was successful.\n */\n status: MutationStatus\n /**\n * The mutation function you can call with variables to trigger the mutation and optionally hooks on additional callback options.\n * @param variables - The variables object to pass to the `mutationFn`.\n * @param options.onSuccess - This function will fire when the mutation is successful and will be passed the mutation's result.\n * @param options.onError - This function will fire if the mutation encounters an error and will be passed the error.\n * @param options.onSettled - This function will fire when the mutation is either successfully fetched or encounters an error and be passed either the data or error.\n * @remarks\n * - If you make multiple requests, `onSuccess` will fire only after the latest call you've made.\n * - All the callback functions (`onSuccess`, `onError`, `onSettled`) are void functions, and the returned value will be ignored.\n */\n mutate: MutateFunction<TData, TError, TVariables, TContext>\n /**\n * A function to clean the mutation internal state (i.e., it resets the mutation to its initial state).\n */\n reset: () => void\n}\n\nexport interface MutationObserverIdleResult<\n TData = unknown,\n TError = DefaultError,\n TVariables = void,\n TContext = unknown,\n> extends MutationObserverBaseResult<TData, TError, TVariables, TContext> {\n data: undefined\n variables: undefined\n error: null\n isError: false\n isIdle: true\n isPending: false\n isSuccess: false\n status: 'idle'\n}\n\nexport interface MutationObserverLoadingResult<\n TData = unknown,\n TError = DefaultError,\n TVariables = void,\n TContext = unknown,\n> extends MutationObserverBaseResult<TData, TError, TVariables, TContext> {\n data: undefined\n variables: TVariables\n error: null\n isError: false\n isIdle: false\n isPending: true\n isSuccess: false\n status: 'pending'\n}\n\nexport interface MutationObserverErrorResult<\n TData = unknown,\n TError = DefaultError,\n TVariables = void,\n TContext = unknown,\n> extends MutationObserverBaseResult<TData, TError, TVariables, TContext> {\n data: undefined\n error: TError\n variables: TVariables\n isError: true\n isIdle: false\n isPending: false\n isSuccess: false\n status: 'error'\n}\n\nexport interface MutationObserverSuccessResult<\n TData = unknown,\n TError = DefaultError,\n TVariables = void,\n TContext = unknown,\n> extends MutationObserverBaseResult<TData, TError, TVariables, TContext> {\n data: TData\n error: null\n variables: TVariables\n isError: false\n isIdle: false\n isPending: false\n isSuccess: true\n status: 'success'\n}\n\nexport type MutationObserverResult<\n TData = unknown,\n TError = DefaultError,\n TVariables = void,\n TContext = unknown,\n> =\n | MutationObserverIdleResult<TData, TError, TVariables, TContext>\n | MutationObserverLoadingResult<TData, TError, TVariables, TContext>\n | MutationObserverErrorResult<TData, TError, TVariables, TContext>\n | MutationObserverSuccessResult<TData, TError, TVariables, TContext>\n\nexport interface QueryClientConfig {\n queryCache?: QueryCache\n mutationCache?: MutationCache\n defaultOptions?: DefaultOptions\n}\n\nexport interface DefaultOptions<TError = DefaultError> {\n queries?: OmitKeyof<\n QueryObserverOptions<unknown, TError>,\n 'suspense' | 'queryKey'\n >\n mutations?: MutationObserverOptions<unknown, TError, unknown, unknown>\n hydrate?: HydrateOptions['defaultOptions']\n dehydrate?: DehydrateOptions\n}\n\nexport interface CancelOptions {\n revert?: boolean\n silent?: boolean\n}\n\nexport interface SetDataOptions {\n updatedAt?: number\n}\n\nexport type NotifyEventType =\n | 'added'\n | 'removed'\n | 'updated'\n | 'observerAdded'\n | 'observerRemoved'\n | 'observerResultsUpdated'\n | 'observerOptionsUpdated'\n\nexport interface NotifyEvent {\n type: NotifyEventType\n}\n", "import { type QueryKey, replaceEqualDeep } from '@tanstack/query-core'\n\nexport function structuralSharing<data>(\n oldData: data | undefined,\n newData: data,\n): data {\n return replaceEqualDeep(oldData, newData)\n}\n\nexport function hashFn(queryKey: QueryKey): string {\n return JSON.stringify(queryKey, (_, value) => {\n if (isPlainObject(value))\n return Object.keys(value)\n .sort()\n .reduce((result, key) => {\n result[key] = value[key]\n return result\n }, {} as any)\n if (typeof value === 'bigint') return value.toString()\n return value\n })\n}\n\n// biome-ignore lint/complexity/noBannedTypes:\nfunction isPlainObject(value: any): value is Object {\n if (!hasObjectPrototype(value)) {\n return false\n }\n\n // If has modified constructor\n const ctor = value.constructor\n if (typeof ctor === 'undefined') return true\n\n // If has modified prototype\n const prot = ctor.prototype\n if (!hasObjectPrototype(prot)) return false\n\n // If constructor does not have an Object-specific method\n // biome-ignore lint/suspicious/noPrototypeBuiltins: <explanation>\n if (!prot.hasOwnProperty('isPrototypeOf')) return false\n\n // Most likely a plain Object\n return true\n}\n\nfunction hasObjectPrototype(o: any): boolean {\n return Object.prototype.toString.call(o) === '[object Object]'\n}\n\nexport function filterQueryOptions<type extends Record<string, unknown>>(\n options: type,\n): type {\n // destructuring is super fast\n // biome-ignore format: no formatting\n const {\n // import('@tanstack/query-core').QueryOptions\n _defaulted, behavior, gcTime, initialData, initialDataUpdatedAt, maxPages, meta, networkMode, queryFn, queryHash, queryKey, queryKeyHashFn, retry, retryDelay, structuralSharing,\n\n // import('@tanstack/query-core').InfiniteQueryObserverOptions\n getPreviousPageParam, getNextPageParam, initialPageParam,\n\n // import('@tanstack/react-query').UseQueryOptions\n _optimisticResults, enabled, notifyOnChangeProps, placeholderData, refetchInterval, refetchIntervalInBackground, refetchOnMount, refetchOnReconnect, refetchOnWindowFocus, retryOnMount, select, staleTime, suspense, throwOnError,\n\n ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////\n // wagmi\n ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////\n config, connector, query,\n ...rest\n } = options\n\n return rest as type\n}\n", "import type { QueryOptions } from '@tanstack/query-core'\n\nimport {\n type CallErrorType,\n type CallParameters,\n type CallReturnType,\n call,\n} from '../actions/call.js'\nimport type { Config } from '../createConfig.js'\nimport type { ScopeKeyParameter } from '../types/properties.js'\nimport type { Compute, ExactPartial } from '../types/utils.js'\nimport { filterQueryOptions } from './utils.js'\n\nexport type CallOptions<config extends Config> = Compute<\n ExactPartial<CallParameters<config>> & ScopeKeyParameter\n>\n\nexport function callQueryOptions<config extends Config>(\n config: config,\n options: CallOptions<config> = {},\n) {\n return {\n async queryFn({ queryKey }) {\n const { scopeKey: _, ...parameters } = queryKey[1]\n const data = await call(config, {\n ...parameters,\n } as CallParameters)\n return data ?? null\n },\n queryKey: callQueryKey(options),\n } as const satisfies QueryOptions<\n CallQueryFnData,\n CallErrorType,\n CallData,\n CallQueryKey<config>\n >\n}\n\nexport type CallQueryFnData = CallReturnType\n\nexport type CallData = CallQueryFnData\n\nexport function callQueryKey<config extends Config>(\n options: CallOptions<config>,\n) {\n return ['call', filterQueryOptions(options)] as const\n}\n\nexport type CallQueryKey<config extends Config> = ReturnType<\n typeof callQueryKey<config>\n>\n", "import type { MutateOptions, MutationOptions } from '@tanstack/query-core'\n\nimport {\n type ConnectErrorType,\n type ConnectParameters,\n type ConnectReturnType,\n connect,\n} from '../actions/connect.js'\nimport type { Config, Connector } from '../createConfig.js'\n\nimport type { CreateConnectorFn } from '../connectors/createConnector.js'\nimport type { Compute } from '../types/utils.js'\n\nexport function connectMutationOptions<config extends Config>(config: config) {\n return {\n mutationFn(variables) {\n return connect(config, variables)\n },\n mutationKey: ['connect'],\n } as const satisfies MutationOptions<\n ConnectData<config>,\n ConnectErrorType,\n ConnectVariables<config, Connector | CreateConnectorFn>\n >\n}\n\nexport type ConnectData<config extends Config> = ConnectReturnType<config>\n\nexport type ConnectVariables<\n config extends Config,\n connector extends Connector | CreateConnectorFn,\n> = ConnectParameters<config, connector>\n\nexport type ConnectMutate<config extends Config, context = unknown> = <\n connector extends\n | config['connectors'][number]\n | Connector\n | CreateConnectorFn,\n>(\n variables: ConnectVariables<config, connector>,\n options?:\n | Compute<\n MutateOptions<\n ConnectData<config>,\n ConnectErrorType,\n Compute<ConnectVariables<config, connector>>,\n context\n >\n >\n | undefined,\n) => void\n\nexport type ConnectMutateAsync<config extends Config, context = unknown> = <\n connector extends\n | config['connectors'][number]\n | Connector\n | CreateConnectorFn,\n>(\n variables: ConnectVariables<config, connector>,\n options?:\n | Compute<\n MutateOptions<\n ConnectData<config>,\n ConnectErrorType,\n Compute<ConnectVariables<config, connector>>,\n context\n >\n >\n | undefined,\n) => Promise<ConnectData<config>>\n", "import type { MutateOptions, MutationOptions } from '@tanstack/query-core'\nimport type { Abi, ContractConstructorArgs } from 'viem'\n\nimport {\n type DeployContractErrorType,\n type DeployContractParameters,\n type DeployContractReturnType,\n deployContract,\n} from '../actions/deployContract.js'\nimport type { Config } from '../createConfig.js'\nimport type { Compute } from '../types/utils.js'\n\nexport function deployContractMutationOptions<config extends Config>(\n config: config,\n) {\n return {\n mutationFn(variables) {\n return deployContract(config, variables)\n },\n mutationKey: ['deployContract'],\n } as const satisfies MutationOptions<\n DeployContractData,\n DeployContractErrorType,\n DeployContractVariables<Abi, config, config['chains'][number]['id']>\n >\n}\n\nexport type DeployContractData = Compute<DeployContractReturnType>\n\nexport type DeployContractVariables<\n abi extends Abi | readonly unknown[],\n config extends Config,\n chainId extends config['chains'][number]['id'],\n ///\n allArgs = ContractConstructorArgs<abi>,\n> = DeployContractParameters<abi, config, chainId, allArgs>\n\nexport type DeployContractMutate<config extends Config, context = unknown> = <\n abi extends Abi | readonly unknown[],\n chainId extends config['chains'][number]['id'],\n>(\n variables: DeployContractVariables<abi, config, chainId>,\n options?:\n | Compute<\n MutateOptions<\n DeployContractData,\n DeployContractErrorType,\n Compute<DeployContractVariables<abi, config, chainId>>,\n context\n >\n >\n | undefined,\n) => void\n\nexport type DeployContractMutateAsync<\n config extends Config,\n context = unknown,\n> = <\n abi extends Abi | readonly unknown[],\n chainId extends config['chains'][number]['id'],\n>(\n variables: DeployContractVariables<abi, config, chainId>,\n options?:\n | Compute<\n MutateOptions<\n DeployContractData,\n DeployContractErrorType,\n Compute<DeployContractVariables<abi, config, chainId>>,\n context\n >\n >\n | undefined,\n) => Promise<DeployContractData>\n", "import type { MutationOptions } from '@tanstack/query-core'\n\nimport {\n type DisconnectErrorType,\n type DisconnectParameters,\n type DisconnectReturnType,\n disconnect,\n} from '../actions/disconnect.js'\nimport type { Config } from '../createConfig.js'\nimport type { Mutate, MutateAsync } from './types.js'\n\nexport function disconnectMutationOptions<config extends Config>(\n config: config,\n) {\n return {\n mutationFn(variables) {\n return disconnect(config, variables)\n },\n mutationKey: ['disconnect'],\n } as const satisfies MutationOptions<\n DisconnectData,\n DisconnectErrorType,\n DisconnectVariables\n >\n}\n\nexport type DisconnectData = DisconnectReturnType\n\nexport type DisconnectVariables = DisconnectParameters | undefined\n\nexport type DisconnectMutate<context = unknown> = Mutate<\n DisconnectData,\n DisconnectErrorType,\n DisconnectVariables,\n context\n>\n\nexport type DisconnectMutateAsync<context = unknown> = MutateAsync<\n DisconnectData,\n DisconnectErrorType,\n DisconnectVariables,\n context\n>\n", "import type { QueryOptions } from '@tanstack/query-core'\nimport type { FeeValuesType } from 'viem'\n\nimport {\n type EstimateFeesPerGasErrorType,\n type EstimateFeesPerGasParameters,\n type EstimateFeesPerGasReturnType,\n estimateFeesPerGas,\n} from '../actions/estimateFeesPerGas.js'\nimport type { Config } from '../createConfig.js'\nimport type { ScopeKeyParameter } from '../types/properties.js'\nimport type { Compute, ExactPartial } from '../types/utils.js'\nimport { filterQueryOptions } from './utils.js'\n\nexport type EstimateFeesPerGasOptions<\n type extends FeeValuesType,\n config extends Config,\n> = Compute<\n ExactPartial<EstimateFeesPerGasParameters<type, config>> & ScopeKeyParameter\n>\n\nexport function estimateFeesPerGasQueryOptions<\n config extends Config,\n type extends FeeValuesType = 'eip1559',\n>(config: config, options: EstimateFeesPerGasOptions<type, config> = {}) {\n return {\n async queryFn({ queryKey }) {\n const { scopeKey: _, ...parameters } = queryKey[1]\n return estimateFeesPerGas(config, parameters)\n },\n queryKey: estimateFeesPerGasQueryKey(options),\n } as const satisfies QueryOptions<\n EstimateFeesPerGasQueryFnData<type>,\n EstimateFeesPerGasErrorType,\n EstimateFeesPerGasData<type>,\n EstimateFeesPerGasQueryKey<config, type>\n >\n}\n\nexport type EstimateFeesPerGasQueryFnData<type extends FeeValuesType> =\n EstimateFeesPerGasReturnType<type>\n\nexport type EstimateFeesPerGasData<type extends FeeValuesType> =\n EstimateFeesPerGasQueryFnData<type>\n\nexport function estimateFeesPerGasQueryKey<\n config extends Config,\n type extends FeeValuesType = 'eip1559',\n>(options: EstimateFeesPerGasOptions<type, config> = {}) {\n return ['estimateFeesPerGas', filterQueryOptions(options)] as const\n}\n\nexport type EstimateFeesPerGasQueryKey<\n config extends Config,\n type extends FeeValuesType,\n> = ReturnType<typeof estimateFeesPerGasQueryKey<config, type>>\n", "import type { QueryOptions } from '@tanstack/query-core'\n\nimport {\n type EstimateGasErrorType,\n type EstimateGasParameters,\n type EstimateGasReturnType,\n estimateGas,\n} from '../actions/estimateGas.js'\nimport type { Config } from '../createConfig.js'\nimport type { ScopeKeyParameter } from '../types/properties.js'\nimport type { UnionExactPartial } from '../types/utils.js'\nimport { filterQueryOptions } from './utils.js'\n\nexport type EstimateGasOptions<\n config extends Config,\n chainId extends config['chains'][number]['id'] | undefined,\n> = UnionExactPartial<EstimateGasParameters<config, chainId>> &\n ScopeKeyParameter\n\nexport function estimateGasQueryOptions<\n config extends Config,\n chainId extends config['chains'][number]['id'],\n>(config: config, options: EstimateGasOptions<config, chainId> = {} as any) {\n return {\n async queryFn({ queryKey }) {\n const { connector } = options\n const { account, scopeKey: _, ...parameters } = queryKey[1]\n if (!account && !connector)\n throw new Error('account or connector is required')\n return estimateGas(config, { account, connector, ...(parameters as any) })\n },\n queryKey: estimateGasQueryKey(options),\n } as const satisfies QueryOptions<\n EstimateGasQueryFnData,\n EstimateGasErrorType,\n EstimateGasData,\n EstimateGasQueryKey<config, chainId>\n >\n}\n\nexport type EstimateGasQueryFnData = EstimateGasReturnType\n\nexport type EstimateGasData = EstimateGasQueryFnData\n\nexport function estimateGasQueryKey<\n config extends Config,\n chainId extends config['chains'][number]['id'] | undefined,\n>(options: EstimateGasOptions<config, chainId> = {} as any) {\n const { connector: _, ...rest } = options\n return ['estimateGas', filterQueryOptions(rest)] as const\n}\n\nexport type EstimateGasQueryKey<\n config extends Config,\n chainId extends config['chains'][number]['id'] | undefined,\n> = ReturnType<typeof estimateGasQueryKey<config, chainId>>\n", "import type { QueryOptions } from '@tanstack/query-core'\n\nimport {\n type EstimateMaxPriorityFeePerGasErrorType,\n type EstimateMaxPriorityFeePerGasParameters,\n type EstimateMaxPriorityFeePerGasReturnType,\n estimateMaxPriorityFeePerGas,\n} from '../actions/estimateMaxPriorityFeePerGas.js'\nimport type { Config } from '../createConfig.js'\nimport type { ScopeKeyParameter } from '../types/properties.js'\nimport type { Compute, ExactPartial } from '../types/utils.js'\nimport { filterQueryOptions } from './utils.js'\n\nexport type EstimateMaxPriorityFeePerGasOptions<config extends Config> =\n Compute<\n ExactPartial<EstimateMaxPriorityFeePerGasParameters<config>> &\n ScopeKeyParameter\n >\n\nexport function estimateMaxPriorityFeePerGasQueryOptions<config extends Config>(\n config: config,\n options: EstimateMaxPriorityFeePerGasOptions<config> = {},\n) {\n return {\n async queryFn({ queryKey }) {\n const { scopeKey: _, ...parameters } = queryKey[1]\n return estimateMaxPriorityFeePerGas(config, parameters)\n },\n queryKey: estimateMaxPriorityFeePerGasQueryKey(options),\n } as const satisfies QueryOptions<\n EstimateMaxPriorityFeePerGasQueryFnData,\n EstimateMaxPriorityFeePerGasErrorType,\n EstimateMaxPriorityFeePerGasData,\n EstimateMaxPriorityFeePerGasQueryKey<config>\n >\n}\n\nexport type EstimateMaxPriorityFeePerGasQueryFnData =\n EstimateMaxPriorityFeePerGasReturnType\n\nexport type EstimateMaxPriorityFeePerGasData =\n EstimateMaxPriorityFeePerGasQueryFnData\n\nexport function estimateMaxPriorityFeePerGasQueryKey<config extends Config>(\n options: EstimateMaxPriorityFeePerGasOptions<config> = {},\n) {\n return ['estimateMaxPriorityFeePerGas', filterQueryOptions(options)] as const\n}\n\nexport type EstimateMaxPriorityFeePerGasQueryKey<config extends Config> =\n ReturnType<typeof estimateMaxPriorityFeePerGasQueryKey<config>>\n", "import type { QueryOptions } from '@tanstack/query-core'\n\nimport {\n type GetBalanceErrorType,\n type GetBalanceParameters,\n type GetBalanceReturnType,\n getBalance,\n} from '../actions/getBalance.js'\nimport type { Config } from '../createConfig.js'\nimport type { ScopeKeyParameter } from '../types/properties.js'\nimport type { Compute, PartialBy } from '../types/utils.js'\nimport { filterQueryOptions } from './utils.js'\n\nexport type GetBalanceOptions<config extends Config> = Compute<\n PartialBy<GetBalanceParameters<config>, 'address'> & ScopeKeyParameter\n>\n\nexport function getBalanceQueryOptions<config extends Config>(\n config: config,\n options: GetBalanceOptions<config> = {},\n) {\n return {\n async queryFn({ queryKey }) {\n const { address, scopeKey: _, ...parameters } = queryKey[1]\n if (!address) throw new Error('address is required')\n const balance = await getBalance(config, {\n ...(parameters as GetBalanceParameters),\n address,\n })\n return balance ?? null\n },\n queryKey: getBalanceQueryKey(options),\n } as const satisfies QueryOptions<\n GetBalanceQueryFnData,\n GetBalanceErrorType,\n GetBalanceData,\n GetBalanceQueryKey<config>\n >\n}\n\nexport type GetBalanceQueryFnData = Compute<GetBalanceReturnType>\n\nexport type GetBalanceData = GetBalanceQueryFnData\n\nexport function getBalanceQueryKey<config extends Config>(\n options: GetBalanceOptions<config> = {},\n) {\n return ['balance', filterQueryOptions(options)] as const\n}\n\nexport type GetBalanceQueryKey<config extends Config> = ReturnType<\n typeof getBalanceQueryKey<config>\n>\n", "import type { QueryOptions } from '@tanstack/query-core'\nimport type { BlockTag } from 'viem'\n\nimport {\n type GetBlockErrorType,\n type GetBlockParameters,\n type GetBlockReturnType,\n getBlock,\n} from '../actions/getBlock.js'\nimport type { Config } from '../createConfig.js'\nimport type { ScopeKeyParameter } from '../types/properties.js'\nimport type { Compute, ExactPartial } from '../types/utils.js'\nimport { filterQueryOptions } from './utils.js'\n\nexport type GetBlockOptions<\n includeTransactions extends boolean,\n blockTag extends BlockTag,\n config extends Config,\n chainId extends\n config['chains'][number]['id'] = config['chains'][number]['id'],\n> = Compute<\n ExactPartial<\n GetBlockParameters<includeTransactions, blockTag, config, chainId>\n > &\n ScopeKeyParameter\n>\n\nexport function getBlockQueryOptions<\n config extends Config,\n chainId extends config['chains'][number]['id'],\n includeTransactions extends boolean,\n blockTag extends BlockTag,\n>(\n config: config,\n options: GetBlockOptions<includeTransactions, blockTag, config, chainId> = {},\n) {\n return {\n async queryFn({ queryKey }) {\n const { scopeKey: _, ...parameters } = queryKey[1]\n const block = await getBlock(config, parameters)\n return (block ?? null) as any\n },\n queryKey: getBlockQueryKey(options),\n } as const satisfies QueryOptions<\n GetBlockQueryFnData<includeTransactions, blockTag, config, chainId>,\n GetBlockErrorType,\n GetBlockData<includeTransactions, blockTag, config, chainId>,\n GetBlockQueryKey<includeTransactions, blockTag, config, chainId>\n >\n}\n\nexport type GetBlockQueryFnData<\n includeTransactions extends boolean,\n blockTag extends BlockTag,\n config extends Config,\n chainId extends config['chains'][number]['id'],\n> = GetBlockReturnType<includeTransactions, blockTag, config, chainId>\n\nexport type GetBlockData<\n includeTransactions extends boolean,\n blockTag extends BlockTag,\n config extends Config,\n chainId extends config['chains'][number]['id'],\n> = GetBlockQueryFnData<includeTransactions, blockTag, config, chainId>\n\nexport function getBlockQueryKey<\n config extends Config,\n chainId extends config['chains'][number]['id'],\n includeTransactions extends boolean = false,\n blockTag extends BlockTag = 'latest',\n>(\n options: GetBlockOptions<includeTransactions, blockTag, config, chainId> = {},\n) {\n return ['block', filterQueryOptions(options)] as const\n}\n\nexport type GetBlockQueryKey<\n includeTransactions extends boolean,\n blockTag extends BlockTag,\n config extends Config,\n chainId extends config['chains'][number]['id'],\n> = ReturnType<\n typeof getBlockQueryKey<config, chainId, includeTransactions, blockTag>\n>\n", "import type { QueryOptions } from '@tanstack/query-core'\n\nimport {\n type GetBlockNumberErrorType,\n type GetBlockNumberParameters,\n type GetBlockNumberReturnType,\n getBlockNumber,\n} from '../actions/getBlockNumber.js'\nimport type { Config } from '../createConfig.js'\nimport type { ScopeKeyParameter } from '../types/properties.js'\nimport type { Compute, ExactPartial } from '../types/utils.js'\nimport { filterQueryOptions } from './utils.js'\n\nexport type GetBlockNumberOptions<\n config extends Config,\n chainId extends config['chains'][number]['id'],\n> = Compute<\n ExactPartial<GetBlockNumberParameters<config, chainId>> & ScopeKeyParameter\n>\n\nexport function getBlockNumberQueryOptions<\n config extends Config,\n chainId extends config['chains'][number]['id'],\n>(config: config, options: GetBlockNumberOptions<config, chainId> = {}) {\n return {\n gcTime: 0,\n async queryFn({ queryKey }) {\n const { scopeKey: _, ...parameters } = queryKey[1]\n const blockNumber = await getBlockNumber(config, parameters)\n return blockNumber ?? null\n },\n queryKey: getBlockNumberQueryKey(options),\n } as const satisfies QueryOptions<\n GetBlockNumberQueryFnData,\n GetBlockNumberErrorType,\n GetBlockNumberData,\n GetBlockNumberQueryKey<config, chainId>\n >\n}\n\nexport type GetBlockNumberQueryFnData = GetBlockNumberReturnType\n\nexport type GetBlockNumberData = GetBlockNumberQueryFnData\n\nexport function getBlockNumberQueryKey<\n config extends Config,\n chainId extends config['chains'][number]['id'],\n>(options: GetBlockNumberOptions<config, chainId> = {}) {\n return ['blockNumber', filterQueryOptions(options)] as const\n}\n\nexport type GetBlockNumberQueryKey<\n config extends Config,\n chainId extends config['chains'][number]['id'],\n> = ReturnType<typeof getBlockNumberQueryKey<config, chainId>>\n", "import type { QueryOptions } from '@tanstack/query-core'\n\nimport {\n type GetBlockTransactionCountErrorType,\n type GetBlockTransactionCountParameters,\n type GetBlockTransactionCountReturnType,\n getBlockTransactionCount,\n} from '../actions/getBlockTransactionCount.js'\nimport type { Config } from '../createConfig.js'\nimport type { ScopeKeyParameter } from '../types/properties.js'\nimport type { ExactPartial, UnionCompute } from '../types/utils.js'\nimport { filterQueryOptions } from './utils.js'\n\nexport type GetBlockTransactionCountOptions<\n config extends Config,\n chainId extends config['chains'][number]['id'],\n> = UnionCompute<\n ExactPartial<GetBlockTransactionCountParameters<config, chainId>> &\n ScopeKeyParameter\n>\n\nexport function getBlockTransactionCountQueryOptions<\n config extends Config,\n chainId extends config['chains'][number]['id'],\n>(\n config: config,\n options: GetBlockTransactionCountOptions<config, chainId> = {},\n) {\n return {\n async queryFn({ queryKey }) {\n const { scopeKey: _, ...parameters } = queryKey[1]\n const blockTransactionCount = await getBlockTransactionCount(\n config,\n parameters,\n )\n return blockTransactionCount ?? null\n },\n queryKey: getBlockTransactionCountQueryKey(options),\n } as const satisfies QueryOptions<\n GetBlockTransactionCountQueryFnData,\n GetBlockTransactionCountErrorType,\n GetBlockTransactionCountData,\n GetBlockTransactionCountQueryKey<config, chainId>\n >\n}\n\nexport type GetBlockTransactionCountQueryFnData =\n GetBlockTransactionCountReturnType\n\nexport type GetBlockTransactionCountData = GetBlockTransactionCountQueryFnData\n\nexport function getBlockTransactionCountQueryKey<\n config extends Config,\n chainId extends config['chains'][number]['id'],\n>(options: GetBlockTransactionCountOptions<config, chainId> = {}) {\n return ['blockTransactionCount', filterQueryOptions(options)] as const\n}\n\nexport type GetBlockTransactionCountQueryKey<\n config extends Config,\n chainId extends config['chains'][number]['id'],\n> = ReturnType<typeof getBlockTransactionCountQueryKey<config, chainId>>\n", "import type { QueryOptions } from '@tanstack/query-core'\n\nimport {\n type GetBytecodeErrorType,\n type GetBytecodeParameters,\n type GetBytecodeReturnType,\n getBytecode,\n} from '../actions/getBytecode.js'\nimport type { Config } from '../createConfig.js'\nimport type { ScopeKeyParameter } from '../types/properties.js'\nimport type { Compute, ExactPartial } from '../types/utils.js'\nimport { filterQueryOptions } from './utils.js'\n\nexport type GetBytecodeOptions<config extends Config> = Compute<\n ExactPartial<GetBytecodeParameters<config>> & ScopeKeyParameter\n>\n\nexport function getBytecodeQueryOptions<config extends Config>(\n config: config,\n options: GetBytecodeOptions<config> = {},\n) {\n return {\n async queryFn({ queryKey }) {\n const { address, scopeKey: _, ...parameters } = queryKey[1]\n if (!address) throw new Error('address is required')\n const bytecode = await getBytecode(config, { ...parameters, address })\n return (bytecode ?? null) as any\n },\n queryKey: getBytecodeQueryKey(options),\n } as const satisfies QueryOptions<\n GetBytecodeQueryFnData,\n GetBytecodeErrorType,\n GetBytecodeData,\n GetBytecodeQueryKey<config>\n >\n}\nexport type GetBytecodeQueryFnData = GetBytecodeReturnType\n\nexport type GetBytecodeData = GetBytecodeQueryFnData\n\nexport function getBytecodeQueryKey<config extends Config>(\n options: GetBytecodeOptions<config>,\n) {\n return ['getBytecode', filterQueryOptions(options)] as const\n}\n\nexport type GetBytecodeQueryKey<config extends Config> = ReturnType<\n typeof getBytecodeQueryKey<config>\n>\n", "import type { QueryOptions } from '@tanstack/query-core'\n\nimport {\n type GetConnectorClientErrorType,\n type GetConnectorClientParameters,\n type GetConnectorClientReturnType,\n getConnectorClient,\n} from '../actions/getConnectorClient.js'\nimport type { Config } from '../createConfig.js'\nimport type { ScopeKeyParameter } from '../types/properties.js'\nimport type { Compute, ExactPartial } from '../types/utils.js'\nimport { filterQueryOptions } from './utils.js'\n\nexport type GetConnectorClientOptions<\n config extends Config,\n chainId extends config['chains'][number]['id'],\n> = Compute<\n ExactPartial<GetConnectorClientParameters<config, chainId>> &\n ScopeKeyParameter\n>\n\nexport function getConnectorClientQueryOptions<\n config extends Config,\n chainId extends config['chains'][number]['id'],\n>(config: config, options: GetConnectorClientOptions<config, chainId> = {}) {\n return {\n gcTime: 0,\n async queryFn({ queryKey }) {\n const { connector } = options\n const { connectorUid: _, scopeKey: _s, ...parameters } = queryKey[1]\n return getConnectorClient(config, {\n ...parameters,\n connector,\n }) as unknown as Promise<GetConnectorClientReturnType<config, chainId>>\n },\n queryKey: getConnectorClientQueryKey(options),\n } as const satisfies QueryOptions<\n GetConnectorClientQueryFnData<config, chainId>,\n GetConnectorClientErrorType,\n GetConnectorClientData<config, chainId>,\n GetConnectorClientQueryKey<config, chainId>\n >\n}\n\nexport type GetConnectorClientQueryFnData<\n config extends Config,\n chainId extends config['chains'][number]['id'],\n> = GetConnectorClientReturnType<config, chainId>\n\nexport type GetConnectorClientData<\n config extends Config,\n chainId extends config['chains'][number]['id'],\n> = GetConnectorClientQueryFnData<config, chainId>\n\nexport function getConnectorClientQueryKey<\n config extends Config,\n chainId extends config['chains'][number]['id'],\n>(options: GetConnectorClientOptions<config, chainId> = {}) {\n const { connector, ...parameters } = options\n return [\n 'connectorClient',\n { ...filterQueryOptions(parameters), connectorUid: connector?.uid },\n ] as const\n}\n\nexport type GetConnectorClientQueryKey<\n config extends Config,\n chainId extends config['chains'][number]['id'],\n> = ReturnType<typeof getConnectorClientQueryKey<config, chainId>>\n", "import type { QueryOptions } from '@tanstack/query-core'\n\nimport {\n type GetEnsAddressErrorType,\n type GetEnsAddressParameters,\n type GetEnsAddressReturnType,\n getEnsAddress,\n} from '../actions/getEnsAddress.js'\nimport type { Config } from '../createConfig.js'\nimport type { ScopeKeyParameter } from '../types/properties.js'\nimport type { Compute, ExactPartial } from '../types/utils.js'\nimport { filterQueryOptions } from './utils.js'\n\nexport type GetEnsAddressOptions<config extends Config> = Compute<\n ExactPartial<GetEnsAddressParameters<config>> & ScopeKeyParameter\n>\n\nexport function getEnsAddressQueryOptions<config extends Config>(\n config: config,\n options: GetEnsAddressOptions<config> = {},\n) {\n return {\n async queryFn({ queryKey }) {\n const { name, scopeKey: _, ...parameters } = queryKey[1]\n if (!name) throw new Error('name is required')\n return getEnsAddress(config, { ...parameters, name })\n },\n queryKey: getEnsAddressQueryKey(options),\n } as const satisfies QueryOptions<\n GetEnsAddressQueryFnData,\n GetEnsAddressErrorType,\n GetEnsAddressData,\n GetEnsAddressQueryKey<config>\n >\n}\n\nexport type GetEnsAddressQueryFnData = GetEnsAddressReturnType\n\nexport type GetEnsAddressData = GetEnsAddressQueryFnData\n\nexport function getEnsAddressQueryKey<config extends Config>(\n options: GetEnsAddressOptions<config> = {},\n) {\n return ['ensAddress', filterQueryOptions(options)] as const\n}\n\nexport type GetEnsAddressQueryKey<config extends Config> = ReturnType<\n typeof getEnsAddressQueryKey<config>\n>\n", "import type { QueryOptions } from '@tanstack/query-core'\n\nimport {\n type GetEnsAvatarErrorType,\n type GetEnsAvatarParameters,\n type GetEnsAvatarReturnType,\n getEnsAvatar,\n} from '../actions/getEnsAvatar.js'\nimport type { Config } from '../createConfig.js'\nimport type { ScopeKeyParameter } from '../types/properties.js'\nimport type { Compute, ExactPartial } from '../types/utils.js'\nimport { filterQueryOptions } from './utils.js'\n\nexport type GetEnsAvatarOptions<config extends Config> = Compute<\n ExactPartial<GetEnsAvatarParameters<config>> & ScopeKeyParameter\n>\n\nexport function getEnsAvatarQueryOptions<config extends Config>(\n config: config,\n options: GetEnsAvatarOptions<config> = {},\n) {\n return {\n async queryFn({ queryKey }) {\n const { name, scopeKey: _, ...parameters } = queryKey[1]\n if (!name) throw new Error('name is required')\n return getEnsAvatar(config, { ...parameters, name })\n },\n queryKey: getEnsAvatarQueryKey(options),\n } as const satisfies QueryOptions<\n GetEnsAvatarQueryFnData,\n GetEnsAvatarErrorType,\n GetEnsAvatarData,\n GetEnsAvatarQueryKey<config>\n >\n}\n\nexport type GetEnsAvatarQueryFnData = GetEnsAvatarReturnType\n\nexport type GetEnsAvatarData = GetEnsAvatarQueryFnData\n\nexport function getEnsAvatarQueryKey<config extends Config>(\n options: GetEnsAvatarOptions<config> = {},\n) {\n return ['ensAvatar', filterQueryOptions(options)] as const\n}\n\nexport type GetEnsAvatarQueryKey<config extends Config> = ReturnType<\n typeof getEnsAvatarQueryKey<config>\n>\n", "import type { QueryOptions } from '@tanstack/query-core'\n\nimport {\n type GetEnsNameErrorType,\n type GetEnsNameParameters,\n type GetEnsNameReturnType,\n getEnsName,\n} from '../actions/getEnsName.js'\nimport type { Config } from '../createConfig.js'\nimport type { ScopeKeyParameter } from '../types/properties.js'\nimport type { Compute, ExactPartial } from '../types/utils.js'\nimport { filterQueryOptions } from './utils.js'\n\nexport type GetEnsNameOptions<config extends Config> = Compute<\n ExactPartial<GetEnsNameParameters<config>> & ScopeKeyParameter\n>\n\nexport function getEnsNameQueryOptions<config extends Config>(\n config: config,\n options: GetEnsNameOptions<config> = {},\n) {\n return {\n async queryFn({ queryKey }) {\n const { address, scopeKey: _, ...parameters } = queryKey[1]\n if (!address) throw new Error('address is required')\n return getEnsName(config, { ...parameters, address })\n },\n queryKey: getEnsNameQueryKey(options),\n } as const satisfies QueryOptions<\n GetEnsNameQueryFnData,\n GetEnsNameErrorType,\n GetEnsNameData,\n GetEnsNameQueryKey<config>\n >\n}\n\nexport type GetEnsNameQueryFnData = GetEnsNameReturnType\n\nexport type GetEnsNameData = GetEnsNameQueryFnData\n\nexport function getEnsNameQueryKey<config extends Config>(\n options: GetEnsNameOptions<config> = {},\n) {\n return ['ensName', filterQueryOptions(options)] as const\n}\n\nexport type GetEnsNameQueryKey<config extends Config> = ReturnType<\n typeof getEnsNameQueryKey<config>\n>\n", "import type { QueryOptions } from '@tanstack/query-core'\n\nimport {\n type GetEnsResolverErrorType,\n type GetEnsResolverParameters,\n type GetEnsResolverReturnType,\n getEnsResolver,\n} from '../actions/getEnsResolver.js'\nimport type { Config } from '../createConfig.js'\nimport type { ScopeKeyParameter } from '../types/properties.js'\nimport type { Compute, ExactPartial } from '../types/utils.js'\nimport { filterQueryOptions } from './utils.js'\n\nexport type GetEnsResolverOptions<config extends Config> = Compute<\n ExactPartial<GetEnsResolverParameters<config>> & ScopeKeyParameter\n>\n\nexport function getEnsResolverQueryOptions<config extends Config>(\n config: config,\n options: GetEnsResolverOptions<config> = {},\n) {\n return {\n async queryFn({ queryKey }) {\n const { name, scopeKey: _, ...parameters } = queryKey[1]\n if (!name) throw new Error('name is required')\n return getEnsResolver(config, { ...parameters, name })\n },\n queryKey: getEnsResolverQueryKey(options),\n } as const satisfies QueryOptions<\n GetEnsResolverQueryFnData,\n GetEnsResolverErrorType,\n GetEnsResolverData,\n GetEnsResolverQueryKey<config>\n >\n}\n\nexport type GetEnsResolverQueryFnData = GetEnsResolverReturnType\n\nexport type GetEnsResolverData = GetEnsResolverQueryFnData\n\nexport function getEnsResolverQueryKey<config extends Config>(\n options: GetEnsResolverOptions<config> = {},\n) {\n return ['ensResolver', filterQueryOptions(options)] as const\n}\n\nexport type GetEnsResolverQueryKey<config extends Config> = ReturnType<\n typeof getEnsResolverQueryKey<config>\n>\n", "import type { QueryOptions } from '@tanstack/query-core'\n\nimport {\n type GetEnsTextErrorType,\n type GetEnsTextParameters,\n type GetEnsTextReturnType,\n getEnsText,\n} from '../actions/getEnsText.js'\nimport type { Config } from '../createConfig.js'\nimport type { ScopeKeyParameter } from '../types/properties.js'\nimport type { Compute, ExactPartial } from '../types/utils.js'\nimport { filterQueryOptions } from './utils.js'\n\nexport type GetEnsTextOptions<config extends Config> = Compute<\n ExactPartial<GetEnsTextParameters<config>> & ScopeKeyParameter\n>\n\nexport function getEnsTextQueryOptions<config extends Config>(\n config: config,\n options: GetEnsTextOptions<config> = {},\n) {\n return {\n async queryFn({ queryKey }) {\n const { key, name, scopeKey: _, ...parameters } = queryKey[1]\n if (!key || !name) throw new Error('key and name are required')\n return getEnsText(config, { ...parameters, key, name })\n },\n queryKey: getEnsTextQueryKey(options),\n } as const satisfies QueryOptions<\n GetEnsTextQueryFnData,\n GetEnsTextErrorType,\n GetEnsTextData,\n GetEnsTextQueryKey<config>\n >\n}\n\nexport type GetEnsTextQueryFnData = GetEnsTextReturnType\n\nexport type GetEnsTextData = GetEnsTextQueryFnData\n\nexport function getEnsTextQueryKey<config extends Config>(\n options: GetEnsTextOptions<config> = {},\n) {\n return ['ensText', filterQueryOptions(options)] as const\n}\n\nexport type GetEnsTextQueryKey<config extends Config> = ReturnType<\n typeof getEnsTextQueryKey<config>\n>\n", "import type { QueryOptions } from '@tanstack/query-core'\n\nimport {\n type GetFeeHistoryErrorType,\n type GetFeeHistoryParameters,\n type GetFeeHistoryReturnType,\n getFeeHistory,\n} from '../actions/getFeeHistory.js'\nimport type { Config } from '../createConfig.js'\nimport type { ScopeKeyParameter } from '../types/properties.js'\nimport type { Compute, PartialBy } from '../types/utils.js'\nimport { filterQueryOptions } from './utils.js'\n\nexport type GetFeeHistoryOptions<\n config extends Config,\n chainId extends config['chains'][number]['id'],\n> = Compute<\n PartialBy<\n GetFeeHistoryParameters<config, chainId>,\n 'blockCount' | 'rewardPercentiles'\n > &\n ScopeKeyParameter\n>\n\nexport function getFeeHistoryQueryOptions<\n config extends Config,\n chainId extends config['chains'][number]['id'],\n>(config: config, options: GetFeeHistoryOptions<config, chainId> = {}) {\n return {\n async queryFn({ queryKey }) {\n const {\n blockCount,\n rewardPercentiles,\n scopeKey: _,\n ...parameters\n } = queryKey[1]\n if (!blockCount) throw new Error('blockCount is required')\n if (!rewardPercentiles) throw new Error('rewardPercentiles is required')\n const feeHistory = await getFeeHistory(config, {\n ...(parameters as GetFeeHistoryParameters),\n blockCount,\n rewardPercentiles,\n })\n return feeHistory ?? null\n },\n queryKey: getFeeHistoryQueryKey(options),\n } as const satisfies QueryOptions<\n GetFeeHistoryQueryFnData,\n GetFeeHistoryErrorType,\n GetFeeHistoryData,\n GetFeeHistoryQueryKey<config, chainId>\n >\n}\n\nexport type GetFeeHistoryQueryFnData = GetFeeHistoryReturnType\n\nexport type GetFeeHistoryData = GetFeeHistoryQueryFnData\n\nexport function getFeeHistoryQueryKey<\n config extends Config,\n chainId extends config['chains'][number]['id'],\n>(options: GetFeeHistoryOptions<config, chainId> = {}) {\n return ['feeHistory', filterQueryOptions(options)] as const\n}\n\nexport type GetFeeHistoryQueryKey<\n config extends Config,\n chainId extends config['chains'][number]['id'],\n> = ReturnType<typeof getFeeHistoryQueryKey<config, chainId>>\n", "import type { QueryOptions } from '@tanstack/query-core'\n\nimport {\n type GetGasPriceErrorType,\n type GetGasPriceParameters,\n type GetGasPriceReturnType,\n getGasPrice,\n} from '../actions/getGasPrice.js'\nimport type { Config } from '../createConfig.js'\nimport type { ScopeKeyParameter } from '../types/properties.js'\nimport type { Compute, ExactPartial } from '../types/utils.js'\nimport { filterQueryOptions } from './utils.js'\n\nexport type GetGasPriceOptions<\n config extends Config,\n chainId extends config['chains'][number]['id'],\n> = Compute<\n ExactPartial<GetGasPriceParameters<config, chainId>> & ScopeKeyParameter\n>\n\nexport function getGasPriceQueryOptions<\n config extends Config,\n chainId extends config['chains'][number]['id'],\n>(config: config, options: GetGasPriceOptions<config, chainId> = {}) {\n return {\n async queryFn({ queryKey }) {\n const { scopeKey: _, ...parameters } = queryKey[1]\n const gasPrice = await getGasPrice(config, parameters)\n return gasPrice ?? null\n },\n queryKey: getGasPriceQueryKey(options),\n } as const satisfies QueryOptions<\n GetGasPriceQueryFnData,\n GetGasPriceErrorType,\n GetGasPriceData,\n GetGasPriceQueryKey<config, chainId>\n >\n}\n\nexport type GetGasPriceQueryFnData = GetGasPriceReturnType\n\nexport type GetGasPriceData = GetGasPriceQueryFnData\n\nexport function getGasPriceQueryKey<\n config extends Config,\n chainId extends config['chains'][number]['id'],\n>(options: GetGasPriceOptions<config, chainId> = {}) {\n return ['gasPrice', filterQueryOptions(options)] as const\n}\n\nexport type GetGasPriceQueryKey<\n config extends Config,\n chainId extends config['chains'][number]['id'],\n> = ReturnType<typeof getGasPriceQueryKey<config, chainId>>\n", "import type { QueryOptions } from '@tanstack/query-core'\n\nimport {\n type GetProofErrorType,\n type GetProofParameters,\n type GetProofReturnType,\n getProof,\n} from '../actions/getProof.js'\nimport type { Config } from '../createConfig.js'\nimport type { ScopeKeyParameter } from '../types/properties.js'\nimport type { Compute, ExactPartial } from '../types/utils.js'\nimport { filterQueryOptions } from './utils.js'\n\nexport type GetProofOptions<config extends Config> = Compute<\n ExactPartial<GetProofParameters<config>> & ScopeKeyParameter\n>\n\nexport function getProofQueryOptions<config extends Config>(\n config: config,\n options: GetProofOptions<config> = {},\n) {\n return {\n async queryFn({ queryKey }) {\n const { address, scopeKey: _, storageKeys, ...parameters } = queryKey[1]\n if (!address || !storageKeys)\n throw new Error('address and storageKeys are required')\n return getProof(config, { ...parameters, address, storageKeys })\n },\n queryKey: getProofQueryKey(options),\n } as const satisfies QueryOptions<\n GetProofQueryFnData,\n GetProofErrorType,\n GetProofData,\n GetProofQueryKey<config>\n >\n}\n\nexport type GetProofQueryFnData = GetProofReturnType\n\nexport type GetProofData = GetProofQueryFnData\n\nexport function getProofQueryKey<config extends Config>(\n options: GetProofOptions<config>,\n) {\n return ['getProof', filterQueryOptions(options)] as const\n}\n\nexport type GetProofQueryKey<config extends Config> = ReturnType<\n typeof getProofQueryKey<config>\n>\n", "import type { QueryOptions } from '@tanstack/query-core'\n\nimport {\n type GetStorageAtErrorType,\n type GetStorageAtParameters,\n type GetStorageAtReturnType,\n getStorageAt,\n} from '../actions/getStorageAt.js'\nimport type { Config } from '../createConfig.js'\nimport type { ScopeKeyParameter } from '../types/properties.js'\nimport type { Compute, ExactPartial } from '../types/utils.js'\nimport { filterQueryOptions } from './utils.js'\n\nexport type GetStorageAtOptions<config extends Config> = Compute<\n ExactPartial<GetStorageAtParameters<config>> & ScopeKeyParameter\n>\n\nexport function getStorageAtQueryOptions<config extends Config>(\n config: config,\n options: GetStorageAtOptions<config> = {},\n) {\n return {\n queryFn({ queryKey }) {\n const { address, slot, scopeKey: _, ...parameters } = queryKey[1]\n if (!address || !slot) throw new Error('address and slot are required')\n return getStorageAt(config, { ...parameters, address, slot })\n },\n queryKey: getStorageAtQueryKey(options),\n } as const satisfies QueryOptions<\n GetStorageAtQueryFnData,\n GetStorageAtErrorType,\n GetStorageAtData,\n GetStorageAtQueryKey<config>\n >\n}\n\nexport type GetStorageAtQueryFnData = GetStorageAtReturnType\n\nexport type GetStorageAtData = GetStorageAtQueryFnData\n\nexport function getStorageAtQueryKey<config extends Config>(\n options: GetStorageAtOptions<config>,\n) {\n return ['getStorageAt', filterQueryOptions(options)] as const\n}\n\nexport type GetStorageAtQueryKey<config extends Config> = ReturnType<\n typeof getStorageAtQueryKey<config>\n>\n", "import type { QueryOptions } from '@tanstack/query-core'\n\nimport {\n type GetTokenErrorType,\n type GetTokenParameters,\n type GetTokenReturnType,\n getToken,\n} from '../actions/getToken.js'\nimport type { Config } from '../createConfig.js'\nimport type { ScopeKeyParameter } from '../types/properties.js'\nimport type { Compute, ExactPartial } from '../types/utils.js'\nimport { filterQueryOptions } from './utils.js'\n\nexport type GetTokenOptions<config extends Config> = Compute<\n ExactPartial<GetTokenParameters<config>> & ScopeKeyParameter\n>\n\nexport function getTokenQueryOptions<config extends Config>(\n config: config,\n options: GetTokenOptions<config> = {},\n) {\n return {\n async queryFn({ queryKey }) {\n const { address, scopeKey: _, ...parameters } = queryKey[1]\n if (!address) throw new Error('address is required')\n return getToken(config, { ...parameters, address })\n },\n queryKey: getTokenQueryKey(options),\n } as const satisfies QueryOptions<\n GetTokenQueryFnData,\n GetTokenErrorType,\n GetTokenData,\n GetTokenQueryKey<config>\n >\n}\n\nexport type GetTokenQueryFnData = GetTokenReturnType\n\nexport type GetTokenData = GetTokenQueryFnData\n\nexport function getTokenQueryKey<config extends Config>(\n options: GetTokenOptions<config> = {},\n) {\n return ['token', filterQueryOptions(options)] as const\n}\n\nexport type GetTokenQueryKey<config extends Config> = ReturnType<\n typeof getTokenQueryKey<config>\n>\n", "import type { QueryOptions } from '@tanstack/query-core'\n\nimport {\n type GetTransactionErrorType,\n type GetTransactionParameters,\n type GetTransactionReturnType,\n getTransaction,\n} from '../actions/getTransaction.js'\nimport type { Config } from '../createConfig.js'\nimport type { ScopeKeyParameter } from '../types/properties.js'\nimport type { Compute, ExactPartial } from '../types/utils.js'\nimport { filterQueryOptions } from './utils.js'\n\nexport type GetTransactionOptions<\n config extends Config,\n chainId extends config['chains'][number]['id'],\n> = Compute<\n ExactPartial<GetTransactionParameters<config, chainId>> & ScopeKeyParameter\n>\n\nexport function getTransactionQueryOptions<\n config extends Config,\n chainId extends config['chains'][number]['id'],\n>(config: config, options: GetTransactionOptions<config, chainId> = {}) {\n return {\n async queryFn({ queryKey }) {\n const { blockHash, blockNumber, blockTag, hash, index } = queryKey[1]\n if (!blockHash && !blockNumber && !blockTag && !hash)\n throw new Error('blockHash, blockNumber, blockTag, or hash is required')\n if (!hash && !index)\n throw new Error(\n 'index is required for blockHash, blockNumber, or blockTag',\n )\n const { scopeKey: _, ...rest } = queryKey[1]\n return getTransaction(\n config,\n rest as GetTransactionParameters,\n ) as unknown as Promise<GetTransactionQueryFnData<config, chainId>>\n },\n queryKey: getTransactionQueryKey(options),\n } as const satisfies QueryOptions<\n GetTransactionQueryFnData<config, chainId>,\n GetTransactionErrorType,\n GetTransactionData<config, chainId>,\n GetTransactionQueryKey<config, chainId>\n >\n}\n\nexport type GetTransactionQueryFnData<\n config extends Config,\n chainId extends config['chains'][number]['id'],\n> = GetTransactionReturnType<config, chainId>\n\nexport type GetTransactionData<\n config extends Config,\n chainId extends config['chains'][number]['id'],\n> = GetTransactionQueryFnData<config, chainId>\n\nexport function getTransactionQueryKey<\n config extends Config,\n chainId extends config['chains'][number]['id'],\n>(options: GetTransactionOptions<config, chainId> = {}) {\n return ['transaction', filterQueryOptions(options)] as const\n}\n\nexport type GetTransactionQueryKey<\n config extends Config,\n chainId extends config['chains'][number]['id'],\n> = ReturnType<typeof getTransactionQueryKey<config, chainId>>\n", "import type { QueryOptions } from '@tanstack/query-core'\n\nimport {\n type GetTransactionConfirmationsErrorType,\n type GetTransactionConfirmationsParameters,\n type GetTransactionConfirmationsReturnType,\n getTransactionConfirmations,\n} from '../actions/getTransactionConfirmations.js'\nimport type { Config } from '../createConfig.js'\nimport type { ScopeKeyParameter } from '../types/properties.js'\nimport type { UnionExactPartial } from '../types/utils.js'\nimport { filterQueryOptions } from './utils.js'\n\nexport type GetTransactionConfirmationsOptions<\n config extends Config,\n chainId extends\n | config['chains'][number]['id']\n | undefined = config['chains'][number]['id'],\n> = UnionExactPartial<GetTransactionConfirmationsParameters<config, chainId>> &\n ScopeKeyParameter\n\nexport function getTransactionConfirmationsQueryOptions<\n config extends Config,\n chainId extends\n | config['chains'][number]['id']\n | undefined = config['chains'][number]['id'],\n>(\n config: config,\n options: GetTransactionConfirmationsOptions<config, chainId> = {} as any,\n) {\n return {\n async queryFn({ queryKey }) {\n const {\n hash,\n transactionReceipt,\n scopeKey: _,\n ...parameters\n } = queryKey[1]\n if (!hash && !transactionReceipt)\n throw new Error('hash or transactionReceipt is required')\n\n const confirmations = await getTransactionConfirmations(config, {\n hash,\n transactionReceipt,\n ...(parameters as any),\n })\n return confirmations ?? null\n },\n queryKey: getTransactionConfirmationsQueryKey(options),\n } as const satisfies QueryOptions<\n GetTransactionConfirmationsQueryFnData,\n GetTransactionConfirmationsErrorType,\n GetTransactionConfirmationsData,\n GetTransactionConfirmationsQueryKey<config, chainId>\n >\n}\n\nexport type GetTransactionConfirmationsQueryFnData =\n GetTransactionConfirmationsReturnType\n\nexport type GetTransactionConfirmationsData =\n GetTransactionConfirmationsQueryFnData\n\nexport function getTransactionConfirmationsQueryKey<\n config extends Config,\n chainId extends\n | config['chains'][number]['id']\n | undefined = config['chains'][number]['id'],\n>(options: GetTransactionConfirmationsOptions<config, chainId> = {} as any) {\n return ['transactionConfirmations', filterQueryOptions(options)] as const\n}\n\nexport type GetTransactionConfirmationsQueryKey<\n config extends Config,\n chainId extends\n | config['chains'][number]['id']\n | undefined = config['chains'][number]['id'],\n> = ReturnType<typeof getTransactionConfirmationsQueryKey<config, chainId>>\n", "import type { QueryOptions } from '@tanstack/query-core'\n\nimport {\n type GetTransactionCountErrorType,\n type GetTransactionCountParameters,\n type GetTransactionCountReturnType,\n getTransactionCount,\n} from '../actions/getTransactionCount.js'\nimport type { Config } from '../createConfig.js'\nimport type { ScopeKeyParameter } from '../types/properties.js'\nimport type { Compute, PartialBy } from '../types/utils.js'\nimport { filterQueryOptions } from './utils.js'\n\nexport type GetTransactionCountOptions<config extends Config> = Compute<\n PartialBy<GetTransactionCountParameters<config>, 'address'> &\n ScopeKeyParameter\n>\n\nexport function getTransactionCountQueryOptions<config extends Config>(\n config: config,\n options: GetTransactionCountOptions<config> = {},\n) {\n return {\n async queryFn({ queryKey }) {\n const { address, scopeKey: _, ...parameters } = queryKey[1]\n if (!address) throw new Error('address is required')\n const transactionCount = await getTransactionCount(config, {\n ...(parameters as GetTransactionCountParameters),\n address,\n })\n return transactionCount ?? null\n },\n queryKey: getTransactionCountQueryKey(options),\n } as const satisfies QueryOptions<\n GetTransactionCountQueryFnData,\n GetTransactionCountErrorType,\n GetTransactionCountData,\n GetTransactionCountQueryKey<config>\n >\n}\n\nexport type GetTransactionCountQueryFnData =\n Compute<GetTransactionCountReturnType>\n\nexport type GetTransactionCountData = GetTransactionCountQueryFnData\n\nexport function getTransactionCountQueryKey<config extends Config>(\n options: GetTransactionCountOptions<config> = {},\n) {\n return ['transactionCount', filterQueryOptions(options)] as const\n}\n\nexport type GetTransactionCountQueryKey<config extends Config> = ReturnType<\n typeof getTransactionCountQueryKey<config>\n>\n", "import type { QueryOptions } from '@tanstack/query-core'\n\nimport {\n type GetTransactionReceiptErrorType,\n type GetTransactionReceiptParameters,\n getTransactionReceipt,\n} from '../actions/getTransactionReceipt.js'\nimport type { GetTransactionReceiptReturnType } from '../actions/getTransactionReceipt.js'\nimport type { Config } from '../createConfig.js'\nimport type { ScopeKeyParameter } from '../types/properties.js'\nimport type { Compute, ExactPartial } from '../types/utils.js'\nimport { filterQueryOptions } from './utils.js'\n\nexport type GetTransactionReceiptOptions<\n config extends Config,\n chainId extends config['chains'][number]['id'],\n> = Compute<\n ExactPartial<GetTransactionReceiptParameters<config, chainId>> &\n ScopeKeyParameter\n>\n\nexport function getTransactionReceiptQueryOptions<\n config extends Config,\n chainId extends config['chains'][number]['id'],\n>(config: config, options: GetTransactionReceiptOptions<config, chainId> = {}) {\n return {\n queryFn({ queryKey }) {\n const { hash, scopeKey: _, ...parameters } = queryKey[1]\n if (!hash) throw new Error('hash is required')\n return getTransactionReceipt(config, { ...parameters, hash })\n },\n queryKey: getTransactionReceiptQueryKey(options),\n } as const satisfies QueryOptions<\n GetTransactionReceiptQueryFnData<config, chainId>,\n GetTransactionReceiptErrorType,\n GetTransactionReceiptData<config, chainId>,\n GetTransactionReceiptQueryKey<config, chainId>\n >\n}\nexport type GetTransactionReceiptQueryFnData<\n config extends Config,\n chainId extends config['chains'][number]['id'],\n> = GetTransactionReceiptReturnType<config, chainId>\n\nexport type GetTransactionReceiptData<\n config extends Config,\n chainId extends config['chains'][number]['id'],\n> = GetTransactionReceiptQueryFnData<config, chainId>\n\nexport function getTransactionReceiptQueryKey<\n config extends Config,\n chainId extends config['chains'][number]['id'],\n>(options: GetTransactionReceiptOptions<config, chainId>) {\n return ['getTransactionReceipt', filterQueryOptions(options)] as const\n}\n\nexport type GetTransactionReceiptQueryKey<\n config extends Config,\n chainId extends config['chains'][number]['id'],\n> = ReturnType<typeof getTransactionReceiptQueryKey<config, chainId>>\n", "import type { QueryOptions } from '@tanstack/query-core'\n\nimport {\n type GetWalletClientErrorType,\n type GetWalletClientParameters,\n type GetWalletClientReturnType,\n getWalletClient,\n} from '../actions/getWalletClient.js'\nimport type { Config } from '../createConfig.js'\nimport type { ScopeKeyParameter } from '../types/properties.js'\nimport type { Compute, ExactPartial } from '../types/utils.js'\nimport { filterQueryOptions } from './utils.js'\n\nexport type GetWalletClientOptions<\n config extends Config,\n chainId extends config['chains'][number]['id'],\n> = Compute<\n ExactPartial<GetWalletClientParameters<config, chainId>> & ScopeKeyParameter\n>\n\nexport function getWalletClientQueryOptions<\n config extends Config,\n chainId extends config['chains'][number]['id'],\n>(config: config, options: GetWalletClientOptions<config, chainId> = {}) {\n return {\n gcTime: 0,\n async queryFn({ queryKey }) {\n const { connector } = options\n const { connectorUid: _, scopeKey: _s, ...parameters } = queryKey[1]\n return getWalletClient(config, { ...parameters, connector })\n },\n queryKey: getWalletClientQueryKey(options),\n } as const satisfies QueryOptions<\n GetWalletClientQueryFnData<config, chainId>,\n GetWalletClientErrorType,\n GetWalletClientData<config, chainId>,\n GetWalletClientQueryKey<config, chainId>\n >\n}\n\nexport type GetWalletClientQueryFnData<\n config extends Config,\n chainId extends config['chains'][number]['id'],\n> = GetWalletClientReturnType<config, chainId>\n\nexport type GetWalletClientData<\n config extends Config,\n chainId extends config['chains'][number]['id'],\n> = GetWalletClientQueryFnData<config, chainId>\n\nexport function getWalletClientQueryKey<\n config extends Config,\n chainId extends config['chains'][number]['id'],\n>(options: GetWalletClientOptions<config, chainId> = {}) {\n const { connector, ...parameters } = options\n return [\n 'walletClient',\n { ...filterQueryOptions(parameters), connectorUid: connector?.uid },\n ] as const\n}\n\nexport type GetWalletClientQueryKey<\n config extends Config,\n chainId extends config['chains'][number]['id'],\n> = ReturnType<typeof getWalletClientQueryKey<config, chainId>>\n", "import type { ContractFunctionParameters } from 'viem'\nimport {\n type ReadContractsErrorType,\n type ReadContractsParameters,\n type ReadContractsReturnType,\n readContracts,\n} from '../actions/readContracts.js'\nimport type { Config } from '../createConfig.js'\nimport type {\n ChainIdParameter,\n ScopeKeyParameter,\n} from '../types/properties.js'\nimport type { StrictOmit } from '../types/utils.js'\nimport type { InfiniteQueryOptions } from './types.js'\nimport { filterQueryOptions } from './utils.js'\n\nexport type InfiniteReadContractsOptions<\n contracts extends readonly unknown[],\n allowFailure extends boolean,\n pageParam,\n config extends Config,\n> = {\n cacheKey: string\n contracts(\n pageParam: pageParam,\n ): ReadContractsParameters<contracts, allowFailure, config>['contracts']\n} & StrictOmit<\n ReadContractsParameters<contracts, allowFailure, config>,\n 'contracts'\n> &\n ScopeKeyParameter\n\nexport function infiniteReadContractsQueryOptions<\n config extends Config,\n const contracts extends readonly ContractFunctionParameters[],\n allowFailure extends boolean = true,\n pageParam = unknown,\n>(\n config: config,\n options: InfiniteReadContractsOptions<\n contracts,\n allowFailure,\n pageParam,\n config\n > &\n ChainIdParameter<config> &\n RequiredPageParamsParameters<contracts, allowFailure, pageParam>,\n) {\n return {\n ...options.query,\n async queryFn({ pageParam, queryKey }) {\n const { contracts } = options\n const { cacheKey: _, scopeKey: _s, ...parameters } = queryKey[1]\n return (await readContracts(config, {\n ...parameters,\n contracts: contracts(pageParam as any),\n })) as ReadContractsReturnType<contracts, allowFailure>\n },\n queryKey: infiniteReadContractsQueryKey(options),\n } as const satisfies InfiniteQueryOptions<\n InfiniteReadContractsQueryFnData<contracts, allowFailure>,\n ReadContractsErrorType,\n InfiniteReadContractsData<contracts, allowFailure>,\n InfiniteReadContractsData<contracts, allowFailure>,\n InfiniteReadContractsQueryKey<contracts, allowFailure, pageParam, config>,\n pageParam\n >\n}\n\ntype RequiredPageParamsParameters<\n contracts extends readonly unknown[],\n allowFailure extends boolean,\n pageParam,\n> = {\n query: {\n initialPageParam: pageParam\n getNextPageParam(\n lastPage: InfiniteReadContractsQueryFnData<contracts, allowFailure>,\n allPages: InfiniteReadContractsQueryFnData<contracts, allowFailure>[],\n lastPageParam: pageParam,\n allPageParams: pageParam[],\n ): pageParam | undefined | null\n }\n}\n\nexport type InfiniteReadContractsQueryFnData<\n contracts extends readonly unknown[],\n allowFailure extends boolean,\n> = ReadContractsReturnType<contracts, allowFailure>\n\nexport type InfiniteReadContractsData<\n contracts extends readonly unknown[],\n allowFailure extends boolean,\n> = InfiniteReadContractsQueryFnData<contracts, allowFailure>\n\nexport function infiniteReadContractsQueryKey<\n config extends Config,\n const contracts extends readonly unknown[],\n allowFailure extends boolean,\n pageParam,\n>(\n options: InfiniteReadContractsOptions<\n contracts,\n allowFailure,\n pageParam,\n config\n > &\n ChainIdParameter<config> &\n RequiredPageParamsParameters<contracts, allowFailure, pageParam>,\n) {\n const { contracts: _, query: _q, ...parameters } = options\n return ['infiniteReadContracts', filterQueryOptions(parameters)] as const\n}\n\nexport type InfiniteReadContractsQueryKey<\n contracts extends readonly unknown[],\n allowFailure extends boolean,\n pageParam,\n config extends Config,\n> = ReturnType<\n typeof infiniteReadContractsQueryKey<\n config,\n contracts,\n allowFailure,\n pageParam\n >\n>\n", "import type { QueryOptions } from '@tanstack/query-core'\n\nimport type { PrepareTransactionRequestRequest as viem_PrepareTransactionRequestRequest } from 'viem'\n\nimport {\n type PrepareTransactionRequestErrorType,\n type PrepareTransactionRequestParameters,\n type PrepareTransactionRequestReturnType,\n prepareTransactionRequest,\n} from '../actions/prepareTransactionRequest.js'\nimport type { Config } from '../createConfig.js'\nimport type { SelectChains } from '../types/chain.js'\nimport type { ScopeKeyParameter } from '../types/properties.js'\nimport type { UnionExactPartial } from '../types/utils.js'\nimport { filterQueryOptions } from './utils.js'\n\nexport type PrepareTransactionRequestOptions<\n config extends Config,\n chainId extends config['chains'][number]['id'] | undefined,\n request extends viem_PrepareTransactionRequestRequest<\n SelectChains<config, chainId>[0],\n SelectChains<config, chainId>[0]\n >,\n> = UnionExactPartial<\n PrepareTransactionRequestParameters<config, chainId, request>\n> &\n ScopeKeyParameter\n\nexport function prepareTransactionRequestQueryOptions<\n config extends Config,\n chainId extends config['chains'][number]['id'] | undefined,\n request extends viem_PrepareTransactionRequestRequest<\n SelectChains<config, chainId>[0],\n SelectChains<config, chainId>[0]\n >,\n>(\n config: config,\n options: PrepareTransactionRequestOptions<\n config,\n chainId,\n request\n > = {} as any,\n) {\n return {\n queryFn({ queryKey }) {\n const { scopeKey: _, to, ...parameters } = queryKey[1]\n if (!to) throw new Error('to is required')\n return prepareTransactionRequest(config, {\n to,\n ...(parameters as any),\n }) as unknown as Promise<\n PrepareTransactionRequestQueryFnData<config, chainId, request>\n >\n },\n queryKey: prepareTransactionRequestQueryKey(options),\n } as const satisfies QueryOptions<\n PrepareTransactionRequestQueryFnData<config, chainId, request>,\n PrepareTransactionRequestErrorType,\n PrepareTransactionRequestData<config, chainId, request>,\n PrepareTransactionRequestQueryKey<config, chainId, request>\n >\n}\nexport type PrepareTransactionRequestQueryFnData<\n config extends Config,\n chainId extends config['chains'][number]['id'] | undefined,\n request extends viem_PrepareTransactionRequestRequest<\n SelectChains<config, chainId>[0],\n SelectChains<config, chainId>[0]\n >,\n> = PrepareTransactionRequestReturnType<config, chainId, request>\n\nexport type PrepareTransactionRequestData<\n config extends Config,\n chainId extends config['chains'][number]['id'] | undefined,\n request extends viem_PrepareTransactionRequestRequest<\n SelectChains<config, chainId>[0],\n SelectChains<config, chainId>[0]\n >,\n> = PrepareTransactionRequestQueryFnData<config, chainId, request>\n\nexport function prepareTransactionRequestQueryKey<\n config extends Config,\n chainId extends config['chains'][number]['id'] | undefined,\n request extends viem_PrepareTransactionRequestRequest<\n SelectChains<config, chainId>[0],\n SelectChains<config, chainId>[0]\n >,\n>(options: PrepareTransactionRequestOptions<config, chainId, request>) {\n return ['prepareTransactionRequest', filterQueryOptions(options)] as const\n}\n\nexport type PrepareTransactionRequestQueryKey<\n config extends Config,\n chainId extends config['chains'][number]['id'] | undefined,\n request extends viem_PrepareTransactionRequestRequest<\n SelectChains<config, chainId>[0],\n SelectChains<config, chainId>[0]\n >,\n> = ReturnType<\n typeof prepareTransactionRequestQueryKey<config, chainId, request>\n>\n", "import type { QueryOptions } from '@tanstack/query-core'\nimport type { Abi, ContractFunctionArgs, ContractFunctionName } from 'viem'\n\nimport {\n type ReadContractErrorType,\n type ReadContractParameters,\n type ReadContractReturnType,\n readContract,\n} from '../actions/readContract.js'\nimport type { Config } from '../createConfig.js'\nimport type { ScopeKeyParameter } from '../types/properties.js'\nimport type { UnionExactPartial } from '../types/utils.js'\nimport { filterQueryOptions } from './utils.js'\n\nexport type ReadContractOptions<\n abi extends Abi | readonly unknown[],\n functionName extends ContractFunctionName<abi, 'pure' | 'view'>,\n args extends ContractFunctionArgs<abi, 'pure' | 'view', functionName>,\n config extends Config,\n> = UnionExactPartial<ReadContractParameters<abi, functionName, args, config>> &\n ScopeKeyParameter\n\nexport function readContractQueryOptions<\n config extends Config,\n const abi extends Abi | readonly unknown[],\n functionName extends ContractFunctionName<abi, 'pure' | 'view'>,\n args extends ContractFunctionArgs<abi, 'pure' | 'view', functionName>,\n>(\n config: config,\n options: ReadContractOptions<abi, functionName, args, config> = {} as any,\n) {\n return {\n // TODO: Support `signal` once Viem actions allow passthrough\n // https://tkdodo.eu/blog/why-you-want-react-query#bonus-cancellation\n async queryFn({ queryKey }) {\n const abi = options.abi as Abi\n if (!abi) throw new Error('abi is required')\n\n const { functionName, scopeKey: _, ...parameters } = queryKey[1]\n const addressOrCodeParams = (() => {\n const params = queryKey[1] as unknown as ReadContractParameters\n if (params.address) return { address: params.address }\n if (params.code) return { code: params.code }\n throw new Error('address or code is required')\n })()\n\n if (!functionName) throw new Error('functionName is required')\n\n return readContract(config, {\n abi,\n functionName,\n args: parameters.args as readonly unknown[],\n ...addressOrCodeParams,\n ...parameters,\n }) as Promise<ReadContractData<abi, functionName, args>>\n },\n queryKey: readContractQueryKey(options as any) as any,\n } as const satisfies QueryOptions<\n ReadContractQueryFnData<abi, functionName, args>,\n ReadContractErrorType,\n ReadContractData<abi, functionName, args>,\n ReadContractQueryKey<abi, functionName, args, config>\n >\n}\n\nexport type ReadContractQueryFnData<\n abi extends Abi | readonly unknown[],\n functionName extends ContractFunctionName<abi, 'pure' | 'view'>,\n args extends ContractFunctionArgs<abi, 'pure' | 'view', functionName>,\n> = ReadContractReturnType<abi, functionName, args>\n\nexport type ReadContractData<\n abi extends Abi | readonly unknown[],\n functionName extends ContractFunctionName<abi, 'pure' | 'view'>,\n args extends ContractFunctionArgs<abi, 'pure' | 'view', functionName>,\n> = ReadContractQueryFnData<abi, functionName, args>\n\nexport function readContractQueryKey<\n config extends Config,\n const abi extends Abi | readonly unknown[],\n functionName extends ContractFunctionName<abi, 'pure' | 'view'>,\n args extends ContractFunctionArgs<abi, 'pure' | 'view', functionName>,\n>(options: ReadContractOptions<abi, functionName, args, config> = {} as any) {\n const { abi: _, ...rest } = options\n return ['readContract', filterQueryOptions(rest)] as const\n}\n\nexport type ReadContractQueryKey<\n abi extends Abi | readonly unknown[],\n functionName extends ContractFunctionName<abi, 'pure' | 'view'>,\n args extends ContractFunctionArgs<abi, 'pure' | 'view', functionName>,\n config extends Config,\n> = ReturnType<typeof readContractQueryKey<config, abi, functionName, args>>\n", "import type { QueryOptions } from '@tanstack/query-core'\nimport type {\n ContractFunctionParameters,\n MulticallParameters as viem_MulticallParameters,\n} from 'viem'\n\nimport {\n type ReadContractsErrorType,\n type ReadContractsReturnType,\n readContracts,\n} from '../actions/readContracts.js'\nimport type { Config } from '../createConfig.js'\nimport type { ChainIdParameter } from '../types/properties.js'\nimport type { ScopeKeyParameter } from '../types/properties.js'\nimport type { ExactPartial } from '../types/utils.js'\nimport { filterQueryOptions } from './utils.js'\n\nexport type ReadContractsOptions<\n contracts extends readonly unknown[],\n allowFailure extends boolean,\n config extends Config,\n> = ExactPartial<\n viem_MulticallParameters<\n contracts,\n allowFailure,\n { optional: true; properties: ChainIdParameter<config> }\n >\n> &\n ScopeKeyParameter\n\nexport function readContractsQueryOptions<\n config extends Config,\n const contracts extends readonly unknown[],\n allowFailure extends boolean = true,\n>(\n config: config,\n options: ReadContractsOptions<contracts, allowFailure, config> &\n ChainIdParameter<config> = {},\n) {\n return {\n async queryFn({ queryKey }) {\n const contracts: ContractFunctionParameters[] = []\n const length = queryKey[1].contracts.length\n for (let i = 0; i < length; i++) {\n const contract = queryKey[1].contracts[i]!\n const abi = (options.contracts?.[i] as ContractFunctionParameters).abi\n contracts.push({ ...contract, abi })\n }\n const { scopeKey: _, ...parameters } = queryKey[1]\n return readContracts(config, {\n ...parameters,\n contracts,\n }) as Promise<ReadContractsReturnType<contracts, allowFailure>>\n },\n queryKey: readContractsQueryKey(options),\n } as const satisfies QueryOptions<\n ReadContractsQueryFnData<contracts, allowFailure>,\n ReadContractsErrorType,\n ReadContractsData<contracts, allowFailure>,\n ReadContractsQueryKey<contracts, allowFailure, config>\n >\n}\n\nexport type ReadContractsQueryFnData<\n contracts extends readonly unknown[],\n allowFailure extends boolean,\n> = ReadContractsReturnType<contracts, allowFailure>\n\nexport type ReadContractsData<\n contracts extends readonly unknown[],\n allowFailure extends boolean,\n> = ReadContractsQueryFnData<contracts, allowFailure>\n\nexport function readContractsQueryKey<\n config extends Config,\n const contracts extends readonly unknown[],\n allowFailure extends boolean,\n>(\n options: ReadContractsOptions<contracts, allowFailure, config> &\n ChainIdParameter<config> = {},\n) {\n const contracts = []\n for (const contract of (options.contracts ??\n []) as (ContractFunctionParameters & { chainId: number })[]) {\n const { abi: _, ...rest } = contract\n contracts.push({ ...rest, chainId: rest.chainId ?? options.chainId })\n }\n return [\n 'readContracts',\n filterQueryOptions({ ...options, contracts }),\n ] as const\n}\n\nexport type ReadContractsQueryKey<\n contracts extends readonly unknown[],\n allowFailure extends boolean,\n config extends Config,\n> = ReturnType<typeof readContractsQueryKey<config, contracts, allowFailure>>\n", "import type { MutationOptions } from '@tanstack/query-core'\n\nimport {\n type ReconnectErrorType,\n type ReconnectParameters,\n type ReconnectReturnType,\n reconnect,\n} from '../actions/reconnect.js'\nimport type { Config } from '../createConfig.js'\nimport type { Compute } from '../types/utils.js'\nimport type { Mutate, MutateAsync } from './types.js'\n\nexport function reconnectMutationOptions(config: Config) {\n return {\n mutationFn(variables) {\n return reconnect(config, variables)\n },\n mutationKey: ['reconnect'],\n } as const satisfies MutationOptions<\n ReconnectData,\n ReconnectErrorType,\n ReconnectVariables\n >\n}\n\nexport type ReconnectData = Compute<ReconnectReturnType>\n\nexport type ReconnectVariables = ReconnectParameters | undefined\n\nexport type ReconnectMutate<context = unknown> = Mutate<\n ReconnectData,\n ReconnectErrorType,\n ReconnectVariables,\n context\n>\n\nexport type ReconnectMutateAsync<context = unknown> = MutateAsync<\n ReconnectData,\n ReconnectErrorType,\n ReconnectVariables,\n context\n>\n", "import type { MutateOptions, MutationOptions } from '@tanstack/query-core'\n\nimport {\n type SendTransactionErrorType,\n type SendTransactionParameters,\n type SendTransactionReturnType,\n sendTransaction,\n} from '../actions/sendTransaction.js'\nimport type { Config } from '../createConfig.js'\nimport type { Compute } from '../types/utils.js'\n\nexport function sendTransactionMutationOptions<config extends Config>(\n config: config,\n) {\n return {\n mutationFn(variables) {\n return sendTransaction(config, variables)\n },\n mutationKey: ['sendTransaction'],\n } as const satisfies MutationOptions<\n SendTransactionData,\n SendTransactionErrorType,\n SendTransactionVariables<config, config['chains'][number]['id']>\n >\n}\n\nexport type SendTransactionData = Compute<SendTransactionReturnType>\n\nexport type SendTransactionVariables<\n config extends Config,\n chainId extends config['chains'][number]['id'],\n> = SendTransactionParameters<config, chainId>\n\nexport type SendTransactionMutate<config extends Config, context = unknown> = <\n chainId extends config['chains'][number]['id'],\n>(\n variables: SendTransactionVariables<config, chainId>,\n options?:\n | Compute<\n MutateOptions<\n SendTransactionData,\n SendTransactionErrorType,\n Compute<SendTransactionVariables<config, chainId>>,\n context\n >\n >\n | undefined,\n) => void\n\nexport type SendTransactionMutateAsync<\n config extends Config,\n context = unknown,\n> = <chainId extends config['chains'][number]['id']>(\n variables: SendTransactionVariables<config, chainId>,\n options?:\n | Compute<\n MutateOptions<\n SendTransactionData,\n SendTransactionErrorType,\n Compute<SendTransactionVariables<config, chainId>>,\n context\n >\n >\n | undefined,\n) => Promise<SendTransactionData>\n", "import type { MutationOptions } from '@tanstack/query-core'\n\nimport {\n type SignMessageErrorType,\n type SignMessageParameters,\n type SignMessageReturnType,\n signMessage,\n} from '../actions/signMessage.js'\nimport type { Config } from '../createConfig.js'\nimport type { Compute } from '../types/utils.js'\nimport type { Mutate, MutateAsync } from './types.js'\n\nexport function signMessageMutationOptions(config: Config) {\n return {\n mutationFn(variables) {\n return signMessage(config, variables)\n },\n mutationKey: ['signMessage'],\n } as const satisfies MutationOptions<\n SignMessageData,\n SignMessageErrorType,\n SignMessageVariables\n >\n}\n\nexport type SignMessageData = SignMessageReturnType\n\nexport type SignMessageVariables = Compute<SignMessageParameters>\n\nexport type SignMessageMutate<context = unknown> = Mutate<\n SignMessageData,\n SignMessageErrorType,\n SignMessageVariables,\n context\n>\n\nexport type SignMessageMutateAsync<context = unknown> = MutateAsync<\n SignMessageData,\n SignMessageErrorType,\n SignMessageVariables,\n context\n>\n", "import type { MutateOptions, MutationOptions } from '@tanstack/query-core'\n\nimport type { TypedData } from 'viem'\nimport {\n type SignTypedDataErrorType,\n type SignTypedDataParameters,\n type SignTypedDataReturnType,\n signTypedData,\n} from '../actions/signTypedData.js'\nimport type { Config } from '../createConfig.js'\nimport type { Compute } from '../types/utils.js'\n\nexport function signTypedDataMutationOptions<config extends Config>(\n config: config,\n) {\n return {\n mutationFn(variables) {\n return signTypedData(config, variables)\n },\n mutationKey: ['signTypedData'],\n } as const satisfies MutationOptions<\n SignTypedDataData,\n SignTypedDataErrorType,\n SignTypedDataVariables\n >\n}\n\nexport type SignTypedDataData = Compute<SignTypedDataReturnType>\n\nexport type SignTypedDataVariables<\n typedData extends TypedData | Record<string, unknown> = TypedData,\n primaryType extends keyof typedData | 'EIP712Domain' = keyof typedData,\n ///\n primaryTypes = typedData extends TypedData ? keyof typedData : string,\n> = SignTypedDataParameters<typedData, primaryType, primaryTypes>\n\nexport type SignTypedDataMutate<context = unknown> = <\n const typedData extends TypedData | Record<string, unknown>,\n primaryType extends keyof typedData | 'EIP712Domain',\n>(\n variables: SignTypedDataVariables<typedData, primaryType>,\n options?:\n | MutateOptions<\n SignTypedDataData,\n SignTypedDataErrorType,\n SignTypedDataVariables<\n typedData,\n primaryType,\n // use `primaryType` to make sure it's not union of all possible primary types\n primaryType\n >,\n context\n >\n | undefined,\n) => void\n\nexport type SignTypedDataMutateAsync<context = unknown> = <\n const typedData extends TypedData | Record<string, unknown>,\n primaryType extends keyof typedData | 'EIP712Domain',\n>(\n variables: SignTypedDataVariables<typedData, primaryType>,\n options?:\n | MutateOptions<\n SignTypedDataData,\n SignTypedDataErrorType,\n SignTypedDataVariables<\n typedData,\n primaryType,\n // use `primaryType` to make sure it's not union of all possible primary types\n primaryType\n >,\n context\n >\n | undefined,\n) => Promise<SignTypedDataData>\n", "import type { MutationOptions } from '@tanstack/query-core'\n\nimport {\n type SwitchAccountErrorType,\n type SwitchAccountParameters,\n type SwitchAccountReturnType,\n switchAccount,\n} from '../actions/switchAccount.js'\nimport type { Config } from '../createConfig.js'\nimport type { Compute } from '../types/utils.js'\nimport type { Mutate, MutateAsync } from './types.js'\n\nexport function switchAccountMutationOptions<config extends Config>(\n config: config,\n) {\n return {\n mutationFn(variables) {\n return switchAccount(config, variables)\n },\n mutationKey: ['switchAccount'],\n } as const satisfies MutationOptions<\n SwitchAccountData<config>,\n SwitchAccountErrorType,\n SwitchAccountVariables\n >\n}\n\nexport type SwitchAccountData<config extends Config> = Compute<\n SwitchAccountReturnType<config>\n>\n\nexport type SwitchAccountVariables = Compute<SwitchAccountParameters>\n\nexport type SwitchAccountMutate<\n config extends Config,\n context = unknown,\n> = Mutate<\n SwitchAccountData<config>,\n SwitchAccountErrorType,\n SwitchAccountVariables,\n context\n>\n\nexport type SwitchAccountMutateAsync<\n config extends Config,\n context = unknown,\n> = MutateAsync<\n SwitchAccountData<config>,\n SwitchAccountErrorType,\n SwitchAccountVariables,\n context\n>\n", "import type { QueryOptions } from '@tanstack/query-core'\nimport type { Abi, ContractFunctionArgs, ContractFunctionName } from 'viem'\n\nimport {\n type SimulateContractErrorType,\n type SimulateContractParameters,\n type SimulateContractReturnType,\n simulateContract,\n} from '../actions/simulateContract.js'\nimport type { Config } from '../createConfig.js'\nimport type { ScopeKeyParameter } from '../types/properties.js'\nimport type { UnionExactPartial } from '../types/utils.js'\nimport { filterQueryOptions } from './utils.js'\n\nexport type SimulateContractOptions<\n abi extends Abi | readonly unknown[],\n functionName extends ContractFunctionName<abi, 'nonpayable' | 'payable'>,\n args extends ContractFunctionArgs<\n abi,\n 'nonpayable' | 'payable',\n functionName\n >,\n config extends Config,\n chainId extends config['chains'][number]['id'] | undefined,\n> = UnionExactPartial<\n SimulateContractParameters<abi, functionName, args, config, chainId>\n> &\n ScopeKeyParameter\n\nexport function simulateContractQueryOptions<\n config extends Config,\n const abi extends Abi | readonly unknown[],\n functionName extends ContractFunctionName<abi, 'nonpayable' | 'payable'>,\n args extends ContractFunctionArgs<\n abi,\n 'nonpayable' | 'payable',\n functionName\n >,\n chainId extends config['chains'][number]['id'] | undefined,\n>(\n config: config,\n options: SimulateContractOptions<\n abi,\n functionName,\n args,\n config,\n chainId\n > = {} as any,\n) {\n return {\n async queryFn({ queryKey }) {\n const { abi, connector } = options\n if (!abi) throw new Error('abi is required')\n const { scopeKey: _, ...parameters } = queryKey[1]\n const { address, functionName } = parameters\n if (!address) throw new Error('address is required')\n if (!functionName) throw new Error('functionName is required')\n return simulateContract(config, {\n abi,\n connector,\n ...(parameters as any),\n })\n },\n queryKey: simulateContractQueryKey(options),\n } as const satisfies QueryOptions<\n SimulateContractQueryFnData<abi, functionName, args, config, chainId>,\n SimulateContractErrorType,\n SimulateContractData<abi, functionName, args, config, chainId>,\n SimulateContractQueryKey<abi, functionName, args, config, chainId>\n >\n}\n\nexport type SimulateContractQueryFnData<\n abi extends Abi | readonly unknown[],\n functionName extends ContractFunctionName<abi, 'nonpayable' | 'payable'>,\n args extends ContractFunctionArgs<\n abi,\n 'nonpayable' | 'payable',\n functionName\n >,\n config extends Config,\n chainId extends config['chains'][number]['id'] | undefined,\n> = SimulateContractReturnType<abi, functionName, args, config, chainId>\n\nexport type SimulateContractData<\n abi extends Abi | readonly unknown[],\n functionName extends ContractFunctionName<abi, 'nonpayable' | 'payable'>,\n args extends ContractFunctionArgs<\n abi,\n 'nonpayable' | 'payable',\n functionName\n >,\n config extends Config,\n chainId extends config['chains'][number]['id'] | undefined,\n> = SimulateContractQueryFnData<abi, functionName, args, config, chainId>\n\nexport function simulateContractQueryKey<\n config extends Config,\n abi extends Abi | readonly unknown[],\n functionName extends ContractFunctionName<abi, 'nonpayable' | 'payable'>,\n args extends ContractFunctionArgs<\n abi,\n 'nonpayable' | 'payable',\n functionName\n >,\n chainId extends config['chains'][number]['id'] | undefined,\n>(\n options: SimulateContractOptions<\n abi,\n functionName,\n args,\n config,\n chainId\n > = {} as any,\n) {\n const { abi: _, connector: _c, ...rest } = options\n return ['simulateContract', filterQueryOptions(rest)] as const\n}\n\nexport type SimulateContractQueryKey<\n abi extends Abi | readonly unknown[],\n functionName extends ContractFunctionName<abi, 'nonpayable' | 'payable'>,\n args extends ContractFunctionArgs<\n abi,\n 'nonpayable' | 'payable',\n functionName\n >,\n config extends Config,\n chainId extends config['chains'][number]['id'] | undefined,\n> = ReturnType<\n typeof simulateContractQueryKey<config, abi, functionName, args, chainId>\n>\n", "import type { MutateOptions, MutationOptions } from '@tanstack/query-core'\n\nimport {\n type SwitchChainErrorType,\n type SwitchChainParameters,\n type SwitchChainReturnType,\n switchChain,\n} from '../actions/switchChain.js'\nimport type { Config } from '../createConfig.js'\nimport type { Compute } from '../types/utils.js'\n\nexport function switchChainMutationOptions<config extends Config>(\n config: config,\n) {\n return {\n mutationFn(variables) {\n return switchChain(config, variables)\n },\n mutationKey: ['switchChain'],\n } as const satisfies MutationOptions<\n SwitchChainData<config, config['chains'][number]['id']>,\n SwitchChainErrorType,\n SwitchChainVariables<config, config['chains'][number]['id']>\n >\n}\n\nexport type SwitchChainData<\n config extends Config,\n chainId extends config['chains'][number]['id'],\n> = Compute<SwitchChainReturnType<config, chainId>>\n\nexport type SwitchChainVariables<\n config extends Config,\n chainId extends config['chains'][number]['id'],\n> = Compute<SwitchChainParameters<config, chainId>>\n\nexport type SwitchChainMutate<config extends Config, context = unknown> = <\n chainId extends config['chains'][number]['id'],\n>(\n variables: SwitchChainVariables<config, chainId>,\n options?:\n | Compute<\n MutateOptions<\n SwitchChainData<config, chainId>,\n SwitchChainErrorType,\n Compute<SwitchChainVariables<config, chainId>>,\n context\n >\n >\n | undefined,\n) => void\n\nexport type SwitchChainMutateAsync<config extends Config, context = unknown> = <\n chainId extends config['chains'][number]['id'],\n>(\n variables: SwitchChainVariables<config, chainId>,\n options?:\n | Compute<\n MutateOptions<\n SwitchChainData<config, chainId>,\n SwitchChainErrorType,\n Compute<SwitchChainVariables<config, chainId>>,\n context\n >\n >\n | undefined,\n) => Promise<SwitchChainData<config, chainId>>\n", "import type { QueryOptions } from '@tanstack/query-core'\n\nimport {\n type VerifyMessageErrorType,\n type VerifyMessageParameters,\n type VerifyMessageReturnType,\n verifyMessage,\n} from '../actions/verifyMessage.js'\nimport type { Config } from '../createConfig.js'\nimport type { ScopeKeyParameter } from '../types/properties.js'\nimport type { Compute, ExactPartial } from '../types/utils.js'\nimport { filterQueryOptions } from './utils.js'\n\nexport type VerifyMessageOptions<config extends Config> = Compute<\n ExactPartial<VerifyMessageParameters<config>> & ScopeKeyParameter\n>\n\nexport function verifyMessageQueryOptions<config extends Config>(\n config: config,\n options: VerifyMessageOptions<config> = {},\n) {\n return {\n async queryFn({ queryKey }) {\n const { address, message, signature } = queryKey[1]\n if (!address || !message || !signature)\n throw new Error('address, message, and signature are required')\n\n const { scopeKey: _, ...parameters } = queryKey[1]\n\n const verified = await verifyMessage(\n config,\n parameters as VerifyMessageParameters,\n )\n return verified ?? null\n },\n queryKey: verifyMessageQueryKey(options),\n } as const satisfies QueryOptions<\n VerifyMessageQueryFnData,\n VerifyMessageErrorType,\n VerifyMessageData,\n VerifyMessageQueryKey<config>\n >\n}\nexport type VerifyMessageQueryFnData = VerifyMessageReturnType\n\nexport type VerifyMessageData = VerifyMessageQueryFnData\n\nexport function verifyMessageQueryKey<config extends Config>(\n options: VerifyMessageOptions<config>,\n) {\n return ['verifyMessage', filterQueryOptions(options)] as const\n}\n\nexport type VerifyMessageQueryKey<config extends Config> = ReturnType<\n typeof verifyMessageQueryKey<config>\n>\n", "import type { QueryOptions } from '@tanstack/query-core'\nimport type { TypedData } from 'viem'\n\nimport {\n type VerifyTypedDataErrorType,\n type VerifyTypedDataParameters,\n type VerifyTypedDataReturnType,\n verifyTypedData,\n} from '../actions/verifyTypedData.js'\nimport type { Config } from '../createConfig.js'\nimport type { ScopeKeyParameter } from '../types/properties.js'\nimport type { ExactPartial } from '../types/utils.js'\nimport { filterQueryOptions } from './utils.js'\n\nexport type VerifyTypedDataOptions<\n typedData extends TypedData | Record<string, unknown>,\n primaryType extends keyof typedData | 'EIP712Domain',\n config extends Config,\n> = ExactPartial<VerifyTypedDataParameters<typedData, primaryType, config>> &\n ScopeKeyParameter\n\nexport function verifyTypedDataQueryOptions<\n config extends Config,\n const typedData extends TypedData | Record<string, unknown>,\n primaryType extends keyof typedData | 'EIP712Domain',\n>(\n config: config,\n options: VerifyTypedDataOptions<typedData, primaryType, config> = {} as any,\n) {\n return {\n async queryFn({ queryKey }) {\n const {\n address,\n message,\n primaryType,\n signature,\n types,\n scopeKey: _,\n ...parameters\n } = queryKey[1]\n if (!address) throw new Error('address is required')\n if (!message) throw new Error('message is required')\n if (!primaryType) throw new Error('primaryType is required')\n if (!signature) throw new Error('signature is required')\n if (!types) throw new Error('types is required')\n\n const verified = await verifyTypedData(config, {\n ...parameters,\n address,\n message,\n primaryType,\n signature,\n types,\n } as VerifyTypedDataParameters)\n return verified ?? null\n },\n queryKey: verifyTypedDataQueryKey(options),\n } as const satisfies QueryOptions<\n VerifyTypedDataQueryFnData,\n VerifyTypedDataErrorType,\n VerifyTypedDataData,\n VerifyTypedDataQueryKey<typedData, primaryType, config>\n >\n}\n\nexport type VerifyTypedDataQueryFnData = VerifyTypedDataReturnType\n\nexport type VerifyTypedDataData = VerifyTypedDataQueryFnData\n\nexport function verifyTypedDataQueryKey<\n config extends Config,\n const typedData extends TypedData | Record<string, unknown>,\n primaryType extends keyof typedData | 'EIP712Domain',\n>(options: VerifyTypedDataOptions<typedData, primaryType, config>) {\n return ['verifyTypedData', filterQueryOptions(options)] as const\n}\n\nexport type VerifyTypedDataQueryKey<\n typedData extends TypedData | Record<string, unknown>,\n primaryType extends keyof typedData | 'EIP712Domain',\n config extends Config,\n> = ReturnType<typeof verifyTypedDataQueryKey<config, typedData, primaryType>>\n", "import type { QueryOptions } from '@tanstack/query-core'\n\nimport {\n type WaitForTransactionReceiptErrorType,\n type WaitForTransactionReceiptParameters,\n type WaitForTransactionReceiptReturnType,\n waitForTransactionReceipt,\n} from '../actions/waitForTransactionReceipt.js'\nimport type { Config } from '../createConfig.js'\nimport type { ScopeKeyParameter } from '../types/properties.js'\nimport type { Compute, ExactPartial } from '../types/utils.js'\nimport { filterQueryOptions } from './utils.js'\n\nexport type WaitForTransactionReceiptOptions<\n config extends Config,\n chainId extends config['chains'][number]['id'],\n> = Compute<\n ExactPartial<WaitForTransactionReceiptParameters<config, chainId>> &\n ScopeKeyParameter\n>\n\nexport function waitForTransactionReceiptQueryOptions<\n config extends Config,\n chainId extends config['chains'][number]['id'],\n>(\n config: config,\n options: WaitForTransactionReceiptOptions<config, chainId> = {},\n) {\n return {\n async queryFn({ queryKey }) {\n const { hash, ...parameters } = queryKey[1]\n if (!hash) throw new Error('hash is required')\n return waitForTransactionReceipt(config, {\n ...parameters,\n onReplaced: options.onReplaced,\n hash,\n }) as unknown as Promise<\n WaitForTransactionReceiptReturnType<config, chainId>\n >\n },\n queryKey: waitForTransactionReceiptQueryKey(options),\n } as const satisfies QueryOptions<\n WaitForTransactionReceiptQueryFnData<config, chainId>,\n WaitForTransactionReceiptErrorType,\n WaitForTransactionReceiptData<config, chainId>,\n WaitForTransactionReceiptQueryKey<config, chainId>\n >\n}\n\nexport type WaitForTransactionReceiptQueryFnData<\n config extends Config,\n chainId extends config['chains'][number]['id'],\n> = WaitForTransactionReceiptReturnType<config, chainId>\n\nexport type WaitForTransactionReceiptData<\n config extends Config,\n chainId extends config['chains'][number]['id'],\n> = WaitForTransactionReceiptQueryFnData<config, chainId>\n\nexport function waitForTransactionReceiptQueryKey<\n config extends Config,\n chainId extends config['chains'][number]['id'],\n>(options: WaitForTransactionReceiptOptions<config, chainId> = {}) {\n const { onReplaced: _, ...rest } = options\n return ['waitForTransactionReceipt', filterQueryOptions(rest)] as const\n}\n\nexport type WaitForTransactionReceiptQueryKey<\n config extends Config,\n chainId extends config['chains'][number]['id'],\n> = ReturnType<typeof waitForTransactionReceiptQueryKey<config, chainId>>\n", "import type { MutationOptions } from '@tanstack/query-core'\n\nimport {\n type WatchAssetErrorType,\n type WatchAssetParameters,\n type WatchAssetReturnType,\n watchAsset,\n} from '../actions/watchAsset.js'\nimport type { Config } from '../createConfig.js'\nimport type { Compute } from '../types/utils.js'\nimport type { Mutate, MutateAsync } from './types.js'\n\nexport function watchAssetMutationOptions(config: Config) {\n return {\n mutationFn(variables) {\n return watchAsset(config, variables)\n },\n mutationKey: ['watchAsset'],\n } as const satisfies MutationOptions<\n WatchAssetData,\n WatchAssetErrorType,\n WatchAssetVariables\n >\n}\n\nexport type WatchAssetData = WatchAssetReturnType\n\nexport type WatchAssetVariables = Compute<WatchAssetParameters>\n\nexport type WatchAssetMutate<context = unknown> = Mutate<\n WatchAssetData,\n WatchAssetErrorType,\n WatchAssetVariables,\n context\n>\n\nexport type WatchAssetMutateAsync<context = unknown> = MutateAsync<\n WatchAssetData,\n WatchAssetErrorType,\n WatchAssetVariables,\n context\n>\n", "import type { MutateOptions, MutationOptions } from '@tanstack/query-core'\nimport type { Abi, ContractFunctionArgs, ContractFunctionName } from 'viem'\n\nimport {\n type WriteContractErrorType,\n type WriteContractParameters,\n type WriteContractReturnType,\n writeContract,\n} from '../actions/writeContract.js'\nimport type { Config } from '../createConfig.js'\nimport type { Compute } from '../types/utils.js'\n\nexport function writeContractMutationOptions<config extends Config>(\n config: config,\n) {\n return {\n mutationFn(variables) {\n return writeContract(config, variables)\n },\n mutationKey: ['writeContract'],\n } as const satisfies MutationOptions<\n WriteContractData,\n WriteContractErrorType,\n WriteContractVariables<\n Abi,\n string,\n readonly unknown[],\n config,\n config['chains'][number]['id']\n >\n >\n}\n\nexport type WriteContractData = Compute<WriteContractReturnType>\n\nexport type WriteContractVariables<\n abi extends Abi | readonly unknown[],\n functionName extends ContractFunctionName<abi, 'nonpayable' | 'payable'>,\n args extends ContractFunctionArgs<\n abi,\n 'nonpayable' | 'payable',\n functionName\n >,\n config extends Config,\n chainId extends config['chains'][number]['id'],\n ///\n allFunctionNames = ContractFunctionName<abi, 'nonpayable' | 'payable'>,\n> = WriteContractParameters<\n abi,\n functionName,\n args,\n config,\n chainId,\n allFunctionNames\n>\n\nexport type WriteContractMutate<config extends Config, context = unknown> = <\n const abi extends Abi | readonly unknown[],\n functionName extends ContractFunctionName<abi, 'nonpayable' | 'payable'>,\n args extends ContractFunctionArgs<\n abi,\n 'nonpayable' | 'payable',\n functionName\n >,\n chainId extends config['chains'][number]['id'],\n>(\n variables: WriteContractVariables<abi, functionName, args, config, chainId>,\n options?:\n | MutateOptions<\n WriteContractData,\n WriteContractErrorType,\n WriteContractVariables<\n abi,\n functionName,\n args,\n config,\n chainId,\n // use `functionName` to make sure it's not union of all possible function names\n functionName\n >,\n context\n >\n | undefined,\n) => void\n\nexport type WriteContractMutateAsync<\n config extends Config,\n context = unknown,\n> = <\n const abi extends Abi | readonly unknown[],\n functionName extends ContractFunctionName<abi, 'nonpayable' | 'payable'>,\n args extends ContractFunctionArgs<\n abi,\n 'nonpayable' | 'payable',\n functionName\n >,\n chainId extends config['chains'][number]['id'],\n>(\n variables: WriteContractVariables<abi, functionName, args, config, chainId>,\n options?:\n | MutateOptions<\n WriteContractData,\n WriteContractErrorType,\n WriteContractVariables<\n abi,\n functionName,\n args,\n config,\n chainId,\n // use `functionName` to make sure it's not union of all possible function names\n functionName\n >,\n context\n >\n | undefined,\n) => Promise<WriteContractData>\n", "import {\n type DefaultError,\n type QueryKey,\n type UseInfiniteQueryOptions,\n type UseInfiniteQueryResult,\n type UseMutationOptions,\n type UseMutationResult,\n type UseQueryOptions,\n type UseQueryResult,\n useInfiniteQuery as tanstack_useInfiniteQuery,\n useQuery as tanstack_useQuery,\n useMutation,\n} from '@tanstack/react-query'\nimport type {\n Compute,\n ExactPartial,\n Omit,\n UnionStrictOmit,\n} from '@wagmi/core/internal'\nimport { hashFn } from '@wagmi/core/query'\n\nexport type UseMutationParameters<\n data = unknown,\n error = Error,\n variables = void,\n context = unknown,\n> = Compute<\n Omit<\n UseMutationOptions<data, error, Compute<variables>, context>,\n 'mutationFn' | 'mutationKey' | 'throwOnError'\n >\n>\n\nexport type UseMutationReturnType<\n data = unknown,\n error = Error,\n variables = void,\n context = unknown,\n> = Compute<\n UnionStrictOmit<\n UseMutationResult<data, error, variables, context>,\n 'mutate' | 'mutateAsync'\n >\n>\n\nexport { useMutation }\n\n////////////////////////////////////////////////////////////////////////////////\n\nexport type UseQueryParameters<\n queryFnData = unknown,\n error = DefaultError,\n data = queryFnData,\n queryKey extends QueryKey = QueryKey,\n> = Compute<\n ExactPartial<\n Omit<UseQueryOptions<queryFnData, error, data, queryKey>, 'initialData'>\n > & {\n // Fix `initialData` type\n initialData?:\n | UseQueryOptions<queryFnData, error, data, queryKey>['initialData']\n | undefined\n }\n>\n\nexport type UseQueryReturnType<data = unknown, error = DefaultError> = Compute<\n UseQueryResult<data, error> & {\n queryKey: QueryKey\n }\n>\n\n// Adding some basic customization.\n// Ideally we don't have this function, but `import('@tanstack/react-query').useQuery` currently has some quirks where it is super hard to\n// pass down the inferred `initialData` type because of it's discriminated overload in the on `useQuery`.\nexport function useQuery<queryFnData, error, data, queryKey extends QueryKey>(\n parameters: UseQueryParameters<queryFnData, error, data, queryKey> & {\n queryKey: QueryKey\n },\n): UseQueryReturnType<data, error> {\n const result = tanstack_useQuery({\n ...(parameters as any),\n queryKeyHashFn: hashFn, // for bigint support\n }) as UseQueryReturnType<data, error>\n result.queryKey = parameters.queryKey\n return result\n}\n\n////////////////////////////////////////////////////////////////////////////////\n\nexport type UseInfiniteQueryParameters<\n queryFnData = unknown,\n error = DefaultError,\n data = queryFnData,\n queryData = queryFnData,\n queryKey extends QueryKey = QueryKey,\n pageParam = unknown,\n> = Compute<\n Omit<\n UseInfiniteQueryOptions<\n queryFnData,\n error,\n data,\n queryData,\n queryKey,\n pageParam\n >,\n 'initialData'\n > & {\n // Fix `initialData` type\n initialData?:\n | UseInfiniteQueryOptions<\n queryFnData,\n error,\n data,\n queryKey\n >['initialData']\n | undefined\n }\n>\n\nexport type UseInfiniteQueryReturnType<\n data = unknown,\n error = DefaultError,\n> = UseInfiniteQueryResult<data, error> & {\n queryKey: QueryKey\n}\n\n// Adding some basic customization.\nexport function useInfiniteQuery<\n queryFnData,\n error,\n data,\n queryKey extends QueryKey,\n>(\n parameters: UseInfiniteQueryParameters<queryFnData, error, data, queryKey> & {\n queryKey: QueryKey\n },\n): UseInfiniteQueryReturnType<data, error> {\n const result = tanstack_useInfiniteQuery({\n ...(parameters as any),\n queryKeyHashFn: hashFn, // for bigint support\n }) as UseInfiniteQueryReturnType<data, error>\n result.queryKey = parameters.queryKey\n return result\n}\n", "'use client'\n\nimport {\n type Config,\n type GetChainIdReturnType,\n type ResolvedRegister,\n getChainId,\n watchChainId,\n} from '@wagmi/core'\nimport { useSyncExternalStore } from 'react'\n\nimport type { ConfigParameter } from '../types/properties.js'\nimport { useConfig } from './useConfig.js'\n\nexport type UseChainIdParameters<config extends Config = Config> =\n ConfigParameter<config>\n\nexport type UseChainIdReturnType<config extends Config = Config> =\n GetChainIdReturnType<config>\n\n/** https://wagmi.sh/react/api/hooks/useChainId */\nexport function useChainId<config extends Config = ResolvedRegister['config']>(\n parameters: UseChainIdParameters<config> = {},\n): UseChainIdReturnType<config> {\n const config = useConfig(parameters)\n\n return useSyncExternalStore(\n (onChange) => watchChainId(config, { onChange }),\n () => getChainId(config),\n () => getChainId(config),\n )\n}\n", "'use client'\n\nimport type { Config, GetBalanceErrorType, ResolvedRegister } from '@wagmi/core'\nimport type { Compute } from '@wagmi/core/internal'\nimport {\n type GetBalanceData,\n type GetBalanceOptions,\n type GetBalanceQueryKey,\n getBalanceQueryOptions,\n} from '@wagmi/core/query'\nimport type { GetBalanceQueryFnData } from '@wagmi/core/query'\n\nimport type { ConfigParameter, QueryParameter } from '../types/properties.js'\nimport { type UseQueryReturnType, useQuery } from '../utils/query.js'\nimport { useChainId } from './useChainId.js'\nimport { useConfig } from './useConfig.js'\n\nexport type UseBalanceParameters<\n config extends Config = Config,\n selectData = GetBalanceData,\n> = Compute<\n GetBalanceOptions<config> &\n ConfigParameter<config> &\n QueryParameter<\n GetBalanceQueryFnData,\n GetBalanceErrorType,\n selectData,\n GetBalanceQueryKey<config>\n >\n>\n\nexport type UseBalanceReturnType<selectData = GetBalanceData> =\n UseQueryReturnType<selectData, GetBalanceErrorType>\n\n/** https://wagmi.sh/react/api/hooks/useBalance */\nexport function useBalance<\n config extends Config = ResolvedRegister['config'],\n selectData = GetBalanceData,\n>(\n parameters: UseBalanceParameters<config, selectData> = {},\n): UseBalanceReturnType<selectData> {\n const { address, query = {} } = parameters\n\n const config = useConfig(parameters)\n const chainId = useChainId({ config })\n\n const options = getBalanceQueryOptions(config, {\n ...parameters,\n chainId: parameters.chainId ?? chainId,\n })\n const enabled = Boolean(address && (query.enabled ?? true))\n\n return useQuery({ ...query, ...options, enabled })\n}\n", "'use client'\n\nimport {\n type Config,\n type ResolvedRegister,\n type WatchBlocksParameters,\n watchBlocks,\n} from '@wagmi/core'\nimport type { UnionCompute, UnionExactPartial } from '@wagmi/core/internal'\nimport { useEffect } from 'react'\nimport type { BlockTag } from 'viem'\n\nimport type { ConfigParameter, EnabledParameter } from '../types/properties.js'\nimport { useChainId } from './useChainId.js'\nimport { useConfig } from './useConfig.js'\n\nexport type UseWatchBlocksParameters<\n includeTransactions extends boolean = false,\n blockTag extends BlockTag = 'latest',\n config extends Config = Config,\n chainId extends\n config['chains'][number]['id'] = config['chains'][number]['id'],\n> = UnionCompute<\n UnionExactPartial<\n WatchBlocksParameters<includeTransactions, blockTag, config, chainId>\n > &\n ConfigParameter<config> &\n EnabledParameter\n>\n\nexport type UseWatchBlocksReturnType = void\n\n/** https://wagmi.sh/react/hooks/useWatchBlocks */\nexport function useWatchBlocks<\n config extends Config = ResolvedRegister['config'],\n chainId extends\n config['chains'][number]['id'] = config['chains'][number]['id'],\n includeTransactions extends boolean = false,\n blockTag extends BlockTag = 'latest',\n>(\n parameters: UseWatchBlocksParameters<\n includeTransactions,\n blockTag,\n config,\n chainId\n > = {} as any,\n): UseWatchBlocksReturnType {\n const { enabled = true, onBlock, config: _, ...rest } = parameters\n\n const config = useConfig(parameters)\n const configChainId = useChainId({ config })\n const chainId = parameters.chainId ?? configChainId\n\n // TODO(react@19): cleanup\n // biome-ignore lint/correctness/useExhaustiveDependencies: `rest` changes every render so only including properties in dependency array\n useEffect(() => {\n if (!enabled) return\n if (!onBlock) return\n return watchBlocks(config, {\n ...(rest as any),\n chainId,\n onBlock,\n })\n }, [\n chainId,\n config,\n enabled,\n onBlock,\n ///\n rest.blockTag,\n rest.emitMissed,\n rest.emitOnBegin,\n rest.includeTransactions,\n rest.onError,\n rest.poll,\n rest.pollingInterval,\n rest.syncConnectedChain,\n ])\n}\n", "'use client'\n\nimport { useQueryClient } from '@tanstack/react-query'\nimport type { Config, GetBlockErrorType, ResolvedRegister } from '@wagmi/core'\nimport type {\n Compute,\n UnionCompute,\n UnionStrictOmit,\n} from '@wagmi/core/internal'\nimport {\n type GetBlockData,\n type GetBlockOptions,\n type GetBlockQueryFnData,\n type GetBlockQueryKey,\n getBlockQueryOptions,\n} from '@wagmi/core/query'\nimport type { BlockTag } from 'viem'\n\nimport type { ConfigParameter, QueryParameter } from '../types/properties.js'\nimport { type UseQueryReturnType, useQuery } from '../utils/query.js'\nimport { useChainId } from './useChainId.js'\nimport { useConfig } from './useConfig.js'\nimport {\n type UseWatchBlocksParameters,\n useWatchBlocks,\n} from './useWatchBlocks.js'\n\nexport type UseBlockParameters<\n includeTransactions extends boolean = false,\n blockTag extends BlockTag = 'latest',\n config extends Config = Config,\n chainId extends\n config['chains'][number]['id'] = config['chains'][number]['id'],\n selectData = GetBlockData<includeTransactions, blockTag, config, chainId>,\n> = Compute<\n GetBlockOptions<includeTransactions, blockTag, config, chainId> &\n ConfigParameter<config> &\n QueryParameter<\n GetBlockQueryFnData<includeTransactions, blockTag, config, chainId>,\n GetBlockErrorType,\n selectData,\n GetBlockQueryKey<includeTransactions, blockTag, config, chainId>\n > & {\n watch?:\n | boolean\n | UnionCompute<\n UnionStrictOmit<\n UseWatchBlocksParameters<\n includeTransactions,\n blockTag,\n config,\n chainId\n >,\n 'chainId' | 'config' | 'onBlock' | 'onError'\n >\n >\n | undefined\n }\n>\n\nexport type UseBlockReturnType<\n includeTransactions extends boolean = false,\n blockTag extends BlockTag = 'latest',\n config extends Config = Config,\n chainId extends\n config['chains'][number]['id'] = config['chains'][number]['id'],\n selectData = GetBlockData<includeTransactions, blockTag, config, chainId>,\n> = UseQueryReturnType<selectData, GetBlockErrorType>\n\n/** https://wagmi.sh/react/hooks/useBlock */\nexport function useBlock<\n includeTransactions extends boolean = false,\n blockTag extends BlockTag = 'latest',\n config extends Config = ResolvedRegister['config'],\n chainId extends\n config['chains'][number]['id'] = config['chains'][number]['id'],\n selectData = GetBlockData<includeTransactions, blockTag, config, chainId>,\n>(\n parameters: UseBlockParameters<\n includeTransactions,\n blockTag,\n config,\n chainId,\n selectData\n > = {},\n): UseBlockReturnType<\n includeTransactions,\n blockTag,\n config,\n chainId,\n selectData\n> {\n const { query = {}, watch } = parameters\n\n const config = useConfig(parameters)\n const queryClient = useQueryClient()\n const configChainId = useChainId({ config })\n const chainId = parameters.chainId ?? configChainId\n\n const options = getBlockQueryOptions(config, {\n ...parameters,\n chainId,\n })\n const enabled = Boolean(query.enabled ?? true)\n\n useWatchBlocks({\n ...({\n config: parameters.config,\n chainId: parameters.chainId!,\n ...(typeof watch === 'object' ? watch : {}),\n } as UseWatchBlocksParameters),\n enabled: Boolean(\n enabled && (typeof watch === 'object' ? watch.enabled : watch),\n ),\n onBlock(block) {\n queryClient.setQueryData(options.queryKey, block)\n },\n })\n\n return useQuery({\n ...(query as any),\n ...options,\n enabled,\n }) as UseBlockReturnType<\n includeTransactions,\n blockTag,\n config,\n chainId,\n selectData\n >\n}\n", "'use client'\n\nimport {\n type Config,\n type ResolvedRegister,\n type WatchBlockNumberParameters,\n watchBlockNumber,\n} from '@wagmi/core'\nimport type { UnionCompute, UnionExactPartial } from '@wagmi/core/internal'\nimport { useEffect } from 'react'\n\nimport type { ConfigParameter, EnabledParameter } from '../types/properties.js'\nimport { useChainId } from './useChainId.js'\nimport { useConfig } from './useConfig.js'\n\nexport type UseWatchBlockNumberParameters<\n config extends Config = Config,\n chainId extends\n config['chains'][number]['id'] = config['chains'][number]['id'],\n> = UnionCompute<\n UnionExactPartial<WatchBlockNumberParameters<config, chainId>> &\n ConfigParameter<config> &\n EnabledParameter\n>\n\nexport type UseWatchBlockNumberReturnType = void\n\n/** https://wagmi.sh/react/api/hooks/useWatchBlockNumber */\nexport function useWatchBlockNumber<\n config extends Config = ResolvedRegister['config'],\n chainId extends\n config['chains'][number]['id'] = config['chains'][number]['id'],\n>(\n parameters: UseWatchBlockNumberParameters<config, chainId> = {} as any,\n): UseWatchBlockNumberReturnType {\n const { enabled = true, onBlockNumber, config: _, ...rest } = parameters\n\n const config = useConfig(parameters)\n const configChainId = useChainId({ config })\n const chainId = parameters.chainId ?? configChainId\n\n // TODO(react@19): cleanup\n // biome-ignore lint/correctness/useExhaustiveDependencies: `rest` changes every render so only including properties in dependency array\n useEffect(() => {\n if (!enabled) return\n if (!onBlockNumber) return\n return watchBlockNumber(config, {\n ...(rest as any),\n chainId,\n onBlockNumber,\n })\n }, [\n chainId,\n config,\n enabled,\n onBlockNumber,\n ///\n rest.onError,\n rest.emitMissed,\n rest.emitOnBegin,\n rest.poll,\n rest.pollingInterval,\n rest.syncConnectedChain,\n ])\n}\n", "'use client'\n\nimport { useQueryClient } from '@tanstack/react-query'\nimport type {\n Config,\n GetBlockNumberErrorType,\n ResolvedRegister,\n} from '@wagmi/core'\nimport type {\n Compute,\n UnionCompute,\n UnionStrictOmit,\n} from '@wagmi/core/internal'\nimport {\n type GetBlockNumberData,\n type GetBlockNumberOptions,\n type GetBlockNumberQueryFnData,\n type GetBlockNumberQueryKey,\n getBlockNumberQueryOptions,\n} from '@wagmi/core/query'\n\nimport type { ConfigParameter, QueryParameter } from '../types/properties.js'\nimport { type UseQueryReturnType, useQuery } from '../utils/query.js'\nimport { useChainId } from './useChainId.js'\nimport { useConfig } from './useConfig.js'\nimport {\n type UseWatchBlockNumberParameters,\n useWatchBlockNumber,\n} from './useWatchBlockNumber.js'\n\nexport type UseBlockNumberParameters<\n config extends Config = Config,\n chainId extends\n config['chains'][number]['id'] = config['chains'][number]['id'],\n selectData = GetBlockNumberData,\n> = Compute<\n GetBlockNumberOptions<config, chainId> &\n ConfigParameter<config> &\n QueryParameter<\n GetBlockNumberQueryFnData,\n GetBlockNumberErrorType,\n selectData,\n GetBlockNumberQueryKey<config, chainId>\n > & {\n watch?:\n | boolean\n | UnionCompute<\n UnionStrictOmit<\n UseWatchBlockNumberParameters<config, chainId>,\n 'chainId' | 'config' | 'onBlockNumber' | 'onError'\n >\n >\n | undefined\n }\n>\n\nexport type UseBlockNumberReturnType<selectData = GetBlockNumberData> =\n UseQueryReturnType<selectData, GetBlockNumberErrorType>\n\n/** https://wagmi.sh/react/api/hooks/useBlockNumber */\nexport function useBlockNumber<\n config extends Config = ResolvedRegister['config'],\n chainId extends\n config['chains'][number]['id'] = config['chains'][number]['id'],\n selectData = GetBlockNumberData,\n>(\n parameters: UseBlockNumberParameters<config, chainId, selectData> = {},\n): UseBlockNumberReturnType<selectData> {\n const { query = {}, watch } = parameters\n\n const config = useConfig(parameters)\n const queryClient = useQueryClient()\n const configChainId = useChainId({ config })\n const chainId = parameters.chainId ?? configChainId\n\n const options = getBlockNumberQueryOptions(config, {\n ...parameters,\n chainId,\n })\n\n useWatchBlockNumber({\n ...({\n config: parameters.config,\n chainId: parameters.chainId,\n ...(typeof watch === 'object' ? watch : {}),\n } as UseWatchBlockNumberParameters),\n enabled: Boolean(\n (query.enabled ?? true) &&\n (typeof watch === 'object' ? watch.enabled : watch),\n ),\n onBlockNumber(blockNumber) {\n queryClient.setQueryData(options.queryKey, blockNumber)\n },\n })\n\n return useQuery({ ...query, ...options })\n}\n", "'use client'\n\nimport type {\n Config,\n GetBlockTransactionCountErrorType,\n ResolvedRegister,\n} from '@wagmi/core'\nimport type { UnionCompute } from '@wagmi/core/internal'\nimport {\n type GetBlockTransactionCountData,\n type GetBlockTransactionCountOptions,\n type GetBlockTransactionCountQueryFnData,\n type GetBlockTransactionCountQueryKey,\n getBlockTransactionCountQueryOptions,\n} from '@wagmi/core/query'\n\nimport type { ConfigParameter, QueryParameter } from '../types/properties.js'\nimport { type UseQueryReturnType, useQuery } from '../utils/query.js'\nimport { useChainId } from './useChainId.js'\nimport { useConfig } from './useConfig.js'\n\nexport type UseBlockTransactionCountParameters<\n config extends Config = Config,\n chainId extends\n config['chains'][number]['id'] = config['chains'][number]['id'],\n selectData = GetBlockTransactionCountData,\n> = UnionCompute<\n GetBlockTransactionCountOptions<config, chainId> &\n ConfigParameter<config> &\n QueryParameter<\n GetBlockTransactionCountQueryFnData,\n GetBlockTransactionCountErrorType,\n selectData,\n GetBlockTransactionCountQueryKey<config, chainId>\n >\n>\n\nexport type UseBlockTransactionCountReturnType<\n selectData = GetBlockTransactionCountData,\n> = UseQueryReturnType<selectData, GetBlockTransactionCountErrorType>\n\n/** https://wagmi.sh/react/api/hooks/useBlockTransactionCount */\nexport function useBlockTransactionCount<\n config extends Config = ResolvedRegister['config'],\n chainId extends\n config['chains'][number]['id'] = config['chains'][number]['id'],\n selectData = GetBlockTransactionCountData,\n>(\n parameters: UseBlockTransactionCountParameters<\n config,\n chainId,\n selectData\n > = {},\n): UseBlockTransactionCountReturnType<selectData> {\n const { query = {} } = parameters\n\n const config = useConfig(parameters)\n const configChainId = useChainId({ config })\n const chainId = parameters.chainId ?? configChainId\n\n const options = getBlockTransactionCountQueryOptions(config, {\n ...parameters,\n chainId,\n })\n\n return useQuery({ ...query, ...options })\n}\n", "'use client'\n\nimport type {\n Config,\n GetBytecodeErrorType,\n ResolvedRegister,\n} from '@wagmi/core'\nimport type { Compute } from '@wagmi/core/internal'\nimport {\n type GetBytecodeData,\n type GetBytecodeOptions,\n type GetBytecodeQueryKey,\n getBytecodeQueryOptions,\n} from '@wagmi/core/query'\nimport type { GetBytecodeQueryFnData } from '@wagmi/core/query'\nimport type { ConfigParameter, QueryParameter } from '../types/properties.js'\nimport { type UseQueryReturnType, useQuery } from '../utils/query.js'\nimport { useChainId } from './useChainId.js'\nimport { useConfig } from './useConfig.js'\n\nexport type UseBytecodeParameters<\n config extends Config = Config,\n selectData = GetBytecodeData,\n> = Compute<\n GetBytecodeOptions<config> &\n ConfigParameter<config> &\n QueryParameter<\n GetBytecodeQueryFnData,\n GetBytecodeErrorType,\n selectData,\n GetBytecodeQueryKey<config>\n >\n>\n\nexport type UseBytecodeReturnType<selectData = GetBytecodeData> =\n UseQueryReturnType<selectData, GetBytecodeErrorType>\n\n/** https://wagmi.sh/react/api/hooks/useBytecode */\nexport function useBytecode<\n config extends Config = ResolvedRegister['config'],\n selectData = GetBytecodeData,\n>(\n parameters: UseBytecodeParameters<config, selectData> = {},\n): UseBytecodeReturnType<selectData> {\n const { address, query = {} } = parameters\n\n const config = useConfig(parameters)\n const chainId = useChainId({ config })\n\n const options = getBytecodeQueryOptions(config, {\n ...parameters,\n chainId: parameters.chainId ?? chainId,\n })\n const enabled = Boolean(address && (query.enabled ?? true))\n\n return useQuery({ ...query, ...options, enabled })\n}\n", "'use client'\n\nimport type { CallErrorType, Config, ResolvedRegister } from '@wagmi/core'\nimport type { Compute } from '@wagmi/core/internal'\nimport {\n type CallData,\n type CallOptions,\n type CallQueryKey,\n callQueryOptions,\n} from '@wagmi/core/query'\nimport type { CallQueryFnData } from '@wagmi/core/query'\n\nimport type { ConfigParameter, QueryParameter } from '../types/properties.js'\nimport { type UseQueryReturnType, useQuery } from '../utils/query.js'\nimport { useChainId } from './useChainId.js'\nimport { useConfig } from './useConfig.js'\n\nexport type UseCallParameters<\n config extends Config = Config,\n selectData = CallData,\n> = Compute<\n CallOptions<config> &\n ConfigParameter<config> &\n QueryParameter<\n CallQueryFnData,\n CallErrorType,\n selectData,\n CallQueryKey<config>\n >\n>\n\nexport type UseCallReturnType<selectData = CallData> = UseQueryReturnType<\n selectData,\n CallErrorType\n>\n\n/** https://wagmi.sh/react/api/hooks/useCall */\nexport function useCall<\n config extends Config = ResolvedRegister['config'],\n selectData = CallData,\n>(\n parameters: UseCallParameters<config, selectData> = {},\n): UseCallReturnType<selectData> {\n const { query = {} } = parameters\n\n const config = useConfig(parameters)\n const chainId = useChainId({ config })\n\n const options = callQueryOptions(config, {\n ...parameters,\n chainId: parameters.chainId ?? chainId,\n })\n\n return useQuery({ ...query, ...options })\n}\n", "'use client'\n\nimport {\n type Config,\n type GetChainsReturnType,\n type ResolvedRegister,\n getChains,\n} from '@wagmi/core'\nimport { watchChains } from '@wagmi/core/internal'\nimport { useSyncExternalStore } from 'react'\n\nimport type { ConfigParameter } from '../types/properties.js'\nimport { useConfig } from './useConfig.js'\n\nexport type UseChainsParameters<config extends Config = Config> =\n ConfigParameter<config>\n\nexport type UseChainsReturnType<config extends Config = Config> =\n GetChainsReturnType<config>\n\n/** https://wagmi.sh/react/api/hooks/useChains */\nexport function useChains<config extends Config = ResolvedRegister['config']>(\n parameters: UseChainsParameters<config> = {},\n): UseChainsReturnType<config> {\n const config = useConfig(parameters)\n\n return useSyncExternalStore(\n (onChange) => watchChains(config, { onChange }),\n () => getChains(config),\n () => getChains(config),\n )\n}\n", "'use client'\n\nimport {\n type Config,\n type GetClientParameters,\n type GetClientReturnType,\n type ResolvedRegister,\n getClient,\n watchClient,\n} from '@wagmi/core'\nimport type { Compute } from '@wagmi/core/internal'\nimport { useSyncExternalStoreWithSelector } from 'use-sync-external-store/shim/with-selector.js'\n\nimport type { ConfigParameter } from '../types/properties.js'\nimport { useConfig } from './useConfig.js'\n\nexport type UseClientParameters<\n config extends Config = Config,\n chainId extends config['chains'][number]['id'] | number | undefined =\n | config['chains'][number]['id']\n | undefined,\n> = Compute<GetClientParameters<config, chainId> & ConfigParameter<config>>\n\nexport type UseClientReturnType<\n config extends Config = Config,\n chainId extends config['chains'][number]['id'] | number | undefined =\n | config['chains'][number]['id']\n | undefined,\n> = GetClientReturnType<config, chainId>\n\n/** https://wagmi.sh/react/api/hooks/useClient */\nexport function useClient<\n config extends Config = ResolvedRegister['config'],\n chainId extends config['chains'][number]['id'] | number | undefined =\n | config['chains'][number]['id']\n | undefined,\n>(\n parameters: UseClientParameters<config, chainId> = {},\n): UseClientReturnType<config, chainId> {\n const config = useConfig(parameters)\n\n return useSyncExternalStoreWithSelector(\n (onChange) => watchClient(config, { onChange }),\n () => getClient(config, parameters),\n () => getClient(config, parameters),\n (x) => x,\n (a, b) => a?.uid === b?.uid,\n ) as any\n}\n", "'use client'\n\nimport { useMutation } from '@tanstack/react-query'\nimport type { Config, ConnectErrorType, ResolvedRegister } from '@wagmi/core'\nimport type { Compute } from '@wagmi/core/internal'\nimport {\n type ConnectData,\n type ConnectMutate,\n type ConnectMutateAsync,\n type ConnectVariables,\n connectMutationOptions,\n} from '@wagmi/core/query'\nimport { useEffect } from 'react'\n\nimport type { ConfigParameter } from '../types/properties.js'\nimport type {\n UseMutationParameters,\n UseMutationReturnType,\n} from '../utils/query.js'\nimport { useConfig } from './useConfig.js'\nimport { type UseConnectorsReturnType, useConnectors } from './useConnectors.js'\n\nexport type UseConnectParameters<\n config extends Config = Config,\n context = unknown,\n> = Compute<\n ConfigParameter<config> & {\n mutation?:\n | UseMutationParameters<\n ConnectData<config>,\n ConnectErrorType,\n ConnectVariables<config, config['connectors'][number]>,\n context\n >\n | undefined\n }\n>\n\nexport type UseConnectReturnType<\n config extends Config = Config,\n context = unknown,\n> = Compute<\n UseMutationReturnType<\n ConnectData<config>,\n ConnectErrorType,\n ConnectVariables<config, config['connectors'][number]>,\n context\n > & {\n connect: ConnectMutate<config, context>\n connectAsync: ConnectMutateAsync<config, context>\n connectors: Compute<UseConnectorsReturnType> | config['connectors']\n }\n>\n\n/** https://wagmi.sh/react/api/hooks/useConnect */\nexport function useConnect<\n config extends Config = ResolvedRegister['config'],\n context = unknown,\n>(\n parameters: UseConnectParameters<config, context> = {},\n): UseConnectReturnType<config, context> {\n const { mutation } = parameters\n\n const config = useConfig(parameters)\n\n const mutationOptions = connectMutationOptions(config)\n const { mutate, mutateAsync, ...result } = useMutation({\n ...mutation,\n ...mutationOptions,\n })\n\n // Reset mutation back to an idle state when the connector disconnects.\n useEffect(() => {\n return config.subscribe(\n ({ status }) => status,\n (status, previousStatus) => {\n if (previousStatus === 'connected' && status === 'disconnected')\n result.reset()\n },\n )\n }, [config, result.reset])\n\n type Return = UseConnectReturnType<config, context>\n return {\n ...(result as Return),\n connect: mutate as Return['connect'],\n connectAsync: mutateAsync as Return['connectAsync'],\n connectors: useConnectors({ config }),\n }\n}\n", "'use client'\n\nimport {\n type Config,\n type GetConnectorsReturnType,\n type ResolvedRegister,\n getConnectors,\n watchConnectors,\n} from '@wagmi/core'\nimport { useSyncExternalStore } from 'react'\n\nimport type { ConfigParameter } from '../types/properties.js'\nimport { useConfig } from './useConfig.js'\n\nexport type UseConnectorsParameters<config extends Config = Config> =\n ConfigParameter<config>\n\nexport type UseConnectorsReturnType<config extends Config = Config> =\n GetConnectorsReturnType<config>\n\n/** https://wagmi.sh/react/api/hooks/useConnectors */\nexport function useConnectors<\n config extends Config = ResolvedRegister['config'],\n>(\n parameters: UseConnectorsParameters<config> = {},\n): UseConnectorsReturnType<config> {\n const config = useConfig(parameters)\n\n return useSyncExternalStore(\n (onChange) => watchConnectors(config, { onChange }),\n () => getConnectors(config),\n () => getConnectors(config),\n )\n}\n", "'use client'\n\nimport {\n type GetConnectionsReturnType,\n getConnections,\n watchConnections,\n} from '@wagmi/core'\nimport { useSyncExternalStore } from 'react'\n\nimport type { ConfigParameter } from '../types/properties.js'\nimport { useConfig } from './useConfig.js'\n\nexport type UseConnectionsParameters = ConfigParameter\n\nexport type UseConnectionsReturnType = GetConnectionsReturnType\n\n/** https://wagmi.sh/react/api/hooks/useConnections */\nexport function useConnections(\n parameters: UseConnectionsParameters = {},\n): UseConnectionsReturnType {\n const config = useConfig(parameters)\n\n return useSyncExternalStore(\n (onChange) => watchConnections(config, { onChange }),\n () => getConnections(config),\n () => getConnections(config),\n )\n}\n", "'use client'\n\nimport { useQueryClient } from '@tanstack/react-query'\nimport type {\n Config,\n GetConnectorClientErrorType,\n ResolvedRegister,\n} from '@wagmi/core'\nimport type { Compute, Omit } from '@wagmi/core/internal'\nimport {\n type GetConnectorClientData,\n type GetConnectorClientOptions,\n type GetConnectorClientQueryFnData,\n type GetConnectorClientQueryKey,\n getConnectorClientQueryOptions,\n} from '@wagmi/core/query'\nimport { useEffect, useRef } from 'react'\n\nimport type { ConfigParameter } from '../types/properties.js'\nimport {\n type UseQueryParameters,\n type UseQueryReturnType,\n useQuery,\n} from '../utils/query.js'\nimport { useAccount } from './useAccount.js'\nimport { useChainId } from './useChainId.js'\nimport { useConfig } from './useConfig.js'\n\nexport type UseConnectorClientParameters<\n config extends Config = Config,\n chainId extends\n config['chains'][number]['id'] = config['chains'][number]['id'],\n selectData = GetConnectorClientData<config, chainId>,\n> = Compute<\n GetConnectorClientOptions<config, chainId> &\n ConfigParameter<config> & {\n query?:\n | Compute<\n Omit<\n UseQueryParameters<\n GetConnectorClientQueryFnData<config, chainId>,\n GetConnectorClientErrorType,\n selectData,\n GetConnectorClientQueryKey<config, chainId>\n >,\n 'gcTime' | 'staleTime'\n >\n >\n | undefined\n }\n>\n\nexport type UseConnectorClientReturnType<\n config extends Config = Config,\n chainId extends\n config['chains'][number]['id'] = config['chains'][number]['id'],\n selectData = GetConnectorClientData<config, chainId>,\n> = UseQueryReturnType<selectData, GetConnectorClientErrorType>\n\n/** https://wagmi.sh/react/api/hooks/useConnectorClient */\nexport function useConnectorClient<\n config extends Config = ResolvedRegister['config'],\n chainId extends\n config['chains'][number]['id'] = config['chains'][number]['id'],\n selectData = GetConnectorClientData<config, chainId>,\n>(\n parameters: UseConnectorClientParameters<config, chainId, selectData> = {},\n): UseConnectorClientReturnType<config, chainId, selectData> {\n const { query = {}, ...rest } = parameters\n\n const config = useConfig(rest)\n const queryClient = useQueryClient()\n const { address, connector, status } = useAccount({ config })\n const chainId = useChainId({ config })\n const activeConnector = parameters.connector ?? connector\n\n const { queryKey, ...options } = getConnectorClientQueryOptions<\n config,\n chainId\n >(config, {\n ...parameters,\n chainId: parameters.chainId ?? chainId,\n connector: activeConnector,\n })\n const enabled = Boolean(\n (status === 'connected' ||\n (status === 'reconnecting' && activeConnector?.getProvider)) &&\n (query.enabled ?? true),\n )\n\n const addressRef = useRef(address)\n // biome-ignore lint/correctness/useExhaustiveDependencies: `queryKey` not required\n useEffect(() => {\n const previousAddress = addressRef.current\n if (!address && previousAddress) {\n // remove when account is disconnected\n queryClient.removeQueries({ queryKey })\n addressRef.current = undefined\n } else if (address !== previousAddress) {\n // invalidate when address changes\n queryClient.invalidateQueries({ queryKey })\n addressRef.current = address\n }\n }, [address, queryClient])\n\n return useQuery({\n ...query,\n ...options,\n queryKey,\n enabled,\n staleTime: Number.POSITIVE_INFINITY,\n })\n}\n", "'use client'\n\nimport { useMutation } from '@tanstack/react-query'\nimport type {\n Config,\n DeployContractErrorType,\n ResolvedRegister,\n} from '@wagmi/core'\nimport type { Compute } from '@wagmi/core/internal'\nimport {\n type DeployContractData,\n type DeployContractMutate,\n type DeployContractMutateAsync,\n type DeployContractVariables,\n deployContractMutationOptions,\n} from '@wagmi/core/query'\nimport type { Abi } from 'viem'\n\nimport type { ConfigParameter } from '../types/properties.js'\nimport type {\n UseMutationParameters,\n UseMutationReturnType,\n} from '../utils/query.js'\nimport { useConfig } from './useConfig.js'\n\nexport type UseDeployContractParameters<\n config extends Config = Config,\n context = unknown,\n> = Compute<\n ConfigParameter<config> & {\n mutation?:\n | UseMutationParameters<\n DeployContractData,\n DeployContractErrorType,\n DeployContractVariables<Abi, config, config['chains'][number]['id']>,\n context\n >\n | undefined\n }\n>\n\nexport type UseDeployContractReturnType<\n config extends Config = Config,\n context = unknown,\n> = UseMutationReturnType<\n DeployContractData,\n DeployContractErrorType,\n DeployContractVariables<Abi, config, config['chains'][number]['id']>,\n context\n> & {\n deployContract: DeployContractMutate<config, context>\n deployContractAsync: DeployContractMutateAsync<config, context>\n}\n\n/** https://wagmi.sh/react/api/hooks/useDeployContract */\nexport function useDeployContract<\n config extends Config = ResolvedRegister['config'],\n context = unknown,\n>(\n parameters: UseDeployContractParameters<config, context> = {},\n): UseDeployContractReturnType<config, context> {\n const { mutation } = parameters\n\n const config = useConfig(parameters)\n\n const mutationOptions = deployContractMutationOptions(config)\n const { mutate, mutateAsync, ...result } = useMutation({\n ...mutation,\n ...mutationOptions,\n })\n\n type Return = UseDeployContractReturnType<config, context>\n return {\n ...result,\n deployContract: mutate as Return['deployContract'],\n deployContractAsync: mutateAsync as Return['deployContractAsync'],\n }\n}\n", "'use client'\n\nimport { useMutation } from '@tanstack/react-query'\nimport type { Connector, DisconnectErrorType } from '@wagmi/core'\nimport type { Compute } from '@wagmi/core/internal'\nimport {\n type DisconnectData,\n type DisconnectMutate,\n type DisconnectMutateAsync,\n type DisconnectVariables,\n disconnectMutationOptions,\n} from '@wagmi/core/query'\n\nimport type { ConfigParameter } from '../types/properties.js'\nimport type {\n UseMutationParameters,\n UseMutationReturnType,\n} from '../utils/query.js'\nimport { useConfig } from './useConfig.js'\nimport { useConnections } from './useConnections.js'\n\nexport type UseDisconnectParameters<context = unknown> = Compute<\n ConfigParameter & {\n mutation?:\n | UseMutationParameters<\n DisconnectData,\n DisconnectErrorType,\n DisconnectVariables,\n context\n >\n | undefined\n }\n>\n\nexport type UseDisconnectReturnType<context = unknown> = Compute<\n UseMutationReturnType<\n DisconnectData,\n DisconnectErrorType,\n DisconnectVariables,\n context\n > & {\n connectors: readonly Connector[]\n disconnect: DisconnectMutate<context>\n disconnectAsync: DisconnectMutateAsync<context>\n }\n>\n\n/** https://wagmi.sh/react/api/hooks/useDisconnect */\nexport function useDisconnect<context = unknown>(\n parameters: UseDisconnectParameters<context> = {},\n): UseDisconnectReturnType<context> {\n const { mutation } = parameters\n\n const config = useConfig(parameters)\n\n const mutationOptions = disconnectMutationOptions(config)\n const { mutate, mutateAsync, ...result } = useMutation({\n ...mutation,\n ...mutationOptions,\n })\n\n return {\n ...result,\n connectors: useConnections({ config }).map(\n (connection) => connection.connector,\n ),\n disconnect: mutate,\n disconnectAsync: mutateAsync,\n }\n}\n", "'use client'\n\nimport type {\n Config,\n GetEnsAddressErrorType,\n ResolvedRegister,\n} from '@wagmi/core'\nimport type { Compute } from '@wagmi/core/internal'\nimport {\n type GetEnsAddressData,\n type GetEnsAddressOptions,\n type GetEnsAddressQueryFnData,\n type GetEnsAddressQueryKey,\n getEnsAddressQueryOptions,\n} from '@wagmi/core/query'\n\nimport type { ConfigParameter, QueryParameter } from '../types/properties.js'\nimport { type UseQueryReturnType, useQuery } from '../utils/query.js'\nimport { useChainId } from './useChainId.js'\nimport { useConfig } from './useConfig.js'\n\nexport type UseEnsAddressParameters<\n config extends Config = Config,\n selectData = GetEnsAddressData,\n> = Compute<\n GetEnsAddressOptions<config> &\n ConfigParameter<config> &\n QueryParameter<\n GetEnsAddressQueryFnData,\n GetEnsAddressErrorType,\n selectData,\n GetEnsAddressQueryKey<config>\n >\n>\n\nexport type UseEnsAddressReturnType<selectData = GetEnsAddressData> =\n UseQueryReturnType<selectData, GetEnsAddressErrorType>\n\n/** https://wagmi.sh/react/api/hooks/useEnsAddress */\nexport function useEnsAddress<\n config extends Config = ResolvedRegister['config'],\n selectData = GetEnsAddressData,\n>(\n parameters: UseEnsAddressParameters<config, selectData> = {},\n): UseEnsAddressReturnType<selectData> {\n const { name, query = {} } = parameters\n\n const config = useConfig(parameters)\n const chainId = useChainId({ config })\n\n const options = getEnsAddressQueryOptions(config, {\n ...parameters,\n chainId: parameters.chainId ?? chainId,\n })\n const enabled = Boolean(name && (query.enabled ?? true))\n\n return useQuery({ ...query, ...options, enabled })\n}\n", "'use client'\n\nimport type {\n Config,\n GetEnsAvatarErrorType,\n ResolvedRegister,\n} from '@wagmi/core'\nimport type { Compute } from '@wagmi/core/internal'\nimport {\n type GetEnsAvatarData,\n type GetEnsAvatarOptions,\n type GetEnsAvatarQueryFnData,\n type GetEnsAvatarQueryKey,\n getEnsAvatarQueryOptions,\n} from '@wagmi/core/query'\n\nimport type { ConfigParameter, QueryParameter } from '../types/properties.js'\nimport { type UseQueryReturnType, useQuery } from '../utils/query.js'\nimport { useChainId } from './useChainId.js'\nimport { useConfig } from './useConfig.js'\n\nexport type UseEnsAvatarParameters<\n config extends Config = Config,\n selectData = GetEnsAvatarData,\n> = Compute<\n GetEnsAvatarOptions<config> &\n ConfigParameter<config> &\n QueryParameter<\n GetEnsAvatarQueryFnData,\n GetEnsAvatarErrorType,\n selectData,\n GetEnsAvatarQueryKey<config>\n >\n>\n\nexport type UseEnsAvatarReturnType<selectData = GetEnsAvatarData> =\n UseQueryReturnType<selectData, GetEnsAvatarErrorType>\n\n/** https://wagmi.sh/react/api/hooks/useEnsAvatar */\nexport function useEnsAvatar<\n config extends Config = ResolvedRegister['config'],\n selectData = GetEnsAvatarData,\n>(\n parameters: UseEnsAvatarParameters<config, selectData> = {},\n): UseEnsAvatarReturnType<selectData> {\n const { name, query = {} } = parameters\n\n const config = useConfig(parameters)\n const chainId = useChainId({ config })\n\n const options = getEnsAvatarQueryOptions(config, {\n ...parameters,\n chainId: parameters.chainId ?? chainId,\n })\n const enabled = Boolean(name && (query.enabled ?? true))\n\n return useQuery({ ...query, ...options, enabled })\n}\n", "'use client'\n\nimport type { Config, GetEnsNameErrorType, ResolvedRegister } from '@wagmi/core'\nimport type { Compute } from '@wagmi/core/internal'\nimport {\n type GetEnsNameData,\n type GetEnsNameOptions,\n type GetEnsNameQueryFnData,\n type GetEnsNameQueryKey,\n getEnsNameQueryOptions,\n} from '@wagmi/core/query'\n\nimport type { ConfigParameter, QueryParameter } from '../types/properties.js'\nimport { type UseQueryReturnType, useQuery } from '../utils/query.js'\nimport { useChainId } from './useChainId.js'\nimport { useConfig } from './useConfig.js'\n\nexport type UseEnsNameParameters<\n config extends Config = Config,\n selectData = GetEnsNameData,\n> = Compute<\n GetEnsNameOptions<config> &\n ConfigParameter<config> &\n QueryParameter<\n GetEnsNameQueryFnData,\n GetEnsNameErrorType,\n selectData,\n GetEnsNameQueryKey<config>\n >\n>\n\nexport type UseEnsNameReturnType<selectData = GetEnsNameData> =\n UseQueryReturnType<selectData, GetEnsNameErrorType>\n\n/** https://wagmi.sh/react/api/hooks/useEnsName */\nexport function useEnsName<\n config extends Config = ResolvedRegister['config'],\n selectData = GetEnsNameData,\n>(\n parameters: UseEnsNameParameters<config, selectData> = {},\n): UseEnsNameReturnType<selectData> {\n const { address, query = {} } = parameters\n\n const config = useConfig(parameters)\n const chainId = useChainId({ config })\n\n const options = getEnsNameQueryOptions(config, {\n ...parameters,\n chainId: parameters.chainId ?? chainId,\n })\n const enabled = Boolean(address && (query.enabled ?? true))\n\n return useQuery({ ...query, ...options, enabled })\n}\n", "'use client'\n\nimport type {\n Config,\n GetEnsResolverErrorType,\n ResolvedRegister,\n} from '@wagmi/core'\nimport type { Compute } from '@wagmi/core/internal'\nimport {\n type GetEnsResolverData,\n type GetEnsResolverOptions,\n type GetEnsResolverQueryFnData,\n type GetEnsResolverQueryKey,\n getEnsResolverQueryOptions,\n} from '@wagmi/core/query'\n\nimport type { ConfigParameter, QueryParameter } from '../types/properties.js'\nimport { type UseQueryReturnType, useQuery } from '../utils/query.js'\nimport { useChainId } from './useChainId.js'\nimport { useConfig } from './useConfig.js'\n\nexport type UseEnsResolverParameters<\n config extends Config = Config,\n selectData = GetEnsResolverData,\n> = Compute<\n GetEnsResolverOptions<config> &\n ConfigParameter<config> &\n QueryParameter<\n GetEnsResolverQueryFnData,\n GetEnsResolverErrorType,\n selectData,\n GetEnsResolverQueryKey<config>\n >\n>\n\nexport type UseEnsResolverReturnType<selectData = GetEnsResolverData> =\n UseQueryReturnType<selectData, GetEnsResolverErrorType>\n\n/** https://wagmi.sh/react/api/hooks/useEnsResolver */\nexport function useEnsResolver<\n config extends Config = ResolvedRegister['config'],\n selectData = GetEnsResolverData,\n>(\n parameters: UseEnsResolverParameters<config, selectData> = {},\n): UseEnsResolverReturnType<selectData> {\n const { name, query = {} } = parameters\n\n const config = useConfig(parameters)\n const chainId = useChainId({ config })\n\n const options = getEnsResolverQueryOptions(config, {\n ...parameters,\n chainId: parameters.chainId ?? chainId,\n })\n const enabled = Boolean(name && (query.enabled ?? true))\n\n return useQuery({ ...query, ...options, enabled })\n}\n", "'use client'\n\nimport type { Config, GetEnsTextErrorType, ResolvedRegister } from '@wagmi/core'\nimport type { Compute } from '@wagmi/core/internal'\nimport {\n type GetEnsTextData,\n type GetEnsTextOptions,\n type GetEnsTextQueryFnData,\n type GetEnsTextQueryKey,\n getEnsTextQueryOptions,\n} from '@wagmi/core/query'\n\nimport type { ConfigParameter, QueryParameter } from '../types/properties.js'\nimport { type UseQueryReturnType, useQuery } from '../utils/query.js'\nimport { useChainId } from './useChainId.js'\nimport { useConfig } from './useConfig.js'\n\nexport type UseEnsTextParameters<\n config extends Config = Config,\n selectData = GetEnsTextData,\n> = Compute<\n GetEnsTextOptions<config> &\n ConfigParameter<config> &\n QueryParameter<\n GetEnsTextQueryFnData,\n GetEnsTextErrorType,\n selectData,\n GetEnsTextQueryKey<config>\n >\n>\n\nexport type UseEnsTextReturnType<selectData = GetEnsTextData> =\n UseQueryReturnType<selectData, GetEnsTextErrorType>\n\n/** https://wagmi.sh/react/api/hooks/useEnsText */\nexport function useEnsText<\n config extends Config = ResolvedRegister['config'],\n selectData = GetEnsTextData,\n>(\n parameters: UseEnsTextParameters<config, selectData> = {},\n): UseEnsTextReturnType<selectData> {\n const { key, name, query = {} } = parameters\n\n const config = useConfig(parameters)\n const chainId = useChainId({ config })\n\n const options = getEnsTextQueryOptions(config, {\n ...parameters,\n chainId: parameters.chainId ?? chainId,\n })\n const enabled = Boolean(key && name && (query.enabled ?? true))\n\n return useQuery({ ...query, ...options, enabled })\n}\n", "'use client'\n\nimport type {\n Config,\n EstimateFeesPerGasErrorType,\n ResolvedRegister,\n} from '@wagmi/core'\nimport type { Compute } from '@wagmi/core/internal'\nimport {\n type EstimateFeesPerGasData,\n type EstimateFeesPerGasOptions,\n type EstimateFeesPerGasQueryFnData,\n type EstimateFeesPerGasQueryKey,\n estimateFeesPerGasQueryOptions,\n} from '@wagmi/core/query'\nimport type { FeeValuesType } from 'viem'\n\nimport type { ConfigParameter, QueryParameter } from '../types/properties.js'\nimport { type UseQueryReturnType, useQuery } from '../utils/query.js'\nimport { useChainId } from './useChainId.js'\nimport { useConfig } from './useConfig.js'\n\nexport type UseEstimateFeesPerGasParameters<\n type extends FeeValuesType = FeeValuesType,\n config extends Config = Config,\n selectData = EstimateFeesPerGasData<type>,\n> = Compute<\n EstimateFeesPerGasOptions<type, config> &\n ConfigParameter<config> &\n QueryParameter<\n EstimateFeesPerGasQueryFnData<type>,\n EstimateFeesPerGasErrorType,\n selectData,\n EstimateFeesPerGasQueryKey<config, type>\n >\n>\n\nexport type UseEstimateFeesPerGasReturnType<\n type extends FeeValuesType = FeeValuesType,\n selectData = EstimateFeesPerGasData<type>,\n> = UseQueryReturnType<selectData, EstimateFeesPerGasErrorType>\n\n/** https://wagmi.sh/react/api/hooks/useEstimateFeesPerGas */\nexport function useEstimateFeesPerGas<\n config extends Config = ResolvedRegister['config'],\n type extends FeeValuesType = 'eip1559',\n selectData = EstimateFeesPerGasData<type>,\n>(\n parameters: UseEstimateFeesPerGasParameters<type, config, selectData> = {},\n): UseEstimateFeesPerGasReturnType<type, selectData> {\n const { query = {} } = parameters\n\n const config = useConfig(parameters)\n const chainId = useChainId({ config })\n\n const options = estimateFeesPerGasQueryOptions(config, {\n ...parameters,\n chainId: parameters.chainId ?? chainId,\n })\n\n return useQuery({ ...query, ...options })\n}\n", "'use client'\n\nimport type {\n Config,\n EstimateGasErrorType,\n ResolvedRegister,\n} from '@wagmi/core'\nimport {\n type EstimateGasData,\n type EstimateGasOptions,\n type EstimateGasQueryFnData,\n type EstimateGasQueryKey,\n estimateGasQueryOptions,\n} from '@wagmi/core/query'\n\nimport type { ConfigParameter, QueryParameter } from '../types/properties.js'\nimport { type UseQueryReturnType, useQuery } from '../utils/query.js'\nimport { useChainId } from './useChainId.js'\nimport { useConfig } from './useConfig.js'\nimport { useConnectorClient } from './useConnectorClient.js'\n\nexport type UseEstimateGasParameters<\n config extends Config = Config,\n chainId extends config['chains'][number]['id'] | undefined = undefined,\n selectData = EstimateGasData,\n> = EstimateGasOptions<config, chainId> &\n ConfigParameter<config> &\n QueryParameter<\n EstimateGasQueryFnData,\n EstimateGasErrorType,\n selectData,\n EstimateGasQueryKey<config, chainId>\n >\n\nexport type UseEstimateGasReturnType<selectData = EstimateGasData> =\n UseQueryReturnType<selectData, EstimateGasErrorType>\n\n/** https://wagmi.sh/react/api/hooks/useEstimateGas */\nexport function useEstimateGas<\n config extends Config = ResolvedRegister['config'],\n chainId extends config['chains'][number]['id'] | undefined = undefined,\n selectData = EstimateGasData,\n>(\n parameters?: UseEstimateGasParameters<config, chainId, selectData>,\n): UseEstimateGasReturnType<selectData>\n\nexport function useEstimateGas(\n parameters: UseEstimateGasParameters = {},\n): UseEstimateGasReturnType {\n const { connector, query = {} } = parameters\n\n const config = useConfig(parameters)\n const { data: connectorClient } = useConnectorClient({\n config,\n connector,\n query: { enabled: parameters.account === undefined },\n })\n const account = parameters.account ?? connectorClient?.account\n const chainId = useChainId({ config })\n\n const options = estimateGasQueryOptions(config, {\n ...parameters,\n account,\n chainId: parameters.chainId ?? chainId,\n connector,\n })\n const enabled = Boolean((account || connector) && (query.enabled ?? true))\n\n return useQuery({ ...query, ...options, enabled })\n}\n", "'use client'\n\nimport type {\n Config,\n EstimateMaxPriorityFeePerGasErrorType,\n ResolvedRegister,\n} from '@wagmi/core'\nimport type { Compute } from '@wagmi/core/internal'\nimport {\n type EstimateMaxPriorityFeePerGasData,\n type EstimateMaxPriorityFeePerGasOptions,\n type EstimateMaxPriorityFeePerGasQueryFnData,\n type EstimateMaxPriorityFeePerGasQueryKey,\n estimateMaxPriorityFeePerGasQueryOptions,\n} from '@wagmi/core/query'\n\nimport type { ConfigParameter, QueryParameter } from '../types/properties.js'\nimport { type UseQueryReturnType, useQuery } from '../utils/query.js'\nimport { useChainId } from './useChainId.js'\nimport { useConfig } from './useConfig.js'\n\nexport type UseEstimateMaxPriorityFeePerGasParameters<\n config extends Config = Config,\n selectData = EstimateMaxPriorityFeePerGasData,\n> = Compute<\n EstimateMaxPriorityFeePerGasOptions<config> &\n ConfigParameter<config> &\n QueryParameter<\n EstimateMaxPriorityFeePerGasQueryFnData,\n EstimateMaxPriorityFeePerGasErrorType,\n selectData,\n EstimateMaxPriorityFeePerGasQueryKey<config>\n >\n>\n\nexport type UseEstimateMaxPriorityFeePerGasReturnType<\n selectData = EstimateMaxPriorityFeePerGasData,\n> = UseQueryReturnType<selectData, EstimateMaxPriorityFeePerGasErrorType>\n\n/** https://wagmi.sh/react/api/hooks/useEstimateMaxPriorityFeePerGas */\nexport function useEstimateMaxPriorityFeePerGas<\n config extends Config = ResolvedRegister['config'],\n selectData = EstimateMaxPriorityFeePerGasData,\n>(\n parameters: UseEstimateMaxPriorityFeePerGasParameters<\n config,\n selectData\n > = {},\n): UseEstimateMaxPriorityFeePerGasReturnType<selectData> {\n const { query = {} } = parameters\n\n const config = useConfig(parameters)\n const chainId = useChainId({ config })\n\n const options = estimateMaxPriorityFeePerGasQueryOptions(config, {\n ...parameters,\n chainId: parameters.chainId ?? chainId,\n })\n\n return useQuery({ ...query, ...options })\n}\n", "'use client'\n\nimport type {\n Config,\n GetFeeHistoryErrorType,\n ResolvedRegister,\n} from '@wagmi/core'\nimport type { Compute } from '@wagmi/core/internal'\nimport {\n type GetFeeHistoryData,\n type GetFeeHistoryOptions,\n type GetFeeHistoryQueryFnData,\n type GetFeeHistoryQueryKey,\n getFeeHistoryQueryOptions,\n} from '@wagmi/core/query'\n\nimport type { ConfigParameter, QueryParameter } from '../types/properties.js'\nimport { type UseQueryReturnType, useQuery } from '../utils/query.js'\nimport { useChainId } from './useChainId.js'\nimport { useConfig } from './useConfig.js'\n\nexport type UseFeeHistoryParameters<\n config extends Config = Config,\n chainId extends\n config['chains'][number]['id'] = config['chains'][number]['id'],\n selectData = GetFeeHistoryData,\n> = Compute<\n GetFeeHistoryOptions<config, chainId> &\n ConfigParameter<config> &\n QueryParameter<\n GetFeeHistoryQueryFnData,\n GetFeeHistoryErrorType,\n selectData,\n GetFeeHistoryQueryKey<config, chainId>\n >\n>\n\nexport type UseFeeHistoryReturnType<selectData = GetFeeHistoryData> =\n UseQueryReturnType<selectData, GetFeeHistoryErrorType>\n\n/** https://wagmi.sh/react/api/hooks/useFeeHistory */\nexport function useFeeHistory<\n config extends Config = ResolvedRegister['config'],\n chainId extends\n config['chains'][number]['id'] = config['chains'][number]['id'],\n selectData = GetFeeHistoryData,\n>(\n parameters: UseFeeHistoryParameters<config, chainId, selectData> = {},\n): UseFeeHistoryReturnType<selectData> {\n const { blockCount, rewardPercentiles, query = {} } = parameters\n\n const config = useConfig(parameters)\n const chainId = useChainId({ config })\n\n const options = getFeeHistoryQueryOptions(config, {\n ...parameters,\n chainId: parameters.chainId ?? chainId,\n })\n const enabled = Boolean(\n blockCount && rewardPercentiles && (query.enabled ?? true),\n )\n\n return useQuery({ ...query, ...options, enabled })\n}\n", "'use client'\n\nimport type {\n Config,\n GetGasPriceErrorType,\n ResolvedRegister,\n} from '@wagmi/core'\nimport type { Compute } from '@wagmi/core/internal'\nimport {\n type GetGasPriceData,\n type GetGasPriceOptions,\n type GetGasPriceQueryFnData,\n type GetGasPriceQueryKey,\n getGasPriceQueryOptions,\n} from '@wagmi/core/query'\n\nimport type { ConfigParameter, QueryParameter } from '../types/properties.js'\nimport { type UseQueryReturnType, useQuery } from '../utils/query.js'\nimport { useChainId } from './useChainId.js'\nimport { useConfig } from './useConfig.js'\n\nexport type UseGasPriceParameters<\n config extends Config = Config,\n chainId extends\n config['chains'][number]['id'] = config['chains'][number]['id'],\n selectData = GetGasPriceData,\n> = Compute<\n GetGasPriceOptions<config, chainId> &\n ConfigParameter<config> &\n QueryParameter<\n GetGasPriceQueryFnData,\n GetGasPriceErrorType,\n selectData,\n GetGasPriceQueryKey<config, chainId>\n >\n>\n\nexport type UseGasPriceReturnType<selectData = GetGasPriceData> =\n UseQueryReturnType<selectData, GetGasPriceErrorType>\n\n/** https://wagmi.sh/react/api/hooks/useGasPrice */\nexport function useGasPrice<\n config extends Config = ResolvedRegister['config'],\n chainId extends\n config['chains'][number]['id'] = config['chains'][number]['id'],\n selectData = GetGasPriceData,\n>(\n parameters: UseGasPriceParameters<config, chainId, selectData> = {},\n): UseGasPriceReturnType<selectData> {\n const { query = {} } = parameters\n\n const config = useConfig(parameters)\n const configChainId = useChainId({ config })\n const chainId = parameters.chainId ?? configChainId\n\n const options = getGasPriceQueryOptions(config, {\n ...parameters,\n chainId,\n })\n\n return useQuery({ ...query, ...options })\n}\n", "'use client'\n\nimport type {\n Config,\n ReadContractsErrorType,\n ResolvedRegister,\n} from '@wagmi/core'\nimport {\n type InfiniteReadContractsQueryFnData,\n type InfiniteReadContractsQueryKey,\n infiniteReadContractsQueryOptions,\n structuralSharing,\n} from '@wagmi/core/query'\nimport type { ContractFunctionParameters } from 'viem'\n\nimport type {\n InfiniteReadContractsData,\n InfiniteReadContractsOptions,\n} from '../exports/query.js'\nimport type {\n ConfigParameter,\n InfiniteQueryParameter,\n} from '../types/properties.js'\nimport {\n type UseInfiniteQueryParameters,\n type UseInfiniteQueryReturnType,\n useInfiniteQuery,\n} from '../utils/query.js'\nimport { useChainId } from './useChainId.js'\nimport { useConfig } from './useConfig.js'\n\nexport type UseInfiniteContractReadsParameters<\n contracts extends readonly unknown[] = readonly ContractFunctionParameters[],\n allowFailure extends boolean = true,\n config extends Config = Config,\n pageParam = unknown,\n selectData = InfiniteReadContractsData<contracts, allowFailure>,\n> = InfiniteReadContractsOptions<contracts, allowFailure, pageParam, config> &\n ConfigParameter<config> &\n InfiniteQueryParameter<\n InfiniteReadContractsQueryFnData<contracts, allowFailure>,\n ReadContractsErrorType,\n selectData,\n InfiniteReadContractsData<contracts, allowFailure>,\n InfiniteReadContractsQueryKey<contracts, allowFailure, pageParam, config>,\n pageParam\n >\n\nexport type UseInfiniteContractReadsReturnType<\n contracts extends readonly unknown[] = readonly ContractFunctionParameters[],\n allowFailure extends boolean = true,\n selectData = InfiniteReadContractsData<contracts, allowFailure>,\n> = UseInfiniteQueryReturnType<selectData, ReadContractsErrorType>\n\n/** https://wagmi.sh/react/api/hooks/useInfiniteReadContracts */\nexport function useInfiniteReadContracts<\n const contracts extends readonly unknown[],\n allowFailure extends boolean = true,\n config extends Config = ResolvedRegister['config'],\n pageParam = unknown,\n selectData = InfiniteReadContractsData<contracts, allowFailure>,\n>(\n parameters: UseInfiniteContractReadsParameters<\n contracts,\n allowFailure,\n config,\n pageParam,\n selectData\n >,\n): UseInfiniteContractReadsReturnType<contracts, allowFailure, selectData> {\n const { contracts = [], query } = parameters\n\n const config = useConfig(parameters)\n const chainId = useChainId({ config })\n\n const options = infiniteReadContractsQueryOptions(config, {\n ...parameters,\n chainId,\n contracts: contracts as UseInfiniteContractReadsParameters['contracts'],\n query: query as UseInfiniteQueryParameters,\n })\n\n return useInfiniteQuery({\n ...(query as any),\n ...options,\n initialPageParam: options.initialPageParam,\n structuralSharing: query.structuralSharing ?? structuralSharing,\n })\n}\n", "'use client'\n\nimport type {\n Config,\n PrepareTransactionRequestErrorType,\n ResolvedRegister,\n SelectChains,\n} from '@wagmi/core'\nimport {\n type PrepareTransactionRequestData,\n type PrepareTransactionRequestOptions,\n type PrepareTransactionRequestQueryKey,\n prepareTransactionRequestQueryOptions,\n} from '@wagmi/core/query'\nimport type { PrepareTransactionRequestQueryFnData } from '@wagmi/core/query'\nimport type { PrepareTransactionRequestRequest as viem_PrepareTransactionRequestRequest } from 'viem'\n\nimport type { ConfigParameter, QueryParameter } from '../types/properties.js'\nimport { type UseQueryReturnType, useQuery } from '../utils/query.js'\nimport { useChainId } from './useChainId.js'\nimport { useConfig } from './useConfig.js'\n\nexport type UsePrepareTransactionRequestParameters<\n config extends Config = Config,\n chainId extends config['chains'][number]['id'] | undefined = undefined,\n request extends viem_PrepareTransactionRequestRequest<\n SelectChains<config, chainId>[0],\n SelectChains<config, chainId>[0]\n > = viem_PrepareTransactionRequestRequest<\n SelectChains<config, chainId>[0],\n SelectChains<config, chainId>[0]\n >,\n selectData = PrepareTransactionRequestData<config, chainId, request>,\n> = PrepareTransactionRequestOptions<config, chainId, request> &\n ConfigParameter<config> &\n QueryParameter<\n PrepareTransactionRequestQueryFnData<config, chainId, request>,\n PrepareTransactionRequestErrorType,\n selectData,\n PrepareTransactionRequestQueryKey<config, chainId, request>\n >\n\nexport type UsePrepareTransactionRequestReturnType<\n config extends Config = Config,\n chainId extends config['chains'][number]['id'] | undefined = undefined,\n request extends viem_PrepareTransactionRequestRequest<\n SelectChains<config, chainId>[0],\n SelectChains<config, chainId>[0]\n > = viem_PrepareTransactionRequestRequest<\n SelectChains<config, chainId>[0],\n SelectChains<config, chainId>[0]\n >,\n selectData = PrepareTransactionRequestData<config, chainId, request>,\n> = UseQueryReturnType<selectData, PrepareTransactionRequestErrorType>\n\n/** https://wagmi.sh/react/api/hooks/usePrepareTransactionRequest */\nexport function usePrepareTransactionRequest<\n config extends Config = ResolvedRegister['config'],\n chainId extends config['chains'][number]['id'] | undefined = undefined,\n request extends viem_PrepareTransactionRequestRequest<\n SelectChains<config, chainId>[0],\n SelectChains<config, chainId>[0]\n > = viem_PrepareTransactionRequestRequest<\n SelectChains<config, chainId>[0],\n SelectChains<config, chainId>[0]\n >,\n selectData = PrepareTransactionRequestData<config, chainId, request>,\n>(\n parameters: UsePrepareTransactionRequestParameters<\n config,\n chainId,\n request,\n selectData\n > = {} as any,\n): UsePrepareTransactionRequestReturnType<\n config,\n chainId,\n request,\n selectData\n> {\n const { to, query = {} } = parameters\n\n const config = useConfig(parameters)\n const chainId = useChainId({ config })\n\n const options = prepareTransactionRequestQueryOptions(config, {\n ...parameters,\n chainId: parameters.chainId ?? chainId,\n } as PrepareTransactionRequestOptions<config, chainId, request>)\n const enabled = Boolean(to && (query.enabled ?? true))\n\n return useQuery({\n ...(query as any),\n ...options,\n enabled,\n }) as UsePrepareTransactionRequestReturnType<\n config,\n chainId,\n request,\n selectData\n >\n}\n", "'use client'\n\nimport type { Config, GetProofErrorType, ResolvedRegister } from '@wagmi/core'\nimport type { Compute } from '@wagmi/core/internal'\nimport {\n type GetProofData,\n type GetProofOptions,\n type GetProofQueryKey,\n getProofQueryOptions,\n} from '@wagmi/core/query'\nimport type { GetProofQueryFnData } from '@wagmi/core/query'\n\nimport type { ConfigParameter, QueryParameter } from '../types/properties.js'\nimport { type UseQueryReturnType, useQuery } from '../utils/query.js'\nimport { useChainId } from './useChainId.js'\nimport { useConfig } from './useConfig.js'\n\nexport type UseProofParameters<\n config extends Config = Config,\n selectData = GetProofData,\n> = Compute<\n GetProofOptions<config> &\n ConfigParameter<config> &\n QueryParameter<\n GetProofQueryFnData,\n GetProofErrorType,\n selectData,\n GetProofQueryKey<config>\n >\n>\n\nexport type UseProofReturnType<selectData = GetProofData> = UseQueryReturnType<\n selectData,\n GetProofErrorType\n>\n\n/** https://wagmi.sh/react/api/hooks/useProof */\nexport function useProof<\n config extends Config = ResolvedRegister['config'],\n selectData = GetProofData,\n>(\n parameters: UseProofParameters<config, selectData> = {},\n): UseProofReturnType<selectData> {\n const { address, storageKeys, query = {} } = parameters\n\n const config = useConfig(parameters)\n const chainId = useChainId({ config })\n\n const options = getProofQueryOptions(config, {\n ...parameters,\n chainId: parameters.chainId ?? chainId,\n })\n const enabled = Boolean(address && storageKeys && (query.enabled ?? true))\n\n return useQuery({ ...query, ...options, enabled })\n}\n", "'use client'\n\nimport {\n type Config,\n type GetPublicClientParameters,\n type GetPublicClientReturnType,\n type ResolvedRegister,\n getPublicClient,\n watchPublicClient,\n} from '@wagmi/core'\nimport type { Compute } from '@wagmi/core/internal'\nimport { useSyncExternalStoreWithSelector } from 'use-sync-external-store/shim/with-selector.js'\n\nimport type { ConfigParameter } from '../types/properties.js'\nimport { useConfig } from './useConfig.js'\n\nexport type UsePublicClientParameters<\n config extends Config = Config,\n chainId extends config['chains'][number]['id'] | number | undefined =\n | config['chains'][number]['id']\n | undefined,\n> = Compute<\n GetPublicClientParameters<config, chainId> & ConfigParameter<config>\n>\n\nexport type UsePublicClientReturnType<\n config extends Config = Config,\n chainId extends config['chains'][number]['id'] | number | undefined =\n | config['chains'][number]['id']\n | undefined,\n> = GetPublicClientReturnType<config, chainId>\n\n/** https://wagmi.sh/react/api/hooks/usePublicClient */\nexport function usePublicClient<\n config extends Config = ResolvedRegister['config'],\n chainId extends config['chains'][number]['id'] | number | undefined =\n | config['chains'][number]['id']\n | undefined,\n>(\n parameters: UsePublicClientParameters<config, chainId> = {},\n): UsePublicClientReturnType<config, chainId> {\n const config = useConfig(parameters)\n\n return useSyncExternalStoreWithSelector(\n (onChange) => watchPublicClient(config, { onChange }),\n () => getPublicClient(config, parameters),\n () => getPublicClient(config, parameters),\n (x) => x,\n (a, b) => a?.uid === b?.uid,\n ) as any\n}\n", "'use client'\n\nimport type {\n Config,\n ReadContractErrorType,\n ResolvedRegister,\n} from '@wagmi/core'\nimport type { UnionCompute } from '@wagmi/core/internal'\nimport {\n type ReadContractData,\n type ReadContractOptions,\n type ReadContractQueryFnData,\n type ReadContractQueryKey,\n readContractQueryOptions,\n structuralSharing,\n} from '@wagmi/core/query'\nimport type { Abi, ContractFunctionArgs, ContractFunctionName, Hex } from 'viem'\n\nimport type { ConfigParameter, QueryParameter } from '../types/properties.js'\nimport { type UseQueryReturnType, useQuery } from '../utils/query.js'\nimport { useChainId } from './useChainId.js'\nimport { useConfig } from './useConfig.js'\n\nexport type UseReadContractParameters<\n abi extends Abi | readonly unknown[] = Abi,\n functionName extends ContractFunctionName<\n abi,\n 'pure' | 'view'\n > = ContractFunctionName<abi, 'pure' | 'view'>,\n args extends ContractFunctionArgs<\n abi,\n 'pure' | 'view',\n functionName\n > = ContractFunctionArgs<abi, 'pure' | 'view', functionName>,\n config extends Config = Config,\n selectData = ReadContractData<abi, functionName, args>,\n> = UnionCompute<\n ReadContractOptions<abi, functionName, args, config> &\n ConfigParameter<config> &\n QueryParameter<\n ReadContractQueryFnData<abi, functionName, args>,\n ReadContractErrorType,\n selectData,\n ReadContractQueryKey<abi, functionName, args, config>\n >\n>\n\nexport type UseReadContractReturnType<\n abi extends Abi | readonly unknown[] = Abi,\n functionName extends ContractFunctionName<\n abi,\n 'pure' | 'view'\n > = ContractFunctionName<abi, 'pure' | 'view'>,\n args extends ContractFunctionArgs<\n abi,\n 'pure' | 'view',\n functionName\n > = ContractFunctionArgs<abi, 'pure' | 'view', functionName>,\n selectData = ReadContractData<abi, functionName, args>,\n> = UseQueryReturnType<selectData, ReadContractErrorType>\n\n/** https://wagmi.sh/react/api/hooks/useReadContract */\nexport function useReadContract<\n const abi extends Abi | readonly unknown[],\n functionName extends ContractFunctionName<abi, 'pure' | 'view'>,\n args extends ContractFunctionArgs<abi, 'pure' | 'view', functionName>,\n config extends Config = ResolvedRegister['config'],\n selectData = ReadContractData<abi, functionName, args>,\n>(\n parameters: UseReadContractParameters<\n abi,\n functionName,\n args,\n config,\n selectData\n > = {} as any,\n): UseReadContractReturnType<abi, functionName, args, selectData> {\n const { abi, address, functionName, query = {} } = parameters\n // @ts-ignore\n const code = parameters.code as Hex | undefined\n\n const config = useConfig(parameters)\n const chainId = useChainId({ config })\n\n const options = readContractQueryOptions<config, abi, functionName, args>(\n config,\n { ...(parameters as any), chainId: parameters.chainId ?? chainId },\n )\n const enabled = Boolean(\n (address || code) && abi && functionName && (query.enabled ?? true),\n )\n\n return useQuery({\n ...query,\n ...options,\n enabled,\n structuralSharing: query.structuralSharing ?? structuralSharing,\n })\n}\n", "'use client'\n\nimport type {\n Config,\n ReadContractsErrorType,\n ResolvedRegister,\n} from '@wagmi/core'\nimport type { Compute } from '@wagmi/core/internal'\nimport {\n type ReadContractsData,\n type ReadContractsOptions,\n type ReadContractsQueryFnData,\n type ReadContractsQueryKey,\n readContractsQueryOptions,\n structuralSharing,\n} from '@wagmi/core/query'\nimport { useMemo } from 'react'\nimport type { ContractFunctionParameters } from 'viem'\n\nimport type { ConfigParameter, QueryParameter } from '../types/properties.js'\nimport { type UseQueryReturnType, useQuery } from '../utils/query.js'\nimport { useChainId } from './useChainId.js'\nimport { useConfig } from './useConfig.js'\n\nexport type UseReadContractsParameters<\n contracts extends readonly unknown[] = readonly ContractFunctionParameters[],\n allowFailure extends boolean = true,\n config extends Config = Config,\n selectData = ReadContractsData<contracts, allowFailure>,\n> = Compute<\n ReadContractsOptions<contracts, allowFailure, config> &\n ConfigParameter<config> &\n QueryParameter<\n ReadContractsQueryFnData<contracts, allowFailure>,\n ReadContractsErrorType,\n selectData,\n ReadContractsQueryKey<contracts, allowFailure, config>\n >\n>\n\nexport type UseReadContractsReturnType<\n contracts extends readonly unknown[] = readonly ContractFunctionParameters[],\n allowFailure extends boolean = true,\n selectData = ReadContractsData<contracts, allowFailure>,\n> = UseQueryReturnType<selectData, ReadContractsErrorType>\n\n/** https://wagmi.sh/react/api/hooks/useReadContracts */\nexport function useReadContracts<\n const contracts extends readonly unknown[],\n allowFailure extends boolean = true,\n config extends Config = ResolvedRegister['config'],\n selectData = ReadContractsData<contracts, allowFailure>,\n>(\n parameters: UseReadContractsParameters<\n contracts,\n allowFailure,\n config,\n selectData\n > = {},\n): UseReadContractsReturnType<contracts, allowFailure, selectData> {\n const { contracts = [], query = {} } = parameters\n\n const config = useConfig(parameters)\n const chainId = useChainId({ config })\n\n const options = readContractsQueryOptions<config, contracts, allowFailure>(\n config,\n { ...parameters, chainId },\n )\n\n const enabled = useMemo(() => {\n let isContractsValid = false\n for (const contract of contracts) {\n const { abi, address, functionName } =\n contract as ContractFunctionParameters\n if (!abi || !address || !functionName) {\n isContractsValid = false\n break\n }\n isContractsValid = true\n }\n return Boolean(isContractsValid && (query.enabled ?? true))\n }, [contracts, query.enabled])\n\n return useQuery({\n ...options,\n ...query,\n enabled,\n structuralSharing: query.structuralSharing ?? structuralSharing,\n })\n}\n", "'use client'\n\nimport { useMutation } from '@tanstack/react-query'\nimport type { Connector, ReconnectErrorType } from '@wagmi/core'\nimport type { Compute } from '@wagmi/core/internal'\nimport {\n type ReconnectData,\n type ReconnectMutate,\n type ReconnectMutateAsync,\n type ReconnectVariables,\n reconnectMutationOptions,\n} from '@wagmi/core/query'\n\nimport type { ConfigParameter } from '../types/properties.js'\nimport type {\n UseMutationParameters,\n UseMutationReturnType,\n} from '../utils/query.js'\nimport { useConfig } from './useConfig.js'\n\nexport type UseReconnectParameters<context = unknown> = Compute<\n ConfigParameter & {\n mutation?:\n | UseMutationParameters<\n ReconnectData,\n ReconnectErrorType,\n ReconnectVariables,\n context\n >\n | undefined\n }\n>\n\nexport type UseReconnectReturnType<context = unknown> = Compute<\n UseMutationReturnType<\n ReconnectData,\n ReconnectErrorType,\n ReconnectVariables,\n context\n > & {\n connectors: readonly Connector[]\n reconnect: ReconnectMutate<context>\n reconnectAsync: ReconnectMutateAsync<context>\n }\n>\n\n/** https://wagmi.sh/react/api/hooks/useReconnect */\nexport function useReconnect<context = unknown>(\n parameters: UseReconnectParameters<context> = {},\n): UseReconnectReturnType<context> {\n const { mutation } = parameters\n\n const config = useConfig(parameters)\n\n const mutationOptions = reconnectMutationOptions(config)\n const { mutate, mutateAsync, ...result } = useMutation({\n ...mutation,\n ...mutationOptions,\n })\n\n return {\n ...result,\n connectors: config.connectors,\n reconnect: mutate,\n reconnectAsync: mutateAsync,\n }\n}\n", "'use client'\n\nimport { useMutation } from '@tanstack/react-query'\nimport type {\n Config,\n ResolvedRegister,\n SendTransactionErrorType,\n} from '@wagmi/core'\nimport type { Compute } from '@wagmi/core/internal'\nimport {\n type SendTransactionData,\n type SendTransactionMutate,\n type SendTransactionMutateAsync,\n type SendTransactionVariables,\n sendTransactionMutationOptions,\n} from '@wagmi/core/query'\n\nimport type { ConfigParameter } from '../types/properties.js'\nimport type {\n UseMutationParameters,\n UseMutationReturnType,\n} from '../utils/query.js'\nimport { useConfig } from './useConfig.js'\n\nexport type UseSendTransactionParameters<\n config extends Config = Config,\n context = unknown,\n> = Compute<\n ConfigParameter<config> & {\n mutation?:\n | UseMutationParameters<\n SendTransactionData,\n SendTransactionErrorType,\n SendTransactionVariables<config, config['chains'][number]['id']>,\n context\n >\n | undefined\n }\n>\n\nexport type UseSendTransactionReturnType<\n config extends Config = Config,\n context = unknown,\n> = Compute<\n UseMutationReturnType<\n SendTransactionData,\n SendTransactionErrorType,\n SendTransactionVariables<config, config['chains'][number]['id']>,\n context\n > & {\n sendTransaction: SendTransactionMutate<config, context>\n sendTransactionAsync: SendTransactionMutateAsync<config, context>\n }\n>\n\n/** https://wagmi.sh/react/api/hooks/useSendTransaction */\nexport function useSendTransaction<\n config extends Config = ResolvedRegister['config'],\n context = unknown,\n>(\n parameters: UseSendTransactionParameters<config, context> = {},\n): UseSendTransactionReturnType<config, context> {\n const { mutation } = parameters\n\n const config = useConfig(parameters)\n\n const mutationOptions = sendTransactionMutationOptions(config)\n const { mutate, mutateAsync, ...result } = useMutation({\n ...mutation,\n ...mutationOptions,\n })\n\n type Return = UseSendTransactionReturnType<config, context>\n return {\n ...result,\n sendTransaction: mutate as Return['sendTransaction'],\n sendTransactionAsync: mutateAsync as Return['sendTransactionAsync'],\n }\n}\n", "'use client'\n\nimport { useMutation } from '@tanstack/react-query'\nimport type { SignMessageErrorType } from '@wagmi/core'\nimport type { Compute } from '@wagmi/core/internal'\nimport {\n type SignMessageData,\n type SignMessageMutate,\n type SignMessageMutateAsync,\n type SignMessageVariables,\n signMessageMutationOptions,\n} from '@wagmi/core/query'\n\nimport type { ConfigParameter } from '../types/properties.js'\nimport type {\n UseMutationParameters,\n UseMutationReturnType,\n} from '../utils/query.js'\nimport { useConfig } from './useConfig.js'\n\nexport type UseSignMessageParameters<context = unknown> = Compute<\n ConfigParameter & {\n mutation?:\n | UseMutationParameters<\n SignMessageData,\n SignMessageErrorType,\n SignMessageVariables,\n context\n >\n | undefined\n }\n>\n\nexport type UseSignMessageReturnType<context = unknown> = Compute<\n UseMutationReturnType<\n SignMessageData,\n SignMessageErrorType,\n SignMessageVariables,\n context\n > & {\n signMessage: SignMessageMutate<context>\n signMessageAsync: SignMessageMutateAsync<context>\n }\n>\n\n/** https://wagmi.sh/react/api/hooks/useSignMessage */\nexport function useSignMessage<context = unknown>(\n parameters: UseSignMessageParameters<context> = {},\n): UseSignMessageReturnType<context> {\n const { mutation } = parameters\n\n const config = useConfig(parameters)\n\n const mutationOptions = signMessageMutationOptions(config)\n const { mutate, mutateAsync, ...result } = useMutation({\n ...mutation,\n ...mutationOptions,\n })\n\n return {\n ...result,\n signMessage: mutate,\n signMessageAsync: mutateAsync,\n }\n}\n", "'use client'\n\nimport { useMutation } from '@tanstack/react-query'\nimport type { SignTypedDataErrorType } from '@wagmi/core'\nimport type { Compute } from '@wagmi/core/internal'\nimport {\n type SignTypedDataData,\n type SignTypedDataMutate,\n type SignTypedDataMutateAsync,\n type SignTypedDataVariables,\n signTypedDataMutationOptions,\n} from '@wagmi/core/query'\n\nimport type { ConfigParameter } from '../types/properties.js'\nimport type {\n UseMutationParameters,\n UseMutationReturnType,\n} from '../utils/query.js'\nimport { useConfig } from './useConfig.js'\n\nexport type UseSignTypedDataParameters<context = unknown> = Compute<\n ConfigParameter & {\n mutation?:\n | UseMutationParameters<\n SignTypedDataData,\n SignTypedDataErrorType,\n SignTypedDataVariables,\n context\n >\n | undefined\n }\n>\n\nexport type UseSignTypedDataReturnType<context = unknown> = Compute<\n UseMutationReturnType<\n SignTypedDataData,\n SignTypedDataErrorType,\n SignTypedDataVariables,\n context\n > & {\n signTypedData: SignTypedDataMutate<context>\n signTypedDataAsync: SignTypedDataMutateAsync<context>\n }\n>\n\n/** https://wagmi.sh/react/api/hooks/useSignTypedData */\nexport function useSignTypedData<context = unknown>(\n parameters: UseSignTypedDataParameters<context> = {},\n): UseSignTypedDataReturnType<context> {\n const { mutation } = parameters\n\n const config = useConfig(parameters)\n\n const mutationOptions = signTypedDataMutationOptions(config)\n const { mutate, mutateAsync, ...result } = useMutation({\n ...mutation,\n ...mutationOptions,\n })\n\n type Return = UseSignTypedDataReturnType<context>\n return {\n ...result,\n signTypedData: mutate as Return['signTypedData'],\n signTypedDataAsync: mutateAsync as Return['signTypedDataAsync'],\n }\n}\n", "'use client'\n\nimport type {\n Config,\n ResolvedRegister,\n SimulateContractErrorType,\n} from '@wagmi/core'\nimport {\n type SimulateContractData,\n type SimulateContractOptions,\n type SimulateContractQueryFnData,\n type SimulateContractQueryKey,\n simulateContractQueryOptions,\n} from '@wagmi/core/query'\nimport type { Abi, ContractFunctionArgs, ContractFunctionName } from 'viem'\n\nimport type { ConfigParameter, QueryParameter } from '../types/properties.js'\nimport { type UseQueryReturnType, useQuery } from '../utils/query.js'\nimport { useChainId } from './useChainId.js'\nimport { useConfig } from './useConfig.js'\nimport { useConnectorClient } from './useConnectorClient.js'\n\nexport type UseSimulateContractParameters<\n abi extends Abi | readonly unknown[] = Abi,\n functionName extends ContractFunctionName<\n abi,\n 'nonpayable' | 'payable'\n > = ContractFunctionName<abi, 'nonpayable' | 'payable'>,\n args extends ContractFunctionArgs<\n abi,\n 'nonpayable' | 'payable',\n functionName\n > = ContractFunctionArgs<abi, 'nonpayable' | 'payable', functionName>,\n config extends Config = Config,\n chainId extends config['chains'][number]['id'] | undefined = undefined,\n selectData = SimulateContractData<abi, functionName, args, config, chainId>,\n> = SimulateContractOptions<abi, functionName, args, config, chainId> &\n ConfigParameter<config> &\n QueryParameter<\n SimulateContractQueryFnData<abi, functionName, args, config, chainId>,\n SimulateContractErrorType,\n selectData,\n SimulateContractQueryKey<abi, functionName, args, config, chainId>\n >\n\nexport type UseSimulateContractReturnType<\n abi extends Abi | readonly unknown[] = Abi,\n functionName extends ContractFunctionName<\n abi,\n 'nonpayable' | 'payable'\n > = ContractFunctionName<abi, 'nonpayable' | 'payable'>,\n args extends ContractFunctionArgs<\n abi,\n 'nonpayable' | 'payable',\n functionName\n > = ContractFunctionArgs<abi, 'nonpayable' | 'payable', functionName>,\n config extends Config = Config,\n chainId extends config['chains'][number]['id'] | undefined = undefined,\n selectData = SimulateContractData<abi, functionName, args, config, chainId>,\n> = UseQueryReturnType<selectData, SimulateContractErrorType>\n\n/** https://wagmi.sh/react/api/hooks/useSimulateContract */\nexport function useSimulateContract<\n const abi extends Abi | readonly unknown[],\n functionName extends ContractFunctionName<abi, 'nonpayable' | 'payable'>,\n args extends ContractFunctionArgs<\n abi,\n 'nonpayable' | 'payable',\n functionName\n >,\n config extends Config = ResolvedRegister['config'],\n chainId extends config['chains'][number]['id'] | undefined = undefined,\n selectData = SimulateContractData<abi, functionName, args, config, chainId>,\n>(\n parameters: UseSimulateContractParameters<\n abi,\n functionName,\n args,\n config,\n chainId,\n selectData\n > = {} as any,\n): UseSimulateContractReturnType<\n abi,\n functionName,\n args,\n config,\n chainId,\n selectData\n> {\n const { abi, address, connector, functionName, query = {} } = parameters\n\n const config = useConfig(parameters)\n const { data: connectorClient } = useConnectorClient({\n config,\n connector,\n query: { enabled: parameters.account === undefined },\n })\n const chainId = useChainId({ config })\n\n const options = simulateContractQueryOptions<\n config,\n abi,\n functionName,\n args,\n chainId\n >(config, {\n ...parameters,\n account: parameters.account ?? connectorClient?.account,\n chainId: parameters.chainId ?? chainId,\n })\n const enabled = Boolean(\n abi && address && functionName && (query.enabled ?? true),\n )\n\n return useQuery({ ...query, ...options, enabled })\n}\n", "'use client'\n\nimport type {\n Config,\n GetStorageAtErrorType,\n ResolvedRegister,\n} from '@wagmi/core'\nimport type { Compute } from '@wagmi/core/internal'\nimport {\n type GetStorageAtData,\n type GetStorageAtOptions,\n type GetStorageAtQueryKey,\n getStorageAtQueryOptions,\n} from '@wagmi/core/query'\nimport type { GetStorageAtQueryFnData } from '@wagmi/core/query'\nimport type { ConfigParameter, QueryParameter } from '../types/properties.js'\nimport { type UseQueryReturnType, useQuery } from '../utils/query.js'\nimport { useChainId } from './useChainId.js'\nimport { useConfig } from './useConfig.js'\n\nexport type UseStorageAtParameters<\n config extends Config = Config,\n selectData = GetStorageAtData,\n> = Compute<\n GetStorageAtOptions<config> &\n ConfigParameter<config> &\n QueryParameter<\n GetStorageAtQueryFnData,\n GetStorageAtErrorType,\n selectData,\n GetStorageAtQueryKey<config>\n >\n>\n\nexport type UseStorageAtReturnType<selectData = GetStorageAtData> =\n UseQueryReturnType<selectData, GetStorageAtErrorType>\n\n/** https://wagmi.sh/react/api/hooks/useStorageAt */\nexport function useStorageAt<\n config extends Config = ResolvedRegister['config'],\n selectData = GetStorageAtData,\n>(\n parameters: UseStorageAtParameters<config, selectData> = {},\n): UseStorageAtReturnType<selectData> {\n const { address, slot, query = {} } = parameters\n\n const config = useConfig(parameters)\n const chainId = useChainId({ config })\n\n const options = getStorageAtQueryOptions(config, {\n ...parameters,\n chainId: parameters.chainId ?? chainId,\n })\n const enabled = Boolean(address && slot && (query.enabled ?? true))\n\n return useQuery({ ...query, ...options, enabled })\n}\n", "'use client'\n\nimport { useMutation } from '@tanstack/react-query'\nimport type {\n Config,\n Connector,\n ResolvedRegister,\n SwitchAccountErrorType,\n} from '@wagmi/core'\nimport type { Compute } from '@wagmi/core/internal'\nimport {\n type SwitchAccountData,\n type SwitchAccountMutate,\n type SwitchAccountMutateAsync,\n type SwitchAccountVariables,\n switchAccountMutationOptions,\n} from '@wagmi/core/query'\n\nimport type { ConfigParameter } from '../types/properties.js'\nimport type {\n UseMutationParameters,\n UseMutationReturnType,\n} from '../utils/query.js'\nimport { useConfig } from './useConfig.js'\nimport { useConnections } from './useConnections.js'\n\nexport type UseSwitchAccountParameters<\n config extends Config = Config,\n context = unknown,\n> = Compute<\n ConfigParameter<config> & {\n mutation?:\n | UseMutationParameters<\n SwitchAccountData<config>,\n SwitchAccountErrorType,\n SwitchAccountVariables,\n context\n >\n | undefined\n }\n>\n\nexport type UseSwitchAccountReturnType<\n config extends Config = Config,\n context = unknown,\n> = Compute<\n UseMutationReturnType<\n SwitchAccountData<config>,\n SwitchAccountErrorType,\n SwitchAccountVariables,\n context\n > & {\n connectors: readonly Connector[]\n switchAccount: SwitchAccountMutate<config, context>\n switchAccountAsync: SwitchAccountMutateAsync<config, context>\n }\n>\n\n/** https://wagmi.sh/react/api/hooks/useSwitchAccount */\nexport function useSwitchAccount<\n config extends Config = ResolvedRegister['config'],\n context = unknown,\n>(\n parameters: UseSwitchAccountParameters<config, context> = {},\n): UseSwitchAccountReturnType<config, context> {\n const { mutation } = parameters\n\n const config = useConfig(parameters)\n\n const mutationOptions = switchAccountMutationOptions(config)\n const { mutate, mutateAsync, ...result } = useMutation({\n ...mutation,\n ...mutationOptions,\n })\n\n return {\n ...result,\n connectors: useConnections({ config }).map(\n (connection) => connection.connector,\n ),\n switchAccount: mutate,\n switchAccountAsync: mutateAsync,\n }\n}\n", "'use client'\n\nimport { useMutation } from '@tanstack/react-query'\nimport type {\n Config,\n ResolvedRegister,\n SwitchChainErrorType,\n} from '@wagmi/core'\nimport type { Compute } from '@wagmi/core/internal'\nimport {\n type SwitchChainData,\n type SwitchChainMutate,\n type SwitchChainMutateAsync,\n type SwitchChainVariables,\n switchChainMutationOptions,\n} from '@wagmi/core/query'\n\nimport type { ConfigParameter } from '../types/properties.js'\nimport type {\n UseMutationParameters,\n UseMutationReturnType,\n} from '../utils/query.js'\nimport { useChains } from './useChains.js'\nimport { useConfig } from './useConfig.js'\n\nexport type UseSwitchChainParameters<\n config extends Config = Config,\n context = unknown,\n> = Compute<\n ConfigParameter<config> & {\n mutation?:\n | UseMutationParameters<\n SwitchChainData<config, config['chains'][number]['id']>,\n SwitchChainErrorType,\n SwitchChainVariables<config, config['chains'][number]['id']>,\n context\n >\n | undefined\n }\n>\n\nexport type UseSwitchChainReturnType<\n config extends Config = Config,\n context = unknown,\n> = Compute<\n UseMutationReturnType<\n SwitchChainData<config, config['chains'][number]['id']>,\n SwitchChainErrorType,\n SwitchChainVariables<config, config['chains'][number]['id']>,\n context\n > & {\n chains: config['chains']\n switchChain: SwitchChainMutate<config, context>\n switchChainAsync: SwitchChainMutateAsync<config, context>\n }\n>\n\n/** https://wagmi.sh/react/api/hooks/useSwitchChain */\nexport function useSwitchChain<\n config extends Config = ResolvedRegister['config'],\n context = unknown,\n>(\n parameters: UseSwitchChainParameters<config, context> = {},\n): UseSwitchChainReturnType<config, context> {\n const { mutation } = parameters\n\n const config = useConfig(parameters)\n\n const mutationOptions = switchChainMutationOptions(config)\n const { mutate, mutateAsync, ...result } = useMutation({\n ...mutation,\n ...mutationOptions,\n })\n\n type Return = UseSwitchChainReturnType<config, context>\n return {\n ...result,\n chains: useChains({ config }) as unknown as config['chains'],\n switchChain: mutate as Return['switchChain'],\n switchChainAsync: mutateAsync as Return['switchChainAsync'],\n }\n}\n", "'use client'\n\nimport type { Config, GetTokenErrorType, ResolvedRegister } from '@wagmi/core'\nimport type { Compute } from '@wagmi/core/internal'\nimport {\n type GetTokenData,\n type GetTokenOptions,\n type GetTokenQueryFnData,\n type GetTokenQueryKey,\n getTokenQueryOptions,\n} from '@wagmi/core/query'\n\nimport type { ConfigParameter, QueryParameter } from '../types/properties.js'\nimport { type UseQueryReturnType, useQuery } from '../utils/query.js'\nimport { useChainId } from './useChainId.js'\nimport { useConfig } from './useConfig.js'\n\nexport type UseTokenParameters<\n config extends Config = Config,\n selectData = GetTokenData,\n> = Compute<\n GetTokenOptions<config> &\n ConfigParameter<config> &\n QueryParameter<\n GetTokenQueryFnData,\n GetTokenErrorType,\n selectData,\n GetTokenQueryKey<config>\n >\n>\n\nexport type UseTokenReturnType<selectData = GetTokenData> = UseQueryReturnType<\n selectData,\n GetTokenErrorType\n>\n\n/**\n * @deprecated\n *\n * https://wagmi.sh/react/api/hooks/useToken\n */\nexport function useToken<\n config extends Config = ResolvedRegister['config'],\n selectData = GetTokenData,\n>(\n parameters: UseTokenParameters<config, selectData> = {},\n): UseTokenReturnType<selectData> {\n const { address, query = {} } = parameters\n\n const config = useConfig(parameters)\n const chainId = useChainId({ config })\n\n const options = getTokenQueryOptions(config, {\n ...parameters,\n chainId: parameters.chainId ?? chainId,\n })\n const enabled = Boolean(address && (query.enabled ?? true))\n\n return useQuery({ ...query, ...options, enabled })\n}\n", "'use client'\n\nimport type {\n Config,\n GetTransactionErrorType,\n ResolvedRegister,\n} from '@wagmi/core'\nimport type { Compute } from '@wagmi/core/internal'\nimport {\n type GetTransactionData,\n type GetTransactionOptions,\n type GetTransactionQueryFnData,\n type GetTransactionQueryKey,\n getTransactionQueryOptions,\n} from '@wagmi/core/query'\n\nimport type { ConfigParameter, QueryParameter } from '../types/properties.js'\nimport { type UseQueryReturnType, useQuery } from '../utils/query.js'\nimport { useChainId } from './useChainId.js'\nimport { useConfig } from './useConfig.js'\n\nexport type UseTransactionParameters<\n config extends Config = Config,\n chainId extends\n config['chains'][number]['id'] = config['chains'][number]['id'],\n selectData = GetTransactionData<config, chainId>,\n> = Compute<\n GetTransactionOptions<config, chainId> &\n ConfigParameter<config> &\n QueryParameter<\n GetTransactionQueryFnData<config, chainId>,\n GetTransactionErrorType,\n selectData,\n GetTransactionQueryKey<config, chainId>\n >\n>\n\nexport type UseTransactionReturnType<\n config extends Config = Config,\n chainId extends\n config['chains'][number]['id'] = config['chains'][number]['id'],\n selectData = GetTransactionData<config, chainId>,\n> = UseQueryReturnType<selectData, GetTransactionErrorType>\n\n/** https://wagmi.sh/react/api/hooks/useTransaction */\nexport function useTransaction<\n config extends Config = ResolvedRegister['config'],\n chainId extends\n config['chains'][number]['id'] = config['chains'][number]['id'],\n selectData = GetTransactionData<config, chainId>,\n>(\n parameters: UseTransactionParameters<config, chainId, selectData> = {},\n): UseTransactionReturnType<config, chainId, selectData> {\n const { blockHash, blockNumber, blockTag, hash, query = {} } = parameters\n\n const config = useConfig(parameters)\n const chainId = useChainId({ config })\n\n const options = getTransactionQueryOptions(config, {\n ...parameters,\n chainId: parameters.chainId ?? chainId,\n })\n const enabled = Boolean(\n !(blockHash && blockNumber && blockTag && hash) && (query.enabled ?? true),\n )\n\n return useQuery({\n ...(query as any),\n ...options,\n enabled,\n }) as UseTransactionReturnType<config, chainId, selectData>\n}\n", "'use client'\n\nimport type {\n Config,\n GetTransactionConfirmationsErrorType,\n ResolvedRegister,\n} from '@wagmi/core'\nimport {\n type GetTransactionConfirmationsData,\n type GetTransactionConfirmationsOptions,\n type GetTransactionConfirmationsQueryFnData,\n type GetTransactionConfirmationsQueryKey,\n getTransactionConfirmationsQueryOptions,\n} from '@wagmi/core/query'\n\nimport type { ConfigParameter, QueryParameter } from '../types/properties.js'\nimport { type UseQueryReturnType, useQuery } from '../utils/query.js'\nimport { useChainId } from './useChainId.js'\nimport { useConfig } from './useConfig.js'\n\nexport type UseTransactionConfirmationsParameters<\n config extends Config = Config,\n chainId extends config['chains'][number]['id'] | undefined = undefined,\n selectData = GetTransactionConfirmationsData,\n> = GetTransactionConfirmationsOptions<config, chainId> &\n ConfigParameter<config> &\n QueryParameter<\n GetTransactionConfirmationsQueryFnData,\n GetTransactionConfirmationsErrorType,\n selectData,\n GetTransactionConfirmationsQueryKey<config, chainId>\n >\n\nexport type UseTransactionConfirmationsReturnType<\n selectData = GetTransactionConfirmationsData,\n> = UseQueryReturnType<selectData, GetTransactionConfirmationsErrorType>\n\n/** https://wagmi.sh/react/api/hooks/useTransactionConfirmations */\nexport function useTransactionConfirmations<\n config extends Config = ResolvedRegister['config'],\n chainId extends config['chains'][number]['id'] | undefined = undefined,\n selectData = GetTransactionConfirmationsData,\n>(\n parameters: UseTransactionConfirmationsParameters<\n config,\n chainId,\n selectData\n > = {} as any,\n): UseTransactionConfirmationsReturnType<selectData> {\n const { hash, transactionReceipt, query = {} } = parameters\n\n const config = useConfig(parameters)\n const chainId = useChainId({ config })\n\n const options = getTransactionConfirmationsQueryOptions(config, {\n ...parameters,\n chainId: parameters.chainId ?? chainId,\n })\n const enabled = Boolean(\n !(hash && transactionReceipt) &&\n (hash || transactionReceipt) &&\n (query.enabled ?? true),\n )\n\n return useQuery({ ...query, ...options, enabled })\n}\n", "'use client'\n\nimport type {\n Config,\n GetTransactionCountErrorType,\n ResolvedRegister,\n} from '@wagmi/core'\nimport type { Compute } from '@wagmi/core/internal'\nimport type { GetTransactionCountQueryFnData } from '@wagmi/core/query'\nimport {\n type GetTransactionCountData,\n type GetTransactionCountOptions,\n type GetTransactionCountQueryKey,\n getTransactionCountQueryOptions,\n} from '@wagmi/core/query'\n\nimport type { ConfigParameter, QueryParameter } from '../types/properties.js'\nimport { type UseQueryReturnType, useQuery } from '../utils/query.js'\nimport { useChainId } from './useChainId.js'\nimport { useConfig } from './useConfig.js'\n\nexport type UseTransactionCountParameters<\n config extends Config = Config,\n selectData = GetTransactionCountData,\n> = Compute<\n GetTransactionCountOptions<config> &\n ConfigParameter<config> &\n QueryParameter<\n GetTransactionCountQueryFnData,\n GetTransactionCountErrorType,\n selectData,\n GetTransactionCountQueryKey<config>\n >\n>\n\nexport type UseTransactionCountReturnType<\n selectData = GetTransactionCountData,\n> = UseQueryReturnType<selectData, GetTransactionCountErrorType>\n\n/** https://wagmi.sh/react/api/hooks/useTransactionCount */\nexport function useTransactionCount<\n config extends Config = ResolvedRegister['config'],\n selectData = GetTransactionCountData,\n>(\n parameters: UseTransactionCountParameters<config, selectData> = {},\n): UseTransactionCountReturnType<selectData> {\n const { address, query = {} } = parameters\n\n const config = useConfig(parameters)\n const chainId = useChainId({ config })\n\n const options = getTransactionCountQueryOptions(config, {\n ...parameters,\n chainId: parameters.chainId ?? chainId,\n })\n const enabled = Boolean(address && (query.enabled ?? true))\n\n return useQuery({ ...query, ...options, enabled })\n}\n", "'use client'\n\nimport type {\n Config,\n GetTransactionReceiptErrorType,\n ResolvedRegister,\n} from '@wagmi/core'\nimport type { Compute } from '@wagmi/core/internal'\nimport {\n type GetTransactionReceiptData,\n type GetTransactionReceiptOptions,\n type GetTransactionReceiptQueryKey,\n getTransactionReceiptQueryOptions,\n} from '@wagmi/core/query'\nimport type { GetTransactionReceiptQueryFnData } from '@wagmi/core/query'\nimport type { ConfigParameter, QueryParameter } from '../types/properties.js'\nimport { type UseQueryReturnType, useQuery } from '../utils/query.js'\nimport { useChainId } from './useChainId.js'\nimport { useConfig } from './useConfig.js'\n\nexport type UseTransactionReceiptParameters<\n config extends Config = Config,\n chainId extends\n config['chains'][number]['id'] = config['chains'][number]['id'],\n selectData = GetTransactionReceiptData<config, chainId>,\n> = Compute<\n GetTransactionReceiptOptions<config, chainId> &\n ConfigParameter<config> &\n QueryParameter<\n GetTransactionReceiptQueryFnData<config, chainId>,\n GetTransactionReceiptErrorType,\n selectData,\n GetTransactionReceiptQueryKey<config, chainId>\n >\n>\n\nexport type UseTransactionReceiptReturnType<\n config extends Config = Config,\n chainId extends\n config['chains'][number]['id'] = config['chains'][number]['id'],\n selectData = GetTransactionReceiptData<config, chainId>,\n> = UseQueryReturnType<selectData, GetTransactionReceiptErrorType>\n\n/** https://wagmi.sh/react/api/hooks/useTransactionReceipt */\nexport function useTransactionReceipt<\n config extends Config = ResolvedRegister['config'],\n chainId extends\n config['chains'][number]['id'] = config['chains'][number]['id'],\n selectData = GetTransactionReceiptData<config, chainId>,\n>(\n parameters: UseTransactionReceiptParameters<config, chainId, selectData> = {},\n): UseTransactionReceiptReturnType<config, chainId, selectData> {\n const { hash, query = {} } = parameters\n\n const config = useConfig(parameters)\n const chainId = useChainId({ config })\n\n const options = getTransactionReceiptQueryOptions(config, {\n ...parameters,\n chainId: parameters.chainId ?? chainId,\n })\n const enabled = Boolean(hash && (query.enabled ?? true))\n\n return useQuery({\n ...(query as any),\n ...options,\n enabled,\n }) as UseTransactionReceiptReturnType<config, chainId, selectData>\n}\n", "'use client'\n\nimport type {\n Config,\n ResolvedRegister,\n VerifyMessageErrorType,\n} from '@wagmi/core'\nimport type { Compute } from '@wagmi/core/internal'\nimport {\n type VerifyMessageData,\n type VerifyMessageOptions,\n type VerifyMessageQueryKey,\n verifyMessageQueryOptions,\n} from '@wagmi/core/query'\nimport type { VerifyMessageQueryFnData } from '@wagmi/core/query'\nimport type { ConfigParameter, QueryParameter } from '../types/properties.js'\nimport { type UseQueryReturnType, useQuery } from '../utils/query.js'\nimport { useChainId } from './useChainId.js'\nimport { useConfig } from './useConfig.js'\n\nexport type UseVerifyMessageParameters<\n config extends Config = Config,\n selectData = VerifyMessageData,\n> = Compute<\n VerifyMessageOptions<config> &\n ConfigParameter<config> &\n QueryParameter<\n VerifyMessageQueryFnData,\n VerifyMessageErrorType,\n selectData,\n VerifyMessageQueryKey<config>\n >\n>\n\nexport type UseVerifyMessageReturnType<selectData = VerifyMessageData> =\n UseQueryReturnType<selectData, VerifyMessageErrorType>\n\n/** https://wagmi.sh/react/api/hooks/useVerifyMessage */\nexport function useVerifyMessage<\n config extends Config = ResolvedRegister['config'],\n selectData = VerifyMessageData,\n>(\n parameters: UseVerifyMessageParameters<config, selectData> = {},\n): UseVerifyMessageReturnType<selectData> {\n const { address, message, signature, query = {} } = parameters\n\n const config = useConfig(parameters)\n const chainId = useChainId({ config })\n\n const options = verifyMessageQueryOptions(config, {\n ...parameters,\n chainId: parameters.chainId ?? chainId,\n })\n const enabled = Boolean(\n address && message && signature && (query.enabled ?? true),\n )\n\n return useQuery({ ...query, ...options, enabled })\n}\n", "'use client'\n\nimport type {\n Config,\n ResolvedRegister,\n VerifyTypedDataErrorType,\n} from '@wagmi/core'\nimport {\n type VerifyTypedDataData,\n type VerifyTypedDataOptions,\n type VerifyTypedDataQueryKey,\n verifyTypedDataQueryOptions,\n} from '@wagmi/core/query'\nimport type { VerifyTypedDataQueryFnData } from '@wagmi/core/query'\nimport type { TypedData } from 'viem'\nimport type { ConfigParameter, QueryParameter } from '../types/properties.js'\nimport { type UseQueryReturnType, useQuery } from '../utils/query.js'\nimport { useChainId } from './useChainId.js'\nimport { useConfig } from './useConfig.js'\n\nexport type UseVerifyTypedDataParameters<\n typedData extends TypedData | Record<string, unknown> = TypedData,\n primaryType extends keyof typedData | 'EIP712Domain' = keyof typedData,\n config extends Config = Config,\n selectData = VerifyTypedDataData,\n> = VerifyTypedDataOptions<typedData, primaryType, config> &\n ConfigParameter<config> &\n QueryParameter<\n VerifyTypedDataQueryFnData,\n VerifyTypedDataErrorType,\n selectData,\n VerifyTypedDataQueryKey<typedData, primaryType, config>\n >\n\nexport type UseVerifyTypedDataReturnType<selectData = VerifyTypedDataData> =\n UseQueryReturnType<selectData, VerifyTypedDataErrorType>\n\n/** https://wagmi.sh/react/api/hooks/useVerifyTypedData */\nexport function useVerifyTypedData<\n const typedData extends TypedData | Record<string, unknown>,\n primaryType extends keyof typedData | 'EIP712Domain',\n config extends Config = ResolvedRegister['config'],\n selectData = VerifyTypedDataData,\n>(\n parameters: UseVerifyTypedDataParameters<\n typedData,\n primaryType,\n config,\n selectData\n > = {} as any,\n): UseVerifyTypedDataReturnType<selectData> {\n const {\n address,\n message,\n primaryType,\n signature,\n types,\n query = {},\n } = parameters\n\n const config = useConfig(parameters)\n const chainId = useChainId({ config })\n\n const options = verifyTypedDataQueryOptions<config, typedData, primaryType>(\n config,\n {\n ...parameters,\n chainId: parameters.chainId ?? chainId,\n },\n )\n const enabled = Boolean(\n address &&\n message &&\n primaryType &&\n signature &&\n types &&\n (query.enabled ?? true),\n )\n\n return useQuery({ ...query, ...options, enabled })\n}\n", "'use client'\n\n// Almost identical implementation to `useConnectorClient` (except for return type)\n// Should update both in tandem\n\nimport { useQueryClient } from '@tanstack/react-query'\nimport type {\n Config,\n GetWalletClientErrorType,\n ResolvedRegister,\n} from '@wagmi/core'\nimport type { Compute, Omit } from '@wagmi/core/internal'\nimport {\n type GetWalletClientData,\n type GetWalletClientOptions,\n type GetWalletClientQueryFnData,\n type GetWalletClientQueryKey,\n getWalletClientQueryOptions,\n} from '@wagmi/core/query'\nimport { useEffect, useRef } from 'react'\n\nimport type { ConfigParameter } from '../types/properties.js'\nimport {\n type UseQueryParameters,\n type UseQueryReturnType,\n useQuery,\n} from '../utils/query.js'\nimport { useAccount } from './useAccount.js'\nimport { useChainId } from './useChainId.js'\nimport { useConfig } from './useConfig.js'\n\nexport type UseWalletClientParameters<\n config extends Config = Config,\n chainId extends\n config['chains'][number]['id'] = config['chains'][number]['id'],\n selectData = GetWalletClientData<config, chainId>,\n> = Compute<\n GetWalletClientOptions<config, chainId> &\n ConfigParameter<config> & {\n query?:\n | Compute<\n Omit<\n UseQueryParameters<\n GetWalletClientQueryFnData<config, chainId>,\n GetWalletClientErrorType,\n selectData,\n GetWalletClientQueryKey<config, chainId>\n >,\n 'gcTime' | 'staleTime'\n >\n >\n | undefined\n }\n>\n\nexport type UseWalletClientReturnType<\n config extends Config = Config,\n chainId extends\n config['chains'][number]['id'] = config['chains'][number]['id'],\n selectData = GetWalletClientData<config, chainId>,\n> = UseQueryReturnType<selectData, GetWalletClientErrorType>\n\n/** https://wagmi.sh/react/api/hooks/useWalletClient */\nexport function useWalletClient<\n config extends Config = ResolvedRegister['config'],\n chainId extends\n config['chains'][number]['id'] = config['chains'][number]['id'],\n selectData = GetWalletClientData<config, chainId>,\n>(\n parameters: UseWalletClientParameters<config, chainId, selectData> = {},\n): UseWalletClientReturnType<config, chainId, selectData> {\n const { query = {}, ...rest } = parameters\n\n const config = useConfig(rest)\n const queryClient = useQueryClient()\n const { address, connector, status } = useAccount({ config })\n const chainId = useChainId({ config })\n const activeConnector = parameters.connector ?? connector\n\n const { queryKey, ...options } = getWalletClientQueryOptions<config, chainId>(\n config,\n {\n ...parameters,\n chainId: parameters.chainId ?? chainId,\n connector: parameters.connector ?? connector,\n },\n )\n const enabled = Boolean(\n (status === 'connected' ||\n (status === 'reconnecting' && activeConnector?.getProvider)) &&\n (query.enabled ?? true),\n )\n\n const addressRef = useRef(address)\n // biome-ignore lint/correctness/useExhaustiveDependencies: `queryKey` not required\n useEffect(() => {\n const previousAddress = addressRef.current\n if (!address && previousAddress) {\n // remove when account is disconnected\n queryClient.removeQueries({ queryKey })\n addressRef.current = undefined\n } else if (address !== previousAddress) {\n // invalidate when address changes\n queryClient.invalidateQueries({ queryKey })\n addressRef.current = address\n }\n }, [address, queryClient])\n\n return useQuery({\n ...query,\n ...options,\n queryKey,\n enabled,\n staleTime: Number.POSITIVE_INFINITY,\n } as any) as UseWalletClientReturnType<config, chainId, selectData>\n}\n", "'use client'\n\nimport type {\n Config,\n ResolvedRegister,\n WaitForTransactionReceiptErrorType,\n} from '@wagmi/core'\nimport type { Compute } from '@wagmi/core/internal'\nimport {\n type WaitForTransactionReceiptData,\n type WaitForTransactionReceiptOptions,\n type WaitForTransactionReceiptQueryFnData,\n type WaitForTransactionReceiptQueryKey,\n waitForTransactionReceiptQueryOptions,\n} from '@wagmi/core/query'\n\nimport type { ConfigParameter, QueryParameter } from '../types/properties.js'\nimport { type UseQueryReturnType, useQuery } from '../utils/query.js'\nimport { useChainId } from './useChainId.js'\nimport { useConfig } from './useConfig.js'\n\nexport type UseWaitForTransactionReceiptParameters<\n config extends Config = Config,\n chainId extends\n config['chains'][number]['id'] = config['chains'][number]['id'],\n selectData = WaitForTransactionReceiptData<config, chainId>,\n> = Compute<\n WaitForTransactionReceiptOptions<config, chainId> &\n ConfigParameter<config> &\n QueryParameter<\n WaitForTransactionReceiptQueryFnData<config, chainId>,\n WaitForTransactionReceiptErrorType,\n selectData,\n WaitForTransactionReceiptQueryKey<config, chainId>\n >\n>\n\nexport type UseWaitForTransactionReceiptReturnType<\n config extends Config = Config,\n chainId extends\n config['chains'][number]['id'] = config['chains'][number]['id'],\n selectData = WaitForTransactionReceiptData<config, chainId>,\n> = UseQueryReturnType<selectData, WaitForTransactionReceiptErrorType>\n\n/** https://wagmi.sh/react/api/hooks/useWaitForTransactionReceipt */\nexport function useWaitForTransactionReceipt<\n config extends Config = ResolvedRegister['config'],\n chainId extends\n config['chains'][number]['id'] = config['chains'][number]['id'],\n selectData = WaitForTransactionReceiptData<config, chainId>,\n>(\n parameters: UseWaitForTransactionReceiptParameters<\n config,\n chainId,\n selectData\n > = {},\n): UseWaitForTransactionReceiptReturnType<config, chainId, selectData> {\n const { hash, query = {} } = parameters\n\n const config = useConfig(parameters)\n const chainId = useChainId({ config })\n\n const options = waitForTransactionReceiptQueryOptions(config, {\n ...parameters,\n chainId: parameters.chainId ?? chainId,\n })\n const enabled = Boolean(hash && (query.enabled ?? true))\n\n return useQuery({\n ...(query as any),\n ...options,\n enabled,\n }) as UseWaitForTransactionReceiptReturnType<config, chainId, selectData>\n}\n", "'use client'\n\nimport { useMutation } from '@tanstack/react-query'\nimport type { WatchAssetErrorType } from '@wagmi/core'\nimport type { Compute } from '@wagmi/core/internal'\nimport {\n type WatchAssetData,\n type WatchAssetMutate,\n type WatchAssetMutateAsync,\n type WatchAssetVariables,\n watchAssetMutationOptions,\n} from '@wagmi/core/query'\n\nimport type { ConfigParameter } from '../types/properties.js'\nimport type {\n UseMutationParameters,\n UseMutationReturnType,\n} from '../utils/query.js'\nimport { useConfig } from './useConfig.js'\n\nexport type UseWatchAssetParameters<context = unknown> = Compute<\n ConfigParameter & {\n mutation?:\n | UseMutationParameters<\n WatchAssetData,\n WatchAssetErrorType,\n WatchAssetVariables,\n context\n >\n | undefined\n }\n>\n\nexport type UseWatchAssetReturnType<context = unknown> = Compute<\n UseMutationReturnType<\n WatchAssetData,\n WatchAssetErrorType,\n WatchAssetVariables,\n context\n > & {\n watchAsset: WatchAssetMutate<context>\n watchAssetAsync: WatchAssetMutateAsync<context>\n }\n>\n\n/** https://wagmi.sh/react/api/hooks/useWatchAsset */\nexport function useWatchAsset<context = unknown>(\n parameters: UseWatchAssetParameters<context> = {},\n): UseWatchAssetReturnType<context> {\n const { mutation } = parameters\n\n const config = useConfig(parameters)\n\n const mutationOptions = watchAssetMutationOptions(config)\n const { mutate, mutateAsync, ...result } = useMutation({\n ...mutation,\n ...mutationOptions,\n })\n\n return {\n ...result,\n watchAsset: mutate,\n watchAssetAsync: mutateAsync,\n }\n}\n", "'use client'\n\nimport {\n type Config,\n type ResolvedRegister,\n type WatchContractEventParameters,\n watchContractEvent,\n} from '@wagmi/core'\nimport type { UnionCompute, UnionExactPartial } from '@wagmi/core/internal'\nimport { useEffect } from 'react'\nimport type { Abi, ContractEventName } from 'viem'\n\nimport type { ConfigParameter, EnabledParameter } from '../types/properties.js'\nimport { useChainId } from './useChainId.js'\nimport { useConfig } from './useConfig.js'\n\nexport type UseWatchContractEventParameters<\n abi extends Abi | readonly unknown[] = Abi,\n eventName extends ContractEventName<abi> = ContractEventName<abi>,\n strict extends boolean | undefined = undefined,\n config extends Config = Config,\n chainId extends\n config['chains'][number]['id'] = config['chains'][number]['id'],\n> = UnionCompute<\n UnionExactPartial<\n WatchContractEventParameters<abi, eventName, strict, config, chainId>\n > &\n ConfigParameter<config> &\n EnabledParameter\n>\n\nexport type UseWatchContractEventReturnType = void\n\n/** https://wagmi.sh/react/api/hooks/useWatchContractEvent */\nexport function useWatchContractEvent<\n const abi extends Abi | readonly unknown[],\n eventName extends ContractEventName<abi>,\n strict extends boolean | undefined = undefined,\n config extends Config = ResolvedRegister['config'],\n chainId extends\n config['chains'][number]['id'] = config['chains'][number]['id'],\n>(\n parameters: UseWatchContractEventParameters<\n abi,\n eventName,\n strict,\n config,\n chainId\n > = {} as any,\n): UseWatchContractEventReturnType {\n const { enabled = true, onLogs, config: _, ...rest } = parameters\n\n const config = useConfig(parameters)\n const configChainId = useChainId({ config })\n const chainId = parameters.chainId ?? configChainId\n\n // TODO(react@19): cleanup\n // biome-ignore lint/correctness/useExhaustiveDependencies: `rest` changes every render so only including properties in dependency array\n useEffect(() => {\n if (!enabled) return\n if (!onLogs) return\n return watchContractEvent(config, {\n ...(rest as any),\n chainId,\n onLogs,\n })\n }, [\n chainId,\n config,\n enabled,\n onLogs,\n ///\n rest.abi,\n rest.address,\n rest.args,\n rest.batch,\n rest.eventName,\n rest.fromBlock,\n rest.onError,\n rest.poll,\n rest.pollingInterval,\n rest.strict,\n rest.syncConnectedChain,\n ])\n}\n", "'use client'\n\nimport {\n type Config,\n type ResolvedRegister,\n type WatchPendingTransactionsParameters,\n watchPendingTransactions,\n} from '@wagmi/core'\nimport type { UnionCompute, UnionExactPartial } from '@wagmi/core/internal'\nimport { useEffect } from 'react'\n\nimport type { ConfigParameter, EnabledParameter } from '../types/properties.js'\nimport { useChainId } from './useChainId.js'\nimport { useConfig } from './useConfig.js'\n\nexport type UseWatchPendingTransactionsParameters<\n config extends Config = Config,\n chainId extends\n config['chains'][number]['id'] = config['chains'][number]['id'],\n> = UnionCompute<\n UnionExactPartial<WatchPendingTransactionsParameters<config, chainId>> &\n ConfigParameter<config> &\n EnabledParameter\n>\n\nexport type UseWatchPendingTransactionsReturnType = void\n\n/** https://wagmi.sh/react/api/hooks/useWatchPendingTransactions */\nexport function useWatchPendingTransactions<\n config extends Config = ResolvedRegister['config'],\n chainId extends\n config['chains'][number]['id'] = config['chains'][number]['id'],\n>(\n parameters: UseWatchPendingTransactionsParameters<\n config,\n chainId\n > = {} as any,\n): UseWatchPendingTransactionsReturnType {\n const { enabled = true, onTransactions, config: _, ...rest } = parameters\n\n const config = useConfig(parameters)\n const configChainId = useChainId({ config })\n const chainId = parameters.chainId ?? configChainId\n\n // TODO(react@19): cleanup\n // biome-ignore lint/correctness/useExhaustiveDependencies: `rest` changes every render so only including properties in dependency array\n useEffect(() => {\n if (!enabled) return\n if (!onTransactions) return\n return watchPendingTransactions(config, {\n ...(rest as any),\n chainId,\n onTransactions,\n })\n }, [\n chainId,\n config,\n enabled,\n onTransactions,\n ///\n rest.batch,\n rest.onError,\n rest.poll,\n rest.pollingInterval,\n rest.syncConnectedChain,\n ])\n}\n", "'use client'\n\nimport { useMutation } from '@tanstack/react-query'\nimport type {\n Config,\n ResolvedRegister,\n WriteContractErrorType,\n} from '@wagmi/core'\nimport {\n type WriteContractData,\n type WriteContractMutate,\n type WriteContractMutateAsync,\n type WriteContractVariables,\n writeContractMutationOptions,\n} from '@wagmi/core/query'\nimport type { Abi } from 'viem'\n\nimport type { ConfigParameter } from '../types/properties.js'\nimport type {\n UseMutationParameters,\n UseMutationReturnType,\n} from '../utils/query.js'\nimport { useConfig } from './useConfig.js'\n\nexport type UseWriteContractParameters<\n config extends Config = Config,\n context = unknown,\n> = ConfigParameter<config> & {\n mutation?:\n | UseMutationParameters<\n WriteContractData,\n WriteContractErrorType,\n WriteContractVariables<\n Abi,\n string,\n readonly unknown[],\n config,\n config['chains'][number]['id']\n >,\n context\n >\n | undefined\n}\n\nexport type UseWriteContractReturnType<\n config extends Config = Config,\n context = unknown,\n> = UseMutationReturnType<\n WriteContractData,\n WriteContractErrorType,\n WriteContractVariables<\n Abi,\n string,\n readonly unknown[],\n config,\n config['chains'][number]['id']\n >,\n context\n> & {\n writeContract: WriteContractMutate<config, context>\n writeContractAsync: WriteContractMutateAsync<config, context>\n}\n\n/** https://wagmi.sh/react/api/hooks/useWriteContract */\nexport function useWriteContract<\n config extends Config = ResolvedRegister['config'],\n context = unknown,\n>(\n parameters: UseWriteContractParameters<config, context> = {},\n): UseWriteContractReturnType<config, context> {\n const { mutation } = parameters\n\n const config = useConfig(parameters)\n\n const mutationOptions = writeContractMutationOptions(config)\n const { mutate, mutateAsync, ...result } = useMutation({\n ...mutation,\n ...mutationOptions,\n })\n\n type Return = UseWriteContractReturnType<config, context>\n return {\n ...result,\n writeContract: mutate as Return['writeContract'],\n writeContractAsync: mutateAsync as Return['writeContractAsync'],\n }\n}\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAWA,KACG,WAAY;AACX,eAAS,GAAG,GAAG,GAAG;AAChB,eAAQ,MAAM,MAAM,MAAM,KAAK,IAAI,MAAM,IAAI,MAAQ,MAAM,KAAK,MAAM;AAAA,MACxE;AACA,eAAS,uBAAuB,WAAW,aAAa;AACtD,6BACE,WAAW,MAAM,oBACf,oBAAoB,MACtB,QAAQ;AAAA,UACN;AAAA,QACF;AACF,YAAI,QAAQ,YAAY;AACxB,YAAI,CAAC,4BAA4B;AAC/B,cAAI,cAAc,YAAY;AAC9B,mBAAS,OAAO,WAAW,MACxB,QAAQ;AAAA,YACP;AAAA,UACF,GACC,6BAA6B;AAAA,QAClC;AACA,sBAAc,SAAS;AAAA,UACrB,MAAM,EAAE,OAAc,YAAyB;AAAA,QACjD,CAAC;AACD,YAAI,OAAO,YAAY,CAAC,EAAE,MACxB,cAAc,YAAY,CAAC;AAC7B;AAAA,UACE,WAAY;AACV,iBAAK,QAAQ;AACb,iBAAK,cAAc;AACnB,mCAAuB,IAAI,KAAK,YAAY,EAAE,KAAW,CAAC;AAAA,UAC5D;AAAA,UACA,CAAC,WAAW,OAAO,WAAW;AAAA,QAChC;AACA,QAAAA;AAAA,UACE,WAAY;AACV,mCAAuB,IAAI,KAAK,YAAY,EAAE,KAAW,CAAC;AAC1D,mBAAO,UAAU,WAAY;AAC3B,qCAAuB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AACnC,QAAM,gBAAgB,WAAW,EAAE,OAAM,CAAE;AAC3C,QAAM,UAAU,WAAW,WAAW;AAItC,gCAAU,MAAK;AACb,QAAI,CAAC;AAAS;AACd,QAAI,CAAC;AAAQ;AACb,WAAOC,oBAAmB,QAAQ;MAChC,GAAI;MACJ;MACA;KACD;EACH,GAAG;IACD;IACA;IACA;IACA;;IAEA,KAAK;IACL,KAAK;IACL,KAAK;IACL,KAAK;IACL,KAAK;IACL,KAAK;IACL,KAAK;IACL,KAAK;IACL,KAAK;IACL,KAAK;IACL,KAAK;GACN;AACH;;;AC3EA,IAAAC,iBAA0B;AAmBpB,SAAU,4BAKd,aAGI,CAAA,GAAS;AAEb,QAAM,EAAE,UAAU,MAAM,gBAAgB,QAAQ,GAAG,GAAG,KAAI,IAAK;AAE/D,QAAM,SAAS,UAAU,UAAU;AACnC,QAAM,gBAAgB,WAAW,EAAE,OAAM,CAAE;AAC3C,QAAM,UAAU,WAAW,WAAW;AAItC,gCAAU,MAAK;AACb,QAAI,CAAC;AAAS;AACd,QAAI,CAAC;AAAgB;AACrB,WAAOC,0BAAyB,QAAQ;MACtC,GAAI;MACJ;MACA;KACD;EACH,GAAG;IACD;IACA;IACA;IACA;;IAEA,KAAK;IACL,KAAK;IACL,KAAK;IACL,KAAK;IACL,KAAK;GACN;AACH;;;ACFM,SAAU,iBAId,aAA0D,CAAA,GAAE;AAE5D,QAAM,EAAE,SAAQ,IAAK;AAErB,QAAM,SAAS,UAAU,UAAU;AAEnC,QAAM,kBAAkB,6BAA6B,MAAM;AAC3D,QAAM,EAAE,QAAQ,aAAa,GAAG,OAAM,IAAK,YAAY;IACrD,GAAG;IACH,GAAG;GACJ;AAGD,SAAO;IACL,GAAG;IACH,eAAe;IACf,oBAAoB;;AAExB;",
|
|
6
|
-
"names": ["useEffect", "useSyncExternalStore", "useRef", "useEffect", "useMemo", "import_react", "secp256k1", "yParityOrV", "recoveryBit", "docsPath", "cause", "_a", "_a", "_a", "_b", "docsPath", "_a", "docsPath", "cause", "_a", "block", "request", "rpcStateOverride", "value", "estimate", "nonceManager", "getBlock", "getChainId", "chainId", "block", "_a", "e", "abi", "_a", "abi", "docsPath", "err", "abi", "custom", "res", "_a", "_a", "_a", "abi", "formatAbiItem", "abi", "event", "abi", "cacheKey", "docsPath", "abi", "formatAbiItem", "abi", "_a", "abiItem", "eventName", "index", "value", "input", "event", "abi", "version", "_a", "index", "_a", "_a", "_a", "abi", "result", "BaseError", "_a", "docsPath", "stringify", "value", "size", "size", "assertSize", "size", "SizeOverflowError", "SliceOffsetOutOfBoundsError", "pad", "SizeExceedsPaddingSizeError", "fromHex", "fromHex", "size", "assertSize", "index", "BaseError", "size", "padRight", "padRight", "size", "size", "BaseError", "BaseError", "size", "encoder", "concat", "assertSize", "size", "fromString", "encoder", "size", "pad", "size", "BaseError", "size", "BaseError", "stringify", "SizeOverflowError", "BaseError", "SliceOffsetOutOfBoundsError", "size", "SizeExceedsPaddingSizeError", "toRpc", "block", "toRpc", "call", "_a", "abi", "result", "error", "keccak256", "LruMap", "size", "LruMap", "assert", "InvalidAddressError", "checksum", "keccak256", "validate", "assert", "InvalidAddressError", "BaseError", "BaseError", "validate", "index", "from", "abi", "abiItem", "index", "keccak256", "fromString", "BaseError", "bytesRegex", "integerRegex", "checksumAddress", "size", "integerRegex", "concat", "checksum", "assert", "length", "BytesSizeMismatchError", "BaseError", "fromString", "index", "PositionOutOfBoundsError", "size", "BaseError", "PositionOutOfBoundsError", "encode", "checksumAddress", "concat", "encodePacked", "assert", "fromString", "integerRegex", "size", "bytesRegex", "BytesSizeMismatchError", "BaseError", "BytesSizeMismatchError", "size", "encode", "_a", "concat", "from", "fromAbi", "getSelector", "encode", "concat", "from", "fromAbi", "abi", "getSelector", "promiseCache", "shouldRetry", "_a", "uid", "_a", "body", "response", "getSocket", "reconnect", "_a", "error", "reconnect", "encodeData", "struct", "encode", "from", "call", "index", "listeners", "cleanup", "_a", "poll", "_a", "block", "transport", "_a", "transport", "_a", "transport", "event", "args", "_a", "_a", "from", "_a", "_a", "abi", "verifyHash", "_a", "verifyMessage", "verifyHash", "verifyTypedData", "verifyHash", "abi", "_a", "transport", "eventName", "args", "abi", "getAction", "call", "getAction", "version", "getVersion", "version", "BaseError", "getVersion", "_a", "docsPath", "_BaseError_walk", "BaseError", "_a", "size", "key", "uid", "fetch", "transport", "transports_", "sample", "wait", "body", "_a", "verifyHash", "verifyMessage", "verifyTypedData", "webSocket", "reconnect", "_a", "connector", "chainId", "chain", "deployContract", "getAction", "_a", "connections", "connector", "estimateGas", "getAction", "estimateFeesPerGas", "getAction", "estimateMaxPriorityFeePerGas", "getAction", "uid", "chain", "multicall", "getAction", "readContract", "getAction", "_a", "index", "contracts", "multicall", "readContract", "getBalance", "getAction", "getBlock", "getAction", "getBlockNumber", "getAction", "getBlockTransactionCount", "getAction", "getAction", "getChainId", "getEnsAddress", "getAction", "getEnsAvatar", "getAction", "getEnsName", "getAction", "getEnsResolver", "getAction", "getEnsText", "getAction", "getFeeHistory", "getAction", "getGasPrice", "getAction", "getProof", "getAction", "getStorageAt", "getAction", "abi", "getTransaction", "getAction", "getTransactionConfirmations", "getAction", "getTransactionCount", "getAction", "getTransactionReceipt", "getAction", "prepareTransactionRequest", "getAction", "_a", "connections", "sendTransaction", "getAction", "signMessage", "getAction", "signTypedData", "getAction", "simulateContract", "abi", "getAction", "_a", "BaseError", "switchChain", "_a", "chain", "verifyMessage", "getAction", "verifyTypedData", "getAction", "watchAsset", "getAction", "watchBlocks", "getAction", "watchBlockNumber", "getAction", "watchContractEvent", "getAction", "watchPendingTransactions", "getAction", "waitForTransactionReceipt", "getAction", "writeContract", "getAction", "window", "connect", "disconnect", "isReconnecting", "_a", "provider", "error", "call", "result", "error", "_a", "hydrate", "_a2", "createStore", "uid", "EventEmitter", "value", "index", "value", "deserialize", "serialize", "size", "index", "buffer", "uid", "createStore", "_a", "uid", "connect", "getClient", "client", "chainId", "parameters", "version", "x", "disconnect", "_a", "connector", "fallback", "_a", "version", "getVersion", "version", "BaseError", "getVersion", "BaseError", "import_react", "import_react", "import_react", "isPlainObject", "isPlainObject", "_a", "_a", "_cleanup", "_setup", "isPlainObject", "hasObjectPrototype", "structuralSharing", "call", "deployContract", "estimateFeesPerGas", "estimateGas", "estimateMaxPriorityFeePerGas", "getBalance", "getBlock", "getBlockNumber", "getBlockTransactionCount", "getEnsAddress", "getEnsAvatar", "getEnsName", "getEnsResolver", "getEnsText", "getFeeHistory", "getGasPrice", "getProof", "getStorageAt", "index", "getTransaction", "getTransactionConfirmations", "getTransactionCount", "getTransactionReceipt", "prepareTransactionRequest", "abi", "readContract", "_a", "abi", "sendTransaction", "signMessage", "signTypedData", "abi", "simulateContract", "switchChain", "verifyMessage", "verifyTypedData", "waitForTransactionReceipt", "watchAsset", "writeContract", "useQuery", "useInfiniteQuery", "import_react", "getChainId", "useQuery", "import_react", "watchBlocks", "useQuery", "import_react", "watchBlockNumber", "useQuery", "useQuery", "useQuery", "useQuery", "import_react", "import_with_selector", "import_react", "import_react", "import_react", "import_react", "useQuery", "useQuery", "useQuery", "useQuery", "useQuery", "useQuery", "useQuery", "useQuery", "useQuery", "useQuery", "useQuery", "useInfiniteQuery", "useQuery", "useQuery", "import_with_selector", "abi", "useQuery", "import_react", "abi", "useQuery", "abi", "useQuery", "useQuery", "useQuery", "useQuery", "useQuery", "useQuery", "useQuery", "useQuery", "useQuery", "import_react", "useQuery", "useQuery", "import_react", "watchContractEvent", "import_react", "watchPendingTransactions"]
|
|
7
|
-
}
|