0xtrails 0.6.6 → 0.7.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/aave.d.ts +10 -2
- package/dist/aave.d.ts.map +1 -1
- package/dist/analytics.d.ts +26 -0
- package/dist/analytics.d.ts.map +1 -1
- package/dist/{ccip-CbJrlK-L.js → ccip-fConRNoG.js} +21 -21
- package/dist/chains.d.ts +23 -8
- package/dist/chains.d.ts.map +1 -1
- package/dist/constants.d.ts +5 -5
- package/dist/constants.d.ts.map +1 -1
- package/dist/customTokens.d.ts +12 -0
- package/dist/customTokens.d.ts.map +1 -0
- package/dist/decoders.d.ts +2 -2
- package/dist/decoders.d.ts.map +1 -1
- package/dist/error.d.ts.map +1 -1
- package/dist/fees.d.ts +37 -2
- package/dist/fees.d.ts.map +1 -1
- package/dist/gasless.d.ts +15 -36
- package/dist/gasless.d.ts.map +1 -1
- package/dist/{index-w7_dK4c5.js → index-BbajxCG_.js} +59269 -77146
- package/dist/index.d.ts +8 -6
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +828 -359
- package/dist/indexerClient.d.ts.map +1 -1
- package/dist/intentReceiptMonitor.d.ts +1 -1
- package/dist/intentReceiptMonitor.d.ts.map +1 -1
- package/dist/intentReceiptPoller.d.ts +1 -1
- package/dist/intentReceiptPoller.d.ts.map +1 -1
- package/dist/intents.d.ts +3 -2
- package/dist/intents.d.ts.map +1 -1
- package/dist/mode.d.ts +1 -1
- package/dist/mode.d.ts.map +1 -1
- package/dist/mutations.d.ts +2 -2
- package/dist/mutations.d.ts.map +1 -1
- package/dist/prepareSend.d.ts +2 -2
- package/dist/prepareSend.d.ts.map +1 -1
- package/dist/prices.d.ts +1 -1
- package/dist/prices.d.ts.map +1 -1
- package/dist/sequenceWallet.d.ts +2 -2
- package/dist/sequenceWallet.d.ts.map +1 -1
- package/dist/time.d.ts +6 -0
- package/dist/time.d.ts.map +1 -1
- package/dist/tokenBalances.d.ts +40 -25
- package/dist/tokenBalances.d.ts.map +1 -1
- package/dist/tokens.d.ts +54 -14
- package/dist/tokens.d.ts.map +1 -1
- package/dist/trailsClient.d.ts +1 -1
- package/dist/trailsClient.d.ts.map +1 -1
- package/dist/trailsRouter.d.ts +2 -1
- package/dist/trailsRouter.d.ts.map +1 -1
- package/dist/transactionIntent/deposits/depositOrchestrator.d.ts +3 -2
- package/dist/transactionIntent/deposits/depositOrchestrator.d.ts.map +1 -1
- package/dist/transactionIntent/deposits/gaslessDeposit.d.ts +2 -1
- package/dist/transactionIntent/deposits/gaslessDeposit.d.ts.map +1 -1
- package/dist/transactionIntent/execution/transactionState.d.ts +1 -1
- package/dist/transactionIntent/execution/transactionState.d.ts.map +1 -1
- package/dist/transactionIntent/handlers/crossChain.d.ts +5 -3
- package/dist/transactionIntent/handlers/crossChain.d.ts.map +1 -1
- package/dist/transactionIntent/handlers/sameChainSameToken.d.ts +5 -3
- package/dist/transactionIntent/handlers/sameChainSameToken.d.ts.map +1 -1
- package/dist/transactionIntent/quote/feeExtractors.d.ts +1 -6
- package/dist/transactionIntent/quote/feeExtractors.d.ts.map +1 -1
- package/dist/transactionIntent/quote/normalizeQuote.d.ts +4 -2
- package/dist/transactionIntent/quote/normalizeQuote.d.ts.map +1 -1
- package/dist/transactionIntent/quote/quoteHelpers.d.ts +1 -1
- package/dist/transactionIntent/quote/quoteHelpers.d.ts.map +1 -1
- package/dist/transactionIntent/types.d.ts +28 -5
- package/dist/transactionIntent/types.d.ts.map +1 -1
- package/dist/transactionIntent/utils/testnetHelpers.d.ts +0 -1
- package/dist/transactionIntent/utils/testnetHelpers.d.ts.map +1 -1
- package/dist/transactionIntent/validators.d.ts +0 -2
- package/dist/transactionIntent/validators.d.ts.map +1 -1
- package/dist/transactions.d.ts +2 -2
- package/dist/transactions.d.ts.map +1 -1
- package/dist/utils.d.ts +7 -0
- package/dist/utils.d.ts.map +1 -1
- package/dist/wallets.d.ts +1 -0
- package/dist/wallets.d.ts.map +1 -1
- package/dist/widget/components/AccountIntentTransactionHistory.d.ts.map +1 -1
- package/dist/widget/components/AddressWalletIcon.d.ts +6 -0
- package/dist/widget/components/AddressWalletIcon.d.ts.map +1 -0
- package/dist/widget/components/ChainFilterDropdown.d.ts +2 -6
- package/dist/widget/components/ChainFilterDropdown.d.ts.map +1 -1
- package/dist/widget/components/ChainImage.d.ts.map +1 -1
- package/dist/widget/components/ChainList.d.ts +0 -5
- package/dist/widget/components/ChainList.d.ts.map +1 -1
- package/dist/widget/components/ClassicSwap.d.ts +6 -6
- package/dist/widget/components/ClassicSwap.d.ts.map +1 -1
- package/dist/widget/components/ConnectWallet.d.ts.map +1 -1
- package/dist/widget/components/ConnectedWallets.d.ts.map +1 -1
- package/dist/widget/components/DebugMenu.d.ts +1 -1
- package/dist/widget/components/DebugMenu.d.ts.map +1 -1
- package/dist/widget/components/DebugScreensList.d.ts.map +1 -1
- package/dist/widget/components/DepositTracker.d.ts.map +1 -1
- package/dist/widget/components/Earn.d.ts +5 -5
- 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 +2 -2
- package/dist/widget/components/FeeOptions.d.ts.map +1 -1
- package/dist/widget/components/Footer.d.ts +1 -1
- package/dist/widget/components/Footer.d.ts.map +1 -1
- package/dist/widget/components/Fund.d.ts +5 -5
- package/dist/widget/components/Fund.d.ts.map +1 -1
- package/dist/widget/components/FundMethods.d.ts +0 -1
- package/dist/widget/components/FundMethods.d.ts.map +1 -1
- package/dist/widget/components/FundSwap.d.ts +6 -6
- package/dist/widget/components/FundSwap.d.ts.map +1 -1
- package/dist/widget/components/HookModalContent.d.ts +8 -0
- package/dist/widget/components/HookModalContent.d.ts.map +1 -0
- package/dist/widget/components/OriginSelectionAmount.d.ts +11 -0
- package/dist/widget/components/OriginSelectionAmount.d.ts.map +1 -0
- package/dist/widget/components/Pay.d.ts +5 -5
- package/dist/widget/components/Pay.d.ts.map +1 -1
- package/dist/widget/components/PoolDeposit.d.ts +5 -5
- package/dist/widget/components/PoolDeposit.d.ts.map +1 -1
- package/dist/widget/components/PoolWithdraw.d.ts +3 -3
- package/dist/widget/components/PoolWithdraw.d.ts.map +1 -1
- package/dist/widget/components/QuoteDetails.d.ts.map +1 -1
- package/dist/widget/components/Receipt.d.ts +2 -1
- package/dist/widget/components/Receipt.d.ts.map +1 -1
- package/dist/widget/components/RecentTokens.d.ts +4 -4
- package/dist/widget/components/RecentTokens.d.ts.map +1 -1
- package/dist/widget/components/RecipientSelectorButton.d.ts.map +1 -1
- package/dist/widget/components/ShadowPortal.d.ts +6 -0
- package/dist/widget/components/ShadowPortal.d.ts.map +1 -0
- package/dist/widget/components/Swap.d.ts +6 -6
- package/dist/widget/components/Swap.d.ts.map +1 -1
- package/dist/widget/components/ThemeProvider.d.ts +1 -1
- package/dist/widget/components/ThemeProvider.d.ts.map +1 -1
- package/dist/widget/components/TokenList.d.ts +3 -4
- package/dist/widget/components/TokenList.d.ts.map +1 -1
- package/dist/widget/components/TokenSelector.d.ts +3 -4
- package/dist/widget/components/TokenSelector.d.ts.map +1 -1
- package/dist/widget/components/Tooltip.d.ts +6 -1
- package/dist/widget/components/Tooltip.d.ts.map +1 -1
- package/dist/widget/components/TrailsHookModal.d.ts +10 -0
- package/dist/widget/components/TrailsHookModal.d.ts.map +1 -0
- package/dist/widget/components/WaasFeeOptions.d.ts +3 -0
- package/dist/widget/components/WaasFeeOptions.d.ts.map +1 -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 +14 -0
- package/dist/widget/components/WidgetProviders.d.ts.map +1 -0
- package/dist/widget/css/compiled.css +1 -1
- package/dist/widget/hooks/useAddressWalletIcon.d.ts +10 -0
- package/dist/widget/hooks/useAddressWalletIcon.d.ts.map +1 -0
- package/dist/widget/hooks/useBalanceVisible.d.ts +1 -1
- package/dist/widget/hooks/useBalanceVisible.d.ts.map +1 -1
- package/dist/widget/hooks/useChainFilter.d.ts +1 -1
- package/dist/widget/hooks/useChainFilter.d.ts.map +1 -1
- package/dist/widget/hooks/useCheckout.d.ts +13 -1
- package/dist/widget/hooks/useCheckout.d.ts.map +1 -1
- package/dist/widget/hooks/useConnector.d.ts +4 -0
- package/dist/widget/hooks/useConnector.d.ts.map +1 -0
- package/dist/widget/hooks/useCurrentScreen.d.ts +1 -1
- package/dist/widget/hooks/useCurrentScreen.d.ts.map +1 -1
- package/dist/widget/hooks/useCustomTokenFetch.d.ts +19 -0
- package/dist/widget/hooks/useCustomTokenFetch.d.ts.map +1 -0
- package/dist/widget/hooks/useCustomTokenSearch.d.ts +20 -0
- package/dist/widget/hooks/useCustomTokenSearch.d.ts.map +1 -0
- package/dist/widget/hooks/useDebounce.d.ts +10 -0
- package/dist/widget/hooks/useDebounce.d.ts.map +1 -0
- package/dist/widget/hooks/useDebugScreens.d.ts +7 -2
- package/dist/widget/hooks/useDebugScreens.d.ts.map +1 -1
- package/dist/widget/hooks/useDefaultTokenSelection.d.ts +3 -19
- package/dist/widget/hooks/useDefaultTokenSelection.d.ts.map +1 -1
- package/dist/widget/hooks/useDestinationSelectedToken.d.ts +1 -14
- package/dist/widget/hooks/useDestinationSelectedToken.d.ts.map +1 -1
- package/dist/widget/hooks/useEarnPool.d.ts +1 -1
- package/dist/widget/hooks/useEarnPool.d.ts.map +1 -1
- package/dist/widget/hooks/useIntentTransactionHistory.d.ts.map +1 -1
- package/dist/widget/hooks/useIsMobile.d.ts +5 -0
- package/dist/widget/hooks/useIsMobile.d.ts.map +1 -0
- package/dist/widget/hooks/useMode.d.ts +2 -2
- package/dist/widget/hooks/useMode.d.ts.map +1 -1
- package/dist/widget/hooks/useOriginSelectedToken.d.ts +2 -15
- package/dist/widget/hooks/useOriginSelectedToken.d.ts.map +1 -1
- package/dist/widget/hooks/usePayMessage.d.ts.map +1 -1
- package/dist/widget/hooks/usePriceImpactWarning.d.ts +1 -1
- package/dist/widget/hooks/usePriceImpactWarning.d.ts.map +1 -1
- package/dist/widget/hooks/useQuote.d.ts +173 -4
- package/dist/widget/hooks/useQuote.d.ts.map +1 -1
- package/dist/widget/hooks/useRecentTokens.d.ts +3 -3
- package/dist/widget/hooks/useRecentTokens.d.ts.map +1 -1
- package/dist/widget/hooks/useRecipients.d.ts +1 -1
- package/dist/widget/hooks/useRecipients.d.ts.map +1 -1
- package/dist/widget/hooks/useSelectedFeeOption.d.ts +2 -2
- package/dist/widget/hooks/useSelectedFeeOption.d.ts.map +1 -1
- package/dist/widget/hooks/useSelectedFundMethod.d.ts +1 -1
- package/dist/widget/hooks/useSelectedFundMethod.d.ts.map +1 -1
- package/dist/widget/hooks/useSelectedRecipient.d.ts +1 -1
- package/dist/widget/hooks/useSelectedRecipient.d.ts.map +1 -1
- package/dist/widget/hooks/useSendForm.d.ts +9 -31
- package/dist/widget/hooks/useSendForm.d.ts.map +1 -1
- package/dist/widget/hooks/useSwapAmount.d.ts +1 -1
- package/dist/widget/hooks/useSwapAmount.d.ts.map +1 -1
- package/dist/widget/hooks/useTheme.d.ts +1 -1
- package/dist/widget/hooks/useTheme.d.ts.map +1 -1
- package/dist/widget/hooks/useTokenList.d.ts +7 -31
- package/dist/widget/hooks/useTokenList.d.ts.map +1 -1
- package/dist/widget/hooks/useTrailsSendTransaction.d.ts +83 -0
- package/dist/widget/hooks/useTrailsSendTransaction.d.ts.map +1 -0
- package/dist/widget/hooks/useWalletConnectUri.d.ts +11 -0
- package/dist/widget/hooks/useWalletConnectUri.d.ts.map +1 -0
- package/dist/widget/hooks/useWidgetProps.d.ts +5 -0
- package/dist/widget/hooks/useWidgetProps.d.ts.map +1 -1
- package/dist/widget/index.d.ts +2 -0
- package/dist/widget/index.d.ts.map +1 -1
- package/dist/widget/index.js +8 -5
- package/dist/widget/providers/TrailsModalProvider.d.ts +65 -0
- package/dist/widget/providers/TrailsModalProvider.d.ts.map +1 -0
- package/dist/widget/providers/TrailsProvider.d.ts +1 -1
- package/dist/widget/providers/TrailsProvider.d.ts.map +1 -1
- package/dist/widget/types.d.ts +11 -18
- package/dist/widget/types.d.ts.map +1 -1
- package/dist/widget/widget.d.ts +20 -11
- package/dist/widget/widget.d.ts.map +1 -1
- package/package.json +45 -49
- package/src/aave.ts +387 -138
- package/src/analytics.ts +208 -2
- package/src/chains.ts +65 -64
- package/src/constants.ts +18 -14
- package/src/customTokens.ts +151 -0
- package/src/decoders.ts +4 -7
- package/src/error.ts +7 -3
- package/src/fees.ts +239 -125
- package/src/gasless.ts +54 -108
- package/src/index.ts +29 -9
- package/src/indexerClient.ts +2 -0
- package/src/intentReceiptMonitor.ts +1 -4
- package/src/intentReceiptPoller.ts +2 -2
- package/src/intents.ts +16 -5
- package/src/mode.ts +1 -1
- package/src/mutations.ts +7 -3
- package/src/prepareSend.ts +19 -14
- package/src/prices.ts +1 -1
- package/src/sequenceWallet.ts +2 -2
- package/src/time.ts +28 -0
- package/src/tokenBalances.ts +348 -153
- package/src/tokens.ts +393 -142
- package/src/trailsClient.ts +1 -1
- package/src/trailsRouter.ts +4 -5
- package/src/transactionIntent/deposits/depositOrchestrator.ts +6 -2
- package/src/transactionIntent/deposits/gaslessDeposit.ts +13 -7
- package/src/transactionIntent/deposits/standardDeposit.ts +1 -1
- package/src/transactionIntent/execution/transactionState.ts +1 -1
- package/src/transactionIntent/handlers/crossChain.ts +75 -37
- package/src/transactionIntent/handlers/sameChainSameToken.ts +66 -20
- package/src/transactionIntent/quote/feeExtractors.ts +1 -29
- package/src/transactionIntent/quote/normalizeQuote.ts +99 -7
- package/src/transactionIntent/quote/quoteHelpers.ts +1 -1
- package/src/transactionIntent/types.ts +31 -6
- package/src/transactionIntent/utils/testnetHelpers.ts +0 -5
- package/src/transactionIntent/validators.ts +0 -30
- package/src/transactions.ts +3 -3
- package/src/utils.ts +18 -0
- package/src/wallets.ts +32 -10
- package/src/widget/compiled.css +1 -1
- package/src/widget/components/AccountIntentTransactionHistory.tsx +2 -1
- package/src/widget/components/AccountIntentTransactionHistoryButton.tsx +2 -2
- package/src/widget/components/AddressWalletIcon.tsx +29 -0
- package/src/widget/components/ChainFilterDropdown.tsx +2 -8
- package/src/widget/components/ChainImage.tsx +8 -5
- package/src/widget/components/ChainList.tsx +6 -8
- package/src/widget/components/ClassicSwap.tsx +93 -85
- package/src/widget/components/ConnectWallet.tsx +1 -2
- package/src/widget/components/ConnectedWallets.tsx +17 -4
- package/src/widget/components/DebugMenu.tsx +2 -2
- package/src/widget/components/DebugScreensList.tsx +0 -1
- package/src/widget/components/DepositTracker.tsx +20 -34
- package/src/widget/components/Earn.tsx +7 -6
- package/src/widget/components/FeeOption.tsx +4 -4
- package/src/widget/components/FeeOptions.tsx +19 -39
- package/src/widget/components/Footer.tsx +1 -1
- package/src/widget/components/Fund.tsx +23 -119
- package/src/widget/components/FundMethods.tsx +9 -6
- package/src/widget/components/FundSwap.tsx +6 -5
- package/src/widget/components/FundingMethodSelectorButton.tsx +2 -2
- package/src/widget/components/HookModalContent.tsx +306 -0
- package/src/widget/components/Modal.tsx +1 -1
- package/src/widget/components/OriginSelectionAmount.tsx +135 -0
- package/src/widget/components/Pay.tsx +66 -124
- package/src/widget/components/PoolDeposit.tsx +11 -55
- package/src/widget/components/PoolWithdraw.tsx +3 -3
- package/src/widget/components/QuoteDetails.tsx +473 -728
- package/src/widget/components/Receipt.tsx +74 -7
- package/src/widget/components/RecentTokens.tsx +8 -8
- package/src/widget/components/RecipientSelectorButton.tsx +4 -2
- package/src/widget/components/ScreenHeader.tsx +2 -2
- package/src/widget/components/SearchInputField.tsx +1 -1
- package/src/widget/components/ShadowPortal.tsx +58 -0
- package/src/widget/components/Swap.tsx +6 -5
- package/src/widget/components/ThemeProvider.tsx +1 -1
- package/src/widget/components/TokenList.tsx +3 -4
- package/src/widget/components/TokenSelector.tsx +211 -80
- package/src/widget/components/Tooltip.tsx +18 -7
- package/src/widget/components/TrailsHookModal.tsx +118 -0
- package/src/widget/components/WaasFeeOptions.tsx +333 -138
- package/src/widget/components/WalletConfirmation.tsx +7 -2
- package/src/widget/components/WalletConnect.tsx +197 -235
- package/src/widget/components/WidgetProviders.tsx +75 -0
- package/src/widget/hooks/useAddressWalletIcon.ts +53 -0
- package/src/widget/hooks/useBalanceVisible.tsx +1 -1
- package/src/widget/hooks/useChainFilter.tsx +1 -1
- package/src/widget/hooks/useCheckout.ts +13 -1
- package/src/widget/hooks/useConnector.tsx +18 -0
- package/src/widget/hooks/useCurrentScreen.tsx +3 -3
- package/src/widget/hooks/useCustomTokenFetch.tsx +72 -0
- package/src/widget/hooks/useCustomTokenSearch.tsx +402 -0
- package/src/widget/hooks/useDebounce.ts +25 -0
- package/src/widget/hooks/useDebugScreens.ts +26 -10
- package/src/widget/hooks/useDefaultTokenSelection.tsx +99 -143
- package/src/widget/hooks/useDestinationSelectedToken.tsx +1 -14
- package/src/widget/hooks/useEarnPool.tsx +1 -1
- package/src/widget/hooks/useIntentTransactionHistory.ts +20 -11
- package/src/widget/hooks/useIsMobile.tsx +50 -0
- package/src/widget/hooks/useMode.ts +2 -3
- package/src/widget/hooks/useOriginSelectedToken.tsx +2 -15
- package/src/widget/hooks/usePayMessage.tsx +31 -11
- package/src/widget/hooks/usePriceImpactWarning.ts +1 -1
- package/src/widget/hooks/useQuote.ts +189 -6
- package/src/widget/hooks/useRecentTokens.ts +6 -6
- package/src/widget/hooks/useRecipients.ts +1 -1
- package/src/widget/hooks/useSelectedFeeOption.tsx +2 -2
- package/src/widget/hooks/useSelectedFundMethod.tsx +1 -1
- package/src/widget/hooks/useSelectedRecipient.tsx +1 -1
- package/src/widget/hooks/useSendForm.ts +328 -152
- package/src/widget/hooks/useSwapAmount.tsx +1 -1
- package/src/widget/hooks/useTheme.tsx +1 -1
- package/src/widget/hooks/useTokenList.ts +672 -400
- package/src/widget/hooks/useTrailsSendTransaction.ts +949 -0
- package/src/widget/hooks/useWalletConnectUri.tsx +228 -0
- package/src/widget/hooks/useWidgetProps.tsx +3 -1
- package/src/widget/index.tsx +12 -0
- package/src/widget/providers/TrailsModalProvider.tsx +195 -0
- package/src/widget/providers/TrailsProvider.tsx +9 -3
- package/src/widget/types.ts +12 -20
- package/src/widget/widget.tsx +598 -385
- package/dist/cctp.d.ts +0 -3
- package/dist/cctp.d.ts.map +0 -1
- package/dist/lifi.d.ts +0 -4
- package/dist/lifi.d.ts.map +0 -1
- package/dist/meshconnect.d.ts +0 -171
- package/dist/meshconnect.d.ts.map +0 -1
- package/dist/relaySdk.d.ts +0 -87
- package/dist/relaySdk.d.ts.map +0 -1
- package/dist/widget/components/MeshConnectExchanges.d.ts +0 -7
- package/dist/widget/components/MeshConnectExchanges.d.ts.map +0 -1
- package/dist/widget/components/MeshConnectFlow.d.ts +0 -13
- package/dist/widget/components/MeshConnectFlow.d.ts.map +0 -1
- package/dist/widget/components/MeshConnectIframe.d.ts +0 -15
- package/dist/widget/components/MeshConnectIframe.d.ts.map +0 -1
- package/dist/widget/components/Receive.d.ts +0 -12
- package/dist/widget/components/Receive.d.ts.map +0 -1
- package/dist/widget/hooks/useSelectedMeshExchange.d.ts +0 -14
- package/dist/widget/hooks/useSelectedMeshExchange.d.ts.map +0 -1
- package/src/cctp.ts +0 -54
- package/src/lifi.ts +0 -108
- package/src/meshconnect.ts +0 -531
- package/src/relaySdk.ts +0 -703
- package/src/widget/components/MeshConnectExchanges.tsx +0 -290
- package/src/widget/components/MeshConnectFlow.tsx +0 -90
- package/src/widget/components/MeshConnectIframe.tsx +0 -500
- package/src/widget/components/Receive.tsx +0 -175
- package/src/widget/hooks/useSelectedMeshExchange.tsx +0 -46
|
@@ -1,500 +0,0 @@
|
|
|
1
|
-
import type React from "react"
|
|
2
|
-
import { useEffect, useState, useCallback } from "react"
|
|
3
|
-
import { createPortal } from "react-dom"
|
|
4
|
-
import * as meshSDK from "@meshconnect/web-link-sdk"
|
|
5
|
-
import {
|
|
6
|
-
createNewLinkToken,
|
|
7
|
-
getMeshConnectClientId,
|
|
8
|
-
getMeshConnectEnvironment,
|
|
9
|
-
getMeshConnectApiKey,
|
|
10
|
-
getMeshNetworkIdFromChainId,
|
|
11
|
-
} from "../../meshconnect.js"
|
|
12
|
-
import type { PrepareSendQuote } from "../../prepareSend.js"
|
|
13
|
-
import { ScreenHeader } from "./ScreenHeader.js"
|
|
14
|
-
import { logger } from "../../logger.js"
|
|
15
|
-
|
|
16
|
-
export interface MeshConnectProps {
|
|
17
|
-
onBack: () => void
|
|
18
|
-
toTokenSymbol?: string
|
|
19
|
-
onComplete?: (transferData: any) => void
|
|
20
|
-
toTokenAmount?: string
|
|
21
|
-
toChainId?: number
|
|
22
|
-
toRecipientAddress?: string
|
|
23
|
-
quote?: PrepareSendQuote | null
|
|
24
|
-
integrationId?: string
|
|
25
|
-
exchangeName?: string
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
export const MeshConnectIframe: React.FC<MeshConnectProps> = ({
|
|
29
|
-
onBack,
|
|
30
|
-
toTokenSymbol,
|
|
31
|
-
toTokenAmount,
|
|
32
|
-
toChainId,
|
|
33
|
-
toRecipientAddress,
|
|
34
|
-
onComplete,
|
|
35
|
-
integrationId,
|
|
36
|
-
exchangeName,
|
|
37
|
-
}) => {
|
|
38
|
-
const [linkToken, setLinkToken] = useState<string | null>(null)
|
|
39
|
-
const [loading, setLoading] = useState(true)
|
|
40
|
-
const [error, setError] = useState<string | null>(null)
|
|
41
|
-
const [payload, setPayload] = useState<any>(null)
|
|
42
|
-
const [transferFinishedData, setTransferFinishedData] = useState<any>(null)
|
|
43
|
-
const [meshLink, setMeshLink] = useState<any>(null)
|
|
44
|
-
const [iframeContainer, setIframeContainer] = useState<HTMLDivElement | null>(
|
|
45
|
-
null,
|
|
46
|
-
)
|
|
47
|
-
const [showIframe, setShowIframe] = useState(false)
|
|
48
|
-
const [iframePlaceholder, setIframePlaceholder] =
|
|
49
|
-
useState<HTMLDivElement | null>(null)
|
|
50
|
-
|
|
51
|
-
// Create iframe container outside shadow DOM on mount
|
|
52
|
-
useEffect(() => {
|
|
53
|
-
// Create container div in document body
|
|
54
|
-
const container = document.createElement("div")
|
|
55
|
-
container.id = "mesh-iframe-portal"
|
|
56
|
-
// Position will be set dynamically based on widget position
|
|
57
|
-
container.style.position = "absolute"
|
|
58
|
-
container.style.zIndex = "10000"
|
|
59
|
-
container.style.display = "none" // Initially hidden
|
|
60
|
-
|
|
61
|
-
document.body.appendChild(container)
|
|
62
|
-
setIframeContainer(container)
|
|
63
|
-
|
|
64
|
-
// Cleanup on unmount
|
|
65
|
-
return () => {
|
|
66
|
-
if (document.body.contains(container)) {
|
|
67
|
-
document.body.removeChild(container)
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
}, [])
|
|
71
|
-
|
|
72
|
-
// Generate link token on component mount
|
|
73
|
-
useEffect(() => {
|
|
74
|
-
const generateLinkToken = async () => {
|
|
75
|
-
try {
|
|
76
|
-
setLoading(true)
|
|
77
|
-
setError(null)
|
|
78
|
-
|
|
79
|
-
if (
|
|
80
|
-
!toRecipientAddress ||
|
|
81
|
-
!toTokenSymbol ||
|
|
82
|
-
!toChainId ||
|
|
83
|
-
!toTokenAmount
|
|
84
|
-
) {
|
|
85
|
-
logger.console.error("[trails-sdk] Missing required parameters", {
|
|
86
|
-
toRecipientAddress,
|
|
87
|
-
toTokenSymbol,
|
|
88
|
-
toChainId,
|
|
89
|
-
toTokenAmount,
|
|
90
|
-
})
|
|
91
|
-
throw new Error("Missing required parameters")
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
const networkId = (await getMeshNetworkIdFromChainId(
|
|
95
|
-
toChainId,
|
|
96
|
-
getMeshConnectEnvironment(),
|
|
97
|
-
)) as string
|
|
98
|
-
|
|
99
|
-
// Generate a new link token for receiving tokens
|
|
100
|
-
const response = await createNewLinkToken(
|
|
101
|
-
getMeshConnectApiKey(getMeshConnectEnvironment()),
|
|
102
|
-
getMeshConnectClientId(),
|
|
103
|
-
{
|
|
104
|
-
environment: getMeshConnectEnvironment(),
|
|
105
|
-
address: toRecipientAddress,
|
|
106
|
-
symbol: toTokenSymbol,
|
|
107
|
-
networkId: networkId,
|
|
108
|
-
amount: toTokenAmount.toString(),
|
|
109
|
-
transactionId: `txid_${Date.now()}`,
|
|
110
|
-
integrationId: integrationId, // Use the provided integration ID (ie Coinbase, Binance, etc)
|
|
111
|
-
},
|
|
112
|
-
)
|
|
113
|
-
|
|
114
|
-
logger.console.log(
|
|
115
|
-
"[trails-sdk] Generated Mesh Connect link token response:",
|
|
116
|
-
response,
|
|
117
|
-
)
|
|
118
|
-
logger.console.log(
|
|
119
|
-
"[trails-sdk] Link token:",
|
|
120
|
-
response.content.linkToken,
|
|
121
|
-
)
|
|
122
|
-
|
|
123
|
-
// Validate link token format
|
|
124
|
-
if (
|
|
125
|
-
!response.content.linkToken ||
|
|
126
|
-
typeof response.content.linkToken !== "string"
|
|
127
|
-
) {
|
|
128
|
-
throw new Error("Invalid link token received")
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
setLinkToken(response.content.linkToken)
|
|
132
|
-
} catch (err) {
|
|
133
|
-
logger.console.error(
|
|
134
|
-
"[trails-sdk] Failed to generate Mesh Connect link token:",
|
|
135
|
-
err,
|
|
136
|
-
)
|
|
137
|
-
setError(
|
|
138
|
-
err instanceof Error ? err.message : "Failed to generate link token",
|
|
139
|
-
)
|
|
140
|
-
} finally {
|
|
141
|
-
setLoading(false)
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
generateLinkToken()
|
|
146
|
-
}, [
|
|
147
|
-
toRecipientAddress,
|
|
148
|
-
toTokenSymbol,
|
|
149
|
-
toChainId,
|
|
150
|
-
toTokenAmount,
|
|
151
|
-
integrationId,
|
|
152
|
-
])
|
|
153
|
-
|
|
154
|
-
const handleIntegrationConnected = useCallback((authData: any) => {
|
|
155
|
-
logger.console.log("[trails-sdk] MESH CONNECTED:", authData)
|
|
156
|
-
setPayload(authData)
|
|
157
|
-
|
|
158
|
-
// Once connected, we can initiate a transfer
|
|
159
|
-
if (authData.accessToken) {
|
|
160
|
-
logger.console.log(
|
|
161
|
-
"[trails-sdk] Ready to transfer - access token available",
|
|
162
|
-
)
|
|
163
|
-
}
|
|
164
|
-
}, [])
|
|
165
|
-
|
|
166
|
-
const handleTransferFinished = useCallback((transferData: any) => {
|
|
167
|
-
logger.console.log("[trails-sdk] MESH TRANSFER FINISHED:", transferData)
|
|
168
|
-
setTransferFinishedData(transferData)
|
|
169
|
-
}, [])
|
|
170
|
-
|
|
171
|
-
const handleExit = useCallback(
|
|
172
|
-
(error?: string) => {
|
|
173
|
-
logger.console.log("[trails-sdk] MESH EXIT:", error)
|
|
174
|
-
|
|
175
|
-
// Hide the iframe when user exits
|
|
176
|
-
setShowIframe(false)
|
|
177
|
-
if (iframeContainer) {
|
|
178
|
-
iframeContainer.style.display = "none"
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
if (error) {
|
|
182
|
-
logger.console.error("[trails-sdk] MESH ERROR:", error)
|
|
183
|
-
setError(error)
|
|
184
|
-
}
|
|
185
|
-
},
|
|
186
|
-
[iframeContainer],
|
|
187
|
-
)
|
|
188
|
-
|
|
189
|
-
// Create Mesh Connect link instance when component mounts
|
|
190
|
-
useEffect(() => {
|
|
191
|
-
const createMeshLink = async () => {
|
|
192
|
-
try {
|
|
193
|
-
logger.console.log("[trails-sdk] Creating Mesh Connect link...")
|
|
194
|
-
const link = meshSDK.createLink({
|
|
195
|
-
clientId: getMeshConnectClientId(),
|
|
196
|
-
language: "en",
|
|
197
|
-
onIntegrationConnected: handleIntegrationConnected,
|
|
198
|
-
onExit: handleExit,
|
|
199
|
-
onTransferFinished: handleTransferFinished,
|
|
200
|
-
onEvent: (ev: any) => {
|
|
201
|
-
logger.console.log("[trails-sdk] MESH Event:", ev)
|
|
202
|
-
if (ev.type === "transferExecuted" && ev.payload) {
|
|
203
|
-
setTransferFinishedData(ev.payload)
|
|
204
|
-
}
|
|
205
|
-
},
|
|
206
|
-
})
|
|
207
|
-
|
|
208
|
-
logger.console.log(
|
|
209
|
-
"[trails-sdk] Mesh Connect link created successfully",
|
|
210
|
-
)
|
|
211
|
-
setMeshLink(link)
|
|
212
|
-
} catch (err) {
|
|
213
|
-
logger.console.error(
|
|
214
|
-
"[trails-sdk] Failed to create Mesh Connect link:",
|
|
215
|
-
err,
|
|
216
|
-
)
|
|
217
|
-
setError(
|
|
218
|
-
`Failed to load Mesh Connect SDK: ${err instanceof Error ? err.message : String(err)}`,
|
|
219
|
-
)
|
|
220
|
-
}
|
|
221
|
-
}
|
|
222
|
-
|
|
223
|
-
createMeshLink()
|
|
224
|
-
}, [handleIntegrationConnected, handleTransferFinished, handleExit])
|
|
225
|
-
|
|
226
|
-
// Position the iframe container based on placeholder position
|
|
227
|
-
useEffect(() => {
|
|
228
|
-
if (typeof window === "undefined") {
|
|
229
|
-
return
|
|
230
|
-
}
|
|
231
|
-
|
|
232
|
-
if (!iframeContainer || !iframePlaceholder || !showIframe) {
|
|
233
|
-
logger.console.log("[trails-sdk] Positioning check failed:", {
|
|
234
|
-
iframeContainer: !!iframeContainer,
|
|
235
|
-
iframePlaceholder: !!iframePlaceholder,
|
|
236
|
-
showIframe,
|
|
237
|
-
})
|
|
238
|
-
return
|
|
239
|
-
}
|
|
240
|
-
|
|
241
|
-
const positionIframe = () => {
|
|
242
|
-
const rect = iframePlaceholder.getBoundingClientRect()
|
|
243
|
-
logger.console.log("[trails-sdk] Positioning iframe at:", rect)
|
|
244
|
-
|
|
245
|
-
iframeContainer.style.position = "fixed"
|
|
246
|
-
iframeContainer.style.left = `${rect.left}px`
|
|
247
|
-
iframeContainer.style.top = `${rect.top}px`
|
|
248
|
-
iframeContainer.style.width = `${rect.width}px`
|
|
249
|
-
iframeContainer.style.height = `${rect.height}px`
|
|
250
|
-
iframeContainer.style.display = "block"
|
|
251
|
-
iframeContainer.style.backgroundColor = "white"
|
|
252
|
-
iframeContainer.style.border = "1px solid #ccc"
|
|
253
|
-
iframeContainer.style.zIndex = "10000"
|
|
254
|
-
|
|
255
|
-
logger.console.log(
|
|
256
|
-
"[trails-sdk] Applied styles:",
|
|
257
|
-
iframeContainer.style.cssText,
|
|
258
|
-
)
|
|
259
|
-
}
|
|
260
|
-
|
|
261
|
-
// Use setTimeout to ensure DOM is ready
|
|
262
|
-
setTimeout(positionIframe, 100)
|
|
263
|
-
|
|
264
|
-
// Update position on scroll/resize
|
|
265
|
-
const handleUpdate = () => positionIframe()
|
|
266
|
-
window.addEventListener("scroll", handleUpdate)
|
|
267
|
-
window.addEventListener("resize", handleUpdate)
|
|
268
|
-
|
|
269
|
-
return () => {
|
|
270
|
-
window.removeEventListener("scroll", handleUpdate)
|
|
271
|
-
window.removeEventListener("resize", handleUpdate)
|
|
272
|
-
}
|
|
273
|
-
}, [iframeContainer, iframePlaceholder, showIframe])
|
|
274
|
-
|
|
275
|
-
// Open Mesh Connect iframe
|
|
276
|
-
const openMeshConnect = useCallback(() => {
|
|
277
|
-
logger.console.log("[trails-sdk] openMeshConnect called:", {
|
|
278
|
-
meshLink: !!meshLink,
|
|
279
|
-
linkToken: !!linkToken,
|
|
280
|
-
iframeContainer: !!iframeContainer,
|
|
281
|
-
})
|
|
282
|
-
|
|
283
|
-
if (!meshLink || !linkToken || !iframeContainer) {
|
|
284
|
-
logger.console.log("[trails-sdk] Missing requirements for opening")
|
|
285
|
-
return
|
|
286
|
-
}
|
|
287
|
-
|
|
288
|
-
logger.console.log("[trails-sdk] Setting showIframe to true")
|
|
289
|
-
setShowIframe(true)
|
|
290
|
-
|
|
291
|
-
// Wait for iframe to be positioned before opening
|
|
292
|
-
setTimeout(() => {
|
|
293
|
-
logger.console.log(
|
|
294
|
-
"[trails-sdk] Opening Mesh Connect with token:",
|
|
295
|
-
linkToken,
|
|
296
|
-
)
|
|
297
|
-
try {
|
|
298
|
-
// Try opening in iframe first
|
|
299
|
-
meshLink.openLink(linkToken, "mesh-iframe")
|
|
300
|
-
logger.console.log("[trails-sdk] Opened in iframe successfully")
|
|
301
|
-
|
|
302
|
-
;(window as any).meshLink = meshLink
|
|
303
|
-
} catch (iframeError) {
|
|
304
|
-
logger.console.warn(
|
|
305
|
-
"[trails-sdk] Failed to open in iframe, trying popup:",
|
|
306
|
-
iframeError,
|
|
307
|
-
)
|
|
308
|
-
try {
|
|
309
|
-
// Fallback to popup
|
|
310
|
-
meshLink.openLink(linkToken)
|
|
311
|
-
logger.console.log("[trails-sdk] Opened in popup successfully")
|
|
312
|
-
} catch (popupError) {
|
|
313
|
-
logger.console.error("[trails-sdk] Failed to open link:", popupError)
|
|
314
|
-
setError("Failed to open Mesh Connect link")
|
|
315
|
-
}
|
|
316
|
-
}
|
|
317
|
-
}, 200)
|
|
318
|
-
}, [meshLink, linkToken, iframeContainer])
|
|
319
|
-
|
|
320
|
-
// Handle closing the iframe
|
|
321
|
-
const handleCloseMeshConnect = useCallback(() => {
|
|
322
|
-
setShowIframe(false)
|
|
323
|
-
if (iframeContainer) {
|
|
324
|
-
iframeContainer.style.display = "none"
|
|
325
|
-
}
|
|
326
|
-
}, [iframeContainer])
|
|
327
|
-
|
|
328
|
-
// Console log payload changes
|
|
329
|
-
useEffect(() => {
|
|
330
|
-
if (payload) {
|
|
331
|
-
logger.console.log("[trails-sdk] Payload updated:", payload)
|
|
332
|
-
}
|
|
333
|
-
}, [payload])
|
|
334
|
-
|
|
335
|
-
// Navigate to pending screen when transfer is finished
|
|
336
|
-
useEffect(() => {
|
|
337
|
-
if (transferFinishedData) {
|
|
338
|
-
logger.console.log(
|
|
339
|
-
"[trails-sdk] Transfer finished data updated:",
|
|
340
|
-
transferFinishedData,
|
|
341
|
-
)
|
|
342
|
-
// Navigate to pending screen
|
|
343
|
-
if (onComplete) {
|
|
344
|
-
onComplete(transferFinishedData)
|
|
345
|
-
}
|
|
346
|
-
}
|
|
347
|
-
}, [transferFinishedData, onComplete])
|
|
348
|
-
|
|
349
|
-
// Auto-click the openMeshConnect button when ready
|
|
350
|
-
useEffect(() => {
|
|
351
|
-
if (meshLink && linkToken && !showIframe && !payload) {
|
|
352
|
-
logger.console.log("[trails-sdk] Auto-clicking openMeshConnect button")
|
|
353
|
-
openMeshConnect()
|
|
354
|
-
}
|
|
355
|
-
}, [meshLink, linkToken, showIframe, payload, openMeshConnect])
|
|
356
|
-
|
|
357
|
-
if (loading) {
|
|
358
|
-
return (
|
|
359
|
-
<div className="flex flex-col h-full">
|
|
360
|
-
<ScreenHeader
|
|
361
|
-
onBack={onBack}
|
|
362
|
-
headerContent="Mesh Connect"
|
|
363
|
-
headerContentAlign="left"
|
|
364
|
-
/>
|
|
365
|
-
|
|
366
|
-
<div className="flex-1 flex items-center justify-center">
|
|
367
|
-
<div className="text-center">
|
|
368
|
-
<div className="w-8 h-8 border-solid border-2 border-blue-500 border-t-transparent rounded-full animate-spin mx-auto mb-4"></div>
|
|
369
|
-
<p className="text-gray-600 dark:text-gray-400">
|
|
370
|
-
Generating secure connection...
|
|
371
|
-
</p>
|
|
372
|
-
</div>
|
|
373
|
-
</div>
|
|
374
|
-
</div>
|
|
375
|
-
)
|
|
376
|
-
}
|
|
377
|
-
|
|
378
|
-
if (error) {
|
|
379
|
-
return (
|
|
380
|
-
<div className="flex flex-col h-full">
|
|
381
|
-
<ScreenHeader
|
|
382
|
-
onBack={onBack}
|
|
383
|
-
headerContent="Mesh Connect"
|
|
384
|
-
headerContentAlign="left"
|
|
385
|
-
/>
|
|
386
|
-
|
|
387
|
-
<div className="flex-1 flex items-center justify-center">
|
|
388
|
-
<div className="text-center p-4 border border-solid border-red-200 rounded-lg bg-red-50 dark:bg-red-900/20 dark:border-red-800">
|
|
389
|
-
<p className="text-red-600 dark:text-red-200 mb-4">{error}</p>
|
|
390
|
-
<button
|
|
391
|
-
type="button"
|
|
392
|
-
onClick={() => {
|
|
393
|
-
if (typeof window !== "undefined") {
|
|
394
|
-
window.location.reload()
|
|
395
|
-
}
|
|
396
|
-
}}
|
|
397
|
-
className="px-4 py-2 bg-red-600 text-white rounded-lg hover:bg-red-700 transition-colors"
|
|
398
|
-
>
|
|
399
|
-
Try Again
|
|
400
|
-
</button>
|
|
401
|
-
</div>
|
|
402
|
-
</div>
|
|
403
|
-
</div>
|
|
404
|
-
)
|
|
405
|
-
}
|
|
406
|
-
|
|
407
|
-
return (
|
|
408
|
-
<div className="flex flex-col h-full">
|
|
409
|
-
<ScreenHeader
|
|
410
|
-
onBack={onBack}
|
|
411
|
-
headerContent={`Fund with ${exchangeName || "Mesh Connect"}`}
|
|
412
|
-
headerContentAlign="left"
|
|
413
|
-
/>
|
|
414
|
-
|
|
415
|
-
{transferFinishedData && (
|
|
416
|
-
<div className="mb-4 p-3 bg-blue-50 dark:bg-blue-900/20 border border-solid border-blue-200 dark:border-blue-800 rounded-lg">
|
|
417
|
-
<p className="text-sm text-blue-600 dark:text-blue-200">
|
|
418
|
-
✓ Transfer completed: {transferFinishedData.amount}{" "}
|
|
419
|
-
{transferFinishedData.symbol}
|
|
420
|
-
</p>
|
|
421
|
-
<p className="text-xs text-blue-500 dark:text-blue-300 mt-1">
|
|
422
|
-
Redirecting to pending screen...
|
|
423
|
-
</p>
|
|
424
|
-
</div>
|
|
425
|
-
)}
|
|
426
|
-
|
|
427
|
-
{/* Mesh Connect iframe area */}
|
|
428
|
-
<div className="flex-1">
|
|
429
|
-
{!showIframe && !payload ? (
|
|
430
|
-
<div className="flex items-center justify-center h-full min-h-[500px]">
|
|
431
|
-
<div className="text-center p-8 border border-solid border-gray-200 dark:border-gray-700 rounded-lg">
|
|
432
|
-
<h3 className="text-lg font-semibold mb-4">
|
|
433
|
-
Fund your account with {exchangeName || "Mesh Connect"}
|
|
434
|
-
</h3>
|
|
435
|
-
<p className="text-gray-600 dark:text-gray-400 mb-6">
|
|
436
|
-
Connect to{" "}
|
|
437
|
-
{exchangeName?.toLowerCase() || "bank account or exchange"} to
|
|
438
|
-
fund your wallet securely.
|
|
439
|
-
</p>
|
|
440
|
-
<button
|
|
441
|
-
onClick={openMeshConnect}
|
|
442
|
-
disabled={!meshLink || !linkToken}
|
|
443
|
-
className="px-6 py-3 bg-blue-600 text-white rounded-lg hover:bg-blue-700 disabled:opacity-50 disabled:cursor-not-allowed"
|
|
444
|
-
>
|
|
445
|
-
{!meshLink || !linkToken ? "Preparing..." : "Continue"}
|
|
446
|
-
</button>
|
|
447
|
-
</div>
|
|
448
|
-
</div>
|
|
449
|
-
) : showIframe ? (
|
|
450
|
-
<div className="relative">
|
|
451
|
-
<button
|
|
452
|
-
onClick={handleCloseMeshConnect}
|
|
453
|
-
className="absolute top-2 right-2 z-10 bg-gray-800 text-white rounded-full w-8 h-8 flex items-center justify-center hover:bg-gray-700"
|
|
454
|
-
>
|
|
455
|
-
×
|
|
456
|
-
</button>
|
|
457
|
-
<div
|
|
458
|
-
ref={setIframePlaceholder}
|
|
459
|
-
className="w-full h-[500px] border border-solid border-gray-200 dark:border-gray-700 rounded-lg bg-gray-50 dark:bg-gray-800"
|
|
460
|
-
/>
|
|
461
|
-
</div>
|
|
462
|
-
) : null}
|
|
463
|
-
</div>
|
|
464
|
-
|
|
465
|
-
{/* Sandbox Environment Banner */}
|
|
466
|
-
{getMeshConnectEnvironment() === "sandbox" && (
|
|
467
|
-
<div className="p-3 bg-yellow-50 dark:bg-yellow-900/20 border border-solid border-yellow-200 dark:border-yellow-800">
|
|
468
|
-
<div className="text-center">
|
|
469
|
-
<p className="text-sm font-medium text-yellow-800 dark:text-yellow-200">
|
|
470
|
-
Sandbox environment
|
|
471
|
-
</p>
|
|
472
|
-
<p className="text-xs text-yellow-600 dark:text-yellow-300">
|
|
473
|
-
No real funds are used
|
|
474
|
-
</p>
|
|
475
|
-
</div>
|
|
476
|
-
</div>
|
|
477
|
-
)}
|
|
478
|
-
|
|
479
|
-
{/* Portal for iframe outside shadow DOM */}
|
|
480
|
-
{iframeContainer &&
|
|
481
|
-
showIframe &&
|
|
482
|
-
createPortal(
|
|
483
|
-
<div style={{ width: "100%", height: "100%", position: "relative" }}>
|
|
484
|
-
<iframe
|
|
485
|
-
id="mesh-iframe"
|
|
486
|
-
title="Mesh Connect"
|
|
487
|
-
style={{
|
|
488
|
-
width: "100%",
|
|
489
|
-
height: "100%",
|
|
490
|
-
border: "none",
|
|
491
|
-
borderRadius: "8px",
|
|
492
|
-
backgroundColor: "white",
|
|
493
|
-
}}
|
|
494
|
-
/>
|
|
495
|
-
</div>,
|
|
496
|
-
iframeContainer,
|
|
497
|
-
)}
|
|
498
|
-
</div>
|
|
499
|
-
)
|
|
500
|
-
}
|
|
@@ -1,175 +0,0 @@
|
|
|
1
|
-
import type React from "react"
|
|
2
|
-
import { useMemo, useState } from "react"
|
|
3
|
-
import { QrCode } from "./QrCode.js"
|
|
4
|
-
import { ScreenHeader } from "./ScreenHeader.js"
|
|
5
|
-
import { getExplorerUrlForAddress } from "../../explorer.js"
|
|
6
|
-
import { ExternalLink, Copy, Check } from "lucide-react"
|
|
7
|
-
import { truncateAddress } from "../../utils.js"
|
|
8
|
-
import { useResolveEnsName } from "../../ens.js"
|
|
9
|
-
|
|
10
|
-
interface ReceiveProps {
|
|
11
|
-
accountAddress: string
|
|
12
|
-
onBack?: () => void
|
|
13
|
-
isConnected?: boolean
|
|
14
|
-
onConnectWallet?: () => void
|
|
15
|
-
onPay?: () => void
|
|
16
|
-
toChainId?: number
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
export const Receive: React.FC<ReceiveProps> = ({
|
|
20
|
-
accountAddress,
|
|
21
|
-
onBack,
|
|
22
|
-
isConnected = false,
|
|
23
|
-
onConnectWallet,
|
|
24
|
-
onPay,
|
|
25
|
-
toChainId,
|
|
26
|
-
}) => {
|
|
27
|
-
// Use the provided address directly
|
|
28
|
-
const resolvedAddress = accountAddress
|
|
29
|
-
|
|
30
|
-
// State for copy feedback
|
|
31
|
-
const [isCopied, setIsCopied] = useState(false)
|
|
32
|
-
|
|
33
|
-
// Resolve ENS name from the address
|
|
34
|
-
const { ensName } = useResolveEnsName({
|
|
35
|
-
address: accountAddress,
|
|
36
|
-
})
|
|
37
|
-
|
|
38
|
-
// Handle copy to clipboard
|
|
39
|
-
const handleCopyAddress = async () => {
|
|
40
|
-
try {
|
|
41
|
-
await navigator.clipboard.writeText(resolvedAddress)
|
|
42
|
-
setIsCopied(true)
|
|
43
|
-
setTimeout(() => setIsCopied(false), 2000) // Reset after 2 seconds
|
|
44
|
-
} catch (error) {
|
|
45
|
-
console.error("Failed to copy address:", error)
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
// Generate QR code URL for the address
|
|
50
|
-
const qrCodeUrl = useMemo(() => {
|
|
51
|
-
if (!resolvedAddress) return ""
|
|
52
|
-
return `ethereum:${resolvedAddress}`
|
|
53
|
-
}, [resolvedAddress])
|
|
54
|
-
|
|
55
|
-
// Check if accountAddress is provided
|
|
56
|
-
if (!accountAddress) {
|
|
57
|
-
return (
|
|
58
|
-
<div className="space-y-6">
|
|
59
|
-
<ScreenHeader
|
|
60
|
-
onBack={onBack}
|
|
61
|
-
headerContent="Receive"
|
|
62
|
-
headerContentAlign="left"
|
|
63
|
-
/>
|
|
64
|
-
|
|
65
|
-
<div className="flex flex-col justify-center min-h-full space-y-6 pt-8">
|
|
66
|
-
<div className="text-center p-6 bg-amber-50 dark:bg-amber-900/20 border border-amber-200 dark:border-amber-700/50 rounded-lg">
|
|
67
|
-
<div className="flex items-center justify-center space-x-2 text-amber-600 dark:text-amber-400">
|
|
68
|
-
<svg
|
|
69
|
-
className="w-5 h-5"
|
|
70
|
-
fill="none"
|
|
71
|
-
viewBox="0 0 24 24"
|
|
72
|
-
stroke="currentColor"
|
|
73
|
-
>
|
|
74
|
-
<path
|
|
75
|
-
strokeLinecap="round"
|
|
76
|
-
strokeLinejoin="round"
|
|
77
|
-
strokeWidth={2}
|
|
78
|
-
d="M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-2.5L13.732 4c-.77-.833-1.964-.833-2.732 0L3.732 16.5c-.77.833.192 2.5 1.732 2.5z"
|
|
79
|
-
/>
|
|
80
|
-
</svg>
|
|
81
|
-
<span className="font-medium">Account address is required</span>
|
|
82
|
-
</div>
|
|
83
|
-
<p className="mt-2 text-sm text-amber-600 dark:text-amber-400">
|
|
84
|
-
Please provide an account address as <code>toAddress</code> to
|
|
85
|
-
generate the receive QR code.
|
|
86
|
-
</p>
|
|
87
|
-
</div>
|
|
88
|
-
</div>
|
|
89
|
-
</div>
|
|
90
|
-
)
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
return (
|
|
94
|
-
<div className="space-y-2">
|
|
95
|
-
<ScreenHeader
|
|
96
|
-
onBack={onBack}
|
|
97
|
-
headerContent={`Pay ${ensName ? ensName : truncateAddress(resolvedAddress)}`}
|
|
98
|
-
headerContentAlign="left"
|
|
99
|
-
/>
|
|
100
|
-
|
|
101
|
-
<div className="flex flex-col justify-center min-h-full space-y-6 pt-2">
|
|
102
|
-
{/* QR Code Section */}
|
|
103
|
-
<div className="space-y-3 p-4 bg-gray-50 dark:bg-gray-800 rounded-lg">
|
|
104
|
-
<div className="flex justify-center">
|
|
105
|
-
<div className="flex flex-col items-center" title={qrCodeUrl}>
|
|
106
|
-
<QrCode url={qrCodeUrl} size={300} />
|
|
107
|
-
</div>
|
|
108
|
-
</div>
|
|
109
|
-
|
|
110
|
-
{/* Address Display */}
|
|
111
|
-
<div className="flex flex-col items-center justify-center gap-1 pt-2">
|
|
112
|
-
<div className="flex items-center gap-2">
|
|
113
|
-
<span className="text-xs text-gray-500 dark:text-gray-400">
|
|
114
|
-
Address:
|
|
115
|
-
</span>
|
|
116
|
-
|
|
117
|
-
<button
|
|
118
|
-
type="button"
|
|
119
|
-
onClick={handleCopyAddress}
|
|
120
|
-
className="flex items-center gap-1 text-xs text-gray-500 dark:text-gray-400 hover:text-gray-700 dark:hover:text-gray-200 transition-colors duration-200 cursor-pointer"
|
|
121
|
-
title="Copy address"
|
|
122
|
-
>
|
|
123
|
-
{isCopied ? (
|
|
124
|
-
<Check className="w-3 h-3 text-green-500" />
|
|
125
|
-
) : (
|
|
126
|
-
<Copy className="w-3 h-3" />
|
|
127
|
-
)}
|
|
128
|
-
</button>
|
|
129
|
-
<a
|
|
130
|
-
href={getExplorerUrlForAddress({
|
|
131
|
-
address: resolvedAddress,
|
|
132
|
-
chainId: toChainId || 1,
|
|
133
|
-
})}
|
|
134
|
-
target="_blank"
|
|
135
|
-
rel="noopener noreferrer"
|
|
136
|
-
className="flex items-center gap-1 text-xs text-gray-500 dark:text-gray-400 hover:underline transition-all"
|
|
137
|
-
title={`View on explorer: ${resolvedAddress}`}
|
|
138
|
-
>
|
|
139
|
-
<span>{truncateAddress(resolvedAddress)}</span>
|
|
140
|
-
|
|
141
|
-
<ExternalLink className="w-3 h-3" />
|
|
142
|
-
</a>
|
|
143
|
-
</div>
|
|
144
|
-
</div>
|
|
145
|
-
</div>
|
|
146
|
-
|
|
147
|
-
{/* Connect Wallet Button - Only show when not connected */}
|
|
148
|
-
{!isConnected && onConnectWallet && (
|
|
149
|
-
<div className="flex justify-center">
|
|
150
|
-
<button
|
|
151
|
-
type="button"
|
|
152
|
-
onClick={onConnectWallet}
|
|
153
|
-
className="px-6 py-3 font-medium rounded-lg transition-colors duration-200 cursor-pointer bg-gray-100 hover:bg-gray-200 text-gray-600 hover:text-gray-900 dark:bg-gray-800 dark:hover:bg-gray-700 dark:text-gray-300 dark:hover:text-white"
|
|
154
|
-
>
|
|
155
|
-
Connect Wallet
|
|
156
|
-
</button>
|
|
157
|
-
</div>
|
|
158
|
-
)}
|
|
159
|
-
|
|
160
|
-
{/* Pay Button - Only show when connected */}
|
|
161
|
-
{isConnected && onPay && (
|
|
162
|
-
<div className="flex justify-center">
|
|
163
|
-
<button
|
|
164
|
-
type="button"
|
|
165
|
-
onClick={onPay}
|
|
166
|
-
className="w-full font-semibold py-4 px-4 trails-border-radius-button transition-colors bg-blue-500 hover:bg-blue-600 disabled:bg-gray-300 text-white disabled:text-gray-500 disabled:cursor-not-allowed cursor-pointer relative"
|
|
167
|
-
>
|
|
168
|
-
Pay {ensName ? ensName : truncateAddress(resolvedAddress)}
|
|
169
|
-
</button>
|
|
170
|
-
</div>
|
|
171
|
-
)}
|
|
172
|
-
</div>
|
|
173
|
-
</div>
|
|
174
|
-
)
|
|
175
|
-
}
|