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.
Files changed (161) hide show
  1. package/dist/aave.d.ts +8 -0
  2. package/dist/aave.d.ts.map +1 -1
  3. package/dist/{ccip-BlV1Mry3.js → ccip-CXlshvBY.js} +1 -1
  4. package/dist/config.d.ts +1 -1
  5. package/dist/config.d.ts.map +1 -1
  6. package/dist/constants.d.ts +1 -0
  7. package/dist/constants.d.ts.map +1 -1
  8. package/dist/error.d.ts +1 -0
  9. package/dist/error.d.ts.map +1 -1
  10. package/dist/estimate.d.ts +52 -0
  11. package/dist/estimate.d.ts.map +1 -1
  12. package/dist/{index-BNWCIGfQ.js → index-_QuyGrjU.js} +72332 -72246
  13. package/dist/index.js +2 -2
  14. package/dist/intents.d.ts +40 -0
  15. package/dist/intents.d.ts.map +1 -1
  16. package/dist/metaTxnMonitor.d.ts +3 -3
  17. package/dist/metaTxnMonitor.d.ts.map +1 -1
  18. package/dist/metaTxns.d.ts +3 -3
  19. package/dist/metaTxns.d.ts.map +1 -1
  20. package/dist/morpho.d.ts +8 -0
  21. package/dist/morpho.d.ts.map +1 -1
  22. package/dist/prepareSend.d.ts +16 -6
  23. package/dist/prepareSend.d.ts.map +1 -1
  24. package/dist/queryParams.d.ts.map +1 -1
  25. package/dist/relayer.d.ts +6 -6
  26. package/dist/relayer.d.ts.map +1 -1
  27. package/dist/sequenceWallet.d.ts +2 -2
  28. package/dist/sequenceWallet.d.ts.map +1 -1
  29. package/dist/tokens.d.ts.map +1 -1
  30. package/dist/wallets.d.ts.map +1 -1
  31. package/dist/widget/components/AccountActionsDropdown.d.ts.map +1 -1
  32. package/dist/widget/components/AccountSettings.d.ts.map +1 -1
  33. package/dist/widget/components/ClassicSwap.d.ts +2 -0
  34. package/dist/widget/components/ClassicSwap.d.ts.map +1 -1
  35. package/dist/widget/components/ConnectWallet.d.ts.map +1 -1
  36. package/dist/widget/components/ConnectedWallets.d.ts +4 -0
  37. package/dist/widget/components/ConnectedWallets.d.ts.map +1 -1
  38. package/dist/widget/components/Earn.d.ts.map +1 -1
  39. package/dist/widget/components/Fund.d.ts.map +1 -1
  40. package/dist/widget/components/FundMethods.d.ts.map +1 -1
  41. package/dist/widget/components/{FundSendForm.d.ts → FundSwap.d.ts} +11 -5
  42. package/dist/widget/components/FundSwap.d.ts.map +1 -0
  43. package/dist/widget/components/FundingMethodSelectorButton.d.ts +4 -0
  44. package/dist/widget/components/FundingMethodSelectorButton.d.ts.map +1 -0
  45. package/dist/widget/components/Modal.d.ts.map +1 -1
  46. package/dist/widget/components/Pay.d.ts.map +1 -1
  47. package/dist/widget/components/PercentageMaxButtons.d.ts +12 -0
  48. package/dist/widget/components/PercentageMaxButtons.d.ts.map +1 -0
  49. package/dist/widget/components/{PaySendForm.d.ts → PoolDeposit.d.ts} +11 -34
  50. package/dist/widget/components/PoolDeposit.d.ts.map +1 -0
  51. package/dist/widget/components/{SimpleSwap.d.ts → PoolWithdraw.d.ts} +16 -8
  52. package/dist/widget/components/PoolWithdraw.d.ts.map +1 -0
  53. package/dist/widget/components/QuoteDetails.d.ts.map +1 -1
  54. package/dist/widget/components/Receive.d.ts.map +1 -1
  55. package/dist/widget/components/RecipientSelectorButton.d.ts +4 -0
  56. package/dist/widget/components/RecipientSelectorButton.d.ts.map +1 -0
  57. package/dist/widget/components/Recipients.d.ts.map +1 -1
  58. package/dist/widget/components/RequiredPropsError.d.ts +8 -0
  59. package/dist/widget/components/RequiredPropsError.d.ts.map +1 -0
  60. package/dist/widget/components/ScreenHeader.d.ts.map +1 -1
  61. package/dist/widget/components/SlippageToleranceSettings.d.ts.map +1 -1
  62. package/dist/widget/components/Swap.d.ts +1 -0
  63. package/dist/widget/components/Swap.d.ts.map +1 -1
  64. package/dist/widget/components/SwapSettings.d.ts.map +1 -1
  65. package/dist/widget/components/TokenImage.d.ts +1 -0
  66. package/dist/widget/components/TokenImage.d.ts.map +1 -1
  67. package/dist/widget/components/TokenList.d.ts.map +1 -1
  68. package/dist/widget/components/TokenSelector.d.ts.map +1 -1
  69. package/dist/widget/components/TokenSelectorButton.d.ts +16 -0
  70. package/dist/widget/components/TokenSelectorButton.d.ts.map +1 -0
  71. package/dist/widget/components/UserPreferences.d.ts.map +1 -1
  72. package/dist/widget/components/WaasFeeOptions.d.ts +8 -0
  73. package/dist/widget/components/WaasFeeOptions.d.ts.map +1 -0
  74. package/dist/widget/components/WalletConfirmation.d.ts.map +1 -1
  75. package/dist/widget/components/WalletList.d.ts.map +1 -1
  76. package/dist/widget/css/compiled.css +2 -0
  77. package/dist/widget/css/index.css +554 -0
  78. package/dist/widget/hooks/useBack.d.ts +1 -0
  79. package/dist/widget/hooks/useBack.d.ts.map +1 -1
  80. package/dist/widget/hooks/useCheckout.d.ts +1 -1
  81. package/dist/widget/hooks/useCheckout.d.ts.map +1 -1
  82. package/dist/widget/hooks/useCurrentScreen.d.ts +1 -1
  83. package/dist/widget/hooks/useCurrentScreen.d.ts.map +1 -1
  84. package/dist/widget/hooks/useDefaultTokenSelection.d.ts +3 -3
  85. package/dist/widget/hooks/useDefaultTokenSelection.d.ts.map +1 -1
  86. package/dist/widget/hooks/usePayMessage.d.ts.map +1 -1
  87. package/dist/widget/hooks/useSelectedFundMethod.d.ts +12 -0
  88. package/dist/widget/hooks/useSelectedFundMethod.d.ts.map +1 -0
  89. package/dist/widget/hooks/useSelectedRecipient.d.ts.map +1 -1
  90. package/dist/widget/hooks/useSendForm.d.ts.map +1 -1
  91. package/dist/widget/index.js +1 -1
  92. package/dist/widget/widget.d.ts +4 -4
  93. package/dist/widget/widget.d.ts.map +1 -1
  94. package/package.json +18 -12
  95. package/src/aave.ts +32 -0
  96. package/src/config.ts +12 -4
  97. package/src/constants.ts +2 -0
  98. package/src/error.ts +19 -1
  99. package/src/estimate.ts +416 -5
  100. package/src/intents.ts +161 -11
  101. package/src/metaTxnMonitor.ts +3 -3
  102. package/src/metaTxns.ts +3 -5
  103. package/src/morpho.ts +32 -0
  104. package/src/prepareSend.ts +503 -166
  105. package/src/queryParams.ts +2 -1
  106. package/src/relayer.ts +11 -11
  107. package/src/sequenceWallet.ts +2 -2
  108. package/src/tokens.ts +7 -1
  109. package/src/wallets.ts +8 -0
  110. package/src/widget/compiled.css +2 -2
  111. package/src/widget/components/AccountActionsDropdown.tsx +3 -13
  112. package/src/widget/components/AccountSettings.tsx +6 -24
  113. package/src/widget/components/ClassicSwap.tsx +111 -155
  114. package/src/widget/components/ConnectWallet.tsx +4 -37
  115. package/src/widget/components/ConnectedWallets.tsx +113 -58
  116. package/src/widget/components/Earn.tsx +73 -589
  117. package/src/widget/components/Fund.tsx +31 -82
  118. package/src/widget/components/FundMethods.tsx +82 -159
  119. package/src/widget/components/FundSwap.tsx +52 -0
  120. package/src/widget/components/FundingMethodSelectorButton.tsx +60 -0
  121. package/src/widget/components/Modal.tsx +6 -2
  122. package/src/widget/components/Pay.tsx +183 -208
  123. package/src/widget/components/PercentageMaxButtons.tsx +77 -0
  124. package/src/widget/components/PoolDeposit.tsx +593 -0
  125. package/src/widget/components/PoolWithdraw.tsx +903 -0
  126. package/src/widget/components/QuoteDetails.tsx +22 -8
  127. package/src/widget/components/Receive.tsx +0 -2
  128. package/src/widget/components/RecipientSelectorButton.tsx +42 -0
  129. package/src/widget/components/Recipients.tsx +62 -156
  130. package/src/widget/components/RequiredPropsError.tsx +33 -0
  131. package/src/widget/components/ScreenHeader.tsx +5 -1
  132. package/src/widget/components/SlippageToleranceSettings.tsx +2 -1
  133. package/src/widget/components/Swap.tsx +2 -43
  134. package/src/widget/components/SwapSettings.tsx +2 -14
  135. package/src/widget/components/TokenImage.tsx +21 -4
  136. package/src/widget/components/TokenList.tsx +0 -1
  137. package/src/widget/components/TokenSelector.tsx +1 -0
  138. package/src/widget/components/TokenSelectorButton.tsx +75 -0
  139. package/src/widget/components/UserPreferences.tsx +6 -24
  140. package/src/widget/components/WaasFeeOptions.tsx +331 -0
  141. package/src/widget/components/WalletConfirmation.tsx +55 -3
  142. package/src/widget/components/WalletList.tsx +4 -2
  143. package/src/widget/hooks/useBack.tsx +2 -0
  144. package/src/widget/hooks/useCheckout.ts +36 -20
  145. package/src/widget/hooks/useCurrentScreen.tsx +1 -0
  146. package/src/widget/hooks/useDefaultTokenSelection.tsx +104 -28
  147. package/src/widget/hooks/usePayMessage.tsx +86 -11
  148. package/src/widget/hooks/useSelectedFundMethod.tsx +41 -0
  149. package/src/widget/hooks/useSelectedRecipient.tsx +10 -0
  150. package/src/widget/hooks/useSendForm.ts +24 -2
  151. package/src/widget/index.css +27 -0
  152. package/src/widget/widget.tsx +169 -111
  153. package/dist/widget/components/FundSendForm.d.ts.map +0 -1
  154. package/dist/widget/components/PaySendForm.d.ts.map +0 -1
  155. package/dist/widget/components/SimpleSwap.d.ts.map +0 -1
  156. package/dist/widget/hooks/useSwapSettings.d.ts +0 -16
  157. package/dist/widget/hooks/useSwapSettings.d.ts.map +0 -1
  158. package/src/widget/components/FundSendForm.tsx +0 -903
  159. package/src/widget/components/PaySendForm.tsx +0 -869
  160. package/src/widget/components/SimpleSwap.tsx +0 -983
  161. 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 and Percentage Buttons */}
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
- <button
873
- type="button"
874
- onClick={() => setShowOriginTokenSelector(true)}
875
- className="flex items-center space-x-2 trails-bg-card hover:trails-hover-bg trails-border-radius-input px-2.5 py-1.5 border trails-border-primary transition-colors cursor-pointer"
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
- <div className="text-xs trails-text-muted text-right">
914
- {originToken ? (
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
- <span>&nbsp;</span>
934
- )}
935
- </div>
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 { Wallet, QrCode, Building2 } from "lucide-react"
3
- import { useAccount } from "wagmi"
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 { address, isConnected, connector } = useAccount()
26
- const { getActiveTheme } = useTheme()
24
+ const { switchAccount } = useSwitchAccount()
25
+ const connections = useConnections()
26
+ const { setCurrentScreen } = useCurrentScreen()
27
+ const { setSelectedFundMethod } = useSelectedFundMethod()
27
28
 
28
- const activeTheme = getActiveTheme()
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="Funding Method"
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-3">
42
- <button
43
- type="button"
44
- onClick={onSelectConnectedAccount}
45
- className="w-full flex items-center justify-between cursor-pointer font-semibold py-4 px-6 trails-border-radius-large-button transition-all duration-200 trails-bg-secondary trails-hover-bg trails-text-primary"
46
- >
47
- <div className="flex items-center space-x-3 flex-1">
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
- <button
82
- type="button"
83
- onClick={onSelectWalletConnect}
84
- className="w-full flex items-center justify-between cursor-pointer font-semibold py-4 px-6 trails-border-radius-large-button transition-all duration-200 trails-bg-secondary trails-hover-bg trails-text-primary"
85
- >
86
- <div className="flex items-center space-x-3 flex-1">
87
- <div className="h-6 w-6 rounded flex items-center justify-center">
88
- <img
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
- <button
126
- type="button"
127
- onClick={onSelectQrCode}
128
- className="w-full flex items-center justify-between cursor-pointer font-semibold py-4 px-6 trails-border-radius-large-button transition-all duration-200 trails-bg-secondary trails-hover-bg trails-text-primary"
129
- >
130
- <div className="flex items-center space-x-3 flex-1">
131
- <QrCode className="h-6 w-6 text-gray-600 dark:text-gray-400" />
132
- <div className="flex-1 text-left">
133
- <h4 className="font-semibold text-gray-900 dark:text-gray-100">
134
- Pay with QR Code
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
- </div>
141
- <div className="text-gray-400">
142
- <svg
143
- className="w-5 h-5"
144
- fill="none"
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
- <button
160
- type="button"
161
- onClick={onSelectExchangeList}
162
- className="w-full flex items-center justify-between cursor-pointer font-semibold py-4 px-6 trails-border-radius-large-button transition-all duration-200 trails-bg-secondary trails-hover-bg trails-text-primary"
163
- >
164
- <div className="flex items-center space-x-3 flex-1">
165
- <Building2 className="h-6 w-6 text-gray-600 dark:text-gray-400" />
166
- <div className="flex-1 text-left">
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
- </div>
175
- <div className="text-gray-400">
176
- <svg
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-2 top-2 p-1 rounded-full transition-colors cursor-pointer z-10 hover:bg-gray-100 text-gray-600 dark:hover:bg-gray-800 dark:text-gray-400 z-20"
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 className="h-4 w-4" />
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>