0xtrails 0.13.0 → 0.13.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{ccip-Cg9-lJ6K.js → ccip-CT_An6eM.js} +39 -39
- package/dist/chains.d.ts +4 -3
- package/dist/chains.d.ts.map +1 -1
- package/dist/constants.d.ts +1 -0
- package/dist/constants.d.ts.map +1 -1
- package/dist/customTokens.d.ts.map +1 -1
- package/dist/error.d.ts +1 -0
- package/dist/error.d.ts.map +1 -1
- package/dist/gasless.d.ts +1 -2
- package/dist/gasless.d.ts.map +1 -1
- package/dist/{index-DEojZg7b.js → index-RfqL5Foz.js} +56672 -43550
- package/dist/index.d.ts +5 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +385 -333
- package/dist/intents.d.ts +8 -2
- package/dist/intents.d.ts.map +1 -1
- package/dist/keyMachineClient.d.ts +9 -0
- package/dist/keyMachineClient.d.ts.map +1 -0
- package/dist/keymachine/index.d.ts +14 -0
- package/dist/keymachine/index.d.ts.map +1 -0
- package/dist/keymachine/key-machine.gen.d.ts +461 -0
- package/dist/keymachine/key-machine.gen.d.ts.map +1 -0
- package/dist/onramp/MeshConnectFlow.d.ts +18 -0
- package/dist/onramp/MeshConnectFlow.d.ts.map +1 -0
- package/dist/onramp/MeshConnectIframe.d.ts +13 -0
- package/dist/onramp/MeshConnectIframe.d.ts.map +1 -0
- package/dist/onramp/SendFromExchangeButton.d.ts +16 -0
- package/dist/onramp/SendFromExchangeButton.d.ts.map +1 -0
- package/dist/onramp/TrailsOnRampProvider.d.ts +31 -0
- package/dist/onramp/TrailsOnRampProvider.d.ts.map +1 -0
- package/dist/onramp/index.d.ts +13 -0
- package/dist/onramp/index.d.ts.map +1 -0
- package/dist/onramp/meshconnect.d.ts +30 -0
- package/dist/onramp/meshconnect.d.ts.map +1 -0
- package/dist/onramp/trailsOnramp.d.ts +24 -0
- package/dist/onramp/trailsOnramp.d.ts.map +1 -0
- package/dist/onramp-client/index.d.ts +3 -3
- package/dist/onramp-client/index.d.ts.map +1 -1
- package/dist/paymasterSend.d.ts.map +1 -1
- package/dist/prepareSend.d.ts.map +1 -1
- package/dist/query/balance.fetchers.d.ts +31 -2
- package/dist/query/balance.fetchers.d.ts.map +1 -1
- package/dist/query/balance.hooks.d.ts +21 -2
- package/dist/query/balance.hooks.d.ts.map +1 -1
- package/dist/query/balance.queries.d.ts +18 -1
- package/dist/query/balance.queries.d.ts.map +1 -1
- package/dist/query/chains.queries.d.ts.map +1 -1
- package/dist/query/meld.fetchers.d.ts +1 -1
- package/dist/query/meld.fetchers.d.ts.map +1 -1
- package/dist/query/meld.hooks.d.ts +3 -3
- package/dist/query/meld.hooks.d.ts.map +1 -1
- package/dist/query/meld.queries.d.ts +1 -1
- package/dist/query/meld.queries.d.ts.map +1 -1
- package/dist/query/price.fetchers.d.ts +15 -0
- package/dist/query/price.fetchers.d.ts.map +1 -0
- package/dist/query/price.hooks.d.ts +352 -0
- package/dist/query/price.hooks.d.ts.map +1 -0
- package/dist/query/price.queries.d.ts +34 -0
- package/dist/query/price.queries.d.ts.map +1 -0
- package/dist/query/tokenList.queries.d.ts +54 -0
- package/dist/query/tokenList.queries.d.ts.map +1 -0
- package/dist/recover.d.ts +6 -4
- package/dist/recover.d.ts.map +1 -1
- package/dist/tokens.d.ts +13 -0
- package/dist/tokens.d.ts.map +1 -1
- package/dist/transactionIntent/deposits/depositOrchestrator.d.ts +2 -2
- package/dist/transactionIntent/deposits/depositOrchestrator.d.ts.map +1 -1
- package/dist/transactionIntent/deposits/gaslessDeposit.d.ts +2 -2
- package/dist/transactionIntent/deposits/gaslessDeposit.d.ts.map +1 -1
- package/dist/transactionIntent/deposits/standardDeposit.d.ts +1 -1
- package/dist/transactionIntent/deposits/standardDeposit.d.ts.map +1 -1
- package/dist/transactionIntent/handlers/intentHandler.d.ts.map +1 -1
- package/dist/transactionIntent/helpers/transactionStateHelpers.d.ts.map +1 -1
- package/dist/transactionIntent/quote/normalizeQuote.d.ts.map +1 -1
- package/dist/transactionIntent/types.d.ts +1 -1
- package/dist/transactionIntent/types.d.ts.map +1 -1
- package/dist/transactions.d.ts +4 -0
- package/dist/transactions.d.ts.map +1 -1
- package/dist/umd/trails.min.js +291 -202
- package/dist/utils/format.d.ts +7 -0
- package/dist/utils/format.d.ts.map +1 -1
- package/dist/walletUtils.d.ts +2 -1
- package/dist/walletUtils.d.ts.map +1 -1
- package/dist/wallets.d.ts +13 -54
- package/dist/wallets.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/ConnectWallet.d.ts.map +1 -1
- package/dist/widget/components/ConnectedWallets.d.ts.map +1 -1
- package/dist/widget/components/DirectTransfer.d.ts +1 -1
- package/dist/widget/components/DirectTransfer.d.ts.map +1 -1
- package/dist/widget/components/EarnPools.d.ts.map +1 -1
- package/dist/widget/components/ExecutionStatusBadge.d.ts.map +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/HighPriceImpactBlock.d.ts +7 -0
- package/dist/widget/components/HighPriceImpactBlock.d.ts.map +1 -0
- package/dist/widget/components/MeldHistory.d.ts.map +1 -1
- package/dist/widget/components/MeshExchangeSelection.d.ts +11 -0
- package/dist/widget/components/MeshExchangeSelection.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.map +1 -1
- package/dist/widget/components/Pay.d.ts.map +1 -1
- package/dist/widget/components/PoolDeposit.d.ts.map +1 -1
- package/dist/widget/components/PoolWithdraw.d.ts.map +1 -1
- package/dist/widget/components/QRCodeWalletSelect.d.ts +1 -1
- package/dist/widget/components/QRCodeWalletSelect.d.ts.map +1 -1
- package/dist/widget/components/QuoteDetails.d.ts.map +1 -1
- package/dist/widget/components/Receipt.d.ts.map +1 -1
- package/dist/widget/components/Recipients.d.ts.map +1 -1
- package/dist/widget/components/RefundWarning.d.ts.map +1 -1
- package/dist/widget/components/TokenSelector.d.ts.map +1 -1
- package/dist/widget/components/TransactionDetails.d.ts.map +1 -1
- package/dist/widget/components/TransactionHistoryItem.d.ts +2 -0
- package/dist/widget/components/TransactionHistoryItem.d.ts.map +1 -1
- package/dist/widget/components/TransferPendingVertical.d.ts +1 -0
- package/dist/widget/components/TransferPendingVertical.d.ts.map +1 -1
- package/dist/widget/components/WaasFeeOptions.d.ts.map +1 -1
- package/dist/widget/components/WalletConnect.d.ts.map +1 -1
- package/dist/widget/components/WalletImage.d.ts.map +1 -1
- package/dist/widget/components/WalletList.d.ts.map +1 -1
- package/dist/widget/components/Withdraw.d.ts.map +1 -1
- package/dist/widget/css/compiled.css +1 -1
- package/dist/widget/hooks/useAddressWalletIcon.d.ts.map +1 -1
- package/dist/widget/hooks/useCombinedHistory.d.ts +6 -5
- package/dist/widget/hooks/useCombinedHistory.d.ts.map +1 -1
- package/dist/widget/hooks/useCustomTokenSearch.d.ts +6 -1
- package/dist/widget/hooks/useCustomTokenSearch.d.ts.map +1 -1
- package/dist/widget/hooks/useDefaultDestinationToken.d.ts.map +1 -1
- package/dist/widget/hooks/useDefaultOriginToken.d.ts.map +1 -1
- package/dist/widget/hooks/useFiatOnRampCurrencies.d.ts +1 -1
- package/dist/widget/hooks/useFiatOnRampCurrencies.d.ts.map +1 -1
- package/dist/widget/hooks/useGetIntent.d.ts +3 -2
- package/dist/widget/hooks/useGetIntent.d.ts.map +1 -1
- package/dist/widget/hooks/useIntentReceiptBalances.d.ts +1 -1
- package/dist/widget/hooks/useIntentReceiptBalances.d.ts.map +1 -1
- package/dist/widget/hooks/useIntentTransactionHistory.d.ts +3 -2
- package/dist/widget/hooks/useIntentTransactionHistory.d.ts.map +1 -1
- package/dist/widget/hooks/useMeldTransactionHistory.d.ts +1 -1
- package/dist/widget/hooks/useMeldTransactionHistory.d.ts.map +1 -1
- package/dist/widget/hooks/useMeldTransactionStatus.d.ts +1 -1
- package/dist/widget/hooks/useMeldTransactionStatus.d.ts.map +1 -1
- package/dist/widget/hooks/useOnRampQuote.d.ts +1 -1
- package/dist/widget/hooks/useOnRampQuote.d.ts.map +1 -1
- package/dist/widget/hooks/useOnRampTransactionStatus.d.ts +1 -1
- package/dist/widget/hooks/useOnRampTransactionStatus.d.ts.map +1 -1
- package/dist/widget/hooks/useQuote.d.ts +2 -2
- package/dist/widget/hooks/useQuote.d.ts.map +1 -1
- package/dist/widget/hooks/useSelectedFundMethod.d.ts +7 -0
- package/dist/widget/hooks/useSelectedFundMethod.d.ts.map +1 -1
- package/dist/widget/hooks/useSendForm.d.ts +0 -1
- package/dist/widget/hooks/useSendForm.d.ts.map +1 -1
- package/dist/widget/hooks/useTokenList.d.ts +7 -1
- package/dist/widget/hooks/useTokenList.d.ts.map +1 -1
- package/dist/widget/hooks/useViewManager.d.ts +1 -1
- package/dist/widget/hooks/useViewManager.d.ts.map +1 -1
- package/dist/widget/index.js +1 -1
- package/dist/widget/providers/TrailsProvider.d.ts +2 -0
- package/dist/widget/providers/TrailsProvider.d.ts.map +1 -1
- package/dist/widget/utils/createWagmiConfig.d.ts +2 -2
- package/dist/widget/utils/createWagmiConfig.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/historyFilters.d.ts +13 -0
- package/dist/widget/utils/historyFilters.d.ts.map +1 -0
- package/dist/widget/utils/meldProviderUtils.d.ts +1 -1
- package/dist/widget/utils/meldProviderUtils.d.ts.map +1 -1
- package/dist/widget/utils/meshSupportedTokens.d.ts +4 -0
- package/dist/widget/utils/meshSupportedTokens.d.ts.map +1 -0
- package/dist/widget/utils/onrampConfig.d.ts +11 -0
- package/dist/widget/utils/onrampConfig.d.ts.map +1 -0
- package/dist/widget/utils/statusLabel.d.ts +2 -0
- package/dist/widget/utils/statusLabel.d.ts.map +1 -0
- package/dist/widget/utils/trailsOnrampConfig.d.ts +18 -0
- package/dist/widget/utils/trailsOnrampConfig.d.ts.map +1 -0
- package/dist/widget/widget.d.ts +24 -8
- package/dist/widget/widget.d.ts.map +1 -1
- package/package.json +9 -7
- package/src/chains.ts +26 -9
- package/src/constants.ts +2 -0
- package/src/customTokens.ts +22 -7
- package/src/error.ts +7 -0
- package/src/gasless.ts +5 -2
- package/src/index.ts +8 -5
- package/src/intents.ts +56 -60
- package/src/keyMachineClient.ts +29 -0
- package/src/keymachine/index.ts +175 -0
- package/src/keymachine/key-machine.gen.ts +993 -0
- package/src/onramp/MeshConnectFlow.tsx +86 -0
- package/src/onramp/MeshConnectIframe.tsx +661 -0
- package/src/onramp/SendFromExchangeButton.tsx +81 -0
- package/src/onramp/TrailsOnRampProvider.tsx +59 -0
- package/src/onramp/index.ts +31 -0
- package/src/onramp/meshconnect.ts +277 -0
- package/src/onramp/trailsOnramp.tsx +130 -0
- package/src/onramp-client/index.ts +4 -6
- package/src/paymasterSend.ts +0 -5
- package/src/prepareSend.ts +45 -44
- package/src/query/balance.fetchers.ts +172 -17
- package/src/query/balance.hooks.ts +69 -6
- package/src/query/balance.queries.ts +63 -0
- package/src/query/chains.queries.ts +1 -6
- package/src/query/meld.fetchers.ts +1 -1
- package/src/query/meld.hooks.ts +1 -1
- package/src/query/meld.queries.ts +1 -1
- package/src/query/price.fetchers.ts +53 -0
- package/src/query/price.hooks.ts +46 -0
- package/src/query/price.queries.ts +364 -0
- package/src/query/tokenList.queries.ts +118 -0
- package/src/recover.ts +89 -26
- package/src/tokens.ts +108 -26
- package/src/transactionIntent/deposits/depositOrchestrator.ts +11 -11
- package/src/transactionIntent/deposits/gaslessDeposit.ts +38 -39
- package/src/transactionIntent/deposits/standardDeposit.ts +5 -30
- package/src/transactionIntent/handlers/intentHandler.ts +29 -12
- package/src/transactionIntent/helpers/transactionStateHelpers.ts +5 -2
- package/src/transactionIntent/quote/normalizeQuote.ts +11 -5
- package/src/transactionIntent/types.ts +1 -1
- package/src/transactions.ts +5 -1
- package/src/utils/format.ts +85 -1
- package/src/walletUtils.ts +2 -1
- package/src/wallets.ts +184 -380
- package/src/widget/compiled.css +1 -1
- package/src/widget/components/AccountIntentTransactionHistory.tsx +134 -109
- package/src/widget/components/ClassicSwap.tsx +26 -24
- package/src/widget/components/ConnectWallet.tsx +4 -2
- package/src/widget/components/ConnectedWallets.tsx +2 -5
- package/src/widget/components/DirectTransfer.tsx +5 -2
- package/src/widget/components/EarnPools.tsx +1 -2
- package/src/widget/components/ExecutionStatusBadge.tsx +10 -4
- package/src/widget/components/Fund.tsx +169 -110
- package/src/widget/components/FundMethods.tsx +5 -9
- package/src/widget/components/HighPriceImpactBlock.tsx +44 -0
- package/src/widget/components/MeldHistory.tsx +4 -28
- package/src/widget/components/MeshExchangeSelection.tsx +218 -0
- package/src/widget/components/OnrampHistoryRow.tsx +3 -27
- package/src/widget/components/OnrampProviderConfirmation.tsx +0 -25
- package/src/widget/components/Pay.tsx +20 -36
- package/src/widget/components/PoolDeposit.tsx +14 -24
- package/src/widget/components/PoolWithdraw.tsx +1 -63
- package/src/widget/components/QRCodeWalletSelect.tsx +5 -2
- package/src/widget/components/QuoteDetails.tsx +113 -106
- package/src/widget/components/Receipt.tsx +0 -11
- package/src/widget/components/Recipients.tsx +2 -1
- package/src/widget/components/RefundWarning.tsx +5 -10
- package/src/widget/components/ThemeProvider.tsx +4 -4
- package/src/widget/components/TokenSelector.tsx +85 -16
- package/src/widget/components/TransactionDetails.tsx +46 -0
- package/src/widget/components/TransactionHistoryItem.tsx +14 -23
- package/src/widget/components/TransferPendingVertical.tsx +17 -11
- package/src/widget/components/WaasFeeOptions.tsx +4 -42
- package/src/widget/components/WalletConnect.tsx +2 -5
- package/src/widget/components/WalletImage.tsx +6 -18
- package/src/widget/components/WalletList.tsx +1 -1
- package/src/widget/components/Withdraw.tsx +22 -23
- package/src/widget/hooks/useAddressWalletIcon.ts +2 -1
- package/src/widget/hooks/useAmountUsd.ts +1 -1
- package/src/widget/hooks/useCombinedHistory.ts +37 -93
- package/src/widget/hooks/useCustomTokenSearch.tsx +63 -33
- package/src/widget/hooks/useDefaultDestinationToken.tsx +2 -5
- package/src/widget/hooks/useDefaultOriginToken.tsx +2 -5
- package/src/widget/hooks/useFiatOnRampCurrencies.ts +1 -1
- package/src/widget/hooks/useGetIntent.ts +5 -4
- package/src/widget/hooks/useIntentReceiptBalances.ts +3 -3
- package/src/widget/hooks/useIntentTransactionHistory.ts +24 -47
- package/src/widget/hooks/useMeldTransactionHistory.ts +4 -2
- package/src/widget/hooks/useMeldTransactionStatus.ts +13 -11
- package/src/widget/hooks/useOnRampQuote.ts +3 -3
- package/src/widget/hooks/useOnRampTransactionStatus.ts +8 -6
- package/src/widget/hooks/useQuote.ts +56 -48
- package/src/widget/hooks/useSelectedFundMethod.tsx +14 -1
- package/src/widget/hooks/useSendForm.ts +52 -31
- package/src/widget/hooks/useTokenList.ts +209 -140
- package/src/widget/hooks/useTrailsSendTransaction.ts +1 -1
- package/src/widget/hooks/useViewManager.tsx +1 -0
- package/src/widget/providers/TrailsProvider.tsx +5 -0
- package/src/widget/styles.ts +1 -1
- package/src/widget/utils/createWagmiConfig.ts +7 -2
- package/src/widget/utils/fundMethodSwitchState.ts +2 -0
- package/src/widget/utils/historyFilters.ts +157 -0
- package/src/widget/utils/meldProviderUtils.ts +8 -2
- package/src/widget/utils/meshSupportedTokens.ts +28 -0
- package/src/widget/utils/onrampConfig.ts +15 -0
- package/src/widget/utils/statusLabel.ts +3 -0
- package/src/widget/utils/trailsOnrampConfig.ts +39 -0
- package/src/widget/widget.tsx +235 -185
- package/dist/onramp-client/trails-onramp.gen.d.ts +0 -570
- package/dist/onramp-client/trails-onramp.gen.d.ts.map +0 -1
- package/dist/prices.d.ts +0 -34
- package/dist/prices.d.ts.map +0 -1
- package/dist/useGasEstimation.d.ts +0 -34
- package/dist/useGasEstimation.d.ts.map +0 -1
- package/dist/widget/hooks/useCustomTokenFetch.d.ts +0 -19
- package/dist/widget/hooks/useCustomTokenFetch.d.ts.map +0 -1
- package/dist/widget/hooks/useTokenWithFreshBalance.d.ts +0 -18
- package/dist/widget/hooks/useTokenWithFreshBalance.d.ts.map +0 -1
- package/src/onramp-client/trails-onramp.gen.ts +0 -1320
- package/src/prices.ts +0 -528
- package/src/useGasEstimation.ts +0 -147
- package/src/widget/assets/Binance_Icon_Logo.svg +0 -14
- package/src/widget/assets/Bitfinex_Icon_Logo.svg +0 -5
- package/src/widget/assets/Coinbase_Icon_Logo.svg +0 -1
- package/src/widget/assets/WalletConnect-logo-blue-bg.svg +0 -11
- package/src/widget/assets/sequence-logo.svg +0 -15
- package/src/widget/hooks/useCustomTokenFetch.tsx +0 -74
- package/src/widget/hooks/useTokenWithFreshBalance.ts +0 -246
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import type React from "react"
|
|
2
|
+
import { AlertCircle, ArrowLeftRight, ChevronRight } from "lucide-react"
|
|
3
|
+
import { isMeshEnabled, useTrailsOnRamp } from "./TrailsOnRampProvider.js"
|
|
4
|
+
|
|
5
|
+
export interface SendFromExchangeButtonProps {
|
|
6
|
+
/**
|
|
7
|
+
* Callback to navigate to the onramp screen.
|
|
8
|
+
* The onramp screen will show the exchange list.
|
|
9
|
+
*/
|
|
10
|
+
onNavigateToOnramp?: () => void
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Button component for "Send from Exchange" option in FundMethods.
|
|
15
|
+
* Only renders if Mesh onramp is configured and exchanges are configured.
|
|
16
|
+
* Shows an error message if no exchanges are configured.
|
|
17
|
+
* When clicked, navigates directly to the onramp screen which shows the exchange list.
|
|
18
|
+
*/
|
|
19
|
+
export const SendFromExchangeButton: React.FC<SendFromExchangeButtonProps> = ({
|
|
20
|
+
onNavigateToOnramp,
|
|
21
|
+
}) => {
|
|
22
|
+
const onRampContext = useTrailsOnRamp()
|
|
23
|
+
|
|
24
|
+
// Check if exchanges are configured
|
|
25
|
+
const hasExchanges =
|
|
26
|
+
onRampContext?.config.mesh?.exchanges &&
|
|
27
|
+
onRampContext.config.mesh.exchanges.length > 0
|
|
28
|
+
|
|
29
|
+
const meshEnabled = isMeshEnabled(onRampContext?.config)
|
|
30
|
+
|
|
31
|
+
if (!meshEnabled) {
|
|
32
|
+
return null
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
// If no exchanges configured, show error message
|
|
36
|
+
if (!hasExchanges) {
|
|
37
|
+
return (
|
|
38
|
+
<>
|
|
39
|
+
{/* Divider between buttons */}
|
|
40
|
+
<div className="border-b border-gray-200 dark:border-gray-700"></div>
|
|
41
|
+
|
|
42
|
+
<div className="px-3 py-4 text-sm">
|
|
43
|
+
<div className="flex items-center gap-3 text-amber-600 dark:text-amber-400">
|
|
44
|
+
<AlertCircle className="w-4 h-4 flex-shrink-0" />
|
|
45
|
+
<div className="flex-1">
|
|
46
|
+
<p className="font-medium">Exchange list not configured</p>
|
|
47
|
+
<p className="text-xs mt-1 text-amber-500 dark:text-amber-500">
|
|
48
|
+
Please configure at least one exchange in the onramp settings.
|
|
49
|
+
</p>
|
|
50
|
+
</div>
|
|
51
|
+
</div>
|
|
52
|
+
</div>
|
|
53
|
+
</>
|
|
54
|
+
)
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
// If no navigation callback provided, don't render button
|
|
58
|
+
if (!onNavigateToOnramp) {
|
|
59
|
+
return null
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
// Render the button - clicking navigates to the onramp screen which shows the exchange list
|
|
63
|
+
return (
|
|
64
|
+
<>
|
|
65
|
+
{/* Divider between buttons */}
|
|
66
|
+
<div className="border-b border-gray-200 dark:border-gray-700"></div>
|
|
67
|
+
|
|
68
|
+
<button
|
|
69
|
+
type="button"
|
|
70
|
+
onClick={onNavigateToOnramp}
|
|
71
|
+
className="w-full text-left px-3 py-4 text-sm flex items-center justify-between cursor-pointer transition-colors trails-text-primary trails-hover-bg"
|
|
72
|
+
>
|
|
73
|
+
<div className="flex items-center gap-3">
|
|
74
|
+
<ArrowLeftRight className="w-4 h-4" />
|
|
75
|
+
<span className="text-sm font-bold">Send from Exchange</span>
|
|
76
|
+
</div>
|
|
77
|
+
<ChevronRight className="w-5 h-5 text-gray-400" />
|
|
78
|
+
</button>
|
|
79
|
+
</>
|
|
80
|
+
)
|
|
81
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import type React from "react"
|
|
2
|
+
import { createContext, useContext, useMemo } from "react"
|
|
3
|
+
|
|
4
|
+
export interface MeshConfig {
|
|
5
|
+
exchanges?: string[]
|
|
6
|
+
clientId?: string
|
|
7
|
+
environment?: "sandbox" | "production"
|
|
8
|
+
sandbox?: boolean
|
|
9
|
+
sandboxEnabled?: boolean
|
|
10
|
+
productionEnabled?: boolean
|
|
11
|
+
mode?: "sandbox" | "production"
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export interface TrailsOnRampConfig {
|
|
15
|
+
mesh?: MeshConfig
|
|
16
|
+
environment?: "sandbox" | "production"
|
|
17
|
+
apiKey?: string
|
|
18
|
+
jwt?: string
|
|
19
|
+
hostname?: string
|
|
20
|
+
clientId?: string
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
interface TrailsOnRampContextValue {
|
|
24
|
+
config: TrailsOnRampConfig
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
const TrailsOnRampContext = createContext<TrailsOnRampContextValue | null>(null)
|
|
28
|
+
|
|
29
|
+
export interface TrailsOnRampProviderProps {
|
|
30
|
+
config?: TrailsOnRampConfig
|
|
31
|
+
children: React.ReactNode
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export function TrailsOnRampProvider({
|
|
35
|
+
config = {},
|
|
36
|
+
children,
|
|
37
|
+
}: TrailsOnRampProviderProps) {
|
|
38
|
+
const value = useMemo<TrailsOnRampContextValue>(() => ({ config }), [config])
|
|
39
|
+
|
|
40
|
+
return (
|
|
41
|
+
<TrailsOnRampContext.Provider value={value}>
|
|
42
|
+
{children}
|
|
43
|
+
</TrailsOnRampContext.Provider>
|
|
44
|
+
)
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export function useTrailsOnRamp(): TrailsOnRampContextValue | null {
|
|
48
|
+
return useContext(TrailsOnRampContext)
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export function isMeshEnabled(config?: TrailsOnRampConfig | null): boolean {
|
|
52
|
+
return !!config?.mesh
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export function getActiveMeshMode(
|
|
56
|
+
config?: TrailsOnRampConfig | null,
|
|
57
|
+
): "sandbox" | "production" {
|
|
58
|
+
return config?.mesh?.environment ?? "production"
|
|
59
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
export { MeshConnectFlow } from "./MeshConnectFlow.js"
|
|
2
|
+
export type {
|
|
3
|
+
MeshConnectFlowProps,
|
|
4
|
+
SelectedMeshExchange,
|
|
5
|
+
} from "./MeshConnectFlow.js"
|
|
6
|
+
export { MeshConnectIframe } from "./MeshConnectIframe.js"
|
|
7
|
+
export type { MeshConnectProps } from "./MeshConnectIframe.js"
|
|
8
|
+
export { SendFromExchangeButton } from "./SendFromExchangeButton.js"
|
|
9
|
+
export type { SendFromExchangeButtonProps } from "./SendFromExchangeButton.js"
|
|
10
|
+
export {
|
|
11
|
+
SimpleHeader,
|
|
12
|
+
type SimpleHeaderProps,
|
|
13
|
+
} from "../meld/components/SimpleHeader.js"
|
|
14
|
+
export {
|
|
15
|
+
TrailsOnRampProvider,
|
|
16
|
+
getActiveMeshMode,
|
|
17
|
+
isMeshEnabled,
|
|
18
|
+
useTrailsOnRamp,
|
|
19
|
+
} from "./TrailsOnRampProvider.js"
|
|
20
|
+
export type {
|
|
21
|
+
MeshConfig,
|
|
22
|
+
TrailsOnRampConfig,
|
|
23
|
+
TrailsOnRampProviderProps,
|
|
24
|
+
} from "./TrailsOnRampProvider.js"
|
|
25
|
+
export {
|
|
26
|
+
trailsOnramp,
|
|
27
|
+
getTrailsOnrampConfig,
|
|
28
|
+
normalizeTrailsOnrampConfig,
|
|
29
|
+
} from "./trailsOnramp.js"
|
|
30
|
+
export type { OnrampFactory, OnrampWidgetHandlers } from "./trailsOnramp.js"
|
|
31
|
+
export * from "./meshconnect.js"
|
|
@@ -0,0 +1,277 @@
|
|
|
1
|
+
import {
|
|
2
|
+
type CreateMeshLinkTokenRequest,
|
|
3
|
+
type CreateMeshLinkTokenResponse,
|
|
4
|
+
type GetMeshIntegrationsRequest,
|
|
5
|
+
type GetMeshSupportedTokensRequest,
|
|
6
|
+
type GetMeshSupportedTokensResponse,
|
|
7
|
+
type MeshIntegration,
|
|
8
|
+
type MeshSupportedToken,
|
|
9
|
+
TrailsOnrampRpcClient,
|
|
10
|
+
} from "@0xtrails/api/onramp"
|
|
11
|
+
import type { TrailsOnRampConfig } from "./TrailsOnRampProvider.js"
|
|
12
|
+
import { getActiveMeshMode } from "./TrailsOnRampProvider.js"
|
|
13
|
+
|
|
14
|
+
const MESH_INTEGRATIONS_CACHE_TTL_MS = 30_000
|
|
15
|
+
const MESH_LINK_TOKEN_CACHE_TTL_MS = 5_000
|
|
16
|
+
|
|
17
|
+
const meshIntegrationsCache = new Map<
|
|
18
|
+
string,
|
|
19
|
+
{ integrations: MeshIntegration[]; expiresAt: number }
|
|
20
|
+
>()
|
|
21
|
+
const meshIntegrationsInFlight = new Map<string, Promise<MeshIntegration[]>>()
|
|
22
|
+
const meshLinkTokenCache = new Map<
|
|
23
|
+
string,
|
|
24
|
+
{ response: CreateMeshLinkTokenResponse; expiresAt: number }
|
|
25
|
+
>()
|
|
26
|
+
const meshLinkTokenInFlight = new Map<
|
|
27
|
+
string,
|
|
28
|
+
Promise<CreateMeshLinkTokenResponse>
|
|
29
|
+
>()
|
|
30
|
+
const meshSupportedTokensCache = new Map<
|
|
31
|
+
string,
|
|
32
|
+
{ tokens: MeshSupportedToken[]; expiresAt: number }
|
|
33
|
+
>()
|
|
34
|
+
const meshSupportedTokensInFlight = new Map<
|
|
35
|
+
string,
|
|
36
|
+
Promise<MeshSupportedToken[]>
|
|
37
|
+
>()
|
|
38
|
+
|
|
39
|
+
export interface CreateMeshLinkTokenOptions {
|
|
40
|
+
address: string
|
|
41
|
+
symbol: string
|
|
42
|
+
amount: string
|
|
43
|
+
destinationChainId: number | string
|
|
44
|
+
integrationId?: string
|
|
45
|
+
exchangeType?: string
|
|
46
|
+
transactionId?: string
|
|
47
|
+
restrictMultipleAccounts?: boolean
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
function createOnrampClient(
|
|
51
|
+
config?: TrailsOnRampConfig,
|
|
52
|
+
): TrailsOnrampRpcClient {
|
|
53
|
+
const customFetch = (
|
|
54
|
+
input: RequestInfo,
|
|
55
|
+
init?: RequestInit,
|
|
56
|
+
): Promise<Response> => {
|
|
57
|
+
const headers: Record<string, string> = {}
|
|
58
|
+
|
|
59
|
+
if (config?.jwt && config.jwt.length > 0) {
|
|
60
|
+
headers.Authorization = `BEARER ${config.jwt}`
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
if (config?.apiKey && config.apiKey.length > 0) {
|
|
64
|
+
headers["X-Access-Key"] = config.apiKey
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
init = init || {}
|
|
68
|
+
init.headers = { ...init.headers, ...headers }
|
|
69
|
+
|
|
70
|
+
return fetch(input, init)
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
return new TrailsOnrampRpcClient(
|
|
74
|
+
config?.hostname && config.hostname.length > 0
|
|
75
|
+
? config.hostname
|
|
76
|
+
: "https://trails-api.sequence.app",
|
|
77
|
+
customFetch,
|
|
78
|
+
)
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
function getMeshConfigKey(config?: TrailsOnRampConfig): string {
|
|
82
|
+
return JSON.stringify({
|
|
83
|
+
hostname: config?.hostname ?? "",
|
|
84
|
+
apiKey: config?.apiKey ?? "",
|
|
85
|
+
jwt: config?.jwt ?? "",
|
|
86
|
+
environment: getActiveMeshMode(config),
|
|
87
|
+
})
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
export async function getMeshIntegrations(
|
|
91
|
+
config?: TrailsOnRampConfig,
|
|
92
|
+
): Promise<MeshIntegration[]> {
|
|
93
|
+
const cacheKey = getMeshConfigKey(config)
|
|
94
|
+
const cached = meshIntegrationsCache.get(cacheKey)
|
|
95
|
+
|
|
96
|
+
if (cached && cached.expiresAt > Date.now()) {
|
|
97
|
+
return cached.integrations
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
const inFlight = meshIntegrationsInFlight.get(cacheKey)
|
|
101
|
+
if (inFlight) {
|
|
102
|
+
return inFlight
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
const client = createOnrampClient(config)
|
|
106
|
+
const request: GetMeshIntegrationsRequest = {
|
|
107
|
+
environment: getActiveMeshMode(config),
|
|
108
|
+
}
|
|
109
|
+
const requestPromise = client
|
|
110
|
+
.getMeshIntegrations(request)
|
|
111
|
+
.then((response) => {
|
|
112
|
+
const integrations = response.integrations || []
|
|
113
|
+
meshIntegrationsCache.set(cacheKey, {
|
|
114
|
+
integrations,
|
|
115
|
+
expiresAt: Date.now() + MESH_INTEGRATIONS_CACHE_TTL_MS,
|
|
116
|
+
})
|
|
117
|
+
return integrations
|
|
118
|
+
})
|
|
119
|
+
.finally(() => {
|
|
120
|
+
meshIntegrationsInFlight.delete(cacheKey)
|
|
121
|
+
})
|
|
122
|
+
|
|
123
|
+
meshIntegrationsInFlight.set(cacheKey, requestPromise)
|
|
124
|
+
return requestPromise
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
export async function getMeshIntegrationId(
|
|
128
|
+
exchangeType: string,
|
|
129
|
+
config?: TrailsOnRampConfig,
|
|
130
|
+
): Promise<string | undefined> {
|
|
131
|
+
const integrations = await getMeshIntegrations(config)
|
|
132
|
+
return integrations.find((integration) => integration.key === exchangeType)
|
|
133
|
+
?.id
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
export async function getCoinbaseIntegrationId(
|
|
137
|
+
config?: TrailsOnRampConfig,
|
|
138
|
+
): Promise<string | undefined> {
|
|
139
|
+
return (
|
|
140
|
+
(await getMeshIntegrationId("coinbaseRamp", config)) ??
|
|
141
|
+
getMeshIntegrationId("coinbase", config)
|
|
142
|
+
)
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
export async function getBinanceIntegrationId(
|
|
146
|
+
config?: TrailsOnRampConfig,
|
|
147
|
+
): Promise<string | undefined> {
|
|
148
|
+
return (
|
|
149
|
+
(await getMeshIntegrationId("binanceInternationalDirect", config)) ??
|
|
150
|
+
getMeshIntegrationId("binanceInternational", config)
|
|
151
|
+
)
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
export async function getBitfinexIntegrationId(
|
|
155
|
+
config?: TrailsOnRampConfig,
|
|
156
|
+
): Promise<string | undefined> {
|
|
157
|
+
return (
|
|
158
|
+
(await getMeshIntegrationId("bitfinexDirect", config)) ??
|
|
159
|
+
getMeshIntegrationId("bitfinex", config)
|
|
160
|
+
)
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
export async function createMeshLinkToken(
|
|
164
|
+
options: CreateMeshLinkTokenOptions,
|
|
165
|
+
config?: TrailsOnRampConfig,
|
|
166
|
+
): Promise<CreateMeshLinkTokenResponse> {
|
|
167
|
+
const cacheKey = JSON.stringify({
|
|
168
|
+
config: getMeshConfigKey(config),
|
|
169
|
+
request: {
|
|
170
|
+
address: options.address,
|
|
171
|
+
symbol: options.symbol,
|
|
172
|
+
amount: options.amount,
|
|
173
|
+
destinationChainId: options.destinationChainId.toString(),
|
|
174
|
+
integrationId: options.integrationId ?? "",
|
|
175
|
+
exchangeType: options.exchangeType ?? "",
|
|
176
|
+
restrictMultipleAccounts: options.restrictMultipleAccounts ?? false,
|
|
177
|
+
transactionId: options.transactionId ?? "",
|
|
178
|
+
},
|
|
179
|
+
})
|
|
180
|
+
|
|
181
|
+
const cached = meshLinkTokenCache.get(cacheKey)
|
|
182
|
+
if (cached && cached.expiresAt > Date.now()) {
|
|
183
|
+
return cached.response
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
const inFlight = meshLinkTokenInFlight.get(cacheKey)
|
|
187
|
+
if (inFlight) {
|
|
188
|
+
return inFlight
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
const client = createOnrampClient(config)
|
|
192
|
+
const request: CreateMeshLinkTokenRequest = {
|
|
193
|
+
environment: getActiveMeshMode(config),
|
|
194
|
+
clientId: config?.mesh?.clientId ?? config?.clientId,
|
|
195
|
+
recipientAddress: options.address,
|
|
196
|
+
tokenSymbol: options.symbol,
|
|
197
|
+
destinationChainId: options.destinationChainId.toString(),
|
|
198
|
+
amount: options.amount,
|
|
199
|
+
integrationId: options.integrationId,
|
|
200
|
+
exchangeType: options.exchangeType,
|
|
201
|
+
transactionId: options.transactionId,
|
|
202
|
+
restrictMultipleAccounts: options.restrictMultipleAccounts,
|
|
203
|
+
}
|
|
204
|
+
const requestPromise = client
|
|
205
|
+
.createMeshLinkToken(request)
|
|
206
|
+
.then((response) => {
|
|
207
|
+
meshLinkTokenCache.set(cacheKey, {
|
|
208
|
+
response,
|
|
209
|
+
expiresAt: Date.now() + MESH_LINK_TOKEN_CACHE_TTL_MS,
|
|
210
|
+
})
|
|
211
|
+
return response
|
|
212
|
+
})
|
|
213
|
+
.finally(() => {
|
|
214
|
+
meshLinkTokenInFlight.delete(cacheKey)
|
|
215
|
+
})
|
|
216
|
+
|
|
217
|
+
meshLinkTokenInFlight.set(cacheKey, requestPromise)
|
|
218
|
+
return requestPromise
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
export async function getMeshSupportedTokens(
|
|
222
|
+
request: Omit<GetMeshSupportedTokensRequest, "environment">,
|
|
223
|
+
config?: TrailsOnRampConfig,
|
|
224
|
+
): Promise<MeshSupportedToken[]> {
|
|
225
|
+
const cacheKey = JSON.stringify({
|
|
226
|
+
config: getMeshConfigKey(config),
|
|
227
|
+
request: {
|
|
228
|
+
integrationId: request.integrationId ?? "",
|
|
229
|
+
exchangeType: request.exchangeType ?? "",
|
|
230
|
+
chainIds: request.chainIds ?? [],
|
|
231
|
+
},
|
|
232
|
+
})
|
|
233
|
+
|
|
234
|
+
const cached = meshSupportedTokensCache.get(cacheKey)
|
|
235
|
+
if (cached && cached.expiresAt > Date.now()) {
|
|
236
|
+
return cached.tokens
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
const inFlight = meshSupportedTokensInFlight.get(cacheKey)
|
|
240
|
+
if (inFlight) {
|
|
241
|
+
return inFlight
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
const client = createOnrampClient(config)
|
|
245
|
+
const fullRequest: GetMeshSupportedTokensRequest = {
|
|
246
|
+
environment: getActiveMeshMode(config),
|
|
247
|
+
integrationId: request.integrationId,
|
|
248
|
+
exchangeType: request.exchangeType,
|
|
249
|
+
chainIds: request.chainIds,
|
|
250
|
+
}
|
|
251
|
+
const requestPromise = client
|
|
252
|
+
.getMeshSupportedTokens(fullRequest)
|
|
253
|
+
.then((response: GetMeshSupportedTokensResponse) => {
|
|
254
|
+
const tokens = response.tokens || []
|
|
255
|
+
meshSupportedTokensCache.set(cacheKey, {
|
|
256
|
+
tokens,
|
|
257
|
+
expiresAt: Date.now() + MESH_INTEGRATIONS_CACHE_TTL_MS,
|
|
258
|
+
})
|
|
259
|
+
return tokens
|
|
260
|
+
})
|
|
261
|
+
.finally(() => {
|
|
262
|
+
meshSupportedTokensInFlight.delete(cacheKey)
|
|
263
|
+
})
|
|
264
|
+
|
|
265
|
+
meshSupportedTokensInFlight.set(cacheKey, requestPromise)
|
|
266
|
+
return requestPromise
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
export default {
|
|
270
|
+
createMeshLinkToken,
|
|
271
|
+
getMeshIntegrations,
|
|
272
|
+
getMeshSupportedTokens,
|
|
273
|
+
getMeshIntegrationId,
|
|
274
|
+
getCoinbaseIntegrationId,
|
|
275
|
+
getBinanceIntegrationId,
|
|
276
|
+
getBitfinexIntegrationId,
|
|
277
|
+
}
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
import type React from "react"
|
|
2
|
+
import { MeshConnectFlow } from "./MeshConnectFlow.js"
|
|
3
|
+
import type { SelectedMeshExchange } from "./MeshConnectFlow.js"
|
|
4
|
+
import {
|
|
5
|
+
TrailsOnRampProvider,
|
|
6
|
+
type TrailsOnRampConfig,
|
|
7
|
+
} from "./TrailsOnRampProvider.js"
|
|
8
|
+
|
|
9
|
+
export interface OnrampWidgetHandlers {
|
|
10
|
+
setCurrentScreen: (screen: string) => void
|
|
11
|
+
onComplete?: (transferData: unknown) => void
|
|
12
|
+
onError?: (error: unknown) => void
|
|
13
|
+
onBack?: () => void
|
|
14
|
+
toTokenSymbol?: string
|
|
15
|
+
toTokenAmount?: string
|
|
16
|
+
toChainId?: number
|
|
17
|
+
toRecipientAddress?: string
|
|
18
|
+
toAmountUsd?: number
|
|
19
|
+
selectedExchange?: SelectedMeshExchange
|
|
20
|
+
apiKey?: string
|
|
21
|
+
hostname?: string
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export type OnrampFactory = (
|
|
25
|
+
handlers: OnrampWidgetHandlers,
|
|
26
|
+
) => React.ReactElement
|
|
27
|
+
|
|
28
|
+
type OnrampFactoryWithConfig = OnrampFactory & {
|
|
29
|
+
trailsOnrampConfig?: TrailsOnRampConfig
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export function normalizeTrailsOnrampConfig(
|
|
33
|
+
config?: TrailsOnRampConfig,
|
|
34
|
+
): TrailsOnRampConfig | undefined {
|
|
35
|
+
if (!config) {
|
|
36
|
+
return undefined
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
if (!config.mesh) {
|
|
40
|
+
return config
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
return {
|
|
44
|
+
...config,
|
|
45
|
+
mesh: {
|
|
46
|
+
environment: "production",
|
|
47
|
+
...config.mesh,
|
|
48
|
+
},
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export function getTrailsOnrampConfig(
|
|
53
|
+
factory?: OnrampFactory,
|
|
54
|
+
): TrailsOnRampConfig | undefined {
|
|
55
|
+
return normalizeTrailsOnrampConfig(
|
|
56
|
+
(factory as OnrampFactoryWithConfig | undefined)?.trailsOnrampConfig,
|
|
57
|
+
)
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export function trailsOnramp(options: {
|
|
61
|
+
config?: TrailsOnRampConfig
|
|
62
|
+
}): OnrampFactory {
|
|
63
|
+
const normalizedConfig = normalizeTrailsOnrampConfig(options.config)
|
|
64
|
+
const factory: OnrampFactoryWithConfig = (handlers: OnrampWidgetHandlers) => {
|
|
65
|
+
const {
|
|
66
|
+
setCurrentScreen,
|
|
67
|
+
onComplete,
|
|
68
|
+
onBack,
|
|
69
|
+
toTokenSymbol,
|
|
70
|
+
toTokenAmount,
|
|
71
|
+
toChainId,
|
|
72
|
+
toRecipientAddress,
|
|
73
|
+
toAmountUsd,
|
|
74
|
+
selectedExchange,
|
|
75
|
+
apiKey,
|
|
76
|
+
hostname,
|
|
77
|
+
} = handlers
|
|
78
|
+
|
|
79
|
+
const handleBack = () => {
|
|
80
|
+
if (onBack) {
|
|
81
|
+
onBack()
|
|
82
|
+
} else {
|
|
83
|
+
setCurrentScreen("home")
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
const handleComplete = (transferData: unknown) => {
|
|
88
|
+
console.log("[onramp] handleComplete called:", {
|
|
89
|
+
hasOnComplete: !!onComplete,
|
|
90
|
+
transferData,
|
|
91
|
+
})
|
|
92
|
+
if (onComplete) {
|
|
93
|
+
try {
|
|
94
|
+
console.log("[onramp] Calling onComplete from widget handlers")
|
|
95
|
+
onComplete(transferData)
|
|
96
|
+
console.log("[onramp] onComplete called successfully")
|
|
97
|
+
} catch (error) {
|
|
98
|
+
console.error("[onramp] Error in onComplete:", error)
|
|
99
|
+
}
|
|
100
|
+
} else {
|
|
101
|
+
console.warn("[onramp] onComplete handler not provided by widget")
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
const configWithApiKey = {
|
|
106
|
+
...normalizedConfig,
|
|
107
|
+
apiKey: apiKey || normalizedConfig?.apiKey,
|
|
108
|
+
hostname: hostname || normalizedConfig?.hostname,
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
return (
|
|
112
|
+
<TrailsOnRampProvider config={configWithApiKey}>
|
|
113
|
+
<MeshConnectFlow
|
|
114
|
+
onBack={handleBack}
|
|
115
|
+
onComplete={handleComplete}
|
|
116
|
+
toTokenSymbol={toTokenSymbol}
|
|
117
|
+
toTokenAmount={toTokenAmount}
|
|
118
|
+
toChainId={toChainId}
|
|
119
|
+
toRecipientAddress={toRecipientAddress}
|
|
120
|
+
toAmountUsd={toAmountUsd}
|
|
121
|
+
selectedExchange={selectedExchange}
|
|
122
|
+
/>
|
|
123
|
+
</TrailsOnRampProvider>
|
|
124
|
+
)
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
factory.trailsOnrampConfig = normalizedConfig
|
|
128
|
+
|
|
129
|
+
return factory
|
|
130
|
+
}
|
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
export * from "./trails-onramp.gen.js"
|
|
2
|
-
|
|
3
1
|
import type { TrailsApi } from "@0xtrails/api"
|
|
4
|
-
|
|
5
|
-
import {
|
|
2
|
+
export type * from "@0xtrails/api/onramp"
|
|
3
|
+
import { TrailsOnrampRpcClient } from "@0xtrails/api/onramp"
|
|
6
4
|
|
|
7
5
|
export interface TrailsOnrampOptions {
|
|
8
6
|
apiKey?: string
|
|
@@ -10,11 +8,11 @@ export interface TrailsOnrampOptions {
|
|
|
10
8
|
hostname?: string
|
|
11
9
|
}
|
|
12
10
|
|
|
13
|
-
export class TrailsOnramp extends
|
|
11
|
+
export class TrailsOnramp extends TrailsOnrampRpcClient {
|
|
14
12
|
static fromTrailsApiClient(client: TrailsApi): TrailsOnramp {
|
|
15
13
|
const hostname = client.getHostname()
|
|
16
14
|
const fetchFn = client.getFetch()
|
|
17
|
-
return new
|
|
15
|
+
return new TrailsOnrampRpcClient(hostname, fetchFn)
|
|
18
16
|
}
|
|
19
17
|
|
|
20
18
|
constructor(apiKey: string, options?: TrailsOnrampOptions) {
|
package/src/paymasterSend.ts
CHANGED
|
@@ -10,7 +10,6 @@ import {
|
|
|
10
10
|
toHex,
|
|
11
11
|
zeroAddress,
|
|
12
12
|
} from "viem"
|
|
13
|
-
import { getChainRpcClient } from "./chains.js"
|
|
14
13
|
import type { UserOperation } from "viem/account-abstraction"
|
|
15
14
|
import {
|
|
16
15
|
createBundlerClient,
|
|
@@ -193,9 +192,6 @@ export async function getPaymasterGaslessTransaction({
|
|
|
193
192
|
recipient: `0x${string}`
|
|
194
193
|
delegatorSmartAccount: ToSimpleSmartAccountReturnType
|
|
195
194
|
}): Promise<{ to: string; data: string; value: string }[]> {
|
|
196
|
-
// Initialize clients
|
|
197
|
-
const publicClient = getChainRpcClient(chain.id)
|
|
198
|
-
|
|
199
195
|
if (!walletClient.account) {
|
|
200
196
|
throw new Error("No account found")
|
|
201
197
|
}
|
|
@@ -205,7 +201,6 @@ export async function getPaymasterGaslessTransaction({
|
|
|
205
201
|
logger.console.log("[trails-sdk] Transfer amount:", amount.toString())
|
|
206
202
|
|
|
207
203
|
const { signature, deadline } = await getPermitSignature({
|
|
208
|
-
publicClient,
|
|
209
204
|
walletClient,
|
|
210
205
|
signer: connectedAccount,
|
|
211
206
|
spender: delegatorSmartAccount.address,
|