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,1651 +0,0 @@
|
|
|
1
|
-
import { ExternalLink } from "lucide-react"
|
|
2
|
-
import type React from "react"
|
|
3
|
-
import { useCallback, useEffect, useMemo, useState } from "react"
|
|
4
|
-
import { useAccount } from "wagmi"
|
|
5
|
-
import { isPositiveNumber } from "../../utils/validation.js"
|
|
6
|
-
import { getChainName } from "../../chains.js"
|
|
7
|
-
import { MeldCountriesList } from "../../meld/components/MeldCountriesList.js"
|
|
8
|
-
import type { MeldPaymentMethod } from "../../meld/components/MeldFundMethods.js"
|
|
9
|
-
import { MeldFundMethods } from "../../meld/components/MeldFundMethods.js"
|
|
10
|
-
import { MeldProvidersList } from "../../meld/components/MeldProvidersList.js"
|
|
11
|
-
import { MeldTokensList } from "../../meld/components/MeldTokensList.js"
|
|
12
|
-
import type { Country, MeldQuote, MeldToken } from "../../meld/utils/meld.js"
|
|
13
|
-
import { getMeldOnrampClient } from "../../meld/utils/meld.js"
|
|
14
|
-
import { normalizeAddress, truncateAddress } from "../../utils/address.js"
|
|
15
|
-
import { MINUTE_MS, SECOND_MS } from "../../utils/time.js"
|
|
16
|
-
import { useViewManager } from "../hooks/useViewManager.js"
|
|
17
|
-
import type { MeldTransaction } from "../hooks/useOnRampTransactionStatus.js"
|
|
18
|
-
import { useOriginSelectedToken } from "../hooks/useOriginSelectedToken.js"
|
|
19
|
-
import { useTokenList } from "../hooks/useTokenList.js"
|
|
20
|
-
import { useTrails } from "../providers/TrailsProvider.js"
|
|
21
|
-
import { MeldForm } from "./MeldForm.js"
|
|
22
|
-
import { ScreenHeader } from "./ScreenHeader.js"
|
|
23
|
-
import { logger } from "../../index.js"
|
|
24
|
-
|
|
25
|
-
export interface MeldStepsFlowProps {
|
|
26
|
-
onBack?: () => void
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
type Screen =
|
|
30
|
-
| "menu"
|
|
31
|
-
| "countries"
|
|
32
|
-
| "payment-methods"
|
|
33
|
-
| "tokens"
|
|
34
|
-
| "amount"
|
|
35
|
-
| "providers"
|
|
36
|
-
|
|
37
|
-
// Local storage keys - use same key as MeldForm for consistency
|
|
38
|
-
const MELD_AMOUNT_STORAGE_KEY = "meld-form-amount"
|
|
39
|
-
const MELD_CURRENCY_STORAGE_KEY = "meld-debug-currency"
|
|
40
|
-
|
|
41
|
-
interface AmountInputScreenProps {
|
|
42
|
-
onBack: (amount: string, currency: string) => void
|
|
43
|
-
onContinue: (amount: string, currency: string) => void
|
|
44
|
-
_selectedCountry: Country | null
|
|
45
|
-
_selectedToken: MeldToken | null
|
|
46
|
-
_selectedPaymentMethod: MeldPaymentMethod | null
|
|
47
|
-
initialAmount?: string
|
|
48
|
-
initialCurrency?: string
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
const AmountInputScreen: React.FC<AmountInputScreenProps> = ({
|
|
52
|
-
onBack,
|
|
53
|
-
onContinue,
|
|
54
|
-
_selectedCountry,
|
|
55
|
-
_selectedToken,
|
|
56
|
-
_selectedPaymentMethod,
|
|
57
|
-
initialAmount = "",
|
|
58
|
-
initialCurrency = "USD",
|
|
59
|
-
}) => {
|
|
60
|
-
const [amount, setAmount] = useState(initialAmount)
|
|
61
|
-
const [currency, setCurrency] = useState(initialCurrency)
|
|
62
|
-
|
|
63
|
-
const numAmount = parseFloat(amount)
|
|
64
|
-
const isValid =
|
|
65
|
-
amount.trim() !== "" && isPositiveNumber(numAmount) && numAmount <= 10000
|
|
66
|
-
|
|
67
|
-
// Local storage persistence
|
|
68
|
-
useEffect(() => {
|
|
69
|
-
if (amount) {
|
|
70
|
-
localStorage.setItem(MELD_AMOUNT_STORAGE_KEY, amount)
|
|
71
|
-
}
|
|
72
|
-
if (currency) {
|
|
73
|
-
localStorage.setItem(MELD_CURRENCY_STORAGE_KEY, currency)
|
|
74
|
-
}
|
|
75
|
-
}, [amount, currency])
|
|
76
|
-
|
|
77
|
-
return (
|
|
78
|
-
<div className="flex flex-col h-full">
|
|
79
|
-
<ScreenHeader
|
|
80
|
-
onBack={() => onBack(amount, currency)}
|
|
81
|
-
headerContent="Enter Amount"
|
|
82
|
-
/>
|
|
83
|
-
|
|
84
|
-
{/* Amount Input */}
|
|
85
|
-
<div className="flex-1 p-4">
|
|
86
|
-
<div className="max-w-md mx-auto">
|
|
87
|
-
<label
|
|
88
|
-
htmlFor="meld-steps-amount"
|
|
89
|
-
className="block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2"
|
|
90
|
-
>
|
|
91
|
-
How much do you want to spend?
|
|
92
|
-
</label>
|
|
93
|
-
|
|
94
|
-
<div className="relative">
|
|
95
|
-
<select
|
|
96
|
-
value={currency}
|
|
97
|
-
onChange={(e) => setCurrency(e.target.value)}
|
|
98
|
-
className="absolute left-3 top-1/2 transform -translate-y-1/2 bg-transparent border-none text-lg font-semibold text-gray-700 dark:text-gray-300 focus:outline-none"
|
|
99
|
-
>
|
|
100
|
-
<option value="USD">$</option>
|
|
101
|
-
<option value="EUR">€</option>
|
|
102
|
-
<option value="GBP">£</option>
|
|
103
|
-
</select>
|
|
104
|
-
|
|
105
|
-
<input
|
|
106
|
-
id="meld-steps-amount"
|
|
107
|
-
type="number"
|
|
108
|
-
value={amount}
|
|
109
|
-
onChange={(e) => setAmount(e.target.value)}
|
|
110
|
-
placeholder="0.00"
|
|
111
|
-
className="w-full pl-12 pr-4 py-3 text-2xl font-semibold border-2 border-gray-200 dark:border-gray-700 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-blue-500 bg-white dark:bg-gray-800 text-gray-900 dark:text-white"
|
|
112
|
-
min="1"
|
|
113
|
-
max="10000"
|
|
114
|
-
step="0.01"
|
|
115
|
-
/>
|
|
116
|
-
</div>
|
|
117
|
-
|
|
118
|
-
{/* Amount suggestions */}
|
|
119
|
-
<div className="mt-4 grid grid-cols-4 gap-2">
|
|
120
|
-
{["25", "50", "100", "500"].map((suggestedAmount) => (
|
|
121
|
-
<button
|
|
122
|
-
type="button"
|
|
123
|
-
key={suggestedAmount}
|
|
124
|
-
onClick={() => setAmount(suggestedAmount)}
|
|
125
|
-
className="py-2 px-3 text-sm text-black dark:text-white border border-gray-300 dark:border-gray-600 rounded-lg hover:bg-gray-50 dark:hover:bg-gray-700 transition-colors cursor-pointer"
|
|
126
|
-
>
|
|
127
|
-
{currency === "USD" ? "$" : currency === "EUR" ? "€" : "£"}
|
|
128
|
-
{suggestedAmount}
|
|
129
|
-
</button>
|
|
130
|
-
))}
|
|
131
|
-
</div>
|
|
132
|
-
|
|
133
|
-
{/* Validation message */}
|
|
134
|
-
{amount && !isValid && (
|
|
135
|
-
<div className="mt-2 text-sm text-red-600 dark:text-red-400">
|
|
136
|
-
Please enter a valid amount between $1 and $10,000
|
|
137
|
-
</div>
|
|
138
|
-
)}
|
|
139
|
-
</div>
|
|
140
|
-
</div>
|
|
141
|
-
|
|
142
|
-
{/* Continue button */}
|
|
143
|
-
<div className="p-4 border-t border-gray-200 dark:border-gray-700">
|
|
144
|
-
<button
|
|
145
|
-
type="button"
|
|
146
|
-
onClick={() => onContinue(amount, currency)}
|
|
147
|
-
disabled={!isValid}
|
|
148
|
-
className={`w-full py-3 px-4 rounded-lg font-semibold transition-colors ${
|
|
149
|
-
isValid
|
|
150
|
-
? "bg-blue-600 hover:bg-blue-700 text-white cursor-pointer"
|
|
151
|
-
: "bg-gray-300 dark:bg-gray-600 text-gray-500 dark:text-gray-400 cursor-not-allowed"
|
|
152
|
-
}`}
|
|
153
|
-
>
|
|
154
|
-
Continue to Providers
|
|
155
|
-
</button>
|
|
156
|
-
</div>
|
|
157
|
-
</div>
|
|
158
|
-
)
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
export const MeldStepsFlow: React.FC<MeldStepsFlowProps> = ({
|
|
162
|
-
onBack: _onBack,
|
|
163
|
-
}) => {
|
|
164
|
-
const trailsConfig = useTrails()
|
|
165
|
-
const { navigate: setGlobalScreen, goHome } = useViewManager()
|
|
166
|
-
const { setSelectedToken: setOriginToken } = useOriginSelectedToken()
|
|
167
|
-
const { filteredTokens } = useTokenList({
|
|
168
|
-
onContinue: () => {},
|
|
169
|
-
onError: () => {},
|
|
170
|
-
})
|
|
171
|
-
const { address: walletAddress } = useAccount()
|
|
172
|
-
|
|
173
|
-
// Create OnrampClient using trails API key from config
|
|
174
|
-
const trailsClient = useMemo(() => {
|
|
175
|
-
return getMeldOnrampClient(
|
|
176
|
-
trailsConfig.trailsApiKey,
|
|
177
|
-
trailsConfig.trailsApiUrl,
|
|
178
|
-
)
|
|
179
|
-
}, [trailsConfig.trailsApiKey, trailsConfig.trailsApiUrl])
|
|
180
|
-
|
|
181
|
-
const [currentScreen, setCurrentScreen] = useState<Screen>("menu")
|
|
182
|
-
|
|
183
|
-
// Load from localStorage on mount
|
|
184
|
-
useEffect(() => {
|
|
185
|
-
const savedAmount = localStorage.getItem(MELD_AMOUNT_STORAGE_KEY)
|
|
186
|
-
const savedCurrency = localStorage.getItem(MELD_CURRENCY_STORAGE_KEY)
|
|
187
|
-
if (savedAmount) setSelectedAmount(savedAmount)
|
|
188
|
-
if (savedCurrency) setSelectedCurrency(savedCurrency)
|
|
189
|
-
}, [])
|
|
190
|
-
|
|
191
|
-
// Load from local storage on mount
|
|
192
|
-
const [selectedCountry, setSelectedCountry] = useState<Country | null>(() => {
|
|
193
|
-
try {
|
|
194
|
-
const saved = localStorage.getItem("meld-debug-country")
|
|
195
|
-
return saved ? JSON.parse(saved) : null
|
|
196
|
-
} catch {
|
|
197
|
-
return null
|
|
198
|
-
}
|
|
199
|
-
})
|
|
200
|
-
|
|
201
|
-
const [selectedPaymentMethod, setSelectedPaymentMethod] =
|
|
202
|
-
useState<MeldPaymentMethod | null>(() => {
|
|
203
|
-
try {
|
|
204
|
-
return localStorage.getItem("meld-debug-payment-method") || null
|
|
205
|
-
} catch {
|
|
206
|
-
return null
|
|
207
|
-
}
|
|
208
|
-
})
|
|
209
|
-
|
|
210
|
-
const [selectedToken, setSelectedToken] = useState<MeldToken | null>(() => {
|
|
211
|
-
try {
|
|
212
|
-
const saved = localStorage.getItem("meld-debug-token")
|
|
213
|
-
return saved ? JSON.parse(saved) : null
|
|
214
|
-
} catch {
|
|
215
|
-
return null
|
|
216
|
-
}
|
|
217
|
-
})
|
|
218
|
-
|
|
219
|
-
const [selectedAmount, setSelectedAmount] = useState<string>("")
|
|
220
|
-
const [selectedCurrency, setSelectedCurrency] = useState<string>("USD")
|
|
221
|
-
const [widgetUrl, setWidgetUrl] = useState<string>("")
|
|
222
|
-
const [isLoadingUrl, setIsLoadingUrl] = useState(false)
|
|
223
|
-
const [widgetUrlError, setWidgetUrlError] = useState<string>("")
|
|
224
|
-
|
|
225
|
-
// Store available providers from quote
|
|
226
|
-
const [availableProviders, setAvailableProviders] = useState<MeldQuote[]>([])
|
|
227
|
-
const [_isLoadingProviders, setIsLoadingProviders] = useState(false)
|
|
228
|
-
const [selectedProvider, setSelectedProvider] = useState<MeldQuote | null>(
|
|
229
|
-
null,
|
|
230
|
-
)
|
|
231
|
-
const [hasClickedContinue, setHasClickedContinue] = useState(false)
|
|
232
|
-
|
|
233
|
-
// Transaction tracking state
|
|
234
|
-
const [currentTransactionId, setCurrentTransactionId] = useState<
|
|
235
|
-
string | null
|
|
236
|
-
>(null)
|
|
237
|
-
const [transactionStatus, setTransactionStatus] = useState<{
|
|
238
|
-
status: string
|
|
239
|
-
message: string
|
|
240
|
-
type: "success" | "error" | "pending" | null
|
|
241
|
-
}>({ status: "", message: "", type: null })
|
|
242
|
-
|
|
243
|
-
// Check for transaction status from URL parameters (when user returns from Meld)
|
|
244
|
-
useEffect(() => {
|
|
245
|
-
const urlParams = new URLSearchParams(window.location.search)
|
|
246
|
-
|
|
247
|
-
// Debug: Log all URL parameters to see what Meld sends
|
|
248
|
-
logger.console.log(
|
|
249
|
-
"[MeldStepsFlow] All URL parameters:",
|
|
250
|
-
Object.fromEntries(urlParams.entries()),
|
|
251
|
-
)
|
|
252
|
-
|
|
253
|
-
// Extract Meld's actual redirect parameters
|
|
254
|
-
const transactionId =
|
|
255
|
-
urlParams.get("orderId") || // Meld sends orderId as the transaction identifier
|
|
256
|
-
urlParams.get("partnerOrderId") || // Backup identifier
|
|
257
|
-
urlParams.get("transactionId") || // Fallback options
|
|
258
|
-
urlParams.get("meld_transaction_id") ||
|
|
259
|
-
urlParams.get("transaction_id") ||
|
|
260
|
-
urlParams.get("id")
|
|
261
|
-
|
|
262
|
-
const status =
|
|
263
|
-
urlParams.get("status") || // Meld sends 'status' parameter
|
|
264
|
-
urlParams.get("meld_status") ||
|
|
265
|
-
urlParams.get("transaction_status") ||
|
|
266
|
-
urlParams.get("state")
|
|
267
|
-
|
|
268
|
-
// Extract additional transaction details from Meld's redirect
|
|
269
|
-
const fiatAmount = urlParams.get("fiatAmount")
|
|
270
|
-
const cryptoAmount = urlParams.get("cryptoAmount")
|
|
271
|
-
const fiatCurrency = urlParams.get("fiatCurrency")
|
|
272
|
-
const cryptoCurrency = urlParams.get("cryptoCurrency")
|
|
273
|
-
const totalFee = urlParams.get("totalFeeInFiat")
|
|
274
|
-
const walletAddress = urlParams.get("walletAddress")
|
|
275
|
-
const network = urlParams.get("network")
|
|
276
|
-
|
|
277
|
-
logger.console.log("[MeldStepsFlow] Meld transaction details:", {
|
|
278
|
-
transactionId,
|
|
279
|
-
status,
|
|
280
|
-
fiatAmount,
|
|
281
|
-
cryptoAmount,
|
|
282
|
-
fiatCurrency,
|
|
283
|
-
cryptoCurrency,
|
|
284
|
-
totalFee,
|
|
285
|
-
walletAddress,
|
|
286
|
-
network,
|
|
287
|
-
})
|
|
288
|
-
|
|
289
|
-
logger.console.log(
|
|
290
|
-
"[MeldStepsFlow] Extracted transaction ID:",
|
|
291
|
-
transactionId,
|
|
292
|
-
)
|
|
293
|
-
logger.console.log("[MeldStepsFlow] Extracted status:", status)
|
|
294
|
-
|
|
295
|
-
// If no transaction ID from URL, try to search for transactions using wallet address
|
|
296
|
-
const finalTransactionId = transactionId
|
|
297
|
-
if (!finalTransactionId) {
|
|
298
|
-
logger.console.log(
|
|
299
|
-
"[MeldStepsFlow] No transaction ID in URL, will search by wallet address:",
|
|
300
|
-
walletAddress,
|
|
301
|
-
)
|
|
302
|
-
|
|
303
|
-
// Use the search API to find transactions by wallet address (external customer ID)
|
|
304
|
-
if (walletAddress) {
|
|
305
|
-
logger.console.log(
|
|
306
|
-
"[MeldStepsFlow] Searching for transactions by wallet address (external customer ID):",
|
|
307
|
-
walletAddress,
|
|
308
|
-
)
|
|
309
|
-
|
|
310
|
-
// Search for transactions - this will be done async after the useEffect
|
|
311
|
-
setTimeout(async () => {
|
|
312
|
-
try {
|
|
313
|
-
// Use stored customer ID from createMeldWidgetSession response
|
|
314
|
-
const storedCustomerId = localStorage.getItem(
|
|
315
|
-
"meld-current-customer-id-for-search",
|
|
316
|
-
)
|
|
317
|
-
|
|
318
|
-
logger.console.log(
|
|
319
|
-
"[MeldStepsFlow] About to call searchMeldTransactions with params:",
|
|
320
|
-
{
|
|
321
|
-
customerIds: storedCustomerId,
|
|
322
|
-
fallbackCustomerIds: walletAddress,
|
|
323
|
-
limit: 10,
|
|
324
|
-
},
|
|
325
|
-
)
|
|
326
|
-
|
|
327
|
-
// Search by customerIds (using customerId value) if available, otherwise fallback to customerIds with wallet address
|
|
328
|
-
const searchParams = storedCustomerId
|
|
329
|
-
? { customerIds: storedCustomerId, limit: 10 }
|
|
330
|
-
: { customerIds: walletAddress, limit: 10 }
|
|
331
|
-
|
|
332
|
-
const searchResponse =
|
|
333
|
-
await trailsClient.searchMeldTransactions(searchParams)
|
|
334
|
-
|
|
335
|
-
// Also try searching without specific customer ID to see all recent transactions
|
|
336
|
-
logger.console.log(
|
|
337
|
-
"[MeldStepsFlow] Also searching for any recent transactions...",
|
|
338
|
-
)
|
|
339
|
-
const allRecentResponse = await trailsClient.searchMeldTransactions(
|
|
340
|
-
{
|
|
341
|
-
limit: 5, // Get last 5 transactions regardless of customer ID
|
|
342
|
-
},
|
|
343
|
-
)
|
|
344
|
-
logger.console.log(
|
|
345
|
-
"[MeldStepsFlow] All recent transactions:",
|
|
346
|
-
allRecentResponse,
|
|
347
|
-
)
|
|
348
|
-
|
|
349
|
-
logger.console.log(
|
|
350
|
-
"[MeldStepsFlow] Search response:",
|
|
351
|
-
searchResponse,
|
|
352
|
-
)
|
|
353
|
-
|
|
354
|
-
// Parse the transactions response
|
|
355
|
-
let transactions: any
|
|
356
|
-
try {
|
|
357
|
-
transactions =
|
|
358
|
-
typeof searchResponse.transactions === "string"
|
|
359
|
-
? JSON.parse(searchResponse.transactions)
|
|
360
|
-
: searchResponse.transactions
|
|
361
|
-
} catch (e) {
|
|
362
|
-
logger.console.error(
|
|
363
|
-
"[MeldStepsFlow] Error parsing search response:",
|
|
364
|
-
e,
|
|
365
|
-
)
|
|
366
|
-
return
|
|
367
|
-
}
|
|
368
|
-
|
|
369
|
-
// Check if we found any transactions
|
|
370
|
-
if (
|
|
371
|
-
transactions?.transactions &&
|
|
372
|
-
transactions.transactions.length > 0
|
|
373
|
-
) {
|
|
374
|
-
const latestTransaction = transactions.transactions[0]
|
|
375
|
-
logger.console.log(
|
|
376
|
-
"[MeldStepsFlow] Found transaction from search:",
|
|
377
|
-
latestTransaction,
|
|
378
|
-
)
|
|
379
|
-
|
|
380
|
-
// Session ID is already saved from createMeldWidgetSession response
|
|
381
|
-
// No need to extract customer ID since we're using sessionIds for search
|
|
382
|
-
|
|
383
|
-
// Set the transaction ID for polling getMeldTransaction
|
|
384
|
-
const transactionId =
|
|
385
|
-
latestTransaction.id || latestTransaction.transactionId
|
|
386
|
-
logger.console.log(
|
|
387
|
-
"[MeldStepsFlow] Setting currentTransactionId for polling:",
|
|
388
|
-
transactionId,
|
|
389
|
-
)
|
|
390
|
-
setCurrentTransactionId(transactionId)
|
|
391
|
-
|
|
392
|
-
// Set initial status based on the transaction
|
|
393
|
-
let type: "success" | "error" | "pending" = "pending"
|
|
394
|
-
let message = "Payment is being processed..."
|
|
395
|
-
|
|
396
|
-
const statusLower = (latestTransaction.status || "").toLowerCase()
|
|
397
|
-
// Use complete Meld status mapping
|
|
398
|
-
switch (statusLower) {
|
|
399
|
-
// TERMINAL SUCCESS STATE
|
|
400
|
-
case "settled": {
|
|
401
|
-
type = "success"
|
|
402
|
-
const amount = latestTransaction.destinationAmount || ""
|
|
403
|
-
const symbol = latestTransaction.destinationCurrencyCode || ""
|
|
404
|
-
const chainId =
|
|
405
|
-
latestTransaction.destinationChainId ||
|
|
406
|
-
latestTransaction.networkId
|
|
407
|
-
const provider =
|
|
408
|
-
latestTransaction.serviceProvider || "provider"
|
|
409
|
-
const chainName = chainId ? getChainName(Number(chainId)) : ""
|
|
410
|
-
|
|
411
|
-
const cryptoInfo =
|
|
412
|
-
amount && symbol
|
|
413
|
-
? `${amount} ${symbol}${chainName ? ` on ${chainName}` : ""} via ${provider.toUpperCase()}`
|
|
414
|
-
: "crypto"
|
|
415
|
-
const addressInfo = latestTransaction.walletAddress
|
|
416
|
-
? ` to ${truncateAddress(latestTransaction.walletAddress, 6, 4)}`
|
|
417
|
-
: ""
|
|
418
|
-
message = `Payment completed! ${cryptoInfo} purchased${addressInfo}`
|
|
419
|
-
break
|
|
420
|
-
}
|
|
421
|
-
|
|
422
|
-
// TERMINAL FAILURE STATES
|
|
423
|
-
case "failed":
|
|
424
|
-
type = "error"
|
|
425
|
-
message =
|
|
426
|
-
"Payment failed. Please try again with a different payment method."
|
|
427
|
-
break
|
|
428
|
-
case "declined":
|
|
429
|
-
type = "error"
|
|
430
|
-
message =
|
|
431
|
-
"Payment declined by your bank. Please check your payment method or try a different card."
|
|
432
|
-
break
|
|
433
|
-
case "cancelled":
|
|
434
|
-
type = "error"
|
|
435
|
-
message =
|
|
436
|
-
"Payment was cancelled. You can start a new transaction."
|
|
437
|
-
break
|
|
438
|
-
case "refunded":
|
|
439
|
-
type = "error"
|
|
440
|
-
message =
|
|
441
|
-
"Payment was refunded. Crypto could not be delivered."
|
|
442
|
-
break
|
|
443
|
-
|
|
444
|
-
// TEMPORARY PROCESSING STATES
|
|
445
|
-
case "pending_created":
|
|
446
|
-
case "pending created":
|
|
447
|
-
type = "pending"
|
|
448
|
-
message =
|
|
449
|
-
"Transaction created. Waiting for provider processing..."
|
|
450
|
-
break
|
|
451
|
-
case "pending":
|
|
452
|
-
type = "pending"
|
|
453
|
-
message = "Payment submitted for review and verification..."
|
|
454
|
-
break
|
|
455
|
-
case "settling":
|
|
456
|
-
type = "pending"
|
|
457
|
-
message = "Payment approved! Crypto transfer in progress..."
|
|
458
|
-
break
|
|
459
|
-
case "two_fa_required":
|
|
460
|
-
case "2fa_required":
|
|
461
|
-
type = "pending"
|
|
462
|
-
message = "Please complete 2FA verification to continue..."
|
|
463
|
-
break
|
|
464
|
-
case "two_fa_provided":
|
|
465
|
-
case "2fa_provided":
|
|
466
|
-
type = "pending"
|
|
467
|
-
message = "2FA submitted. Validating with card issuer..."
|
|
468
|
-
break
|
|
469
|
-
case "error":
|
|
470
|
-
type = "pending"
|
|
471
|
-
message = "Processing error. Retrying automatically..."
|
|
472
|
-
break
|
|
473
|
-
|
|
474
|
-
// LEGACY STATUS MAPPING
|
|
475
|
-
case "accepted":
|
|
476
|
-
case "authorized":
|
|
477
|
-
case "partially_settled":
|
|
478
|
-
case "completed":
|
|
479
|
-
case "success":
|
|
480
|
-
case "processing":
|
|
481
|
-
type = "pending"
|
|
482
|
-
message = "Payment is being processed..."
|
|
483
|
-
break
|
|
484
|
-
case "authorization_expired":
|
|
485
|
-
type = "error"
|
|
486
|
-
message = "Payment authorization expired. Please try again."
|
|
487
|
-
break
|
|
488
|
-
|
|
489
|
-
default:
|
|
490
|
-
type = "pending"
|
|
491
|
-
break
|
|
492
|
-
}
|
|
493
|
-
|
|
494
|
-
// Fallback message handling for pending states
|
|
495
|
-
if (
|
|
496
|
-
type === "pending" &&
|
|
497
|
-
!message.includes("Transaction created") &&
|
|
498
|
-
!message.includes("Payment submitted") &&
|
|
499
|
-
!message.includes("Payment approved") &&
|
|
500
|
-
!message.includes("complete 2FA") &&
|
|
501
|
-
!message.includes("2FA submitted") &&
|
|
502
|
-
!message.includes("Processing error")
|
|
503
|
-
) {
|
|
504
|
-
const amount = latestTransaction.destinationAmount || ""
|
|
505
|
-
const symbol = latestTransaction.destinationCurrencyCode || ""
|
|
506
|
-
const chainId =
|
|
507
|
-
latestTransaction.destinationChainId ||
|
|
508
|
-
latestTransaction.networkId
|
|
509
|
-
const provider = latestTransaction.serviceProvider || "provider"
|
|
510
|
-
const chainName = chainId ? getChainName(Number(chainId)) : ""
|
|
511
|
-
|
|
512
|
-
const cryptoInfo =
|
|
513
|
-
amount && symbol
|
|
514
|
-
? `${amount} ${symbol}${chainName ? ` on ${chainName}` : ""} via ${provider.toUpperCase()}`
|
|
515
|
-
: "payment"
|
|
516
|
-
message = `${cryptoInfo} is being processed...`
|
|
517
|
-
}
|
|
518
|
-
|
|
519
|
-
setTransactionStatus({
|
|
520
|
-
status: latestTransaction.status || "PROCESSING",
|
|
521
|
-
message,
|
|
522
|
-
type,
|
|
523
|
-
})
|
|
524
|
-
logger.console.log(
|
|
525
|
-
"[MeldStepsFlow] Set transaction status from search:",
|
|
526
|
-
{ status: latestTransaction.status, type, message },
|
|
527
|
-
)
|
|
528
|
-
} else {
|
|
529
|
-
logger.console.log(
|
|
530
|
-
"[MeldStepsFlow] No transactions found for wallet address:",
|
|
531
|
-
walletAddress,
|
|
532
|
-
)
|
|
533
|
-
logger.console.log(
|
|
534
|
-
"[MeldStepsFlow] Search result shows no transactions, this is normal for first-time users",
|
|
535
|
-
)
|
|
536
|
-
// Don't set any transaction status or error here - this is expected for new users
|
|
537
|
-
}
|
|
538
|
-
} catch (error) {
|
|
539
|
-
logger.console.error(
|
|
540
|
-
"[MeldStepsFlow] Error searching for transactions:",
|
|
541
|
-
error,
|
|
542
|
-
)
|
|
543
|
-
}
|
|
544
|
-
}, 100)
|
|
545
|
-
} else {
|
|
546
|
-
logger.console.log(
|
|
547
|
-
"[MeldStepsFlow] No wallet address available for transaction search",
|
|
548
|
-
)
|
|
549
|
-
}
|
|
550
|
-
}
|
|
551
|
-
|
|
552
|
-
if (finalTransactionId) {
|
|
553
|
-
logger.console.log(
|
|
554
|
-
"[MeldStepsFlow] Setting transaction ID for tracking from URL:",
|
|
555
|
-
finalTransactionId,
|
|
556
|
-
)
|
|
557
|
-
setCurrentTransactionId(finalTransactionId)
|
|
558
|
-
|
|
559
|
-
if (status) {
|
|
560
|
-
// Set initial status based on URL params from Meld
|
|
561
|
-
const statusLower = (status || "").toLowerCase()
|
|
562
|
-
|
|
563
|
-
// Use complete Meld status mapping
|
|
564
|
-
let type: "success" | "error" | "pending" = "pending"
|
|
565
|
-
switch (statusLower) {
|
|
566
|
-
case "settled":
|
|
567
|
-
type = "success"
|
|
568
|
-
break
|
|
569
|
-
case "failed":
|
|
570
|
-
case "declined":
|
|
571
|
-
case "cancelled":
|
|
572
|
-
case "refunded":
|
|
573
|
-
case "authorization_expired":
|
|
574
|
-
type = "error"
|
|
575
|
-
break
|
|
576
|
-
case "pending_created":
|
|
577
|
-
case "pending created":
|
|
578
|
-
case "pending":
|
|
579
|
-
case "settling":
|
|
580
|
-
case "two_fa_required":
|
|
581
|
-
case "2fa_required":
|
|
582
|
-
case "two_fa_provided":
|
|
583
|
-
case "2fa_provided":
|
|
584
|
-
case "error":
|
|
585
|
-
case "accepted":
|
|
586
|
-
case "authorized":
|
|
587
|
-
case "partially_settled":
|
|
588
|
-
case "completed":
|
|
589
|
-
case "success":
|
|
590
|
-
case "processing":
|
|
591
|
-
type = "pending"
|
|
592
|
-
break
|
|
593
|
-
default:
|
|
594
|
-
type = "pending"
|
|
595
|
-
break
|
|
596
|
-
}
|
|
597
|
-
|
|
598
|
-
// Create detailed message using Meld's redirect data
|
|
599
|
-
let message = "Payment is being processed..."
|
|
600
|
-
if (type === "success") {
|
|
601
|
-
const amount = cryptoAmount || ""
|
|
602
|
-
const symbol = cryptoCurrency || ""
|
|
603
|
-
const chainName = network || ""
|
|
604
|
-
// Extract provider from URL or use "MELD"
|
|
605
|
-
const provider = "MELD" // Default since we may not have provider info in URL params
|
|
606
|
-
|
|
607
|
-
const cryptoInfo =
|
|
608
|
-
amount && symbol
|
|
609
|
-
? `${amount} ${symbol}${chainName ? ` on ${chainName}` : ""} via ${provider}`
|
|
610
|
-
: "crypto"
|
|
611
|
-
const addressInfo = walletAddress
|
|
612
|
-
? ` to ${truncateAddress(walletAddress, 6, 4)}`
|
|
613
|
-
: ""
|
|
614
|
-
message = `Payment completed! ${cryptoInfo} purchased${addressInfo}`
|
|
615
|
-
} else if (type === "error") {
|
|
616
|
-
message = "Payment failed or was cancelled."
|
|
617
|
-
} else {
|
|
618
|
-
// For pending states, we might not have full transaction details yet
|
|
619
|
-
const amount = cryptoAmount || fiatAmount || ""
|
|
620
|
-
const symbol = cryptoCurrency || ""
|
|
621
|
-
const chainName = network || ""
|
|
622
|
-
const provider = "MELD" // Default provider
|
|
623
|
-
|
|
624
|
-
if (amount && symbol) {
|
|
625
|
-
const cryptoInfo = `${amount} ${symbol}${chainName ? ` on ${chainName}` : ""} via ${provider}`
|
|
626
|
-
message = `${cryptoInfo} is being processed...`
|
|
627
|
-
} else {
|
|
628
|
-
const fiatInfo =
|
|
629
|
-
fiatAmount && fiatCurrency
|
|
630
|
-
? `${fiatCurrency} ${fiatAmount}`
|
|
631
|
-
: "payment"
|
|
632
|
-
message = `${fiatInfo} is being processed...`
|
|
633
|
-
}
|
|
634
|
-
}
|
|
635
|
-
|
|
636
|
-
setTransactionStatus({ status, message, type })
|
|
637
|
-
logger.console.log("[MeldStepsFlow] Set initial transaction status:", {
|
|
638
|
-
status,
|
|
639
|
-
type,
|
|
640
|
-
message,
|
|
641
|
-
})
|
|
642
|
-
}
|
|
643
|
-
|
|
644
|
-
// Clean up URL parameters (expand the list to include Meld's actual parameters)
|
|
645
|
-
const newUrl = new URL(window.location.href)
|
|
646
|
-
const paramsToClean = [
|
|
647
|
-
// Original fallback parameters
|
|
648
|
-
"transactionId",
|
|
649
|
-
"meld_transaction_id",
|
|
650
|
-
"transaction_id",
|
|
651
|
-
"id",
|
|
652
|
-
"sessionId",
|
|
653
|
-
"session_id",
|
|
654
|
-
"status",
|
|
655
|
-
"meld_status",
|
|
656
|
-
"transaction_status",
|
|
657
|
-
"state",
|
|
658
|
-
// Meld's actual redirect parameters
|
|
659
|
-
"orderId",
|
|
660
|
-
"partnerOrderId",
|
|
661
|
-
"partnerCustomerId",
|
|
662
|
-
"fiatAmount",
|
|
663
|
-
"cryptoAmount",
|
|
664
|
-
"fiatCurrency",
|
|
665
|
-
"cryptoCurrency",
|
|
666
|
-
"totalFeeInFiat",
|
|
667
|
-
"walletAddress",
|
|
668
|
-
"network",
|
|
669
|
-
"isBuyOrSell",
|
|
670
|
-
"isNFTOrder",
|
|
671
|
-
]
|
|
672
|
-
for (const param of paramsToClean) {
|
|
673
|
-
newUrl.searchParams.delete(param)
|
|
674
|
-
}
|
|
675
|
-
window.history.replaceState(null, "", newUrl.toString())
|
|
676
|
-
} else {
|
|
677
|
-
logger.console.log(
|
|
678
|
-
"[MeldStepsFlow] No transaction ID found in URL parameters",
|
|
679
|
-
)
|
|
680
|
-
}
|
|
681
|
-
}, [trailsClient])
|
|
682
|
-
|
|
683
|
-
// Function to check transaction status
|
|
684
|
-
const checkTransactionStatus = useCallback(
|
|
685
|
-
async (transactionId: string) => {
|
|
686
|
-
// Validate transaction ID format
|
|
687
|
-
if (
|
|
688
|
-
!transactionId ||
|
|
689
|
-
transactionId.trim() === "" ||
|
|
690
|
-
transactionId === "null" ||
|
|
691
|
-
transactionId === "undefined"
|
|
692
|
-
) {
|
|
693
|
-
logger.console.warn(
|
|
694
|
-
"[MeldStepsFlow] Invalid transaction ID, skipping API call:",
|
|
695
|
-
transactionId,
|
|
696
|
-
)
|
|
697
|
-
return
|
|
698
|
-
}
|
|
699
|
-
|
|
700
|
-
try {
|
|
701
|
-
logger.console.log(
|
|
702
|
-
"[MeldStepsFlow] Checking transaction status for ID:",
|
|
703
|
-
transactionId,
|
|
704
|
-
)
|
|
705
|
-
logger.console.log(
|
|
706
|
-
"[MeldStepsFlow] Making API call to getMeldTransaction...",
|
|
707
|
-
)
|
|
708
|
-
const response = await trailsClient.getMeldTransaction({
|
|
709
|
-
transactionId,
|
|
710
|
-
})
|
|
711
|
-
logger.console.log("[MeldStepsFlow] Raw API response:", response)
|
|
712
|
-
logger.console.log("[MeldStepsFlow] Response type:", typeof response)
|
|
713
|
-
logger.console.log(
|
|
714
|
-
"[MeldStepsFlow] Response keys:",
|
|
715
|
-
Object.keys(response || {}),
|
|
716
|
-
)
|
|
717
|
-
logger.console.log(
|
|
718
|
-
"[MeldStepsFlow] Transaction data:",
|
|
719
|
-
response?.transaction,
|
|
720
|
-
)
|
|
721
|
-
logger.console.log(
|
|
722
|
-
"[MeldStepsFlow] Transaction data type:",
|
|
723
|
-
typeof response?.transaction,
|
|
724
|
-
)
|
|
725
|
-
|
|
726
|
-
// Parse transaction data - it comes back as JSON string
|
|
727
|
-
let transaction: any
|
|
728
|
-
try {
|
|
729
|
-
transaction =
|
|
730
|
-
typeof response.transaction === "string"
|
|
731
|
-
? JSON.parse(response.transaction)
|
|
732
|
-
: response.transaction
|
|
733
|
-
} catch (e) {
|
|
734
|
-
logger.console.error(
|
|
735
|
-
"[MeldStepsFlow] Error parsing transaction data:",
|
|
736
|
-
e,
|
|
737
|
-
)
|
|
738
|
-
return
|
|
739
|
-
}
|
|
740
|
-
|
|
741
|
-
// Handle nested transaction structure (transaction.transaction)
|
|
742
|
-
if (transaction?.transaction) {
|
|
743
|
-
transaction = transaction.transaction
|
|
744
|
-
}
|
|
745
|
-
|
|
746
|
-
if (!transaction) {
|
|
747
|
-
logger.console.warn("[MeldStepsFlow] No transaction data in response")
|
|
748
|
-
return
|
|
749
|
-
}
|
|
750
|
-
|
|
751
|
-
let type: "success" | "error" | "pending" = "pending"
|
|
752
|
-
let message = "Payment is being processed..."
|
|
753
|
-
|
|
754
|
-
logger.console.log(
|
|
755
|
-
"[MeldStepsFlow] Transaction status:",
|
|
756
|
-
transaction.status,
|
|
757
|
-
)
|
|
758
|
-
|
|
759
|
-
switch ((transaction.status || "").toLowerCase()) {
|
|
760
|
-
// TERMINAL SUCCESS STATE
|
|
761
|
-
case "settled": {
|
|
762
|
-
type = "success"
|
|
763
|
-
// Try multiple possible wallet address fields
|
|
764
|
-
const walletAddr =
|
|
765
|
-
transaction.walletAddress ||
|
|
766
|
-
transaction.destinationWalletAddress ||
|
|
767
|
-
transaction.cryptoDetails?.destinationWalletAddress ||
|
|
768
|
-
transaction.cryptoDetails?.sessionWalletAddress ||
|
|
769
|
-
""
|
|
770
|
-
const addressInfo =
|
|
771
|
-
walletAddr && typeof walletAddr === "string"
|
|
772
|
-
? ` sent to ${truncateAddress(walletAddr)}`
|
|
773
|
-
: ""
|
|
774
|
-
const amount =
|
|
775
|
-
transaction.destinationAmount ||
|
|
776
|
-
transaction.cryptoDetails?.destinationAmount ||
|
|
777
|
-
""
|
|
778
|
-
const currency = transaction.destinationCurrencyCode || ""
|
|
779
|
-
const chainId =
|
|
780
|
-
transaction.destinationChainId || transaction.networkId
|
|
781
|
-
const provider = transaction.serviceProvider || "MELD"
|
|
782
|
-
const chainName = chainId ? getChainName(Number(chainId)) : ""
|
|
783
|
-
|
|
784
|
-
const cryptoInfo =
|
|
785
|
-
amount && currency
|
|
786
|
-
? `${amount} ${currency}${chainName ? ` on ${chainName}` : ""} via ${provider.toUpperCase()}`
|
|
787
|
-
: "crypto"
|
|
788
|
-
message = `Payment completed! ${cryptoInfo} purchased${addressInfo}`
|
|
789
|
-
break
|
|
790
|
-
}
|
|
791
|
-
|
|
792
|
-
// TERMINAL FAILURE STATES
|
|
793
|
-
case "failed":
|
|
794
|
-
type = "error"
|
|
795
|
-
message =
|
|
796
|
-
"Payment failed. Please try again with a different payment method."
|
|
797
|
-
break
|
|
798
|
-
case "declined":
|
|
799
|
-
type = "error"
|
|
800
|
-
message =
|
|
801
|
-
"Payment declined by your bank. Please check your payment method or try a different card."
|
|
802
|
-
break
|
|
803
|
-
case "cancelled":
|
|
804
|
-
type = "error"
|
|
805
|
-
message = "Payment was cancelled. You can start a new transaction."
|
|
806
|
-
break
|
|
807
|
-
case "refunded":
|
|
808
|
-
type = "error"
|
|
809
|
-
message = "Payment was refunded. Crypto could not be delivered."
|
|
810
|
-
break
|
|
811
|
-
|
|
812
|
-
// TEMPORARY PROCESSING STATES
|
|
813
|
-
case "pending_created":
|
|
814
|
-
case "pending created":
|
|
815
|
-
type = "pending"
|
|
816
|
-
message = "Transaction created. Waiting for provider processing..."
|
|
817
|
-
break
|
|
818
|
-
case "pending":
|
|
819
|
-
type = "pending"
|
|
820
|
-
message = "Payment submitted for review and verification..."
|
|
821
|
-
break
|
|
822
|
-
case "settling":
|
|
823
|
-
type = "pending"
|
|
824
|
-
message = "Payment approved! Crypto transfer in progress..."
|
|
825
|
-
break
|
|
826
|
-
case "two_fa_required":
|
|
827
|
-
case "2fa_required":
|
|
828
|
-
type = "pending"
|
|
829
|
-
message = "Please complete 2FA verification to continue..."
|
|
830
|
-
break
|
|
831
|
-
case "two_fa_provided":
|
|
832
|
-
case "2fa_provided":
|
|
833
|
-
type = "pending"
|
|
834
|
-
message = "2FA submitted. Validating with card issuer..."
|
|
835
|
-
break
|
|
836
|
-
case "error":
|
|
837
|
-
type = "pending"
|
|
838
|
-
message = "Processing error. Retrying automatically..."
|
|
839
|
-
break
|
|
840
|
-
|
|
841
|
-
// LEGACY STATUS MAPPING
|
|
842
|
-
case "accepted":
|
|
843
|
-
case "authorized":
|
|
844
|
-
case "partially_settled":
|
|
845
|
-
type = "pending"
|
|
846
|
-
message = "Payment is being processed..."
|
|
847
|
-
break
|
|
848
|
-
case "authorization_expired":
|
|
849
|
-
type = "error"
|
|
850
|
-
message = "Payment authorization expired. Please try again."
|
|
851
|
-
break
|
|
852
|
-
|
|
853
|
-
// FALLBACK
|
|
854
|
-
case "processing":
|
|
855
|
-
case "completed":
|
|
856
|
-
case "success":
|
|
857
|
-
type = "pending"
|
|
858
|
-
message = "Payment is being processed..."
|
|
859
|
-
break
|
|
860
|
-
default:
|
|
861
|
-
type = "pending"
|
|
862
|
-
message = `Payment status: ${transaction.status || "Processing..."}`
|
|
863
|
-
}
|
|
864
|
-
|
|
865
|
-
logger.console.log("[MeldStepsFlow] Setting transaction status:", {
|
|
866
|
-
status: transaction.status,
|
|
867
|
-
message,
|
|
868
|
-
type,
|
|
869
|
-
})
|
|
870
|
-
setTransactionStatus({ status: transaction.status, message, type })
|
|
871
|
-
return transaction
|
|
872
|
-
} catch (error) {
|
|
873
|
-
logger.console.error(
|
|
874
|
-
"[MeldStepsFlow] Error checking transaction status:",
|
|
875
|
-
error,
|
|
876
|
-
)
|
|
877
|
-
|
|
878
|
-
// Provide more detailed error information
|
|
879
|
-
let errorMessage = "Unable to check payment status."
|
|
880
|
-
if (error instanceof Error) {
|
|
881
|
-
errorMessage = `Error: ${error.message}`
|
|
882
|
-
// Check for specific error types
|
|
883
|
-
if (
|
|
884
|
-
error.message.includes("404") ||
|
|
885
|
-
error.message.includes("not found")
|
|
886
|
-
) {
|
|
887
|
-
errorMessage = `Transaction not found. ID: ${transactionId}`
|
|
888
|
-
} else if (
|
|
889
|
-
error.message.includes("401") ||
|
|
890
|
-
error.message.includes("Unauthorized")
|
|
891
|
-
) {
|
|
892
|
-
errorMessage = "Not authorized to access transaction data."
|
|
893
|
-
} else if (error.message.includes("timeout")) {
|
|
894
|
-
errorMessage = "Request timed out. Please try again."
|
|
895
|
-
}
|
|
896
|
-
}
|
|
897
|
-
|
|
898
|
-
setTransactionStatus({
|
|
899
|
-
status: "error",
|
|
900
|
-
message: errorMessage,
|
|
901
|
-
type: "error",
|
|
902
|
-
})
|
|
903
|
-
}
|
|
904
|
-
},
|
|
905
|
-
[trailsClient],
|
|
906
|
-
)
|
|
907
|
-
|
|
908
|
-
// Generate widget URL using selected provider
|
|
909
|
-
const generateWidgetUrl = useCallback(async () => {
|
|
910
|
-
if (
|
|
911
|
-
!selectedProvider ||
|
|
912
|
-
!selectedCountry ||
|
|
913
|
-
!selectedToken ||
|
|
914
|
-
!selectedAmount
|
|
915
|
-
) {
|
|
916
|
-
setWidgetUrl("")
|
|
917
|
-
setWidgetUrlError("Please select all required options")
|
|
918
|
-
return
|
|
919
|
-
}
|
|
920
|
-
|
|
921
|
-
if (!walletAddress) {
|
|
922
|
-
setWidgetUrl("")
|
|
923
|
-
setWidgetUrlError("Please connect your wallet first")
|
|
924
|
-
return
|
|
925
|
-
}
|
|
926
|
-
|
|
927
|
-
setIsLoadingUrl(true)
|
|
928
|
-
setWidgetUrlError("") // Clear previous errors
|
|
929
|
-
try {
|
|
930
|
-
// Generate external session ID for tracking
|
|
931
|
-
const externalSessionId = `meld-${Date.now()}-${Math.random().toString(36).substring(7)}`
|
|
932
|
-
logger.console.log(
|
|
933
|
-
"[MeldStepsFlow] Generated external session ID:",
|
|
934
|
-
externalSessionId,
|
|
935
|
-
)
|
|
936
|
-
localStorage.setItem(
|
|
937
|
-
"meld-current-external-session-id",
|
|
938
|
-
externalSessionId,
|
|
939
|
-
)
|
|
940
|
-
logger.console.log(
|
|
941
|
-
"[MeldStepsFlow] Stored external session ID in localStorage",
|
|
942
|
-
)
|
|
943
|
-
|
|
944
|
-
// Build redirect URL (current page URL without query params)
|
|
945
|
-
const _redirectUrl = window.location.origin + window.location.pathname
|
|
946
|
-
|
|
947
|
-
logger.console.log("[MeldStepsFlow] Creating widget session with:", {
|
|
948
|
-
countryCode: selectedCountry.countryCode,
|
|
949
|
-
destinationCurrencyCode: selectedToken.code,
|
|
950
|
-
serviceProvider: selectedProvider.serviceProvider,
|
|
951
|
-
paymentMethodType: selectedPaymentMethod,
|
|
952
|
-
externalSessionId,
|
|
953
|
-
walletAddress,
|
|
954
|
-
})
|
|
955
|
-
|
|
956
|
-
// Use the active wallet address directly
|
|
957
|
-
const effectiveCustomerId = normalizeAddress(walletAddress)
|
|
958
|
-
|
|
959
|
-
// Create widget session via API call - use wallet address as customer ID
|
|
960
|
-
const sessionResponse = await trailsClient.createMeldWidgetSession({
|
|
961
|
-
sessionData: {
|
|
962
|
-
walletAddress: walletAddress,
|
|
963
|
-
countryCode: selectedCountry.countryCode,
|
|
964
|
-
sourceCurrencyCode: selectedCurrency,
|
|
965
|
-
sourceAmount: selectedAmount,
|
|
966
|
-
destinationCurrencyCode: selectedToken.code,
|
|
967
|
-
serviceProvider: selectedProvider.serviceProvider,
|
|
968
|
-
paymentMethodType: selectedPaymentMethod || undefined,
|
|
969
|
-
// redirectUrl, // Redirect back to current page after completion
|
|
970
|
-
},
|
|
971
|
-
sessionType: "BUY",
|
|
972
|
-
externalCustomerId: effectiveCustomerId,
|
|
973
|
-
externalSessionId: externalSessionId,
|
|
974
|
-
})
|
|
975
|
-
|
|
976
|
-
logger.console.log("[MeldStepsFlow] Session response:", sessionResponse)
|
|
977
|
-
|
|
978
|
-
// The API returns { WidgetSession: { widgetUrl, serviceProviderWidgetUrl, ... } }
|
|
979
|
-
// Similar to QuoteResponse, it's wrapped in a capitalized object
|
|
980
|
-
const widgetSessionData =
|
|
981
|
-
(sessionResponse as any).WidgetSession || sessionResponse.widgetSession
|
|
982
|
-
|
|
983
|
-
if (!widgetSessionData) {
|
|
984
|
-
logger.console.error(
|
|
985
|
-
"[MeldStepsFlow] No WidgetSession found in response. Keys:",
|
|
986
|
-
Object.keys(sessionResponse),
|
|
987
|
-
)
|
|
988
|
-
setWidgetUrl("Error: No widget session data returned from API")
|
|
989
|
-
setIsLoadingUrl(false)
|
|
990
|
-
return
|
|
991
|
-
}
|
|
992
|
-
|
|
993
|
-
logger.console.log(
|
|
994
|
-
"[MeldStepsFlow] Widget session data:",
|
|
995
|
-
widgetSessionData,
|
|
996
|
-
)
|
|
997
|
-
|
|
998
|
-
// Store the customer ID returned by Meld (this is what we use for search)
|
|
999
|
-
const returnedCustomerId = widgetSessionData.customerId
|
|
1000
|
-
if (returnedCustomerId) {
|
|
1001
|
-
logger.console.log(
|
|
1002
|
-
"[MeldStepsFlow] Storing customer ID for search:",
|
|
1003
|
-
returnedCustomerId,
|
|
1004
|
-
)
|
|
1005
|
-
localStorage.setItem(
|
|
1006
|
-
"meld-current-customer-id-for-search",
|
|
1007
|
-
returnedCustomerId,
|
|
1008
|
-
)
|
|
1009
|
-
}
|
|
1010
|
-
|
|
1011
|
-
// Extract the URL from the widget session data
|
|
1012
|
-
const widgetUrl =
|
|
1013
|
-
widgetSessionData.serviceProviderWidgetUrl ||
|
|
1014
|
-
widgetSessionData.widgetUrl ||
|
|
1015
|
-
widgetSessionData.url ||
|
|
1016
|
-
(typeof widgetSessionData === "string" ? widgetSessionData : null)
|
|
1017
|
-
|
|
1018
|
-
if (!widgetUrl) {
|
|
1019
|
-
logger.console.error(
|
|
1020
|
-
"[MeldStepsFlow] No widget URL found in session data. Keys:",
|
|
1021
|
-
Object.keys(widgetSessionData),
|
|
1022
|
-
)
|
|
1023
|
-
setWidgetUrl("Error: No widget URL found in session data")
|
|
1024
|
-
setIsLoadingUrl(false)
|
|
1025
|
-
return
|
|
1026
|
-
}
|
|
1027
|
-
|
|
1028
|
-
logger.console.log("[MeldStepsFlow] Widget URL:", widgetUrl)
|
|
1029
|
-
setWidgetUrl(widgetUrl)
|
|
1030
|
-
setWidgetUrlError("") // Clear any previous errors on success
|
|
1031
|
-
} catch (error) {
|
|
1032
|
-
logger.console.error(
|
|
1033
|
-
"[MeldStepsFlow] Error generating widget URL:",
|
|
1034
|
-
error,
|
|
1035
|
-
)
|
|
1036
|
-
setWidgetUrl("")
|
|
1037
|
-
|
|
1038
|
-
let errorMessage = error instanceof Error ? error.message : String(error)
|
|
1039
|
-
|
|
1040
|
-
// Provide more helpful error messages
|
|
1041
|
-
if (errorMessage.includes("Invalid Customer")) {
|
|
1042
|
-
errorMessage = `Payment provider issue: ${selectedProvider?.serviceProvider || "Unknown provider"} is currently unavailable. Please try again later or contact support.`
|
|
1043
|
-
} else if (errorMessage.includes("BAD_REQUEST")) {
|
|
1044
|
-
errorMessage =
|
|
1045
|
-
"Invalid request parameters. Please check your selection and try again."
|
|
1046
|
-
}
|
|
1047
|
-
|
|
1048
|
-
setWidgetUrlError(errorMessage)
|
|
1049
|
-
} finally {
|
|
1050
|
-
setIsLoadingUrl(false)
|
|
1051
|
-
}
|
|
1052
|
-
}, [
|
|
1053
|
-
selectedProvider,
|
|
1054
|
-
selectedCountry,
|
|
1055
|
-
selectedToken,
|
|
1056
|
-
selectedAmount,
|
|
1057
|
-
selectedCurrency,
|
|
1058
|
-
selectedPaymentMethod,
|
|
1059
|
-
walletAddress,
|
|
1060
|
-
trailsClient,
|
|
1061
|
-
])
|
|
1062
|
-
|
|
1063
|
-
// Declare unused functions with underscore prefix to avoid linting warnings
|
|
1064
|
-
const _handleOpenWidget = useCallback(async () => {
|
|
1065
|
-
await generateWidgetUrl()
|
|
1066
|
-
if (
|
|
1067
|
-
widgetUrl &&
|
|
1068
|
-
!widgetUrl.startsWith("Error") &&
|
|
1069
|
-
!widgetUrl.startsWith("Please") &&
|
|
1070
|
-
!widgetUrl.startsWith("No")
|
|
1071
|
-
) {
|
|
1072
|
-
window.open(widgetUrl, "_blank")
|
|
1073
|
-
}
|
|
1074
|
-
}, [widgetUrl, generateWidgetUrl])
|
|
1075
|
-
|
|
1076
|
-
const _handleContinue = useCallback(() => {
|
|
1077
|
-
if (!selectedToken) {
|
|
1078
|
-
return
|
|
1079
|
-
}
|
|
1080
|
-
|
|
1081
|
-
// Find the matching token in the widget's token list
|
|
1082
|
-
// Meld token has symbol (e.g., "USDC") and chainId
|
|
1083
|
-
// We need to match by symbol and chainId
|
|
1084
|
-
const matchingToken = filteredTokens.find((token) => {
|
|
1085
|
-
// Match by symbol and chainId
|
|
1086
|
-
return (
|
|
1087
|
-
token.symbol.toUpperCase() === selectedToken.symbol.toUpperCase() &&
|
|
1088
|
-
token.chainId === selectedToken.chainId
|
|
1089
|
-
)
|
|
1090
|
-
})
|
|
1091
|
-
|
|
1092
|
-
if (matchingToken) {
|
|
1093
|
-
// Set as origin token
|
|
1094
|
-
setOriginToken(matchingToken)
|
|
1095
|
-
goHome()
|
|
1096
|
-
}
|
|
1097
|
-
}, [selectedToken, filteredTokens, setOriginToken, goHome])
|
|
1098
|
-
|
|
1099
|
-
// Poll transaction status when we have a pending transaction
|
|
1100
|
-
useEffect(() => {
|
|
1101
|
-
logger.console.log("[MeldStepsFlow] Polling useEffect triggered:", {
|
|
1102
|
-
currentTransactionId,
|
|
1103
|
-
transactionStatusType: transactionStatus.type,
|
|
1104
|
-
shouldReturn:
|
|
1105
|
-
!currentTransactionId ||
|
|
1106
|
-
transactionStatus.type === "success" ||
|
|
1107
|
-
transactionStatus.type === "error",
|
|
1108
|
-
})
|
|
1109
|
-
|
|
1110
|
-
if (currentTransactionId) {
|
|
1111
|
-
logger.console.log(
|
|
1112
|
-
"[MeldStepsFlow] Will poll getMeldTransaction API with transaction ID:",
|
|
1113
|
-
currentTransactionId,
|
|
1114
|
-
)
|
|
1115
|
-
}
|
|
1116
|
-
|
|
1117
|
-
if (
|
|
1118
|
-
!currentTransactionId ||
|
|
1119
|
-
transactionStatus.type === "success" ||
|
|
1120
|
-
transactionStatus.type === "error"
|
|
1121
|
-
) {
|
|
1122
|
-
logger.console.log(
|
|
1123
|
-
"[MeldStepsFlow] Polling useEffect: Not starting poll, conditions not met",
|
|
1124
|
-
)
|
|
1125
|
-
return
|
|
1126
|
-
}
|
|
1127
|
-
|
|
1128
|
-
logger.console.log(
|
|
1129
|
-
"[MeldStepsFlow] Starting transaction polling for ID:",
|
|
1130
|
-
currentTransactionId,
|
|
1131
|
-
)
|
|
1132
|
-
const pollInterval = setInterval(() => {
|
|
1133
|
-
logger.console.log(
|
|
1134
|
-
"[MeldStepsFlow] Interval check for transaction:",
|
|
1135
|
-
currentTransactionId,
|
|
1136
|
-
)
|
|
1137
|
-
checkTransactionStatus(currentTransactionId)
|
|
1138
|
-
}, 10 * SECOND_MS) // Poll every 10 seconds
|
|
1139
|
-
|
|
1140
|
-
// Initial check
|
|
1141
|
-
logger.console.log(
|
|
1142
|
-
"[MeldStepsFlow] Initial transaction status check for:",
|
|
1143
|
-
currentTransactionId,
|
|
1144
|
-
)
|
|
1145
|
-
checkTransactionStatus(currentTransactionId)
|
|
1146
|
-
|
|
1147
|
-
return () => clearInterval(pollInterval)
|
|
1148
|
-
}, [currentTransactionId, transactionStatus.type, checkTransactionStatus])
|
|
1149
|
-
|
|
1150
|
-
// Save to local storage when selections change
|
|
1151
|
-
useEffect(() => {
|
|
1152
|
-
if (selectedCountry) {
|
|
1153
|
-
localStorage.setItem(
|
|
1154
|
-
"meld-debug-country",
|
|
1155
|
-
JSON.stringify(selectedCountry),
|
|
1156
|
-
)
|
|
1157
|
-
}
|
|
1158
|
-
}, [selectedCountry])
|
|
1159
|
-
|
|
1160
|
-
useEffect(() => {
|
|
1161
|
-
if (selectedPaymentMethod) {
|
|
1162
|
-
localStorage.setItem("meld-debug-payment-method", selectedPaymentMethod)
|
|
1163
|
-
}
|
|
1164
|
-
}, [selectedPaymentMethod])
|
|
1165
|
-
|
|
1166
|
-
useEffect(() => {
|
|
1167
|
-
if (selectedToken) {
|
|
1168
|
-
localStorage.setItem("meld-debug-token", JSON.stringify(selectedToken))
|
|
1169
|
-
}
|
|
1170
|
-
}, [selectedToken])
|
|
1171
|
-
|
|
1172
|
-
// Load providers by calling the quote API
|
|
1173
|
-
const loadProviders = useCallback(async () => {
|
|
1174
|
-
if (!selectedCountry || !selectedToken || !selectedAmount) {
|
|
1175
|
-
return
|
|
1176
|
-
}
|
|
1177
|
-
|
|
1178
|
-
setIsLoadingProviders(true)
|
|
1179
|
-
setAvailableProviders([]) // Clear existing providers
|
|
1180
|
-
try {
|
|
1181
|
-
// First, get a quote to find the best service provider
|
|
1182
|
-
const quoteResponse = await trailsClient.getMeldQuote({
|
|
1183
|
-
walletAddress: "0x1234567890123456789012345678901234567890",
|
|
1184
|
-
countryCode: selectedCountry.countryCode,
|
|
1185
|
-
sourceCurrencyCode: selectedCurrency,
|
|
1186
|
-
sourceAmount: selectedAmount,
|
|
1187
|
-
destinationCurrencyCode: selectedToken.code,
|
|
1188
|
-
})
|
|
1189
|
-
|
|
1190
|
-
logger.console.log("[MeldStepsFlow] Quote response:", quoteResponse)
|
|
1191
|
-
|
|
1192
|
-
// Parse the JSON string in quoteResponse field
|
|
1193
|
-
let parsedQuoteResponse: any
|
|
1194
|
-
try {
|
|
1195
|
-
parsedQuoteResponse =
|
|
1196
|
-
typeof quoteResponse.quoteResponse === "string"
|
|
1197
|
-
? JSON.parse(quoteResponse.quoteResponse)
|
|
1198
|
-
: quoteResponse.quoteResponse
|
|
1199
|
-
} catch (e) {
|
|
1200
|
-
logger.console.error("[MeldStepsFlow] Error parsing quote response:", e)
|
|
1201
|
-
setIsLoadingProviders(false)
|
|
1202
|
-
return
|
|
1203
|
-
}
|
|
1204
|
-
|
|
1205
|
-
logger.console.log(
|
|
1206
|
-
"[MeldStepsFlow] Parsed quote response:",
|
|
1207
|
-
parsedQuoteResponse,
|
|
1208
|
-
)
|
|
1209
|
-
const quotes = parsedQuoteResponse?.quotes
|
|
1210
|
-
if (!quotes || quotes.length === 0) {
|
|
1211
|
-
setWidgetUrl("No quotes available for this selection")
|
|
1212
|
-
setIsLoadingUrl(false)
|
|
1213
|
-
return
|
|
1214
|
-
}
|
|
1215
|
-
|
|
1216
|
-
// Store all available providers for user selection
|
|
1217
|
-
setAvailableProviders(quotes)
|
|
1218
|
-
|
|
1219
|
-
// Auto-select the first provider to save time
|
|
1220
|
-
if (quotes.length > 0) {
|
|
1221
|
-
setSelectedProvider(quotes[0])
|
|
1222
|
-
}
|
|
1223
|
-
|
|
1224
|
-
setIsLoadingProviders(false)
|
|
1225
|
-
} catch (error) {
|
|
1226
|
-
logger.console.error("Error loading providers:", error)
|
|
1227
|
-
setIsLoadingProviders(false)
|
|
1228
|
-
}
|
|
1229
|
-
}, [
|
|
1230
|
-
selectedCountry,
|
|
1231
|
-
selectedToken,
|
|
1232
|
-
selectedAmount,
|
|
1233
|
-
selectedCurrency,
|
|
1234
|
-
trailsClient,
|
|
1235
|
-
])
|
|
1236
|
-
|
|
1237
|
-
// Refetch providers when visiting the providers screen, but only if we don't have providers
|
|
1238
|
-
useEffect(() => {
|
|
1239
|
-
if (currentScreen === "providers" && availableProviders.length === 0) {
|
|
1240
|
-
loadProviders()
|
|
1241
|
-
}
|
|
1242
|
-
}, [currentScreen, loadProviders, availableProviders.length])
|
|
1243
|
-
|
|
1244
|
-
const handleBackFromSubScreen = () => {
|
|
1245
|
-
setCurrentScreen("menu")
|
|
1246
|
-
}
|
|
1247
|
-
|
|
1248
|
-
const handleSelectCountry = (country: Country) => {
|
|
1249
|
-
setSelectedCountry(country)
|
|
1250
|
-
// Clear providers since country change affects quotes
|
|
1251
|
-
setAvailableProviders([])
|
|
1252
|
-
setSelectedProvider(null)
|
|
1253
|
-
setHasClickedContinue(false) // Reset continue button state
|
|
1254
|
-
setWidgetUrl("") // Clear widget URL
|
|
1255
|
-
setWidgetUrlError("") // Clear widget URL errors
|
|
1256
|
-
setCurrentScreen("menu")
|
|
1257
|
-
}
|
|
1258
|
-
|
|
1259
|
-
const handleSelectPaymentMethod = (paymentMethod: MeldPaymentMethod) => {
|
|
1260
|
-
setSelectedPaymentMethod(paymentMethod)
|
|
1261
|
-
// Clear providers since payment method change affects quotes
|
|
1262
|
-
setAvailableProviders([])
|
|
1263
|
-
setSelectedProvider(null)
|
|
1264
|
-
setHasClickedContinue(false) // Reset continue button state
|
|
1265
|
-
setWidgetUrl("") // Clear widget URL
|
|
1266
|
-
setWidgetUrlError("") // Clear widget URL errors
|
|
1267
|
-
setCurrentScreen("menu")
|
|
1268
|
-
}
|
|
1269
|
-
|
|
1270
|
-
const handleSelectToken = (token: MeldToken) => {
|
|
1271
|
-
setSelectedToken(token)
|
|
1272
|
-
// Clear providers since token change affects quotes
|
|
1273
|
-
setAvailableProviders([])
|
|
1274
|
-
setSelectedProvider(null)
|
|
1275
|
-
setHasClickedContinue(false) // Reset continue button state
|
|
1276
|
-
setWidgetUrl("") // Clear widget URL
|
|
1277
|
-
setWidgetUrlError("") // Clear widget URL errors
|
|
1278
|
-
setCurrentScreen("menu")
|
|
1279
|
-
}
|
|
1280
|
-
|
|
1281
|
-
const handleAmountContinue = (amount: string, currency: string) => {
|
|
1282
|
-
setSelectedAmount(amount)
|
|
1283
|
-
setSelectedCurrency(currency)
|
|
1284
|
-
// Clear providers since amount/currency change affects quotes
|
|
1285
|
-
setAvailableProviders([])
|
|
1286
|
-
setSelectedProvider(null)
|
|
1287
|
-
setHasClickedContinue(false) // Reset continue button state
|
|
1288
|
-
setWidgetUrl("") // Clear widget URL
|
|
1289
|
-
setWidgetUrlError("") // Clear widget URL errors
|
|
1290
|
-
setCurrentScreen("providers")
|
|
1291
|
-
}
|
|
1292
|
-
|
|
1293
|
-
const handleSelectProvider = (provider: MeldQuote) => {
|
|
1294
|
-
setSelectedProvider(provider)
|
|
1295
|
-
setHasClickedContinue(false) // Reset continue button state for new provider
|
|
1296
|
-
setWidgetUrl("") // Clear widget URL to force regeneration
|
|
1297
|
-
setWidgetUrlError("") // Clear any widget URL errors
|
|
1298
|
-
setCurrentScreen("menu")
|
|
1299
|
-
// Widget URL will be auto-generated by useEffect
|
|
1300
|
-
}
|
|
1301
|
-
|
|
1302
|
-
// Load providers when basic selections are made
|
|
1303
|
-
useEffect(() => {
|
|
1304
|
-
if (selectedCountry && selectedToken && selectedAmount) {
|
|
1305
|
-
loadProviders()
|
|
1306
|
-
}
|
|
1307
|
-
}, [selectedCountry, selectedToken, selectedAmount, loadProviders])
|
|
1308
|
-
|
|
1309
|
-
// Auto-generate widget URL when provider is selected (including auto-selection)
|
|
1310
|
-
useEffect(() => {
|
|
1311
|
-
if (
|
|
1312
|
-
selectedProvider &&
|
|
1313
|
-
selectedCountry &&
|
|
1314
|
-
selectedToken &&
|
|
1315
|
-
selectedAmount
|
|
1316
|
-
) {
|
|
1317
|
-
generateWidgetUrl()
|
|
1318
|
-
}
|
|
1319
|
-
}, [
|
|
1320
|
-
selectedProvider,
|
|
1321
|
-
selectedCountry,
|
|
1322
|
-
selectedToken,
|
|
1323
|
-
selectedAmount,
|
|
1324
|
-
generateWidgetUrl,
|
|
1325
|
-
])
|
|
1326
|
-
|
|
1327
|
-
// Render sub-screens
|
|
1328
|
-
if (currentScreen === "countries") {
|
|
1329
|
-
return (
|
|
1330
|
-
<MeldCountriesList
|
|
1331
|
-
onBack={handleBackFromSubScreen}
|
|
1332
|
-
onSelectCountry={handleSelectCountry}
|
|
1333
|
-
selectedCountry={selectedCountry}
|
|
1334
|
-
/>
|
|
1335
|
-
)
|
|
1336
|
-
}
|
|
1337
|
-
|
|
1338
|
-
if (currentScreen === "payment-methods") {
|
|
1339
|
-
return (
|
|
1340
|
-
<MeldFundMethods
|
|
1341
|
-
onBack={handleBackFromSubScreen}
|
|
1342
|
-
onSelectPaymentMethod={handleSelectPaymentMethod}
|
|
1343
|
-
selectedPaymentMethod={selectedPaymentMethod}
|
|
1344
|
-
trailsClient={trailsClient}
|
|
1345
|
-
onNavigateToFund={() => {
|
|
1346
|
-
// Navigate to the fund-form screen, bypassing the payment selection
|
|
1347
|
-
setGlobalScreen("fund-form")
|
|
1348
|
-
}}
|
|
1349
|
-
/>
|
|
1350
|
-
)
|
|
1351
|
-
}
|
|
1352
|
-
|
|
1353
|
-
if (currentScreen === "tokens") {
|
|
1354
|
-
return (
|
|
1355
|
-
<MeldTokensList
|
|
1356
|
-
onBack={handleBackFromSubScreen}
|
|
1357
|
-
onSelectToken={handleSelectToken}
|
|
1358
|
-
selectedToken={selectedToken}
|
|
1359
|
-
trailsClient={trailsClient}
|
|
1360
|
-
countryCode={selectedCountry?.countryCode}
|
|
1361
|
-
/>
|
|
1362
|
-
)
|
|
1363
|
-
}
|
|
1364
|
-
|
|
1365
|
-
if (currentScreen === "amount") {
|
|
1366
|
-
return (
|
|
1367
|
-
<AmountInputScreen
|
|
1368
|
-
onBack={(amount, currency) => {
|
|
1369
|
-
// Save the amount and currency before going back
|
|
1370
|
-
if (amount) {
|
|
1371
|
-
setSelectedAmount(amount)
|
|
1372
|
-
localStorage.setItem(MELD_AMOUNT_STORAGE_KEY, amount)
|
|
1373
|
-
}
|
|
1374
|
-
if (currency) {
|
|
1375
|
-
setSelectedCurrency(currency)
|
|
1376
|
-
localStorage.setItem(MELD_CURRENCY_STORAGE_KEY, currency)
|
|
1377
|
-
}
|
|
1378
|
-
setCurrentScreen("menu")
|
|
1379
|
-
}}
|
|
1380
|
-
onContinue={handleAmountContinue}
|
|
1381
|
-
_selectedCountry={selectedCountry}
|
|
1382
|
-
_selectedToken={selectedToken}
|
|
1383
|
-
_selectedPaymentMethod={selectedPaymentMethod}
|
|
1384
|
-
initialAmount={selectedAmount}
|
|
1385
|
-
initialCurrency={selectedCurrency}
|
|
1386
|
-
/>
|
|
1387
|
-
)
|
|
1388
|
-
}
|
|
1389
|
-
|
|
1390
|
-
if (currentScreen === "providers") {
|
|
1391
|
-
return (
|
|
1392
|
-
<div className="flex flex-col h-full">
|
|
1393
|
-
{/* Transaction Status Display */}
|
|
1394
|
-
{transactionStatus.type && hasClickedContinue && (
|
|
1395
|
-
<div
|
|
1396
|
-
className={`p-4 border-b ${
|
|
1397
|
-
transactionStatus.type === "success"
|
|
1398
|
-
? "bg-green-50 dark:bg-green-900/20 border-green-200 dark:border-green-700"
|
|
1399
|
-
: transactionStatus.type === "error"
|
|
1400
|
-
? "bg-red-50 dark:bg-red-900/20 border-red-200 dark:border-red-700"
|
|
1401
|
-
: "bg-blue-50 dark:bg-blue-900/20 border-blue-200 dark:border-blue-700"
|
|
1402
|
-
}`}
|
|
1403
|
-
>
|
|
1404
|
-
<div className="flex items-center gap-3">
|
|
1405
|
-
{transactionStatus.type === "success" && (
|
|
1406
|
-
<div className="w-5 h-5 rounded-full bg-green-500 flex items-center justify-center">
|
|
1407
|
-
<span className="text-white text-xs">✓</span>
|
|
1408
|
-
</div>
|
|
1409
|
-
)}
|
|
1410
|
-
{transactionStatus.type === "error" && (
|
|
1411
|
-
<div className="w-5 h-5 rounded-full bg-red-500 flex items-center justify-center">
|
|
1412
|
-
<span className="text-white text-xs">✕</span>
|
|
1413
|
-
</div>
|
|
1414
|
-
)}
|
|
1415
|
-
{transactionStatus.type === "pending" && (
|
|
1416
|
-
<div className="animate-spin rounded-full h-5 w-5 border-b-2 border-blue-500"></div>
|
|
1417
|
-
)}
|
|
1418
|
-
<div>
|
|
1419
|
-
<p
|
|
1420
|
-
className={`font-medium ${
|
|
1421
|
-
transactionStatus.type === "success"
|
|
1422
|
-
? "text-green-800 dark:text-green-200"
|
|
1423
|
-
: transactionStatus.type === "error"
|
|
1424
|
-
? "text-red-800 dark:text-red-200"
|
|
1425
|
-
: "text-blue-800 dark:text-blue-200"
|
|
1426
|
-
}`}
|
|
1427
|
-
>
|
|
1428
|
-
{transactionStatus.message}
|
|
1429
|
-
</p>
|
|
1430
|
-
{transactionStatus.type === "pending" && (
|
|
1431
|
-
<p className="text-sm text-blue-600 dark:text-blue-400">
|
|
1432
|
-
We'll update you when the payment completes.
|
|
1433
|
-
</p>
|
|
1434
|
-
)}
|
|
1435
|
-
</div>
|
|
1436
|
-
{(transactionStatus.type === "success" ||
|
|
1437
|
-
transactionStatus.type === "error") && (
|
|
1438
|
-
<button
|
|
1439
|
-
type="button"
|
|
1440
|
-
onClick={() =>
|
|
1441
|
-
setTransactionStatus({
|
|
1442
|
-
status: "",
|
|
1443
|
-
message: "",
|
|
1444
|
-
type: null,
|
|
1445
|
-
})
|
|
1446
|
-
}
|
|
1447
|
-
className="ml-auto text-gray-400 hover:text-gray-600 dark:hover:text-gray-300"
|
|
1448
|
-
>
|
|
1449
|
-
✕
|
|
1450
|
-
</button>
|
|
1451
|
-
)}
|
|
1452
|
-
</div>
|
|
1453
|
-
</div>
|
|
1454
|
-
)}
|
|
1455
|
-
|
|
1456
|
-
{/* Providers list with its own header */}
|
|
1457
|
-
<div className="flex-1">
|
|
1458
|
-
<MeldProvidersList
|
|
1459
|
-
onBack={() => {
|
|
1460
|
-
setHasClickedContinue(false) // Reset continue button state when going back
|
|
1461
|
-
setCurrentScreen("menu")
|
|
1462
|
-
}}
|
|
1463
|
-
onSelectProvider={handleSelectProvider}
|
|
1464
|
-
selectedProvider={selectedProvider}
|
|
1465
|
-
providers={availableProviders}
|
|
1466
|
-
/>
|
|
1467
|
-
</div>
|
|
1468
|
-
|
|
1469
|
-
{/* Continue to Provider button and debug tools */}
|
|
1470
|
-
{selectedProvider && (
|
|
1471
|
-
<div className="p-4 border-t border-gray-200 dark:border-gray-700 space-y-3">
|
|
1472
|
-
{/* Error display */}
|
|
1473
|
-
{widgetUrlError && (
|
|
1474
|
-
<div className="p-3 bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-700 rounded-lg">
|
|
1475
|
-
<p className="text-sm text-red-800 dark:text-red-200">
|
|
1476
|
-
<strong>Error:</strong> {widgetUrlError}
|
|
1477
|
-
</p>
|
|
1478
|
-
</div>
|
|
1479
|
-
)}
|
|
1480
|
-
|
|
1481
|
-
<button
|
|
1482
|
-
type="button"
|
|
1483
|
-
onClick={() => {
|
|
1484
|
-
if (widgetUrl && !hasClickedContinue) {
|
|
1485
|
-
const popup = window.open(
|
|
1486
|
-
widgetUrl,
|
|
1487
|
-
"_blank",
|
|
1488
|
-
"width=800,height=600,scrollbars=yes,resizable=yes",
|
|
1489
|
-
)
|
|
1490
|
-
|
|
1491
|
-
if (!popup) {
|
|
1492
|
-
logger.console.error(
|
|
1493
|
-
"[MeldStepsFlow] Popup blocked by browser",
|
|
1494
|
-
)
|
|
1495
|
-
setWidgetUrlError(
|
|
1496
|
-
"Popup blocked. Please allow popups for this site.",
|
|
1497
|
-
)
|
|
1498
|
-
return
|
|
1499
|
-
}
|
|
1500
|
-
|
|
1501
|
-
setHasClickedContinue(true)
|
|
1502
|
-
|
|
1503
|
-
// Start polling for transactions after user goes to Meld
|
|
1504
|
-
if (walletAddress) {
|
|
1505
|
-
logger.console.log(
|
|
1506
|
-
"[MeldStepsFlow] Starting transaction search after widget opened",
|
|
1507
|
-
)
|
|
1508
|
-
|
|
1509
|
-
// Search for transactions every 5 seconds to detect when user returns
|
|
1510
|
-
const searchInterval = setInterval(async () => {
|
|
1511
|
-
try {
|
|
1512
|
-
// Use stored customer ID from createMeldWidgetSession response
|
|
1513
|
-
const storedCustomerId = localStorage.getItem(
|
|
1514
|
-
"meld-current-customer-id-for-search",
|
|
1515
|
-
)
|
|
1516
|
-
|
|
1517
|
-
// Search by customerIds (using customerId value) if available, otherwise fallback to customerIds with wallet address
|
|
1518
|
-
const searchParams = storedCustomerId
|
|
1519
|
-
? { customerIds: storedCustomerId, limit: 5 }
|
|
1520
|
-
: { customerIds: walletAddress, limit: 5 }
|
|
1521
|
-
|
|
1522
|
-
logger.console.log(
|
|
1523
|
-
"[MeldStepsFlow] Polling search with params:",
|
|
1524
|
-
searchParams,
|
|
1525
|
-
)
|
|
1526
|
-
const searchResponse =
|
|
1527
|
-
await trailsClient.searchMeldTransactions(
|
|
1528
|
-
searchParams,
|
|
1529
|
-
)
|
|
1530
|
-
|
|
1531
|
-
// Parse and check for new transactions
|
|
1532
|
-
let transactions: MeldTransaction[] | any
|
|
1533
|
-
try {
|
|
1534
|
-
transactions =
|
|
1535
|
-
typeof searchResponse.transactions === "string"
|
|
1536
|
-
? JSON.parse(searchResponse.transactions)
|
|
1537
|
-
: searchResponse.transactions
|
|
1538
|
-
} catch (e) {
|
|
1539
|
-
logger.console.error(
|
|
1540
|
-
"[MeldStepsFlow] Error parsing search response:",
|
|
1541
|
-
e,
|
|
1542
|
-
)
|
|
1543
|
-
return
|
|
1544
|
-
}
|
|
1545
|
-
|
|
1546
|
-
if (
|
|
1547
|
-
transactions?.transactions &&
|
|
1548
|
-
transactions.transactions.length > 0
|
|
1549
|
-
) {
|
|
1550
|
-
const latestTransaction = transactions.transactions[0]
|
|
1551
|
-
const transactionId =
|
|
1552
|
-
latestTransaction.id ||
|
|
1553
|
-
latestTransaction.transactionId
|
|
1554
|
-
|
|
1555
|
-
// Check if this is a new transaction (not already being tracked)
|
|
1556
|
-
if (
|
|
1557
|
-
transactionId &&
|
|
1558
|
-
transactionId !== currentTransactionId
|
|
1559
|
-
) {
|
|
1560
|
-
logger.console.log(
|
|
1561
|
-
"[MeldStepsFlow] Found new transaction:",
|
|
1562
|
-
transactionId,
|
|
1563
|
-
)
|
|
1564
|
-
setCurrentTransactionId(transactionId)
|
|
1565
|
-
clearInterval(searchInterval) // Stop searching once we find a transaction
|
|
1566
|
-
}
|
|
1567
|
-
}
|
|
1568
|
-
} catch (error) {
|
|
1569
|
-
logger.console.error(
|
|
1570
|
-
"[MeldStepsFlow] Search polling error:",
|
|
1571
|
-
error,
|
|
1572
|
-
)
|
|
1573
|
-
}
|
|
1574
|
-
}, 5 * SECOND_MS) // Poll every 5 seconds
|
|
1575
|
-
|
|
1576
|
-
// Stop searching after 10 minutes
|
|
1577
|
-
setTimeout(() => {
|
|
1578
|
-
clearInterval(searchInterval)
|
|
1579
|
-
logger.console.log(
|
|
1580
|
-
"[MeldStepsFlow] Stopped transaction search polling",
|
|
1581
|
-
)
|
|
1582
|
-
}, 10 * MINUTE_MS)
|
|
1583
|
-
}
|
|
1584
|
-
}
|
|
1585
|
-
}}
|
|
1586
|
-
disabled={
|
|
1587
|
-
isLoadingUrl ||
|
|
1588
|
-
!widgetUrl ||
|
|
1589
|
-
!!widgetUrlError ||
|
|
1590
|
-
hasClickedContinue
|
|
1591
|
-
}
|
|
1592
|
-
className={`w-full flex items-center justify-center py-3 px-4 font-semibold rounded-lg transition-colors ${
|
|
1593
|
-
isLoadingUrl ||
|
|
1594
|
-
!widgetUrl ||
|
|
1595
|
-
!!widgetUrlError ||
|
|
1596
|
-
hasClickedContinue
|
|
1597
|
-
? "bg-gray-400 text-gray-200 cursor-not-allowed"
|
|
1598
|
-
: "bg-blue-600 hover:bg-blue-700 text-white cursor-pointer"
|
|
1599
|
-
}`}
|
|
1600
|
-
>
|
|
1601
|
-
{isLoadingUrl ? (
|
|
1602
|
-
<>
|
|
1603
|
-
<div className="animate-spin rounded-full h-4 w-4 border-b-2 border-white mr-2"></div>
|
|
1604
|
-
<span>Preparing Widget...</span>
|
|
1605
|
-
</>
|
|
1606
|
-
) : (
|
|
1607
|
-
<>
|
|
1608
|
-
<span>
|
|
1609
|
-
{hasClickedContinue
|
|
1610
|
-
? "Provider Opened"
|
|
1611
|
-
: "Continue to Provider"}
|
|
1612
|
-
</span>
|
|
1613
|
-
<ExternalLink className="w-4 h-4 ml-2" />
|
|
1614
|
-
</>
|
|
1615
|
-
)}
|
|
1616
|
-
</button>
|
|
1617
|
-
</div>
|
|
1618
|
-
)}
|
|
1619
|
-
</div>
|
|
1620
|
-
)
|
|
1621
|
-
}
|
|
1622
|
-
|
|
1623
|
-
// Main menu screen - Show new MeldForm as primary interface
|
|
1624
|
-
return (
|
|
1625
|
-
<div className="flex flex-col h-full">
|
|
1626
|
-
{/* Primary Interface - New Simplified MeldForm */}
|
|
1627
|
-
<MeldForm
|
|
1628
|
-
trailsApiKey={trailsConfig.trailsApiKey}
|
|
1629
|
-
onBack={_onBack}
|
|
1630
|
-
onTransactionStatus={(status) => {
|
|
1631
|
-
setTransactionStatus({
|
|
1632
|
-
status: status.message,
|
|
1633
|
-
message: status.message,
|
|
1634
|
-
type: status.type,
|
|
1635
|
-
})
|
|
1636
|
-
}}
|
|
1637
|
-
onNavigateToCountries={() => setCurrentScreen("countries")}
|
|
1638
|
-
onNavigateToPaymentMethods={() => setCurrentScreen("payment-methods")}
|
|
1639
|
-
onNavigateToTokens={() => setCurrentScreen("tokens")}
|
|
1640
|
-
onNavigateToProviders={() => setCurrentScreen("providers")}
|
|
1641
|
-
onNavigateToHistory={() => setGlobalScreen("meld-history")}
|
|
1642
|
-
onSelectProvider={setSelectedProvider}
|
|
1643
|
-
onProvidersLoaded={setAvailableProviders}
|
|
1644
|
-
selectedCountry={selectedCountry}
|
|
1645
|
-
selectedPaymentMethod={selectedPaymentMethod}
|
|
1646
|
-
selectedToken={selectedToken}
|
|
1647
|
-
selectedProvider={selectedProvider}
|
|
1648
|
-
/>
|
|
1649
|
-
</div>
|
|
1650
|
-
)
|
|
1651
|
-
}
|