0xtrails 0.2.0 → 0.2.1
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/analytics.d.ts +1 -0
- package/dist/analytics.d.ts.map +1 -1
- package/dist/{ccip-D6ToCrWc.js → ccip-BbfANth7.js} +1 -1
- package/dist/chains.d.ts.map +1 -1
- package/dist/config.d.ts +1 -2
- package/dist/config.d.ts.map +1 -1
- package/dist/constants.d.ts +2 -2
- package/dist/constants.d.ts.map +1 -1
- package/dist/gasless.d.ts +19 -7
- package/dist/gasless.d.ts.map +1 -1
- package/dist/{index-BqgeTLL8.js → index-WpIVoh3X.js} +27626 -26572
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +68 -68
- package/dist/indexerClient.d.ts +10 -0
- package/dist/indexerClient.d.ts.map +1 -1
- package/dist/intentEntrypoint.d.ts +40 -14
- package/dist/intentEntrypoint.d.ts.map +1 -1
- package/dist/intents.d.ts.map +1 -1
- package/dist/prepareSend.d.ts +11 -8
- package/dist/prepareSend.d.ts.map +1 -1
- package/dist/relayer.d.ts.map +1 -1
- package/dist/trails.d.ts.map +1 -1
- package/dist/trailsClient.d.ts.map +1 -1
- package/dist/trailsRouter.d.ts +22 -0
- package/dist/trailsRouter.d.ts.map +1 -0
- package/dist/transactions.d.ts +0 -1
- package/dist/transactions.d.ts.map +1 -1
- package/dist/widget/components/AccountSettings.d.ts.map +1 -1
- 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/Earn.d.ts.map +1 -1
- package/dist/widget/components/FeeOption.d.ts +22 -0
- package/dist/widget/components/FeeOption.d.ts.map +1 -0
- package/dist/widget/components/FeeOptions.d.ts +13 -17
- package/dist/widget/components/FeeOptions.d.ts.map +1 -1
- package/dist/widget/components/Fund.d.ts.map +1 -1
- package/dist/widget/components/FundMethods.d.ts +1 -1
- package/dist/widget/components/FundMethods.d.ts.map +1 -1
- package/dist/widget/components/FundSendForm.d.ts.map +1 -1
- package/dist/widget/components/MeshConnectExchanges.d.ts +5 -2
- package/dist/widget/components/MeshConnectExchanges.d.ts.map +1 -1
- package/dist/widget/components/MeshConnectFlow.d.ts +2 -0
- package/dist/widget/components/MeshConnectFlow.d.ts.map +1 -1
- package/dist/widget/components/NativeGasOption.d.ts +12 -0
- package/dist/widget/components/NativeGasOption.d.ts.map +1 -0
- package/dist/widget/components/Pay.d.ts.map +1 -1
- package/dist/widget/components/PaySendForm.d.ts.map +1 -1
- package/dist/widget/components/QuoteDetails.d.ts.map +1 -1
- package/dist/widget/components/TokenSelector.d.ts.map +1 -1
- package/dist/widget/components/UserPreferences.d.ts.map +1 -1
- package/dist/widget/hooks/useBack.d.ts +2 -0
- package/dist/widget/hooks/useBack.d.ts.map +1 -1
- package/dist/widget/hooks/useCurrentScreen.d.ts +1 -1
- package/dist/widget/hooks/useCurrentScreen.d.ts.map +1 -1
- package/dist/widget/hooks/useDefaultTokenSelection.d.ts.map +1 -1
- package/dist/widget/hooks/useSelectedFeeToken.d.ts +32 -0
- package/dist/widget/hooks/useSelectedFeeToken.d.ts.map +1 -0
- package/dist/widget/hooks/useSelectedMeshExchange.d.ts +14 -0
- package/dist/widget/hooks/useSelectedMeshExchange.d.ts.map +1 -0
- package/dist/widget/hooks/useSendForm.d.ts +8 -13
- package/dist/widget/hooks/useSendForm.d.ts.map +1 -1
- package/dist/widget/index.js +1 -1
- package/dist/widget/widget.d.ts.map +1 -1
- package/package.json +29 -28
- package/src/analytics.ts +6 -0
- package/src/chains.ts +10 -0
- package/src/config.ts +25 -10
- package/src/constants.ts +11 -10
- package/src/gasless.ts +162 -109
- package/src/index.ts +1 -1
- package/src/indexerClient.ts +73 -1
- package/src/intentEntrypoint.ts +66 -101
- package/src/intents.ts +0 -2
- package/src/prepareSend.ts +1409 -887
- package/src/relayer.ts +4 -3
- package/src/trails.ts +1 -3
- package/src/trailsClient.ts +4 -1
- package/src/{balanceInjector.ts → trailsRouter.ts} +14 -14
- package/src/transactions.ts +4 -54
- package/src/widget/compiled.css +1 -1
- package/src/widget/components/AccountSettings.tsx +7 -1
- package/src/widget/components/ClassicSwap.tsx +173 -175
- package/src/widget/components/ConfigDisplay.tsx +34 -1
- package/src/widget/components/ConnectWallet.tsx +168 -11
- package/src/widget/components/ConnectedWallets.tsx +184 -102
- package/src/widget/components/DebugToast.tsx +3 -3
- package/src/widget/components/Earn.tsx +4 -27
- package/src/widget/components/FeeOption.tsx +78 -0
- package/src/widget/components/FeeOptions.tsx +192 -127
- package/src/widget/components/Fund.tsx +18 -27
- package/src/widget/components/FundMethods.tsx +3 -3
- package/src/widget/components/FundSendForm.tsx +0 -33
- package/src/widget/components/MeshConnectExchanges.tsx +32 -3
- package/src/widget/components/MeshConnectFlow.tsx +23 -4
- package/src/widget/components/NativeGasOption.tsx +99 -0
- package/src/widget/components/Pay.tsx +36 -32
- package/src/widget/components/PaySendForm.tsx +0 -37
- package/src/widget/components/QuoteDetails.tsx +0 -29
- package/src/widget/components/TokenSelector.tsx +11 -0
- package/src/widget/components/TransferPendingVertical.tsx +1 -1
- package/src/widget/components/UserPreferences.tsx +3 -4
- package/src/widget/hooks/useBack.tsx +4 -0
- package/src/widget/hooks/useCurrentScreen.tsx +1 -0
- package/src/widget/hooks/useDefaultTokenSelection.tsx +3 -7
- package/src/widget/hooks/useSelectedFeeToken.tsx +299 -0
- package/src/widget/hooks/useSelectedMeshExchange.tsx +46 -0
- package/src/widget/hooks/useSendForm.ts +78 -23
- package/src/widget/widget.tsx +173 -111
- package/dist/balanceInjector.d.ts +0 -22
- package/dist/balanceInjector.d.ts.map +0 -1
|
@@ -7,13 +7,10 @@ import type { OnCompleteProps, Token } from "../hooks/useSendForm.js"
|
|
|
7
7
|
import type { SupportedToken } from "../../tokens.js"
|
|
8
8
|
import { useSendForm } from "../hooks/useSendForm.js"
|
|
9
9
|
import type { CheckoutOnHandlers } from "../hooks/useCheckout.js"
|
|
10
|
-
import { FeeOptions } from "./FeeOptions.js"
|
|
11
10
|
import { TokenImage } from "./TokenImage.js"
|
|
12
11
|
import { QuoteDetails } from "./QuoteDetails.js"
|
|
13
12
|
import { type PrepareSendQuote, TradeType } from "../../prepareSend.js"
|
|
14
13
|
import { getChainInfo } from "../../chains.js"
|
|
15
|
-
import { formatUsdAmountDisplay } from "../../tokenBalances.js"
|
|
16
|
-
import { MINIMUM_USD_AMOUNT_FOR_SWAP } from "../../constants.js"
|
|
17
14
|
import { ScreenHeader } from "./ScreenHeader.js"
|
|
18
15
|
import { TokenSelector } from "./TokenSelector.js"
|
|
19
16
|
import { ErrorDisplay } from "./ErrorDisplay.js"
|
|
@@ -24,6 +21,7 @@ import { useOriginSelectedToken } from "../hooks/useOriginSelectedToken.js"
|
|
|
24
21
|
import { useDestinationSelectedToken } from "../hooks/useDestinationSelectedToken.js"
|
|
25
22
|
import { useBalanceVisible } from "../hooks/useBalanceVisible.js"
|
|
26
23
|
import { useDefaultTokenSelection } from "../hooks/useDefaultTokenSelection.js"
|
|
24
|
+
import { ChainList } from "./ChainList.js"
|
|
27
25
|
|
|
28
26
|
interface ClassicSwapProps {
|
|
29
27
|
selectedToken: Token | null
|
|
@@ -86,7 +84,6 @@ export const ClassicSwap: React.FC<ClassicSwapProps> = ({
|
|
|
86
84
|
onAmountUpdate,
|
|
87
85
|
checkoutOnHandlers,
|
|
88
86
|
recentTokens,
|
|
89
|
-
onRecentTokenSelect,
|
|
90
87
|
onTrackToken,
|
|
91
88
|
}) => {
|
|
92
89
|
const { mode } = useMode()
|
|
@@ -122,17 +119,12 @@ export const ClassicSwap: React.FC<ClassicSwapProps> = ({
|
|
|
122
119
|
handleSubmit,
|
|
123
120
|
isSubmitting,
|
|
124
121
|
isLoadingQuote,
|
|
125
|
-
isTokenDropdownOpen,
|
|
126
122
|
selectedDestinationChain,
|
|
127
123
|
selectedDestToken,
|
|
128
124
|
setAmount,
|
|
129
125
|
setSelectedDestinationChain,
|
|
130
126
|
setSelectedDestToken,
|
|
131
127
|
buttonText,
|
|
132
|
-
selectedFeeToken,
|
|
133
|
-
setSelectedFeeToken,
|
|
134
|
-
feeOptions,
|
|
135
|
-
setIsTokenDropdownOpen,
|
|
136
128
|
toAmountDisplay,
|
|
137
129
|
destinationTokenAddress,
|
|
138
130
|
isValidCustomToken,
|
|
@@ -177,6 +169,11 @@ export const ClassicSwap: React.FC<ClassicSwapProps> = ({
|
|
|
177
169
|
|
|
178
170
|
// Handle sell amount input changes with decimal validation
|
|
179
171
|
const handleSellAmountChange = useCallback((value: string) => {
|
|
172
|
+
// Limit total length to 16 characters
|
|
173
|
+
if (value.length > 16) {
|
|
174
|
+
return
|
|
175
|
+
}
|
|
176
|
+
|
|
180
177
|
// Validate decimal places (max 8 decimals)
|
|
181
178
|
const decimalMatch = value.match(/^\d*\.?\d{0,8}$/)
|
|
182
179
|
if (!decimalMatch && value !== "") {
|
|
@@ -190,6 +187,11 @@ export const ClassicSwap: React.FC<ClassicSwapProps> = ({
|
|
|
190
187
|
|
|
191
188
|
// Handle buy amount input changes with decimal validation
|
|
192
189
|
const handleBuyAmountChange = useCallback((value: string) => {
|
|
190
|
+
// Limit total length to 16 characters
|
|
191
|
+
if (value.length > 16) {
|
|
192
|
+
return
|
|
193
|
+
}
|
|
194
|
+
|
|
193
195
|
// Validate decimal places (max 8 decimals)
|
|
194
196
|
const decimalMatch = value.match(/^\d*\.?\d{0,8}$/)
|
|
195
197
|
if (!decimalMatch && value !== "") {
|
|
@@ -299,11 +301,13 @@ export const ClassicSwap: React.FC<ClassicSwapProps> = ({
|
|
|
299
301
|
}
|
|
300
302
|
}, [])
|
|
301
303
|
|
|
302
|
-
const originTokenDropdownRef = useRef<HTMLDivElement>(null)
|
|
303
|
-
const tokenDropdownRef = useRef<HTMLInputElement>(null)
|
|
304
304
|
const inputRef = useRef<HTMLInputElement>(null)
|
|
305
305
|
|
|
306
|
-
const [
|
|
306
|
+
const [showSourceTokenSelector, setShowSourceTokenSelector] = useState(false)
|
|
307
|
+
const [showDestinationTokenSelector, setShowDestinationTokenSelector] =
|
|
308
|
+
useState(false)
|
|
309
|
+
const [showSourceChainList, setShowSourceChainList] = useState(false)
|
|
310
|
+
const [showDestinationChainList, setShowDestinationChainList] =
|
|
307
311
|
useState(false)
|
|
308
312
|
|
|
309
313
|
useEffect(() => {
|
|
@@ -326,28 +330,6 @@ export const ClassicSwap: React.FC<ClassicSwapProps> = ({
|
|
|
326
330
|
}
|
|
327
331
|
}, [destinationToken, setSelectedDestToken])
|
|
328
332
|
|
|
329
|
-
useEffect(() => {
|
|
330
|
-
const handleClickOutside = (event: MouseEvent) => {
|
|
331
|
-
if (
|
|
332
|
-
tokenDropdownRef.current &&
|
|
333
|
-
!tokenDropdownRef.current.contains(event.target as Node)
|
|
334
|
-
) {
|
|
335
|
-
setIsTokenDropdownOpen(false)
|
|
336
|
-
}
|
|
337
|
-
if (
|
|
338
|
-
originTokenDropdownRef.current &&
|
|
339
|
-
!originTokenDropdownRef.current.contains(event.target as Node)
|
|
340
|
-
) {
|
|
341
|
-
setIsOriginTokenDropdownOpen(false)
|
|
342
|
-
}
|
|
343
|
-
}
|
|
344
|
-
|
|
345
|
-
if (isTokenDropdownOpen || isOriginTokenDropdownOpen) {
|
|
346
|
-
document.addEventListener("click", handleClickOutside)
|
|
347
|
-
return () => document.removeEventListener("click", handleClickOutside)
|
|
348
|
-
}
|
|
349
|
-
}, [isTokenDropdownOpen, isOriginTokenDropdownOpen, setIsTokenDropdownOpen])
|
|
350
|
-
|
|
351
333
|
// Handle flip functionality
|
|
352
334
|
const handleFlip = () => {
|
|
353
335
|
if (!selectedDestinationChain || !originToken || !selectedDestToken) return
|
|
@@ -434,6 +416,159 @@ export const ClassicSwap: React.FC<ClassicSwapProps> = ({
|
|
|
434
416
|
}
|
|
435
417
|
}, [tradeType, buyAmount, toAmountDisplay])
|
|
436
418
|
|
|
419
|
+
// Handle source token selection from full-screen selector
|
|
420
|
+
const handleSourceTokenSelectorSelect = useCallback(
|
|
421
|
+
(token: any) => {
|
|
422
|
+
const formattedToken = {
|
|
423
|
+
...token,
|
|
424
|
+
decimals: token.contractInfo?.decimals || token.decimals,
|
|
425
|
+
contractInfo: {
|
|
426
|
+
decimals: token.contractInfo?.decimals || token.decimals,
|
|
427
|
+
contractAddress: token.contractAddress,
|
|
428
|
+
symbol: token.symbol,
|
|
429
|
+
name: token.name,
|
|
430
|
+
},
|
|
431
|
+
}
|
|
432
|
+
setOriginToken(formattedToken as any)
|
|
433
|
+
setOriginChainId(token.chainId)
|
|
434
|
+
setShowSourceTokenSelector(false)
|
|
435
|
+
onTrackToken?.(token)
|
|
436
|
+
logger.console.log("[trails-sdk] selected origin token", token)
|
|
437
|
+
},
|
|
438
|
+
[setOriginToken, onTrackToken],
|
|
439
|
+
)
|
|
440
|
+
|
|
441
|
+
// Handle destination token selection from full-screen selector
|
|
442
|
+
const handleDestinationTokenSelectorSelect = useCallback(
|
|
443
|
+
(token: any) => {
|
|
444
|
+
const formattedToken = {
|
|
445
|
+
...token,
|
|
446
|
+
decimals: token.contractInfo?.decimals || token.decimals,
|
|
447
|
+
contractInfo: {
|
|
448
|
+
decimals: token.contractInfo?.decimals || token.decimals,
|
|
449
|
+
contractAddress: token.contractAddress,
|
|
450
|
+
symbol: token.symbol,
|
|
451
|
+
name: token.name,
|
|
452
|
+
},
|
|
453
|
+
}
|
|
454
|
+
setDestinationToken(formattedToken as any)
|
|
455
|
+
setSelectedDestToken(formattedToken as any)
|
|
456
|
+
|
|
457
|
+
// Update destination chain
|
|
458
|
+
const chainInfo = getChainInfo(token.chainId)
|
|
459
|
+
if (chainInfo) {
|
|
460
|
+
setSelectedDestinationChain(chainInfo)
|
|
461
|
+
}
|
|
462
|
+
|
|
463
|
+
setShowDestinationTokenSelector(false)
|
|
464
|
+
onTrackToken?.(token)
|
|
465
|
+
logger.console.log("[trails-sdk] selected destination token", token)
|
|
466
|
+
},
|
|
467
|
+
[
|
|
468
|
+
setDestinationToken,
|
|
469
|
+
setSelectedDestToken,
|
|
470
|
+
setSelectedDestinationChain,
|
|
471
|
+
onTrackToken,
|
|
472
|
+
],
|
|
473
|
+
)
|
|
474
|
+
|
|
475
|
+
// Handle recent token selection
|
|
476
|
+
const handleRecentTokenSelect = useCallback(
|
|
477
|
+
(token: any) => {
|
|
478
|
+
if (showSourceTokenSelector) {
|
|
479
|
+
handleSourceTokenSelectorSelect(token)
|
|
480
|
+
} else if (showDestinationTokenSelector) {
|
|
481
|
+
handleDestinationTokenSelectorSelect(token)
|
|
482
|
+
}
|
|
483
|
+
},
|
|
484
|
+
[
|
|
485
|
+
showSourceTokenSelector,
|
|
486
|
+
showDestinationTokenSelector,
|
|
487
|
+
handleSourceTokenSelectorSelect,
|
|
488
|
+
handleDestinationTokenSelectorSelect,
|
|
489
|
+
],
|
|
490
|
+
)
|
|
491
|
+
|
|
492
|
+
// Show source chain list screen
|
|
493
|
+
if (showSourceChainList) {
|
|
494
|
+
return (
|
|
495
|
+
<ChainList
|
|
496
|
+
onBack={() => {
|
|
497
|
+
setShowSourceChainList(false)
|
|
498
|
+
setShowSourceTokenSelector(true)
|
|
499
|
+
}}
|
|
500
|
+
/>
|
|
501
|
+
)
|
|
502
|
+
}
|
|
503
|
+
|
|
504
|
+
// Show source token selector screen
|
|
505
|
+
if (showSourceTokenSelector) {
|
|
506
|
+
return (
|
|
507
|
+
<div className="space-y-2">
|
|
508
|
+
<ScreenHeader
|
|
509
|
+
onBack={() => setShowSourceTokenSelector(false)}
|
|
510
|
+
headerContent="Select From Token"
|
|
511
|
+
headerContentAlign="left"
|
|
512
|
+
/>
|
|
513
|
+
<TokenSelector
|
|
514
|
+
onTokenSelect={handleSourceTokenSelectorSelect}
|
|
515
|
+
onError={onError}
|
|
516
|
+
showContinueButton={false}
|
|
517
|
+
compactMode={false}
|
|
518
|
+
allSupportedTokens={false}
|
|
519
|
+
fundMethod={fundMethod}
|
|
520
|
+
chainListScreen={true}
|
|
521
|
+
onNavigateToChainList={() => {
|
|
522
|
+
setShowSourceTokenSelector(false)
|
|
523
|
+
setShowSourceChainList(true)
|
|
524
|
+
}}
|
|
525
|
+
recentTokens={recentTokens}
|
|
526
|
+
onRecentTokenSelect={handleRecentTokenSelect}
|
|
527
|
+
/>
|
|
528
|
+
</div>
|
|
529
|
+
)
|
|
530
|
+
}
|
|
531
|
+
|
|
532
|
+
// Show destination chain list screen
|
|
533
|
+
if (showDestinationChainList) {
|
|
534
|
+
return (
|
|
535
|
+
<ChainList
|
|
536
|
+
onBack={() => {
|
|
537
|
+
setShowDestinationChainList(false)
|
|
538
|
+
setShowDestinationTokenSelector(true)
|
|
539
|
+
}}
|
|
540
|
+
/>
|
|
541
|
+
)
|
|
542
|
+
}
|
|
543
|
+
|
|
544
|
+
// Show destination token selector screen
|
|
545
|
+
if (showDestinationTokenSelector) {
|
|
546
|
+
return (
|
|
547
|
+
<div className="space-y-2">
|
|
548
|
+
<ScreenHeader
|
|
549
|
+
onBack={() => setShowDestinationTokenSelector(false)}
|
|
550
|
+
headerContent="Select To Token"
|
|
551
|
+
headerContentAlign="left"
|
|
552
|
+
/>
|
|
553
|
+
<TokenSelector
|
|
554
|
+
onTokenSelect={handleDestinationTokenSelectorSelect}
|
|
555
|
+
onError={onError}
|
|
556
|
+
showContinueButton={false}
|
|
557
|
+
compactMode={false}
|
|
558
|
+
allSupportedTokens={true}
|
|
559
|
+
fundMethod={fundMethod}
|
|
560
|
+
chainListScreen={true}
|
|
561
|
+
onNavigateToChainList={() => {
|
|
562
|
+
setShowDestinationTokenSelector(false)
|
|
563
|
+
setShowDestinationChainList(true)
|
|
564
|
+
}}
|
|
565
|
+
recentTokens={recentTokens}
|
|
566
|
+
onRecentTokenSelect={handleRecentTokenSelect}
|
|
567
|
+
/>
|
|
568
|
+
</div>
|
|
569
|
+
)
|
|
570
|
+
}
|
|
571
|
+
|
|
437
572
|
return (
|
|
438
573
|
<div className="space-y-2">
|
|
439
574
|
<ScreenHeader
|
|
@@ -516,12 +651,10 @@ export const ClassicSwap: React.FC<ClassicSwapProps> = ({
|
|
|
516
651
|
</div>
|
|
517
652
|
|
|
518
653
|
{/* Token Selection Button */}
|
|
519
|
-
<div className="relative"
|
|
654
|
+
<div className="relative">
|
|
520
655
|
<button
|
|
521
656
|
type="button"
|
|
522
|
-
onClick={() =>
|
|
523
|
-
setIsOriginTokenDropdownOpen(!isOriginTokenDropdownOpen)
|
|
524
|
-
}
|
|
657
|
+
onClick={() => setShowSourceTokenSelector(true)}
|
|
525
658
|
className={`flex items-center space-x-2 trails-border-radius-input px-2.5 py-1.5 border transition-colors cursor-pointer ${
|
|
526
659
|
originToken
|
|
527
660
|
? "trails-bg-card hover:trails-hover-bg trails-border-primary"
|
|
@@ -550,60 +683,6 @@ export const ClassicSwap: React.FC<ClassicSwapProps> = ({
|
|
|
550
683
|
</>
|
|
551
684
|
)}
|
|
552
685
|
</button>
|
|
553
|
-
|
|
554
|
-
{/* Token Selector Modal */}
|
|
555
|
-
{isOriginTokenDropdownOpen && (
|
|
556
|
-
<div className="absolute right-0 top-full mt-2 w-80 trails-bg-card rounded-lg shadow-lg border trails-border-primary max-h-80 overflow-hidden z-10 -translate-y-28">
|
|
557
|
-
<div className="p-2">
|
|
558
|
-
<TokenSelector
|
|
559
|
-
onTokenSelect={(token: any) => {
|
|
560
|
-
const formattedToken = {
|
|
561
|
-
...token,
|
|
562
|
-
decimals:
|
|
563
|
-
token.contractInfo?.decimals || token.decimals,
|
|
564
|
-
contractInfo: {
|
|
565
|
-
decimals:
|
|
566
|
-
token.contractInfo?.decimals || token.decimals,
|
|
567
|
-
contractAddress: token.contractAddress,
|
|
568
|
-
symbol: token.symbol,
|
|
569
|
-
name: token.name,
|
|
570
|
-
},
|
|
571
|
-
} as any
|
|
572
|
-
setOriginToken(formattedToken)
|
|
573
|
-
logger.console.log(
|
|
574
|
-
"[trails-sdk] selected origin token",
|
|
575
|
-
token,
|
|
576
|
-
)
|
|
577
|
-
setOriginChainId(token.chainId)
|
|
578
|
-
setIsOriginTokenDropdownOpen(false)
|
|
579
|
-
// Track the token selection
|
|
580
|
-
onTrackToken?.(token)
|
|
581
|
-
}}
|
|
582
|
-
onError={onError}
|
|
583
|
-
fundMethod={fundMethod}
|
|
584
|
-
showContinueButton={false}
|
|
585
|
-
compactMode={false}
|
|
586
|
-
recentTokens={recentTokens}
|
|
587
|
-
onRecentTokenSelect={(token) => {
|
|
588
|
-
const formattedToken = {
|
|
589
|
-
...token,
|
|
590
|
-
decimals: token.decimals,
|
|
591
|
-
contractInfo: {
|
|
592
|
-
decimals: token.decimals,
|
|
593
|
-
contractAddress: token.contractAddress,
|
|
594
|
-
symbol: token.symbol,
|
|
595
|
-
name: token.name,
|
|
596
|
-
},
|
|
597
|
-
} as any
|
|
598
|
-
setOriginToken(formattedToken)
|
|
599
|
-
setOriginChainId(token.chainId)
|
|
600
|
-
setIsOriginTokenDropdownOpen(false)
|
|
601
|
-
onRecentTokenSelect?.(token)
|
|
602
|
-
}}
|
|
603
|
-
/>
|
|
604
|
-
</div>
|
|
605
|
-
</div>
|
|
606
|
-
)}
|
|
607
686
|
</div>
|
|
608
687
|
</div>
|
|
609
688
|
|
|
@@ -714,10 +793,10 @@ export const ClassicSwap: React.FC<ClassicSwapProps> = ({
|
|
|
714
793
|
</div>
|
|
715
794
|
|
|
716
795
|
{/* Destination Token Selection */}
|
|
717
|
-
<div className="relative"
|
|
796
|
+
<div className="relative">
|
|
718
797
|
<button
|
|
719
798
|
type="button"
|
|
720
|
-
onClick={() =>
|
|
799
|
+
onClick={() => setShowDestinationTokenSelector(true)}
|
|
721
800
|
className={`flex items-center space-x-2 trails-border-radius-input px-2.5 py-1.5 border transition-colors cursor-pointer ${
|
|
722
801
|
selectedDestToken
|
|
723
802
|
? "trails-bg-card hover:trails-hover-bg trails-border-primary"
|
|
@@ -746,56 +825,6 @@ export const ClassicSwap: React.FC<ClassicSwapProps> = ({
|
|
|
746
825
|
</>
|
|
747
826
|
)}
|
|
748
827
|
</button>
|
|
749
|
-
|
|
750
|
-
{/* Token Selector Modal */}
|
|
751
|
-
{isTokenDropdownOpen && (
|
|
752
|
-
<div className="absolute right-0 bottom-full mb-1 w-80 trails-bg-card rounded-lg shadow-lg border trails-border-primary max-h-80 overflow-hidden z-10 translate-y-32">
|
|
753
|
-
<div className="p-2">
|
|
754
|
-
<TokenSelector
|
|
755
|
-
onTokenSelect={(token: any) => {
|
|
756
|
-
const formattedToken = {
|
|
757
|
-
...token,
|
|
758
|
-
decimals:
|
|
759
|
-
token.contractInfo?.decimals || token.decimals,
|
|
760
|
-
contractInfo: {
|
|
761
|
-
decimals:
|
|
762
|
-
token.contractInfo?.decimals || token.decimals,
|
|
763
|
-
},
|
|
764
|
-
} as any
|
|
765
|
-
setDestinationToken(formattedToken)
|
|
766
|
-
setSelectedDestToken(formattedToken)
|
|
767
|
-
logger.console.log(
|
|
768
|
-
"[trails-sdk] selected destination token",
|
|
769
|
-
token,
|
|
770
|
-
)
|
|
771
|
-
|
|
772
|
-
setIsTokenDropdownOpen(false)
|
|
773
|
-
// Track the token selection
|
|
774
|
-
onTrackToken?.(token)
|
|
775
|
-
}}
|
|
776
|
-
onError={onError}
|
|
777
|
-
fundMethod={fundMethod}
|
|
778
|
-
allSupportedTokens={true}
|
|
779
|
-
showContinueButton={false}
|
|
780
|
-
compactMode={false}
|
|
781
|
-
recentTokens={recentTokens}
|
|
782
|
-
onRecentTokenSelect={(token) => {
|
|
783
|
-
const formattedToken = {
|
|
784
|
-
...token,
|
|
785
|
-
decimals: token.decimals,
|
|
786
|
-
contractInfo: {
|
|
787
|
-
decimals: token.decimals,
|
|
788
|
-
},
|
|
789
|
-
} as any
|
|
790
|
-
setDestinationToken(formattedToken)
|
|
791
|
-
setSelectedDestToken(formattedToken)
|
|
792
|
-
setIsTokenDropdownOpen(false)
|
|
793
|
-
onRecentTokenSelect?.(token)
|
|
794
|
-
}}
|
|
795
|
-
/>
|
|
796
|
-
</div>
|
|
797
|
-
</div>
|
|
798
|
-
)}
|
|
799
828
|
</div>
|
|
800
829
|
</div>
|
|
801
830
|
|
|
@@ -814,13 +843,6 @@ export const ClassicSwap: React.FC<ClassicSwapProps> = ({
|
|
|
814
843
|
</div>
|
|
815
844
|
</div>
|
|
816
845
|
|
|
817
|
-
{/* Fee Options */}
|
|
818
|
-
<FeeOptions
|
|
819
|
-
options={feeOptions}
|
|
820
|
-
selectedOption={selectedFeeToken ?? undefined}
|
|
821
|
-
onSelect={setSelectedFeeToken}
|
|
822
|
-
/>
|
|
823
|
-
|
|
824
846
|
{/* Warning Messages - Show only one at a time */}
|
|
825
847
|
<ErrorDisplay
|
|
826
848
|
errorPrettified={quoteErrorPrettified}
|
|
@@ -851,30 +873,6 @@ export const ClassicSwap: React.FC<ClassicSwapProps> = ({
|
|
|
851
873
|
</p>
|
|
852
874
|
</div>
|
|
853
875
|
</div>
|
|
854
|
-
) : prepareSendQuote?.minimumNotMet ? (
|
|
855
|
-
<div className="px-2 py-3 rounded-lg bg-amber-500/10 border border-solid border-amber-500/30">
|
|
856
|
-
<div className="flex items-center space-x-2">
|
|
857
|
-
<svg
|
|
858
|
-
className="w-4 h-4 text-amber-500 flex-shrink-0"
|
|
859
|
-
fill="none"
|
|
860
|
-
stroke="currentColor"
|
|
861
|
-
viewBox="0 0 24 24"
|
|
862
|
-
aria-hidden="true"
|
|
863
|
-
>
|
|
864
|
-
<path
|
|
865
|
-
strokeLinecap="round"
|
|
866
|
-
strokeLinejoin="round"
|
|
867
|
-
strokeWidth={2}
|
|
868
|
-
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"
|
|
869
|
-
/>
|
|
870
|
-
</svg>
|
|
871
|
-
<p className="text-sm text-amber-600 dark:text-amber-400">
|
|
872
|
-
Please enter an amount above{" "}
|
|
873
|
-
{formatUsdAmountDisplay(MINIMUM_USD_AMOUNT_FOR_SWAP)} otherwise
|
|
874
|
-
transfer may fail
|
|
875
|
-
</p>
|
|
876
|
-
</div>
|
|
877
|
-
</div>
|
|
878
876
|
) : null}
|
|
879
877
|
|
|
880
878
|
{/* Quote Details */}
|
|
@@ -16,6 +16,7 @@ import { getChainInfo } from "../../chains.js"
|
|
|
16
16
|
import { mainnet } from "viem/chains"
|
|
17
17
|
import { logger } from "../../logger.js"
|
|
18
18
|
import { useWidgetProps } from "../hooks/useWidgetProps.js"
|
|
19
|
+
import { useTargetAmount } from "../hooks/useTargetAmount.js"
|
|
19
20
|
|
|
20
21
|
interface ConfigDisplayProps {
|
|
21
22
|
className?: string
|
|
@@ -24,7 +25,14 @@ interface ConfigDisplayProps {
|
|
|
24
25
|
export const ConfigDisplay: React.FC<ConfigDisplayProps> = ({
|
|
25
26
|
className = "",
|
|
26
27
|
}) => {
|
|
27
|
-
const {
|
|
28
|
+
const {
|
|
29
|
+
toast = false,
|
|
30
|
+
toAddress,
|
|
31
|
+
toAmount,
|
|
32
|
+
toToken,
|
|
33
|
+
toCalldata,
|
|
34
|
+
} = useWidgetProps()
|
|
35
|
+
const { targetAmountUsdFormatted } = useTargetAmount()
|
|
28
36
|
const [sequenceEnv, setSequenceEnv] = useState(getSequenceEnv())
|
|
29
37
|
const [trailsApiUrl, setTrailsApiUrl] = useState(getTrailsApiUrl())
|
|
30
38
|
const [sequenceIndexerUrl, setSequenceIndexerUrl] = useState(
|
|
@@ -114,6 +122,31 @@ export const ConfigDisplay: React.FC<ConfigDisplayProps> = ({
|
|
|
114
122
|
{ label: "Slippage Tolerance", value: `${slippageTolerance}%` },
|
|
115
123
|
{ label: "Debug Mode", value: debugMode ? "Enabled" : "Disabled" },
|
|
116
124
|
{ label: "Toast Notifications", value: toast ? "Enabled" : "Disabled" },
|
|
125
|
+
{
|
|
126
|
+
label: "Target Amount USD",
|
|
127
|
+
value: targetAmountUsdFormatted || "N/A",
|
|
128
|
+
display: targetAmountUsdFormatted || "N/A",
|
|
129
|
+
},
|
|
130
|
+
{
|
|
131
|
+
label: "To Address",
|
|
132
|
+
value: toAddress || "N/A",
|
|
133
|
+
display: toAddress ? truncateString(toAddress, 20) : "N/A",
|
|
134
|
+
},
|
|
135
|
+
{
|
|
136
|
+
label: "To Amount",
|
|
137
|
+
value: toAmount || "N/A",
|
|
138
|
+
display: toAmount || "N/A",
|
|
139
|
+
},
|
|
140
|
+
{
|
|
141
|
+
label: "To Token",
|
|
142
|
+
value: toToken || "N/A",
|
|
143
|
+
display: toToken ? truncateString(toToken, 20) : "N/A",
|
|
144
|
+
},
|
|
145
|
+
{
|
|
146
|
+
label: "To Calldata",
|
|
147
|
+
value: toCalldata || "N/A",
|
|
148
|
+
display: toCalldata ? truncateString(toCalldata, 20) : "N/A",
|
|
149
|
+
},
|
|
117
150
|
]
|
|
118
151
|
|
|
119
152
|
return (
|