@b3dotfun/sdk 0.0.20 → 0.0.21-alpha.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (152) hide show
  1. package/README.md +28 -0
  2. package/dist/cjs/anyspend/index.native.d.ts +0 -2
  3. package/dist/cjs/anyspend/index.native.js +0 -4
  4. package/dist/cjs/anyspend/react/components/AnySpend.d.ts +3 -3
  5. package/dist/cjs/anyspend/react/components/AnySpend.js +43 -55
  6. package/dist/cjs/anyspend/react/components/AnySpendCustom.d.ts +1 -1
  7. package/dist/cjs/anyspend/react/components/AnySpendCustom.js +159 -84
  8. package/dist/cjs/anyspend/react/components/AnySpendFingerprintWrapper.d.ts +1 -1
  9. package/dist/cjs/anyspend/react/components/AnySpendFingerprintWrapper.js +2 -5
  10. package/dist/cjs/anyspend/react/components/AnySpendNFT.js +1 -1
  11. package/dist/cjs/anyspend/react/components/common/ConnectWalletPayment.js +1 -1
  12. package/dist/cjs/anyspend/react/components/common/CryptoPaymentMethod.d.ts +4 -4
  13. package/dist/cjs/anyspend/react/components/common/CryptoPaymentMethod.js +50 -102
  14. package/dist/cjs/anyspend/react/components/common/FiatPaymentMethod.js +1 -1
  15. package/dist/cjs/anyspend/react/components/common/OrderDetails.d.ts +2 -2
  16. package/dist/cjs/anyspend/react/components/common/OrderDetails.js +7 -9
  17. package/dist/cjs/anyspend/react/components/common/OrderStatus.js +2 -2
  18. package/dist/cjs/anyspend/react/components/common/PaymentStripeWeb2.js +1 -3
  19. package/dist/cjs/anyspend/react/components/common/RecipientSelection.d.ts +42 -0
  20. package/dist/cjs/anyspend/react/components/common/RecipientSelection.example.d.ts +7 -0
  21. package/dist/cjs/anyspend/react/components/common/RecipientSelection.example.js +27 -0
  22. package/dist/cjs/anyspend/react/components/common/RecipientSelection.js +36 -0
  23. package/dist/cjs/anyspend/react/components/common/TransferCryptoDetails.js +1 -1
  24. package/dist/cjs/anyspend/react/components/index.d.ts +1 -0
  25. package/dist/cjs/anyspend/react/components/index.js +3 -1
  26. package/dist/cjs/anyspend/react/hooks/index.d.ts +1 -0
  27. package/dist/cjs/anyspend/react/hooks/index.js +1 -0
  28. package/dist/cjs/anyspend/react/hooks/useConnectedUserProfile.d.ts +12 -0
  29. package/dist/cjs/anyspend/react/hooks/useConnectedUserProfile.js +25 -0
  30. package/dist/cjs/anyspend/react/hooks/useSigMint.d.ts +5 -5
  31. package/dist/cjs/anyspend/react/index.d.ts +1 -1
  32. package/dist/cjs/anyspend/react/index.js +1 -1
  33. package/dist/cjs/anyspend/react/providers/index.d.ts +2 -0
  34. package/dist/cjs/anyspend/react/providers/index.js +18 -0
  35. package/dist/cjs/anyspend/types/api.d.ts +35 -56
  36. package/dist/cjs/anyspend/utils/chain.d.ts +1 -1
  37. package/dist/cjs/anyspend/utils/chain.js +122 -15
  38. package/dist/cjs/global-account/react/components/B3Provider/B3Provider.d.ts +5 -1
  39. package/dist/cjs/global-account/react/components/B3Provider/B3Provider.js +2 -2
  40. package/dist/cjs/global-account/react/components/SignInWithB3/SignInWithB3Flow.js +2 -0
  41. package/dist/cjs/global-account/react/components/SignInWithB3/SignInWithB3Privy.js +1 -1
  42. package/dist/cjs/global-account/react/components/SignInWithB3/steps/LoginStep.js +3 -0
  43. package/dist/cjs/global-account/react/components/SignInWithB3/steps/LoginStepCustom.js +4 -1
  44. package/dist/cjs/global-account/react/hooks/index.d.ts +1 -1
  45. package/dist/cjs/global-account/react/hooks/useAuthentication.js +4 -1
  46. package/dist/cjs/global-account/react/hooks/useProfile.d.ts +2 -1
  47. package/dist/cjs/global-account/react/hooks/useProfile.js +9 -7
  48. package/dist/cjs/shared/constants/index.js +5 -3
  49. package/dist/cjs/shared/utils/formatUsername.d.ts +1 -1
  50. package/dist/cjs/shared/utils/formatUsername.js +3 -1
  51. package/dist/esm/anyspend/index.native.d.ts +0 -2
  52. package/dist/esm/anyspend/index.native.js +0 -4
  53. package/dist/esm/anyspend/react/components/AnySpend.d.ts +3 -3
  54. package/dist/esm/anyspend/react/components/AnySpend.js +46 -58
  55. package/dist/esm/anyspend/react/components/AnySpendCustom.d.ts +1 -1
  56. package/dist/esm/anyspend/react/components/AnySpendCustom.js +163 -88
  57. package/dist/esm/anyspend/react/components/AnySpendFingerprintWrapper.d.ts +1 -1
  58. package/dist/esm/anyspend/react/components/AnySpendFingerprintWrapper.js +2 -5
  59. package/dist/esm/anyspend/react/components/AnySpendNFT.js +1 -1
  60. package/dist/esm/anyspend/react/components/common/ConnectWalletPayment.js +1 -1
  61. package/dist/esm/anyspend/react/components/common/CryptoPaymentMethod.d.ts +4 -4
  62. package/dist/esm/anyspend/react/components/common/CryptoPaymentMethod.js +52 -104
  63. package/dist/esm/anyspend/react/components/common/FiatPaymentMethod.js +1 -1
  64. package/dist/esm/anyspend/react/components/common/OrderDetails.d.ts +2 -2
  65. package/dist/esm/anyspend/react/components/common/OrderDetails.js +8 -10
  66. package/dist/esm/anyspend/react/components/common/OrderStatus.js +2 -2
  67. package/dist/esm/anyspend/react/components/common/PaymentStripeWeb2.js +1 -3
  68. package/dist/esm/anyspend/react/components/common/RecipientSelection.d.ts +42 -0
  69. package/dist/esm/anyspend/react/components/common/RecipientSelection.example.d.ts +7 -0
  70. package/dist/esm/anyspend/react/components/common/RecipientSelection.example.js +22 -0
  71. package/dist/esm/anyspend/react/components/common/RecipientSelection.js +33 -0
  72. package/dist/esm/anyspend/react/components/common/TransferCryptoDetails.js +1 -1
  73. package/dist/esm/anyspend/react/components/index.d.ts +1 -0
  74. package/dist/esm/anyspend/react/components/index.js +1 -0
  75. package/dist/esm/anyspend/react/hooks/index.d.ts +1 -0
  76. package/dist/esm/anyspend/react/hooks/index.js +1 -0
  77. package/dist/esm/anyspend/react/hooks/useConnectedUserProfile.d.ts +12 -0
  78. package/dist/esm/anyspend/react/hooks/useConnectedUserProfile.js +22 -0
  79. package/dist/esm/anyspend/react/hooks/useSigMint.d.ts +5 -5
  80. package/dist/esm/anyspend/react/index.d.ts +1 -1
  81. package/dist/esm/anyspend/react/index.js +1 -1
  82. package/dist/esm/anyspend/react/providers/index.d.ts +2 -0
  83. package/dist/esm/anyspend/react/providers/index.js +2 -0
  84. package/dist/esm/anyspend/types/api.d.ts +35 -56
  85. package/dist/esm/anyspend/utils/chain.d.ts +1 -1
  86. package/dist/esm/anyspend/utils/chain.js +122 -15
  87. package/dist/esm/global-account/react/components/B3Provider/B3Provider.d.ts +5 -1
  88. package/dist/esm/global-account/react/components/B3Provider/B3Provider.js +2 -2
  89. package/dist/esm/global-account/react/components/SignInWithB3/SignInWithB3Flow.js +2 -0
  90. package/dist/esm/global-account/react/components/SignInWithB3/SignInWithB3Privy.js +2 -2
  91. package/dist/esm/global-account/react/components/SignInWithB3/steps/LoginStep.js +4 -1
  92. package/dist/esm/global-account/react/components/SignInWithB3/steps/LoginStepCustom.js +4 -1
  93. package/dist/esm/global-account/react/hooks/index.d.ts +1 -1
  94. package/dist/esm/global-account/react/hooks/useAuthentication.js +4 -1
  95. package/dist/esm/global-account/react/hooks/useProfile.d.ts +2 -1
  96. package/dist/esm/global-account/react/hooks/useProfile.js +9 -7
  97. package/dist/esm/shared/constants/index.js +5 -3
  98. package/dist/esm/shared/utils/formatUsername.d.ts +1 -1
  99. package/dist/esm/shared/utils/formatUsername.js +3 -1
  100. package/dist/styles/index.css +1 -1
  101. package/dist/types/anyspend/index.native.d.ts +0 -2
  102. package/dist/types/anyspend/react/components/AnySpend.d.ts +3 -3
  103. package/dist/types/anyspend/react/components/AnySpendCustom.d.ts +1 -1
  104. package/dist/types/anyspend/react/components/AnySpendFingerprintWrapper.d.ts +1 -1
  105. package/dist/types/anyspend/react/components/common/CryptoPaymentMethod.d.ts +4 -4
  106. package/dist/types/anyspend/react/components/common/OrderDetails.d.ts +2 -2
  107. package/dist/types/anyspend/react/components/common/RecipientSelection.d.ts +42 -0
  108. package/dist/types/anyspend/react/components/common/RecipientSelection.example.d.ts +7 -0
  109. package/dist/types/anyspend/react/components/index.d.ts +1 -0
  110. package/dist/types/anyspend/react/hooks/index.d.ts +1 -0
  111. package/dist/types/anyspend/react/hooks/useConnectedUserProfile.d.ts +12 -0
  112. package/dist/types/anyspend/react/hooks/useSigMint.d.ts +5 -5
  113. package/dist/types/anyspend/react/index.d.ts +1 -1
  114. package/dist/types/anyspend/react/providers/index.d.ts +2 -0
  115. package/dist/types/anyspend/types/api.d.ts +35 -56
  116. package/dist/types/anyspend/utils/chain.d.ts +1 -1
  117. package/dist/types/global-account/react/components/B3Provider/B3Provider.d.ts +5 -1
  118. package/dist/types/global-account/react/hooks/index.d.ts +1 -1
  119. package/dist/types/global-account/react/hooks/useProfile.d.ts +2 -1
  120. package/dist/types/shared/utils/formatUsername.d.ts +1 -1
  121. package/package.json +2 -2
  122. package/src/anyspend/index.native.ts +0 -6
  123. package/src/anyspend/react/components/AnySpend.tsx +110 -134
  124. package/src/anyspend/react/components/AnySpendCustom.tsx +488 -196
  125. package/src/anyspend/react/components/AnySpendFingerprintWrapper.tsx +4 -8
  126. package/src/anyspend/react/components/AnySpendNFT.tsx +1 -1
  127. package/src/anyspend/react/components/common/ConnectWalletPayment.tsx +1 -1
  128. package/src/anyspend/react/components/common/CryptoPaymentMethod.tsx +76 -108
  129. package/src/anyspend/react/components/common/FiatPaymentMethod.tsx +1 -1
  130. package/src/anyspend/react/components/common/OrderDetails.tsx +12 -13
  131. package/src/anyspend/react/components/common/OrderStatus.tsx +2 -2
  132. package/src/anyspend/react/components/common/PaymentStripeWeb2.tsx +1 -3
  133. package/src/anyspend/react/components/common/RecipientSelection.example.tsx +52 -0
  134. package/src/anyspend/react/components/common/RecipientSelection.tsx +146 -0
  135. package/src/anyspend/react/components/common/TransferCryptoDetails.tsx +1 -0
  136. package/src/anyspend/react/components/index.ts +1 -0
  137. package/src/anyspend/react/hooks/index.ts +1 -0
  138. package/src/anyspend/react/hooks/useConnectedUserProfile.ts +26 -0
  139. package/src/anyspend/react/index.ts +1 -1
  140. package/src/anyspend/react/providers/index.ts +2 -0
  141. package/src/anyspend/types/api.ts +37 -58
  142. package/src/anyspend/utils/chain.ts +126 -18
  143. package/src/global-account/react/components/B3Provider/B3Provider.tsx +6 -1
  144. package/src/global-account/react/components/SignInWithB3/SignInWithB3Flow.tsx +2 -0
  145. package/src/global-account/react/components/SignInWithB3/SignInWithB3Privy.tsx +2 -2
  146. package/src/global-account/react/components/SignInWithB3/steps/LoginStep.tsx +4 -1
  147. package/src/global-account/react/components/SignInWithB3/steps/LoginStepCustom.tsx +4 -1
  148. package/src/global-account/react/hooks/index.ts +1 -1
  149. package/src/global-account/react/hooks/useAuthentication.ts +4 -2
  150. package/src/global-account/react/hooks/useProfile.ts +10 -5
  151. package/src/shared/constants/index.ts +5 -3
  152. package/src/shared/utils/formatUsername.ts +3 -2
@@ -16,4 +16,4 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./components"), exports);
18
18
  __exportStar(require("./hooks"), exports);
19
- __exportStar(require("./providers/AnyspendProvider"), exports);
19
+ __exportStar(require("./providers"), exports);
@@ -0,0 +1,2 @@
1
+ export * from "./AnyspendProvider";
2
+ export * from "./StripeRedirectHandler";
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./AnyspendProvider"), exports);
18
+ __exportStar(require("./StripeRedirectHandler"), exports);
@@ -51,10 +51,6 @@ export interface paths {
51
51
  metadata: {
52
52
  /** @description Token logo URI */
53
53
  logoURI: string;
54
- /** @description Whether token is verified */
55
- verified: boolean;
56
- /** @description Whether token is native to chain */
57
- isNative: boolean;
58
54
  };
59
55
  }[];
60
56
  /** @example 200 */
@@ -430,12 +426,8 @@ export interface paths {
430
426
  * "createdAt": 1752505817654
431
427
  * } */
432
428
  relayTx: components["schemas"]["RelayTx"] | null;
433
- /** @example null */
434
429
  executeTx: components["schemas"]["ExecuteTx"] | null;
435
- /**
436
- * @description Refund transactions if order failed
437
- * @example null
438
- */
430
+ /** @description Refund transactions if order failed */
439
431
  refundTxs: components["schemas"]["RefundTx"][] | null;
440
432
  };
441
433
  /** @example 200 */
@@ -643,8 +635,6 @@ export interface paths {
643
635
  metadata?: {
644
636
  /** @example https://assets.relay.link/icons/1/light.png */
645
637
  logoURI?: string;
646
- /** @example true */
647
- verified?: boolean;
648
638
  };
649
639
  };
650
640
  /**
@@ -684,8 +674,6 @@ export interface paths {
684
674
  metadata?: {
685
675
  /** @example https://coin-images.coingecko.com/coins/images/6319/large/usdc.png?1696506694 */
686
676
  logoURI?: string;
687
- /** @example true */
688
- verified?: boolean;
689
677
  };
690
678
  };
691
679
  /**
@@ -1026,7 +1014,7 @@ export interface components {
1026
1014
  expectedDstAmount: string;
1027
1015
  /**
1028
1016
  * @description Actual received amount (null for new orders)
1029
- * @example null
1017
+ * @example 990000
1030
1018
  */
1031
1019
  actualDstAmount: string | null;
1032
1020
  };
@@ -1062,7 +1050,7 @@ export interface components {
1062
1050
  contractAddress: string;
1063
1051
  /**
1064
1052
  * @description Token ID (for ERC1155, null for ERC721)
1065
- * @example null
1053
+ * @example 1
1066
1054
  */
1067
1055
  tokenId: number | null;
1068
1056
  /**
@@ -1179,10 +1167,7 @@ export interface components {
1179
1167
  * @enum {string}
1180
1168
  */
1181
1169
  status: "scanning_deposit_transaction" | "waiting_stripe_payment" | "expired" | "sending_token_from_vault" | "relay" | "executed" | "refunding" | "refunded" | "failure";
1182
- /**
1183
- * @description Error details if order failed
1184
- * @example null
1185
- */
1170
+ /** @description Error details if order failed */
1186
1171
  errorDetails: string | null;
1187
1172
  /**
1188
1173
  * @description Creation timestamp
@@ -1199,17 +1184,11 @@ export interface components {
1199
1184
  * @example 0xb34facb90a200251318e8841c05102366f2158cf
1200
1185
  */
1201
1186
  creatorAddress: string | null;
1202
- /**
1203
- * @description Optional partner identifier
1204
- * @example null
1205
- */
1187
+ /** @description Optional partner identifier */
1206
1188
  partnerId: string | null;
1207
1189
  /** @description Onramp configuration if used */
1208
1190
  onrampMetadata: components["schemas"]["OnrampMetadata"] | null;
1209
- /**
1210
- * @description Quick purchase URL if available
1211
- * @example null
1212
- */
1191
+ /** @description Quick purchase URL if available */
1213
1192
  oneClickBuyUrl: string | null;
1214
1193
  /**
1215
1194
  * @description Stripe payment intent ID if using Stripe
@@ -1628,34 +1607,6 @@ export interface components {
1628
1607
  */
1629
1608
  createdAt: number;
1630
1609
  };
1631
- StripeWeb2Support: {
1632
- /**
1633
- * @example false
1634
- * @constant
1635
- */
1636
- isSupport: false;
1637
- } | {
1638
- /**
1639
- * @example true
1640
- * @constant
1641
- */
1642
- isSupport: true;
1643
- /**
1644
- * @description Total payment amount formatted in USD
1645
- * @example 10.00
1646
- */
1647
- formattedTotalUsd: string;
1648
- /**
1649
- * @description Onramp amount formatted in USD
1650
- * @example 9.50
1651
- */
1652
- formattedOnrampUsd: string;
1653
- /**
1654
- * @description Stripe fee formatted in USD
1655
- * @example 0.50
1656
- */
1657
- formattedFeeUsd: string;
1658
- };
1659
1610
  /** @description NFT contract details */
1660
1611
  NftContract: {
1661
1612
  /**
@@ -1696,7 +1647,7 @@ export interface components {
1696
1647
  description: string;
1697
1648
  /**
1698
1649
  * @description Token ID (null for ERC721, specific ID for ERC1155)
1699
- * @example null
1650
+ * @example 1
1700
1651
  */
1701
1652
  tokenId: number | null;
1702
1653
  /**
@@ -1706,6 +1657,34 @@ export interface components {
1706
1657
  */
1707
1658
  type: "erc721" | "erc1155";
1708
1659
  };
1660
+ StripeWeb2Support: {
1661
+ /**
1662
+ * @example false
1663
+ * @constant
1664
+ */
1665
+ isSupport: false;
1666
+ } | {
1667
+ /**
1668
+ * @example true
1669
+ * @constant
1670
+ */
1671
+ isSupport: true;
1672
+ /**
1673
+ * @description Total payment amount formatted in USD
1674
+ * @example 10.00
1675
+ */
1676
+ formattedTotalUsd: string;
1677
+ /**
1678
+ * @description Onramp amount formatted in USD
1679
+ * @example 9.50
1680
+ */
1681
+ formattedOnrampUsd: string;
1682
+ /**
1683
+ * @description Stripe fee formatted in USD
1684
+ * @example 0.50
1685
+ */
1686
+ formattedFeeUsd: string;
1687
+ };
1709
1688
  };
1710
1689
  responses: never;
1711
1690
  parameters: never;
@@ -18,7 +18,7 @@ export declare function isMainnet(chainId: number): boolean;
18
18
  export declare function isTestnet(chainId: number): boolean;
19
19
  export declare function getDefaultToken(chainId: number): components["schemas"]["Token"];
20
20
  export declare function getChainName(chainId: number): string;
21
- export declare function getPaymentUrl(address: string, amount: bigint, currency: string, chainId: number): string;
21
+ export declare function getPaymentUrl(address: string, amount: bigint, currency: string, chainId: number, decimals?: number): string;
22
22
  export declare function getExplorerTxUrl(chainId: number, txHash: string): string;
23
23
  export declare function getExplorerAddressUrl(chainId: number, address: string): string;
24
24
  export declare function getMulticall3Address(chainId: number): string;
@@ -260,7 +260,7 @@ function getChainName(chainId) {
260
260
  (0, invariant_1.default)(exports.ALL_CHAINS[chainId], `Chain ${chainId} is not supported`);
261
261
  return exports.EVM_CHAINS[chainId] ? exports.EVM_CHAINS[chainId].viem.name : "Solana";
262
262
  }
263
- function getPaymentUrl(address, amount, currency, chainId) {
263
+ function getPaymentUrl(address, amount, currency, chainId, decimals) {
264
264
  // Get chain type to determine URL format
265
265
  const chainType = getChainType(chainId);
266
266
  const chain = exports.ALL_CHAINS[chainId];
@@ -274,27 +274,134 @@ function getPaymentUrl(address, amount, currency, chainId) {
274
274
  if (currency === chain.nativeToken.symbol) {
275
275
  params.append("value", amount.toString());
276
276
  }
277
- // Add chain ID for non-Ethereum chains
278
- const chainParam = chainId !== chains_1.mainnet.id ? `@${chainId}` : "";
279
- // Add token info for non-native token transfers
277
+ // Handle token transfers differently from native transfers
280
278
  if (currency !== chain.nativeToken.symbol) {
281
- params.append("symbol", currency);
279
+ // For ERC20 tokens, the issue is that mobile wallets often ignore chainId
280
+ // and default to mainnet when they see ethereum: scheme
281
+ // Let's try a different approach: put chainId first and be very explicit
282
+ const tokenParams = new URLSearchParams();
283
+ // Put chainId first to make it more prominent
284
+ if (chainId !== chains_1.mainnet.id) {
285
+ tokenParams.append("chainId", chainId.toString());
286
+ }
287
+ // For ERC20 tokens, convert from smallest unit to display units using decimals
288
+ // For example: 2400623 (raw) with 6 decimals becomes "2.400623"
289
+ let displayAmount;
290
+ if (decimals !== undefined && currency !== chain.nativeToken.symbol) {
291
+ // Convert from smallest unit to display unit for ERC20 tokens
292
+ const divisor = BigInt(10 ** decimals);
293
+ const wholePart = amount / divisor;
294
+ const fractionalPart = amount % divisor;
295
+ if (fractionalPart === BigInt(0)) {
296
+ displayAmount = wholePart.toString();
297
+ }
298
+ else {
299
+ // Format fractional part with leading zeros if needed
300
+ const fractionalStr = fractionalPart.toString().padStart(decimals, "0");
301
+ // Remove trailing zeros
302
+ const trimmedFractional = fractionalStr.replace(/0+$/, "");
303
+ displayAmount = trimmedFractional ? `${wholePart}.${trimmedFractional}` : wholePart.toString();
304
+ }
305
+ }
306
+ else {
307
+ // For native tokens or when decimals not provided, use raw amount
308
+ displayAmount = amount.toString();
309
+ }
310
+ tokenParams.append("amount", displayAmount);
311
+ tokenParams.append("address", address); // recipient address
312
+ // For Arbitrum and other L2s, try a more explicit format
313
+ if (chainId !== chains_1.mainnet.id) {
314
+ // Include the token contract address in the path more explicitly
315
+ const url = `ethereum:${currency}@${chainId}?${tokenParams.toString()}`;
316
+ return url;
317
+ }
318
+ else {
319
+ // Mainnet tokens
320
+ const url = `ethereum:${currency}?${tokenParams.toString()}`;
321
+ return url;
322
+ }
323
+ }
324
+ // For native ETH transfers:
325
+ if (chainId !== chains_1.mainnet.id) {
326
+ // For non-mainnet chains, use the same explicit format as tokens
327
+ // to make sure wallets recognize the correct chain
328
+ const nativeParams = new URLSearchParams();
329
+ nativeParams.append("chainId", chainId.toString());
330
+ nativeParams.append("value", amount.toString());
331
+ const url = `ethereum:${address}@${chainId}?${nativeParams.toString()}`;
332
+ return url;
333
+ }
334
+ else {
335
+ // For mainnet, use the simple format
336
+ const queryString = params.toString();
337
+ const url = `ethereum:${address}${queryString ? `?${queryString}` : ""}`;
338
+ return url;
282
339
  }
283
- const queryString = params.toString();
284
- return `ethereum:${address}${chainParam}${queryString ? `?${queryString}` : ""}`;
285
340
  }
286
341
  case chain_1.ChainType.SOLANA: {
287
- // Solana URL format: solana:${address}?amount=${amount}&spl-token=${tokenAddress}
342
+ // Solana URL format for Phantom and other mobile wallets
288
343
  const params = new URLSearchParams();
289
- // Add amount for native SOL transfers
290
- if (currency === "SOL") {
291
- params.append("amount", amount.toString());
344
+ // Check if this is native SOL or SPL token
345
+ // The address "11111111111111111111111111111111" is Solana's System Program, indicating native SOL
346
+ const isNativeSOL = currency === chain.nativeToken.symbol || currency === "SOL" || currency === "11111111111111111111111111111111";
347
+ if (isNativeSOL) {
348
+ // Native SOL transfers - convert from lamports to SOL
349
+ let displayAmount;
350
+ if (decimals !== undefined) {
351
+ const divisor = BigInt(10 ** decimals);
352
+ const wholePart = amount / divisor;
353
+ const fractionalPart = amount % divisor;
354
+ if (fractionalPart === BigInt(0)) {
355
+ displayAmount = wholePart.toString();
356
+ }
357
+ else {
358
+ const fractionalStr = fractionalPart.toString().padStart(decimals, "0");
359
+ const trimmedFractional = fractionalStr.replace(/0+$/, "");
360
+ displayAmount = trimmedFractional ? `${wholePart}.${trimmedFractional}` : wholePart.toString();
361
+ }
362
+ }
363
+ else {
364
+ // Fallback: assume SOL has 9 decimals
365
+ const divisor = BigInt(1000000000); // 1e9
366
+ const wholePart = amount / divisor;
367
+ const fractionalPart = amount % divisor;
368
+ if (fractionalPart === BigInt(0)) {
369
+ displayAmount = wholePart.toString();
370
+ }
371
+ else {
372
+ const fractionalStr = fractionalPart.toString().padStart(9, "0");
373
+ const trimmedFractional = fractionalStr.replace(/0+$/, "");
374
+ displayAmount = trimmedFractional ? `${wholePart}.${trimmedFractional}` : wholePart.toString();
375
+ }
376
+ }
377
+ // For native SOL, use simple format without spl-token parameter
378
+ params.append("amount", displayAmount);
292
379
  }
293
- // Add SPL token info for token transfers
294
- if (currency !== "SOL") {
295
- params.append("spl-token", currency); // currency here should be token address
380
+ else {
381
+ // SPL token transfers
382
+ let displayAmount;
383
+ if (decimals !== undefined) {
384
+ const divisor = BigInt(10 ** decimals);
385
+ const wholePart = amount / divisor;
386
+ const fractionalPart = amount % divisor;
387
+ if (fractionalPart === BigInt(0)) {
388
+ displayAmount = wholePart.toString();
389
+ }
390
+ else {
391
+ const fractionalStr = fractionalPart.toString().padStart(decimals, "0");
392
+ const trimmedFractional = fractionalStr.replace(/0+$/, "");
393
+ displayAmount = trimmedFractional ? `${wholePart}.${trimmedFractional}` : wholePart.toString();
394
+ }
395
+ }
396
+ else {
397
+ displayAmount = amount.toString();
398
+ }
399
+ params.append("amount", displayAmount);
400
+ params.append("spl-token", currency); // token mint address
296
401
  }
297
- return `solana:${address}?${params.toString()}`;
402
+ const url = `solana:${address}?${params.toString()}`;
403
+ console.log("Solana URL (isNativeSOL:", isNativeSOL, "):", url);
404
+ return url;
298
405
  }
299
406
  default:
300
407
  // Fallback to just the address if chain type is unknown
@@ -6,7 +6,7 @@ export declare const wagmiConfig: import("wagmi").Config<readonly [import("viem"
6
6
  /**
7
7
  * Main B3Provider component
8
8
  */
9
- export declare function B3Provider({ isMainnetAnySpend, theme, children, accountOverride, environment, automaticallySetFirstEoa, simDuneApiKey, }: {
9
+ export declare function B3Provider({ isMainnetAnySpend, theme, children, accountOverride, environment, automaticallySetFirstEoa, simDuneApiKey, toaster, }: {
10
10
  isMainnetAnySpend?: boolean;
11
11
  theme: "light" | "dark";
12
12
  children: React.ReactNode;
@@ -14,6 +14,10 @@ export declare function B3Provider({ isMainnetAnySpend, theme, children, account
14
14
  environment: B3ContextType["environment"];
15
15
  automaticallySetFirstEoa?: boolean;
16
16
  simDuneApiKey?: string;
17
+ toaster?: {
18
+ position?: "top-center" | "top-right" | "bottom-center" | "bottom-right";
19
+ style?: React.CSSProperties;
20
+ };
17
21
  }): import("react/jsx-runtime").JSX.Element;
18
22
  /**
19
23
  * Inner provider component that provides the actual B3Context
@@ -32,8 +32,8 @@ const queryClient = new react_query_1.QueryClient();
32
32
  /**
33
33
  * Main B3Provider component
34
34
  */
35
- function B3Provider({ isMainnetAnySpend = true, theme = "light", children, accountOverride, environment, automaticallySetFirstEoa, simDuneApiKey, }) {
36
- return ((0, jsx_runtime_1.jsx)(wagmi_1.WagmiProvider, { config: exports.wagmiConfig, children: (0, jsx_runtime_1.jsx)(react_query_1.QueryClientProvider, { client: queryClient, children: (0, jsx_runtime_1.jsx)(react_3.ThirdwebProvider, { children: (0, jsx_runtime_1.jsx)(react_1.TooltipProvider, { children: (0, jsx_runtime_1.jsx)(InnerProvider, { accountOverride: accountOverride, environment: environment, theme: theme, automaticallySetFirstEoa: !!automaticallySetFirstEoa, children: (0, jsx_runtime_1.jsxs)(react_1.RelayKitProviderWrapper, { isMainnet: isMainnetAnySpend, simDuneApiKey: simDuneApiKey, children: [children, (0, jsx_runtime_1.jsx)(StyleRoot_1.StyleRoot, { id: "b3-root" }), (0, jsx_runtime_1.jsx)(sonner_1.Toaster, { theme: theme })] }) }) }) }) }) }));
35
+ function B3Provider({ isMainnetAnySpend = true, theme = "light", children, accountOverride, environment, automaticallySetFirstEoa, simDuneApiKey, toaster, }) {
36
+ return ((0, jsx_runtime_1.jsx)(wagmi_1.WagmiProvider, { config: exports.wagmiConfig, children: (0, jsx_runtime_1.jsx)(react_query_1.QueryClientProvider, { client: queryClient, children: (0, jsx_runtime_1.jsx)(react_3.ThirdwebProvider, { children: (0, jsx_runtime_1.jsx)(react_1.TooltipProvider, { children: (0, jsx_runtime_1.jsx)(InnerProvider, { accountOverride: accountOverride, environment: environment, theme: theme, automaticallySetFirstEoa: !!automaticallySetFirstEoa, children: (0, jsx_runtime_1.jsxs)(react_1.RelayKitProviderWrapper, { isMainnet: isMainnetAnySpend, simDuneApiKey: simDuneApiKey, children: [children, (0, jsx_runtime_1.jsx)(StyleRoot_1.StyleRoot, { id: "b3-root" }), (0, jsx_runtime_1.jsx)(sonner_1.Toaster, { theme: theme, position: toaster?.position, style: toaster?.style })] }) }) }) }) }) }));
37
37
  }
38
38
  /**
39
39
  * Inner provider component that provides the actual B3Context
@@ -164,12 +164,14 @@ function SignInWithB3Flow({ strategies, onLoginSuccess, onSessionKeySuccess, onE
164
164
  debug("Authenticating with B3 via SIWE");
165
165
  setIsConnected(true);
166
166
  if (loginWithSiwe) {
167
+ debug("@@setIsAuthenticating:true:1");
167
168
  setIsAuthenticating(true);
168
169
  const userAuth = await authenticate(account, partnerId);
169
170
  setUser(userAuth.user);
170
171
  }
171
172
  debug("handleLoginSuccess:account", account);
172
173
  onLoginSuccess?.(account);
174
+ debug("@@setIsAuthenticating:false:1");
173
175
  setIsAuthenticating(false);
174
176
  }, [loginWithSiwe, onLoginSuccess, setIsAuthenticating, authenticate, partnerId, setUser, setIsConnected]);
175
177
  (0, react_2.useEffect)(() => {
@@ -18,7 +18,6 @@ function SignInWithB3Privy({ onSuccess, onError, partnerId, chain }) {
18
18
  (0, react_2.useEffect)(() => {
19
19
  async function autoConnect() {
20
20
  try {
21
- setIsAuthenticating(true);
22
21
  const connectResult = await connectTw();
23
22
  const account = connectResult?.getAccount();
24
23
  if (!account) {
@@ -35,6 +34,7 @@ function SignInWithB3Privy({ onSuccess, onError, partnerId, chain }) {
35
34
  setIsAuthenticated(false);
36
35
  }
37
36
  finally {
37
+ debug("@@setIsAuthenticating:false:7");
38
38
  setIsAuthenticating(false);
39
39
  }
40
40
  }
@@ -5,6 +5,7 @@ exports.LoginStep = LoginStep;
5
5
  const jsx_runtime_1 = require("react/jsx-runtime");
6
6
  const react_1 = require("../../../../../global-account/react");
7
7
  const constants_1 = require("../../../../../shared/constants");
8
+ const debug_1 = require("../../../../../shared/utils/debug");
8
9
  const thirdweb_1 = require("../../../../../shared/utils/thirdweb");
9
10
  const react_2 = require("thirdweb/react");
10
11
  const wallets_1 = require("thirdweb/wallets");
@@ -64,6 +65,7 @@ function LoginStep({ onSuccess, onError, partnerId, chain }) {
64
65
  }, onConnect: async (wallet) => {
65
66
  try {
66
67
  setIsAuthenticating(true);
68
+ (0, debug_1.debug)("@@setIsAuthenticating:true:6");
67
69
  const account = wallet.getAccount();
68
70
  if (!account)
69
71
  throw new Error("No account found");
@@ -77,6 +79,7 @@ function LoginStep({ onSuccess, onError, partnerId, chain }) {
77
79
  setIsAuthenticated(false);
78
80
  }
79
81
  finally {
82
+ (0, debug_1.debug)("@@setIsAuthenticating:false:6");
80
83
  setIsAuthenticating(false);
81
84
  }
82
85
  } }) }));
@@ -3,10 +3,11 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.LoginStepCustom = LoginStepCustom;
4
4
  const jsx_runtime_1 = require("react/jsx-runtime");
5
5
  const react_1 = require("../../../../../global-account/react");
6
+ const debug_1 = require("../../../../../shared/utils/debug");
7
+ const thirdweb_1 = require("../../../../../shared/utils/thirdweb");
6
8
  const react_2 = require("react");
7
9
  const react_3 = require("thirdweb/react");
8
10
  const wallets_1 = require("thirdweb/wallets");
9
- const thirdweb_1 = require("../../../../../shared/utils/thirdweb");
10
11
  function LoginStepCustom({ onSuccess, onError, partnerId, chain, strategies, maxInitialWallets = 2, automaticallySetFirstEoa, }) {
11
12
  const [isLoading, setIsLoading] = (0, react_2.useState)(false);
12
13
  const [showAllWallets, setShowAllWallets] = (0, react_2.useState)(false);
@@ -23,6 +24,7 @@ function LoginStepCustom({ onSuccess, onError, partnerId, chain, strategies, max
23
24
  const handleConnect = async (strategy) => {
24
25
  try {
25
26
  setIsLoading(true);
27
+ (0, debug_1.debug)("@@setIsAuthenticating:true:3");
26
28
  setIsAuthenticating(true);
27
29
  const options = (0, react_1.getConnectOptionsFromStrategy)(strategy);
28
30
  let connectResult;
@@ -56,6 +58,7 @@ function LoginStepCustom({ onSuccess, onError, partnerId, chain, strategies, max
56
58
  }
57
59
  finally {
58
60
  setIsLoading(false);
61
+ (0, debug_1.debug)("@@setIsAuthenticating:false:3");
59
62
  setIsAuthenticating(false);
60
63
  }
61
64
  };
@@ -18,7 +18,7 @@ export { useIsomorphicLayoutEffect } from "./useIsomorphicLayoutEffect";
18
18
  export { useMediaQuery } from "./useMediaQuery";
19
19
  export { useNativeBalance, useNativeBalanceFromRPC } from "./useNativeBalance";
20
20
  export { useOneBalance } from "./useOneBalance";
21
- export { useProfile, useProfilePreference, type Profile, type CombinedProfile, type PreferenceRequestBody, } from "./useProfile";
21
+ export { useProfile, useProfilePreference, type CombinedProfile, type PreferenceRequestBody, type Profile, } from "./useProfile";
22
22
  export { useQueryB3 } from "./useQueryB3";
23
23
  export { useQueryBSMNT } from "./useQueryBSMNT";
24
24
  export { useRemoveSessionKey } from "./useRemoveSessionKey";
@@ -46,6 +46,7 @@ function useAuthentication(partnerId, loginWithSiwe) {
46
46
  setIsAuthenticated(true);
47
47
  return;
48
48
  }
49
+ debug("@@setIsAuthenticating:true:4");
49
50
  setIsAuthenticating(true);
50
51
  const account = await wallet.getAccount();
51
52
  if (!account) {
@@ -70,6 +71,7 @@ function useAuthentication(partnerId, loginWithSiwe) {
70
71
  catch (error) {
71
72
  debug("Auto-connect authentication failed", { error });
72
73
  setIsAuthenticated(false);
74
+ debug("@@setIsAuthenticating:false:4");
73
75
  setUser();
74
76
  }
75
77
  },
@@ -77,19 +79,20 @@ function useAuthentication(partnerId, loginWithSiwe) {
77
79
  // Ensure isAuthenticating stays true until we're fully ready
78
80
  (0, react_2.useEffect)(() => {
79
81
  if (useAutoConnectLoading) {
80
- setIsAuthenticating(true);
81
82
  setIsConnecting(true);
82
83
  }
83
84
  else if (!isAuthenticated) {
84
85
  // Only set isAuthenticating to false if we're not authenticated
85
86
  // This prevents the flicker state where both isAuthenticating and isAuthenticated are false
86
87
  const timeout = setTimeout(() => {
88
+ debug("@@setIsAuthenticating:false:5a");
87
89
  setIsAuthenticating(false);
88
90
  setIsConnecting(false);
89
91
  }, 100); // Add a small delay to prevent quick flickers
90
92
  return () => clearTimeout(timeout);
91
93
  }
92
94
  else {
95
+ debug("@@setIsAuthenticating:false:5b");
93
96
  setIsAuthenticating(false);
94
97
  setIsConnecting(false);
95
98
  }
@@ -28,9 +28,10 @@ export interface DisplayNameRequestBody {
28
28
  signer: string;
29
29
  timestamp: number;
30
30
  }
31
- export declare function useProfile({ address, name, fresh, }: {
31
+ export declare function useProfile({ address, name, b3GlobalId, fresh, }: {
32
32
  address?: string;
33
33
  name?: string;
34
+ b3GlobalId?: string;
34
35
  fresh?: boolean;
35
36
  }, options?: {
36
37
  enabled?: boolean;
@@ -6,15 +6,17 @@ exports.useDisplayName = useDisplayName;
6
6
  exports.useProfileSettings = useProfileSettings;
7
7
  const react_query_1 = require("@tanstack/react-query");
8
8
  const PROFILES_API_URL = "https://profiles.b3.fun";
9
- async function fetchProfile({ address, name, fresh = false, }) {
10
- if (!address && !name) {
11
- throw new Error("Either address or name must be provided");
9
+ async function fetchProfile({ address, name, b3GlobalId, fresh = false, }) {
10
+ if (!address && !name && !b3GlobalId) {
11
+ throw new Error("Either address or name or b3GlobalId must be provided");
12
12
  }
13
13
  const params = new URLSearchParams();
14
14
  if (address)
15
15
  params.append("address", address);
16
16
  if (name)
17
17
  params.append("name", name);
18
+ if (b3GlobalId)
19
+ params.append("b3GlobalId", b3GlobalId);
18
20
  if (fresh)
19
21
  params.append("fresh", "true");
20
22
  const response = await fetch(`${PROFILES_API_URL}?${params.toString()}`);
@@ -61,11 +63,11 @@ async function setDisplayName({ key, displayName, signature, signer, timestamp,
61
63
  }
62
64
  return response.json();
63
65
  }
64
- function useProfile({ address, name, fresh = false, }, options) {
66
+ function useProfile({ address, name, b3GlobalId, fresh = false, }, options) {
65
67
  return (0, react_query_1.useQuery)({
66
- queryKey: ["profile", address || name, fresh],
67
- queryFn: () => fetchProfile({ address, name, fresh }),
68
- enabled: (options?.enabled ?? true) && (!!address || !!name),
68
+ queryKey: ["profile", address || name || b3GlobalId, fresh],
69
+ queryFn: () => fetchProfile({ address, name, b3GlobalId, fresh }),
70
+ enabled: (options?.enabled ?? true) && (!!address || !!name || !!b3GlobalId),
69
71
  refetchInterval: options?.refetchInterval,
70
72
  staleTime: options?.staleTime ?? 5 * 60 * 1000, // 5 minutes default
71
73
  });
@@ -3,8 +3,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ENS_GATEWAY_URL = exports.B3_AUTH_COOKIE_NAME = exports.CLIENT_APP_BUNDLE_ID = exports.THIRDWEB_CLIENT_ID = exports.THIRDWEB_SECRET_KEY = exports.tokenIcons = exports.ecosystemWalletId = exports.b3CoinIcon = exports.siteURL = void 0;
4
4
  exports.siteURL = "https://basement.fun";
5
5
  exports.b3CoinIcon = "https://cdn.b3.fun/b3-coin-3d.png";
6
- exports.ecosystemWalletId = (process.env.EXPO_PUBLIC_THIRDWEB_ECOSYSTEM_ID ||
7
- process.env.NEXT_PUBLIC_THIRDWEB_ECOSYSTEM_ID ||
6
+ exports.ecosystemWalletId = (process.env.NEXT_PUBLIC_THIRDWEB_ECOSYSTEM_ID ||
7
+ process.env.EXPO_PUBLIC_THIRDWEB_ECOSYSTEM_ID ||
8
8
  "ecosystem.b3-open-gaming"); // Fallback to prod key lookup
9
9
  exports.tokenIcons = {
10
10
  ETH: "https://cdn.b3.fun/ethereum.svg",
@@ -16,7 +16,9 @@ exports.tokenIcons = {
16
16
  // Add more asset icons as needed
17
17
  };
18
18
  exports.THIRDWEB_SECRET_KEY = process.env.THIRDWEB_SECRET_KEY || "";
19
- exports.THIRDWEB_CLIENT_ID = process.env.NEXT_PUBLIC_THIRDWEB_CLIENT_ID || process.env.EXPO_PUBLIC_THIRDWEB_CLIENT_ID || "";
19
+ exports.THIRDWEB_CLIENT_ID = process.env.NEXT_PUBLIC_THIRDWEB_CLIENT_ID ||
20
+ process.env.EXPO_PUBLIC_THIRDWEB_CLIENT_ID ||
21
+ "f393c7eb287696dc4db76d980cc68328";
20
22
  exports.CLIENT_APP_BUNDLE_ID = process.env.EXPO_PUBLIC_B3_BUNDLE_ID || "";
21
23
  exports.B3_AUTH_COOKIE_NAME = "b3-auth";
22
24
  exports.ENS_GATEWAY_URL = "https://ens-gateway.b3.fun/";
@@ -1 +1 @@
1
- export declare function formatUsername(username: string): string;
1
+ export declare function formatUsername(username?: string): string | undefined;
@@ -2,7 +2,9 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.formatUsername = formatUsername;
4
4
  function formatUsername(username) {
5
+ if (!username)
6
+ return "";
5
7
  // Remove .b3.fun and put an @ before it
6
8
  // Make it all lowercase
7
- return `@${username.replace(".b3.fun", "").toLowerCase()}`;
9
+ return `@${username.replace(".b3.fun", "").toLowerCase()}` || undefined;
8
10
  }
@@ -1,5 +1,3 @@
1
- export * from "./react/hooks";
2
- export * from "./react/providers/AnyspendProvider";
3
1
  export * from "./types/api";
4
2
  export * from "./utils/address";
5
3
  export * from "./utils/chain";
@@ -1,7 +1,3 @@
1
- // Export all hooks
2
- export * from "./react/hooks/index.js";
3
- // Providers
4
- export * from "./react/providers/AnyspendProvider.js";
5
1
  // Types
6
2
  export * from "./types/api.js";
7
3
  // Utils