@relayprotocol/relay-kit-ui 7.1.6 → 8.0.1
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/_cjs/src/components/common/AmountInput.js +2 -17
- package/_cjs/src/components/common/AmountInput.js.map +1 -1
- package/_cjs/src/components/common/BalanceDisplay.js +2 -2
- package/_cjs/src/components/common/BalanceDisplay.js.map +1 -1
- package/_cjs/src/components/common/CopyToClipBoard.js +3 -7
- package/_cjs/src/components/common/CopyToClipBoard.js.map +1 -1
- package/_cjs/src/components/common/CustomAddressModal.js +10 -48
- package/_cjs/src/components/common/CustomAddressModal.js.map +1 -1
- package/_cjs/src/components/common/ErrorWell.js +9 -28
- package/_cjs/src/components/common/ErrorWell.js.map +1 -1
- package/_cjs/src/components/common/LoadingSpinner.js +7 -13
- package/_cjs/src/components/common/LoadingSpinner.js.map +1 -1
- package/_cjs/src/components/common/Modal.js +4 -22
- package/_cjs/src/components/common/Modal.js.map +1 -1
- package/_cjs/src/components/common/MultiWalletDropdown.js +23 -57
- package/_cjs/src/components/common/MultiWalletDropdown.js.map +1 -1
- package/_cjs/src/components/common/PercentageButtons.js +7 -24
- package/_cjs/src/components/common/PercentageButtons.js.map +1 -1
- package/_cjs/src/components/common/SlippageToleranceConfig.js +21 -117
- package/_cjs/src/components/common/SlippageToleranceConfig.js.map +1 -1
- package/_cjs/src/components/common/StepIcon.js +1 -7
- package/_cjs/src/components/common/StepIcon.js.map +1 -1
- package/_cjs/src/components/common/TokenSelector/ChainFilter.js +19 -109
- package/_cjs/src/components/common/TokenSelector/ChainFilter.js.map +1 -1
- package/_cjs/src/components/common/TokenSelector/ChainFilterRow.js +10 -54
- package/_cjs/src/components/common/TokenSelector/ChainFilterRow.js.map +1 -1
- package/_cjs/src/components/common/TokenSelector/ChainFilterSidebar.js +15 -98
- package/_cjs/src/components/common/TokenSelector/ChainFilterSidebar.js.map +1 -1
- package/_cjs/src/components/common/TokenSelector/ChainShortcuts.js +6 -28
- package/_cjs/src/components/common/TokenSelector/ChainShortcuts.js.map +1 -1
- package/_cjs/src/components/common/TokenSelector/CompactChainFilter.js +12 -83
- package/_cjs/src/components/common/TokenSelector/CompactChainFilter.js.map +1 -1
- package/_cjs/src/components/common/TokenSelector/MobileChainSelector.js +16 -109
- package/_cjs/src/components/common/TokenSelector/MobileChainSelector.js.map +1 -1
- package/_cjs/src/components/common/TokenSelector/PaymentMethod.js +10 -101
- package/_cjs/src/components/common/TokenSelector/PaymentMethod.js.map +1 -1
- package/_cjs/src/components/common/TokenSelector/PaymentTokenList.js +8 -69
- package/_cjs/src/components/common/TokenSelector/PaymentTokenList.js.map +1 -1
- package/_cjs/src/components/common/TokenSelector/SuggestedTokens.js +2 -33
- package/_cjs/src/components/common/TokenSelector/SuggestedTokens.js.map +1 -1
- package/_cjs/src/components/common/TokenSelector/TagPill.js +1 -9
- package/_cjs/src/components/common/TokenSelector/TagPill.js.map +1 -1
- package/_cjs/src/components/common/TokenSelector/TokenList.js +8 -57
- package/_cjs/src/components/common/TokenSelector/TokenList.js.map +1 -1
- package/_cjs/src/components/common/TokenSelector/TokenSelector.js +24 -70
- package/_cjs/src/components/common/TokenSelector/TokenSelector.js.map +1 -1
- package/_cjs/src/components/common/TokenSelector/triggers/PaymentMethodTrigger.js +2 -35
- package/_cjs/src/components/common/TokenSelector/triggers/PaymentMethodTrigger.js.map +1 -1
- package/_cjs/src/components/common/TokenSelector/triggers/TokenTrigger.js +2 -28
- package/_cjs/src/components/common/TokenSelector/triggers/TokenTrigger.js.map +1 -1
- package/_cjs/src/components/common/TransactionModal/DepositAddressModal.js +2 -10
- package/_cjs/src/components/common/TransactionModal/DepositAddressModal.js.map +1 -1
- package/_cjs/src/components/common/TransactionModal/TransactionModal.js +2 -13
- package/_cjs/src/components/common/TransactionModal/TransactionModal.js.map +1 -1
- package/_cjs/src/components/common/TransactionModal/steps/ApprovalPlusSwapStep.js +8 -45
- package/_cjs/src/components/common/TransactionModal/steps/ApprovalPlusSwapStep.js.map +1 -1
- package/_cjs/src/components/common/TransactionModal/steps/DepositAddressValidatingStep.js +1 -5
- package/_cjs/src/components/common/TransactionModal/steps/DepositAddressValidatingStep.js.map +1 -1
- package/_cjs/src/components/common/TransactionModal/steps/ErrorStep.js +9 -30
- package/_cjs/src/components/common/TransactionModal/steps/ErrorStep.js.map +1 -1
- package/_cjs/src/components/common/TransactionModal/steps/SwapConfirmationStep.js +26 -81
- package/_cjs/src/components/common/TransactionModal/steps/SwapConfirmationStep.js.map +1 -1
- package/_cjs/src/components/common/TransactionModal/steps/SwapSuccessStep.js +16 -76
- package/_cjs/src/components/common/TransactionModal/steps/SwapSuccessStep.js.map +1 -1
- package/_cjs/src/components/common/TransactionModal/steps/TransactionsByChain.js +3 -8
- package/_cjs/src/components/common/TransactionModal/steps/TransactionsByChain.js.map +1 -1
- package/_cjs/src/components/common/TransactionModal/steps/WaitingForDepositStep.js +27 -63
- package/_cjs/src/components/common/TransactionModal/steps/WaitingForDepositStep.js.map +1 -1
- package/_cjs/src/components/common/UnverifiedTokenModal.js +6 -32
- package/_cjs/src/components/common/UnverifiedTokenModal.js.map +1 -1
- package/_cjs/src/components/primitives/AccessibleList.js +5 -21
- package/_cjs/src/components/primitives/AccessibleList.js.map +1 -1
- package/_cjs/src/components/primitives/Anchor.js +18 -41
- package/_cjs/src/components/primitives/Anchor.js.map +1 -1
- package/_cjs/src/components/primitives/Box.js +3 -4
- package/_cjs/src/components/primitives/Box.js.map +1 -1
- package/_cjs/src/components/primitives/Button.js +63 -124
- package/_cjs/src/components/primitives/Button.js.map +1 -1
- package/_cjs/src/components/primitives/ChainIcon.js +5 -9
- package/_cjs/src/components/primitives/ChainIcon.js.map +1 -1
- package/_cjs/src/components/primitives/ChainTokenIcon.js +7 -26
- package/_cjs/src/components/primitives/ChainTokenIcon.js.map +1 -1
- package/_cjs/src/components/primitives/Collapsible.js +7 -32
- package/_cjs/src/components/primitives/Collapsible.js.map +1 -1
- package/_cjs/src/components/primitives/Dialog.js +39 -81
- package/_cjs/src/components/primitives/Dialog.js.map +1 -1
- package/_cjs/src/components/primitives/Dropdown.js +5 -35
- package/_cjs/src/components/primitives/Dropdown.js.map +1 -1
- package/_cjs/src/components/primitives/Flex.js +23 -59
- package/_cjs/src/components/primitives/Flex.js.map +1 -1
- package/_cjs/src/components/primitives/Input.js +19 -51
- package/_cjs/src/components/primitives/Input.js.map +1 -1
- package/_cjs/src/components/primitives/Pill.js +18 -49
- package/_cjs/src/components/primitives/Pill.js.map +1 -1
- package/_cjs/src/components/primitives/Skeleton.js +3 -12
- package/_cjs/src/components/primitives/Skeleton.js.map +1 -1
- package/_cjs/src/components/primitives/SlippageButton.js +1 -13
- package/_cjs/src/components/primitives/SlippageButton.js.map +1 -1
- package/_cjs/src/components/primitives/Switch.js +5 -43
- package/_cjs/src/components/primitives/Switch.js.map +1 -1
- package/_cjs/src/components/primitives/Tabs.js +9 -39
- package/_cjs/src/components/primitives/Tabs.js.map +1 -1
- package/_cjs/src/components/primitives/Text.js +36 -94
- package/_cjs/src/components/primitives/Text.js.map +1 -1
- package/_cjs/src/components/primitives/Tooltip.js +2 -30
- package/_cjs/src/components/primitives/Tooltip.js.map +1 -1
- package/_cjs/src/components/widgets/FeeBreakdown.js +25 -82
- package/_cjs/src/components/widgets/FeeBreakdown.js.map +1 -1
- package/_cjs/src/components/widgets/FetchingQuoteLoader.js +3 -9
- package/_cjs/src/components/widgets/FetchingQuoteLoader.js.map +1 -1
- package/_cjs/src/components/widgets/OnrampWidget/modals/OnrampModal.js +1 -8
- package/_cjs/src/components/widgets/OnrampWidget/modals/OnrampModal.js.map +1 -1
- package/_cjs/src/components/widgets/OnrampWidget/modals/steps/OnrampConfirmingStep.js +2 -19
- package/_cjs/src/components/widgets/OnrampWidget/modals/steps/OnrampConfirmingStep.js.map +1 -1
- package/_cjs/src/components/widgets/OnrampWidget/modals/steps/OnrampMoonPayStep.js +3 -27
- package/_cjs/src/components/widgets/OnrampWidget/modals/steps/OnrampMoonPayStep.js.map +1 -1
- package/_cjs/src/components/widgets/OnrampWidget/modals/steps/OnrampProcessingPassthroughStep.js +2 -32
- package/_cjs/src/components/widgets/OnrampWidget/modals/steps/OnrampProcessingPassthroughStep.js.map +1 -1
- package/_cjs/src/components/widgets/OnrampWidget/modals/steps/OnrampProcessingStepUI.js +9 -45
- package/_cjs/src/components/widgets/OnrampWidget/modals/steps/OnrampProcessingStepUI.js.map +1 -1
- package/_cjs/src/components/widgets/OnrampWidget/modals/steps/OnrampSuccessStep.js +5 -26
- package/_cjs/src/components/widgets/OnrampWidget/modals/steps/OnrampSuccessStep.js.map +1 -1
- package/_cjs/src/components/widgets/OnrampWidget/widget/FiatCurrencyModal.js +7 -96
- package/_cjs/src/components/widgets/OnrampWidget/widget/FiatCurrencyModal.js.map +1 -1
- package/_cjs/src/components/widgets/OnrampWidget/widget/index.js +18 -112
- package/_cjs/src/components/widgets/OnrampWidget/widget/index.js.map +1 -1
- package/_cjs/src/components/widgets/PriceImpactTooltip.js +3 -9
- package/_cjs/src/components/widgets/PriceImpactTooltip.js.map +1 -1
- package/_cjs/src/components/widgets/SwapButton.js +3 -14
- package/_cjs/src/components/widgets/SwapButton.js.map +1 -1
- package/_cjs/src/components/widgets/SwapWidget/GasTopUpSection.js +6 -11
- package/_cjs/src/components/widgets/SwapWidget/GasTopUpSection.js.map +1 -1
- package/_cjs/src/components/widgets/SwapWidget/PriceImpact.js +2 -4
- package/_cjs/src/components/widgets/SwapWidget/PriceImpact.js.map +1 -1
- package/_cjs/src/components/widgets/SwapWidget/index.js +35 -136
- package/_cjs/src/components/widgets/SwapWidget/index.js.map +1 -1
- package/_cjs/src/components/widgets/TokenSelectorContainer.js +3 -13
- package/_cjs/src/components/widgets/TokenSelectorContainer.js.map +1 -1
- package/_cjs/src/components/widgets/WidgetErrorWell.js +10 -76
- package/_cjs/src/components/widgets/WidgetErrorWell.js.map +1 -1
- package/_cjs/src/providers/RelayKitProvider.js +1 -0
- package/_cjs/src/providers/RelayKitProvider.js.map +1 -1
- package/_cjs/src/styles.css +3 -3717
- package/_cjs/src/themes/RelayKitTheme.js.map +1 -1
- package/_cjs/src/utils/cn.js +13 -0
- package/_cjs/src/utils/cn.js.map +1 -0
- package/_cjs/src/utils/theme.js +13 -1
- package/_cjs/src/utils/theme.js.map +1 -1
- package/_cjs/src/version.js +1 -1
- package/_cjs/tsconfig.build.tsbuildinfo +1 -1
- package/_esm/package.json +1 -1
- package/_esm/src/components/common/AmountInput.js +2 -17
- package/_esm/src/components/common/AmountInput.js.map +1 -1
- package/_esm/src/components/common/BalanceDisplay.js +2 -2
- package/_esm/src/components/common/BalanceDisplay.js.map +1 -1
- package/_esm/src/components/common/CopyToClipBoard.js +3 -7
- package/_esm/src/components/common/CopyToClipBoard.js.map +1 -1
- package/_esm/src/components/common/CustomAddressModal.js +10 -48
- package/_esm/src/components/common/CustomAddressModal.js.map +1 -1
- package/_esm/src/components/common/ErrorWell.js +9 -29
- package/_esm/src/components/common/ErrorWell.js.map +1 -1
- package/_esm/src/components/common/LoadingSpinner.js +7 -13
- package/_esm/src/components/common/LoadingSpinner.js.map +1 -1
- package/_esm/src/components/common/Modal.js +4 -22
- package/_esm/src/components/common/Modal.js.map +1 -1
- package/_esm/src/components/common/MultiWalletDropdown.js +22 -56
- package/_esm/src/components/common/MultiWalletDropdown.js.map +1 -1
- package/_esm/src/components/common/PercentageButtons.js +7 -24
- package/_esm/src/components/common/PercentageButtons.js.map +1 -1
- package/_esm/src/components/common/SlippageToleranceConfig.js +21 -117
- package/_esm/src/components/common/SlippageToleranceConfig.js.map +1 -1
- package/_esm/src/components/common/StepIcon.js +1 -7
- package/_esm/src/components/common/StepIcon.js.map +1 -1
- package/_esm/src/components/common/TokenSelector/ChainFilter.js +19 -109
- package/_esm/src/components/common/TokenSelector/ChainFilter.js.map +1 -1
- package/_esm/src/components/common/TokenSelector/ChainFilterRow.js +10 -54
- package/_esm/src/components/common/TokenSelector/ChainFilterRow.js.map +1 -1
- package/_esm/src/components/common/TokenSelector/ChainFilterSidebar.js +15 -98
- package/_esm/src/components/common/TokenSelector/ChainFilterSidebar.js.map +1 -1
- package/_esm/src/components/common/TokenSelector/ChainShortcuts.js +6 -28
- package/_esm/src/components/common/TokenSelector/ChainShortcuts.js.map +1 -1
- package/_esm/src/components/common/TokenSelector/CompactChainFilter.js +12 -83
- package/_esm/src/components/common/TokenSelector/CompactChainFilter.js.map +1 -1
- package/_esm/src/components/common/TokenSelector/MobileChainSelector.js +16 -109
- package/_esm/src/components/common/TokenSelector/MobileChainSelector.js.map +1 -1
- package/_esm/src/components/common/TokenSelector/PaymentMethod.js +10 -101
- package/_esm/src/components/common/TokenSelector/PaymentMethod.js.map +1 -1
- package/_esm/src/components/common/TokenSelector/PaymentTokenList.js +8 -69
- package/_esm/src/components/common/TokenSelector/PaymentTokenList.js.map +1 -1
- package/_esm/src/components/common/TokenSelector/SuggestedTokens.js +2 -33
- package/_esm/src/components/common/TokenSelector/SuggestedTokens.js.map +1 -1
- package/_esm/src/components/common/TokenSelector/TagPill.js +1 -9
- package/_esm/src/components/common/TokenSelector/TagPill.js.map +1 -1
- package/_esm/src/components/common/TokenSelector/TokenList.js +9 -57
- package/_esm/src/components/common/TokenSelector/TokenList.js.map +1 -1
- package/_esm/src/components/common/TokenSelector/TokenSelector.js +24 -70
- package/_esm/src/components/common/TokenSelector/TokenSelector.js.map +1 -1
- package/_esm/src/components/common/TokenSelector/triggers/PaymentMethodTrigger.js +2 -35
- package/_esm/src/components/common/TokenSelector/triggers/PaymentMethodTrigger.js.map +1 -1
- package/_esm/src/components/common/TokenSelector/triggers/TokenTrigger.js +2 -28
- package/_esm/src/components/common/TokenSelector/triggers/TokenTrigger.js.map +1 -1
- package/_esm/src/components/common/TransactionModal/DepositAddressModal.js +2 -10
- package/_esm/src/components/common/TransactionModal/DepositAddressModal.js.map +1 -1
- package/_esm/src/components/common/TransactionModal/TransactionModal.js +2 -13
- package/_esm/src/components/common/TransactionModal/TransactionModal.js.map +1 -1
- package/_esm/src/components/common/TransactionModal/steps/ApprovalPlusSwapStep.js +8 -45
- package/_esm/src/components/common/TransactionModal/steps/ApprovalPlusSwapStep.js.map +1 -1
- package/_esm/src/components/common/TransactionModal/steps/DepositAddressValidatingStep.js +1 -5
- package/_esm/src/components/common/TransactionModal/steps/DepositAddressValidatingStep.js.map +1 -1
- package/_esm/src/components/common/TransactionModal/steps/ErrorStep.js +9 -30
- package/_esm/src/components/common/TransactionModal/steps/ErrorStep.js.map +1 -1
- package/_esm/src/components/common/TransactionModal/steps/SwapConfirmationStep.js +26 -81
- package/_esm/src/components/common/TransactionModal/steps/SwapConfirmationStep.js.map +1 -1
- package/_esm/src/components/common/TransactionModal/steps/SwapSuccessStep.js +16 -76
- package/_esm/src/components/common/TransactionModal/steps/SwapSuccessStep.js.map +1 -1
- package/_esm/src/components/common/TransactionModal/steps/TransactionsByChain.js +3 -8
- package/_esm/src/components/common/TransactionModal/steps/TransactionsByChain.js.map +1 -1
- package/_esm/src/components/common/TransactionModal/steps/WaitingForDepositStep.js +28 -63
- package/_esm/src/components/common/TransactionModal/steps/WaitingForDepositStep.js.map +1 -1
- package/_esm/src/components/common/UnverifiedTokenModal.js +6 -32
- package/_esm/src/components/common/UnverifiedTokenModal.js.map +1 -1
- package/_esm/src/components/primitives/AccessibleList.js +5 -21
- package/_esm/src/components/primitives/AccessibleList.js.map +1 -1
- package/_esm/src/components/primitives/Anchor.js +18 -41
- package/_esm/src/components/primitives/Anchor.js.map +1 -1
- package/_esm/src/components/primitives/Box.js +3 -4
- package/_esm/src/components/primitives/Box.js.map +1 -1
- package/_esm/src/components/primitives/Button.js +63 -124
- package/_esm/src/components/primitives/Button.js.map +1 -1
- package/_esm/src/components/primitives/ChainIcon.js +5 -9
- package/_esm/src/components/primitives/ChainIcon.js.map +1 -1
- package/_esm/src/components/primitives/ChainTokenIcon.js +7 -26
- package/_esm/src/components/primitives/ChainTokenIcon.js.map +1 -1
- package/_esm/src/components/primitives/Collapsible.js +7 -32
- package/_esm/src/components/primitives/Collapsible.js.map +1 -1
- package/_esm/src/components/primitives/Dialog.js +39 -81
- package/_esm/src/components/primitives/Dialog.js.map +1 -1
- package/_esm/src/components/primitives/Dropdown.js +5 -35
- package/_esm/src/components/primitives/Dropdown.js.map +1 -1
- package/_esm/src/components/primitives/Flex.js +22 -58
- package/_esm/src/components/primitives/Flex.js.map +1 -1
- package/_esm/src/components/primitives/Input.js +19 -50
- package/_esm/src/components/primitives/Input.js.map +1 -1
- package/_esm/src/components/primitives/Pill.js +17 -48
- package/_esm/src/components/primitives/Pill.js.map +1 -1
- package/_esm/src/components/primitives/Skeleton.js +3 -12
- package/_esm/src/components/primitives/Skeleton.js.map +1 -1
- package/_esm/src/components/primitives/SlippageButton.js +1 -13
- package/_esm/src/components/primitives/SlippageButton.js.map +1 -1
- package/_esm/src/components/primitives/Switch.js +5 -43
- package/_esm/src/components/primitives/Switch.js.map +1 -1
- package/_esm/src/components/primitives/Tabs.js +9 -39
- package/_esm/src/components/primitives/Tabs.js.map +1 -1
- package/_esm/src/components/primitives/Text.js +36 -94
- package/_esm/src/components/primitives/Text.js.map +1 -1
- package/_esm/src/components/primitives/Tooltip.js +3 -30
- package/_esm/src/components/primitives/Tooltip.js.map +1 -1
- package/_esm/src/components/widgets/FeeBreakdown.js +24 -81
- package/_esm/src/components/widgets/FeeBreakdown.js.map +1 -1
- package/_esm/src/components/widgets/FetchingQuoteLoader.js +3 -9
- package/_esm/src/components/widgets/FetchingQuoteLoader.js.map +1 -1
- package/_esm/src/components/widgets/OnrampWidget/modals/OnrampModal.js +1 -8
- package/_esm/src/components/widgets/OnrampWidget/modals/OnrampModal.js.map +1 -1
- package/_esm/src/components/widgets/OnrampWidget/modals/steps/OnrampConfirmingStep.js +3 -20
- package/_esm/src/components/widgets/OnrampWidget/modals/steps/OnrampConfirmingStep.js.map +1 -1
- package/_esm/src/components/widgets/OnrampWidget/modals/steps/OnrampMoonPayStep.js +4 -28
- package/_esm/src/components/widgets/OnrampWidget/modals/steps/OnrampMoonPayStep.js.map +1 -1
- package/_esm/src/components/widgets/OnrampWidget/modals/steps/OnrampProcessingPassthroughStep.js +3 -33
- package/_esm/src/components/widgets/OnrampWidget/modals/steps/OnrampProcessingPassthroughStep.js.map +1 -1
- package/_esm/src/components/widgets/OnrampWidget/modals/steps/OnrampProcessingStepUI.js +9 -45
- package/_esm/src/components/widgets/OnrampWidget/modals/steps/OnrampProcessingStepUI.js.map +1 -1
- package/_esm/src/components/widgets/OnrampWidget/modals/steps/OnrampSuccessStep.js +5 -26
- package/_esm/src/components/widgets/OnrampWidget/modals/steps/OnrampSuccessStep.js.map +1 -1
- package/_esm/src/components/widgets/OnrampWidget/widget/FiatCurrencyModal.js +7 -96
- package/_esm/src/components/widgets/OnrampWidget/widget/FiatCurrencyModal.js.map +1 -1
- package/_esm/src/components/widgets/OnrampWidget/widget/index.js +18 -112
- package/_esm/src/components/widgets/OnrampWidget/widget/index.js.map +1 -1
- package/_esm/src/components/widgets/PriceImpactTooltip.js +4 -10
- package/_esm/src/components/widgets/PriceImpactTooltip.js.map +1 -1
- package/_esm/src/components/widgets/SwapButton.js +3 -14
- package/_esm/src/components/widgets/SwapButton.js.map +1 -1
- package/_esm/src/components/widgets/SwapWidget/GasTopUpSection.js +5 -10
- package/_esm/src/components/widgets/SwapWidget/GasTopUpSection.js.map +1 -1
- package/_esm/src/components/widgets/SwapWidget/PriceImpact.js +2 -4
- package/_esm/src/components/widgets/SwapWidget/PriceImpact.js.map +1 -1
- package/_esm/src/components/widgets/SwapWidget/index.js +35 -136
- package/_esm/src/components/widgets/SwapWidget/index.js.map +1 -1
- package/_esm/src/components/widgets/TokenSelectorContainer.js +3 -14
- package/_esm/src/components/widgets/TokenSelectorContainer.js.map +1 -1
- package/_esm/src/components/widgets/WidgetErrorWell.js +14 -80
- package/_esm/src/components/widgets/WidgetErrorWell.js.map +1 -1
- package/_esm/src/providers/RelayKitProvider.js +1 -0
- package/_esm/src/providers/RelayKitProvider.js.map +1 -1
- package/_esm/src/styles.css +3 -3717
- package/_esm/src/themes/RelayKitTheme.js.map +1 -1
- package/_esm/src/utils/cn.js +9 -0
- package/_esm/src/utils/cn.js.map +1 -0
- package/_esm/src/utils/theme.js +15 -1
- package/_esm/src/utils/theme.js.map +1 -1
- package/_esm/src/version.js +1 -1
- package/_esm/tsconfig.build.tsbuildinfo +1 -1
- package/_types/src/components/common/AmountInput.d.ts.map +1 -1
- package/_types/src/components/common/CopyToClipBoard.d.ts.map +1 -1
- package/_types/src/components/common/CustomAddressModal.d.ts.map +1 -1
- package/_types/src/components/common/ErrorWell.d.ts.map +1 -1
- package/_types/src/components/common/LoadingSpinner.d.ts +1 -2
- package/_types/src/components/common/LoadingSpinner.d.ts.map +1 -1
- package/_types/src/components/common/Modal.d.ts +3 -3
- package/_types/src/components/common/Modal.d.ts.map +1 -1
- package/_types/src/components/common/MultiWalletDropdown.d.ts.map +1 -1
- package/_types/src/components/common/PercentageButtons.d.ts +1 -1
- package/_types/src/components/common/PercentageButtons.d.ts.map +1 -1
- package/_types/src/components/common/SlippageToleranceConfig.d.ts +0 -1
- package/_types/src/components/common/SlippageToleranceConfig.d.ts.map +1 -1
- package/_types/src/components/common/StepIcon.d.ts.map +1 -1
- package/_types/src/components/common/TokenSelector/ChainFilter.d.ts.map +1 -1
- package/_types/src/components/common/TokenSelector/ChainFilterRow.d.ts.map +1 -1
- package/_types/src/components/common/TokenSelector/ChainFilterSidebar.d.ts.map +1 -1
- package/_types/src/components/common/TokenSelector/ChainShortcuts.d.ts.map +1 -1
- package/_types/src/components/common/TokenSelector/CompactChainFilter.d.ts.map +1 -1
- package/_types/src/components/common/TokenSelector/MobileChainSelector.d.ts.map +1 -1
- package/_types/src/components/common/TokenSelector/PaymentMethod.d.ts.map +1 -1
- package/_types/src/components/common/TokenSelector/PaymentTokenList.d.ts.map +1 -1
- package/_types/src/components/common/TokenSelector/SuggestedTokens.d.ts.map +1 -1
- package/_types/src/components/common/TokenSelector/TagPill.d.ts.map +1 -1
- package/_types/src/components/common/TokenSelector/TokenList.d.ts.map +1 -1
- package/_types/src/components/common/TokenSelector/TokenSelector.d.ts.map +1 -1
- package/_types/src/components/common/TokenSelector/triggers/PaymentMethodTrigger.d.ts.map +1 -1
- package/_types/src/components/common/TokenSelector/triggers/TokenTrigger.d.ts.map +1 -1
- package/_types/src/components/common/TransactionModal/steps/ApprovalPlusSwapStep.d.ts.map +1 -1
- package/_types/src/components/common/TransactionModal/steps/DepositAddressValidatingStep.d.ts.map +1 -1
- package/_types/src/components/common/TransactionModal/steps/ErrorStep.d.ts.map +1 -1
- package/_types/src/components/common/TransactionModal/steps/SwapConfirmationStep.d.ts.map +1 -1
- package/_types/src/components/common/TransactionModal/steps/SwapSuccessStep.d.ts.map +1 -1
- package/_types/src/components/common/TransactionModal/steps/TransactionsByChain.d.ts.map +1 -1
- package/_types/src/components/common/TransactionModal/steps/WaitingForDepositStep.d.ts.map +1 -1
- package/_types/src/components/common/UnverifiedTokenModal.d.ts.map +1 -1
- package/_types/src/components/primitives/AccessibleList.d.ts +2 -3
- package/_types/src/components/primitives/AccessibleList.d.ts.map +1 -1
- package/_types/src/components/primitives/Anchor.d.ts +10 -39
- package/_types/src/components/primitives/Anchor.d.ts.map +1 -1
- package/_types/src/components/primitives/Box.d.ts +2 -5
- package/_types/src/components/primitives/Box.d.ts.map +1 -1
- package/_types/src/components/primitives/Button.d.ts +11 -8
- package/_types/src/components/primitives/Button.d.ts.map +1 -1
- package/_types/src/components/primitives/ChainIcon.d.ts +1 -2
- package/_types/src/components/primitives/ChainIcon.d.ts.map +1 -1
- package/_types/src/components/primitives/ChainTokenIcon.d.ts +1 -2
- package/_types/src/components/primitives/ChainTokenIcon.d.ts.map +1 -1
- package/_types/src/components/primitives/Collapsible.d.ts +3 -4
- package/_types/src/components/primitives/Collapsible.d.ts.map +1 -1
- package/_types/src/components/primitives/Dialog.d.ts +2 -3
- package/_types/src/components/primitives/Dialog.d.ts.map +1 -1
- package/_types/src/components/primitives/Dropdown.d.ts +2 -3
- package/_types/src/components/primitives/Dropdown.d.ts.map +1 -1
- package/_types/src/components/primitives/Flex.d.ts +10 -65
- package/_types/src/components/primitives/Flex.d.ts.map +1 -1
- package/_types/src/components/primitives/Input.d.ts +10 -8
- package/_types/src/components/primitives/Input.d.ts.map +1 -1
- package/_types/src/components/primitives/Pill.d.ts +9 -50
- package/_types/src/components/primitives/Pill.d.ts.map +1 -1
- package/_types/src/components/primitives/Skeleton.d.ts +1 -2
- package/_types/src/components/primitives/Skeleton.d.ts.map +1 -1
- package/_types/src/components/primitives/SlippageButton.d.ts.map +1 -1
- package/_types/src/components/primitives/Switch.d.ts +2 -3
- package/_types/src/components/primitives/Switch.d.ts.map +1 -1
- package/_types/src/components/primitives/Tabs.d.ts +4 -5
- package/_types/src/components/primitives/Tabs.d.ts.map +1 -1
- package/_types/src/components/primitives/Text.d.ts +10 -100
- package/_types/src/components/primitives/Text.d.ts.map +1 -1
- package/_types/src/components/primitives/Tooltip.d.ts.map +1 -1
- package/_types/src/components/widgets/FeeBreakdown.d.ts.map +1 -1
- package/_types/src/components/widgets/FetchingQuoteLoader.d.ts +1 -2
- package/_types/src/components/widgets/FetchingQuoteLoader.d.ts.map +1 -1
- package/_types/src/components/widgets/OnrampWidget/modals/OnrampModal.d.ts.map +1 -1
- package/_types/src/components/widgets/OnrampWidget/modals/steps/OnrampConfirmingStep.d.ts.map +1 -1
- package/_types/src/components/widgets/OnrampWidget/modals/steps/OnrampMoonPayStep.d.ts.map +1 -1
- package/_types/src/components/widgets/OnrampWidget/modals/steps/OnrampProcessingPassthroughStep.d.ts.map +1 -1
- package/_types/src/components/widgets/OnrampWidget/modals/steps/OnrampProcessingStepUI.d.ts.map +1 -1
- package/_types/src/components/widgets/OnrampWidget/modals/steps/OnrampSuccessStep.d.ts.map +1 -1
- package/_types/src/components/widgets/OnrampWidget/widget/FiatCurrencyModal.d.ts.map +1 -1
- package/_types/src/components/widgets/OnrampWidget/widget/index.d.ts.map +1 -1
- package/_types/src/components/widgets/PriceImpactTooltip.d.ts.map +1 -1
- package/_types/src/components/widgets/SwapButton.d.ts.map +1 -1
- package/_types/src/components/widgets/SwapWidget/GasTopUpSection.d.ts.map +1 -1
- package/_types/src/components/widgets/SwapWidget/PriceImpact.d.ts.map +1 -1
- package/_types/src/components/widgets/SwapWidget/index.d.ts.map +1 -1
- package/_types/src/components/widgets/TokenSelectorContainer.d.ts +1 -2
- package/_types/src/components/widgets/TokenSelectorContainer.d.ts.map +1 -1
- package/_types/src/components/widgets/WidgetErrorWell.d.ts +1 -2
- package/_types/src/components/widgets/WidgetErrorWell.d.ts.map +1 -1
- package/_types/src/providers/RelayKitProvider.d.ts.map +1 -1
- package/_types/src/themes/RelayKitTheme.d.ts +1 -0
- package/_types/src/themes/RelayKitTheme.d.ts.map +1 -1
- package/_types/src/utils/cn.d.ts +3 -0
- package/_types/src/utils/cn.d.ts.map +1 -0
- package/_types/src/utils/theme.d.ts.map +1 -1
- package/_types/src/version.d.ts +1 -1
- package/_types/tsconfig.build.tsbuildinfo +1 -1
- package/dist/styles.css +3 -3717
- package/package.json +20 -19
- package/_cjs/src/components/widgets/TokenWidget/AmountModeToggle.js +0 -31
- package/_cjs/src/components/widgets/TokenWidget/AmountModeToggle.js.map +0 -1
- package/_cjs/src/components/widgets/TokenWidget/AmountSectionHeader.js +0 -8
- package/_cjs/src/components/widgets/TokenWidget/AmountSectionHeader.js.map +0 -1
- package/_cjs/src/components/widgets/TokenWidget/BuyTabContent.js +0 -214
- package/_cjs/src/components/widgets/TokenWidget/BuyTabContent.js.map +0 -1
- package/_cjs/src/components/widgets/TokenWidget/DestinationWalletSelector.js +0 -20
- package/_cjs/src/components/widgets/TokenWidget/DestinationWalletSelector.js.map +0 -1
- package/_cjs/src/components/widgets/TokenWidget/FeeBreakdownInfo.js +0 -64
- package/_cjs/src/components/widgets/TokenWidget/FeeBreakdownInfo.js.map +0 -1
- package/_cjs/src/components/widgets/TokenWidget/FeeBreakdownTooltip.js +0 -44
- package/_cjs/src/components/widgets/TokenWidget/FeeBreakdownTooltip.js.map +0 -1
- package/_cjs/src/components/widgets/TokenWidget/SectionContainer.js +0 -25
- package/_cjs/src/components/widgets/TokenWidget/SectionContainer.js.map +0 -1
- package/_cjs/src/components/widgets/TokenWidget/SellTabContent.js +0 -261
- package/_cjs/src/components/widgets/TokenWidget/SellTabContent.js.map +0 -1
- package/_cjs/src/components/widgets/TokenWidget/TransactionDetailsFooter.js +0 -42
- package/_cjs/src/components/widgets/TokenWidget/TransactionDetailsFooter.js.map +0 -1
- package/_cjs/src/components/widgets/TokenWidget/hooks/useWalletGuards.js +0 -108
- package/_cjs/src/components/widgets/TokenWidget/hooks/useWalletGuards.js.map +0 -1
- package/_cjs/src/components/widgets/TokenWidget/index.js +0 -9
- package/_cjs/src/components/widgets/TokenWidget/index.js.map +0 -1
- package/_cjs/src/components/widgets/TokenWidget/widget/TokenWidgetRenderer.js +0 -719
- package/_cjs/src/components/widgets/TokenWidget/widget/TokenWidgetRenderer.js.map +0 -1
- package/_cjs/src/components/widgets/TokenWidget/widget/index.js +0 -1034
- package/_cjs/src/components/widgets/TokenWidget/widget/index.js.map +0 -1
- package/_esm/src/components/widgets/TokenWidget/AmountModeToggle.js +0 -30
- package/_esm/src/components/widgets/TokenWidget/AmountModeToggle.js.map +0 -1
- package/_esm/src/components/widgets/TokenWidget/AmountSectionHeader.js +0 -7
- package/_esm/src/components/widgets/TokenWidget/AmountSectionHeader.js.map +0 -1
- package/_esm/src/components/widgets/TokenWidget/BuyTabContent.js +0 -211
- package/_esm/src/components/widgets/TokenWidget/BuyTabContent.js.map +0 -1
- package/_esm/src/components/widgets/TokenWidget/DestinationWalletSelector.js +0 -16
- package/_esm/src/components/widgets/TokenWidget/DestinationWalletSelector.js.map +0 -1
- package/_esm/src/components/widgets/TokenWidget/FeeBreakdownInfo.js +0 -59
- package/_esm/src/components/widgets/TokenWidget/FeeBreakdownInfo.js.map +0 -1
- package/_esm/src/components/widgets/TokenWidget/FeeBreakdownTooltip.js +0 -43
- package/_esm/src/components/widgets/TokenWidget/FeeBreakdownTooltip.js.map +0 -1
- package/_esm/src/components/widgets/TokenWidget/SectionContainer.js +0 -25
- package/_esm/src/components/widgets/TokenWidget/SectionContainer.js.map +0 -1
- package/_esm/src/components/widgets/TokenWidget/SellTabContent.js +0 -264
- package/_esm/src/components/widgets/TokenWidget/SellTabContent.js.map +0 -1
- package/_esm/src/components/widgets/TokenWidget/TransactionDetailsFooter.js +0 -41
- package/_esm/src/components/widgets/TokenWidget/TransactionDetailsFooter.js.map +0 -1
- package/_esm/src/components/widgets/TokenWidget/hooks/useWalletGuards.js +0 -104
- package/_esm/src/components/widgets/TokenWidget/hooks/useWalletGuards.js.map +0 -1
- package/_esm/src/components/widgets/TokenWidget/index.js +0 -2
- package/_esm/src/components/widgets/TokenWidget/index.js.map +0 -1
- package/_esm/src/components/widgets/TokenWidget/widget/TokenWidgetRenderer.js +0 -742
- package/_esm/src/components/widgets/TokenWidget/widget/TokenWidgetRenderer.js.map +0 -1
- package/_esm/src/components/widgets/TokenWidget/widget/index.js +0 -1100
- package/_esm/src/components/widgets/TokenWidget/widget/index.js.map +0 -1
- package/_types/src/components/widgets/TokenWidget/AmountModeToggle.d.ts +0 -12
- package/_types/src/components/widgets/TokenWidget/AmountModeToggle.d.ts.map +0 -1
- package/_types/src/components/widgets/TokenWidget/AmountSectionHeader.d.ts +0 -11
- package/_types/src/components/widgets/TokenWidget/AmountSectionHeader.d.ts.map +0 -1
- package/_types/src/components/widgets/TokenWidget/BuyTabContent.d.ts +0 -53
- package/_types/src/components/widgets/TokenWidget/BuyTabContent.d.ts.map +0 -1
- package/_types/src/components/widgets/TokenWidget/DestinationWalletSelector.d.ts +0 -17
- package/_types/src/components/widgets/TokenWidget/DestinationWalletSelector.d.ts.map +0 -1
- package/_types/src/components/widgets/TokenWidget/FeeBreakdownInfo.d.ts +0 -16
- package/_types/src/components/widgets/TokenWidget/FeeBreakdownInfo.d.ts.map +0 -1
- package/_types/src/components/widgets/TokenWidget/FeeBreakdownTooltip.d.ts +0 -15
- package/_types/src/components/widgets/TokenWidget/FeeBreakdownTooltip.d.ts.map +0 -1
- package/_types/src/components/widgets/TokenWidget/SectionContainer.d.ts +0 -11
- package/_types/src/components/widgets/TokenWidget/SectionContainer.d.ts.map +0 -1
- package/_types/src/components/widgets/TokenWidget/SellTabContent.d.ts +0 -61
- package/_types/src/components/widgets/TokenWidget/SellTabContent.d.ts.map +0 -1
- package/_types/src/components/widgets/TokenWidget/TransactionDetailsFooter.d.ts +0 -14
- package/_types/src/components/widgets/TokenWidget/TransactionDetailsFooter.d.ts.map +0 -1
- package/_types/src/components/widgets/TokenWidget/hooks/useWalletGuards.d.ts +0 -28
- package/_types/src/components/widgets/TokenWidget/hooks/useWalletGuards.d.ts.map +0 -1
- package/_types/src/components/widgets/TokenWidget/index.d.ts +0 -3
- package/_types/src/components/widgets/TokenWidget/index.d.ts.map +0 -1
- package/_types/src/components/widgets/TokenWidget/widget/TokenWidgetRenderer.d.ts +0 -117
- package/_types/src/components/widgets/TokenWidget/widget/TokenWidgetRenderer.d.ts.map +0 -1
- package/_types/src/components/widgets/TokenWidget/widget/index.d.ts +0 -58
- package/_types/src/components/widgets/TokenWidget/widget/index.d.ts.map +0 -1
- package/dist/panda.buildinfo.json +0 -676
|
@@ -1,719 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
4
|
-
const react_1 = require("react");
|
|
5
|
-
const index_js_1 = require("../../../../hooks/index.js");
|
|
6
|
-
const viem_1 = require("viem");
|
|
7
|
-
const wagmi_1 = require("wagmi");
|
|
8
|
-
const experimental_1 = require("wagmi/experimental");
|
|
9
|
-
const react_query_1 = require("@tanstack/react-query");
|
|
10
|
-
const quote_js_1 = require("../../../../utils/quote.js");
|
|
11
|
-
const relay_kit_hooks_1 = require("@relayprotocol/relay-kit-hooks");
|
|
12
|
-
const events_js_1 = require("../../../../constants/events.js");
|
|
13
|
-
const RelayKitProvider_js_1 = require("../../../../providers/RelayKitProvider.js");
|
|
14
|
-
const address_js_1 = require("../../../../utils/address.js");
|
|
15
|
-
const relay_sdk_1 = require("@relayprotocol/relay-sdk");
|
|
16
|
-
const errors_js_1 = require("../../../../utils/errors.js");
|
|
17
|
-
const useSwapButtonCta_js_1 = require("../../../../hooks/widget/useSwapButtonCta.js");
|
|
18
|
-
const hashing_js_1 = require("../../../../utils/hashing.js");
|
|
19
|
-
const time_js_1 = require("../../../../utils/time.js");
|
|
20
|
-
const lighter_js_1 = require("../../../../utils/lighter.js");
|
|
21
|
-
const tokenPriceQueryOptions = {
|
|
22
|
-
staleTime: 60 * 1000,
|
|
23
|
-
refetchInterval: 30 * 1000,
|
|
24
|
-
refetchOnWindowFocus: false
|
|
25
|
-
};
|
|
26
|
-
const TokenWidgetRenderer = ({ transactionModalOpen, setTransactionModalOpen, depositAddressModalOpen, fromToken: _fromToken, setFromToken: _setFromToken, toToken: _toToken, setToToken: _setToToken, defaultToAddress, defaultAmount, defaultTradeType, slippageTolerance, context, wallet, multiWalletSupportEnabled = false, linkedWallets, supportedWalletVMs, useSecureBaseUrl, children, onAnalyticEvent, onSwapError }) => {
|
|
27
|
-
const [fromToken, setFromToken] = (0, index_js_1.useFallbackState)(_setFromToken ? _fromToken : undefined, _setFromToken
|
|
28
|
-
? [
|
|
29
|
-
_fromToken,
|
|
30
|
-
_setFromToken
|
|
31
|
-
]
|
|
32
|
-
: undefined);
|
|
33
|
-
const [toToken, setToToken] = (0, index_js_1.useFallbackState)(_setToToken ? _toToken : undefined, _setToToken
|
|
34
|
-
? [_toToken, _setToToken]
|
|
35
|
-
: undefined);
|
|
36
|
-
const providerOptionsContext = (0, react_1.useContext)(RelayKitProvider_js_1.ProviderOptionsContext);
|
|
37
|
-
const connectorKeyOverrides = providerOptionsContext.vmConnectorKeyOverrides;
|
|
38
|
-
const relayClient = (0, index_js_1.useRelayClient)();
|
|
39
|
-
const { connector } = (0, wagmi_1.useAccount)();
|
|
40
|
-
const walletClient = (0, wagmi_1.useWalletClient)();
|
|
41
|
-
const [customToAddress, setCustomToAddress] = (0, react_1.useState)(defaultToAddress);
|
|
42
|
-
const [destinationAddressOverride, setDestinationAddressOverride] = (0, react_1.useState)(undefined);
|
|
43
|
-
const [originAddressOverride, setOriginAddressOverride] = (0, react_1.useState)(undefined);
|
|
44
|
-
const [allowUnsupportedOrigin, setAllowUnsupportedOrigin] = (0, react_1.useState)(false);
|
|
45
|
-
const [allowUnsupportedRecipient, setAllowUnsupportedRecipient] = (0, react_1.useState)(false);
|
|
46
|
-
const defaultAddress = (0, index_js_1.useWalletAddress)(wallet, linkedWallets);
|
|
47
|
-
const [tradeType, setTradeType] = (0, react_1.useState)(defaultTradeType ?? 'EXACT_INPUT');
|
|
48
|
-
const queryClient = (0, react_query_1.useQueryClient)();
|
|
49
|
-
const [steps, setSteps] = (0, react_1.useState)(null);
|
|
50
|
-
const [quoteInProgress, setQuoteInProgress] = (0, react_1.useState)(null);
|
|
51
|
-
const [waitingForSteps, setWaitingForSteps] = (0, react_1.useState)(false);
|
|
52
|
-
const [details, setDetails] = (0, react_1.useState)(null);
|
|
53
|
-
const [abortController, setAbortController] = (0, react_1.useState)(null);
|
|
54
|
-
const { value: amountInputValue, debouncedValue: debouncedInputAmountValue, setValue: setAmountInputValue, debouncedControls: debouncedAmountInputControls } = (0, index_js_1.useDebounceState)(!defaultTradeType || defaultTradeType === 'EXACT_INPUT'
|
|
55
|
-
? (defaultAmount ?? '')
|
|
56
|
-
: '', 500);
|
|
57
|
-
const { value: amountOutputValue, debouncedValue: debouncedOutputAmountValue, setValue: setAmountOutputValue, debouncedControls: debouncedAmountOutputControls } = (0, index_js_1.useDebounceState)(defaultTradeType === 'EXPECTED_OUTPUT' ? (defaultAmount ?? '') : '', 500);
|
|
58
|
-
const [swapError, setSwapError] = (0, react_1.useState)(null);
|
|
59
|
-
const toChain = (0, react_1.useMemo)(() => relayClient?.chains?.find((chain) => chain.id === toToken?.chainId), [relayClient?.chains, toToken?.chainId]);
|
|
60
|
-
const fromChain = (0, react_1.useMemo)(() => relayClient?.chains?.find((chain) => chain.id === fromToken?.chainId), [relayClient?.chains, fromToken?.chainId]);
|
|
61
|
-
const fromChainWalletVMSupported = (0, react_1.useMemo)(() => (0, address_js_1.isChainVmTypeSupported)(fromChain?.vmType, supportedWalletVMs) ||
|
|
62
|
-
fromChain?.id === 1337, [fromChain?.vmType, fromChain?.id, supportedWalletVMs]);
|
|
63
|
-
const toChainWalletVMSupported = (0, react_1.useMemo)(() => (0, address_js_1.isChainVmTypeSupported)(toChain?.vmType, supportedWalletVMs), [toChain?.vmType, supportedWalletVMs]);
|
|
64
|
-
const address = (0, react_1.useMemo)(() => {
|
|
65
|
-
if (!multiWalletSupportEnabled || !linkedWallets?.length) {
|
|
66
|
-
return defaultAddress;
|
|
67
|
-
}
|
|
68
|
-
if (originAddressOverride) {
|
|
69
|
-
return originAddressOverride;
|
|
70
|
-
}
|
|
71
|
-
const targetChain = fromChain || toChain;
|
|
72
|
-
if (!targetChain) {
|
|
73
|
-
return defaultAddress;
|
|
74
|
-
}
|
|
75
|
-
const isCompatibleWallet = (wallet) => (0, address_js_1.isWalletVmTypeCompatible)(wallet.vmType, targetChain.vmType) &&
|
|
76
|
-
(0, address_js_1.isValidAddress)(targetChain.vmType, wallet.address, targetChain.id, wallet.connector, connectorKeyOverrides);
|
|
77
|
-
const activeLinkedWallet = linkedWallets.find((wallet) => (0, address_js_1.addressesEqual)(wallet.vmType, wallet.address, defaultAddress));
|
|
78
|
-
if (activeLinkedWallet && isCompatibleWallet(activeLinkedWallet)) {
|
|
79
|
-
return activeLinkedWallet.address;
|
|
80
|
-
}
|
|
81
|
-
const compatibleWallet = linkedWallets.find(isCompatibleWallet);
|
|
82
|
-
return compatibleWallet?.address || defaultAddress;
|
|
83
|
-
}, [
|
|
84
|
-
multiWalletSupportEnabled,
|
|
85
|
-
originAddressOverride,
|
|
86
|
-
fromChain,
|
|
87
|
-
toChain,
|
|
88
|
-
linkedWallets,
|
|
89
|
-
defaultAddress,
|
|
90
|
-
connectorKeyOverrides
|
|
91
|
-
]);
|
|
92
|
-
const defaultRecipient = (0, react_1.useMemo)(() => {
|
|
93
|
-
const _linkedWallet = linkedWallets?.find((linkedWallet) => address ===
|
|
94
|
-
(linkedWallet.vmType === 'evm'
|
|
95
|
-
? linkedWallet.address.toLowerCase()
|
|
96
|
-
: linkedWallet.address));
|
|
97
|
-
const _isValidToAddress = (0, address_js_1.isValidAddress)(toChain?.vmType, customToAddress ?? '', toChain?.id, !customToAddress && _linkedWallet?.address === address
|
|
98
|
-
? _linkedWallet?.connector
|
|
99
|
-
: undefined, connectorKeyOverrides);
|
|
100
|
-
if (multiWalletSupportEnabled &&
|
|
101
|
-
toChain &&
|
|
102
|
-
linkedWallets &&
|
|
103
|
-
!_isValidToAddress) {
|
|
104
|
-
const supportedWallet = linkedWallets.find((wallet) => wallet.address !== address &&
|
|
105
|
-
(0, address_js_1.isValidAddress)(toChain.vmType, wallet.address, toChain.id, wallet.connector, connectorKeyOverrides));
|
|
106
|
-
return supportedWallet?.address;
|
|
107
|
-
}
|
|
108
|
-
return undefined;
|
|
109
|
-
}, [
|
|
110
|
-
multiWalletSupportEnabled,
|
|
111
|
-
toChain,
|
|
112
|
-
customToAddress,
|
|
113
|
-
address,
|
|
114
|
-
linkedWallets,
|
|
115
|
-
setCustomToAddress,
|
|
116
|
-
connectorKeyOverrides
|
|
117
|
-
]);
|
|
118
|
-
const recipient = destinationAddressOverride ??
|
|
119
|
-
customToAddress ??
|
|
120
|
-
defaultRecipient ??
|
|
121
|
-
(!allowUnsupportedRecipient && address ? address : undefined);
|
|
122
|
-
const { value: fromBalance, queryKey: fromBalanceQueryKey, isLoading: isLoadingFromBalance, isError: fromBalanceErrorFetching, isDuneBalance: fromBalanceIsDune, hasPendingBalance: fromBalancePending } = (0, index_js_1.useCurrencyBalance)({
|
|
123
|
-
chain: fromChain,
|
|
124
|
-
address: address,
|
|
125
|
-
currency: fromToken?.address ? fromToken.address : undefined,
|
|
126
|
-
enabled: fromToken !== undefined,
|
|
127
|
-
refreshInterval: undefined,
|
|
128
|
-
wallet
|
|
129
|
-
});
|
|
130
|
-
const { value: toBalance, queryKey: toBalanceQueryKey, isLoading: isLoadingToBalance, isDuneBalance: toBalanceIsDune, hasPendingBalance: toBalancePending } = (0, index_js_1.useCurrencyBalance)({
|
|
131
|
-
chain: toChain,
|
|
132
|
-
address: recipient,
|
|
133
|
-
currency: toToken?.address ? toToken.address : undefined,
|
|
134
|
-
enabled: toToken !== undefined && recipient !== undefined && recipient !== '',
|
|
135
|
-
refreshInterval: undefined,
|
|
136
|
-
wallet
|
|
137
|
-
});
|
|
138
|
-
const invalidateBalanceQueries = (0, react_1.useCallback)(() => {
|
|
139
|
-
const invalidatePeriodically = (invalidateFn) => {
|
|
140
|
-
let maxRefreshes = 4;
|
|
141
|
-
let refreshCount = 0;
|
|
142
|
-
const timer = setInterval(() => {
|
|
143
|
-
if (maxRefreshes === refreshCount) {
|
|
144
|
-
clearInterval(timer);
|
|
145
|
-
return;
|
|
146
|
-
}
|
|
147
|
-
refreshCount++;
|
|
148
|
-
invalidateFn();
|
|
149
|
-
}, 3000);
|
|
150
|
-
};
|
|
151
|
-
queryClient.invalidateQueries({ queryKey: ['useDuneBalances'] });
|
|
152
|
-
if (fromBalanceIsDune) {
|
|
153
|
-
invalidatePeriodically(() => {
|
|
154
|
-
queryClient.invalidateQueries({ queryKey: fromBalanceQueryKey });
|
|
155
|
-
});
|
|
156
|
-
}
|
|
157
|
-
else {
|
|
158
|
-
queryClient.invalidateQueries({ queryKey: fromBalanceQueryKey });
|
|
159
|
-
}
|
|
160
|
-
if (toBalanceIsDune) {
|
|
161
|
-
invalidatePeriodically(() => {
|
|
162
|
-
queryClient.invalidateQueries({ queryKey: toBalanceQueryKey });
|
|
163
|
-
});
|
|
164
|
-
}
|
|
165
|
-
else {
|
|
166
|
-
queryClient.invalidateQueries({ queryKey: toBalanceQueryKey });
|
|
167
|
-
}
|
|
168
|
-
}, [
|
|
169
|
-
queryClient,
|
|
170
|
-
fromBalanceQueryKey,
|
|
171
|
-
toBalanceQueryKey,
|
|
172
|
-
toBalanceIsDune,
|
|
173
|
-
fromBalanceIsDune,
|
|
174
|
-
address
|
|
175
|
-
]);
|
|
176
|
-
const { data: capabilities } = (0, experimental_1.useCapabilities)({
|
|
177
|
-
query: {
|
|
178
|
-
enabled: connector &&
|
|
179
|
-
(connector.id === 'coinbaseWalletSDK' || connector.id === 'coinbase')
|
|
180
|
-
}
|
|
181
|
-
});
|
|
182
|
-
const hasAuxiliaryFundsSupport = Boolean(fromToken?.chainId
|
|
183
|
-
? capabilities?.[fromToken?.chainId]?.auxiliaryFunds?.supported
|
|
184
|
-
: false);
|
|
185
|
-
const isSvmSwap = fromChain?.vmType === 'svm' || toChain?.vmType === 'svm';
|
|
186
|
-
const isBvmSwap = fromChain?.vmType === 'bvm' || toChain?.vmType === 'bvm';
|
|
187
|
-
const linkedWallet = linkedWallets?.find((linkedWallet) => address ===
|
|
188
|
-
(linkedWallet.vmType === 'evm'
|
|
189
|
-
? linkedWallet.address.toLowerCase()
|
|
190
|
-
: linkedWallet.address) || linkedWallet.address === address);
|
|
191
|
-
const isRecipientLinked = (recipient
|
|
192
|
-
? linkedWallets?.find((wallet) => wallet.address === recipient)
|
|
193
|
-
: undefined) !== undefined;
|
|
194
|
-
const isValidFromAddress = (0, react_1.useMemo)(() => (0, address_js_1.isValidAddress)(fromChain?.vmType, address ?? '', fromChain?.id, linkedWallet?.connector, connectorKeyOverrides), [
|
|
195
|
-
fromChain?.vmType,
|
|
196
|
-
address,
|
|
197
|
-
fromChain?.id,
|
|
198
|
-
linkedWallet?.connector,
|
|
199
|
-
connectorKeyOverrides
|
|
200
|
-
]);
|
|
201
|
-
const fromAddressWithFallback = (0, address_js_1.addressWithFallback)(fromChain?.vmType, address, fromChain?.id, linkedWallet?.connector, connectorKeyOverrides);
|
|
202
|
-
const isValidToAddress = (0, react_1.useMemo)(() => (0, address_js_1.isValidAddress)(toChain?.vmType, recipient ?? '', toChain?.id), [toChain?.vmType, recipient, toChain?.id]);
|
|
203
|
-
const toAddressWithFallback = (0, address_js_1.addressWithFallback)(toChain?.vmType, recipient, toChain?.id);
|
|
204
|
-
const { displayName: toDisplayName } = (0, index_js_1.useDisplayName)(recipient, toChain?.vmType, toChain?.id);
|
|
205
|
-
const [currentSlippageTolerance, setCurrentSlippageTolerance] = (0, react_1.useState)(slippageTolerance);
|
|
206
|
-
(0, react_1.useEffect)(() => {
|
|
207
|
-
setCurrentSlippageTolerance(slippageTolerance);
|
|
208
|
-
}, [slippageTolerance]);
|
|
209
|
-
const { data: fromTokenPriceData, isLoading: isLoadingFromTokenPrice } = (0, relay_kit_hooks_1.useTokenPrice)(relayClient?.baseApiUrl, {
|
|
210
|
-
address: fromToken?.address ?? '',
|
|
211
|
-
chainId: fromToken?.chainId ?? 0,
|
|
212
|
-
referrer: relayClient?.source
|
|
213
|
-
}, {
|
|
214
|
-
enabled: !!(fromToken?.address && fromToken.chainId),
|
|
215
|
-
...tokenPriceQueryOptions
|
|
216
|
-
});
|
|
217
|
-
const { data: toTokenPriceData, isLoading: isLoadingToTokenPrice } = (0, relay_kit_hooks_1.useTokenPrice)(relayClient?.baseApiUrl, {
|
|
218
|
-
address: toToken?.address ?? '',
|
|
219
|
-
chainId: toToken?.chainId ?? 0,
|
|
220
|
-
referrer: relayClient?.source
|
|
221
|
-
}, {
|
|
222
|
-
enabled: !!(toToken?.address && toToken.chainId),
|
|
223
|
-
...tokenPriceQueryOptions
|
|
224
|
-
});
|
|
225
|
-
const isFromNative = fromToken?.address === fromChain?.currency?.address;
|
|
226
|
-
const explicitDeposit = (0, index_js_1.useExplicitDeposit)(wallet, fromToken?.chainId, fromChain?.vmType, address);
|
|
227
|
-
const shouldSetQuoteParameters = fromToken && toToken;
|
|
228
|
-
const quoteParameters = shouldSetQuoteParameters
|
|
229
|
-
? {
|
|
230
|
-
user: fromAddressWithFallback,
|
|
231
|
-
originChainId: fromToken.chainId,
|
|
232
|
-
destinationChainId: toToken.chainId,
|
|
233
|
-
originCurrency: fromToken.address,
|
|
234
|
-
destinationCurrency: toToken.address,
|
|
235
|
-
recipient: toAddressWithFallback,
|
|
236
|
-
tradeType,
|
|
237
|
-
appFees: providerOptionsContext.appFees,
|
|
238
|
-
amount: tradeType === 'EXACT_INPUT'
|
|
239
|
-
? (0, viem_1.parseUnits)(debouncedInputAmountValue, fromToken.decimals).toString()
|
|
240
|
-
: (0, viem_1.parseUnits)(debouncedOutputAmountValue, toToken.decimals).toString(),
|
|
241
|
-
referrer: relayClient?.source ?? undefined,
|
|
242
|
-
useDepositAddress: !fromChainWalletVMSupported || fromToken?.chainId === 1337,
|
|
243
|
-
refundTo: fromToken?.chainId === 1337 ? address : undefined,
|
|
244
|
-
slippageTolerance: slippageTolerance,
|
|
245
|
-
...(linkedWallet?.vmType === 'bvm' && wallet?.metadata?.publicKey
|
|
246
|
-
? {
|
|
247
|
-
additionalData: {
|
|
248
|
-
userPublicKey: wallet?.metadata?.publicKey
|
|
249
|
-
}
|
|
250
|
-
}
|
|
251
|
-
: {}),
|
|
252
|
-
...(explicitDeposit !== undefined &&
|
|
253
|
-
fromChain?.vmType === 'evm' && {
|
|
254
|
-
explicitDeposit: explicitDeposit
|
|
255
|
-
})
|
|
256
|
-
}
|
|
257
|
-
: undefined;
|
|
258
|
-
const onQuoteRequested = (options, config) => {
|
|
259
|
-
const interval = (0, time_js_1.get15MinuteInterval)();
|
|
260
|
-
const quoteRequestId = (0, hashing_js_1.sha256)({ ...options, interval });
|
|
261
|
-
onAnalyticEvent?.(events_js_1.EventNames.QUOTE_REQUESTED, {
|
|
262
|
-
parameters: options,
|
|
263
|
-
wallet_connector: linkedWallet?.connector,
|
|
264
|
-
chain_id_in: options?.originChainId,
|
|
265
|
-
chain_id_out: options?.destinationChainId,
|
|
266
|
-
http_config: config,
|
|
267
|
-
quote_request_id: quoteRequestId
|
|
268
|
-
});
|
|
269
|
-
};
|
|
270
|
-
const onQuoteReceived = ({ details, steps }, options) => {
|
|
271
|
-
const interval = (0, time_js_1.get15MinuteInterval)();
|
|
272
|
-
const quoteRequestId = (0, hashing_js_1.sha256)({ ...options, interval });
|
|
273
|
-
onAnalyticEvent?.(events_js_1.EventNames.QUOTE_RECEIVED, {
|
|
274
|
-
parameters: options,
|
|
275
|
-
wallet_connector: linkedWallet?.connector,
|
|
276
|
-
amount_in: details?.currencyIn?.amountFormatted,
|
|
277
|
-
amount_in_raw: details?.currencyIn?.amount,
|
|
278
|
-
currency_in: details?.currencyIn?.currency?.symbol,
|
|
279
|
-
chain_id_in: details?.currencyIn?.currency?.chainId,
|
|
280
|
-
amount_out: details?.currencyOut?.amountFormatted,
|
|
281
|
-
amount_out_raw: details?.currencyOut?.amount,
|
|
282
|
-
currency_out: details?.currencyOut?.currency?.symbol,
|
|
283
|
-
chain_id_out: details?.currencyOut?.currency?.chainId,
|
|
284
|
-
slippage_tolerance_destination_percentage: details?.slippageTolerance?.destination?.percent,
|
|
285
|
-
slippage_tolerance_origin_percentage: details?.slippageTolerance?.origin?.percent,
|
|
286
|
-
steps,
|
|
287
|
-
quote_request_id: quoteRequestId,
|
|
288
|
-
quote_id: steps ? (0, quote_js_1.extractQuoteId)(steps) : undefined
|
|
289
|
-
});
|
|
290
|
-
};
|
|
291
|
-
const quoteFetchingEnabled = Boolean(relayClient &&
|
|
292
|
-
((tradeType === 'EXACT_INPUT' &&
|
|
293
|
-
debouncedInputAmountValue &&
|
|
294
|
-
debouncedInputAmountValue.length > 0 &&
|
|
295
|
-
Number(debouncedInputAmountValue) !== 0) ||
|
|
296
|
-
(tradeType === 'EXPECTED_OUTPUT' &&
|
|
297
|
-
debouncedOutputAmountValue &&
|
|
298
|
-
debouncedOutputAmountValue.length > 0 &&
|
|
299
|
-
Number(debouncedOutputAmountValue) !== 0)) &&
|
|
300
|
-
fromToken !== undefined &&
|
|
301
|
-
toToken !== undefined &&
|
|
302
|
-
!transactionModalOpen &&
|
|
303
|
-
!depositAddressModalOpen);
|
|
304
|
-
const quoteRefetchInterval = !transactionModalOpen &&
|
|
305
|
-
!depositAddressModalOpen &&
|
|
306
|
-
debouncedInputAmountValue === amountInputValue &&
|
|
307
|
-
debouncedOutputAmountValue === amountOutputValue
|
|
308
|
-
? 12000
|
|
309
|
-
: undefined;
|
|
310
|
-
const handleQuoteError = (e) => {
|
|
311
|
-
const errorMessage = (0, errors_js_1.errorToJSON)(e?.response?.data?.message ? new Error(e?.response?.data?.message) : e);
|
|
312
|
-
const interval = (0, time_js_1.get15MinuteInterval)();
|
|
313
|
-
const quoteRequestId = (0, hashing_js_1.sha256)({ ...quoteParameters, interval });
|
|
314
|
-
onAnalyticEvent?.(events_js_1.EventNames.QUOTE_ERROR, {
|
|
315
|
-
wallet_connector: linkedWallet?.connector,
|
|
316
|
-
error_message: errorMessage,
|
|
317
|
-
parameters: quoteParameters,
|
|
318
|
-
quote_request_id: quoteRequestId,
|
|
319
|
-
status_code: e?.response?.status ?? e?.status ?? ''
|
|
320
|
-
});
|
|
321
|
-
};
|
|
322
|
-
const { data: quote, error: quoteError, isFetching: isFetchingQuote, executeQuote: executeSwap, queryKey: quoteQueryKey } = (0, relay_kit_hooks_1.useQuote)(relayClient ? relayClient : undefined, wallet, quoteParameters, onQuoteRequested, onQuoteReceived, {
|
|
323
|
-
refetchOnWindowFocus: false,
|
|
324
|
-
enabled: Boolean(quoteFetchingEnabled && quoteParameters !== undefined),
|
|
325
|
-
refetchInterval: quoteRefetchInterval
|
|
326
|
-
}, handleQuoteError, undefined, useSecureBaseUrl?.(quoteParameters)
|
|
327
|
-
? providerOptionsContext?.secureBaseUrl
|
|
328
|
-
: undefined);
|
|
329
|
-
const invalidateQuoteQuery = (0, react_1.useCallback)(() => {
|
|
330
|
-
queryClient.invalidateQueries({ queryKey: quoteQueryKey });
|
|
331
|
-
}, [queryClient, quoteQueryKey]);
|
|
332
|
-
const derivedError = quote ||
|
|
333
|
-
(isFetchingQuote &&
|
|
334
|
-
Boolean(quoteFetchingEnabled && quoteParameters !== undefined))
|
|
335
|
-
? null
|
|
336
|
-
: quoteError;
|
|
337
|
-
const error = derivedError;
|
|
338
|
-
(0, index_js_1.useDisconnected)(address, () => {
|
|
339
|
-
setCustomToAddress(undefined);
|
|
340
|
-
setOriginAddressOverride(undefined);
|
|
341
|
-
setDestinationAddressOverride(undefined);
|
|
342
|
-
});
|
|
343
|
-
const isLighterChain = toChain?.vmType === 'lvm';
|
|
344
|
-
const { data: connectedLighterAccount } = (0, index_js_1.useLighterAccount)(isLighterChain && address ? address : undefined);
|
|
345
|
-
(0, react_1.useEffect)(() => {
|
|
346
|
-
if (isLighterChain &&
|
|
347
|
-
connectedLighterAccount?.index &&
|
|
348
|
-
(!customToAddress || !(0, lighter_js_1.isLighterAddress)(customToAddress))) {
|
|
349
|
-
setCustomToAddress(connectedLighterAccount.index.toString());
|
|
350
|
-
}
|
|
351
|
-
}, [isLighterChain, connectedLighterAccount, customToAddress]);
|
|
352
|
-
(0, react_1.useEffect)(() => {
|
|
353
|
-
if (tradeType === 'EXACT_INPUT') {
|
|
354
|
-
const amountOut = quote?.details?.currencyOut?.amount ?? '';
|
|
355
|
-
setAmountOutputValue(amountOut !== ''
|
|
356
|
-
? (0, viem_1.formatUnits)(BigInt(amountOut), Number(quote?.details?.currencyOut?.currency?.decimals ?? 18))
|
|
357
|
-
: '');
|
|
358
|
-
}
|
|
359
|
-
else if (tradeType === 'EXPECTED_OUTPUT') {
|
|
360
|
-
const amountIn = quote?.details?.currencyIn?.amount ?? '';
|
|
361
|
-
setAmountInputValue(amountIn !== ''
|
|
362
|
-
? (0, viem_1.formatUnits)(BigInt(amountIn), Number(quote?.details?.currencyIn?.currency?.decimals ?? 18))
|
|
363
|
-
: '');
|
|
364
|
-
}
|
|
365
|
-
debouncedAmountInputControls.flush();
|
|
366
|
-
debouncedAmountOutputControls.flush();
|
|
367
|
-
}, [quote, tradeType]);
|
|
368
|
-
const feeBreakdown = (0, react_1.useMemo)(() => {
|
|
369
|
-
const chains = relayClient?.chains;
|
|
370
|
-
const fromChain = chains?.find((chain) => chain.id === fromToken?.chainId);
|
|
371
|
-
const toChain = chains?.find((chain) => chain.id === toToken?.chainId);
|
|
372
|
-
return fromToken && toToken && fromChain && toChain && quote
|
|
373
|
-
? (0, quote_js_1.parseFees)(toChain, fromChain, quote)
|
|
374
|
-
: null;
|
|
375
|
-
}, [quote, fromToken, toToken, relayClient]);
|
|
376
|
-
const totalAmount = BigInt(quote?.details?.currencyIn?.amount ?? 0n);
|
|
377
|
-
const hasInsufficientBalance = Boolean(!fromBalanceErrorFetching &&
|
|
378
|
-
totalAmount &&
|
|
379
|
-
address &&
|
|
380
|
-
(fromBalance ?? 0n) < totalAmount &&
|
|
381
|
-
!hasAuxiliaryFundsSupport &&
|
|
382
|
-
fromChainWalletVMSupported);
|
|
383
|
-
const fetchQuoteErrorMessage = error
|
|
384
|
-
? error?.message
|
|
385
|
-
? error?.message
|
|
386
|
-
: 'Unknown Error'
|
|
387
|
-
: null;
|
|
388
|
-
const fetchQuoteDataErrorMessage = error
|
|
389
|
-
? error?.response?.data?.message
|
|
390
|
-
? error?.response?.data.message
|
|
391
|
-
: 'Unknown Error'
|
|
392
|
-
: null;
|
|
393
|
-
const isInsufficientLiquidityError = Boolean(fetchQuoteErrorMessage?.includes('No quotes available'));
|
|
394
|
-
const isCapacityExceededError = fetchQuoteDataErrorMessage?.includes('Amount is higher than the available liquidity') || fetchQuoteDataErrorMessage?.includes('Insufficient relayer liquidity');
|
|
395
|
-
const isCouldNotExecuteError = fetchQuoteDataErrorMessage?.includes('Could not execute');
|
|
396
|
-
const highRelayerServiceFee = (0, quote_js_1.isHighRelayerServiceFeeUsd)(quote);
|
|
397
|
-
const relayerFeeProportion = (0, quote_js_1.calculateRelayerFeeProportionUsd)(quote);
|
|
398
|
-
const timeEstimate = (0, quote_js_1.calculatePriceTimeEstimate)(quote?.details);
|
|
399
|
-
const recipientWalletSupportsChain = (0, index_js_1.useIsWalletCompatible)(toChain?.id, recipient, linkedWallets, onAnalyticEvent);
|
|
400
|
-
const isSameCurrencySameRecipientSwap = fromToken?.address === toToken?.address &&
|
|
401
|
-
fromToken?.chainId === toToken?.chainId &&
|
|
402
|
-
address === recipient;
|
|
403
|
-
const ctaCopy = (0, useSwapButtonCta_js_1.useSwapButtonCta)({
|
|
404
|
-
fromToken,
|
|
405
|
-
toToken,
|
|
406
|
-
multiWalletSupportEnabled,
|
|
407
|
-
isValidFromAddress,
|
|
408
|
-
fromChainWalletVMSupported,
|
|
409
|
-
isValidToAddress,
|
|
410
|
-
toChainWalletVMSupported,
|
|
411
|
-
fromChain,
|
|
412
|
-
toChain,
|
|
413
|
-
isSameCurrencySameRecipientSwap,
|
|
414
|
-
debouncedInputAmountValue,
|
|
415
|
-
debouncedOutputAmountValue,
|
|
416
|
-
hasInsufficientBalance,
|
|
417
|
-
isInsufficientLiquidityError,
|
|
418
|
-
quote,
|
|
419
|
-
operation: quote?.details?.operation
|
|
420
|
-
});
|
|
421
|
-
(0, index_js_1.usePreviousValueChange)(isCapacityExceededError, !isFetchingQuote, (capacityExceeded) => {
|
|
422
|
-
if (capacityExceeded) {
|
|
423
|
-
onAnalyticEvent?.(events_js_1.EventNames.CTA_MAX_CAPACITY_PROMPTED, {
|
|
424
|
-
inputAmount: debouncedInputAmountValue,
|
|
425
|
-
outputAmount: debouncedOutputAmountValue
|
|
426
|
-
});
|
|
427
|
-
}
|
|
428
|
-
});
|
|
429
|
-
const swap = (0, react_1.useCallback)(async () => {
|
|
430
|
-
let submittedEvents = [];
|
|
431
|
-
const swapErrorHandler = (error, currentSteps) => {
|
|
432
|
-
const errorMessage = (0, errors_js_1.errorToJSON)(error?.response?.data?.message
|
|
433
|
-
? new Error(error?.response?.data?.message)
|
|
434
|
-
: error);
|
|
435
|
-
if (error &&
|
|
436
|
-
((typeof error.message === 'string' &&
|
|
437
|
-
error.message.includes('rejected')) ||
|
|
438
|
-
(typeof error === 'string' && error.includes('rejected')) ||
|
|
439
|
-
(typeof error === 'string' && error.includes('Approval Denied')) ||
|
|
440
|
-
(typeof error === 'string' && error.includes('denied transaction')) ||
|
|
441
|
-
(typeof error.message === 'string' &&
|
|
442
|
-
error.message.includes('Approval Denied')) ||
|
|
443
|
-
(typeof error.message === 'string' &&
|
|
444
|
-
error.message.includes('Plugin Closed')) ||
|
|
445
|
-
(typeof error.message === 'string' &&
|
|
446
|
-
error.message.includes('denied transaction')) ||
|
|
447
|
-
(typeof error.message === 'string' &&
|
|
448
|
-
error.message.includes('Failed to initialize request') &&
|
|
449
|
-
fromChain?.id === 2741))) {
|
|
450
|
-
setTransactionModalOpen(false);
|
|
451
|
-
onAnalyticEvent?.(events_js_1.EventNames.USER_REJECTED_WALLET, {
|
|
452
|
-
error_message: errorMessage
|
|
453
|
-
});
|
|
454
|
-
return;
|
|
455
|
-
}
|
|
456
|
-
const { step, stepItem } = (0, quote_js_1.getCurrentStep)(currentSteps);
|
|
457
|
-
const swapEventData = {
|
|
458
|
-
...(0, quote_js_1.getSwapEventData)(quote?.details, quote?.fees, currentSteps ?? null, linkedWallet?.connector, quoteParameters),
|
|
459
|
-
error_message: errorMessage
|
|
460
|
-
};
|
|
461
|
-
const isApproval = step?.id === 'approve';
|
|
462
|
-
const errorEvent = isApproval
|
|
463
|
-
? events_js_1.EventNames.APPROVAL_ERROR
|
|
464
|
-
: events_js_1.EventNames.DEPOSIT_ERROR;
|
|
465
|
-
const isTransactionConfirmationError = (error &&
|
|
466
|
-
typeof error.message === 'string' &&
|
|
467
|
-
error.message.includes('TransactionConfirmationError')) ||
|
|
468
|
-
(error.name && error.name.includes('TransactionConfirmationError'));
|
|
469
|
-
if (stepItem?.receipt &&
|
|
470
|
-
stepItem.check &&
|
|
471
|
-
!isTransactionConfirmationError &&
|
|
472
|
-
(typeof stepItem.receipt === 'object' && 'status' in stepItem.receipt
|
|
473
|
-
? stepItem.receipt.status !== 'reverted'
|
|
474
|
-
: true) &&
|
|
475
|
-
(!stepItem.checkStatus || stepItem.checkStatus !== 'unknown')) {
|
|
476
|
-
const successEvent = isApproval
|
|
477
|
-
? events_js_1.EventNames.APPROVAL_SUCCESS
|
|
478
|
-
: events_js_1.EventNames.DEPOSIT_SUCCESS;
|
|
479
|
-
if (!submittedEvents.includes(successEvent)) {
|
|
480
|
-
onAnalyticEvent?.(successEvent, swapEventData);
|
|
481
|
-
submittedEvents.push(successEvent);
|
|
482
|
-
setTimeout(() => {
|
|
483
|
-
onAnalyticEvent?.(events_js_1.EventNames.FILL_ERROR, swapEventData);
|
|
484
|
-
}, 20);
|
|
485
|
-
}
|
|
486
|
-
else {
|
|
487
|
-
onAnalyticEvent?.(events_js_1.EventNames.FILL_ERROR, swapEventData);
|
|
488
|
-
}
|
|
489
|
-
}
|
|
490
|
-
else if (!stepItem?.receipt ||
|
|
491
|
-
(typeof stepItem.receipt === 'object' &&
|
|
492
|
-
'status' in stepItem.receipt &&
|
|
493
|
-
stepItem.receipt.status === 'reverted')) {
|
|
494
|
-
onAnalyticEvent?.(errorEvent, swapEventData);
|
|
495
|
-
}
|
|
496
|
-
else {
|
|
497
|
-
onAnalyticEvent?.(events_js_1.EventNames.SWAP_ERROR, swapEventData);
|
|
498
|
-
}
|
|
499
|
-
setSwapError(errorMessage);
|
|
500
|
-
onSwapError?.(errorMessage, { ...quote, steps: currentSteps });
|
|
501
|
-
};
|
|
502
|
-
try {
|
|
503
|
-
const swapEventData = (0, quote_js_1.getSwapEventData)(quote?.details, quote?.fees, quote?.steps ? quote?.steps : null, linkedWallet?.connector, quoteParameters);
|
|
504
|
-
onAnalyticEvent?.(events_js_1.EventNames.SWAP_CTA_CLICKED, swapEventData);
|
|
505
|
-
setWaitingForSteps(true);
|
|
506
|
-
if (!executeSwap) {
|
|
507
|
-
throw new Error('Missing a quote');
|
|
508
|
-
}
|
|
509
|
-
if (!wallet && !walletClient.data) {
|
|
510
|
-
throw new Error('Missing a wallet');
|
|
511
|
-
}
|
|
512
|
-
setSteps(quote?.steps);
|
|
513
|
-
setQuoteInProgress(quote);
|
|
514
|
-
setTransactionModalOpen(true);
|
|
515
|
-
const _wallet = wallet ?? (0, relay_sdk_1.adaptViemWallet)(walletClient.data);
|
|
516
|
-
const activeWalletChainId = await _wallet?.getChainId();
|
|
517
|
-
const activeWalletChain = relayClient?.chains?.find((chain) => chain.id === activeWalletChainId);
|
|
518
|
-
let targetChainId = fromToken?.chainId;
|
|
519
|
-
if (fromToken?.chainId === 1337) {
|
|
520
|
-
targetChainId =
|
|
521
|
-
activeWalletChain?.vmType !== 'evm' ? 1 : activeWalletChainId;
|
|
522
|
-
}
|
|
523
|
-
if (fromToken && targetChainId && targetChainId !== activeWalletChainId) {
|
|
524
|
-
onAnalyticEvent?.(events_js_1.EventNames.SWAP_SWITCH_NETWORK, {
|
|
525
|
-
activeWalletChainId,
|
|
526
|
-
...swapEventData
|
|
527
|
-
});
|
|
528
|
-
await _wallet?.switchChain(targetChainId);
|
|
529
|
-
}
|
|
530
|
-
let _currentSteps = undefined;
|
|
531
|
-
const execPromise = executeSwap(({ steps: currentSteps }) => {
|
|
532
|
-
setSteps(currentSteps);
|
|
533
|
-
_currentSteps = currentSteps;
|
|
534
|
-
const { step, stepItem } = (0, quote_js_1.getCurrentStep)(currentSteps);
|
|
535
|
-
const swapEventData = (0, quote_js_1.getSwapEventData)(quote?.details, quote?.fees, currentSteps, linkedWallet?.connector, quoteParameters);
|
|
536
|
-
if (step && stepItem) {
|
|
537
|
-
const isApproval = step.id === 'approve' || step.id === 'approval';
|
|
538
|
-
let submittedEvent = isApproval
|
|
539
|
-
? events_js_1.EventNames.APPROVAL_SUBMITTED
|
|
540
|
-
: events_js_1.EventNames.DEPOSIT_SUBMITTED;
|
|
541
|
-
const successEvent = isApproval
|
|
542
|
-
? events_js_1.EventNames.APPROVAL_SUCCESS
|
|
543
|
-
: events_js_1.EventNames.DEPOSIT_SUCCESS;
|
|
544
|
-
const isBatchTransaction = Boolean(Array.isArray(step.items) &&
|
|
545
|
-
step.items.length > 1 &&
|
|
546
|
-
wallet?.handleBatchTransactionStep);
|
|
547
|
-
if (!isApproval && isBatchTransaction) {
|
|
548
|
-
submittedEvent = events_js_1.EventNames.BATCH_TX_SUBMITTED;
|
|
549
|
-
}
|
|
550
|
-
if (!submittedEvents.includes(submittedEvent) &&
|
|
551
|
-
!stepItem.receipt &&
|
|
552
|
-
stepItem?.txHashes &&
|
|
553
|
-
stepItem?.txHashes?.length > 0) {
|
|
554
|
-
submittedEvents.push(submittedEvent);
|
|
555
|
-
onAnalyticEvent?.(submittedEvent, swapEventData);
|
|
556
|
-
}
|
|
557
|
-
else if (!submittedEvents.includes(successEvent) &&
|
|
558
|
-
((stepItem.receipt &&
|
|
559
|
-
!(typeof stepItem.receipt === 'object' &&
|
|
560
|
-
'status' in stepItem.receipt &&
|
|
561
|
-
stepItem.receipt.status === 'reverted')) ||
|
|
562
|
-
stepItem.checkStatus === 'pending')) {
|
|
563
|
-
onAnalyticEvent?.(successEvent, swapEventData);
|
|
564
|
-
submittedEvents.push(successEvent);
|
|
565
|
-
}
|
|
566
|
-
if (stepItem.status === 'complete' &&
|
|
567
|
-
stepItem.check &&
|
|
568
|
-
!submittedEvents.includes(events_js_1.EventNames.FILL_SUCCESS)) {
|
|
569
|
-
if (!submittedEvents.includes(events_js_1.EventNames.DEPOSIT_SUCCESS) &&
|
|
570
|
-
!isBatchTransaction) {
|
|
571
|
-
onAnalyticEvent?.(events_js_1.EventNames.DEPOSIT_SUCCESS, swapEventData);
|
|
572
|
-
submittedEvents.push(events_js_1.EventNames.DEPOSIT_SUCCESS);
|
|
573
|
-
setTimeout(() => {
|
|
574
|
-
onAnalyticEvent?.(events_js_1.EventNames.FILL_SUCCESS, swapEventData);
|
|
575
|
-
}, 20);
|
|
576
|
-
}
|
|
577
|
-
else {
|
|
578
|
-
onAnalyticEvent?.(events_js_1.EventNames.FILL_SUCCESS, swapEventData);
|
|
579
|
-
}
|
|
580
|
-
submittedEvents.push(events_js_1.EventNames.FILL_SUCCESS);
|
|
581
|
-
}
|
|
582
|
-
}
|
|
583
|
-
else if (currentSteps?.every((step) => step.items?.every((item) => item.status === 'complete')) &&
|
|
584
|
-
!submittedEvents.includes(events_js_1.EventNames.FILL_SUCCESS)) {
|
|
585
|
-
if (!submittedEvents.includes(events_js_1.EventNames.DEPOSIT_SUCCESS) &&
|
|
586
|
-
!submittedEvents.includes(events_js_1.EventNames.BATCH_TX_SUBMITTED)) {
|
|
587
|
-
onAnalyticEvent?.(events_js_1.EventNames.DEPOSIT_SUCCESS, swapEventData);
|
|
588
|
-
submittedEvents.push(events_js_1.EventNames.DEPOSIT_SUCCESS);
|
|
589
|
-
setTimeout(() => {
|
|
590
|
-
onAnalyticEvent?.(events_js_1.EventNames.FILL_SUCCESS, swapEventData);
|
|
591
|
-
}, 20);
|
|
592
|
-
}
|
|
593
|
-
else {
|
|
594
|
-
onAnalyticEvent?.(events_js_1.EventNames.FILL_SUCCESS, swapEventData);
|
|
595
|
-
}
|
|
596
|
-
submittedEvents.push(events_js_1.EventNames.FILL_SUCCESS);
|
|
597
|
-
}
|
|
598
|
-
});
|
|
599
|
-
if (execPromise &&
|
|
600
|
-
typeof execPromise === 'object' &&
|
|
601
|
-
'abortController' in execPromise) {
|
|
602
|
-
setAbortController(execPromise.abortController);
|
|
603
|
-
}
|
|
604
|
-
execPromise
|
|
605
|
-
?.catch((error) => {
|
|
606
|
-
swapErrorHandler(error, _currentSteps);
|
|
607
|
-
})
|
|
608
|
-
.finally(() => {
|
|
609
|
-
setWaitingForSteps(false);
|
|
610
|
-
setAbortController(null);
|
|
611
|
-
invalidateBalanceQueries();
|
|
612
|
-
});
|
|
613
|
-
}
|
|
614
|
-
catch (error) {
|
|
615
|
-
swapErrorHandler(error);
|
|
616
|
-
setWaitingForSteps(false);
|
|
617
|
-
}
|
|
618
|
-
}, [
|
|
619
|
-
relayClient,
|
|
620
|
-
address,
|
|
621
|
-
connector,
|
|
622
|
-
wallet,
|
|
623
|
-
walletClient,
|
|
624
|
-
fromToken,
|
|
625
|
-
toToken,
|
|
626
|
-
customToAddress,
|
|
627
|
-
recipient,
|
|
628
|
-
debouncedInputAmountValue,
|
|
629
|
-
debouncedOutputAmountValue,
|
|
630
|
-
tradeType,
|
|
631
|
-
waitingForSteps,
|
|
632
|
-
executeSwap,
|
|
633
|
-
setSteps,
|
|
634
|
-
setQuoteInProgress,
|
|
635
|
-
invalidateBalanceQueries,
|
|
636
|
-
linkedWallet,
|
|
637
|
-
abortController
|
|
638
|
-
]);
|
|
639
|
-
return ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: children({
|
|
640
|
-
quote,
|
|
641
|
-
steps,
|
|
642
|
-
setSteps,
|
|
643
|
-
swap,
|
|
644
|
-
transactionModalOpen,
|
|
645
|
-
feeBreakdown,
|
|
646
|
-
fromToken,
|
|
647
|
-
setFromToken,
|
|
648
|
-
toToken,
|
|
649
|
-
setToToken,
|
|
650
|
-
swapError,
|
|
651
|
-
error,
|
|
652
|
-
toDisplayName,
|
|
653
|
-
address,
|
|
654
|
-
originAddressOverride,
|
|
655
|
-
setOriginAddressOverride,
|
|
656
|
-
recipient,
|
|
657
|
-
destinationAddressOverride,
|
|
658
|
-
customToAddress,
|
|
659
|
-
setCustomToAddress,
|
|
660
|
-
setDestinationAddressOverride,
|
|
661
|
-
tradeType,
|
|
662
|
-
setTradeType,
|
|
663
|
-
details,
|
|
664
|
-
isSameCurrencySameRecipientSwap,
|
|
665
|
-
allowUnsupportedOrigin,
|
|
666
|
-
setAllowUnsupportedOrigin,
|
|
667
|
-
allowUnsupportedRecipient,
|
|
668
|
-
setAllowUnsupportedRecipient,
|
|
669
|
-
debouncedInputAmountValue,
|
|
670
|
-
debouncedAmountInputControls,
|
|
671
|
-
setAmountInputValue,
|
|
672
|
-
amountInputValue,
|
|
673
|
-
amountOutputValue,
|
|
674
|
-
debouncedOutputAmountValue,
|
|
675
|
-
debouncedAmountOutputControls,
|
|
676
|
-
setAmountOutputValue,
|
|
677
|
-
toBalance,
|
|
678
|
-
toBalancePending,
|
|
679
|
-
isLoadingToBalance,
|
|
680
|
-
isFetchingQuote,
|
|
681
|
-
isLoadingFromBalance,
|
|
682
|
-
fromBalance,
|
|
683
|
-
fromBalancePending,
|
|
684
|
-
highRelayerServiceFee,
|
|
685
|
-
relayerFeeProportion,
|
|
686
|
-
hasInsufficientBalance,
|
|
687
|
-
isInsufficientLiquidityError,
|
|
688
|
-
isCapacityExceededError,
|
|
689
|
-
isCouldNotExecuteError,
|
|
690
|
-
ctaCopy,
|
|
691
|
-
isFromNative,
|
|
692
|
-
slippageTolerance: currentSlippageTolerance,
|
|
693
|
-
timeEstimate,
|
|
694
|
-
isSvmSwap,
|
|
695
|
-
isBvmSwap,
|
|
696
|
-
isValidFromAddress,
|
|
697
|
-
isValidToAddress,
|
|
698
|
-
supportedWalletVMs,
|
|
699
|
-
fromChainWalletVMSupported,
|
|
700
|
-
toChainWalletVMSupported,
|
|
701
|
-
isRecipientLinked,
|
|
702
|
-
recipientWalletSupportsChain,
|
|
703
|
-
invalidateBalanceQueries,
|
|
704
|
-
invalidateQuoteQuery,
|
|
705
|
-
setDetails,
|
|
706
|
-
setSwapError,
|
|
707
|
-
quoteInProgress,
|
|
708
|
-
setQuoteInProgress,
|
|
709
|
-
linkedWallet,
|
|
710
|
-
quoteParameters,
|
|
711
|
-
abortController,
|
|
712
|
-
fromTokenPriceData,
|
|
713
|
-
toTokenPriceData,
|
|
714
|
-
isLoadingFromTokenPrice,
|
|
715
|
-
isLoadingToTokenPrice
|
|
716
|
-
}) }));
|
|
717
|
-
};
|
|
718
|
-
exports.default = TokenWidgetRenderer;
|
|
719
|
-
//# sourceMappingURL=TokenWidgetRenderer.js.map
|