@0xsquid/react-hooks 6.4.4-beta.4 → 6.4.4-stellar-beta.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/core/client/index.d.ts +17 -0
- package/dist/core/client/index.js +40 -0
- package/dist/core/client/index.js.map +1 -0
- package/dist/core/connectors/bitcoin/helpers.d.ts +15 -0
- package/dist/core/connectors/bitcoin/helpers.js +6 -1
- package/dist/core/connectors/bitcoin/helpers.js.map +1 -1
- package/dist/core/connectors/bitcoin/wallets/index.d.ts +1 -0
- package/dist/core/connectors/bitcoin/wallets/index.js +1 -0
- package/dist/core/connectors/bitcoin/wallets/index.js.map +1 -1
- package/dist/core/connectors/bitcoin/wallets/keplr.d.ts +11 -0
- package/dist/core/connectors/bitcoin/wallets/keplr.js +28 -0
- package/dist/core/connectors/bitcoin/wallets/keplr.js.map +1 -0
- package/dist/core/connectors/xrpl/CrossMark.d.ts +13 -0
- package/dist/core/connectors/{xrp → xrpl}/CrossMark.js +11 -11
- package/dist/core/connectors/xrpl/CrossMark.js.map +1 -0
- package/dist/core/connectors/xrpl/Xaman.d.ts +16 -0
- package/dist/core/connectors/xrpl/Xaman.js +80 -0
- package/dist/core/connectors/xrpl/Xaman.js.map +1 -0
- package/dist/core/connectors/xrpl/XamanQr.d.ts +15 -0
- package/dist/core/connectors/xrpl/XamanQr.js +78 -0
- package/dist/core/connectors/xrpl/XamanQr.js.map +1 -0
- package/dist/core/connectors/{xrp/XrpMetamaskSnap.d.ts → xrpl/XrplMetamaskSnap.d.ts} +7 -16
- package/dist/core/connectors/{xrp/XrpMetamaskSnap.js → xrpl/XrplMetamaskSnap.js} +22 -57
- package/dist/core/connectors/xrpl/XrplMetamaskSnap.js.map +1 -0
- package/dist/core/constants.d.ts +14 -22
- package/dist/core/constants.js +43 -41
- package/dist/core/constants.js.map +1 -1
- package/dist/core/externalLinks.d.ts +1 -1
- package/dist/core/externalLinks.js +1 -1
- package/dist/core/index.d.ts +1 -1
- package/dist/core/index.js +1 -1
- package/dist/core/index.js.map +1 -1
- package/dist/core/multicall3.d.ts +5 -1
- package/dist/core/multicall3.js +21 -1
- package/dist/core/multicall3.js.map +1 -1
- package/dist/core/providers/SolanaProvider.d.ts +0 -2
- package/dist/core/providers/SolanaProvider.js.map +1 -1
- package/dist/core/providers/StellarProvider.d.ts +19 -0
- package/dist/core/providers/StellarProvider.js +15 -0
- package/dist/core/providers/StellarProvider.js.map +1 -0
- package/dist/core/providers/SuiProvider.d.ts +19 -0
- package/dist/core/providers/SuiProvider.js +15 -0
- package/dist/core/providers/SuiProvider.js.map +1 -0
- package/dist/core/providers/XrplProvider.d.ts +17 -0
- package/dist/core/providers/XrplProvider.js +15 -0
- package/dist/core/providers/XrplProvider.js.map +1 -0
- package/dist/core/queries/queries-keys.d.ts +25 -30
- package/dist/core/queries/queries-keys.js +76 -86
- package/dist/core/queries/queries-keys.js.map +1 -1
- package/dist/core/stellar-test.d.ts +1 -0
- package/dist/core/stellar-test.js +11 -0
- package/dist/core/stellar-test.js.map +1 -0
- package/dist/core/types/config.d.ts +2 -0
- package/dist/core/types/error.d.ts +4 -3
- package/dist/core/types/error.js.map +1 -1
- package/dist/core/types/event.d.ts +31 -1
- package/dist/core/types/history.d.ts +84 -0
- package/dist/core/types/history.js +7 -0
- package/dist/core/types/history.js.map +1 -0
- package/dist/core/types/index.d.ts +5 -2
- package/dist/core/types/index.js +2 -1
- package/dist/core/types/index.js.map +1 -1
- package/dist/core/types/onramps/index.d.ts +2 -0
- package/dist/core/types/onramps/index.js +3 -0
- package/dist/core/types/onramps/index.js.map +1 -0
- package/dist/core/types/onramps/onramp.d.ts +157 -0
- package/dist/core/types/onramps/onramp.js +2 -0
- package/dist/core/types/onramps/onramp.js.map +1 -0
- package/dist/core/types/onramps/revolut.d.ts +92 -0
- package/dist/core/types/onramps/revolut.js +2 -0
- package/dist/core/types/onramps/revolut.js.map +1 -0
- package/dist/core/types/rpc.d.ts +10 -0
- package/dist/core/types/rpc.js +2 -0
- package/dist/core/types/rpc.js.map +1 -0
- package/dist/core/types/stellar.d.ts +3 -0
- package/dist/core/types/stellar.js +2 -0
- package/dist/core/types/stellar.js.map +1 -0
- package/dist/core/types/sui.d.ts +14 -0
- package/dist/core/types/sui.js +2 -0
- package/dist/core/types/sui.js.map +1 -0
- package/dist/core/types/transaction.d.ts +10 -30
- package/dist/core/types/transaction.js +6 -0
- package/dist/core/types/transaction.js.map +1 -1
- package/dist/core/types/wallet.d.ts +34 -20
- package/dist/core/types/wallet.js +3 -1
- package/dist/core/types/wallet.js.map +1 -1
- package/dist/core/types/xrpl.d.ts +70 -0
- package/dist/core/types/xrpl.js +20 -0
- package/dist/core/types/xrpl.js.map +1 -0
- package/dist/core/wagmiConfig.js +2 -8
- package/dist/core/wagmiConfig.js.map +1 -1
- package/dist/core/wallets.d.ts +2 -1
- package/dist/core/wallets.js +61 -45
- package/dist/core/wallets.js.map +1 -1
- package/dist/hooks/analytics/useTrackSearchEmpty.d.ts +12 -0
- package/dist/hooks/analytics/useTrackSearchEmpty.js +22 -0
- package/dist/hooks/analytics/useTrackSearchEmpty.js.map +1 -0
- package/dist/hooks/chains/useSquidChains.d.ts +1 -0
- package/dist/hooks/chains/useSquidChains.js +22 -3
- package/dist/hooks/chains/useSquidChains.js.map +1 -1
- package/dist/hooks/client/useClient.d.ts +2 -0
- package/dist/hooks/client/useClient.js +58 -1
- package/dist/hooks/client/useClient.js.map +1 -1
- package/dist/hooks/cosmos/useCosmos.d.ts +9 -0
- package/dist/hooks/cosmos/useCosmos.js +49 -39
- package/dist/hooks/cosmos/useCosmos.js.map +1 -1
- package/dist/hooks/cosmos/useCosmosForChain.d.ts +1 -1
- package/dist/hooks/cosmos/useCosmosForChain.js +20 -13
- package/dist/hooks/cosmos/useCosmosForChain.js.map +1 -1
- package/dist/hooks/index.d.ts +10 -3
- package/dist/hooks/index.js +10 -4
- package/dist/hooks/index.js.map +1 -1
- package/dist/hooks/onramp/useFiatToCrypto.d.ts +84 -0
- package/dist/hooks/onramp/useFiatToCrypto.js +316 -0
- package/dist/hooks/onramp/useFiatToCrypto.js.map +1 -0
- package/dist/hooks/solana/useSolana.d.ts +2 -1
- package/dist/hooks/solana/useSolana.js +12 -4
- package/dist/hooks/solana/useSolana.js.map +1 -1
- package/dist/hooks/squid/useSquid.js +1 -1
- package/dist/hooks/squid/useSquid.js.map +1 -1
- package/dist/hooks/stellar/useStellar.d.ts +2 -0
- package/dist/hooks/stellar/useStellar.js +27 -0
- package/dist/hooks/stellar/useStellar.js.map +1 -0
- package/dist/hooks/stellar/useStellarWallets.d.ts +4 -0
- package/dist/hooks/stellar/useStellarWallets.js +12 -0
- package/dist/hooks/stellar/useStellarWallets.js.map +1 -0
- package/dist/hooks/store/useAddressBookStore.d.ts +1 -1
- package/dist/hooks/store/useAddressBookStore.js +6 -2
- package/dist/hooks/store/useAddressBookStore.js.map +1 -1
- package/dist/hooks/store/useHistoryStore.d.ts +33 -13
- package/dist/hooks/store/useHistoryStore.js +120 -32
- package/dist/hooks/store/useHistoryStore.js.map +1 -1
- package/dist/hooks/store/useSendTransactionStore.d.ts +20 -0
- package/dist/hooks/store/useSendTransactionStore.js +21 -0
- package/dist/hooks/store/useSendTransactionStore.js.map +1 -0
- package/dist/hooks/store/useSquidStore.d.ts +0 -5
- package/dist/hooks/store/useSquidStore.js +0 -2
- package/dist/hooks/store/useSquidStore.js.map +1 -1
- package/dist/hooks/store/useWalletStore.d.ts +8 -5
- package/dist/hooks/store/useWalletStore.js +9 -15
- package/dist/hooks/store/useWalletStore.js.map +1 -1
- package/dist/hooks/sui/useSui.d.ts +2 -0
- package/dist/hooks/sui/useSui.js +28 -0
- package/dist/hooks/sui/useSui.js.map +1 -0
- package/dist/hooks/sui/useSuiWallets.d.ts +7 -0
- package/dist/hooks/sui/useSuiWallets.js +42 -0
- package/dist/hooks/sui/useSuiWallets.js.map +1 -0
- package/dist/hooks/swap/useSwap.d.ts +1 -0
- package/dist/hooks/swap/useSwap.js +4 -16
- package/dist/hooks/swap/useSwap.js.map +1 -1
- package/dist/hooks/tokens/useAllConnectedWalletBalances.d.ts +1 -1
- package/dist/hooks/tokens/useAllConnectedWalletBalances.js +28 -6
- package/dist/hooks/tokens/useAllConnectedWalletBalances.js.map +1 -1
- package/dist/hooks/tokens/useAllTokensWithBalanceForChainType.d.ts +1 -1
- package/dist/hooks/tokens/useAllTokensWithBalanceForChainType.js +34 -17
- package/dist/hooks/tokens/useAllTokensWithBalanceForChainType.js.map +1 -1
- package/dist/hooks/tokens/useBalance.d.ts +3 -1
- package/dist/hooks/tokens/useBalance.js +49 -8
- package/dist/hooks/tokens/useBalance.js.map +1 -1
- package/dist/hooks/tokens/useMultiChainBalance.js +24 -6
- package/dist/hooks/tokens/useMultiChainBalance.js.map +1 -1
- package/dist/hooks/tokens/useNativeBalance.d.ts +3 -1
- package/dist/hooks/tokens/useNativeBalance.js +72 -10
- package/dist/hooks/tokens/useNativeBalance.js.map +1 -1
- package/dist/hooks/tokens/useNativeTokenForChain.js +7 -3
- package/dist/hooks/tokens/useNativeTokenForChain.js.map +1 -1
- package/dist/hooks/tokens/useSquidTokens.d.ts +3 -1
- package/dist/hooks/tokens/useSquidTokens.js +15 -5
- package/dist/hooks/tokens/useSquidTokens.js.map +1 -1
- package/dist/hooks/transaction/send/useEstimateSendTransactionGas.d.ts +28 -0
- package/dist/hooks/transaction/send/useEstimateSendTransactionGas.js +58 -0
- package/dist/hooks/transaction/send/useEstimateSendTransactionGas.js.map +1 -0
- package/dist/hooks/transaction/send/useSendTransaction.d.ts +13 -0
- package/dist/hooks/transaction/send/useSendTransaction.js +256 -0
- package/dist/hooks/transaction/send/useSendTransaction.js.map +1 -0
- package/dist/hooks/transaction/send/useSendTransactionGas.d.ts +6 -0
- package/dist/hooks/transaction/send/useSendTransactionGas.js +73 -0
- package/dist/hooks/transaction/send/useSendTransactionGas.js.map +1 -0
- package/dist/hooks/transaction/useAllTransactionsStatus.d.ts +34 -2
- package/dist/hooks/transaction/useAllTransactionsStatus.js +119 -62
- package/dist/hooks/transaction/useAllTransactionsStatus.js.map +1 -1
- package/dist/hooks/transaction/useApproval.js +3 -3
- package/dist/hooks/transaction/useApproval.js.map +1 -1
- package/dist/hooks/transaction/useEstimate.d.ts +1 -1
- package/dist/hooks/transaction/useExecuteTransaction.d.ts +1 -0
- package/dist/hooks/transaction/useExecuteTransaction.js +175 -99
- package/dist/hooks/transaction/useExecuteTransaction.js.map +1 -1
- package/dist/hooks/transaction/useGetRoute.d.ts +13 -7
- package/dist/hooks/transaction/useGetRoute.js +17 -151
- package/dist/hooks/transaction/useGetRoute.js.map +1 -1
- package/dist/hooks/transaction/useSendTransactionStatus.d.ts +11 -0
- package/dist/hooks/transaction/useSendTransactionStatus.js +63 -0
- package/dist/hooks/transaction/useSendTransactionStatus.js.map +1 -0
- package/dist/hooks/transaction/useSwapTransactionStatus.d.ts +15 -0
- package/dist/hooks/transaction/{useSingleTransaction.js → useSwapTransactionStatus.js} +40 -18
- package/dist/hooks/transaction/useSwapTransactionStatus.js.map +1 -0
- package/dist/hooks/user/useAvatar.js +13 -7
- package/dist/hooks/user/useAvatar.js.map +1 -1
- package/dist/hooks/user/useHistory.d.ts +12 -10
- package/dist/hooks/user/useHistory.js +49 -51
- package/dist/hooks/user/useHistory.js.map +1 -1
- package/dist/hooks/utils/useUtils.d.ts +7 -0
- package/dist/hooks/utils/useUtils.js +20 -0
- package/dist/hooks/utils/useUtils.js.map +1 -0
- package/dist/hooks/wallet/useEns.d.ts +0 -1
- package/dist/hooks/wallet/useEns.js +1 -13
- package/dist/hooks/wallet/useEns.js.map +1 -1
- package/dist/hooks/wallet/useGnosisContext.js +7 -11
- package/dist/hooks/wallet/useGnosisContext.js.map +1 -1
- package/dist/hooks/wallet/useMultiChainWallet.d.ts +4 -0
- package/dist/hooks/wallet/useMultiChainWallet.js +53 -6
- package/dist/hooks/wallet/useMultiChainWallet.js.map +1 -1
- package/dist/hooks/wallet/useSigner.d.ts +9 -6
- package/dist/hooks/wallet/useSigner.js +41 -22
- package/dist/hooks/wallet/useSigner.js.map +1 -1
- package/dist/hooks/wallet/useWallet.d.ts +64 -7
- package/dist/hooks/wallet/useWallet.js +58 -10
- package/dist/hooks/wallet/useWallet.js.map +1 -1
- package/dist/hooks/wallet/useWallets.d.ts +31 -1
- package/dist/hooks/wallet/useWallets.js +35 -1
- package/dist/hooks/wallet/useWallets.js.map +1 -1
- package/dist/hooks/xrpl/useXrpl.d.ts +2 -0
- package/dist/hooks/xrpl/useXrpl.js +21 -0
- package/dist/hooks/xrpl/useXrpl.js.map +1 -0
- package/dist/hooks/xrpl/useXrplTrustLine.d.ts +17 -0
- package/dist/hooks/xrpl/useXrplTrustLine.js +136 -0
- package/dist/hooks/xrpl/useXrplTrustLine.js.map +1 -0
- package/dist/hooks/xrpl/useXrplWallets.d.ts +4 -0
- package/dist/hooks/xrpl/useXrplWallets.js +46 -0
- package/dist/hooks/xrpl/useXrplWallets.js.map +1 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/provider/index.js +9 -4
- package/dist/provider/index.js.map +1 -1
- package/dist/services/external/cosmosRestClient.d.ts +18 -0
- package/dist/services/external/cosmosRestClient.js +45 -0
- package/dist/services/external/cosmosRestClient.js.map +1 -0
- package/dist/services/external/index.d.ts +1 -0
- package/dist/services/external/index.js +2 -0
- package/dist/services/external/index.js.map +1 -0
- package/dist/services/external/onrampAdapter.d.ts +12 -0
- package/dist/services/external/onrampAdapter.js +41 -0
- package/dist/services/external/onrampAdapter.js.map +1 -0
- package/dist/services/external/rpcService.d.ts +13 -8
- package/dist/services/external/rpcService.js +58 -69
- package/dist/services/external/rpcService.js.map +1 -1
- package/dist/services/external/suiRpcClient.d.ts +32 -0
- package/dist/services/external/suiRpcClient.js +80 -0
- package/dist/services/external/suiRpcClient.js.map +1 -0
- package/dist/services/external/websocket.d.ts +6 -0
- package/dist/services/external/websocket.js +34 -0
- package/dist/services/external/websocket.js.map +1 -0
- package/dist/services/external/xaman.d.ts +30 -0
- package/dist/services/external/xaman.js +46 -0
- package/dist/services/external/xaman.js.map +1 -0
- package/dist/services/external/xrplRpcClient.d.ts +11 -11
- package/dist/services/external/xrplRpcClient.js +46 -55
- package/dist/services/external/xrplRpcClient.js.map +1 -1
- package/dist/services/index.d.ts +4 -3
- package/dist/services/index.js +4 -4
- package/dist/services/index.js.map +1 -1
- package/dist/services/internal/assetsService.d.ts +5 -3
- package/dist/services/internal/assetsService.js +22 -377
- package/dist/services/internal/assetsService.js.map +1 -1
- package/dist/services/internal/bitcoinService.d.ts +3 -5
- package/dist/services/internal/bitcoinService.js +9 -1
- package/dist/services/internal/bitcoinService.js.map +1 -1
- package/dist/services/internal/configService.js +10 -2
- package/dist/services/internal/configService.js.map +1 -1
- package/dist/services/internal/cosmosService.d.ts +14 -2
- package/dist/services/internal/cosmosService.js +18 -1
- package/dist/services/internal/cosmosService.js.map +1 -1
- package/dist/services/internal/countryCurrencyMap.d.ts +13 -0
- package/dist/services/internal/countryCurrencyMap.js +1102 -0
- package/dist/services/internal/countryCurrencyMap.js.map +1 -0
- package/dist/services/internal/errorService.d.ts +3 -7
- package/dist/services/internal/errorService.js +26 -2
- package/dist/services/internal/errorService.js.map +1 -1
- package/dist/services/internal/estimateService.js +3 -3
- package/dist/services/internal/estimateService.js.map +1 -1
- package/dist/services/internal/eventService.d.ts +46 -0
- package/dist/services/internal/eventService.js +61 -5
- package/dist/services/internal/eventService.js.map +1 -1
- package/dist/services/internal/evmService.d.ts +2 -2
- package/dist/services/internal/evmService.js.map +1 -1
- package/dist/services/internal/fiatToCryptoService.d.ts +29 -0
- package/dist/services/internal/fiatToCryptoService.js +84 -0
- package/dist/services/internal/fiatToCryptoService.js.map +1 -0
- package/dist/services/internal/fiatToCryptoService.test.d.ts +1 -0
- package/dist/services/internal/fiatToCryptoService.test.js +45 -0
- package/dist/services/internal/fiatToCryptoService.test.js.map +1 -0
- package/dist/services/internal/numberService.d.ts +1 -1
- package/dist/services/internal/numberService.js.map +1 -1
- package/dist/services/internal/searchService.d.ts +1 -1
- package/dist/services/internal/searchService.js +18 -15
- package/dist/services/internal/searchService.js.map +1 -1
- package/dist/services/internal/sendTransaction.d.ts +53 -0
- package/dist/services/internal/sendTransaction.js +194 -0
- package/dist/services/internal/sendTransaction.js.map +1 -0
- package/dist/services/internal/sendTransactionStatus.d.ts +6 -0
- package/dist/services/internal/sendTransactionStatus.js +142 -0
- package/dist/services/internal/sendTransactionStatus.js.map +1 -0
- package/dist/services/internal/solanaService.d.ts +2 -2
- package/dist/services/internal/solanaService.js.map +1 -1
- package/dist/services/internal/stellarService.d.ts +4 -0
- package/dist/services/internal/stellarService.js +20 -0
- package/dist/services/internal/stellarService.js.map +1 -0
- package/dist/services/internal/suiService.d.ts +20 -0
- package/dist/services/internal/suiService.js +119 -0
- package/dist/services/internal/suiService.js.map +1 -0
- package/dist/services/internal/transactionService.d.ts +8 -36
- package/dist/services/internal/transactionService.js +32 -35
- package/dist/services/internal/transactionService.js.map +1 -1
- package/dist/services/internal/transactionStatusService.d.ts +16 -5
- package/dist/services/internal/transactionStatusService.js +82 -5
- package/dist/services/internal/transactionStatusService.js.map +1 -1
- package/dist/services/internal/walletService.d.ts +17 -11
- package/dist/services/internal/walletService.js +70 -21
- package/dist/services/internal/walletService.js.map +1 -1
- package/dist/services/internal/xionService.d.ts +1 -0
- package/dist/services/internal/xionService.js +6 -0
- package/dist/services/internal/xionService.js.map +1 -0
- package/dist/services/internal/xrplService.d.ts +17 -0
- package/dist/services/internal/xrplService.js +50 -0
- package/dist/services/internal/xrplService.js.map +1 -0
- package/dist/tests/assetsService.test.js +13 -26
- package/dist/tests/assetsService.test.js.map +1 -1
- package/dist/tests/searchService.test.js +0 -6
- package/dist/tests/searchService.test.js.map +1 -1
- package/dist/tests/swapConfig.test.js +72 -7
- package/dist/tests/swapConfig.test.js.map +1 -1
- package/dist/tests/transactionService.test.js +18 -18
- package/dist/tests/transactionService.test.js.map +1 -1
- package/package.json +13 -5
- package/dist/core/connectors/xrp/CrossMark.d.ts +0 -26
- package/dist/core/connectors/xrp/CrossMark.js.map +0 -1
- package/dist/core/connectors/xrp/XrpMetamaskSnap.js.map +0 -1
- package/dist/core/its/config.d.ts +0 -200
- package/dist/core/its/config.js +0 -193
- package/dist/core/its/config.js.map +0 -1
- package/dist/core/types/route.d.ts +0 -9
- package/dist/core/types/route.js +0 -4
- package/dist/core/types/route.js.map +0 -1
- package/dist/core/types/xrp.d.ts +0 -51
- package/dist/core/types/xrp.js +0 -2
- package/dist/core/types/xrp.js.map +0 -1
- package/dist/core/xrp/config.d.ts +0 -24
- package/dist/core/xrp/config.js +0 -74
- package/dist/core/xrp/config.js.map +0 -1
- package/dist/hooks/transaction/useSingleTransaction.d.ts +0 -10
- package/dist/hooks/transaction/useSingleTransaction.js.map +0 -1
- package/dist/hooks/xrp/useXrp.d.ts +0 -7
- package/dist/hooks/xrp/useXrp.js +0 -22
- package/dist/hooks/xrp/useXrp.js.map +0 -1
- package/dist/hooks/xrp/useXrpPrice.d.ts +0 -1
- package/dist/hooks/xrp/useXrpPrice.js +0 -12
- package/dist/hooks/xrp/useXrpPrice.js.map +0 -1
- package/dist/hooks/xrp/useXrplTrustLine.d.ts +0 -7
- package/dist/hooks/xrp/useXrplTrustLine.js +0 -127
- package/dist/hooks/xrp/useXrplTrustLine.js.map +0 -1
- package/dist/services/internal/xrpService.d.ts +0 -37
- package/dist/services/internal/xrpService.js +0 -179
- package/dist/services/internal/xrpService.js.map +0 -1
- package/dist/services/internal/xrpStatusService.d.ts +0 -4
- package/dist/services/internal/xrpStatusService.js +0 -102
- package/dist/services/internal/xrpStatusService.js.map +0 -1
|
@@ -0,0 +1,256 @@
|
|
|
1
|
+
import { ChainType } from "@0xsquid/squid-types";
|
|
2
|
+
import { useMutation, useQueryClient } from "@tanstack/react-query";
|
|
3
|
+
import { useCallback } from "react";
|
|
4
|
+
import { getPrefixKey, QueryKeys } from "../../../core/queries/queries-keys";
|
|
5
|
+
import { HistoryTxType } from "../../../core/types/history";
|
|
6
|
+
import { SendTransactionStatus } from "../../../core/types/transaction";
|
|
7
|
+
import { useHistoryStore } from "../../../hooks/store/useHistoryStore";
|
|
8
|
+
import { useSendTransactionStore, } from "../../../hooks/store/useSendTransactionStore";
|
|
9
|
+
import { useNativeTokenForChain } from "../../../hooks/tokens/useNativeTokenForChain";
|
|
10
|
+
import { useMultiChainWallet } from "../../../hooks/wallet/useMultiChainWallet";
|
|
11
|
+
import { useWallet } from "../../../hooks/wallet/useWallet";
|
|
12
|
+
import { isWalletAddressValid, parseToBigInt, WidgetEvents, } from "../../../services";
|
|
13
|
+
import { getWorkingCosmosRpcUrl } from "../../../services/external/rpcService";
|
|
14
|
+
import { getTransactionError } from "../../../services/internal/errorService";
|
|
15
|
+
import { sendTransactionBitcoin, sendTransactionCosmos, sendTransactionEvm, sendTransactionSolana, sendTransactionStellar, sendTransactionSui, sendTransactionXrpl, } from "../../../services/internal/sendTransaction";
|
|
16
|
+
import { useSolanaConnection } from "../../solana/useSolana";
|
|
17
|
+
import { useSigner } from "../../wallet/useSigner";
|
|
18
|
+
export function useSendTransaction({ to, amount, token, chain, }) {
|
|
19
|
+
const { connectedWalletsByChainType } = useWallet();
|
|
20
|
+
const { connectedAddress } = useMultiChainWallet(chain);
|
|
21
|
+
const { evmSigner, cosmosSigner, solanaSigner, bitcoinSigner, suiSigner, xrplSigner, stellarSigner, } = useSigner({
|
|
22
|
+
chain,
|
|
23
|
+
});
|
|
24
|
+
const solanaClient = useSolanaConnection();
|
|
25
|
+
const queryClient = useQueryClient();
|
|
26
|
+
const { nativeToken } = useNativeTokenForChain(chain);
|
|
27
|
+
const getTransaction = useSendTransactionStore((state) => state.getTransaction);
|
|
28
|
+
const setTransactionState = useSendTransactionStore((state) => state.setTransactionState);
|
|
29
|
+
const persistTransaction = useHistoryStore((state) => state.persistTransaction);
|
|
30
|
+
const allEventParamsDefined = !!connectedAddress.address && !!amount && !!token && !!to;
|
|
31
|
+
const dispatchPreSendEvent = useCallback(() => {
|
|
32
|
+
if (!allEventParamsDefined || !connectedAddress.address)
|
|
33
|
+
return;
|
|
34
|
+
WidgetEvents.getInstance().dispatchPreSend({
|
|
35
|
+
fromAddress: connectedAddress.address,
|
|
36
|
+
// amount is already formatted with the token decimals
|
|
37
|
+
amount,
|
|
38
|
+
toAddress: to,
|
|
39
|
+
token: {
|
|
40
|
+
address: token.address,
|
|
41
|
+
chainId: token.chainId,
|
|
42
|
+
symbol: token.symbol,
|
|
43
|
+
type: token.type,
|
|
44
|
+
},
|
|
45
|
+
});
|
|
46
|
+
}, [
|
|
47
|
+
allEventParamsDefined,
|
|
48
|
+
token?.type,
|
|
49
|
+
token?.chainId,
|
|
50
|
+
token?.symbol,
|
|
51
|
+
token?.address,
|
|
52
|
+
amount,
|
|
53
|
+
connectedAddress.address,
|
|
54
|
+
to,
|
|
55
|
+
]);
|
|
56
|
+
const dispatchPostSendEvent = useCallback(({ txHash }) => {
|
|
57
|
+
if (!allEventParamsDefined || !connectedAddress.address)
|
|
58
|
+
return;
|
|
59
|
+
WidgetEvents.getInstance().dispatchPostSend({
|
|
60
|
+
fromAddress: connectedAddress.address,
|
|
61
|
+
// amount is already formatted with the token decimals
|
|
62
|
+
amount,
|
|
63
|
+
toAddress: to,
|
|
64
|
+
token: {
|
|
65
|
+
address: token.address,
|
|
66
|
+
chainId: token.chainId,
|
|
67
|
+
symbol: token.symbol,
|
|
68
|
+
type: token.type,
|
|
69
|
+
},
|
|
70
|
+
txHash,
|
|
71
|
+
});
|
|
72
|
+
}, [
|
|
73
|
+
allEventParamsDefined,
|
|
74
|
+
token?.type,
|
|
75
|
+
token?.chainId,
|
|
76
|
+
token?.symbol,
|
|
77
|
+
token?.address,
|
|
78
|
+
amount,
|
|
79
|
+
connectedAddress.address,
|
|
80
|
+
to,
|
|
81
|
+
]);
|
|
82
|
+
const sendTransactionMutation = useMutation({
|
|
83
|
+
mutationFn: async () => {
|
|
84
|
+
const allParamsDefined = token && to && amount && chain;
|
|
85
|
+
if (!allParamsDefined)
|
|
86
|
+
throw new Error("Need all params");
|
|
87
|
+
if (token.type !== chain.chainType) {
|
|
88
|
+
throw new Error("Invalid token or chain");
|
|
89
|
+
}
|
|
90
|
+
const isValidDestinationAddress = isWalletAddressValid(chain, to);
|
|
91
|
+
if (!isValidDestinationAddress) {
|
|
92
|
+
throw new Error("Invalid destination address");
|
|
93
|
+
}
|
|
94
|
+
const rawAmount = parseToBigInt(amount, token.decimals).toString();
|
|
95
|
+
let tx;
|
|
96
|
+
switch (token.type) {
|
|
97
|
+
case ChainType.EVM:
|
|
98
|
+
if (!evmSigner) {
|
|
99
|
+
throw new Error("Need EVM signer");
|
|
100
|
+
}
|
|
101
|
+
tx = await sendTransactionEvm({
|
|
102
|
+
to,
|
|
103
|
+
amount: rawAmount,
|
|
104
|
+
token,
|
|
105
|
+
signer: evmSigner,
|
|
106
|
+
rpcUrl: chain.rpc,
|
|
107
|
+
});
|
|
108
|
+
break;
|
|
109
|
+
case ChainType.COSMOS:
|
|
110
|
+
if (!cosmosSigner) {
|
|
111
|
+
throw new Error("Need Cosmos signer");
|
|
112
|
+
}
|
|
113
|
+
if (!nativeToken) {
|
|
114
|
+
throw new Error("Need Cosmos native token");
|
|
115
|
+
}
|
|
116
|
+
const rpcUrl = await getWorkingCosmosRpcUrl(chain);
|
|
117
|
+
tx = await sendTransactionCosmos({
|
|
118
|
+
amount: rawAmount,
|
|
119
|
+
rpcUrl,
|
|
120
|
+
signer: cosmosSigner,
|
|
121
|
+
to,
|
|
122
|
+
token,
|
|
123
|
+
nativeToken,
|
|
124
|
+
});
|
|
125
|
+
break;
|
|
126
|
+
case ChainType.SOLANA:
|
|
127
|
+
if (!solanaSigner) {
|
|
128
|
+
throw new Error("Need Solana signer");
|
|
129
|
+
}
|
|
130
|
+
tx = await sendTransactionSolana({
|
|
131
|
+
amount: rawAmount,
|
|
132
|
+
to,
|
|
133
|
+
token,
|
|
134
|
+
connection: solanaClient,
|
|
135
|
+
signer: solanaSigner,
|
|
136
|
+
});
|
|
137
|
+
break;
|
|
138
|
+
case ChainType.BTC:
|
|
139
|
+
if (!bitcoinSigner) {
|
|
140
|
+
throw new Error("Need Bitcoin signer");
|
|
141
|
+
}
|
|
142
|
+
tx = await sendTransactionBitcoin({
|
|
143
|
+
amount: rawAmount,
|
|
144
|
+
to,
|
|
145
|
+
token,
|
|
146
|
+
signer: bitcoinSigner,
|
|
147
|
+
});
|
|
148
|
+
break;
|
|
149
|
+
case ChainType.SUI:
|
|
150
|
+
if (!suiSigner) {
|
|
151
|
+
throw new Error("Need Sui signer");
|
|
152
|
+
}
|
|
153
|
+
const suiAccount = connectedWalletsByChainType[ChainType.SUI];
|
|
154
|
+
if (!suiAccount.account) {
|
|
155
|
+
throw new Error("Need Sui account");
|
|
156
|
+
}
|
|
157
|
+
tx = await sendTransactionSui({
|
|
158
|
+
amount: rawAmount,
|
|
159
|
+
to,
|
|
160
|
+
token,
|
|
161
|
+
chain,
|
|
162
|
+
account: suiAccount.account,
|
|
163
|
+
signer: suiSigner,
|
|
164
|
+
});
|
|
165
|
+
break;
|
|
166
|
+
case ChainType.XRPL:
|
|
167
|
+
if (!xrplSigner) {
|
|
168
|
+
throw new Error("Need XRPL signer");
|
|
169
|
+
}
|
|
170
|
+
if (!connectedAddress.address) {
|
|
171
|
+
throw new Error("No connected address found");
|
|
172
|
+
}
|
|
173
|
+
tx = await sendTransactionXrpl({
|
|
174
|
+
amount: rawAmount,
|
|
175
|
+
to,
|
|
176
|
+
token,
|
|
177
|
+
signer: xrplSigner,
|
|
178
|
+
from: connectedAddress.address,
|
|
179
|
+
});
|
|
180
|
+
break;
|
|
181
|
+
case ChainType.STELLAR:
|
|
182
|
+
if (!stellarSigner) {
|
|
183
|
+
throw new Error("Need Stellar signer");
|
|
184
|
+
}
|
|
185
|
+
tx = await sendTransactionStellar({
|
|
186
|
+
amount: rawAmount,
|
|
187
|
+
to,
|
|
188
|
+
token,
|
|
189
|
+
signer: stellarSigner,
|
|
190
|
+
});
|
|
191
|
+
break;
|
|
192
|
+
}
|
|
193
|
+
return {
|
|
194
|
+
amount,
|
|
195
|
+
to,
|
|
196
|
+
token,
|
|
197
|
+
txHash: tx.txHash,
|
|
198
|
+
};
|
|
199
|
+
},
|
|
200
|
+
onMutate: (variables) => {
|
|
201
|
+
useSendTransactionStore.setState({
|
|
202
|
+
txLocalId: variables.id,
|
|
203
|
+
currentTransaction: undefined,
|
|
204
|
+
});
|
|
205
|
+
},
|
|
206
|
+
onError: (error, variables) => {
|
|
207
|
+
const currentTx = getTransaction(variables.id);
|
|
208
|
+
const errorObject = getTransactionError(error);
|
|
209
|
+
setTransactionState(variables.id, {
|
|
210
|
+
...currentTx,
|
|
211
|
+
error: errorObject,
|
|
212
|
+
});
|
|
213
|
+
},
|
|
214
|
+
onSuccess: (tx, variables) => {
|
|
215
|
+
queryClient.invalidateQueries(getPrefixKey(QueryKeys.Balance));
|
|
216
|
+
setTransactionState(variables.id, tx);
|
|
217
|
+
persistTransaction({
|
|
218
|
+
txType: HistoryTxType.SEND,
|
|
219
|
+
data: {
|
|
220
|
+
amount: tx.amount,
|
|
221
|
+
token: {
|
|
222
|
+
address: tx.token.address,
|
|
223
|
+
chainId: tx.token.chainId,
|
|
224
|
+
decimals: tx.token.decimals,
|
|
225
|
+
symbol: tx.token.symbol,
|
|
226
|
+
type: tx.token.type,
|
|
227
|
+
},
|
|
228
|
+
hash: tx.txHash,
|
|
229
|
+
timestamp: Date.now(),
|
|
230
|
+
toAddress: tx.to,
|
|
231
|
+
status: SendTransactionStatus.ONGOING,
|
|
232
|
+
},
|
|
233
|
+
});
|
|
234
|
+
dispatchPostSendEvent({ txHash: tx.txHash });
|
|
235
|
+
},
|
|
236
|
+
});
|
|
237
|
+
const sendTransaction = useCallback(async () => {
|
|
238
|
+
const transactionId = Date.now().toString();
|
|
239
|
+
dispatchPreSendEvent();
|
|
240
|
+
return sendTransactionMutation.mutate({
|
|
241
|
+
id: transactionId,
|
|
242
|
+
});
|
|
243
|
+
}, [dispatchPreSendEvent, sendTransactionMutation.mutate]);
|
|
244
|
+
/**
|
|
245
|
+
* In QR-based wallets, cleans up listeners and network requests (e.g. websockets)
|
|
246
|
+
* Useful to save resources i.e when the user dismisses the QR code or aborts the connection process
|
|
247
|
+
*/
|
|
248
|
+
const cancelSend = useCallback(() => {
|
|
249
|
+
switch (chain?.chainType) {
|
|
250
|
+
case ChainType.XRPL:
|
|
251
|
+
return xrplSigner?.cancelSignAndSubmit?.();
|
|
252
|
+
}
|
|
253
|
+
}, [chain?.chainType, xrplSigner]);
|
|
254
|
+
return { sendTransaction, cancelSend };
|
|
255
|
+
}
|
|
256
|
+
//# sourceMappingURL=useSendTransaction.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useSendTransaction.js","sourceRoot":"","sources":["../../../../src/hooks/transaction/send/useSendTransaction.ts"],"names":[],"mappings":"AAAA,OAAO,EAAa,SAAS,EAAS,MAAM,sBAAsB,CAAC;AACnE,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACpE,OAAO,EAAE,WAAW,EAAE,MAAM,OAAO,CAAC;AACpC,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,oCAAoC,CAAC;AAC7E,OAAO,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAC5D,OAAO,EAAE,qBAAqB,EAAE,MAAM,iCAAiC,CAAC;AACxE,OAAO,EAAE,eAAe,EAAE,MAAM,sCAAsC,CAAC;AACvE,OAAO,EAEL,uBAAuB,GACxB,MAAM,8CAA8C,CAAC;AACtD,OAAO,EAAE,sBAAsB,EAAE,MAAM,8CAA8C,CAAC;AACtF,OAAO,EAAE,mBAAmB,EAAE,MAAM,2CAA2C,CAAC;AAChF,OAAO,EAAE,SAAS,EAAE,MAAM,iCAAiC,CAAC;AAC5D,OAAO,EACL,oBAAoB,EACpB,aAAa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oB,EAAE,CAAC;QAEvB,OAAO,uBAAuB,CAAC,MAAM,CAAC;YACpC,EAAE,EAAE,aAAa;SAClB,CAAC,CAAC;IACL,CAAC,EAAE,CAAC,oBAAoB,EAAE,uBAAuB,CAAC,MAAM,CAAC,CAAC,CAAC;IAE3D;;;OAGG;IACH,MAAM,UAAU,GAAG,WAAW,CAAC,GAAG,EAAE;QAClC,QAAQ,KAAK,EAAE,SAAS,EAAE;YACxB,KAAK,SAAS,CAAC,IAAI;gBACjB,OAAO,UAAU,EAAE,mBAAmB,EAAE,EAAE,CAAC;SAC9C;IACH,CAAC,EAAE,CAAC,KAAK,EAAE,SAAS,EAAE,UAAU,CAAC,CAAC,CAAC;IAEnC,OAAO,EAAE,eAAe,EAAE,UAAU,EAAE,CAAC;AACzC,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { ChainData, Token } from "@0xsquid/squid-types";
|
|
2
|
+
export declare function useSendTransactionGas({ chain, token, from, }: {
|
|
3
|
+
chain: ChainData | undefined;
|
|
4
|
+
token: Token | undefined;
|
|
5
|
+
from: string | undefined;
|
|
6
|
+
}): import("@tanstack/react-query").UseQueryResult<bigint, unknown>;
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { ChainType } from "@0xsquid/squid-types";
|
|
2
|
+
import { useQuery } from "@tanstack/react-query";
|
|
3
|
+
import { Interface } from "ethers";
|
|
4
|
+
import { erc20Abi } from "viem";
|
|
5
|
+
import { getClient } from "../../../core/client";
|
|
6
|
+
import { getFeeRate } from "../../../core/connectors/bitcoin/helpers";
|
|
7
|
+
import { nativeEvmTokenAddress } from "../../../core/constants";
|
|
8
|
+
import { keys } from "../../../core/queries/queries-keys";
|
|
9
|
+
export function useSendTransactionGas({ chain, token, from, }) {
|
|
10
|
+
return useQuery({
|
|
11
|
+
queryKey: keys().sendTransactionGas(chain?.chainId, token?.address, from),
|
|
12
|
+
queryFn: async () => {
|
|
13
|
+
if (!chain || !token)
|
|
14
|
+
throw new Error("Missing params");
|
|
15
|
+
switch (chain.chainType) {
|
|
16
|
+
case ChainType.EVM: {
|
|
17
|
+
const client = await getClient(chain);
|
|
18
|
+
const feeData = await client.getFeeData();
|
|
19
|
+
if (!feeData.maxFeePerGas)
|
|
20
|
+
return BigInt(0);
|
|
21
|
+
const dummyAddress = "0x1111111111111111111111111111111111111111";
|
|
22
|
+
// Some RPC providers require the sender to have enough balance, otherwise estimation reverts
|
|
23
|
+
// so we'll try to use the user provided address when possible
|
|
24
|
+
const sender = from || dummyAddress;
|
|
25
|
+
if (token.address.toLowerCase() === nativeEvmTokenAddress.toLowerCase()) {
|
|
26
|
+
const gas = await client.estimateGas({
|
|
27
|
+
from: sender,
|
|
28
|
+
to: dummyAddress,
|
|
29
|
+
value: 1,
|
|
30
|
+
chainId: chain.chainId,
|
|
31
|
+
});
|
|
32
|
+
return gas * feeData.maxFeePerGas;
|
|
33
|
+
}
|
|
34
|
+
const erc20Interface = new Interface(erc20Abi);
|
|
35
|
+
const data = erc20Interface.encodeFunctionData("transfer", [
|
|
36
|
+
dummyAddress,
|
|
37
|
+
1,
|
|
38
|
+
]);
|
|
39
|
+
const gas = await client.estimateGas({
|
|
40
|
+
from: sender,
|
|
41
|
+
to: token.address,
|
|
42
|
+
data,
|
|
43
|
+
chainId: chain.chainId,
|
|
44
|
+
});
|
|
45
|
+
return gas * feeData.maxFeePerGas;
|
|
46
|
+
}
|
|
47
|
+
case ChainType.COSMOS: {
|
|
48
|
+
// TODO: get gas estimation from backend
|
|
49
|
+
return BigInt(0);
|
|
50
|
+
}
|
|
51
|
+
case ChainType.SOLANA: {
|
|
52
|
+
// TODO: get gas estimation from backend
|
|
53
|
+
return BigInt(5000);
|
|
54
|
+
}
|
|
55
|
+
case ChainType.BTC: {
|
|
56
|
+
const feeRate = await getFeeRate();
|
|
57
|
+
// average vBytes for a segwit tx (2 inputs, 2 outputs)
|
|
58
|
+
const vBytes = 378;
|
|
59
|
+
const feeSats = feeRate * vBytes;
|
|
60
|
+
// TODO: get gas estimation from backend?
|
|
61
|
+
return BigInt(feeSats);
|
|
62
|
+
}
|
|
63
|
+
default:
|
|
64
|
+
throw new Error(`Gas estimation not implemented for chain type ${chain.chainType}`);
|
|
65
|
+
}
|
|
66
|
+
},
|
|
67
|
+
enabled: !!chain && !!token,
|
|
68
|
+
// 5 minutes
|
|
69
|
+
staleTime: 1_000 * 60 * 5,
|
|
70
|
+
refetchInterval: 1_000 * 60 * 5,
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
//# sourceMappingURL=useSendTransactionGas.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useSendTransactionGas.js","sourceRoot":"","sources":["../../../../src/hooks/transaction/send/useSendTransactionGas.ts"],"names":[],"mappings":"AAAA,OAAO,EAAa,SAAS,EAAS,MAAM,sBAAsB,CAAC;AACnE,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AACjD,OAAO,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC;AACnC,OAAO,EAAE,QAAQ,EAAE,MAAM,MAAM,CAAC;AAChC,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACjD,OAAO,EAAE,UAAU,EAAE,MAAM,0CAA0C,CAAC;AACtE,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAChE,OAAO,EAAE,IAAI,EAAE,MAAM,oCAAoC,CAAC;AAE1D,MAAM,UAAU,qBAAqB,CAAC,EACpC,KAAK,EACL,KAAK,EACL,IAAI,GAKL;IACC,OAAO,QAAQ,CAAS;QACtB,QAAQ,EAAE,IAAI,EAAE,CAAC,kBAAkB,CAAC,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,IAAI,CAAC;QACzE,OAAO,EAAE,KAAK,IAAI,EAAE;YAClB,IAAI,CAAC,KAAK,IAAI,CAAC,KAAK;gBAAE,MAAM,IAAI,KAAK,CAAC,gBAAgB,CAAC,CAAC;YAExD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,CAAC,CAAC,CAAC;iBAClB;gBACD,KAAK,SAAS,CAAC,MAAM,CAAC,CAAC;oBACrB,wCAAwC;oBACxC,OAAO,MAAM,CAAC,IAAI,CAAC,CAAC;iBACrB;gBACD,KAAK,SAAS,CAAC,GAAG,CAAC,CAAC;oBAClB,MAAM,OAAO,GAAG,MAAM,UAAU,EAAE,CAAC;oBAEnC,uDAAuD;oBACvD,MAAM,MAAM,GAAG,GAAG,CAAC;oBACnB,MAAM,OAAO,GAAG,OAAO,GAAG,MAAM,CAAC;oBAEjC,yCAAyC;oBACzC,OAAO,MAAM,CAAC,OAAO,CAAC,CAAC;iBACxB;gBAED;oBACE,MAAM,IAAI,KAAK,CACb,iDAAiD,KAAK,CAAC,SAAS,EAAE,CACnE,CAAC;aACL;QACH,CAAC;QACD,OAAO,EAAE,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC,KAAK;QAC3B,YAAY;QACZ,SAAS,EAAE,KAAK,GAAG,EAAE,GAAG,CAAC;QACzB,eAAe,EAAE,KAAK,GAAG,EAAE,GAAG,CAAC;KAChC,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -1,4 +1,36 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { OnRampTransactionStatus } from "../../core/types/onramps/onramp";
|
|
2
|
+
import { SendTransactionStatus } from "../../core/types/transaction";
|
|
2
3
|
export declare const useAllTransactionsStatus: ({ enabled }: {
|
|
3
4
|
enabled: boolean;
|
|
4
|
-
}) =>
|
|
5
|
+
}) => {
|
|
6
|
+
isLoading: boolean;
|
|
7
|
+
isError: boolean;
|
|
8
|
+
data: ((import("@0xsquid/squid-types").ApiBasicResponse & {
|
|
9
|
+
id: string;
|
|
10
|
+
status: string;
|
|
11
|
+
gasStatus: string;
|
|
12
|
+
isGMPTransaction?: boolean | undefined;
|
|
13
|
+
axelarTransactionUrl: string;
|
|
14
|
+
fromChain?: {
|
|
15
|
+
transactionId: string;
|
|
16
|
+
blockNumber: string;
|
|
17
|
+
callEventStatus: string;
|
|
18
|
+
callEventLog: any[];
|
|
19
|
+
chainData?: any;
|
|
20
|
+
transactionUrl?: string | undefined;
|
|
21
|
+
destinationAddress?: string | undefined;
|
|
22
|
+
} | undefined;
|
|
23
|
+
toChain?: {
|
|
24
|
+
transactionId: string;
|
|
25
|
+
blockNumber: string;
|
|
26
|
+
callEventStatus: string;
|
|
27
|
+
callEventLog: any[];
|
|
28
|
+
chainData?: any;
|
|
29
|
+
transactionUrl?: string | undefined;
|
|
30
|
+
destinationAddress?: string | undefined;
|
|
31
|
+
} | undefined;
|
|
32
|
+
timeSpent?: {} | Record<string, number> | undefined;
|
|
33
|
+
squidTransactionStatus?: import("@0xsquid/squid-types").SquidTransactionStatus | undefined;
|
|
34
|
+
routeStatus?: any[] | undefined;
|
|
35
|
+
} & OnRampTransactionStatus & SendTransactionStatus) | undefined)[];
|
|
36
|
+
};
|
|
@@ -1,70 +1,127 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { useQueries } from "@tanstack/react-query";
|
|
2
2
|
import { keys } from "../../core/queries/queries-keys";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
3
|
+
import { HistoryTxType } from "../../core/types/history";
|
|
4
|
+
import { fetchSwapTransactionStatus, getSendTxStatusRefetchInterval, getSwapTxStatusRefetchInterval, getTransactionEndStatus, } from "../../services";
|
|
5
|
+
import { OnrampService } from "../../services/external/onrampAdapter";
|
|
6
|
+
import { getSendTransactionStatus } from "../../services/internal/sendTransactionStatus";
|
|
7
|
+
import { useSquidChains } from "../chains/useSquidChains";
|
|
8
|
+
import { SendTransactionStatus } from "../../core/types/transaction";
|
|
9
|
+
import { FINAL_TRANSACTION_STATUSES, TX_STATUS_CONSTANTS, } from "../onramp/useFiatToCrypto";
|
|
10
|
+
import { useHistoryStore } from "../store/useHistoryStore";
|
|
11
|
+
import { useConfigStore } from "../store/useSquidStore";
|
|
6
12
|
import { useHistory } from "../user/useHistory";
|
|
7
13
|
export const useAllTransactionsStatus = ({ enabled }) => {
|
|
8
|
-
const {
|
|
14
|
+
const { pendingTransactions, replaceSwapTransactionStatus } = useHistory();
|
|
15
|
+
const replaceTransactionStatus = useHistoryStore((state) => state.replaceTransactionStatus);
|
|
9
16
|
const config = useConfigStore((state) => state.config);
|
|
10
|
-
const
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
17
|
+
const { findChain } = useSquidChains();
|
|
18
|
+
const onrampService = new OnrampService();
|
|
19
|
+
const statusQueries = pendingTransactions.map(({ txType, data }) => {
|
|
20
|
+
switch (txType) {
|
|
21
|
+
case HistoryTxType.SWAP: {
|
|
22
|
+
return {
|
|
23
|
+
queryKey: keys().swapTransactionStatus(data.transactionId),
|
|
24
|
+
queryFn: async () => {
|
|
25
|
+
return fetchSwapTransactionStatus({
|
|
26
|
+
transaction: {
|
|
27
|
+
...data,
|
|
28
|
+
transactionId: data.transactionIdForStatus ?? data.transactionId,
|
|
29
|
+
},
|
|
30
|
+
apiUrl: config.apiUrl,
|
|
31
|
+
integratorId: config.integratorId,
|
|
32
|
+
});
|
|
33
|
+
},
|
|
34
|
+
enabled: true,
|
|
35
|
+
retry: 4,
|
|
36
|
+
retryDelay: getSwapTxStatusRefetchInterval(data),
|
|
37
|
+
refetchInterval: 5000,
|
|
38
|
+
onSuccess: (statusResponse) => {
|
|
39
|
+
if (!statusResponse)
|
|
40
|
+
return;
|
|
41
|
+
const endStatus = getTransactionEndStatus({
|
|
42
|
+
statusResponse,
|
|
43
|
+
});
|
|
44
|
+
if (!endStatus)
|
|
45
|
+
return;
|
|
46
|
+
replaceSwapTransactionStatus({
|
|
47
|
+
transactionId: data.transactionId,
|
|
48
|
+
statusResponse,
|
|
49
|
+
status: endStatus,
|
|
50
|
+
});
|
|
51
|
+
},
|
|
52
|
+
};
|
|
33
53
|
}
|
|
34
|
-
|
|
35
|
-
return
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
54
|
+
case HistoryTxType.BUY:
|
|
55
|
+
return {
|
|
56
|
+
queryFn: () => onrampService.getTransactionStatus(data.orderId, data.toAddress, data.providerId),
|
|
57
|
+
queryKey: keys().fiatToCryptoStatus(data.orderId),
|
|
58
|
+
retry: TX_STATUS_CONSTANTS.RETRY_COUNT,
|
|
59
|
+
retryDelay: TX_STATUS_CONSTANTS.RETRY_DELAY,
|
|
60
|
+
refetchInterval: (data) => {
|
|
61
|
+
if (data?.status &&
|
|
62
|
+
FINAL_TRANSACTION_STATUSES.includes(data.status)) {
|
|
63
|
+
return false;
|
|
64
|
+
}
|
|
65
|
+
return TX_STATUS_CONSTANTS.REFETCH_INTERVAL;
|
|
66
|
+
},
|
|
67
|
+
onSuccess: (statusData) => {
|
|
68
|
+
replaceTransactionStatus({
|
|
69
|
+
orderId: data.orderId,
|
|
70
|
+
status: statusData.status,
|
|
71
|
+
transactionHash: statusData.transactionHash,
|
|
72
|
+
txType: HistoryTxType.BUY,
|
|
73
|
+
});
|
|
74
|
+
},
|
|
75
|
+
onError: () => {
|
|
76
|
+
replaceTransactionStatus({
|
|
77
|
+
txType: HistoryTxType.BUY,
|
|
78
|
+
orderId: data.orderId,
|
|
79
|
+
status: "failed",
|
|
80
|
+
transactionHash: undefined,
|
|
81
|
+
});
|
|
82
|
+
},
|
|
83
|
+
enabled: true,
|
|
84
|
+
};
|
|
85
|
+
case HistoryTxType.SEND:
|
|
86
|
+
return {
|
|
87
|
+
queryKey: keys().sendTransactionStatus(data.hash, data.token.chainId),
|
|
88
|
+
queryFn: async () => {
|
|
89
|
+
const chain = findChain(data.token.chainId);
|
|
90
|
+
if (!chain) {
|
|
91
|
+
throw new Error(`Could not find chain ${data.token.chainId} for tx status`);
|
|
92
|
+
}
|
|
93
|
+
return getSendTransactionStatus({
|
|
94
|
+
chain,
|
|
95
|
+
txHash: data.hash,
|
|
96
|
+
});
|
|
97
|
+
},
|
|
98
|
+
refetchInterval: getSendTxStatusRefetchInterval(data.token.type),
|
|
99
|
+
onSuccess: (status) => {
|
|
100
|
+
if (status !== SendTransactionStatus.ONGOING) {
|
|
101
|
+
replaceTransactionStatus({
|
|
102
|
+
txType: HistoryTxType.SEND,
|
|
103
|
+
status,
|
|
104
|
+
hash: data.hash,
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
},
|
|
108
|
+
onError: () => {
|
|
109
|
+
replaceTransactionStatus({
|
|
110
|
+
txType: HistoryTxType.SEND,
|
|
111
|
+
status: SendTransactionStatus.ERROR,
|
|
112
|
+
hash: data.hash,
|
|
113
|
+
});
|
|
114
|
+
},
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
});
|
|
118
|
+
const queries = useQueries({
|
|
119
|
+
queries: enabled && config.apiUrl ? statusQueries : [],
|
|
68
120
|
});
|
|
121
|
+
return {
|
|
122
|
+
isLoading: queries.some((q) => q.isLoading),
|
|
123
|
+
isError: queries.some((q) => q.isError),
|
|
124
|
+
data: queries.map((q) => q.data).filter(Boolean),
|
|
125
|
+
};
|
|
69
126
|
};
|
|
70
127
|
//# sourceMappingURL=useAllTransactionsStatus.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useAllTransactionsStatus.js","sourceRoot":"","sources":["../../../src/hooks/transaction/useAllTransactionsStatus.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"useAllTransactionsStatus.js","sourceRoot":"","sources":["../../../src/hooks/transaction/useAllTransactionsStatus.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACnD,OAAO,EAAE,IAAI,EAAE,MAAM,iCAAiC,CAAC;AACvD,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAMzD,OAAO,EACL,0BAA0B,EAC1B,8BAA8B,EAC9B,8BAA8B,EAC9B,uBAAuB,GACxB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,aAAa,EAAE,MAAM,uCAAuC,CAAC;AACtE,OAAO,EAAE,wBAAwB,EAAE,MAAM,+CAA+C,CAAC;AACzF,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAE1D,OAAO,EAAE,qBAAqB,EAAE,MAAM,8BAA8B,CAAC;AACrE,OAAO,EACL,0BAA0B,EAC1B,mBAAmB,GACpB,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAC3D,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AACxD,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAEhD,MAAM,CAAC,MAAM,wBAAwB,GAAG,CAAC,EAAE,OAAO,EAAwB,EAAE,EAAE;IAC5E,MAAM,EAAE,mBAAmB,EAAE,4BAA4B,EAAE,GAAG,UAAU,EAAE,CAAC;IAC3E,MAAM,wBAAwB,GAAG,eAAe,CAC9C,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,wBAAwB,CAC1C,CAAC;IACF,MAAM,MAAM,GAAG,cAAc,CAAC,CAAC,KAAK,EAAE,EAAE,C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AAC,MAAM,CAAC,OAAO,CAAC;KACjD,CAAC;AACJ,CAAC,CAAC"}
|
|
@@ -18,10 +18,10 @@ export const useApproval = ({ squidRoute, }) => {
|
|
|
18
18
|
const publicClient = usePublicClient();
|
|
19
19
|
const queryClient = useQueryClient();
|
|
20
20
|
const squid = useSquidStore((state) => state.squid);
|
|
21
|
-
const {
|
|
21
|
+
const { fromChain, fromToken, fromPrice } = useSwap();
|
|
22
|
+
const { evmSigner } = useSigner({ chain: fromChain });
|
|
22
23
|
const { connector: activeConnector } = useAccount();
|
|
23
24
|
const { getChainType } = useSquidChains();
|
|
24
|
-
const { fromChain, fromToken, fromPrice } = useSwap();
|
|
25
25
|
const { switchChainAsync } = useSwitchChain();
|
|
26
26
|
const { connectedAddress: { address: sourceUserAddress }, } = useMultiChainWallet(fromChain);
|
|
27
27
|
const isSrcChainEvmos = isEvmosChain(fromChain);
|
|
@@ -209,7 +209,7 @@ export const useApproval = ({ squidRoute, }) => {
|
|
|
209
209
|
// This is to ensure we're using the latest expiry timestamp
|
|
210
210
|
if (squidRoute) {
|
|
211
211
|
queryClient.refetchQueries({
|
|
212
|
-
queryKey: keys().transaction(squidRoute.params.fromChain, squidRoute.params.toChain, squidRoute.params.toToken, squidRoute.params.fromToken, fromPrice, squidRoute.params.slippage, squidRoute.params.receiveGasOnDestination, squidRoute.params.fromAddress, squidRoute.params.bypassGuardrails, squidRoute.params.toAddress, squidRoute.params.fallbackAddresses?.[0]?.address, squidRoute.params.quoteOnly, getChainType(squidRoute.params.fromChain)),
|
|
212
|
+
queryKey: keys().transaction(squidRoute.params.fromChain, squidRoute.params.toChain, squidRoute.params.toToken, squidRoute.params.fromToken, fromPrice, squidRoute.params.slippage, squidRoute.params.receiveGasOnDestination, squidRoute.params.fromAddress, squidRoute.params.bypassGuardrails, squidRoute.params.toAddress, squidRoute.params.fallbackAddresses?.[0]?.address, squidRoute.params.quoteOnly, getChainType(squidRoute.params.fromChain), squidRoute.params.preHook, squidRoute.params.postHook),
|
|
213
213
|
});
|
|
214
214
|
}
|
|
215
215
|
},
|