@wagmi/core 1.4.1 → 2.0.0
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/dist/esm/actions/connect.js +53 -0
- package/dist/esm/actions/connect.js.map +1 -0
- package/dist/esm/actions/disconnect.js +49 -0
- package/dist/esm/actions/disconnect.js.map +1 -0
- package/dist/esm/actions/estimateFeesPerGas.js +24 -0
- package/dist/esm/actions/estimateFeesPerGas.js.map +1 -0
- package/dist/esm/actions/estimateGas.js +25 -0
- package/dist/esm/actions/estimateGas.js.map +1 -0
- package/dist/esm/actions/getAccount.js +61 -0
- package/dist/esm/actions/getAccount.js.map +1 -0
- package/dist/esm/actions/getBalance.js +83 -0
- package/dist/esm/actions/getBalance.js.map +1 -0
- package/dist/esm/actions/getBlockNumber.js +9 -0
- package/dist/esm/actions/getBlockNumber.js.map +1 -0
- package/dist/esm/actions/getChainId.js +5 -0
- package/dist/esm/actions/getChainId.js.map +1 -0
- package/dist/esm/actions/getClient.js +5 -0
- package/dist/esm/actions/getClient.js.map +1 -0
- package/dist/esm/actions/getConnections.js +13 -0
- package/dist/esm/actions/getConnections.js.map +1 -0
- package/dist/esm/actions/getConnectorClient.js +42 -0
- package/dist/esm/actions/getConnectorClient.js.map +1 -0
- package/dist/esm/actions/getEnsAddress.js +9 -0
- package/dist/esm/actions/getEnsAddress.js.map +1 -0
- package/dist/esm/actions/getEnsAvatar.js +9 -0
- package/dist/esm/actions/getEnsAvatar.js.map +1 -0
- package/dist/esm/actions/getEnsName.js +9 -0
- package/dist/esm/actions/getEnsName.js.map +1 -0
- package/dist/esm/actions/getEnsResolver.js +9 -0
- package/dist/esm/actions/getEnsResolver.js.map +1 -0
- package/dist/esm/actions/getPublicClient.js +6 -0
- package/dist/esm/actions/getPublicClient.js.map +1 -0
- package/dist/esm/actions/getToken.js +101 -0
- package/dist/esm/actions/getToken.js.map +1 -0
- package/dist/esm/actions/getTransaction.js +10 -0
- package/dist/esm/actions/getTransaction.js.map +1 -0
- package/dist/esm/actions/getWalletClient.js +7 -0
- package/dist/esm/actions/getWalletClient.js.map +1 -0
- package/dist/esm/actions/multicall.js +11 -0
- package/dist/esm/actions/multicall.js.map +1 -0
- package/dist/esm/actions/readContract.js +10 -0
- package/dist/esm/actions/readContract.js.map +1 -0
- package/dist/esm/actions/readContracts.js +46 -0
- package/dist/esm/actions/readContracts.js.map +1 -0
- package/dist/esm/actions/reconnect.js +78 -0
- package/dist/esm/actions/reconnect.js.map +1 -0
- package/dist/esm/actions/sendTransaction.js +22 -0
- package/dist/esm/actions/sendTransaction.js.map +1 -0
- package/dist/esm/actions/signMessage.js +10 -0
- package/dist/esm/actions/signMessage.js.map +1 -0
- package/dist/esm/actions/signTypedData.js +10 -0
- package/dist/esm/actions/signTypedData.js.map +1 -0
- package/dist/esm/actions/simulateContract.js +33 -0
- package/dist/esm/actions/simulateContract.js.map +1 -0
- package/dist/esm/actions/switchAccount.js +19 -0
- package/dist/esm/actions/switchAccount.js.map +1 -0
- package/dist/esm/actions/switchChain.js +23 -0
- package/dist/esm/actions/switchChain.js.map +1 -0
- package/dist/esm/actions/waitForTransactionReceipt.js +23 -0
- package/dist/esm/actions/waitForTransactionReceipt.js.map +1 -0
- package/dist/esm/actions/watchAccount.js +18 -0
- package/dist/esm/actions/watchAccount.js.map +1 -0
- package/dist/esm/actions/watchBlockNumber.js +28 -0
- package/dist/esm/actions/watchBlockNumber.js.map +1 -0
- package/dist/esm/actions/watchChainId.js +6 -0
- package/dist/esm/actions/watchChainId.js.map +1 -0
- package/dist/esm/actions/watchClient.js +11 -0
- package/dist/esm/actions/watchClient.js.map +1 -0
- package/dist/esm/actions/watchConnections.js +10 -0
- package/dist/esm/actions/watchConnections.js.map +1 -0
- package/dist/esm/actions/watchContractEvent.js +27 -0
- package/dist/esm/actions/watchContractEvent.js.map +1 -0
- package/dist/esm/actions/watchPendingTransactions.js +27 -0
- package/dist/esm/actions/watchPendingTransactions.js.map +1 -0
- package/dist/esm/actions/watchPublicClient.js +11 -0
- package/dist/esm/actions/watchPublicClient.js.map +1 -0
- package/dist/esm/actions/writeContract.js +31 -0
- package/dist/esm/actions/writeContract.js.map +1 -0
- package/dist/esm/createConfig.js +218 -0
- package/dist/esm/createConfig.js.map +1 -0
- package/dist/esm/createConnector.js +8 -0
- package/dist/esm/createConnector.js.map +1 -0
- package/dist/esm/createEmitter.js +39 -0
- package/dist/esm/createEmitter.js.map +1 -0
- package/dist/esm/createStorage.js +37 -0
- package/dist/esm/createStorage.js.map +1 -0
- package/dist/esm/errors/base.js +86 -0
- package/dist/esm/errors/base.js.map +1 -0
- package/dist/esm/errors/config.js +70 -0
- package/dist/esm/errors/config.js.map +1 -0
- package/dist/esm/errors/connector.js +24 -0
- package/dist/esm/errors/connector.js.map +1 -0
- package/dist/esm/exports/actions.js +42 -0
- package/dist/esm/exports/actions.js.map +1 -0
- package/dist/esm/exports/chains.js +4 -0
- package/dist/esm/exports/chains.js.map +1 -0
- package/dist/esm/exports/index.js +71 -0
- package/dist/esm/exports/index.js.map +1 -0
- package/dist/esm/exports/internal.js +11 -0
- package/dist/esm/exports/internal.js.map +1 -0
- package/dist/esm/exports/query.js +29 -0
- package/dist/esm/exports/query.js.map +1 -0
- package/dist/esm/query/connect.js +11 -0
- package/dist/esm/query/connect.js.map +1 -0
- package/dist/esm/query/disconnect.js +10 -0
- package/dist/esm/query/disconnect.js.map +1 -0
- package/dist/esm/query/estimateFeesPerGas.js +16 -0
- package/dist/esm/query/estimateFeesPerGas.js.map +1 -0
- package/dist/esm/query/estimateGas.js +20 -0
- package/dist/esm/query/estimateGas.js.map +1 -0
- package/dist/esm/query/getBalance.js +21 -0
- package/dist/esm/query/getBalance.js.map +1 -0
- package/dist/esm/query/getBlockNumber.js +18 -0
- package/dist/esm/query/getBlockNumber.js.map +1 -0
- package/dist/esm/query/getConnectorClient.js +24 -0
- package/dist/esm/query/getConnectorClient.js.map +1 -0
- package/dist/esm/query/getEnsAddress.js +18 -0
- package/dist/esm/query/getEnsAddress.js.map +1 -0
- package/dist/esm/query/getEnsAvatar.js +18 -0
- package/dist/esm/query/getEnsAvatar.js.map +1 -0
- package/dist/esm/query/getEnsName.js +18 -0
- package/dist/esm/query/getEnsName.js.map +1 -0
- package/dist/esm/query/getEnsResolver.js +18 -0
- package/dist/esm/query/getEnsResolver.js.map +1 -0
- package/dist/esm/query/getToken.js +18 -0
- package/dist/esm/query/getToken.js.map +1 -0
- package/dist/esm/query/getTransaction.js +20 -0
- package/dist/esm/query/getTransaction.js.map +1 -0
- package/dist/esm/query/getWalletClient.js +21 -0
- package/dist/esm/query/getWalletClient.js.map +1 -0
- package/dist/esm/query/readContract.js +32 -0
- package/dist/esm/query/readContract.js.map +1 -0
- package/dist/esm/query/readContracts.js +36 -0
- package/dist/esm/query/readContracts.js.map +1 -0
- package/dist/esm/query/reconnect.js +10 -0
- package/dist/esm/query/reconnect.js.map +1 -0
- package/dist/esm/query/sendTransaction.js +11 -0
- package/dist/esm/query/sendTransaction.js.map +1 -0
- package/dist/esm/query/signMessage.js +13 -0
- package/dist/esm/query/signMessage.js.map +1 -0
- package/dist/esm/query/signTypedData.js +11 -0
- package/dist/esm/query/signTypedData.js.map +1 -0
- package/dist/esm/query/simulateContract.js +25 -0
- package/dist/esm/query/simulateContract.js.map +1 -0
- package/dist/esm/query/switchAccount.js +11 -0
- package/dist/esm/query/switchAccount.js.map +1 -0
- package/dist/esm/query/switchChain.js +11 -0
- package/dist/esm/query/switchChain.js.map +1 -0
- package/dist/esm/query/types.js +2 -0
- package/dist/esm/query/types.js.map +1 -0
- package/dist/esm/query/utils.js +45 -0
- package/dist/esm/query/utils.js.map +1 -0
- package/dist/esm/query/waitForTransactionReceipt.js +23 -0
- package/dist/esm/query/waitForTransactionReceipt.js.map +1 -0
- package/dist/esm/query/writeContract.js +11 -0
- package/dist/esm/query/writeContract.js.map +1 -0
- package/dist/esm/tsconfig.build.tsbuildinfo +1 -0
- package/dist/esm/types/chain.js +2 -0
- package/dist/esm/types/chain.js.map +1 -0
- package/dist/esm/types/properties.js +2 -0
- package/dist/esm/types/properties.js.map +1 -0
- package/dist/esm/types/register.js +2 -0
- package/dist/esm/types/register.js.map +1 -0
- package/dist/esm/types/unit.js +2 -0
- package/dist/esm/types/unit.js.map +1 -0
- package/dist/esm/types/utils.js +2 -0
- package/dist/esm/types/utils.js.map +1 -0
- package/dist/esm/utils/assertActiveChain.js +14 -0
- package/dist/esm/utils/assertActiveChain.js.map +1 -0
- package/dist/esm/utils/deepEqual.js +41 -0
- package/dist/esm/utils/deepEqual.js.map +1 -0
- package/dist/esm/utils/deserialize.js +11 -0
- package/dist/esm/utils/deserialize.js.map +1 -0
- package/dist/esm/utils/getUnit.js +10 -0
- package/dist/esm/utils/getUnit.js.map +1 -0
- package/dist/esm/utils/getVersion.js +3 -0
- package/dist/esm/utils/getVersion.js.map +1 -0
- package/dist/esm/utils/normalizeChainId.js +10 -0
- package/dist/esm/utils/normalizeChainId.js.map +1 -0
- package/dist/esm/utils/serialize.js +87 -0
- package/dist/esm/utils/serialize.js.map +1 -0
- package/dist/esm/utils/uid.js +14 -0
- package/dist/esm/utils/uid.js.map +1 -0
- package/dist/esm/version.js +2 -0
- package/dist/esm/version.js.map +1 -0
- package/dist/types/actions/connect.d.ts +19 -0
- package/dist/types/actions/connect.d.ts.map +1 -0
- package/dist/types/actions/disconnect.d.ts +9 -0
- package/dist/types/actions/disconnect.d.ts.map +1 -0
- package/dist/types/actions/estimateFeesPerGas.d.ts +16 -0
- package/dist/types/actions/estimateFeesPerGas.d.ts.map +1 -0
- package/dist/types/actions/estimateGas.d.ts +14 -0
- package/dist/types/actions/estimateGas.d.ts.map +1 -0
- package/dist/types/actions/getAccount.d.ts +46 -0
- package/dist/types/actions/getAccount.d.ts.map +1 -0
- package/dist/types/actions/getBalance.d.ts +21 -0
- package/dist/types/actions/getBalance.d.ts.map +1 -0
- package/dist/types/actions/getBlockNumber.d.ts +10 -0
- package/dist/types/actions/getBlockNumber.d.ts.map +1 -0
- package/dist/types/actions/getChainId.d.ts +5 -0
- package/dist/types/actions/getChainId.d.ts.map +1 -0
- package/dist/types/actions/getClient.d.ts +10 -0
- package/dist/types/actions/getClient.d.ts.map +1 -0
- package/dist/types/actions/getConnections.d.ts +6 -0
- package/dist/types/actions/getConnections.d.ts.map +1 -0
- package/dist/types/actions/getConnectorClient.d.ts +15 -0
- package/dist/types/actions/getConnectorClient.d.ts.map +1 -0
- package/dist/types/actions/getEnsAddress.d.ts +10 -0
- package/dist/types/actions/getEnsAddress.d.ts.map +1 -0
- package/dist/types/actions/getEnsAvatar.d.ts +10 -0
- package/dist/types/actions/getEnsAvatar.d.ts.map +1 -0
- package/dist/types/actions/getEnsName.d.ts +10 -0
- package/dist/types/actions/getEnsName.d.ts.map +1 -0
- package/dist/types/actions/getEnsResolver.d.ts +10 -0
- package/dist/types/actions/getEnsResolver.d.ts.map +1 -0
- package/dist/types/actions/getPublicClient.d.ts +10 -0
- package/dist/types/actions/getPublicClient.d.ts.map +1 -0
- package/dist/types/actions/getToken.d.ts +22 -0
- package/dist/types/actions/getToken.d.ts.map +1 -0
- package/dist/types/actions/getTransaction.d.ts +14 -0
- package/dist/types/actions/getTransaction.d.ts.map +1 -0
- package/dist/types/actions/getWalletClient.d.ts +11 -0
- package/dist/types/actions/getWalletClient.d.ts.map +1 -0
- package/dist/types/actions/multicall.d.ts +7 -0
- package/dist/types/actions/multicall.d.ts.map +1 -0
- package/dist/types/actions/readContract.d.ts +11 -0
- package/dist/types/actions/readContract.d.ts.map +1 -0
- package/dist/types/actions/readContracts.d.ts +10 -0
- package/dist/types/actions/readContracts.d.ts.map +1 -0
- package/dist/types/actions/reconnect.d.ts +12 -0
- package/dist/types/actions/reconnect.d.ts.map +1 -0
- package/dist/types/actions/sendTransaction.d.ts +15 -0
- package/dist/types/actions/sendTransaction.d.ts.map +1 -0
- package/dist/types/actions/signMessage.d.ts +11 -0
- package/dist/types/actions/signMessage.d.ts.map +1 -0
- package/dist/types/actions/signTypedData.d.ts +10 -0
- package/dist/types/actions/signTypedData.d.ts.map +1 -0
- package/dist/types/actions/simulateContract.d.ts +21 -0
- package/dist/types/actions/simulateContract.d.ts.map +1 -0
- package/dist/types/actions/switchAccount.d.ts +14 -0
- package/dist/types/actions/switchAccount.d.ts.map +1 -0
- package/dist/types/actions/switchChain.d.ts +16 -0
- package/dist/types/actions/switchChain.d.ts.map +1 -0
- package/dist/types/actions/waitForTransactionReceipt.d.ts +12 -0
- package/dist/types/actions/waitForTransactionReceipt.d.ts.map +1 -0
- package/dist/types/actions/watchAccount.d.ts +9 -0
- package/dist/types/actions/watchAccount.d.ts.map +1 -0
- package/dist/types/actions/watchBlockNumber.d.ts +13 -0
- package/dist/types/actions/watchBlockNumber.d.ts.map +1 -0
- package/dist/types/actions/watchChainId.d.ts +9 -0
- package/dist/types/actions/watchChainId.d.ts.map +1 -0
- package/dist/types/actions/watchClient.d.ts +9 -0
- package/dist/types/actions/watchClient.d.ts.map +1 -0
- package/dist/types/actions/watchConnections.d.ts +9 -0
- package/dist/types/actions/watchConnections.d.ts.map +1 -0
- package/dist/types/actions/watchContractEvent.d.ts +13 -0
- package/dist/types/actions/watchContractEvent.d.ts.map +1 -0
- package/dist/types/actions/watchPendingTransactions.d.ts +13 -0
- package/dist/types/actions/watchPendingTransactions.d.ts.map +1 -0
- package/dist/types/actions/watchPublicClient.d.ts +9 -0
- package/dist/types/actions/watchPublicClient.d.ts.map +1 -0
- package/dist/types/actions/writeContract.d.ts +15 -0
- package/dist/types/actions/writeContract.d.ts.map +1 -0
- package/dist/types/createConfig.d.ts +72 -0
- package/dist/types/createConfig.d.ts.map +1 -0
- package/dist/types/createConnector.d.ts +57 -0
- package/dist/types/createConnector.d.ts.map +1 -0
- package/dist/types/createEmitter.d.ts +31 -0
- package/dist/types/createEmitter.d.ts.map +1 -0
- package/dist/types/createStorage.d.ts +30 -0
- package/dist/types/createStorage.d.ts.map +1 -0
- package/dist/types/errors/base.d.ts +24 -0
- package/dist/types/errors/base.d.ts.map +1 -0
- package/dist/types/errors/config.d.ts +34 -0
- package/dist/types/errors/config.d.ts.map +1 -0
- package/dist/types/errors/connector.d.ts +13 -0
- package/dist/types/errors/connector.d.ts.map +1 -0
- package/dist/types/exports/actions.d.ts +40 -0
- package/dist/types/exports/actions.d.ts.map +1 -0
- package/dist/types/exports/chains.d.ts +2 -0
- package/dist/types/exports/chains.d.ts.map +1 -0
- package/dist/types/exports/index.d.ts +52 -0
- package/dist/types/exports/index.d.ts.map +1 -0
- package/dist/types/exports/internal.d.ts +5 -0
- package/dist/types/exports/internal.d.ts.map +1 -0
- package/dist/types/exports/query.d.ts +27 -0
- package/dist/types/exports/query.d.ts.map +1 -0
- package/dist/types/query/connect.d.ts +15 -0
- package/dist/types/query/connect.d.ts.map +1 -0
- package/dist/types/query/disconnect.d.ts +12 -0
- package/dist/types/query/disconnect.d.ts.map +1 -0
- package/dist/types/query/estimateFeesPerGas.d.ts +34 -0
- package/dist/types/query/estimateFeesPerGas.d.ts.map +1 -0
- package/dist/types/query/estimateGas.d.ts +18 -0
- package/dist/types/query/estimateGas.d.ts.map +1 -0
- package/dist/types/query/getBalance.d.ts +42 -0
- package/dist/types/query/getBalance.d.ts.map +1 -0
- package/dist/types/query/getBlockNumber.d.ts +34 -0
- package/dist/types/query/getBlockNumber.d.ts.map +1 -0
- package/dist/types/query/getConnectorClient.d.ts +319 -0
- package/dist/types/query/getConnectorClient.d.ts.map +1 -0
- package/dist/types/query/getEnsAddress.d.ts +42 -0
- package/dist/types/query/getEnsAddress.d.ts.map +1 -0
- package/dist/types/query/getEnsAvatar.d.ts +42 -0
- package/dist/types/query/getEnsAvatar.d.ts.map +1 -0
- package/dist/types/query/getEnsName.d.ts +39 -0
- package/dist/types/query/getEnsName.d.ts.map +1 -0
- package/dist/types/query/getEnsResolver.d.ts +39 -0
- package/dist/types/query/getEnsResolver.d.ts.map +1 -0
- package/dist/types/query/getToken.d.ts +33 -0
- package/dist/types/query/getToken.d.ts.map +1 -0
- package/dist/types/query/getTransaction.d.ts +110 -0
- package/dist/types/query/getTransaction.d.ts.map +1 -0
- package/dist/types/query/getWalletClient.d.ts +540 -0
- package/dist/types/query/getWalletClient.d.ts.map +1 -0
- package/dist/types/query/readContract.d.ts +19 -0
- package/dist/types/query/readContract.d.ts.map +1 -0
- package/dist/types/query/readContracts.d.ts +65 -0
- package/dist/types/query/readContracts.d.ts.map +1 -0
- package/dist/types/query/reconnect.d.ts +13 -0
- package/dist/types/query/reconnect.d.ts.map +1 -0
- package/dist/types/query/sendTransaction.d.ts +13 -0
- package/dist/types/query/sendTransaction.d.ts.map +1 -0
- package/dist/types/query/signMessage.d.ts +17 -0
- package/dist/types/query/signMessage.d.ts.map +1 -0
- package/dist/types/query/signTypedData.d.ts +219 -0
- package/dist/types/query/signTypedData.d.ts.map +1 -0
- package/dist/types/query/simulateContract.d.ts +19 -0
- package/dist/types/query/simulateContract.d.ts.map +1 -0
- package/dist/types/query/switchAccount.d.ts +15 -0
- package/dist/types/query/switchAccount.d.ts.map +1 -0
- package/dist/types/query/switchChain.d.ts +18 -0
- package/dist/types/query/switchChain.d.ts.map +1 -0
- package/dist/types/query/types.d.ts +9 -0
- package/dist/types/query/types.d.ts.map +1 -0
- package/dist/types/query/utils.d.ts +4 -0
- package/dist/types/query/utils.d.ts.map +1 -0
- package/dist/types/query/waitForTransactionReceipt.d.ts +131 -0
- package/dist/types/query/waitForTransactionReceipt.d.ts.map +1 -0
- package/dist/types/query/writeContract.d.ts +14 -0
- package/dist/types/query/writeContract.d.ts.map +1 -0
- package/dist/types/types/chain.d.ts +15 -0
- package/dist/types/types/chain.d.ts.map +1 -0
- package/dist/types/types/properties.d.ts +11 -0
- package/dist/types/types/properties.d.ts.map +1 -0
- package/dist/types/types/register.d.ts +8 -0
- package/dist/types/types/register.d.ts.map +1 -0
- package/dist/types/types/unit.d.ts +2 -0
- package/dist/types/types/unit.d.ts.map +1 -0
- package/dist/types/types/utils.d.ts +41 -0
- package/dist/types/types/utils.d.ts.map +1 -0
- package/dist/types/utils/assertActiveChain.d.ts +8 -0
- package/dist/types/utils/assertActiveChain.d.ts.map +1 -0
- package/dist/types/utils/deepEqual.d.ts +3 -0
- package/dist/types/utils/deepEqual.d.ts.map +1 -0
- package/dist/types/utils/deserialize.d.ts +4 -0
- package/dist/types/utils/deserialize.d.ts.map +1 -0
- package/dist/types/utils/getUnit.d.ts +3 -0
- package/dist/types/utils/getUnit.d.ts.map +1 -0
- package/dist/types/utils/getVersion.d.ts +2 -0
- package/dist/types/utils/getVersion.d.ts.map +1 -0
- package/dist/types/utils/normalizeChainId.d.ts +2 -0
- package/dist/types/utils/normalizeChainId.d.ts.map +1 -0
- package/dist/types/utils/serialize.d.ts +16 -0
- package/dist/types/utils/serialize.d.ts.map +1 -0
- package/dist/types/utils/uid.d.ts +2 -0
- package/dist/types/utils/uid.d.ts.map +1 -0
- package/dist/types/version.d.ts +2 -0
- package/dist/types/version.d.ts.map +1 -0
- package/package.json +65 -101
- package/src/actions/connect.ts +86 -0
- package/src/actions/disconnect.ts +68 -0
- package/src/actions/estimateFeesPerGas.ts +76 -0
- package/src/actions/estimateGas.ts +62 -0
- package/src/actions/getAccount.ts +109 -0
- package/src/actions/getBalance.ts +141 -0
- package/src/actions/getBlockNumber.ts +27 -0
- package/src/actions/getChainId.ts +11 -0
- package/src/actions/getClient.ts +30 -0
- package/src/actions/getConnections.ts +16 -0
- package/src/actions/getConnectorClient.ts +96 -0
- package/src/actions/getEnsAddress.ts +27 -0
- package/src/actions/getEnsAvatar.ts +27 -0
- package/src/actions/getEnsName.ts +27 -0
- package/src/actions/getEnsResolver.ts +27 -0
- package/src/actions/getPublicClient.ts +34 -0
- package/src/actions/getToken.ts +140 -0
- package/src/actions/getTransaction.ts +44 -0
- package/src/actions/getWalletClient.ts +41 -0
- package/src/actions/multicall.ts +37 -0
- package/src/actions/readContract.ts +55 -0
- package/src/actions/readContracts.ts +98 -0
- package/src/actions/reconnect.ts +102 -0
- package/src/actions/sendTransaction.ts +68 -0
- package/src/actions/signMessage.ts +29 -0
- package/src/actions/signTypedData.ts +36 -0
- package/src/actions/simulateContract.ts +161 -0
- package/src/actions/switchAccount.ts +37 -0
- package/src/actions/switchChain.ts +63 -0
- package/src/actions/waitForTransactionReceipt.ts +69 -0
- package/src/actions/watchAccount.ts +32 -0
- package/src/actions/watchBlockNumber.ts +78 -0
- package/src/actions/watchChainId.ts +20 -0
- package/src/actions/watchClient.ts +34 -0
- package/src/actions/watchConnections.ts +26 -0
- package/src/actions/watchContractEvent.ts +98 -0
- package/src/actions/watchPendingTransactions.ts +79 -0
- package/src/actions/watchPublicClient.ts +37 -0
- package/src/actions/writeContract.ts +111 -0
- package/src/createConfig.ts +382 -0
- package/src/createConnector.ts +78 -0
- package/src/createEmitter.ts +68 -0
- package/src/createStorage.ts +89 -0
- package/src/errors/base.ts +71 -0
- package/src/errors/config.ts +60 -0
- package/src/errors/connector.ts +17 -0
- package/src/exports/actions.ts +258 -0
- package/src/exports/chains.ts +4 -0
- package/src/exports/index.ts +339 -0
- package/src/exports/internal.ts +28 -0
- package/src/exports/query.ts +220 -0
- package/src/query/connect.ts +45 -0
- package/src/query/disconnect.ts +43 -0
- package/src/query/estimateFeesPerGas.ts +56 -0
- package/src/query/estimateGas.ts +55 -0
- package/src/query/getBalance.ts +61 -0
- package/src/query/getBlockNumber.ts +50 -0
- package/src/query/getConnectorClient.ts +68 -0
- package/src/query/getEnsAddress.ts +49 -0
- package/src/query/getEnsAvatar.ts +49 -0
- package/src/query/getEnsName.ts +49 -0
- package/src/query/getEnsResolver.ts +49 -0
- package/src/query/getToken.ts +49 -0
- package/src/query/getTransaction.ts +75 -0
- package/src/query/getWalletClient.ts +64 -0
- package/src/query/readContract.ts +88 -0
- package/src/query/readContracts.ts +98 -0
- package/src/query/reconnect.ts +42 -0
- package/src/query/sendTransaction.ts +65 -0
- package/src/query/signMessage.ts +42 -0
- package/src/query/signTypedData.ts +63 -0
- package/src/query/simulateContract.ts +128 -0
- package/src/query/switchAccount.ts +52 -0
- package/src/query/switchChain.ts +67 -0
- package/src/query/types.ts +52 -0
- package/src/query/utils.ts +54 -0
- package/src/query/waitForTransactionReceipt.ts +71 -0
- package/src/query/writeContract.ts +91 -0
- package/src/types/chain.ts +25 -0
- package/src/types/properties.ts +21 -0
- package/src/types/register.ts +8 -0
- package/src/types/unit.ts +1 -0
- package/src/types/utils.ts +85 -0
- package/src/utils/assertActiveChain.ts +26 -0
- package/src/utils/deepEqual.ts +43 -0
- package/src/utils/deserialize.ts +10 -0
- package/src/utils/getUnit.ts +9 -0
- package/src/utils/getVersion.ts +3 -0
- package/src/utils/normalizeChainId.ts +12 -0
- package/src/utils/serialize.ts +116 -0
- package/src/utils/uid.ts +14 -0
- package/src/version.ts +1 -0
- package/README.md +0 -30
- package/chains/package.json +0 -4
- package/connectors/coinbaseWallet/package.json +0 -4
- package/connectors/injected/package.json +0 -4
- package/connectors/ledger/package.json +0 -4
- package/connectors/metaMask/package.json +0 -4
- package/connectors/mock/package.json +0 -4
- package/connectors/package.json +0 -4
- package/connectors/safe/package.json +0 -4
- package/connectors/walletConnect/package.json +0 -4
- package/connectors/walletConnectLegacy/package.json +0 -4
- package/dist/chains.d.ts +0 -2
- package/dist/chains.js +0 -2
- package/dist/chunk-4E64EZ7V.js +0 -7
- package/dist/chunk-BVC4KGLQ.js +0 -8
- package/dist/chunk-EQOEZP46.js +0 -6
- package/dist/chunk-KFW652VN.js +0 -7
- package/dist/chunk-LAFZBYO7.js +0 -2934
- package/dist/chunk-MQXBDTVK.js +0 -29
- package/dist/connectors/coinbaseWallet.d.ts +0 -1
- package/dist/connectors/coinbaseWallet.js +0 -7
- package/dist/connectors/index.d.ts +0 -2
- package/dist/connectors/index.js +0 -9
- package/dist/connectors/injected.d.ts +0 -1
- package/dist/connectors/injected.js +0 -7
- package/dist/connectors/ledger.d.ts +0 -1
- package/dist/connectors/ledger.js +0 -7
- package/dist/connectors/metaMask.d.ts +0 -1
- package/dist/connectors/metaMask.js +0 -7
- package/dist/connectors/mock.d.ts +0 -1
- package/dist/connectors/mock.js +0 -9
- package/dist/connectors/safe.d.ts +0 -1
- package/dist/connectors/safe.js +0 -7
- package/dist/connectors/walletConnect.d.ts +0 -1
- package/dist/connectors/walletConnect.js +0 -7
- package/dist/connectors/walletConnectLegacy.d.ts +0 -1
- package/dist/connectors/walletConnectLegacy.js +0 -7
- package/dist/index-e744bbc2.d.ts +0 -22
- package/dist/index.d.ts +0 -1397
- package/dist/index.js +0 -135
- package/dist/internal/index.d.ts +0 -24
- package/dist/internal/index.js +0 -10
- package/dist/internal/test.d.ts +0 -438
- package/dist/internal/test.js +0 -160
- package/dist/providers/alchemy.d.ts +0 -11
- package/dist/providers/alchemy.js +0 -29
- package/dist/providers/infura.d.ts +0 -11
- package/dist/providers/infura.js +0 -29
- package/dist/providers/jsonRpc.d.ts +0 -13
- package/dist/providers/jsonRpc.js +0 -28
- package/dist/providers/public.d.ts +0 -7
- package/dist/providers/public.js +0 -16
- package/dist/window.d.ts +0 -7
- package/dist/window.js +0 -0
- package/internal/package.json +0 -4
- package/internal/test/package.json +0 -4
- package/providers/alchemy/package.json +0 -4
- package/providers/infura/package.json +0 -4
- package/providers/jsonRpc/package.json +0 -4
- package/providers/public/package.json +0 -4
- package/window/package.json +0 -4
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import { type QueryOptions } from '@tanstack/query-core'
|
|
2
|
+
import type { Abi, ContractFunctionArgs, ContractFunctionName } from 'viem'
|
|
3
|
+
|
|
4
|
+
import {
|
|
5
|
+
type SimulateContractError,
|
|
6
|
+
type SimulateContractParameters,
|
|
7
|
+
type SimulateContractReturnType,
|
|
8
|
+
simulateContract,
|
|
9
|
+
} from '../actions/simulateContract.js'
|
|
10
|
+
import type { Config } from '../createConfig.js'
|
|
11
|
+
import type { UnionPartial } from '../types/utils.js'
|
|
12
|
+
import type { ScopeKeyParameter } from './types.js'
|
|
13
|
+
import { filterQueryOptions } from './utils.js'
|
|
14
|
+
|
|
15
|
+
export type SimulateContractOptions<
|
|
16
|
+
abi extends Abi | readonly unknown[],
|
|
17
|
+
functionName extends ContractFunctionName<abi, 'nonpayable' | 'payable'>,
|
|
18
|
+
args extends ContractFunctionArgs<
|
|
19
|
+
abi,
|
|
20
|
+
'nonpayable' | 'payable',
|
|
21
|
+
functionName
|
|
22
|
+
>,
|
|
23
|
+
config extends Config,
|
|
24
|
+
chainId extends config['chains'][number]['id'] | undefined,
|
|
25
|
+
> = UnionPartial<
|
|
26
|
+
SimulateContractParameters<abi, functionName, args, config, chainId>
|
|
27
|
+
> &
|
|
28
|
+
ScopeKeyParameter
|
|
29
|
+
|
|
30
|
+
export function simulateContractQueryOptions<
|
|
31
|
+
const abi extends Abi | readonly unknown[],
|
|
32
|
+
functionName extends ContractFunctionName<abi, 'nonpayable' | 'payable'>,
|
|
33
|
+
args extends ContractFunctionArgs<
|
|
34
|
+
abi,
|
|
35
|
+
'nonpayable' | 'payable',
|
|
36
|
+
functionName
|
|
37
|
+
>,
|
|
38
|
+
config extends Config,
|
|
39
|
+
chainId extends config['chains'][number]['id'] | undefined,
|
|
40
|
+
>(
|
|
41
|
+
config: config,
|
|
42
|
+
options: SimulateContractOptions<
|
|
43
|
+
abi,
|
|
44
|
+
functionName,
|
|
45
|
+
args,
|
|
46
|
+
config,
|
|
47
|
+
chainId
|
|
48
|
+
> = {} as any,
|
|
49
|
+
) {
|
|
50
|
+
return {
|
|
51
|
+
async queryFn({ queryKey }) {
|
|
52
|
+
const { abi, connector } = options
|
|
53
|
+
if (!abi) throw new Error('abi is required')
|
|
54
|
+
const { scopeKey: _, ...parameters } = queryKey[1]
|
|
55
|
+
const { address, functionName } = parameters
|
|
56
|
+
if (!address) throw new Error('address is required')
|
|
57
|
+
if (!functionName) throw new Error('functionName is required')
|
|
58
|
+
return simulateContract(config, { abi, connector, ...parameters } as any)
|
|
59
|
+
},
|
|
60
|
+
queryKey: simulateContractQueryKey(options),
|
|
61
|
+
} as const satisfies QueryOptions<
|
|
62
|
+
SimulateContractQueryFnData<abi, functionName, args, config, chainId>,
|
|
63
|
+
SimulateContractError,
|
|
64
|
+
SimulateContractData<abi, functionName, args, config, chainId>,
|
|
65
|
+
SimulateContractQueryKey<abi, functionName, args, config, chainId>
|
|
66
|
+
>
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export type SimulateContractQueryFnData<
|
|
70
|
+
abi extends Abi | readonly unknown[],
|
|
71
|
+
functionName extends ContractFunctionName<abi, 'nonpayable' | 'payable'>,
|
|
72
|
+
args extends ContractFunctionArgs<
|
|
73
|
+
abi,
|
|
74
|
+
'nonpayable' | 'payable',
|
|
75
|
+
functionName
|
|
76
|
+
>,
|
|
77
|
+
config extends Config,
|
|
78
|
+
chainId extends config['chains'][number]['id'] | undefined,
|
|
79
|
+
> = SimulateContractReturnType<abi, functionName, args, config, chainId>
|
|
80
|
+
|
|
81
|
+
export type SimulateContractData<
|
|
82
|
+
abi extends Abi | readonly unknown[],
|
|
83
|
+
functionName extends ContractFunctionName<abi, 'nonpayable' | 'payable'>,
|
|
84
|
+
args extends ContractFunctionArgs<
|
|
85
|
+
abi,
|
|
86
|
+
'nonpayable' | 'payable',
|
|
87
|
+
functionName
|
|
88
|
+
>,
|
|
89
|
+
config extends Config,
|
|
90
|
+
chainId extends config['chains'][number]['id'] | undefined,
|
|
91
|
+
> = SimulateContractQueryFnData<abi, functionName, args, config, chainId>
|
|
92
|
+
|
|
93
|
+
export function simulateContractQueryKey<
|
|
94
|
+
abi extends Abi | readonly unknown[],
|
|
95
|
+
functionName extends ContractFunctionName<abi, 'nonpayable' | 'payable'>,
|
|
96
|
+
args extends ContractFunctionArgs<
|
|
97
|
+
abi,
|
|
98
|
+
'nonpayable' | 'payable',
|
|
99
|
+
functionName
|
|
100
|
+
>,
|
|
101
|
+
config extends Config,
|
|
102
|
+
chainId extends config['chains'][number]['id'] | undefined,
|
|
103
|
+
>(
|
|
104
|
+
options: SimulateContractOptions<
|
|
105
|
+
abi,
|
|
106
|
+
functionName,
|
|
107
|
+
args,
|
|
108
|
+
config,
|
|
109
|
+
chainId
|
|
110
|
+
> = {} as any,
|
|
111
|
+
) {
|
|
112
|
+
const { abi: _, connector: _c, ...rest } = options
|
|
113
|
+
return ['simulateContract', filterQueryOptions(rest)] as const
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
export type SimulateContractQueryKey<
|
|
117
|
+
abi extends Abi | readonly unknown[],
|
|
118
|
+
functionName extends ContractFunctionName<abi, 'nonpayable' | 'payable'>,
|
|
119
|
+
args extends ContractFunctionArgs<
|
|
120
|
+
abi,
|
|
121
|
+
'nonpayable' | 'payable',
|
|
122
|
+
functionName
|
|
123
|
+
>,
|
|
124
|
+
config extends Config,
|
|
125
|
+
chainId extends config['chains'][number]['id'] | undefined,
|
|
126
|
+
> = ReturnType<
|
|
127
|
+
typeof simulateContractQueryKey<abi, functionName, args, config, chainId>
|
|
128
|
+
>
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import type { MutationOptions } from '@tanstack/query-core'
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
type SwitchAccountError,
|
|
5
|
+
type SwitchAccountParameters,
|
|
6
|
+
type SwitchAccountReturnType,
|
|
7
|
+
switchAccount,
|
|
8
|
+
} from '../actions/switchAccount.js'
|
|
9
|
+
import { type Config } from '../createConfig.js'
|
|
10
|
+
import type { Evaluate } from '../types/utils.js'
|
|
11
|
+
import type { Mutate, MutateAsync } from './types.js'
|
|
12
|
+
|
|
13
|
+
export function switchAccountMutationOptions<config extends Config>(
|
|
14
|
+
config: config,
|
|
15
|
+
) {
|
|
16
|
+
return {
|
|
17
|
+
mutationFn(variables) {
|
|
18
|
+
return switchAccount(config, variables)
|
|
19
|
+
},
|
|
20
|
+
mutationKey: ['switchAccount'],
|
|
21
|
+
} as const satisfies MutationOptions<
|
|
22
|
+
SwitchAccountData<config>,
|
|
23
|
+
SwitchAccountError,
|
|
24
|
+
SwitchAccountVariables
|
|
25
|
+
>
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export type SwitchAccountData<config extends Config> = Evaluate<
|
|
29
|
+
SwitchAccountReturnType<config>
|
|
30
|
+
>
|
|
31
|
+
|
|
32
|
+
export type SwitchAccountVariables = Evaluate<SwitchAccountParameters>
|
|
33
|
+
|
|
34
|
+
export type SwitchAccountMutate<
|
|
35
|
+
config extends Config,
|
|
36
|
+
context = unknown,
|
|
37
|
+
> = Mutate<
|
|
38
|
+
SwitchAccountData<config>,
|
|
39
|
+
SwitchAccountError,
|
|
40
|
+
SwitchAccountVariables,
|
|
41
|
+
context
|
|
42
|
+
>
|
|
43
|
+
|
|
44
|
+
export type SwitchAccountMutateAsync<
|
|
45
|
+
config extends Config,
|
|
46
|
+
context = unknown,
|
|
47
|
+
> = MutateAsync<
|
|
48
|
+
SwitchAccountData<config>,
|
|
49
|
+
SwitchAccountError,
|
|
50
|
+
SwitchAccountVariables,
|
|
51
|
+
context
|
|
52
|
+
>
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import type { MutateOptions, MutationOptions } from '@tanstack/query-core'
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
type SwitchChainError,
|
|
5
|
+
type SwitchChainParameters,
|
|
6
|
+
type SwitchChainReturnType,
|
|
7
|
+
switchChain,
|
|
8
|
+
} from '../actions/switchChain.js'
|
|
9
|
+
import { type Config } from '../createConfig.js'
|
|
10
|
+
import type { Evaluate } from '../types/utils.js'
|
|
11
|
+
|
|
12
|
+
export function switchChainMutationOptions<config extends Config>(
|
|
13
|
+
config: config,
|
|
14
|
+
) {
|
|
15
|
+
return {
|
|
16
|
+
mutationFn(variables) {
|
|
17
|
+
return switchChain(config, variables)
|
|
18
|
+
},
|
|
19
|
+
mutationKey: ['switchChain'],
|
|
20
|
+
} as const satisfies MutationOptions<
|
|
21
|
+
SwitchChainData<config, config['chains'][number]['id']>,
|
|
22
|
+
SwitchChainError,
|
|
23
|
+
SwitchChainVariables<config, config['chains'][number]['id']>
|
|
24
|
+
>
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export type SwitchChainData<
|
|
28
|
+
config extends Config,
|
|
29
|
+
chainId extends config['chains'][number]['id'],
|
|
30
|
+
> = Evaluate<SwitchChainReturnType<config, chainId>>
|
|
31
|
+
|
|
32
|
+
export type SwitchChainVariables<
|
|
33
|
+
config extends Config,
|
|
34
|
+
chainId extends config['chains'][number]['id'],
|
|
35
|
+
> = Evaluate<SwitchChainParameters<config, chainId>>
|
|
36
|
+
|
|
37
|
+
export type SwitchChainMutate<config extends Config, context = unknown> = <
|
|
38
|
+
chainId extends config['chains'][number]['id'],
|
|
39
|
+
>(
|
|
40
|
+
variables: SwitchChainVariables<config, chainId>,
|
|
41
|
+
options?:
|
|
42
|
+
| Evaluate<
|
|
43
|
+
MutateOptions<
|
|
44
|
+
SwitchChainData<config, chainId>,
|
|
45
|
+
SwitchChainError,
|
|
46
|
+
Evaluate<SwitchChainVariables<config, chainId>>,
|
|
47
|
+
context
|
|
48
|
+
>
|
|
49
|
+
>
|
|
50
|
+
| undefined,
|
|
51
|
+
) => void
|
|
52
|
+
|
|
53
|
+
export type SwitchChainMutateAsync<config extends Config, context = unknown> = <
|
|
54
|
+
chainId extends config['chains'][number]['id'],
|
|
55
|
+
>(
|
|
56
|
+
variables: SwitchChainVariables<config, chainId>,
|
|
57
|
+
options?:
|
|
58
|
+
| Evaluate<
|
|
59
|
+
MutateOptions<
|
|
60
|
+
SwitchChainData<config, chainId>,
|
|
61
|
+
SwitchChainError,
|
|
62
|
+
Evaluate<SwitchChainVariables<config, chainId>>,
|
|
63
|
+
context
|
|
64
|
+
>
|
|
65
|
+
>
|
|
66
|
+
| undefined,
|
|
67
|
+
) => Promise<SwitchChainData<config, chainId>>
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import type { Evaluate } from '../types/utils.js'
|
|
2
|
+
|
|
3
|
+
export type ScopeKeyParameter = { scopeKey?: string | undefined }
|
|
4
|
+
|
|
5
|
+
type MutateFn<
|
|
6
|
+
data = unknown,
|
|
7
|
+
error = unknown,
|
|
8
|
+
variables = void,
|
|
9
|
+
context = unknown,
|
|
10
|
+
> = undefined extends variables
|
|
11
|
+
? (
|
|
12
|
+
variables?: variables,
|
|
13
|
+
options?:
|
|
14
|
+
| Evaluate<
|
|
15
|
+
import('@tanstack/query-core').MutateOptions<
|
|
16
|
+
data,
|
|
17
|
+
error,
|
|
18
|
+
variables,
|
|
19
|
+
context
|
|
20
|
+
>
|
|
21
|
+
>
|
|
22
|
+
| undefined,
|
|
23
|
+
) => Promise<data>
|
|
24
|
+
: (
|
|
25
|
+
variables: variables,
|
|
26
|
+
options?:
|
|
27
|
+
| Evaluate<
|
|
28
|
+
import('@tanstack/query-core').MutateOptions<
|
|
29
|
+
data,
|
|
30
|
+
error,
|
|
31
|
+
variables,
|
|
32
|
+
context
|
|
33
|
+
>
|
|
34
|
+
>
|
|
35
|
+
| undefined,
|
|
36
|
+
) => Promise<data>
|
|
37
|
+
|
|
38
|
+
export type Mutate<
|
|
39
|
+
data = unknown,
|
|
40
|
+
error = unknown,
|
|
41
|
+
variables = void,
|
|
42
|
+
context = unknown,
|
|
43
|
+
> = (
|
|
44
|
+
...args: Parameters<MutateFn<data, error, Evaluate<variables>, context>>
|
|
45
|
+
) => void
|
|
46
|
+
|
|
47
|
+
export type MutateAsync<
|
|
48
|
+
data = unknown,
|
|
49
|
+
error = unknown,
|
|
50
|
+
variables = void,
|
|
51
|
+
context = unknown,
|
|
52
|
+
> = MutateFn<data, error, Evaluate<variables>, context>
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import type { QueryKey } from '@tanstack/query-core'
|
|
2
|
+
|
|
3
|
+
export function hashFn(queryKey: QueryKey): string {
|
|
4
|
+
return JSON.stringify(queryKey, (_, value) => {
|
|
5
|
+
if (isPlainObject(value))
|
|
6
|
+
return Object.keys(value)
|
|
7
|
+
.sort()
|
|
8
|
+
.reduce((result, key) => {
|
|
9
|
+
result[key] = value[key]
|
|
10
|
+
return result
|
|
11
|
+
}, {} as any)
|
|
12
|
+
if (typeof value === 'bigint') return value.toString()
|
|
13
|
+
return value
|
|
14
|
+
})
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
function isPlainObject(o: any): o is Object {
|
|
18
|
+
if (!hasObjectPrototype(o)) {
|
|
19
|
+
return false
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
// If has modified constructor
|
|
23
|
+
const ctor = o.constructor
|
|
24
|
+
if (typeof ctor === 'undefined') return true
|
|
25
|
+
|
|
26
|
+
// If has modified prototype
|
|
27
|
+
const prot = ctor.prototype
|
|
28
|
+
if (!hasObjectPrototype(prot)) return false
|
|
29
|
+
|
|
30
|
+
// If constructor does not have an Object-specific method
|
|
31
|
+
// biome-ignore lint/suspicious/noPrototypeBuiltins: <explanation>
|
|
32
|
+
if (!prot.hasOwnProperty('isPrototypeOf')) return false
|
|
33
|
+
|
|
34
|
+
// Most likely a plain Object
|
|
35
|
+
return true
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
function hasObjectPrototype(o: any): boolean {
|
|
39
|
+
return Object.prototype.toString.call(o) === '[object Object]'
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export function filterQueryOptions<type extends Record<string, unknown>>(
|
|
43
|
+
options: type,
|
|
44
|
+
): type {
|
|
45
|
+
// destructuring is super fast
|
|
46
|
+
// biome-ignore format: no formatting
|
|
47
|
+
const {
|
|
48
|
+
// biome-ignore lint/correctness/noUnusedVariables: remove properties
|
|
49
|
+
config, connector, query,
|
|
50
|
+
...rest
|
|
51
|
+
} = options
|
|
52
|
+
|
|
53
|
+
return rest as type
|
|
54
|
+
}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { type QueryOptions } from '@tanstack/query-core'
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
type WaitForTransactionReceiptError,
|
|
5
|
+
type WaitForTransactionReceiptParameters,
|
|
6
|
+
type WaitForTransactionReceiptReturnType,
|
|
7
|
+
waitForTransactionReceipt,
|
|
8
|
+
} from '../actions/waitForTransactionReceipt.js'
|
|
9
|
+
import type { Config } from '../createConfig.js'
|
|
10
|
+
import type { Evaluate, ExactPartial } from '../types/utils.js'
|
|
11
|
+
import type { ScopeKeyParameter } from './types.js'
|
|
12
|
+
import { filterQueryOptions } from './utils.js'
|
|
13
|
+
|
|
14
|
+
export type WaitForTransactionReceiptOptions<
|
|
15
|
+
config extends Config,
|
|
16
|
+
chainId extends config['chains'][number]['id'],
|
|
17
|
+
> = Evaluate<
|
|
18
|
+
ExactPartial<WaitForTransactionReceiptParameters<config, chainId>> &
|
|
19
|
+
ScopeKeyParameter
|
|
20
|
+
>
|
|
21
|
+
|
|
22
|
+
export function waitForTransactionReceiptQueryOptions<
|
|
23
|
+
config extends Config,
|
|
24
|
+
chainId extends config['chains'][number]['id'],
|
|
25
|
+
>(
|
|
26
|
+
config: Config,
|
|
27
|
+
options: WaitForTransactionReceiptOptions<config, chainId> = {},
|
|
28
|
+
) {
|
|
29
|
+
return {
|
|
30
|
+
async queryFn({ queryKey }) {
|
|
31
|
+
const { hash, ...parameters } = queryKey[1]
|
|
32
|
+
if (!hash) throw new Error('hash is required')
|
|
33
|
+
return waitForTransactionReceipt(config, {
|
|
34
|
+
...parameters,
|
|
35
|
+
onReplaced: options.onReplaced,
|
|
36
|
+
hash,
|
|
37
|
+
}) as unknown as Promise<
|
|
38
|
+
WaitForTransactionReceiptReturnType<config, chainId>
|
|
39
|
+
>
|
|
40
|
+
},
|
|
41
|
+
queryKey: waitForTransactionReceiptQueryKey(options),
|
|
42
|
+
} as const satisfies QueryOptions<
|
|
43
|
+
WaitForTransactionReceiptQueryFnData<config, chainId>,
|
|
44
|
+
WaitForTransactionReceiptError,
|
|
45
|
+
WaitForTransactionReceiptData<config, chainId>,
|
|
46
|
+
WaitForTransactionReceiptQueryKey<config, chainId>
|
|
47
|
+
>
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export type WaitForTransactionReceiptQueryFnData<
|
|
51
|
+
config extends Config,
|
|
52
|
+
chainId extends config['chains'][number]['id'],
|
|
53
|
+
> = WaitForTransactionReceiptReturnType<config, chainId>
|
|
54
|
+
|
|
55
|
+
export type WaitForTransactionReceiptData<
|
|
56
|
+
config extends Config,
|
|
57
|
+
chainId extends config['chains'][number]['id'],
|
|
58
|
+
> = WaitForTransactionReceiptQueryFnData<config, chainId>
|
|
59
|
+
|
|
60
|
+
export function waitForTransactionReceiptQueryKey<
|
|
61
|
+
config extends Config,
|
|
62
|
+
chainId extends config['chains'][number]['id'],
|
|
63
|
+
>(options: WaitForTransactionReceiptOptions<config, chainId> = {}) {
|
|
64
|
+
const { onReplaced: _, ...rest } = options
|
|
65
|
+
return ['waitForTransactionReceipt', filterQueryOptions(rest)] as const
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
export type WaitForTransactionReceiptQueryKey<
|
|
69
|
+
config extends Config,
|
|
70
|
+
chainId extends config['chains'][number]['id'],
|
|
71
|
+
> = ReturnType<typeof waitForTransactionReceiptQueryKey<config, chainId>>
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import type { MutateOptions, MutationOptions } from '@tanstack/query-core'
|
|
2
|
+
import type { Abi, ContractFunctionArgs, ContractFunctionName } from 'viem'
|
|
3
|
+
|
|
4
|
+
import {
|
|
5
|
+
type WriteContractError,
|
|
6
|
+
type WriteContractParameters,
|
|
7
|
+
type WriteContractReturnType,
|
|
8
|
+
writeContract,
|
|
9
|
+
} from '../actions/writeContract.js'
|
|
10
|
+
import { type Config } from '../createConfig.js'
|
|
11
|
+
import type { Evaluate } from '../types/utils.js'
|
|
12
|
+
|
|
13
|
+
export function writeContractMutationOptions<config extends Config>(
|
|
14
|
+
config: config,
|
|
15
|
+
) {
|
|
16
|
+
return {
|
|
17
|
+
mutationFn(variables) {
|
|
18
|
+
return writeContract(config, variables)
|
|
19
|
+
},
|
|
20
|
+
mutationKey: ['writeContract'],
|
|
21
|
+
} as const satisfies MutationOptions<
|
|
22
|
+
WriteContractData,
|
|
23
|
+
WriteContractError,
|
|
24
|
+
WriteContractVariables<
|
|
25
|
+
Abi,
|
|
26
|
+
string,
|
|
27
|
+
readonly unknown[],
|
|
28
|
+
config,
|
|
29
|
+
config['chains'][number]['id']
|
|
30
|
+
>
|
|
31
|
+
>
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export type WriteContractData = Evaluate<WriteContractReturnType>
|
|
35
|
+
|
|
36
|
+
export type WriteContractVariables<
|
|
37
|
+
abi extends Abi | readonly unknown[],
|
|
38
|
+
functionName extends ContractFunctionName<abi, 'nonpayable' | 'payable'>,
|
|
39
|
+
args extends ContractFunctionArgs<
|
|
40
|
+
abi,
|
|
41
|
+
'nonpayable' | 'payable',
|
|
42
|
+
functionName
|
|
43
|
+
>,
|
|
44
|
+
config extends Config,
|
|
45
|
+
chainId extends config['chains'][number]['id'],
|
|
46
|
+
> = WriteContractParameters<abi, functionName, args, config, chainId>
|
|
47
|
+
|
|
48
|
+
export type WriteContractMutate<config extends Config, context = unknown> = <
|
|
49
|
+
const abi extends Abi | readonly unknown[],
|
|
50
|
+
functionName extends ContractFunctionName<abi, 'nonpayable' | 'payable'>,
|
|
51
|
+
args extends ContractFunctionArgs<
|
|
52
|
+
abi,
|
|
53
|
+
'nonpayable' | 'payable',
|
|
54
|
+
functionName
|
|
55
|
+
>,
|
|
56
|
+
chainId extends config['chains'][number]['id'],
|
|
57
|
+
>(
|
|
58
|
+
variables: WriteContractVariables<abi, functionName, args, config, chainId>,
|
|
59
|
+
options?:
|
|
60
|
+
| MutateOptions<
|
|
61
|
+
WriteContractData,
|
|
62
|
+
WriteContractError,
|
|
63
|
+
WriteContractVariables<abi, functionName, args, config, chainId>,
|
|
64
|
+
context
|
|
65
|
+
>
|
|
66
|
+
| undefined,
|
|
67
|
+
) => void
|
|
68
|
+
|
|
69
|
+
export type WriteContractMutateAsync<
|
|
70
|
+
config extends Config,
|
|
71
|
+
context = unknown,
|
|
72
|
+
> = <
|
|
73
|
+
const abi extends Abi | readonly unknown[],
|
|
74
|
+
functionName extends ContractFunctionName<abi, 'nonpayable' | 'payable'>,
|
|
75
|
+
args extends ContractFunctionArgs<
|
|
76
|
+
abi,
|
|
77
|
+
'nonpayable' | 'payable',
|
|
78
|
+
functionName
|
|
79
|
+
>,
|
|
80
|
+
chainId extends config['chains'][number]['id'],
|
|
81
|
+
>(
|
|
82
|
+
variables: WriteContractVariables<abi, functionName, args, config, chainId>,
|
|
83
|
+
options?:
|
|
84
|
+
| MutateOptions<
|
|
85
|
+
WriteContractData,
|
|
86
|
+
WriteContractError,
|
|
87
|
+
WriteContractVariables<abi, functionName, args, config, chainId>,
|
|
88
|
+
context
|
|
89
|
+
>
|
|
90
|
+
| undefined,
|
|
91
|
+
) => Promise<WriteContractData>
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { Chain, ChainFormatters } from 'viem'
|
|
2
|
+
|
|
3
|
+
import type { Config } from '../createConfig.js'
|
|
4
|
+
import type { IsNarrowable, Merge } from './utils.js'
|
|
5
|
+
|
|
6
|
+
/** Filters {@link Config} chains by {@link chainId} or simplifies if no `ChainFormatters` are present. */
|
|
7
|
+
export type SelectChains<
|
|
8
|
+
config extends Config,
|
|
9
|
+
chainId extends config['chains'][number]['id'] | undefined = undefined,
|
|
10
|
+
> = Config extends config
|
|
11
|
+
? readonly [Chain] // chains not inferrable, return default
|
|
12
|
+
: IsNarrowable<chainId, config['chains'][number]['id']> extends true
|
|
13
|
+
? readonly [Extract<config['chains'][number], { id: chainId }>] // select specific chain
|
|
14
|
+
: HasFormatter<config['chains']> extends true
|
|
15
|
+
? config['chains'] // return all chains since one has formatter
|
|
16
|
+
: readonly [Merge<Chain, { id: config['chains'][number]['id'] }>] // return default chain with ID set to union (allows for more simple type since the only thing that is different is the chain ID for each chain)
|
|
17
|
+
|
|
18
|
+
type HasFormatter<chains extends readonly Chain[]> = chains extends readonly [
|
|
19
|
+
infer head extends Chain,
|
|
20
|
+
...infer tail extends readonly Chain[],
|
|
21
|
+
]
|
|
22
|
+
? IsNarrowable<head['formatters'], ChainFormatters | undefined> extends true
|
|
23
|
+
? true
|
|
24
|
+
: HasFormatter<tail>
|
|
25
|
+
: false
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { Config, Connector } from '../createConfig.js'
|
|
2
|
+
|
|
3
|
+
export type ChainIdParameter<
|
|
4
|
+
config extends Config,
|
|
5
|
+
chainId extends
|
|
6
|
+
| config['chains'][number]['id']
|
|
7
|
+
| undefined = config['chains'][number]['id'],
|
|
8
|
+
> = {
|
|
9
|
+
chainId?:
|
|
10
|
+
| (chainId extends config['chains'][number]['id'] ? chainId : undefined)
|
|
11
|
+
| config['chains'][number]['id']
|
|
12
|
+
| undefined
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export type ConnectorParameter = {
|
|
16
|
+
connector?: Connector | undefined
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export type SyncConnectedChainParameter = {
|
|
20
|
+
syncConnectedChain?: boolean | undefined
|
|
21
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type Unit = 'ether' | 'gwei' | 'wei' | number
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
/** Combines members of an intersection into a readable type. */
|
|
2
|
+
// https://twitter.com/mattpocockuk/status/1622730173446557697?s=20&t=NdpAcmEFXY01xkqU3KO0Mg
|
|
3
|
+
export type Evaluate<type> = { [key in keyof type]: type[key] } & unknown
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Makes all properties of an object optional.
|
|
7
|
+
*
|
|
8
|
+
* Compatible with [`exactOptionalPropertyTypes`](https://www.typescriptlang.org/tsconfig#exactOptionalPropertyTypes).
|
|
9
|
+
*/
|
|
10
|
+
export type ExactPartial<type> = {
|
|
11
|
+
[key in keyof type]?: type[key] | undefined
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/** Checks if {@link type} can be narrowed further than {@link type2} */
|
|
15
|
+
export type IsNarrowable<type, type2> = IsUnknown<type> extends true
|
|
16
|
+
? false
|
|
17
|
+
: IsNever<
|
|
18
|
+
(type extends type2 ? true : false) & (type2 extends type ? false : true)
|
|
19
|
+
> extends true
|
|
20
|
+
? false
|
|
21
|
+
: true
|
|
22
|
+
|
|
23
|
+
/** Checks if {@link type} is `never` */
|
|
24
|
+
export type IsNever<type> = [type] extends [never] ? true : false
|
|
25
|
+
|
|
26
|
+
/** Checks if {@link type} is `unknown` */
|
|
27
|
+
export type IsUnknown<type> = unknown extends type ? true : false
|
|
28
|
+
|
|
29
|
+
/** Merges two object types into new type */
|
|
30
|
+
export type Merge<obj1, obj2> = Evaluate<
|
|
31
|
+
LooseOmit<obj1, keyof obj2 extends infer key extends string ? key : never> &
|
|
32
|
+
obj2
|
|
33
|
+
>
|
|
34
|
+
|
|
35
|
+
/** Removes `readonly` from all properties of an object. */
|
|
36
|
+
export type Mutable<type extends object> = {
|
|
37
|
+
-readonly [key in keyof type]: type[key]
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/** Strict version of built-in Omit type */
|
|
41
|
+
export type Omit<type, keys extends keyof type> = Pick<
|
|
42
|
+
type,
|
|
43
|
+
Exclude<keyof type, keys>
|
|
44
|
+
>
|
|
45
|
+
|
|
46
|
+
/** Makes objects destructurable. */
|
|
47
|
+
export type OneOf<
|
|
48
|
+
union extends object,
|
|
49
|
+
///
|
|
50
|
+
keys extends KeyofUnion<union> = KeyofUnion<union>,
|
|
51
|
+
> = union extends infer Item
|
|
52
|
+
? Evaluate<Item & { [K in Exclude<keys, keyof Item>]?: undefined }>
|
|
53
|
+
: never
|
|
54
|
+
type KeyofUnion<type> = type extends type ? keyof type : never
|
|
55
|
+
|
|
56
|
+
/** Makes {@link key} optional in {@link type} while preserving type inference. */
|
|
57
|
+
// s/o trpc (https://github.com/trpc/trpc/blob/main/packages/server/src/types.ts#L6)
|
|
58
|
+
export type PartialBy<type, key extends keyof type> = ExactPartial<
|
|
59
|
+
Pick<type, key>
|
|
60
|
+
> &
|
|
61
|
+
Omit<type, key>
|
|
62
|
+
|
|
63
|
+
///////////////////////////////////////////////////////////////////////////
|
|
64
|
+
// Loose types
|
|
65
|
+
|
|
66
|
+
/** Loose version of {@link Omit} */
|
|
67
|
+
export type LooseOmit<type, keys extends string> = Pick<
|
|
68
|
+
type,
|
|
69
|
+
Exclude<keyof type, keys>
|
|
70
|
+
>
|
|
71
|
+
|
|
72
|
+
///////////////////////////////////////////////////////////////////////////
|
|
73
|
+
// Union types
|
|
74
|
+
|
|
75
|
+
export type UnionEvaluate<type> = type extends object ? Evaluate<type> : type
|
|
76
|
+
|
|
77
|
+
export type UnionLooseOmit<type, keys extends string> = type extends any
|
|
78
|
+
? LooseOmit<type, keys>
|
|
79
|
+
: never
|
|
80
|
+
|
|
81
|
+
export type UnionOmit<type, keys extends keyof type> = type extends any
|
|
82
|
+
? Omit<type, keys>
|
|
83
|
+
: never
|
|
84
|
+
|
|
85
|
+
export type UnionPartial<type> = type extends object ? ExactPartial<type> : type
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { getChainId } from '../actions/getChainId.js'
|
|
2
|
+
import type { Config } from '../createConfig.js'
|
|
3
|
+
import { ChainMismatchError } from '../errors/config.js'
|
|
4
|
+
|
|
5
|
+
type AssertActiveChainParamters = {
|
|
6
|
+
activeChainId?: number | undefined
|
|
7
|
+
chainId: number
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export function assertActiveChain(
|
|
11
|
+
config: Config,
|
|
12
|
+
parameters: AssertActiveChainParamters,
|
|
13
|
+
) {
|
|
14
|
+
const { chainId } = parameters
|
|
15
|
+
|
|
16
|
+
// Check that active chain and target chain match
|
|
17
|
+
const activeChainId = parameters.activeChainId ?? getChainId(config)
|
|
18
|
+
if (activeChainId && chainId !== activeChainId) {
|
|
19
|
+
const activeChain =
|
|
20
|
+
config.chains.find((x) => x.id === activeChainId)?.name ??
|
|
21
|
+
`Chain ${activeChainId}`
|
|
22
|
+
const targetChain =
|
|
23
|
+
config.chains.find((x) => x.id === chainId)?.name ?? `Chain ${chainId}`
|
|
24
|
+
throw new ChainMismatchError({ activeChain, targetChain })
|
|
25
|
+
}
|
|
26
|
+
}
|