@b3dotfun/sdk 0.0.83 → 0.0.84-alpha.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.
Files changed (133) hide show
  1. package/dist/cjs/anyspend/constants/index.d.ts +1 -1
  2. package/dist/cjs/anyspend/constants/index.js +2 -2
  3. package/dist/cjs/anyspend/react/components/AnySpend.js +21 -9
  4. package/dist/cjs/anyspend/react/components/AnySpendCustom.js +4 -3
  5. package/dist/cjs/anyspend/react/components/common/CryptoPaySection.js +2 -4
  6. package/dist/cjs/anyspend/react/components/common/CryptoPaymentMethodDisplay.d.ts +15 -0
  7. package/dist/cjs/anyspend/react/components/common/CryptoPaymentMethodDisplay.js +28 -0
  8. package/dist/cjs/anyspend/react/components/common/InsufficientDepositPayment.js +1 -1
  9. package/dist/cjs/anyspend/react/components/common/OrderDetails.js +5 -4
  10. package/dist/cjs/anyspend/react/components/common/OrderToken.js +2 -2
  11. package/dist/cjs/anyspend/react/components/common/OrderTokenAmount.js +1 -1
  12. package/dist/cjs/anyspend/react/components/common/OrderTokenAmountFiat.js +1 -1
  13. package/dist/cjs/anyspend/react/components/common/OrderTokenAmountNew.js +2 -2
  14. package/dist/cjs/anyspend/react/components/common/PaymentStripeWeb2.js +4 -6
  15. package/dist/cjs/anyspend/react/components/common/PaymentVendorUI.js +41 -2
  16. package/dist/cjs/anyspend/react/components/common/TransferCryptoDetails.js +1 -1
  17. package/dist/cjs/anyspend/react/components/webview/WebviewOnrampPayment.js +2 -3
  18. package/dist/cjs/anyspend/react/hooks/index.d.ts +1 -0
  19. package/dist/cjs/anyspend/react/hooks/index.js +1 -0
  20. package/dist/cjs/anyspend/react/hooks/useConnectedUserProfile.d.ts +2 -1
  21. package/dist/cjs/anyspend/react/hooks/useConnectedUserProfile.js +5 -8
  22. package/dist/cjs/anyspend/react/hooks/useConnectedWalletDisplay.d.ts +0 -2
  23. package/dist/cjs/anyspend/react/hooks/useConnectedWalletDisplay.js +2 -12
  24. package/dist/cjs/anyspend/react/hooks/useHyperliquidTransfer.d.ts +37 -0
  25. package/dist/cjs/anyspend/react/hooks/useHyperliquidTransfer.js +133 -0
  26. package/dist/cjs/anyspend/react/providers/AnyspendProvider.js +1 -13
  27. package/dist/cjs/anyspend/types/chain.d.ts +10 -2
  28. package/dist/cjs/anyspend/types/chain.js +1 -0
  29. package/dist/cjs/anyspend/utils/address.d.ts +11 -0
  30. package/dist/cjs/anyspend/utils/address.js +15 -0
  31. package/dist/cjs/anyspend/utils/chain.d.ts +20 -1
  32. package/dist/cjs/anyspend/utils/chain.js +73 -4
  33. package/dist/cjs/anyspend/utils/token.d.ts +1 -0
  34. package/dist/cjs/anyspend/utils/token.js +19 -6
  35. package/dist/cjs/global-account/react/components/B3Provider/B3Provider.js +1 -1
  36. package/dist/cjs/global-account/react/components/SignInWithB3/SignIn.js +3 -4
  37. package/dist/cjs/global-account/react/components/SignInWithB3/steps/LoginStep.js +1 -1
  38. package/dist/cjs/global-account/react/hooks/index.d.ts +0 -1
  39. package/dist/cjs/global-account/react/hooks/index.js +1 -3
  40. package/dist/cjs/global-account/react/hooks/useAccountWallet.js +11 -10
  41. package/dist/cjs/shared/utils/payment.utils.d.ts +1 -0
  42. package/dist/cjs/shared/utils/payment.utils.js +9 -0
  43. package/dist/esm/anyspend/constants/index.d.ts +1 -1
  44. package/dist/esm/anyspend/constants/index.js +1 -1
  45. package/dist/esm/anyspend/react/components/AnySpend.js +22 -10
  46. package/dist/esm/anyspend/react/components/AnySpendCustom.js +5 -4
  47. package/dist/esm/anyspend/react/components/common/CryptoPaySection.js +4 -6
  48. package/dist/esm/anyspend/react/components/common/CryptoPaymentMethodDisplay.d.ts +15 -0
  49. package/dist/esm/anyspend/react/components/common/CryptoPaymentMethodDisplay.js +25 -0
  50. package/dist/esm/anyspend/react/components/common/InsufficientDepositPayment.js +2 -2
  51. package/dist/esm/anyspend/react/components/common/OrderDetails.js +6 -5
  52. package/dist/esm/anyspend/react/components/common/OrderToken.js +3 -3
  53. package/dist/esm/anyspend/react/components/common/OrderTokenAmount.js +2 -2
  54. package/dist/esm/anyspend/react/components/common/OrderTokenAmountFiat.js +2 -2
  55. package/dist/esm/anyspend/react/components/common/OrderTokenAmountNew.js +3 -3
  56. package/dist/esm/anyspend/react/components/common/PaymentStripeWeb2.js +2 -4
  57. package/dist/esm/anyspend/react/components/common/PaymentVendorUI.js +9 -3
  58. package/dist/esm/anyspend/react/components/common/TransferCryptoDetails.js +2 -2
  59. package/dist/esm/anyspend/react/components/webview/WebviewOnrampPayment.js +3 -4
  60. package/dist/esm/anyspend/react/hooks/index.d.ts +1 -0
  61. package/dist/esm/anyspend/react/hooks/index.js +1 -0
  62. package/dist/esm/anyspend/react/hooks/useConnectedUserProfile.d.ts +2 -1
  63. package/dist/esm/anyspend/react/hooks/useConnectedUserProfile.js +6 -9
  64. package/dist/esm/anyspend/react/hooks/useConnectedWalletDisplay.d.ts +0 -2
  65. package/dist/esm/anyspend/react/hooks/useConnectedWalletDisplay.js +2 -12
  66. package/dist/esm/anyspend/react/hooks/useHyperliquidTransfer.d.ts +37 -0
  67. package/dist/esm/anyspend/react/hooks/useHyperliquidTransfer.js +127 -0
  68. package/dist/esm/anyspend/react/providers/AnyspendProvider.js +1 -13
  69. package/dist/esm/anyspend/types/chain.d.ts +10 -2
  70. package/dist/esm/anyspend/types/chain.js +1 -0
  71. package/dist/esm/anyspend/utils/address.d.ts +11 -0
  72. package/dist/esm/anyspend/utils/address.js +14 -0
  73. package/dist/esm/anyspend/utils/chain.d.ts +20 -1
  74. package/dist/esm/anyspend/utils/chain.js +70 -4
  75. package/dist/esm/anyspend/utils/token.d.ts +1 -0
  76. package/dist/esm/anyspend/utils/token.js +19 -7
  77. package/dist/esm/global-account/react/components/B3Provider/B3Provider.js +2 -2
  78. package/dist/esm/global-account/react/components/SignInWithB3/SignIn.js +4 -5
  79. package/dist/esm/global-account/react/components/SignInWithB3/steps/LoginStep.js +1 -1
  80. package/dist/esm/global-account/react/hooks/index.d.ts +0 -1
  81. package/dist/esm/global-account/react/hooks/index.js +0 -1
  82. package/dist/esm/global-account/react/hooks/useAccountWallet.js +11 -10
  83. package/dist/esm/shared/utils/payment.utils.d.ts +1 -0
  84. package/dist/esm/shared/utils/payment.utils.js +9 -1
  85. package/dist/types/anyspend/constants/index.d.ts +1 -1
  86. package/dist/types/anyspend/react/components/common/CryptoPaymentMethodDisplay.d.ts +15 -0
  87. package/dist/types/anyspend/react/hooks/index.d.ts +1 -0
  88. package/dist/types/anyspend/react/hooks/useConnectedUserProfile.d.ts +2 -1
  89. package/dist/types/anyspend/react/hooks/useConnectedWalletDisplay.d.ts +0 -2
  90. package/dist/types/anyspend/react/hooks/useHyperliquidTransfer.d.ts +37 -0
  91. package/dist/types/anyspend/types/chain.d.ts +10 -2
  92. package/dist/types/anyspend/utils/address.d.ts +11 -0
  93. package/dist/types/anyspend/utils/chain.d.ts +20 -1
  94. package/dist/types/anyspend/utils/token.d.ts +1 -0
  95. package/dist/types/global-account/react/hooks/index.d.ts +0 -1
  96. package/dist/types/shared/utils/payment.utils.d.ts +1 -0
  97. package/package.json +1 -1
  98. package/src/anyspend/constants/index.ts +1 -1
  99. package/src/anyspend/react/components/AnySpend.tsx +31 -9
  100. package/src/anyspend/react/components/AnySpendCustom.tsx +9 -25
  101. package/src/anyspend/react/components/common/CryptoPaySection.tsx +7 -30
  102. package/src/anyspend/react/components/common/CryptoPaymentMethodDisplay.tsx +64 -0
  103. package/src/anyspend/react/components/common/InsufficientDepositPayment.tsx +2 -2
  104. package/src/anyspend/react/components/common/OrderDetails.tsx +6 -5
  105. package/src/anyspend/react/components/common/OrderToken.tsx +5 -5
  106. package/src/anyspend/react/components/common/OrderTokenAmount.tsx +3 -3
  107. package/src/anyspend/react/components/common/OrderTokenAmountFiat.tsx +3 -3
  108. package/src/anyspend/react/components/common/OrderTokenAmountNew.tsx +6 -6
  109. package/src/anyspend/react/components/common/PaymentStripeWeb2.tsx +3 -5
  110. package/src/anyspend/react/components/common/PaymentVendorUI.tsx +26 -2
  111. package/src/anyspend/react/components/common/TransferCryptoDetails.tsx +2 -2
  112. package/src/anyspend/react/components/webview/WebviewOnrampPayment.tsx +3 -5
  113. package/src/anyspend/react/hooks/index.ts +1 -0
  114. package/src/anyspend/react/hooks/useConnectedUserProfile.ts +7 -10
  115. package/src/anyspend/react/hooks/useConnectedWalletDisplay.ts +2 -15
  116. package/src/anyspend/react/hooks/useHyperliquidTransfer.ts +152 -0
  117. package/src/anyspend/react/providers/AnyspendProvider.tsx +7 -22
  118. package/src/anyspend/types/chain.ts +10 -1
  119. package/src/anyspend/utils/address.ts +15 -0
  120. package/src/anyspend/utils/chain.ts +84 -4
  121. package/src/anyspend/utils/token.ts +20 -7
  122. package/src/global-account/react/components/B3Provider/B3Provider.tsx +6 -2
  123. package/src/global-account/react/components/SignInWithB3/SignIn.tsx +4 -6
  124. package/src/global-account/react/components/SignInWithB3/steps/LoginStep.tsx +1 -1
  125. package/src/global-account/react/hooks/index.ts +0 -1
  126. package/src/global-account/react/hooks/useAccountWallet.tsx +12 -11
  127. package/src/shared/utils/payment.utils.ts +10 -1
  128. package/dist/cjs/global-account/react/hooks/useBestTransactionPath.d.ts +0 -41
  129. package/dist/cjs/global-account/react/hooks/useBestTransactionPath.js +0 -148
  130. package/dist/esm/global-account/react/hooks/useBestTransactionPath.d.ts +0 -41
  131. package/dist/esm/global-account/react/hooks/useBestTransactionPath.js +0 -145
  132. package/dist/types/global-account/react/hooks/useBestTransactionPath.d.ts +0 -41
  133. package/src/global-account/react/hooks/useBestTransactionPath.tsx +0 -201
@@ -1,6 +1,13 @@
1
1
  "use client";
2
2
 
3
- import { getDefaultToken, USDC_BASE } from "@b3dotfun/sdk/anyspend";
3
+ import {
4
+ eqci,
5
+ getDefaultToken,
6
+ getHyperliquidUSDCToken,
7
+ HYPERLIQUID_CHAIN_ID,
8
+ USDC_BASE,
9
+ ZERO_ADDRESS,
10
+ } from "@b3dotfun/sdk/anyspend";
4
11
  import {
5
12
  useAnyspendCreateOnrampOrder,
6
13
  useAnyspendCreateOrder,
@@ -224,14 +231,17 @@ function AnySpendInner({
224
231
  // State for destination chain/token selection
225
232
  const [selectedDstChainId, setSelectedDstChainId] = useState<number>(initialDstChainId);
226
233
  const defaultDstToken = isBuyMode
227
- ? {
228
- symbol: "",
229
- chainId: destinationTokenChainId,
230
- address: destinationTokenAddress,
231
- name: "",
232
- decimals: 18,
233
- metadata: {},
234
- }
234
+ ? // Special case: Hyperliquid uses zero address for USDC
235
+ destinationTokenChainId === HYPERLIQUID_CHAIN_ID && eqci(destinationTokenAddress, ZERO_ADDRESS)
236
+ ? getHyperliquidUSDCToken()
237
+ : {
238
+ symbol: "",
239
+ chainId: destinationTokenChainId,
240
+ address: destinationTokenAddress,
241
+ name: "",
242
+ decimals: 18,
243
+ metadata: {},
244
+ }
235
245
  : getDefaultToken(selectedDstChainId);
236
246
  const dstTokenFromUrl = useTokenFromUrl({
237
247
  defaultToken: defaultDstToken,
@@ -277,6 +287,12 @@ function AnySpendInner({
277
287
  // Update destination token with metadata
278
288
  useEffect(() => {
279
289
  if (selectedDstToken && dstTokenMetadata && !appliedDstMetadataRef.current) {
290
+ // Skip metadata enhancement for Hyperliquid USDC - we already have correct metadata from getHyperliquidUSDCToken()
291
+ if (selectedDstToken.chainId === HYPERLIQUID_CHAIN_ID && eqci(selectedDstToken.address, ZERO_ADDRESS)) {
292
+ appliedDstMetadataRef.current = true;
293
+ return;
294
+ }
295
+
280
296
  // Mark as applied
281
297
  appliedDstMetadataRef.current = true;
282
298
 
@@ -1126,12 +1142,18 @@ function AnySpendInner({
1126
1142
  "border-as-stroke bg-as-surface-primary absolute left-1/2 top-1/2 z-10 h-10 w-10 -translate-x-1/2 -translate-y-1/2 rounded-xl border-2 sm:h-8 sm:w-8 sm:rounded-xl",
1127
1143
  isBuyMode && "top-[calc(50%+56px)] cursor-default",
1128
1144
  activeTab === "fiat" && "hidden",
1145
+ selectedDstChainId === HYPERLIQUID_CHAIN_ID && "cursor-not-allowed opacity-50",
1129
1146
  )}
1130
1147
  onClick={() => {
1131
1148
  if (activeTab === "fiat" || isBuyMode) {
1132
1149
  return;
1133
1150
  }
1134
1151
 
1152
+ // Prevent swapping if destination is Hyperliquid (only supported as destination, not source)
1153
+ if (selectedDstChainId === HYPERLIQUID_CHAIN_ID) {
1154
+ return;
1155
+ }
1156
+
1135
1157
  // Swap chain selections
1136
1158
  const tempSrcChainId = selectedSrcChainId;
1137
1159
  const tempDstChainId = selectedDstChainId;
@@ -1,5 +1,5 @@
1
1
  import { eqci, getDefaultToken, roundUpUSDCBaseAmountToNearest } from "@b3dotfun/sdk/anyspend";
2
- import { RELAY_ETH_ADDRESS, USDC_BASE } from "@b3dotfun/sdk/anyspend/constants";
2
+ import { USDC_BASE, ZERO_ADDRESS } from "@b3dotfun/sdk/anyspend/constants";
3
3
  import {
4
4
  CreateOrderParams,
5
5
  useAnyspendCreateOnrampOrder,
@@ -48,6 +48,7 @@ import { useCryptoPaymentMethodState } from "../hooks/useCryptoPaymentMethodStat
48
48
  import { useRecipientAddressState } from "../hooks/useRecipientAddressState";
49
49
  import { AnySpendFingerprintWrapper, getFingerprintConfig } from "./AnySpendFingerprintWrapper";
50
50
  import { CryptoPaymentMethod, CryptoPaymentMethodType } from "./common/CryptoPaymentMethod";
51
+ import { CryptoPaymentMethodDisplay } from "./common/CryptoPaymentMethodDisplay";
51
52
  import { FeeBreakDown } from "./common/FeeBreakDown";
52
53
  import { FIAT_PAYMENT_METHOD_DISPLAY, FiatPaymentMethod, FiatPaymentMethodComponent } from "./common/FiatPaymentMethod";
53
54
  import { OrderDetails } from "./common/OrderDetails";
@@ -295,7 +296,7 @@ function AnySpendCustomInner({
295
296
  // First check native tokens (ETH, etc.)
296
297
  const nativeToken = nativeTokens?.find(t => t.chainId === srcChainId && Number(t.displayValue) > 0);
297
298
  if (nativeToken) {
298
- const matchingToken = tokenList.find(t => t.address === RELAY_ETH_ADDRESS);
299
+ const matchingToken = tokenList.find(t => t.address === ZERO_ADDRESS);
299
300
  if (matchingToken) return matchingToken;
300
301
  }
301
302
 
@@ -469,7 +470,7 @@ function AnySpendCustomInner({
469
470
 
470
471
  const isCreatingOrder = isCreatingRegularOrder || isCreatingOnrampOrder;
471
472
 
472
- const { address: connectedAddress, name: connectedName } = useConnectedUserProfile();
473
+ const { address: connectedAddress, name: connectedName } = useConnectedUserProfile(effectiveCryptoPaymentMethod);
473
474
  const recipientProfile = useProfile({ address: recipientAddress });
474
475
  const recipientName = recipientProfile.data?.name;
475
476
 
@@ -951,28 +952,11 @@ function AnySpendCustomInner({
951
952
  className="text-as-tertiarry flex flex-wrap items-center justify-end gap-2 text-sm transition-colors hover:text-blue-700"
952
953
  onClick={() => setActivePanel(PanelView.CRYPTO_PAYMENT_METHOD)}
953
954
  >
954
- {effectiveCryptoPaymentMethod === CryptoPaymentMethodType.CONNECT_WALLET ? (
955
- <>
956
- {connectedAddress ? (
957
- <span className="text-as-tertiarry whitespace-nowrap">
958
- {connectedName ? formatUsername(connectedName) : shortenAddress(connectedAddress || "")}
959
- </span>
960
- ) : (
961
- <span className="whitespace-nowrap">Connect wallet</span>
962
- )}
963
- <ChevronRight className="h-4 w-4 shrink-0" />
964
- </>
965
- ) : effectiveCryptoPaymentMethod === CryptoPaymentMethodType.TRANSFER_CRYPTO ? (
966
- <>
967
- <span className="whitespace-nowrap">Transfer crypto</span>
968
- <ChevronRight className="h-4 w-4 shrink-0" />
969
- </>
970
- ) : (
971
- <>
972
- <span className="whitespace-nowrap">Select payment method</span>
973
- <ChevronRight className="h-4 w-4 shrink-0" />
974
- </>
975
- )}
955
+ <CryptoPaymentMethodDisplay
956
+ paymentMethod={effectiveCryptoPaymentMethod}
957
+ connectedAddress={connectedAddress}
958
+ connectedName={connectedName}
959
+ />
976
960
  </button>
977
961
  </motion.div>
978
962
 
@@ -1,13 +1,12 @@
1
1
  import { useProfile, useTokenData } from "@b3dotfun/sdk/global-account/react";
2
- import { formatUsername } from "@b3dotfun/sdk/shared/utils";
3
- import { shortenAddress } from "@b3dotfun/sdk/shared/utils/formatAddress";
4
2
  import { formatDisplayNumber } from "@b3dotfun/sdk/shared/utils/number";
5
- import { ChevronRight, Info } from "lucide-react";
3
+ import { Info } from "lucide-react";
6
4
  import { motion } from "motion/react";
7
5
  import { useEffect, useRef } from "react";
8
6
  import { components } from "../../../types/api";
9
7
  import { useConnectedWalletDisplay } from "../../hooks/useConnectedWalletDisplay";
10
8
  import { CryptoPaymentMethodType } from "./CryptoPaymentMethod";
9
+ import { CryptoPaymentMethodDisplay } from "./CryptoPaymentMethodDisplay";
11
10
  import { OrderTokenAmount } from "./OrderTokenAmount";
12
11
  import { TokenBalance } from "./TokenBalance";
13
12
 
@@ -103,33 +102,11 @@ export function CryptoPaySection({
103
102
  className="text-as-tertiarry flex h-7 items-center gap-2 text-sm transition-colors focus:!outline-none"
104
103
  onClick={onSelectCryptoPaymentMethod}
105
104
  >
106
- {selectedCryptoPaymentMethod === CryptoPaymentMethodType.CONNECT_WALLET ? (
107
- <>
108
- {walletAddress ? (
109
- <div className="flex items-center gap-1">
110
- {connectedName ? formatUsername(connectedName) : shortenAddress(walletAddress || "")}
111
- </div>
112
- ) : (
113
- "Connect wallet"
114
- )}
115
- <ChevronRight className="h-4 w-4" />
116
- </>
117
- ) : selectedCryptoPaymentMethod === CryptoPaymentMethodType.GLOBAL_WALLET ? (
118
- <>
119
- Global Account
120
- <ChevronRight className="h-4 w-4" />
121
- </>
122
- ) : selectedCryptoPaymentMethod === CryptoPaymentMethodType.TRANSFER_CRYPTO ? (
123
- <>
124
- Transfer crypto
125
- <ChevronRight className="h-4 w-4" />
126
- </>
127
- ) : (
128
- <>
129
- Select payment method
130
- <ChevronRight className="h-4 w-4" />
131
- </>
132
- )}
105
+ <CryptoPaymentMethodDisplay
106
+ paymentMethod={selectedCryptoPaymentMethod}
107
+ connectedAddress={walletAddress}
108
+ connectedName={connectedName}
109
+ />
133
110
  </button>
134
111
  </div>
135
112
  <OrderTokenAmount
@@ -0,0 +1,64 @@
1
+ import { formatUsername } from "@b3dotfun/sdk/shared/utils";
2
+ import { shortenAddress } from "@b3dotfun/sdk/shared/utils/formatAddress";
3
+ import { ChevronRight } from "lucide-react";
4
+ import { CryptoPaymentMethodType } from "./CryptoPaymentMethod";
5
+
6
+ interface CryptoPaymentMethodDisplayProps {
7
+ paymentMethod: CryptoPaymentMethodType;
8
+ connectedAddress?: string | null;
9
+ connectedName?: string | null;
10
+ }
11
+
12
+ /**
13
+ * Displays the selected crypto payment method with appropriate label
14
+ * - CONNECT_WALLET: Shows wallet address/name or "Connect wallet"
15
+ * - GLOBAL_WALLET: Shows "Global Account"
16
+ * - TRANSFER_CRYPTO: Shows "Transfer crypto"
17
+ * - NONE: Shows "Select payment method"
18
+ */
19
+ export function CryptoPaymentMethodDisplay({
20
+ paymentMethod,
21
+ connectedAddress,
22
+ connectedName,
23
+ }: CryptoPaymentMethodDisplayProps) {
24
+ if (paymentMethod === CryptoPaymentMethodType.CONNECT_WALLET) {
25
+ return (
26
+ <>
27
+ {connectedAddress ? (
28
+ <span className="text-as-tertiarry whitespace-nowrap">
29
+ {connectedName ? formatUsername(connectedName) : shortenAddress(connectedAddress)}
30
+ </span>
31
+ ) : (
32
+ <span className="whitespace-nowrap">Connect wallet</span>
33
+ )}
34
+ <ChevronRight className="h-4 w-4 shrink-0" />
35
+ </>
36
+ );
37
+ }
38
+
39
+ if (paymentMethod === CryptoPaymentMethodType.GLOBAL_WALLET) {
40
+ return (
41
+ <>
42
+ <span className="whitespace-nowrap">Global Account</span>
43
+ <ChevronRight className="h-4 w-4 shrink-0" />
44
+ </>
45
+ );
46
+ }
47
+
48
+ if (paymentMethod === CryptoPaymentMethodType.TRANSFER_CRYPTO) {
49
+ return (
50
+ <>
51
+ <span className="whitespace-nowrap">Transfer crypto</span>
52
+ <ChevronRight className="h-4 w-4 shrink-0" />
53
+ </>
54
+ );
55
+ }
56
+
57
+ // NONE or any other case
58
+ return (
59
+ <>
60
+ <span className="whitespace-nowrap">Select payment method</span>
61
+ <ChevronRight className="h-4 w-4 shrink-0" />
62
+ </>
63
+ );
64
+ }
@@ -4,8 +4,8 @@ import {
4
4
  ALL_CHAINS,
5
5
  getChainName,
6
6
  getPaymentUrl,
7
- RELAY_ETH_ADDRESS,
8
7
  RELAY_SOLANA_MAINNET_CHAIN_ID,
8
+ ZERO_ADDRESS,
9
9
  } from "@b3dotfun/sdk/anyspend";
10
10
  import { components } from "@b3dotfun/sdk/anyspend/types/api";
11
11
  import { Badge, CopyToClipboard, ShinyButton, TextLoop } from "@b3dotfun/sdk/global-account/react";
@@ -121,7 +121,7 @@ export function InsufficientDepositPayment({
121
121
  value={getPaymentUrl(
122
122
  order.globalAddress,
123
123
  BigInt(depositDeficit),
124
- order.srcTokenAddress === RELAY_ETH_ADDRESS ? srcToken?.symbol || "ETH" : order.srcTokenAddress,
124
+ order.srcTokenAddress === ZERO_ADDRESS ? srcToken?.symbol || "ETH" : order.srcTokenAddress,
125
125
  order.srcChain,
126
126
  srcToken?.decimals,
127
127
  )}
@@ -8,8 +8,8 @@ import {
8
8
  getPaymentUrl,
9
9
  getStatusDisplay,
10
10
  isNativeToken,
11
- RELAY_ETH_ADDRESS,
12
11
  RELAY_SOLANA_MAINNET_CHAIN_ID,
12
+ ZERO_ADDRESS,
13
13
  } from "@b3dotfun/sdk/anyspend";
14
14
  import { components } from "@b3dotfun/sdk/anyspend/types/api";
15
15
  import {
@@ -327,16 +327,17 @@ export const OrderDetails = memo(function OrderDetails({
327
327
  // Main payment handler that triggers chain switch and payment
328
328
  const handlePayment = useCallback(async () => {
329
329
  console.log("Initiating payment process. Target chain:", order.srcChain, "Current chain:", walletClient?.chain?.id);
330
+ const amountToSend = depositDeficit > BigInt(0) ? depositDeficit.toString() : order.srcAmount;
330
331
  if (order.srcChain === RELAY_SOLANA_MAINNET_CHAIN_ID) {
331
- // Use the existing depositDeficit calculation to determine amount to send
332
- const amountToSend = depositDeficit > BigInt(0) ? depositDeficit.toString() : order.srcAmount;
332
+ // Solana payment flow
333
333
  await initiatePhantomTransfer({
334
334
  amountLamports: amountToSend,
335
335
  tokenAddress: order.srcTokenAddress,
336
336
  recipientAddress: order.globalAddress,
337
337
  });
338
338
  } else {
339
- // Use unified payment process for both EOA and AA wallets
339
+ // EVM payment flow (EOA and AA wallets)
340
+ // Note: Hyperliquid is NOT supported as source chain, only as destination chain
340
341
  await handleUnifiedPaymentProcess();
341
342
  }
342
343
  }, [order, walletClient?.chain?.id, depositDeficit, handleUnifiedPaymentProcess, initiatePhantomTransfer]);
@@ -1039,7 +1040,7 @@ export const OrderDetails = memo(function OrderDetails({
1039
1040
  value={getPaymentUrl(
1040
1041
  order.globalAddress,
1041
1042
  BigInt(order.srcAmount),
1042
- order.srcTokenAddress === RELAY_ETH_ADDRESS ? srcToken?.symbol || "ETH" : order.srcTokenAddress,
1043
+ order.srcTokenAddress === ZERO_ADDRESS ? srcToken?.symbol || "ETH" : order.srcTokenAddress,
1043
1044
  order.srcChain,
1044
1045
  srcToken?.decimals,
1045
1046
  )}
@@ -1,6 +1,7 @@
1
1
  "use client";
2
2
 
3
- import { ALL_CHAINS, RELAY_ETH_ADDRESS, RELAY_SOLANA_MAINNET_CHAIN_ID } from "@b3dotfun/sdk/anyspend";
3
+ import { ALL_CHAINS, RELAY_SOLANA_MAINNET_CHAIN_ID, ZERO_ADDRESS, getAvailableChainIds } from "@b3dotfun/sdk/anyspend";
4
+ import { components } from "@b3dotfun/sdk/anyspend/types/api";
4
5
  import { Button, useAccountWallet, useTokenBalancesByChain } from "@b3dotfun/sdk/global-account/react";
5
6
  import { cn } from "@b3dotfun/sdk/shared/utils";
6
7
  import { formatTokenAmount } from "@b3dotfun/sdk/shared/utils/number";
@@ -9,7 +10,6 @@ import { TokenSelector } from "@relayprotocol/relay-kit-ui";
9
10
  import { CheckCircle2, ChevronsUpDown } from "lucide-react";
10
11
  import { useMemo } from "react";
11
12
  import { ChainTokenIcon } from "./ChainTokenIcon";
12
- import { components } from "@b3dotfun/sdk/anyspend/types/api";
13
13
 
14
14
  export function OrderToken({
15
15
  context,
@@ -44,7 +44,7 @@ export function OrderToken({
44
44
  // Get balance for the selected token
45
45
  let balance: bigint | null = null;
46
46
  if (token && wallet?.address) {
47
- if (token.address === RELAY_ETH_ADDRESS) {
47
+ if (token.address === ZERO_ADDRESS) {
48
48
  // Native token
49
49
  const nativeToken = nativeTokens?.find(t => t.chainId === chainId);
50
50
  balance = nativeToken?.value ?? null;
@@ -69,12 +69,12 @@ export function OrderToken({
69
69
  return (
70
70
  <TokenSelector
71
71
  address={address}
72
- chainIdsFilter={Object.values(ALL_CHAINS).map(chain => chain.id)}
72
+ chainIdsFilter={getAvailableChainIds(context)}
73
73
  context={context}
74
74
  fromChainWalletVMSupported={true}
75
75
  isValidAddress={true}
76
76
  key={undefined}
77
- lockedChainIds={Object.values(ALL_CHAINS).map(chain => chain.id)}
77
+ lockedChainIds={getAvailableChainIds(context)}
78
78
  multiWalletSupportEnabled={true}
79
79
  onAnalyticEvent={undefined}
80
80
  popularChainIds={[1, 8453, RELAY_SOLANA_MAINNET_CHAIN_ID]}
@@ -5,7 +5,7 @@ import { useEffect, useRef } from "react";
5
5
  import { NumericFormat } from "react-number-format";
6
6
  import { formatUnits } from "viem";
7
7
 
8
- import { ALL_CHAINS, RELAY_SOLANA_MAINNET_CHAIN_ID } from "@b3dotfun/sdk/anyspend";
8
+ import { ALL_CHAINS, RELAY_SOLANA_MAINNET_CHAIN_ID, getAvailableChainIds } from "@b3dotfun/sdk/anyspend";
9
9
  import { components } from "@b3dotfun/sdk/anyspend/types/api";
10
10
  import { getNativeRequired } from "@b3dotfun/sdk/anyspend/utils/chain";
11
11
  import { isNativeToken } from "@b3dotfun/sdk/anyspend/utils/token";
@@ -163,12 +163,12 @@ export function OrderTokenAmount({
163
163
  {!hideTokenSelect && (
164
164
  <TokenSelector
165
165
  address={address}
166
- chainIdsFilter={Object.values(ALL_CHAINS).map(chain => chain.id)}
166
+ chainIdsFilter={getAvailableChainIds(context)}
167
167
  context={context}
168
168
  fromChainWalletVMSupported={true}
169
169
  isValidAddress={true}
170
170
  key={`selector-${context}-${token.address}-${chainId}`}
171
- lockedChainIds={Object.values(ALL_CHAINS).map(chain => chain.id)}
171
+ lockedChainIds={getAvailableChainIds(context)}
172
172
  multiWalletSupportEnabled={true}
173
173
  onAnalyticEvent={undefined}
174
174
  popularChainIds={[1, 8453, RELAY_SOLANA_MAINNET_CHAIN_ID]}
@@ -4,7 +4,7 @@ import { ChevronsUpDown } from "lucide-react";
4
4
  import { useEffect, useRef } from "react";
5
5
  import { NumericFormat } from "react-number-format";
6
6
 
7
- import { ALL_CHAINS, RELAY_SOLANA_MAINNET_CHAIN_ID } from "@b3dotfun/sdk/anyspend";
7
+ import { ALL_CHAINS, RELAY_SOLANA_MAINNET_CHAIN_ID, getAvailableChainIds } from "@b3dotfun/sdk/anyspend";
8
8
  import { components } from "@b3dotfun/sdk/anyspend/types/api";
9
9
  import { cn } from "@b3dotfun/sdk/shared/utils";
10
10
  import { TokenSelector } from "@relayprotocol/relay-kit-ui";
@@ -79,12 +79,12 @@ export function OrderTokenAmountFiat({
79
79
  return (
80
80
  <TokenSelector
81
81
  address={address}
82
- chainIdsFilter={Object.values(ALL_CHAINS).map(chain => chain.id)}
82
+ chainIdsFilter={getAvailableChainIds(context)}
83
83
  context={context}
84
84
  fromChainWalletVMSupported={true}
85
85
  isValidAddress={true}
86
86
  key={`selector-${context}-${token.address}-${chainId}`}
87
- lockedChainIds={Object.values(ALL_CHAINS).map(chain => chain.id)}
87
+ lockedChainIds={getAvailableChainIds(context)}
88
88
  multiWalletSupportEnabled={true}
89
89
  onAnalyticEvent={undefined}
90
90
  popularChainIds={[1, 8453, RELAY_SOLANA_MAINNET_CHAIN_ID]}
@@ -4,12 +4,12 @@ import { ChevronsUpDown } from "lucide-react";
4
4
  import { useEffect, useRef } from "react";
5
5
  import { NumericFormat } from "react-number-format";
6
6
 
7
- import { ALL_CHAINS, RELAY_SOLANA_MAINNET_CHAIN_ID } from "@b3dotfun/sdk/anyspend";
7
+ import { ALL_CHAINS, RELAY_SOLANA_MAINNET_CHAIN_ID, getAvailableChainIds } from "@b3dotfun/sdk/anyspend";
8
+ import { components } from "@b3dotfun/sdk/anyspend/types/api";
8
9
  import { Button } from "@b3dotfun/sdk/global-account/react";
9
10
  import { cn } from "@b3dotfun/sdk/shared/utils";
10
11
  import { TokenSelector } from "@relayprotocol/relay-kit-ui";
11
12
  import { ChainTokenIcon } from "./ChainTokenIcon";
12
- import { components } from "@b3dotfun/sdk/anyspend/types/api";
13
13
 
14
14
  export function OrderTokenAmountFiat({
15
15
  disabled,
@@ -118,12 +118,12 @@ export function OrderTokenAmountFiat({
118
118
  {!hideTokenSelect && (
119
119
  <TokenSelector
120
120
  address={address}
121
- chainIdsFilter={Object.values(ALL_CHAINS).map(chain => chain.id)}
121
+ chainIdsFilter={getAvailableChainIds(context)}
122
122
  context={context}
123
123
  fromChainWalletVMSupported={true}
124
124
  isValidAddress={true}
125
125
  key={`selector-${context}-${token.address}-${chainId}`}
126
- lockedChainIds={Object.values(ALL_CHAINS).map(chain => chain.id)}
126
+ lockedChainIds={getAvailableChainIds(context)}
127
127
  multiWalletSupportEnabled={true}
128
128
  onAnalyticEvent={undefined}
129
129
  popularChainIds={[1, 8453, RELAY_SOLANA_MAINNET_CHAIN_ID]}
@@ -173,12 +173,12 @@ export function OrderTokenAmountFiat({
173
173
  {!hideTokenSelect && (
174
174
  <TokenSelector
175
175
  address={address}
176
- chainIdsFilter={Object.values(ALL_CHAINS).map(chain => chain.id)}
176
+ chainIdsFilter={getAvailableChainIds(context)}
177
177
  context={context}
178
178
  fromChainWalletVMSupported={true}
179
179
  isValidAddress={true}
180
180
  key={`selector-${context}-${token.address}-${chainId}`}
181
- lockedChainIds={Object.values(ALL_CHAINS).map(chain => chain.id)}
181
+ lockedChainIds={getAvailableChainIds(context)}
182
182
  multiWalletSupportEnabled={true}
183
183
  onAnalyticEvent={undefined}
184
184
  popularChainIds={[1, 8453, RELAY_SOLANA_MAINNET_CHAIN_ID]}
@@ -1,19 +1,17 @@
1
- import { STRIPE_CONFIG } from "@b3dotfun/sdk/anyspend/constants";
1
+ import { getStripePromise } from "@b3dotfun/sdk/shared/utils/payment.utils";
2
2
  import { OrderDetailsCollapsible, useStripeClientSecret } from "@b3dotfun/sdk/anyspend/react";
3
3
  import { components } from "@b3dotfun/sdk/anyspend/types/api";
4
4
  import { ShinyButton, useB3, useModalStore, useProfile } from "@b3dotfun/sdk/global-account/react";
5
5
  import { formatTokenAmount } from "@b3dotfun/sdk/shared/utils/number";
6
6
  import { formatStripeAmount } from "@b3dotfun/sdk/shared/utils/payment.utils";
7
7
  import { AddressElement, Elements, PaymentElement, useElements, useStripe } from "@stripe/react-stripe-js";
8
- import { loadStripe, PaymentIntentResult, StripePaymentElementOptions } from "@stripe/stripe-js";
8
+ import { PaymentIntentResult, StripePaymentElementOptions } from "@stripe/stripe-js";
9
9
  import { X } from "lucide-react";
10
10
  import { useEffect, useState } from "react";
11
11
  import { AnySpendFingerprintWrapper, getFingerprintConfig } from "../AnySpendFingerprintWrapper";
12
12
  import HowItWorks from "./HowItWorks";
13
13
  import PaymentMethodIcons from "./PaymentMethodIcons";
14
14
 
15
- const stripePromise = loadStripe(STRIPE_CONFIG.publishableKey);
16
-
17
15
  interface PaymentStripeWeb2Props {
18
16
  order: components["schemas"]["Order"];
19
17
  stripePaymentIntentId: string;
@@ -38,7 +36,7 @@ export default function PaymentStripeWeb2({ order, stripePaymentIntentId, onPaym
38
36
  return (
39
37
  <AnySpendFingerprintWrapper fingerprint={fingerprintConfig}>
40
38
  <Elements
41
- stripe={stripePromise}
39
+ stripe={getStripePromise()}
42
40
  options={{
43
41
  clientSecret: clientSecret || undefined,
44
42
  appearance: { theme: theme === "light" ? "stripe" : "night" },
@@ -1,12 +1,32 @@
1
+ import { lazy, Suspense } from "react";
1
2
  import { components } from "@b3dotfun/sdk/anyspend/types/api";
2
3
  import PaymentOneClick from "./PaymentOneClick";
3
- import PaymentStripeWeb2 from "./PaymentStripeWeb2";
4
+
5
+ // Lazy load Stripe component to prevent loadStripe() from running at module level
6
+ // This prevents EIP-6963 wallet detection events when Stripe is not used
7
+ const PaymentStripeWeb2 = lazy(() => import("./PaymentStripeWeb2"));
4
8
 
5
9
  interface PaymentVendorUIProps {
6
10
  order: components["schemas"]["Order"];
7
11
  dstTokenSymbol: string;
8
12
  }
9
13
 
14
+ function StripeLoadingFallback() {
15
+ return (
16
+ <div className="relative my-8 flex w-full flex-1 flex-col items-center justify-center">
17
+ <div className="bg-as-on-surface-1 flex w-full flex-col items-center justify-center gap-4 rounded-2xl p-8">
18
+ <div className="bg-as-brand/20 flex h-16 w-16 items-center justify-center rounded-full">
19
+ <div className="text-as-brand h-8 w-8 animate-spin rounded-full border-2 border-current border-t-transparent" />
20
+ </div>
21
+ <div className="text-as-primary/70 text-center">
22
+ <div className="text-lg font-medium">Loading payment</div>
23
+ <div className="text-as-primary/50 mt-2 text-sm">Initializing secure payment form...</div>
24
+ </div>
25
+ </div>
26
+ </div>
27
+ );
28
+ }
29
+
10
30
  export default function PaymentVendorUI({ order, dstTokenSymbol }: PaymentVendorUIProps) {
11
31
  const vendor = order.onrampMetadata?.vendor;
12
32
 
@@ -17,7 +37,11 @@ export default function PaymentVendorUI({ order, dstTokenSymbol }: PaymentVendor
17
37
 
18
38
  // Handle Stripe Web2 payment flow
19
39
  if (vendor === "stripe-web2" && order.stripePaymentIntentId) {
20
- return <PaymentStripeWeb2 order={order} stripePaymentIntentId={order.stripePaymentIntentId} />;
40
+ return (
41
+ <Suspense fallback={<StripeLoadingFallback />}>
42
+ <PaymentStripeWeb2 order={order} stripePaymentIntentId={order.stripePaymentIntentId} />
43
+ </Suspense>
44
+ );
21
45
  }
22
46
 
23
47
  // Return null for unsupported vendors
@@ -1,6 +1,6 @@
1
1
  "use client";
2
2
 
3
- import { ALL_CHAINS, getChainName, getPaymentUrl, RELAY_ETH_ADDRESS } from "@b3dotfun/sdk/anyspend";
3
+ import { ALL_CHAINS, getChainName, getPaymentUrl, ZERO_ADDRESS } from "@b3dotfun/sdk/anyspend";
4
4
  import { components } from "@b3dotfun/sdk/anyspend/types/api";
5
5
  import { CopyToClipboard, ShinyButton, TextLoop, toast } from "@b3dotfun/sdk/global-account/react";
6
6
  import { cn } from "@b3dotfun/sdk/shared/utils";
@@ -206,7 +206,7 @@ export const TransferCryptoDetails = memo(function TransferCryptoDetails({
206
206
  value={getPaymentUrl(
207
207
  order.globalAddress,
208
208
  BigInt(order.srcAmount),
209
- order.srcTokenAddress === RELAY_ETH_ADDRESS ? "ETH" : order.srcTokenAddress,
209
+ order.srcTokenAddress === ZERO_ADDRESS ? "ETH" : order.srcTokenAddress,
210
210
  order.srcChain,
211
211
  srcToken?.decimals,
212
212
  )}
@@ -1,11 +1,11 @@
1
- import { getChainName, STRIPE_CONFIG } from "@b3dotfun/sdk/anyspend";
1
+ import { getChainName } from "@b3dotfun/sdk/anyspend";
2
+ import { getStripePromise } from "@b3dotfun/sdk/shared/utils/payment.utils";
2
3
  import { useAnyspendCreateOnrampOrder, useGeoOnrampOptions, useStripeClientSecret } from "@b3dotfun/sdk/anyspend/react";
3
4
  import { components } from "@b3dotfun/sdk/anyspend/types/api";
4
5
  import { GetQuoteResponse } from "@b3dotfun/sdk/anyspend/types/api_req_res";
5
6
  import { toast } from "@b3dotfun/sdk/global-account/react";
6
7
  import centerTruncate from "@b3dotfun/sdk/shared/utils/centerTruncate";
7
8
  import { AddressElement, Elements, PaymentElement, useElements, useStripe } from "@stripe/react-stripe-js";
8
- import { loadStripe } from "@stripe/stripe-js";
9
9
  import { Loader2 } from "lucide-react";
10
10
  import { motion } from "motion/react";
11
11
  import { useEffect, useRef, useState } from "react";
@@ -13,8 +13,6 @@ import { useEffect, useRef, useState } from "react";
13
13
  import { formatUnits } from "viem";
14
14
  import { AnySpendFingerprintWrapper, getFingerprintConfig } from "../AnySpendFingerprintWrapper";
15
15
 
16
- const stripePromise = loadStripe(STRIPE_CONFIG.publishableKey);
17
-
18
16
  interface WebviewOnrampPaymentProps {
19
17
  srcAmountOnRamp: string;
20
18
  recipientAddress?: string;
@@ -309,7 +307,7 @@ function WebviewOnrampPaymentInner({
309
307
 
310
308
  {/* Stripe Elements */}
311
309
  <Elements
312
- stripe={stripePromise}
310
+ stripe={getStripePromise()}
313
311
  options={{
314
312
  clientSecret,
315
313
  appearance: {
@@ -8,6 +8,7 @@ export * from "./useCoinbaseOnrampOptions";
8
8
  export * from "./useConnectedUserProfile";
9
9
  export * from "./useGeoOnrampOptions";
10
10
  export * from "./useGetGeo";
11
+ export * from "./useHyperliquidTransfer";
11
12
  export * from "./useRecipientAddressState";
12
13
  export * from "./useSigMint";
13
14
  export * from "./useStripeClientSecret";
@@ -1,22 +1,19 @@
1
- import { useAccountWallet, useProfile } from "@b3dotfun/sdk/global-account/react";
2
- import { useConnectedWallets } from "thirdweb/react";
1
+ import { useProfile } from "@b3dotfun/sdk/global-account/react";
2
+ import { CryptoPaymentMethodType } from "../components/common/CryptoPaymentMethod";
3
+ import { useConnectedWalletDisplay } from "./useConnectedWalletDisplay";
3
4
 
4
5
  /**
5
6
  * Hook that provides connected user's address, profile, and cleaned display name
6
7
  * Combines logic for getting connected address from either global account or thirdweb wallets
7
8
  */
8
- export function useConnectedUserProfile() {
9
- const { address: globalAddress } = useAccountWallet();
10
- const connectedWallets = useConnectedWallets();
11
-
12
- // Get connected address from global account or first connected wallet
13
- const connectedAddress = globalAddress || connectedWallets?.[0]?.getAccount()?.address;
9
+ export function useConnectedUserProfile(selectedCryptoPaymentMethod?: CryptoPaymentMethodType) {
10
+ const { walletAddress } = useConnectedWalletDisplay(selectedCryptoPaymentMethod);
14
11
 
15
12
  // Fetch profile data for the connected address with cleaned name
16
- const connectedProfile = useProfile({ address: connectedAddress });
13
+ const connectedProfile = useProfile({ address: walletAddress });
17
14
 
18
15
  return {
19
- address: connectedAddress,
16
+ address: walletAddress,
20
17
  profile: connectedProfile,
21
18
  name: connectedProfile.data?.name,
22
19
  isLoading: connectedProfile.isLoading,