0xtrails 0.2.5 → 0.3.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 +2 -0
- package/dist/aave.d.ts.map +1 -1
- package/dist/abortController.d.ts +8 -0
- package/dist/abortController.d.ts.map +1 -0
- package/dist/{ccip-CXlshvBY.js → ccip-BMB3uDZt.js} +1 -1
- package/dist/config.d.ts +0 -5
- package/dist/config.d.ts.map +1 -1
- package/dist/constants.d.ts +4 -4
- package/dist/constants.d.ts.map +1 -1
- package/dist/error.d.ts +4 -1
- package/dist/error.d.ts.map +1 -1
- package/dist/fees.d.ts +19 -0
- package/dist/fees.d.ts.map +1 -0
- package/dist/{index-_QuyGrjU.js → index-QXPUrZVv.js} +48719 -50852
- package/dist/index.d.ts +9 -8
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +811 -784
- package/dist/intentReceiptMonitor.d.ts +24 -0
- package/dist/intentReceiptMonitor.d.ts.map +1 -0
- package/dist/intentReceiptPoller.d.ts +69 -0
- package/dist/intentReceiptPoller.d.ts.map +1 -0
- package/dist/intents.d.ts +15 -11
- package/dist/intents.d.ts.map +1 -1
- package/dist/morpho.d.ts +6 -5
- package/dist/morpho.d.ts.map +1 -1
- package/dist/mutations.d.ts +16 -0
- package/dist/mutations.d.ts.map +1 -0
- package/dist/preconditions.d.ts +5 -4
- package/dist/preconditions.d.ts.map +1 -1
- package/dist/prepareSend.d.ts +7 -258
- package/dist/prepareSend.d.ts.map +1 -1
- package/dist/prices.d.ts +9 -6
- package/dist/prices.d.ts.map +1 -1
- package/dist/sequenceWallet.d.ts +3 -16
- package/dist/sequenceWallet.d.ts.map +1 -1
- package/dist/tokenBalances.d.ts +17 -13
- package/dist/tokenBalances.d.ts.map +1 -1
- package/dist/trails.d.ts +24 -40
- package/dist/trails.d.ts.map +1 -1
- package/dist/transactionIntent/constants.d.ts +7 -0
- package/dist/transactionIntent/constants.d.ts.map +1 -0
- package/dist/transactionIntent/deposits/depositOrchestrator.d.ts +44 -0
- package/dist/transactionIntent/deposits/depositOrchestrator.d.ts.map +1 -0
- package/dist/transactionIntent/deposits/gaslessDeposit.d.ts +30 -0
- package/dist/transactionIntent/deposits/gaslessDeposit.d.ts.map +1 -0
- package/dist/transactionIntent/deposits/index.d.ts +4 -0
- package/dist/transactionIntent/deposits/index.d.ts.map +1 -0
- package/dist/transactionIntent/deposits/standardDeposit.d.ts +30 -0
- package/dist/transactionIntent/deposits/standardDeposit.d.ts.map +1 -0
- package/dist/transactionIntent/execution/index.d.ts +2 -0
- package/dist/transactionIntent/execution/index.d.ts.map +1 -0
- package/dist/transactionIntent/execution/transactionState.d.ts +5 -0
- package/dist/transactionIntent/execution/transactionState.d.ts.map +1 -0
- package/dist/transactionIntent/handlers/crossChain.d.ts +82 -0
- package/dist/transactionIntent/handlers/crossChain.d.ts.map +1 -0
- package/dist/transactionIntent/handlers/index.d.ts +4 -0
- package/dist/transactionIntent/handlers/index.d.ts.map +1 -0
- package/dist/transactionIntent/handlers/sameChainDifferentToken.d.ts +62 -0
- package/dist/transactionIntent/handlers/sameChainDifferentToken.d.ts.map +1 -0
- package/dist/transactionIntent/handlers/sameChainSameToken.d.ts +72 -0
- package/dist/transactionIntent/handlers/sameChainSameToken.d.ts.map +1 -0
- package/dist/transactionIntent/index.d.ts +9 -0
- package/dist/transactionIntent/index.d.ts.map +1 -0
- package/dist/transactionIntent/quote/feeExtractors.d.ts +17 -0
- package/dist/transactionIntent/quote/feeExtractors.d.ts.map +1 -0
- package/dist/transactionIntent/quote/index.d.ts +4 -0
- package/dist/transactionIntent/quote/index.d.ts.map +1 -0
- package/dist/transactionIntent/quote/normalizeQuote.d.ts +34 -0
- package/dist/transactionIntent/quote/normalizeQuote.d.ts.map +1 -0
- package/dist/transactionIntent/quote/quoteHelpers.d.ts +5 -0
- package/dist/transactionIntent/quote/quoteHelpers.d.ts.map +1 -0
- package/dist/transactionIntent/types.d.ts +131 -0
- package/dist/transactionIntent/types.d.ts.map +1 -0
- package/dist/transactionIntent/utils/balanceChecker.d.ts +18 -0
- package/dist/transactionIntent/utils/balanceChecker.d.ts.map +1 -0
- package/dist/transactionIntent/utils/index.d.ts +4 -0
- package/dist/transactionIntent/utils/index.d.ts.map +1 -0
- package/dist/transactionIntent/utils/lifiHelpers.d.ts +10 -0
- package/dist/transactionIntent/utils/lifiHelpers.d.ts.map +1 -0
- package/dist/transactionIntent/utils/testnetHelpers.d.ts +3 -0
- package/dist/transactionIntent/utils/testnetHelpers.d.ts.map +1 -0
- package/dist/transactionIntent/validators.d.ts +6 -0
- package/dist/transactionIntent/validators.d.ts.map +1 -0
- package/dist/transactions.d.ts +6 -3
- package/dist/transactions.d.ts.map +1 -1
- package/dist/widget/components/AccountIntentTransactionHistoryButton.d.ts +4 -0
- package/dist/widget/components/AccountIntentTransactionHistoryButton.d.ts.map +1 -0
- package/dist/widget/components/AccountSettings.d.ts.map +1 -1
- package/dist/widget/components/ChainFilterDropdown.d.ts.map +1 -1
- package/dist/widget/components/ClassicSwap.d.ts +2 -3
- package/dist/widget/components/ClassicSwap.d.ts.map +1 -1
- package/dist/widget/components/ConfigDisplay.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/DynamicInputStyles.d.ts +18 -0
- package/dist/widget/components/DynamicInputStyles.d.ts.map +1 -0
- package/dist/widget/components/DynamicSizeInputField.d.ts +13 -0
- package/dist/widget/components/DynamicSizeInputField.d.ts.map +1 -0
- package/dist/widget/components/Earn.d.ts +2 -3
- package/dist/widget/components/Earn.d.ts.map +1 -1
- package/dist/widget/components/ErrorAnimationIcon.d.ts +2 -0
- package/dist/widget/components/ErrorAnimationIcon.d.ts.map +1 -0
- package/dist/widget/components/FeeBreakdown.d.ts +9 -0
- package/dist/widget/components/FeeBreakdown.d.ts.map +1 -0
- package/dist/widget/components/FeeOptions.d.ts +5 -13
- package/dist/widget/components/FeeOptions.d.ts.map +1 -1
- package/dist/widget/components/Fund.d.ts +2 -3
- package/dist/widget/components/Fund.d.ts.map +1 -1
- package/dist/widget/components/FundMethods.d.ts.map +1 -1
- package/dist/widget/components/FundSwap.d.ts +2 -3
- package/dist/widget/components/FundSwap.d.ts.map +1 -1
- package/dist/widget/components/FundingMethodSelectorButton.d.ts.map +1 -1
- package/dist/widget/components/Identicon.d.ts.map +1 -1
- package/dist/widget/components/MeshConnectExchanges.d.ts +0 -3
- package/dist/widget/components/MeshConnectExchanges.d.ts.map +1 -1
- package/dist/widget/components/Modal.d.ts.map +1 -1
- package/dist/widget/components/Pay.d.ts +2 -3
- package/dist/widget/components/Pay.d.ts.map +1 -1
- package/dist/widget/components/PoolDeposit.d.ts +3 -3
- package/dist/widget/components/PoolDeposit.d.ts.map +1 -1
- package/dist/widget/components/PoolWithdraw.d.ts +3 -20
- package/dist/widget/components/PoolWithdraw.d.ts.map +1 -1
- package/dist/widget/components/QuoteDetails.d.ts +2 -0
- package/dist/widget/components/QuoteDetails.d.ts.map +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/ScreenHeader.d.ts.map +1 -1
- package/dist/widget/components/Swap.d.ts +2 -3
- package/dist/widget/components/Swap.d.ts.map +1 -1
- package/dist/widget/components/ThemeProvider.d.ts.map +1 -1
- package/dist/widget/components/TokenDisplayNonSelectable.d.ts +11 -0
- package/dist/widget/components/TokenDisplayNonSelectable.d.ts.map +1 -0
- package/dist/widget/components/TokenSelector.d.ts.map +1 -1
- package/dist/widget/components/TokenSelectorButton.d.ts.map +1 -1
- package/dist/widget/components/Tooltip.d.ts +9 -0
- package/dist/widget/components/Tooltip.d.ts.map +1 -0
- package/dist/widget/components/TransferPendingVertical.d.ts.map +1 -1
- package/dist/widget/components/WaasFeeOptions.d.ts +1 -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/css/compiled.css +2 -2
- package/dist/widget/hooks/useCheckout.d.ts +17 -4
- package/dist/widget/hooks/useCheckout.d.ts.map +1 -1
- package/dist/widget/hooks/useDefaultTokenSelection.d.ts.map +1 -1
- package/dist/widget/hooks/useQuote.d.ts +82 -0
- package/dist/widget/hooks/useQuote.d.ts.map +1 -0
- package/dist/widget/hooks/useSelectedFeeToken.d.ts +1 -0
- package/dist/widget/hooks/useSelectedFeeToken.d.ts.map +1 -1
- package/dist/widget/hooks/useSendForm.d.ts +5 -6
- package/dist/widget/hooks/useSendForm.d.ts.map +1 -1
- package/dist/widget/hooks/useTokenList.d.ts.map +1 -1
- package/dist/widget/hooks/useWalletConnectionContext.d.ts +25 -0
- package/dist/widget/hooks/useWalletConnectionContext.d.ts.map +1 -0
- package/dist/widget/index.js +2 -2
- package/dist/widget/widget.d.ts +17 -7
- package/dist/widget/widget.d.ts.map +1 -1
- package/package.json +19 -21
- package/src/aave.ts +54 -1
- package/src/abortController.ts +35 -0
- package/src/config.ts +57 -58
- package/src/constants.ts +11 -9
- package/src/error.ts +21 -3
- package/src/fees.ts +210 -0
- package/src/index.ts +35 -13
- package/src/intentReceiptMonitor.ts +102 -0
- package/src/intentReceiptPoller.ts +299 -0
- package/src/intents.ts +205 -171
- package/src/morpho.ts +58 -9
- package/src/mutations.ts +129 -0
- package/src/preconditions.ts +16 -21
- package/src/prepareSend.ts +92 -4699
- package/src/prices.ts +26 -22
- package/src/relaySdk.ts +2 -2
- package/src/sequenceWallet.ts +6 -73
- package/src/tokenBalances.ts +175 -69
- package/src/trails.ts +230 -722
- package/src/transactionIntent/constants.ts +11 -0
- package/src/transactionIntent/deposits/depositOrchestrator.ts +210 -0
- package/src/transactionIntent/deposits/gaslessDeposit.ts +588 -0
- package/src/transactionIntent/deposits/index.ts +3 -0
- package/src/transactionIntent/deposits/standardDeposit.ts +379 -0
- package/src/transactionIntent/execution/index.ts +1 -0
- package/src/transactionIntent/execution/transactionState.ts +35 -0
- package/src/transactionIntent/handlers/crossChain.ts +1707 -0
- package/src/transactionIntent/handlers/index.ts +3 -0
- package/src/transactionIntent/handlers/sameChainDifferentToken.ts +323 -0
- package/src/transactionIntent/handlers/sameChainSameToken.ts +712 -0
- package/src/transactionIntent/index.ts +9 -0
- package/src/transactionIntent/quote/feeExtractors.ts +81 -0
- package/src/transactionIntent/quote/index.ts +3 -0
- package/src/transactionIntent/quote/normalizeQuote.ts +367 -0
- package/src/transactionIntent/quote/quoteHelpers.ts +53 -0
- package/src/transactionIntent/types.ts +157 -0
- package/src/transactionIntent/utils/balanceChecker.ts +96 -0
- package/src/transactionIntent/utils/index.ts +3 -0
- package/src/transactionIntent/utils/lifiHelpers.ts +68 -0
- package/src/transactionIntent/utils/testnetHelpers.ts +10 -0
- package/src/transactionIntent/validators.ts +57 -0
- package/src/transactions.ts +98 -71
- package/src/widget/compiled.css +2 -2
- package/src/widget/components/AccountIntentTransactionHistory.tsx +36 -36
- package/src/widget/components/AccountIntentTransactionHistoryButton.tsx +22 -0
- package/src/widget/components/AccountSettings.tsx +70 -41
- package/src/widget/components/ChainFilterDropdown.tsx +24 -3
- package/src/widget/components/ClassicSwap.tsx +44 -107
- package/src/widget/components/ConfigDisplay.tsx +0 -11
- package/src/widget/components/ConnectWallet.tsx +4 -1
- package/src/widget/components/ConnectedWallets.tsx +51 -25
- package/src/widget/components/DynamicInputStyles.tsx +76 -0
- package/src/widget/components/DynamicSizeInputField.tsx +109 -0
- package/src/widget/components/Earn.tsx +34 -45
- package/src/widget/components/ErrorAnimationIcon.tsx +130 -0
- package/src/widget/components/FeeBreakdown.tsx +155 -0
- package/src/widget/components/FeeOption.tsx +2 -2
- package/src/widget/components/FeeOptions.tsx +151 -112
- package/src/widget/components/Fund.tsx +10 -29
- package/src/widget/components/FundMethods.tsx +4 -3
- package/src/widget/components/FundSwap.tsx +2 -3
- package/src/widget/components/FundingMethodSelectorButton.tsx +24 -14
- package/src/widget/components/Identicon.tsx +164 -95
- package/src/widget/components/MeshConnectExchanges.tsx +2 -15
- package/src/widget/components/Modal.tsx +0 -12
- package/src/widget/components/Pay.tsx +72 -75
- package/src/widget/components/PoolDeposit.tsx +221 -242
- package/src/widget/components/PoolWithdraw.tsx +347 -469
- package/src/widget/components/PriceImpactWarning.tsx +1 -1
- package/src/widget/components/QuoteDetails.tsx +906 -484
- package/src/widget/components/Receipt.tsx +16 -2
- package/src/widget/components/RecipientSelectorButton.tsx +7 -5
- package/src/widget/components/Recipients.tsx +1 -1
- package/src/widget/components/ScreenHeader.tsx +60 -36
- package/src/widget/components/Swap.tsx +2 -3
- package/src/widget/components/ThemeProvider.tsx +2 -1
- package/src/widget/components/TokenDisplayNonSelectable.tsx +40 -0
- package/src/widget/components/TokenImage.tsx +1 -1
- package/src/widget/components/TokenSelector.tsx +62 -53
- package/src/widget/components/TokenSelectorButton.tsx +38 -15
- package/src/widget/components/Tooltip.tsx +51 -0
- package/src/widget/components/TransferPendingVertical.tsx +12 -8
- package/src/widget/components/WaasFeeOptions.tsx +139 -4
- package/src/widget/components/WalletConfirmation.tsx +23 -13
- package/src/widget/components/WalletConnect.tsx +93 -29
- package/src/widget/hooks/useAmountUsd.ts +9 -9
- package/src/widget/hooks/useCheckout.ts +97 -9
- package/src/widget/hooks/useDefaultTokenSelection.tsx +27 -21
- package/src/widget/hooks/useQuote.ts +466 -0
- package/src/widget/hooks/useSelectedFeeToken.tsx +32 -37
- package/src/widget/hooks/useSendForm.ts +45 -51
- package/src/widget/hooks/useTokenList.ts +34 -26
- package/src/widget/hooks/useWalletConnectionContext.tsx +128 -0
- package/src/widget/widget.tsx +365 -390
- package/dist/apiClient.d.ts +0 -9
- package/dist/apiClient.d.ts.map +0 -1
- package/dist/intentEntrypoint.d.ts +0 -114
- package/dist/intentEntrypoint.d.ts.map +0 -1
- package/dist/metaTxnMonitor.d.ts +0 -15
- package/dist/metaTxnMonitor.d.ts.map +0 -1
- package/dist/metaTxns.d.ts +0 -11
- package/dist/metaTxns.d.ts.map +0 -1
- package/dist/relayer.d.ts +0 -43
- package/dist/relayer.d.ts.map +0 -1
- package/src/apiClient.ts +0 -35
- package/src/intentEntrypoint.ts +0 -203
- package/src/metaTxnMonitor.ts +0 -171
- package/src/metaTxns.ts +0 -45
- package/src/relayer.ts +0 -289
|
@@ -36,12 +36,14 @@ import { TokenSelectorButton } from "./TokenSelectorButton.js"
|
|
|
36
36
|
import { RequiredPropsError } from "./RequiredPropsError.js"
|
|
37
37
|
import { FundingMethodSelectorButton } from "./FundingMethodSelectorButton.js"
|
|
38
38
|
import { PercentageMaxButtons } from "./PercentageMaxButtons.js"
|
|
39
|
+
import { useDynamicInputStyles } from "./DynamicInputStyles.js"
|
|
40
|
+
import { DynamicSizeInputField } from "./DynamicSizeInputField.js"
|
|
39
41
|
|
|
40
42
|
interface PayProps {
|
|
41
43
|
selectedToken?: any // Origin token (optional - user can select)
|
|
42
44
|
onBack?: () => void
|
|
43
|
-
account
|
|
44
|
-
walletClient
|
|
45
|
+
account?: Account
|
|
46
|
+
walletClient?: WalletClient
|
|
45
47
|
onTransactionStateChange: (transactionStates: TransactionState[]) => void
|
|
46
48
|
onError: (error: Error | string | null) => void
|
|
47
49
|
onWaitingForWalletConfirm: (props: PrepareSendQuote) => void
|
|
@@ -49,7 +51,6 @@ interface PayProps {
|
|
|
49
51
|
onComplete: (result: OnCompleteProps) => void
|
|
50
52
|
onSend: (amount: string, recipient: string) => void
|
|
51
53
|
paymasterUrls?: Array<{ chainId: number; url: string }>
|
|
52
|
-
gasless?: boolean
|
|
53
54
|
isSequenceWallet?: boolean
|
|
54
55
|
setWalletConfirmRetryHandler: (handler: () => Promise<void>) => void
|
|
55
56
|
quoteProvider?: string
|
|
@@ -87,7 +88,6 @@ export const Pay: React.FC<PayProps> = ({
|
|
|
87
88
|
onComplete,
|
|
88
89
|
onSend,
|
|
89
90
|
paymasterUrls,
|
|
90
|
-
gasless,
|
|
91
91
|
isSequenceWallet = false,
|
|
92
92
|
setWalletConfirmRetryHandler,
|
|
93
93
|
quoteProvider,
|
|
@@ -162,6 +162,19 @@ export const Pay: React.FC<PayProps> = ({
|
|
|
162
162
|
)
|
|
163
163
|
}, [originToken, filteredTokensFormatted])
|
|
164
164
|
|
|
165
|
+
// Calculate effective recipient for useSendForm
|
|
166
|
+
const effectiveRecipient = useMemo(() => {
|
|
167
|
+
const recipient = selectedRecipient || toRecipient || account?.address
|
|
168
|
+
logger.console.log("[trails-sdk] Effective recipient calculated:", {
|
|
169
|
+
selectedRecipient,
|
|
170
|
+
toRecipient,
|
|
171
|
+
accountAddress: account?.address,
|
|
172
|
+
effectiveRecipient: recipient,
|
|
173
|
+
willPassToUseSendForm: recipient,
|
|
174
|
+
})
|
|
175
|
+
return recipient
|
|
176
|
+
}, [selectedRecipient, toRecipient, account?.address])
|
|
177
|
+
|
|
165
178
|
// Use useSendForm for quote functionality with EXACT_OUTPUT trade type
|
|
166
179
|
const {
|
|
167
180
|
amountUsdDisplay,
|
|
@@ -187,7 +200,7 @@ export const Pay: React.FC<PayProps> = ({
|
|
|
187
200
|
} = useSendForm({
|
|
188
201
|
account,
|
|
189
202
|
toAmount: tokenAmountForBackend || toAmount, // Use the input amount as target amount for EXACT_OUTPUT
|
|
190
|
-
toRecipient:
|
|
203
|
+
toRecipient: effectiveRecipient,
|
|
191
204
|
toChainId,
|
|
192
205
|
toToken,
|
|
193
206
|
toCalldata,
|
|
@@ -196,7 +209,6 @@ export const Pay: React.FC<PayProps> = ({
|
|
|
196
209
|
onError,
|
|
197
210
|
onWaitingForWalletConfirm,
|
|
198
211
|
paymasterUrls,
|
|
199
|
-
gasless,
|
|
200
212
|
onConfirm,
|
|
201
213
|
onComplete,
|
|
202
214
|
onSend,
|
|
@@ -288,15 +300,31 @@ export const Pay: React.FC<PayProps> = ({
|
|
|
288
300
|
setSelectedDestinationChain,
|
|
289
301
|
])
|
|
290
302
|
|
|
291
|
-
// Initialize selected recipient from toRecipient prop or default to connected wallet
|
|
303
|
+
// Initialize and update selected recipient from toRecipient prop or default to connected wallet
|
|
304
|
+
// biome-ignore lint/correctness/useExhaustiveDependencies: selectedRecipient is intentionally excluded to avoid infinite loops
|
|
292
305
|
useEffect(() => {
|
|
293
|
-
|
|
306
|
+
logger.console.log("[trails-sdk] toRecipient prop effect:", {
|
|
307
|
+
toRecipient,
|
|
308
|
+
selectedRecipient,
|
|
309
|
+
accountAddress: account?.address,
|
|
310
|
+
})
|
|
311
|
+
|
|
312
|
+
if (toRecipient) {
|
|
313
|
+
// Always sync with toRecipient prop when it changes
|
|
314
|
+
logger.console.log(
|
|
315
|
+
"[trails-sdk] Setting selectedRecipient to toRecipient:",
|
|
316
|
+
toRecipient,
|
|
317
|
+
)
|
|
294
318
|
setSelectedRecipient(toRecipient)
|
|
295
319
|
} else if (!selectedRecipient && account?.address) {
|
|
296
320
|
// Default to connected wallet address if no recipient is set
|
|
321
|
+
logger.console.log(
|
|
322
|
+
"[trails-sdk] Setting selectedRecipient to account address:",
|
|
323
|
+
account.address,
|
|
324
|
+
)
|
|
297
325
|
setSelectedRecipient(account.address)
|
|
298
326
|
}
|
|
299
|
-
}, [toRecipient,
|
|
327
|
+
}, [toRecipient, setSelectedRecipient, account?.address])
|
|
300
328
|
|
|
301
329
|
// Initialize and update amount from toAmount prop
|
|
302
330
|
useEffect(() => {
|
|
@@ -425,50 +453,7 @@ export const Pay: React.FC<PayProps> = ({
|
|
|
425
453
|
}, [inputDisplayValue])
|
|
426
454
|
|
|
427
455
|
// Dynamic font size based on input length for destination amount
|
|
428
|
-
const inputStyles =
|
|
429
|
-
const inputLength = displayAmount.length
|
|
430
|
-
let fontSize: string
|
|
431
|
-
|
|
432
|
-
if (inputLength > 12) {
|
|
433
|
-
fontSize = "1rem"
|
|
434
|
-
} else if (inputLength > 9) {
|
|
435
|
-
fontSize = "1.25rem"
|
|
436
|
-
} else if (inputLength > 6) {
|
|
437
|
-
fontSize = "1.5rem"
|
|
438
|
-
} else if (inputLength > 3) {
|
|
439
|
-
fontSize = "1.75rem"
|
|
440
|
-
} else {
|
|
441
|
-
fontSize = "2rem"
|
|
442
|
-
}
|
|
443
|
-
|
|
444
|
-
return {
|
|
445
|
-
fontSize,
|
|
446
|
-
transition: "all 0.1s ease-in-out",
|
|
447
|
-
}
|
|
448
|
-
}, [displayAmount.length])
|
|
449
|
-
|
|
450
|
-
// Dynamic font size based on input length for origin amount (Pay with section)
|
|
451
|
-
const originInputStyles = useMemo(() => {
|
|
452
|
-
const inputLength = (prepareSendQuote?.originAmountFormatted || "").length
|
|
453
|
-
let fontSize: string
|
|
454
|
-
|
|
455
|
-
if (inputLength > 12) {
|
|
456
|
-
fontSize = "1rem"
|
|
457
|
-
} else if (inputLength > 9) {
|
|
458
|
-
fontSize = "1.25rem"
|
|
459
|
-
} else if (inputLength > 6) {
|
|
460
|
-
fontSize = "1.5rem"
|
|
461
|
-
} else if (inputLength > 3) {
|
|
462
|
-
fontSize = "1.75rem"
|
|
463
|
-
} else {
|
|
464
|
-
fontSize = "2rem"
|
|
465
|
-
}
|
|
466
|
-
|
|
467
|
-
return {
|
|
468
|
-
fontSize,
|
|
469
|
-
transition: "all 0.1s ease-in-out",
|
|
470
|
-
}
|
|
471
|
-
}, [prepareSendQuote?.originAmountFormatted])
|
|
456
|
+
const inputStyles = useDynamicInputStyles({ inputValue: displayAmount })
|
|
472
457
|
|
|
473
458
|
const handleOriginTokenSelect = useCallback(
|
|
474
459
|
(token: any) => {
|
|
@@ -649,7 +634,7 @@ export const Pay: React.FC<PayProps> = ({
|
|
|
649
634
|
const missingRequiredProps = []
|
|
650
635
|
if (!toAmount) missingRequiredProps.push("toAmount")
|
|
651
636
|
if (!toToken) missingRequiredProps.push("toToken")
|
|
652
|
-
if (!toRecipient) missingRequiredProps.push("
|
|
637
|
+
if (!toRecipient) missingRequiredProps.push("toAddress")
|
|
653
638
|
|
|
654
639
|
// Check if this is a payment request (all required props are set)
|
|
655
640
|
const isPaymentRequest = !!(toToken && toAmount && toChainId && toRecipient)
|
|
@@ -694,11 +679,11 @@ export const Pay: React.FC<PayProps> = ({
|
|
|
694
679
|
</div>
|
|
695
680
|
|
|
696
681
|
{/* Origin Token Selection for Payment Request */}
|
|
697
|
-
<div className="
|
|
698
|
-
<div className="
|
|
682
|
+
<div className="mb-4">
|
|
683
|
+
<div className="pt-4 pb-4 trails-bg-secondary trails-border-radius-container p-3 group transition-all duration-200 border border-transparent min-h-[120px] flex flex-col">
|
|
699
684
|
{/* Amount to Pay Label */}
|
|
700
|
-
<div className="flex justify-between items-center
|
|
701
|
-
<div className="text-sm font-medium trails-text-secondary text-left">
|
|
685
|
+
<div className="mb-4 flex justify-between items-center">
|
|
686
|
+
<div className="text-sm font-medium trails-text-secondary text-left m-0">
|
|
702
687
|
Pay with
|
|
703
688
|
{fundMethod === "qr-code"
|
|
704
689
|
? " QR Code"
|
|
@@ -713,16 +698,12 @@ export const Pay: React.FC<PayProps> = ({
|
|
|
713
698
|
{/* Amount Display - Non-editable */}
|
|
714
699
|
<div className="flex-1">
|
|
715
700
|
<div className="flex items-center space-x-2">
|
|
716
|
-
<
|
|
701
|
+
<DynamicSizeInputField
|
|
717
702
|
ref={paymentRequestInputRef}
|
|
718
|
-
type="text"
|
|
719
703
|
value={prepareSendQuote?.originAmountFormatted || ""}
|
|
720
|
-
placeholder={`0 ${originToken?.symbol || ""}`.trim()}
|
|
721
704
|
readOnly={true}
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
}`}
|
|
725
|
-
style={originInputStyles}
|
|
705
|
+
isLoading={isLoadingQuote}
|
|
706
|
+
variant="default"
|
|
726
707
|
/>
|
|
727
708
|
{isLoadingQuote && (
|
|
728
709
|
<div className="animate-spin rounded-full h-4 w-4 border-solid border-b-2 trails-primary" />
|
|
@@ -741,9 +722,9 @@ export const Pay: React.FC<PayProps> = ({
|
|
|
741
722
|
</div>
|
|
742
723
|
|
|
743
724
|
{/* Bottom Info Row */}
|
|
744
|
-
<div className="mt-
|
|
725
|
+
<div className="mt-4 flex justify-between items-center">
|
|
745
726
|
{/* USD Amount */}
|
|
746
|
-
<div className="text-xs
|
|
727
|
+
<div className="text-xs text-gray-500 dark:text-gray-400">
|
|
747
728
|
{originToken?.symbol &&
|
|
748
729
|
prepareSendQuote?.originAmountFormatted ? (
|
|
749
730
|
<>≈ {prepareSendQuote?.originAmountUsdDisplay || "$0.00"}</>
|
|
@@ -757,7 +738,7 @@ export const Pay: React.FC<PayProps> = ({
|
|
|
757
738
|
<div className="flex items-center space-x-2">
|
|
758
739
|
<button
|
|
759
740
|
type="button"
|
|
760
|
-
className="text-xs
|
|
741
|
+
className="text-xs text-gray-500 dark:text-gray-400 cursor-pointer hover:text-gray-700 dark:hover:text-gray-200 transition-colors bg-transparent border-none p-0"
|
|
761
742
|
onClick={() => {
|
|
762
743
|
if (originTokenBalance.balanceFormatted) {
|
|
763
744
|
const balance = parseFloat(
|
|
@@ -933,10 +914,16 @@ export const Pay: React.FC<PayProps> = ({
|
|
|
933
914
|
|
|
934
915
|
<div className="space-y-1">
|
|
935
916
|
{/* Destination Amount Input Section - Like Fund.tsx but for destination token */}
|
|
936
|
-
<div
|
|
917
|
+
<div
|
|
918
|
+
className={`pt-4 pb-4 trails-bg-secondary trails-border-radius-container p-3 group transition-all duration-200 border border-transparent min-h-[120px] flex flex-col ${
|
|
919
|
+
!toAmount
|
|
920
|
+
? "trails-bg-secondary-hover focus-within:!bg-white dark:focus-within:!bg-gray-800 trails-focus-border-secondary"
|
|
921
|
+
: ""
|
|
922
|
+
}`}
|
|
923
|
+
>
|
|
937
924
|
{/* Amount to Pay Label */}
|
|
938
|
-
<div className="flex justify-between items-center
|
|
939
|
-
<div className="text-sm font-medium trails-text-secondary text-left">
|
|
925
|
+
<div className="mb-4 flex justify-between items-center">
|
|
926
|
+
<div className="text-sm font-medium trails-text-secondary text-left m-0">
|
|
940
927
|
Recipient receives
|
|
941
928
|
</div>
|
|
942
929
|
<FundingMethodSelectorButton />
|
|
@@ -953,6 +940,7 @@ export const Pay: React.FC<PayProps> = ({
|
|
|
953
940
|
onChange={(e) => handleAmountChange(e.target.value)}
|
|
954
941
|
placeholder={`0 ${selectedDestToken?.symbol || ""}`}
|
|
955
942
|
readOnly={!!toAmount}
|
|
943
|
+
autoComplete="off"
|
|
956
944
|
className={`w-full bg-transparent font-bold trails-text-primary placeholder:trails-text-muted border-none outline-none ${
|
|
957
945
|
isLoadingQuote ? "animate-pulse" : ""
|
|
958
946
|
}`}
|
|
@@ -976,9 +964,9 @@ export const Pay: React.FC<PayProps> = ({
|
|
|
976
964
|
</div>
|
|
977
965
|
|
|
978
966
|
{/* Bottom Info Row */}
|
|
979
|
-
<div className="mt-
|
|
967
|
+
<div className="mt-4 flex justify-between items-center">
|
|
980
968
|
{/* USD Amount */}
|
|
981
|
-
<div className="text-xs
|
|
969
|
+
<div className="text-xs text-gray-500 dark:text-gray-400">
|
|
982
970
|
{selectedDestToken?.symbol && displayAmount ? (
|
|
983
971
|
<>≈ {amountUsdDisplay || "$0.00"}</>
|
|
984
972
|
) : (
|
|
@@ -1036,12 +1024,17 @@ export const Pay: React.FC<PayProps> = ({
|
|
|
1036
1024
|
selectedFeeToken={selectedFeeToken}
|
|
1037
1025
|
setSelectedFeeToken={(token) => setSelectedFeeToken(token as any)}
|
|
1038
1026
|
chainId={originToken?.chainId}
|
|
1027
|
+
isRefetching={isLoadingQuote}
|
|
1039
1028
|
/>
|
|
1040
1029
|
|
|
1041
1030
|
{/* Quote Details */}
|
|
1042
1031
|
{prepareSendQuote && (
|
|
1043
|
-
<div className="
|
|
1044
|
-
<QuoteDetails
|
|
1032
|
+
<div className="mb-4">
|
|
1033
|
+
<QuoteDetails
|
|
1034
|
+
quote={prepareSendQuote}
|
|
1035
|
+
showContent={true}
|
|
1036
|
+
isRefetching={isLoadingQuote}
|
|
1037
|
+
/>
|
|
1045
1038
|
</div>
|
|
1046
1039
|
)}
|
|
1047
1040
|
|
|
@@ -1067,10 +1060,14 @@ export const Pay: React.FC<PayProps> = ({
|
|
|
1067
1060
|
<Loader2 className="w-5 h-5 animate-spin mr-2" />
|
|
1068
1061
|
<span>{buttonText}</span>
|
|
1069
1062
|
</div>
|
|
1063
|
+
) : !account?.address ? (
|
|
1064
|
+
"Connect your wallet"
|
|
1070
1065
|
) : prepareSendQuote?.noSufficientBalance ? (
|
|
1071
1066
|
"Insufficient Balance"
|
|
1072
1067
|
) : !selectedRecipient ? (
|
|
1073
1068
|
"Select recipient address"
|
|
1069
|
+
) : !originToken ? (
|
|
1070
|
+
"Select payment token"
|
|
1074
1071
|
) : !selectedDestToken ? (
|
|
1075
1072
|
"Select destination token"
|
|
1076
1073
|
) : !tokenAmountForBackend ||
|