0xtrails 0.2.4 → 0.2.5
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 +8 -0
- package/dist/aave.d.ts.map +1 -1
- package/dist/{ccip-BlV1Mry3.js → ccip-CXlshvBY.js} +1 -1
- package/dist/config.d.ts +1 -1
- package/dist/config.d.ts.map +1 -1
- package/dist/constants.d.ts +1 -0
- package/dist/constants.d.ts.map +1 -1
- package/dist/error.d.ts +1 -0
- package/dist/error.d.ts.map +1 -1
- package/dist/estimate.d.ts +52 -0
- package/dist/estimate.d.ts.map +1 -1
- package/dist/{index-BNWCIGfQ.js → index-_QuyGrjU.js} +72332 -72246
- package/dist/index.js +2 -2
- package/dist/intents.d.ts +40 -0
- package/dist/intents.d.ts.map +1 -1
- package/dist/metaTxnMonitor.d.ts +3 -3
- package/dist/metaTxnMonitor.d.ts.map +1 -1
- package/dist/metaTxns.d.ts +3 -3
- package/dist/metaTxns.d.ts.map +1 -1
- package/dist/morpho.d.ts +8 -0
- package/dist/morpho.d.ts.map +1 -1
- package/dist/prepareSend.d.ts +16 -6
- package/dist/prepareSend.d.ts.map +1 -1
- package/dist/queryParams.d.ts.map +1 -1
- package/dist/relayer.d.ts +6 -6
- package/dist/relayer.d.ts.map +1 -1
- package/dist/sequenceWallet.d.ts +2 -2
- package/dist/sequenceWallet.d.ts.map +1 -1
- package/dist/tokens.d.ts.map +1 -1
- package/dist/wallets.d.ts.map +1 -1
- package/dist/widget/components/AccountActionsDropdown.d.ts.map +1 -1
- package/dist/widget/components/AccountSettings.d.ts.map +1 -1
- package/dist/widget/components/ClassicSwap.d.ts +2 -0
- 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 +4 -0
- package/dist/widget/components/ConnectedWallets.d.ts.map +1 -1
- package/dist/widget/components/Earn.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/{FundSendForm.d.ts → FundSwap.d.ts} +11 -5
- package/dist/widget/components/FundSwap.d.ts.map +1 -0
- package/dist/widget/components/FundingMethodSelectorButton.d.ts +4 -0
- package/dist/widget/components/FundingMethodSelectorButton.d.ts.map +1 -0
- package/dist/widget/components/Modal.d.ts.map +1 -1
- package/dist/widget/components/Pay.d.ts.map +1 -1
- package/dist/widget/components/PercentageMaxButtons.d.ts +12 -0
- package/dist/widget/components/PercentageMaxButtons.d.ts.map +1 -0
- package/dist/widget/components/{PaySendForm.d.ts → PoolDeposit.d.ts} +11 -34
- package/dist/widget/components/PoolDeposit.d.ts.map +1 -0
- package/dist/widget/components/{SimpleSwap.d.ts → PoolWithdraw.d.ts} +16 -8
- package/dist/widget/components/PoolWithdraw.d.ts.map +1 -0
- package/dist/widget/components/QuoteDetails.d.ts.map +1 -1
- package/dist/widget/components/Receive.d.ts.map +1 -1
- package/dist/widget/components/RecipientSelectorButton.d.ts +4 -0
- package/dist/widget/components/RecipientSelectorButton.d.ts.map +1 -0
- package/dist/widget/components/Recipients.d.ts.map +1 -1
- package/dist/widget/components/RequiredPropsError.d.ts +8 -0
- package/dist/widget/components/RequiredPropsError.d.ts.map +1 -0
- package/dist/widget/components/ScreenHeader.d.ts.map +1 -1
- package/dist/widget/components/SlippageToleranceSettings.d.ts.map +1 -1
- package/dist/widget/components/Swap.d.ts +1 -0
- package/dist/widget/components/Swap.d.ts.map +1 -1
- package/dist/widget/components/SwapSettings.d.ts.map +1 -1
- package/dist/widget/components/TokenImage.d.ts +1 -0
- package/dist/widget/components/TokenImage.d.ts.map +1 -1
- package/dist/widget/components/TokenList.d.ts.map +1 -1
- package/dist/widget/components/TokenSelector.d.ts.map +1 -1
- package/dist/widget/components/TokenSelectorButton.d.ts +16 -0
- package/dist/widget/components/TokenSelectorButton.d.ts.map +1 -0
- package/dist/widget/components/UserPreferences.d.ts.map +1 -1
- package/dist/widget/components/WaasFeeOptions.d.ts +8 -0
- package/dist/widget/components/WaasFeeOptions.d.ts.map +1 -0
- package/dist/widget/components/WalletConfirmation.d.ts.map +1 -1
- package/dist/widget/components/WalletList.d.ts.map +1 -1
- package/dist/widget/css/compiled.css +2 -0
- package/dist/widget/css/index.css +554 -0
- package/dist/widget/hooks/useBack.d.ts +1 -0
- package/dist/widget/hooks/useBack.d.ts.map +1 -1
- package/dist/widget/hooks/useCheckout.d.ts +1 -1
- package/dist/widget/hooks/useCheckout.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 +3 -3
- package/dist/widget/hooks/useDefaultTokenSelection.d.ts.map +1 -1
- package/dist/widget/hooks/usePayMessage.d.ts.map +1 -1
- package/dist/widget/hooks/useSelectedFundMethod.d.ts +12 -0
- package/dist/widget/hooks/useSelectedFundMethod.d.ts.map +1 -0
- package/dist/widget/hooks/useSelectedRecipient.d.ts.map +1 -1
- package/dist/widget/hooks/useSendForm.d.ts.map +1 -1
- package/dist/widget/index.js +1 -1
- package/dist/widget/widget.d.ts +4 -4
- package/dist/widget/widget.d.ts.map +1 -1
- package/package.json +18 -12
- package/src/aave.ts +32 -0
- package/src/config.ts +12 -4
- package/src/constants.ts +2 -0
- package/src/error.ts +19 -1
- package/src/estimate.ts +416 -5
- package/src/intents.ts +161 -11
- package/src/metaTxnMonitor.ts +3 -3
- package/src/metaTxns.ts +3 -5
- package/src/morpho.ts +32 -0
- package/src/prepareSend.ts +503 -166
- package/src/queryParams.ts +2 -1
- package/src/relayer.ts +11 -11
- package/src/sequenceWallet.ts +2 -2
- package/src/tokens.ts +7 -1
- package/src/wallets.ts +8 -0
- package/src/widget/compiled.css +2 -2
- package/src/widget/components/AccountActionsDropdown.tsx +3 -13
- package/src/widget/components/AccountSettings.tsx +6 -24
- package/src/widget/components/ClassicSwap.tsx +111 -155
- package/src/widget/components/ConnectWallet.tsx +4 -37
- package/src/widget/components/ConnectedWallets.tsx +113 -58
- package/src/widget/components/Earn.tsx +73 -589
- package/src/widget/components/Fund.tsx +31 -82
- package/src/widget/components/FundMethods.tsx +82 -159
- package/src/widget/components/FundSwap.tsx +52 -0
- package/src/widget/components/FundingMethodSelectorButton.tsx +60 -0
- package/src/widget/components/Modal.tsx +6 -2
- package/src/widget/components/Pay.tsx +183 -208
- package/src/widget/components/PercentageMaxButtons.tsx +77 -0
- package/src/widget/components/PoolDeposit.tsx +593 -0
- package/src/widget/components/PoolWithdraw.tsx +903 -0
- package/src/widget/components/QuoteDetails.tsx +22 -8
- package/src/widget/components/Receive.tsx +0 -2
- package/src/widget/components/RecipientSelectorButton.tsx +42 -0
- package/src/widget/components/Recipients.tsx +62 -156
- package/src/widget/components/RequiredPropsError.tsx +33 -0
- package/src/widget/components/ScreenHeader.tsx +5 -1
- package/src/widget/components/SlippageToleranceSettings.tsx +2 -1
- package/src/widget/components/Swap.tsx +2 -43
- package/src/widget/components/SwapSettings.tsx +2 -14
- package/src/widget/components/TokenImage.tsx +21 -4
- package/src/widget/components/TokenList.tsx +0 -1
- package/src/widget/components/TokenSelector.tsx +1 -0
- package/src/widget/components/TokenSelectorButton.tsx +75 -0
- package/src/widget/components/UserPreferences.tsx +6 -24
- package/src/widget/components/WaasFeeOptions.tsx +331 -0
- package/src/widget/components/WalletConfirmation.tsx +55 -3
- package/src/widget/components/WalletList.tsx +4 -2
- package/src/widget/hooks/useBack.tsx +2 -0
- package/src/widget/hooks/useCheckout.ts +36 -20
- package/src/widget/hooks/useCurrentScreen.tsx +1 -0
- package/src/widget/hooks/useDefaultTokenSelection.tsx +104 -28
- package/src/widget/hooks/usePayMessage.tsx +86 -11
- package/src/widget/hooks/useSelectedFundMethod.tsx +41 -0
- package/src/widget/hooks/useSelectedRecipient.tsx +10 -0
- package/src/widget/hooks/useSendForm.ts +24 -2
- package/src/widget/index.css +27 -0
- package/src/widget/widget.tsx +169 -111
- package/dist/widget/components/FundSendForm.d.ts.map +0 -1
- package/dist/widget/components/PaySendForm.d.ts.map +0 -1
- package/dist/widget/components/SimpleSwap.d.ts.map +0 -1
- package/dist/widget/hooks/useSwapSettings.d.ts +0 -16
- package/dist/widget/hooks/useSwapSettings.d.ts.map +0 -1
- package/src/widget/components/FundSendForm.tsx +0 -903
- package/src/widget/components/PaySendForm.tsx +0 -869
- package/src/widget/components/SimpleSwap.tsx +0 -983
- package/src/widget/hooks/useSwapSettings.tsx +0 -100
|
@@ -1,13 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
ChevronRight,
|
|
3
|
-
Search,
|
|
4
|
-
Loader2,
|
|
5
|
-
ChevronDown,
|
|
6
|
-
ArrowDown,
|
|
7
|
-
} from "lucide-react"
|
|
1
|
+
import { ChevronRight, Search, Loader2, ArrowDown } from "lucide-react"
|
|
8
2
|
import { useEffect, useState, useMemo, useRef, useCallback } from "react"
|
|
9
3
|
import type React from "react"
|
|
10
4
|
import type { Account, WalletClient } from "viem"
|
|
5
|
+
import { zeroAddress } from "viem"
|
|
11
6
|
import type { TransactionState } from "../../transactions.js"
|
|
12
7
|
import type { OnCompleteProps } from "../hooks/useSendForm.js"
|
|
13
8
|
import type { CheckoutOnHandlers } from "../hooks/useCheckout.js"
|
|
@@ -35,6 +30,8 @@ import type { PrepareSendQuote } from "../../prepareSend.js"
|
|
|
35
30
|
import type { SupportedToken } from "../../tokens.js"
|
|
36
31
|
import { logger } from "../../logger.js"
|
|
37
32
|
import { RefundWarning } from "./RefundWarning.js"
|
|
33
|
+
import { PercentageMaxButtons } from "./PercentageMaxButtons.js"
|
|
34
|
+
import { TokenSelectorButton } from "./TokenSelectorButton.js"
|
|
38
35
|
|
|
39
36
|
interface FundProps {
|
|
40
37
|
onBack?: () => void
|
|
@@ -637,7 +634,6 @@ export const Fund: React.FC<FundProps> = ({
|
|
|
637
634
|
onBack={() => setShowOriginTokenSelector(false)}
|
|
638
635
|
headerContent="Select From Token"
|
|
639
636
|
headerContentAlign="left"
|
|
640
|
-
showAccountActions={true}
|
|
641
637
|
/>
|
|
642
638
|
<TokenSelector
|
|
643
639
|
onTokenSelect={handleOriginTokenSelect}
|
|
@@ -684,7 +680,6 @@ export const Fund: React.FC<FundProps> = ({
|
|
|
684
680
|
onBack={() => setShowDestinationTokenSelector(false)}
|
|
685
681
|
headerContent="Select To Token"
|
|
686
682
|
headerContentAlign="left"
|
|
687
|
-
showAccountActions={true}
|
|
688
683
|
/>
|
|
689
684
|
<TokenSelector
|
|
690
685
|
onTokenSelect={handleDestinationTokenSelect}
|
|
@@ -728,7 +723,6 @@ export const Fund: React.FC<FundProps> = ({
|
|
|
728
723
|
onBack={onBack}
|
|
729
724
|
headerContent="Fund"
|
|
730
725
|
headerContentAlign="left"
|
|
731
|
-
showAccountActions={true}
|
|
732
726
|
/>
|
|
733
727
|
|
|
734
728
|
<div className="space-y-2">
|
|
@@ -770,7 +764,7 @@ export const Fund: React.FC<FundProps> = ({
|
|
|
770
764
|
<div className="space-y-1">
|
|
771
765
|
{/* Origin Amount Input Section */}
|
|
772
766
|
<div className="trails-bg-secondary trails-bg-secondary-hover trails-border-radius-container p-3 group transition-all duration-200 border border-transparent focus-within:!bg-white dark:focus-within:!bg-gray-800 focus-within:border-gray-400 dark:focus-within:border-gray-500">
|
|
773
|
-
{/* Deposit Label
|
|
767
|
+
{/* Deposit Label */}
|
|
774
768
|
<div className="flex justify-between items-center mb-2">
|
|
775
769
|
<div className="text-sm font-medium trails-text-secondary text-left">
|
|
776
770
|
Deposit
|
|
@@ -782,40 +776,6 @@ export const Fund: React.FC<FundProps> = ({
|
|
|
782
776
|
""
|
|
783
777
|
)}
|
|
784
778
|
</div>
|
|
785
|
-
|
|
786
|
-
{/* Percentage Buttons */}
|
|
787
|
-
{originToken && (
|
|
788
|
-
<div className="flex space-x-1 opacity-0 group-hover:opacity-100 transition-opacity duration-200">
|
|
789
|
-
<button
|
|
790
|
-
type="button"
|
|
791
|
-
onClick={() => handlePercentageClick(25)}
|
|
792
|
-
className="py-1 px-2 text-xs font-medium trails-border-radius-container border border-solid transition-colors cursor-pointer border-gray-300 text-gray-600 dark:border-gray-600 dark:text-gray-300 hover:bg-gray-50 dark:hover:bg-gray-700 hover:trails-hover-bg hover:border-gray-400 dark:hover:border-gray-500"
|
|
793
|
-
>
|
|
794
|
-
25%
|
|
795
|
-
</button>
|
|
796
|
-
<button
|
|
797
|
-
type="button"
|
|
798
|
-
onClick={() => handlePercentageClick(50)}
|
|
799
|
-
className="py-1 px-2 text-xs font-medium trails-border-radius-container border border-solid transition-colors cursor-pointer border-gray-300 text-gray-600 dark:border-gray-600 dark:text-gray-300 hover:bg-gray-50 dark:hover:bg-gray-700 hover:trails-hover-bg hover:border-gray-400 dark:hover:border-gray-500"
|
|
800
|
-
>
|
|
801
|
-
50%
|
|
802
|
-
</button>
|
|
803
|
-
<button
|
|
804
|
-
type="button"
|
|
805
|
-
onClick={() => handlePercentageClick(75)}
|
|
806
|
-
className="py-1 px-2 text-xs font-medium trails-border-radius-container border border-solid transition-colors cursor-pointer border-gray-300 text-gray-600 dark:border-gray-600 dark:text-gray-300 hover:bg-gray-50 dark:hover:bg-gray-700 hover:trails-hover-bg hover:border-gray-400 dark:hover:border-gray-500"
|
|
807
|
-
>
|
|
808
|
-
75%
|
|
809
|
-
</button>
|
|
810
|
-
<button
|
|
811
|
-
type="button"
|
|
812
|
-
onClick={() => handlePercentageClick(100)}
|
|
813
|
-
className="py-1 px-2 text-xs font-medium trails-border-radius-container border border-solid transition-colors cursor-pointer border-gray-300 text-gray-600 dark:border-gray-600 dark:text-gray-300 hover:bg-gray-50 dark:hover:bg-gray-700 hover:trails-hover-bg hover:border-gray-400 dark:hover:border-gray-500"
|
|
814
|
-
>
|
|
815
|
-
Max
|
|
816
|
-
</button>
|
|
817
|
-
</div>
|
|
818
|
-
)}
|
|
819
779
|
</div>
|
|
820
780
|
|
|
821
781
|
<div className="flex items-center space-x-2">
|
|
@@ -869,33 +829,11 @@ export const Fund: React.FC<FundProps> = ({
|
|
|
869
829
|
</div>
|
|
870
830
|
|
|
871
831
|
{/* Token Selection Button */}
|
|
872
|
-
<
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
{originToken ? (
|
|
878
|
-
<>
|
|
879
|
-
<TokenImage
|
|
880
|
-
symbol={originToken.symbol}
|
|
881
|
-
imageUrl={originToken.imageUrl}
|
|
882
|
-
chainId={originToken.chainId}
|
|
883
|
-
size={20}
|
|
884
|
-
/>
|
|
885
|
-
<span className="font-medium trails-text-primary text-sm">
|
|
886
|
-
{originToken.symbol}
|
|
887
|
-
</span>
|
|
888
|
-
<ChevronDown className="w-3.5 h-3.5 trails-text-muted" />
|
|
889
|
-
</>
|
|
890
|
-
) : (
|
|
891
|
-
<>
|
|
892
|
-
<span className="font-medium trails-text-muted text-sm">
|
|
893
|
-
Select Token
|
|
894
|
-
</span>
|
|
895
|
-
<ChevronDown className="w-3.5 h-3.5 trails-text-muted" />
|
|
896
|
-
</>
|
|
897
|
-
)}
|
|
898
|
-
</button>
|
|
832
|
+
<TokenSelectorButton
|
|
833
|
+
token={originToken}
|
|
834
|
+
chainId={originToken?.chainId}
|
|
835
|
+
onSelect={() => setShowOriginTokenSelector(true)}
|
|
836
|
+
/>
|
|
899
837
|
</div>
|
|
900
838
|
|
|
901
839
|
{/* Bottom Info Row */}
|
|
@@ -909,9 +847,9 @@ export const Fund: React.FC<FundProps> = ({
|
|
|
909
847
|
)}
|
|
910
848
|
</div>
|
|
911
849
|
|
|
912
|
-
{/* Origin Token Balance */}
|
|
913
|
-
|
|
914
|
-
|
|
850
|
+
{/* Origin Token Balance and Percentage Buttons */}
|
|
851
|
+
{originToken && balanceFormatted && (
|
|
852
|
+
<div className="flex items-center space-x-2">
|
|
915
853
|
<button
|
|
916
854
|
type="button"
|
|
917
855
|
className="text-xs trails-text-muted cursor-pointer hover:trails-hover-text transition-colors bg-transparent border-none p-0"
|
|
@@ -925,14 +863,25 @@ export const Fund: React.FC<FundProps> = ({
|
|
|
925
863
|
title="Click to use full balance"
|
|
926
864
|
>
|
|
927
865
|
Balance:{" "}
|
|
928
|
-
{isBalanceVisible
|
|
929
|
-
? `${balanceFormatted || "0.00"} ${originToken.symbol}`
|
|
930
|
-
: "••••••"}
|
|
866
|
+
{isBalanceVisible ? balanceFormatted || "0.00" : "••••••"}
|
|
931
867
|
</button>
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
868
|
+
|
|
869
|
+
{/* Percentage Buttons */}
|
|
870
|
+
<PercentageMaxButtons
|
|
871
|
+
userBalance={balanceFormatted}
|
|
872
|
+
isNativeToken={originToken.contractAddress === zeroAddress}
|
|
873
|
+
gasCostFormatted={prepareSendQuote?.gasCostFormatted}
|
|
874
|
+
chainId={originToken.chainId}
|
|
875
|
+
onAmountSelect={(amount) => {
|
|
876
|
+
setTokenAmountForBackend(amount)
|
|
877
|
+
setSendFormAmount(amount)
|
|
878
|
+
setGlobalAmount(amount)
|
|
879
|
+
setInputDisplayValue(amount)
|
|
880
|
+
}}
|
|
881
|
+
className="opacity-100"
|
|
882
|
+
/>
|
|
883
|
+
</div>
|
|
884
|
+
)}
|
|
936
885
|
</div>
|
|
937
886
|
</div>
|
|
938
887
|
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import type React from "react"
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { truncateAddress } from "../../utils.js"
|
|
5
|
-
import { useTheme } from "../components/ThemeProvider.js"
|
|
6
|
-
import WalletConnectLogoWhite from "../assets/WalletConnect-logo-white.svg"
|
|
7
|
-
import WalletConnectLogoBlack from "../assets/WalletConnect-logo-black.svg"
|
|
2
|
+
import { QrCode, Send, ChevronRight } from "lucide-react"
|
|
3
|
+
import { useSwitchAccount } from "wagmi"
|
|
8
4
|
import { ScreenHeader } from "./ScreenHeader.js"
|
|
5
|
+
import { ConnectedWallets } from "./ConnectedWallets.js"
|
|
6
|
+
import { useCurrentScreen } from "../hooks/useCurrentScreen.js"
|
|
7
|
+
import { useConnections } from "wagmi"
|
|
8
|
+
import { logger } from "../../logger.js"
|
|
9
|
+
import { useSelectedFundMethod } from "../hooks/useSelectedFundMethod.js"
|
|
9
10
|
|
|
10
11
|
export interface FundMethodsProps {
|
|
11
12
|
onBack?: () => void
|
|
@@ -17,178 +18,100 @@ export interface FundMethodsProps {
|
|
|
17
18
|
|
|
18
19
|
const FundMethods: React.FC<FundMethodsProps> = ({
|
|
19
20
|
onBack,
|
|
20
|
-
onSelectWalletConnect,
|
|
21
21
|
onSelectExchangeList,
|
|
22
|
-
onSelectConnectedAccount,
|
|
23
22
|
onSelectQrCode,
|
|
24
23
|
}) => {
|
|
25
|
-
const {
|
|
26
|
-
const
|
|
24
|
+
const { switchAccount } = useSwitchAccount()
|
|
25
|
+
const connections = useConnections()
|
|
26
|
+
const { setCurrentScreen } = useCurrentScreen()
|
|
27
|
+
const { setSelectedFundMethod } = useSelectedFundMethod()
|
|
27
28
|
|
|
28
|
-
|
|
29
|
+
// Handle wallet selection - switch to the selected wallet and go to home
|
|
30
|
+
const handleWalletSelect = async (
|
|
31
|
+
walletAddress: string,
|
|
32
|
+
walletConnector: unknown,
|
|
33
|
+
) => {
|
|
34
|
+
try {
|
|
35
|
+
// Find the connection for this wallet
|
|
36
|
+
const connection = connections.find(
|
|
37
|
+
(conn) =>
|
|
38
|
+
conn.accounts.includes(walletAddress as `0x${string}`) &&
|
|
39
|
+
conn.connector.id === (walletConnector as { id: string }).id,
|
|
40
|
+
)
|
|
41
|
+
|
|
42
|
+
if (connection) {
|
|
43
|
+
await switchAccount({
|
|
44
|
+
connector: connection.connector,
|
|
45
|
+
})
|
|
46
|
+
logger.console.log(`[trails-sdk] Switched to wallet: ${walletAddress}`)
|
|
47
|
+
|
|
48
|
+
// Set funding method to "wallet" since user selected a wallet
|
|
49
|
+
setSelectedFundMethod("wallet")
|
|
50
|
+
|
|
51
|
+
// Navigate to home screen which will redirect to the appropriate mode screen
|
|
52
|
+
setCurrentScreen("home")
|
|
53
|
+
}
|
|
54
|
+
} catch (error) {
|
|
55
|
+
logger.console.error("[trails-sdk] Failed to switch wallet:", error)
|
|
56
|
+
}
|
|
57
|
+
}
|
|
29
58
|
|
|
30
59
|
return (
|
|
31
60
|
<div className="flex flex-col h-full">
|
|
32
61
|
<ScreenHeader
|
|
33
62
|
onBack={onBack}
|
|
34
|
-
headerContent="
|
|
63
|
+
headerContent="Payment methods"
|
|
35
64
|
headerContentAlign="left"
|
|
36
65
|
rightSideContent={<div className="w-9" />}
|
|
37
|
-
showAccountActions={true}
|
|
38
66
|
/>
|
|
39
67
|
|
|
40
68
|
<div className="flex-1">
|
|
41
|
-
<div className="space-y-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
<Wallet className="h-6 w-6 text-gray-600 dark:text-gray-400" />
|
|
49
|
-
<div className="flex-1 text-left">
|
|
50
|
-
<h4 className="font-semibold text-gray-900 dark:text-gray-100">
|
|
51
|
-
Connected Account
|
|
52
|
-
</h4>
|
|
53
|
-
<p className="text-sm text-gray-600 dark:text-gray-400">
|
|
54
|
-
Use your connected wallet to fund directly.
|
|
55
|
-
</p>
|
|
56
|
-
<p className="text-xs font-mono text-gray-600 dark:text-gray-300">
|
|
57
|
-
{isConnected && address
|
|
58
|
-
? `${connector?.name || "Connected"}: ${truncateAddress(address)}`
|
|
59
|
-
: "No wallet connected"}
|
|
60
|
-
</p>
|
|
61
|
-
</div>
|
|
62
|
-
</div>
|
|
63
|
-
<div className="text-gray-400">
|
|
64
|
-
<svg
|
|
65
|
-
className="w-5 h-5"
|
|
66
|
-
fill="none"
|
|
67
|
-
stroke="currentColor"
|
|
68
|
-
viewBox="0 0 24 24"
|
|
69
|
-
aria-label="Chevron right"
|
|
70
|
-
>
|
|
71
|
-
<path
|
|
72
|
-
strokeLinecap="round"
|
|
73
|
-
strokeLinejoin="round"
|
|
74
|
-
strokeWidth={2}
|
|
75
|
-
d="M9 5l7 7-7 7"
|
|
76
|
-
/>
|
|
77
|
-
</svg>
|
|
78
|
-
</div>
|
|
79
|
-
</button>
|
|
69
|
+
<div className="space-y-4">
|
|
70
|
+
{/* Connected Wallets Section */}
|
|
71
|
+
<ConnectedWallets
|
|
72
|
+
showConnectNewWallet={true}
|
|
73
|
+
onWalletSelect={handleWalletSelect}
|
|
74
|
+
backScreen="fund-methods"
|
|
75
|
+
/>
|
|
80
76
|
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
className="
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
src={
|
|
90
|
-
activeTheme === "dark"
|
|
91
|
-
? WalletConnectLogoWhite
|
|
92
|
-
: WalletConnectLogoBlack
|
|
93
|
-
}
|
|
94
|
-
alt="WalletConnect"
|
|
95
|
-
className="h-4 w-4"
|
|
96
|
-
/>
|
|
97
|
-
</div>
|
|
98
|
-
<div className="flex-1 text-left">
|
|
99
|
-
<h4 className="font-semibold text-gray-900 dark:text-gray-100">
|
|
100
|
-
WalletConnect
|
|
101
|
-
</h4>
|
|
102
|
-
<p className="text-sm text-gray-600 dark:text-gray-400">
|
|
103
|
-
Connect another wallet.
|
|
104
|
-
</p>
|
|
105
|
-
</div>
|
|
106
|
-
</div>
|
|
107
|
-
<div className="text-gray-400">
|
|
108
|
-
<svg
|
|
109
|
-
className="w-5 h-5"
|
|
110
|
-
fill="none"
|
|
111
|
-
stroke="currentColor"
|
|
112
|
-
viewBox="0 0 24 24"
|
|
113
|
-
aria-label="Chevron right"
|
|
114
|
-
>
|
|
115
|
-
<path
|
|
116
|
-
strokeLinecap="round"
|
|
117
|
-
strokeLinejoin="round"
|
|
118
|
-
strokeWidth={2}
|
|
119
|
-
d="M9 5l7 7-7 7"
|
|
120
|
-
/>
|
|
121
|
-
</svg>
|
|
122
|
-
</div>
|
|
123
|
-
</button>
|
|
77
|
+
{/* Divider */}
|
|
78
|
+
<div className="relative flex items-center justify-center">
|
|
79
|
+
<div className="flex-1 border-t border-gray-200 dark:border-gray-700"></div>
|
|
80
|
+
<span className="px-4 text-sm text-gray-500 dark:text-gray-400 bg-white dark:bg-gray-900">
|
|
81
|
+
or
|
|
82
|
+
</span>
|
|
83
|
+
<div className="flex-1 border-t border-gray-200 dark:border-gray-700"></div>
|
|
84
|
+
</div>
|
|
124
85
|
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
<div className="flex-
|
|
133
|
-
<
|
|
134
|
-
|
|
135
|
-
</h4>
|
|
136
|
-
<p className="text-sm text-gray-600 dark:text-gray-400">
|
|
137
|
-
Scan a QR code to deposit funds.
|
|
138
|
-
</p>
|
|
86
|
+
{/* Additional Funding Options */}
|
|
87
|
+
<div className="trails-border-radius-container border trails-border-primary">
|
|
88
|
+
<button
|
|
89
|
+
type="button"
|
|
90
|
+
onClick={onSelectQrCode}
|
|
91
|
+
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"
|
|
92
|
+
>
|
|
93
|
+
<div className="flex items-center gap-3">
|
|
94
|
+
<QrCode className="w-4 h-4" />
|
|
95
|
+
<span className="text-sm font-bold">Pay with QR Code</span>
|
|
139
96
|
</div>
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
stroke="currentColor"
|
|
146
|
-
viewBox="0 0 24 24"
|
|
147
|
-
aria-label="Chevron right"
|
|
148
|
-
>
|
|
149
|
-
<path
|
|
150
|
-
strokeLinecap="round"
|
|
151
|
-
strokeLinejoin="round"
|
|
152
|
-
strokeWidth={2}
|
|
153
|
-
d="M9 5l7 7-7 7"
|
|
154
|
-
/>
|
|
155
|
-
</svg>
|
|
156
|
-
</div>
|
|
157
|
-
</button>
|
|
97
|
+
<ChevronRight className="w-5 h-5 text-gray-400" />
|
|
98
|
+
</button>
|
|
99
|
+
|
|
100
|
+
{/* Divider between buttons */}
|
|
101
|
+
<div className="border-b border-gray-200 dark:border-gray-700"></div>
|
|
158
102
|
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
<h4 className="font-semibold text-gray-900 dark:text-gray-100">
|
|
168
|
-
Send from Exchange
|
|
169
|
-
</h4>
|
|
170
|
-
<p className="text-sm text-gray-600 dark:text-gray-400">
|
|
171
|
-
Transfer from Coinbase, Binance, etc.
|
|
172
|
-
</p>
|
|
103
|
+
<button
|
|
104
|
+
type="button"
|
|
105
|
+
onClick={onSelectExchangeList}
|
|
106
|
+
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"
|
|
107
|
+
>
|
|
108
|
+
<div className="flex items-center gap-3">
|
|
109
|
+
<Send className="w-4 h-4" />
|
|
110
|
+
<span className="text-sm font-bold">Send from Exchange</span>
|
|
173
111
|
</div>
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
className="w-5 h-5"
|
|
178
|
-
fill="none"
|
|
179
|
-
stroke="currentColor"
|
|
180
|
-
viewBox="0 0 24 24"
|
|
181
|
-
aria-label="Chevron right"
|
|
182
|
-
>
|
|
183
|
-
<path
|
|
184
|
-
strokeLinecap="round"
|
|
185
|
-
strokeLinejoin="round"
|
|
186
|
-
strokeWidth={2}
|
|
187
|
-
d="M9 5l7 7-7 7"
|
|
188
|
-
/>
|
|
189
|
-
</svg>
|
|
190
|
-
</div>
|
|
191
|
-
</button>
|
|
112
|
+
<ChevronRight className="w-5 h-5 text-gray-400" />
|
|
113
|
+
</button>
|
|
114
|
+
</div>
|
|
192
115
|
</div>
|
|
193
116
|
</div>
|
|
194
117
|
</div>
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import type React from "react"
|
|
2
|
+
import type { Account, WalletClient } from "viem"
|
|
3
|
+
import type { TransactionState } from "../../transactions.js"
|
|
4
|
+
import type { OnCompleteProps, Token } from "../hooks/useSendForm.js"
|
|
5
|
+
import type { SupportedToken } from "../../tokens.js"
|
|
6
|
+
import type { CheckoutOnHandlers } from "../hooks/useCheckout.js"
|
|
7
|
+
import type { PrepareSendQuote } from "../../prepareSend.js"
|
|
8
|
+
import { ClassicSwap } from "./ClassicSwap.js"
|
|
9
|
+
|
|
10
|
+
interface FundProps {
|
|
11
|
+
selectedToken: Token | null
|
|
12
|
+
onSend: (amount: string, recipient: string) => void
|
|
13
|
+
onBack?: () => void
|
|
14
|
+
onConfirm: () => void
|
|
15
|
+
onComplete: (result: OnCompleteProps) => void
|
|
16
|
+
account: Account
|
|
17
|
+
toRecipient?: string
|
|
18
|
+
toAmount?: string
|
|
19
|
+
toChainId?: number
|
|
20
|
+
toToken?: string
|
|
21
|
+
toCalldata?: string
|
|
22
|
+
walletClient: WalletClient
|
|
23
|
+
onTransactionStateChange: (transactionStates: TransactionState[]) => void
|
|
24
|
+
onError: (error: Error | string | null) => void
|
|
25
|
+
onWaitingForWalletConfirm: (props: PrepareSendQuote) => void
|
|
26
|
+
paymasterUrls?: Array<{ chainId: number; url: string }>
|
|
27
|
+
gasless?: boolean
|
|
28
|
+
setWalletConfirmRetryHandler: (handler: () => Promise<void>) => void
|
|
29
|
+
quoteProvider?: string
|
|
30
|
+
fundMethod?: string
|
|
31
|
+
onNavigateToMeshConnect?: (
|
|
32
|
+
props: {
|
|
33
|
+
toTokenSymbol: string
|
|
34
|
+
toTokenAmount: string
|
|
35
|
+
toChainId: number
|
|
36
|
+
toRecipientAddress: string
|
|
37
|
+
},
|
|
38
|
+
quote?: PrepareSendQuote | null,
|
|
39
|
+
) => void
|
|
40
|
+
onAmountUpdate?: (amount: string) => void
|
|
41
|
+
checkoutOnHandlers?: CheckoutOnHandlers
|
|
42
|
+
recentTokens?: SupportedToken[]
|
|
43
|
+
onRecentTokenSelect?: (token: SupportedToken) => void
|
|
44
|
+
onTrackToken?: (token: any) => void
|
|
45
|
+
isSequenceWallet?: boolean
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export const Fund: React.FC<FundProps> = (props) => {
|
|
49
|
+
return <ClassicSwap {...props} title="Fund" />
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export default Fund
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { ChevronRight, QrCode, Send } from "lucide-react"
|
|
2
|
+
import type React from "react"
|
|
3
|
+
import { truncateAddress } from "../../utils.js"
|
|
4
|
+
import { useAccount } from "wagmi"
|
|
5
|
+
import { Identicon } from "./Identicon.js"
|
|
6
|
+
import { useBack } from "../hooks/useBack.js"
|
|
7
|
+
import { useSelectedFundMethod } from "../hooks/useSelectedFundMethod.js"
|
|
8
|
+
|
|
9
|
+
export const FundingMethodSelectorButton: React.FC = () => {
|
|
10
|
+
const { address, isConnected } = useAccount()
|
|
11
|
+
const { setCurrentScreenWithBack } = useBack()
|
|
12
|
+
const { selectedFundMethod } = useSelectedFundMethod()
|
|
13
|
+
|
|
14
|
+
const handleClick = () => {
|
|
15
|
+
if (isConnected && address) {
|
|
16
|
+
// If wallet is connected, go to fund methods
|
|
17
|
+
setCurrentScreenWithBack("fund-methods")
|
|
18
|
+
} else {
|
|
19
|
+
// If no wallet connected, go to connect wallet
|
|
20
|
+
setCurrentScreenWithBack("connect")
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
return (
|
|
25
|
+
<button
|
|
26
|
+
type="button"
|
|
27
|
+
onClick={handleClick}
|
|
28
|
+
className="flex items-center space-x-2 text-blue-500 hover:text-blue-600 transition-colors cursor-pointer bg-transparent border-none p-0"
|
|
29
|
+
title={
|
|
30
|
+
isConnected && address ? "Select funding method" : "Connect wallet"
|
|
31
|
+
}
|
|
32
|
+
>
|
|
33
|
+
{isConnected && address ? (
|
|
34
|
+
selectedFundMethod === "qr-code" ? (
|
|
35
|
+
<>
|
|
36
|
+
<QrCode className="w-4 h-4" />
|
|
37
|
+
<span className="text-sm font-medium">QR Code</span>
|
|
38
|
+
</>
|
|
39
|
+
) : selectedFundMethod === "exchange" ? (
|
|
40
|
+
<>
|
|
41
|
+
<Send className="w-4 h-4" />
|
|
42
|
+
<span className="text-sm font-medium">Exchange</span>
|
|
43
|
+
</>
|
|
44
|
+
) : (
|
|
45
|
+
<>
|
|
46
|
+
<Identicon value={address} size={16} />
|
|
47
|
+
<span className="text-sm font-medium">
|
|
48
|
+
{truncateAddress(address, 4, 2)}
|
|
49
|
+
</span>
|
|
50
|
+
</>
|
|
51
|
+
)
|
|
52
|
+
) : (
|
|
53
|
+
<span className="text-sm font-medium">Connect Wallet</span>
|
|
54
|
+
)}
|
|
55
|
+
<ChevronRight className="w-4 h-4" />
|
|
56
|
+
</button>
|
|
57
|
+
)
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export default FundingMethodSelectorButton
|
|
@@ -73,9 +73,13 @@ const Modal: React.FC<ModalProps> = ({ isOpen, onClose, children }) => {
|
|
|
73
73
|
<button
|
|
74
74
|
type="button"
|
|
75
75
|
onClick={onClose}
|
|
76
|
-
className="absolute right-
|
|
76
|
+
className="absolute right-4 top-6 flex h-8 w-8 justify-center items-center rounded-full bg-gray-50 dark:bg-gray-700 cursor-pointer transition-colors text-gray-900 dark:text-gray-200 hover:bg-gray-100 dark:hover:bg-gray-600 z-20"
|
|
77
|
+
title="Close"
|
|
77
78
|
>
|
|
78
|
-
<X
|
|
79
|
+
<X
|
|
80
|
+
className="h-4 w-4"
|
|
81
|
+
style={{ transform: "translate(0, -2px)" }}
|
|
82
|
+
/>
|
|
79
83
|
</button>
|
|
80
84
|
{children}
|
|
81
85
|
</motion.div>
|