@0xsquid/react-hooks 1.0.4 → 1.0.6
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/assets/images/icons/wallets/index.d.ts +22 -0
- package/{src/assets/images/icons/wallets/index.ts → dist/assets/images/icons/wallets/index.js} +21 -21
- package/dist/assets/images/icons/wallets/index.js.map +1 -0
- package/dist/connectors/ExodusConnector.d.ts +4 -0
- package/{src/connectors/ExodusConnector.ts → dist/connectors/ExodusConnector.js} +3 -3
- package/dist/connectors/ExodusConnector.js.map +1 -0
- package/dist/connectors/LedgerLiveConnector.d.ts +40 -0
- package/dist/connectors/LedgerLiveConnector.js +177 -0
- package/dist/connectors/LedgerLiveConnector.js.map +1 -0
- package/dist/contracts/typechain/factories/ERC20__factory.js +324 -0
- package/dist/contracts/typechain/factories/ERC20__factory.js.map +1 -0
- package/dist/core/constants.d.ts +37 -0
- package/dist/core/constants.js +487 -0
- package/dist/core/constants.js.map +1 -0
- package/dist/core/externalLinks.d.ts +18 -0
- package/{src/core/externalLinks.ts → dist/core/externalLinks.js} +5 -9
- package/dist/core/externalLinks.js.map +1 -0
- package/dist/core/index.js +2 -0
- package/dist/core/index.js.map +1 -0
- package/dist/core/multicall3.d.ts +16 -0
- package/dist/core/multicall3.js +23 -0
- package/dist/core/multicall3.js.map +1 -0
- package/dist/core/numbers.d.ts +3 -0
- package/dist/core/numbers.js +28 -0
- package/dist/core/numbers.js.map +1 -0
- package/dist/core/providers/CosmosProvider.d.ts +34 -0
- package/dist/core/providers/CosmosProvider.js +12 -0
- package/dist/core/providers/CosmosProvider.js.map +1 -0
- package/dist/core/queries/queries-keys.d.ts +34 -0
- package/dist/core/queries/queries-keys.js +120 -0
- package/dist/core/queries/queries-keys.js.map +1 -0
- package/dist/core/queries/react-query-config.d.ts +3 -0
- package/dist/core/queries/react-query-config.js +11 -0
- package/dist/core/queries/react-query-config.js.map +1 -0
- package/dist/core/types/components.d.ts +14 -0
- package/dist/core/types/components.js +2 -0
- package/dist/core/types/components.js.map +1 -0
- package/dist/core/types/config.d.ts +47 -0
- package/dist/core/types/config.js +2 -0
- package/dist/core/types/config.js.map +1 -0
- package/dist/core/types/dex.d.ts +28 -0
- package/dist/core/types/dex.js +33 -0
- package/dist/core/types/dex.js.map +1 -0
- package/dist/core/types/error.d.ts +44 -0
- package/dist/core/types/error.js +12 -0
- package/dist/core/types/error.js.map +1 -0
- package/dist/core/types/event.d.ts +17 -0
- package/dist/core/types/event.js +2 -0
- package/dist/core/types/event.js.map +1 -0
- package/dist/core/types/route.d.ts +9 -0
- package/dist/core/types/route.js +4 -0
- package/dist/core/types/route.js.map +1 -0
- package/dist/core/types/swap.d.ts +8 -0
- package/dist/core/types/swap.js +2 -0
- package/dist/core/types/swap.js.map +1 -0
- package/dist/core/types/tokens.d.ts +29 -0
- package/dist/core/types/tokens.js +2 -0
- package/dist/core/types/tokens.js.map +1 -0
- package/dist/core/types/transaction.d.ts +68 -0
- package/dist/core/types/transaction.js +38 -0
- package/dist/core/types/transaction.js.map +1 -0
- package/dist/core/types/types.d.ts +30 -0
- package/dist/core/types/types.js +7 -0
- package/dist/core/types/types.js.map +1 -0
- package/dist/core/types/wallet.d.ts +55 -0
- package/dist/core/types/wallet.js +26 -0
- package/dist/core/types/wallet.js.map +1 -0
- package/dist/hooks/chains/useSquidChains.d.ts +12 -0
- package/dist/hooks/chains/useSquidChains.js +45 -0
- package/dist/hooks/chains/useSquidChains.js.map +1 -0
- package/dist/hooks/cosmos/useCosmos.d.ts +33 -0
- package/dist/hooks/cosmos/useCosmos.js +194 -0
- package/dist/hooks/cosmos/useCosmos.js.map +1 -0
- package/dist/hooks/cosmos/useCosmosForChain.d.ts +4 -0
- package/dist/hooks/cosmos/useCosmosForChain.js +22 -0
- package/dist/hooks/cosmos/useCosmosForChain.js.map +1 -0
- package/{src/hooks/index.ts → dist/hooks/index.d.ts} +1 -7
- package/dist/hooks/index.js +27 -0
- package/dist/hooks/index.js.map +1 -0
- package/dist/hooks/navigation/useKeyboardNavigation.d.ts +7 -0
- package/dist/hooks/navigation/useKeyboardNavigation.js +69 -0
- package/dist/hooks/navigation/useKeyboardNavigation.js.map +1 -0
- package/dist/hooks/store/useSquidStore.d.ts +105 -0
- package/dist/hooks/store/useSquidStore.js +35 -0
- package/dist/hooks/store/useSquidStore.js.map +1 -0
- package/dist/hooks/swap/useSwap.d.ts +25 -0
- package/dist/hooks/swap/useSwap.js +229 -0
- package/dist/hooks/swap/useSwap.js.map +1 -0
- package/dist/hooks/tokens/useAllTokensWithBalance.d.ts +11 -0
- package/dist/hooks/tokens/useAllTokensWithBalance.js +97 -0
- package/dist/hooks/tokens/useAllTokensWithBalance.js.map +1 -0
- package/dist/hooks/tokens/useBalance.d.ts +34 -0
- package/dist/hooks/tokens/useBalance.js +112 -0
- package/dist/hooks/tokens/useBalance.js.map +1 -0
- package/dist/hooks/tokens/useMultiChainBalance.d.ts +17 -0
- package/dist/hooks/tokens/useMultiChainBalance.js +36 -0
- package/dist/hooks/tokens/useMultiChainBalance.js.map +1 -0
- package/dist/hooks/tokens/usePrices.d.ts +6 -0
- package/dist/hooks/tokens/usePrices.js +42 -0
- package/dist/hooks/tokens/usePrices.js.map +1 -0
- package/dist/hooks/tokens/useSingleTokenPrice.d.ts +10 -0
- package/dist/hooks/tokens/useSingleTokenPrice.js +32 -0
- package/dist/hooks/tokens/useSingleTokenPrice.js.map +1 -0
- package/dist/hooks/tokens/useSquidTokens.d.ts +13 -0
- package/dist/hooks/tokens/useSquidTokens.js +35 -0
- package/dist/hooks/tokens/useSquidTokens.js.map +1 -0
- package/dist/hooks/tokens/useTokensWithBalance.d.ts +7 -0
- package/dist/hooks/tokens/useTokensWithBalance.js +111 -0
- package/dist/hooks/tokens/useTokensWithBalance.js.map +1 -0
- package/dist/hooks/transaction/useEstimate.d.ts +44 -0
- package/dist/hooks/transaction/useEstimate.js +274 -0
- package/dist/hooks/transaction/useEstimate.js.map +1 -0
- package/dist/hooks/transaction/useEstimatePriceImpact.d.ts +7 -0
- package/dist/hooks/transaction/useEstimatePriceImpact.js +26 -0
- package/dist/hooks/transaction/useEstimatePriceImpact.js.map +1 -0
- package/dist/hooks/transaction/useExecuteTransaction.d.ts +20 -0
- package/dist/hooks/transaction/useExecuteTransaction.js +310 -0
- package/dist/hooks/transaction/useExecuteTransaction.js.map +1 -0
- package/dist/hooks/transaction/useExpress.d.ts +5 -0
- package/dist/hooks/transaction/useExpress.js +31 -0
- package/dist/hooks/transaction/useExpress.js.map +1 -0
- package/dist/hooks/transaction/useGetRoute.d.ts +14 -0
- package/dist/hooks/transaction/useGetRoute.js +96 -0
- package/dist/hooks/transaction/useGetRoute.js.map +1 -0
- package/dist/hooks/transaction/useSingleTransaction.d.ts +8 -0
- package/dist/hooks/transaction/useSingleTransaction.js +99 -0
- package/dist/hooks/transaction/useSingleTransaction.js.map +1 -0
- package/dist/hooks/transaction/useTransaction.d.ts +25 -0
- package/dist/hooks/transaction/useTransaction.js +521 -0
- package/dist/hooks/transaction/useTransaction.js.map +1 -0
- package/dist/hooks/user/useUserParams.d.ts +6 -0
- package/dist/hooks/user/useUserParams.js +41 -0
- package/dist/hooks/user/useUserParams.js.map +1 -0
- package/dist/hooks/wallet/useAddToken.d.ts +4 -0
- package/dist/hooks/wallet/useAddToken.js +45 -0
- package/dist/hooks/wallet/useAddToken.js.map +1 -0
- package/dist/hooks/wallet/useAutoConnect.d.ts +6 -0
- package/dist/hooks/wallet/useAutoConnect.js +44 -0
- package/dist/hooks/wallet/useAutoConnect.js.map +1 -0
- package/dist/hooks/wallet/useGnosisContext.d.ts +7 -0
- package/dist/hooks/wallet/useGnosisContext.js +70 -0
- package/dist/hooks/wallet/useGnosisContext.js.map +1 -0
- package/dist/hooks/wallet/useIntegratorContext.d.ts +5 -0
- package/dist/hooks/wallet/useIntegratorContext.js +39 -0
- package/dist/hooks/wallet/useIntegratorContext.js.map +1 -0
- package/dist/hooks/wallet/useMultiChainWallet.d.ts +8 -0
- package/dist/hooks/wallet/useMultiChainWallet.js +113 -0
- package/dist/hooks/wallet/useMultiChainWallet.js.map +1 -0
- package/dist/hooks/wallet/useWallet.d.ts +6 -0
- package/dist/hooks/wallet/useWallet.js +65 -0
- package/dist/hooks/wallet/useWallet.js.map +1 -0
- package/dist/hooks/webapp-router/useSquidRouter.d.ts +11 -0
- package/dist/hooks/webapp-router/useSquidRouter.js +33 -0
- package/dist/hooks/webapp-router/useSquidRouter.js.map +1 -0
- package/{src/index.ts → dist/index.d.ts} +0 -1
- package/dist/index.js.map +1 -0
- package/dist/provider/index.d.ts +10 -0
- package/dist/provider/index.js +71 -0
- package/dist/provider/index.js.map +1 -0
- package/dist/services/external/analyticsService.d.ts +18 -0
- package/dist/services/external/analyticsService.js +30 -0
- package/dist/services/external/analyticsService.js.map +1 -0
- package/dist/services/external/coingeckoService.d.ts +8 -0
- package/dist/services/external/coingeckoService.js +20 -0
- package/dist/services/external/coingeckoService.js.map +1 -0
- package/dist/services/external/rpcService.d.ts +4 -0
- package/dist/services/external/rpcService.js +145 -0
- package/dist/services/external/rpcService.js.map +1 -0
- package/dist/services/external/secretService.d.ts +28 -0
- package/dist/services/external/secretService.js +129 -0
- package/dist/services/external/secretService.js.map +1 -0
- package/dist/services/index.js +2 -0
- package/dist/services/index.js.map +1 -0
- package/dist/services/internal/apiService.d.ts +4 -0
- package/dist/services/internal/apiService.js +7 -0
- package/dist/services/internal/apiService.js.map +1 -0
- package/dist/services/internal/assetsService.d.ts +28 -0
- package/dist/services/internal/assetsService.js +46 -0
- package/dist/services/internal/assetsService.js.map +1 -0
- package/dist/services/internal/configService.d.ts +40 -0
- package/dist/services/internal/configService.js +119 -0
- package/dist/services/internal/configService.js.map +1 -0
- package/dist/services/internal/errorService.d.ts +30 -0
- package/{src/services/internal/errorService.ts → dist/services/internal/errorService.js} +35 -54
- package/dist/services/internal/errorService.js.map +1 -0
- package/dist/services/internal/eventService.d.ts +52 -0
- package/dist/services/internal/eventService.js +66 -0
- package/dist/services/internal/eventService.js.map +1 -0
- package/dist/services/internal/priceService.d.ts +1 -0
- package/dist/services/internal/priceService.js +7 -0
- package/dist/services/internal/priceService.js.map +1 -0
- package/dist/services/internal/transactionService.d.ts +43 -0
- package/dist/services/internal/transactionService.js +172 -0
- package/dist/services/internal/transactionService.js.map +1 -0
- package/dist/services/internal/transactionStatusService.d.ts +28 -0
- package/dist/services/internal/transactionStatusService.js +225 -0
- package/dist/services/internal/transactionStatusService.js.map +1 -0
- package/dist/services/internal/walletService.d.ts +28 -0
- package/dist/services/internal/walletService.js +123 -0
- package/dist/services/internal/walletService.js.map +1 -0
- package/dist/tests/assetsService.test.d.ts +1 -0
- package/dist/tests/assetsService.test.js +130 -0
- package/dist/tests/assetsService.test.js.map +1 -0
- package/dist/tests/configService.test.d.ts +1 -0
- package/dist/tests/configService.test.js +295 -0
- package/dist/tests/configService.test.js.map +1 -0
- package/dist/tests/fetchSquidData.d.ts +6 -0
- package/dist/tests/fetchSquidData.js +27 -0
- package/dist/tests/fetchSquidData.js.map +1 -0
- package/{src/tests/jest-svg-transform.ts → dist/tests/jest-svg-transform.js} +11 -9
- package/dist/tests/jest-svg-transform.js.map +1 -0
- package/dist/tests/sample.json +0 -0
- package/dist/tests/walletService.test.d.ts +1 -0
- package/dist/tests/walletService.test.js +74 -0
- package/dist/tests/walletService.test.js.map +1 -0
- package/package.json +6 -1
- package/.babelrc +0 -7
- package/.eslintignore +0 -1
- package/.eslintrc.json +0 -44
- package/CHANGELOG.md +0 -9
- package/jest.config.ts +0 -28
- package/scripts/copyAssets.js +0 -27
- package/scripts/removeBuildTestFolder.js +0 -28
- package/scripts/replacePaths.js +0 -37
- package/src/connectors/LedgerLiveConnector.ts +0 -226
- package/src/contracts/typechain/ERC20.d.ts +0 -441
- package/src/contracts/typechain/factories/ERC20__factory.ts +0 -340
- package/src/core/constants.ts +0 -549
- package/src/core/multicall3.ts +0 -22
- package/src/core/numbers.ts +0 -44
- package/src/core/providers/CosmosProvider.tsx +0 -55
- package/src/core/queries/queries-keys.ts +0 -156
- package/src/core/queries/react-query-config.ts +0 -13
- package/src/core/types/components.ts +0 -16
- package/src/core/types/config.ts +0 -52
- package/src/core/types/dex.ts +0 -31
- package/src/core/types/error.ts +0 -52
- package/src/core/types/event.ts +0 -16
- package/src/core/types/route.ts +0 -21
- package/src/core/types/swap.ts +0 -8
- package/src/core/types/tokens.ts +0 -30
- package/src/core/types/transaction.ts +0 -84
- package/src/core/types/types.ts +0 -37
- package/src/core/types/wallet.ts +0 -83
- package/src/hooks/chains/useSquidChains.ts +0 -66
- package/src/hooks/cosmos/useCosmos.ts +0 -279
- package/src/hooks/cosmos/useCosmosForChain.ts +0 -33
- package/src/hooks/navigation/useKeyboardNavigation.ts +0 -88
- package/src/hooks/store/useSquidStore.ts +0 -80
- package/src/hooks/swap/useSwap.ts +0 -359
- package/src/hooks/tokens/useAllTokensWithBalance.ts +0 -157
- package/src/hooks/tokens/useBalance.ts +0 -180
- package/src/hooks/tokens/useMultiChainBalance.ts +0 -59
- package/src/hooks/tokens/usePrices.ts +0 -52
- package/src/hooks/tokens/useSingleTokenPrice.ts +0 -45
- package/src/hooks/tokens/useSquidTokens.ts +0 -48
- package/src/hooks/tokens/useTokensWithBalance.ts +0 -169
- package/src/hooks/transaction/useEstimate.ts +0 -397
- package/src/hooks/transaction/useEstimatePriceImpact.ts +0 -39
- package/src/hooks/transaction/useExecuteTransaction.ts +0 -440
- package/src/hooks/transaction/useExpress.ts +0 -46
- package/src/hooks/transaction/useGetRoute.ts +0 -145
- package/src/hooks/transaction/useSingleTransaction.ts +0 -155
- package/src/hooks/transaction/useTransaction.ts +0 -734
- package/src/hooks/user/useUserParams.ts +0 -63
- package/src/hooks/wallet/useAddToken.ts +0 -53
- package/src/hooks/wallet/useAutoConnect.ts +0 -56
- package/src/hooks/wallet/useGnosisContext.ts +0 -84
- package/src/hooks/wallet/useIntegratorContext.ts +0 -44
- package/src/hooks/wallet/useMultiChainWallet.ts +0 -146
- package/src/hooks/wallet/useWallet.ts +0 -86
- package/src/hooks/webapp-router/useSquidRouter.ts +0 -42
- package/src/provider/index.tsx +0 -105
- package/src/react-app-env.d.ts +0 -2
- package/src/services/external/analyticsService.ts +0 -46
- package/src/services/external/coingeckoService.ts +0 -35
- package/src/services/external/rpcService.ts +0 -196
- package/src/services/external/secretService.ts +0 -178
- package/src/services/internal/apiService.ts +0 -6
- package/src/services/internal/assetsService.ts +0 -84
- package/src/services/internal/configService.ts +0 -261
- package/src/services/internal/eventService.ts +0 -93
- package/src/services/internal/priceService.ts +0 -10
- package/src/services/internal/transactionService.ts +0 -255
- package/src/services/internal/transactionStatusService.ts +0 -293
- package/src/services/internal/walletService.ts +0 -158
- package/src/tests/assetsService.test.ts +0 -176
- package/src/tests/configService.test.ts +0 -486
- package/src/tests/fetchSquidData.ts +0 -43
- package/src/tests/walletService.test.ts +0 -178
- package/tsconfig.cjs.json +0 -8
- package/tsconfig.json +0 -31
- /package/{src → dist}/assets/images/icons/wallets/binance.svg +0 -0
- /package/{src → dist}/assets/images/icons/wallets/bitget.svg +0 -0
- /package/{src → dist}/assets/images/icons/wallets/bitkeep.svg +0 -0
- /package/{src → dist}/assets/images/icons/wallets/blockchaindotcom.svg +0 -0
- /package/{src → dist}/assets/images/icons/wallets/brave.svg +0 -0
- /package/{src → dist}/assets/images/icons/wallets/c98.svg +0 -0
- /package/{src → dist}/assets/images/icons/wallets/coinbase.svg +0 -0
- /package/{src → dist}/assets/images/icons/wallets/cosmostation.svg +0 -0
- /package/{src → dist}/assets/images/icons/wallets/defiConnect.svg +0 -0
- /package/{src → dist}/assets/images/icons/wallets/exodus.svg +0 -0
- /package/{src → dist}/assets/images/icons/wallets/fetchai.svg +0 -0
- /package/{src → dist}/assets/images/icons/wallets/keplr.svg +0 -0
- /package/{src → dist}/assets/images/icons/wallets/leap.svg +0 -0
- /package/{src → dist}/assets/images/icons/wallets/metamask.svg +0 -0
- /package/{src → dist}/assets/images/icons/wallets/okx.svg +0 -0
- /package/{src → dist}/assets/images/icons/wallets/rabby.svg +0 -0
- /package/{src → dist}/assets/images/icons/wallets/trustwallet.svg +0 -0
- /package/{src → dist}/assets/images/icons/wallets/walletConnect.svg +0 -0
- /package/{src → dist}/assets/images/icons/wallets/wallet_icon.svg +0 -0
- /package/{src → dist}/assets/images/icons/wallets/xdefi.svg +0 -0
- /package/{src → dist}/assets/images/icons/wallets/zerion.svg +0 -0
- /package/{src → dist}/contracts/typechain/factories/ERC20__factory.d.ts +0 -0
- /package/{src/core/index.ts → dist/core/index.d.ts} +0 -0
- /package/{src/services/index.ts → dist/services/index.d.ts} +0 -0
- /package/{src/tests/sample.json → dist/tests/jest-svg-transform.d.ts} +0 -0
|
@@ -1,156 +0,0 @@
|
|
|
1
|
-
import type { SlippageOption } from "@/core/types/config";
|
|
2
|
-
import type { SwapRoute } from "@/core/types/swap";
|
|
3
|
-
import type { TransactionParams } from "@/core/types/transaction";
|
|
4
|
-
import type { RouteResponse } from "@0xsquid/sdk/dist/types";
|
|
5
|
-
import { ChainType } from "@0xsquid/sdk/dist/types";
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* Cache keys implementation for react-query caching / invalidating
|
|
9
|
-
* For example if you invalidate a top level query, all its child will be invalidated, e.g "all" key
|
|
10
|
-
* @returns Query Keys array
|
|
11
|
-
*/
|
|
12
|
-
export const keys = ({
|
|
13
|
-
address,
|
|
14
|
-
apiUrl,
|
|
15
|
-
}: {
|
|
16
|
-
address?: string;
|
|
17
|
-
apiUrl?: string;
|
|
18
|
-
}) => ({
|
|
19
|
-
all: [address, apiUrl, "all"],
|
|
20
|
-
// Chains
|
|
21
|
-
chains: () => [...keys({ apiUrl, address }).all, apiUrl, "chains"],
|
|
22
|
-
|
|
23
|
-
// Tokens
|
|
24
|
-
tokens: () => [...keys({ apiUrl, address }).all, apiUrl, "tokens"],
|
|
25
|
-
tokensForChain: (chainId?: number | string) => [
|
|
26
|
-
...keys({ apiUrl, address }).tokens(),
|
|
27
|
-
chainId,
|
|
28
|
-
"tokensForChain",
|
|
29
|
-
],
|
|
30
|
-
tokensPrice: (swapRoute: SwapRoute | undefined) => [
|
|
31
|
-
...keys({ apiUrl, address }).tokens(),
|
|
32
|
-
swapRoute?.fromChainId,
|
|
33
|
-
swapRoute?.toChainId,
|
|
34
|
-
swapRoute?.toTokenAddress,
|
|
35
|
-
swapRoute?.fromTokenAddress,
|
|
36
|
-
"tokensPrice",
|
|
37
|
-
],
|
|
38
|
-
singleTokenPrice: (tokenAddress?: string, chainId?: number | string) => [
|
|
39
|
-
...keys({ apiUrl, address }).tokens(),
|
|
40
|
-
tokenAddress,
|
|
41
|
-
chainId,
|
|
42
|
-
"singleTokenPrice",
|
|
43
|
-
],
|
|
44
|
-
axelarTokens: () => [...keys({ apiUrl }).tokens(), "axelarTokens"],
|
|
45
|
-
|
|
46
|
-
// Balances
|
|
47
|
-
balances: () => [...keys({ apiUrl, address }).all, "balances"],
|
|
48
|
-
balance: (
|
|
49
|
-
chainId?: number | string,
|
|
50
|
-
tokenAddress?: string,
|
|
51
|
-
userAddress?: string,
|
|
52
|
-
chainType: ChainType = ChainType.EVM
|
|
53
|
-
) => [
|
|
54
|
-
...keys({ apiUrl, address }).balances(),
|
|
55
|
-
address,
|
|
56
|
-
chainId,
|
|
57
|
-
tokenAddress,
|
|
58
|
-
chainType,
|
|
59
|
-
userAddress,
|
|
60
|
-
"balance",
|
|
61
|
-
],
|
|
62
|
-
nativeBalanceBigNumber: (
|
|
63
|
-
chainId?: number | string,
|
|
64
|
-
tokenAddress?: string,
|
|
65
|
-
chainType: ChainType = ChainType.EVM
|
|
66
|
-
) => [
|
|
67
|
-
...keys({ apiUrl, address }).balances(),
|
|
68
|
-
address,
|
|
69
|
-
chainId,
|
|
70
|
-
tokenAddress,
|
|
71
|
-
chainType,
|
|
72
|
-
"nativeBalance",
|
|
73
|
-
],
|
|
74
|
-
tokensBalanceForChain: (chainType?: ChainType, chainId?: number | string) => [
|
|
75
|
-
...keys({ apiUrl, address }).balances(),
|
|
76
|
-
address,
|
|
77
|
-
chainId,
|
|
78
|
-
chainType,
|
|
79
|
-
"tokensBalanceForChain",
|
|
80
|
-
],
|
|
81
|
-
|
|
82
|
-
allTokensBalance: (direction: "from" | "to") => [
|
|
83
|
-
...keys({ apiUrl, address }).balances(),
|
|
84
|
-
address,
|
|
85
|
-
direction,
|
|
86
|
-
"allTokensBalance",
|
|
87
|
-
],
|
|
88
|
-
|
|
89
|
-
allTokensPriceUSDAndBalance: () => [
|
|
90
|
-
...keys({ apiUrl, address }).balances(),
|
|
91
|
-
address,
|
|
92
|
-
"allTokensPriceUSDAndBalance",
|
|
93
|
-
],
|
|
94
|
-
|
|
95
|
-
// Transactions
|
|
96
|
-
transactions: () => [...keys({ apiUrl, address }).all, "transactions"],
|
|
97
|
-
transaction: (
|
|
98
|
-
swapDirection: SwapRoute | undefined,
|
|
99
|
-
price: string | undefined,
|
|
100
|
-
slippage: SlippageOption | undefined,
|
|
101
|
-
infiniteApproval: boolean | undefined,
|
|
102
|
-
getGasOnDestination: boolean | undefined,
|
|
103
|
-
expressEnabled: boolean | undefined,
|
|
104
|
-
sourceUserAddress: string | undefined
|
|
105
|
-
) => [
|
|
106
|
-
...keys({ apiUrl, address }).transactions(),
|
|
107
|
-
swapDirection?.fromChainId,
|
|
108
|
-
swapDirection?.toChainId,
|
|
109
|
-
swapDirection?.toTokenAddress,
|
|
110
|
-
swapDirection?.fromTokenAddress,
|
|
111
|
-
price,
|
|
112
|
-
slippage,
|
|
113
|
-
infiniteApproval,
|
|
114
|
-
getGasOnDestination,
|
|
115
|
-
expressEnabled,
|
|
116
|
-
sourceUserAddress,
|
|
117
|
-
"transaction",
|
|
118
|
-
],
|
|
119
|
-
transactionStatus: (currentTransaction?: TransactionParams) => [
|
|
120
|
-
...keys({ apiUrl, address }).transactions(),
|
|
121
|
-
currentTransaction?.routeType,
|
|
122
|
-
currentTransaction?.transactionId,
|
|
123
|
-
currentTransaction?.status,
|
|
124
|
-
currentTransaction?.fromChain?.chainId,
|
|
125
|
-
currentTransaction?.toChain?.chainId,
|
|
126
|
-
"transactionStatus",
|
|
127
|
-
],
|
|
128
|
-
transactionStatusRefetcher: (currentTransaction?: TransactionParams) => [
|
|
129
|
-
...keys({ apiUrl, address }).transactions(),
|
|
130
|
-
currentTransaction?.routeType,
|
|
131
|
-
currentTransaction?.transactionId,
|
|
132
|
-
currentTransaction?.status,
|
|
133
|
-
"transactionStatusRefetcher",
|
|
134
|
-
],
|
|
135
|
-
routeApproved: (
|
|
136
|
-
swapDirection: SwapRoute | undefined,
|
|
137
|
-
sender: string | undefined,
|
|
138
|
-
routeData: RouteResponse["route"] | undefined
|
|
139
|
-
) => [
|
|
140
|
-
...keys({ apiUrl, address }).transactions(),
|
|
141
|
-
swapDirection?.fromChainId,
|
|
142
|
-
swapDirection?.toChainId,
|
|
143
|
-
swapDirection?.toTokenAddress,
|
|
144
|
-
swapDirection?.fromTokenAddress,
|
|
145
|
-
swapDirection?.destinationAddress,
|
|
146
|
-
sender,
|
|
147
|
-
routeData?.estimate?.fromAmount,
|
|
148
|
-
"routeApproved",
|
|
149
|
-
],
|
|
150
|
-
aproveRoute: (tokenAddress?: string, amount?: string) => [
|
|
151
|
-
...keys({ apiUrl, address }).transactions(),
|
|
152
|
-
tokenAddress,
|
|
153
|
-
amount,
|
|
154
|
-
"aproveRoute",
|
|
155
|
-
],
|
|
156
|
-
});
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import type { DefaultOptions } from "@tanstack/react-query";
|
|
2
|
-
|
|
3
|
-
// Prevent fetching too soon after the first successful request.
|
|
4
|
-
export const DEFAULT_STALE_TIME = 8000;
|
|
5
|
-
|
|
6
|
-
export const defaultOptions: DefaultOptions = {
|
|
7
|
-
queries: {
|
|
8
|
-
staleTime: DEFAULT_STALE_TIME,
|
|
9
|
-
refetchOnWindowFocus: false,
|
|
10
|
-
retry: false, // Prevent refetching everytime a query fails, will do manually when needed
|
|
11
|
-
retryOnMount: false,
|
|
12
|
-
},
|
|
13
|
-
};
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
export type ComponentSize = "xs" | "sm" | "md" | "lg";
|
|
2
|
-
|
|
3
|
-
export interface SkeletonConfig {
|
|
4
|
-
hasRandomWidth?: boolean;
|
|
5
|
-
backgroundColor?: string;
|
|
6
|
-
foregroundColor?: string;
|
|
7
|
-
animate?: boolean;
|
|
8
|
-
title?: string;
|
|
9
|
-
speed?: number;
|
|
10
|
-
width?: number;
|
|
11
|
-
height?: number;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
export interface LoadingComponentProps {
|
|
15
|
-
isLoading?: boolean;
|
|
16
|
-
}
|
package/src/core/types/config.ts
DELETED
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
import type { DexName } from "./dex";
|
|
2
|
-
|
|
3
|
-
export type SlippageOption = 0.5 | 1 | 1.5 | 3;
|
|
4
|
-
|
|
5
|
-
export type TokenConfig = {
|
|
6
|
-
address: string;
|
|
7
|
-
chainId: number | string;
|
|
8
|
-
};
|
|
9
|
-
|
|
10
|
-
export interface AppConfig {
|
|
11
|
-
integratorId: string; // The integrator ID, this way we'll be able to provide data about volume to integrators
|
|
12
|
-
companyName?: string;
|
|
13
|
-
slippage?: SlippageOption;
|
|
14
|
-
enableExpress?: boolean;
|
|
15
|
-
enableGetGasOnDestination?: boolean;
|
|
16
|
-
infiniteApproval?: boolean;
|
|
17
|
-
apiUrl?: string;
|
|
18
|
-
internalSameChainSwapAllowed?: boolean; // Will display a message indicating that the swap is possible on the website
|
|
19
|
-
hideAnimations?: boolean;
|
|
20
|
-
preferDex?: DexName[] | string[]; // Can select a preferred dex to route transactions, will be sent to the sdk when executing route
|
|
21
|
-
advanced?: {
|
|
22
|
-
shareOnTwitter?: boolean;
|
|
23
|
-
disableTradeLimit?: boolean; // Will probably disappear in the future, when we remove the trade limit by default
|
|
24
|
-
};
|
|
25
|
-
priceImpactWarnings?: {
|
|
26
|
-
warning: number;
|
|
27
|
-
critical: number;
|
|
28
|
-
};
|
|
29
|
-
favTokens?: TokenConfig[];
|
|
30
|
-
comingSoonChainIds?: any[]; // number | string chain ids. If set to [], will show all chains
|
|
31
|
-
// The initial from and to assets when widget loads
|
|
32
|
-
initialAssets?: {
|
|
33
|
-
from?: TokenConfig;
|
|
34
|
-
to?: TokenConfig;
|
|
35
|
-
};
|
|
36
|
-
defaultTokensPerChain?: TokenConfig[]; // When chain is changed, this allow to chose the first token that will be selected
|
|
37
|
-
availableChains?: {
|
|
38
|
-
source?: (number | string)[];
|
|
39
|
-
destination?: (number | string)[];
|
|
40
|
-
}; // If set to [] or undefined, will show all chains
|
|
41
|
-
collectFees?: {
|
|
42
|
-
integratorAddress: string; // The EVM address of the integrator that will receive the fee
|
|
43
|
-
fee: number; // The amount in "basis points" for the fee. 50 = 0.05%. there is currently soft limit of 1% fee allowed for each tx.
|
|
44
|
-
};
|
|
45
|
-
showOnRampLink?: boolean; // If set to true, will show the default onramp link in the widget
|
|
46
|
-
onChainQuoting?: boolean; // Will pass this param to API when doing a quote. if true, then rpc calls for quoting instead of off chain calls
|
|
47
|
-
// Allows to disable chains for a specific direction (source or destination)
|
|
48
|
-
disabledChains?: {
|
|
49
|
-
source?: string[];
|
|
50
|
-
destination?: string[];
|
|
51
|
-
};
|
|
52
|
-
}
|
package/src/core/types/dex.ts
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
// This is a temporary list to help integrator
|
|
2
|
-
// Selecting the right name, this enum will evolve in api side
|
|
3
|
-
// This enum was not available in the sdk
|
|
4
|
-
export enum DexName {
|
|
5
|
-
UNISWAP_V2 = "UniswapV2",
|
|
6
|
-
UNISWAP_V3 = "UniswapV3",
|
|
7
|
-
UBESWAP = "Ubeswap",
|
|
8
|
-
SPOOKYSWAP = "Spookyswap",
|
|
9
|
-
SUSHISWAP = "Sushiswap",
|
|
10
|
-
STELLASWAP = "Stellaswap",
|
|
11
|
-
PANGOLIN = "Pangolin",
|
|
12
|
-
CURVE_V2 = "Curve_v2",
|
|
13
|
-
CURVE_V2_CELO = "Curve_v2_celo",
|
|
14
|
-
ELLIPSIS = "Ellipsis",
|
|
15
|
-
QUICKSWAP = "Quickswap",
|
|
16
|
-
STELLASWAP_SADDLE = "Stellaswap_Saddle",
|
|
17
|
-
QUICKSWAP_V3 = "Quickswap_v3",
|
|
18
|
-
PANCAKESWAP = "Pancakeswap",
|
|
19
|
-
PANCAKESWAP_V3 = "Pancakeswap_v3",
|
|
20
|
-
PANCAKESWAP_STABLE = "Pancakeswap_stable",
|
|
21
|
-
TRADERJOE = "TraderJoe",
|
|
22
|
-
TRIDENT = "Trident",
|
|
23
|
-
PLATYPUS = "Platypus",
|
|
24
|
-
WOMBAT = "Wombat",
|
|
25
|
-
ZYBERSWAP = "Zyberswap",
|
|
26
|
-
KYBERSWAP = "KyberSwap",
|
|
27
|
-
KYBERSWAP_AGGREGATOR = "KyberSwap_Aggregator",
|
|
28
|
-
GMX = "GMX",
|
|
29
|
-
APESWAP = "Apeswap",
|
|
30
|
-
OPENOCEAN = "OpenOcean",
|
|
31
|
-
}
|
package/src/core/types/error.ts
DELETED
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
import type { TransactionResponse } from "@ethersproject/providers";
|
|
2
|
-
import type { BigNumber } from "ethers";
|
|
3
|
-
|
|
4
|
-
export enum TransactionErrorType {
|
|
5
|
-
REJECTED_BY_USER,
|
|
6
|
-
CALL_EXCEPTION,
|
|
7
|
-
UNKNOWN,
|
|
8
|
-
WARNING,
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
export type TransactionErrorWithMessage = {
|
|
12
|
-
type: TransactionErrorType;
|
|
13
|
-
message: string;
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
export interface TransactionReplacedError extends Error {
|
|
17
|
-
code: string;
|
|
18
|
-
replacement: TransactionResponse;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
export interface TransactionError {
|
|
22
|
-
reason: string;
|
|
23
|
-
code: string;
|
|
24
|
-
action: string;
|
|
25
|
-
message: string;
|
|
26
|
-
transaction: {
|
|
27
|
-
to: string;
|
|
28
|
-
data: string;
|
|
29
|
-
gasLimit: number;
|
|
30
|
-
value: { type: BigNumber; hex: string };
|
|
31
|
-
from: string;
|
|
32
|
-
};
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
export interface SquidRouteError {
|
|
36
|
-
code?: string;
|
|
37
|
-
errorType?: string;
|
|
38
|
-
message?: string;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
export interface SquidStatusError {
|
|
42
|
-
errorType?: string;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
export type SquidRouteErrorType =
|
|
46
|
-
| "Unknown"
|
|
47
|
-
| "UnknownError"
|
|
48
|
-
| "SquidServiceError";
|
|
49
|
-
|
|
50
|
-
export enum SquidStatusErrorType {
|
|
51
|
-
NotFoundError = "NotFoundError",
|
|
52
|
-
}
|
package/src/core/types/event.ts
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import type { RouteResponse } from "@0xsquid/sdk/dist/types";
|
|
2
|
-
|
|
3
|
-
export interface WidgetEventMap {
|
|
4
|
-
swapStatus: { status: string };
|
|
5
|
-
swap: { route: RouteResponse["route"]; txHash: string };
|
|
6
|
-
swapParamsChanged: {
|
|
7
|
-
fromChainId?: string;
|
|
8
|
-
toChainId?: string;
|
|
9
|
-
fromTokenAddress?: string;
|
|
10
|
-
toTokenAddress?: string;
|
|
11
|
-
};
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
export type EventListenerFunction<T extends keyof WidgetEventMap> = (
|
|
15
|
-
event: CustomEvent<WidgetEventMap[T]>
|
|
16
|
-
) => void;
|
package/src/core/types/route.ts
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
// TODO: Might not be needed in this file
|
|
2
|
-
// Could be on widget code only
|
|
3
|
-
|
|
4
|
-
export type Routes =
|
|
5
|
-
| "swap"
|
|
6
|
-
| "settings"
|
|
7
|
-
| "wallets"
|
|
8
|
-
| "tokens"
|
|
9
|
-
| "chains"
|
|
10
|
-
| "history"
|
|
11
|
-
| "transaction"
|
|
12
|
-
| "allTokens"
|
|
13
|
-
| "destination";
|
|
14
|
-
|
|
15
|
-
type HeaderButton = "back" | "settings" | "history";
|
|
16
|
-
export interface WidgetRoute {
|
|
17
|
-
id: Routes;
|
|
18
|
-
path: string;
|
|
19
|
-
title: string;
|
|
20
|
-
headerButtons?: HeaderButton[];
|
|
21
|
-
}
|
package/src/core/types/swap.ts
DELETED
package/src/core/types/tokens.ts
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import type { Token } from "@0xsquid/sdk/dist/types";
|
|
2
|
-
|
|
3
|
-
export type TokenWithBalance = Token & {
|
|
4
|
-
balance: string;
|
|
5
|
-
priceUSD?: string;
|
|
6
|
-
isFavorite?: boolean;
|
|
7
|
-
};
|
|
8
|
-
|
|
9
|
-
export type AxelarTokenData = {
|
|
10
|
-
id: string;
|
|
11
|
-
common_key: object;
|
|
12
|
-
native_chain: string;
|
|
13
|
-
fully_supported: boolean;
|
|
14
|
-
decimals: number;
|
|
15
|
-
chain_aliases: {
|
|
16
|
-
[key: string]: {
|
|
17
|
-
assetSymbol: string;
|
|
18
|
-
assetName: string;
|
|
19
|
-
minDepositAmt: number;
|
|
20
|
-
ibcDenom: string;
|
|
21
|
-
fullDenomPath: string;
|
|
22
|
-
tokenAddress: string;
|
|
23
|
-
mintLimit: number;
|
|
24
|
-
};
|
|
25
|
-
};
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
export type AxelarTokensData = {
|
|
29
|
-
assets: { [key: string]: AxelarTokenData };
|
|
30
|
-
};
|
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
ChainData,
|
|
3
|
-
RouteResponse,
|
|
4
|
-
// StatusResponse,
|
|
5
|
-
Token,
|
|
6
|
-
} from "@0xsquid/sdk/dist/types";
|
|
7
|
-
import type { UseQueryResult } from "@tanstack/react-query";
|
|
8
|
-
import type { TransactionErrorWithMessage } from "./error";
|
|
9
|
-
|
|
10
|
-
export enum TransactionType {
|
|
11
|
-
BRIDGE = "BRIDGE",
|
|
12
|
-
BRIDGE_CALL = "BRIDGE_CALL",
|
|
13
|
-
CALL_BRIDGE = "CALL_BRIDGE",
|
|
14
|
-
CALL_BRIDGE_CALL = "CALL_BRIDGE_CALL",
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export enum AxelarStatusResponseType {
|
|
18
|
-
GAS_PAID_NOT_ENOUGH_GAS = "gas_paid_not_enough_gas",
|
|
19
|
-
DESTINATION_EXECUTED = "destination_executed",
|
|
20
|
-
EXPRESS_EXECUTED = "express_executed",
|
|
21
|
-
CROSS_MULTICALL_EXECUTED = "CrossMulticallExecuted",
|
|
22
|
-
CROSS_MULTICALL_FAILED = "CrossMulticallFailed",
|
|
23
|
-
SRC_GATEWAY_CALLED = "source_gateway_called",
|
|
24
|
-
DEST_GATEWAY_APPROVED = "destination_gateway_approved",
|
|
25
|
-
DESTINATION_EXECUTE_ERROR = "destination_execute_error",
|
|
26
|
-
DESTINATION_EXECUTING = "executing",
|
|
27
|
-
UNKNOWN_ERROR = "unknown_error",
|
|
28
|
-
CANNOT_FETCH_STATUS = "cannot_fetch_status",
|
|
29
|
-
ERROR = "error",
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
export enum TransactionStatus {
|
|
33
|
-
// Submitted transaction, returned by squid axelar
|
|
34
|
-
SUCCESS = "success",
|
|
35
|
-
NEEDS_GAS = "needs_gas",
|
|
36
|
-
ONGOING = "ongoing",
|
|
37
|
-
PARTIAL_SUCCESS = "partial_success",
|
|
38
|
-
NOT_FOUND = "not_found",
|
|
39
|
-
// Unsubmitted Transaction, can be status from wallet
|
|
40
|
-
INITIAL_LOADING = "initialLoading",
|
|
41
|
-
ERROR = "error",
|
|
42
|
-
WARNING = "warning",
|
|
43
|
-
PENDING = "pending",
|
|
44
|
-
REJECTED = "rejected",
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
export interface TransactionParams {
|
|
48
|
-
routeType: string;
|
|
49
|
-
fromChain?: ChainData;
|
|
50
|
-
toChain?: ChainData;
|
|
51
|
-
nonce?: number;
|
|
52
|
-
transactionId: string | undefined;
|
|
53
|
-
timestamp?: number;
|
|
54
|
-
sourceStatus?: TransactionStatus; // The source / wallet transaction status
|
|
55
|
-
status: TransactionStatus; // Cross chain Transaction Status
|
|
56
|
-
error?: TransactionErrorWithMessage;
|
|
57
|
-
fromAddress?: string;
|
|
58
|
-
statusResponse?: any;
|
|
59
|
-
axelarUrl?: string;
|
|
60
|
-
sourceTxExplorerUrl?: string;
|
|
61
|
-
sourceExplorerImgUrl?: string;
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
export type TransactionHistoryStore = TransactionParams &
|
|
65
|
-
Pick<RouteResponse["route"], "params" | "estimate">;
|
|
66
|
-
|
|
67
|
-
export interface TransactionStepsProps {
|
|
68
|
-
currentTransaction?: TransactionParams;
|
|
69
|
-
sourceExplorerUrl?: string;
|
|
70
|
-
fromToken?: Token;
|
|
71
|
-
toToken?: Token;
|
|
72
|
-
toChain?: ChainData;
|
|
73
|
-
fromChain?: ChainData;
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
export type TransactionStepProps = TransactionStepsProps & {
|
|
77
|
-
statusResponse?: UseQueryResult<any, unknown>;
|
|
78
|
-
};
|
|
79
|
-
|
|
80
|
-
export interface StepStatusGetterProps {
|
|
81
|
-
transaction?: TransactionParams;
|
|
82
|
-
statusResponse?: UseQueryResult<any, unknown>;
|
|
83
|
-
onlyFullStatusStep?: boolean;
|
|
84
|
-
}
|
package/src/core/types/types.ts
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import type { Token } from "@0xsquid/sdk/dist/types";
|
|
2
|
-
|
|
3
|
-
export type SwapDirection = "from" | "to";
|
|
4
|
-
|
|
5
|
-
export type NextJsImg = {
|
|
6
|
-
src: string;
|
|
7
|
-
}; // On nextjs the image will be of type {src: "/_next/static/media/metamask.8a0fd576.svg", width: number, height: number}
|
|
8
|
-
export type ImgType = string | NextJsImg;
|
|
9
|
-
|
|
10
|
-
// TODO: BELOW Are temporary types taken from api for development because SDK wasn't up to date
|
|
11
|
-
export enum FeeType {
|
|
12
|
-
AXELAR_FEE = "Axelar Fee",
|
|
13
|
-
GAS_RECEIVER_FEE = "Cross-chain gas fees",
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
export type FeeCost = {
|
|
17
|
-
name: FeeType;
|
|
18
|
-
description: string;
|
|
19
|
-
percentage: string;
|
|
20
|
-
token: Token;
|
|
21
|
-
amount: string;
|
|
22
|
-
amountUSD: string;
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
export type ApiBasicResponse = {
|
|
26
|
-
error?: string;
|
|
27
|
-
errorType?: any;
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
export type TimeSpent = {
|
|
31
|
-
send_vote?: number;
|
|
32
|
-
type?: string;
|
|
33
|
-
destination_chain_type?: string;
|
|
34
|
-
source_chain_type?: string;
|
|
35
|
-
total?: number;
|
|
36
|
-
vote_ibc?: number;
|
|
37
|
-
};
|
package/src/core/types/wallet.ts
DELETED
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
/* eslint-disable @typescript-eslint/no-duplicate-enum-values */
|
|
2
|
-
import type { ChainType } from "@0xsquid/sdk/dist/types";
|
|
3
|
-
import type { Chain } from "wagmi";
|
|
4
|
-
|
|
5
|
-
export type TypedWindow = Window &
|
|
6
|
-
typeof globalThis & {
|
|
7
|
-
[key in WindowWalletFlag]?: any;
|
|
8
|
-
};
|
|
9
|
-
|
|
10
|
-
export enum WindowWalletFlag {
|
|
11
|
-
Binance = "bbcSignTx",
|
|
12
|
-
Coinbase = "isCoinbaseWallet",
|
|
13
|
-
MetaMask = "isMetaMask",
|
|
14
|
-
WalletConnect = "walletConnect",
|
|
15
|
-
CosmostationEVM = "cosmostation",
|
|
16
|
-
BlockchainDotCom = "blockchaindotcom",
|
|
17
|
-
CosmostationCosmos = "cosmostation.providers.keplr",
|
|
18
|
-
Keplr = "keplr",
|
|
19
|
-
Leap = "leap",
|
|
20
|
-
Xdefi = "xfi",
|
|
21
|
-
XdefiCosmos = "xfi.keplr",
|
|
22
|
-
BitGet = "bitkeep",
|
|
23
|
-
TrustWallet = "trustwallet",
|
|
24
|
-
FetchAi = "keplr", // Sadly the same as the real Keplr wallet
|
|
25
|
-
Coin98 = "coin98",
|
|
26
|
-
Rabby = "isRabby",
|
|
27
|
-
OKX = "okxwallet",
|
|
28
|
-
Injected = "injected",
|
|
29
|
-
DefiConnect = "deficonnectProvider", // From crypto.com: https://github.com/crypto-com/deficonnect-monorepo/wiki/Chrome-Extension-Wallet-Integration
|
|
30
|
-
Zerion = "isZerion",
|
|
31
|
-
Snapper = "cosmos",
|
|
32
|
-
Exodus = "exodus",
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
export type ConnectorID =
|
|
36
|
-
| "metaMask"
|
|
37
|
-
| "walletConnect"
|
|
38
|
-
| "blockchaindotcom"
|
|
39
|
-
| "coinbaseWallet"
|
|
40
|
-
| "keplr"
|
|
41
|
-
| "cosmostation"
|
|
42
|
-
| "cosmostationCosmos"
|
|
43
|
-
| "leap"
|
|
44
|
-
| "xdefi"
|
|
45
|
-
| "xdeficosmos"
|
|
46
|
-
| "bitget"
|
|
47
|
-
| "fetchai"
|
|
48
|
-
| "coin98"
|
|
49
|
-
| "rabby"
|
|
50
|
-
| "okx"
|
|
51
|
-
| "injected"
|
|
52
|
-
| "zerion"
|
|
53
|
-
| "deficonnect"
|
|
54
|
-
| "snapper"
|
|
55
|
-
| "trustwallet"
|
|
56
|
-
| "exodus";
|
|
57
|
-
|
|
58
|
-
export interface Wallet {
|
|
59
|
-
name: string;
|
|
60
|
-
type: ChainType;
|
|
61
|
-
connectorId: ConnectorID;
|
|
62
|
-
connectorName: string;
|
|
63
|
-
connector?: (chains?: Chain[]) => any; // For evm chains only
|
|
64
|
-
icon: string | undefined;
|
|
65
|
-
windowFlag: string; // Wallet identitiy attached to window object
|
|
66
|
-
canSwitchWallets: boolean;
|
|
67
|
-
direction?: "from" | "to";
|
|
68
|
-
connectedAddress?: string;
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
export interface AddEthereumChainParameter {
|
|
72
|
-
chainId: string; // A 0x-prefixed hexadecimal string
|
|
73
|
-
chainName: string;
|
|
74
|
-
nativeCurrency: {
|
|
75
|
-
name: string;
|
|
76
|
-
symbol: string; // 2-6 characters long
|
|
77
|
-
decimals: number;
|
|
78
|
-
icon: string;
|
|
79
|
-
};
|
|
80
|
-
rpcUrls: string[];
|
|
81
|
-
blockExplorerUrls?: string[];
|
|
82
|
-
iconUrls?: string[]; // Currently ignored.
|
|
83
|
-
}
|
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
import { keys } from "@/core/queries/queries-keys";
|
|
2
|
-
import { useSquidStore } from "@/hooks/store/useSquidStore";
|
|
3
|
-
import { useQuery } from "@tanstack/react-query";
|
|
4
|
-
import { useMemo } from "react";
|
|
5
|
-
|
|
6
|
-
export const useSquidChains = () => {
|
|
7
|
-
const { squid, config } = useSquidStore();
|
|
8
|
-
|
|
9
|
-
const fuseSearchOptions = {
|
|
10
|
-
isCaseSensitive: false,
|
|
11
|
-
includeScore: false,
|
|
12
|
-
minMatchCharLength: 1,
|
|
13
|
-
threshold: 0.1,
|
|
14
|
-
keys: ["networkName", "chainName", "nativeCurrency.symbol"],
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
const supportedChains = useQuery(
|
|
18
|
-
keys({ apiUrl: config.apiUrl }).chains(),
|
|
19
|
-
() => {
|
|
20
|
-
return squid?.chains ?? [];
|
|
21
|
-
},
|
|
22
|
-
{
|
|
23
|
-
enabled: squid !== undefined,
|
|
24
|
-
// cacheTime: 1000 * 60 * 60 * 24,
|
|
25
|
-
// staleTime: 1000 * 60 * 60 * 24,
|
|
26
|
-
}
|
|
27
|
-
);
|
|
28
|
-
|
|
29
|
-
const chains = useMemo(
|
|
30
|
-
() => supportedChains.data ?? [],
|
|
31
|
-
[supportedChains.data]
|
|
32
|
-
);
|
|
33
|
-
|
|
34
|
-
const supportedSourceChains = useMemo(() => {
|
|
35
|
-
if (
|
|
36
|
-
config.availableChains &&
|
|
37
|
-
config.availableChains?.source &&
|
|
38
|
-
config.availableChains.source.length > 0
|
|
39
|
-
) {
|
|
40
|
-
return chains.filter((c) =>
|
|
41
|
-
config.availableChains?.source?.includes(c.chainId)
|
|
42
|
-
);
|
|
43
|
-
}
|
|
44
|
-
return chains;
|
|
45
|
-
}, [chains, config.availableChains]);
|
|
46
|
-
|
|
47
|
-
const supportedDestinationChains = useMemo(() => {
|
|
48
|
-
if (
|
|
49
|
-
config.availableChains &&
|
|
50
|
-
config.availableChains?.destination &&
|
|
51
|
-
config.availableChains.destination.length > 0
|
|
52
|
-
) {
|
|
53
|
-
return chains.filter((c) =>
|
|
54
|
-
config.availableChains?.destination?.includes(c.chainId)
|
|
55
|
-
);
|
|
56
|
-
}
|
|
57
|
-
return chains;
|
|
58
|
-
}, [chains, config.availableChains]);
|
|
59
|
-
|
|
60
|
-
return {
|
|
61
|
-
supportedSourceChains,
|
|
62
|
-
supportedDestinationChains,
|
|
63
|
-
chains,
|
|
64
|
-
fuseSearchOptions,
|
|
65
|
-
};
|
|
66
|
-
};
|