@0xsquid/react-hooks 7.7.0 → 8.0.0-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/constants.d.ts +0 -2
- package/dist/core/queries/queries-keys.d.ts +2 -1
- package/dist/core/types/config.d.ts +27 -4
- package/dist/core/types/swap.d.ts +1 -0
- package/dist/hooks/chains/useSquidChains.d.ts +5 -8
- package/dist/hooks/swap/useSwap.d.ts +1 -1
- package/dist/hooks/tokens/useAllConnectedWalletBalances.d.ts +2 -1
- package/dist/hooks/tokens/useAllTokensWithBalanceForChainType.d.ts +2 -1
- package/dist/hooks/tokens/useSquidTokens.d.ts +5 -1
- package/dist/hooks/transaction/useEstimate.d.ts +0 -2
- package/dist/index-B3FG6tRj.js +6021 -0
- package/dist/index-B3FG6tRj.js.map +1 -0
- package/dist/index-CeIwio11.js +41015 -0
- package/dist/index-CeIwio11.js.map +1 -0
- package/dist/index-CjYMwYuT.js +41267 -0
- package/dist/index-CjYMwYuT.js.map +1 -0
- package/dist/index-CoxuUJzG.js +6021 -0
- package/dist/index-CoxuUJzG.js.map +1 -0
- package/dist/index.esm.js +36 -0
- package/dist/index.esm.js.map +1 -0
- package/dist/index.js +292 -6
- package/dist/index.js.map +1 -1
- package/dist/secretService-C6ack504.js +168 -0
- package/dist/secretService-C6ack504.js.map +1 -0
- package/dist/{services/external/secretService.js → secretService-CgLleYSR.js} +43 -8
- package/dist/secretService-CgLleYSR.js.map +1 -0
- package/dist/services/internal/assetsService.d.ts +18 -19
- package/dist/services/internal/configService.d.ts +8 -16
- package/dist/services/internal/estimateService.d.ts +0 -1
- package/package.json +18 -4
- package/dist/core/abis/ics20.json +0 -128
- package/dist/core/client/index.js +0 -38
- package/dist/core/client/index.js.map +0 -1
- package/dist/core/connectors/bitcoin/errors/index.js +0 -22
- package/dist/core/connectors/bitcoin/errors/index.js.map +0 -1
- package/dist/core/connectors/bitcoin/helpers.js +0 -91
- package/dist/core/connectors/bitcoin/helpers.js.map +0 -1
- package/dist/core/connectors/bitcoin/index.js +0 -2
- package/dist/core/connectors/bitcoin/index.js.map +0 -1
- package/dist/core/connectors/bitcoin/wallets/index.js +0 -4
- package/dist/core/connectors/bitcoin/wallets/index.js.map +0 -1
- package/dist/core/connectors/bitcoin/wallets/keplr.js +0 -28
- package/dist/core/connectors/bitcoin/wallets/keplr.js.map +0 -1
- package/dist/core/connectors/bitcoin/wallets/phantom.js +0 -56
- package/dist/core/connectors/bitcoin/wallets/phantom.js.map +0 -1
- package/dist/core/connectors/bitcoin/wallets/unisat.js +0 -28
- package/dist/core/connectors/bitcoin/wallets/unisat.js.map +0 -1
- package/dist/core/connectors/xrpl/CrossMark.js +0 -76
- package/dist/core/connectors/xrpl/CrossMark.js.map +0 -1
- package/dist/core/connectors/xrpl/WalletConnect.js +0 -194
- package/dist/core/connectors/xrpl/WalletConnect.js.map +0 -1
- package/dist/core/connectors/xrpl/Xaman.js +0 -71
- package/dist/core/connectors/xrpl/Xaman.js.map +0 -1
- package/dist/core/connectors/xrpl/XamanQr.js +0 -95
- package/dist/core/connectors/xrpl/XamanQr.js.map +0 -1
- package/dist/core/connectors/xrpl/XrplMetamaskSnap.js +0 -176
- package/dist/core/connectors/xrpl/XrplMetamaskSnap.js.map +0 -1
- package/dist/core/constants.js +0 -159
- package/dist/core/constants.js.map +0 -1
- package/dist/core/externalLinks.js +0 -21
- package/dist/core/externalLinks.js.map +0 -1
- package/dist/core/index.js +0 -4
- package/dist/core/index.js.map +0 -1
- package/dist/core/multicall3.js +0 -462
- package/dist/core/multicall3.js.map +0 -1
- package/dist/core/providers/BitcoinProvider.js +0 -15
- package/dist/core/providers/BitcoinProvider.js.map +0 -1
- package/dist/core/providers/CosmosProvider.js +0 -13
- package/dist/core/providers/CosmosProvider.js.map +0 -1
- package/dist/core/providers/EvmProvider.js +0 -15
- package/dist/core/providers/EvmProvider.js.map +0 -1
- package/dist/core/providers/SolanaProvider.js +0 -15
- package/dist/core/providers/SolanaProvider.js.map +0 -1
- package/dist/core/providers/SuiProvider.js +0 -15
- package/dist/core/providers/SuiProvider.js.map +0 -1
- package/dist/core/providers/XrplProvider.js +0 -15
- package/dist/core/providers/XrplProvider.js.map +0 -1
- package/dist/core/queries/queries-keys.js +0 -226
- package/dist/core/queries/queries-keys.js.map +0 -1
- package/dist/core/queries/react-query-config.js +0 -11
- package/dist/core/queries/react-query-config.js.map +0 -1
- package/dist/core/types/bitcoin.js +0 -2
- package/dist/core/types/bitcoin.js.map +0 -1
- package/dist/core/types/config.js +0 -2
- package/dist/core/types/config.js.map +0 -1
- package/dist/core/types/dex.d.ts +0 -28
- package/dist/core/types/dex.js +0 -33
- package/dist/core/types/dex.js.map +0 -1
- package/dist/core/types/error.js +0 -18
- package/dist/core/types/error.js.map +0 -1
- package/dist/core/types/event.js +0 -2
- package/dist/core/types/event.js.map +0 -1
- package/dist/core/types/evm.js +0 -2
- package/dist/core/types/evm.js.map +0 -1
- package/dist/core/types/history.js +0 -7
- package/dist/core/types/history.js.map +0 -1
- package/dist/core/types/index.js +0 -4
- package/dist/core/types/index.js.map +0 -1
- package/dist/core/types/onramps/index.js +0 -3
- package/dist/core/types/onramps/index.js.map +0 -1
- package/dist/core/types/onramps/onramp.js +0 -2
- package/dist/core/types/onramps/onramp.js.map +0 -1
- package/dist/core/types/onramps/revolut.js +0 -2
- package/dist/core/types/onramps/revolut.js.map +0 -1
- package/dist/core/types/rpc.js +0 -2
- package/dist/core/types/rpc.js.map +0 -1
- package/dist/core/types/solana.js +0 -2
- package/dist/core/types/solana.js.map +0 -1
- package/dist/core/types/sui.js +0 -2
- package/dist/core/types/sui.js.map +0 -1
- package/dist/core/types/swap.js +0 -2
- package/dist/core/types/swap.js.map +0 -1
- package/dist/core/types/tokens.js +0 -2
- package/dist/core/types/tokens.js.map +0 -1
- package/dist/core/types/transaction.js +0 -47
- package/dist/core/types/transaction.js.map +0 -1
- package/dist/core/types/wallet.js +0 -19
- package/dist/core/types/wallet.js.map +0 -1
- package/dist/core/types/xrpl.js +0 -32
- package/dist/core/types/xrpl.js.map +0 -1
- package/dist/core/wagmiConfig.js +0 -81
- package/dist/core/wagmiConfig.js.map +0 -1
- package/dist/core/wallets.js +0 -357
- package/dist/core/wallets.js.map +0 -1
- package/dist/hooks/analytics/useTrackSearchEmpty.js +0 -22
- package/dist/hooks/analytics/useTrackSearchEmpty.js.map +0 -1
- package/dist/hooks/bitcoin/useBitcoin.js +0 -18
- package/dist/hooks/bitcoin/useBitcoin.js.map +0 -1
- package/dist/hooks/chains/useSquidChains.js +0 -107
- package/dist/hooks/chains/useSquidChains.js.map +0 -1
- package/dist/hooks/client/useClient.js +0 -63
- package/dist/hooks/client/useClient.js.map +0 -1
- package/dist/hooks/cosmos/useCosmos.js +0 -167
- package/dist/hooks/cosmos/useCosmos.js.map +0 -1
- package/dist/hooks/cosmos/useCosmosForChain.js +0 -29
- package/dist/hooks/cosmos/useCosmosForChain.js.map +0 -1
- package/dist/hooks/evm/useEvm.js +0 -68
- package/dist/hooks/evm/useEvm.js.map +0 -1
- package/dist/hooks/evm/useEvmWallets.js +0 -13
- package/dist/hooks/evm/useEvmWallets.js.map +0 -1
- package/dist/hooks/index.js +0 -54
- package/dist/hooks/index.js.map +0 -1
- package/dist/hooks/navigation/useKeyboardNavigation.js +0 -67
- package/dist/hooks/navigation/useKeyboardNavigation.js.map +0 -1
- package/dist/hooks/onramp/useFiatToCrypto.js +0 -298
- package/dist/hooks/onramp/useFiatToCrypto.js.map +0 -1
- package/dist/hooks/query/useSquidQueryClient.js +0 -23
- package/dist/hooks/query/useSquidQueryClient.js.map +0 -1
- package/dist/hooks/solana/useSolana.js +0 -81
- package/dist/hooks/solana/useSolana.js.map +0 -1
- package/dist/hooks/solana/useSolanaWallets.js +0 -8
- package/dist/hooks/solana/useSolanaWallets.js.map +0 -1
- package/dist/hooks/squid/useSquid.js +0 -55
- package/dist/hooks/squid/useSquid.js.map +0 -1
- package/dist/hooks/store/useAddressBookStore.js +0 -30
- package/dist/hooks/store/useAddressBookStore.js.map +0 -1
- package/dist/hooks/store/useAssetsColorsStore.js +0 -7
- package/dist/hooks/store/useAssetsColorsStore.js.map +0 -1
- package/dist/hooks/store/useDepositAddressStore.js +0 -12
- package/dist/hooks/store/useDepositAddressStore.js.map +0 -1
- package/dist/hooks/store/useFavoriteTokensStore.js +0 -28
- package/dist/hooks/store/useFavoriteTokensStore.js.map +0 -1
- package/dist/hooks/store/useHistoryStore.js +0 -129
- package/dist/hooks/store/useHistoryStore.js.map +0 -1
- package/dist/hooks/store/useSendTransactionStore.js +0 -21
- package/dist/hooks/store/useSendTransactionStore.js.map +0 -1
- package/dist/hooks/store/useSquidStore.js +0 -53
- package/dist/hooks/store/useSquidStore.js.map +0 -1
- package/dist/hooks/store/useWalletStore.js +0 -61
- package/dist/hooks/store/useWalletStore.js.map +0 -1
- package/dist/hooks/sui/useSui.js +0 -81
- package/dist/hooks/sui/useSui.js.map +0 -1
- package/dist/hooks/sui/useSuiWallets.js +0 -23
- package/dist/hooks/sui/useSuiWallets.js.map +0 -1
- package/dist/hooks/swap/useDepositAddress.js +0 -63
- package/dist/hooks/swap/useDepositAddress.js.map +0 -1
- package/dist/hooks/swap/useSwap.js +0 -203
- package/dist/hooks/swap/useSwap.js.map +0 -1
- package/dist/hooks/tokens/useAllConnectedWalletBalances.js +0 -114
- package/dist/hooks/tokens/useAllConnectedWalletBalances.js.map +0 -1
- package/dist/hooks/tokens/useAllTokensWithBalanceForChainType.js +0 -130
- package/dist/hooks/tokens/useAllTokensWithBalanceForChainType.js.map +0 -1
- package/dist/hooks/tokens/useBalance.js +0 -157
- package/dist/hooks/tokens/useBalance.js.map +0 -1
- package/dist/hooks/tokens/useMultiChainBalance.js +0 -77
- package/dist/hooks/tokens/useMultiChainBalance.js.map +0 -1
- package/dist/hooks/tokens/useMultipleTokenPrices.js +0 -46
- package/dist/hooks/tokens/useMultipleTokenPrices.js.map +0 -1
- package/dist/hooks/tokens/useNativeBalance.js +0 -249
- package/dist/hooks/tokens/useNativeBalance.js.map +0 -1
- package/dist/hooks/tokens/useNativeTokenForChain.js +0 -30
- package/dist/hooks/tokens/useNativeTokenForChain.js.map +0 -1
- package/dist/hooks/tokens/useSingleTokenPrice.js +0 -38
- package/dist/hooks/tokens/useSingleTokenPrice.js.map +0 -1
- package/dist/hooks/tokens/useSquidTokens.js +0 -85
- package/dist/hooks/tokens/useSquidTokens.js.map +0 -1
- package/dist/hooks/tokens/useTokenHistoricalData.js +0 -23
- package/dist/hooks/tokens/useTokenHistoricalData.js.map +0 -1
- package/dist/hooks/transaction/send/useEstimateSendTransactionGas.js +0 -58
- package/dist/hooks/transaction/send/useEstimateSendTransactionGas.js.map +0 -1
- package/dist/hooks/transaction/send/useSendTransaction.js +0 -245
- package/dist/hooks/transaction/send/useSendTransaction.js.map +0 -1
- package/dist/hooks/transaction/send/useSendTransactionGas.js +0 -73
- package/dist/hooks/transaction/send/useSendTransactionGas.js.map +0 -1
- package/dist/hooks/transaction/useAllTransactionsStatus.js +0 -127
- package/dist/hooks/transaction/useAllTransactionsStatus.js.map +0 -1
- package/dist/hooks/transaction/useApproval.js +0 -246
- package/dist/hooks/transaction/useApproval.js.map +0 -1
- package/dist/hooks/transaction/useErc20Allowance.js +0 -43
- package/dist/hooks/transaction/useErc20Allowance.js.map +0 -1
- package/dist/hooks/transaction/useEstimate.js +0 -118
- package/dist/hooks/transaction/useEstimate.js.map +0 -1
- package/dist/hooks/transaction/useEstimatePriceImpact.js +0 -31
- package/dist/hooks/transaction/useEstimatePriceImpact.js.map +0 -1
- package/dist/hooks/transaction/useExecuteTransaction.js +0 -678
- package/dist/hooks/transaction/useExecuteTransaction.js.map +0 -1
- package/dist/hooks/transaction/useGetRoute.js +0 -207
- package/dist/hooks/transaction/useGetRoute.js.map +0 -1
- package/dist/hooks/transaction/useIcs20Allowance.js +0 -46
- package/dist/hooks/transaction/useIcs20Allowance.js.map +0 -1
- package/dist/hooks/transaction/useRouteWarnings.js +0 -19
- package/dist/hooks/transaction/useRouteWarnings.js.map +0 -1
- package/dist/hooks/transaction/useSendTransactionStatus.js +0 -63
- package/dist/hooks/transaction/useSendTransactionStatus.js.map +0 -1
- package/dist/hooks/transaction/useSwapTransactionStatus.js +0 -114
- package/dist/hooks/transaction/useSwapTransactionStatus.js.map +0 -1
- package/dist/hooks/user/useAvatar.js +0 -40
- package/dist/hooks/user/useAvatar.js.map +0 -1
- package/dist/hooks/user/useHistory.js +0 -103
- package/dist/hooks/user/useHistory.js.map +0 -1
- package/dist/hooks/user/useUserParams.js +0 -33
- package/dist/hooks/user/useUserParams.js.map +0 -1
- package/dist/hooks/utils/useUtils.js +0 -20
- package/dist/hooks/utils/useUtils.js.map +0 -1
- package/dist/hooks/wallet/useAddToken.js +0 -49
- package/dist/hooks/wallet/useAddToken.js.map +0 -1
- package/dist/hooks/wallet/useAutoConnect.js +0 -92
- package/dist/hooks/wallet/useAutoConnect.js.map +0 -1
- package/dist/hooks/wallet/useEns.js +0 -57
- package/dist/hooks/wallet/useEns.js.map +0 -1
- package/dist/hooks/wallet/useGnosisContext.js +0 -74
- package/dist/hooks/wallet/useGnosisContext.js.map +0 -1
- package/dist/hooks/wallet/useIntegratorContext.js +0 -39
- package/dist/hooks/wallet/useIntegratorContext.js.map +0 -1
- package/dist/hooks/wallet/useMultiChainWallet.js +0 -210
- package/dist/hooks/wallet/useMultiChainWallet.js.map +0 -1
- package/dist/hooks/wallet/useSigner.js +0 -68
- package/dist/hooks/wallet/useSigner.js.map +0 -1
- package/dist/hooks/wallet/useStandardWallets.js +0 -26
- package/dist/hooks/wallet/useStandardWallets.js.map +0 -1
- package/dist/hooks/wallet/useWallet.js +0 -199
- package/dist/hooks/wallet/useWallet.js.map +0 -1
- package/dist/hooks/wallet/useWallets.js +0 -33
- package/dist/hooks/wallet/useWallets.js.map +0 -1
- package/dist/hooks/xrpl/useXrpl.js +0 -55
- package/dist/hooks/xrpl/useXrpl.js.map +0 -1
- package/dist/hooks/xrpl/useXrplTrustLine.js +0 -159
- package/dist/hooks/xrpl/useXrplTrustLine.js.map +0 -1
- package/dist/hooks/xrpl/useXrplWallets.js +0 -51
- package/dist/hooks/xrpl/useXrplWallets.js.map +0 -1
- package/dist/provider/index.js +0 -118
- package/dist/provider/index.js.map +0 -1
- package/dist/services/external/cosmosRestClient.js +0 -45
- package/dist/services/external/cosmosRestClient.js.map +0 -1
- package/dist/services/external/ens.js +0 -66
- package/dist/services/external/ens.js.map +0 -1
- package/dist/services/external/index.js +0 -3
- package/dist/services/external/index.js.map +0 -1
- package/dist/services/external/onrampAdapter.js +0 -52
- package/dist/services/external/onrampAdapter.js.map +0 -1
- package/dist/services/external/rpcService.js +0 -411
- package/dist/services/external/rpcService.js.map +0 -1
- package/dist/services/external/secretService.js.map +0 -1
- package/dist/services/external/suiRpcClient.js +0 -80
- package/dist/services/external/suiRpcClient.js.map +0 -1
- package/dist/services/external/tokenDataService.js +0 -108
- package/dist/services/external/tokenDataService.js.map +0 -1
- package/dist/services/external/websocket.js +0 -34
- package/dist/services/external/websocket.js.map +0 -1
- package/dist/services/external/xaman.js +0 -78
- package/dist/services/external/xaman.js.map +0 -1
- package/dist/services/external/xrplRpcClient.js +0 -167
- package/dist/services/external/xrplRpcClient.js.map +0 -1
- package/dist/services/index.js +0 -19
- package/dist/services/index.js.map +0 -1
- package/dist/services/internal/apiService.js +0 -21
- package/dist/services/internal/apiService.js.map +0 -1
- package/dist/services/internal/assetsService.js +0 -569
- package/dist/services/internal/assetsService.js.map +0 -1
- package/dist/services/internal/bitcoinService.js +0 -20
- package/dist/services/internal/bitcoinService.js.map +0 -1
- package/dist/services/internal/configService.js +0 -218
- package/dist/services/internal/configService.js.map +0 -1
- package/dist/services/internal/cosmosService.js +0 -141
- package/dist/services/internal/cosmosService.js.map +0 -1
- package/dist/services/internal/countryCurrencyMap.js +0 -1102
- package/dist/services/internal/countryCurrencyMap.js.map +0 -1
- package/dist/services/internal/errorService.js +0 -190
- package/dist/services/internal/errorService.js.map +0 -1
- package/dist/services/internal/estimateService.js +0 -227
- package/dist/services/internal/estimateService.js.map +0 -1
- package/dist/services/internal/eventService.js +0 -219
- package/dist/services/internal/eventService.js.map +0 -1
- package/dist/services/internal/evmService.js +0 -67
- package/dist/services/internal/evmService.js.map +0 -1
- package/dist/services/internal/fiatToCryptoService.js +0 -84
- package/dist/services/internal/fiatToCryptoService.js.map +0 -1
- package/dist/services/internal/fiatToCryptoService.test.js +0 -45
- package/dist/services/internal/fiatToCryptoService.test.js.map +0 -1
- package/dist/services/internal/numberService.js +0 -199
- package/dist/services/internal/numberService.js.map +0 -1
- package/dist/services/internal/priceService.js +0 -53
- package/dist/services/internal/priceService.js.map +0 -1
- package/dist/services/internal/searchService.js +0 -98
- package/dist/services/internal/searchService.js.map +0 -1
- package/dist/services/internal/sendTransaction.js +0 -191
- package/dist/services/internal/sendTransaction.js.map +0 -1
- package/dist/services/internal/sendTransactionStatus.js +0 -134
- package/dist/services/internal/sendTransactionStatus.js.map +0 -1
- package/dist/services/internal/solanaService.js +0 -142
- package/dist/services/internal/solanaService.js.map +0 -1
- package/dist/services/internal/suiService.js +0 -81
- package/dist/services/internal/suiService.js.map +0 -1
- package/dist/services/internal/transactionService.js +0 -210
- package/dist/services/internal/transactionService.js.map +0 -1
- package/dist/services/internal/transactionStatusService.js +0 -390
- package/dist/services/internal/transactionStatusService.js.map +0 -1
- package/dist/services/internal/walletService.js +0 -546
- package/dist/services/internal/walletService.js.map +0 -1
- package/dist/services/internal/walletStandardService.js +0 -128
- package/dist/services/internal/walletStandardService.js.map +0 -1
- package/dist/services/internal/xionService.js +0 -6
- package/dist/services/internal/xionService.js.map +0 -1
- package/dist/services/internal/xrplService.js +0 -52
- package/dist/services/internal/xrplService.js.map +0 -1
- package/dist/tests/apiService.test.js +0 -40
- package/dist/tests/apiService.test.js.map +0 -1
- package/dist/tests/assetsService.test.js +0 -487
- package/dist/tests/assetsService.test.js.map +0 -1
- package/dist/tests/configService.test.js +0 -673
- package/dist/tests/configService.test.js.map +0 -1
- package/dist/tests/estimateService.test.js +0 -429
- package/dist/tests/estimateService.test.js.map +0 -1
- package/dist/tests/fetchSquidData.js +0 -36
- package/dist/tests/fetchSquidData.js.map +0 -1
- package/dist/tests/jest-svg-transform.d.ts +0 -0
- package/dist/tests/jest-svg-transform.js +0 -21
- package/dist/tests/jest-svg-transform.js.map +0 -1
- package/dist/tests/numberService.test.js +0 -166
- package/dist/tests/numberService.test.js.map +0 -1
- package/dist/tests/priceService.test.js +0 -38
- package/dist/tests/priceService.test.js.map +0 -1
- package/dist/tests/sample.json +0 -0
- package/dist/tests/searchService.test.js +0 -86
- package/dist/tests/searchService.test.js.map +0 -1
- package/dist/tests/swapConfig.test.js +0 -332
- package/dist/tests/swapConfig.test.js.map +0 -1
- package/dist/tests/transactionService.test.js +0 -53
- package/dist/tests/transactionService.test.js.map +0 -1
- package/dist/tests/transactionStatusService.test.js +0 -165
- package/dist/tests/transactionStatusService.test.js.map +0 -1
- package/dist/tests/walletService.test.js +0 -488
- package/dist/tests/walletService.test.js.map +0 -1
|
@@ -2,7 +2,7 @@ import type { Squid } from "@0xsquid/sdk";
|
|
|
2
2
|
import { ChainData, ChainType, Token } from "@0xsquid/squid-types";
|
|
3
3
|
import { QueryClient } from "@tanstack/react-query";
|
|
4
4
|
import type { AppConfig } from "../../core/types/config";
|
|
5
|
-
import { SwapParams } from "../../core/types/swap";
|
|
5
|
+
import { SwapDirection, SwapParams } from "../../core/types/swap";
|
|
6
6
|
import type { TokenGroup, TokenWithBalance } from "../../core/types/tokens";
|
|
7
7
|
export declare const assetsBaseUrl = "https://raw.githubusercontent.com/0xsquid/assets/main";
|
|
8
8
|
export declare const shareSubgraphId: (token1: Token, token2: Token) => boolean;
|
|
@@ -19,31 +19,28 @@ export declare const sortTokensBySharedSubgraphIds: ({ a, b, tokenToCheck, }: {
|
|
|
19
19
|
tokenToCheck: Token;
|
|
20
20
|
}) => -1 | 0 | 1;
|
|
21
21
|
/**
|
|
22
|
-
*
|
|
23
|
-
* -
|
|
22
|
+
* Returns an array of supported chain IDs based on the provided config:
|
|
23
|
+
* - If `availableChains` is defined, only chains in `availableChains` will be returned
|
|
24
|
+
* - If `disabledChains` is defined, chains in `disabledChains` will be removed
|
|
25
|
+
* - If none of the above is defined, returns all chains
|
|
26
|
+
*/
|
|
27
|
+
export declare const getSupportedChainIdsForDirection: (chainIds: string[], config: Pick<AppConfig, "availableChains" | "disabledChains">, direction?: SwapDirection) => string[];
|
|
28
|
+
/**
|
|
29
|
+
* Filter available chains based on provided config and direction
|
|
24
30
|
*/
|
|
25
31
|
export declare const filterChains: ({ chains, config, direction, }: {
|
|
26
32
|
chains: ChainData[];
|
|
27
|
-
config: Pick<AppConfig, "disabledChains">;
|
|
28
|
-
direction?:
|
|
33
|
+
config: Pick<AppConfig, "disabledChains" | "availableChains">;
|
|
34
|
+
direction?: SwapDirection | undefined;
|
|
29
35
|
}) => ChainData[];
|
|
30
36
|
/**
|
|
31
|
-
* Filter tokens based on provided config
|
|
32
|
-
* - removes tokens from disabled chains
|
|
37
|
+
* Filter tokens based on provided config and direction
|
|
33
38
|
*/
|
|
34
39
|
export declare const filterTokens: ({ tokens, config, direction, }: {
|
|
35
40
|
tokens: Token[];
|
|
36
|
-
config: Pick<AppConfig, "disabledChains">;
|
|
37
|
-
direction?:
|
|
41
|
+
config: Pick<AppConfig, "disabledChains" | "availableChains">;
|
|
42
|
+
direction?: SwapDirection | undefined;
|
|
38
43
|
}) => Token[];
|
|
39
|
-
/**
|
|
40
|
-
* Get disabled chains based on the provided config
|
|
41
|
-
* @returns array of disabled chain ids
|
|
42
|
-
*/
|
|
43
|
-
export declare function getDisabledChainsIds({ config, direction, }: {
|
|
44
|
-
config: Pick<AppConfig, "disabledChains">;
|
|
45
|
-
direction?: "from" | "to";
|
|
46
|
-
}): string[];
|
|
47
44
|
export declare function getTokenImage(token?: Pick<Token, "address" | "chainId">): string;
|
|
48
45
|
/**
|
|
49
46
|
* When user changes something from the SwapView
|
|
@@ -60,7 +57,7 @@ export declare const getNewSwapParamsFromInput: ({ inputParams, initialSwapRoute
|
|
|
60
57
|
initialSwapRoute?: SwapParams | undefined;
|
|
61
58
|
tokens: Token[];
|
|
62
59
|
chains: ChainData[];
|
|
63
|
-
config: Pick<AppConfig, "initialAssets" | "defaultTokensPerChain" | "disabledChains">;
|
|
60
|
+
config: Pick<AppConfig, "initialAssets" | "defaultTokensPerChain" | "disabledChains" | "availableChains">;
|
|
64
61
|
queryClient: QueryClient;
|
|
65
62
|
connectedSourceAddress?: string | undefined;
|
|
66
63
|
}) => SwapParams;
|
|
@@ -95,9 +92,11 @@ export declare const groupTokensByChainId: <T extends TokenWithBalance>(tokens:
|
|
|
95
92
|
* Removes some tokens based on address and chain ID.
|
|
96
93
|
* Some tokens will be returned by backend but should be hidden.
|
|
97
94
|
*
|
|
95
|
+
* Also filters tokens in `config.availableTokensPerChain` if provided.
|
|
96
|
+
*
|
|
98
97
|
* TODO: in the future we might want to have this as a token attribute instead.
|
|
99
98
|
*/
|
|
100
|
-
export declare const filterViewableTokens: (tokens: TokenWithBalance[]) => TokenWithBalance[];
|
|
99
|
+
export declare const filterViewableTokens: (tokens: TokenWithBalance[], config: Pick<AppConfig, "availableTokensPerChain">) => TokenWithBalance[];
|
|
101
100
|
export declare const getSecretNetworkBalances: (chainData: ChainData, cosmosAddress: string, squidTokens: Token[], keplrTypeWallet: any) => Promise<TokenWithBalance[]>;
|
|
102
101
|
export declare function getTokenAssetsKey(token?: Pick<Token, "address" | "chainId">): string;
|
|
103
102
|
export type AssetsColors = {
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { QueryClient } from "@tanstack/react-query";
|
|
2
2
|
import type { AppConfig } from "../../core/types/config";
|
|
3
|
+
import { SwapDirection } from "../../core/types/swap";
|
|
3
4
|
import { Chain, Token } from "../../core/types/tokens";
|
|
4
5
|
export declare const getConfigWithDefaults: (config: AppConfig | undefined) => AppConfig;
|
|
5
6
|
export declare const randomIntFromInterval: (min: number, max: number) => number;
|
|
@@ -9,14 +10,14 @@ export declare const getTokensForChain: (tokens: Token[], chainId: number | stri
|
|
|
9
10
|
* If no initial chains are found in config, returns the first available chain ID.
|
|
10
11
|
* @returns The first available chain ID.
|
|
11
12
|
*/
|
|
12
|
-
export declare const getFirstAvailableChainId: (config: Pick<AppConfig, "disabledChains" | "initialAssets"
|
|
13
|
+
export declare const getFirstAvailableChainId: (config: Pick<AppConfig, "disabledChains" | "initialAssets" | "availableChains">, direction: SwapDirection, chains?: Chain[] | undefined) => string | undefined;
|
|
13
14
|
export declare const fetchHighestBalanceToken: (fetchCachedBalance?: {
|
|
14
15
|
address?: string;
|
|
15
16
|
queryClient?: QueryClient;
|
|
16
17
|
}, chainId?: string) => string | undefined;
|
|
17
18
|
/**
|
|
18
19
|
* Returns the default token address for a specific chain and direction based on config.
|
|
19
|
-
* If no default tokens are set in config, returns the
|
|
20
|
+
* If no default tokens are set in config, returns the native token for the specified chain
|
|
20
21
|
*
|
|
21
22
|
* @param tokens The list of tokens.
|
|
22
23
|
* @param config App config
|
|
@@ -27,9 +28,9 @@ export declare const fetchHighestBalanceToken: (fetchCachedBalance?: {
|
|
|
27
28
|
*/
|
|
28
29
|
export declare const getInitialOrDefaultTokenAddressForChain: ({ tokens, config, chainId, direction, excludeToken, fetchCachedBalance, }: {
|
|
29
30
|
tokens: Token[];
|
|
30
|
-
config: Pick<AppConfig, "initialAssets" | "defaultTokensPerChain" | "disabledChains">;
|
|
31
|
+
config: Pick<AppConfig, "initialAssets" | "defaultTokensPerChain" | "disabledChains" | "availableChains">;
|
|
31
32
|
chainId: string | undefined;
|
|
32
|
-
direction:
|
|
33
|
+
direction: SwapDirection;
|
|
33
34
|
excludeToken?: {
|
|
34
35
|
address?: string | undefined;
|
|
35
36
|
chainId?: string | undefined;
|
|
@@ -53,7 +54,7 @@ export declare const getInitialTokenAddressForChain: ({ chainId, config, directi
|
|
|
53
54
|
tokens: Token[];
|
|
54
55
|
config: Pick<AppConfig, "initialAssets">;
|
|
55
56
|
chainId: string | undefined;
|
|
56
|
-
direction:
|
|
57
|
+
direction: SwapDirection;
|
|
57
58
|
unavailableTokenAddress?: string | undefined;
|
|
58
59
|
}) => string | undefined;
|
|
59
60
|
/**
|
|
@@ -82,16 +83,7 @@ export declare const filterTokensForDestination: <T extends Token>({ tokens, sel
|
|
|
82
83
|
* @returns The initial chain ID if found in config; otherwise, undefined.
|
|
83
84
|
*/
|
|
84
85
|
export declare const getInitialChainIdFromConfig: ({ config, direction, chains, }: {
|
|
85
|
-
config: Pick<AppConfig, "initialAssets" | "disabledChains">;
|
|
86
|
-
direction:
|
|
86
|
+
config: Pick<AppConfig, "initialAssets" | "disabledChains" | "availableChains">;
|
|
87
|
+
direction: SwapDirection;
|
|
87
88
|
chains: Chain[] | undefined;
|
|
88
89
|
}) => string | undefined;
|
|
89
|
-
/**
|
|
90
|
-
* Returns the unavailable chains for a specific direction based on the provided config,
|
|
91
|
-
* filtering config.disabledChains and config.comingSoonChains
|
|
92
|
-
* @returns The unavailable chains for the specified direction.
|
|
93
|
-
*/
|
|
94
|
-
export declare const getUnavailableChainIdsForDirection: ({ config, direction, }: {
|
|
95
|
-
config: Pick<AppConfig, "disabledChains">;
|
|
96
|
-
direction: "from" | "to";
|
|
97
|
-
}) => Set<string>;
|
|
@@ -74,7 +74,6 @@ export declare const calculateEstimateResults: ({ squidRoute, tokens, fromChain,
|
|
|
74
74
|
sourceChainNativeToken: Token | undefined;
|
|
75
75
|
destChainNativeToken: Token | undefined;
|
|
76
76
|
toAmountUSD: string | undefined;
|
|
77
|
-
toAmountUSDFloat: number;
|
|
78
77
|
exchangeRate: string;
|
|
79
78
|
toAmountMinUSD: string;
|
|
80
79
|
toAmountMin: string;
|
package/package.json
CHANGED
|
@@ -1,11 +1,18 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@0xsquid/react-hooks",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "8.0.0-beta.0",
|
|
4
4
|
"description": "Squid hooks monorepo",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
7
|
-
"module": "dist/index.js",
|
|
7
|
+
"module": "dist/index.esm.js",
|
|
8
8
|
"type": "module",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"import": "./dist/index.esm.js",
|
|
12
|
+
"require": "./dist/index.js",
|
|
13
|
+
"types": "./dist/index.d.ts"
|
|
14
|
+
}
|
|
15
|
+
},
|
|
9
16
|
"files": [
|
|
10
17
|
"dist",
|
|
11
18
|
"README.md"
|
|
@@ -16,12 +23,12 @@
|
|
|
16
23
|
},
|
|
17
24
|
"scripts": {
|
|
18
25
|
"clean": "rimraf dist",
|
|
19
|
-
"build": "yarn clean &&
|
|
26
|
+
"build": "yarn clean && rollup -c rollup.config.js && node scripts/copyAssets.js",
|
|
20
27
|
"lint": "eslint . --ext .js,.jsx,.ts,.tsx",
|
|
21
28
|
"lint:fix": "eslint . --ext .js,.jsx,.ts,.tsx --fix",
|
|
22
29
|
"test": "node --experimental-vm-modules node_modules/.bin/jest",
|
|
23
30
|
"release": "release-it",
|
|
24
|
-
"release:pre": "release-it --preRelease=beta",
|
|
31
|
+
"release:pre": "release-it --preRelease=rollup-beta",
|
|
25
32
|
"release:ci": "release-it --ci",
|
|
26
33
|
"release:dry": "release-it --dry-run",
|
|
27
34
|
"packlib": "rm -f squid-hooks-lib-*.tgz && yarn build && yarn pack --filename squid-hooks-lib-$(date +%s).tgz"
|
|
@@ -80,6 +87,12 @@
|
|
|
80
87
|
"@types/node": "18.7.23",
|
|
81
88
|
"@types/react": "^18.3.3",
|
|
82
89
|
"@types/react-dom": "^18.3.0",
|
|
90
|
+
"@rollup/plugin-commonjs": "^25.0.7",
|
|
91
|
+
"@rollup/plugin-json": "^6.1.0",
|
|
92
|
+
"@rollup/plugin-node-resolve": "^15.2.3",
|
|
93
|
+
"@rollup/plugin-typescript": "^11.1.6",
|
|
94
|
+
"rollup": "^4.18.0",
|
|
95
|
+
"rollup-plugin-dts": "^6.1.1",
|
|
83
96
|
"@typescript-eslint/eslint-plugin": "7.5.0",
|
|
84
97
|
"@typescript-eslint/parser": "7.5.0",
|
|
85
98
|
"autoprefixer": "9",
|
|
@@ -105,6 +118,7 @@
|
|
|
105
118
|
"rimraf": "5.0.5",
|
|
106
119
|
"ts-jest": "29.1.0",
|
|
107
120
|
"ts-loader": "9.4.1",
|
|
121
|
+
"tslib": "^2.6.3",
|
|
108
122
|
"ts-node": "10.9.2",
|
|
109
123
|
"typescript": "5.1.3"
|
|
110
124
|
},
|
|
@@ -1,128 +0,0 @@
|
|
|
1
|
-
[
|
|
2
|
-
{
|
|
3
|
-
"inputs": [
|
|
4
|
-
{
|
|
5
|
-
"internalType": "address",
|
|
6
|
-
"name": "grantee",
|
|
7
|
-
"type": "address"
|
|
8
|
-
},
|
|
9
|
-
{
|
|
10
|
-
"internalType": "address",
|
|
11
|
-
"name": "granter",
|
|
12
|
-
"type": "address"
|
|
13
|
-
}
|
|
14
|
-
],
|
|
15
|
-
"name": "allowance",
|
|
16
|
-
"outputs": [
|
|
17
|
-
{
|
|
18
|
-
"components": [
|
|
19
|
-
{
|
|
20
|
-
"internalType": "string",
|
|
21
|
-
"name": "sourcePort",
|
|
22
|
-
"type": "string"
|
|
23
|
-
},
|
|
24
|
-
{
|
|
25
|
-
"internalType": "string",
|
|
26
|
-
"name": "sourceChannel",
|
|
27
|
-
"type": "string"
|
|
28
|
-
},
|
|
29
|
-
{
|
|
30
|
-
"components": [
|
|
31
|
-
{
|
|
32
|
-
"internalType": "string",
|
|
33
|
-
"name": "denom",
|
|
34
|
-
"type": "string"
|
|
35
|
-
},
|
|
36
|
-
{
|
|
37
|
-
"internalType": "uint256",
|
|
38
|
-
"name": "amount",
|
|
39
|
-
"type": "uint256"
|
|
40
|
-
}
|
|
41
|
-
],
|
|
42
|
-
"internalType": "struct Coin[]",
|
|
43
|
-
"name": "spendLimit",
|
|
44
|
-
"type": "tuple[]"
|
|
45
|
-
},
|
|
46
|
-
{
|
|
47
|
-
"internalType": "string[]",
|
|
48
|
-
"name": "allowList",
|
|
49
|
-
"type": "string[]"
|
|
50
|
-
},
|
|
51
|
-
{
|
|
52
|
-
"internalType": "string[]",
|
|
53
|
-
"name": "allowedPacketData",
|
|
54
|
-
"type": "string[]"
|
|
55
|
-
}
|
|
56
|
-
],
|
|
57
|
-
"internalType": "struct ICS20Allocation[]",
|
|
58
|
-
"name": "allocations",
|
|
59
|
-
"type": "tuple[]"
|
|
60
|
-
}
|
|
61
|
-
],
|
|
62
|
-
"stateMutability": "view",
|
|
63
|
-
"type": "function"
|
|
64
|
-
},
|
|
65
|
-
{
|
|
66
|
-
"inputs": [
|
|
67
|
-
{
|
|
68
|
-
"internalType": "address",
|
|
69
|
-
"name": "grantee",
|
|
70
|
-
"type": "address"
|
|
71
|
-
},
|
|
72
|
-
{
|
|
73
|
-
"components": [
|
|
74
|
-
{
|
|
75
|
-
"internalType": "string",
|
|
76
|
-
"name": "sourcePort",
|
|
77
|
-
"type": "string"
|
|
78
|
-
},
|
|
79
|
-
{
|
|
80
|
-
"internalType": "string",
|
|
81
|
-
"name": "sourceChannel",
|
|
82
|
-
"type": "string"
|
|
83
|
-
},
|
|
84
|
-
{
|
|
85
|
-
"components": [
|
|
86
|
-
{
|
|
87
|
-
"internalType": "string",
|
|
88
|
-
"name": "denom",
|
|
89
|
-
"type": "string"
|
|
90
|
-
},
|
|
91
|
-
{
|
|
92
|
-
"internalType": "uint256",
|
|
93
|
-
"name": "amount",
|
|
94
|
-
"type": "uint256"
|
|
95
|
-
}
|
|
96
|
-
],
|
|
97
|
-
"internalType": "struct Coin[]",
|
|
98
|
-
"name": "spendLimit",
|
|
99
|
-
"type": "tuple[]"
|
|
100
|
-
},
|
|
101
|
-
{
|
|
102
|
-
"internalType": "string[]",
|
|
103
|
-
"name": "allowList",
|
|
104
|
-
"type": "string[]"
|
|
105
|
-
},
|
|
106
|
-
{
|
|
107
|
-
"internalType": "string[]",
|
|
108
|
-
"name": "allowedPacketData",
|
|
109
|
-
"type": "string[]"
|
|
110
|
-
}
|
|
111
|
-
],
|
|
112
|
-
"internalType": "struct ICS20Allocation[]",
|
|
113
|
-
"name": "allocations",
|
|
114
|
-
"type": "tuple[]"
|
|
115
|
-
}
|
|
116
|
-
],
|
|
117
|
-
"name": "approve",
|
|
118
|
-
"outputs": [
|
|
119
|
-
{
|
|
120
|
-
"internalType": "bool",
|
|
121
|
-
"name": "approved",
|
|
122
|
-
"type": "bool"
|
|
123
|
-
}
|
|
124
|
-
],
|
|
125
|
-
"stateMutability": "nonpayable",
|
|
126
|
-
"type": "function"
|
|
127
|
-
}
|
|
128
|
-
]
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import { ChainType } from "@0xsquid/squid-types";
|
|
2
|
-
import { StargateClient } from "@cosmjs/stargate";
|
|
3
|
-
import { SuiClient } from "@mysten/sui/client";
|
|
4
|
-
import { Connection as SolanaConnection } from "@solana/web3.js";
|
|
5
|
-
import { JsonRpcProvider } from "ethers";
|
|
6
|
-
import { getWorkingCosmosRpcUrl } from "../../services/external/rpcService";
|
|
7
|
-
import { XrplRpcClient } from "../../services/external/xrplRpcClient";
|
|
8
|
-
import { SOLANA_RPC_URL } from "../constants";
|
|
9
|
-
const clientCache = new Map();
|
|
10
|
-
export async function getClient(chain) {
|
|
11
|
-
const key = `${chain.chainType}:${chain.chainId}`;
|
|
12
|
-
if (clientCache.has(key)) {
|
|
13
|
-
return clientCache.get(key);
|
|
14
|
-
}
|
|
15
|
-
const client = await createClient(chain);
|
|
16
|
-
clientCache.set(key, client);
|
|
17
|
-
return client;
|
|
18
|
-
}
|
|
19
|
-
async function createClient(chain) {
|
|
20
|
-
switch (chain.chainType) {
|
|
21
|
-
case ChainType.EVM:
|
|
22
|
-
return new JsonRpcProvider(chain.rpc);
|
|
23
|
-
case ChainType.COSMOS:
|
|
24
|
-
const rpcUrl = await getWorkingCosmosRpcUrl(chain);
|
|
25
|
-
return (await StargateClient.connect(rpcUrl));
|
|
26
|
-
case ChainType.SOLANA:
|
|
27
|
-
return new SolanaConnection(SOLANA_RPC_URL);
|
|
28
|
-
case ChainType.BTC:
|
|
29
|
-
return null;
|
|
30
|
-
case ChainType.SUI:
|
|
31
|
-
return new SuiClient({
|
|
32
|
-
url: chain.rpc,
|
|
33
|
-
});
|
|
34
|
-
case ChainType.XRPL:
|
|
35
|
-
return new XrplRpcClient(chain.rpc);
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/core/client/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAa,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAC5D,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAC/C,OAAO,EAAE,UAAU,IAAI,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AACjE,OAAO,EAAE,eAAe,EAAE,MAAM,QAAQ,CAAC;AACzC,OAAO,EAAE,sBAAsB,EAAE,MAAM,oCAAoC,CAAC;AAC5E,OAAO,EAAE,aAAa,EAAE,MAAM,uCAAuC,CAAC;AACtE,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAa9C,MAAM,WAAW,GAAG,IAAI,GAAG,EAAgD,CAAC;AAE5E,MAAM,CAAC,KAAK,UAAU,SAAS,CAC7B,KAAgB;IAEhB,MAAM,GAAG,GAAG,GAAG,KAAK,CAAC,SAAS,IAAI,KAAK,CAAC,OAAO,EAAW,CAAC;IAE3D,IAAI,WAAW,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE;QACxB,OAAO,WAAW,CAAC,GAAG,CAAC,GAAG,CAAyB,CAAC;KACrD;IAED,MAAM,MAAM,GAAG,MAAM,YAAY,CAAI,KAAK,CAAC,CAAC;IAE5C,WAAW,CAAC,GAAG,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC;IAE7B,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,KAAK,UAAU,YAAY,CACzB,KAAgB;IAEhB,QAAQ,KAAK,CAAC,SAAS,EAAE;QACvB,KAAK,SAAS,CAAC,GAAG;YAChB,OAAO,IAAI,eAAe,CAAC,KAAK,CAAC,GAAG,CAAyB,CAAC;QAEhE,KAAK,SAAS,CAAC,MAAM;YACnB,MAAM,MAAM,GAAG,MAAM,sBAAsB,CAAC,KAAK,CAAC,CAAC;YACnD,OAAO,CAAC,MAAM,cAAc,CAAC,OAAO,CAAC,MAAM,CAAC,CAAyB,CAAC;QAExE,KAAK,SAAS,CAAC,MAAM;YACnB,OAAO,IAAI,gBAAgB,CAAC,cAAc,CAAyB,CAAC;QAEtE,KAAK,SAAS,CAAC,GAAG;YAChB,OAAO,IAA4B,CAAC;QAEtC,KAAK,SAAS,CAAC,GAAG;YAChB,OAAO,IAAI,SAAS,CAAC;gBACnB,GAAG,EAAE,KAAK,CAAC,GAAG;aACf,CAAyB,CAAC;QAE7B,KAAK,SAAS,CAAC,IAAI;YACjB,OAAO,IAAI,aAAa,CAAC,KAAK,CAAC,GAAG,CAAyB,CAAC;KAC/D;AACH,CAAC"}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
class BitcoinConnectorError extends Error {
|
|
2
|
-
constructor(message) {
|
|
3
|
-
super(message);
|
|
4
|
-
this.name = "BitcoinConnectorError";
|
|
5
|
-
}
|
|
6
|
-
}
|
|
7
|
-
export class BitcoinConnectorProviderNotFoundError extends BitcoinConnectorError {
|
|
8
|
-
constructor(providerName) {
|
|
9
|
-
super(`Bitcoin provider ${providerName} not found`);
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
|
-
export class BitcoinConnectorTransactionFailedError extends BitcoinConnectorError {
|
|
13
|
-
constructor() {
|
|
14
|
-
super("Bitcoin transaction failed");
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
export class BitcoinConnectorInvalidAccountError extends BitcoinConnectorError {
|
|
18
|
-
constructor() {
|
|
19
|
-
super("Bitcoin account is invalid");
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/core/connectors/bitcoin/errors/index.ts"],"names":[],"mappings":"AAAA,MAAM,qBAAsB,SAAQ,KAAK;IACvC,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,uBAAuB,CAAC;IACtC,CAAC;CACF;AAED,MAAM,OAAO,qCAAsC,SAAQ,qBAAqB;IAC9E,YAAY,YAAoB;QAC9B,KAAK,CAAC,oBAAoB,YAAY,YAAY,CAAC,CAAC;IACtD,CAAC;CACF;AAED,MAAM,OAAO,sCAAuC,SAAQ,qBAAqB;IAC/E;QACE,KAAK,CAAC,4BAA4B,CAAC,CAAC;IACtC,CAAC;CACF;AAED,MAAM,OAAO,mCAAoC,SAAQ,qBAAqB;IAC5E;QACE,KAAK,CAAC,4BAA4B,CAAC,CAAC;IACtC,CAAC;CACF"}
|
|
@@ -1,91 +0,0 @@
|
|
|
1
|
-
import * as ecc from "@bitcoinerlab/secp256k1";
|
|
2
|
-
import axios from "axios";
|
|
3
|
-
import * as bitcoin from "bitcoinjs-lib";
|
|
4
|
-
bitcoin.initEccLib(ecc);
|
|
5
|
-
const network = bitcoin.networks.bitcoin;
|
|
6
|
-
export const fromHexString = (hexString) => {
|
|
7
|
-
const matches = hexString.match(/.{1,2}/g);
|
|
8
|
-
if (!matches) {
|
|
9
|
-
throw new Error("Invalid hex string");
|
|
10
|
-
}
|
|
11
|
-
return Uint8Array.from(matches.map((byte) => parseInt(byte, 16)));
|
|
12
|
-
};
|
|
13
|
-
export async function createSendBtcPsbt(senderAddress, recipientAddress, amount) {
|
|
14
|
-
const feeRate = await getFeeRate();
|
|
15
|
-
const utxos = await getAddressUtxos(senderAddress);
|
|
16
|
-
if (!utxos) {
|
|
17
|
-
throw new Error("No UTXOs found");
|
|
18
|
-
}
|
|
19
|
-
// Sort UTXOs by value in descending order
|
|
20
|
-
// This ensures that we select the UTXOs with the highest value first
|
|
21
|
-
// to optimize the transaction size
|
|
22
|
-
const sortedUtxos = utxos.sort((a, b) => b.value - a.value);
|
|
23
|
-
// Sum up the values of the UTXOs up to the desired amount
|
|
24
|
-
let inputAmount = 0;
|
|
25
|
-
const inputs = [];
|
|
26
|
-
for (const utxo of sortedUtxos) {
|
|
27
|
-
inputAmount += utxo.value;
|
|
28
|
-
inputs.push(utxo);
|
|
29
|
-
if (inputAmount >= amount)
|
|
30
|
-
break;
|
|
31
|
-
}
|
|
32
|
-
if (inputAmount < amount)
|
|
33
|
-
throw new Error("Insufficient balance");
|
|
34
|
-
const outputsCount = 2; // Only two outputs, recipient and change outputs
|
|
35
|
-
// Calculate fee based on the byte size of the total inputs and outputs
|
|
36
|
-
// Approximate transaction size = (inputs * 150 bytes + outputs * 34 bytes + 10 bytes overhead)
|
|
37
|
-
const transactionSize = inputs.length * 150 + outputsCount * 34 + 10;
|
|
38
|
-
const fee = feeRate * transactionSize;
|
|
39
|
-
const satsNeeded = fee + amount;
|
|
40
|
-
const psbt = new bitcoin.Psbt({ network });
|
|
41
|
-
let amountGathered = 0;
|
|
42
|
-
for (const utxo of sortedUtxos) {
|
|
43
|
-
const { txid, vout, value } = utxo;
|
|
44
|
-
const script = bitcoin.address.toOutputScript(senderAddress, network);
|
|
45
|
-
psbt.addInput({
|
|
46
|
-
hash: txid,
|
|
47
|
-
index: vout,
|
|
48
|
-
witnessUtxo: {
|
|
49
|
-
script,
|
|
50
|
-
value: BigInt(value),
|
|
51
|
-
},
|
|
52
|
-
});
|
|
53
|
-
amountGathered += value;
|
|
54
|
-
if (amountGathered >= satsNeeded) {
|
|
55
|
-
break;
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
psbt.addOutput({
|
|
59
|
-
address: recipientAddress,
|
|
60
|
-
value: BigInt(amount),
|
|
61
|
-
});
|
|
62
|
-
if (amountGathered > satsNeeded) {
|
|
63
|
-
psbt.addOutput({
|
|
64
|
-
address: senderAddress,
|
|
65
|
-
value: BigInt(amountGathered - satsNeeded),
|
|
66
|
-
});
|
|
67
|
-
}
|
|
68
|
-
return {
|
|
69
|
-
psbtHex: psbt.toHex(),
|
|
70
|
-
};
|
|
71
|
-
}
|
|
72
|
-
export async function broadcastTx(txHex) {
|
|
73
|
-
return axios
|
|
74
|
-
.post(`https://mempool.space/api/tx`, txHex)
|
|
75
|
-
.then((res) => res.data);
|
|
76
|
-
}
|
|
77
|
-
async function getAddressUtxos(address) {
|
|
78
|
-
return axios
|
|
79
|
-
.get(`https://mempool.space/api/address/${address}/utxo`)
|
|
80
|
-
.then((response) => response.data);
|
|
81
|
-
}
|
|
82
|
-
export async function getFeeRate() {
|
|
83
|
-
const response = await axios.get("https://mempool.space/api/v1/fees/recommended");
|
|
84
|
-
return response.data.halfHourFee;
|
|
85
|
-
}
|
|
86
|
-
export async function getTransactionStatus(txHash) {
|
|
87
|
-
return axios
|
|
88
|
-
.get(`https://mempool.space/api/tx/${txHash}`)
|
|
89
|
-
.then((response) => response.data);
|
|
90
|
-
}
|
|
91
|
-
//# sourceMappingURL=helpers.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"helpers.js","sourceRoot":"","sources":["../../../../src/core/connectors/bitcoin/helpers.ts"],"names":[],"mappings":"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"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/core/connectors/bitcoin/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/core/connectors/bitcoin/wallets/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AACzC,OAAO,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAC7C,OAAO,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC"}
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { BitcoinConnectorInvalidAccountError, BitcoinConnectorProviderNotFoundError, BitcoinConnectorTransactionFailedError, } from "../errors";
|
|
2
|
-
export class KeplrConnector {
|
|
3
|
-
get getProvider() {
|
|
4
|
-
const provider = window?.bitcoin_keplr;
|
|
5
|
-
if (!provider) {
|
|
6
|
-
throw new BitcoinConnectorProviderNotFoundError("Keplr");
|
|
7
|
-
}
|
|
8
|
-
return provider;
|
|
9
|
-
}
|
|
10
|
-
async sendBTC(to, amount) {
|
|
11
|
-
const txHash = await this.getProvider.sendBitcoin(to, amount);
|
|
12
|
-
if (!txHash) {
|
|
13
|
-
throw new BitcoinConnectorTransactionFailedError();
|
|
14
|
-
}
|
|
15
|
-
return { txHash };
|
|
16
|
-
}
|
|
17
|
-
async requestAccount() {
|
|
18
|
-
const accounts = await this.getProvider.requestAccounts();
|
|
19
|
-
const account = accounts[0];
|
|
20
|
-
if (typeof account !== "string") {
|
|
21
|
-
throw new BitcoinConnectorInvalidAccountError();
|
|
22
|
-
}
|
|
23
|
-
return {
|
|
24
|
-
address: account,
|
|
25
|
-
};
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
//# sourceMappingURL=keplr.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"keplr.js","sourceRoot":"","sources":["../../../../../src/core/connectors/bitcoin/wallets/keplr.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,mCAAmC,EACnC,qCAAqC,EACrC,sCAAsC,GACvC,MAAM,WAAW,CAAC;AAEnB,MAAM,OAAO,cAAc;IACzB,IAAW,WAAW;QACpB,MAAM,QAAQ,GAAI,MAAc,EAAE,aAAa,CAAC;QAEhD,IAAI,CAAC,QAAQ,EAAE;YACb,MAAM,IAAI,qCAAqC,CAAC,OAAO,CAAC,CAAC;SAC1D;QAED,OAAO,QAAQ,CAAC;IAClB,CAAC;IAED,KAAK,CAAC,OAAO,CAAC,EAAU,EAAE,MAAc;QACtC,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,WAAW,CAAC,WAAW,CAAC,EAAE,EAAE,MAAM,CAAC,CAAC;QAE9D,IAAI,CAAC,MAAM,EAAE;YACX,MAAM,IAAI,sCAAsC,EAAE,CAAC;SACpD;QAED,OAAO,EAAE,MAAM,EAAE,CAAC;IACpB,CAAC;IAED,KAAK,CAAC,cAAc;QAClB,MAAM,QAAQ,GAAa,MAAM,IAAI,CAAC,WAAW,CAAC,eAAe,EAAE,CAAC;QAEpE,MAAM,OAAO,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAC;QAE5B,IAAI,OAAO,OAAO,KAAK,QAAQ,EAAE;YAC/B,MAAM,IAAI,mCAAmC,EAAE,CAAC;SACjD;QAED,OAAO;YACL,OAAO,EAAE,OAAO;SACjB,CAAC;IACJ,CAAC;CACF"}
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
import * as bitcoin from "bitcoinjs-lib";
|
|
2
|
-
import { BitcoinConnectorInvalidAccountError, BitcoinConnectorProviderNotFoundError, BitcoinConnectorTransactionFailedError, } from "../errors";
|
|
3
|
-
import { broadcastTx, createSendBtcPsbt, fromHexString } from "../helpers";
|
|
4
|
-
const MAINNET = bitcoin.networks.bitcoin;
|
|
5
|
-
export class PhantomConnector {
|
|
6
|
-
get getProvider() {
|
|
7
|
-
const provider = window?.phantom?.bitcoin;
|
|
8
|
-
if (!provider) {
|
|
9
|
-
throw new BitcoinConnectorProviderNotFoundError("Phantom");
|
|
10
|
-
}
|
|
11
|
-
return provider;
|
|
12
|
-
}
|
|
13
|
-
async requestAccount() {
|
|
14
|
-
const phantomAccounts = await this.getProvider.requestAccounts();
|
|
15
|
-
if (!phantomAccounts)
|
|
16
|
-
throw new BitcoinConnectorInvalidAccountError();
|
|
17
|
-
const paymentAccount = phantomAccounts.find((account) => account.purpose === "payment");
|
|
18
|
-
if (typeof paymentAccount?.address !== "string") {
|
|
19
|
-
throw new BitcoinConnectorInvalidAccountError();
|
|
20
|
-
}
|
|
21
|
-
return {
|
|
22
|
-
address: paymentAccount.address,
|
|
23
|
-
};
|
|
24
|
-
}
|
|
25
|
-
async sendBTC(to, amount) {
|
|
26
|
-
const { address } = await this.requestAccount();
|
|
27
|
-
const { psbtHex } = await createSendBtcPsbt(address, to, amount);
|
|
28
|
-
const { txId } = await this.signPsbt(psbtHex);
|
|
29
|
-
if (!txId)
|
|
30
|
-
throw new BitcoinConnectorTransactionFailedError();
|
|
31
|
-
return { txHash: txId };
|
|
32
|
-
}
|
|
33
|
-
async signPsbt(psbtHex) {
|
|
34
|
-
const { address: paymentAddress } = await this.requestAccount();
|
|
35
|
-
const toSignPsbt = bitcoin.Psbt.fromHex(String(psbtHex), {
|
|
36
|
-
network: MAINNET,
|
|
37
|
-
});
|
|
38
|
-
const inputs = toSignPsbt.data.inputs;
|
|
39
|
-
const inputsToSign = [
|
|
40
|
-
{
|
|
41
|
-
// Need to sign each input with the payment address
|
|
42
|
-
address: paymentAddress,
|
|
43
|
-
signingIndexes: inputs.map((_, index) => index),
|
|
44
|
-
},
|
|
45
|
-
];
|
|
46
|
-
const signedPsbtBytes = await this.getProvider.signPSBT(fromHexString(psbtHex), {
|
|
47
|
-
inputsToSign,
|
|
48
|
-
});
|
|
49
|
-
const signedPsbt = bitcoin.Psbt.fromBuffer(signedPsbtBytes);
|
|
50
|
-
signedPsbt.finalizeAllInputs();
|
|
51
|
-
const tx = signedPsbt.extractTransaction();
|
|
52
|
-
const txId = await broadcastTx(tx.toHex());
|
|
53
|
-
return { txId };
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
//# sourceMappingURL=phantom.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"phantom.js","sourceRoot":"","sources":["../../../../../src/core/connectors/bitcoin/wallets/phantom.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,OAAO,MAAM,eAAe,CAAC;AAEzC,OAAO,EACL,mCAAmC,EACnC,qCAAqC,EACrC,sCAAsC,GACvC,MAAM,WAAW,CAAC;AACnB,OAAO,EAAE,WAAW,EAAE,iBAAiB,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAC3E,MAAM,OAAO,GAAG,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAC;AAsBzC,MAAM,OAAO,gBAAgB;IAC3B,IAAW,WAAW;QACpB,MAAM,QAAQ,GAAI,MAAc,EAAE,OAAO,EAAE,OAAO,CAAC;QAEnD,IAAI,CAAC,QAAQ,EAAE;YACb,MAAM,IAAI,qCAAqC,CAAC,SAAS,CAAC,CAAC;SAC5D;QAED,OAAO,QAAQ,CAAC;IAClB,CAAC;IAED,KAAK,CAAC,cAAc;QAClB,MAAM,eAAe,GAAG,MAAM,IAAI,CAAC,WAAW,CAAC,eAAe,EAAE,CAAC;QAEjE,IAAI,CAAC,eAAe;YAAE,MAAM,IAAI,mCAAmC,EAAE,CAAC;QAEtE,MAAM,cAAc,GAAG,eAAe,CAAC,IAAI,CACzC,CAAC,OAA4B,EAAE,EAAE,CAAC,OAAO,CAAC,OAAO,KAAK,SAAS,CAChE,CAAC;QAEF,IAAI,OAAO,cAAc,EAAE,OAAO,KAAK,QAAQ,EAAE;YAC/C,MAAM,IAAI,mCAAmC,EAAE,CAAC;SACjD;QAED,OAAO;YACL,OAAO,EAAE,cAAc,CAAC,OAAO;SAChC,CAAC;IACJ,CAAC;IAED,KAAK,CAAC,OAAO,CAAC,EAAU,EAAE,MAAc;QACtC,MAAM,EAAE,OAAO,EAAE,GAAG,MAAM,IAAI,CAAC,cAAc,EAAE,CAAC;QAChD,MAAM,EAAE,OAAO,EAAE,GAAG,MAAM,iBAAiB,CAAC,OAAO,EAAE,EAAE,EAAE,MAAM,CAAC,CAAC;QACjE,MAAM,EAAE,IAAI,EAAE,GAAG,MAAM,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;QAE9C,IAAI,CAAC,IAAI;YAAE,MAAM,IAAI,sCAAsC,EAAE,CAAC;QAE9D,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC;IAC1B,CAAC;IAEO,KAAK,CAAC,QAAQ,CAAC,OAAe;QAGpC,MAAM,EAAE,OAAO,EAAE,cAAc,EAAE,GAAG,MAAM,IAAI,CAAC,cAAc,EAAE,CAAC;QAEhE,MAAM,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,OAAO,CAAC,EAAE;YACvD,OAAO,EAAE,OAAO;SACjB,CAAC,CAAC;QAEH,MAAM,MAAM,GAAG,UAAU,CAAC,IAAI,CAAC,MAAM,CAAC;QACtC,MAAM,YAAY,GAAG;YACnB;gBACE,mDAAmD;gBACnD,OAAO,EAAE,cAAc;gBACvB,cAAc,EAAE,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC;aAChD;SACF,CAAC;QAEF,MAAM,eAAe,GAAG,MAAM,IAAI,CAAC,WAAW,CAAC,QAAQ,CACrD,aAAa,CAAC,OAAO,CAAC,EACtB;YACE,YAAY;SACb,CACF,CAAC;QAEF,MAAM,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC,UAAU,CAAC,eAAe,CAAC,CAAC;QAE5D,UAAU,CAAC,iBAAiB,EAAE,CAAC;QAE/B,MAAM,EAAE,GAAG,UAAU,CAAC,kBAAkB,EAAE,CAAC;QAE3C,MAAM,IAAI,GAAG,MAAM,WAAW,CAAC,EAAE,CAAC,KAAK,EAAE,CAAC,CAAC;QAE3C,OAAO,EAAE,IAAI,EAAE,CAAC;IAClB,CAAC;CACF"}
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { BitcoinConnectorInvalidAccountError, BitcoinConnectorProviderNotFoundError, BitcoinConnectorTransactionFailedError, } from "../errors";
|
|
2
|
-
export class UnisatConnector {
|
|
3
|
-
get getProvider() {
|
|
4
|
-
const provider = window?.unisat;
|
|
5
|
-
if (!provider) {
|
|
6
|
-
throw new BitcoinConnectorProviderNotFoundError("Unisat");
|
|
7
|
-
}
|
|
8
|
-
return provider;
|
|
9
|
-
}
|
|
10
|
-
async sendBTC(to, amount) {
|
|
11
|
-
const txHash = await this.getProvider.sendBitcoin(to, amount);
|
|
12
|
-
if (!txHash) {
|
|
13
|
-
throw new BitcoinConnectorTransactionFailedError();
|
|
14
|
-
}
|
|
15
|
-
return { txHash };
|
|
16
|
-
}
|
|
17
|
-
async requestAccount() {
|
|
18
|
-
const accounts = await this.getProvider.requestAccounts();
|
|
19
|
-
const account = accounts[0];
|
|
20
|
-
if (typeof account !== "string") {
|
|
21
|
-
throw new BitcoinConnectorInvalidAccountError();
|
|
22
|
-
}
|
|
23
|
-
return {
|
|
24
|
-
address: account,
|
|
25
|
-
};
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
//# sourceMappingURL=unisat.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"unisat.js","sourceRoot":"","sources":["../../../../../src/core/connectors/bitcoin/wallets/unisat.ts"],"names":[],"mappings":"AACA,OAAO,EACL,mCAAmC,EACnC,qCAAqC,EACrC,sCAAsC,GACvC,MAAM,WAAW,CAAC;AAOnB,MAAM,OAAO,eAAe;IAC1B,IAAW,WAAW;QACpB,MAAM,QAAQ,GAAI,MAAc,EAAE,MAAM,CAAC;QAEzC,IAAI,CAAC,QAAQ,EAAE;YACb,MAAM,IAAI,qCAAqC,CAAC,QAAQ,CAAC,CAAC;SAC3D;QAED,OAAO,QAAQ,CAAC;IAClB,CAAC;IAED,KAAK,CAAC,OAAO,CAAC,EAAU,EAAE,MAAc;QACtC,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,WAAW,CAAC,WAAW,CAAC,EAAE,EAAE,MAAM,CAAC,CAAC;QAE9D,IAAI,CAAC,MAAM,EAAE;YACX,MAAM,IAAI,sCAAsC,EAAE,CAAC;SACpD;QAED,OAAO,EAAE,MAAM,EAAE,CAAC;IACpB,CAAC;IAED,KAAK,CAAC,cAAc;QAClB,MAAM,QAAQ,GAAa,MAAM,IAAI,CAAC,WAAW,CAAC,eAAe,EAAE,CAAC;QAEpE,MAAM,OAAO,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAC;QAE5B,IAAI,OAAO,OAAO,KAAK,QAAQ,EAAE;YAC/B,MAAM,IAAI,mCAAmC,EAAE,CAAC;SACjD;QAED,OAAO;YACL,OAAO,EAAE,OAAO;SACjB,CAAC;IACJ,CAAC;CACF"}
|