@0xsquid/react-hooks 1.0.3 → 1.0.5
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 -2
- package/.babelrc +0 -7
- package/.eslintignore +0 -1
- package/.eslintrc.json +0 -44
- package/CHANGELOG.md +0 -7
- 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.json +0 -30
- /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
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { ethers } from "ethers";
|
|
2
|
+
import take from "lodash/take";
|
|
3
|
+
import takeWhile from "lodash/takeWhile";
|
|
4
|
+
export const roundNumericValue = (value = "0", precision = 2, useComaEvery3Digits = true, significantFigures = 0) => {
|
|
5
|
+
let newValue = value;
|
|
6
|
+
const temp = newValue?.toString() ?? "";
|
|
7
|
+
let [integers, decimals] = temp.split(".");
|
|
8
|
+
// toLocaleString is supported on all modern browsers
|
|
9
|
+
// We might monitor and have a polyfill if some people are not
|
|
10
|
+
// Seeing the comas.
|
|
11
|
+
if (useComaEvery3Digits && integers !== "0") {
|
|
12
|
+
integers = parseInt(integers, 10).toLocaleString("en-US").toString();
|
|
13
|
+
}
|
|
14
|
+
if (significantFigures && decimals) {
|
|
15
|
+
const zeros = takeWhile(decimals?.toString(), (c) => c === "0").length;
|
|
16
|
+
return `${integers}.${take(decimals, zeros + significantFigures).join("")}`;
|
|
17
|
+
}
|
|
18
|
+
return decimals
|
|
19
|
+
? `${integers}.${take(decimals, precision).join("")}`
|
|
20
|
+
: integers;
|
|
21
|
+
};
|
|
22
|
+
export function formatUnitsRounded(value, decimals, maxDecimalDigits) {
|
|
23
|
+
const dc = decimals ?? "0";
|
|
24
|
+
return ethers.FixedNumber.from(ethers.utils.formatUnits(value, dc))
|
|
25
|
+
.round(maxDecimalDigits ?? ethers.BigNumber.from(dc).toNumber())
|
|
26
|
+
.toString();
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=numbers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"numbers.js","sourceRoot":"","sources":["../../src/core/numbers.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,IAAI,MAAM,aAAa,CAAC;AAC/B,OAAO,SAAS,MAAM,kBAAkB,CAAC;AAEzC,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAC/B,QAAgB,GAAG,EACnB,YAAoB,CAAC,EACrB,mBAAmB,GAAG,IAAI,EAC1B,qBAA6B,CAAC,EACtB,EAAE;IACV,IAAI,QAAQ,GAAG,KAAK,CAAC;IAErB,MAAM,IAAI,GAAG,QAAQ,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;IACxC,IAAI,CAAC,QAAQ,EAAE,QAAQ,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IAE3C,qDAAqD;IACrD,8DAA8D;IAC9D,oBAAoB;IACpB,IAAI,mBAAmB,IAAI,QAAQ,KAAK,GAAG,EAAE,CAAC;QAC5C,QAAQ,GAAG,QAAQ,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC,QAAQ,EAAE,CAAC;IACvE,CAAC;IAED,IAAI,kBAAkB,IAAI,QAAQ,EAAE,CAAC;QACnC,MAAM,KAAK,GAAG,SAAS,CAAC,QAAQ,EAAE,QAAQ,EAAE,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,KAAK,GAAG,CAAC,CAAC,MAAM,CAAC;QACvE,OAAO,GAAG,QAAQ,IAAI,IAAI,CAAC,QAAQ,EAAE,KAAK,GAAG,kBAAkB,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,CAAC;IAC9E,CAAC;IAED,OAAO,QAAQ;QACb,CAAC,CAAC,GAAG,QAAQ,IAAI,IAAI,CAAC,QAAQ,EAAE,SAAS,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE;QACrD,CAAC,CAAC,QAAQ,CAAC;AACf,CAAC,CAAC;AAEF,MAAM,UAAU,kBAAkB,CAChC,KAAmB,EACnB,QAAgC,EAChC,gBAAyB;IAEzB,MAAM,EAAE,GAAG,QAAQ,IAAI,GAAG,CAAC;IAC3B,OAAO,MAAM,CAAC,WAAW,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,WAAW,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;SAChE,KAAK,CAAC,gBAAgB,IAAI,MAAM,CAAC,SAAS,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,QAAQ,EAAE,CAAC;SAC/D,QAAQ,EAAE,CAAC;AAChB,CAAC"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { Wallet } from "@/core/types/wallet";
|
|
2
|
+
import type { ChainData } from "@0xsquid/sdk/dist/types";
|
|
3
|
+
import type { OfflineSigner } from "@cosmjs/proto-signing";
|
|
4
|
+
import type { Keplr } from "@keplr-wallet/types";
|
|
5
|
+
import type { UseMutationResult } from "@tanstack/react-query";
|
|
6
|
+
import type { ReactNode } from "react";
|
|
7
|
+
import React from "react";
|
|
8
|
+
interface ICosmsosContextData {
|
|
9
|
+
connectCosmos?: UseMutationResult<void, unknown, {
|
|
10
|
+
chain: ChainData;
|
|
11
|
+
wallet?: Wallet;
|
|
12
|
+
direction?: "from" | "to";
|
|
13
|
+
}, unknown>;
|
|
14
|
+
cosmosConnectedWallet?: Wallet;
|
|
15
|
+
keplrTypeWallet?: Keplr;
|
|
16
|
+
cosmosChainId?: string;
|
|
17
|
+
setCosmosChainId?: React.Dispatch<React.SetStateAction<string | undefined>>;
|
|
18
|
+
isConnected?: boolean;
|
|
19
|
+
onCosmosChainChange?: (chainId: string) => void;
|
|
20
|
+
isInstalled?: boolean;
|
|
21
|
+
cosmosSigner?: OfflineSigner;
|
|
22
|
+
cosmosAddress?: string;
|
|
23
|
+
getCosmosWalletInfos?: UseMutationResult<string | undefined, unknown, {
|
|
24
|
+
chainId: string;
|
|
25
|
+
cosmosWalletObject?: Keplr | undefined;
|
|
26
|
+
}, unknown>;
|
|
27
|
+
getCosmosAddressForChain: (chainId?: string) => Promise<string | undefined>;
|
|
28
|
+
}
|
|
29
|
+
export declare const CosmosContext: React.Context<ICosmsosContextData>;
|
|
30
|
+
export declare const CosmosProvider: React.FC<{
|
|
31
|
+
children?: ReactNode;
|
|
32
|
+
}>;
|
|
33
|
+
export declare function useCosmosContext(): ICosmsosContextData;
|
|
34
|
+
export {};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { useCosmos } from "./../../hooks/cosmos/useCosmos";
|
|
2
|
+
import React from "react";
|
|
3
|
+
export const CosmosContext = React.createContext({
|
|
4
|
+
getCosmosAddressForChain: async () => "",
|
|
5
|
+
});
|
|
6
|
+
export const CosmosProvider = ({ children }) => {
|
|
7
|
+
return (React.createElement(CosmosContext.Provider, { value: useCosmos() }, children));
|
|
8
|
+
};
|
|
9
|
+
export function useCosmosContext() {
|
|
10
|
+
return React.useContext(CosmosContext);
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=CosmosProvider.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CosmosProvider.js","sourceRoot":"","sources":["../../../src/core/providers/CosmosProvider.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAC;AAMrD,OAAO,KAAK,MAAM,OAAO,CAAC;AA+B1B,MAAM,CAAC,MAAM,aAAa,GAAG,KAAK,CAAC,aAAa,CAAsB;IACpE,wBAAwB,EAAE,KAAK,IAAI,EAAE,CAAC,EAAE;CACzC,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,cAAc,GAEtB,CAAC,EAAE,QAAQ,EAAE,EAAE,EAAE;IACpB,OAAO,CACL,oBAAC,aAAa,CAAC,QAAQ,IAAC,KAAK,EAAE,SAAS,EAAE,IACvC,QAAQ,CACc,CAC1B,CAAC;AACJ,CAAC,CAAC;AAEF,MAAM,UAAU,gBAAgB;IAC9B,OAAO,KAAK,CAAC,UAAU,CAAC,aAAa,CAAC,CAAC;AACzC,CAAC"}
|
|
@@ -0,0 +1,34 @@
|
|
|
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
|
+
* Cache keys implementation for react-query caching / invalidating
|
|
8
|
+
* For example if you invalidate a top level query, all its child will be invalidated, e.g "all" key
|
|
9
|
+
* @returns Query Keys array
|
|
10
|
+
*/
|
|
11
|
+
export declare const keys: ({ address, apiUrl, }: {
|
|
12
|
+
address?: string;
|
|
13
|
+
apiUrl?: string;
|
|
14
|
+
}) => {
|
|
15
|
+
all: (string | undefined)[];
|
|
16
|
+
chains: () => (string | undefined)[];
|
|
17
|
+
tokens: () => (string | undefined)[];
|
|
18
|
+
tokensForChain: (chainId?: number | string) => (string | number | undefined)[];
|
|
19
|
+
tokensPrice: (swapRoute: SwapRoute | undefined) => (string | number | undefined)[];
|
|
20
|
+
singleTokenPrice: (tokenAddress?: string, chainId?: number | string) => (string | number | undefined)[];
|
|
21
|
+
axelarTokens: () => (string | undefined)[];
|
|
22
|
+
balances: () => (string | undefined)[];
|
|
23
|
+
balance: (chainId?: number | string, tokenAddress?: string, userAddress?: string, chainType?: ChainType) => (string | number | undefined)[];
|
|
24
|
+
nativeBalanceBigNumber: (chainId?: number | string, tokenAddress?: string, chainType?: ChainType) => (string | number | undefined)[];
|
|
25
|
+
tokensBalanceForChain: (chainType?: ChainType, chainId?: number | string) => (string | number | undefined)[];
|
|
26
|
+
allTokensBalance: (direction: "from" | "to") => (string | undefined)[];
|
|
27
|
+
allTokensPriceUSDAndBalance: () => (string | undefined)[];
|
|
28
|
+
transactions: () => (string | undefined)[];
|
|
29
|
+
transaction: (swapDirection: SwapRoute | undefined, price: string | undefined, slippage: SlippageOption | undefined, infiniteApproval: boolean | undefined, getGasOnDestination: boolean | undefined, expressEnabled: boolean | undefined, sourceUserAddress: string | undefined) => (string | number | boolean | undefined)[];
|
|
30
|
+
transactionStatus: (currentTransaction?: TransactionParams) => (string | undefined)[];
|
|
31
|
+
transactionStatusRefetcher: (currentTransaction?: TransactionParams) => (string | undefined)[];
|
|
32
|
+
routeApproved: (swapDirection: SwapRoute | undefined, sender: string | undefined, routeData: RouteResponse["route"] | undefined) => (string | number | undefined)[];
|
|
33
|
+
aproveRoute: (tokenAddress?: string, amount?: string) => (string | undefined)[];
|
|
34
|
+
};
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import { ChainType } from "@0xsquid/sdk/dist/types";
|
|
2
|
+
/**
|
|
3
|
+
* Cache keys implementation for react-query caching / invalidating
|
|
4
|
+
* For example if you invalidate a top level query, all its child will be invalidated, e.g "all" key
|
|
5
|
+
* @returns Query Keys array
|
|
6
|
+
*/
|
|
7
|
+
export const keys = ({ address, apiUrl, }) => ({
|
|
8
|
+
all: [address, apiUrl, "all"],
|
|
9
|
+
// Chains
|
|
10
|
+
chains: () => [...keys({ apiUrl, address }).all, apiUrl, "chains"],
|
|
11
|
+
// Tokens
|
|
12
|
+
tokens: () => [...keys({ apiUrl, address }).all, apiUrl, "tokens"],
|
|
13
|
+
tokensForChain: (chainId) => [
|
|
14
|
+
...keys({ apiUrl, address }).tokens(),
|
|
15
|
+
chainId,
|
|
16
|
+
"tokensForChain",
|
|
17
|
+
],
|
|
18
|
+
tokensPrice: (swapRoute) => [
|
|
19
|
+
...keys({ apiUrl, address }).tokens(),
|
|
20
|
+
swapRoute?.fromChainId,
|
|
21
|
+
swapRoute?.toChainId,
|
|
22
|
+
swapRoute?.toTokenAddress,
|
|
23
|
+
swapRoute?.fromTokenAddress,
|
|
24
|
+
"tokensPrice",
|
|
25
|
+
],
|
|
26
|
+
singleTokenPrice: (tokenAddress, chainId) => [
|
|
27
|
+
...keys({ apiUrl, address }).tokens(),
|
|
28
|
+
tokenAddress,
|
|
29
|
+
chainId,
|
|
30
|
+
"singleTokenPrice",
|
|
31
|
+
],
|
|
32
|
+
axelarTokens: () => [...keys({ apiUrl }).tokens(), "axelarTokens"],
|
|
33
|
+
// Balances
|
|
34
|
+
balances: () => [...keys({ apiUrl, address }).all, "balances"],
|
|
35
|
+
balance: (chainId, tokenAddress, userAddress, chainType = ChainType.EVM) => [
|
|
36
|
+
...keys({ apiUrl, address }).balances(),
|
|
37
|
+
address,
|
|
38
|
+
chainId,
|
|
39
|
+
tokenAddress,
|
|
40
|
+
chainType,
|
|
41
|
+
userAddress,
|
|
42
|
+
"balance",
|
|
43
|
+
],
|
|
44
|
+
nativeBalanceBigNumber: (chainId, tokenAddress, chainType = ChainType.EVM) => [
|
|
45
|
+
...keys({ apiUrl, address }).balances(),
|
|
46
|
+
address,
|
|
47
|
+
chainId,
|
|
48
|
+
tokenAddress,
|
|
49
|
+
chainType,
|
|
50
|
+
"nativeBalance",
|
|
51
|
+
],
|
|
52
|
+
tokensBalanceForChain: (chainType, chainId) => [
|
|
53
|
+
...keys({ apiUrl, address }).balances(),
|
|
54
|
+
address,
|
|
55
|
+
chainId,
|
|
56
|
+
chainType,
|
|
57
|
+
"tokensBalanceForChain",
|
|
58
|
+
],
|
|
59
|
+
allTokensBalance: (direction) => [
|
|
60
|
+
...keys({ apiUrl, address }).balances(),
|
|
61
|
+
address,
|
|
62
|
+
direction,
|
|
63
|
+
"allTokensBalance",
|
|
64
|
+
],
|
|
65
|
+
allTokensPriceUSDAndBalance: () => [
|
|
66
|
+
...keys({ apiUrl, address }).balances(),
|
|
67
|
+
address,
|
|
68
|
+
"allTokensPriceUSDAndBalance",
|
|
69
|
+
],
|
|
70
|
+
// Transactions
|
|
71
|
+
transactions: () => [...keys({ apiUrl, address }).all, "transactions"],
|
|
72
|
+
transaction: (swapDirection, price, slippage, infiniteApproval, getGasOnDestination, expressEnabled, sourceUserAddress) => [
|
|
73
|
+
...keys({ apiUrl, address }).transactions(),
|
|
74
|
+
swapDirection?.fromChainId,
|
|
75
|
+
swapDirection?.toChainId,
|
|
76
|
+
swapDirection?.toTokenAddress,
|
|
77
|
+
swapDirection?.fromTokenAddress,
|
|
78
|
+
price,
|
|
79
|
+
slippage,
|
|
80
|
+
infiniteApproval,
|
|
81
|
+
getGasOnDestination,
|
|
82
|
+
expressEnabled,
|
|
83
|
+
sourceUserAddress,
|
|
84
|
+
"transaction",
|
|
85
|
+
],
|
|
86
|
+
transactionStatus: (currentTransaction) => [
|
|
87
|
+
...keys({ apiUrl, address }).transactions(),
|
|
88
|
+
currentTransaction?.routeType,
|
|
89
|
+
currentTransaction?.transactionId,
|
|
90
|
+
currentTransaction?.status,
|
|
91
|
+
currentTransaction?.fromChain?.chainId,
|
|
92
|
+
currentTransaction?.toChain?.chainId,
|
|
93
|
+
"transactionStatus",
|
|
94
|
+
],
|
|
95
|
+
transactionStatusRefetcher: (currentTransaction) => [
|
|
96
|
+
...keys({ apiUrl, address }).transactions(),
|
|
97
|
+
currentTransaction?.routeType,
|
|
98
|
+
currentTransaction?.transactionId,
|
|
99
|
+
currentTransaction?.status,
|
|
100
|
+
"transactionStatusRefetcher",
|
|
101
|
+
],
|
|
102
|
+
routeApproved: (swapDirection, sender, routeData) => [
|
|
103
|
+
...keys({ apiUrl, address }).transactions(),
|
|
104
|
+
swapDirection?.fromChainId,
|
|
105
|
+
swapDirection?.toChainId,
|
|
106
|
+
swapDirection?.toTokenAddress,
|
|
107
|
+
swapDirection?.fromTokenAddress,
|
|
108
|
+
swapDirection?.destinationAddress,
|
|
109
|
+
sender,
|
|
110
|
+
routeData?.estimate?.fromAmount,
|
|
111
|
+
"routeApproved",
|
|
112
|
+
],
|
|
113
|
+
aproveRoute: (tokenAddress, amount) => [
|
|
114
|
+
...keys({ apiUrl, address }).transactions(),
|
|
115
|
+
tokenAddress,
|
|
116
|
+
amount,
|
|
117
|
+
"aproveRoute",
|
|
118
|
+
],
|
|
119
|
+
});
|
|
120
|
+
//# sourceMappingURL=queries-keys.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"queries-keys.js","sourceRoot":"","sources":["../../../src/core/queries/queries-keys.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
// Prevent fetching too soon after the first successful request.
|
|
2
|
+
export const DEFAULT_STALE_TIME = 8000;
|
|
3
|
+
export const defaultOptions = {
|
|
4
|
+
queries: {
|
|
5
|
+
staleTime: DEFAULT_STALE_TIME,
|
|
6
|
+
refetchOnWindowFocus: false,
|
|
7
|
+
retry: false, // Prevent refetching everytime a query fails, will do manually when needed
|
|
8
|
+
retryOnMount: false,
|
|
9
|
+
},
|
|
10
|
+
};
|
|
11
|
+
//# sourceMappingURL=react-query-config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"react-query-config.js","sourceRoot":"","sources":["../../../src/core/queries/react-query-config.ts"],"names":[],"mappings":"AAEA,gEAAgE;AAChE,MAAM,CAAC,MAAM,kBAAkB,GAAG,IAAI,CAAC;AAEvC,MAAM,CAAC,MAAM,cAAc,GAAmB;IAC5C,OAAO,EAAE;QACP,SAAS,EAAE,kBAAkB;QAC7B,oBAAoB,EAAE,KAAK;QAC3B,KAAK,EAAE,KAAK,EAAE,2EAA2E;QACzF,YAAY,EAAE,KAAK;KACpB;CACF,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export type ComponentSize = "xs" | "sm" | "md" | "lg";
|
|
2
|
+
export interface SkeletonConfig {
|
|
3
|
+
hasRandomWidth?: boolean;
|
|
4
|
+
backgroundColor?: string;
|
|
5
|
+
foregroundColor?: string;
|
|
6
|
+
animate?: boolean;
|
|
7
|
+
title?: string;
|
|
8
|
+
speed?: number;
|
|
9
|
+
width?: number;
|
|
10
|
+
height?: number;
|
|
11
|
+
}
|
|
12
|
+
export interface LoadingComponentProps {
|
|
13
|
+
isLoading?: boolean;
|
|
14
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"components.js","sourceRoot":"","sources":["../../../src/core/types/components.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import type { DexName } from "./dex";
|
|
2
|
+
export type SlippageOption = 0.5 | 1 | 1.5 | 3;
|
|
3
|
+
export type TokenConfig = {
|
|
4
|
+
address: string;
|
|
5
|
+
chainId: number | string;
|
|
6
|
+
};
|
|
7
|
+
export interface AppConfig {
|
|
8
|
+
integratorId: string;
|
|
9
|
+
companyName?: string;
|
|
10
|
+
slippage?: SlippageOption;
|
|
11
|
+
enableExpress?: boolean;
|
|
12
|
+
enableGetGasOnDestination?: boolean;
|
|
13
|
+
infiniteApproval?: boolean;
|
|
14
|
+
apiUrl?: string;
|
|
15
|
+
internalSameChainSwapAllowed?: boolean;
|
|
16
|
+
hideAnimations?: boolean;
|
|
17
|
+
preferDex?: DexName[] | string[];
|
|
18
|
+
advanced?: {
|
|
19
|
+
shareOnTwitter?: boolean;
|
|
20
|
+
disableTradeLimit?: boolean;
|
|
21
|
+
};
|
|
22
|
+
priceImpactWarnings?: {
|
|
23
|
+
warning: number;
|
|
24
|
+
critical: number;
|
|
25
|
+
};
|
|
26
|
+
favTokens?: TokenConfig[];
|
|
27
|
+
comingSoonChainIds?: any[];
|
|
28
|
+
initialAssets?: {
|
|
29
|
+
from?: TokenConfig;
|
|
30
|
+
to?: TokenConfig;
|
|
31
|
+
};
|
|
32
|
+
defaultTokensPerChain?: TokenConfig[];
|
|
33
|
+
availableChains?: {
|
|
34
|
+
source?: (number | string)[];
|
|
35
|
+
destination?: (number | string)[];
|
|
36
|
+
};
|
|
37
|
+
collectFees?: {
|
|
38
|
+
integratorAddress: string;
|
|
39
|
+
fee: number;
|
|
40
|
+
};
|
|
41
|
+
showOnRampLink?: boolean;
|
|
42
|
+
onChainQuoting?: boolean;
|
|
43
|
+
disabledChains?: {
|
|
44
|
+
source?: string[];
|
|
45
|
+
destination?: string[];
|
|
46
|
+
};
|
|
47
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../../src/core/types/config.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
export declare enum DexName {
|
|
2
|
+
UNISWAP_V2 = "UniswapV2",
|
|
3
|
+
UNISWAP_V3 = "UniswapV3",
|
|
4
|
+
UBESWAP = "Ubeswap",
|
|
5
|
+
SPOOKYSWAP = "Spookyswap",
|
|
6
|
+
SUSHISWAP = "Sushiswap",
|
|
7
|
+
STELLASWAP = "Stellaswap",
|
|
8
|
+
PANGOLIN = "Pangolin",
|
|
9
|
+
CURVE_V2 = "Curve_v2",
|
|
10
|
+
CURVE_V2_CELO = "Curve_v2_celo",
|
|
11
|
+
ELLIPSIS = "Ellipsis",
|
|
12
|
+
QUICKSWAP = "Quickswap",
|
|
13
|
+
STELLASWAP_SADDLE = "Stellaswap_Saddle",
|
|
14
|
+
QUICKSWAP_V3 = "Quickswap_v3",
|
|
15
|
+
PANCAKESWAP = "Pancakeswap",
|
|
16
|
+
PANCAKESWAP_V3 = "Pancakeswap_v3",
|
|
17
|
+
PANCAKESWAP_STABLE = "Pancakeswap_stable",
|
|
18
|
+
TRADERJOE = "TraderJoe",
|
|
19
|
+
TRIDENT = "Trident",
|
|
20
|
+
PLATYPUS = "Platypus",
|
|
21
|
+
WOMBAT = "Wombat",
|
|
22
|
+
ZYBERSWAP = "Zyberswap",
|
|
23
|
+
KYBERSWAP = "KyberSwap",
|
|
24
|
+
KYBERSWAP_AGGREGATOR = "KyberSwap_Aggregator",
|
|
25
|
+
GMX = "GMX",
|
|
26
|
+
APESWAP = "Apeswap",
|
|
27
|
+
OPENOCEAN = "OpenOcean"
|
|
28
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
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 var DexName;
|
|
5
|
+
(function (DexName) {
|
|
6
|
+
DexName["UNISWAP_V2"] = "UniswapV2";
|
|
7
|
+
DexName["UNISWAP_V3"] = "UniswapV3";
|
|
8
|
+
DexName["UBESWAP"] = "Ubeswap";
|
|
9
|
+
DexName["SPOOKYSWAP"] = "Spookyswap";
|
|
10
|
+
DexName["SUSHISWAP"] = "Sushiswap";
|
|
11
|
+
DexName["STELLASWAP"] = "Stellaswap";
|
|
12
|
+
DexName["PANGOLIN"] = "Pangolin";
|
|
13
|
+
DexName["CURVE_V2"] = "Curve_v2";
|
|
14
|
+
DexName["CURVE_V2_CELO"] = "Curve_v2_celo";
|
|
15
|
+
DexName["ELLIPSIS"] = "Ellipsis";
|
|
16
|
+
DexName["QUICKSWAP"] = "Quickswap";
|
|
17
|
+
DexName["STELLASWAP_SADDLE"] = "Stellaswap_Saddle";
|
|
18
|
+
DexName["QUICKSWAP_V3"] = "Quickswap_v3";
|
|
19
|
+
DexName["PANCAKESWAP"] = "Pancakeswap";
|
|
20
|
+
DexName["PANCAKESWAP_V3"] = "Pancakeswap_v3";
|
|
21
|
+
DexName["PANCAKESWAP_STABLE"] = "Pancakeswap_stable";
|
|
22
|
+
DexName["TRADERJOE"] = "TraderJoe";
|
|
23
|
+
DexName["TRIDENT"] = "Trident";
|
|
24
|
+
DexName["PLATYPUS"] = "Platypus";
|
|
25
|
+
DexName["WOMBAT"] = "Wombat";
|
|
26
|
+
DexName["ZYBERSWAP"] = "Zyberswap";
|
|
27
|
+
DexName["KYBERSWAP"] = "KyberSwap";
|
|
28
|
+
DexName["KYBERSWAP_AGGREGATOR"] = "KyberSwap_Aggregator";
|
|
29
|
+
DexName["GMX"] = "GMX";
|
|
30
|
+
DexName["APESWAP"] = "Apeswap";
|
|
31
|
+
DexName["OPENOCEAN"] = "OpenOcean";
|
|
32
|
+
})(DexName || (DexName = {}));
|
|
33
|
+
//# sourceMappingURL=dex.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dex.js","sourceRoot":"","sources":["../../../src/core/types/dex.ts"],"names":[],"mappings":"AAAA,8CAA8C;AAC9C,8DAA8D;AAC9D,yCAAyC;AACzC,MAAM,CAAN,IAAY,OA2BX;AA3BD,WAAY,OAAO;IACjB,mCAAwB,CAAA;IACxB,mCAAwB,CAAA;IACxB,8BAAmB,CAAA;IACnB,oCAAyB,CAAA;IACzB,kCAAuB,CAAA;IACvB,oCAAyB,CAAA;IACzB,gCAAqB,CAAA;IACrB,gCAAqB,CAAA;IACrB,0CAA+B,CAAA;IAC/B,gCAAqB,CAAA;IACrB,kCAAuB,CAAA;IACvB,kDAAuC,CAAA;IACvC,wCAA6B,CAAA;IAC7B,sCAA2B,CAAA;IAC3B,4CAAiC,CAAA;IACjC,oDAAyC,CAAA;IACzC,kCAAuB,CAAA;IACvB,8BAAmB,CAAA;IACnB,gCAAqB,CAAA;IACrB,4BAAiB,CAAA;IACjB,kCAAuB,CAAA;IACvB,kCAAuB,CAAA;IACvB,wDAA6C,CAAA;IAC7C,sBAAW,CAAA;IACX,8BAAmB,CAAA;IACnB,kCAAuB,CAAA;AACzB,CAAC,EA3BW,OAAO,KAAP,OAAO,QA2BlB"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import type { TransactionResponse } from "@ethersproject/providers";
|
|
2
|
+
import type { BigNumber } from "ethers";
|
|
3
|
+
export declare enum TransactionErrorType {
|
|
4
|
+
REJECTED_BY_USER = 0,
|
|
5
|
+
CALL_EXCEPTION = 1,
|
|
6
|
+
UNKNOWN = 2,
|
|
7
|
+
WARNING = 3
|
|
8
|
+
}
|
|
9
|
+
export type TransactionErrorWithMessage = {
|
|
10
|
+
type: TransactionErrorType;
|
|
11
|
+
message: string;
|
|
12
|
+
};
|
|
13
|
+
export interface TransactionReplacedError extends Error {
|
|
14
|
+
code: string;
|
|
15
|
+
replacement: TransactionResponse;
|
|
16
|
+
}
|
|
17
|
+
export interface TransactionError {
|
|
18
|
+
reason: string;
|
|
19
|
+
code: string;
|
|
20
|
+
action: string;
|
|
21
|
+
message: string;
|
|
22
|
+
transaction: {
|
|
23
|
+
to: string;
|
|
24
|
+
data: string;
|
|
25
|
+
gasLimit: number;
|
|
26
|
+
value: {
|
|
27
|
+
type: BigNumber;
|
|
28
|
+
hex: string;
|
|
29
|
+
};
|
|
30
|
+
from: string;
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
export interface SquidRouteError {
|
|
34
|
+
code?: string;
|
|
35
|
+
errorType?: string;
|
|
36
|
+
message?: string;
|
|
37
|
+
}
|
|
38
|
+
export interface SquidStatusError {
|
|
39
|
+
errorType?: string;
|
|
40
|
+
}
|
|
41
|
+
export type SquidRouteErrorType = "Unknown" | "UnknownError" | "SquidServiceError";
|
|
42
|
+
export declare enum SquidStatusErrorType {
|
|
43
|
+
NotFoundError = "NotFoundError"
|
|
44
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export var TransactionErrorType;
|
|
2
|
+
(function (TransactionErrorType) {
|
|
3
|
+
TransactionErrorType[TransactionErrorType["REJECTED_BY_USER"] = 0] = "REJECTED_BY_USER";
|
|
4
|
+
TransactionErrorType[TransactionErrorType["CALL_EXCEPTION"] = 1] = "CALL_EXCEPTION";
|
|
5
|
+
TransactionErrorType[TransactionErrorType["UNKNOWN"] = 2] = "UNKNOWN";
|
|
6
|
+
TransactionErrorType[TransactionErrorType["WARNING"] = 3] = "WARNING";
|
|
7
|
+
})(TransactionErrorType || (TransactionErrorType = {}));
|
|
8
|
+
export var SquidStatusErrorType;
|
|
9
|
+
(function (SquidStatusErrorType) {
|
|
10
|
+
SquidStatusErrorType["NotFoundError"] = "NotFoundError";
|
|
11
|
+
})(SquidStatusErrorType || (SquidStatusErrorType = {}));
|
|
12
|
+
//# sourceMappingURL=error.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"error.js","sourceRoot":"","sources":["../../../src/core/types/error.ts"],"names":[],"mappings":"AAGA,MAAM,CAAN,IAAY,oBAKX;AALD,WAAY,oBAAoB;IAC9B,uFAAgB,CAAA;IAChB,mFAAc,CAAA;IACd,qEAAO,CAAA;IACP,qEAAO,CAAA;AACT,CAAC,EALW,oBAAoB,KAApB,oBAAoB,QAK/B;AAyCD,MAAM,CAAN,IAAY,oBAEX;AAFD,WAAY,oBAAoB;IAC9B,uDAA+B,CAAA;AACjC,CAAC,EAFW,oBAAoB,KAApB,oBAAoB,QAE/B"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { RouteResponse } from "@0xsquid/sdk/dist/types";
|
|
2
|
+
export interface WidgetEventMap {
|
|
3
|
+
swapStatus: {
|
|
4
|
+
status: string;
|
|
5
|
+
};
|
|
6
|
+
swap: {
|
|
7
|
+
route: RouteResponse["route"];
|
|
8
|
+
txHash: string;
|
|
9
|
+
};
|
|
10
|
+
swapParamsChanged: {
|
|
11
|
+
fromChainId?: string;
|
|
12
|
+
toChainId?: string;
|
|
13
|
+
fromTokenAddress?: string;
|
|
14
|
+
toTokenAddress?: string;
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
export type EventListenerFunction<T extends keyof WidgetEventMap> = (event: CustomEvent<WidgetEventMap[T]>) => void;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"event.js","sourceRoot":"","sources":["../../../src/core/types/event.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export type Routes = "swap" | "settings" | "wallets" | "tokens" | "chains" | "history" | "transaction" | "allTokens" | "destination";
|
|
2
|
+
type HeaderButton = "back" | "settings" | "history";
|
|
3
|
+
export interface WidgetRoute {
|
|
4
|
+
id: Routes;
|
|
5
|
+
path: string;
|
|
6
|
+
title: string;
|
|
7
|
+
headerButtons?: HeaderButton[];
|
|
8
|
+
}
|
|
9
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"route.js","sourceRoot":"","sources":["../../../src/core/types/route.ts"],"names":[],"mappings":"AAAA,yCAAyC;AACzC,+BAA+B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"swap.js","sourceRoot":"","sources":["../../../src/core/types/swap.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { Token } from "@0xsquid/sdk/dist/types";
|
|
2
|
+
export type TokenWithBalance = Token & {
|
|
3
|
+
balance: string;
|
|
4
|
+
priceUSD?: string;
|
|
5
|
+
isFavorite?: boolean;
|
|
6
|
+
};
|
|
7
|
+
export type AxelarTokenData = {
|
|
8
|
+
id: string;
|
|
9
|
+
common_key: object;
|
|
10
|
+
native_chain: string;
|
|
11
|
+
fully_supported: boolean;
|
|
12
|
+
decimals: number;
|
|
13
|
+
chain_aliases: {
|
|
14
|
+
[key: string]: {
|
|
15
|
+
assetSymbol: string;
|
|
16
|
+
assetName: string;
|
|
17
|
+
minDepositAmt: number;
|
|
18
|
+
ibcDenom: string;
|
|
19
|
+
fullDenomPath: string;
|
|
20
|
+
tokenAddress: string;
|
|
21
|
+
mintLimit: number;
|
|
22
|
+
};
|
|
23
|
+
};
|
|
24
|
+
};
|
|
25
|
+
export type AxelarTokensData = {
|
|
26
|
+
assets: {
|
|
27
|
+
[key: string]: AxelarTokenData;
|
|
28
|
+
};
|
|
29
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tokens.js","sourceRoot":"","sources":["../../../src/core/types/tokens.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import type { ChainData, RouteResponse, Token } from "@0xsquid/sdk/dist/types";
|
|
2
|
+
import type { UseQueryResult } from "@tanstack/react-query";
|
|
3
|
+
import type { TransactionErrorWithMessage } from "./error";
|
|
4
|
+
export declare enum TransactionType {
|
|
5
|
+
BRIDGE = "BRIDGE",
|
|
6
|
+
BRIDGE_CALL = "BRIDGE_CALL",
|
|
7
|
+
CALL_BRIDGE = "CALL_BRIDGE",
|
|
8
|
+
CALL_BRIDGE_CALL = "CALL_BRIDGE_CALL"
|
|
9
|
+
}
|
|
10
|
+
export declare enum AxelarStatusResponseType {
|
|
11
|
+
GAS_PAID_NOT_ENOUGH_GAS = "gas_paid_not_enough_gas",
|
|
12
|
+
DESTINATION_EXECUTED = "destination_executed",
|
|
13
|
+
EXPRESS_EXECUTED = "express_executed",
|
|
14
|
+
CROSS_MULTICALL_EXECUTED = "CrossMulticallExecuted",
|
|
15
|
+
CROSS_MULTICALL_FAILED = "CrossMulticallFailed",
|
|
16
|
+
SRC_GATEWAY_CALLED = "source_gateway_called",
|
|
17
|
+
DEST_GATEWAY_APPROVED = "destination_gateway_approved",
|
|
18
|
+
DESTINATION_EXECUTE_ERROR = "destination_execute_error",
|
|
19
|
+
DESTINATION_EXECUTING = "executing",
|
|
20
|
+
UNKNOWN_ERROR = "unknown_error",
|
|
21
|
+
CANNOT_FETCH_STATUS = "cannot_fetch_status",
|
|
22
|
+
ERROR = "error"
|
|
23
|
+
}
|
|
24
|
+
export declare enum TransactionStatus {
|
|
25
|
+
SUCCESS = "success",
|
|
26
|
+
NEEDS_GAS = "needs_gas",
|
|
27
|
+
ONGOING = "ongoing",
|
|
28
|
+
PARTIAL_SUCCESS = "partial_success",
|
|
29
|
+
NOT_FOUND = "not_found",
|
|
30
|
+
INITIAL_LOADING = "initialLoading",
|
|
31
|
+
ERROR = "error",
|
|
32
|
+
WARNING = "warning",
|
|
33
|
+
PENDING = "pending",
|
|
34
|
+
REJECTED = "rejected"
|
|
35
|
+
}
|
|
36
|
+
export interface TransactionParams {
|
|
37
|
+
routeType: string;
|
|
38
|
+
fromChain?: ChainData;
|
|
39
|
+
toChain?: ChainData;
|
|
40
|
+
nonce?: number;
|
|
41
|
+
transactionId: string | undefined;
|
|
42
|
+
timestamp?: number;
|
|
43
|
+
sourceStatus?: TransactionStatus;
|
|
44
|
+
status: TransactionStatus;
|
|
45
|
+
error?: TransactionErrorWithMessage;
|
|
46
|
+
fromAddress?: string;
|
|
47
|
+
statusResponse?: any;
|
|
48
|
+
axelarUrl?: string;
|
|
49
|
+
sourceTxExplorerUrl?: string;
|
|
50
|
+
sourceExplorerImgUrl?: string;
|
|
51
|
+
}
|
|
52
|
+
export type TransactionHistoryStore = TransactionParams & Pick<RouteResponse["route"], "params" | "estimate">;
|
|
53
|
+
export interface TransactionStepsProps {
|
|
54
|
+
currentTransaction?: TransactionParams;
|
|
55
|
+
sourceExplorerUrl?: string;
|
|
56
|
+
fromToken?: Token;
|
|
57
|
+
toToken?: Token;
|
|
58
|
+
toChain?: ChainData;
|
|
59
|
+
fromChain?: ChainData;
|
|
60
|
+
}
|
|
61
|
+
export type TransactionStepProps = TransactionStepsProps & {
|
|
62
|
+
statusResponse?: UseQueryResult<any, unknown>;
|
|
63
|
+
};
|
|
64
|
+
export interface StepStatusGetterProps {
|
|
65
|
+
transaction?: TransactionParams;
|
|
66
|
+
statusResponse?: UseQueryResult<any, unknown>;
|
|
67
|
+
onlyFullStatusStep?: boolean;
|
|
68
|
+
}
|