@b3dotfun/sdk 0.1.0 → 0.1.1-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 (171) hide show
  1. package/dist/cjs/anyspend/react/components/AnySpend.js +1 -1
  2. package/dist/cjs/anyspend/react/components/AnySpendDeposit.d.ts +15 -10
  3. package/dist/cjs/anyspend/react/components/AnySpendDeposit.js +22 -14
  4. package/dist/cjs/anyspend/react/components/QRDeposit.js +31 -5
  5. package/dist/cjs/anyspend/react/components/common/CryptoPaymentMethod.js +9 -2
  6. package/dist/cjs/anyspend/react/components/common/GasIndicator.d.ts +1 -1
  7. package/dist/cjs/anyspend/react/components/common/GasIndicator.js +6 -16
  8. package/dist/cjs/anyspend/react/components/common/TokenBalance.js +15 -4
  9. package/dist/cjs/anyspend/react/components/common/TransferResultScreen.d.ts +22 -0
  10. package/dist/cjs/anyspend/react/components/common/TransferResultScreen.js +25 -0
  11. package/dist/cjs/anyspend/react/hooks/index.d.ts +1 -0
  12. package/dist/cjs/anyspend/react/hooks/index.js +1 -0
  13. package/dist/cjs/anyspend/react/hooks/useWatchTransfer.d.ts +41 -0
  14. package/dist/cjs/anyspend/react/hooks/useWatchTransfer.js +75 -0
  15. package/dist/cjs/anyspend/react/providers/AnyspendProvider.js +1 -2
  16. package/dist/cjs/anyspend/utils/address.d.ts +5 -0
  17. package/dist/cjs/anyspend/utils/address.js +8 -0
  18. package/dist/cjs/global-account/react/components/AccountAssets/AccountAssets.js +7 -3
  19. package/dist/cjs/global-account/react/components/B3DynamicModal.js +4 -14
  20. package/dist/cjs/global-account/react/components/B3Provider/B3ConfigProvider.d.ts +31 -0
  21. package/dist/cjs/global-account/react/components/B3Provider/B3ConfigProvider.js +37 -0
  22. package/dist/cjs/global-account/react/components/B3Provider/B3Provider.d.ts +4 -1
  23. package/dist/cjs/global-account/react/components/B3Provider/B3Provider.js +3 -31
  24. package/dist/cjs/global-account/react/components/B3Provider/B3Provider.native.js +4 -31
  25. package/dist/cjs/global-account/react/components/B3Provider/LocalSDKProvider.d.ts +6 -1
  26. package/dist/cjs/global-account/react/components/B3Provider/LocalSDKProvider.js +5 -1
  27. package/dist/cjs/global-account/react/components/B3Provider/useB3.d.ts +1 -12
  28. package/dist/cjs/global-account/react/components/B3Provider/useB3Config.d.ts +1 -17
  29. package/dist/cjs/global-account/react/components/B3Provider/useB3Config.js +2 -21
  30. package/dist/cjs/global-account/react/components/ManageAccount/NFTContent.js +2 -2
  31. package/dist/cjs/global-account/react/components/SignInWithB3/SignInWithB3Flow.js +24 -4
  32. package/dist/cjs/global-account/react/components/SingleUserSearchSelector/SingleUserSearchSelector.d.ts +64 -0
  33. package/dist/cjs/global-account/react/components/SingleUserSearchSelector/SingleUserSearchSelector.js +163 -0
  34. package/dist/cjs/global-account/react/components/SingleUserSearchSelector/index.d.ts +2 -0
  35. package/dist/cjs/global-account/react/components/SingleUserSearchSelector/index.js +5 -0
  36. package/dist/cjs/global-account/react/components/WalletImage/WalletImage.d.ts +1 -1
  37. package/dist/cjs/global-account/react/components/index.d.ts +2 -0
  38. package/dist/cjs/global-account/react/components/index.js +6 -3
  39. package/dist/cjs/global-account/react/hooks/index.d.ts +2 -1
  40. package/dist/cjs/global-account/react/hooks/index.js +5 -1
  41. package/dist/cjs/global-account/react/hooks/useAuthentication.js +5 -2
  42. package/dist/cjs/global-account/react/hooks/useProfile.js +4 -23
  43. package/dist/cjs/global-account/react/hooks/useSimBalance.d.ts +7 -0
  44. package/dist/cjs/global-account/react/hooks/useSimBalance.js +43 -11
  45. package/dist/cjs/global-account/react/hooks/useSimCollectibles.d.ts +45 -0
  46. package/dist/cjs/global-account/react/hooks/useSimCollectibles.js +190 -0
  47. package/dist/cjs/global-account/react/stores/index.d.ts +0 -1
  48. package/dist/cjs/global-account/react/stores/index.js +1 -3
  49. package/dist/cjs/global-account/react/stores/useModalStore.d.ts +63 -1
  50. package/dist/cjs/global-account/react/stores/useModalStore.js +3 -0
  51. package/dist/cjs/global-account/react/utils/profileApi.d.ts +13 -0
  52. package/dist/cjs/global-account/react/utils/profileApi.js +29 -0
  53. package/dist/cjs/global-account/react/utils/simdune.d.ts +7 -0
  54. package/dist/cjs/global-account/react/utils/simdune.js +21 -0
  55. package/dist/esm/anyspend/react/components/AnySpend.js +1 -1
  56. package/dist/esm/anyspend/react/components/AnySpendDeposit.d.ts +15 -10
  57. package/dist/esm/anyspend/react/components/AnySpendDeposit.js +23 -15
  58. package/dist/esm/anyspend/react/components/QRDeposit.js +32 -6
  59. package/dist/esm/anyspend/react/components/common/CryptoPaymentMethod.js +10 -3
  60. package/dist/esm/anyspend/react/components/common/GasIndicator.d.ts +1 -1
  61. package/dist/esm/anyspend/react/components/common/GasIndicator.js +7 -17
  62. package/dist/esm/anyspend/react/components/common/TokenBalance.js +16 -5
  63. package/dist/esm/anyspend/react/components/common/TransferResultScreen.d.ts +22 -0
  64. package/dist/esm/anyspend/react/components/common/TransferResultScreen.js +22 -0
  65. package/dist/esm/anyspend/react/hooks/index.d.ts +1 -0
  66. package/dist/esm/anyspend/react/hooks/index.js +1 -0
  67. package/dist/esm/anyspend/react/hooks/useWatchTransfer.d.ts +41 -0
  68. package/dist/esm/anyspend/react/hooks/useWatchTransfer.js +72 -0
  69. package/dist/esm/anyspend/react/providers/AnyspendProvider.js +1 -2
  70. package/dist/esm/anyspend/utils/address.d.ts +5 -0
  71. package/dist/esm/anyspend/utils/address.js +7 -0
  72. package/dist/esm/global-account/react/components/AccountAssets/AccountAssets.js +7 -3
  73. package/dist/esm/global-account/react/components/B3DynamicModal.js +5 -15
  74. package/dist/esm/global-account/react/components/B3Provider/B3ConfigProvider.d.ts +31 -0
  75. package/dist/esm/global-account/react/components/B3Provider/B3ConfigProvider.js +33 -0
  76. package/dist/esm/global-account/react/components/B3Provider/B3Provider.d.ts +4 -1
  77. package/dist/esm/global-account/react/components/B3Provider/B3Provider.js +3 -31
  78. package/dist/esm/global-account/react/components/B3Provider/B3Provider.native.js +3 -30
  79. package/dist/esm/global-account/react/components/B3Provider/LocalSDKProvider.d.ts +6 -1
  80. package/dist/esm/global-account/react/components/B3Provider/LocalSDKProvider.js +5 -1
  81. package/dist/esm/global-account/react/components/B3Provider/useB3.d.ts +1 -12
  82. package/dist/esm/global-account/react/components/B3Provider/useB3Config.d.ts +1 -17
  83. package/dist/esm/global-account/react/components/B3Provider/useB3Config.js +1 -20
  84. package/dist/esm/global-account/react/components/ManageAccount/NFTContent.js +3 -3
  85. package/dist/esm/global-account/react/components/SignInWithB3/SignInWithB3Flow.js +25 -5
  86. package/dist/esm/global-account/react/components/SingleUserSearchSelector/SingleUserSearchSelector.d.ts +64 -0
  87. package/dist/esm/global-account/react/components/SingleUserSearchSelector/SingleUserSearchSelector.js +160 -0
  88. package/dist/esm/global-account/react/components/SingleUserSearchSelector/index.d.ts +2 -0
  89. package/dist/esm/global-account/react/components/SingleUserSearchSelector/index.js +1 -0
  90. package/dist/esm/global-account/react/components/WalletImage/WalletImage.d.ts +1 -1
  91. package/dist/esm/global-account/react/components/index.d.ts +2 -0
  92. package/dist/esm/global-account/react/components/index.js +2 -0
  93. package/dist/esm/global-account/react/hooks/index.d.ts +2 -1
  94. package/dist/esm/global-account/react/hooks/index.js +2 -1
  95. package/dist/esm/global-account/react/hooks/useAuthentication.js +5 -2
  96. package/dist/esm/global-account/react/hooks/useProfile.js +1 -20
  97. package/dist/esm/global-account/react/hooks/useSimBalance.d.ts +7 -0
  98. package/dist/esm/global-account/react/hooks/useSimBalance.js +42 -11
  99. package/dist/esm/global-account/react/hooks/useSimCollectibles.d.ts +45 -0
  100. package/dist/esm/global-account/react/hooks/useSimCollectibles.js +187 -0
  101. package/dist/esm/global-account/react/stores/index.d.ts +0 -1
  102. package/dist/esm/global-account/react/stores/index.js +0 -1
  103. package/dist/esm/global-account/react/stores/useModalStore.d.ts +63 -1
  104. package/dist/esm/global-account/react/stores/useModalStore.js +3 -0
  105. package/dist/esm/global-account/react/utils/profileApi.d.ts +13 -0
  106. package/dist/esm/global-account/react/utils/profileApi.js +25 -0
  107. package/dist/esm/global-account/react/utils/simdune.d.ts +7 -0
  108. package/dist/esm/global-account/react/utils/simdune.js +17 -0
  109. package/dist/styles/index.css +1 -1
  110. package/dist/types/anyspend/react/components/AnySpendDeposit.d.ts +15 -10
  111. package/dist/types/anyspend/react/components/common/GasIndicator.d.ts +1 -1
  112. package/dist/types/anyspend/react/components/common/TransferResultScreen.d.ts +22 -0
  113. package/dist/types/anyspend/react/hooks/index.d.ts +1 -0
  114. package/dist/types/anyspend/react/hooks/useWatchTransfer.d.ts +41 -0
  115. package/dist/types/anyspend/utils/address.d.ts +5 -0
  116. package/dist/types/global-account/react/components/B3Provider/B3ConfigProvider.d.ts +31 -0
  117. package/dist/types/global-account/react/components/B3Provider/B3Provider.d.ts +4 -1
  118. package/dist/types/global-account/react/components/B3Provider/LocalSDKProvider.d.ts +6 -1
  119. package/dist/types/global-account/react/components/B3Provider/useB3.d.ts +1 -12
  120. package/dist/types/global-account/react/components/B3Provider/useB3Config.d.ts +1 -17
  121. package/dist/types/global-account/react/components/SingleUserSearchSelector/SingleUserSearchSelector.d.ts +64 -0
  122. package/dist/types/global-account/react/components/SingleUserSearchSelector/index.d.ts +2 -0
  123. package/dist/types/global-account/react/components/WalletImage/WalletImage.d.ts +1 -1
  124. package/dist/types/global-account/react/components/index.d.ts +2 -0
  125. package/dist/types/global-account/react/hooks/index.d.ts +2 -1
  126. package/dist/types/global-account/react/hooks/useSimBalance.d.ts +7 -0
  127. package/dist/types/global-account/react/hooks/useSimCollectibles.d.ts +45 -0
  128. package/dist/types/global-account/react/stores/index.d.ts +0 -1
  129. package/dist/types/global-account/react/stores/useModalStore.d.ts +63 -1
  130. package/dist/types/global-account/react/utils/profileApi.d.ts +13 -0
  131. package/dist/types/global-account/react/utils/simdune.d.ts +7 -0
  132. package/package.json +6 -1
  133. package/src/anyspend/react/components/AnySpend.tsx +1 -0
  134. package/src/anyspend/react/components/AnySpendDeposit.tsx +60 -42
  135. package/src/anyspend/react/components/QRDeposit.tsx +57 -5
  136. package/src/anyspend/react/components/common/CryptoPaymentMethod.tsx +13 -3
  137. package/src/anyspend/react/components/common/GasIndicator.tsx +11 -30
  138. package/src/anyspend/react/components/common/TokenBalance.tsx +17 -5
  139. package/src/anyspend/react/components/common/TransferResultScreen.tsx +107 -0
  140. package/src/anyspend/react/hooks/index.ts +1 -0
  141. package/src/anyspend/react/hooks/useWatchTransfer.ts +114 -0
  142. package/src/anyspend/react/providers/AnyspendProvider.tsx +2 -5
  143. package/src/anyspend/utils/address.ts +13 -0
  144. package/src/global-account/react/components/AccountAssets/AccountAssets.tsx +25 -13
  145. package/src/global-account/react/components/B3DynamicModal.tsx +5 -17
  146. package/src/global-account/react/components/B3Provider/B3ConfigProvider.tsx +84 -0
  147. package/src/global-account/react/components/B3Provider/B3Provider.native.tsx +28 -36
  148. package/src/global-account/react/components/B3Provider/B3Provider.tsx +31 -39
  149. package/src/global-account/react/components/B3Provider/LocalSDKProvider.tsx +11 -0
  150. package/src/global-account/react/components/B3Provider/useB3Config.ts +1 -21
  151. package/src/global-account/react/components/ManageAccount/NFTContent.tsx +4 -4
  152. package/src/global-account/react/components/SignInWithB3/SignInWithB3Flow.tsx +29 -6
  153. package/src/global-account/react/components/SingleUserSearchSelector/README.md +266 -0
  154. package/src/global-account/react/components/SingleUserSearchSelector/SingleUserSearchSelector.tsx +330 -0
  155. package/src/global-account/react/components/SingleUserSearchSelector/index.ts +2 -0
  156. package/src/global-account/react/components/index.ts +7 -0
  157. package/src/global-account/react/hooks/index.ts +2 -1
  158. package/src/global-account/react/hooks/useAuthentication.ts +6 -2
  159. package/src/global-account/react/hooks/useProfile.ts +1 -32
  160. package/src/global-account/react/hooks/useSimBalance.ts +49 -12
  161. package/src/global-account/react/hooks/useSimCollectibles.ts +238 -0
  162. package/src/global-account/react/stores/index.ts +0 -1
  163. package/src/global-account/react/stores/useModalStore.ts +67 -1
  164. package/src/global-account/react/utils/profileApi.ts +38 -0
  165. package/src/global-account/react/utils/simdune.ts +20 -0
  166. package/dist/cjs/global-account/react/stores/configStore.d.ts +0 -24
  167. package/dist/cjs/global-account/react/stores/configStore.js +0 -30
  168. package/dist/esm/global-account/react/stores/configStore.d.ts +0 -24
  169. package/dist/esm/global-account/react/stores/configStore.js +0 -27
  170. package/dist/types/global-account/react/stores/configStore.d.ts +0 -24
  171. package/src/global-account/react/stores/configStore.ts +0 -51
@@ -16,7 +16,7 @@ import { useTWAuth } from "./useTWAuth.js";
16
16
  import { useUserQuery } from "./useUserQuery.js";
17
17
  const debug = debugB3React("useAuthentication");
18
18
  export function useAuthentication(partnerId) {
19
- const { onConnectCallback } = useContext(LocalSDKContext);
19
+ const { onConnectCallback, onLogoutCallback } = useContext(LocalSDKContext);
20
20
  const { disconnect } = useDisconnect();
21
21
  const wallets = useConnectedWallets();
22
22
  const activeWallet = useActiveWallet();
@@ -150,7 +150,10 @@ export function useAuthentication(partnerId) {
150
150
  setIsConnected(false);
151
151
  setUser();
152
152
  callback?.();
153
- }, [activeWallet, disconnect, wallets, setIsAuthenticated, setUser, setIsConnected]);
153
+ if (onLogoutCallback) {
154
+ await onLogoutCallback();
155
+ }
156
+ }, [activeWallet, disconnect, wallets, setIsAuthenticated, setUser, setIsConnected, onLogoutCallback]);
154
157
  const onConnect = useCallback(async (_walleAutoConnectedWith, allConnectedWallets) => {
155
158
  debug("@@useAuthentication:onConnect", { _walleAutoConnectedWith, allConnectedWallets });
156
159
  try {
@@ -1,24 +1,5 @@
1
1
  import { useQuery } from "@tanstack/react-query";
2
- const PROFILES_API_URL = "https://profiles.b3.fun";
3
- async function fetchProfile({ address, name, b3GlobalId, fresh = false, }) {
4
- if (!address && !name && !b3GlobalId) {
5
- throw new Error("Either address or name or b3GlobalId must be provided");
6
- }
7
- const params = new URLSearchParams();
8
- if (address)
9
- params.append("address", address);
10
- if (name)
11
- params.append("name", name);
12
- if (b3GlobalId)
13
- params.append("b3GlobalId", b3GlobalId);
14
- if (fresh)
15
- params.append("fresh", "true");
16
- const response = await fetch(`${PROFILES_API_URL}?${params.toString()}`);
17
- if (!response.ok) {
18
- throw new Error(`Failed to fetch profile: ${response.statusText}`);
19
- }
20
- return response.json();
21
- }
2
+ import { fetchProfile, PROFILES_API_URL } from "../utils/profileApi.js";
22
3
  async function setProfilePreference({ key, preferredType, signature, signer, timestamp, }) {
23
4
  const response = await fetch(`${PROFILES_API_URL}/preference`, {
24
5
  method: "POST",
@@ -50,3 +50,10 @@ export interface SvmBalanceResponse {
50
50
  }
51
51
  export declare function useSimBalance(address?: string, chainIdsParam?: number[]): import("@tanstack/react-query").UseQueryResult<SimBalanceResponse, Error>;
52
52
  export declare function useSimSvmBalance(address?: string, chains?: ("solana" | "eclipse")[], limit?: number): import("@tanstack/react-query").UseQueryResult<SvmBalanceResponse, Error>;
53
+ /**
54
+ * Hook to fetch a single token balance for a wallet.
55
+ * @param walletAddress - The wallet address to fetch balance for
56
+ * @param tokenAddress - The token contract address, or "native" for native token (ETH, etc.)
57
+ * @param chainId - Chain ID to query (defaults to 1 for Ethereum mainnet)
58
+ */
59
+ export declare function useSimTokenBalance(walletAddress?: string, tokenAddress?: string, chainId?: number): import("@tanstack/react-query").UseQueryResult<SimBalanceResponse, Error>;
@@ -1,12 +1,14 @@
1
1
  import { useQuery } from "@tanstack/react-query";
2
+ import { buildSimduneUrl } from "../utils/simdune.js";
2
3
  async function fetchSimBalance(address, chainIdsParam) {
3
4
  if (!address)
4
5
  throw new Error("Address is required");
5
6
  const chainIds = chainIdsParam.length === 0 ? "mainnet" : chainIdsParam.join(",");
6
- let url = `https://simdune-api.sean-430.workers.dev/?url=https://api.sim.dune.com/v1/evm/balances/${address}?metadata=logo&chain_ids=${chainIds}&exclude_spam_tokens=true`;
7
- if (process.env.NEXT_PUBLIC_DEVMODE_SHARED_SECRET) {
8
- url += `&localkey=${process.env.NEXT_PUBLIC_DEVMODE_SHARED_SECRET}`;
9
- }
7
+ const queryParams = new URLSearchParams();
8
+ queryParams.append("metadata", "logo");
9
+ queryParams.append("chain_ids", chainIds);
10
+ queryParams.append("exclude_spam_tokens", "true");
11
+ const url = buildSimduneUrl(`/v1/evm/balances/${address}`, queryParams);
10
12
  const response = await fetch(url);
11
13
  if (!response.ok) {
12
14
  throw new Error(`Failed to fetch balance: ${response.statusText}`);
@@ -14,6 +16,23 @@ async function fetchSimBalance(address, chainIdsParam) {
14
16
  const balanceData = await response.json();
15
17
  return balanceData;
16
18
  }
19
+ async function fetchSimTokenBalance(walletAddress, tokenAddress, chainId) {
20
+ if (!walletAddress)
21
+ throw new Error("Wallet address is required");
22
+ if (!tokenAddress)
23
+ throw new Error("Token address is required");
24
+ if (!chainId)
25
+ throw new Error("Chain ID is required");
26
+ const queryParams = new URLSearchParams();
27
+ queryParams.append("chain_ids", chainId.toString());
28
+ const url = buildSimduneUrl(`/v1/evm/balances/${walletAddress}/token/${tokenAddress}`, queryParams);
29
+ const response = await fetch(url);
30
+ if (!response.ok) {
31
+ throw new Error(`Failed to fetch token balance: ${response.statusText}`);
32
+ }
33
+ const balanceData = await response.json();
34
+ return balanceData;
35
+ }
17
36
  async function fetchSimSvmBalance(address, chains, limit) {
18
37
  if (!address)
19
38
  throw new Error("Address is required");
@@ -24,13 +43,7 @@ async function fetchSimSvmBalance(address, chains, limit) {
24
43
  if (limit) {
25
44
  queryParams.append("limit", limit.toString());
26
45
  }
27
- let url = `https://simdune-api.sean-430.workers.dev/?url=https://api.sim.dune.com/beta/svm/balances/${address}`;
28
- if (queryParams.toString()) {
29
- url += `?${queryParams.toString()}`;
30
- }
31
- if (process.env.NEXT_PUBLIC_LOCAL_SIMDUNE_KEY) {
32
- url += `${queryParams.toString() ? "&" : "?"}localkey=${process.env.NEXT_PUBLIC_LOCAL_SIMDUNE_KEY}`;
33
- }
46
+ const url = buildSimduneUrl(`/beta/svm/balances/${address}`, queryParams.toString() ? queryParams : undefined);
34
47
  const response = await fetch(url);
35
48
  if (!response.ok) {
36
49
  throw new Error(`Failed to fetch SVM balance: ${response.statusText}`);
@@ -60,3 +73,21 @@ export function useSimSvmBalance(address, chains, limit) {
60
73
  enabled: Boolean(address),
61
74
  });
62
75
  }
76
+ /**
77
+ * Hook to fetch a single token balance for a wallet.
78
+ * @param walletAddress - The wallet address to fetch balance for
79
+ * @param tokenAddress - The token contract address, or "native" for native token (ETH, etc.)
80
+ * @param chainId - Chain ID to query (defaults to 1 for Ethereum mainnet)
81
+ */
82
+ export function useSimTokenBalance(walletAddress, tokenAddress, chainId) {
83
+ return useQuery({
84
+ queryKey: ["simTokenBalance", walletAddress, tokenAddress, chainId],
85
+ queryFn: () => {
86
+ if (!walletAddress || !tokenAddress || !chainId) {
87
+ throw new Error("Missing required parameters");
88
+ }
89
+ return fetchSimTokenBalance(walletAddress, tokenAddress, chainId);
90
+ },
91
+ enabled: Boolean(walletAddress) && Boolean(tokenAddress),
92
+ });
93
+ }
@@ -0,0 +1,45 @@
1
+ import type { SimpleHashNFTResponse } from "../../../global-account/types/simplehash.types";
2
+ export interface SimCollectibleMetadata {
3
+ uri: string;
4
+ attributes?: Array<{
5
+ trait_type: string;
6
+ value: string;
7
+ display_type?: string | null;
8
+ }>;
9
+ }
10
+ export interface SimCollectibleEntry {
11
+ contract_address: string;
12
+ token_standard: "ERC721" | "ERC1155";
13
+ token_id: string;
14
+ chain: string;
15
+ chain_id: number;
16
+ name?: string;
17
+ description?: string;
18
+ symbol?: string;
19
+ image_url?: string;
20
+ last_sale_price?: string;
21
+ metadata?: SimCollectibleMetadata;
22
+ is_spam?: boolean;
23
+ spam_score?: number;
24
+ explanations?: string[];
25
+ balance?: string;
26
+ last_acquired?: string;
27
+ }
28
+ export interface SimCollectiblesResponse {
29
+ address: string;
30
+ entries: SimCollectibleEntry[];
31
+ next_offset?: string;
32
+ request_time: string;
33
+ response_time: string;
34
+ }
35
+ /**
36
+ * Hook to fetch NFT collectibles from Simdune API.
37
+ * Returns data in SimpleHash format for compatibility with AccountAssets component.
38
+ * @param address - Wallet address to fetch collectibles for
39
+ * @param chainIdsParam - Optional array of chain IDs to filter by
40
+ * @param options - Optional parameters (limit, filterSpam)
41
+ */
42
+ export declare function useSimCollectibles(address?: string, chainIdsParam?: number[], options?: {
43
+ limit?: number;
44
+ filterSpam?: boolean;
45
+ }): import("@tanstack/react-query").UseQueryResult<SimpleHashNFTResponse, Error>;
@@ -0,0 +1,187 @@
1
+ import { useQuery } from "@tanstack/react-query";
2
+ import { buildSimduneUrl } from "../utils/simdune.js";
3
+ /**
4
+ * Safely parse a balance string to a number, capping at MAX_SAFE_INTEGER
5
+ * to prevent overflow issues with large ERC1155 balances.
6
+ */
7
+ function safeParseBalance(balance) {
8
+ if (!balance)
9
+ return 1;
10
+ const parsed = parseInt(balance, 10);
11
+ if (Number.isNaN(parsed))
12
+ return 1;
13
+ return Math.min(parsed, Number.MAX_SAFE_INTEGER);
14
+ }
15
+ async function fetchSimCollectibles(address, chainIdsParam, options) {
16
+ if (!address)
17
+ throw new Error("Address is required");
18
+ const queryParams = new URLSearchParams();
19
+ if (chainIdsParam && chainIdsParam.length > 0) {
20
+ queryParams.append("chain_ids", chainIdsParam.join(","));
21
+ }
22
+ if (options?.limit) {
23
+ queryParams.append("limit", options.limit.toString());
24
+ }
25
+ if (options?.filterSpam !== undefined) {
26
+ queryParams.append("filter_spam", options.filterSpam.toString());
27
+ }
28
+ const url = buildSimduneUrl(`/v1/evm/collectibles/${address}`, queryParams);
29
+ const response = await fetch(url);
30
+ if (!response.ok) {
31
+ throw new Error(`Failed to fetch collectibles: ${response.statusText}`);
32
+ }
33
+ const data = await response.json();
34
+ return data;
35
+ }
36
+ /**
37
+ * Transforms Simdune collectibles response to SimpleHash NFT format
38
+ * for compatibility with existing AccountAssets component
39
+ */
40
+ function transformToSimpleHashFormat(data) {
41
+ const nfts = data.entries.map(entry => ({
42
+ nft_id: `${entry.chain}.${entry.contract_address}.${entry.token_id}`,
43
+ chain: entry.chain,
44
+ contract_address: entry.contract_address,
45
+ token_id: entry.token_id,
46
+ name: entry.name || "",
47
+ description: entry.description || "",
48
+ previews: {
49
+ image_small_url: entry.image_url || "",
50
+ image_medium_url: entry.image_url || "",
51
+ image_large_url: entry.image_url || "",
52
+ image_opengraph_url: entry.image_url || "",
53
+ blurhash: "",
54
+ predominant_color: "",
55
+ },
56
+ image_url: entry.image_url || "",
57
+ image_properties: {
58
+ width: 0,
59
+ height: 0,
60
+ size: 0,
61
+ mime_type: "",
62
+ exif_orientation: null,
63
+ },
64
+ video_url: null,
65
+ video_properties: null,
66
+ audio_url: null,
67
+ audio_properties: null,
68
+ model_url: null,
69
+ model_properties: null,
70
+ other_url: null,
71
+ other_properties: null,
72
+ background_color: null,
73
+ external_url: null,
74
+ created_date: "",
75
+ status: "minted",
76
+ token_count: 1,
77
+ owner_count: 1,
78
+ owners: [
79
+ {
80
+ owner_address: data.address,
81
+ quantity: safeParseBalance(entry.balance),
82
+ quantity_string: entry.balance || "1",
83
+ first_acquired_date: entry.last_acquired || "",
84
+ last_acquired_date: entry.last_acquired || "",
85
+ },
86
+ ],
87
+ contract: {
88
+ type: entry.token_standard,
89
+ name: entry.name || "",
90
+ symbol: entry.symbol || null,
91
+ deployed_by: "",
92
+ deployed_via_contract: "",
93
+ owned_by: "",
94
+ has_multiple_collections: false,
95
+ },
96
+ collection: {
97
+ collection_id: entry.contract_address,
98
+ name: entry.symbol || "Unknown Collection",
99
+ description: null,
100
+ image_url: entry.image_url || "",
101
+ image_properties: {
102
+ width: 0,
103
+ height: 0,
104
+ mime_type: "",
105
+ },
106
+ banner_image_url: null,
107
+ category: null,
108
+ is_nsfw: null,
109
+ external_url: null,
110
+ twitter_username: null,
111
+ discord_url: null,
112
+ instagram_username: null,
113
+ medium_username: null,
114
+ telegram_url: null,
115
+ marketplace_pages: [],
116
+ metaplex_mint: null,
117
+ metaplex_candy_machine: null,
118
+ metaplex_first_verified_creator: null,
119
+ floor_prices: [],
120
+ top_bids: [],
121
+ distinct_owner_count: 0,
122
+ distinct_nft_count: 0,
123
+ total_quantity: 0,
124
+ chains: [entry.chain],
125
+ top_contracts: [entry.contract_address],
126
+ collection_royalties: [],
127
+ },
128
+ last_sale: entry.last_sale_price
129
+ ? {
130
+ price: entry.last_sale_price,
131
+ }
132
+ : null,
133
+ primary_sale: null,
134
+ first_created: {
135
+ minted_to: data.address,
136
+ quantity: 1,
137
+ quantity_string: "1",
138
+ timestamp: "",
139
+ block_number: 0,
140
+ transaction: "",
141
+ transaction_initiator: "",
142
+ },
143
+ rarity: {
144
+ rank: null,
145
+ score: null,
146
+ unique_attributes: null,
147
+ },
148
+ royalty: [],
149
+ extra_metadata: {
150
+ attributes: (entry.metadata?.attributes || []).map(attr => ({
151
+ trait_type: attr.trait_type,
152
+ value: attr.value,
153
+ display_type: attr.display_type ?? null,
154
+ })),
155
+ image_original_url: entry.image_url || "",
156
+ animation_original_url: null,
157
+ metadata_original_url: entry.metadata?.uri || "",
158
+ },
159
+ }));
160
+ return {
161
+ next_cursor: data.next_offset || null,
162
+ next: null,
163
+ previous: null,
164
+ nfts,
165
+ };
166
+ }
167
+ /**
168
+ * Hook to fetch NFT collectibles from Simdune API.
169
+ * Returns data in SimpleHash format for compatibility with AccountAssets component.
170
+ * @param address - Wallet address to fetch collectibles for
171
+ * @param chainIdsParam - Optional array of chain IDs to filter by
172
+ * @param options - Optional parameters (limit, filterSpam)
173
+ */
174
+ export function useSimCollectibles(address, chainIdsParam, options) {
175
+ return useQuery({
176
+ queryKey: ["simCollectibles", address, chainIdsParam, options],
177
+ queryFn: async () => {
178
+ if (!address)
179
+ throw new Error("Address is required");
180
+ const data = await fetchSimCollectibles(address, chainIdsParam, options);
181
+ return transformToSimpleHashFormat(data);
182
+ },
183
+ enabled: Boolean(address),
184
+ staleTime: 30 * 1000,
185
+ gcTime: 5 * 60 * 1000,
186
+ });
187
+ }
@@ -1,5 +1,4 @@
1
1
  export { useAuthStore } from "./useAuthStore";
2
- export { useB3ConfigStore } from "./configStore";
3
2
  export { useModalStore } from "./useModalStore";
4
3
  export { useRecentAddressesStore } from "./useRecentAddressesStore";
5
4
  export type { AnySpendBuySpinProps, AnySpendFundTournamentProps, AnySpendJoinTournamentProps, AnySpendModalProps, AnySpendNftProps, AnySpendOrderHistoryProps, AnySpendStakeB3Props, AnyspendOrderDetailsProps, ManageAccountModalProps, ModalContentType, RequestPermissionsModalProps, SignInWithB3ModalProps, } from "./useModalStore";
@@ -1,4 +1,3 @@
1
1
  export { useAuthStore } from "./useAuthStore.js";
2
- export { useB3ConfigStore } from "./configStore.js";
3
2
  export { useModalStore } from "./useModalStore.js";
4
3
  export { useRecentAddressesStore } from "./useRecentAddressesStore.js";
@@ -482,10 +482,70 @@ export interface AnySpendCollectorClubPurchaseProps extends BaseModalProps {
482
482
  /** Force fiat payment */
483
483
  forceFiatPayment?: boolean;
484
484
  }
485
+ /**
486
+ * Props for the AnySpend Deposit modal
487
+ * Flexible deposit component with optional chain selection
488
+ */
489
+ export interface AnySpendDepositModalProps extends BaseModalProps {
490
+ /** Modal type identifier */
491
+ type: "anySpendDeposit";
492
+ /** Order ID to load an existing order */
493
+ loadOrder?: string;
494
+ /** The recipient address for the deposit */
495
+ recipientAddress: string;
496
+ /** Payment type - crypto or fiat. If not set, shows chain selection first */
497
+ paymentType?: "crypto" | "fiat";
498
+ /** Source token address to pre-select */
499
+ sourceTokenAddress?: string;
500
+ /** Source chain ID to pre-select. If not provided, shows chain selection */
501
+ sourceTokenChainId?: number;
502
+ /** The destination token address */
503
+ destinationTokenAddress: string;
504
+ /** The destination chain ID */
505
+ destinationTokenChainId: number;
506
+ /** Callback when deposit succeeds */
507
+ onSuccess?: (amount: string) => void;
508
+ /** Callback for opening a custom modal (e.g., for special token handling) */
509
+ onOpenCustomModal?: () => void;
510
+ /** Custom footer content */
511
+ mainFooter?: React.ReactNode;
512
+ /** Called when a token is selected. Call event.preventDefault() to prevent default behavior */
513
+ onTokenSelect?: (token: components["schemas"]["Token"], event: {
514
+ preventDefault: () => void;
515
+ }) => void;
516
+ /** Custom USD input value presets for fiat payment */
517
+ customUsdInputValues?: string[];
518
+ /** Whether to prefer using connected EOA wallet */
519
+ preferEoa?: boolean;
520
+ /** Minimum destination amount required */
521
+ minDestinationAmount?: number;
522
+ /** Order type for the deposit */
523
+ orderType?: "hype_duel" | "custom_exact_in" | "swap";
524
+ /** Custom action label displayed on buttons */
525
+ actionLabel?: string;
526
+ /** Whether to show chain selection step. Defaults to true if sourceTokenChainId is not provided */
527
+ showChainSelection?: boolean;
528
+ /** Minimum pool size for filtering tokens (default: 1,000,000) */
529
+ minPoolSize?: number;
530
+ /** Custom title for chain selection step */
531
+ chainSelectionTitle?: string;
532
+ /** Custom description for chain selection step */
533
+ chainSelectionDescription?: string;
534
+ /** Number of top chains to show (default: 3) */
535
+ topChainsCount?: number;
536
+ /** Custom URL to redirect to when clicking "Return to Home" on complete order screen */
537
+ returnToHomeUrl?: string;
538
+ /** Custom label for recipient display (e.g., "OBSN Telegram Bot") */
539
+ customRecipientLabel?: string;
540
+ /** Custom label for the return home button (overrides "Return to Home" / "Close") */
541
+ returnHomeLabel?: string;
542
+ /** Whether the deposit requires a custom function (uses AnySpendCustomExactIn). Defaults to false. */
543
+ isCustomDeposit?: boolean;
544
+ }
485
545
  /**
486
546
  * Union type of all possible modal content types
487
547
  */
488
- export type ModalContentType = SignInWithB3ModalProps | TurnkeyAuthModalProps | RequestPermissionsModalProps | ManageAccountModalProps | AnySpendModalProps | AnyspendOrderDetailsProps | AnySpendNftProps | AnySpendJoinTournamentProps | AnySpendFundTournamentProps | AnySpendOrderHistoryProps | AnySpendStakeB3Props | AnySpendStakeB3ExactInProps | AnySpendStakeUpsideProps | AnySpendStakeUpsideExactInProps | AnySpendDepositUpsideProps | AnySpendBuySpinProps | AnySpendSignatureMintProps | AnySpendBondKitProps | LinkAccountModalProps | LinkNewAccountModalProps | AnySpendDepositHypeProps | AvatarEditorModalProps | DepositModalProps | SendModalProps | NotificationsModalProps | AnySpendCollectorClubPurchaseProps;
548
+ export type ModalContentType = SignInWithB3ModalProps | TurnkeyAuthModalProps | RequestPermissionsModalProps | ManageAccountModalProps | AnySpendModalProps | AnyspendOrderDetailsProps | AnySpendNftProps | AnySpendJoinTournamentProps | AnySpendFundTournamentProps | AnySpendOrderHistoryProps | AnySpendStakeB3Props | AnySpendStakeB3ExactInProps | AnySpendStakeUpsideProps | AnySpendStakeUpsideExactInProps | AnySpendDepositUpsideProps | AnySpendBuySpinProps | AnySpendSignatureMintProps | AnySpendBondKitProps | LinkAccountModalProps | LinkNewAccountModalProps | AnySpendDepositHypeProps | AvatarEditorModalProps | DepositModalProps | SendModalProps | NotificationsModalProps | AnySpendCollectorClubPurchaseProps | AnySpendDepositModalProps;
489
549
  /**
490
550
  * State interface for the modal store
491
551
  */
@@ -514,6 +574,8 @@ interface ModalState {
514
574
  linkingMethod: string | null;
515
575
  /** Function to set the linking state */
516
576
  setLinkingState: (isLinking: boolean, method?: string | null) => void;
577
+ /** Function to update closable property of current content without adding to history */
578
+ setClosable: (closable: boolean) => void;
517
579
  }
518
580
  /**
519
581
  * Zustand store for managing modal state
@@ -33,4 +33,7 @@ export const useModalStore = create(set => ({
33
33
  isLinking: false,
34
34
  linkingMethod: null,
35
35
  setLinkingState: (isLinking, method = null) => set({ isLinking, linkingMethod: isLinking ? method : null }),
36
+ setClosable: (closable) => set(state => ({
37
+ contentType: state.contentType ? { ...state.contentType, closable } : null,
38
+ })),
36
39
  }));
@@ -0,0 +1,13 @@
1
+ import type { CombinedProfile } from "../hooks/useProfile";
2
+ export declare const PROFILES_API_URL = "https://profiles.b3.fun";
3
+ /**
4
+ * Fetch a user profile from the B3 Profiles API
5
+ * @param params - Search parameters (address, name, or b3GlobalId)
6
+ * @returns Promise resolving to CombinedProfile or null if not found
7
+ */
8
+ export declare function fetchProfile({ address, name, b3GlobalId, fresh, }: {
9
+ address?: string;
10
+ name?: string;
11
+ b3GlobalId?: string;
12
+ fresh?: boolean;
13
+ }): Promise<CombinedProfile>;
@@ -0,0 +1,25 @@
1
+ export const PROFILES_API_URL = "https://profiles.b3.fun";
2
+ /**
3
+ * Fetch a user profile from the B3 Profiles API
4
+ * @param params - Search parameters (address, name, or b3GlobalId)
5
+ * @returns Promise resolving to CombinedProfile or null if not found
6
+ */
7
+ export async function fetchProfile({ address, name, b3GlobalId, fresh = false, }) {
8
+ if (!address && !name && !b3GlobalId) {
9
+ throw new Error("Either address or name or b3GlobalId must be provided");
10
+ }
11
+ const params = new URLSearchParams();
12
+ if (address)
13
+ params.append("address", address);
14
+ if (name)
15
+ params.append("name", name);
16
+ if (b3GlobalId)
17
+ params.append("b3GlobalId", b3GlobalId);
18
+ if (fresh)
19
+ params.append("fresh", "true");
20
+ const response = await fetch(`${PROFILES_API_URL}?${params.toString()}`);
21
+ if (!response.ok) {
22
+ throw new Error(`Failed to fetch profile: ${response.statusText}`);
23
+ }
24
+ return response.json();
25
+ }
@@ -0,0 +1,7 @@
1
+ export declare const SIMDUNE_API_HOST = "https://simdune-api.sean-430.workers.dev";
2
+ /**
3
+ * Builds a Simdune API URL with the proxy wrapper and optional dev mode key.
4
+ * @param endpoint - The Simdune API endpoint (e.g., "/v1/evm/balances/0x...")
5
+ * @param queryParams - Optional URLSearchParams to append
6
+ */
7
+ export declare function buildSimduneUrl(endpoint: string, queryParams?: URLSearchParams): string;
@@ -0,0 +1,17 @@
1
+ export const SIMDUNE_API_HOST = "https://simdune-api.sean-430.workers.dev";
2
+ /**
3
+ * Builds a Simdune API URL with the proxy wrapper and optional dev mode key.
4
+ * @param endpoint - The Simdune API endpoint (e.g., "/v1/evm/balances/0x...")
5
+ * @param queryParams - Optional URLSearchParams to append
6
+ */
7
+ export function buildSimduneUrl(endpoint, queryParams) {
8
+ const baseUrl = `${SIMDUNE_API_HOST}/?url=https://api.sim.dune.com${endpoint}`;
9
+ let url = baseUrl;
10
+ if (queryParams && queryParams.toString()) {
11
+ url += `?${queryParams.toString()}`;
12
+ }
13
+ if (process.env.NEXT_PUBLIC_DEVMODE_SHARED_SECRET) {
14
+ url += `${queryParams?.toString() ? "&" : "?"}localkey=${process.env.NEXT_PUBLIC_DEVMODE_SHARED_SECRET}`;
15
+ }
16
+ return url;
17
+ }