@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
package/src/hooks/useBlock.ts
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
'use client'
|
|
2
2
|
|
|
3
3
|
import {
|
|
4
|
+
type GetBlockErrorType,
|
|
4
5
|
type GetBlockParameters,
|
|
5
6
|
type GetBlockReturnType,
|
|
6
|
-
type GetBlockErrorType,
|
|
7
7
|
getBlock,
|
|
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 UseBlockParameters = Compute<
|
|
16
16
|
GetBlockParameters & ConfigParameter & { enabled?: boolean }
|
|
@@ -28,15 +28,19 @@ export function useBlock(
|
|
|
28
28
|
const networkId = useNetworkId({ config })
|
|
29
29
|
|
|
30
30
|
return useQuery({
|
|
31
|
-
queryKey: [
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
31
|
+
queryKey: [
|
|
32
|
+
'block',
|
|
33
|
+
{
|
|
34
|
+
height: parameters.height,
|
|
35
|
+
hash: parameters.hash,
|
|
36
|
+
networkId: parameters.networkId ?? networkId,
|
|
37
|
+
},
|
|
38
|
+
],
|
|
39
|
+
queryFn: () =>
|
|
40
|
+
getBlock(config, {
|
|
41
|
+
...parameters,
|
|
42
|
+
networkId: parameters.networkId ?? networkId,
|
|
43
|
+
}),
|
|
40
44
|
enabled: parameters.enabled ?? true,
|
|
41
45
|
}) as UseBlockReturnType
|
|
42
46
|
}
|
|
@@ -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 { useBuildTransaction } from './useBuildTransaction'
|
|
25
|
+
|
|
26
|
+
describe('useBuildTransaction', () => {
|
|
27
|
+
it('should be a function', () => {
|
|
28
|
+
expect(typeof useBuildTransaction).toBe('function')
|
|
29
|
+
})
|
|
30
|
+
|
|
31
|
+
it('should be exported', () => {
|
|
32
|
+
expect(useBuildTransaction).toBeDefined()
|
|
33
|
+
})
|
|
34
|
+
|
|
35
|
+
it('should return mutation with convenience aliases', () => {
|
|
36
|
+
const result = useBuildTransaction()
|
|
37
|
+
expect(result).toHaveProperty('buildTransaction')
|
|
38
|
+
expect(result).toHaveProperty('buildTransactionAsync')
|
|
39
|
+
expect(typeof result.buildTransaction).toBe('function')
|
|
40
|
+
expect(typeof result.buildTransactionAsync).toBe('function')
|
|
41
|
+
})
|
|
42
|
+
})
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
type BuildTransactionErrorType,
|
|
5
|
+
type BuildTransactionParameters,
|
|
6
|
+
type BuildTransactionReturnType,
|
|
7
|
+
buildTransaction,
|
|
8
|
+
} from '@growae/reactive'
|
|
9
|
+
import type { Compute } from '@growae/reactive'
|
|
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
|
+
|
|
15
|
+
export type UseBuildTransactionParameters<context = unknown> = Compute<
|
|
16
|
+
ConfigParameter & {
|
|
17
|
+
mutation?: {
|
|
18
|
+
onSuccess?: (
|
|
19
|
+
data: BuildTransactionReturnType,
|
|
20
|
+
variables: BuildTransactionParameters,
|
|
21
|
+
context: context,
|
|
22
|
+
) => void
|
|
23
|
+
onError?: (
|
|
24
|
+
error: BuildTransactionErrorType,
|
|
25
|
+
variables: BuildTransactionParameters,
|
|
26
|
+
context: context,
|
|
27
|
+
) => void
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
>
|
|
31
|
+
|
|
32
|
+
export type UseBuildTransactionReturnType<context = unknown> = Compute<
|
|
33
|
+
UseMutationReturnType<
|
|
34
|
+
BuildTransactionReturnType,
|
|
35
|
+
BuildTransactionErrorType,
|
|
36
|
+
BuildTransactionParameters,
|
|
37
|
+
context
|
|
38
|
+
> & {
|
|
39
|
+
buildTransaction: (variables: BuildTransactionParameters) => void
|
|
40
|
+
buildTransactionAsync: (
|
|
41
|
+
variables: BuildTransactionParameters,
|
|
42
|
+
) => Promise<BuildTransactionReturnType>
|
|
43
|
+
}
|
|
44
|
+
>
|
|
45
|
+
|
|
46
|
+
export function useBuildTransaction<context = unknown>(
|
|
47
|
+
parameters: UseBuildTransactionParameters<context> = {},
|
|
48
|
+
): UseBuildTransactionReturnType<context> {
|
|
49
|
+
const config = useConfig(parameters)
|
|
50
|
+
|
|
51
|
+
const mutation = useMutation({
|
|
52
|
+
mutationKey: ['buildTransaction'],
|
|
53
|
+
mutationFn: (variables: BuildTransactionParameters) =>
|
|
54
|
+
buildTransaction(config, variables),
|
|
55
|
+
...parameters.mutation,
|
|
56
|
+
} as any)
|
|
57
|
+
|
|
58
|
+
type Return = UseBuildTransactionReturnType<context>
|
|
59
|
+
return {
|
|
60
|
+
...(mutation as unknown as Return),
|
|
61
|
+
buildTransaction: mutation.mutate as unknown as Return['buildTransaction'],
|
|
62
|
+
buildTransactionAsync:
|
|
63
|
+
mutation.mutateAsync as unknown as Return['buildTransactionAsync'],
|
|
64
|
+
}
|
|
65
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { describe,
|
|
2
|
-
import { useCallContract } from './useCallContract
|
|
1
|
+
import { describe, expect, it } from 'vitest'
|
|
2
|
+
import { useCallContract } from './useCallContract'
|
|
3
3
|
|
|
4
4
|
describe('useCallContract', () => {
|
|
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 CallContractErrorType,
|
|
5
5
|
type CallContractParameters,
|
|
6
6
|
type CallContractReturnType,
|
|
7
|
-
type CallContractErrorType,
|
|
8
7
|
callContract,
|
|
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 UseCallContractParameters<context = unknown> = Compute<
|
|
16
16
|
ConfigParameter & {
|
|
17
17
|
mutation?: {
|
|
18
|
-
onSuccess?: (
|
|
19
|
-
|
|
18
|
+
onSuccess?: (
|
|
19
|
+
data: CallContractReturnType,
|
|
20
|
+
variables: CallContractParameters,
|
|
21
|
+
context: context,
|
|
22
|
+
) => void
|
|
23
|
+
onError?: (
|
|
24
|
+
error: CallContractErrorType,
|
|
25
|
+
variables: CallContractParameters,
|
|
26
|
+
context: context,
|
|
27
|
+
) => void
|
|
20
28
|
}
|
|
21
29
|
}
|
|
22
30
|
>
|
|
@@ -29,7 +37,9 @@ export type UseCallContractReturnType<context = unknown> = Compute<
|
|
|
29
37
|
context
|
|
30
38
|
> & {
|
|
31
39
|
callContract: (variables: CallContractParameters) => void
|
|
32
|
-
callContractAsync: (
|
|
40
|
+
callContractAsync: (
|
|
41
|
+
variables: CallContractParameters,
|
|
42
|
+
) => Promise<CallContractReturnType>
|
|
33
43
|
}
|
|
34
44
|
>
|
|
35
45
|
|
|
@@ -43,12 +53,13 @@ export function useCallContract<context = unknown>(
|
|
|
43
53
|
mutationFn: (variables: CallContractParameters) =>
|
|
44
54
|
callContract(config, variables),
|
|
45
55
|
...parameters.mutation,
|
|
46
|
-
})
|
|
56
|
+
} as any)
|
|
47
57
|
|
|
48
58
|
type Return = UseCallContractReturnType<context>
|
|
49
59
|
return {
|
|
50
60
|
...(mutation as unknown as Return),
|
|
51
|
-
callContract: mutation.mutate as Return['callContract'],
|
|
52
|
-
callContractAsync:
|
|
61
|
+
callContract: mutation.mutate as unknown as Return['callContract'],
|
|
62
|
+
callContractAsync:
|
|
63
|
+
mutation.mutateAsync as unknown as Return['callContractAsync'],
|
|
53
64
|
}
|
|
54
65
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { describe,
|
|
2
|
-
import { useChannelDeposit } from './useChannelDeposit
|
|
1
|
+
import { describe, expect, it } from 'vitest'
|
|
2
|
+
import { useChannelDeposit } from './useChannelDeposit'
|
|
3
3
|
|
|
4
4
|
describe('useChannelDeposit', () => {
|
|
5
5
|
it('should be a function', () => {
|
|
@@ -1,21 +1,29 @@
|
|
|
1
1
|
'use client'
|
|
2
2
|
|
|
3
|
-
import { useMutation } from '@tanstack/react-query'
|
|
4
3
|
import {
|
|
5
4
|
type ChannelDepositParameters,
|
|
6
5
|
type ChannelDepositReturnType,
|
|
7
6
|
channelDeposit,
|
|
8
7
|
} from '@growae/reactive'
|
|
9
8
|
import type { Compute } from '@growae/reactive'
|
|
10
|
-
import
|
|
11
|
-
import type {
|
|
12
|
-
import {
|
|
9
|
+
import { useMutation } from '@tanstack/react-query'
|
|
10
|
+
import type { ConfigParameter } from '../types/properties'
|
|
11
|
+
import type { UseMutationReturnType } from '../utils/query'
|
|
12
|
+
import { useConfig } from './useConfig'
|
|
13
13
|
|
|
14
14
|
export type UseChannelDepositParameters<context = unknown> = Compute<
|
|
15
15
|
ConfigParameter & {
|
|
16
16
|
mutation?: {
|
|
17
|
-
onSuccess?: (
|
|
18
|
-
|
|
17
|
+
onSuccess?: (
|
|
18
|
+
data: ChannelDepositReturnType,
|
|
19
|
+
variables: ChannelDepositParameters,
|
|
20
|
+
context: context,
|
|
21
|
+
) => void
|
|
22
|
+
onError?: (
|
|
23
|
+
error: Error,
|
|
24
|
+
variables: ChannelDepositParameters,
|
|
25
|
+
context: context,
|
|
26
|
+
) => void
|
|
19
27
|
}
|
|
20
28
|
}
|
|
21
29
|
>
|
|
@@ -28,7 +36,9 @@ export type UseChannelDepositReturnType<context = unknown> = Compute<
|
|
|
28
36
|
context
|
|
29
37
|
> & {
|
|
30
38
|
channelDeposit: (variables: ChannelDepositParameters) => void
|
|
31
|
-
channelDepositAsync: (
|
|
39
|
+
channelDepositAsync: (
|
|
40
|
+
variables: ChannelDepositParameters,
|
|
41
|
+
) => Promise<ChannelDepositReturnType>
|
|
32
42
|
}
|
|
33
43
|
>
|
|
34
44
|
|
|
@@ -42,12 +52,13 @@ export function useChannelDeposit<context = unknown>(
|
|
|
42
52
|
mutationFn: (variables: ChannelDepositParameters) =>
|
|
43
53
|
channelDeposit(config, variables),
|
|
44
54
|
...parameters.mutation,
|
|
45
|
-
})
|
|
55
|
+
} as any)
|
|
46
56
|
|
|
47
57
|
type Return = UseChannelDepositReturnType<context>
|
|
48
58
|
return {
|
|
49
59
|
...(mutation as unknown as Return),
|
|
50
|
-
channelDeposit: mutation.mutate as Return['channelDeposit'],
|
|
51
|
-
channelDepositAsync:
|
|
60
|
+
channelDeposit: mutation.mutate as unknown as Return['channelDeposit'],
|
|
61
|
+
channelDepositAsync:
|
|
62
|
+
mutation.mutateAsync as unknown as Return['channelDepositAsync'],
|
|
52
63
|
}
|
|
53
64
|
}
|
|
@@ -1,21 +1,29 @@
|
|
|
1
1
|
'use client'
|
|
2
2
|
|
|
3
|
-
import { useMutation } from '@tanstack/react-query'
|
|
4
3
|
import {
|
|
5
4
|
type ClaimNameParameters,
|
|
6
5
|
type ClaimNameReturnType,
|
|
7
6
|
claimName,
|
|
8
7
|
} from '@growae/reactive'
|
|
9
8
|
import type { Compute } from '@growae/reactive'
|
|
10
|
-
import
|
|
11
|
-
import type {
|
|
12
|
-
import {
|
|
9
|
+
import { useMutation } from '@tanstack/react-query'
|
|
10
|
+
import type { ConfigParameter } from '../types/properties'
|
|
11
|
+
import type { UseMutationReturnType } from '../utils/query'
|
|
12
|
+
import { useConfig } from './useConfig'
|
|
13
13
|
|
|
14
14
|
export type UseClaimNameParameters<context = unknown> = Compute<
|
|
15
15
|
ConfigParameter & {
|
|
16
16
|
mutation?: {
|
|
17
|
-
onSuccess?: (
|
|
18
|
-
|
|
17
|
+
onSuccess?: (
|
|
18
|
+
data: ClaimNameReturnType,
|
|
19
|
+
variables: ClaimNameParameters,
|
|
20
|
+
context: context,
|
|
21
|
+
) => void
|
|
22
|
+
onError?: (
|
|
23
|
+
error: Error,
|
|
24
|
+
variables: ClaimNameParameters,
|
|
25
|
+
context: context,
|
|
26
|
+
) => void
|
|
19
27
|
}
|
|
20
28
|
}
|
|
21
29
|
>
|
|
@@ -28,7 +36,9 @@ export type UseClaimNameReturnType<context = unknown> = Compute<
|
|
|
28
36
|
context
|
|
29
37
|
> & {
|
|
30
38
|
claimName: (variables: ClaimNameParameters) => void
|
|
31
|
-
claimNameAsync: (
|
|
39
|
+
claimNameAsync: (
|
|
40
|
+
variables: ClaimNameParameters,
|
|
41
|
+
) => Promise<ClaimNameReturnType>
|
|
32
42
|
}
|
|
33
43
|
>
|
|
34
44
|
|
|
@@ -42,12 +52,12 @@ export function useClaimName<context = unknown>(
|
|
|
42
52
|
mutationFn: (variables: ClaimNameParameters) =>
|
|
43
53
|
claimName(config, variables),
|
|
44
54
|
...parameters.mutation,
|
|
45
|
-
})
|
|
55
|
+
} as any)
|
|
46
56
|
|
|
47
57
|
type Return = UseClaimNameReturnType<context>
|
|
48
58
|
return {
|
|
49
59
|
...(mutation as unknown as Return),
|
|
50
|
-
claimName: mutation.mutate as Return['claimName'],
|
|
51
|
-
claimNameAsync: mutation.mutateAsync as Return['claimNameAsync'],
|
|
60
|
+
claimName: mutation.mutate as unknown as Return['claimName'],
|
|
61
|
+
claimNameAsync: mutation.mutateAsync as unknown as Return['claimNameAsync'],
|
|
52
62
|
}
|
|
53
63
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { describe,
|
|
2
|
-
import { useCloseChannel } from './useCloseChannel
|
|
1
|
+
import { describe, expect, it } from 'vitest'
|
|
2
|
+
import { useCloseChannel } from './useCloseChannel'
|
|
3
3
|
|
|
4
4
|
describe('useCloseChannel', () => {
|
|
5
5
|
it('should be a function', () => {
|
|
@@ -1,21 +1,29 @@
|
|
|
1
1
|
'use client'
|
|
2
2
|
|
|
3
|
-
import { useMutation } from '@tanstack/react-query'
|
|
4
3
|
import {
|
|
5
4
|
type CloseChannelParameters,
|
|
6
5
|
type CloseChannelReturnType,
|
|
7
6
|
closeChannel,
|
|
8
7
|
} from '@growae/reactive'
|
|
9
8
|
import type { Compute } from '@growae/reactive'
|
|
10
|
-
import
|
|
11
|
-
import type {
|
|
12
|
-
import {
|
|
9
|
+
import { useMutation } from '@tanstack/react-query'
|
|
10
|
+
import type { ConfigParameter } from '../types/properties'
|
|
11
|
+
import type { UseMutationReturnType } from '../utils/query'
|
|
12
|
+
import { useConfig } from './useConfig'
|
|
13
13
|
|
|
14
14
|
export type UseCloseChannelParameters<context = unknown> = Compute<
|
|
15
15
|
ConfigParameter & {
|
|
16
16
|
mutation?: {
|
|
17
|
-
onSuccess?: (
|
|
18
|
-
|
|
17
|
+
onSuccess?: (
|
|
18
|
+
data: CloseChannelReturnType,
|
|
19
|
+
variables: CloseChannelParameters,
|
|
20
|
+
context: context,
|
|
21
|
+
) => void
|
|
22
|
+
onError?: (
|
|
23
|
+
error: Error,
|
|
24
|
+
variables: CloseChannelParameters,
|
|
25
|
+
context: context,
|
|
26
|
+
) => void
|
|
19
27
|
}
|
|
20
28
|
}
|
|
21
29
|
>
|
|
@@ -28,7 +36,9 @@ export type UseCloseChannelReturnType<context = unknown> = Compute<
|
|
|
28
36
|
context
|
|
29
37
|
> & {
|
|
30
38
|
closeChannel: (variables: CloseChannelParameters) => void
|
|
31
|
-
closeChannelAsync: (
|
|
39
|
+
closeChannelAsync: (
|
|
40
|
+
variables: CloseChannelParameters,
|
|
41
|
+
) => Promise<CloseChannelReturnType>
|
|
32
42
|
}
|
|
33
43
|
>
|
|
34
44
|
|
|
@@ -42,12 +52,13 @@ export function useCloseChannel<context = unknown>(
|
|
|
42
52
|
mutationFn: (variables: CloseChannelParameters) =>
|
|
43
53
|
closeChannel(config, variables),
|
|
44
54
|
...parameters.mutation,
|
|
45
|
-
})
|
|
55
|
+
} as any)
|
|
46
56
|
|
|
47
57
|
type Return = UseCloseChannelReturnType<context>
|
|
48
58
|
return {
|
|
49
59
|
...(mutation as unknown as Return),
|
|
50
|
-
closeChannel: mutation.mutate as Return['closeChannel'],
|
|
51
|
-
closeChannelAsync:
|
|
60
|
+
closeChannel: mutation.mutate as unknown as Return['closeChannel'],
|
|
61
|
+
closeChannelAsync:
|
|
62
|
+
mutation.mutateAsync as unknown as Return['closeChannelAsync'],
|
|
52
63
|
}
|
|
53
64
|
}
|
|
@@ -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 { useCompileContract } from './useCompileContract'
|
|
25
|
+
|
|
26
|
+
describe('useCompileContract', () => {
|
|
27
|
+
it('should be a function', () => {
|
|
28
|
+
expect(typeof useCompileContract).toBe('function')
|
|
29
|
+
})
|
|
30
|
+
|
|
31
|
+
it('should be exported', () => {
|
|
32
|
+
expect(useCompileContract).toBeDefined()
|
|
33
|
+
})
|
|
34
|
+
|
|
35
|
+
it('should return mutation with convenience aliases', () => {
|
|
36
|
+
const result = useCompileContract()
|
|
37
|
+
expect(result).toHaveProperty('compileContract')
|
|
38
|
+
expect(result).toHaveProperty('compileContractAsync')
|
|
39
|
+
expect(typeof result.compileContract).toBe('function')
|
|
40
|
+
expect(typeof result.compileContractAsync).toBe('function')
|
|
41
|
+
})
|
|
42
|
+
})
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
type CompileContractErrorType,
|
|
5
|
+
type CompileContractParameters,
|
|
6
|
+
type CompileContractReturnType,
|
|
7
|
+
compileContract,
|
|
8
|
+
} from '@growae/reactive'
|
|
9
|
+
import type { Compute } from '@growae/reactive'
|
|
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
|
+
|
|
15
|
+
export type UseCompileContractParameters<context = unknown> = Compute<
|
|
16
|
+
ConfigParameter & {
|
|
17
|
+
mutation?: {
|
|
18
|
+
onSuccess?: (
|
|
19
|
+
data: CompileContractReturnType,
|
|
20
|
+
variables: CompileContractParameters,
|
|
21
|
+
context: context,
|
|
22
|
+
) => void
|
|
23
|
+
onError?: (
|
|
24
|
+
error: CompileContractErrorType,
|
|
25
|
+
variables: CompileContractParameters,
|
|
26
|
+
context: context,
|
|
27
|
+
) => void
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
>
|
|
31
|
+
|
|
32
|
+
export type UseCompileContractReturnType<context = unknown> = Compute<
|
|
33
|
+
UseMutationReturnType<
|
|
34
|
+
CompileContractReturnType,
|
|
35
|
+
CompileContractErrorType,
|
|
36
|
+
CompileContractParameters,
|
|
37
|
+
context
|
|
38
|
+
> & {
|
|
39
|
+
compileContract: (variables: CompileContractParameters) => void
|
|
40
|
+
compileContractAsync: (
|
|
41
|
+
variables: CompileContractParameters,
|
|
42
|
+
) => Promise<CompileContractReturnType>
|
|
43
|
+
}
|
|
44
|
+
>
|
|
45
|
+
|
|
46
|
+
export function useCompileContract<context = unknown>(
|
|
47
|
+
parameters: UseCompileContractParameters<context> = {},
|
|
48
|
+
): UseCompileContractReturnType<context> {
|
|
49
|
+
const config = useConfig(parameters)
|
|
50
|
+
|
|
51
|
+
const mutation = useMutation({
|
|
52
|
+
mutationKey: ['compileContract'],
|
|
53
|
+
mutationFn: (variables: CompileContractParameters) =>
|
|
54
|
+
compileContract(config, variables),
|
|
55
|
+
...parameters.mutation,
|
|
56
|
+
} as any)
|
|
57
|
+
|
|
58
|
+
type Return = UseCompileContractReturnType<context>
|
|
59
|
+
return {
|
|
60
|
+
...(mutation as unknown as Return),
|
|
61
|
+
compileContract: mutation.mutate as unknown as Return['compileContract'],
|
|
62
|
+
compileContractAsync:
|
|
63
|
+
mutation.mutateAsync as unknown as Return['compileContractAsync'],
|
|
64
|
+
}
|
|
65
|
+
}
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
// @vitest-environment jsdom
|
|
2
|
-
import { describe,
|
|
2
|
+
import { describe, expect, it, vi } from 'vitest'
|
|
3
3
|
|
|
4
4
|
vi.mock('@aeternity/aepp-sdk', () => ({
|
|
5
5
|
Node: vi.fn().mockImplementation(() => ({})),
|
|
6
6
|
}))
|
|
7
7
|
|
|
8
|
-
import { createElement } from 'react'
|
|
9
|
-
import { renderHook } from '@testing-library/react'
|
|
10
|
-
import { useConfig } from './useConfig.js'
|
|
11
|
-
import { ReactiveProvider } from '../context.js'
|
|
12
8
|
import { createConfig } from '@growae/reactive'
|
|
13
9
|
import { testnet } from '@growae/reactive'
|
|
14
10
|
import { mock } from '@growae/reactive'
|
|
11
|
+
import { renderHook } from '@testing-library/react'
|
|
12
|
+
import { createElement } from 'react'
|
|
13
|
+
import { ReactiveProvider } from '../context'
|
|
14
|
+
import { useConfig } from './useConfig'
|
|
15
15
|
|
|
16
16
|
const TEST_ACCOUNTS = [
|
|
17
17
|
'ak_2swhLkgBPeeADxVTABy7tt6d2HgBQFnGJELkBUMY4FUa8RVLM',
|
package/src/hooks/useConfig.ts
CHANGED
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
import type { Config } from '@growae/reactive'
|
|
4
4
|
import { useContext } from 'react'
|
|
5
|
-
import { ReactiveContext } from '../context
|
|
6
|
-
import { ReactiveProviderNotFoundError } from '../errors/context
|
|
7
|
-
import type { ConfigParameter } from '../types/properties
|
|
5
|
+
import { ReactiveContext } from '../context'
|
|
6
|
+
import { ReactiveProviderNotFoundError } from '../errors/context'
|
|
7
|
+
import type { ConfigParameter } from '../types/properties'
|
|
8
8
|
|
|
9
9
|
export type UseConfigParameters<config extends Config = Config> =
|
|
10
10
|
ConfigParameter<config>
|
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
// @vitest-environment jsdom
|
|
2
|
-
import { describe,
|
|
2
|
+
import { describe, expect, it, vi } from 'vitest'
|
|
3
3
|
|
|
4
4
|
vi.mock('@aeternity/aepp-sdk', () => ({
|
|
5
5
|
Node: vi.fn().mockImplementation(() => ({})),
|
|
6
6
|
}))
|
|
7
7
|
|
|
8
|
-
import { createElement } from 'react'
|
|
9
|
-
import { renderHook } from '@testing-library/react'
|
|
10
|
-
import { QueryClient, QueryClientProvider } from '@tanstack/react-query'
|
|
11
|
-
import { useConnect } from './useConnect.js'
|
|
12
|
-
import { ReactiveProvider } from '../context.js'
|
|
13
8
|
import { createConfig } from '@growae/reactive'
|
|
14
9
|
import { testnet } from '@growae/reactive'
|
|
15
10
|
import { mock } from '@growae/reactive'
|
|
11
|
+
import { QueryClient, QueryClientProvider } from '@tanstack/react-query'
|
|
12
|
+
import { renderHook } from '@testing-library/react'
|
|
13
|
+
import { createElement } from 'react'
|
|
14
|
+
import { ReactiveProvider } from '../context'
|
|
15
|
+
import { useConnect } from './useConnect'
|
|
16
16
|
|
|
17
17
|
const TEST_ACCOUNTS = [
|
|
18
18
|
'ak_2swhLkgBPeeADxVTABy7tt6d2HgBQFnGJELkBUMY4FUa8RVLM',
|