0xtrails 0.13.2 → 0.14.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/abis/trailsHydrate.d.ts +5 -42
- package/dist/abis/trailsHydrate.d.ts.map +1 -1
- package/dist/abis/trailsRouter.d.ts +1 -1
- package/dist/abis/trailsRouter.d.ts.map +1 -1
- package/dist/{widget/analytics → analytics/hooks}/useWidgetAnalytics.d.ts +2 -4
- package/dist/analytics/hooks/useWidgetAnalytics.d.ts.map +1 -0
- package/dist/analytics.d.ts.map +1 -1
- package/dist/chainSwitch.d.ts.map +1 -1
- package/dist/chains-C1NhDLF_.js +4 -0
- package/dist/chains-CcoarGia.js +658 -0
- package/dist/chains.d.ts +0 -1
- package/dist/chains.d.ts.map +1 -1
- package/dist/committedIntentStore.d.ts +5 -0
- package/dist/committedIntentStore.d.ts.map +1 -0
- package/dist/config.d.ts +2 -0
- package/dist/config.d.ts.map +1 -1
- package/dist/constants.d.ts +2 -1
- package/dist/constants.d.ts.map +1 -1
- package/dist/error.d.ts +73 -4
- package/dist/error.d.ts.map +1 -1
- package/dist/hooks/useAddressWalletIcon.d.ts.map +1 -0
- package/dist/hooks/useAmountUsd.d.ts.map +1 -0
- package/dist/hooks/useBalanceVisible.d.ts.map +1 -0
- package/dist/hooks/useChainFilter.d.ts.map +1 -0
- package/dist/{widget/hooks → hooks}/useCheckout.d.ts +15 -15
- package/dist/hooks/useCheckout.d.ts.map +1 -0
- package/dist/hooks/useClickTracking.d.ts.map +1 -0
- package/dist/{widget/hooks → hooks}/useCombinedHistory.d.ts +3 -2
- package/dist/hooks/useCombinedHistory.d.ts.map +1 -0
- package/dist/hooks/useConnector.d.ts.map +1 -0
- package/dist/{widget/hooks → hooks}/useCustomTokenSearch.d.ts +1 -1
- package/dist/hooks/useCustomTokenSearch.d.ts.map +1 -0
- package/dist/hooks/useDebounce.d.ts.map +1 -0
- package/dist/{widget/hooks → hooks}/useDebugScreens.d.ts +2 -2
- package/dist/hooks/useDebugScreens.d.ts.map +1 -0
- package/dist/{widget/hooks → hooks}/useDefaultDestinationToken.d.ts +1 -1
- package/dist/hooks/useDefaultDestinationToken.d.ts.map +1 -0
- package/dist/{widget/hooks → hooks}/useDefaultOriginToken.d.ts +1 -1
- package/dist/hooks/useDefaultOriginToken.d.ts.map +1 -0
- package/dist/hooks/useDepositMonitor.d.ts.map +1 -0
- package/dist/{widget/hooks → hooks}/useDestinationSelectedToken.d.ts +2 -2
- package/dist/hooks/useDestinationSelectedToken.d.ts.map +1 -0
- package/dist/hooks/useDisplayCurrencyPreference.d.ts.map +1 -0
- package/dist/{widget/hooks → hooks}/useEarnPool.d.ts +1 -1
- package/dist/hooks/useEarnPool.d.ts.map +1 -0
- package/dist/hooks/useEffectiveFundBalance.d.ts +28 -0
- package/dist/hooks/useEffectiveFundBalance.d.ts.map +1 -0
- package/dist/hooks/useExecutingIntentsCount.d.ts.map +1 -0
- package/dist/{widget/hooks → hooks}/useExternalFundingReceiptSync.d.ts +1 -1
- package/dist/hooks/useExternalFundingReceiptSync.d.ts.map +1 -0
- package/dist/{widget/hooks → hooks}/useFiatOnRampCurrencies.d.ts +1 -1
- package/dist/hooks/useFiatOnRampCurrencies.d.ts.map +1 -0
- package/dist/hooks/useFiatSelectedCurrency.d.ts.map +1 -0
- package/dist/hooks/useGetIntent.d.ts.map +1 -0
- package/dist/{widget/hooks → hooks}/useIntentReceiptBalances.d.ts +1 -1
- package/dist/hooks/useIntentReceiptBalances.d.ts.map +1 -0
- package/dist/{widget/hooks → hooks}/useIntentTransactionHistory.d.ts +2 -1
- package/dist/hooks/useIntentTransactionHistory.d.ts.map +1 -0
- package/dist/hooks/useIsMobile.d.ts.map +1 -0
- package/dist/hooks/useIsSequenceWallet.d.ts.map +1 -0
- package/dist/hooks/useLocalePreference.d.ts.map +1 -0
- package/dist/hooks/useMeldTransactionHistory.d.ts.map +1 -0
- package/dist/hooks/useMeldTransactionStatus.d.ts.map +1 -0
- package/dist/hooks/useOnRampCountryDefaults.d.ts.map +1 -0
- package/dist/{widget/hooks → hooks}/useOnRampPaymentMethods.d.ts +2 -2
- package/dist/hooks/useOnRampPaymentMethods.d.ts.map +1 -0
- package/dist/{widget/hooks → hooks}/useOnRampProviderWidget.d.ts +1 -1
- package/dist/hooks/useOnRampProviderWidget.d.ts.map +1 -0
- package/dist/{widget/hooks → hooks}/useOnRampQuote.d.ts +3 -3
- package/dist/hooks/useOnRampQuote.d.ts.map +1 -0
- package/dist/{widget/hooks → hooks}/useOnRampTransactionStatus.d.ts +1 -1
- package/dist/hooks/useOnRampTransactionStatus.d.ts.map +1 -0
- package/dist/{widget/hooks → hooks}/useOriginSelectedToken.d.ts +1 -1
- package/dist/hooks/useOriginSelectedToken.d.ts.map +1 -0
- package/dist/hooks/usePayMessage.d.ts.map +1 -0
- package/dist/hooks/usePriceImpactWarning.d.ts.map +1 -0
- package/dist/hooks/useQuote.d.ts +439 -0
- package/dist/hooks/useQuote.d.ts.map +1 -0
- package/dist/{widget/hooks → hooks}/useRecentTokens.d.ts +1 -1
- package/dist/hooks/useRecentTokens.d.ts.map +1 -0
- package/dist/hooks/useRecipients.d.ts.map +1 -0
- package/dist/hooks/useSelectedFeeOption.d.ts.map +1 -0
- package/dist/{widget/hooks → hooks}/useSelectedFundMethod.d.ts +11 -1
- package/dist/hooks/useSelectedFundMethod.d.ts.map +1 -0
- package/dist/hooks/useSelectedRecipient.d.ts.map +1 -0
- package/dist/{widget/hooks → hooks}/useSendForm.d.ts +6 -11
- package/dist/hooks/useSendForm.d.ts.map +1 -0
- package/dist/hooks/useSwapAmount.d.ts.map +1 -0
- package/dist/{widget/hooks → hooks}/useSwapState.d.ts +1 -1
- package/dist/hooks/useSwapState.d.ts.map +1 -0
- package/dist/hooks/useTargetAmount.d.ts.map +1 -0
- package/dist/hooks/useTheme.d.ts.map +1 -0
- package/dist/{widget/hooks → hooks}/useTokenList.d.ts +2 -2
- package/dist/hooks/useTokenList.d.ts.map +1 -0
- package/dist/{widget/hooks → hooks}/useTrailsSendTransaction.d.ts +1 -1
- package/dist/hooks/useTrailsSendTransaction.d.ts.map +1 -0
- package/dist/{widget/hooks → hooks}/useViewManager.d.ts +1 -1
- package/dist/hooks/useViewManager.d.ts.map +1 -0
- package/dist/hooks/useWalletConnectUri.d.ts +19 -0
- package/dist/hooks/useWalletConnectUri.d.ts.map +1 -0
- package/dist/hooks/useWalletConnectionContext.d.ts.map +1 -0
- package/dist/{widget/hooks → hooks}/useWidgetProps.d.ts +1 -1
- package/dist/hooks/useWidgetProps.d.ts.map +1 -0
- package/dist/hydrate/builder.d.ts +131 -0
- package/dist/hydrate/builder.d.ts.map +1 -0
- package/dist/hydrate/constants.d.ts +13 -0
- package/dist/hydrate/constants.d.ts.map +1 -0
- package/dist/hydrate/encodeExecute.d.ts +73 -0
- package/dist/hydrate/encodeExecute.d.ts.map +1 -0
- package/dist/hydrate/index.d.ts +6 -0
- package/dist/hydrate/index.d.ts.map +1 -0
- package/dist/hydrate/index.js +11 -0
- package/dist/hydrate/payload.d.ts +38 -0
- package/dist/hydrate/payload.d.ts.map +1 -0
- package/dist/hydrate/selectors.d.ts +28 -0
- package/dist/hydrate/selectors.d.ts.map +1 -0
- package/dist/hydrate/types.d.ts +19 -0
- package/dist/hydrate/types.d.ts.map +1 -0
- package/dist/hydrate/utils.d.ts +8 -0
- package/dist/hydrate/utils.d.ts.map +1 -0
- package/dist/hydrate-Cr9eaeDK.js +654 -0
- package/dist/index.d.ts +19 -13
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +157 -662
- package/dist/intentConfigStore.d.ts +8 -0
- package/dist/intentConfigStore.d.ts.map +1 -0
- package/dist/intentProtocolApi.d.ts +11 -0
- package/dist/intentProtocolApi.d.ts.map +1 -0
- package/dist/intentProtocolEncoding.d.ts +25 -0
- package/dist/intentProtocolEncoding.d.ts.map +1 -0
- package/dist/intentProtocolResolver.d.ts +28 -0
- package/dist/intentProtocolResolver.d.ts.map +1 -0
- package/dist/intentReceiptPoller.d.ts.map +1 -1
- package/dist/intentValidation.d.ts +5 -0
- package/dist/intentValidation.d.ts.map +1 -0
- package/dist/intents.d.ts.map +1 -1
- package/dist/keymachine/index.d.ts +20 -0
- package/dist/keymachine/index.d.ts.map +1 -1
- package/dist/mutations.d.ts.map +1 -1
- package/dist/offlineRecovery.d.ts +24 -0
- package/dist/offlineRecovery.d.ts.map +1 -0
- package/dist/onramp/MeshConnectFlow.d.ts +9 -0
- package/dist/onramp/MeshConnectFlow.d.ts.map +1 -1
- package/dist/onramp/MeshConnectIframe.d.ts +9 -0
- package/dist/onramp/MeshConnectIframe.d.ts.map +1 -1
- package/dist/onramp/TrailsOnRampProvider.d.ts.map +1 -1
- package/dist/onramp/mesh/components/MeshExchangeConfirmation.d.ts +10 -0
- package/dist/onramp/mesh/components/MeshExchangeConfirmation.d.ts.map +1 -0
- package/dist/onramp/mesh/components/MeshExchangeIcon.d.ts +13 -0
- package/dist/onramp/mesh/components/MeshExchangeIcon.d.ts.map +1 -0
- package/dist/{widget → onramp/mesh}/components/MeshExchangeSelection.d.ts +1 -0
- package/dist/onramp/mesh/components/MeshExchangeSelection.d.ts.map +1 -0
- package/dist/onramp/mesh/components/MeshSessionOptions.d.ts +15 -0
- package/dist/onramp/mesh/components/MeshSessionOptions.d.ts.map +1 -0
- package/dist/onramp/mesh/hooks/useMeshAccessTokens.d.ts +9 -0
- package/dist/onramp/mesh/hooks/useMeshAccessTokens.d.ts.map +1 -0
- package/dist/onramp/mesh/hooks/useMeshFundingSelection.d.ts +11 -0
- package/dist/onramp/mesh/hooks/useMeshFundingSelection.d.ts.map +1 -0
- package/dist/onramp/mesh/hooks/useMeshOnrampFlow.d.ts +71 -0
- package/dist/onramp/mesh/hooks/useMeshOnrampFlow.d.ts.map +1 -0
- package/dist/onramp/mesh/hooks/useMeshOnrampSessionState.d.ts +32 -0
- package/dist/onramp/mesh/hooks/useMeshOnrampSessionState.d.ts.map +1 -0
- package/dist/onramp/mesh/hooks/useMeshSelectedTokenBalance.d.ts +19 -0
- package/dist/onramp/mesh/hooks/useMeshSelectedTokenBalance.d.ts.map +1 -0
- package/dist/onramp/mesh/hooks/useMeshSessionAccountBalance.d.ts +15 -0
- package/dist/onramp/mesh/hooks/useMeshSessionAccountBalance.d.ts.map +1 -0
- package/dist/onramp/mesh/hooks/useMeshSessionStorage.d.ts +7 -0
- package/dist/onramp/mesh/hooks/useMeshSessionStorage.d.ts.map +1 -0
- package/dist/onramp/meshSessionStorage.d.ts +13 -0
- package/dist/onramp/meshSessionStorage.d.ts.map +1 -0
- package/dist/onramp/meshconnect.d.ts +6 -4
- package/dist/onramp/meshconnect.d.ts.map +1 -1
- package/dist/onramp/trailsOnramp.d.ts +8 -0
- package/dist/onramp/trailsOnramp.d.ts.map +1 -1
- package/dist/onrampClient.d.ts.map +1 -1
- package/dist/prepareSend.d.ts +3 -2
- package/dist/prepareSend.d.ts.map +1 -1
- package/dist/query/intentProtocol.queries.d.ts +32 -0
- package/dist/query/intentProtocol.queries.d.ts.map +1 -0
- package/dist/recover.d.ts +70 -24
- package/dist/recover.d.ts.map +1 -1
- package/dist/src-4HYDQv2T.js +48798 -0
- package/dist/transactionIntent/deposits/depositOrchestrator.d.ts +2 -3
- package/dist/transactionIntent/deposits/depositOrchestrator.d.ts.map +1 -1
- package/dist/transactionIntent/deposits/gaslessDeposit.d.ts +2 -3
- package/dist/transactionIntent/deposits/gaslessDeposit.d.ts.map +1 -1
- package/dist/transactionIntent/deposits/standardDeposit.d.ts +2 -5
- package/dist/transactionIntent/deposits/standardDeposit.d.ts.map +1 -1
- package/dist/transactionIntent/handlers/intentHandler.d.ts +4 -4
- package/dist/transactionIntent/handlers/intentHandler.d.ts.map +1 -1
- package/dist/transactionIntent/quote/quoteHelpers.d.ts +2 -2
- package/dist/transactionIntent/quote/quoteHelpers.d.ts.map +1 -1
- package/dist/transactionIntent/types.d.ts +3 -3
- package/dist/transactionIntent/types.d.ts.map +1 -1
- package/dist/transactions.d.ts +1 -0
- package/dist/transactions.d.ts.map +1 -1
- package/dist/umd/trails.min.js +1370 -410
- package/dist/utils/localStorageGc.d.ts +22 -0
- package/dist/utils/localStorageGc.d.ts.map +1 -0
- package/dist/walletUtils.d.ts.map +1 -1
- package/dist/widget/components/AccountIntentTransactionHistory.d.ts.map +1 -1
- package/dist/widget/components/ClassicSwap.d.ts.map +1 -1
- package/dist/widget/components/ConnectedWallets.d.ts +1 -1
- package/dist/widget/components/ConnectedWallets.d.ts.map +1 -1
- package/dist/widget/components/Earn.d.ts +2 -6
- package/dist/widget/components/Earn.d.ts.map +1 -1
- package/dist/widget/components/FeeOption.d.ts +1 -1
- package/dist/widget/components/FeeOption.d.ts.map +1 -1
- package/dist/widget/components/FeeOptions.d.ts +1 -1
- package/dist/widget/components/FeeOptions.d.ts.map +1 -1
- package/dist/widget/components/FiatSelector.d.ts +1 -1
- package/dist/widget/components/FiatSelector.d.ts.map +1 -1
- package/dist/widget/components/FiatSelectorButton.d.ts +1 -1
- package/dist/widget/components/FiatSelectorButton.d.ts.map +1 -1
- package/dist/widget/components/Fund.d.ts +1 -1
- package/dist/widget/components/Fund.d.ts.map +1 -1
- package/dist/widget/components/FundMethods.d.ts.map +1 -1
- package/dist/widget/components/FundingMethodSelectorButton.d.ts +1 -1
- package/dist/widget/components/FundingMethodSelectorButton.d.ts.map +1 -1
- package/dist/widget/components/MeldHistory.d.ts +1 -1
- package/dist/widget/components/MeldHistory.d.ts.map +1 -1
- package/dist/widget/components/MeldTransactionStatus.d.ts +1 -1
- package/dist/widget/components/MeldTransactionStatus.d.ts.map +1 -1
- package/dist/widget/components/MeshExchangeAccountHeader.d.ts +9 -0
- package/dist/widget/components/MeshExchangeAccountHeader.d.ts.map +1 -0
- package/dist/widget/components/OnrampHistoryRow.d.ts +1 -1
- package/dist/widget/components/OnrampHistoryRow.d.ts.map +1 -1
- package/dist/widget/components/OnrampProviderConfirmation.d.ts +1 -1
- package/dist/widget/components/OnrampProviderConfirmation.d.ts.map +1 -1
- package/dist/widget/components/Pay.d.ts.map +1 -1
- package/dist/widget/components/PoolDeposit.d.ts +2 -6
- package/dist/widget/components/PoolDeposit.d.ts.map +1 -1
- package/dist/widget/components/PoolWithdraw.d.ts +2 -2
- package/dist/widget/components/PoolWithdraw.d.ts.map +1 -1
- package/dist/widget/components/PulsatingButton.d.ts +9 -0
- package/dist/widget/components/PulsatingButton.d.ts.map +1 -0
- package/dist/widget/components/Receipt.d.ts +1 -1
- package/dist/widget/components/Receipt.d.ts.map +1 -1
- package/dist/widget/components/RecipientSelectorButton.d.ts.map +1 -1
- package/dist/widget/components/Recipients.d.ts.map +1 -1
- package/dist/widget/components/Swap.d.ts +2 -6
- package/dist/widget/components/Swap.d.ts.map +1 -1
- package/dist/widget/components/TokenList.d.ts +1 -0
- package/dist/widget/components/TokenList.d.ts.map +1 -1
- package/dist/widget/components/TokenSelector.d.ts +1 -2
- package/dist/widget/components/TokenSelector.d.ts.map +1 -1
- package/dist/widget/components/TransactionDetails.d.ts +1 -0
- package/dist/widget/components/TransactionDetails.d.ts.map +1 -1
- package/dist/widget/components/TransactionHistoryItem.d.ts +1 -0
- package/dist/widget/components/TransactionHistoryItem.d.ts.map +1 -1
- package/dist/widget/components/TransferPendingVertical.d.ts +1 -1
- package/dist/widget/components/TransferPendingVertical.d.ts.map +1 -1
- package/dist/widget/components/WalletAccountHeader.d.ts +7 -0
- package/dist/widget/components/WalletAccountHeader.d.ts.map +1 -0
- package/dist/widget/components/WalletConfirmation.d.ts +2 -1
- package/dist/widget/components/WalletConfirmation.d.ts.map +1 -1
- package/dist/widget/components/WalletConnect.d.ts.map +1 -1
- package/dist/widget/components/WidgetProviders.d.ts.map +1 -1
- package/dist/widget/components/Withdraw.d.ts.map +1 -1
- package/dist/widget/index.d.ts +13 -0
- package/dist/widget/index.d.ts.map +1 -1
- package/dist/widget/index.js +16 -8
- package/dist/widget/modes/EarnWidget.d.ts +83 -0
- package/dist/widget/modes/EarnWidget.d.ts.map +1 -0
- package/dist/widget/modes/FundWidget.d.ts +103 -0
- package/dist/widget/modes/FundWidget.d.ts.map +1 -0
- package/dist/widget/modes/PayWidget.d.ts +86 -0
- package/dist/widget/modes/PayWidget.d.ts.map +1 -0
- package/dist/widget/modes/SwapWidget.d.ts +82 -0
- package/dist/widget/modes/SwapWidget.d.ts.map +1 -0
- package/dist/widget/modes/WithdrawWidget.d.ts +71 -0
- package/dist/widget/modes/WithdrawWidget.d.ts.map +1 -0
- package/dist/widget/providers/TrailsProvider.d.ts +3 -0
- package/dist/widget/providers/TrailsProvider.d.ts.map +1 -1
- package/dist/widget/shared/mapSharedProps.d.ts +9 -0
- package/dist/widget/shared/mapSharedProps.d.ts.map +1 -0
- package/dist/widget/shared/methodMap.d.ts +18 -0
- package/dist/widget/shared/methodMap.d.ts.map +1 -0
- package/dist/widget/shared/resolution.d.ts +22 -0
- package/dist/widget/shared/resolution.d.ts.map +1 -0
- package/dist/widget/shared/resolvePaymentSource.d.ts +34 -0
- package/dist/widget/shared/resolvePaymentSource.d.ts.map +1 -0
- package/dist/widget/shared/types.d.ts +94 -0
- package/dist/widget/shared/types.d.ts.map +1 -0
- package/dist/widget/types/commonProps.d.ts +3 -7
- package/dist/widget/types/commonProps.d.ts.map +1 -1
- package/dist/widget/utils/fundMethodSwitchState.d.ts +1 -0
- package/dist/widget/utils/fundMethodSwitchState.d.ts.map +1 -1
- package/dist/widget/utils/viewManagerGuards.d.ts +1 -1
- package/dist/widget/utils/viewManagerGuards.d.ts.map +1 -1
- package/dist/widget/widget.d.ts +21 -16
- package/dist/widget/widget.d.ts.map +1 -1
- package/package.json +17 -23
- package/dist/buffer.d.ts +0 -3
- package/dist/buffer.d.ts.map +0 -1
- package/dist/ccip-CT_An6eM.js +0 -230
- package/dist/index-RfqL5Foz.js +0 -114567
- package/dist/paymasterSend.d.ts +0 -90
- package/dist/paymasterSend.d.ts.map +0 -1
- package/dist/sendUserOp.d.ts +0 -122
- package/dist/sendUserOp.d.ts.map +0 -1
- package/dist/toSimpleSmartAccount.d.ts +0 -95
- package/dist/toSimpleSmartAccount.d.ts.map +0 -1
- package/dist/transactionIntent/utils/erc20Approval.d.ts +0 -34
- package/dist/transactionIntent/utils/erc20Approval.d.ts.map +0 -1
- package/dist/utils/allowance.d.ts +0 -19
- package/dist/utils/allowance.d.ts.map +0 -1
- package/dist/widget/analytics/useWidgetAnalytics.d.ts.map +0 -1
- package/dist/widget/components/FeeBreakdown.d.ts +0 -9
- package/dist/widget/components/FeeBreakdown.d.ts.map +0 -1
- package/dist/widget/components/HideBalances.d.ts +0 -4
- package/dist/widget/components/HideBalances.d.ts.map +0 -1
- package/dist/widget/components/MeshExchangeSelection.d.ts.map +0 -1
- package/dist/widget/components/OnrampDeposit.d.ts +0 -10
- package/dist/widget/components/OnrampDeposit.d.ts.map +0 -1
- package/dist/widget/components/SwapSettings.d.ts +0 -4
- package/dist/widget/components/SwapSettings.d.ts.map +0 -1
- package/dist/widget/components/TruncatedAddress.d.ts +0 -12
- package/dist/widget/components/TruncatedAddress.d.ts.map +0 -1
- package/dist/widget/components/WalletImage.d.ts +0 -8
- package/dist/widget/components/WalletImage.d.ts.map +0 -1
- package/dist/widget/css/compiled.css +0 -26
- package/dist/widget/css/index.css +0 -686
- package/dist/widget/hooks/useAddressWalletIcon.d.ts.map +0 -1
- package/dist/widget/hooks/useAmountUsd.d.ts.map +0 -1
- package/dist/widget/hooks/useBalanceVisible.d.ts.map +0 -1
- package/dist/widget/hooks/useChainFilter.d.ts.map +0 -1
- package/dist/widget/hooks/useCheckout.d.ts.map +0 -1
- package/dist/widget/hooks/useClickTracking.d.ts.map +0 -1
- package/dist/widget/hooks/useCombinedHistory.d.ts.map +0 -1
- package/dist/widget/hooks/useConnector.d.ts.map +0 -1
- package/dist/widget/hooks/useCustomTokenSearch.d.ts.map +0 -1
- package/dist/widget/hooks/useDebounce.d.ts.map +0 -1
- package/dist/widget/hooks/useDebugScreens.d.ts.map +0 -1
- package/dist/widget/hooks/useDefaultDestinationToken.d.ts.map +0 -1
- package/dist/widget/hooks/useDefaultOriginToken.d.ts.map +0 -1
- package/dist/widget/hooks/useDepositMonitor.d.ts.map +0 -1
- package/dist/widget/hooks/useDestinationSelectedToken.d.ts.map +0 -1
- package/dist/widget/hooks/useDisplayCurrencyPreference.d.ts.map +0 -1
- package/dist/widget/hooks/useEarnPool.d.ts.map +0 -1
- package/dist/widget/hooks/useExecutingIntentsCount.d.ts.map +0 -1
- package/dist/widget/hooks/useExternalFundingReceiptSync.d.ts.map +0 -1
- package/dist/widget/hooks/useFiatOnRampCurrencies.d.ts.map +0 -1
- package/dist/widget/hooks/useFiatSelectedCurrency.d.ts.map +0 -1
- package/dist/widget/hooks/useGetIntent.d.ts.map +0 -1
- package/dist/widget/hooks/useIntentReceiptBalances.d.ts.map +0 -1
- package/dist/widget/hooks/useIntentTransactionHistory.d.ts.map +0 -1
- package/dist/widget/hooks/useIsConnectedWalletSmartContract.d.ts +0 -7
- package/dist/widget/hooks/useIsConnectedWalletSmartContract.d.ts.map +0 -1
- package/dist/widget/hooks/useIsMobile.d.ts.map +0 -1
- package/dist/widget/hooks/useIsSequenceWallet.d.ts.map +0 -1
- package/dist/widget/hooks/useLocalePreference.d.ts.map +0 -1
- package/dist/widget/hooks/useMeldTransactionHistory.d.ts.map +0 -1
- package/dist/widget/hooks/useMeldTransactionStatus.d.ts.map +0 -1
- package/dist/widget/hooks/useOnRampCountryDefaults.d.ts.map +0 -1
- package/dist/widget/hooks/useOnRampPaymentMethods.d.ts.map +0 -1
- package/dist/widget/hooks/useOnRampProviderWidget.d.ts.map +0 -1
- package/dist/widget/hooks/useOnRampQuote.d.ts.map +0 -1
- package/dist/widget/hooks/useOnRampTransactionStatus.d.ts.map +0 -1
- package/dist/widget/hooks/useOriginSelectedToken.d.ts.map +0 -1
- package/dist/widget/hooks/usePayMessage.d.ts.map +0 -1
- package/dist/widget/hooks/usePriceImpactWarning.d.ts.map +0 -1
- package/dist/widget/hooks/useQuote.d.ts +0 -378
- package/dist/widget/hooks/useQuote.d.ts.map +0 -1
- package/dist/widget/hooks/useRecentTokens.d.ts.map +0 -1
- package/dist/widget/hooks/useRecipients.d.ts.map +0 -1
- package/dist/widget/hooks/useScreenTracking.d.ts +0 -2
- package/dist/widget/hooks/useScreenTracking.d.ts.map +0 -1
- package/dist/widget/hooks/useSelectedFeeOption.d.ts.map +0 -1
- package/dist/widget/hooks/useSelectedFundMethod.d.ts.map +0 -1
- package/dist/widget/hooks/useSelectedRecipient.d.ts.map +0 -1
- package/dist/widget/hooks/useSendForm.d.ts.map +0 -1
- package/dist/widget/hooks/useSwapAmount.d.ts.map +0 -1
- package/dist/widget/hooks/useSwapState.d.ts.map +0 -1
- package/dist/widget/hooks/useTargetAmount.d.ts.map +0 -1
- package/dist/widget/hooks/useTheme.d.ts.map +0 -1
- package/dist/widget/hooks/useTokenList.d.ts.map +0 -1
- package/dist/widget/hooks/useTrailsSendTransaction.d.ts.map +0 -1
- package/dist/widget/hooks/useViewManager.d.ts.map +0 -1
- package/dist/widget/hooks/useWalletConnectUri.d.ts +0 -11
- package/dist/widget/hooks/useWalletConnectUri.d.ts.map +0 -1
- package/dist/widget/hooks/useWalletConnectionContext.d.ts.map +0 -1
- package/dist/widget/hooks/useWidgetProps.d.ts.map +0 -1
- package/dist/widget/types.d.ts +0 -44
- package/dist/widget/types.d.ts.map +0 -1
- package/dist/widget/utils/historyUtils.d.ts +0 -18
- package/dist/widget/utils/historyUtils.d.ts.map +0 -1
- package/src/abi.ts +0 -38
- package/src/abis/erc20.ts +0 -60
- package/src/abis/trailsHydrate.ts +0 -185
- package/src/abis/trailsRouter.ts +0 -121
- package/src/abis/trailsSweep.ts +0 -32
- package/src/abortController.ts +0 -35
- package/src/analytics.ts +0 -2029
- package/src/buffer.ts +0 -10
- package/src/chainSwitch.ts +0 -95
- package/src/chains.ts +0 -570
- package/src/config.ts +0 -118
- package/src/constants.ts +0 -239
- package/src/contractUtils.ts +0 -46
- package/src/cssUtils.ts +0 -5
- package/src/customChains.ts +0 -24
- package/src/customTokens.ts +0 -168
- package/src/decoders.ts +0 -365
- package/src/ens.ts +0 -74
- package/src/error.ts +0 -268
- package/src/estimate.ts +0 -480
- package/src/explorer.ts +0 -38
- package/src/fees.ts +0 -362
- package/src/gasless.ts +0 -638
- package/src/index.ts +0 -205
- package/src/indexerClient.ts +0 -118
- package/src/intentReceiptMonitor.ts +0 -99
- package/src/intentReceiptPoller.ts +0 -327
- package/src/intents.ts +0 -1133
- package/src/keyMachineClient.ts +0 -29
- package/src/keymachine/index.ts +0 -175
- package/src/keymachine/key-machine.gen.ts +0 -993
- package/src/localeUtils.ts +0 -244
- package/src/logger/index.ts +0 -95
- package/src/logger/useSyncLoggerDebug.ts +0 -11
- package/src/logger.ts +0 -1
- package/src/meld/components/MeldCountriesList.tsx +0 -237
- package/src/meld/components/MeldFundMethods.tsx +0 -265
- package/src/meld/components/MeldProvidersList.tsx +0 -187
- package/src/meld/components/MeldTokensList.tsx +0 -321
- package/src/meld/components/SimpleHeader.tsx +0 -35
- package/src/meld/utils/meld.ts +0 -77
- package/src/mutations.ts +0 -166
- package/src/onramp/MeshConnectFlow.tsx +0 -86
- package/src/onramp/MeshConnectIframe.tsx +0 -661
- package/src/onramp/SendFromExchangeButton.tsx +0 -81
- package/src/onramp/TrailsOnRampProvider.tsx +0 -59
- package/src/onramp/index.ts +0 -31
- package/src/onramp/meshconnect.ts +0 -277
- package/src/onramp/trailsOnramp.tsx +0 -130
- package/src/onramp-client/index.ts +0 -52
- package/src/onrampClient.ts +0 -46
- package/src/paymasterSend.ts +0 -521
- package/src/placeholder.ts +0 -92
- package/src/poolUtils.ts +0 -222
- package/src/pools.ts +0 -120
- package/src/prepareSend.ts +0 -553
- package/src/query/balance.fetchers.ts +0 -753
- package/src/query/balance.hooks.ts +0 -357
- package/src/query/balance.queries.ts +0 -307
- package/src/query/chains.hooks.ts +0 -45
- package/src/query/chains.queries.ts +0 -17
- package/src/query/client.ts +0 -20
- package/src/query/fiat.fetchers.ts +0 -33
- package/src/query/fiat.hooks.ts +0 -71
- package/src/query/fiat.queries.ts +0 -67
- package/src/query/geo.fetchers.ts +0 -100
- package/src/query/geo.hooks.ts +0 -16
- package/src/query/geo.queries.ts +0 -36
- package/src/query/helpers.ts +0 -81
- package/src/query/meld.fetchers.ts +0 -97
- package/src/query/meld.hooks.ts +0 -18
- package/src/query/meld.queries.ts +0 -184
- package/src/query/persister.ts +0 -11
- package/src/query/price.fetchers.ts +0 -53
- package/src/query/price.hooks.ts +0 -46
- package/src/query/price.queries.ts +0 -364
- package/src/query/tokenList.queries.ts +0 -118
- package/src/queryParams.ts +0 -100
- package/src/recover.ts +0 -1728
- package/src/sendUserOp.ts +0 -512
- package/src/theme.ts +0 -2
- package/src/toSimpleSmartAccount.ts +0 -567
- package/src/toast.ts +0 -110
- package/src/tokens.ts +0 -1862
- package/src/trailsClient.ts +0 -40
- package/src/transactionIntent/constants.ts +0 -15
- package/src/transactionIntent/deposits/depositOrchestrator.ts +0 -243
- package/src/transactionIntent/deposits/gaslessDeposit.ts +0 -705
- package/src/transactionIntent/deposits/index.ts +0 -3
- package/src/transactionIntent/deposits/standardDeposit.ts +0 -590
- package/src/transactionIntent/execution/index.ts +0 -1
- package/src/transactionIntent/execution/transactionState.ts +0 -38
- package/src/transactionIntent/handlers/index.ts +0 -1
- package/src/transactionIntent/handlers/intentHandler.ts +0 -1613
- package/src/transactionIntent/helpers/index.ts +0 -1
- package/src/transactionIntent/helpers/transactionStateHelpers.ts +0 -440
- package/src/transactionIntent/index.ts +0 -10
- package/src/transactionIntent/quote/feeExtractors.ts +0 -61
- package/src/transactionIntent/quote/index.ts +0 -3
- package/src/transactionIntent/quote/normalizeQuote.ts +0 -559
- package/src/transactionIntent/quote/quoteHelpers.ts +0 -117
- package/src/transactionIntent/types.ts +0 -241
- package/src/transactionIntent/utils/balanceChecker.ts +0 -103
- package/src/transactionIntent/utils/erc20Approval.ts +0 -171
- package/src/transactionIntent/utils/index.ts +0 -2
- package/src/transactionIntent/utils/resilientDepositTracker.ts +0 -171
- package/src/transactionIntent/utils/testnetHelpers.ts +0 -5
- package/src/transactionIntent/validators.ts +0 -27
- package/src/transactions.ts +0 -429
- package/src/types.d.ts +0 -16
- package/src/umd.tsx +0 -33
- package/src/utils/address.ts +0 -78
- package/src/utils/allowance.ts +0 -47
- package/src/utils/fiat.ts +0 -32
- package/src/utils/format.ts +0 -625
- package/src/utils/passthrough.ts +0 -93
- package/src/utils/time.ts +0 -118
- package/src/utils/validation.ts +0 -104
- package/src/utils.ts +0 -112
- package/src/version.ts +0 -8
- package/src/vite-env.d.ts +0 -4
- package/src/walletUtils.ts +0 -293
- package/src/wallets.ts +0 -544
- package/src/widget/analytics/useWidgetAnalytics.ts +0 -56
- package/src/widget/assets/Exchange-icon-black.svg +0 -5
- package/src/widget/assets/MetaMask-icon-fox-with-margins.svg +0 -31
- package/src/widget/assets/MetaMask-icon-fox.svg +0 -26
- package/src/widget/assets/MetaMask-logo-black.svg +0 -3
- package/src/widget/assets/MetaMask-logo-white.svg +0 -16
- package/src/widget/assets/Trails-logo-black.svg +0 -13
- package/src/widget/assets/Trails-logo-white.svg +0 -13
- package/src/widget/assets/WalletChange-black.svg +0 -5
- package/src/widget/assets/WalletConnect-logo-black.svg +0 -14
- package/src/widget/assets/WalletConnect-logo-blue.svg +0 -14
- package/src/widget/assets/WalletConnect-logo-white.svg +0 -14
- package/src/widget/assets/WalletConnect-logo.svg +0 -40
- package/src/widget/assets/aave.svg +0 -14
- package/src/widget/assets/morpho.svg +0 -14
- package/src/widget/compiled.css +0 -26
- package/src/widget/components/AccountActionsDropdown.tsx +0 -31
- package/src/widget/components/AccountIntentTransactionHistory.tsx +0 -756
- package/src/widget/components/AccountIntentTransactionHistoryButton.tsx +0 -34
- package/src/widget/components/AccountSettings.tsx +0 -168
- package/src/widget/components/AddressOrEnsName.tsx +0 -24
- package/src/widget/components/AddressWalletIcon.tsx +0 -49
- package/src/widget/components/AllChainsIcon.tsx +0 -54
- package/src/widget/components/ChainFilterDropdown.tsx +0 -220
- package/src/widget/components/ChainImage.tsx +0 -40
- package/src/widget/components/ChainList.tsx +0 -158
- package/src/widget/components/ClassicSwap.tsx +0 -1761
- package/src/widget/components/ConfigDisplay.tsx +0 -158
- package/src/widget/components/ConnectWallet.tsx +0 -566
- package/src/widget/components/ConnectedWallets.tsx +0 -414
- package/src/widget/components/CopyButton.tsx +0 -108
- package/src/widget/components/CountryFilterDropdown.tsx +0 -179
- package/src/widget/components/DebugMenu.tsx +0 -50
- package/src/widget/components/DebugScreensList.tsx +0 -70
- package/src/widget/components/DebugToast.tsx +0 -63
- package/src/widget/components/DepositTracker.tsx +0 -326
- package/src/widget/components/DirectTransfer.tsx +0 -305
- package/src/widget/components/Disconnect.tsx +0 -68
- package/src/widget/components/DynamicInputStyles.tsx +0 -121
- package/src/widget/components/DynamicSizeInputField.tsx +0 -245
- package/src/widget/components/ENSAvatar.tsx +0 -33
- package/src/widget/components/Earn.tsx +0 -160
- package/src/widget/components/EarnPools.tsx +0 -417
- package/src/widget/components/EarnPoolsFilters.tsx +0 -165
- package/src/widget/components/ErrorAnimationIcon.tsx +0 -130
- package/src/widget/components/ErrorDisplay.tsx +0 -152
- package/src/widget/components/ExecutingIntentsBadge.tsx +0 -24
- package/src/widget/components/ExecutionStatusBadge.tsx +0 -53
- package/src/widget/components/FeeBreakdown.tsx +0 -155
- package/src/widget/components/FeeOption.tsx +0 -170
- package/src/widget/components/FeeOptions.tsx +0 -247
- package/src/widget/components/FiatSelector.tsx +0 -308
- package/src/widget/components/FiatSelectorButton.tsx +0 -68
- package/src/widget/components/Footer.tsx +0 -67
- package/src/widget/components/Fund.tsx +0 -2463
- package/src/widget/components/FundMethods.tsx +0 -423
- package/src/widget/components/FundWalletSelection.tsx +0 -60
- package/src/widget/components/FundingMethodSelectorButton.tsx +0 -106
- package/src/widget/components/GreenCheckAnimation.tsx +0 -119
- package/src/widget/components/HideBalances.tsx +0 -24
- package/src/widget/components/HighPriceImpactBlock.tsx +0 -44
- package/src/widget/components/HookModalContent.tsx +0 -377
- package/src/widget/components/Identicon.tsx +0 -228
- package/src/widget/components/LoadingSpinner.tsx +0 -9
- package/src/widget/components/MeldForm.tsx +0 -780
- package/src/widget/components/MeldHistory.tsx +0 -433
- package/src/widget/components/MeldStepsFlow.tsx +0 -1651
- package/src/widget/components/MeldTransactionStatus.tsx +0 -255
- package/src/widget/components/MeshExchangeSelection.tsx +0 -218
- package/src/widget/components/Modal.tsx +0 -86
- package/src/widget/components/OFTProgressBar.tsx +0 -89
- package/src/widget/components/OnRampProviderSelector.tsx +0 -263
- package/src/widget/components/OnrampDeposit.tsx +0 -122
- package/src/widget/components/OnrampErrorScreen.tsx +0 -163
- package/src/widget/components/OnrampHistoryRow.tsx +0 -321
- package/src/widget/components/OnrampPaymentMethods.tsx +0 -81
- package/src/widget/components/OnrampProviderConfirmation.tsx +0 -1060
- package/src/widget/components/OriginSelectionAmount.tsx +0 -144
- package/src/widget/components/OriginTransferInformation.tsx +0 -59
- package/src/widget/components/Pay.tsx +0 -1165
- package/src/widget/components/PaymentMethods.tsx +0 -198
- package/src/widget/components/PercentageMaxButtons.tsx +0 -112
- package/src/widget/components/PoolDeposit.tsx +0 -642
- package/src/widget/components/PoolWithdraw.tsx +0 -761
- package/src/widget/components/PriceImpactWarning.tsx +0 -87
- package/src/widget/components/QRCodeOptions.tsx +0 -65
- package/src/widget/components/QRCodeWalletSelect.tsx +0 -80
- package/src/widget/components/QrCode.tsx +0 -216
- package/src/widget/components/QuoteDetails.tsx +0 -1275
- package/src/widget/components/Receipt.tsx +0 -673
- package/src/widget/components/ReceiptRecoverableFunds.tsx +0 -135
- package/src/widget/components/RecentTokens.tsx +0 -66
- package/src/widget/components/RecipientSelectorButton.tsx +0 -50
- package/src/widget/components/Recipients.tsx +0 -413
- package/src/widget/components/RefundWarning.tsx +0 -61
- package/src/widget/components/RequiredPropsError.tsx +0 -33
- package/src/widget/components/ScreenHeader.tsx +0 -123
- package/src/widget/components/SearchInputField.tsx +0 -99
- package/src/widget/components/SessionTimeoutScreen.tsx +0 -103
- package/src/widget/components/ShadowPortal.tsx +0 -99
- package/src/widget/components/ShadowRootContext.tsx +0 -17
- package/src/widget/components/SimpleRecipientInputScreen.tsx +0 -91
- package/src/widget/components/SlippageToleranceSettings.tsx +0 -279
- package/src/widget/components/Swap.tsx +0 -50
- package/src/widget/components/SwapDisplay.tsx +0 -68
- package/src/widget/components/SwapSettings.tsx +0 -52
- package/src/widget/components/ThemeProvider.tsx +0 -115
- package/src/widget/components/ThemeSyncer.tsx +0 -47
- package/src/widget/components/Toast.tsx +0 -336
- package/src/widget/components/TokenDisplayNonSelectable.tsx +0 -40
- package/src/widget/components/TokenImage.tsx +0 -156
- package/src/widget/components/TokenList.tsx +0 -107
- package/src/widget/components/TokenSelector.tsx +0 -807
- package/src/widget/components/TokenSelectorButton.tsx +0 -123
- package/src/widget/components/TokenSkeleton.tsx +0 -53
- package/src/widget/components/Tooltip.tsx +0 -64
- package/src/widget/components/TrailsHookModal.tsx +0 -107
- package/src/widget/components/TransactionDetails.tsx +0 -534
- package/src/widget/components/TransactionHistoryItem.tsx +0 -767
- package/src/widget/components/TransferPendingVertical.tsx +0 -591
- package/src/widget/components/TruncatedAddress.tsx +0 -68
- package/src/widget/components/TruncatedTransactionHash.tsx +0 -74
- package/src/widget/components/UserPreferences.tsx +0 -570
- package/src/widget/components/WaasFeeOptions.tsx +0 -588
- package/src/widget/components/WalletConfirmation.tsx +0 -220
- package/src/widget/components/WalletConnect.tsx +0 -348
- package/src/widget/components/WalletConnectionPending.tsx +0 -178
- package/src/widget/components/WalletImage.tsx +0 -52
- package/src/widget/components/WalletList.tsx +0 -125
- package/src/widget/components/WidgetProviders.tsx +0 -82
- package/src/widget/components/Withdraw.tsx +0 -1106
- package/src/widget/components/YellowWarningAnimation.tsx +0 -146
- package/src/widget/hooks/useAddressWalletIcon.ts +0 -55
- package/src/widget/hooks/useAmountUsd.ts +0 -44
- package/src/widget/hooks/useBalanceVisible.tsx +0 -95
- package/src/widget/hooks/useChainFilter.tsx +0 -56
- package/src/widget/hooks/useCheckout.ts +0 -361
- package/src/widget/hooks/useClickTracking.ts +0 -74
- package/src/widget/hooks/useCombinedHistory.ts +0 -420
- package/src/widget/hooks/useConnector.tsx +0 -24
- package/src/widget/hooks/useCustomTokenSearch.tsx +0 -369
- package/src/widget/hooks/useDebounce.ts +0 -25
- package/src/widget/hooks/useDebugScreens.ts +0 -600
- package/src/widget/hooks/useDefaultDestinationToken.tsx +0 -179
- package/src/widget/hooks/useDefaultOriginToken.tsx +0 -407
- package/src/widget/hooks/useDepositMonitor.ts +0 -118
- package/src/widget/hooks/useDestinationSelectedToken.tsx +0 -310
- package/src/widget/hooks/useDisplayCurrencyPreference.tsx +0 -145
- package/src/widget/hooks/useEarnPool.tsx +0 -36
- package/src/widget/hooks/useExecutingIntentsCount.ts +0 -78
- package/src/widget/hooks/useExternalFundingReceiptSync.ts +0 -79
- package/src/widget/hooks/useFiatOnRampCurrencies.ts +0 -46
- package/src/widget/hooks/useFiatSelectedCurrency.tsx +0 -123
- package/src/widget/hooks/useGetIntent.ts +0 -54
- package/src/widget/hooks/useIntentReceiptBalances.ts +0 -141
- package/src/widget/hooks/useIntentTransactionHistory.ts +0 -790
- package/src/widget/hooks/useIsConnectedWalletSmartContract.ts +0 -43
- package/src/widget/hooks/useIsMobile.tsx +0 -50
- package/src/widget/hooks/useIsSequenceWallet.ts +0 -17
- package/src/widget/hooks/useLocalePreference.tsx +0 -187
- package/src/widget/hooks/useMeldTransactionHistory.ts +0 -184
- package/src/widget/hooks/useMeldTransactionStatus.ts +0 -707
- package/src/widget/hooks/useOnRampCountryDefaults.ts +0 -57
- package/src/widget/hooks/useOnRampPaymentMethods.ts +0 -72
- package/src/widget/hooks/useOnRampProviderWidget.ts +0 -184
- package/src/widget/hooks/useOnRampQuote.ts +0 -340
- package/src/widget/hooks/useOnRampTransactionStatus.ts +0 -196
- package/src/widget/hooks/useOriginSelectedToken.tsx +0 -253
- package/src/widget/hooks/usePayMessage.tsx +0 -496
- package/src/widget/hooks/usePriceImpactWarning.ts +0 -17
- package/src/widget/hooks/useQuote.ts +0 -1239
- package/src/widget/hooks/useRecentTokens.ts +0 -159
- package/src/widget/hooks/useRecipients.ts +0 -167
- package/src/widget/hooks/useScreenTracking.ts +0 -14
- package/src/widget/hooks/useSelectedFeeOption.tsx +0 -323
- package/src/widget/hooks/useSelectedFundMethod.tsx +0 -93
- package/src/widget/hooks/useSelectedRecipient.tsx +0 -75
- package/src/widget/hooks/useSendForm.ts +0 -1389
- package/src/widget/hooks/useSwapAmount.tsx +0 -50
- package/src/widget/hooks/useSwapState.tsx +0 -121
- package/src/widget/hooks/useTargetAmount.ts +0 -26
- package/src/widget/hooks/useTheme.tsx +0 -80
- package/src/widget/hooks/useTokenList.ts +0 -1168
- package/src/widget/hooks/useTrailsSendTransaction.ts +0 -987
- package/src/widget/hooks/useViewManager.tsx +0 -506
- package/src/widget/hooks/useWalletConnectUri.tsx +0 -307
- package/src/widget/hooks/useWalletConnectionContext.tsx +0 -128
- package/src/widget/hooks/useWidgetProps.tsx +0 -33
- package/src/widget/index.css +0 -686
- package/src/widget/index.tsx +0 -28
- package/src/widget/providers/TrailsModalProvider.tsx +0 -238
- package/src/widget/providers/TrailsProvider.tsx +0 -155
- package/src/widget/providers/UserActivityProvider.tsx +0 -78
- package/src/widget/providers/WidgetProviderTree.tsx +0 -90
- package/src/widget/styles.ts +0 -26
- package/src/widget/types/analytics.ts +0 -22
- package/src/widget/types/commonProps.ts +0 -56
- package/src/widget/types/svg.d.ts +0 -8
- package/src/widget/types.ts +0 -51
- package/src/widget/utils/countryUtils.ts +0 -89
- package/src/widget/utils/createWagmiConfig.ts +0 -43
- package/src/widget/utils/forexRateStore.ts +0 -120
- package/src/widget/utils/fundMethodSwitchState.ts +0 -27
- package/src/widget/utils/historyFilters.ts +0 -157
- package/src/widget/utils/historyUtils.ts +0 -101
- package/src/widget/utils/localeStore.ts +0 -68
- package/src/widget/utils/meldProviderUtils.ts +0 -26
- package/src/widget/utils/meshSupportedTokens.ts +0 -28
- package/src/widget/utils/onrampConfig.ts +0 -15
- package/src/widget/utils/statusLabel.ts +0 -3
- package/src/widget/utils/tokens.ts +0 -138
- package/src/widget/utils/trailsOnrampConfig.ts +0 -39
- package/src/widget/utils/transactionFailure.ts +0 -52
- package/src/widget/utils/viewManagerGuards.ts +0 -49
- package/src/widget/utils/windowUtils.ts +0 -138
- package/src/widget/widget.tsx +0 -3400
- /package/dist/{widget/hooks → hooks}/useAddressWalletIcon.d.ts +0 -0
- /package/dist/{widget/hooks → hooks}/useAmountUsd.d.ts +0 -0
- /package/dist/{widget/hooks → hooks}/useBalanceVisible.d.ts +0 -0
- /package/dist/{widget/hooks → hooks}/useChainFilter.d.ts +0 -0
- /package/dist/{widget/hooks → hooks}/useClickTracking.d.ts +0 -0
- /package/dist/{widget/hooks → hooks}/useConnector.d.ts +0 -0
- /package/dist/{widget/hooks → hooks}/useDebounce.d.ts +0 -0
- /package/dist/{widget/hooks → hooks}/useDepositMonitor.d.ts +0 -0
- /package/dist/{widget/hooks → hooks}/useDisplayCurrencyPreference.d.ts +0 -0
- /package/dist/{widget/hooks → hooks}/useExecutingIntentsCount.d.ts +0 -0
- /package/dist/{widget/hooks → hooks}/useFiatSelectedCurrency.d.ts +0 -0
- /package/dist/{widget/hooks → hooks}/useGetIntent.d.ts +0 -0
- /package/dist/{widget/hooks → hooks}/useIsMobile.d.ts +0 -0
- /package/dist/{widget/hooks → hooks}/useIsSequenceWallet.d.ts +0 -0
- /package/dist/{widget/hooks → hooks}/useLocalePreference.d.ts +0 -0
- /package/dist/{widget/hooks → hooks}/useMeldTransactionHistory.d.ts +0 -0
- /package/dist/{widget/hooks → hooks}/useMeldTransactionStatus.d.ts +0 -0
- /package/dist/{widget/hooks → hooks}/useOnRampCountryDefaults.d.ts +0 -0
- /package/dist/{widget/hooks → hooks}/usePayMessage.d.ts +0 -0
- /package/dist/{widget/hooks → hooks}/usePriceImpactWarning.d.ts +0 -0
- /package/dist/{widget/hooks → hooks}/useRecipients.d.ts +0 -0
- /package/dist/{widget/hooks → hooks}/useSelectedFeeOption.d.ts +0 -0
- /package/dist/{widget/hooks → hooks}/useSelectedRecipient.d.ts +0 -0
- /package/dist/{widget/hooks → hooks}/useSwapAmount.d.ts +0 -0
- /package/dist/{widget/hooks → hooks}/useTargetAmount.d.ts +0 -0
- /package/dist/{widget/hooks → hooks}/useTheme.d.ts +0 -0
- /package/dist/{widget/hooks → hooks}/useWalletConnectionContext.d.ts +0 -0
|
@@ -1,1761 +0,0 @@
|
|
|
1
|
-
import { Loader2, ArrowDown } from "lucide-react"
|
|
2
|
-
import type React from "react"
|
|
3
|
-
import { useCallback, useEffect, useMemo, useRef, useState } from "react"
|
|
4
|
-
import { isWithinCooldown, SECOND_MS } from "../../utils/time.js"
|
|
5
|
-
import { isValidNumber } from "../../utils/validation.js"
|
|
6
|
-
import { openPopup, setPopupUrl, closePopup } from "../utils/windowUtils.js"
|
|
7
|
-
import type { BaseProps, OnrampConfirmCallback } from "../types/commonProps.js"
|
|
8
|
-
import type { Token } from "../../tokens.js"
|
|
9
|
-
import { useSendForm, type OnCompleteProps } from "../hooks/useSendForm.js"
|
|
10
|
-
import { QuoteDetails } from "./QuoteDetails.js"
|
|
11
|
-
import { HighPriceImpactBlock } from "./HighPriceImpactBlock.js"
|
|
12
|
-
import { TradeType } from "../../prepareSend.js"
|
|
13
|
-
import { getChainInfo } from "../../chains.js"
|
|
14
|
-
import { ScreenHeader } from "./ScreenHeader.js"
|
|
15
|
-
import { TokenSelector } from "./TokenSelector.js"
|
|
16
|
-
import { useViewManager } from "../hooks/useViewManager.js"
|
|
17
|
-
import { useSwapState } from "../hooks/useSwapState.js"
|
|
18
|
-
import { logger } from "../../logger.js"
|
|
19
|
-
import { useSelectedRecipient } from "../hooks/useSelectedRecipient.js"
|
|
20
|
-
import { useOriginSelectedToken } from "../hooks/useOriginSelectedToken.js"
|
|
21
|
-
import { useDestinationSelectedToken } from "../hooks/useDestinationSelectedToken.js"
|
|
22
|
-
import { useFiatSelectedCurrency } from "../hooks/useFiatSelectedCurrency.js"
|
|
23
|
-
import { useBalanceVisible } from "../hooks/useBalanceVisible.js"
|
|
24
|
-
import { useDefaultOriginToken } from "../hooks/useDefaultOriginToken.js"
|
|
25
|
-
import { useDefaultDestinationToken } from "../hooks/useDefaultDestinationToken.js"
|
|
26
|
-
import { ChainList } from "./ChainList.js"
|
|
27
|
-
import { PercentageMaxButtons } from "./PercentageMaxButtons.js"
|
|
28
|
-
import { TokenSelectorButton } from "./TokenSelectorButton.js"
|
|
29
|
-
import { FundingMethodSelectorButton } from "./FundingMethodSelectorButton.js"
|
|
30
|
-
import { RecipientSelectorButton } from "./RecipientSelectorButton.js"
|
|
31
|
-
import { FiatSelectorButton } from "./FiatSelectorButton.js"
|
|
32
|
-
import { FiatSelector } from "./FiatSelector.js"
|
|
33
|
-
import { useOnRampCountryDefaults } from "../hooks/useOnRampCountryDefaults.js"
|
|
34
|
-
import { useFiatOnRampCurrencies } from "../hooks/useFiatOnRampCurrencies.js"
|
|
35
|
-
import { useOnRampQuote } from "../hooks/useOnRampQuote.js"
|
|
36
|
-
import { useOnRampProviderWidget } from "../hooks/useOnRampProviderWidget.js"
|
|
37
|
-
import { RefundWarning } from "./RefundWarning.js"
|
|
38
|
-
import { AddressWalletIcon } from "./AddressWalletIcon.js"
|
|
39
|
-
import { AddressOrEnsName } from "./AddressOrEnsName.js"
|
|
40
|
-
import { DynamicSizeInputField } from "./DynamicSizeInputField.js"
|
|
41
|
-
import { FeeOptions } from "./FeeOptions.js"
|
|
42
|
-
import { isFeeOptionDisabled } from "./FeeOption.js"
|
|
43
|
-
import type { ProcessedFeeOption } from "../hooks/useSelectedFeeOption.js"
|
|
44
|
-
import { isPassthroughEligible } from "../../utils/passthrough.js"
|
|
45
|
-
import {
|
|
46
|
-
formatRawAmount,
|
|
47
|
-
formatUsdAmountDisplay,
|
|
48
|
-
formatUsdAmountLocaleDisplay,
|
|
49
|
-
} from "../../utils/format.js"
|
|
50
|
-
import { useAccountTokenBalanceOnchain } from "../../query/balance.hooks.js"
|
|
51
|
-
import { base } from "viem/chains"
|
|
52
|
-
import { MeldProvidersList } from "../../meld/components/MeldProvidersList.js"
|
|
53
|
-
import type { OnrampQuote } from "../hooks/useOnRampQuote.js"
|
|
54
|
-
import { getFullErrorMessage, getPrettifiedErrorMessage } from "../../error.js"
|
|
55
|
-
import { ErrorDisplay } from "./ErrorDisplay.js"
|
|
56
|
-
import { useExchangeRate } from "../../query/fiat.hooks.js"
|
|
57
|
-
import { OnRampProviderSelector } from "./OnRampProviderSelector.js"
|
|
58
|
-
import { trackOnrampWidgetSession } from "../../analytics.js"
|
|
59
|
-
import { USDC_BASE } from "../../constants.js"
|
|
60
|
-
import LoadingSpinner from "./LoadingSpinner.js"
|
|
61
|
-
import { useWidgetProps } from "../hooks/useWidgetProps.js"
|
|
62
|
-
|
|
63
|
-
import { addressEqual } from "../../utils/address.js"
|
|
64
|
-
interface ClassicSwapProps extends BaseProps {
|
|
65
|
-
onWaitingForOnrampConfirm?: OnrampConfirmCallback
|
|
66
|
-
title?: string
|
|
67
|
-
exactInputOnly?: boolean
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
export const ClassicSwap: React.FC<ClassicSwapProps> = ({
|
|
71
|
-
selectedToken: initialSelectedToken,
|
|
72
|
-
onSend,
|
|
73
|
-
onBack,
|
|
74
|
-
onConfirm,
|
|
75
|
-
onComplete,
|
|
76
|
-
account,
|
|
77
|
-
toRecipient,
|
|
78
|
-
toAmount,
|
|
79
|
-
toChainId,
|
|
80
|
-
toToken,
|
|
81
|
-
toCalldata,
|
|
82
|
-
walletClient,
|
|
83
|
-
onTransactionStateChange,
|
|
84
|
-
onError,
|
|
85
|
-
onWaitingForWalletConfirm,
|
|
86
|
-
onWaitingForOnrampConfirm,
|
|
87
|
-
paymasterUrls,
|
|
88
|
-
setWalletConfirmRetryHandler,
|
|
89
|
-
swapProvider,
|
|
90
|
-
bridgeProvider,
|
|
91
|
-
swapProviderFallback,
|
|
92
|
-
bridgeProviderFallback,
|
|
93
|
-
fundMethod,
|
|
94
|
-
onAmountUpdate,
|
|
95
|
-
checkoutOnHandlers,
|
|
96
|
-
recentTokens,
|
|
97
|
-
onTrackToken,
|
|
98
|
-
title = "Swap",
|
|
99
|
-
isSequenceWallet = false,
|
|
100
|
-
exactInputOnly = false,
|
|
101
|
-
}) => {
|
|
102
|
-
const { fundOptions } = useWidgetProps()
|
|
103
|
-
const { mode, navigate } = useViewManager()
|
|
104
|
-
const { isBalanceVisible } = useBalanceVisible()
|
|
105
|
-
const {
|
|
106
|
-
selectedToken: originToken,
|
|
107
|
-
setSelectedToken: setOriginToken,
|
|
108
|
-
hasManualSelection: hasManualOriginSelection,
|
|
109
|
-
setHasManualSelection: setHasManualOriginSelection,
|
|
110
|
-
} = useOriginSelectedToken()
|
|
111
|
-
const {
|
|
112
|
-
selectedToken: destinationToken,
|
|
113
|
-
setSelectedToken: setDestinationToken,
|
|
114
|
-
hasManualSelection: hasManualDestinationSelection,
|
|
115
|
-
setHasManualSelection: setHasManualDestinationSelection,
|
|
116
|
-
isControlledByProps: isDestinationControlledByProps,
|
|
117
|
-
} = useDestinationSelectedToken()
|
|
118
|
-
const { selectedRecipient, setSelectedRecipient } = useSelectedRecipient()
|
|
119
|
-
const {
|
|
120
|
-
selectedCurrency: selectedFiatCurrency,
|
|
121
|
-
setSelectedCurrency: setSelectedFiatCurrency,
|
|
122
|
-
hasManualSelection: hasManualFiatSelection,
|
|
123
|
-
setHasManualSelection: setHasManualFiatSelection,
|
|
124
|
-
fiatAmount: sellFiatAmount,
|
|
125
|
-
setFiatAmount: setSellFiatAmount,
|
|
126
|
-
} = useFiatSelectedCurrency()
|
|
127
|
-
const [isFlipped, setIsFlipped] = useState(false)
|
|
128
|
-
const [showFiatSelector, setShowFiatSelector] = useState(false)
|
|
129
|
-
const [selectedCountryCode, setSelectedCountryCode] = useState<string | null>(
|
|
130
|
-
null,
|
|
131
|
-
)
|
|
132
|
-
const [showProviderSelector, setShowProviderSelector] = useState(false)
|
|
133
|
-
const [selectedOnrampProvider, setSelectedOnrampProvider] =
|
|
134
|
-
useState<OnrampQuote | null>(null)
|
|
135
|
-
|
|
136
|
-
// Check if onramp is active
|
|
137
|
-
const isMeldOnRampActive = fundMethod === "onramp-meld"
|
|
138
|
-
|
|
139
|
-
// Get country defaults when onramp is active
|
|
140
|
-
const {
|
|
141
|
-
countryCode: detectedCountryCode,
|
|
142
|
-
defaultCurrencyCode,
|
|
143
|
-
isLoading: isLoadingCountryDefaults,
|
|
144
|
-
} = useOnRampCountryDefaults({
|
|
145
|
-
enabled: isMeldOnRampActive,
|
|
146
|
-
})
|
|
147
|
-
|
|
148
|
-
// Use selected country if available, otherwise use detected country
|
|
149
|
-
const effectiveCountryCode = selectedCountryCode || detectedCountryCode
|
|
150
|
-
|
|
151
|
-
// Fetch fiat currencies when onramp is active
|
|
152
|
-
const { fiatCurrencies, isLoading: isLoadingFiatCurrencies } =
|
|
153
|
-
useFiatOnRampCurrencies({
|
|
154
|
-
countryCode: effectiveCountryCode || "US",
|
|
155
|
-
enabled: isMeldOnRampActive && !!effectiveCountryCode,
|
|
156
|
-
})
|
|
157
|
-
|
|
158
|
-
// Auto-select default currency when onramp is active and currencies are loaded
|
|
159
|
-
// Only auto-select if user hasn't manually selected a currency
|
|
160
|
-
useEffect(() => {
|
|
161
|
-
if (
|
|
162
|
-
isMeldOnRampActive &&
|
|
163
|
-
!selectedFiatCurrency &&
|
|
164
|
-
fiatCurrencies.length > 0 &&
|
|
165
|
-
!isLoadingCountryDefaults &&
|
|
166
|
-
!isLoadingFiatCurrencies &&
|
|
167
|
-
!hasManualFiatSelection
|
|
168
|
-
) {
|
|
169
|
-
// Use detected currency code, or fallback to USD if not detected
|
|
170
|
-
const currencyCodeToSelect = defaultCurrencyCode || "USD"
|
|
171
|
-
|
|
172
|
-
const defaultCurrency = fiatCurrencies.find(
|
|
173
|
-
(currency) => currency.currencyCode === currencyCodeToSelect,
|
|
174
|
-
)
|
|
175
|
-
|
|
176
|
-
if (defaultCurrency) {
|
|
177
|
-
logger.console.log(
|
|
178
|
-
"[ClassicSwap] Auto-selecting default currency:",
|
|
179
|
-
defaultCurrency,
|
|
180
|
-
defaultCurrencyCode ? "(detected)" : "(fallback to USD)",
|
|
181
|
-
)
|
|
182
|
-
setSelectedFiatCurrency(defaultCurrency)
|
|
183
|
-
}
|
|
184
|
-
}
|
|
185
|
-
}, [
|
|
186
|
-
isMeldOnRampActive,
|
|
187
|
-
selectedFiatCurrency,
|
|
188
|
-
defaultCurrencyCode,
|
|
189
|
-
fiatCurrencies,
|
|
190
|
-
isLoadingCountryDefaults,
|
|
191
|
-
isLoadingFiatCurrencies,
|
|
192
|
-
hasManualFiatSelection,
|
|
193
|
-
setSelectedFiatCurrency,
|
|
194
|
-
])
|
|
195
|
-
|
|
196
|
-
const lastAppliedConfiguredFiatRef = useRef<string | null>(null)
|
|
197
|
-
useEffect(() => {
|
|
198
|
-
if (!isMeldOnRampActive) {
|
|
199
|
-
lastAppliedConfiguredFiatRef.current = null
|
|
200
|
-
}
|
|
201
|
-
}, [isMeldOnRampActive])
|
|
202
|
-
|
|
203
|
-
useEffect(() => {
|
|
204
|
-
if (!isMeldOnRampActive || isLoadingFiatCurrencies) return
|
|
205
|
-
if (fiatCurrencies.length === 0) return
|
|
206
|
-
const configuredFiatCurrency = fundOptions?.fiatCurrency?.trim() || ""
|
|
207
|
-
const configuredFiatAmount = fundOptions?.fiatAmount?.trim() || ""
|
|
208
|
-
const configKey = `${configuredFiatCurrency.toUpperCase()}|${configuredFiatAmount}`
|
|
209
|
-
if (lastAppliedConfiguredFiatRef.current === configKey) return
|
|
210
|
-
lastAppliedConfiguredFiatRef.current = configKey
|
|
211
|
-
|
|
212
|
-
if (configuredFiatCurrency) {
|
|
213
|
-
const matchedCurrency = fiatCurrencies.find(
|
|
214
|
-
(currency) =>
|
|
215
|
-
currency.currencyCode.toUpperCase() ===
|
|
216
|
-
configuredFiatCurrency.toUpperCase(),
|
|
217
|
-
)
|
|
218
|
-
if (matchedCurrency) {
|
|
219
|
-
setSelectedFiatCurrency(matchedCurrency)
|
|
220
|
-
setHasManualFiatSelection(true)
|
|
221
|
-
}
|
|
222
|
-
}
|
|
223
|
-
|
|
224
|
-
if (configuredFiatAmount) {
|
|
225
|
-
setSellFiatAmount(configuredFiatAmount)
|
|
226
|
-
}
|
|
227
|
-
}, [
|
|
228
|
-
isMeldOnRampActive,
|
|
229
|
-
isLoadingFiatCurrencies,
|
|
230
|
-
fiatCurrencies,
|
|
231
|
-
fundOptions?.fiatCurrency,
|
|
232
|
-
fundOptions?.fiatAmount,
|
|
233
|
-
setSelectedFiatCurrency,
|
|
234
|
-
setHasManualFiatSelection,
|
|
235
|
-
setSellFiatAmount,
|
|
236
|
-
])
|
|
237
|
-
|
|
238
|
-
const normalizedConfiguredFiatCurrency =
|
|
239
|
-
fundOptions?.fiatCurrency?.trim().toUpperCase() || null
|
|
240
|
-
const isConfiguredFiatCurrencyApplied =
|
|
241
|
-
!!normalizedConfiguredFiatCurrency &&
|
|
242
|
-
!!selectedFiatCurrency &&
|
|
243
|
-
selectedFiatCurrency.currencyCode.toUpperCase() ===
|
|
244
|
-
normalizedConfiguredFiatCurrency
|
|
245
|
-
const isFiatCurrencyLocked =
|
|
246
|
-
isMeldOnRampActive && isConfiguredFiatCurrencyApplied
|
|
247
|
-
const isFiatAmountLocked = isMeldOnRampActive && !!fundOptions?.fiatAmount
|
|
248
|
-
|
|
249
|
-
// Use a ref to track user actions to prevent race conditions with async state updates
|
|
250
|
-
const userActionRef = useRef({
|
|
251
|
-
hasManualDestinationSelection: false,
|
|
252
|
-
lastOriginSelectionTime: 0,
|
|
253
|
-
lastDestinationSelectionTime: 0,
|
|
254
|
-
})
|
|
255
|
-
|
|
256
|
-
// Use separated default token selection hooks
|
|
257
|
-
const { defaultOriginToken, isLoading: isLoadingOriginDefaults } =
|
|
258
|
-
useDefaultOriginToken()
|
|
259
|
-
|
|
260
|
-
const { defaultDestinationToken, isLoading: isLoadingDestinationDefaults } =
|
|
261
|
-
useDefaultDestinationToken(originToken)
|
|
262
|
-
|
|
263
|
-
const [originChainId, setOriginChainId] = useState<number | null | undefined>(
|
|
264
|
-
initialSelectedToken?.chainId || originToken?.chainId,
|
|
265
|
-
)
|
|
266
|
-
const {
|
|
267
|
-
tradeType: globalTradeType,
|
|
268
|
-
setTradeType,
|
|
269
|
-
sellAmount,
|
|
270
|
-
setSellAmount,
|
|
271
|
-
buyAmount,
|
|
272
|
-
setBuyAmount,
|
|
273
|
-
resetSwapState,
|
|
274
|
-
enterFormMode,
|
|
275
|
-
} = useSwapState()
|
|
276
|
-
|
|
277
|
-
// Reset swap state only when switching between different form modes
|
|
278
|
-
// biome-ignore lint/correctness/useExhaustiveDependencies: Only run on mount to register form mode
|
|
279
|
-
useEffect(() => {
|
|
280
|
-
enterFormMode("swap")
|
|
281
|
-
}, [])
|
|
282
|
-
|
|
283
|
-
const tradeType = globalTradeType || TradeType.EXACT_INPUT
|
|
284
|
-
const [isCreatingWidgetSession, setIsCreatingWidgetSession] = useState(false)
|
|
285
|
-
const [widgetError, setWidgetError] = useState<string | null>(null)
|
|
286
|
-
|
|
287
|
-
const handleCompleteAndClearAmounts = useCallback(
|
|
288
|
-
(result: OnCompleteProps) => {
|
|
289
|
-
setSellFiatAmount("")
|
|
290
|
-
resetSwapState()
|
|
291
|
-
onComplete(result)
|
|
292
|
-
},
|
|
293
|
-
[onComplete, resetSwapState, setSellFiatAmount],
|
|
294
|
-
)
|
|
295
|
-
|
|
296
|
-
// Initialize and update selected recipient from toRecipient prop (but don't auto-set to account address)
|
|
297
|
-
// biome-ignore lint/correctness/useExhaustiveDependencies: selectedRecipient is intentionally excluded to avoid infinite loops
|
|
298
|
-
useEffect(() => {
|
|
299
|
-
logger.console.log("[trails-sdk] ClassicSwap toRecipient prop effect:", {
|
|
300
|
-
toRecipient,
|
|
301
|
-
selectedRecipient,
|
|
302
|
-
accountAddress: account?.address,
|
|
303
|
-
})
|
|
304
|
-
|
|
305
|
-
if (toRecipient) {
|
|
306
|
-
// Always sync with toRecipient prop when it changes
|
|
307
|
-
logger.console.log(
|
|
308
|
-
"[trails-sdk] ClassicSwap Setting selectedRecipient to toRecipient:",
|
|
309
|
-
toRecipient,
|
|
310
|
-
)
|
|
311
|
-
setSelectedRecipient(toRecipient)
|
|
312
|
-
}
|
|
313
|
-
// Don't auto-set to account.address - let user select via RecipientSelectorButton
|
|
314
|
-
}, [toRecipient, setSelectedRecipient])
|
|
315
|
-
|
|
316
|
-
const effectiveRecipient =
|
|
317
|
-
selectedRecipient || toRecipient || account?.address
|
|
318
|
-
|
|
319
|
-
const effectiveFundMethod = isMeldOnRampActive ? "onramp-meld" : fundMethod
|
|
320
|
-
const skipBalanceFetch =
|
|
321
|
-
effectiveFundMethod === "onramp-meld" ||
|
|
322
|
-
effectiveFundMethod === "direct-transfer" ||
|
|
323
|
-
effectiveFundMethod === "onramp-mesh"
|
|
324
|
-
|
|
325
|
-
// Get onramp quote when onramp is active
|
|
326
|
-
const {
|
|
327
|
-
quotes: onrampQuotes,
|
|
328
|
-
selectedQuote: autoSelectedOnrampQuote,
|
|
329
|
-
isLoading: isLoadingOnrampQuote,
|
|
330
|
-
error: onrampQuoteError,
|
|
331
|
-
onrampTrackingData,
|
|
332
|
-
} = useOnRampQuote({
|
|
333
|
-
amount: sellFiatAmount,
|
|
334
|
-
sourceCurrencyCode: selectedFiatCurrency?.currencyCode,
|
|
335
|
-
destinationCurrencyCode: "USDC_BASE",
|
|
336
|
-
countryCode: effectiveCountryCode || undefined,
|
|
337
|
-
walletAddress: account?.address || "",
|
|
338
|
-
enabled:
|
|
339
|
-
isMeldOnRampActive &&
|
|
340
|
-
!!sellFiatAmount &&
|
|
341
|
-
!!selectedFiatCurrency &&
|
|
342
|
-
!!effectiveCountryCode &&
|
|
343
|
-
!!effectiveRecipient,
|
|
344
|
-
})
|
|
345
|
-
|
|
346
|
-
const {
|
|
347
|
-
amount,
|
|
348
|
-
amountRaw,
|
|
349
|
-
amountUsdDisplay,
|
|
350
|
-
amountUsdLocaleDisplay,
|
|
351
|
-
balanceFormatted,
|
|
352
|
-
balanceRaw,
|
|
353
|
-
tokenDecimals,
|
|
354
|
-
handleSubmit,
|
|
355
|
-
isSubmitting,
|
|
356
|
-
isLoadingQuote,
|
|
357
|
-
selectedDestinationChain,
|
|
358
|
-
selectedDestToken,
|
|
359
|
-
setSelectedDestinationChain,
|
|
360
|
-
setSelectedDestToken,
|
|
361
|
-
buttonText,
|
|
362
|
-
toAmountDisplay,
|
|
363
|
-
destinationTokenAddress,
|
|
364
|
-
isValidCustomToken,
|
|
365
|
-
prepareSendQuote,
|
|
366
|
-
quoteError,
|
|
367
|
-
processedFeeOptions,
|
|
368
|
-
selectedFeeOption,
|
|
369
|
-
setSelectedFeeOption,
|
|
370
|
-
sendFn,
|
|
371
|
-
} = useSendForm({
|
|
372
|
-
account,
|
|
373
|
-
toAmount: tradeType === TradeType.EXACT_OUTPUT ? buyAmount : toAmount,
|
|
374
|
-
fromAmount: tradeType === TradeType.EXACT_INPUT ? sellAmount : undefined,
|
|
375
|
-
toRecipient: effectiveRecipient,
|
|
376
|
-
toChainId,
|
|
377
|
-
toToken,
|
|
378
|
-
toCalldata,
|
|
379
|
-
walletClient,
|
|
380
|
-
onTransactionStateChange,
|
|
381
|
-
onError,
|
|
382
|
-
onWaitingForWalletConfirm,
|
|
383
|
-
onWaitingForOnrampConfirm,
|
|
384
|
-
paymasterUrls,
|
|
385
|
-
onSend,
|
|
386
|
-
onConfirm,
|
|
387
|
-
onComplete: handleCompleteAndClearAmounts,
|
|
388
|
-
selectedToken: originToken ?? undefined,
|
|
389
|
-
setWalletConfirmRetryHandler,
|
|
390
|
-
tradeType: tradeType,
|
|
391
|
-
swapProvider,
|
|
392
|
-
bridgeProvider,
|
|
393
|
-
swapProviderFallback,
|
|
394
|
-
bridgeProviderFallback,
|
|
395
|
-
fundMethod: effectiveFundMethod,
|
|
396
|
-
mode,
|
|
397
|
-
checkoutOnHandlers,
|
|
398
|
-
onrampTrackingData: isMeldOnRampActive ? onrampTrackingData : null,
|
|
399
|
-
// Skip fee balance fetching for onramp/direct-transfer modes where fee options aren't shown
|
|
400
|
-
skipFeeBalanceFetch:
|
|
401
|
-
effectiveFundMethod === "onramp-meld" ||
|
|
402
|
-
effectiveFundMethod === "direct-transfer" ||
|
|
403
|
-
effectiveFundMethod === "onramp-mesh",
|
|
404
|
-
})
|
|
405
|
-
|
|
406
|
-
const selectedOnrampProviderQuote =
|
|
407
|
-
selectedOnrampProvider || autoSelectedOnrampQuote
|
|
408
|
-
|
|
409
|
-
// Get exchange rate for onramp fee conversion to USD
|
|
410
|
-
const {
|
|
411
|
-
exchangeRate: fiatToUsdExchangeRate,
|
|
412
|
-
isLoading: isLoadingFiatToUsdExchangeRate,
|
|
413
|
-
} = useExchangeRate({
|
|
414
|
-
fromCurrency: "USD",
|
|
415
|
-
toCurrency: selectedOnrampProviderQuote?.sourceCurrencyCode || "USD",
|
|
416
|
-
disabled:
|
|
417
|
-
!selectedOnrampProviderQuote ||
|
|
418
|
-
selectedOnrampProviderQuote?.sourceCurrencyCode === "USD",
|
|
419
|
-
})
|
|
420
|
-
|
|
421
|
-
// Hook to create onramp widget session
|
|
422
|
-
const {
|
|
423
|
-
createWidgetSession,
|
|
424
|
-
isLoading: isLoadingWidgetSession,
|
|
425
|
-
error: widgetSessionError,
|
|
426
|
-
} = useOnRampProviderWidget()
|
|
427
|
-
|
|
428
|
-
// If we are on ramping lock the origin token and origin chain to USDC BASE
|
|
429
|
-
// Also ensure tradeType is EXACT_INPUT (disable exact output mode)
|
|
430
|
-
useEffect(() => {
|
|
431
|
-
if (isMeldOnRampActive) {
|
|
432
|
-
// Find USDC on Base from supported tokens (correct Base USDC address)
|
|
433
|
-
const usdcBaseToken = USDC_BASE
|
|
434
|
-
logger.console.log(
|
|
435
|
-
"[ClassicSwap] Setting origin token to USDC on Base:",
|
|
436
|
-
usdcBaseToken,
|
|
437
|
-
)
|
|
438
|
-
setOriginToken(usdcBaseToken)
|
|
439
|
-
setOriginChainId(base.id)
|
|
440
|
-
|
|
441
|
-
// Ensure tradeType is EXACT_INPUT when onramp is active
|
|
442
|
-
setTradeType(TradeType.EXACT_INPUT)
|
|
443
|
-
}
|
|
444
|
-
}, [isMeldOnRampActive, setOriginToken, setTradeType])
|
|
445
|
-
|
|
446
|
-
// Get destination token with fresh balance
|
|
447
|
-
const { token: freshDestinationToken } = useAccountTokenBalanceOnchain(
|
|
448
|
-
destinationToken,
|
|
449
|
-
account?.address,
|
|
450
|
-
{ disabled: skipBalanceFetch },
|
|
451
|
-
)
|
|
452
|
-
|
|
453
|
-
// Get origin token with fresh balance for fee option checks
|
|
454
|
-
const {
|
|
455
|
-
token: freshOriginToken,
|
|
456
|
-
isLoadingBalance: isLoadingFreshOriginBalance,
|
|
457
|
-
} = useAccountTokenBalanceOnchain(originToken, account?.address, {
|
|
458
|
-
disabled: skipBalanceFetch,
|
|
459
|
-
})
|
|
460
|
-
|
|
461
|
-
const destinationBalanceDisplay = useMemo(() => {
|
|
462
|
-
if (!freshDestinationToken) return "0.00"
|
|
463
|
-
try {
|
|
464
|
-
return formatRawAmount(
|
|
465
|
-
freshDestinationToken.balance || "0",
|
|
466
|
-
freshDestinationToken.decimals ?? 18,
|
|
467
|
-
)
|
|
468
|
-
} catch (err) {
|
|
469
|
-
logger.console.error("[trails-sdk] balance format failed", err)
|
|
470
|
-
return "0.00"
|
|
471
|
-
}
|
|
472
|
-
}, [freshDestinationToken])
|
|
473
|
-
|
|
474
|
-
const handleSellFiatAmountChange = useCallback(
|
|
475
|
-
(value: string) => {
|
|
476
|
-
setWidgetError(null)
|
|
477
|
-
setSellFiatAmount(value)
|
|
478
|
-
},
|
|
479
|
-
[setSellFiatAmount],
|
|
480
|
-
)
|
|
481
|
-
|
|
482
|
-
// Handle sell amount input changes
|
|
483
|
-
const handleSellAmountChange = useCallback(
|
|
484
|
-
(value: string) => {
|
|
485
|
-
// Strip leading zeros unless it's a decimal (e.g., "0.5" is valid, "05" becomes "5")
|
|
486
|
-
let processedValue = value
|
|
487
|
-
if (value.length > 1 && value.startsWith("0") && value[1] !== ".") {
|
|
488
|
-
processedValue = value.replace(/^0+/, "") || "0"
|
|
489
|
-
}
|
|
490
|
-
setTradeType(TradeType.EXACT_INPUT)
|
|
491
|
-
setSellAmount(processedValue)
|
|
492
|
-
},
|
|
493
|
-
[setTradeType, setSellAmount],
|
|
494
|
-
)
|
|
495
|
-
|
|
496
|
-
// Handle sell input focus
|
|
497
|
-
const handleSellInputFocus = useCallback(() => {
|
|
498
|
-
// Copy displayed value for editing
|
|
499
|
-
if (
|
|
500
|
-
tradeType === TradeType.EXACT_OUTPUT &&
|
|
501
|
-
prepareSendQuote?.originAmountDisplay &&
|
|
502
|
-
!sellAmount
|
|
503
|
-
) {
|
|
504
|
-
setSellAmount(prepareSendQuote.originAmountDisplay)
|
|
505
|
-
}
|
|
506
|
-
}, [
|
|
507
|
-
tradeType,
|
|
508
|
-
prepareSendQuote?.originAmountDisplay,
|
|
509
|
-
sellAmount,
|
|
510
|
-
setSellAmount,
|
|
511
|
-
])
|
|
512
|
-
|
|
513
|
-
// Handle buy amount input changes
|
|
514
|
-
const handleBuyAmountChange = useCallback(
|
|
515
|
-
(value: string) => {
|
|
516
|
-
// Disable exact output mode when onramp is active or exactInputOnly is enabled
|
|
517
|
-
if (isMeldOnRampActive || exactInputOnly) {
|
|
518
|
-
return
|
|
519
|
-
}
|
|
520
|
-
|
|
521
|
-
// Strip leading zeros unless it's a decimal (e.g., "0.5" is valid, "05" becomes "5")
|
|
522
|
-
let processedValue = value
|
|
523
|
-
if (value.length > 1 && value.startsWith("0") && value[1] !== ".") {
|
|
524
|
-
processedValue = value.replace(/^0+/, "") || "0"
|
|
525
|
-
}
|
|
526
|
-
setTradeType(TradeType.EXACT_OUTPUT)
|
|
527
|
-
setBuyAmount(processedValue)
|
|
528
|
-
},
|
|
529
|
-
[isMeldOnRampActive, exactInputOnly, setTradeType, setBuyAmount],
|
|
530
|
-
)
|
|
531
|
-
|
|
532
|
-
// Handle buy input focus
|
|
533
|
-
const handleBuyInputFocus = useCallback(() => {
|
|
534
|
-
// Disable exact output mode when onramp is active or exactInputOnly is enabled
|
|
535
|
-
if (isMeldOnRampActive || exactInputOnly) {
|
|
536
|
-
return
|
|
537
|
-
}
|
|
538
|
-
|
|
539
|
-
// Copy displayed value for editing
|
|
540
|
-
if (tradeType === TradeType.EXACT_INPUT && toAmountDisplay && !buyAmount) {
|
|
541
|
-
setBuyAmount(toAmountDisplay)
|
|
542
|
-
}
|
|
543
|
-
}, [
|
|
544
|
-
tradeType,
|
|
545
|
-
toAmountDisplay,
|
|
546
|
-
buyAmount,
|
|
547
|
-
isMeldOnRampActive,
|
|
548
|
-
exactInputOnly,
|
|
549
|
-
setBuyAmount,
|
|
550
|
-
])
|
|
551
|
-
|
|
552
|
-
// Check if we received a quote from on ramp for USDC BASE, if so set the origin token amount to the quote.destinationAmount
|
|
553
|
-
// This will trigger useSendForm to get the trails quote
|
|
554
|
-
// Subtract 0.25 USDC from the amount to cover fees
|
|
555
|
-
useEffect(() => {
|
|
556
|
-
if (
|
|
557
|
-
isMeldOnRampActive &&
|
|
558
|
-
selectedOnrampProviderQuote &&
|
|
559
|
-
originToken &&
|
|
560
|
-
originToken.contractAddress
|
|
561
|
-
) {
|
|
562
|
-
// Subtract 0.25 USDC from the destination amount to cover fees
|
|
563
|
-
const destinationAmount = Number(
|
|
564
|
-
selectedOnrampProviderQuote.destinationAmount,
|
|
565
|
-
)
|
|
566
|
-
const adjustedAmount = Math.max(0, destinationAmount - 0.25)
|
|
567
|
-
|
|
568
|
-
logger.console.log("[trails-sdk] Adjusting onramp amount for fees:", {
|
|
569
|
-
originalAmount: destinationAmount,
|
|
570
|
-
adjustedAmount,
|
|
571
|
-
feeSubtracted: 0.25,
|
|
572
|
-
})
|
|
573
|
-
|
|
574
|
-
setSellAmount(adjustedAmount.toString())
|
|
575
|
-
setTradeType(TradeType.EXACT_INPUT)
|
|
576
|
-
}
|
|
577
|
-
}, [
|
|
578
|
-
isMeldOnRampActive,
|
|
579
|
-
selectedOnrampProviderQuote,
|
|
580
|
-
originToken,
|
|
581
|
-
setSellAmount,
|
|
582
|
-
setTradeType,
|
|
583
|
-
])
|
|
584
|
-
|
|
585
|
-
// Update amounts when quote is received
|
|
586
|
-
// Always update the calculated field based on the current trade type
|
|
587
|
-
useEffect(() => {
|
|
588
|
-
if (!prepareSendQuote) return
|
|
589
|
-
|
|
590
|
-
if (
|
|
591
|
-
tradeType === TradeType.EXACT_OUTPUT &&
|
|
592
|
-
prepareSendQuote.originAmountDisplay
|
|
593
|
-
) {
|
|
594
|
-
// In EXACT_OUTPUT mode, update sellAmount from the quote
|
|
595
|
-
setSellAmount(prepareSendQuote.originAmountDisplay)
|
|
596
|
-
} else if (
|
|
597
|
-
tradeType === TradeType.EXACT_INPUT &&
|
|
598
|
-
prepareSendQuote.destinationAmountDisplay
|
|
599
|
-
) {
|
|
600
|
-
// In EXACT_INPUT mode, update buyAmount from the quote
|
|
601
|
-
setBuyAmount(prepareSendQuote.destinationAmountDisplay)
|
|
602
|
-
}
|
|
603
|
-
}, [prepareSendQuote, tradeType, setSellAmount, setBuyAmount])
|
|
604
|
-
|
|
605
|
-
// Call onAmountUpdate when amountRaw changes
|
|
606
|
-
useEffect(() => {
|
|
607
|
-
if (onAmountUpdate) {
|
|
608
|
-
onAmountUpdate(amountRaw)
|
|
609
|
-
}
|
|
610
|
-
}, [amountRaw, onAmountUpdate])
|
|
611
|
-
|
|
612
|
-
// Reset the flag so auto-selection can work as a fallback if has manual origin token is cleared
|
|
613
|
-
useEffect(() => {
|
|
614
|
-
if (hasManualOriginSelection && !originToken && !isLoadingOriginDefaults) {
|
|
615
|
-
logger.console.log(
|
|
616
|
-
"[trails-sdk] Resetting hasManualOriginSelection - token was cleared",
|
|
617
|
-
)
|
|
618
|
-
setHasManualOriginSelection(false)
|
|
619
|
-
}
|
|
620
|
-
}, [
|
|
621
|
-
hasManualOriginSelection,
|
|
622
|
-
originToken,
|
|
623
|
-
isLoadingOriginDefaults,
|
|
624
|
-
setHasManualOriginSelection,
|
|
625
|
-
])
|
|
626
|
-
|
|
627
|
-
// Auto-select origin token using separated hook
|
|
628
|
-
useEffect(() => {
|
|
629
|
-
if (
|
|
630
|
-
!originToken &&
|
|
631
|
-
!isLoadingOriginDefaults &&
|
|
632
|
-
defaultOriginToken &&
|
|
633
|
-
!hasManualOriginSelection
|
|
634
|
-
) {
|
|
635
|
-
logger.console.log(
|
|
636
|
-
"[trails-sdk] Auto-selecting origin token:",
|
|
637
|
-
defaultOriginToken,
|
|
638
|
-
)
|
|
639
|
-
setOriginToken(defaultOriginToken)
|
|
640
|
-
setOriginChainId(defaultOriginToken.chainId)
|
|
641
|
-
}
|
|
642
|
-
}, [
|
|
643
|
-
originToken,
|
|
644
|
-
isLoadingOriginDefaults,
|
|
645
|
-
defaultOriginToken,
|
|
646
|
-
setOriginToken,
|
|
647
|
-
hasManualOriginSelection,
|
|
648
|
-
])
|
|
649
|
-
|
|
650
|
-
// Auto-select destination token using separated hook
|
|
651
|
-
// Note: In swap mode, we still auto-select a destination even if toToken is provided,
|
|
652
|
-
// since the user needs a starting point to modify
|
|
653
|
-
// IMPORTANT: Only auto-select if user hasn't made manual selections to prevent override
|
|
654
|
-
useEffect(() => {
|
|
655
|
-
// hasManualOriginSelection is now persisted in context across component mounts
|
|
656
|
-
const hasRecentOriginSelection =
|
|
657
|
-
hasManualOriginSelection ||
|
|
658
|
-
isWithinCooldown(userActionRef.current.lastOriginSelectionTime, SECOND_MS)
|
|
659
|
-
|
|
660
|
-
const hasRecentDestSelection =
|
|
661
|
-
userActionRef.current.hasManualDestinationSelection ||
|
|
662
|
-
hasManualDestinationSelection ||
|
|
663
|
-
isWithinCooldown(
|
|
664
|
-
userActionRef.current.lastDestinationSelectionTime,
|
|
665
|
-
SECOND_MS,
|
|
666
|
-
)
|
|
667
|
-
|
|
668
|
-
// If destination is controlled via props, do not auto-select/override it.
|
|
669
|
-
const isDestinationControlled = !!toToken && !!toChainId
|
|
670
|
-
|
|
671
|
-
if (
|
|
672
|
-
!isDestinationControlled &&
|
|
673
|
-
!destinationToken &&
|
|
674
|
-
!isLoadingDestinationDefaults &&
|
|
675
|
-
defaultDestinationToken &&
|
|
676
|
-
!hasRecentDestSelection &&
|
|
677
|
-
!hasRecentOriginSelection // Don't auto-select destination if user recently selected origin
|
|
678
|
-
) {
|
|
679
|
-
logger.console.log(
|
|
680
|
-
"[trails-sdk] Auto-selecting destination token:",
|
|
681
|
-
defaultDestinationToken,
|
|
682
|
-
)
|
|
683
|
-
setDestinationToken(defaultDestinationToken)
|
|
684
|
-
setSelectedDestToken(defaultDestinationToken)
|
|
685
|
-
|
|
686
|
-
// Also set the destination chain
|
|
687
|
-
const chainInfo = getChainInfo(defaultDestinationToken.chainId)
|
|
688
|
-
if (chainInfo) {
|
|
689
|
-
setSelectedDestinationChain(chainInfo)
|
|
690
|
-
}
|
|
691
|
-
}
|
|
692
|
-
}, [
|
|
693
|
-
destinationToken,
|
|
694
|
-
isLoadingDestinationDefaults,
|
|
695
|
-
defaultDestinationToken,
|
|
696
|
-
hasManualDestinationSelection,
|
|
697
|
-
hasManualOriginSelection,
|
|
698
|
-
setDestinationToken,
|
|
699
|
-
setSelectedDestToken,
|
|
700
|
-
setSelectedDestinationChain,
|
|
701
|
-
toToken,
|
|
702
|
-
toChainId,
|
|
703
|
-
])
|
|
704
|
-
|
|
705
|
-
// Auto-focus the input field when component mounts
|
|
706
|
-
useEffect(() => {
|
|
707
|
-
if (inputRef.current) {
|
|
708
|
-
inputRef.current.focus()
|
|
709
|
-
}
|
|
710
|
-
}, [])
|
|
711
|
-
|
|
712
|
-
const inputRef = useRef<HTMLInputElement>(null)
|
|
713
|
-
|
|
714
|
-
const [showSourceTokenSelector, setShowSourceTokenSelector] = useState(false)
|
|
715
|
-
const [showDestinationTokenSelector, setShowDestinationTokenSelector] =
|
|
716
|
-
useState(false)
|
|
717
|
-
const [showSourceChainList, setShowSourceChainList] = useState(false)
|
|
718
|
-
const [showDestinationChainList, setShowDestinationChainList] =
|
|
719
|
-
useState(false)
|
|
720
|
-
|
|
721
|
-
// Sync destination token from hook with useSendForm
|
|
722
|
-
// This ensures the destination token auto-selection flows into useSendForm
|
|
723
|
-
useEffect(() => {
|
|
724
|
-
// If destination is controlled via props, don't sync context destination into useSendForm.
|
|
725
|
-
if (toToken && toChainId) return
|
|
726
|
-
if (destinationToken) {
|
|
727
|
-
logger.console.log(
|
|
728
|
-
"[trails-sdk] Syncing destination token to useSendForm:",
|
|
729
|
-
destinationToken,
|
|
730
|
-
)
|
|
731
|
-
setSelectedDestToken(destinationToken)
|
|
732
|
-
}
|
|
733
|
-
}, [destinationToken, setSelectedDestToken, toToken, toChainId])
|
|
734
|
-
|
|
735
|
-
// Sync resolved token from useSendForm back to global provider
|
|
736
|
-
// This handles the case where toToken is not in supported tokens and useSendForm resolves it
|
|
737
|
-
useEffect(() => {
|
|
738
|
-
// Skip if not controlled by props or no resolved token
|
|
739
|
-
if (!isDestinationControlledByProps || !selectedDestToken || !toToken) {
|
|
740
|
-
return
|
|
741
|
-
}
|
|
742
|
-
|
|
743
|
-
// Check if the resolved token matches what we're looking for
|
|
744
|
-
const chainIdMatches = selectedDestToken.chainId === Number(toChainId)
|
|
745
|
-
const tokenMatches =
|
|
746
|
-
selectedDestToken.contractAddress?.toLowerCase() ===
|
|
747
|
-
toToken.toLowerCase() ||
|
|
748
|
-
selectedDestToken.symbol?.toLowerCase() === toToken.toLowerCase()
|
|
749
|
-
|
|
750
|
-
// Only sync if the token matches the toToken prop
|
|
751
|
-
if (chainIdMatches && tokenMatches) {
|
|
752
|
-
const globalMatches =
|
|
753
|
-
destinationToken &&
|
|
754
|
-
destinationToken.chainId === selectedDestToken.chainId &&
|
|
755
|
-
destinationToken.contractAddress?.toLowerCase() ===
|
|
756
|
-
selectedDestToken.contractAddress?.toLowerCase()
|
|
757
|
-
|
|
758
|
-
if (!globalMatches) {
|
|
759
|
-
logger.console.log(
|
|
760
|
-
"[trails-sdk] ClassicSwap: Syncing resolved token from useSendForm to global provider:",
|
|
761
|
-
selectedDestToken.symbol,
|
|
762
|
-
)
|
|
763
|
-
setDestinationToken(selectedDestToken)
|
|
764
|
-
}
|
|
765
|
-
}
|
|
766
|
-
}, [
|
|
767
|
-
isDestinationControlledByProps,
|
|
768
|
-
selectedDestToken,
|
|
769
|
-
destinationToken,
|
|
770
|
-
setDestinationToken,
|
|
771
|
-
toToken,
|
|
772
|
-
toChainId,
|
|
773
|
-
])
|
|
774
|
-
|
|
775
|
-
// Handle flip functionality
|
|
776
|
-
const handleFlip = useCallback(() => {
|
|
777
|
-
if (!selectedDestinationChain || !originToken || !selectedDestToken) return
|
|
778
|
-
|
|
779
|
-
// Don't flip if recipient is not the sender/from address
|
|
780
|
-
if (
|
|
781
|
-
effectiveRecipient &&
|
|
782
|
-
account?.address &&
|
|
783
|
-
!addressEqual(effectiveRecipient, account.address)
|
|
784
|
-
) {
|
|
785
|
-
return
|
|
786
|
-
}
|
|
787
|
-
|
|
788
|
-
setIsFlipped(!isFlipped)
|
|
789
|
-
|
|
790
|
-
// Store current values
|
|
791
|
-
const tempOriginToken = originToken
|
|
792
|
-
const tempOriginChainId = originChainId
|
|
793
|
-
const tempBuyAmount = buyAmount || toAmountDisplay || ""
|
|
794
|
-
const tempSellAmount = sellAmount || amount || ""
|
|
795
|
-
|
|
796
|
-
// Swap origin and destination using hooks
|
|
797
|
-
setOriginToken(selectedDestToken)
|
|
798
|
-
setDestinationToken(tempOriginToken)
|
|
799
|
-
setOriginChainId(selectedDestToken?.chainId)
|
|
800
|
-
setSelectedDestToken(tempOriginToken)
|
|
801
|
-
|
|
802
|
-
// Update destination chain
|
|
803
|
-
const newChain = getChainInfo(tempOriginChainId ?? undefined)
|
|
804
|
-
if (newChain) {
|
|
805
|
-
setSelectedDestinationChain(newChain)
|
|
806
|
-
}
|
|
807
|
-
|
|
808
|
-
// Flipping is an intentional user action, so maintain manual selection state
|
|
809
|
-
// Both tokens are still manually selected, just swapped
|
|
810
|
-
if (hasManualOriginSelection || hasManualDestinationSelection) {
|
|
811
|
-
setHasManualOriginSelection(true)
|
|
812
|
-
setHasManualDestinationSelection(true)
|
|
813
|
-
}
|
|
814
|
-
|
|
815
|
-
if (exactInputOnly) {
|
|
816
|
-
// When exactInputOnly is enabled, always maintain EXACT_INPUT mode
|
|
817
|
-
// Move the sell amount to the new origin (what was destination)
|
|
818
|
-
setSellAmount(tempSellAmount)
|
|
819
|
-
setBuyAmount("") // Clear buy amount to get fresh quote
|
|
820
|
-
setTradeType(TradeType.EXACT_INPUT)
|
|
821
|
-
} else {
|
|
822
|
-
// Normal flip behavior - switch trade types
|
|
823
|
-
if (tradeType === TradeType.EXACT_INPUT) {
|
|
824
|
-
// Move the user-entered sell amount into the buy field and treat it as exact output
|
|
825
|
-
setBuyAmount(tempSellAmount)
|
|
826
|
-
setSellAmount("")
|
|
827
|
-
setTradeType(TradeType.EXACT_OUTPUT)
|
|
828
|
-
} else {
|
|
829
|
-
// If we were in EXACT_OUTPUT, use the current buy amount as the new sell amount
|
|
830
|
-
setSellAmount(tempBuyAmount)
|
|
831
|
-
setBuyAmount("")
|
|
832
|
-
setTradeType(TradeType.EXACT_INPUT)
|
|
833
|
-
}
|
|
834
|
-
}
|
|
835
|
-
}, [
|
|
836
|
-
originToken,
|
|
837
|
-
selectedDestinationChain,
|
|
838
|
-
selectedDestToken,
|
|
839
|
-
originChainId,
|
|
840
|
-
setOriginToken,
|
|
841
|
-
setDestinationToken,
|
|
842
|
-
setSelectedDestToken,
|
|
843
|
-
setSelectedDestinationChain,
|
|
844
|
-
isFlipped,
|
|
845
|
-
hasManualOriginSelection,
|
|
846
|
-
hasManualDestinationSelection,
|
|
847
|
-
setHasManualOriginSelection,
|
|
848
|
-
setHasManualDestinationSelection,
|
|
849
|
-
exactInputOnly,
|
|
850
|
-
tradeType,
|
|
851
|
-
toAmountDisplay,
|
|
852
|
-
sellAmount,
|
|
853
|
-
buyAmount,
|
|
854
|
-
amount,
|
|
855
|
-
setSellAmount,
|
|
856
|
-
setBuyAmount,
|
|
857
|
-
setTradeType,
|
|
858
|
-
effectiveRecipient,
|
|
859
|
-
account?.address,
|
|
860
|
-
])
|
|
861
|
-
|
|
862
|
-
// Handle source token selection from full-screen selector
|
|
863
|
-
const handleSourceTokenSelectorSelect = useCallback(
|
|
864
|
-
(token: Token) => {
|
|
865
|
-
// Only flip if it's the exact same token (same contract address AND chain ID)
|
|
866
|
-
if (
|
|
867
|
-
token.contractAddress === destinationToken?.contractAddress &&
|
|
868
|
-
token.chainId === destinationToken?.chainId
|
|
869
|
-
) {
|
|
870
|
-
handleFlip()
|
|
871
|
-
}
|
|
872
|
-
|
|
873
|
-
// Only reset input fields if the token symbol is different
|
|
874
|
-
const isDifferentToken =
|
|
875
|
-
!originToken || originToken.symbol !== token.symbol
|
|
876
|
-
if (isDifferentToken) {
|
|
877
|
-
setSellAmount("")
|
|
878
|
-
setBuyAmount("")
|
|
879
|
-
setTradeType(TradeType.EXACT_INPUT)
|
|
880
|
-
}
|
|
881
|
-
|
|
882
|
-
setOriginToken(token)
|
|
883
|
-
setOriginChainId(token.chainId)
|
|
884
|
-
setShowSourceTokenSelector(false)
|
|
885
|
-
|
|
886
|
-
// Mark as manual selection to prevent auto-selection override
|
|
887
|
-
setHasManualOriginSelection(true)
|
|
888
|
-
userActionRef.current.lastOriginSelectionTime = Date.now()
|
|
889
|
-
|
|
890
|
-
onTrackToken?.(token)
|
|
891
|
-
logger.console.log("[trails-sdk] selected origin token", token)
|
|
892
|
-
},
|
|
893
|
-
[
|
|
894
|
-
setOriginToken,
|
|
895
|
-
setHasManualOriginSelection,
|
|
896
|
-
onTrackToken,
|
|
897
|
-
originToken,
|
|
898
|
-
handleFlip,
|
|
899
|
-
destinationToken,
|
|
900
|
-
setSellAmount,
|
|
901
|
-
setBuyAmount,
|
|
902
|
-
setTradeType,
|
|
903
|
-
],
|
|
904
|
-
)
|
|
905
|
-
|
|
906
|
-
// Handle destination token selection from full-screen selector
|
|
907
|
-
const handleDestinationTokenSelectorSelect = useCallback(
|
|
908
|
-
(token: Token) => {
|
|
909
|
-
// Only flip if it's the exact same token (same contract address AND chain ID)
|
|
910
|
-
if (
|
|
911
|
-
token.contractAddress === originToken?.contractAddress &&
|
|
912
|
-
token.chainId === originToken?.chainId
|
|
913
|
-
) {
|
|
914
|
-
handleFlip()
|
|
915
|
-
}
|
|
916
|
-
|
|
917
|
-
setDestinationToken(token)
|
|
918
|
-
setSelectedDestToken(token)
|
|
919
|
-
|
|
920
|
-
// Update destination chain
|
|
921
|
-
const chainInfo = getChainInfo(token.chainId)
|
|
922
|
-
if (chainInfo) {
|
|
923
|
-
setSelectedDestinationChain(chainInfo)
|
|
924
|
-
}
|
|
925
|
-
|
|
926
|
-
setShowDestinationTokenSelector(false)
|
|
927
|
-
|
|
928
|
-
// Mark as manual selection to prevent auto-selection override
|
|
929
|
-
setHasManualDestinationSelection(true)
|
|
930
|
-
userActionRef.current.hasManualDestinationSelection = true
|
|
931
|
-
userActionRef.current.lastDestinationSelectionTime = Date.now()
|
|
932
|
-
|
|
933
|
-
onTrackToken?.(token)
|
|
934
|
-
logger.console.log("[trails-sdk] selected destination token", token)
|
|
935
|
-
},
|
|
936
|
-
[
|
|
937
|
-
setDestinationToken,
|
|
938
|
-
setSelectedDestToken,
|
|
939
|
-
setSelectedDestinationChain,
|
|
940
|
-
setHasManualDestinationSelection,
|
|
941
|
-
onTrackToken,
|
|
942
|
-
originToken,
|
|
943
|
-
handleFlip,
|
|
944
|
-
],
|
|
945
|
-
)
|
|
946
|
-
|
|
947
|
-
// Handle recent token selection
|
|
948
|
-
const handleRecentTokenSelect = useCallback(
|
|
949
|
-
(token: Token) => {
|
|
950
|
-
// Only flip if it's the exact same token (same contract address AND chain ID)
|
|
951
|
-
if (
|
|
952
|
-
token.contractAddress === originToken?.contractAddress &&
|
|
953
|
-
token.chainId === originToken?.chainId
|
|
954
|
-
) {
|
|
955
|
-
handleFlip()
|
|
956
|
-
}
|
|
957
|
-
|
|
958
|
-
if (showSourceTokenSelector) {
|
|
959
|
-
handleSourceTokenSelectorSelect(token)
|
|
960
|
-
} else if (showDestinationTokenSelector) {
|
|
961
|
-
handleDestinationTokenSelectorSelect(token)
|
|
962
|
-
}
|
|
963
|
-
},
|
|
964
|
-
[
|
|
965
|
-
showSourceTokenSelector,
|
|
966
|
-
showDestinationTokenSelector,
|
|
967
|
-
handleSourceTokenSelectorSelect,
|
|
968
|
-
handleDestinationTokenSelectorSelect,
|
|
969
|
-
originToken?.contractAddress,
|
|
970
|
-
originToken?.chainId,
|
|
971
|
-
handleFlip,
|
|
972
|
-
],
|
|
973
|
-
)
|
|
974
|
-
|
|
975
|
-
// Show provider selector screen
|
|
976
|
-
if (showProviderSelector) {
|
|
977
|
-
return (
|
|
978
|
-
<MeldProvidersList
|
|
979
|
-
onBack={() => setShowProviderSelector(false)}
|
|
980
|
-
onSelectProvider={(provider) => {
|
|
981
|
-
setSelectedOnrampProvider(provider as OnrampQuote)
|
|
982
|
-
setShowProviderSelector(false)
|
|
983
|
-
}}
|
|
984
|
-
selectedProvider={selectedOnrampProviderQuote}
|
|
985
|
-
providers={onrampQuotes}
|
|
986
|
-
isLoading={isLoadingOnrampQuote}
|
|
987
|
-
/>
|
|
988
|
-
)
|
|
989
|
-
}
|
|
990
|
-
|
|
991
|
-
// Show fiat selector screen
|
|
992
|
-
if (showFiatSelector) {
|
|
993
|
-
return (
|
|
994
|
-
<div className="space-y-2">
|
|
995
|
-
<ScreenHeader
|
|
996
|
-
onBack={() => setShowFiatSelector(false)}
|
|
997
|
-
headerContent="Select Currency"
|
|
998
|
-
headerContentAlign="left"
|
|
999
|
-
/>
|
|
1000
|
-
<FiatSelector
|
|
1001
|
-
onCurrencySelect={(currency) => {
|
|
1002
|
-
setSelectedFiatCurrency(currency)
|
|
1003
|
-
setShowFiatSelector(false)
|
|
1004
|
-
setHasManualFiatSelection(true)
|
|
1005
|
-
}}
|
|
1006
|
-
onAutoSelect={(currency) => {
|
|
1007
|
-
// Auto-select doesn't close the selector, just sets the currency
|
|
1008
|
-
setSelectedFiatCurrency(currency)
|
|
1009
|
-
}}
|
|
1010
|
-
onSelectCountry={(countryCode) => {
|
|
1011
|
-
setSelectedCountryCode(countryCode)
|
|
1012
|
-
}}
|
|
1013
|
-
onError={onError}
|
|
1014
|
-
selectedCurrency={selectedFiatCurrency}
|
|
1015
|
-
/>
|
|
1016
|
-
</div>
|
|
1017
|
-
)
|
|
1018
|
-
}
|
|
1019
|
-
|
|
1020
|
-
// Show source chain list screen
|
|
1021
|
-
if (showSourceChainList) {
|
|
1022
|
-
return (
|
|
1023
|
-
<ChainList
|
|
1024
|
-
onBack={() => {
|
|
1025
|
-
setShowSourceChainList(false)
|
|
1026
|
-
setShowSourceTokenSelector(true)
|
|
1027
|
-
}}
|
|
1028
|
-
/>
|
|
1029
|
-
)
|
|
1030
|
-
}
|
|
1031
|
-
|
|
1032
|
-
// Show source token selector screen
|
|
1033
|
-
if (showSourceTokenSelector) {
|
|
1034
|
-
return (
|
|
1035
|
-
<div className="space-y-2">
|
|
1036
|
-
<ScreenHeader
|
|
1037
|
-
onBack={() => setShowSourceTokenSelector(false)}
|
|
1038
|
-
headerContent="Select From Token"
|
|
1039
|
-
headerContentAlign="left"
|
|
1040
|
-
/>
|
|
1041
|
-
<TokenSelector
|
|
1042
|
-
onTokenSelect={handleSourceTokenSelectorSelect}
|
|
1043
|
-
onError={onError}
|
|
1044
|
-
showContinueButton={false}
|
|
1045
|
-
compactMode={false}
|
|
1046
|
-
allSupportedTokens={false}
|
|
1047
|
-
fundMethod={fundMethod}
|
|
1048
|
-
chainListScreen={true}
|
|
1049
|
-
onNavigateToChainList={() => {
|
|
1050
|
-
setShowSourceTokenSelector(false)
|
|
1051
|
-
setShowSourceChainList(true)
|
|
1052
|
-
}}
|
|
1053
|
-
recentTokens={recentTokens}
|
|
1054
|
-
onRecentTokenSelect={handleRecentTokenSelect}
|
|
1055
|
-
/>
|
|
1056
|
-
</div>
|
|
1057
|
-
)
|
|
1058
|
-
}
|
|
1059
|
-
|
|
1060
|
-
// Show destination chain list screen
|
|
1061
|
-
if (showDestinationChainList) {
|
|
1062
|
-
return (
|
|
1063
|
-
<ChainList
|
|
1064
|
-
onBack={() => {
|
|
1065
|
-
setShowDestinationChainList(false)
|
|
1066
|
-
setShowDestinationTokenSelector(true)
|
|
1067
|
-
}}
|
|
1068
|
-
/>
|
|
1069
|
-
)
|
|
1070
|
-
}
|
|
1071
|
-
|
|
1072
|
-
// Show destination token selector screen
|
|
1073
|
-
if (showDestinationTokenSelector) {
|
|
1074
|
-
return (
|
|
1075
|
-
<div className="space-y-2">
|
|
1076
|
-
<ScreenHeader
|
|
1077
|
-
onBack={() => setShowDestinationTokenSelector(false)}
|
|
1078
|
-
headerContent="Select To Token"
|
|
1079
|
-
headerContentAlign="left"
|
|
1080
|
-
/>
|
|
1081
|
-
<TokenSelector
|
|
1082
|
-
onTokenSelect={handleDestinationTokenSelectorSelect}
|
|
1083
|
-
onError={onError}
|
|
1084
|
-
showContinueButton={false}
|
|
1085
|
-
compactMode={false}
|
|
1086
|
-
allSupportedTokens={true}
|
|
1087
|
-
fundMethod={fundMethod}
|
|
1088
|
-
chainListScreen={true}
|
|
1089
|
-
onNavigateToChainList={() => {
|
|
1090
|
-
setShowDestinationTokenSelector(false)
|
|
1091
|
-
setShowDestinationChainList(true)
|
|
1092
|
-
}}
|
|
1093
|
-
recentTokens={recentTokens}
|
|
1094
|
-
onRecentTokenSelect={handleRecentTokenSelect}
|
|
1095
|
-
/>
|
|
1096
|
-
</div>
|
|
1097
|
-
)
|
|
1098
|
-
}
|
|
1099
|
-
|
|
1100
|
-
return (
|
|
1101
|
-
<div className="space-y-2">
|
|
1102
|
-
<ScreenHeader
|
|
1103
|
-
onBack={
|
|
1104
|
-
mode === "fund"
|
|
1105
|
-
? () => navigate("fund-form")
|
|
1106
|
-
: mode === "earn"
|
|
1107
|
-
? () => navigate("earn")
|
|
1108
|
-
: mode === "pay"
|
|
1109
|
-
? () => navigate("send-form")
|
|
1110
|
-
: mode === "withdraw"
|
|
1111
|
-
? () => navigate("withdraw")
|
|
1112
|
-
: onBack
|
|
1113
|
-
}
|
|
1114
|
-
headerContent={title}
|
|
1115
|
-
headerContentAlign="left"
|
|
1116
|
-
showAccountActions={true}
|
|
1117
|
-
/>
|
|
1118
|
-
|
|
1119
|
-
<form
|
|
1120
|
-
onSubmit={async (e) => {
|
|
1121
|
-
e.preventDefault()
|
|
1122
|
-
|
|
1123
|
-
logger.console.log(
|
|
1124
|
-
"[trails-sdk] Creating widget session",
|
|
1125
|
-
isMeldOnRampActive,
|
|
1126
|
-
)
|
|
1127
|
-
// Handle onramp flow separately
|
|
1128
|
-
if (
|
|
1129
|
-
isMeldOnRampActive &&
|
|
1130
|
-
selectedOnrampProviderQuote &&
|
|
1131
|
-
selectedFiatCurrency
|
|
1132
|
-
) {
|
|
1133
|
-
const {
|
|
1134
|
-
popup,
|
|
1135
|
-
blocked,
|
|
1136
|
-
error: popupError,
|
|
1137
|
-
} = openPopup("meld-widget", 450, 700)
|
|
1138
|
-
|
|
1139
|
-
if (blocked) {
|
|
1140
|
-
setWidgetError(
|
|
1141
|
-
popupError ||
|
|
1142
|
-
"Popup blocked. Please allow popups for this site.",
|
|
1143
|
-
)
|
|
1144
|
-
onError(popupError || "Popup blocked")
|
|
1145
|
-
return
|
|
1146
|
-
}
|
|
1147
|
-
|
|
1148
|
-
try {
|
|
1149
|
-
setIsCreatingWidgetSession(true)
|
|
1150
|
-
setWidgetError(null)
|
|
1151
|
-
|
|
1152
|
-
logger.console.log(
|
|
1153
|
-
"[trails-sdk] prepareSendQuote",
|
|
1154
|
-
prepareSendQuote,
|
|
1155
|
-
)
|
|
1156
|
-
|
|
1157
|
-
// Commit the intent immediately when user clicks continue
|
|
1158
|
-
// Call sendFn to trigger the commit without deposit
|
|
1159
|
-
if (sendFn) {
|
|
1160
|
-
logger.console.log(
|
|
1161
|
-
"[trails-sdk] Committing intent for onramp-meld flow",
|
|
1162
|
-
)
|
|
1163
|
-
|
|
1164
|
-
try {
|
|
1165
|
-
// Call sendFn without depositTransactionHash to just commit
|
|
1166
|
-
// The crossChain handler will commit but not execute/wait for deposit
|
|
1167
|
-
await sendFn({
|
|
1168
|
-
selectedFeeOption: selectedFeeOption ?? null,
|
|
1169
|
-
})
|
|
1170
|
-
|
|
1171
|
-
logger.console.log(
|
|
1172
|
-
"[trails-sdk] Intent committed for onramp-meld",
|
|
1173
|
-
)
|
|
1174
|
-
} catch (error) {
|
|
1175
|
-
logger.console.error(
|
|
1176
|
-
"[trails-sdk] Failed to commit intent:",
|
|
1177
|
-
error,
|
|
1178
|
-
)
|
|
1179
|
-
// Continue anyway
|
|
1180
|
-
}
|
|
1181
|
-
}
|
|
1182
|
-
|
|
1183
|
-
// Create widget session
|
|
1184
|
-
const widgetSessionResponse = await createWidgetSession({
|
|
1185
|
-
depositAddress: prepareSendQuote?.originDepositAddress || "",
|
|
1186
|
-
userAddress: account?.address || "",
|
|
1187
|
-
countryCode: effectiveCountryCode || "",
|
|
1188
|
-
sourceCurrencyCode: selectedFiatCurrency.currencyCode,
|
|
1189
|
-
sourceAmount: sellFiatAmount,
|
|
1190
|
-
destinationCurrencyCode: "USDC_BASE",
|
|
1191
|
-
serviceProvider: selectedOnrampProviderQuote.serviceProvider,
|
|
1192
|
-
paymentMethodType:
|
|
1193
|
-
selectedOnrampProviderQuote.paymentMethodType,
|
|
1194
|
-
lockFields: [
|
|
1195
|
-
"cryptoCurrency",
|
|
1196
|
-
"destinationCurrencyCode",
|
|
1197
|
-
"sourceCurrencyCode",
|
|
1198
|
-
"walletAddress",
|
|
1199
|
-
],
|
|
1200
|
-
})
|
|
1201
|
-
|
|
1202
|
-
logger.console.log(
|
|
1203
|
-
"[ClassicSwap] Widget session response:",
|
|
1204
|
-
widgetSessionResponse,
|
|
1205
|
-
)
|
|
1206
|
-
const { widgetUrl, id, externalSessionId } = widgetSessionResponse
|
|
1207
|
-
|
|
1208
|
-
// Track widget session
|
|
1209
|
-
trackOnrampWidgetSession({
|
|
1210
|
-
sessionId: onrampTrackingData?.sessionId || externalSessionId,
|
|
1211
|
-
provider:
|
|
1212
|
-
selectedOnrampProviderQuote?.serviceProvider || "Meld",
|
|
1213
|
-
widgetUrl,
|
|
1214
|
-
depositAddress: prepareSendQuote?.originDepositAddress || "",
|
|
1215
|
-
userAddress: account?.address?.toLowerCase() || "",
|
|
1216
|
-
countryCode: effectiveCountryCode || "",
|
|
1217
|
-
sourceCurrencyCode: selectedFiatCurrency?.currencyCode || "",
|
|
1218
|
-
sourceAmount: sellFiatAmount,
|
|
1219
|
-
destinationCurrencyCode: "USDC_BASE",
|
|
1220
|
-
paymentMethodType:
|
|
1221
|
-
selectedOnrampProviderQuote?.paymentMethodType || "",
|
|
1222
|
-
})
|
|
1223
|
-
|
|
1224
|
-
if (!setPopupUrl(popup, widgetUrl)) {
|
|
1225
|
-
throw new Error("Payment window was closed. Please try again.")
|
|
1226
|
-
}
|
|
1227
|
-
|
|
1228
|
-
logger.console.log(
|
|
1229
|
-
"[ClassicSwap] Opened onramp widget in popup",
|
|
1230
|
-
{ widgetUrl, meldTransactionId: id },
|
|
1231
|
-
)
|
|
1232
|
-
|
|
1233
|
-
if (onWaitingForOnrampConfirm && prepareSendQuote) {
|
|
1234
|
-
// Pass both quote and widget creation parameters
|
|
1235
|
-
logger.console.log(
|
|
1236
|
-
"[ClassicSwap] Calling onWaitingForOnrampConfirm with externalSessionId:",
|
|
1237
|
-
externalSessionId,
|
|
1238
|
-
)
|
|
1239
|
-
onWaitingForOnrampConfirm(
|
|
1240
|
-
prepareSendQuote,
|
|
1241
|
-
selectedOnrampProviderQuote,
|
|
1242
|
-
{
|
|
1243
|
-
depositAddress:
|
|
1244
|
-
prepareSendQuote?.originDepositAddress || "",
|
|
1245
|
-
userAddress: account?.address?.toLowerCase() || "",
|
|
1246
|
-
countryCode: effectiveCountryCode || "",
|
|
1247
|
-
sourceCurrencyCode: selectedFiatCurrency.currencyCode,
|
|
1248
|
-
sourceAmount: sellFiatAmount,
|
|
1249
|
-
destinationCurrencyCode: "USDC_BASE",
|
|
1250
|
-
serviceProvider:
|
|
1251
|
-
selectedOnrampProviderQuote.serviceProvider,
|
|
1252
|
-
paymentMethodType:
|
|
1253
|
-
selectedOnrampProviderQuote.paymentMethodType,
|
|
1254
|
-
},
|
|
1255
|
-
externalSessionId,
|
|
1256
|
-
popup,
|
|
1257
|
-
)
|
|
1258
|
-
}
|
|
1259
|
-
|
|
1260
|
-
await handleSubmit(e)
|
|
1261
|
-
} catch (err) {
|
|
1262
|
-
closePopup(popup)
|
|
1263
|
-
logger.console.error(
|
|
1264
|
-
"[ClassicSwap] Error creating widget session",
|
|
1265
|
-
err,
|
|
1266
|
-
)
|
|
1267
|
-
const errorMessage =
|
|
1268
|
-
err instanceof Error
|
|
1269
|
-
? err.message
|
|
1270
|
-
: "Failed to create widget session"
|
|
1271
|
-
setWidgetError(errorMessage)
|
|
1272
|
-
onError(errorMessage)
|
|
1273
|
-
} finally {
|
|
1274
|
-
setIsCreatingWidgetSession(false)
|
|
1275
|
-
}
|
|
1276
|
-
return
|
|
1277
|
-
}
|
|
1278
|
-
|
|
1279
|
-
logger.console.log(
|
|
1280
|
-
"[trails-sdk] Calling handleSubmit from ClassicSwap",
|
|
1281
|
-
)
|
|
1282
|
-
handleSubmit(e)
|
|
1283
|
-
}}
|
|
1284
|
-
className="space-y-1"
|
|
1285
|
-
>
|
|
1286
|
-
{/* Input Section - Amount + Token Selection */}
|
|
1287
|
-
<div className="pt-4 pb-4 trails-bg-secondary trails-bg-secondary-hover trails-border-radius-container p-3 group transition-all duration-200 border border-transparent focus-within:bg-white! dark:focus-within:bg-gray-800! trails-focus-border-secondary min-h-[120px] flex flex-col">
|
|
1288
|
-
{/* Sell Label */}
|
|
1289
|
-
<div className="mb-4 flex justify-between items-center">
|
|
1290
|
-
<div className="text-sm font-medium trails-text-secondary text-left m-0">
|
|
1291
|
-
{mode === "fund" ? "Payment method" : "Sell"}
|
|
1292
|
-
</div>
|
|
1293
|
-
<FundingMethodSelectorButton />
|
|
1294
|
-
</div>
|
|
1295
|
-
|
|
1296
|
-
<div className="flex items-center space-x-2 flex-1">
|
|
1297
|
-
{/* Amount Input */}
|
|
1298
|
-
<div className="flex-1">
|
|
1299
|
-
<div className="flex items-center space-x-2">
|
|
1300
|
-
<DynamicSizeInputField
|
|
1301
|
-
ref={inputRef}
|
|
1302
|
-
value={isMeldOnRampActive ? sellFiatAmount : sellAmount}
|
|
1303
|
-
disabled={isFiatAmountLocked}
|
|
1304
|
-
onChange={(e) => {
|
|
1305
|
-
if (isMeldOnRampActive) {
|
|
1306
|
-
// Always update fiat amount in onramp mode - the UI shows fiat
|
|
1307
|
-
handleSellFiatAmountChange(e.target.value)
|
|
1308
|
-
} else {
|
|
1309
|
-
handleSellAmountChange(e.target.value)
|
|
1310
|
-
}
|
|
1311
|
-
}}
|
|
1312
|
-
onFocus={handleSellInputFocus}
|
|
1313
|
-
isLoading={
|
|
1314
|
-
isLoadingQuote && tradeType === TradeType.EXACT_OUTPUT
|
|
1315
|
-
}
|
|
1316
|
-
variant="default"
|
|
1317
|
-
/>
|
|
1318
|
-
{isLoadingQuote && tradeType === TradeType.EXACT_OUTPUT && (
|
|
1319
|
-
<LoadingSpinner />
|
|
1320
|
-
)}
|
|
1321
|
-
</div>
|
|
1322
|
-
</div>
|
|
1323
|
-
|
|
1324
|
-
{/* Token/Fiat Selection Button */}
|
|
1325
|
-
<div className="relative">
|
|
1326
|
-
{isMeldOnRampActive ? (
|
|
1327
|
-
<FiatSelectorButton
|
|
1328
|
-
currency={selectedFiatCurrency}
|
|
1329
|
-
onSelect={() => setShowFiatSelector(true)}
|
|
1330
|
-
unselectable={isFiatCurrencyLocked}
|
|
1331
|
-
/>
|
|
1332
|
-
) : (
|
|
1333
|
-
<TokenSelectorButton
|
|
1334
|
-
token={originToken}
|
|
1335
|
-
chainId={originChainId}
|
|
1336
|
-
onSelect={() => setShowSourceTokenSelector(true)}
|
|
1337
|
-
/>
|
|
1338
|
-
)}
|
|
1339
|
-
</div>
|
|
1340
|
-
</div>
|
|
1341
|
-
|
|
1342
|
-
{/* Bottom Info Row for sell */}
|
|
1343
|
-
<div className="mt-4 flex justify-between items-center">
|
|
1344
|
-
{isMeldOnRampActive &&
|
|
1345
|
-
selectedOnrampProviderQuote &&
|
|
1346
|
-
fiatToUsdExchangeRate &&
|
|
1347
|
-
selectedOnrampProviderQuote &&
|
|
1348
|
-
!isLoadingFiatToUsdExchangeRate ? (
|
|
1349
|
-
(() => {
|
|
1350
|
-
const usdAmount =
|
|
1351
|
-
selectedOnrampProviderQuote.sourceCurrencyCode === "USD"
|
|
1352
|
-
? selectedOnrampProviderQuote.sourceAmount
|
|
1353
|
-
: selectedOnrampProviderQuote.sourceAmount /
|
|
1354
|
-
fiatToUsdExchangeRate
|
|
1355
|
-
|
|
1356
|
-
const displayValue = formatUsdAmountDisplay(usdAmount || 0)
|
|
1357
|
-
const localeValue = formatUsdAmountLocaleDisplay(usdAmount || 0)
|
|
1358
|
-
|
|
1359
|
-
return (
|
|
1360
|
-
<div
|
|
1361
|
-
className="text-xs text-gray-500 dark:text-gray-400"
|
|
1362
|
-
title={displayValue}
|
|
1363
|
-
>
|
|
1364
|
-
<span className="notranslate" translate="no">
|
|
1365
|
-
≈ {localeValue}
|
|
1366
|
-
</span>
|
|
1367
|
-
</div>
|
|
1368
|
-
)
|
|
1369
|
-
})()
|
|
1370
|
-
) : (
|
|
1371
|
-
<div className="text-xs text-gray-500 dark:text-gray-400">
|
|
1372
|
-
<span className="notranslate" translate="no">
|
|
1373
|
-
≈{" "}
|
|
1374
|
-
{tradeType === TradeType.EXACT_INPUT
|
|
1375
|
-
? prepareSendQuote?.originAmountUsdLocaleDisplay ||
|
|
1376
|
-
amountUsdLocaleDisplay ||
|
|
1377
|
-
amountUsdDisplay ||
|
|
1378
|
-
formatUsdAmountLocaleDisplay(0)
|
|
1379
|
-
: isLoadingQuote
|
|
1380
|
-
? ""
|
|
1381
|
-
: prepareSendQuote?.originAmountUsdLocaleDisplay ||
|
|
1382
|
-
prepareSendQuote?.originAmountUsdDisplay ||
|
|
1383
|
-
""}
|
|
1384
|
-
</span>
|
|
1385
|
-
</div>
|
|
1386
|
-
)}
|
|
1387
|
-
|
|
1388
|
-
{/* Origin Token Balance and Percentage Buttons */}
|
|
1389
|
-
{originToken &&
|
|
1390
|
-
!isMeldOnRampActive &&
|
|
1391
|
-
fundMethod !== "direct-transfer" &&
|
|
1392
|
-
fundMethod !== "onramp-mesh" && (
|
|
1393
|
-
<div className="flex items-center space-x-2">
|
|
1394
|
-
<div className="flex items-center space-x-1">
|
|
1395
|
-
<span
|
|
1396
|
-
className="text-xs text-gray-500 dark:text-gray-400 notranslate"
|
|
1397
|
-
translate="no"
|
|
1398
|
-
>
|
|
1399
|
-
Balance:
|
|
1400
|
-
</span>
|
|
1401
|
-
<button
|
|
1402
|
-
type="button"
|
|
1403
|
-
className="text-xs text-gray-500 dark:text-gray-400 cursor-pointer hover:text-gray-700 dark:hover:text-gray-200 transition-colors bg-transparent border-none p-0"
|
|
1404
|
-
onClick={() => {
|
|
1405
|
-
if (balanceFormatted) {
|
|
1406
|
-
const balance = parseFloat(balanceFormatted)
|
|
1407
|
-
if (isValidNumber(balance)) {
|
|
1408
|
-
setTradeType(TradeType.EXACT_INPUT)
|
|
1409
|
-
setSellAmount(balance.toFixed(6))
|
|
1410
|
-
setBuyAmount("")
|
|
1411
|
-
}
|
|
1412
|
-
}
|
|
1413
|
-
}}
|
|
1414
|
-
onKeyDown={(e) => {
|
|
1415
|
-
if (e.key === "Enter" || e.key === " ") {
|
|
1416
|
-
e.preventDefault()
|
|
1417
|
-
if (balanceFormatted) {
|
|
1418
|
-
const balance = parseFloat(balanceFormatted)
|
|
1419
|
-
if (isValidNumber(balance)) {
|
|
1420
|
-
setTradeType(TradeType.EXACT_INPUT)
|
|
1421
|
-
setSellAmount(balance.toFixed(6))
|
|
1422
|
-
setBuyAmount("")
|
|
1423
|
-
}
|
|
1424
|
-
}
|
|
1425
|
-
}
|
|
1426
|
-
}}
|
|
1427
|
-
title="Click to use full balance"
|
|
1428
|
-
disabled={!balanceFormatted}
|
|
1429
|
-
>
|
|
1430
|
-
<span className="notranslate" translate="no">
|
|
1431
|
-
{isBalanceVisible
|
|
1432
|
-
? freshOriginToken?.balanceLocaleDisplay ||
|
|
1433
|
-
originToken?.balanceLocaleDisplay ||
|
|
1434
|
-
freshOriginToken?.balanceDisplay ||
|
|
1435
|
-
originToken?.balanceDisplay ||
|
|
1436
|
-
balanceFormatted ||
|
|
1437
|
-
"0.00"
|
|
1438
|
-
: "••••••"}
|
|
1439
|
-
</span>
|
|
1440
|
-
</button>
|
|
1441
|
-
</div>
|
|
1442
|
-
|
|
1443
|
-
{/* Percentage Buttons */}
|
|
1444
|
-
{balanceFormatted && (
|
|
1445
|
-
<PercentageMaxButtons
|
|
1446
|
-
userBalance={balanceFormatted}
|
|
1447
|
-
userBalanceRaw={balanceRaw}
|
|
1448
|
-
decimals={tokenDecimals}
|
|
1449
|
-
isNativeToken={originToken.isNativeToken ?? false}
|
|
1450
|
-
gasCostFormatted={prepareSendQuote?.gasCostFormatted}
|
|
1451
|
-
chainId={originChainId || undefined}
|
|
1452
|
-
onAmountSelect={(amount) => {
|
|
1453
|
-
setTradeType(TradeType.EXACT_INPUT)
|
|
1454
|
-
setSellAmount(amount)
|
|
1455
|
-
setBuyAmount("")
|
|
1456
|
-
}}
|
|
1457
|
-
className="opacity-100"
|
|
1458
|
-
/>
|
|
1459
|
-
)}
|
|
1460
|
-
</div>
|
|
1461
|
-
)}
|
|
1462
|
-
</div>
|
|
1463
|
-
</div>
|
|
1464
|
-
|
|
1465
|
-
{/* Flip Button - Absolutely Positioned */}
|
|
1466
|
-
<div className="relative">
|
|
1467
|
-
<button
|
|
1468
|
-
type="button"
|
|
1469
|
-
onClick={handleFlip}
|
|
1470
|
-
disabled={
|
|
1471
|
-
!!(
|
|
1472
|
-
effectiveRecipient &&
|
|
1473
|
-
account?.address &&
|
|
1474
|
-
!addressEqual(effectiveRecipient, account.address)
|
|
1475
|
-
)
|
|
1476
|
-
}
|
|
1477
|
-
className="absolute left-1/2 top-1/2 transform -translate-x-1/2 -translate-y-1/2 p-1.5 trails-border-radius-button trails-bg-tertiary hover:trails-hover-bg transition-colors cursor-pointer border-2 border-white dark:border-gray-800 disabled:opacity-50 disabled:cursor-not-allowed disabled:hover:trails-bg-tertiary"
|
|
1478
|
-
>
|
|
1479
|
-
<ArrowDown
|
|
1480
|
-
className="w-5 h-5 text-gray-900 dark:text-white"
|
|
1481
|
-
strokeWidth={2.5}
|
|
1482
|
-
/>
|
|
1483
|
-
</button>
|
|
1484
|
-
</div>
|
|
1485
|
-
|
|
1486
|
-
{/* Output Section - Amount + Token Selection */}
|
|
1487
|
-
<div className="pt-4 pb-4 trails-bg-secondary trails-bg-secondary-hover trails-border-radius-container p-3 transition-all duration-200 border border-transparent focus-within:bg-white! dark:focus-within:bg-gray-800! trails-focus-border-secondary min-h-[120px] flex flex-col mb-4">
|
|
1488
|
-
{/* Buy Label */}
|
|
1489
|
-
<div className="mb-4 flex justify-between items-center mb-2">
|
|
1490
|
-
<div className="text-sm font-medium trails-text-secondary text-left m-0">
|
|
1491
|
-
{mode === "fund" ? "Recipient" : "Buy"}
|
|
1492
|
-
</div>
|
|
1493
|
-
{toRecipient ? (
|
|
1494
|
-
/* Display only - recipient is fixed when toRecipient prop is provided */
|
|
1495
|
-
<div className="flex items-center space-x-2 text-black dark:text-white">
|
|
1496
|
-
<AddressWalletIcon
|
|
1497
|
-
walletAddress={toRecipient as `0x${string}`}
|
|
1498
|
-
/>
|
|
1499
|
-
<AddressOrEnsName
|
|
1500
|
-
address={toRecipient}
|
|
1501
|
-
startChars={4}
|
|
1502
|
-
endChars={4}
|
|
1503
|
-
className="text-sm font-medium"
|
|
1504
|
-
/>
|
|
1505
|
-
</div>
|
|
1506
|
-
) : (
|
|
1507
|
-
/* Interactive button - user can select recipient */
|
|
1508
|
-
<RecipientSelectorButton selectedRecipient={selectedRecipient} />
|
|
1509
|
-
)}
|
|
1510
|
-
</div>
|
|
1511
|
-
|
|
1512
|
-
<div className="flex items-center space-x-2 flex-1">
|
|
1513
|
-
{/* Output Amount */}
|
|
1514
|
-
<div className="flex-1">
|
|
1515
|
-
<div className="flex items-center space-x-2">
|
|
1516
|
-
<DynamicSizeInputField
|
|
1517
|
-
value={
|
|
1518
|
-
tradeType === TradeType.EXACT_OUTPUT
|
|
1519
|
-
? buyAmount
|
|
1520
|
-
: buyAmount || toAmountDisplay || ""
|
|
1521
|
-
}
|
|
1522
|
-
onChange={
|
|
1523
|
-
exactInputOnly
|
|
1524
|
-
? undefined
|
|
1525
|
-
: (e) => handleBuyAmountChange(e.target.value)
|
|
1526
|
-
}
|
|
1527
|
-
onFocus={exactInputOnly ? undefined : handleBuyInputFocus}
|
|
1528
|
-
isLoading={
|
|
1529
|
-
isLoadingQuote && tradeType === TradeType.EXACT_INPUT
|
|
1530
|
-
}
|
|
1531
|
-
readOnly={
|
|
1532
|
-
isMeldOnRampActive ||
|
|
1533
|
-
exactInputOnly ||
|
|
1534
|
-
(tradeType === TradeType.EXACT_INPUT && isLoadingQuote) ||
|
|
1535
|
-
!!toAmount
|
|
1536
|
-
}
|
|
1537
|
-
disabled={exactInputOnly}
|
|
1538
|
-
showPlaceholderStyle={!amount}
|
|
1539
|
-
variant="default"
|
|
1540
|
-
/>
|
|
1541
|
-
{isLoadingQuote && tradeType === TradeType.EXACT_INPUT && (
|
|
1542
|
-
<LoadingSpinner />
|
|
1543
|
-
)}
|
|
1544
|
-
</div>
|
|
1545
|
-
</div>
|
|
1546
|
-
|
|
1547
|
-
{/* Destination Token Selection */}
|
|
1548
|
-
<div className="relative">
|
|
1549
|
-
<TokenSelectorButton
|
|
1550
|
-
token={selectedDestToken}
|
|
1551
|
-
chainId={selectedDestToken?.chainId}
|
|
1552
|
-
onSelect={() => setShowDestinationTokenSelector(true)}
|
|
1553
|
-
unselectable={!!toToken}
|
|
1554
|
-
/>
|
|
1555
|
-
</div>
|
|
1556
|
-
</div>
|
|
1557
|
-
|
|
1558
|
-
{/* Bottom Info Row */}
|
|
1559
|
-
<div className="mt-4 flex items-center justify-between">
|
|
1560
|
-
{/* Destination Amount USD from Quote */}
|
|
1561
|
-
<div className="text-xs text-gray-500 dark:text-gray-400">
|
|
1562
|
-
{(prepareSendQuote?.destinationAmountUsdDisplay ||
|
|
1563
|
-
(isLoadingQuote && tradeType === TradeType.EXACT_INPUT)) && (
|
|
1564
|
-
<span className="notranslate" translate="no">
|
|
1565
|
-
≈{" "}
|
|
1566
|
-
{isLoadingQuote && tradeType === TradeType.EXACT_INPUT
|
|
1567
|
-
? formatUsdAmountLocaleDisplay(0)
|
|
1568
|
-
: prepareSendQuote?.destinationAmountUsdLocaleDisplay ||
|
|
1569
|
-
prepareSendQuote?.destinationAmountUsdDisplay}
|
|
1570
|
-
</span>
|
|
1571
|
-
)}
|
|
1572
|
-
</div>
|
|
1573
|
-
|
|
1574
|
-
{/* Dest Token Balance - always on right */}
|
|
1575
|
-
{destinationToken && (
|
|
1576
|
-
<div className="text-xs text-gray-500 dark:text-gray-400">
|
|
1577
|
-
<span className="notranslate" translate="no">
|
|
1578
|
-
Balance:{" "}
|
|
1579
|
-
{isBalanceVisible
|
|
1580
|
-
? freshDestinationToken?.balanceLocaleDisplay ||
|
|
1581
|
-
destinationToken?.balanceLocaleDisplay ||
|
|
1582
|
-
freshDestinationToken?.balanceDisplay ||
|
|
1583
|
-
destinationToken?.balanceDisplay ||
|
|
1584
|
-
destinationBalanceDisplay ||
|
|
1585
|
-
"-"
|
|
1586
|
-
: "••••••"}
|
|
1587
|
-
</span>
|
|
1588
|
-
</div>
|
|
1589
|
-
)}
|
|
1590
|
-
</div>
|
|
1591
|
-
</div>
|
|
1592
|
-
{/* Exchange/Contract Warning */}
|
|
1593
|
-
<RefundWarning
|
|
1594
|
-
fundMethod={fundMethod}
|
|
1595
|
-
isSenderContractOnOrigin={false}
|
|
1596
|
-
isSenderContractOnDestination={false}
|
|
1597
|
-
isSequenceWallet={isSequenceWallet}
|
|
1598
|
-
/>
|
|
1599
|
-
|
|
1600
|
-
{/* Quote Details - only show for non-onramp quotes */}
|
|
1601
|
-
{prepareSendQuote && (
|
|
1602
|
-
<div>
|
|
1603
|
-
<QuoteDetails
|
|
1604
|
-
quote={prepareSendQuote}
|
|
1605
|
-
fiatToUsdExchangeRate={fiatToUsdExchangeRate}
|
|
1606
|
-
onRampQuote={selectedOnrampProviderQuote}
|
|
1607
|
-
showContent={true}
|
|
1608
|
-
swapMode={true}
|
|
1609
|
-
isRefetching={isLoadingQuote}
|
|
1610
|
-
isPassthrough={isPassthroughEligible(
|
|
1611
|
-
prepareSendQuote.passthroughEligible,
|
|
1612
|
-
selectedFeeOption,
|
|
1613
|
-
processedFeeOptions,
|
|
1614
|
-
)}
|
|
1615
|
-
/>
|
|
1616
|
-
</div>
|
|
1617
|
-
)}
|
|
1618
|
-
|
|
1619
|
-
<HighPriceImpactBlock quoteError={quoteError} />
|
|
1620
|
-
|
|
1621
|
-
{/* Onramp Provider Selector */}
|
|
1622
|
-
{isMeldOnRampActive &&
|
|
1623
|
-
!isLoadingOnrampQuote &&
|
|
1624
|
-
!isLoadingQuote &&
|
|
1625
|
-
prepareSendQuote &&
|
|
1626
|
-
onrampQuotes &&
|
|
1627
|
-
onrampQuotes.length > 0 && (
|
|
1628
|
-
<OnRampProviderSelector
|
|
1629
|
-
providers={onrampQuotes}
|
|
1630
|
-
selectedProvider={selectedOnrampProviderQuote}
|
|
1631
|
-
trailsQuote={prepareSendQuote}
|
|
1632
|
-
setSelectedProvider={(provider) => {
|
|
1633
|
-
setSelectedOnrampProvider(provider as OnrampQuote)
|
|
1634
|
-
}}
|
|
1635
|
-
isRefetching={isLoadingOnrampQuote}
|
|
1636
|
-
/>
|
|
1637
|
-
)}
|
|
1638
|
-
|
|
1639
|
-
{/* Onramp Quote Error */}
|
|
1640
|
-
{isMeldOnRampActive && onrampQuoteError && (
|
|
1641
|
-
<div className="mt-4">
|
|
1642
|
-
<ErrorDisplay
|
|
1643
|
-
errorPrettified={getPrettifiedErrorMessage(
|
|
1644
|
-
onrampQuoteError,
|
|
1645
|
-
"Error loading quote",
|
|
1646
|
-
)}
|
|
1647
|
-
error={getFullErrorMessage(onrampQuoteError)}
|
|
1648
|
-
severity="error"
|
|
1649
|
-
/>
|
|
1650
|
-
</div>
|
|
1651
|
-
)}
|
|
1652
|
-
|
|
1653
|
-
{/* Fee Options */}
|
|
1654
|
-
{!isMeldOnRampActive &&
|
|
1655
|
-
fundMethod !== "direct-transfer" &&
|
|
1656
|
-
fundMethod !== "onramp-mesh" && (
|
|
1657
|
-
<FeeOptions
|
|
1658
|
-
processedFeeOptions={processedFeeOptions || []}
|
|
1659
|
-
selectedFeeOption={selectedFeeOption}
|
|
1660
|
-
setSelectedFeeOption={(feeOption) =>
|
|
1661
|
-
setSelectedFeeOption(feeOption)
|
|
1662
|
-
}
|
|
1663
|
-
chainId={originToken?.chainId}
|
|
1664
|
-
isRefetching={isLoadingQuote}
|
|
1665
|
-
originTokenInfo={{
|
|
1666
|
-
originToken: freshOriginToken ?? originToken!,
|
|
1667
|
-
originTokenBalance:
|
|
1668
|
-
freshOriginToken?.balance ?? originToken?.balance ?? "0",
|
|
1669
|
-
originTokenAmount: sellAmount,
|
|
1670
|
-
isLoadingBalance: isLoadingFreshOriginBalance,
|
|
1671
|
-
}}
|
|
1672
|
-
/>
|
|
1673
|
-
)}
|
|
1674
|
-
|
|
1675
|
-
<button
|
|
1676
|
-
type="submit"
|
|
1677
|
-
disabled={
|
|
1678
|
-
isMeldOnRampActive
|
|
1679
|
-
? !sellAmount ||
|
|
1680
|
-
isSubmitting ||
|
|
1681
|
-
isCreatingWidgetSession ||
|
|
1682
|
-
!selectedFiatCurrency ||
|
|
1683
|
-
!selectedDestToken ||
|
|
1684
|
-
!effectiveCountryCode ||
|
|
1685
|
-
!effectiveRecipient ||
|
|
1686
|
-
isLoadingOnrampQuote ||
|
|
1687
|
-
isLoadingWidgetSession ||
|
|
1688
|
-
!selectedOnrampProviderQuote ||
|
|
1689
|
-
!!onrampQuoteError ||
|
|
1690
|
-
!!widgetSessionError ||
|
|
1691
|
-
isLoadingQuote ||
|
|
1692
|
-
!prepareSendQuote
|
|
1693
|
-
: !amount ||
|
|
1694
|
-
isSubmitting ||
|
|
1695
|
-
!destinationTokenAddress ||
|
|
1696
|
-
!isValidCustomToken ||
|
|
1697
|
-
isLoadingQuote ||
|
|
1698
|
-
!prepareSendQuote ||
|
|
1699
|
-
(!isMeldOnRampActive &&
|
|
1700
|
-
fundMethod !== "direct-transfer" &&
|
|
1701
|
-
prepareSendQuote?.noSufficientBalance) ||
|
|
1702
|
-
(fundMethod !== "direct-transfer" &&
|
|
1703
|
-
(selectedFeeOption
|
|
1704
|
-
? isFeeOptionDisabled(
|
|
1705
|
-
selectedFeeOption as ProcessedFeeOption,
|
|
1706
|
-
{
|
|
1707
|
-
originToken: freshOriginToken ?? originToken!,
|
|
1708
|
-
originTokenBalance:
|
|
1709
|
-
freshOriginToken?.balance ??
|
|
1710
|
-
originToken?.balance ??
|
|
1711
|
-
"0",
|
|
1712
|
-
originTokenAmount: sellAmount,
|
|
1713
|
-
},
|
|
1714
|
-
)
|
|
1715
|
-
: false))
|
|
1716
|
-
}
|
|
1717
|
-
className="w-full font-semibold py-4 px-4 trails-border-radius-button transition-colors bg-blue-500 hover:bg-blue-600 disabled:bg-gray-300 text-white disabled:text-gray-500 disabled:cursor-not-allowed cursor-pointer relative"
|
|
1718
|
-
>
|
|
1719
|
-
{isSubmitting || isCreatingWidgetSession || isLoadingWidgetSession ? (
|
|
1720
|
-
<div className="flex items-center justify-center">
|
|
1721
|
-
<Loader2 className="w-5 h-5 animate-spin mr-2 trails-text-muted" />
|
|
1722
|
-
<span>
|
|
1723
|
-
{isCreatingWidgetSession || isLoadingWidgetSession
|
|
1724
|
-
? "Creating session..."
|
|
1725
|
-
: buttonText}
|
|
1726
|
-
</span>
|
|
1727
|
-
</div>
|
|
1728
|
-
) : isMeldOnRampActive &&
|
|
1729
|
-
!prepareSendQuote &&
|
|
1730
|
-
!selectedOnrampProviderQuote &&
|
|
1731
|
-
(onrampQuoteError || widgetSessionError || widgetError) ? (
|
|
1732
|
-
"Error Loading Quote"
|
|
1733
|
-
) : fundMethod !== "direct-transfer" &&
|
|
1734
|
-
prepareSendQuote?.noSufficientBalance ? (
|
|
1735
|
-
"Insufficient Balance"
|
|
1736
|
-
) : isMeldOnRampActive &&
|
|
1737
|
-
(isLoadingOnrampQuote || isLoadingQuote) &&
|
|
1738
|
-
!prepareSendQuote &&
|
|
1739
|
-
!autoSelectedOnrampQuote &&
|
|
1740
|
-
!onrampQuotes ? (
|
|
1741
|
-
<div className="flex items-center justify-center">
|
|
1742
|
-
<LoadingSpinner className="mr-2" />
|
|
1743
|
-
<span>Getting quote...</span>
|
|
1744
|
-
</div>
|
|
1745
|
-
) : isMeldOnRampActive && prepareSendQuote ? (
|
|
1746
|
-
"Continue"
|
|
1747
|
-
) : buttonText === "Getting quote..." ? (
|
|
1748
|
-
<div className="flex items-center justify-center">
|
|
1749
|
-
<LoadingSpinner className="mr-2" />
|
|
1750
|
-
<span>{buttonText}</span>
|
|
1751
|
-
</div>
|
|
1752
|
-
) : (
|
|
1753
|
-
buttonText
|
|
1754
|
-
)}
|
|
1755
|
-
</button>
|
|
1756
|
-
</form>
|
|
1757
|
-
</div>
|
|
1758
|
-
)
|
|
1759
|
-
}
|
|
1760
|
-
|
|
1761
|
-
export default ClassicSwap
|