@b3dotfun/sdk 0.1.70-alpha.18 → 0.1.70-alpha.19
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -3
- package/dist/cjs/anyspend/constants/rpc.d.ts +1 -0
- package/dist/cjs/anyspend/constants/rpc.js +3 -1
- package/dist/cjs/anyspend/react/components/AnySpendDeposit.d.ts +1 -3
- package/dist/cjs/anyspend/react/components/AnySpendDeposit.js +14 -12
- package/dist/cjs/anyspend/react/components/AnySpendStakeB3.js +32 -13
- package/dist/cjs/anyspend/react/components/AnySpendStakeB3ExactIn.js +32 -10
- package/dist/cjs/anyspend/react/components/checkout/CryptoPayPanel.js +16 -8
- package/dist/cjs/anyspend/react/components/common/TokenBalance.js +4 -5
- package/dist/cjs/anyspend/react/hooks/useSigMint.d.ts +1 -1
- package/dist/cjs/anyspend/utils/chain.d.ts +45 -0
- package/dist/cjs/anyspend/utils/chain.js +51 -2
- package/dist/cjs/global-account/react/components/B3Provider/B3Provider.d.ts +1 -2
- package/dist/cjs/global-account/react/components/B3Provider/B3Provider.js +2 -2
- package/dist/cjs/global-account/react/components/B3Provider/RelayKitProviderWrapper.d.ts +1 -2
- package/dist/cjs/global-account/react/components/B3Provider/RelayKitProviderWrapper.js +4 -5
- package/dist/cjs/global-account/react/components/ManageAccount/ContentTokens.js +23 -15
- package/dist/cjs/global-account/react/components/ManageAccount/NFTContent.js +2 -2
- package/dist/cjs/global-account/react/components/ManageAccount/ProfileSection.js +8 -6
- package/dist/cjs/global-account/react/components/ManageAccount/TokenContent.js +17 -8
- package/dist/cjs/global-account/react/components/Send/Send.js +15 -11
- package/dist/cjs/global-account/react/hooks/index.d.ts +2 -2
- package/dist/cjs/global-account/react/hooks/index.js +7 -8
- package/dist/cjs/global-account/react/hooks/useAuth.d.ts +2 -1
- package/dist/cjs/global-account/react/hooks/useAuth.js +1 -0
- package/dist/cjs/global-account/react/hooks/useAuthentication.d.ts +2 -1
- package/dist/cjs/global-account/react/hooks/useAuthentication.js +1 -0
- package/dist/cjs/global-account/react/hooks/useFirstEOA.d.ts +4 -7666
- package/dist/cjs/global-account/react/hooks/useFirstEOA.js +1 -0
- package/dist/cjs/global-account/react/hooks/usePortfolioBalance.d.ts +15 -0
- package/dist/cjs/global-account/react/hooks/usePortfolioBalance.js +76 -0
- package/dist/cjs/global-account/react/hooks/usePortfolioCollectibles.d.ts +12 -0
- package/dist/cjs/global-account/react/hooks/usePortfolioCollectibles.js +178 -0
- package/dist/cjs/global-account/react/stores/useModalStore.d.ts +0 -2
- package/dist/cjs/global-account/react/utils/createWagmiConfig.d.ts +2 -2
- package/dist/cjs/shared/constants/chains/b3Chain.d.ts +24 -0
- package/dist/cjs/shared/constants/chains/supported.d.ts +4 -4
- package/dist/cjs/shared/constants/index.d.ts +4 -0
- package/dist/cjs/shared/utils/zerionPositions.d.ts +96 -0
- package/dist/cjs/shared/utils/zerionPositions.js +186 -0
- package/dist/cjs/wallet/utils/createWalletConfig.d.ts +2 -2
- package/dist/esm/anyspend/constants/rpc.d.ts +1 -0
- package/dist/esm/anyspend/constants/rpc.js +2 -0
- package/dist/esm/anyspend/react/components/AnySpendDeposit.d.ts +1 -3
- package/dist/esm/anyspend/react/components/AnySpendDeposit.js +15 -13
- package/dist/esm/anyspend/react/components/AnySpendStakeB3.js +33 -14
- package/dist/esm/anyspend/react/components/AnySpendStakeB3ExactIn.js +33 -11
- package/dist/esm/anyspend/react/components/checkout/CryptoPayPanel.js +18 -10
- package/dist/esm/anyspend/react/components/common/TokenBalance.js +6 -7
- package/dist/esm/anyspend/react/hooks/useSigMint.d.ts +1 -1
- package/dist/esm/anyspend/utils/chain.d.ts +45 -0
- package/dist/esm/anyspend/utils/chain.js +50 -3
- package/dist/esm/global-account/react/components/B3Provider/B3Provider.d.ts +1 -2
- package/dist/esm/global-account/react/components/B3Provider/B3Provider.js +2 -2
- package/dist/esm/global-account/react/components/B3Provider/RelayKitProviderWrapper.d.ts +1 -2
- package/dist/esm/global-account/react/components/B3Provider/RelayKitProviderWrapper.js +4 -5
- package/dist/esm/global-account/react/components/ManageAccount/ContentTokens.js +24 -16
- package/dist/esm/global-account/react/components/ManageAccount/NFTContent.js +3 -3
- package/dist/esm/global-account/react/components/ManageAccount/ProfileSection.js +9 -7
- package/dist/esm/global-account/react/components/ManageAccount/TokenContent.js +18 -9
- package/dist/esm/global-account/react/components/Send/Send.js +16 -12
- package/dist/esm/global-account/react/hooks/index.d.ts +2 -2
- package/dist/esm/global-account/react/hooks/index.js +2 -2
- package/dist/esm/global-account/react/hooks/useAuth.d.ts +2 -1
- package/dist/esm/global-account/react/hooks/useAuth.js +1 -0
- package/dist/esm/global-account/react/hooks/useAuthentication.d.ts +2 -1
- package/dist/esm/global-account/react/hooks/useAuthentication.js +1 -0
- package/dist/esm/global-account/react/hooks/useFirstEOA.d.ts +4 -7666
- package/dist/esm/global-account/react/hooks/useFirstEOA.js +1 -0
- package/dist/esm/global-account/react/hooks/usePortfolioBalance.d.ts +15 -0
- package/dist/esm/global-account/react/hooks/usePortfolioBalance.js +72 -0
- package/dist/esm/global-account/react/hooks/usePortfolioCollectibles.d.ts +12 -0
- package/dist/esm/global-account/react/hooks/usePortfolioCollectibles.js +175 -0
- package/dist/esm/global-account/react/stores/useModalStore.d.ts +0 -2
- package/dist/esm/global-account/react/utils/createWagmiConfig.d.ts +2 -2
- package/dist/esm/shared/constants/chains/b3Chain.d.ts +24 -0
- package/dist/esm/shared/constants/chains/supported.d.ts +4 -4
- package/dist/esm/shared/constants/index.d.ts +4 -0
- package/dist/esm/shared/utils/zerionPositions.d.ts +96 -0
- package/dist/esm/shared/utils/zerionPositions.js +178 -0
- package/dist/esm/wallet/utils/createWalletConfig.d.ts +2 -2
- package/dist/types/anyspend/constants/rpc.d.ts +1 -0
- package/dist/types/anyspend/react/components/AnySpendDeposit.d.ts +1 -3
- package/dist/types/anyspend/react/hooks/useSigMint.d.ts +1 -1
- package/dist/types/anyspend/utils/chain.d.ts +45 -0
- package/dist/types/global-account/react/components/B3Provider/B3Provider.d.ts +1 -2
- package/dist/types/global-account/react/components/B3Provider/RelayKitProviderWrapper.d.ts +1 -2
- package/dist/types/global-account/react/hooks/index.d.ts +2 -2
- package/dist/types/global-account/react/hooks/useAuth.d.ts +2 -1
- package/dist/types/global-account/react/hooks/useAuthentication.d.ts +2 -1
- package/dist/types/global-account/react/hooks/useFirstEOA.d.ts +4 -7666
- package/dist/types/global-account/react/hooks/usePortfolioBalance.d.ts +15 -0
- package/dist/types/global-account/react/hooks/usePortfolioCollectibles.d.ts +12 -0
- package/dist/types/global-account/react/stores/useModalStore.d.ts +0 -2
- package/dist/types/global-account/react/utils/createWagmiConfig.d.ts +2 -2
- package/dist/types/shared/constants/chains/b3Chain.d.ts +24 -0
- package/dist/types/shared/constants/chains/supported.d.ts +4 -4
- package/dist/types/shared/constants/index.d.ts +4 -0
- package/dist/types/shared/utils/zerionPositions.d.ts +96 -0
- package/dist/types/wallet/utils/createWalletConfig.d.ts +2 -2
- package/node_modules/@b3/chain-registry/chains.json +29 -1
- package/node_modules/@b3/chain-registry/package.json +18 -2
- package/package.json +2 -2
- package/src/anyspend/README.md +2 -2
- package/src/anyspend/constants/rpc.ts +2 -0
- package/src/anyspend/docs/components.md +6 -6
- package/src/anyspend/docs/contributing.md +1 -1
- package/src/anyspend/docs/hooks.md +3 -3
- package/src/anyspend/docs/installation.md +2 -2
- package/src/anyspend/react/components/AnySpendDeposit.tsx +26 -19
- package/src/anyspend/react/components/AnySpendStakeB3.tsx +55 -14
- package/src/anyspend/react/components/AnySpendStakeB3ExactIn.tsx +55 -11
- package/src/anyspend/react/components/__tests__/QRDeposit.test.tsx +3 -4
- package/src/anyspend/react/components/checkout/CryptoPayPanel.tsx +25 -12
- package/src/anyspend/react/components/common/TokenBalance.tsx +10 -7
- package/src/anyspend/utils/__tests__/deprecatedChains.test.ts +44 -0
- package/src/anyspend/utils/__tests__/toRegistryChainId.test.ts +17 -0
- package/src/anyspend/utils/chain.ts +53 -2
- package/src/global-account/react/components/B3Provider/B3Provider.tsx +1 -3
- package/src/global-account/react/components/B3Provider/RelayKitProviderWrapper.tsx +4 -11
- package/src/global-account/react/components/ManageAccount/ContentTokens.tsx +50 -21
- package/src/global-account/react/components/ManageAccount/NFTContent.tsx +5 -3
- package/src/global-account/react/components/ManageAccount/ProfileSection.tsx +10 -6
- package/src/global-account/react/components/ManageAccount/TokenContent.tsx +22 -9
- package/src/global-account/react/components/Send/Send.tsx +39 -15
- package/src/global-account/react/hooks/index.ts +2 -2
- package/src/global-account/react/hooks/useAuth.ts +3 -2
- package/src/global-account/react/hooks/useAuthentication.ts +3 -2
- package/src/global-account/react/hooks/useFirstEOA.tsx +9 -2
- package/src/global-account/react/hooks/usePortfolioBalance.ts +89 -0
- package/src/global-account/react/hooks/usePortfolioCollectibles.ts +212 -0
- package/src/global-account/react/stores/useModalStore.ts +0 -2
- package/src/shared/constants/index.ts +8 -0
- package/src/shared/utils/__tests__/zerionPositions.test.ts +226 -0
- package/src/shared/utils/zerionPositions.ts +244 -0
- package/dist/cjs/global-account/react/hooks/useSimBalance.d.ts +0 -59
- package/dist/cjs/global-account/react/hooks/useSimBalance.js +0 -98
- package/dist/cjs/global-account/react/hooks/useSimCollectibles.d.ts +0 -45
- package/dist/cjs/global-account/react/hooks/useSimCollectibles.js +0 -190
- package/dist/cjs/global-account/react/utils/simdune.d.ts +0 -7
- package/dist/cjs/global-account/react/utils/simdune.js +0 -21
- package/dist/esm/global-account/react/hooks/useSimBalance.d.ts +0 -59
- package/dist/esm/global-account/react/hooks/useSimBalance.js +0 -93
- package/dist/esm/global-account/react/hooks/useSimCollectibles.d.ts +0 -45
- package/dist/esm/global-account/react/hooks/useSimCollectibles.js +0 -187
- package/dist/esm/global-account/react/utils/simdune.d.ts +0 -7
- package/dist/esm/global-account/react/utils/simdune.js +0 -17
- package/dist/types/global-account/react/hooks/useSimBalance.d.ts +0 -59
- package/dist/types/global-account/react/hooks/useSimCollectibles.d.ts +0 -45
- package/dist/types/global-account/react/utils/simdune.d.ts +0 -7
- package/node_modules/@b3/chain-registry/src/index.ts +0 -169
- package/node_modules/@b3/chain-registry/tsconfig.json +0 -16
- package/src/global-account/react/hooks/useSimBalance.ts +0 -164
- package/src/global-account/react/hooks/useSimCollectibles.ts +0 -238
- package/src/global-account/react/utils/simdune.ts +0 -20
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
export interface SimTokenMetadata {
|
|
2
|
-
logo?: string;
|
|
3
|
-
}
|
|
4
|
-
export interface SimBalanceItem {
|
|
5
|
-
chain: string;
|
|
6
|
-
chain_id: number;
|
|
7
|
-
address: string;
|
|
8
|
-
amount: string;
|
|
9
|
-
symbol: string;
|
|
10
|
-
decimals: number;
|
|
11
|
-
price_usd?: number;
|
|
12
|
-
value_usd?: number;
|
|
13
|
-
name?: string;
|
|
14
|
-
token_metadata?: SimTokenMetadata;
|
|
15
|
-
pool_size?: number;
|
|
16
|
-
low_liquidity?: boolean;
|
|
17
|
-
}
|
|
18
|
-
export interface SimBalanceResponse {
|
|
19
|
-
request_time: string;
|
|
20
|
-
response_time: string;
|
|
21
|
-
wallet_address: string;
|
|
22
|
-
balances: SimBalanceItem[];
|
|
23
|
-
}
|
|
24
|
-
export interface SvmBalanceItem {
|
|
25
|
-
chain: string;
|
|
26
|
-
address: string;
|
|
27
|
-
amount: string;
|
|
28
|
-
balance: string;
|
|
29
|
-
raw_balance: string;
|
|
30
|
-
value_usd?: number;
|
|
31
|
-
program_id: string | null;
|
|
32
|
-
decimals: number;
|
|
33
|
-
total_supply: string;
|
|
34
|
-
metadata_address?: string;
|
|
35
|
-
name?: string;
|
|
36
|
-
symbol: string;
|
|
37
|
-
uri?: string | null;
|
|
38
|
-
price_usd?: number;
|
|
39
|
-
liquidity_usd?: number;
|
|
40
|
-
pool_type?: string | null;
|
|
41
|
-
pool_address?: string | null;
|
|
42
|
-
mint_authority?: string | null;
|
|
43
|
-
}
|
|
44
|
-
export interface SvmBalanceResponse {
|
|
45
|
-
processing_time_ms?: number;
|
|
46
|
-
wallet_address: string;
|
|
47
|
-
next_offset?: string;
|
|
48
|
-
balances_count?: number;
|
|
49
|
-
balances: SvmBalanceItem[];
|
|
50
|
-
}
|
|
51
|
-
export declare function useSimBalance(address?: string, chainIdsParam?: number[]): import("@tanstack/react-query").UseQueryResult<SimBalanceResponse, Error>;
|
|
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,93 +0,0 @@
|
|
|
1
|
-
import { useQuery } from "@tanstack/react-query";
|
|
2
|
-
import { buildSimduneUrl } from "../utils/simdune.js";
|
|
3
|
-
async function fetchSimBalance(address, chainIdsParam) {
|
|
4
|
-
if (!address)
|
|
5
|
-
throw new Error("Address is required");
|
|
6
|
-
const chainIds = chainIdsParam.length === 0 ? "mainnet" : chainIdsParam.join(",");
|
|
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);
|
|
12
|
-
const response = await fetch(url);
|
|
13
|
-
if (!response.ok) {
|
|
14
|
-
throw new Error(`Failed to fetch balance: ${response.statusText}`);
|
|
15
|
-
}
|
|
16
|
-
const balanceData = await response.json();
|
|
17
|
-
return balanceData;
|
|
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
|
-
}
|
|
36
|
-
async function fetchSimSvmBalance(address, chains, limit) {
|
|
37
|
-
if (!address)
|
|
38
|
-
throw new Error("Address is required");
|
|
39
|
-
const queryParams = new URLSearchParams();
|
|
40
|
-
if (chains && chains.length > 0) {
|
|
41
|
-
queryParams.append("chains", chains.join(","));
|
|
42
|
-
}
|
|
43
|
-
if (limit) {
|
|
44
|
-
queryParams.append("limit", limit.toString());
|
|
45
|
-
}
|
|
46
|
-
const url = buildSimduneUrl(`/beta/svm/balances/${address}`, queryParams.toString() ? queryParams : undefined);
|
|
47
|
-
const response = await fetch(url);
|
|
48
|
-
if (!response.ok) {
|
|
49
|
-
throw new Error(`Failed to fetch SVM balance: ${response.statusText}`);
|
|
50
|
-
}
|
|
51
|
-
const balanceData = await response.json();
|
|
52
|
-
return balanceData;
|
|
53
|
-
}
|
|
54
|
-
export function useSimBalance(address, chainIdsParam) {
|
|
55
|
-
return useQuery({
|
|
56
|
-
queryKey: ["simBalance", address, chainIdsParam],
|
|
57
|
-
queryFn: () => {
|
|
58
|
-
if (!address)
|
|
59
|
-
throw new Error("Address is required");
|
|
60
|
-
return fetchSimBalance(address, chainIdsParam || []);
|
|
61
|
-
},
|
|
62
|
-
enabled: Boolean(address),
|
|
63
|
-
});
|
|
64
|
-
}
|
|
65
|
-
export function useSimSvmBalance(address, chains, limit) {
|
|
66
|
-
return useQuery({
|
|
67
|
-
queryKey: ["svmBalance", address, chains, limit],
|
|
68
|
-
queryFn: () => {
|
|
69
|
-
if (!address)
|
|
70
|
-
throw new Error("Address is required");
|
|
71
|
-
return fetchSimSvmBalance(address, chains, limit);
|
|
72
|
-
},
|
|
73
|
-
enabled: Boolean(address),
|
|
74
|
-
});
|
|
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
|
-
}
|
|
@@ -1,45 +0,0 @@
|
|
|
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>;
|
|
@@ -1,187 +0,0 @@
|
|
|
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,7 +0,0 @@
|
|
|
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;
|
|
@@ -1,17 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
export interface SimTokenMetadata {
|
|
2
|
-
logo?: string;
|
|
3
|
-
}
|
|
4
|
-
export interface SimBalanceItem {
|
|
5
|
-
chain: string;
|
|
6
|
-
chain_id: number;
|
|
7
|
-
address: string;
|
|
8
|
-
amount: string;
|
|
9
|
-
symbol: string;
|
|
10
|
-
decimals: number;
|
|
11
|
-
price_usd?: number;
|
|
12
|
-
value_usd?: number;
|
|
13
|
-
name?: string;
|
|
14
|
-
token_metadata?: SimTokenMetadata;
|
|
15
|
-
pool_size?: number;
|
|
16
|
-
low_liquidity?: boolean;
|
|
17
|
-
}
|
|
18
|
-
export interface SimBalanceResponse {
|
|
19
|
-
request_time: string;
|
|
20
|
-
response_time: string;
|
|
21
|
-
wallet_address: string;
|
|
22
|
-
balances: SimBalanceItem[];
|
|
23
|
-
}
|
|
24
|
-
export interface SvmBalanceItem {
|
|
25
|
-
chain: string;
|
|
26
|
-
address: string;
|
|
27
|
-
amount: string;
|
|
28
|
-
balance: string;
|
|
29
|
-
raw_balance: string;
|
|
30
|
-
value_usd?: number;
|
|
31
|
-
program_id: string | null;
|
|
32
|
-
decimals: number;
|
|
33
|
-
total_supply: string;
|
|
34
|
-
metadata_address?: string;
|
|
35
|
-
name?: string;
|
|
36
|
-
symbol: string;
|
|
37
|
-
uri?: string | null;
|
|
38
|
-
price_usd?: number;
|
|
39
|
-
liquidity_usd?: number;
|
|
40
|
-
pool_type?: string | null;
|
|
41
|
-
pool_address?: string | null;
|
|
42
|
-
mint_authority?: string | null;
|
|
43
|
-
}
|
|
44
|
-
export interface SvmBalanceResponse {
|
|
45
|
-
processing_time_ms?: number;
|
|
46
|
-
wallet_address: string;
|
|
47
|
-
next_offset?: string;
|
|
48
|
-
balances_count?: number;
|
|
49
|
-
balances: SvmBalanceItem[];
|
|
50
|
-
}
|
|
51
|
-
export declare function useSimBalance(address?: string, chainIdsParam?: number[]): import("@tanstack/react-query").UseQueryResult<SimBalanceResponse, Error>;
|
|
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,45 +0,0 @@
|
|
|
1
|
-
import type { SimpleHashNFTResponse } from "@b3dotfun/sdk/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>;
|
|
@@ -1,7 +0,0 @@
|
|
|
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;
|