@relayprotocol/relay-kit-ui 2.17.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/_cjs/package.json +1 -0
- package/_cjs/src/components/common/AmountInput.js +42 -0
- package/_cjs/src/components/common/AmountInput.js.map +1 -0
- package/_cjs/src/components/common/BalanceDisplay.js +18 -0
- package/_cjs/src/components/common/BalanceDisplay.js.map +1 -0
- package/_cjs/src/components/common/CopyToClipBoard.js +36 -0
- package/_cjs/src/components/common/CopyToClipBoard.js.map +1 -0
- package/_cjs/src/components/common/CustomAddressModal.js +105 -0
- package/_cjs/src/components/common/CustomAddressModal.js.map +1 -0
- package/_cjs/src/components/common/ErrorWell.js +41 -0
- package/_cjs/src/components/common/ErrorWell.js.map +1 -0
- package/_cjs/src/components/common/LoadingSpinner.js +19 -0
- package/_cjs/src/components/common/LoadingSpinner.js.map +1 -0
- package/_cjs/src/components/common/Modal.js +34 -0
- package/_cjs/src/components/common/Modal.js.map +1 -0
- package/_cjs/src/components/common/MultiWalletDropdown.js +148 -0
- package/_cjs/src/components/common/MultiWalletDropdown.js.map +1 -0
- package/_cjs/src/components/common/RefundReason.js +52 -0
- package/_cjs/src/components/common/RefundReason.js.map +1 -0
- package/_cjs/src/components/common/SlippageToleranceConfig.js +143 -0
- package/_cjs/src/components/common/SlippageToleranceConfig.js.map +1 -0
- package/_cjs/src/components/common/TokenSelector/ChainFilter.js +119 -0
- package/_cjs/src/components/common/TokenSelector/ChainFilter.js.map +1 -0
- package/_cjs/src/components/common/TokenSelector/ChainFilterSidebar.js +150 -0
- package/_cjs/src/components/common/TokenSelector/ChainFilterSidebar.js.map +1 -0
- package/_cjs/src/components/common/TokenSelector/SuggestedTokens.js +67 -0
- package/_cjs/src/components/common/TokenSelector/SuggestedTokens.js.map +1 -0
- package/_cjs/src/components/common/TokenSelector/TagPill.js +18 -0
- package/_cjs/src/components/common/TokenSelector/TagPill.js.map +1 -0
- package/_cjs/src/components/common/TokenSelector/TokenList.js +83 -0
- package/_cjs/src/components/common/TokenSelector/TokenList.js.map +1 -0
- package/_cjs/src/components/common/TokenSelector/TokenSelector.js +402 -0
- package/_cjs/src/components/common/TokenSelector/TokenSelector.js.map +1 -0
- package/_cjs/src/components/common/TokenSelector/triggers/TokenTrigger.js +42 -0
- package/_cjs/src/components/common/TokenSelector/triggers/TokenTrigger.js.map +1 -0
- package/_cjs/src/components/common/TransactionModal/DepositAddressModal.js +85 -0
- package/_cjs/src/components/common/TransactionModal/DepositAddressModal.js.map +1 -0
- package/_cjs/src/components/common/TransactionModal/DepositAddressModalRenderer.js +247 -0
- package/_cjs/src/components/common/TransactionModal/DepositAddressModalRenderer.js.map +1 -0
- package/_cjs/src/components/common/TransactionModal/TransactionModal.js +121 -0
- package/_cjs/src/components/common/TransactionModal/TransactionModal.js.map +1 -0
- package/_cjs/src/components/common/TransactionModal/TransactionModalRenderer.js +136 -0
- package/_cjs/src/components/common/TransactionModal/TransactionModalRenderer.js.map +1 -0
- package/_cjs/src/components/common/TransactionModal/steps/ApprovalPlusSwapStep.js +80 -0
- package/_cjs/src/components/common/TransactionModal/steps/ApprovalPlusSwapStep.js.map +1 -0
- package/_cjs/src/components/common/TransactionModal/steps/DepositAddressValidatingStep.js +21 -0
- package/_cjs/src/components/common/TransactionModal/steps/DepositAddressValidatingStep.js.map +1 -0
- package/_cjs/src/components/common/TransactionModal/steps/ErrorStep.js +82 -0
- package/_cjs/src/components/common/TransactionModal/steps/ErrorStep.js.map +1 -0
- package/_cjs/src/components/common/TransactionModal/steps/SwapConfirmationStep.js +117 -0
- package/_cjs/src/components/common/TransactionModal/steps/SwapConfirmationStep.js.map +1 -0
- package/_cjs/src/components/common/TransactionModal/steps/SwapSuccessStep.js +131 -0
- package/_cjs/src/components/common/TransactionModal/steps/SwapSuccessStep.js.map +1 -0
- package/_cjs/src/components/common/TransactionModal/steps/TransactionsByChain.js +67 -0
- package/_cjs/src/components/common/TransactionModal/steps/TransactionsByChain.js.map +1 -0
- package/_cjs/src/components/common/TransactionModal/steps/WaitingForDepositStep.js +86 -0
- package/_cjs/src/components/common/TransactionModal/steps/WaitingForDepositStep.js.map +1 -0
- package/_cjs/src/components/common/UnverifiedTokenModal.js +75 -0
- package/_cjs/src/components/common/UnverifiedTokenModal.js.map +1 -0
- package/_cjs/src/components/primitives/AccessibleList.js +33 -0
- package/_cjs/src/components/primitives/AccessibleList.js.map +1 -0
- package/_cjs/src/components/primitives/Anchor.js +57 -0
- package/_cjs/src/components/primitives/Anchor.js.map +1 -0
- package/_cjs/src/components/primitives/Box.js +10 -0
- package/_cjs/src/components/primitives/Box.js.map +1 -0
- package/_cjs/src/components/primitives/Button.js +155 -0
- package/_cjs/src/components/primitives/Button.js.map +1 -0
- package/_cjs/src/components/primitives/ChainIcon.js +35 -0
- package/_cjs/src/components/primitives/ChainIcon.js.map +1 -0
- package/_cjs/src/components/primitives/ChainTokenIcon.js +54 -0
- package/_cjs/src/components/primitives/ChainTokenIcon.js.map +1 -0
- package/_cjs/src/components/primitives/Collapsible.js +46 -0
- package/_cjs/src/components/primitives/Collapsible.js.map +1 -0
- package/_cjs/src/components/primitives/Dialog.js +104 -0
- package/_cjs/src/components/primitives/Dialog.js.map +1 -0
- package/_cjs/src/components/primitives/Dropdown.js +55 -0
- package/_cjs/src/components/primitives/Dropdown.js.map +1 -0
- package/_cjs/src/components/primitives/Flex.js +76 -0
- package/_cjs/src/components/primitives/Flex.js.map +1 -0
- package/_cjs/src/components/primitives/Input.js +69 -0
- package/_cjs/src/components/primitives/Input.js.map +1 -0
- package/_cjs/src/components/primitives/Pill.js +64 -0
- package/_cjs/src/components/primitives/Pill.js.map +1 -0
- package/_cjs/src/components/primitives/Skeleton.js +18 -0
- package/_cjs/src/components/primitives/Skeleton.js.map +1 -0
- package/_cjs/src/components/primitives/Switch.js +53 -0
- package/_cjs/src/components/primitives/Switch.js.map +1 -0
- package/_cjs/src/components/primitives/Tabs.js +53 -0
- package/_cjs/src/components/primitives/Tabs.js.map +1 -0
- package/_cjs/src/components/primitives/Text.js +106 -0
- package/_cjs/src/components/primitives/Text.js.map +1 -0
- package/_cjs/src/components/primitives/Tooltip.js +44 -0
- package/_cjs/src/components/primitives/Tooltip.js.map +1 -0
- package/_cjs/src/components/primitives/index.js +31 -0
- package/_cjs/src/components/primitives/index.js.map +1 -0
- package/_cjs/src/components/widgets/FeeBreakdown.js +165 -0
- package/_cjs/src/components/widgets/FeeBreakdown.js.map +1 -0
- package/_cjs/src/components/widgets/FetchingQuoteLoader.js +20 -0
- package/_cjs/src/components/widgets/FetchingQuoteLoader.js.map +1 -0
- package/_cjs/src/components/widgets/OnrampWidget/index.js +9 -0
- package/_cjs/src/components/widgets/OnrampWidget/index.js.map +1 -0
- package/_cjs/src/components/widgets/OnrampWidget/modals/OnrampModal.js +286 -0
- package/_cjs/src/components/widgets/OnrampWidget/modals/OnrampModal.js.map +1 -0
- package/_cjs/src/components/widgets/OnrampWidget/modals/steps/OnrampConfirmingStep.js +42 -0
- package/_cjs/src/components/widgets/OnrampWidget/modals/steps/OnrampConfirmingStep.js.map +1 -0
- package/_cjs/src/components/widgets/OnrampWidget/modals/steps/OnrampMoonPayStep.js +203 -0
- package/_cjs/src/components/widgets/OnrampWidget/modals/steps/OnrampMoonPayStep.js.map +1 -0
- package/_cjs/src/components/widgets/OnrampWidget/modals/steps/OnrampProcessingPassthroughStep.js +45 -0
- package/_cjs/src/components/widgets/OnrampWidget/modals/steps/OnrampProcessingPassthroughStep.js.map +1 -0
- package/_cjs/src/components/widgets/OnrampWidget/modals/steps/OnrampProcessingStepUI.js +87 -0
- package/_cjs/src/components/widgets/OnrampWidget/modals/steps/OnrampProcessingStepUI.js.map +1 -0
- package/_cjs/src/components/widgets/OnrampWidget/modals/steps/OnrampSuccessStep.js +39 -0
- package/_cjs/src/components/widgets/OnrampWidget/modals/steps/OnrampSuccessStep.js.map +1 -0
- package/_cjs/src/components/widgets/OnrampWidget/widget/FiatCurrencyModal.js +171 -0
- package/_cjs/src/components/widgets/OnrampWidget/widget/FiatCurrencyModal.js.map +1 -0
- package/_cjs/src/components/widgets/OnrampWidget/widget/OnrampWidgetRenderer.js +197 -0
- package/_cjs/src/components/widgets/OnrampWidget/widget/OnrampWidgetRenderer.js.map +1 -0
- package/_cjs/src/components/widgets/OnrampWidget/widget/index.js +332 -0
- package/_cjs/src/components/widgets/OnrampWidget/widget/index.js.map +1 -0
- package/_cjs/src/components/widgets/PriceImpactTooltip.js +28 -0
- package/_cjs/src/components/widgets/PriceImpactTooltip.js.map +1 -0
- package/_cjs/src/components/widgets/SwapButton.js +37 -0
- package/_cjs/src/components/widgets/SwapButton.js.map +1 -0
- package/_cjs/src/components/widgets/SwapRouteSelector.js +86 -0
- package/_cjs/src/components/widgets/SwapRouteSelector.js.map +1 -0
- package/_cjs/src/components/widgets/SwapWidget/GasTopUpSection.js +24 -0
- package/_cjs/src/components/widgets/SwapWidget/GasTopUpSection.js.map +1 -0
- package/_cjs/src/components/widgets/SwapWidget/index.js +912 -0
- package/_cjs/src/components/widgets/SwapWidget/index.js.map +1 -0
- package/_cjs/src/components/widgets/SwapWidgetRenderer.js +735 -0
- package/_cjs/src/components/widgets/SwapWidgetRenderer.js.map +1 -0
- package/_cjs/src/components/widgets/TokenSelectorContainer.js +20 -0
- package/_cjs/src/components/widgets/TokenSelectorContainer.js.map +1 -0
- package/_cjs/src/components/widgets/WidgetContainer.js +27 -0
- package/_cjs/src/components/widgets/WidgetContainer.js.map +1 -0
- package/_cjs/src/components/widgets/WidgetErrorWell.js +148 -0
- package/_cjs/src/components/widgets/WidgetErrorWell.js.map +1 -0
- package/_cjs/src/components/widgets/WidgetFooter.js +34 -0
- package/_cjs/src/components/widgets/WidgetFooter.js.map +1 -0
- package/_cjs/src/constants/address.js +15 -0
- package/_cjs/src/constants/address.js.map +1 -0
- package/_cjs/src/constants/agwRegistryAbi.js +20 -0
- package/_cjs/src/constants/agwRegistryAbi.js.map +1 -0
- package/_cjs/src/constants/cache.js +6 -0
- package/_cjs/src/constants/cache.js.map +1 -0
- package/_cjs/src/constants/chainIdToAlchemyNetworkMap.js +13 -0
- package/_cjs/src/constants/chainIdToAlchemyNetworkMap.js.map +1 -0
- package/_cjs/src/constants/currencies.js +3 -0
- package/_cjs/src/constants/currencies.js.map +1 -0
- package/_cjs/src/constants/depositAddresses.js +14 -0
- package/_cjs/src/constants/depositAddresses.js.map +1 -0
- package/_cjs/src/constants/events.js +62 -0
- package/_cjs/src/constants/events.js.map +1 -0
- package/_cjs/src/constants/maxGasBuffer.js +12 -0
- package/_cjs/src/constants/maxGasBuffer.js.map +1 -0
- package/_cjs/src/constants/moonPayCurrencies.js +295 -0
- package/_cjs/src/constants/moonPayCurrencies.js.map +1 -0
- package/_cjs/src/constants/moonPayFiatCurrencies.js +209 -0
- package/_cjs/src/constants/moonPayFiatCurrencies.js.map +1 -0
- package/_cjs/src/constants/walletCompatibility.js +23 -0
- package/_cjs/src/constants/walletCompatibility.js.map +1 -0
- package/_cjs/src/hooks/index.js +51 -0
- package/_cjs/src/hooks/index.js.map +1 -0
- package/_cjs/src/hooks/useAdaptedWalletBalance.js +28 -0
- package/_cjs/src/hooks/useAdaptedWalletBalance.js.map +1 -0
- package/_cjs/src/hooks/useAtomicBatchSupport.js +34 -0
- package/_cjs/src/hooks/useAtomicBatchSupport.js.map +1 -0
- package/_cjs/src/hooks/useBitcoinBalance.js +40 -0
- package/_cjs/src/hooks/useBitcoinBalance.js.map +1 -0
- package/_cjs/src/hooks/useCexAddresses.js +21 -0
- package/_cjs/src/hooks/useCexAddresses.js.map +1 -0
- package/_cjs/src/hooks/useCurrencyBalance.js +234 -0
- package/_cjs/src/hooks/useCurrencyBalance.js.map +1 -0
- package/_cjs/src/hooks/useDebounceState.js +35 -0
- package/_cjs/src/hooks/useDebounceState.js.map +1 -0
- package/_cjs/src/hooks/useDisconnected.js +14 -0
- package/_cjs/src/hooks/useDisconnected.js.map +1 -0
- package/_cjs/src/hooks/useDuneBalances.js +99 -0
- package/_cjs/src/hooks/useDuneBalances.js.map +1 -0
- package/_cjs/src/hooks/useENSResolver.js +37 -0
- package/_cjs/src/hooks/useENSResolver.js.map +1 -0
- package/_cjs/src/hooks/useEclipseBalance.js +47 -0
- package/_cjs/src/hooks/useEclipseBalance.js.map +1 -0
- package/_cjs/src/hooks/useEnhancedTokensList.js +80 -0
- package/_cjs/src/hooks/useEnhancedTokensList.js.map +1 -0
- package/_cjs/src/hooks/useFallbackState.js +12 -0
- package/_cjs/src/hooks/useFallbackState.js.map +1 -0
- package/_cjs/src/hooks/useGasTopUpRequired.js +59 -0
- package/_cjs/src/hooks/useGasTopUpRequired.js.map +1 -0
- package/_cjs/src/hooks/useHyperliquidUsdcBalance.js +37 -0
- package/_cjs/src/hooks/useHyperliquidUsdcBalance.js.map +1 -0
- package/_cjs/src/hooks/useInternalRelayChains.js +23 -0
- package/_cjs/src/hooks/useInternalRelayChains.js.map +1 -0
- package/_cjs/src/hooks/useIpAddress.js +12 -0
- package/_cjs/src/hooks/useIpAddress.js.map +1 -0
- package/_cjs/src/hooks/useIsAGW.js +34 -0
- package/_cjs/src/hooks/useIsAGW.js.map +1 -0
- package/_cjs/src/hooks/useIsPassthrough.js +56 -0
- package/_cjs/src/hooks/useIsPassthrough.js.map +1 -0
- package/_cjs/src/hooks/useIsWalletCompatible.js +42 -0
- package/_cjs/src/hooks/useIsWalletCompatible.js.map +1 -0
- package/_cjs/src/hooks/useMoonPayCurrencies.js +23 -0
- package/_cjs/src/hooks/useMoonPayCurrencies.js.map +1 -0
- package/_cjs/src/hooks/useMoonPayGeolocation.js +25 -0
- package/_cjs/src/hooks/useMoonPayGeolocation.js.map +1 -0
- package/_cjs/src/hooks/useMoonPayTransaction.js +25 -0
- package/_cjs/src/hooks/useMoonPayTransaction.js.map +1 -0
- package/_cjs/src/hooks/useMounted.js +11 -0
- package/_cjs/src/hooks/useMounted.js.map +1 -0
- package/_cjs/src/hooks/usePreviousValueChange.js +14 -0
- package/_cjs/src/hooks/usePreviousValueChange.js.map +1 -0
- package/_cjs/src/hooks/useRelayClient.js +9 -0
- package/_cjs/src/hooks/useRelayClient.js.map +1 -0
- package/_cjs/src/hooks/useSuiBalance.js +48 -0
- package/_cjs/src/hooks/useSuiBalance.js.map +1 -0
- package/_cjs/src/hooks/useSupportedMoonPayCurrencyCode.js +65 -0
- package/_cjs/src/hooks/useSupportedMoonPayCurrencyCode.js.map +1 -0
- package/_cjs/src/hooks/useWalletAddress.js +23 -0
- package/_cjs/src/hooks/useWalletAddress.js.map +1 -0
- package/_cjs/src/hooks/widget/useSwapButtonCta.js +76 -0
- package/_cjs/src/hooks/widget/useSwapButtonCta.js.map +1 -0
- package/_cjs/src/icons/SwitchIcon.js +9 -0
- package/_cjs/src/icons/SwitchIcon.js.map +1 -0
- package/_cjs/src/icons/index.js +6 -0
- package/_cjs/src/icons/index.js.map +1 -0
- package/_cjs/src/img/AllChainsLogo.js +10 -0
- package/_cjs/src/img/AllChainsLogo.js.map +1 -0
- package/_cjs/src/img/MoonPayLogo.js +10 -0
- package/_cjs/src/img/MoonPayLogo.js.map +1 -0
- package/_cjs/src/img/ReservoirText.js +10 -0
- package/_cjs/src/img/ReservoirText.js.map +1 -0
- package/_cjs/src/index.js +23 -0
- package/_cjs/src/index.js.map +1 -0
- package/_cjs/src/providers/RelayClientProvider.js +14 -0
- package/_cjs/src/providers/RelayClientProvider.js.map +1 -0
- package/_cjs/src/providers/RelayKitProvider.js +123 -0
- package/_cjs/src/providers/RelayKitProvider.js.map +1 -0
- package/_cjs/src/styles.css +3408 -0
- package/_cjs/src/themes/RelayKitTheme.js +89 -0
- package/_cjs/src/themes/RelayKitTheme.js.map +1 -0
- package/_cjs/src/themes/index.js +6 -0
- package/_cjs/src/themes/index.js.map +1 -0
- package/_cjs/src/types/BridgeFee.js +3 -0
- package/_cjs/src/types/BridgeFee.js.map +1 -0
- package/_cjs/src/types/Fiat.js +3 -0
- package/_cjs/src/types/Fiat.js.map +1 -0
- package/_cjs/src/types/RelayTransaction.js +3 -0
- package/_cjs/src/types/RelayTransaction.js.map +1 -0
- package/_cjs/src/types/index.js +3 -0
- package/_cjs/src/types/index.js.map +1 -0
- package/_cjs/src/utils/address.js +75 -0
- package/_cjs/src/utils/address.js.map +1 -0
- package/_cjs/src/utils/bitcoin.js +12 -0
- package/_cjs/src/utils/bitcoin.js.map +1 -0
- package/_cjs/src/utils/browser.js +8 -0
- package/_cjs/src/utils/browser.js.map +1 -0
- package/_cjs/src/utils/ens.js +9 -0
- package/_cjs/src/utils/ens.js.map +1 -0
- package/_cjs/src/utils/errors.js +38 -0
- package/_cjs/src/utils/errors.js.map +1 -0
- package/_cjs/src/utils/fetcher.js +20 -0
- package/_cjs/src/utils/fetcher.js.map +1 -0
- package/_cjs/src/utils/getChainBlockExplorerUrl.js +12 -0
- package/_cjs/src/utils/getChainBlockExplorerUrl.js.map +1 -0
- package/_cjs/src/utils/getTxBlockExplorerUrl.js +28 -0
- package/_cjs/src/utils/getTxBlockExplorerUrl.js.map +1 -0
- package/_cjs/src/utils/hashing.js +41 -0
- package/_cjs/src/utils/hashing.js.map +1 -0
- package/_cjs/src/utils/localStorage.js +84 -0
- package/_cjs/src/utils/localStorage.js.map +1 -0
- package/_cjs/src/utils/moonPay.js +49 -0
- package/_cjs/src/utils/moonPay.js.map +1 -0
- package/_cjs/src/utils/nativeMaxAmount.js +137 -0
- package/_cjs/src/utils/nativeMaxAmount.js.map +1 -0
- package/_cjs/src/utils/numbers.js +171 -0
- package/_cjs/src/utils/numbers.js.map +1 -0
- package/_cjs/src/utils/qrcode.js +23 -0
- package/_cjs/src/utils/qrcode.js.map +1 -0
- package/_cjs/src/utils/quote.js +262 -0
- package/_cjs/src/utils/quote.js.map +1 -0
- package/_cjs/src/utils/relayTransaction.js +85 -0
- package/_cjs/src/utils/relayTransaction.js.map +1 -0
- package/_cjs/src/utils/slippage.js +18 -0
- package/_cjs/src/utils/slippage.js.map +1 -0
- package/_cjs/src/utils/solana.js +16 -0
- package/_cjs/src/utils/solana.js.map +1 -0
- package/_cjs/src/utils/steps.js +87 -0
- package/_cjs/src/utils/steps.js.map +1 -0
- package/_cjs/src/utils/sui.js +15 -0
- package/_cjs/src/utils/sui.js.map +1 -0
- package/_cjs/src/utils/theme.js +40 -0
- package/_cjs/src/utils/theme.js.map +1 -0
- package/_cjs/src/utils/time.js +36 -0
- package/_cjs/src/utils/time.js.map +1 -0
- package/_cjs/src/utils/titleCase.js +9 -0
- package/_cjs/src/utils/titleCase.js.map +1 -0
- package/_cjs/src/utils/tokenSelector.js +81 -0
- package/_cjs/src/utils/tokenSelector.js.map +1 -0
- package/_cjs/src/utils/tokens.js +56 -0
- package/_cjs/src/utils/tokens.js.map +1 -0
- package/_cjs/src/utils/tron.js +12 -0
- package/_cjs/src/utils/tron.js.map +1 -0
- package/_cjs/src/utils/truncate.js +18 -0
- package/_cjs/src/utils/truncate.js.map +1 -0
- package/_cjs/src/version.js +5 -0
- package/_cjs/src/version.js.map +1 -0
- package/_cjs/tsconfig.build.tsbuildinfo +1 -0
- package/_esm/package.json +1 -0
- package/_esm/src/components/common/AmountInput.js +43 -0
- package/_esm/src/components/common/AmountInput.js.map +1 -0
- package/_esm/src/components/common/BalanceDisplay.js +15 -0
- package/_esm/src/components/common/BalanceDisplay.js.map +1 -0
- package/_esm/src/components/common/CopyToClipBoard.js +31 -0
- package/_esm/src/components/common/CopyToClipBoard.js.map +1 -0
- package/_esm/src/components/common/CustomAddressModal.js +102 -0
- package/_esm/src/components/common/CustomAddressModal.js.map +1 -0
- package/_esm/src/components/common/ErrorWell.js +38 -0
- package/_esm/src/components/common/ErrorWell.js.map +1 -0
- package/_esm/src/components/common/LoadingSpinner.js +15 -0
- package/_esm/src/components/common/LoadingSpinner.js.map +1 -0
- package/_esm/src/components/common/Modal.js +30 -0
- package/_esm/src/components/common/Modal.js.map +1 -0
- package/_esm/src/components/common/MultiWalletDropdown.js +144 -0
- package/_esm/src/components/common/MultiWalletDropdown.js.map +1 -0
- package/_esm/src/components/common/RefundReason.js +49 -0
- package/_esm/src/components/common/RefundReason.js.map +1 -0
- package/_esm/src/components/common/SlippageToleranceConfig.js +143 -0
- package/_esm/src/components/common/SlippageToleranceConfig.js.map +1 -0
- package/_esm/src/components/common/TokenSelector/ChainFilter.js +116 -0
- package/_esm/src/components/common/TokenSelector/ChainFilter.js.map +1 -0
- package/_esm/src/components/common/TokenSelector/ChainFilterSidebar.js +150 -0
- package/_esm/src/components/common/TokenSelector/ChainFilterSidebar.js.map +1 -0
- package/_esm/src/components/common/TokenSelector/SuggestedTokens.js +63 -0
- package/_esm/src/components/common/TokenSelector/SuggestedTokens.js.map +1 -0
- package/_esm/src/components/common/TokenSelector/TagPill.js +15 -0
- package/_esm/src/components/common/TokenSelector/TagPill.js.map +1 -0
- package/_esm/src/components/common/TokenSelector/TokenList.js +79 -0
- package/_esm/src/components/common/TokenSelector/TokenList.js.map +1 -0
- package/_esm/src/components/common/TokenSelector/TokenSelector.js +411 -0
- package/_esm/src/components/common/TokenSelector/TokenSelector.js.map +1 -0
- package/_esm/src/components/common/TokenSelector/triggers/TokenTrigger.js +37 -0
- package/_esm/src/components/common/TokenSelector/triggers/TokenTrigger.js.map +1 -0
- package/_esm/src/components/common/TransactionModal/DepositAddressModal.js +83 -0
- package/_esm/src/components/common/TransactionModal/DepositAddressModal.js.map +1 -0
- package/_esm/src/components/common/TransactionModal/DepositAddressModalRenderer.js +245 -0
- package/_esm/src/components/common/TransactionModal/DepositAddressModalRenderer.js.map +1 -0
- package/_esm/src/components/common/TransactionModal/TransactionModal.js +120 -0
- package/_esm/src/components/common/TransactionModal/TransactionModal.js.map +1 -0
- package/_esm/src/components/common/TransactionModal/TransactionModalRenderer.js +135 -0
- package/_esm/src/components/common/TransactionModal/TransactionModalRenderer.js.map +1 -0
- package/_esm/src/components/common/TransactionModal/steps/ApprovalPlusSwapStep.js +77 -0
- package/_esm/src/components/common/TransactionModal/steps/ApprovalPlusSwapStep.js.map +1 -0
- package/_esm/src/components/common/TransactionModal/steps/DepositAddressValidatingStep.js +20 -0
- package/_esm/src/components/common/TransactionModal/steps/DepositAddressValidatingStep.js.map +1 -0
- package/_esm/src/components/common/TransactionModal/steps/ErrorStep.js +80 -0
- package/_esm/src/components/common/TransactionModal/steps/ErrorStep.js.map +1 -0
- package/_esm/src/components/common/TransactionModal/steps/SwapConfirmationStep.js +112 -0
- package/_esm/src/components/common/TransactionModal/steps/SwapConfirmationStep.js.map +1 -0
- package/_esm/src/components/common/TransactionModal/steps/SwapSuccessStep.js +130 -0
- package/_esm/src/components/common/TransactionModal/steps/SwapSuccessStep.js.map +1 -0
- package/_esm/src/components/common/TransactionModal/steps/TransactionsByChain.js +64 -0
- package/_esm/src/components/common/TransactionModal/steps/TransactionsByChain.js.map +1 -0
- package/_esm/src/components/common/TransactionModal/steps/WaitingForDepositStep.js +84 -0
- package/_esm/src/components/common/TransactionModal/steps/WaitingForDepositStep.js.map +1 -0
- package/_esm/src/components/common/UnverifiedTokenModal.js +70 -0
- package/_esm/src/components/common/UnverifiedTokenModal.js.map +1 -0
- package/_esm/src/components/primitives/AccessibleList.js +28 -0
- package/_esm/src/components/primitives/AccessibleList.js.map +1 -0
- package/_esm/src/components/primitives/Anchor.js +53 -0
- package/_esm/src/components/primitives/Anchor.js.map +1 -0
- package/_esm/src/components/primitives/Box.js +8 -0
- package/_esm/src/components/primitives/Box.js.map +1 -0
- package/_esm/src/components/primitives/Button.js +153 -0
- package/_esm/src/components/primitives/Button.js.map +1 -0
- package/_esm/src/components/primitives/ChainIcon.js +32 -0
- package/_esm/src/components/primitives/ChainIcon.js.map +1 -0
- package/_esm/src/components/primitives/ChainTokenIcon.js +50 -0
- package/_esm/src/components/primitives/ChainTokenIcon.js.map +1 -0
- package/_esm/src/components/primitives/Collapsible.js +40 -0
- package/_esm/src/components/primitives/Collapsible.js.map +1 -0
- package/_esm/src/components/primitives/Dialog.js +97 -0
- package/_esm/src/components/primitives/Dialog.js.map +1 -0
- package/_esm/src/components/primitives/Dropdown.js +49 -0
- package/_esm/src/components/primitives/Dropdown.js.map +1 -0
- package/_esm/src/components/primitives/Flex.js +73 -0
- package/_esm/src/components/primitives/Flex.js.map +1 -0
- package/_esm/src/components/primitives/Input.js +66 -0
- package/_esm/src/components/primitives/Input.js.map +1 -0
- package/_esm/src/components/primitives/Pill.js +60 -0
- package/_esm/src/components/primitives/Pill.js.map +1 -0
- package/_esm/src/components/primitives/Skeleton.js +16 -0
- package/_esm/src/components/primitives/Skeleton.js.map +1 -0
- package/_esm/src/components/primitives/Switch.js +49 -0
- package/_esm/src/components/primitives/Switch.js.map +1 -0
- package/_esm/src/components/primitives/Tabs.js +46 -0
- package/_esm/src/components/primitives/Tabs.js.map +1 -0
- package/_esm/src/components/primitives/Text.js +104 -0
- package/_esm/src/components/primitives/Text.js.map +1 -0
- package/_esm/src/components/primitives/Tooltip.js +41 -0
- package/_esm/src/components/primitives/Tooltip.js.map +1 -0
- package/_esm/src/components/primitives/index.js +14 -0
- package/_esm/src/components/primitives/index.js.map +1 -0
- package/_esm/src/components/widgets/FeeBreakdown.js +162 -0
- package/_esm/src/components/widgets/FeeBreakdown.js.map +1 -0
- package/_esm/src/components/widgets/FetchingQuoteLoader.js +19 -0
- package/_esm/src/components/widgets/FetchingQuoteLoader.js.map +1 -0
- package/_esm/src/components/widgets/OnrampWidget/index.js +2 -0
- package/_esm/src/components/widgets/OnrampWidget/index.js.map +1 -0
- package/_esm/src/components/widgets/OnrampWidget/modals/OnrampModal.js +281 -0
- package/_esm/src/components/widgets/OnrampWidget/modals/OnrampModal.js.map +1 -0
- package/_esm/src/components/widgets/OnrampWidget/modals/steps/OnrampConfirmingStep.js +38 -0
- package/_esm/src/components/widgets/OnrampWidget/modals/steps/OnrampConfirmingStep.js.map +1 -0
- package/_esm/src/components/widgets/OnrampWidget/modals/steps/OnrampMoonPayStep.js +176 -0
- package/_esm/src/components/widgets/OnrampWidget/modals/steps/OnrampMoonPayStep.js.map +1 -0
- package/_esm/src/components/widgets/OnrampWidget/modals/steps/OnrampProcessingPassthroughStep.js +40 -0
- package/_esm/src/components/widgets/OnrampWidget/modals/steps/OnrampProcessingPassthroughStep.js.map +1 -0
- package/_esm/src/components/widgets/OnrampWidget/modals/steps/OnrampProcessingStepUI.js +83 -0
- package/_esm/src/components/widgets/OnrampWidget/modals/steps/OnrampProcessingStepUI.js.map +1 -0
- package/_esm/src/components/widgets/OnrampWidget/modals/steps/OnrampSuccessStep.js +35 -0
- package/_esm/src/components/widgets/OnrampWidget/modals/steps/OnrampSuccessStep.js.map +1 -0
- package/_esm/src/components/widgets/OnrampWidget/widget/FiatCurrencyModal.js +170 -0
- package/_esm/src/components/widgets/OnrampWidget/widget/FiatCurrencyModal.js.map +1 -0
- package/_esm/src/components/widgets/OnrampWidget/widget/OnrampWidgetRenderer.js +195 -0
- package/_esm/src/components/widgets/OnrampWidget/widget/OnrampWidgetRenderer.js.map +1 -0
- package/_esm/src/components/widgets/OnrampWidget/widget/index.js +332 -0
- package/_esm/src/components/widgets/OnrampWidget/widget/index.js.map +1 -0
- package/_esm/src/components/widgets/PriceImpactTooltip.js +23 -0
- package/_esm/src/components/widgets/PriceImpactTooltip.js.map +1 -0
- package/_esm/src/components/widgets/SwapButton.js +36 -0
- package/_esm/src/components/widgets/SwapButton.js.map +1 -0
- package/_esm/src/components/widgets/SwapRouteSelector.js +84 -0
- package/_esm/src/components/widgets/SwapRouteSelector.js.map +1 -0
- package/_esm/src/components/widgets/SwapWidget/GasTopUpSection.js +23 -0
- package/_esm/src/components/widgets/SwapWidget/GasTopUpSection.js.map +1 -0
- package/_esm/src/components/widgets/SwapWidget/index.js +955 -0
- package/_esm/src/components/widgets/SwapWidget/index.js.map +1 -0
- package/_esm/src/components/widgets/SwapWidgetRenderer.js +754 -0
- package/_esm/src/components/widgets/SwapWidgetRenderer.js.map +1 -0
- package/_esm/src/components/widgets/TokenSelectorContainer.js +20 -0
- package/_esm/src/components/widgets/TokenSelectorContainer.js.map +1 -0
- package/_esm/src/components/widgets/WidgetContainer.js +26 -0
- package/_esm/src/components/widgets/WidgetContainer.js.map +1 -0
- package/_esm/src/components/widgets/WidgetErrorWell.js +153 -0
- package/_esm/src/components/widgets/WidgetErrorWell.js.map +1 -0
- package/_esm/src/components/widgets/WidgetFooter.js +31 -0
- package/_esm/src/components/widgets/WidgetFooter.js.map +1 -0
- package/_esm/src/constants/address.js +11 -0
- package/_esm/src/constants/address.js.map +1 -0
- package/_esm/src/constants/agwRegistryAbi.js +17 -0
- package/_esm/src/constants/agwRegistryAbi.js.map +1 -0
- package/_esm/src/constants/cache.js +3 -0
- package/_esm/src/constants/cache.js.map +1 -0
- package/_esm/src/constants/chainIdToAlchemyNetworkMap.js +11 -0
- package/_esm/src/constants/chainIdToAlchemyNetworkMap.js.map +1 -0
- package/_esm/src/constants/currencies.js +2 -0
- package/_esm/src/constants/currencies.js.map +1 -0
- package/_esm/src/constants/depositAddresses.js +11 -0
- package/_esm/src/constants/depositAddresses.js.map +1 -0
- package/_esm/src/constants/events.js +60 -0
- package/_esm/src/constants/events.js.map +1 -0
- package/_esm/src/constants/maxGasBuffer.js +9 -0
- package/_esm/src/constants/maxGasBuffer.js.map +1 -0
- package/_esm/src/constants/moonPayCurrencies.js +293 -0
- package/_esm/src/constants/moonPayCurrencies.js.map +1 -0
- package/_esm/src/constants/moonPayFiatCurrencies.js +207 -0
- package/_esm/src/constants/moonPayFiatCurrencies.js.map +1 -0
- package/_esm/src/constants/walletCompatibility.js +20 -0
- package/_esm/src/constants/walletCompatibility.js.map +1 -0
- package/_esm/src/hooks/index.js +25 -0
- package/_esm/src/hooks/index.js.map +1 -0
- package/_esm/src/hooks/useAdaptedWalletBalance.js +26 -0
- package/_esm/src/hooks/useAdaptedWalletBalance.js.map +1 -0
- package/_esm/src/hooks/useAtomicBatchSupport.js +33 -0
- package/_esm/src/hooks/useAtomicBatchSupport.js.map +1 -0
- package/_esm/src/hooks/useBitcoinBalance.js +38 -0
- package/_esm/src/hooks/useBitcoinBalance.js.map +1 -0
- package/_esm/src/hooks/useCexAddresses.js +19 -0
- package/_esm/src/hooks/useCexAddresses.js.map +1 -0
- package/_esm/src/hooks/useCurrencyBalance.js +232 -0
- package/_esm/src/hooks/useCurrencyBalance.js.map +1 -0
- package/_esm/src/hooks/useDebounceState.js +33 -0
- package/_esm/src/hooks/useDebounceState.js.map +1 -0
- package/_esm/src/hooks/useDisconnected.js +12 -0
- package/_esm/src/hooks/useDisconnected.js.map +1 -0
- package/_esm/src/hooks/useDuneBalances.js +98 -0
- package/_esm/src/hooks/useDuneBalances.js.map +1 -0
- package/_esm/src/hooks/useENSResolver.js +35 -0
- package/_esm/src/hooks/useENSResolver.js.map +1 -0
- package/_esm/src/hooks/useEclipseBalance.js +44 -0
- package/_esm/src/hooks/useEclipseBalance.js.map +1 -0
- package/_esm/src/hooks/useEnhancedTokensList.js +85 -0
- package/_esm/src/hooks/useEnhancedTokensList.js.map +1 -0
- package/_esm/src/hooks/useFallbackState.js +10 -0
- package/_esm/src/hooks/useFallbackState.js.map +1 -0
- package/_esm/src/hooks/useGasTopUpRequired.js +57 -0
- package/_esm/src/hooks/useGasTopUpRequired.js.map +1 -0
- package/_esm/src/hooks/useHyperliquidUsdcBalance.js +35 -0
- package/_esm/src/hooks/useHyperliquidUsdcBalance.js.map +1 -0
- package/_esm/src/hooks/useInternalRelayChains.js +19 -0
- package/_esm/src/hooks/useInternalRelayChains.js.map +1 -0
- package/_esm/src/hooks/useIpAddress.js +10 -0
- package/_esm/src/hooks/useIpAddress.js.map +1 -0
- package/_esm/src/hooks/useIsAGW.js +31 -0
- package/_esm/src/hooks/useIsAGW.js.map +1 -0
- package/_esm/src/hooks/useIsPassthrough.js +53 -0
- package/_esm/src/hooks/useIsPassthrough.js.map +1 -0
- package/_esm/src/hooks/useIsWalletCompatible.js +40 -0
- package/_esm/src/hooks/useIsWalletCompatible.js.map +1 -0
- package/_esm/src/hooks/useMoonPayCurrencies.js +21 -0
- package/_esm/src/hooks/useMoonPayCurrencies.js.map +1 -0
- package/_esm/src/hooks/useMoonPayGeolocation.js +23 -0
- package/_esm/src/hooks/useMoonPayGeolocation.js.map +1 -0
- package/_esm/src/hooks/useMoonPayTransaction.js +23 -0
- package/_esm/src/hooks/useMoonPayTransaction.js.map +1 -0
- package/_esm/src/hooks/useMounted.js +9 -0
- package/_esm/src/hooks/useMounted.js.map +1 -0
- package/_esm/src/hooks/usePreviousValueChange.js +12 -0
- package/_esm/src/hooks/usePreviousValueChange.js.map +1 -0
- package/_esm/src/hooks/useRelayClient.js +6 -0
- package/_esm/src/hooks/useRelayClient.js.map +1 -0
- package/_esm/src/hooks/useSuiBalance.js +45 -0
- package/_esm/src/hooks/useSuiBalance.js.map +1 -0
- package/_esm/src/hooks/useSupportedMoonPayCurrencyCode.js +61 -0
- package/_esm/src/hooks/useSupportedMoonPayCurrencyCode.js.map +1 -0
- package/_esm/src/hooks/useWalletAddress.js +20 -0
- package/_esm/src/hooks/useWalletAddress.js.map +1 -0
- package/_esm/src/hooks/widget/useSwapButtonCta.js +77 -0
- package/_esm/src/hooks/widget/useSwapButtonCta.js.map +1 -0
- package/_esm/src/icons/SwitchIcon.js +6 -0
- package/_esm/src/icons/SwitchIcon.js.map +1 -0
- package/_esm/src/icons/index.js +2 -0
- package/_esm/src/icons/index.js.map +1 -0
- package/_esm/src/img/AllChainsLogo.js +7 -0
- package/_esm/src/img/AllChainsLogo.js.map +1 -0
- package/_esm/src/img/MoonPayLogo.js +7 -0
- package/_esm/src/img/MoonPayLogo.js.map +1 -0
- package/_esm/src/img/ReservoirText.js +7 -0
- package/_esm/src/img/ReservoirText.js.map +1 -0
- package/_esm/src/index.js +13 -0
- package/_esm/src/index.js.map +1 -0
- package/_esm/src/providers/RelayClientProvider.js +10 -0
- package/_esm/src/providers/RelayClientProvider.js.map +1 -0
- package/_esm/src/providers/RelayKitProvider.js +120 -0
- package/_esm/src/providers/RelayKitProvider.js.map +1 -0
- package/_esm/src/styles.css +3408 -0
- package/_esm/src/themes/RelayKitTheme.js +86 -0
- package/_esm/src/themes/RelayKitTheme.js.map +1 -0
- package/_esm/src/themes/index.js +2 -0
- package/_esm/src/themes/index.js.map +1 -0
- package/_esm/src/types/BridgeFee.js +2 -0
- package/_esm/src/types/BridgeFee.js.map +1 -0
- package/_esm/src/types/Fiat.js +2 -0
- package/_esm/src/types/Fiat.js.map +1 -0
- package/_esm/src/types/RelayTransaction.js +2 -0
- package/_esm/src/types/RelayTransaction.js.map +1 -0
- package/_esm/src/types/index.js +2 -0
- package/_esm/src/types/index.js.map +1 -0
- package/_esm/src/utils/address.js +68 -0
- package/_esm/src/utils/address.js.map +1 -0
- package/_esm/src/utils/bitcoin.js +8 -0
- package/_esm/src/utils/bitcoin.js.map +1 -0
- package/_esm/src/utils/browser.js +4 -0
- package/_esm/src/utils/browser.js.map +1 -0
- package/_esm/src/utils/ens.js +5 -0
- package/_esm/src/utils/ens.js.map +1 -0
- package/_esm/src/utils/errors.js +36 -0
- package/_esm/src/utils/errors.js.map +1 -0
- package/_esm/src/utils/fetcher.js +15 -0
- package/_esm/src/utils/fetcher.js.map +1 -0
- package/_esm/src/utils/getChainBlockExplorerUrl.js +11 -0
- package/_esm/src/utils/getChainBlockExplorerUrl.js.map +1 -0
- package/_esm/src/utils/getTxBlockExplorerUrl.js +23 -0
- package/_esm/src/utils/getTxBlockExplorerUrl.js.map +1 -0
- package/_esm/src/utils/hashing.js +38 -0
- package/_esm/src/utils/hashing.js.map +1 -0
- package/_esm/src/utils/localStorage.js +93 -0
- package/_esm/src/utils/localStorage.js.map +1 -0
- package/_esm/src/utils/moonPay.js +44 -0
- package/_esm/src/utils/moonPay.js.map +1 -0
- package/_esm/src/utils/nativeMaxAmount.js +172 -0
- package/_esm/src/utils/nativeMaxAmount.js.map +1 -0
- package/_esm/src/utils/numbers.js +191 -0
- package/_esm/src/utils/numbers.js.map +1 -0
- package/_esm/src/utils/qrcode.js +19 -0
- package/_esm/src/utils/qrcode.js.map +1 -0
- package/_esm/src/utils/quote.js +248 -0
- package/_esm/src/utils/quote.js.map +1 -0
- package/_esm/src/utils/relayTransaction.js +80 -0
- package/_esm/src/utils/relayTransaction.js.map +1 -0
- package/_esm/src/utils/slippage.js +14 -0
- package/_esm/src/utils/slippage.js.map +1 -0
- package/_esm/src/utils/solana.js +12 -0
- package/_esm/src/utils/solana.js.map +1 -0
- package/_esm/src/utils/steps.js +102 -0
- package/_esm/src/utils/steps.js.map +1 -0
- package/_esm/src/utils/sui.js +11 -0
- package/_esm/src/utils/sui.js.map +1 -0
- package/_esm/src/utils/theme.js +37 -0
- package/_esm/src/utils/theme.js.map +1 -0
- package/_esm/src/utils/time.js +29 -0
- package/_esm/src/utils/time.js.map +1 -0
- package/_esm/src/utils/titleCase.js +12 -0
- package/_esm/src/utils/titleCase.js.map +1 -0
- package/_esm/src/utils/tokenSelector.js +79 -0
- package/_esm/src/utils/tokenSelector.js.map +1 -0
- package/_esm/src/utils/tokens.js +50 -0
- package/_esm/src/utils/tokens.js.map +1 -0
- package/_esm/src/utils/tron.js +8 -0
- package/_esm/src/utils/tron.js.map +1 -0
- package/_esm/src/utils/truncate.js +23 -0
- package/_esm/src/utils/truncate.js.map +1 -0
- package/_esm/src/version.js +2 -0
- package/_esm/src/version.js.map +1 -0
- package/_esm/tsconfig.build.tsbuildinfo +1 -0
- package/_types/src/components/common/AmountInput.d.ts +10 -0
- package/_types/src/components/common/AmountInput.d.ts.map +1 -0
- package/_types/src/components/common/BalanceDisplay.d.ts +14 -0
- package/_types/src/components/common/BalanceDisplay.d.ts.map +1 -0
- package/_types/src/components/common/CopyToClipBoard.d.ts +7 -0
- package/_types/src/components/common/CopyToClipBoard.d.ts.map +1 -0
- package/_types/src/components/common/CustomAddressModal.d.ts +22 -0
- package/_types/src/components/common/CustomAddressModal.d.ts.map +1 -0
- package/_types/src/components/common/ErrorWell.d.ts +11 -0
- package/_types/src/components/common/ErrorWell.d.ts.map +1 -0
- package/_types/src/components/common/LoadingSpinner.d.ts +6 -0
- package/_types/src/components/common/LoadingSpinner.d.ts.map +1 -0
- package/_types/src/components/common/Modal.d.ts +15 -0
- package/_types/src/components/common/Modal.d.ts.map +1 -0
- package/_types/src/components/common/MultiWalletDropdown.d.ts +17 -0
- package/_types/src/components/common/MultiWalletDropdown.d.ts.map +1 -0
- package/_types/src/components/common/RefundReason.d.ts +8 -0
- package/_types/src/components/common/RefundReason.d.ts.map +1 -0
- package/_types/src/components/common/SlippageToleranceConfig.d.ts +8 -0
- package/_types/src/components/common/SlippageToleranceConfig.d.ts.map +1 -0
- package/_types/src/components/common/TokenSelector/ChainFilter.d.ts +16 -0
- package/_types/src/components/common/TokenSelector/ChainFilter.d.ts.map +1 -0
- package/_types/src/components/common/TokenSelector/ChainFilterSidebar.d.ts +20 -0
- package/_types/src/components/common/TokenSelector/ChainFilterSidebar.d.ts.map +1 -0
- package/_types/src/components/common/TokenSelector/SuggestedTokens.d.ts +10 -0
- package/_types/src/components/common/TokenSelector/SuggestedTokens.d.ts.map +1 -0
- package/_types/src/components/common/TokenSelector/TagPill.d.ts +7 -0
- package/_types/src/components/common/TokenSelector/TagPill.d.ts.map +1 -0
- package/_types/src/components/common/TokenSelector/TokenList.d.ts +13 -0
- package/_types/src/components/common/TokenSelector/TokenList.d.ts.map +1 -0
- package/_types/src/components/common/TokenSelector/TokenSelector.d.ts +22 -0
- package/_types/src/components/common/TokenSelector/TokenSelector.d.ts.map +1 -0
- package/_types/src/components/common/TokenSelector/triggers/TokenTrigger.d.ts +11 -0
- package/_types/src/components/common/TokenSelector/triggers/TokenTrigger.d.ts.map +1 -0
- package/_types/src/components/common/TransactionModal/DepositAddressModal.d.ts +26 -0
- package/_types/src/components/common/TransactionModal/DepositAddressModal.d.ts.map +1 -0
- package/_types/src/components/common/TransactionModal/DepositAddressModalRenderer.d.ts +57 -0
- package/_types/src/components/common/TransactionModal/DepositAddressModalRenderer.d.ts.map +1 -0
- package/_types/src/components/common/TransactionModal/TransactionModal.d.ts +33 -0
- package/_types/src/components/common/TransactionModal/TransactionModal.d.ts.map +1 -0
- package/_types/src/components/common/TransactionModal/TransactionModalRenderer.d.ts +63 -0
- package/_types/src/components/common/TransactionModal/TransactionModalRenderer.d.ts.map +1 -0
- package/_types/src/components/common/TransactionModal/steps/ApprovalPlusSwapStep.d.ts +15 -0
- package/_types/src/components/common/TransactionModal/steps/ApprovalPlusSwapStep.d.ts.map +1 -0
- package/_types/src/components/common/TransactionModal/steps/DepositAddressValidatingStep.d.ts +9 -0
- package/_types/src/components/common/TransactionModal/steps/DepositAddressValidatingStep.d.ts.map +1 -0
- package/_types/src/components/common/TransactionModal/steps/ErrorStep.d.ts +17 -0
- package/_types/src/components/common/TransactionModal/steps/ErrorStep.d.ts.map +1 -0
- package/_types/src/components/common/TransactionModal/steps/SwapConfirmationStep.d.ts +30 -0
- package/_types/src/components/common/TransactionModal/steps/SwapConfirmationStep.d.ts.map +1 -0
- package/_types/src/components/common/TransactionModal/steps/SwapSuccessStep.d.ts +24 -0
- package/_types/src/components/common/TransactionModal/steps/SwapSuccessStep.d.ts.map +1 -0
- package/_types/src/components/common/TransactionModal/steps/TransactionsByChain.d.ts +14 -0
- package/_types/src/components/common/TransactionModal/steps/TransactionsByChain.d.ts.map +1 -0
- package/_types/src/components/common/TransactionModal/steps/WaitingForDepositStep.d.ts +13 -0
- package/_types/src/components/common/TransactionModal/steps/WaitingForDepositStep.d.ts.map +1 -0
- package/_types/src/components/common/UnverifiedTokenModal.d.ts +16 -0
- package/_types/src/components/common/UnverifiedTokenModal.d.ts.map +1 -0
- package/_types/src/components/primitives/AccessibleList.d.ts +17 -0
- package/_types/src/components/primitives/AccessibleList.d.ts.map +1 -0
- package/_types/src/components/primitives/Anchor.d.ts +44 -0
- package/_types/src/components/primitives/Anchor.d.ts.map +1 -0
- package/_types/src/components/primitives/Box.d.ts +10 -0
- package/_types/src/components/primitives/Box.d.ts.map +1 -0
- package/_types/src/components/primitives/Button.d.ts +11 -0
- package/_types/src/components/primitives/Button.d.ts.map +1 -0
- package/_types/src/components/primitives/ChainIcon.d.ts +12 -0
- package/_types/src/components/primitives/ChainIcon.d.ts.map +1 -0
- package/_types/src/components/primitives/ChainTokenIcon.d.ts +13 -0
- package/_types/src/components/primitives/ChainTokenIcon.d.ts.map +1 -0
- package/_types/src/components/primitives/Collapsible.d.ts +20 -0
- package/_types/src/components/primitives/Collapsible.d.ts.map +1 -0
- package/_types/src/components/primitives/Dialog.d.ts +23 -0
- package/_types/src/components/primitives/Dialog.d.ts.map +1 -0
- package/_types/src/components/primitives/Dropdown.d.ts +16 -0
- package/_types/src/components/primitives/Dropdown.d.ts.map +1 -0
- package/_types/src/components/primitives/Flex.d.ts +71 -0
- package/_types/src/components/primitives/Flex.d.ts.map +1 -0
- package/_types/src/components/primitives/Input.d.ts +18 -0
- package/_types/src/components/primitives/Input.d.ts.map +1 -0
- package/_types/src/components/primitives/Pill.d.ts +50 -0
- package/_types/src/components/primitives/Pill.d.ts.map +1 -0
- package/_types/src/components/primitives/Skeleton.d.ts +8 -0
- package/_types/src/components/primitives/Skeleton.d.ts.map +1 -0
- package/_types/src/components/primitives/Switch.d.ts +10 -0
- package/_types/src/components/primitives/Switch.d.ts.map +1 -0
- package/_types/src/components/primitives/Tabs.d.ts +17 -0
- package/_types/src/components/primitives/Tabs.d.ts.map +1 -0
- package/_types/src/components/primitives/Text.d.ts +99 -0
- package/_types/src/components/primitives/Text.d.ts.map +1 -0
- package/_types/src/components/primitives/Tooltip.d.ts +3 -0
- package/_types/src/components/primitives/Tooltip.d.ts.map +1 -0
- package/_types/src/components/primitives/index.d.ts +14 -0
- package/_types/src/components/primitives/index.d.ts.map +1 -0
- package/_types/src/components/widgets/FeeBreakdown.d.ts +14 -0
- package/_types/src/components/widgets/FeeBreakdown.d.ts.map +1 -0
- package/_types/src/components/widgets/FetchingQuoteLoader.d.ts +9 -0
- package/_types/src/components/widgets/FetchingQuoteLoader.d.ts.map +1 -0
- package/_types/src/components/widgets/OnrampWidget/index.d.ts +2 -0
- package/_types/src/components/widgets/OnrampWidget/index.d.ts.map +1 -0
- package/_types/src/components/widgets/OnrampWidget/modals/OnrampModal.d.ts +41 -0
- package/_types/src/components/widgets/OnrampWidget/modals/OnrampModal.d.ts.map +1 -0
- package/_types/src/components/widgets/OnrampWidget/modals/steps/OnrampConfirmingStep.d.ts +22 -0
- package/_types/src/components/widgets/OnrampWidget/modals/steps/OnrampConfirmingStep.d.ts.map +1 -0
- package/_types/src/components/widgets/OnrampWidget/modals/steps/OnrampMoonPayStep.d.ts +33 -0
- package/_types/src/components/widgets/OnrampWidget/modals/steps/OnrampMoonPayStep.d.ts.map +1 -0
- package/_types/src/components/widgets/OnrampWidget/modals/steps/OnrampProcessingPassthroughStep.d.ts +11 -0
- package/_types/src/components/widgets/OnrampWidget/modals/steps/OnrampProcessingPassthroughStep.d.ts.map +1 -0
- package/_types/src/components/widgets/OnrampWidget/modals/steps/OnrampProcessingStepUI.d.ts +19 -0
- package/_types/src/components/widgets/OnrampWidget/modals/steps/OnrampProcessingStepUI.d.ts.map +1 -0
- package/_types/src/components/widgets/OnrampWidget/modals/steps/OnrampSuccessStep.d.ts +15 -0
- package/_types/src/components/widgets/OnrampWidget/modals/steps/OnrampSuccessStep.d.ts.map +1 -0
- package/_types/src/components/widgets/OnrampWidget/widget/FiatCurrencyModal.d.ts +10 -0
- package/_types/src/components/widgets/OnrampWidget/widget/FiatCurrencyModal.d.ts.map +1 -0
- package/_types/src/components/widgets/OnrampWidget/widget/OnrampWidgetRenderer.d.ts +45 -0
- package/_types/src/components/widgets/OnrampWidget/widget/OnrampWidgetRenderer.d.ts.map +1 -0
- package/_types/src/components/widgets/OnrampWidget/widget/index.d.ts +38 -0
- package/_types/src/components/widgets/OnrampWidget/widget/index.d.ts.map +1 -0
- package/_types/src/components/widgets/PriceImpactTooltip.d.ts +10 -0
- package/_types/src/components/widgets/PriceImpactTooltip.d.ts.map +1 -0
- package/_types/src/components/widgets/SwapButton.d.ts +14 -0
- package/_types/src/components/widgets/SwapButton.d.ts.map +1 -0
- package/_types/src/components/widgets/SwapRouteSelector.d.ts +14 -0
- package/_types/src/components/widgets/SwapRouteSelector.d.ts.map +1 -0
- package/_types/src/components/widgets/SwapWidget/GasTopUpSection.d.ts +13 -0
- package/_types/src/components/widgets/SwapWidget/GasTopUpSection.d.ts.map +1 -0
- package/_types/src/components/widgets/SwapWidget/index.d.ts +50 -0
- package/_types/src/components/widgets/SwapWidget/index.d.ts.map +1 -0
- package/_types/src/components/widgets/SwapWidgetRenderer.d.ts +133 -0
- package/_types/src/components/widgets/SwapWidgetRenderer.d.ts.map +1 -0
- package/_types/src/components/widgets/TokenSelectorContainer.d.ts +8 -0
- package/_types/src/components/widgets/TokenSelectorContainer.d.ts.map +1 -0
- package/_types/src/components/widgets/WidgetContainer.d.ts +29 -0
- package/_types/src/components/widgets/WidgetContainer.d.ts.map +1 -0
- package/_types/src/components/widgets/WidgetErrorWell.d.ts +26 -0
- package/_types/src/components/widgets/WidgetErrorWell.d.ts.map +1 -0
- package/_types/src/components/widgets/WidgetFooter.d.ts +3 -0
- package/_types/src/components/widgets/WidgetFooter.d.ts.map +1 -0
- package/_types/src/constants/address.d.ts +5 -0
- package/_types/src/constants/address.d.ts.map +1 -0
- package/_types/src/constants/agwRegistryAbi.d.ts +16 -0
- package/_types/src/constants/agwRegistryAbi.d.ts.map +1 -0
- package/_types/src/constants/cache.d.ts +3 -0
- package/_types/src/constants/cache.d.ts.map +1 -0
- package/_types/src/constants/chainIdToAlchemyNetworkMap.d.ts +2 -0
- package/_types/src/constants/chainIdToAlchemyNetworkMap.d.ts.map +1 -0
- package/_types/src/constants/currencies.d.ts +8 -0
- package/_types/src/constants/currencies.d.ts.map +1 -0
- package/_types/src/constants/depositAddresses.d.ts +2 -0
- package/_types/src/constants/depositAddresses.d.ts.map +1 -0
- package/_types/src/constants/events.d.ts +59 -0
- package/_types/src/constants/events.d.ts.map +1 -0
- package/_types/src/constants/maxGasBuffer.d.ts +9 -0
- package/_types/src/constants/maxGasBuffer.d.ts.map +1 -0
- package/_types/src/constants/moonPayCurrencies.d.ts +11 -0
- package/_types/src/constants/moonPayCurrencies.d.ts.map +1 -0
- package/_types/src/constants/moonPayFiatCurrencies.d.ts +8 -0
- package/_types/src/constants/moonPayFiatCurrencies.d.ts.map +1 -0
- package/_types/src/constants/walletCompatibility.d.ts +4 -0
- package/_types/src/constants/walletCompatibility.d.ts.map +1 -0
- package/_types/src/hooks/index.d.ts +25 -0
- package/_types/src/hooks/index.d.ts.map +1 -0
- package/_types/src/hooks/useAdaptedWalletBalance.d.ts +175 -0
- package/_types/src/hooks/useAdaptedWalletBalance.d.ts.map +1 -0
- package/_types/src/hooks/useAtomicBatchSupport.d.ts +9 -0
- package/_types/src/hooks/useAtomicBatchSupport.d.ts.map +1 -0
- package/_types/src/hooks/useBitcoinBalance.d.ts +13 -0
- package/_types/src/hooks/useBitcoinBalance.d.ts.map +1 -0
- package/_types/src/hooks/useCexAddresses.d.ts +6 -0
- package/_types/src/hooks/useCexAddresses.d.ts.map +1 -0
- package/_types/src/hooks/useCurrencyBalance.d.ts +23 -0
- package/_types/src/hooks/useCurrencyBalance.d.ts.map +1 -0
- package/_types/src/hooks/useDebounceState.d.ts +11 -0
- package/_types/src/hooks/useDebounceState.d.ts.map +1 -0
- package/_types/src/hooks/useDisconnected.d.ts +4 -0
- package/_types/src/hooks/useDisconnected.d.ts.map +1 -0
- package/_types/src/hooks/useDuneBalances.d.ts +25 -0
- package/_types/src/hooks/useDuneBalances.d.ts.map +1 -0
- package/_types/src/hooks/useENSResolver.d.ts +14 -0
- package/_types/src/hooks/useENSResolver.d.ts.map +1 -0
- package/_types/src/hooks/useEclipseBalance.d.ts +12 -0
- package/_types/src/hooks/useEclipseBalance.d.ts.map +1 -0
- package/_types/src/hooks/useEnhancedTokensList.d.ts +23 -0
- package/_types/src/hooks/useEnhancedTokensList.d.ts.map +1 -0
- package/_types/src/hooks/useFallbackState.d.ts +5 -0
- package/_types/src/hooks/useFallbackState.d.ts.map +1 -0
- package/_types/src/hooks/useGasTopUpRequired.d.ts +9 -0
- package/_types/src/hooks/useGasTopUpRequired.d.ts.map +1 -0
- package/_types/src/hooks/useHyperliquidUsdcBalance.d.ts +23 -0
- package/_types/src/hooks/useHyperliquidUsdcBalance.d.ts.map +1 -0
- package/_types/src/hooks/useInternalRelayChains.d.ts +131 -0
- package/_types/src/hooks/useInternalRelayChains.d.ts.map +1 -0
- package/_types/src/hooks/useIpAddress.d.ts +9 -0
- package/_types/src/hooks/useIpAddress.d.ts.map +1 -0
- package/_types/src/hooks/useIsAGW.d.ts +2 -0
- package/_types/src/hooks/useIsAGW.d.ts.map +1 -0
- package/_types/src/hooks/useIsPassthrough.d.ts +17 -0
- package/_types/src/hooks/useIsPassthrough.d.ts.map +1 -0
- package/_types/src/hooks/useIsWalletCompatible.d.ts +4 -0
- package/_types/src/hooks/useIsWalletCompatible.d.ts.map +1 -0
- package/_types/src/hooks/useMoonPayCurrencies.d.ts +51 -0
- package/_types/src/hooks/useMoonPayCurrencies.d.ts.map +1 -0
- package/_types/src/hooks/useMoonPayGeolocation.d.ts +25 -0
- package/_types/src/hooks/useMoonPayGeolocation.d.ts.map +1 -0
- package/_types/src/hooks/useMoonPayTransaction.d.ts +22 -0
- package/_types/src/hooks/useMoonPayTransaction.d.ts.map +1 -0
- package/_types/src/hooks/useMounted.d.ts +3 -0
- package/_types/src/hooks/useMounted.d.ts.map +1 -0
- package/_types/src/hooks/usePreviousValueChange.d.ts +3 -0
- package/_types/src/hooks/usePreviousValueChange.d.ts.map +1 -0
- package/_types/src/hooks/useRelayClient.d.ts +2 -0
- package/_types/src/hooks/useRelayClient.d.ts.map +1 -0
- package/_types/src/hooks/useSuiBalance.d.ts +14 -0
- package/_types/src/hooks/useSuiBalance.d.ts.map +1 -0
- package/_types/src/hooks/useSupportedMoonPayCurrencyCode.d.ts +11 -0
- package/_types/src/hooks/useSupportedMoonPayCurrencyCode.d.ts.map +1 -0
- package/_types/src/hooks/useWalletAddress.d.ts +5 -0
- package/_types/src/hooks/useWalletAddress.d.ts.map +1 -0
- package/_types/src/hooks/widget/useSwapButtonCta.d.ts +28 -0
- package/_types/src/hooks/widget/useSwapButtonCta.d.ts.map +1 -0
- package/_types/src/icons/SwitchIcon.d.ts +9 -0
- package/_types/src/icons/SwitchIcon.d.ts.map +1 -0
- package/_types/src/icons/index.d.ts +2 -0
- package/_types/src/icons/index.d.ts.map +1 -0
- package/_types/src/img/AllChainsLogo.d.ts +4 -0
- package/_types/src/img/AllChainsLogo.d.ts.map +1 -0
- package/_types/src/img/MoonPayLogo.d.ts +4 -0
- package/_types/src/img/MoonPayLogo.d.ts.map +1 -0
- package/_types/src/img/ReservoirText.d.ts +4 -0
- package/_types/src/img/ReservoirText.d.ts.map +1 -0
- package/_types/src/index.d.ts +11 -0
- package/_types/src/index.d.ts.map +1 -0
- package/_types/src/providers/RelayClientProvider.d.ts +9 -0
- package/_types/src/providers/RelayClientProvider.d.ts.map +1 -0
- package/_types/src/providers/RelayKitProvider.d.ts +58 -0
- package/_types/src/providers/RelayKitProvider.d.ts.map +1 -0
- package/_types/src/themes/RelayKitTheme.d.ts +78 -0
- package/_types/src/themes/RelayKitTheme.d.ts.map +1 -0
- package/_types/src/themes/index.d.ts +3 -0
- package/_types/src/themes/index.d.ts.map +1 -0
- package/_types/src/types/BridgeFee.d.ts +15 -0
- package/_types/src/types/BridgeFee.d.ts.map +1 -0
- package/_types/src/types/Fiat.d.ts +7 -0
- package/_types/src/types/Fiat.d.ts.map +1 -0
- package/_types/src/types/RelayTransaction.d.ts +4 -0
- package/_types/src/types/RelayTransaction.d.ts.map +1 -0
- package/_types/src/types/index.d.ts +21 -0
- package/_types/src/types/index.d.ts.map +1 -0
- package/_types/src/utils/address.d.ts +8 -0
- package/_types/src/utils/address.d.ts.map +1 -0
- package/_types/src/utils/bitcoin.d.ts +5 -0
- package/_types/src/utils/bitcoin.d.ts.map +1 -0
- package/_types/src/utils/browser.d.ts +2 -0
- package/_types/src/utils/browser.d.ts.map +1 -0
- package/_types/src/utils/ens.d.ts +2 -0
- package/_types/src/utils/ens.d.ts.map +1 -0
- package/_types/src/utils/errors.d.ts +3 -0
- package/_types/src/utils/errors.d.ts.map +1 -0
- package/_types/src/utils/fetcher.d.ts +4 -0
- package/_types/src/utils/fetcher.d.ts.map +1 -0
- package/_types/src/utils/getChainBlockExplorerUrl.d.ts +4 -0
- package/_types/src/utils/getChainBlockExplorerUrl.d.ts.map +1 -0
- package/_types/src/utils/getTxBlockExplorerUrl.d.ts +3 -0
- package/_types/src/utils/getTxBlockExplorerUrl.d.ts.map +1 -0
- package/_types/src/utils/hashing.d.ts +2 -0
- package/_types/src/utils/hashing.d.ts.map +1 -0
- package/_types/src/utils/localStorage.d.ts +30 -0
- package/_types/src/utils/localStorage.d.ts.map +1 -0
- package/_types/src/utils/moonPay.d.ts +11 -0
- package/_types/src/utils/moonPay.d.ts.map +1 -0
- package/_types/src/utils/nativeMaxAmount.d.ts +34 -0
- package/_types/src/utils/nativeMaxAmount.d.ts.map +1 -0
- package/_types/src/utils/numbers.d.ts +21 -0
- package/_types/src/utils/numbers.d.ts.map +1 -0
- package/_types/src/utils/qrcode.d.ts +3 -0
- package/_types/src/utils/qrcode.d.ts.map +1 -0
- package/_types/src/utils/quote.d.ts +132 -0
- package/_types/src/utils/quote.d.ts.map +1 -0
- package/_types/src/utils/relayTransaction.d.ts +21 -0
- package/_types/src/utils/relayTransaction.d.ts.map +1 -0
- package/_types/src/utils/slippage.d.ts +9 -0
- package/_types/src/utils/slippage.d.ts.map +1 -0
- package/_types/src/utils/solana.d.ts +10 -0
- package/_types/src/utils/solana.d.ts.map +1 -0
- package/_types/src/utils/steps.d.ts +43 -0
- package/_types/src/utils/steps.d.ts.map +1 -0
- package/_types/src/utils/sui.d.ts +8 -0
- package/_types/src/utils/sui.d.ts.map +1 -0
- package/_types/src/utils/theme.d.ts +5 -0
- package/_types/src/utils/theme.d.ts.map +1 -0
- package/_types/src/utils/time.d.ts +4 -0
- package/_types/src/utils/time.d.ts.map +1 -0
- package/_types/src/utils/titleCase.d.ts +8 -0
- package/_types/src/utils/titleCase.d.ts.map +1 -0
- package/_types/src/utils/tokenSelector.d.ts +23 -0
- package/_types/src/utils/tokenSelector.d.ts.map +1 -0
- package/_types/src/utils/tokens.d.ts +21 -0
- package/_types/src/utils/tokens.d.ts.map +1 -0
- package/_types/src/utils/tron.d.ts +6 -0
- package/_types/src/utils/tron.d.ts.map +1 -0
- package/_types/src/utils/truncate.d.ts +13 -0
- package/_types/src/utils/truncate.d.ts.map +1 -0
- package/_types/src/version.d.ts +2 -0
- package/_types/src/version.d.ts.map +1 -0
- package/_types/tsconfig.build.tsbuildinfo +1 -0
- package/dist/panda.buildinfo.json +575 -0
- package/dist/styles.css +3408 -0
- package/package.json +109 -0
- package/readme.md +36 -0
|
@@ -0,0 +1,754 @@
|
|
|
1
|
+
import { Fragment as _Fragment, jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useCallback, useContext, useEffect, useMemo, useState } from 'react';
|
|
3
|
+
import { useCurrencyBalance, useENSResolver, useRelayClient, useDebounceState, useWalletAddress, useDisconnected, usePreviousValueChange, useIsWalletCompatible, useFallbackState, useGasTopUpRequired } from '../../hooks/index.js';
|
|
4
|
+
import { formatUnits, parseUnits } from 'viem';
|
|
5
|
+
import { useAccount, useWalletClient } from 'wagmi';
|
|
6
|
+
import { useCapabilities } from 'wagmi/experimental';
|
|
7
|
+
import { useQueryClient } from '@tanstack/react-query';
|
|
8
|
+
import { calculatePriceTimeEstimate, calculateRelayerFeeProportionUsd, calculateUsdValue, extractQuoteId, getCurrentStep, getSwapEventData, isHighRelayerServiceFeeUsd, parseFees } from '../../utils/quote.js';
|
|
9
|
+
import { useQuote, useTokenPrice } from '@relayprotocol/relay-kit-hooks';
|
|
10
|
+
import { EventNames } from '../../constants/events.js';
|
|
11
|
+
import { ProviderOptionsContext } from '../../providers/RelayKitProvider.js';
|
|
12
|
+
import { addressWithFallback, isValidAddress, findSupportedWallet } from '../../utils/address.js';
|
|
13
|
+
import { adaptViemWallet, getDeadAddress } from '@relayprotocol/relay-sdk';
|
|
14
|
+
import { errorToJSON } from '../../utils/errors.js';
|
|
15
|
+
import { useSwapButtonCta } from '../../hooks/widget/useSwapButtonCta.js';
|
|
16
|
+
import { sha256 } from '../../utils/hashing.js';
|
|
17
|
+
import { get15MinuteInterval } from '../../utils/time.js';
|
|
18
|
+
// shared query options for useTokenPrice
|
|
19
|
+
const tokenPriceQueryOptions = {
|
|
20
|
+
staleTime: 60 * 1000, // 1 minute
|
|
21
|
+
refetchInterval: 30 * 1000, // 30 seconds
|
|
22
|
+
refetchOnWindowFocus: false
|
|
23
|
+
};
|
|
24
|
+
const SwapWidgetRenderer = ({ transactionModalOpen, setTransactionModalOpen, depositAddressModalOpen, fromToken: _fromToken, setFromToken: _setFromToken, toToken: _toToken, setToToken: _setToToken, defaultToAddress, defaultAmount, defaultTradeType, slippageTolerance, context, wallet, multiWalletSupportEnabled = false, linkedWallets, supportedWalletVMs, children, onAnalyticEvent, onSwapError }) => {
|
|
25
|
+
const [fromToken, setFromToken] = useFallbackState(_setFromToken ? _fromToken : undefined, _setFromToken
|
|
26
|
+
? [
|
|
27
|
+
_fromToken,
|
|
28
|
+
_setFromToken
|
|
29
|
+
]
|
|
30
|
+
: undefined);
|
|
31
|
+
const [toToken, setToToken] = useFallbackState(_setToToken ? _toToken : undefined, _setToToken
|
|
32
|
+
? [_toToken, _setToToken]
|
|
33
|
+
: undefined);
|
|
34
|
+
const providerOptionsContext = useContext(ProviderOptionsContext);
|
|
35
|
+
const connectorKeyOverrides = providerOptionsContext.vmConnectorKeyOverrides;
|
|
36
|
+
const relayClient = useRelayClient();
|
|
37
|
+
const { connector } = useAccount();
|
|
38
|
+
const walletClient = useWalletClient();
|
|
39
|
+
const [customToAddress, setCustomToAddress] = useState(defaultToAddress);
|
|
40
|
+
const [useExternalLiquidity, setUseExternalLiquidity] = useState(false);
|
|
41
|
+
const address = useWalletAddress(wallet, linkedWallets);
|
|
42
|
+
const [tradeType, setTradeType] = useState(defaultTradeType ?? 'EXACT_INPUT');
|
|
43
|
+
const queryClient = useQueryClient();
|
|
44
|
+
const [steps, setSteps] = useState(null);
|
|
45
|
+
const [quoteInProgress, setQuoteInProgress] = useState(null);
|
|
46
|
+
const [waitingForSteps, setWaitingForSteps] = useState(false);
|
|
47
|
+
const [details, setDetails] = useState(null);
|
|
48
|
+
const [gasTopUpEnabled, setGasTopUpEnabled] = useState(false);
|
|
49
|
+
const [abortController, setAbortController] = useState(null);
|
|
50
|
+
const { value: amountInputValue, debouncedValue: debouncedInputAmountValue, setValue: setAmountInputValue, debouncedControls: debouncedAmountInputControls } = useDebounceState(!defaultTradeType || defaultTradeType === 'EXACT_INPUT'
|
|
51
|
+
? (defaultAmount ?? '')
|
|
52
|
+
: '', 500);
|
|
53
|
+
const { value: amountOutputValue, debouncedValue: debouncedOutputAmountValue, setValue: setAmountOutputValue, debouncedControls: debouncedAmountOutputControls } = useDebounceState(defaultTradeType === 'EXPECTED_OUTPUT' ? (defaultAmount ?? '') : '', 500);
|
|
54
|
+
const [swapError, setSwapError] = useState(null);
|
|
55
|
+
const tokenPairIsCanonical = fromToken?.chainId !== undefined &&
|
|
56
|
+
toToken?.chainId !== undefined &&
|
|
57
|
+
fromToken.symbol === toToken.symbol;
|
|
58
|
+
const toChain = relayClient?.chains.find((chain) => chain.id === toToken?.chainId);
|
|
59
|
+
const fromChain = relayClient?.chains?.find((chain) => chain.id === fromToken?.chainId);
|
|
60
|
+
const fromChainWalletVMSupported = !fromChain?.vmType ||
|
|
61
|
+
supportedWalletVMs.includes(fromChain?.vmType) ||
|
|
62
|
+
fromChain?.id === 1337;
|
|
63
|
+
const toChainWalletVMSupported = !toChain?.vmType || supportedWalletVMs.includes(toChain?.vmType);
|
|
64
|
+
const defaultRecipient = useMemo(() => {
|
|
65
|
+
const _linkedWallet = linkedWallets?.find((linkedWallet) => address ===
|
|
66
|
+
(linkedWallet.vmType === 'evm'
|
|
67
|
+
? linkedWallet.address.toLowerCase()
|
|
68
|
+
: linkedWallet.address));
|
|
69
|
+
const _isValidToAddress = isValidAddress(toChain?.vmType, customToAddress ?? '', toChain?.id, !customToAddress && _linkedWallet?.address === address
|
|
70
|
+
? _linkedWallet?.connector
|
|
71
|
+
: undefined, connectorKeyOverrides);
|
|
72
|
+
if (multiWalletSupportEnabled &&
|
|
73
|
+
toChain &&
|
|
74
|
+
linkedWallets &&
|
|
75
|
+
!_isValidToAddress) {
|
|
76
|
+
const supportedAddress = findSupportedWallet(toChain, customToAddress, linkedWallets, connectorKeyOverrides);
|
|
77
|
+
return supportedAddress;
|
|
78
|
+
}
|
|
79
|
+
}, [
|
|
80
|
+
multiWalletSupportEnabled,
|
|
81
|
+
toChain,
|
|
82
|
+
customToAddress,
|
|
83
|
+
address,
|
|
84
|
+
linkedWallets,
|
|
85
|
+
setCustomToAddress
|
|
86
|
+
]);
|
|
87
|
+
const recipient = customToAddress ?? defaultRecipient ?? address;
|
|
88
|
+
const { value: fromBalance, queryKey: fromBalanceQueryKey, isLoading: isLoadingFromBalance, isError: fromBalanceErrorFetching, isDuneBalance: fromBalanceIsDune, hasPendingBalance: fromBalancePending } = useCurrencyBalance({
|
|
89
|
+
chain: fromChain,
|
|
90
|
+
address: address,
|
|
91
|
+
currency: fromToken?.address ? fromToken.address : undefined,
|
|
92
|
+
enabled: fromToken !== undefined,
|
|
93
|
+
refreshInterval: undefined,
|
|
94
|
+
wallet
|
|
95
|
+
});
|
|
96
|
+
const { value: toBalance, queryKey: toBalanceQueryKey, isLoading: isLoadingToBalance, isDuneBalance: toBalanceIsDune, hasPendingBalance: toBalancePending } = useCurrencyBalance({
|
|
97
|
+
chain: toChain,
|
|
98
|
+
address: recipient,
|
|
99
|
+
currency: toToken?.address ? toToken.address : undefined,
|
|
100
|
+
enabled: toToken !== undefined,
|
|
101
|
+
refreshInterval: undefined,
|
|
102
|
+
wallet
|
|
103
|
+
});
|
|
104
|
+
const invalidateBalanceQueries = useCallback(() => {
|
|
105
|
+
const invalidatePeriodically = (invalidateFn) => {
|
|
106
|
+
let maxRefreshes = 4;
|
|
107
|
+
let refreshCount = 0;
|
|
108
|
+
const timer = setInterval(() => {
|
|
109
|
+
if (maxRefreshes === refreshCount) {
|
|
110
|
+
clearInterval(timer);
|
|
111
|
+
return;
|
|
112
|
+
}
|
|
113
|
+
refreshCount++;
|
|
114
|
+
invalidateFn();
|
|
115
|
+
}, 3000);
|
|
116
|
+
};
|
|
117
|
+
queryClient.invalidateQueries({ queryKey: ['useDuneBalances'] });
|
|
118
|
+
// Dune balances are sometimes stale, because of this we need to aggressively fetch them
|
|
119
|
+
// for a predetermined period to make sure we get back a fresh response
|
|
120
|
+
if (fromBalanceIsDune) {
|
|
121
|
+
invalidatePeriodically(() => {
|
|
122
|
+
queryClient.invalidateQueries({ queryKey: fromBalanceQueryKey });
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
else {
|
|
126
|
+
queryClient.invalidateQueries({ queryKey: fromBalanceQueryKey });
|
|
127
|
+
}
|
|
128
|
+
if (toBalanceIsDune) {
|
|
129
|
+
invalidatePeriodically(() => {
|
|
130
|
+
queryClient.invalidateQueries({ queryKey: toBalanceQueryKey });
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
else {
|
|
134
|
+
queryClient.invalidateQueries({ queryKey: toBalanceQueryKey });
|
|
135
|
+
}
|
|
136
|
+
}, [
|
|
137
|
+
queryClient,
|
|
138
|
+
fromBalanceQueryKey,
|
|
139
|
+
toBalanceQueryKey,
|
|
140
|
+
toBalanceIsDune,
|
|
141
|
+
fromBalanceIsDune,
|
|
142
|
+
address
|
|
143
|
+
]);
|
|
144
|
+
const { data: capabilities } = useCapabilities({
|
|
145
|
+
query: {
|
|
146
|
+
enabled: connector &&
|
|
147
|
+
(connector.id === 'coinbaseWalletSDK' || connector.id === 'coinbase')
|
|
148
|
+
}
|
|
149
|
+
});
|
|
150
|
+
const hasAuxiliaryFundsSupport = Boolean(fromToken?.chainId
|
|
151
|
+
? capabilities?.[fromToken?.chainId]?.auxiliaryFunds?.supported
|
|
152
|
+
: false);
|
|
153
|
+
const isSvmSwap = fromChain?.vmType === 'svm' || toChain?.vmType === 'svm';
|
|
154
|
+
const isBvmSwap = fromChain?.vmType === 'bvm' || toChain?.vmType === 'bvm';
|
|
155
|
+
const linkedWallet = linkedWallets?.find((linkedWallet) => address ===
|
|
156
|
+
(linkedWallet.vmType === 'evm'
|
|
157
|
+
? linkedWallet.address.toLowerCase()
|
|
158
|
+
: linkedWallet.address) || linkedWallet.address === address);
|
|
159
|
+
const isRecipientLinked = (recipient
|
|
160
|
+
? linkedWallets?.find((wallet) => wallet.address === recipient)
|
|
161
|
+
: undefined) !== undefined;
|
|
162
|
+
const isValidFromAddress = isValidAddress(fromChain?.vmType, address ?? '', fromChain?.id, linkedWallet?.connector, connectorKeyOverrides);
|
|
163
|
+
const fromAddressWithFallback = addressWithFallback(fromChain?.vmType, address, fromChain?.id, linkedWallet?.connector, connectorKeyOverrides);
|
|
164
|
+
const isValidToAddress = isValidAddress(toChain?.vmType, recipient ?? '', toChain?.id);
|
|
165
|
+
const toAddressWithFallback = addressWithFallback(toChain?.vmType, recipient, toChain?.id);
|
|
166
|
+
const externalLiquiditySupport = useQuote(relayClient ? relayClient : undefined, wallet, fromToken && toToken
|
|
167
|
+
? {
|
|
168
|
+
user: getDeadAddress(fromChain?.vmType, fromChain?.id),
|
|
169
|
+
originChainId: fromToken.chainId,
|
|
170
|
+
destinationChainId: toToken.chainId,
|
|
171
|
+
originCurrency: fromToken.address,
|
|
172
|
+
destinationCurrency: toToken.address,
|
|
173
|
+
recipient: getDeadAddress(toChain?.vmType, toChain?.id),
|
|
174
|
+
tradeType,
|
|
175
|
+
appFees: providerOptionsContext.appFees,
|
|
176
|
+
amount: '10000000000000000000000', //Hardcode an extremely high number
|
|
177
|
+
referrer: relayClient?.source ?? undefined,
|
|
178
|
+
useExternalLiquidity: true
|
|
179
|
+
}
|
|
180
|
+
: undefined, undefined, undefined, {
|
|
181
|
+
refetchOnWindowFocus: false,
|
|
182
|
+
enabled: fromToken !== undefined &&
|
|
183
|
+
toToken !== undefined &&
|
|
184
|
+
fromChain &&
|
|
185
|
+
toChain &&
|
|
186
|
+
(fromChain.id === toChain.baseChainId ||
|
|
187
|
+
toChain.id === fromChain.baseChainId)
|
|
188
|
+
});
|
|
189
|
+
const supportsExternalLiquidity = tokenPairIsCanonical &&
|
|
190
|
+
externalLiquiditySupport.status === 'success' &&
|
|
191
|
+
fromChainWalletVMSupported
|
|
192
|
+
? true
|
|
193
|
+
: false;
|
|
194
|
+
const { displayName: toDisplayName } = useENSResolver(recipient, {
|
|
195
|
+
enabled: toChain?.vmType === 'evm' && isValidToAddress
|
|
196
|
+
});
|
|
197
|
+
const [currentSlippageTolerance, setCurrentSlippageTolerance] = useState(slippageTolerance);
|
|
198
|
+
useEffect(() => {
|
|
199
|
+
setCurrentSlippageTolerance(slippageTolerance);
|
|
200
|
+
}, [slippageTolerance]);
|
|
201
|
+
const { required: gasTopUpRequired, amount: _gasTopUpAmount, amountUsd: _gasTopUpAmountUsd } = useGasTopUpRequired(toChain, fromChain, toToken, recipient);
|
|
202
|
+
// Retrieve the price of the `from` token
|
|
203
|
+
const { data: fromTokenPriceData, isLoading: isLoadingFromTokenPrice } = useTokenPrice(relayClient?.baseApiUrl, {
|
|
204
|
+
address: fromToken?.address ?? '',
|
|
205
|
+
chainId: fromToken?.chainId ?? 0,
|
|
206
|
+
referrer: relayClient?.source
|
|
207
|
+
}, {
|
|
208
|
+
enabled: !!(fromToken?.address && fromToken.chainId),
|
|
209
|
+
...tokenPriceQueryOptions
|
|
210
|
+
});
|
|
211
|
+
// Retrieve the price of the `to` token
|
|
212
|
+
const { data: toTokenPriceData, isLoading: isLoadingToTokenPrice } = useTokenPrice(relayClient?.baseApiUrl, {
|
|
213
|
+
address: toToken?.address ?? '',
|
|
214
|
+
chainId: toToken?.chainId ?? 0,
|
|
215
|
+
referrer: relayClient?.source
|
|
216
|
+
}, {
|
|
217
|
+
enabled: !!(toToken?.address && toToken.chainId),
|
|
218
|
+
...tokenPriceQueryOptions
|
|
219
|
+
});
|
|
220
|
+
const originChainSupportsProtocolv2 = fromChain?.protocol?.v2?.depository !== undefined;
|
|
221
|
+
const quoteProtocol = useMemo(() => {
|
|
222
|
+
//Enabled only on certain chains
|
|
223
|
+
if (fromChain?.id && originChainSupportsProtocolv2) {
|
|
224
|
+
if (!fromToken && !fromTokenPriceData) {
|
|
225
|
+
return undefined;
|
|
226
|
+
}
|
|
227
|
+
const relevantPrice = fromTokenPriceData?.price && !isLoadingFromTokenPrice
|
|
228
|
+
? fromTokenPriceData.price
|
|
229
|
+
: undefined;
|
|
230
|
+
const amount = tradeType === 'EXACT_INPUT'
|
|
231
|
+
? debouncedInputAmountValue
|
|
232
|
+
: debouncedOutputAmountValue;
|
|
233
|
+
if (!amount) {
|
|
234
|
+
return undefined;
|
|
235
|
+
}
|
|
236
|
+
const usdAmount = relevantPrice
|
|
237
|
+
? calculateUsdValue(relevantPrice, amount)
|
|
238
|
+
: undefined;
|
|
239
|
+
return usdAmount !== undefined && usdAmount <= 100
|
|
240
|
+
? 'preferV2'
|
|
241
|
+
: undefined;
|
|
242
|
+
}
|
|
243
|
+
else {
|
|
244
|
+
return undefined;
|
|
245
|
+
}
|
|
246
|
+
}, [
|
|
247
|
+
fromTokenPriceData,
|
|
248
|
+
isLoadingFromTokenPrice,
|
|
249
|
+
debouncedInputAmountValue,
|
|
250
|
+
tradeType,
|
|
251
|
+
originChainSupportsProtocolv2
|
|
252
|
+
]);
|
|
253
|
+
const loadingProtocolVersion = fromChain?.id && originChainSupportsProtocolv2 && isLoadingFromTokenPrice;
|
|
254
|
+
const quoteParameters = fromToken && toToken
|
|
255
|
+
? {
|
|
256
|
+
user: fromAddressWithFallback,
|
|
257
|
+
originChainId: fromToken.chainId,
|
|
258
|
+
destinationChainId: toToken.chainId,
|
|
259
|
+
originCurrency: fromToken.address,
|
|
260
|
+
destinationCurrency: toToken.address,
|
|
261
|
+
recipient: toAddressWithFallback,
|
|
262
|
+
tradeType,
|
|
263
|
+
appFees: providerOptionsContext.appFees,
|
|
264
|
+
amount: tradeType === 'EXACT_INPUT'
|
|
265
|
+
? parseUnits(debouncedInputAmountValue, fromToken.decimals).toString()
|
|
266
|
+
: parseUnits(debouncedOutputAmountValue, toToken.decimals).toString(),
|
|
267
|
+
referrer: relayClient?.source ?? undefined,
|
|
268
|
+
useExternalLiquidity,
|
|
269
|
+
useDepositAddress: !fromChainWalletVMSupported || fromToken?.chainId === 1337,
|
|
270
|
+
refundTo: fromToken?.chainId === 1337 ? address : undefined,
|
|
271
|
+
slippageTolerance: slippageTolerance,
|
|
272
|
+
topupGas: gasTopUpEnabled && gasTopUpRequired,
|
|
273
|
+
protocolVersion: quoteProtocol
|
|
274
|
+
}
|
|
275
|
+
: undefined;
|
|
276
|
+
const onQuoteRequested = (options, config) => {
|
|
277
|
+
const interval = get15MinuteInterval();
|
|
278
|
+
const quoteRequestId = sha256({ ...options, interval });
|
|
279
|
+
onAnalyticEvent?.(EventNames.QUOTE_REQUESTED, {
|
|
280
|
+
parameters: options,
|
|
281
|
+
wallet_connector: linkedWallet?.connector,
|
|
282
|
+
chain_id_in: options?.originChainId,
|
|
283
|
+
chain_id_out: options?.destinationChainId,
|
|
284
|
+
http_config: config,
|
|
285
|
+
quote_request_id: quoteRequestId
|
|
286
|
+
});
|
|
287
|
+
};
|
|
288
|
+
const onQuoteReceived = ({ details, steps }, options) => {
|
|
289
|
+
const interval = get15MinuteInterval();
|
|
290
|
+
const quoteRequestId = sha256({ ...options, interval });
|
|
291
|
+
onAnalyticEvent?.(EventNames.QUOTE_RECEIVED, {
|
|
292
|
+
parameters: options,
|
|
293
|
+
wallet_connector: linkedWallet?.connector,
|
|
294
|
+
amount_in: details?.currencyIn?.amountFormatted,
|
|
295
|
+
amount_in_raw: details?.currencyIn?.amount,
|
|
296
|
+
currency_in: details?.currencyIn?.currency?.symbol,
|
|
297
|
+
chain_id_in: details?.currencyIn?.currency?.chainId,
|
|
298
|
+
amount_out: details?.currencyOut?.amountFormatted,
|
|
299
|
+
amount_out_raw: details?.currencyOut?.amount,
|
|
300
|
+
currency_out: details?.currencyOut?.currency?.symbol,
|
|
301
|
+
chain_id_out: details?.currencyOut?.currency?.chainId,
|
|
302
|
+
slippage_tolerance_destination_percentage: details?.slippageTolerance?.destination?.percent,
|
|
303
|
+
slippage_tolerance_origin_percentage: details?.slippageTolerance?.origin?.percent,
|
|
304
|
+
steps,
|
|
305
|
+
quote_request_id: quoteRequestId,
|
|
306
|
+
quote_id: steps ? extractQuoteId(steps) : undefined
|
|
307
|
+
});
|
|
308
|
+
};
|
|
309
|
+
const quoteFetchingEnabled = Boolean(relayClient &&
|
|
310
|
+
((tradeType === 'EXACT_INPUT' &&
|
|
311
|
+
debouncedInputAmountValue &&
|
|
312
|
+
debouncedInputAmountValue.length > 0 &&
|
|
313
|
+
Number(debouncedInputAmountValue) !== 0) ||
|
|
314
|
+
(tradeType === 'EXPECTED_OUTPUT' &&
|
|
315
|
+
debouncedOutputAmountValue &&
|
|
316
|
+
debouncedOutputAmountValue.length > 0 &&
|
|
317
|
+
Number(debouncedOutputAmountValue) !== 0)) &&
|
|
318
|
+
fromToken !== undefined &&
|
|
319
|
+
toToken !== undefined &&
|
|
320
|
+
!transactionModalOpen &&
|
|
321
|
+
!depositAddressModalOpen &&
|
|
322
|
+
!loadingProtocolVersion);
|
|
323
|
+
const { data: _quoteData, error: quoteError, isFetching: isFetchingQuote, executeQuote: executeSwap, queryKey: quoteQueryKey } = useQuote(relayClient ? relayClient : undefined, wallet, quoteParameters, onQuoteRequested, onQuoteReceived, {
|
|
324
|
+
refetchOnWindowFocus: false,
|
|
325
|
+
enabled: quoteFetchingEnabled,
|
|
326
|
+
refetchInterval: !transactionModalOpen &&
|
|
327
|
+
!depositAddressModalOpen &&
|
|
328
|
+
debouncedInputAmountValue === amountInputValue &&
|
|
329
|
+
debouncedOutputAmountValue === amountOutputValue
|
|
330
|
+
? 12000
|
|
331
|
+
: undefined
|
|
332
|
+
}, (e) => {
|
|
333
|
+
const errorMessage = errorToJSON(e?.response?.data?.message ? new Error(e?.response?.data?.message) : e);
|
|
334
|
+
const interval = get15MinuteInterval();
|
|
335
|
+
const quoteRequestId = sha256({ ...quoteParameters, interval });
|
|
336
|
+
onAnalyticEvent?.(EventNames.QUOTE_ERROR, {
|
|
337
|
+
wallet_connector: linkedWallet?.connector,
|
|
338
|
+
error_message: errorMessage,
|
|
339
|
+
parameters: quoteParameters,
|
|
340
|
+
quote_request_id: quoteRequestId,
|
|
341
|
+
status_code: e.response.status ?? e.status ?? ''
|
|
342
|
+
});
|
|
343
|
+
});
|
|
344
|
+
const invalidateQuoteQuery = useCallback(() => {
|
|
345
|
+
queryClient.invalidateQueries({ queryKey: quoteQueryKey });
|
|
346
|
+
}, [queryClient, quoteQueryKey]);
|
|
347
|
+
let error = _quoteData || (isFetchingQuote && quoteFetchingEnabled) ? null : quoteError;
|
|
348
|
+
let quote = error ? undefined : _quoteData;
|
|
349
|
+
const gasTopUpAmount = quote?.details?.currencyGasTopup?.amount
|
|
350
|
+
? BigInt(quote?.details?.currencyGasTopup?.amount)
|
|
351
|
+
: _gasTopUpAmount;
|
|
352
|
+
const gasTopUpAmountUsd = quote?.details?.currencyGasTopup?.amountUsd ?? _gasTopUpAmountUsd;
|
|
353
|
+
useDisconnected(address, () => {
|
|
354
|
+
setCustomToAddress(undefined);
|
|
355
|
+
});
|
|
356
|
+
useEffect(() => {
|
|
357
|
+
if (tradeType === 'EXACT_INPUT') {
|
|
358
|
+
const amountOut = quote?.details?.currencyOut?.amount ?? '';
|
|
359
|
+
setAmountOutputValue(amountOut !== ''
|
|
360
|
+
? formatUnits(BigInt(amountOut), Number(quote?.details?.currencyOut?.currency?.decimals ?? 18))
|
|
361
|
+
: '');
|
|
362
|
+
}
|
|
363
|
+
else if (tradeType === 'EXPECTED_OUTPUT') {
|
|
364
|
+
const amountIn = quote?.details?.currencyIn?.amount ?? '';
|
|
365
|
+
setAmountInputValue(amountIn !== ''
|
|
366
|
+
? formatUnits(BigInt(amountIn), Number(quote?.details?.currencyIn?.currency?.decimals ?? 18))
|
|
367
|
+
: '');
|
|
368
|
+
}
|
|
369
|
+
debouncedAmountInputControls.flush();
|
|
370
|
+
debouncedAmountOutputControls.flush();
|
|
371
|
+
}, [quote, tradeType]);
|
|
372
|
+
useEffect(() => {
|
|
373
|
+
if (useExternalLiquidity &&
|
|
374
|
+
!externalLiquiditySupport.isFetching &&
|
|
375
|
+
!supportsExternalLiquidity) {
|
|
376
|
+
setUseExternalLiquidity(false);
|
|
377
|
+
}
|
|
378
|
+
}, [
|
|
379
|
+
supportsExternalLiquidity,
|
|
380
|
+
useExternalLiquidity,
|
|
381
|
+
externalLiquiditySupport.isFetching
|
|
382
|
+
]);
|
|
383
|
+
const feeBreakdown = useMemo(() => {
|
|
384
|
+
const chains = relayClient?.chains;
|
|
385
|
+
const fromChain = chains?.find((chain) => chain.id === fromToken?.chainId);
|
|
386
|
+
const toChain = chains?.find((chain) => chain.id === toToken?.chainId);
|
|
387
|
+
return fromToken && toToken && fromChain && toChain && quote
|
|
388
|
+
? parseFees(toChain, fromChain, quote)
|
|
389
|
+
: null;
|
|
390
|
+
}, [quote, fromToken, toToken, relayClient]);
|
|
391
|
+
const totalAmount = BigInt(quote?.details?.currencyIn?.amount ?? 0n);
|
|
392
|
+
const hasInsufficientBalance = Boolean(!fromBalanceErrorFetching &&
|
|
393
|
+
totalAmount &&
|
|
394
|
+
address &&
|
|
395
|
+
(fromBalance ?? 0n) < totalAmount &&
|
|
396
|
+
!hasAuxiliaryFundsSupport &&
|
|
397
|
+
fromChainWalletVMSupported);
|
|
398
|
+
const fetchQuoteErrorMessage = error
|
|
399
|
+
? error?.message
|
|
400
|
+
? error?.message
|
|
401
|
+
: 'Unknown Error'
|
|
402
|
+
: null;
|
|
403
|
+
const fetchQuoteDataErrorMessage = error
|
|
404
|
+
? error?.response?.data?.message
|
|
405
|
+
? error?.response?.data.message
|
|
406
|
+
: 'Unknown Error'
|
|
407
|
+
: null;
|
|
408
|
+
const isInsufficientLiquidityError = Boolean(fetchQuoteErrorMessage?.includes('No quotes available'));
|
|
409
|
+
const isCapacityExceededError = fetchQuoteDataErrorMessage?.includes('Amount is higher than the available liquidity') || fetchQuoteDataErrorMessage?.includes('Insufficient relayer liquidity');
|
|
410
|
+
const isCouldNotExecuteError = fetchQuoteDataErrorMessage?.includes('Could not execute');
|
|
411
|
+
const highRelayerServiceFee = isHighRelayerServiceFeeUsd(quote);
|
|
412
|
+
const relayerFeeProportion = calculateRelayerFeeProportionUsd(quote);
|
|
413
|
+
const timeEstimate = calculatePriceTimeEstimate(quote?.details);
|
|
414
|
+
const canonicalTimeEstimate = calculatePriceTimeEstimate(externalLiquiditySupport.data?.details);
|
|
415
|
+
const recipientWalletSupportsChain = useIsWalletCompatible(toChain?.id, recipient, linkedWallets, onAnalyticEvent);
|
|
416
|
+
const isFromNative = fromToken?.address === fromChain?.currency?.address;
|
|
417
|
+
const isSameCurrencySameRecipientSwap = fromToken?.address === toToken?.address &&
|
|
418
|
+
fromToken?.chainId === toToken?.chainId &&
|
|
419
|
+
address === recipient;
|
|
420
|
+
const ctaCopy = useSwapButtonCta({
|
|
421
|
+
fromToken,
|
|
422
|
+
toToken,
|
|
423
|
+
multiWalletSupportEnabled,
|
|
424
|
+
isValidFromAddress,
|
|
425
|
+
fromChainWalletVMSupported,
|
|
426
|
+
isValidToAddress,
|
|
427
|
+
toChainWalletVMSupported,
|
|
428
|
+
fromChain,
|
|
429
|
+
toChain,
|
|
430
|
+
isSameCurrencySameRecipientSwap,
|
|
431
|
+
debouncedInputAmountValue,
|
|
432
|
+
debouncedOutputAmountValue,
|
|
433
|
+
hasInsufficientBalance,
|
|
434
|
+
isInsufficientLiquidityError,
|
|
435
|
+
quote,
|
|
436
|
+
operation: quote?.details?.operation
|
|
437
|
+
});
|
|
438
|
+
usePreviousValueChange(isCapacityExceededError && supportsExternalLiquidity, !isFetchingQuote && !externalLiquiditySupport.isFetching, (capacityExceeded) => {
|
|
439
|
+
if (capacityExceeded) {
|
|
440
|
+
onAnalyticEvent?.(EventNames.CTA_MAX_CAPACITY_PROMPTED, {
|
|
441
|
+
inputAmount: debouncedInputAmountValue,
|
|
442
|
+
outputAmount: debouncedOutputAmountValue
|
|
443
|
+
});
|
|
444
|
+
}
|
|
445
|
+
});
|
|
446
|
+
const swap = useCallback(async () => {
|
|
447
|
+
let submittedEvents = [];
|
|
448
|
+
const swapErrorHandler = (error, currentSteps) => {
|
|
449
|
+
const errorMessage = errorToJSON(error?.response?.data?.message
|
|
450
|
+
? new Error(error?.response?.data?.message)
|
|
451
|
+
: error);
|
|
452
|
+
if (error &&
|
|
453
|
+
((typeof error.message === 'string' &&
|
|
454
|
+
error.message.includes('rejected')) ||
|
|
455
|
+
(typeof error === 'string' && error.includes('rejected')) ||
|
|
456
|
+
(typeof error === 'string' && error.includes('Approval Denied')) ||
|
|
457
|
+
(typeof error === 'string' && error.includes('denied transaction')) ||
|
|
458
|
+
(typeof error.message === 'string' &&
|
|
459
|
+
error.message.includes('Approval Denied')) ||
|
|
460
|
+
(typeof error.message === 'string' &&
|
|
461
|
+
error.message.includes('Plugin Closed')) ||
|
|
462
|
+
(typeof error.message === 'string' &&
|
|
463
|
+
error.message.includes('denied transaction')) ||
|
|
464
|
+
(typeof error.message === 'string' &&
|
|
465
|
+
error.message.includes('Failed to initialize request') &&
|
|
466
|
+
fromChain?.id === 2741)) // Abstract @TODO: remove once privy improves handling rejected transactions
|
|
467
|
+
) {
|
|
468
|
+
// Close the transaction modal if the user rejects the tx
|
|
469
|
+
setTransactionModalOpen(false);
|
|
470
|
+
onAnalyticEvent?.(EventNames.USER_REJECTED_WALLET, {
|
|
471
|
+
error_message: errorMessage
|
|
472
|
+
});
|
|
473
|
+
return;
|
|
474
|
+
}
|
|
475
|
+
const { step, stepItem } = getCurrentStep(currentSteps);
|
|
476
|
+
const swapEventData = {
|
|
477
|
+
...getSwapEventData(quote?.details, currentSteps ?? null, linkedWallet?.connector, quoteParameters),
|
|
478
|
+
error_message: errorMessage
|
|
479
|
+
};
|
|
480
|
+
const isApproval = step?.id === 'approve';
|
|
481
|
+
const errorEvent = isApproval
|
|
482
|
+
? EventNames.APPROVAL_ERROR
|
|
483
|
+
: EventNames.DEPOSIT_ERROR;
|
|
484
|
+
//Filter out receipt/deposit transaction errors, those are approval/deposit errors
|
|
485
|
+
const isTransactionConfirmationError = (error &&
|
|
486
|
+
typeof error.message === 'string' &&
|
|
487
|
+
error.message.includes('TransactionConfirmationError')) ||
|
|
488
|
+
(error.name && error.name.includes('TransactionConfirmationError'));
|
|
489
|
+
if (stepItem?.receipt &&
|
|
490
|
+
stepItem.check &&
|
|
491
|
+
!isTransactionConfirmationError &&
|
|
492
|
+
(typeof stepItem.receipt === 'object' && 'status' in stepItem.receipt
|
|
493
|
+
? stepItem.receipt.status !== 'reverted'
|
|
494
|
+
: true) &&
|
|
495
|
+
(!stepItem.checkStatus || stepItem.checkStatus !== 'unknown')) {
|
|
496
|
+
//In some cases there's a race condition where an error is thrown before the steps get a chance to call
|
|
497
|
+
//the callback which triggers the success event. This is a workaround to ensure the success event is triggered when
|
|
498
|
+
//we have a receipt and require a fill check if we haven't already send the success event.
|
|
499
|
+
const successEvent = isApproval
|
|
500
|
+
? EventNames.APPROVAL_SUCCESS
|
|
501
|
+
: EventNames.DEPOSIT_SUCCESS;
|
|
502
|
+
if (!submittedEvents.includes(successEvent)) {
|
|
503
|
+
onAnalyticEvent?.(successEvent, swapEventData);
|
|
504
|
+
submittedEvents.push(successEvent);
|
|
505
|
+
//To preserve the order of events we need to delay sending the fill error event but mark that we did send it to avoid duplicates
|
|
506
|
+
setTimeout(() => {
|
|
507
|
+
onAnalyticEvent?.(EventNames.FILL_ERROR, swapEventData);
|
|
508
|
+
}, 20);
|
|
509
|
+
}
|
|
510
|
+
else {
|
|
511
|
+
onAnalyticEvent?.(EventNames.FILL_ERROR, swapEventData);
|
|
512
|
+
}
|
|
513
|
+
}
|
|
514
|
+
else if (!stepItem?.receipt ||
|
|
515
|
+
(typeof stepItem.receipt === 'object' &&
|
|
516
|
+
'status' in stepItem.receipt &&
|
|
517
|
+
stepItem.receipt.status === 'reverted')) {
|
|
518
|
+
onAnalyticEvent?.(errorEvent, swapEventData);
|
|
519
|
+
}
|
|
520
|
+
else {
|
|
521
|
+
onAnalyticEvent?.(EventNames.SWAP_ERROR, swapEventData);
|
|
522
|
+
}
|
|
523
|
+
setSwapError(errorMessage);
|
|
524
|
+
onSwapError?.(errorMessage, { ...quote, steps: currentSteps });
|
|
525
|
+
};
|
|
526
|
+
try {
|
|
527
|
+
const swapEventData = getSwapEventData(quote?.details, quote?.steps ? quote?.steps : null, linkedWallet?.connector, quoteParameters);
|
|
528
|
+
onAnalyticEvent?.(EventNames.SWAP_CTA_CLICKED, swapEventData);
|
|
529
|
+
setWaitingForSteps(true);
|
|
530
|
+
if (!executeSwap) {
|
|
531
|
+
throw 'Missing a quote';
|
|
532
|
+
}
|
|
533
|
+
if (!wallet && !walletClient.data) {
|
|
534
|
+
throw 'Missing a wallet';
|
|
535
|
+
}
|
|
536
|
+
setSteps(quote?.steps);
|
|
537
|
+
setQuoteInProgress(quote);
|
|
538
|
+
setTransactionModalOpen(true);
|
|
539
|
+
const _wallet = wallet ?? adaptViemWallet(walletClient.data);
|
|
540
|
+
const activeWalletChainId = await _wallet?.getChainId();
|
|
541
|
+
const activeWalletChain = relayClient?.chains?.find((chain) => chain.id === activeWalletChainId);
|
|
542
|
+
let targetChainId = fromToken?.chainId;
|
|
543
|
+
//Special case for Hyperliquid, to sign txs on an evm chain
|
|
544
|
+
if (fromToken?.chainId === 1337) {
|
|
545
|
+
targetChainId =
|
|
546
|
+
activeWalletChain?.vmType !== 'evm' ? 1 : activeWalletChainId;
|
|
547
|
+
}
|
|
548
|
+
if (fromToken && targetChainId && targetChainId !== activeWalletChainId) {
|
|
549
|
+
onAnalyticEvent?.(EventNames.SWAP_SWITCH_NETWORK, {
|
|
550
|
+
activeWalletChainId,
|
|
551
|
+
...swapEventData
|
|
552
|
+
});
|
|
553
|
+
await _wallet?.switchChain(targetChainId);
|
|
554
|
+
}
|
|
555
|
+
let _currentSteps = undefined;
|
|
556
|
+
const execPromise = executeSwap(({ steps: currentSteps }) => {
|
|
557
|
+
setSteps(currentSteps);
|
|
558
|
+
_currentSteps = currentSteps;
|
|
559
|
+
const { step, stepItem } = getCurrentStep(currentSteps);
|
|
560
|
+
const swapEventData = getSwapEventData(quote?.details, currentSteps, linkedWallet?.connector, quoteParameters);
|
|
561
|
+
if (step && stepItem) {
|
|
562
|
+
//@ts-ignore
|
|
563
|
+
const isApproval = step.id === 'approve' || step.id === 'approval';
|
|
564
|
+
let submittedEvent = isApproval
|
|
565
|
+
? EventNames.APPROVAL_SUBMITTED
|
|
566
|
+
: EventNames.DEPOSIT_SUBMITTED;
|
|
567
|
+
const successEvent = isApproval
|
|
568
|
+
? EventNames.APPROVAL_SUCCESS
|
|
569
|
+
: EventNames.DEPOSIT_SUCCESS;
|
|
570
|
+
const isBatchTransaction = Boolean(Array.isArray(step.items) &&
|
|
571
|
+
step.items.length > 1 &&
|
|
572
|
+
wallet?.handleBatchTransactionStep);
|
|
573
|
+
if (!isApproval && isBatchTransaction) {
|
|
574
|
+
submittedEvent = EventNames.BATCH_TX_SUBMITTED;
|
|
575
|
+
}
|
|
576
|
+
if (!submittedEvents.includes(submittedEvent) &&
|
|
577
|
+
!stepItem.receipt &&
|
|
578
|
+
stepItem?.txHashes &&
|
|
579
|
+
stepItem?.txHashes?.length > 0) {
|
|
580
|
+
submittedEvents.push(submittedEvent);
|
|
581
|
+
onAnalyticEvent?.(submittedEvent, swapEventData);
|
|
582
|
+
}
|
|
583
|
+
else if ((!submittedEvents.includes(successEvent) &&
|
|
584
|
+
stepItem.receipt &&
|
|
585
|
+
!(typeof stepItem.receipt === 'object' &&
|
|
586
|
+
'status' in stepItem.receipt &&
|
|
587
|
+
stepItem.receipt.status === 'reverted')) ||
|
|
588
|
+
stepItem.checkStatus === 'pending') {
|
|
589
|
+
onAnalyticEvent?.(successEvent, swapEventData);
|
|
590
|
+
submittedEvents.push(successEvent);
|
|
591
|
+
}
|
|
592
|
+
if (stepItem.status === 'complete' &&
|
|
593
|
+
stepItem.check &&
|
|
594
|
+
!submittedEvents.includes(EventNames.FILL_SUCCESS)) {
|
|
595
|
+
//Sometimes a fill may be quicker than the tx receipt is available, so we need to handle this scenario
|
|
596
|
+
if (!submittedEvents.includes(EventNames.DEPOSIT_SUCCESS) &&
|
|
597
|
+
!isBatchTransaction) {
|
|
598
|
+
onAnalyticEvent?.(EventNames.DEPOSIT_SUCCESS, swapEventData);
|
|
599
|
+
submittedEvents.push(EventNames.DEPOSIT_SUCCESS);
|
|
600
|
+
//To preserve the order of events we need to delay sending the fill success event but mark that we did send it to avoid duplicates
|
|
601
|
+
setTimeout(() => {
|
|
602
|
+
onAnalyticEvent?.(EventNames.FILL_SUCCESS, swapEventData);
|
|
603
|
+
}, 20);
|
|
604
|
+
}
|
|
605
|
+
else {
|
|
606
|
+
onAnalyticEvent?.(EventNames.FILL_SUCCESS, swapEventData);
|
|
607
|
+
}
|
|
608
|
+
submittedEvents.push(EventNames.FILL_SUCCESS);
|
|
609
|
+
}
|
|
610
|
+
}
|
|
611
|
+
else if (currentSteps?.every((step) => step.items?.every((item) => item.status === 'complete')) &&
|
|
612
|
+
!submittedEvents.includes(EventNames.FILL_SUCCESS)) {
|
|
613
|
+
//Sometimes a fill may be quicker than the tx receipt is available, so we need to handle this scenario
|
|
614
|
+
if (!submittedEvents.includes(EventNames.DEPOSIT_SUCCESS) &&
|
|
615
|
+
!submittedEvents.includes(EventNames.BATCH_TX_SUBMITTED)) {
|
|
616
|
+
onAnalyticEvent?.(EventNames.DEPOSIT_SUCCESS, swapEventData);
|
|
617
|
+
submittedEvents.push(EventNames.DEPOSIT_SUCCESS);
|
|
618
|
+
//To preserve the order of events we need to delay sending the fill success event but mark that we did send it to avoid duplicates
|
|
619
|
+
setTimeout(() => {
|
|
620
|
+
onAnalyticEvent?.(EventNames.FILL_SUCCESS, swapEventData);
|
|
621
|
+
}, 20);
|
|
622
|
+
}
|
|
623
|
+
else {
|
|
624
|
+
onAnalyticEvent?.(EventNames.FILL_SUCCESS, swapEventData);
|
|
625
|
+
}
|
|
626
|
+
submittedEvents.push(EventNames.FILL_SUCCESS);
|
|
627
|
+
}
|
|
628
|
+
});
|
|
629
|
+
// Store the AbortController for potential cancellation immediately
|
|
630
|
+
if (execPromise &&
|
|
631
|
+
typeof execPromise === 'object' &&
|
|
632
|
+
'abortController' in execPromise) {
|
|
633
|
+
setAbortController(execPromise.abortController);
|
|
634
|
+
}
|
|
635
|
+
execPromise
|
|
636
|
+
?.catch((error) => {
|
|
637
|
+
swapErrorHandler(error, _currentSteps);
|
|
638
|
+
})
|
|
639
|
+
.finally(() => {
|
|
640
|
+
setWaitingForSteps(false);
|
|
641
|
+
setAbortController(null);
|
|
642
|
+
invalidateBalanceQueries();
|
|
643
|
+
});
|
|
644
|
+
}
|
|
645
|
+
catch (error) {
|
|
646
|
+
swapErrorHandler(error);
|
|
647
|
+
setWaitingForSteps(false);
|
|
648
|
+
}
|
|
649
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
650
|
+
}, [
|
|
651
|
+
relayClient,
|
|
652
|
+
address,
|
|
653
|
+
connector,
|
|
654
|
+
wallet,
|
|
655
|
+
walletClient,
|
|
656
|
+
fromToken,
|
|
657
|
+
toToken,
|
|
658
|
+
customToAddress,
|
|
659
|
+
recipient,
|
|
660
|
+
debouncedInputAmountValue,
|
|
661
|
+
debouncedOutputAmountValue,
|
|
662
|
+
tradeType,
|
|
663
|
+
useExternalLiquidity,
|
|
664
|
+
waitingForSteps,
|
|
665
|
+
executeSwap,
|
|
666
|
+
setSteps,
|
|
667
|
+
setQuoteInProgress,
|
|
668
|
+
invalidateBalanceQueries,
|
|
669
|
+
linkedWallet,
|
|
670
|
+
abortController
|
|
671
|
+
]);
|
|
672
|
+
return (_jsx(_Fragment, { children: children({
|
|
673
|
+
quote,
|
|
674
|
+
steps,
|
|
675
|
+
setSteps,
|
|
676
|
+
swap,
|
|
677
|
+
transactionModalOpen,
|
|
678
|
+
feeBreakdown,
|
|
679
|
+
fromToken,
|
|
680
|
+
setFromToken,
|
|
681
|
+
toToken,
|
|
682
|
+
setToToken,
|
|
683
|
+
swapError,
|
|
684
|
+
error,
|
|
685
|
+
toDisplayName,
|
|
686
|
+
address,
|
|
687
|
+
recipient,
|
|
688
|
+
customToAddress,
|
|
689
|
+
setCustomToAddress,
|
|
690
|
+
tradeType,
|
|
691
|
+
setTradeType,
|
|
692
|
+
details,
|
|
693
|
+
isSameCurrencySameRecipientSwap,
|
|
694
|
+
debouncedInputAmountValue,
|
|
695
|
+
debouncedAmountInputControls,
|
|
696
|
+
setAmountInputValue,
|
|
697
|
+
amountInputValue,
|
|
698
|
+
amountOutputValue,
|
|
699
|
+
debouncedOutputAmountValue,
|
|
700
|
+
debouncedAmountOutputControls,
|
|
701
|
+
setAmountOutputValue,
|
|
702
|
+
toBalance,
|
|
703
|
+
toBalancePending,
|
|
704
|
+
isLoadingToBalance,
|
|
705
|
+
isFetchingQuote,
|
|
706
|
+
isLoadingFromBalance,
|
|
707
|
+
fromBalance,
|
|
708
|
+
fromBalancePending,
|
|
709
|
+
highRelayerServiceFee,
|
|
710
|
+
relayerFeeProportion,
|
|
711
|
+
hasInsufficientBalance,
|
|
712
|
+
isInsufficientLiquidityError,
|
|
713
|
+
isCapacityExceededError,
|
|
714
|
+
isCouldNotExecuteError,
|
|
715
|
+
ctaCopy,
|
|
716
|
+
isFromNative,
|
|
717
|
+
useExternalLiquidity,
|
|
718
|
+
slippageTolerance: currentSlippageTolerance,
|
|
719
|
+
supportsExternalLiquidity,
|
|
720
|
+
timeEstimate,
|
|
721
|
+
canonicalTimeEstimate,
|
|
722
|
+
fetchingExternalLiquiditySupport: externalLiquiditySupport.isFetching,
|
|
723
|
+
isSvmSwap,
|
|
724
|
+
isBvmSwap,
|
|
725
|
+
isValidFromAddress,
|
|
726
|
+
isValidToAddress,
|
|
727
|
+
supportedWalletVMs,
|
|
728
|
+
fromChainWalletVMSupported,
|
|
729
|
+
toChainWalletVMSupported,
|
|
730
|
+
isRecipientLinked,
|
|
731
|
+
recipientWalletSupportsChain,
|
|
732
|
+
gasTopUpEnabled,
|
|
733
|
+
setGasTopUpEnabled,
|
|
734
|
+
gasTopUpRequired,
|
|
735
|
+
gasTopUpAmount,
|
|
736
|
+
gasTopUpAmountUsd,
|
|
737
|
+
invalidateBalanceQueries,
|
|
738
|
+
invalidateQuoteQuery,
|
|
739
|
+
setUseExternalLiquidity,
|
|
740
|
+
setDetails,
|
|
741
|
+
setSwapError,
|
|
742
|
+
quoteInProgress,
|
|
743
|
+
setQuoteInProgress,
|
|
744
|
+
linkedWallet,
|
|
745
|
+
quoteParameters,
|
|
746
|
+
abortController,
|
|
747
|
+
fromTokenPriceData,
|
|
748
|
+
toTokenPriceData,
|
|
749
|
+
isLoadingFromTokenPrice,
|
|
750
|
+
isLoadingToTokenPrice
|
|
751
|
+
}) }));
|
|
752
|
+
};
|
|
753
|
+
export default SwapWidgetRenderer;
|
|
754
|
+
//# sourceMappingURL=SwapWidgetRenderer.js.map
|