@wagmi/core 2.0.0 → 2.0.2
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/README.md +13 -0
- package/actions/package.json +5 -0
- package/chains/package.json +5 -0
- package/dist/esm/actions/codegen/createReadContract.js +31 -0
- package/dist/esm/actions/codegen/createReadContract.js.map +1 -0
- package/dist/esm/actions/codegen/createSimulateContract.js +33 -0
- package/dist/esm/actions/codegen/createSimulateContract.js.map +1 -0
- package/dist/esm/actions/codegen/createWatchContractEvent.js +31 -0
- package/dist/esm/actions/codegen/createWatchContractEvent.js.map +1 -0
- package/dist/esm/actions/codegen/createWriteContract.js +43 -0
- package/dist/esm/actions/codegen/createWriteContract.js.map +1 -0
- package/dist/esm/actions/connect.js +15 -19
- package/dist/esm/actions/connect.js.map +1 -1
- package/dist/esm/actions/disconnect.js +10 -12
- package/dist/esm/actions/disconnect.js.map +1 -1
- package/dist/esm/actions/estimateFeesPerGas.js +3 -0
- package/dist/esm/actions/estimateFeesPerGas.js.map +1 -1
- package/dist/esm/actions/estimateGas.js +2 -2
- package/dist/esm/actions/estimateGas.js.map +1 -1
- package/dist/esm/actions/estimateMaxPriorityFeePerGas.js +12 -0
- package/dist/esm/actions/estimateMaxPriorityFeePerGas.js.map +1 -0
- package/dist/esm/actions/getAccount.js +6 -1
- package/dist/esm/actions/getAccount.js.map +1 -1
- package/dist/esm/actions/getBalance.js +14 -5
- package/dist/esm/actions/getBalance.js.map +1 -1
- package/dist/esm/actions/getBlock.js +15 -0
- package/dist/esm/actions/getBlock.js.map +1 -0
- package/dist/esm/actions/getBlockNumber.js +3 -1
- package/dist/esm/actions/getBlockNumber.js.map +1 -1
- package/dist/esm/actions/getBlockTransactionCount.js +11 -0
- package/dist/esm/actions/getBlockTransactionCount.js.map +1 -0
- package/dist/esm/actions/getChainId.js +2 -1
- package/dist/esm/actions/getChainId.js.map +1 -1
- package/dist/esm/actions/getClient.js +3 -0
- package/dist/esm/actions/getClient.js.map +1 -1
- package/dist/esm/actions/getConnections.js +2 -1
- package/dist/esm/actions/getConnections.js.map +1 -1
- package/dist/esm/actions/getConnectorClient.js +7 -3
- package/dist/esm/actions/getConnectorClient.js.map +1 -1
- package/dist/esm/actions/getConnectors.js +11 -0
- package/dist/esm/actions/getConnectors.js.map +1 -0
- package/dist/esm/actions/getEnsAddress.js +3 -1
- package/dist/esm/actions/getEnsAddress.js.map +1 -1
- package/dist/esm/actions/getEnsAvatar.js +3 -1
- package/dist/esm/actions/getEnsAvatar.js.map +1 -1
- package/dist/esm/actions/getEnsName.js +3 -1
- package/dist/esm/actions/getEnsName.js.map +1 -1
- package/dist/esm/actions/getEnsResolver.js +3 -1
- package/dist/esm/actions/getEnsResolver.js.map +1 -1
- package/dist/esm/actions/getFeeHistory.js +11 -0
- package/dist/esm/actions/getFeeHistory.js.map +1 -0
- package/dist/esm/actions/getGasPrice.js +11 -0
- package/dist/esm/actions/getGasPrice.js.map +1 -0
- package/dist/esm/actions/getPublicClient.js +3 -0
- package/dist/esm/actions/getPublicClient.js.map +1 -1
- package/dist/esm/actions/getToken.js +5 -0
- package/dist/esm/actions/getToken.js.map +1 -1
- package/dist/esm/actions/getTransaction.js +2 -1
- package/dist/esm/actions/getTransaction.js.map +1 -1
- package/dist/esm/actions/getTransactionCount.js +11 -0
- package/dist/esm/actions/getTransactionCount.js.map +1 -0
- package/dist/esm/actions/getWalletClient.js +4 -0
- package/dist/esm/actions/getWalletClient.js.map +1 -1
- package/dist/esm/actions/multicall.js +2 -0
- package/dist/esm/actions/multicall.js.map +1 -1
- package/dist/esm/actions/readContract.js +2 -1
- package/dist/esm/actions/readContract.js.map +1 -1
- package/dist/esm/actions/readContracts.js.map +1 -1
- package/dist/esm/actions/reconnect.js +13 -7
- package/dist/esm/actions/reconnect.js.map +1 -1
- package/dist/esm/actions/sendTransaction.js +5 -8
- package/dist/esm/actions/sendTransaction.js.map +1 -1
- package/dist/esm/actions/signMessage.js +4 -2
- package/dist/esm/actions/signMessage.js.map +1 -1
- package/dist/esm/actions/signTypedData.js +2 -2
- package/dist/esm/actions/signTypedData.js.map +1 -1
- package/dist/esm/actions/simulateContract.js +6 -7
- package/dist/esm/actions/simulateContract.js.map +1 -1
- package/dist/esm/actions/switchAccount.js +3 -2
- package/dist/esm/actions/switchAccount.js.map +1 -1
- package/dist/esm/actions/switchChain.js +5 -5
- package/dist/esm/actions/switchChain.js.map +1 -1
- package/dist/esm/actions/verifyMessage.js +11 -0
- package/dist/esm/actions/verifyMessage.js.map +1 -0
- package/dist/esm/actions/verifyTypedData.js +12 -0
- package/dist/esm/actions/verifyTypedData.js.map +1 -0
- package/dist/esm/actions/waitForTransactionReceipt.js +7 -1
- package/dist/esm/actions/waitForTransactionReceipt.js.map +1 -1
- package/dist/esm/actions/watchAccount.js +1 -1
- package/dist/esm/actions/watchAccount.js.map +1 -1
- package/dist/esm/actions/watchBlockNumber.js +2 -4
- package/dist/esm/actions/watchBlockNumber.js.map +1 -1
- package/dist/esm/actions/watchBlocks.js +26 -0
- package/dist/esm/actions/watchBlocks.js.map +1 -0
- package/dist/esm/actions/watchChainId.js +2 -1
- package/dist/esm/actions/watchChainId.js.map +1 -1
- package/dist/esm/actions/watchClient.js +2 -1
- package/dist/esm/actions/watchClient.js.map +1 -1
- package/dist/esm/actions/watchConnections.js +2 -1
- package/dist/esm/actions/watchConnections.js.map +1 -1
- package/dist/esm/actions/watchConnectors.js +10 -0
- package/dist/esm/actions/watchConnectors.js.map +1 -0
- package/dist/esm/actions/watchContractEvent.js +6 -4
- package/dist/esm/actions/watchContractEvent.js.map +1 -1
- package/dist/esm/actions/watchPendingTransactions.js +3 -4
- package/dist/esm/actions/watchPendingTransactions.js.map +1 -1
- package/dist/esm/actions/watchPublicClient.js +2 -1
- package/dist/esm/actions/watchPublicClient.js.map +1 -1
- package/dist/esm/actions/writeContract.js +9 -11
- package/dist/esm/actions/writeContract.js.map +1 -1
- package/dist/esm/connectors/createConnector.js +8 -0
- package/dist/esm/connectors/createConnector.js.map +1 -0
- package/dist/esm/connectors/injected.js +402 -0
- package/dist/esm/connectors/injected.js.map +1 -0
- package/dist/esm/connectors/mock.js +131 -0
- package/dist/esm/connectors/mock.js.map +1 -0
- package/dist/esm/createConfig.js +65 -23
- package/dist/esm/createConfig.js.map +1 -1
- package/dist/esm/createStorage.js +4 -2
- package/dist/esm/createStorage.js.map +1 -1
- package/dist/esm/errors/base.js +1 -1
- package/dist/esm/errors/base.js.map +1 -1
- package/dist/esm/errors/config.js +3 -15
- package/dist/esm/errors/config.js.map +1 -1
- package/dist/esm/errors/connector.js.map +1 -1
- package/dist/esm/exports/actions.js +43 -11
- package/dist/esm/exports/actions.js.map +1 -1
- package/dist/esm/exports/chains.js +1 -0
- package/dist/esm/exports/chains.js.map +1 -1
- package/dist/esm/exports/codegen.js +5 -0
- package/dist/esm/exports/codegen.js.map +1 -0
- package/dist/esm/exports/index.js +67 -18
- package/dist/esm/exports/index.js.map +1 -1
- package/dist/esm/exports/internal.js +5 -0
- package/dist/esm/exports/internal.js.map +1 -1
- package/dist/esm/exports/query.js +10 -0
- package/dist/esm/exports/query.js.map +1 -1
- package/dist/esm/hydrate.js +34 -0
- package/dist/esm/hydrate.js.map +1 -0
- package/dist/esm/query/disconnect.js +1 -0
- package/dist/esm/query/disconnect.js.map +1 -1
- package/dist/esm/query/estimateFeesPerGas.js +1 -0
- package/dist/esm/query/estimateFeesPerGas.js.map +1 -1
- package/dist/esm/query/estimateGas.js +1 -0
- package/dist/esm/query/estimateGas.js.map +1 -1
- package/dist/esm/query/estimateMaxPriorityFeePerGas.js +19 -0
- package/dist/esm/query/estimateMaxPriorityFeePerGas.js.map +1 -0
- package/dist/esm/query/getBalance.js +6 -4
- package/dist/esm/query/getBalance.js.map +1 -1
- package/dist/esm/query/getBlock.js +18 -0
- package/dist/esm/query/getBlock.js.map +1 -0
- package/dist/esm/query/getBlockNumber.js +1 -0
- package/dist/esm/query/getBlockNumber.js.map +1 -1
- package/dist/esm/query/getBlockTransactionCount.js +20 -0
- package/dist/esm/query/getBlockTransactionCount.js.map +1 -0
- package/dist/esm/query/getConnectorClient.js +2 -0
- package/dist/esm/query/getConnectorClient.js.map +1 -1
- package/dist/esm/query/getEnsAddress.js +1 -0
- package/dist/esm/query/getEnsAddress.js.map +1 -1
- package/dist/esm/query/getEnsAvatar.js +1 -0
- package/dist/esm/query/getEnsAvatar.js.map +1 -1
- package/dist/esm/query/getEnsName.js +1 -0
- package/dist/esm/query/getEnsName.js.map +1 -1
- package/dist/esm/query/getEnsResolver.js +1 -0
- package/dist/esm/query/getEnsResolver.js.map +1 -1
- package/dist/esm/query/getFeeHistory.js +27 -0
- package/dist/esm/query/getFeeHistory.js.map +1 -0
- package/dist/esm/query/getGasPrice.js +20 -0
- package/dist/esm/query/getGasPrice.js.map +1 -0
- package/dist/esm/query/getToken.js +1 -0
- package/dist/esm/query/getToken.js.map +1 -1
- package/dist/esm/query/getTransaction.js +4 -2
- package/dist/esm/query/getTransaction.js.map +1 -1
- package/dist/esm/query/getTransactionCount.js +23 -0
- package/dist/esm/query/getTransactionCount.js.map +1 -0
- package/dist/esm/query/getWalletClient.js +2 -0
- package/dist/esm/query/getWalletClient.js.map +1 -1
- package/dist/esm/query/infiniteReadContracts.js +25 -0
- package/dist/esm/query/infiniteReadContracts.js.map +1 -0
- package/dist/esm/query/readContract.js +7 -2
- package/dist/esm/query/readContract.js.map +1 -1
- package/dist/esm/query/readContracts.js +5 -3
- package/dist/esm/query/readContracts.js.map +1 -1
- package/dist/esm/query/reconnect.js +2 -0
- package/dist/esm/query/reconnect.js.map +1 -1
- package/dist/esm/query/sendTransaction.js +1 -0
- package/dist/esm/query/sendTransaction.js.map +1 -1
- package/dist/esm/query/signTypedData.js +1 -0
- package/dist/esm/query/signTypedData.js.map +1 -1
- package/dist/esm/query/simulateContract.js +6 -1
- package/dist/esm/query/simulateContract.js.map +1 -1
- package/dist/esm/query/switchAccount.js +3 -0
- package/dist/esm/query/switchAccount.js.map +1 -1
- package/dist/esm/query/switchChain.js +2 -0
- package/dist/esm/query/switchChain.js.map +1 -1
- package/dist/esm/query/types.js +2 -1
- package/dist/esm/query/types.js.map +1 -1
- package/dist/esm/query/utils.js +13 -0
- package/dist/esm/query/utils.js.map +1 -1
- package/dist/esm/query/verifyMessage.js +21 -0
- package/dist/esm/query/verifyMessage.js.map +1 -0
- package/dist/esm/query/verifyTypedData.js +38 -0
- package/dist/esm/query/verifyTypedData.js.map +1 -0
- package/dist/esm/query/waitForTransactionReceipt.js +3 -0
- package/dist/esm/query/waitForTransactionReceipt.js.map +1 -1
- package/dist/esm/query/writeContract.js +3 -0
- package/dist/esm/query/writeContract.js.map +1 -1
- package/dist/esm/transports/connector.js +37 -0
- package/dist/esm/transports/connector.js.map +1 -0
- package/dist/esm/transports/fallback.js +6 -0
- package/dist/esm/transports/fallback.js.map +1 -0
- package/dist/esm/tsconfig.build.tsbuildinfo +1 -1
- package/dist/esm/types/chain.js +3 -1
- package/dist/esm/types/chain.js.map +1 -1
- package/dist/esm/types/properties.js +1 -1
- package/dist/esm/types/properties.js.map +1 -1
- package/dist/esm/types/register.js +1 -1
- package/dist/esm/types/register.js.map +1 -1
- package/dist/esm/utils/cookie.js +37 -0
- package/dist/esm/utils/cookie.js.map +1 -0
- package/dist/esm/version.js +1 -1
- package/dist/types/actions/codegen/createReadContract.d.ts +16 -0
- package/dist/types/actions/codegen/createReadContract.d.ts.map +1 -0
- package/dist/types/actions/codegen/createSimulateContract.d.ts +20 -0
- package/dist/types/actions/codegen/createSimulateContract.d.ts.map +1 -0
- package/dist/types/actions/codegen/createWatchContractEvent.d.ts +14 -0
- package/dist/types/actions/codegen/createWatchContractEvent.d.ts.map +1 -0
- package/dist/types/actions/codegen/createWriteContract.d.ts +22 -0
- package/dist/types/actions/codegen/createWriteContract.d.ts.map +1 -0
- package/dist/types/actions/connect.d.ts +10 -11
- package/dist/types/actions/connect.d.ts.map +1 -1
- package/dist/types/actions/disconnect.d.ts +7 -6
- package/dist/types/actions/disconnect.d.ts.map +1 -1
- package/dist/types/actions/estimateFeesPerGas.d.ts +7 -5
- package/dist/types/actions/estimateFeesPerGas.d.ts.map +1 -1
- package/dist/types/actions/estimateGas.d.ts +7 -5
- package/dist/types/actions/estimateGas.d.ts.map +1 -1
- package/dist/types/actions/estimateMaxPriorityFeePerGas.d.ts +11 -0
- package/dist/types/actions/estimateMaxPriorityFeePerGas.d.ts.map +1 -0
- package/dist/types/actions/getAccount.d.ts +6 -2
- package/dist/types/actions/getAccount.d.ts.map +1 -1
- package/dist/types/actions/getBalance.d.ts +7 -5
- package/dist/types/actions/getBalance.d.ts.map +1 -1
- package/dist/types/actions/getBlock.d.ts +16 -0
- package/dist/types/actions/getBlock.d.ts.map +1 -0
- package/dist/types/actions/getBlockNumber.d.ts +7 -7
- package/dist/types/actions/getBlockNumber.d.ts.map +1 -1
- package/dist/types/actions/getBlockTransactionCount.d.ts +10 -0
- package/dist/types/actions/getBlockTransactionCount.d.ts.map +1 -0
- package/dist/types/actions/getChainId.d.ts +2 -2
- package/dist/types/actions/getChainId.d.ts.map +1 -1
- package/dist/types/actions/getClient.d.ts +3 -3
- package/dist/types/actions/getClient.d.ts.map +1 -1
- package/dist/types/actions/getConnections.d.ts +2 -2
- package/dist/types/actions/getConnections.d.ts.map +1 -1
- package/dist/types/actions/getConnectorClient.d.ts +6 -5
- package/dist/types/actions/getConnectorClient.d.ts.map +1 -1
- package/dist/types/actions/getConnectors.d.ts +5 -0
- package/dist/types/actions/getConnectors.d.ts.map +1 -0
- package/dist/types/actions/getEnsAddress.d.ts +5 -5
- package/dist/types/actions/getEnsAddress.d.ts.map +1 -1
- package/dist/types/actions/getEnsAvatar.d.ts +5 -5
- package/dist/types/actions/getEnsAvatar.d.ts.map +1 -1
- package/dist/types/actions/getEnsName.d.ts +5 -5
- package/dist/types/actions/getEnsName.d.ts.map +1 -1
- package/dist/types/actions/getEnsResolver.d.ts +5 -5
- package/dist/types/actions/getEnsResolver.d.ts.map +1 -1
- package/dist/types/actions/getFeeHistory.d.ts +10 -0
- package/dist/types/actions/getFeeHistory.d.ts.map +1 -0
- package/dist/types/actions/getGasPrice.d.ts +10 -0
- package/dist/types/actions/getGasPrice.d.ts.map +1 -0
- package/dist/types/actions/getPublicClient.d.ts +3 -3
- package/dist/types/actions/getPublicClient.d.ts.map +1 -1
- package/dist/types/actions/getToken.d.ts +10 -8
- package/dist/types/actions/getToken.d.ts.map +1 -1
- package/dist/types/actions/getTransaction.d.ts +8 -6
- package/dist/types/actions/getTransaction.d.ts.map +1 -1
- package/dist/types/actions/getTransactionCount.d.ts +10 -0
- package/dist/types/actions/getTransactionCount.d.ts.map +1 -0
- package/dist/types/actions/getWalletClient.d.ts +5 -4
- package/dist/types/actions/getWalletClient.d.ts.map +1 -1
- package/dist/types/actions/multicall.d.ts +5 -4
- package/dist/types/actions/multicall.d.ts.map +1 -1
- package/dist/types/actions/readContract.d.ts +4 -4
- package/dist/types/actions/readContract.d.ts.map +1 -1
- package/dist/types/actions/readContracts.d.ts +3 -1
- package/dist/types/actions/readContracts.d.ts.map +1 -1
- package/dist/types/actions/reconnect.d.ts +5 -4
- package/dist/types/actions/reconnect.d.ts.map +1 -1
- package/dist/types/actions/sendTransaction.d.ts +7 -5
- package/dist/types/actions/sendTransaction.d.ts.map +1 -1
- package/dist/types/actions/signMessage.d.ts +7 -5
- package/dist/types/actions/signMessage.d.ts.map +1 -1
- package/dist/types/actions/signTypedData.d.ts +7 -4
- package/dist/types/actions/signTypedData.d.ts.map +1 -1
- package/dist/types/actions/simulateContract.d.ts +15 -11
- package/dist/types/actions/simulateContract.d.ts.map +1 -1
- package/dist/types/actions/switchAccount.d.ts +5 -4
- package/dist/types/actions/switchAccount.d.ts.map +1 -1
- package/dist/types/actions/switchChain.d.ts +9 -8
- package/dist/types/actions/switchChain.d.ts.map +1 -1
- package/dist/types/actions/verifyMessage.d.ts +10 -0
- package/dist/types/actions/verifyMessage.d.ts.map +1 -0
- package/dist/types/actions/verifyTypedData.d.ts +11 -0
- package/dist/types/actions/verifyTypedData.d.ts.map +1 -0
- package/dist/types/actions/waitForTransactionReceipt.d.ts +9 -6
- package/dist/types/actions/waitForTransactionReceipt.d.ts.map +1 -1
- package/dist/types/actions/watchAccount.d.ts +1 -1
- package/dist/types/actions/watchAccount.d.ts.map +1 -1
- package/dist/types/actions/watchBlockNumber.d.ts +1 -1
- package/dist/types/actions/watchBlockNumber.d.ts.map +1 -1
- package/dist/types/actions/watchBlocks.d.ts +13 -0
- package/dist/types/actions/watchBlocks.d.ts.map +1 -0
- package/dist/types/actions/watchChainId.d.ts +2 -2
- package/dist/types/actions/watchChainId.d.ts.map +1 -1
- package/dist/types/actions/watchClient.d.ts +2 -2
- package/dist/types/actions/watchClient.d.ts.map +1 -1
- package/dist/types/actions/watchConnections.d.ts +2 -2
- package/dist/types/actions/watchConnections.d.ts.map +1 -1
- package/dist/types/actions/watchConnectors.d.ts +9 -0
- package/dist/types/actions/watchConnectors.d.ts.map +1 -0
- package/dist/types/actions/watchContractEvent.d.ts +5 -5
- package/dist/types/actions/watchContractEvent.d.ts.map +1 -1
- package/dist/types/actions/watchPendingTransactions.d.ts +2 -2
- package/dist/types/actions/watchPendingTransactions.d.ts.map +1 -1
- package/dist/types/actions/watchPublicClient.d.ts +2 -2
- package/dist/types/actions/watchPublicClient.d.ts.map +1 -1
- package/dist/types/actions/writeContract.d.ts +14 -10
- package/dist/types/actions/writeContract.d.ts.map +1 -1
- package/dist/types/{createConnector.d.ts → connectors/createConnector.d.ts} +7 -4
- package/dist/types/connectors/createConnector.d.ts.map +1 -0
- package/dist/types/connectors/injected.d.ts +356 -0
- package/dist/types/connectors/injected.d.ts.map +1 -0
- package/dist/types/connectors/mock.d.ts +20 -0
- package/dist/types/connectors/mock.d.ts.map +1 -0
- package/dist/types/createConfig.d.ts +30 -20
- package/dist/types/createConfig.d.ts.map +1 -1
- package/dist/types/createStorage.d.ts +4 -4
- package/dist/types/createStorage.d.ts.map +1 -1
- package/dist/types/errors/base.d.ts +13 -7
- package/dist/types/errors/base.d.ts.map +1 -1
- package/dist/types/errors/config.d.ts +17 -9
- package/dist/types/errors/config.d.ts.map +1 -1
- package/dist/types/errors/connector.d.ts +6 -0
- package/dist/types/errors/connector.d.ts.map +1 -1
- package/dist/types/exports/actions.d.ts +56 -25
- package/dist/types/exports/actions.d.ts.map +1 -1
- package/dist/types/exports/chains.d.ts.map +1 -1
- package/dist/types/exports/codegen.d.ts +5 -0
- package/dist/types/exports/codegen.d.ts.map +1 -0
- package/dist/types/exports/index.d.ts +67 -29
- package/dist/types/exports/index.d.ts.map +1 -1
- package/dist/types/exports/internal.d.ts +3 -1
- package/dist/types/exports/internal.d.ts.map +1 -1
- package/dist/types/exports/query.d.ts +9 -0
- package/dist/types/exports/query.d.ts.map +1 -1
- package/dist/types/hydrate.d.ts +10 -0
- package/dist/types/hydrate.d.ts.map +1 -0
- package/dist/types/query/connect.d.ts +4 -4
- package/dist/types/query/connect.d.ts.map +1 -1
- package/dist/types/query/disconnect.d.ts +4 -4
- package/dist/types/query/disconnect.d.ts.map +1 -1
- package/dist/types/query/estimateFeesPerGas.d.ts +2 -2
- package/dist/types/query/estimateFeesPerGas.d.ts.map +1 -1
- package/dist/types/query/estimateGas.d.ts +2 -2
- package/dist/types/query/estimateGas.d.ts.map +1 -1
- package/dist/types/query/estimateMaxPriorityFeePerGas.d.ts +27 -0
- package/dist/types/query/estimateMaxPriorityFeePerGas.d.ts.map +1 -0
- package/dist/types/query/getBalance.d.ts +2 -2
- package/dist/types/query/getBalance.d.ts.map +1 -1
- package/dist/types/query/getBlock.d.ts +19 -0
- package/dist/types/query/getBlock.d.ts.map +1 -0
- package/dist/types/query/getBlockNumber.d.ts +9 -12
- package/dist/types/query/getBlockNumber.d.ts.map +1 -1
- package/dist/types/query/getBlockTransactionCount.d.ts +18 -0
- package/dist/types/query/getBlockTransactionCount.d.ts.map +1 -0
- package/dist/types/query/getConnectorClient.d.ts +12 -3
- package/dist/types/query/getConnectorClient.d.ts.map +1 -1
- package/dist/types/query/getEnsAddress.d.ts +2 -2
- package/dist/types/query/getEnsAddress.d.ts.map +1 -1
- package/dist/types/query/getEnsAvatar.d.ts +2 -2
- package/dist/types/query/getEnsAvatar.d.ts.map +1 -1
- package/dist/types/query/getEnsName.d.ts +2 -2
- package/dist/types/query/getEnsName.d.ts.map +1 -1
- package/dist/types/query/getEnsResolver.d.ts +2 -2
- package/dist/types/query/getEnsResolver.d.ts.map +1 -1
- package/dist/types/query/getFeeHistory.d.ts +39 -0
- package/dist/types/query/getFeeHistory.d.ts.map +1 -0
- package/dist/types/query/getGasPrice.d.ts +27 -0
- package/dist/types/query/getGasPrice.d.ts.map +1 -0
- package/dist/types/query/getToken.d.ts +5 -5
- package/dist/types/query/getToken.d.ts.map +1 -1
- package/dist/types/query/getTransaction.d.ts +7 -95
- package/dist/types/query/getTransaction.d.ts.map +1 -1
- package/dist/types/query/getTransactionCount.d.ts +36 -0
- package/dist/types/query/getTransactionCount.d.ts.map +1 -0
- package/dist/types/query/getWalletClient.d.ts +27 -256
- package/dist/types/query/getWalletClient.d.ts.map +1 -1
- package/dist/types/query/infiniteReadContracts.d.ts +60 -0
- package/dist/types/query/infiniteReadContracts.d.ts.map +1 -0
- package/dist/types/query/readContract.d.ts +6 -6
- package/dist/types/query/readContract.d.ts.map +1 -1
- package/dist/types/query/readContracts.d.ts +15 -15
- package/dist/types/query/readContracts.d.ts.map +1 -1
- package/dist/types/query/reconnect.d.ts +5 -5
- package/dist/types/query/reconnect.d.ts.map +1 -1
- package/dist/types/query/sendTransaction.d.ts +4 -4
- package/dist/types/query/sendTransaction.d.ts.map +1 -1
- package/dist/types/query/signMessage.d.ts +3 -3
- package/dist/types/query/signMessage.d.ts.map +1 -1
- package/dist/types/query/signTypedData.d.ts +224 -211
- package/dist/types/query/signTypedData.d.ts.map +1 -1
- package/dist/types/query/simulateContract.d.ts +5 -5
- package/dist/types/query/simulateContract.d.ts.map +1 -1
- package/dist/types/query/switchAccount.d.ts +5 -5
- package/dist/types/query/switchAccount.d.ts.map +1 -1
- package/dist/types/query/switchChain.d.ts +6 -6
- package/dist/types/query/switchChain.d.ts.map +1 -1
- package/dist/types/query/types.d.ts +12 -5
- package/dist/types/query/types.d.ts.map +1 -1
- package/dist/types/query/utils.d.ts +1 -1
- package/dist/types/query/utils.d.ts.map +1 -1
- package/dist/types/query/verifyMessage.d.ts +42 -0
- package/dist/types/query/verifyMessage.d.ts.map +1 -0
- package/dist/types/query/verifyTypedData.d.ts +19 -0
- package/dist/types/query/verifyTypedData.d.ts.map +1 -0
- package/dist/types/query/waitForTransactionReceipt.d.ts +9 -97
- package/dist/types/query/waitForTransactionReceipt.d.ts.map +1 -1
- package/dist/types/query/writeContract.d.ts +12 -8
- package/dist/types/query/writeContract.d.ts.map +1 -1
- package/dist/types/transports/connector.d.ts +15 -0
- package/dist/types/transports/connector.d.ts.map +1 -0
- package/dist/types/transports/fallback.d.ts +4 -0
- package/dist/types/transports/fallback.d.ts.map +1 -0
- package/dist/types/types/chain.d.ts +3 -3
- package/dist/types/types/chain.d.ts.map +1 -1
- package/dist/types/types/properties.d.ts +4 -1
- package/dist/types/types/properties.d.ts.map +1 -1
- package/dist/types/types/register.d.ts +1 -1
- package/dist/types/types/register.d.ts.map +1 -1
- package/dist/types/types/utils.d.ts +9 -3
- package/dist/types/types/utils.d.ts.map +1 -1
- package/dist/types/utils/cookie.d.ts +9 -0
- package/dist/types/utils/cookie.d.ts.map +1 -0
- package/dist/types/version.d.ts +1 -1
- package/internal/package.json +5 -0
- package/package.json +25 -27
- package/query/package.json +5 -0
- package/src/actions/codegen/createReadContract.ts +100 -0
- package/src/actions/codegen/createSimulateContract.ts +122 -0
- package/src/actions/codegen/createWatchContractEvent.ts +87 -0
- package/src/actions/codegen/createWriteContract.ts +142 -0
- package/src/actions/connect.ts +32 -32
- package/src/actions/disconnect.ts +23 -20
- package/src/actions/estimateFeesPerGas.ts +7 -4
- package/src/actions/estimateGas.ts +16 -4
- package/src/actions/estimateMaxPriorityFeePerGas.ts +41 -0
- package/src/actions/getAccount.ts +11 -2
- package/src/actions/getBalance.ts +19 -8
- package/src/actions/getBlock.ts +71 -0
- package/src/actions/getBlockNumber.ts +14 -9
- package/src/actions/getBlockTransactionCount.ts +36 -0
- package/src/actions/getChainId.ts +2 -2
- package/src/actions/getClient.ts +3 -3
- package/src/actions/getConnections.ts +2 -2
- package/src/actions/getConnectorClient.ts +18 -9
- package/src/actions/getConnectors.ts +14 -0
- package/src/actions/getEnsAddress.ts +5 -4
- package/src/actions/getEnsAvatar.ts +5 -4
- package/src/actions/getEnsName.ts +5 -4
- package/src/actions/getEnsResolver.ts +5 -4
- package/src/actions/getFeeHistory.ts +32 -0
- package/src/actions/getGasPrice.ts +31 -0
- package/src/actions/getPublicClient.ts +3 -3
- package/src/actions/getToken.ts +10 -9
- package/src/actions/getTransaction.ts +8 -5
- package/src/actions/getTransactionCount.ts +31 -0
- package/src/actions/getWalletClient.ts +13 -4
- package/src/actions/multicall.ts +6 -3
- package/src/actions/readContract.ts +4 -3
- package/src/actions/readContracts.ts +4 -4
- package/src/actions/reconnect.ts +15 -10
- package/src/actions/sendTransaction.ts +20 -13
- package/src/actions/signMessage.ts +17 -5
- package/src/actions/signTypedData.ts +22 -5
- package/src/actions/simulateContract.ts +38 -31
- package/src/actions/switchAccount.ts +12 -4
- package/src/actions/switchChain.ts +27 -16
- package/src/actions/verifyMessage.ts +28 -0
- package/src/actions/verifyTypedData.ts +38 -0
- package/src/actions/waitForTransactionReceipt.ts +22 -16
- package/src/actions/watchAccount.ts +2 -1
- package/src/actions/watchBlockNumber.ts +4 -6
- package/src/actions/watchBlocks.ts +85 -0
- package/src/actions/watchChainId.ts +2 -2
- package/src/actions/watchClient.ts +2 -2
- package/src/actions/watchConnections.ts +2 -2
- package/src/actions/watchConnectors.ts +22 -0
- package/src/actions/watchContractEvent.ts +9 -10
- package/src/actions/watchPendingTransactions.ts +3 -5
- package/src/actions/watchPublicClient.ts +2 -2
- package/src/actions/writeContract.ts +52 -44
- package/src/{createConnector.ts → connectors/createConnector.ts} +12 -16
- package/src/connectors/injected.ts +556 -0
- package/src/connectors/mock.ts +176 -0
- package/src/createConfig.ts +153 -76
- package/src/createStorage.ts +7 -6
- package/src/errors/base.ts +9 -6
- package/src/errors/config.ts +20 -18
- package/src/errors/connector.ts +6 -0
- package/src/exports/actions.ts +121 -29
- package/src/exports/chains.ts +1 -0
- package/src/exports/codegen.ts +7 -0
- package/src/exports/index.ts +177 -47
- package/src/exports/internal.ts +12 -0
- package/src/exports/query.ts +82 -0
- package/src/hydrate.ts +42 -0
- package/src/query/connect.ts +4 -4
- package/src/query/disconnect.ts +5 -5
- package/src/query/estimateFeesPerGas.ts +4 -4
- package/src/query/estimateGas.ts +5 -5
- package/src/query/estimateMaxPriorityFeePerGas.ts +51 -0
- package/src/query/getBalance.ts +9 -17
- package/src/query/getBlock.ts +84 -0
- package/src/query/getBlockNumber.ts +22 -17
- package/src/query/getBlockTransactionCount.ts +62 -0
- package/src/query/getConnectorClient.ts +5 -4
- package/src/query/getEnsAddress.ts +4 -4
- package/src/query/getEnsAvatar.ts +4 -4
- package/src/query/getEnsName.ts +4 -4
- package/src/query/getEnsResolver.ts +4 -4
- package/src/query/getFeeHistory.ts +69 -0
- package/src/query/getGasPrice.ts +54 -0
- package/src/query/getToken.ts +4 -4
- package/src/query/getTransaction.ts +7 -13
- package/src/query/getTransactionCount.ts +55 -0
- package/src/query/getWalletClient.ts +5 -4
- package/src/query/infiniteReadContracts.ts +129 -0
- package/src/query/readContract.ts +14 -12
- package/src/query/readContracts.ts +16 -16
- package/src/query/reconnect.ts +6 -6
- package/src/query/sendTransaction.ts +5 -5
- package/src/query/signMessage.ts +4 -4
- package/src/query/signTypedData.ts +20 -8
- package/src/query/simulateContract.ts +12 -8
- package/src/query/switchAccount.ts +7 -7
- package/src/query/switchChain.ts +6 -6
- package/src/query/types.ts +63 -34
- package/src/query/utils.ts +16 -1
- package/src/query/verifyMessage.ts +54 -0
- package/src/query/verifyTypedData.ts +81 -0
- package/src/query/waitForTransactionReceipt.ts +6 -6
- package/src/query/writeContract.ts +39 -10
- package/src/transports/connector.ts +87 -0
- package/src/transports/fallback.ts +10 -0
- package/src/types/chain.ts +5 -4
- package/src/types/properties.ts +3 -1
- package/src/types/register.ts +1 -1
- package/src/types/utils.ts +10 -2
- package/src/utils/cookie.ts +34 -0
- package/src/version.ts +1 -1
- package/dist/esm/createConnector.js +0 -8
- package/dist/esm/createConnector.js.map +0 -1
- package/dist/esm/utils/assertActiveChain.js +0 -14
- package/dist/esm/utils/assertActiveChain.js.map +0 -1
- package/dist/types/createConnector.d.ts.map +0 -1
- package/dist/types/utils/assertActiveChain.d.ts +0 -8
- package/dist/types/utils/assertActiveChain.d.ts.map +0 -1
- package/src/utils/assertActiveChain.ts +0 -26
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import {
|
|
2
|
+
type Abi,
|
|
3
|
+
type Address,
|
|
4
|
+
type ContractFunctionArgs,
|
|
5
|
+
type ContractFunctionName,
|
|
6
|
+
} from 'viem'
|
|
7
|
+
|
|
8
|
+
import { type Config } from '../../createConfig.js'
|
|
9
|
+
import { type UnionEvaluate, type UnionOmit } from '../../types/utils.js'
|
|
10
|
+
import { getAccount } from '../getAccount.js'
|
|
11
|
+
import { getChainId } from '../getChainId.js'
|
|
12
|
+
import {
|
|
13
|
+
type ReadContractParameters,
|
|
14
|
+
type ReadContractReturnType,
|
|
15
|
+
readContract,
|
|
16
|
+
} from '../readContract.js'
|
|
17
|
+
|
|
18
|
+
type stateMutability = 'pure' | 'view'
|
|
19
|
+
|
|
20
|
+
export type CreateReadContractParameters<
|
|
21
|
+
abi extends Abi | readonly unknown[],
|
|
22
|
+
address extends Address | Record<number, Address> | undefined = undefined,
|
|
23
|
+
functionName extends
|
|
24
|
+
| ContractFunctionName<abi, stateMutability>
|
|
25
|
+
| undefined = undefined,
|
|
26
|
+
> = {
|
|
27
|
+
abi: abi | Abi | readonly unknown[]
|
|
28
|
+
address?: address | Address | Record<number, Address> | undefined
|
|
29
|
+
functionName?:
|
|
30
|
+
| functionName
|
|
31
|
+
| ContractFunctionName<abi, stateMutability>
|
|
32
|
+
| undefined
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export type CreateReadContractReturnType<
|
|
36
|
+
abi extends Abi | readonly unknown[],
|
|
37
|
+
address extends Address | Record<number, Address> | undefined,
|
|
38
|
+
functionName extends ContractFunctionName<abi, stateMutability> | undefined,
|
|
39
|
+
///
|
|
40
|
+
omittedProperties extends 'abi' | 'address' | 'chainId' | 'functionName' =
|
|
41
|
+
| 'abi'
|
|
42
|
+
| (address extends undefined ? never : 'address')
|
|
43
|
+
| (address extends Record<number, Address> ? 'chainId' : never)
|
|
44
|
+
| (functionName extends undefined ? never : 'functionName'),
|
|
45
|
+
> = <
|
|
46
|
+
config extends Config,
|
|
47
|
+
name extends functionName extends ContractFunctionName<abi, stateMutability>
|
|
48
|
+
? functionName
|
|
49
|
+
: ContractFunctionName<abi, stateMutability>,
|
|
50
|
+
args extends ContractFunctionArgs<abi, stateMutability, name>,
|
|
51
|
+
>(
|
|
52
|
+
config: config,
|
|
53
|
+
parameters: UnionEvaluate<
|
|
54
|
+
UnionOmit<
|
|
55
|
+
ReadContractParameters<abi, name, args, config>,
|
|
56
|
+
omittedProperties
|
|
57
|
+
>
|
|
58
|
+
> &
|
|
59
|
+
(address extends Record<number, Address>
|
|
60
|
+
? { chainId?: keyof address | undefined }
|
|
61
|
+
: unknown),
|
|
62
|
+
) => Promise<ReadContractReturnType<abi, name, args>>
|
|
63
|
+
|
|
64
|
+
export function createReadContract<
|
|
65
|
+
const abi extends Abi | readonly unknown[],
|
|
66
|
+
const address extends
|
|
67
|
+
| Address
|
|
68
|
+
| Record<number, Address>
|
|
69
|
+
| undefined = undefined,
|
|
70
|
+
functionName extends
|
|
71
|
+
| ContractFunctionName<abi, stateMutability>
|
|
72
|
+
| undefined = undefined,
|
|
73
|
+
>(
|
|
74
|
+
c: CreateReadContractParameters<abi, address, functionName>,
|
|
75
|
+
): CreateReadContractReturnType<abi, address, functionName> {
|
|
76
|
+
if (c.address !== undefined && typeof c.address === 'object')
|
|
77
|
+
return (config, parameters) => {
|
|
78
|
+
const configChainId = getChainId(config)
|
|
79
|
+
const account = getAccount(config)
|
|
80
|
+
const chainId =
|
|
81
|
+
(parameters as { chainId?: number })?.chainId ??
|
|
82
|
+
account.chainId ??
|
|
83
|
+
configChainId
|
|
84
|
+
return readContract(config, {
|
|
85
|
+
...(parameters as any),
|
|
86
|
+
...(c.functionName ? { functionName: c.functionName } : {}),
|
|
87
|
+
address: c.address?.[chainId],
|
|
88
|
+
abi: c.abi,
|
|
89
|
+
})
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
return (config, parameters) => {
|
|
93
|
+
return readContract(config, {
|
|
94
|
+
...(parameters as any),
|
|
95
|
+
...(c.address ? { address: c.address } : {}),
|
|
96
|
+
...(c.functionName ? { functionName: c.functionName } : {}),
|
|
97
|
+
abi: c.abi,
|
|
98
|
+
})
|
|
99
|
+
}
|
|
100
|
+
}
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import {
|
|
2
|
+
type Abi,
|
|
3
|
+
type Account,
|
|
4
|
+
type Address,
|
|
5
|
+
type Chain,
|
|
6
|
+
type ContractFunctionArgs,
|
|
7
|
+
type ContractFunctionName,
|
|
8
|
+
type SimulateContractParameters as viem_SimulateContractParameters,
|
|
9
|
+
} from 'viem'
|
|
10
|
+
|
|
11
|
+
import { type Config } from '../../createConfig.js'
|
|
12
|
+
import { type SelectChains } from '../../types/chain.js'
|
|
13
|
+
import {
|
|
14
|
+
type ChainIdParameter,
|
|
15
|
+
type ConnectorParameter,
|
|
16
|
+
} from '../../types/properties.js'
|
|
17
|
+
import { type UnionEvaluate, type UnionOmit } from '../../types/utils.js'
|
|
18
|
+
import { getAccount } from '../getAccount.js'
|
|
19
|
+
import { getChainId } from '../getChainId.js'
|
|
20
|
+
import {
|
|
21
|
+
type SimulateContractReturnType,
|
|
22
|
+
simulateContract,
|
|
23
|
+
} from '../simulateContract.js'
|
|
24
|
+
|
|
25
|
+
type stateMutability = 'nonpayable' | 'payable'
|
|
26
|
+
|
|
27
|
+
export type CreateSimulateContractParameters<
|
|
28
|
+
abi extends Abi | readonly unknown[],
|
|
29
|
+
address extends Address | Record<number, Address> | undefined = undefined,
|
|
30
|
+
functionName extends
|
|
31
|
+
| ContractFunctionName<abi, stateMutability>
|
|
32
|
+
| undefined = undefined,
|
|
33
|
+
> = {
|
|
34
|
+
abi: abi | Abi | readonly unknown[]
|
|
35
|
+
address?: address | Address | Record<number, Address> | undefined
|
|
36
|
+
functionName?:
|
|
37
|
+
| functionName
|
|
38
|
+
| ContractFunctionName<abi, stateMutability>
|
|
39
|
+
| undefined
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export type CreateSimulateContractReturnType<
|
|
43
|
+
abi extends Abi | readonly unknown[],
|
|
44
|
+
address extends Address | Record<number, Address> | undefined,
|
|
45
|
+
functionName extends ContractFunctionName<abi, stateMutability> | undefined,
|
|
46
|
+
> = <
|
|
47
|
+
config extends Config,
|
|
48
|
+
name extends functionName extends ContractFunctionName<abi, stateMutability>
|
|
49
|
+
? functionName
|
|
50
|
+
: ContractFunctionName<abi, stateMutability>,
|
|
51
|
+
args extends ContractFunctionArgs<abi, stateMutability, name>,
|
|
52
|
+
chainId extends config['chains'][number]['id'] | undefined = undefined,
|
|
53
|
+
///
|
|
54
|
+
chains extends readonly Chain[] = SelectChains<config, chainId>,
|
|
55
|
+
>(
|
|
56
|
+
config: config,
|
|
57
|
+
parameters: {
|
|
58
|
+
[key in keyof chains]: UnionEvaluate<
|
|
59
|
+
UnionOmit<
|
|
60
|
+
viem_SimulateContractParameters<
|
|
61
|
+
abi,
|
|
62
|
+
name,
|
|
63
|
+
args,
|
|
64
|
+
chains[key],
|
|
65
|
+
chains[key],
|
|
66
|
+
Account | Address
|
|
67
|
+
>,
|
|
68
|
+
| 'abi'
|
|
69
|
+
| 'chain'
|
|
70
|
+
| (address extends undefined ? never : 'address')
|
|
71
|
+
| (functionName extends undefined ? never : 'functionName')
|
|
72
|
+
>
|
|
73
|
+
> &
|
|
74
|
+
ChainIdParameter<config, chainId> &
|
|
75
|
+
ConnectorParameter & {
|
|
76
|
+
chainId?: address extends Record<number, Address>
|
|
77
|
+
?
|
|
78
|
+
| keyof address
|
|
79
|
+
| (chainId extends keyof address ? chainId : never)
|
|
80
|
+
| undefined
|
|
81
|
+
: chainId | number | undefined
|
|
82
|
+
}
|
|
83
|
+
}[number],
|
|
84
|
+
) => Promise<SimulateContractReturnType<abi, name, args, config, chainId>>
|
|
85
|
+
|
|
86
|
+
export function createSimulateContract<
|
|
87
|
+
const abi extends Abi | readonly unknown[],
|
|
88
|
+
const address extends
|
|
89
|
+
| Address
|
|
90
|
+
| Record<number, Address>
|
|
91
|
+
| undefined = undefined,
|
|
92
|
+
functionName extends
|
|
93
|
+
| ContractFunctionName<abi, stateMutability>
|
|
94
|
+
| undefined = undefined,
|
|
95
|
+
>(
|
|
96
|
+
c: CreateSimulateContractParameters<abi, address, functionName>,
|
|
97
|
+
): CreateSimulateContractReturnType<abi, address, functionName> {
|
|
98
|
+
if (c.address !== undefined && typeof c.address === 'object')
|
|
99
|
+
return (config, parameters) => {
|
|
100
|
+
const configChainId = getChainId(config)
|
|
101
|
+
const account = getAccount(config)
|
|
102
|
+
const chainId =
|
|
103
|
+
(parameters as { chainId?: number })?.chainId ??
|
|
104
|
+
account.chainId ??
|
|
105
|
+
configChainId
|
|
106
|
+
return simulateContract(config, {
|
|
107
|
+
...(parameters as any),
|
|
108
|
+
...(c.functionName ? { functionName: c.functionName } : {}),
|
|
109
|
+
address: c.address?.[chainId],
|
|
110
|
+
abi: c.abi,
|
|
111
|
+
})
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
return (config, parameters) => {
|
|
115
|
+
return simulateContract(config, {
|
|
116
|
+
...(parameters as any),
|
|
117
|
+
...(c.address ? { address: c.address } : {}),
|
|
118
|
+
...(c.functionName ? { functionName: c.functionName } : {}),
|
|
119
|
+
abi: c.abi,
|
|
120
|
+
})
|
|
121
|
+
}
|
|
122
|
+
}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { type Abi, type Address, type ContractEventName } from 'viem'
|
|
2
|
+
|
|
3
|
+
import { type Config } from '../../createConfig.js'
|
|
4
|
+
import { type UnionEvaluate, type UnionOmit } from '../../types/utils.js'
|
|
5
|
+
import { getAccount } from '../getAccount.js'
|
|
6
|
+
import { getChainId } from '../getChainId.js'
|
|
7
|
+
import {
|
|
8
|
+
type WatchContractEventParameters,
|
|
9
|
+
type WatchContractEventReturnType,
|
|
10
|
+
watchContractEvent,
|
|
11
|
+
} from '../watchContractEvent.js'
|
|
12
|
+
|
|
13
|
+
export type CreateWatchContractEventParameters<
|
|
14
|
+
abi extends Abi | readonly unknown[],
|
|
15
|
+
address extends Address | Record<number, Address> | undefined = undefined,
|
|
16
|
+
eventName extends ContractEventName<abi> | undefined = undefined,
|
|
17
|
+
> = {
|
|
18
|
+
abi: abi | Abi | readonly unknown[]
|
|
19
|
+
address?: address | Address | Record<number, Address> | undefined
|
|
20
|
+
eventName?: eventName | ContractEventName<abi> | undefined
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export type CreateWatchContractEventReturnType<
|
|
24
|
+
abi extends Abi | readonly unknown[],
|
|
25
|
+
address extends Address | Record<number, Address> | undefined,
|
|
26
|
+
eventName extends ContractEventName<abi> | undefined,
|
|
27
|
+
///
|
|
28
|
+
omittedProperties extends 'abi' | 'address' | 'chainId' | 'eventName' =
|
|
29
|
+
| 'abi'
|
|
30
|
+
| (address extends undefined ? never : 'address')
|
|
31
|
+
| (address extends Record<number, Address> ? 'chainId' : never)
|
|
32
|
+
| (eventName extends undefined ? never : 'eventName'),
|
|
33
|
+
> = <
|
|
34
|
+
config extends Config,
|
|
35
|
+
name extends eventName extends ContractEventName<abi>
|
|
36
|
+
? eventName
|
|
37
|
+
: ContractEventName<abi>,
|
|
38
|
+
strict extends boolean | undefined = undefined,
|
|
39
|
+
chainId extends config['chains'][number]['id'] = config['chains'][number]['id'],
|
|
40
|
+
>(
|
|
41
|
+
config: config,
|
|
42
|
+
parameters: UnionEvaluate<
|
|
43
|
+
UnionOmit<
|
|
44
|
+
WatchContractEventParameters<abi, name, strict, config, chainId>,
|
|
45
|
+
omittedProperties
|
|
46
|
+
>
|
|
47
|
+
> &
|
|
48
|
+
(address extends Record<number, Address>
|
|
49
|
+
? { chainId?: keyof address | undefined }
|
|
50
|
+
: unknown),
|
|
51
|
+
) => WatchContractEventReturnType
|
|
52
|
+
|
|
53
|
+
export function createWatchContractEvent<
|
|
54
|
+
const abi extends Abi | readonly unknown[],
|
|
55
|
+
const address extends
|
|
56
|
+
| Address
|
|
57
|
+
| Record<number, Address>
|
|
58
|
+
| undefined = undefined,
|
|
59
|
+
eventName extends ContractEventName<abi> | undefined = undefined,
|
|
60
|
+
>(
|
|
61
|
+
c: CreateWatchContractEventParameters<abi, address, eventName>,
|
|
62
|
+
): CreateWatchContractEventReturnType<abi, address, eventName> {
|
|
63
|
+
if (c.address !== undefined && typeof c.address === 'object')
|
|
64
|
+
return (config, parameters) => {
|
|
65
|
+
const configChainId = getChainId(config)
|
|
66
|
+
const account = getAccount(config)
|
|
67
|
+
const chainId =
|
|
68
|
+
(parameters as { chainId?: number })?.chainId ??
|
|
69
|
+
account.chainId ??
|
|
70
|
+
configChainId
|
|
71
|
+
return watchContractEvent(config, {
|
|
72
|
+
...(parameters as any),
|
|
73
|
+
...(c.eventName ? { functionName: c.eventName } : {}),
|
|
74
|
+
address: c.address?.[chainId],
|
|
75
|
+
abi: c.abi,
|
|
76
|
+
})
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
return (config, parameters) => {
|
|
80
|
+
return watchContractEvent(config, {
|
|
81
|
+
...(parameters as any),
|
|
82
|
+
...(c.address ? { address: c.address } : {}),
|
|
83
|
+
...(c.eventName ? { functionName: c.eventName } : {}),
|
|
84
|
+
abi: c.abi,
|
|
85
|
+
})
|
|
86
|
+
}
|
|
87
|
+
}
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
import {
|
|
2
|
+
type Abi,
|
|
3
|
+
type Account,
|
|
4
|
+
type Address,
|
|
5
|
+
type Chain,
|
|
6
|
+
type ContractFunctionArgs,
|
|
7
|
+
type ContractFunctionName,
|
|
8
|
+
type WriteContractParameters as viem_WriteContractParameters,
|
|
9
|
+
} from 'viem'
|
|
10
|
+
|
|
11
|
+
import { type Config } from '../../createConfig.js'
|
|
12
|
+
import { type SelectChains } from '../../types/chain.js'
|
|
13
|
+
import {
|
|
14
|
+
type ChainIdParameter,
|
|
15
|
+
type ConnectorParameter,
|
|
16
|
+
} from '../../types/properties.js'
|
|
17
|
+
import {
|
|
18
|
+
type Evaluate,
|
|
19
|
+
type UnionEvaluate,
|
|
20
|
+
type UnionOmit,
|
|
21
|
+
} from '../../types/utils.js'
|
|
22
|
+
import { getAccount } from '../getAccount.js'
|
|
23
|
+
import { getChainId } from '../getChainId.js'
|
|
24
|
+
import {
|
|
25
|
+
type WriteContractReturnType,
|
|
26
|
+
writeContract,
|
|
27
|
+
} from '../writeContract.js'
|
|
28
|
+
|
|
29
|
+
type stateMutability = 'nonpayable' | 'payable'
|
|
30
|
+
|
|
31
|
+
export type CreateWriteContractParameters<
|
|
32
|
+
abi extends Abi | readonly unknown[],
|
|
33
|
+
address extends Address | Record<number, Address> | undefined = undefined,
|
|
34
|
+
functionName extends
|
|
35
|
+
| ContractFunctionName<abi, stateMutability>
|
|
36
|
+
| undefined = undefined,
|
|
37
|
+
> = {
|
|
38
|
+
abi: abi | Abi | readonly unknown[]
|
|
39
|
+
address?: address | Address | Record<number, Address> | undefined
|
|
40
|
+
functionName?:
|
|
41
|
+
| functionName
|
|
42
|
+
| ContractFunctionName<abi, stateMutability>
|
|
43
|
+
| undefined
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export type CreateWriteContractReturnType<
|
|
47
|
+
abi extends Abi | readonly unknown[],
|
|
48
|
+
address extends Address | Record<number, Address> | undefined,
|
|
49
|
+
functionName extends ContractFunctionName<abi, stateMutability> | undefined,
|
|
50
|
+
> = <
|
|
51
|
+
config extends Config,
|
|
52
|
+
name extends functionName extends ContractFunctionName<abi, stateMutability>
|
|
53
|
+
? functionName
|
|
54
|
+
: ContractFunctionName<abi, stateMutability>,
|
|
55
|
+
args extends ContractFunctionArgs<abi, stateMutability, name>,
|
|
56
|
+
chainId extends config['chains'][number]['id'],
|
|
57
|
+
///
|
|
58
|
+
allFunctionNames = ContractFunctionName<abi, 'nonpayable' | 'payable'>,
|
|
59
|
+
chains extends readonly Chain[] = SelectChains<config, chainId>,
|
|
60
|
+
omittedProperties extends 'abi' | 'address' | 'functionName' =
|
|
61
|
+
| 'abi'
|
|
62
|
+
| (address extends undefined ? never : 'address')
|
|
63
|
+
| (functionName extends undefined ? never : 'functionName'),
|
|
64
|
+
>(
|
|
65
|
+
config: config,
|
|
66
|
+
parameters: UnionEvaluate<
|
|
67
|
+
{
|
|
68
|
+
[key in keyof chains]: UnionOmit<
|
|
69
|
+
viem_WriteContractParameters<
|
|
70
|
+
abi,
|
|
71
|
+
name,
|
|
72
|
+
args,
|
|
73
|
+
chains[key],
|
|
74
|
+
Account,
|
|
75
|
+
chains[key],
|
|
76
|
+
allFunctionNames
|
|
77
|
+
>,
|
|
78
|
+
omittedProperties | 'chain'
|
|
79
|
+
>
|
|
80
|
+
}[number] &
|
|
81
|
+
(address extends Record<number, Address>
|
|
82
|
+
? {
|
|
83
|
+
chainId?:
|
|
84
|
+
| keyof address
|
|
85
|
+
| (chainId extends keyof address ? chainId : never)
|
|
86
|
+
| undefined
|
|
87
|
+
}
|
|
88
|
+
: Evaluate<ChainIdParameter<config, chainId>>) &
|
|
89
|
+
ConnectorParameter & { __mode?: 'prepared' }
|
|
90
|
+
>,
|
|
91
|
+
) => Promise<WriteContractReturnType>
|
|
92
|
+
|
|
93
|
+
export function createWriteContract<
|
|
94
|
+
const abi extends Abi | readonly unknown[],
|
|
95
|
+
const address extends
|
|
96
|
+
| Address
|
|
97
|
+
| Record<number, Address>
|
|
98
|
+
| undefined = undefined,
|
|
99
|
+
functionName extends
|
|
100
|
+
| ContractFunctionName<abi, stateMutability>
|
|
101
|
+
| undefined = undefined,
|
|
102
|
+
>(
|
|
103
|
+
c: CreateWriteContractParameters<abi, address, functionName>,
|
|
104
|
+
): CreateWriteContractReturnType<abi, address, functionName> {
|
|
105
|
+
if (c.address !== undefined && typeof c.address === 'object')
|
|
106
|
+
return (config, parameters) => {
|
|
107
|
+
const configChainId = getChainId(config)
|
|
108
|
+
const account = getAccount(config)
|
|
109
|
+
|
|
110
|
+
let chainId
|
|
111
|
+
if (parameters.chainId) chainId = parameters.chainId
|
|
112
|
+
else if (
|
|
113
|
+
(parameters as unknown as { account: Address | Account | undefined })
|
|
114
|
+
.account &&
|
|
115
|
+
(parameters as unknown as { account: Address | Account | undefined })
|
|
116
|
+
.account === account.address
|
|
117
|
+
)
|
|
118
|
+
chainId = account.chainId
|
|
119
|
+
else if (
|
|
120
|
+
(parameters as unknown as { account: Address | Account | undefined })
|
|
121
|
+
.account === undefined
|
|
122
|
+
)
|
|
123
|
+
chainId = account.chainId
|
|
124
|
+
else chainId = configChainId
|
|
125
|
+
|
|
126
|
+
return writeContract(config, {
|
|
127
|
+
...(parameters as any),
|
|
128
|
+
...(c.functionName ? { functionName: c.functionName } : {}),
|
|
129
|
+
address: chainId ? c.address?.[chainId] : undefined,
|
|
130
|
+
abi: c.abi,
|
|
131
|
+
})
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
return (config, parameters) => {
|
|
135
|
+
return writeContract(config, {
|
|
136
|
+
...(parameters as any),
|
|
137
|
+
...(c.address ? { address: c.address } : {}),
|
|
138
|
+
...(c.functionName ? { functionName: c.functionName } : {}),
|
|
139
|
+
abi: c.abi,
|
|
140
|
+
})
|
|
141
|
+
}
|
|
142
|
+
}
|
package/src/actions/connect.ts
CHANGED
|
@@ -1,17 +1,23 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import {
|
|
2
|
+
type Address,
|
|
3
|
+
type ResourceUnavailableRpcErrorType,
|
|
4
|
+
type UserRejectedRequestErrorType,
|
|
5
|
+
} from 'viem'
|
|
3
6
|
|
|
7
|
+
import { type CreateConnectorFn } from '../connectors/createConnector.js'
|
|
4
8
|
import { type Config, type Connector } from '../createConfig.js'
|
|
5
|
-
import {
|
|
6
|
-
import
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
9
|
+
import type { BaseErrorType, ErrorType } from '../errors/base.js'
|
|
10
|
+
import {
|
|
11
|
+
ConnectorAlreadyConnectedError,
|
|
12
|
+
type ConnectorAlreadyConnectedErrorType,
|
|
13
|
+
} from '../errors/config.js'
|
|
14
|
+
import { type ChainIdParameter } from '../types/properties.js'
|
|
15
|
+
import { type Evaluate } from '../types/utils.js'
|
|
10
16
|
|
|
11
17
|
export type ConnectParameters<config extends Config = Config> = Evaluate<
|
|
12
|
-
{
|
|
18
|
+
ChainIdParameter<config> & {
|
|
13
19
|
connector: Connector | CreateConnectorFn
|
|
14
|
-
}
|
|
20
|
+
}
|
|
15
21
|
>
|
|
16
22
|
|
|
17
23
|
export type ConnectReturnType<config extends Config = Config> = {
|
|
@@ -21,17 +27,16 @@ export type ConnectReturnType<config extends Config = Config> = {
|
|
|
21
27
|
| (number extends config['chains'][number]['id'] ? number : number & {})
|
|
22
28
|
}
|
|
23
29
|
|
|
24
|
-
export type
|
|
25
|
-
|
|
26
|
-
| ConnectorAlreadyConnectedError
|
|
30
|
+
export type ConnectErrorType =
|
|
31
|
+
| ConnectorAlreadyConnectedErrorType
|
|
27
32
|
// connector.connect()
|
|
28
|
-
|
|
|
29
|
-
|
|
|
33
|
+
| UserRejectedRequestErrorType
|
|
34
|
+
| ResourceUnavailableRpcErrorType
|
|
30
35
|
// base
|
|
31
|
-
|
|
|
32
|
-
|
|
|
36
|
+
| BaseErrorType
|
|
37
|
+
| ErrorType
|
|
33
38
|
|
|
34
|
-
/** https://
|
|
39
|
+
/** https://wagmi.sh/core/api/actions/connect */
|
|
35
40
|
export async function connect<config extends Config>(
|
|
36
41
|
config: config,
|
|
37
42
|
parameters: ConnectParameters<config>,
|
|
@@ -39,7 +44,7 @@ export async function connect<config extends Config>(
|
|
|
39
44
|
// "Register" connector if not already created
|
|
40
45
|
let connector: Connector
|
|
41
46
|
if (typeof parameters.connector === 'function') {
|
|
42
|
-
connector = config._internal.setup(parameters.connector)
|
|
47
|
+
connector = config._internal.connectors.setup(parameters.connector)
|
|
43
48
|
} else connector = parameters.connector
|
|
44
49
|
|
|
45
50
|
// Check if connector is already connected
|
|
@@ -53,9 +58,9 @@ export async function connect<config extends Config>(
|
|
|
53
58
|
const data = await connector.connect({ chainId: parameters.chainId })
|
|
54
59
|
const accounts = data.accounts as readonly [Address, ...Address[]]
|
|
55
60
|
|
|
56
|
-
connector.emitter.off('connect', config._internal.connect)
|
|
57
|
-
connector.emitter.on('change', config._internal.change)
|
|
58
|
-
connector.emitter.on('disconnect', config._internal.disconnect)
|
|
61
|
+
connector.emitter.off('connect', config._internal.events.connect)
|
|
62
|
+
connector.emitter.on('change', config._internal.events.change)
|
|
63
|
+
connector.emitter.on('disconnect', config._internal.events.disconnect)
|
|
59
64
|
|
|
60
65
|
await config.storage?.setItem('recentConnectorId', connector.id)
|
|
61
66
|
config.setState((x) => ({
|
|
@@ -69,18 +74,13 @@ export async function connect<config extends Config>(
|
|
|
69
74
|
status: 'connected',
|
|
70
75
|
}))
|
|
71
76
|
|
|
72
|
-
return {
|
|
73
|
-
accounts,
|
|
74
|
-
chainId: data.chainId,
|
|
75
|
-
}
|
|
77
|
+
return { accounts, chainId: data.chainId }
|
|
76
78
|
} catch (error) {
|
|
77
|
-
config.setState((x) => {
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
}
|
|
83
|
-
})
|
|
79
|
+
config.setState((x) => ({
|
|
80
|
+
...x,
|
|
81
|
+
// Keep existing connector connected in case of error
|
|
82
|
+
status: x.current ? 'connected' : 'disconnected',
|
|
83
|
+
}))
|
|
84
84
|
throw error
|
|
85
85
|
}
|
|
86
86
|
}
|
|
@@ -1,22 +1,23 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
import {
|
|
7
|
-
ConnectorNotConnectedError,
|
|
8
|
-
ConnectorNotFoundError,
|
|
1
|
+
import type { Config, Connection, Connector } from '../createConfig.js'
|
|
2
|
+
import type { BaseErrorType, ErrorType } from '../errors/base.js'
|
|
3
|
+
import type {
|
|
4
|
+
ConnectorNotConnectedErrorType,
|
|
5
|
+
ConnectorNotFoundErrorType,
|
|
9
6
|
} from '../errors/config.js'
|
|
7
|
+
import type { ConnectorParameter } from '../types/properties.js'
|
|
10
8
|
|
|
11
|
-
export type DisconnectParameters =
|
|
12
|
-
connector?: Connector | undefined
|
|
13
|
-
}
|
|
9
|
+
export type DisconnectParameters = ConnectorParameter
|
|
14
10
|
|
|
15
11
|
export type DisconnectReturnType = void
|
|
16
12
|
|
|
17
|
-
export type
|
|
13
|
+
export type DisconnectErrorType =
|
|
14
|
+
| ConnectorNotFoundErrorType
|
|
15
|
+
| ConnectorNotConnectedErrorType
|
|
16
|
+
// base
|
|
17
|
+
| BaseErrorType
|
|
18
|
+
| ErrorType
|
|
18
19
|
|
|
19
|
-
/** https://
|
|
20
|
+
/** https://wagmi.sh/core/api/actions/disconnect */
|
|
20
21
|
export async function disconnect(
|
|
21
22
|
config: Config,
|
|
22
23
|
parameters: DisconnectParameters = {},
|
|
@@ -29,18 +30,19 @@ export async function disconnect(
|
|
|
29
30
|
connector = connection?.connector
|
|
30
31
|
}
|
|
31
32
|
|
|
32
|
-
if (!connector) throw new ConnectorNotFoundError()
|
|
33
33
|
const connections = config.state.connections
|
|
34
|
-
if (!connections.has(connector.uid)) throw new ConnectorNotConnectedError()
|
|
35
34
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
35
|
+
if (connector) {
|
|
36
|
+
await connector.disconnect()
|
|
37
|
+
connector.emitter.off('change', config._internal.events.change)
|
|
38
|
+
connector.emitter.off('disconnect', config._internal.events.disconnect)
|
|
39
|
+
connector.emitter.on('connect', config._internal.events.connect)
|
|
40
40
|
|
|
41
|
-
|
|
41
|
+
connections.delete(connector.uid)
|
|
42
|
+
}
|
|
42
43
|
|
|
43
44
|
config.setState((x) => {
|
|
45
|
+
// if no connections exist, move to disconnected state
|
|
44
46
|
if (connections.size === 0)
|
|
45
47
|
return {
|
|
46
48
|
...x,
|
|
@@ -49,6 +51,7 @@ export async function disconnect(
|
|
|
49
51
|
status: 'disconnected',
|
|
50
52
|
}
|
|
51
53
|
|
|
54
|
+
// switch over to another connection
|
|
52
55
|
const nextConnection = connections.values().next().value as Connection
|
|
53
56
|
return {
|
|
54
57
|
...x,
|
|
@@ -6,15 +6,16 @@ import {
|
|
|
6
6
|
formatUnits,
|
|
7
7
|
} from 'viem'
|
|
8
8
|
import {
|
|
9
|
+
type EstimateFeesPerGasErrorType as viem_EstimateFeesPerGasErrorType,
|
|
9
10
|
type EstimateFeesPerGasParameters as viem_EstimateFeesPerGasParameters,
|
|
10
11
|
type EstimateFeesPerGasReturnType as viem_EstimateFeesPerGasReturnType,
|
|
11
12
|
estimateFeesPerGas as viem_estimateFeesPerGas,
|
|
12
13
|
} from 'viem/actions'
|
|
13
14
|
|
|
14
15
|
import { type Config } from '../createConfig.js'
|
|
15
|
-
import type
|
|
16
|
-
import type
|
|
17
|
-
import type
|
|
16
|
+
import { type ChainIdParameter } from '../types/properties.js'
|
|
17
|
+
import { type Unit } from '../types/unit.js'
|
|
18
|
+
import { type Evaluate } from '../types/utils.js'
|
|
18
19
|
import type { UnionEvaluate, UnionLooseOmit } from '../types/utils.js'
|
|
19
20
|
import { getUnit } from '../utils/getUnit.js'
|
|
20
21
|
|
|
@@ -27,6 +28,7 @@ export type EstimateFeesPerGasParameters<
|
|
|
27
28
|
'chain'
|
|
28
29
|
> &
|
|
29
30
|
ChainIdParameter<config> & {
|
|
31
|
+
/** @deprecated */
|
|
30
32
|
formatUnits?: Unit | undefined
|
|
31
33
|
}
|
|
32
34
|
>
|
|
@@ -35,6 +37,7 @@ export type EstimateFeesPerGasReturnType<
|
|
|
35
37
|
type extends FeeValuesType = FeeValuesType,
|
|
36
38
|
> = Evaluate<
|
|
37
39
|
viem_EstimateFeesPerGasReturnType<type> & {
|
|
40
|
+
/** @deprecated */
|
|
38
41
|
formatted: UnionEvaluate<
|
|
39
42
|
| (type extends 'legacy' ? FeeValuesLegacy<string> : never)
|
|
40
43
|
| (type extends 'eip1559' ? FeeValuesEIP1559<string> : never)
|
|
@@ -42,7 +45,7 @@ export type EstimateFeesPerGasReturnType<
|
|
|
42
45
|
}
|
|
43
46
|
>
|
|
44
47
|
|
|
45
|
-
export type
|
|
48
|
+
export type EstimateFeesPerGasErrorType = viem_EstimateFeesPerGasErrorType
|
|
46
49
|
|
|
47
50
|
export async function estimateFeesPerGas<
|
|
48
51
|
config extends Config,
|