@growae/reactive-react 0.0.1 → 0.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/CHANGELOG.md +9 -0
- package/dist/esm/context.js +10 -0
- package/dist/esm/context.js.map +1 -0
- package/dist/esm/errors/base.js +14 -0
- package/dist/esm/errors/base.js.map +1 -0
- package/dist/esm/errors/context.js +13 -0
- package/dist/esm/errors/context.js.map +1 -0
- package/dist/esm/errors/index.js +3 -0
- package/dist/esm/errors/index.js.map +1 -0
- package/dist/esm/exports/index.js +40 -0
- package/dist/esm/exports/index.js.map +1 -0
- package/dist/esm/exports/query.js +5 -0
- package/dist/esm/exports/query.js.map +1 -0
- package/dist/esm/hooks/index.js +71 -0
- package/dist/esm/hooks/index.js.map +1 -0
- package/dist/esm/hooks/useAccount.js +30 -0
- package/dist/esm/hooks/useAccount.js.map +1 -0
- package/dist/esm/hooks/useActiveAccount.js +21 -0
- package/dist/esm/hooks/useActiveAccount.js.map +1 -0
- package/dist/esm/hooks/useBalance.js +29 -0
- package/dist/esm/hooks/useBalance.js.map +1 -0
- package/dist/esm/hooks/useBlock.js +25 -0
- package/dist/esm/hooks/useBlock.js.map +1 -0
- package/dist/esm/hooks/useBuildTransaction.js +18 -0
- package/dist/esm/hooks/useBuildTransaction.js.map +1 -0
- package/dist/esm/hooks/useCallContract.js +18 -0
- package/dist/esm/hooks/useCallContract.js.map +1 -0
- package/dist/esm/hooks/useChannelDeposit.js +18 -0
- package/dist/esm/hooks/useChannelDeposit.js.map +1 -0
- package/dist/esm/hooks/useClaimName.js +18 -0
- package/dist/esm/hooks/useClaimName.js.map +1 -0
- package/dist/esm/hooks/useCloseChannel.js +18 -0
- package/dist/esm/hooks/useCloseChannel.js.map +1 -0
- package/dist/esm/hooks/useCompileContract.js +18 -0
- package/dist/esm/hooks/useCompileContract.js.map +1 -0
- package/dist/esm/hooks/useConfig.js +11 -0
- package/dist/esm/hooks/useConfig.js.map +1 -0
- package/dist/esm/hooks/useConnect.js +27 -0
- package/dist/esm/hooks/useConnect.js.map +1 -0
- package/dist/esm/hooks/useConnection.js +9 -0
- package/dist/esm/hooks/useConnection.js.map +1 -0
- package/dist/esm/hooks/useConnections.js +9 -0
- package/dist/esm/hooks/useConnections.js.map +1 -0
- package/dist/esm/hooks/useConnectorClient.js +23 -0
- package/dist/esm/hooks/useConnectorClient.js.map +1 -0
- package/dist/esm/hooks/useConnectors.js +9 -0
- package/dist/esm/hooks/useConnectors.js.map +1 -0
- package/dist/esm/hooks/useContractBytecode.js +24 -0
- package/dist/esm/hooks/useContractBytecode.js.map +1 -0
- package/dist/esm/hooks/useContractEvents.js +26 -0
- package/dist/esm/hooks/useContractEvents.js.map +1 -0
- package/dist/esm/hooks/useDeployContract.js +18 -0
- package/dist/esm/hooks/useDeployContract.js.map +1 -0
- package/dist/esm/hooks/useDisconnect.js +18 -0
- package/dist/esm/hooks/useDisconnect.js.map +1 -0
- package/dist/esm/hooks/useEstimateGas.js +26 -0
- package/dist/esm/hooks/useEstimateGas.js.map +1 -0
- package/dist/esm/hooks/useHeight.js +22 -0
- package/dist/esm/hooks/useHeight.js.map +1 -0
- package/dist/esm/hooks/useMicroBlock.js +24 -0
- package/dist/esm/hooks/useMicroBlock.js.map +1 -0
- package/dist/esm/hooks/useNameEntry.js +24 -0
- package/dist/esm/hooks/useNameEntry.js.map +1 -0
- package/dist/esm/hooks/useNetworkId.js +9 -0
- package/dist/esm/hooks/useNetworkId.js.map +1 -0
- package/dist/esm/hooks/useNetworks.js +8 -0
- package/dist/esm/hooks/useNetworks.js.map +1 -0
- package/dist/esm/hooks/useNodeClient.js +9 -0
- package/dist/esm/hooks/useNodeClient.js.map +1 -0
- package/dist/esm/hooks/useOpenChannel.js +18 -0
- package/dist/esm/hooks/useOpenChannel.js.map +1 -0
- package/dist/esm/hooks/useOracleQueries.js +24 -0
- package/dist/esm/hooks/useOracleQueries.js.map +1 -0
- package/dist/esm/hooks/useOracleState.js +24 -0
- package/dist/esm/hooks/useOracleState.js.map +1 -0
- package/dist/esm/hooks/usePayForTransaction.js +18 -0
- package/dist/esm/hooks/usePayForTransaction.js.map +1 -0
- package/dist/esm/hooks/usePreclaimName.js +18 -0
- package/dist/esm/hooks/usePreclaimName.js.map +1 -0
- package/dist/esm/hooks/useQueryOracle.js +18 -0
- package/dist/esm/hooks/useQueryOracle.js.map +1 -0
- package/dist/esm/hooks/useReadContract.js +27 -0
- package/dist/esm/hooks/useReadContract.js.map +1 -0
- package/dist/esm/hooks/useReadContracts.js +22 -0
- package/dist/esm/hooks/useReadContracts.js.map +1 -0
- package/dist/esm/hooks/useReconnect.js +18 -0
- package/dist/esm/hooks/useReconnect.js.map +1 -0
- package/dist/esm/hooks/useRegisterOracle.js +18 -0
- package/dist/esm/hooks/useRegisterOracle.js.map +1 -0
- package/dist/esm/hooks/useResolveName.js +25 -0
- package/dist/esm/hooks/useResolveName.js.map +1 -0
- package/dist/esm/hooks/useRespondToQuery.js +18 -0
- package/dist/esm/hooks/useRespondToQuery.js.map +1 -0
- package/dist/esm/hooks/useRevokeName.js +18 -0
- package/dist/esm/hooks/useRevokeName.js.map +1 -0
- package/dist/esm/hooks/useSendTransaction.js +18 -0
- package/dist/esm/hooks/useSendTransaction.js.map +1 -0
- package/dist/esm/hooks/useSignDelegation.js +18 -0
- package/dist/esm/hooks/useSignDelegation.js.map +1 -0
- package/dist/esm/hooks/useSignMessage.js +18 -0
- package/dist/esm/hooks/useSignMessage.js.map +1 -0
- package/dist/esm/hooks/useSignTransaction.js +18 -0
- package/dist/esm/hooks/useSignTransaction.js.map +1 -0
- package/dist/esm/hooks/useSignTypedData.js +18 -0
- package/dist/esm/hooks/useSignTypedData.js.map +1 -0
- package/dist/esm/hooks/useSimulateContract.js +27 -0
- package/dist/esm/hooks/useSimulateContract.js.map +1 -0
- package/dist/esm/hooks/useSpend.js +18 -0
- package/dist/esm/hooks/useSpend.js.map +1 -0
- package/dist/esm/hooks/useSwitchActiveAccount.js +20 -0
- package/dist/esm/hooks/useSwitchActiveAccount.js.map +1 -0
- package/dist/esm/hooks/useSwitchNetwork.js +20 -0
- package/dist/esm/hooks/useSwitchNetwork.js.map +1 -0
- package/dist/esm/hooks/useTransaction.js +24 -0
- package/dist/esm/hooks/useTransaction.js.map +1 -0
- package/dist/esm/hooks/useTransactionCount.js +24 -0
- package/dist/esm/hooks/useTransactionCount.js.map +1 -0
- package/dist/esm/hooks/useTransferFunds.js +18 -0
- package/dist/esm/hooks/useTransferFunds.js.map +1 -0
- package/dist/esm/hooks/useTransferName.js +18 -0
- package/dist/esm/hooks/useTransferName.js.map +1 -0
- package/dist/esm/hooks/useUpdateName.js +18 -0
- package/dist/esm/hooks/useUpdateName.js.map +1 -0
- package/dist/esm/hooks/useVerifyMessage.js +21 -0
- package/dist/esm/hooks/useVerifyMessage.js.map +1 -0
- package/dist/esm/hooks/useVerifyTypedData.js +21 -0
- package/dist/esm/hooks/useVerifyTypedData.js.map +1 -0
- package/dist/esm/hooks/useWaitForTransaction.js +24 -0
- package/dist/esm/hooks/useWaitForTransaction.js.map +1 -0
- package/dist/esm/hooks/useWaitForTransactionConfirm.js +24 -0
- package/dist/esm/hooks/useWaitForTransactionConfirm.js.map +1 -0
- package/dist/esm/hooks/useWatchConnection.js +20 -0
- package/dist/esm/hooks/useWatchConnection.js.map +1 -0
- package/dist/esm/hooks/useWatchConnectors.js +20 -0
- package/dist/esm/hooks/useWatchConnectors.js.map +1 -0
- package/dist/esm/hooks/useWatchHeight.js +25 -0
- package/dist/esm/hooks/useWatchHeight.js.map +1 -0
- package/dist/esm/hydrate.js +26 -0
- package/dist/esm/hydrate.js.map +1 -0
- package/dist/esm/types/properties.js +2 -0
- package/dist/esm/types/properties.js.map +1 -0
- package/dist/esm/utils/query.js +13 -0
- package/dist/esm/utils/query.js.map +1 -0
- package/dist/tsconfig.build.tsbuildinfo +1 -0
- package/dist/types/context.d.ts +9 -0
- package/dist/types/context.d.ts.map +1 -0
- package/dist/types/errors/base.d.ts +8 -0
- package/dist/types/errors/base.d.ts.map +1 -0
- package/dist/types/errors/context.d.ts +9 -0
- package/dist/types/errors/context.d.ts.map +1 -0
- package/dist/types/errors/index.d.ts +3 -0
- package/dist/types/errors/index.d.ts.map +1 -0
- package/dist/types/exports/index.d.ts +8 -0
- package/dist/types/exports/index.d.ts.map +1 -0
- package/dist/types/exports/query.d.ts +3 -0
- package/dist/types/exports/query.d.ts.map +1 -0
- package/dist/types/hooks/index.d.ts +62 -0
- package/dist/types/hooks/index.d.ts.map +1 -0
- package/dist/types/hooks/useAccount.d.ts +11 -0
- package/dist/types/hooks/useAccount.d.ts.map +1 -0
- package/dist/types/hooks/useActiveAccount.d.ts +6 -0
- package/dist/types/hooks/useActiveAccount.d.ts.map +1 -0
- package/dist/types/hooks/useBalance.d.ts +11 -0
- package/dist/types/hooks/useBalance.d.ts.map +1 -0
- package/dist/types/hooks/useBlock.d.ts +10 -0
- package/dist/types/hooks/useBlock.d.ts.map +1 -0
- package/dist/types/hooks/useBuildTransaction.d.ts +16 -0
- package/dist/types/hooks/useBuildTransaction.d.ts.map +1 -0
- package/dist/types/hooks/useCallContract.d.ts +16 -0
- package/dist/types/hooks/useCallContract.d.ts.map +1 -0
- package/dist/types/hooks/useChannelDeposit.d.ts +16 -0
- package/dist/types/hooks/useChannelDeposit.d.ts.map +1 -0
- package/dist/types/hooks/useClaimName.d.ts +16 -0
- package/dist/types/hooks/useClaimName.d.ts.map +1 -0
- package/dist/types/hooks/useCloseChannel.d.ts +16 -0
- package/dist/types/hooks/useCloseChannel.d.ts.map +1 -0
- package/dist/types/hooks/useCompileContract.d.ts +16 -0
- package/dist/types/hooks/useCompileContract.d.ts.map +1 -0
- package/dist/types/hooks/useConfig.d.ts +6 -0
- package/dist/types/hooks/useConfig.d.ts.map +1 -0
- package/dist/types/hooks/useConnect.d.ts +19 -0
- package/dist/types/hooks/useConnect.d.ts.map +1 -0
- package/dist/types/hooks/useConnection.d.ts +6 -0
- package/dist/types/hooks/useConnection.d.ts.map +1 -0
- package/dist/types/hooks/useConnections.d.ts +6 -0
- package/dist/types/hooks/useConnections.d.ts.map +1 -0
- package/dist/types/hooks/useConnectorClient.d.ts +8 -0
- package/dist/types/hooks/useConnectorClient.d.ts.map +1 -0
- package/dist/types/hooks/useConnectors.d.ts +6 -0
- package/dist/types/hooks/useConnectors.d.ts.map +1 -0
- package/dist/types/hooks/useContractBytecode.d.ts +10 -0
- package/dist/types/hooks/useContractBytecode.d.ts.map +1 -0
- package/dist/types/hooks/useContractEvents.d.ts +10 -0
- package/dist/types/hooks/useContractEvents.d.ts.map +1 -0
- package/dist/types/hooks/useDeployContract.d.ts +16 -0
- package/dist/types/hooks/useDeployContract.d.ts.map +1 -0
- package/dist/types/hooks/useDisconnect.d.ts +16 -0
- package/dist/types/hooks/useDisconnect.d.ts.map +1 -0
- package/dist/types/hooks/useEstimateGas.d.ts +10 -0
- package/dist/types/hooks/useEstimateGas.d.ts.map +1 -0
- package/dist/types/hooks/useHeight.d.ts +10 -0
- package/dist/types/hooks/useHeight.d.ts.map +1 -0
- package/dist/types/hooks/useMicroBlock.d.ts +10 -0
- package/dist/types/hooks/useMicroBlock.d.ts.map +1 -0
- package/dist/types/hooks/useNameEntry.d.ts +10 -0
- package/dist/types/hooks/useNameEntry.d.ts.map +1 -0
- package/dist/types/hooks/useNetworkId.d.ts +6 -0
- package/dist/types/hooks/useNetworkId.d.ts.map +1 -0
- package/dist/types/hooks/useNetworks.d.ts +6 -0
- package/dist/types/hooks/useNetworks.d.ts.map +1 -0
- package/dist/types/hooks/useNodeClient.d.ts +7 -0
- package/dist/types/hooks/useNodeClient.d.ts.map +1 -0
- package/dist/types/hooks/useOpenChannel.d.ts +16 -0
- package/dist/types/hooks/useOpenChannel.d.ts.map +1 -0
- package/dist/types/hooks/useOracleQueries.d.ts +10 -0
- package/dist/types/hooks/useOracleQueries.d.ts.map +1 -0
- package/dist/types/hooks/useOracleState.d.ts +10 -0
- package/dist/types/hooks/useOracleState.d.ts.map +1 -0
- package/dist/types/hooks/usePayForTransaction.d.ts +16 -0
- package/dist/types/hooks/usePayForTransaction.d.ts.map +1 -0
- package/dist/types/hooks/usePreclaimName.d.ts +16 -0
- package/dist/types/hooks/usePreclaimName.d.ts.map +1 -0
- package/dist/types/hooks/useQueryOracle.d.ts +16 -0
- package/dist/types/hooks/useQueryOracle.d.ts.map +1 -0
- package/dist/types/hooks/useReadContract.d.ts +10 -0
- package/dist/types/hooks/useReadContract.d.ts.map +1 -0
- package/dist/types/hooks/useReadContracts.d.ts +10 -0
- package/dist/types/hooks/useReadContracts.d.ts.map +1 -0
- package/dist/types/hooks/useReconnect.d.ts +16 -0
- package/dist/types/hooks/useReconnect.d.ts.map +1 -0
- package/dist/types/hooks/useRegisterOracle.d.ts +16 -0
- package/dist/types/hooks/useRegisterOracle.d.ts.map +1 -0
- package/dist/types/hooks/useResolveName.d.ts +10 -0
- package/dist/types/hooks/useResolveName.d.ts.map +1 -0
- package/dist/types/hooks/useRespondToQuery.d.ts +16 -0
- package/dist/types/hooks/useRespondToQuery.d.ts.map +1 -0
- package/dist/types/hooks/useRevokeName.d.ts +16 -0
- package/dist/types/hooks/useRevokeName.d.ts.map +1 -0
- package/dist/types/hooks/useSendTransaction.d.ts +16 -0
- package/dist/types/hooks/useSendTransaction.d.ts.map +1 -0
- package/dist/types/hooks/useSignDelegation.d.ts +16 -0
- package/dist/types/hooks/useSignDelegation.d.ts.map +1 -0
- package/dist/types/hooks/useSignMessage.d.ts +16 -0
- package/dist/types/hooks/useSignMessage.d.ts.map +1 -0
- package/dist/types/hooks/useSignTransaction.d.ts +16 -0
- package/dist/types/hooks/useSignTransaction.d.ts.map +1 -0
- package/dist/types/hooks/useSignTypedData.d.ts +16 -0
- package/dist/types/hooks/useSignTypedData.d.ts.map +1 -0
- package/dist/types/hooks/useSimulateContract.d.ts +10 -0
- package/dist/types/hooks/useSimulateContract.d.ts.map +1 -0
- package/dist/types/hooks/useSpend.d.ts +16 -0
- package/dist/types/hooks/useSpend.d.ts.map +1 -0
- package/dist/types/hooks/useSwitchActiveAccount.d.ts +10 -0
- package/dist/types/hooks/useSwitchActiveAccount.d.ts.map +1 -0
- package/dist/types/hooks/useSwitchNetwork.d.ts +18 -0
- package/dist/types/hooks/useSwitchNetwork.d.ts.map +1 -0
- package/dist/types/hooks/useTransaction.d.ts +10 -0
- package/dist/types/hooks/useTransaction.d.ts.map +1 -0
- package/dist/types/hooks/useTransactionCount.d.ts +10 -0
- package/dist/types/hooks/useTransactionCount.d.ts.map +1 -0
- package/dist/types/hooks/useTransferFunds.d.ts +16 -0
- package/dist/types/hooks/useTransferFunds.d.ts.map +1 -0
- package/dist/types/hooks/useTransferName.d.ts +16 -0
- package/dist/types/hooks/useTransferName.d.ts.map +1 -0
- package/dist/types/hooks/useUpdateName.d.ts +16 -0
- package/dist/types/hooks/useUpdateName.d.ts.map +1 -0
- package/dist/types/hooks/useVerifyMessage.d.ts +10 -0
- package/dist/types/hooks/useVerifyMessage.d.ts.map +1 -0
- package/dist/types/hooks/useVerifyTypedData.d.ts +10 -0
- package/dist/types/hooks/useVerifyTypedData.d.ts.map +1 -0
- package/dist/types/hooks/useWaitForTransaction.d.ts +10 -0
- package/dist/types/hooks/useWaitForTransaction.d.ts.map +1 -0
- package/dist/types/hooks/useWaitForTransactionConfirm.d.ts +10 -0
- package/dist/types/hooks/useWaitForTransactionConfirm.d.ts.map +1 -0
- package/dist/types/hooks/useWatchConnection.d.ts +9 -0
- package/dist/types/hooks/useWatchConnection.d.ts.map +1 -0
- package/dist/types/hooks/useWatchConnectors.d.ts +9 -0
- package/dist/types/hooks/useWatchConnectors.d.ts.map +1 -0
- package/dist/types/hooks/useWatchHeight.d.ts +11 -0
- package/dist/types/hooks/useWatchHeight.d.ts.map +1 -0
- package/dist/types/hydrate.d.ts +9 -0
- package/dist/types/hydrate.d.ts.map +1 -0
- package/dist/types/types/properties.d.ts +8 -0
- package/dist/types/types/properties.d.ts.map +1 -0
- package/dist/types/utils/query.d.ts +18 -0
- package/dist/types/utils/query.d.ts.map +1 -0
- package/package.json +5 -2
- package/src/context.test.ts +4 -4
- package/src/context.ts +2 -2
- package/src/errors/context.ts +1 -1
- package/src/errors/index.ts +2 -2
- package/src/exports/index.ts +11 -13
- package/src/exports/query.ts +1 -1
- package/src/hooks/index.ts +305 -52
- package/src/hooks/useAccount.test.ts +2 -2
- package/src/hooks/useAccount.ts +27 -17
- package/src/hooks/useActiveAccount.test.ts +28 -0
- package/src/hooks/useActiveAccount.ts +40 -0
- package/src/hooks/useBalance.test.ts +8 -12
- package/src/hooks/useBalance.ts +26 -16
- package/src/hooks/useBlock.test.ts +2 -2
- package/src/hooks/useBlock.ts +18 -14
- package/src/hooks/useBuildTransaction.test.ts +42 -0
- package/src/hooks/useBuildTransaction.ts +65 -0
- package/src/hooks/useCallContract.test.ts +2 -2
- package/src/hooks/useCallContract.ts +22 -11
- package/src/hooks/useChannelDeposit.test.ts +2 -2
- package/src/hooks/useChannelDeposit.ts +21 -10
- package/src/hooks/useClaimName.test.ts +2 -2
- package/src/hooks/useClaimName.ts +20 -10
- package/src/hooks/useCloseChannel.test.ts +2 -2
- package/src/hooks/useCloseChannel.ts +21 -10
- package/src/hooks/useCompileContract.test.ts +42 -0
- package/src/hooks/useCompileContract.ts +65 -0
- package/src/hooks/useConfig.test.ts +5 -5
- package/src/hooks/useConfig.ts +3 -3
- package/src/hooks/useConnect.test.ts +6 -6
- package/src/hooks/useConnect.ts +25 -13
- package/src/hooks/useConnection.test.ts +2 -2
- package/src/hooks/useConnection.ts +2 -2
- package/src/hooks/useConnections.test.ts +2 -2
- package/src/hooks/useConnections.ts +2 -2
- package/src/hooks/useConnectorClient.test.ts +2 -2
- package/src/hooks/useConnectorClient.ts +19 -20
- package/src/hooks/useConnectors.test.ts +2 -2
- package/src/hooks/useConnectors.ts +2 -2
- package/src/hooks/useContractBytecode.test.ts +2 -2
- package/src/hooks/useContractBytecode.ts +18 -14
- package/src/hooks/useContractEvents.test.ts +2 -2
- package/src/hooks/useContractEvents.ts +18 -14
- package/src/hooks/useDeployContract.test.ts +2 -2
- package/src/hooks/useDeployContract.ts +22 -11
- package/src/hooks/useDisconnect.test.ts +2 -2
- package/src/hooks/useDisconnect.ts +22 -11
- package/src/hooks/useEstimateGas.test.ts +2 -2
- package/src/hooks/useEstimateGas.ts +21 -15
- package/src/hooks/useHeight.test.ts +2 -2
- package/src/hooks/useHeight.ts +15 -11
- package/src/hooks/useMicroBlock.test.ts +45 -0
- package/src/hooks/useMicroBlock.ts +45 -0
- package/src/hooks/useNameEntry.test.ts +45 -0
- package/src/hooks/useNameEntry.ts +45 -0
- package/src/hooks/useNetworkId.test.ts +6 -6
- package/src/hooks/useNetworkId.ts +2 -2
- package/src/hooks/useNetworks.test.ts +2 -2
- package/src/hooks/useNetworks.ts +3 -6
- package/src/hooks/useNodeClient.test.ts +2 -2
- package/src/hooks/useNodeClient.ts +2 -2
- package/src/hooks/useOpenChannel.test.ts +2 -2
- package/src/hooks/useOpenChannel.ts +21 -10
- package/src/hooks/useOracleQueries.test.ts +2 -2
- package/src/hooks/useOracleQueries.ts +16 -12
- package/src/hooks/useOracleState.test.ts +2 -2
- package/src/hooks/useOracleState.ts +16 -12
- package/src/hooks/usePayForTransaction.test.ts +2 -2
- package/src/hooks/usePayForTransaction.ts +23 -11
- package/src/hooks/usePreclaimName.test.ts +2 -2
- package/src/hooks/usePreclaimName.ts +21 -10
- package/src/hooks/useQueryOracle.test.ts +2 -2
- package/src/hooks/useQueryOracle.ts +21 -10
- package/src/hooks/useReadContract.test.ts +2 -2
- package/src/hooks/useReadContract.ts +20 -15
- package/src/hooks/useReadContracts.test.ts +2 -2
- package/src/hooks/useReadContracts.ts +15 -11
- package/src/hooks/useReconnect.test.ts +2 -2
- package/src/hooks/useReconnect.ts +21 -11
- package/src/hooks/useRegisterOracle.test.ts +2 -2
- package/src/hooks/useRegisterOracle.ts +21 -10
- package/src/hooks/useResolveName.test.ts +2 -2
- package/src/hooks/useResolveName.ts +17 -13
- package/src/hooks/useRespondToQuery.test.ts +2 -2
- package/src/hooks/useRespondToQuery.ts +21 -10
- package/src/hooks/useRevokeName.test.ts +2 -2
- package/src/hooks/useRevokeName.ts +21 -10
- package/src/hooks/useSendTransaction.test.ts +2 -2
- package/src/hooks/useSendTransaction.ts +22 -11
- package/src/hooks/useSignDelegation.test.ts +42 -0
- package/src/hooks/useSignDelegation.ts +65 -0
- package/src/hooks/useSignMessage.test.ts +2 -2
- package/src/hooks/useSignMessage.ts +22 -11
- package/src/hooks/useSignTransaction.test.ts +2 -2
- package/src/hooks/useSignTransaction.ts +22 -11
- package/src/hooks/useSignTypedData.test.ts +2 -2
- package/src/hooks/useSignTypedData.ts +22 -11
- package/src/hooks/useSimulateContract.test.ts +2 -2
- package/src/hooks/useSimulateContract.ts +20 -15
- package/src/hooks/useSpend.test.ts +2 -2
- package/src/hooks/useSpend.ts +18 -10
- package/src/hooks/useSwitchActiveAccount.ts +38 -0
- package/src/hooks/useSwitchNetwork.test.ts +2 -2
- package/src/hooks/useSwitchNetwork.ts +23 -12
- package/src/hooks/useTransaction.test.ts +2 -2
- package/src/hooks/useTransaction.ts +17 -13
- package/src/hooks/useTransactionCount.test.ts +2 -2
- package/src/hooks/useTransactionCount.ts +17 -13
- package/src/hooks/useTransferFunds.test.ts +42 -0
- package/src/hooks/useTransferFunds.ts +65 -0
- package/src/hooks/useTransferName.test.ts +2 -2
- package/src/hooks/useTransferName.ts +21 -10
- package/src/hooks/useUpdateName.test.ts +2 -2
- package/src/hooks/useUpdateName.ts +21 -10
- package/src/hooks/useVerifyMessage.test.ts +2 -2
- package/src/hooks/useVerifyMessage.ts +17 -12
- package/src/hooks/useVerifyTypedData.test.ts +2 -2
- package/src/hooks/useVerifyTypedData.ts +15 -12
- package/src/hooks/useWaitForTransaction.test.ts +2 -2
- package/src/hooks/useWaitForTransaction.ts +17 -13
- package/src/hooks/useWaitForTransactionConfirm.test.ts +45 -0
- package/src/hooks/useWaitForTransactionConfirm.ts +45 -0
- package/src/hooks/useWatchConnection.test.ts +2 -2
- package/src/hooks/useWatchConnection.ts +3 -3
- package/src/hooks/useWatchConnectors.test.ts +2 -2
- package/src/hooks/useWatchConnectors.ts +3 -3
- package/src/hooks/useWatchHeight.test.ts +2 -2
- package/src/hooks/useWatchHeight.ts +4 -8
- package/src/hydrate.ts +1 -0
- package/src/utils/query.ts +12 -4
- package/tsconfig.build.json +2 -1
- package/tsconfig.json +6 -4
|
@@ -1,22 +1,30 @@
|
|
|
1
1
|
'use client'
|
|
2
2
|
|
|
3
|
-
import { useMutation } from '@tanstack/react-query'
|
|
4
3
|
import {
|
|
4
|
+
type SignMessageErrorType,
|
|
5
5
|
type SignMessageParameters,
|
|
6
6
|
type SignMessageReturnType,
|
|
7
|
-
type SignMessageErrorType,
|
|
8
7
|
signMessage,
|
|
9
8
|
} from '@growae/reactive'
|
|
10
9
|
import type { Compute } from '@growae/reactive'
|
|
11
|
-
import
|
|
12
|
-
import type {
|
|
13
|
-
import {
|
|
10
|
+
import { useMutation } from '@tanstack/react-query'
|
|
11
|
+
import type { ConfigParameter } from '../types/properties'
|
|
12
|
+
import type { UseMutationReturnType } from '../utils/query'
|
|
13
|
+
import { useConfig } from './useConfig'
|
|
14
14
|
|
|
15
15
|
export type UseSignMessageParameters<context = unknown> = Compute<
|
|
16
16
|
ConfigParameter & {
|
|
17
17
|
mutation?: {
|
|
18
|
-
onSuccess?: (
|
|
19
|
-
|
|
18
|
+
onSuccess?: (
|
|
19
|
+
data: SignMessageReturnType,
|
|
20
|
+
variables: SignMessageParameters,
|
|
21
|
+
context: context,
|
|
22
|
+
) => void
|
|
23
|
+
onError?: (
|
|
24
|
+
error: SignMessageErrorType,
|
|
25
|
+
variables: SignMessageParameters,
|
|
26
|
+
context: context,
|
|
27
|
+
) => void
|
|
20
28
|
}
|
|
21
29
|
}
|
|
22
30
|
>
|
|
@@ -29,7 +37,9 @@ export type UseSignMessageReturnType<context = unknown> = Compute<
|
|
|
29
37
|
context
|
|
30
38
|
> & {
|
|
31
39
|
signMessage: (variables: SignMessageParameters) => void
|
|
32
|
-
signMessageAsync: (
|
|
40
|
+
signMessageAsync: (
|
|
41
|
+
variables: SignMessageParameters,
|
|
42
|
+
) => Promise<SignMessageReturnType>
|
|
33
43
|
}
|
|
34
44
|
>
|
|
35
45
|
|
|
@@ -43,12 +53,13 @@ export function useSignMessage<context = unknown>(
|
|
|
43
53
|
mutationFn: (variables: SignMessageParameters) =>
|
|
44
54
|
signMessage(config, variables),
|
|
45
55
|
...parameters.mutation,
|
|
46
|
-
})
|
|
56
|
+
} as any)
|
|
47
57
|
|
|
48
58
|
type Return = UseSignMessageReturnType<context>
|
|
49
59
|
return {
|
|
50
60
|
...(mutation as unknown as Return),
|
|
51
|
-
signMessage: mutation.mutate as Return['signMessage'],
|
|
52
|
-
signMessageAsync:
|
|
61
|
+
signMessage: mutation.mutate as unknown as Return['signMessage'],
|
|
62
|
+
signMessageAsync:
|
|
63
|
+
mutation.mutateAsync as unknown as Return['signMessageAsync'],
|
|
53
64
|
}
|
|
54
65
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { describe,
|
|
2
|
-
import { useSignTransaction } from './useSignTransaction
|
|
1
|
+
import { describe, expect, it } from 'vitest'
|
|
2
|
+
import { useSignTransaction } from './useSignTransaction'
|
|
3
3
|
|
|
4
4
|
describe('useSignTransaction', () => {
|
|
5
5
|
it('should be a function', () => {
|
|
@@ -1,22 +1,30 @@
|
|
|
1
1
|
'use client'
|
|
2
2
|
|
|
3
|
-
import { useMutation } from '@tanstack/react-query'
|
|
4
3
|
import {
|
|
4
|
+
type SignTransactionErrorType,
|
|
5
5
|
type SignTransactionParameters,
|
|
6
6
|
type SignTransactionReturnType,
|
|
7
|
-
type SignTransactionErrorType,
|
|
8
7
|
signTransaction,
|
|
9
8
|
} from '@growae/reactive'
|
|
10
9
|
import type { Compute } from '@growae/reactive'
|
|
11
|
-
import
|
|
12
|
-
import type {
|
|
13
|
-
import {
|
|
10
|
+
import { useMutation } from '@tanstack/react-query'
|
|
11
|
+
import type { ConfigParameter } from '../types/properties'
|
|
12
|
+
import type { UseMutationReturnType } from '../utils/query'
|
|
13
|
+
import { useConfig } from './useConfig'
|
|
14
14
|
|
|
15
15
|
export type UseSignTransactionParameters<context = unknown> = Compute<
|
|
16
16
|
ConfigParameter & {
|
|
17
17
|
mutation?: {
|
|
18
|
-
onSuccess?: (
|
|
19
|
-
|
|
18
|
+
onSuccess?: (
|
|
19
|
+
data: SignTransactionReturnType,
|
|
20
|
+
variables: SignTransactionParameters,
|
|
21
|
+
context: context,
|
|
22
|
+
) => void
|
|
23
|
+
onError?: (
|
|
24
|
+
error: SignTransactionErrorType,
|
|
25
|
+
variables: SignTransactionParameters,
|
|
26
|
+
context: context,
|
|
27
|
+
) => void
|
|
20
28
|
}
|
|
21
29
|
}
|
|
22
30
|
>
|
|
@@ -29,7 +37,9 @@ export type UseSignTransactionReturnType<context = unknown> = Compute<
|
|
|
29
37
|
context
|
|
30
38
|
> & {
|
|
31
39
|
signTransaction: (variables: SignTransactionParameters) => void
|
|
32
|
-
signTransactionAsync: (
|
|
40
|
+
signTransactionAsync: (
|
|
41
|
+
variables: SignTransactionParameters,
|
|
42
|
+
) => Promise<SignTransactionReturnType>
|
|
33
43
|
}
|
|
34
44
|
>
|
|
35
45
|
|
|
@@ -43,12 +53,13 @@ export function useSignTransaction<context = unknown>(
|
|
|
43
53
|
mutationFn: (variables: SignTransactionParameters) =>
|
|
44
54
|
signTransaction(config, variables),
|
|
45
55
|
...parameters.mutation,
|
|
46
|
-
})
|
|
56
|
+
} as any)
|
|
47
57
|
|
|
48
58
|
type Return = UseSignTransactionReturnType<context>
|
|
49
59
|
return {
|
|
50
60
|
...(mutation as unknown as Return),
|
|
51
|
-
signTransaction: mutation.mutate as Return['signTransaction'],
|
|
52
|
-
signTransactionAsync:
|
|
61
|
+
signTransaction: mutation.mutate as unknown as Return['signTransaction'],
|
|
62
|
+
signTransactionAsync:
|
|
63
|
+
mutation.mutateAsync as unknown as Return['signTransactionAsync'],
|
|
53
64
|
}
|
|
54
65
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { describe,
|
|
2
|
-
import { useSignTypedData } from './useSignTypedData
|
|
1
|
+
import { describe, expect, it } from 'vitest'
|
|
2
|
+
import { useSignTypedData } from './useSignTypedData'
|
|
3
3
|
|
|
4
4
|
describe('useSignTypedData', () => {
|
|
5
5
|
it('should be a function', () => {
|
|
@@ -1,22 +1,30 @@
|
|
|
1
1
|
'use client'
|
|
2
2
|
|
|
3
|
-
import { useMutation } from '@tanstack/react-query'
|
|
4
3
|
import {
|
|
4
|
+
type SignTypedDataErrorType,
|
|
5
5
|
type SignTypedDataParameters,
|
|
6
6
|
type SignTypedDataReturnType,
|
|
7
|
-
type SignTypedDataErrorType,
|
|
8
7
|
signTypedData,
|
|
9
8
|
} from '@growae/reactive'
|
|
10
9
|
import type { Compute } from '@growae/reactive'
|
|
11
|
-
import
|
|
12
|
-
import type {
|
|
13
|
-
import {
|
|
10
|
+
import { useMutation } from '@tanstack/react-query'
|
|
11
|
+
import type { ConfigParameter } from '../types/properties'
|
|
12
|
+
import type { UseMutationReturnType } from '../utils/query'
|
|
13
|
+
import { useConfig } from './useConfig'
|
|
14
14
|
|
|
15
15
|
export type UseSignTypedDataParameters<context = unknown> = Compute<
|
|
16
16
|
ConfigParameter & {
|
|
17
17
|
mutation?: {
|
|
18
|
-
onSuccess?: (
|
|
19
|
-
|
|
18
|
+
onSuccess?: (
|
|
19
|
+
data: SignTypedDataReturnType,
|
|
20
|
+
variables: SignTypedDataParameters,
|
|
21
|
+
context: context,
|
|
22
|
+
) => void
|
|
23
|
+
onError?: (
|
|
24
|
+
error: SignTypedDataErrorType,
|
|
25
|
+
variables: SignTypedDataParameters,
|
|
26
|
+
context: context,
|
|
27
|
+
) => void
|
|
20
28
|
}
|
|
21
29
|
}
|
|
22
30
|
>
|
|
@@ -29,7 +37,9 @@ export type UseSignTypedDataReturnType<context = unknown> = Compute<
|
|
|
29
37
|
context
|
|
30
38
|
> & {
|
|
31
39
|
signTypedData: (variables: SignTypedDataParameters) => void
|
|
32
|
-
signTypedDataAsync: (
|
|
40
|
+
signTypedDataAsync: (
|
|
41
|
+
variables: SignTypedDataParameters,
|
|
42
|
+
) => Promise<SignTypedDataReturnType>
|
|
33
43
|
}
|
|
34
44
|
>
|
|
35
45
|
|
|
@@ -43,12 +53,13 @@ export function useSignTypedData<context = unknown>(
|
|
|
43
53
|
mutationFn: (variables: SignTypedDataParameters) =>
|
|
44
54
|
signTypedData(config, variables),
|
|
45
55
|
...parameters.mutation,
|
|
46
|
-
})
|
|
56
|
+
} as any)
|
|
47
57
|
|
|
48
58
|
type Return = UseSignTypedDataReturnType<context>
|
|
49
59
|
return {
|
|
50
60
|
...(mutation as unknown as Return),
|
|
51
|
-
signTypedData: mutation.mutate as Return['signTypedData'],
|
|
52
|
-
signTypedDataAsync:
|
|
61
|
+
signTypedData: mutation.mutate as unknown as Return['signTypedData'],
|
|
62
|
+
signTypedDataAsync:
|
|
63
|
+
mutation.mutateAsync as unknown as Return['signTypedDataAsync'],
|
|
53
64
|
}
|
|
54
65
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { describe,
|
|
2
|
-
import { useSimulateContract } from './useSimulateContract
|
|
1
|
+
import { describe, expect, it } from 'vitest'
|
|
2
|
+
import { useSimulateContract } from './useSimulateContract'
|
|
3
3
|
|
|
4
4
|
describe('useSimulateContract', () => {
|
|
5
5
|
it('should be a function', () => {
|
|
@@ -6,10 +6,10 @@ import {
|
|
|
6
6
|
simulateContract,
|
|
7
7
|
} from '@growae/reactive'
|
|
8
8
|
import type { Compute } from '@growae/reactive'
|
|
9
|
-
import
|
|
10
|
-
import type
|
|
11
|
-
import { useConfig } from './useConfig
|
|
12
|
-
import { useNetworkId } from './useNetworkId
|
|
9
|
+
import type { ConfigParameter } from '../types/properties'
|
|
10
|
+
import { type UseQueryReturnType, useQuery } from '../utils/query'
|
|
11
|
+
import { useConfig } from './useConfig'
|
|
12
|
+
import { useNetworkId } from './useNetworkId'
|
|
13
13
|
|
|
14
14
|
export type UseSimulateContractParameters = Compute<
|
|
15
15
|
SimulateContractParameters & ConfigParameter & { enabled?: boolean }
|
|
@@ -27,17 +27,22 @@ export function useSimulateContract(
|
|
|
27
27
|
const networkId = useNetworkId({ config })
|
|
28
28
|
|
|
29
29
|
return useQuery({
|
|
30
|
-
queryKey: [
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
30
|
+
queryKey: [
|
|
31
|
+
'simulateContract',
|
|
32
|
+
{
|
|
33
|
+
address: parameters.address,
|
|
34
|
+
method: parameters.method,
|
|
35
|
+
args: parameters.args,
|
|
36
|
+
networkId: parameters.networkId ?? networkId,
|
|
37
|
+
},
|
|
38
|
+
],
|
|
39
|
+
queryFn: () =>
|
|
40
|
+
simulateContract(config, {
|
|
41
|
+
...parameters,
|
|
42
|
+
networkId: parameters.networkId ?? networkId,
|
|
43
|
+
}),
|
|
44
|
+
enabled:
|
|
45
|
+
Boolean(parameters.address && parameters.aci && parameters.method) &&
|
|
41
46
|
(parameters.enabled ?? true),
|
|
42
47
|
}) as UseSimulateContractReturnType
|
|
43
48
|
}
|
package/src/hooks/useSpend.ts
CHANGED
|
@@ -1,22 +1,30 @@
|
|
|
1
1
|
'use client'
|
|
2
2
|
|
|
3
|
-
import { useMutation } from '@tanstack/react-query'
|
|
4
3
|
import {
|
|
4
|
+
type SpendErrorType,
|
|
5
5
|
type SpendParameters,
|
|
6
6
|
type SpendReturnType,
|
|
7
|
-
type SpendErrorType,
|
|
8
7
|
spend,
|
|
9
8
|
} from '@growae/reactive'
|
|
10
9
|
import type { Compute } from '@growae/reactive'
|
|
11
|
-
import
|
|
12
|
-
import type {
|
|
13
|
-
import {
|
|
10
|
+
import { useMutation } from '@tanstack/react-query'
|
|
11
|
+
import type { ConfigParameter } from '../types/properties'
|
|
12
|
+
import type { UseMutationReturnType } from '../utils/query'
|
|
13
|
+
import { useConfig } from './useConfig'
|
|
14
14
|
|
|
15
15
|
export type UseSpendParameters<context = unknown> = Compute<
|
|
16
16
|
ConfigParameter & {
|
|
17
17
|
mutation?: {
|
|
18
|
-
onSuccess?: (
|
|
19
|
-
|
|
18
|
+
onSuccess?: (
|
|
19
|
+
data: SpendReturnType,
|
|
20
|
+
variables: SpendParameters,
|
|
21
|
+
context: context,
|
|
22
|
+
) => void
|
|
23
|
+
onError?: (
|
|
24
|
+
error: SpendErrorType,
|
|
25
|
+
variables: SpendParameters,
|
|
26
|
+
context: context,
|
|
27
|
+
) => void
|
|
20
28
|
}
|
|
21
29
|
}
|
|
22
30
|
>
|
|
@@ -42,12 +50,12 @@ export function useSpend<context = unknown>(
|
|
|
42
50
|
mutationKey: ['spend'],
|
|
43
51
|
mutationFn: (variables: SpendParameters) => spend(config, variables),
|
|
44
52
|
...parameters.mutation,
|
|
45
|
-
})
|
|
53
|
+
} as any)
|
|
46
54
|
|
|
47
55
|
type Return = UseSpendReturnType<context>
|
|
48
56
|
return {
|
|
49
57
|
...(mutation as unknown as Return),
|
|
50
|
-
spend: mutation.mutate as Return['spend'],
|
|
51
|
-
spendAsync: mutation.mutateAsync as Return['spendAsync'],
|
|
58
|
+
spend: mutation.mutate as unknown as Return['spend'],
|
|
59
|
+
spendAsync: mutation.mutateAsync as unknown as Return['spendAsync'],
|
|
52
60
|
}
|
|
53
61
|
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
type SwitchActiveAccountParameters,
|
|
5
|
+
switchActiveAccount,
|
|
6
|
+
} from '@growae/reactive'
|
|
7
|
+
import { useMutation } from '@tanstack/react-query'
|
|
8
|
+
import type { ConfigParameter } from '../types/properties'
|
|
9
|
+
import { useConfig } from './useConfig'
|
|
10
|
+
|
|
11
|
+
export type UseSwitchActiveAccountParameters = ConfigParameter
|
|
12
|
+
|
|
13
|
+
export type UseSwitchActiveAccountReturnType = {
|
|
14
|
+
switchActiveAccount: (params: SwitchActiveAccountParameters) => void
|
|
15
|
+
isPending: boolean
|
|
16
|
+
error: Error | null
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export function useSwitchActiveAccount(
|
|
20
|
+
parameters: UseSwitchActiveAccountParameters = {},
|
|
21
|
+
): UseSwitchActiveAccountReturnType {
|
|
22
|
+
const config = useConfig(parameters)
|
|
23
|
+
|
|
24
|
+
const mutation = useMutation({
|
|
25
|
+
mutationKey: ['switchActiveAccount'],
|
|
26
|
+
mutationFn: (params: SwitchActiveAccountParameters) => {
|
|
27
|
+
switchActiveAccount(config, params)
|
|
28
|
+
return Promise.resolve()
|
|
29
|
+
},
|
|
30
|
+
} as any)
|
|
31
|
+
|
|
32
|
+
return {
|
|
33
|
+
switchActiveAccount:
|
|
34
|
+
mutation.mutate as unknown as UseSwitchActiveAccountReturnType['switchActiveAccount'],
|
|
35
|
+
isPending: mutation.isPending,
|
|
36
|
+
error: mutation.error,
|
|
37
|
+
}
|
|
38
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { describe,
|
|
2
|
-
import { useSwitchNetwork } from './useSwitchNetwork
|
|
1
|
+
import { describe, expect, it } from 'vitest'
|
|
2
|
+
import { useSwitchNetwork } from './useSwitchNetwork'
|
|
3
3
|
|
|
4
4
|
describe('useSwitchNetwork', () => {
|
|
5
5
|
it('should be a function', () => {
|
|
@@ -1,23 +1,31 @@
|
|
|
1
1
|
'use client'
|
|
2
2
|
|
|
3
|
-
import { useMutation } from '@tanstack/react-query'
|
|
4
3
|
import {
|
|
4
|
+
type SwitchNetworkErrorType,
|
|
5
5
|
type SwitchNetworkParameters,
|
|
6
6
|
type SwitchNetworkReturnType,
|
|
7
|
-
type SwitchNetworkErrorType,
|
|
8
7
|
switchNetwork,
|
|
9
8
|
} from '@growae/reactive'
|
|
10
9
|
import type { Compute } from '@growae/reactive'
|
|
11
|
-
import
|
|
12
|
-
import type {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
10
|
+
import { useMutation } from '@tanstack/react-query'
|
|
11
|
+
import type { ConfigParameter } from '../types/properties'
|
|
12
|
+
import type { UseMutationReturnType } from '../utils/query'
|
|
13
|
+
import { useConfig } from './useConfig'
|
|
14
|
+
import { useNetworks } from './useNetworks'
|
|
15
15
|
|
|
16
16
|
export type UseSwitchNetworkParameters<context = unknown> = Compute<
|
|
17
17
|
ConfigParameter & {
|
|
18
18
|
mutation?: {
|
|
19
|
-
onSuccess?: (
|
|
20
|
-
|
|
19
|
+
onSuccess?: (
|
|
20
|
+
data: SwitchNetworkReturnType,
|
|
21
|
+
variables: SwitchNetworkParameters,
|
|
22
|
+
context: context,
|
|
23
|
+
) => void
|
|
24
|
+
onError?: (
|
|
25
|
+
error: SwitchNetworkErrorType,
|
|
26
|
+
variables: SwitchNetworkParameters,
|
|
27
|
+
context: context,
|
|
28
|
+
) => void
|
|
21
29
|
}
|
|
22
30
|
}
|
|
23
31
|
>
|
|
@@ -30,7 +38,9 @@ export type UseSwitchNetworkReturnType<context = unknown> = Compute<
|
|
|
30
38
|
context
|
|
31
39
|
> & {
|
|
32
40
|
switchNetwork: (variables: SwitchNetworkParameters) => void
|
|
33
|
-
switchNetworkAsync: (
|
|
41
|
+
switchNetworkAsync: (
|
|
42
|
+
variables: SwitchNetworkParameters,
|
|
43
|
+
) => Promise<SwitchNetworkReturnType>
|
|
34
44
|
networks: ReturnType<typeof useNetworks>
|
|
35
45
|
}
|
|
36
46
|
>
|
|
@@ -45,13 +55,14 @@ export function useSwitchNetwork<context = unknown>(
|
|
|
45
55
|
mutationFn: (variables: SwitchNetworkParameters) =>
|
|
46
56
|
switchNetwork(config, variables),
|
|
47
57
|
...parameters.mutation,
|
|
48
|
-
})
|
|
58
|
+
} as any)
|
|
49
59
|
|
|
50
60
|
type Return = UseSwitchNetworkReturnType<context>
|
|
51
61
|
return {
|
|
52
62
|
...(mutation as unknown as Return),
|
|
53
|
-
switchNetwork: mutation.mutate as Return['switchNetwork'],
|
|
54
|
-
switchNetworkAsync:
|
|
63
|
+
switchNetwork: mutation.mutate as unknown as Return['switchNetwork'],
|
|
64
|
+
switchNetworkAsync:
|
|
65
|
+
mutation.mutateAsync as unknown as Return['switchNetworkAsync'],
|
|
55
66
|
networks: useNetworks({ config }),
|
|
56
67
|
}
|
|
57
68
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { describe,
|
|
2
|
-
import { useTransaction } from './useTransaction
|
|
1
|
+
import { describe, expect, it } from 'vitest'
|
|
2
|
+
import { useTransaction } from './useTransaction'
|
|
3
3
|
|
|
4
4
|
describe('useTransaction', () => {
|
|
5
5
|
it('should be a function', () => {
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
'use client'
|
|
2
2
|
|
|
3
3
|
import {
|
|
4
|
+
type GetTransactionErrorType,
|
|
4
5
|
type GetTransactionParameters,
|
|
5
6
|
type GetTransactionReturnType,
|
|
6
|
-
type GetTransactionErrorType,
|
|
7
7
|
getTransaction,
|
|
8
8
|
} from '@growae/reactive'
|
|
9
9
|
import type { Compute } from '@growae/reactive'
|
|
10
|
-
import
|
|
11
|
-
import type
|
|
12
|
-
import { useConfig } from './useConfig
|
|
13
|
-
import { useNetworkId } from './useNetworkId
|
|
10
|
+
import type { ConfigParameter } from '../types/properties'
|
|
11
|
+
import { type UseQueryReturnType, useQuery } from '../utils/query'
|
|
12
|
+
import { useConfig } from './useConfig'
|
|
13
|
+
import { useNetworkId } from './useNetworkId'
|
|
14
14
|
|
|
15
15
|
export type UseTransactionParameters = Compute<
|
|
16
16
|
GetTransactionParameters & ConfigParameter & { enabled?: boolean }
|
|
@@ -28,14 +28,18 @@ export function useTransaction(
|
|
|
28
28
|
const networkId = useNetworkId({ config })
|
|
29
29
|
|
|
30
30
|
return useQuery({
|
|
31
|
-
queryKey: [
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
31
|
+
queryKey: [
|
|
32
|
+
'transaction',
|
|
33
|
+
{
|
|
34
|
+
hash: parameters.hash,
|
|
35
|
+
networkId: parameters.networkId ?? networkId,
|
|
36
|
+
},
|
|
37
|
+
],
|
|
38
|
+
queryFn: () =>
|
|
39
|
+
getTransaction(config, {
|
|
40
|
+
...parameters,
|
|
41
|
+
networkId: parameters.networkId ?? networkId,
|
|
42
|
+
}),
|
|
39
43
|
enabled: Boolean(parameters.hash) && (parameters.enabled ?? true),
|
|
40
44
|
}) as UseTransactionReturnType
|
|
41
45
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { describe,
|
|
2
|
-
import { useTransactionCount } from './useTransactionCount
|
|
1
|
+
import { describe, expect, it } from 'vitest'
|
|
2
|
+
import { useTransactionCount } from './useTransactionCount'
|
|
3
3
|
|
|
4
4
|
describe('useTransactionCount', () => {
|
|
5
5
|
it('should be a function', () => {
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
'use client'
|
|
2
2
|
|
|
3
3
|
import {
|
|
4
|
+
type GetTransactionCountErrorType,
|
|
4
5
|
type GetTransactionCountParameters,
|
|
5
6
|
type GetTransactionCountReturnType,
|
|
6
|
-
type GetTransactionCountErrorType,
|
|
7
7
|
getTransactionCount,
|
|
8
8
|
} from '@growae/reactive'
|
|
9
9
|
import type { Compute } from '@growae/reactive'
|
|
10
|
-
import
|
|
11
|
-
import type
|
|
12
|
-
import { useConfig } from './useConfig
|
|
13
|
-
import { useNetworkId } from './useNetworkId
|
|
10
|
+
import type { ConfigParameter } from '../types/properties'
|
|
11
|
+
import { type UseQueryReturnType, useQuery } from '../utils/query'
|
|
12
|
+
import { useConfig } from './useConfig'
|
|
13
|
+
import { useNetworkId } from './useNetworkId'
|
|
14
14
|
|
|
15
15
|
export type UseTransactionCountParameters = Compute<
|
|
16
16
|
GetTransactionCountParameters & ConfigParameter & { enabled?: boolean }
|
|
@@ -28,14 +28,18 @@ export function useTransactionCount(
|
|
|
28
28
|
const networkId = useNetworkId({ config })
|
|
29
29
|
|
|
30
30
|
return useQuery({
|
|
31
|
-
queryKey: [
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
31
|
+
queryKey: [
|
|
32
|
+
'transactionCount',
|
|
33
|
+
{
|
|
34
|
+
address: parameters.address,
|
|
35
|
+
networkId: parameters.networkId ?? networkId,
|
|
36
|
+
},
|
|
37
|
+
],
|
|
38
|
+
queryFn: () =>
|
|
39
|
+
getTransactionCount(config, {
|
|
40
|
+
...parameters,
|
|
41
|
+
networkId: parameters.networkId ?? networkId,
|
|
42
|
+
}),
|
|
39
43
|
enabled: Boolean(parameters.address) && (parameters.enabled ?? true),
|
|
40
44
|
}) as UseTransactionCountReturnType
|
|
41
45
|
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { describe, expect, it, vi } from 'vitest'
|
|
2
|
+
|
|
3
|
+
vi.mock('@tanstack/react-query', () => ({
|
|
4
|
+
useMutation: vi.fn(() => {
|
|
5
|
+
const state = {
|
|
6
|
+
data: undefined,
|
|
7
|
+
error: null,
|
|
8
|
+
isPending: false,
|
|
9
|
+
isSuccess: false,
|
|
10
|
+
isError: false,
|
|
11
|
+
status: 'idle' as const,
|
|
12
|
+
mutate: vi.fn(),
|
|
13
|
+
mutateAsync: vi.fn(),
|
|
14
|
+
reset: vi.fn(),
|
|
15
|
+
}
|
|
16
|
+
return state
|
|
17
|
+
}),
|
|
18
|
+
}))
|
|
19
|
+
|
|
20
|
+
vi.mock('./useConfig.js', () => ({
|
|
21
|
+
useConfig: vi.fn(() => ({})),
|
|
22
|
+
}))
|
|
23
|
+
|
|
24
|
+
import { useTransferFunds } from './useTransferFunds'
|
|
25
|
+
|
|
26
|
+
describe('useTransferFunds', () => {
|
|
27
|
+
it('should be a function', () => {
|
|
28
|
+
expect(typeof useTransferFunds).toBe('function')
|
|
29
|
+
})
|
|
30
|
+
|
|
31
|
+
it('should be exported', () => {
|
|
32
|
+
expect(useTransferFunds).toBeDefined()
|
|
33
|
+
})
|
|
34
|
+
|
|
35
|
+
it('should return mutation with convenience aliases', () => {
|
|
36
|
+
const result = useTransferFunds()
|
|
37
|
+
expect(result).toHaveProperty('transferFunds')
|
|
38
|
+
expect(result).toHaveProperty('transferFundsAsync')
|
|
39
|
+
expect(typeof result.transferFunds).toBe('function')
|
|
40
|
+
expect(typeof result.transferFundsAsync).toBe('function')
|
|
41
|
+
})
|
|
42
|
+
})
|