@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
|
@@ -8,6 +8,7 @@ const react_2 = require("react");
|
|
|
8
8
|
const viem_1 = require("thirdweb/adapters/viem");
|
|
9
9
|
const react_3 = require("thirdweb/react");
|
|
10
10
|
const debug = (0, debug_1.debugB3React)("useFirstEOA");
|
|
11
|
+
// Explicit return annotation keeps the hook's declaration portable (TS2742).
|
|
11
12
|
function useFirstEOA(chain) {
|
|
12
13
|
const wallets = (0, react_3.useConnectedWallets)();
|
|
13
14
|
const isConnected = (0, react_1.useAuthStore)(state => state.isConnected);
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { type B3TokenBalance } from "../../../shared/utils/zerionPositions";
|
|
2
|
+
/**
|
|
3
|
+
* Holdings for a wallet, optionally narrowed to specific chains.
|
|
4
|
+
*
|
|
5
|
+
* Read `isError` before reading `data`: a failed read and an empty wallet are different facts, and
|
|
6
|
+
* rendering the first as the second tells the user they hold nothing when nobody knows.
|
|
7
|
+
*/
|
|
8
|
+
export declare function usePortfolioBalance(address?: string, chainIds?: number[]): import("@tanstack/react-query").UseQueryResult<B3TokenBalance[], Error>;
|
|
9
|
+
/**
|
|
10
|
+
* One token's balance for a wallet, served from the same per-wallet fetch as {@link usePortfolioBalance}.
|
|
11
|
+
*
|
|
12
|
+
* `tokenAddress` may be a contract address or the chain's native sentinel; matching is
|
|
13
|
+
* case-insensitive because callers pass addresses in whatever casing their source used.
|
|
14
|
+
*/
|
|
15
|
+
export declare function usePortfolioTokenBalance(walletAddress?: string, tokenAddress?: string, chainId?: number): import("@tanstack/react-query").UseQueryResult<B3TokenBalance | undefined, Error>;
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.usePortfolioBalance = usePortfolioBalance;
|
|
4
|
+
exports.usePortfolioTokenBalance = usePortfolioTokenBalance;
|
|
5
|
+
const react_query_1 = require("@tanstack/react-query");
|
|
6
|
+
const zerionPositions_1 = require("../../../shared/utils/zerionPositions");
|
|
7
|
+
/**
|
|
8
|
+
* Wallet holdings, read through the b3 portfolio proxy.
|
|
9
|
+
*
|
|
10
|
+
* The proxy holds the upstream API key server-side and authorizes browsers by Origin allowlist, so
|
|
11
|
+
* nothing secret ships to the client and no key is accepted from it. A consumer served from an
|
|
12
|
+
* origin the proxy does not know will be refused — adding an origin is a proxy config change, not
|
|
13
|
+
* an SDK change.
|
|
14
|
+
*/
|
|
15
|
+
const PORTFOLIO_API_BASE_URL = "https://portfolio-api.b3.fun";
|
|
16
|
+
/**
|
|
17
|
+
* Fetch every spendable holding for a wallet in one request.
|
|
18
|
+
*
|
|
19
|
+
* Deliberately unpaginated and unfiltered by chain. The positions endpoint returns a wallet's full
|
|
20
|
+
* simple-position list in a single response, and passing a chain filter is actively harmful: the
|
|
21
|
+
* upstream rejects a handful of otherwise-valid chain slugs and fails the WHOLE request when one
|
|
22
|
+
* appears, so a caller asking for five chains can lose all five. Callers narrow the result instead.
|
|
23
|
+
*/
|
|
24
|
+
async function fetchWalletPositions(address) {
|
|
25
|
+
const url = `${PORTFOLIO_API_BASE_URL}/v1/wallets/${encodeURIComponent(address)}/positions/?filter[positions]=only_simple`;
|
|
26
|
+
const response = await fetch(url, { headers: { Accept: "application/json" } });
|
|
27
|
+
if (!response.ok) {
|
|
28
|
+
throw new Error(`Failed to fetch wallet balances: ${response.status} ${response.statusText}`);
|
|
29
|
+
}
|
|
30
|
+
const body = (await response.json());
|
|
31
|
+
return (0, zerionPositions_1.adaptZerionPositions)(body.data ?? []);
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Keyed by wallet alone so every consumer of the same wallet shares one fetch and one cache entry.
|
|
35
|
+
* Keying by the requested chain subset instead would refetch per caller and share nothing.
|
|
36
|
+
*/
|
|
37
|
+
function walletPositionsQueryKey(address) {
|
|
38
|
+
return ["walletPositions", address];
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Holdings for a wallet, optionally narrowed to specific chains.
|
|
42
|
+
*
|
|
43
|
+
* Read `isError` before reading `data`: a failed read and an empty wallet are different facts, and
|
|
44
|
+
* rendering the first as the second tells the user they hold nothing when nobody knows.
|
|
45
|
+
*/
|
|
46
|
+
function usePortfolioBalance(address, chainIds) {
|
|
47
|
+
const wantedChainIds = chainIds && chainIds.length > 0 ? chainIds : undefined;
|
|
48
|
+
return (0, react_query_1.useQuery)({
|
|
49
|
+
queryKey: walletPositionsQueryKey(address),
|
|
50
|
+
queryFn: () => {
|
|
51
|
+
if (!address)
|
|
52
|
+
throw new Error("Address is required");
|
|
53
|
+
return fetchWalletPositions(address);
|
|
54
|
+
},
|
|
55
|
+
enabled: Boolean(address),
|
|
56
|
+
select: (balances) => wantedChainIds ? balances.filter(balance => wantedChainIds.includes(balance.chain_id)) : balances,
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* One token's balance for a wallet, served from the same per-wallet fetch as {@link usePortfolioBalance}.
|
|
61
|
+
*
|
|
62
|
+
* `tokenAddress` may be a contract address or the chain's native sentinel; matching is
|
|
63
|
+
* case-insensitive because callers pass addresses in whatever casing their source used.
|
|
64
|
+
*/
|
|
65
|
+
function usePortfolioTokenBalance(walletAddress, tokenAddress, chainId) {
|
|
66
|
+
return (0, react_query_1.useQuery)({
|
|
67
|
+
queryKey: walletPositionsQueryKey(walletAddress),
|
|
68
|
+
queryFn: () => {
|
|
69
|
+
if (!walletAddress)
|
|
70
|
+
throw new Error("Address is required");
|
|
71
|
+
return fetchWalletPositions(walletAddress);
|
|
72
|
+
},
|
|
73
|
+
enabled: Boolean(walletAddress) && Boolean(tokenAddress) && Boolean(chainId),
|
|
74
|
+
select: (balances) => balances.find(balance => balance.chain_id === chainId && (0, zerionPositions_1.balanceMatchesToken)(balance, tokenAddress ?? "")),
|
|
75
|
+
});
|
|
76
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { SimpleHashNFTResponse } from "../../../global-account/types/simplehash.types";
|
|
2
|
+
/**
|
|
3
|
+
* NFTs held by a wallet, in the SimpleHash shape `AccountAssets` already renders.
|
|
4
|
+
*
|
|
5
|
+
* Chain narrowing happens here rather than in the request: the upstream rejects some valid chain
|
|
6
|
+
* slugs outright and fails the whole request when one is present, so asking for a subset can cost
|
|
7
|
+
* you the whole answer.
|
|
8
|
+
*/
|
|
9
|
+
export declare function usePortfolioCollectibles(address?: string, chainIds?: number[], options?: {
|
|
10
|
+
limit?: number;
|
|
11
|
+
filterSpam?: boolean;
|
|
12
|
+
}): import("@tanstack/react-query").UseQueryResult<SimpleHashNFTResponse, Error>;
|
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.usePortfolioCollectibles = usePortfolioCollectibles;
|
|
4
|
+
const zerionPositions_1 = require("../../../shared/utils/zerionPositions");
|
|
5
|
+
const react_query_1 = require("@tanstack/react-query");
|
|
6
|
+
const PORTFOLIO_API_BASE_URL = "https://portfolio-api.b3.fun";
|
|
7
|
+
/** Caps an ERC-1155 balance string at MAX_SAFE_INTEGER so a huge supply cannot overflow. */
|
|
8
|
+
function safeParseBalance(balance) {
|
|
9
|
+
if (!balance)
|
|
10
|
+
return 1;
|
|
11
|
+
const parsed = parseInt(balance, 10);
|
|
12
|
+
if (Number.isNaN(parsed))
|
|
13
|
+
return 1;
|
|
14
|
+
return Math.min(parsed, Number.MAX_SAFE_INTEGER);
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Reshape one Zerion NFT position into the SimpleHash record `AccountAssets` renders.
|
|
18
|
+
*
|
|
19
|
+
* Fields Zerion does not carry — traits, rarity, royalties, sale history — stay empty rather than
|
|
20
|
+
* being synthesised from something adjacent. In particular the position's `price` is a current
|
|
21
|
+
* estimate, not a sale, so it must not be written into `last_sale`.
|
|
22
|
+
*/
|
|
23
|
+
function toSimpleHashNft(position, ownerAddress) {
|
|
24
|
+
const attributes = position.attributes ?? {};
|
|
25
|
+
const nftInfo = attributes.nft_info;
|
|
26
|
+
const slug = position.relationships?.chain?.data?.id;
|
|
27
|
+
if (!nftInfo?.contract_address || !nftInfo.token_id || !slug)
|
|
28
|
+
return null;
|
|
29
|
+
const imageUrl = nftInfo.content?.detail?.url ?? nftInfo.content?.preview?.url ?? "";
|
|
30
|
+
const collectionInfo = attributes.collection_info ?? {};
|
|
31
|
+
const acquiredAt = attributes.changed_at ?? "";
|
|
32
|
+
return {
|
|
33
|
+
nft_id: `${slug}.${nftInfo.contract_address}.${nftInfo.token_id}`,
|
|
34
|
+
chain: slug,
|
|
35
|
+
contract_address: nftInfo.contract_address,
|
|
36
|
+
token_id: nftInfo.token_id,
|
|
37
|
+
name: nftInfo.name || "",
|
|
38
|
+
description: collectionInfo.description || "",
|
|
39
|
+
previews: {
|
|
40
|
+
image_small_url: nftInfo.content?.preview?.url ?? imageUrl,
|
|
41
|
+
image_medium_url: imageUrl,
|
|
42
|
+
image_large_url: imageUrl,
|
|
43
|
+
image_opengraph_url: imageUrl,
|
|
44
|
+
blurhash: "",
|
|
45
|
+
predominant_color: "",
|
|
46
|
+
},
|
|
47
|
+
image_url: imageUrl,
|
|
48
|
+
image_properties: { width: 0, height: 0, size: 0, mime_type: "", exif_orientation: null },
|
|
49
|
+
video_url: null,
|
|
50
|
+
video_properties: null,
|
|
51
|
+
audio_url: null,
|
|
52
|
+
audio_properties: null,
|
|
53
|
+
model_url: null,
|
|
54
|
+
model_properties: null,
|
|
55
|
+
other_url: null,
|
|
56
|
+
other_properties: null,
|
|
57
|
+
background_color: null,
|
|
58
|
+
external_url: null,
|
|
59
|
+
created_date: "",
|
|
60
|
+
status: "minted",
|
|
61
|
+
token_count: 1,
|
|
62
|
+
owner_count: 1,
|
|
63
|
+
owners: [
|
|
64
|
+
{
|
|
65
|
+
owner_address: ownerAddress,
|
|
66
|
+
quantity: safeParseBalance(attributes.amount),
|
|
67
|
+
quantity_string: attributes.amount || "1",
|
|
68
|
+
first_acquired_date: acquiredAt,
|
|
69
|
+
last_acquired_date: acquiredAt,
|
|
70
|
+
},
|
|
71
|
+
],
|
|
72
|
+
contract: {
|
|
73
|
+
type: nftInfo.interface === "ERC1155" ? "ERC1155" : "ERC721",
|
|
74
|
+
name: collectionInfo.name || "",
|
|
75
|
+
symbol: null,
|
|
76
|
+
deployed_by: "",
|
|
77
|
+
deployed_via_contract: "",
|
|
78
|
+
owned_by: "",
|
|
79
|
+
has_multiple_collections: false,
|
|
80
|
+
},
|
|
81
|
+
collection: {
|
|
82
|
+
collection_id: nftInfo.contract_address,
|
|
83
|
+
name: collectionInfo.name || "Unknown Collection",
|
|
84
|
+
description: collectionInfo.description ?? null,
|
|
85
|
+
image_url: collectionInfo.content?.icon?.url ?? "",
|
|
86
|
+
image_properties: { width: 0, height: 0, mime_type: "" },
|
|
87
|
+
banner_image_url: null,
|
|
88
|
+
category: null,
|
|
89
|
+
is_nsfw: null,
|
|
90
|
+
external_url: null,
|
|
91
|
+
twitter_username: null,
|
|
92
|
+
discord_url: null,
|
|
93
|
+
instagram_username: null,
|
|
94
|
+
medium_username: null,
|
|
95
|
+
telegram_url: null,
|
|
96
|
+
marketplace_pages: [],
|
|
97
|
+
metaplex_mint: null,
|
|
98
|
+
metaplex_candy_machine: null,
|
|
99
|
+
metaplex_first_verified_creator: null,
|
|
100
|
+
floor_prices: [],
|
|
101
|
+
top_bids: [],
|
|
102
|
+
distinct_owner_count: 0,
|
|
103
|
+
distinct_nft_count: 0,
|
|
104
|
+
total_quantity: 0,
|
|
105
|
+
chains: [slug],
|
|
106
|
+
top_contracts: [nftInfo.contract_address],
|
|
107
|
+
collection_royalties: [],
|
|
108
|
+
},
|
|
109
|
+
last_sale: null,
|
|
110
|
+
primary_sale: null,
|
|
111
|
+
first_created: {
|
|
112
|
+
minted_to: ownerAddress,
|
|
113
|
+
quantity: 1,
|
|
114
|
+
quantity_string: "1",
|
|
115
|
+
timestamp: "",
|
|
116
|
+
block_number: 0,
|
|
117
|
+
transaction: "",
|
|
118
|
+
transaction_initiator: "",
|
|
119
|
+
},
|
|
120
|
+
rarity: { rank: null, score: null, unique_attributes: null },
|
|
121
|
+
royalty: [],
|
|
122
|
+
extra_metadata: {
|
|
123
|
+
attributes: [],
|
|
124
|
+
image_original_url: imageUrl,
|
|
125
|
+
animation_original_url: null,
|
|
126
|
+
metadata_original_url: "",
|
|
127
|
+
},
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* NFTs held by a wallet, in the SimpleHash shape `AccountAssets` already renders.
|
|
132
|
+
*
|
|
133
|
+
* Chain narrowing happens here rather than in the request: the upstream rejects some valid chain
|
|
134
|
+
* slugs outright and fails the whole request when one is present, so asking for a subset can cost
|
|
135
|
+
* you the whole answer.
|
|
136
|
+
*/
|
|
137
|
+
function usePortfolioCollectibles(address, chainIds, options) {
|
|
138
|
+
const limit = options?.limit;
|
|
139
|
+
const filterSpam = options?.filterSpam;
|
|
140
|
+
const wantedChainIds = chainIds && chainIds.length > 0 ? chainIds : undefined;
|
|
141
|
+
return (0, react_query_1.useQuery)({
|
|
142
|
+
queryKey: ["walletCollectibles", address, limit, filterSpam],
|
|
143
|
+
queryFn: async () => {
|
|
144
|
+
if (!address)
|
|
145
|
+
throw new Error("Address is required");
|
|
146
|
+
const params = new URLSearchParams();
|
|
147
|
+
if (limit)
|
|
148
|
+
params.set("page[size]", String(limit));
|
|
149
|
+
const query = params.toString();
|
|
150
|
+
const url = `${PORTFOLIO_API_BASE_URL}/v1/wallets/${encodeURIComponent(address)}/nft-positions/${query ? `?${query}` : ""}`;
|
|
151
|
+
const response = await fetch(url, { headers: { Accept: "application/json" } });
|
|
152
|
+
if (!response.ok) {
|
|
153
|
+
throw new Error(`Failed to fetch collectibles: ${response.status} ${response.statusText}`);
|
|
154
|
+
}
|
|
155
|
+
const body = (await response.json());
|
|
156
|
+
// Spam is dropped here, not in `select`: the flag lives on the raw position and the
|
|
157
|
+
// SimpleHash shape has nowhere to carry it downstream.
|
|
158
|
+
const nfts = (body.data ?? [])
|
|
159
|
+
.filter(position => !(filterSpam && position.attributes?.nft_info?.flags?.is_spam === true))
|
|
160
|
+
.map(position => toSimpleHashNft(position, address))
|
|
161
|
+
.filter((nft) => nft !== null);
|
|
162
|
+
return { next_cursor: null, next: null, previous: null, nfts };
|
|
163
|
+
},
|
|
164
|
+
enabled: Boolean(address),
|
|
165
|
+
staleTime: 30 * 1000,
|
|
166
|
+
gcTime: 5 * 60 * 1000,
|
|
167
|
+
select: (data) => {
|
|
168
|
+
if (!wantedChainIds)
|
|
169
|
+
return data;
|
|
170
|
+
const all = data.nfts ?? [];
|
|
171
|
+
const nfts = all.filter(nft => {
|
|
172
|
+
const chainId = (0, zerionPositions_1.zerionSlugToChainId)(nft.chain);
|
|
173
|
+
return chainId !== undefined && wantedChainIds.includes(chainId);
|
|
174
|
+
});
|
|
175
|
+
return nfts.length === all.length ? data : { ...data, nfts };
|
|
176
|
+
},
|
|
177
|
+
});
|
|
178
|
+
}
|
|
@@ -649,8 +649,6 @@ export interface AnySpendDepositModalProps extends BaseModalProps {
|
|
|
649
649
|
showChainSelection?: boolean;
|
|
650
650
|
/** Whether to show the "Fund with Fiat" option in the deposit options list. Defaults to true */
|
|
651
651
|
showFiatOption?: boolean;
|
|
652
|
-
/** Minimum pool size for filtering tokens (default: 1,000,000) */
|
|
653
|
-
minPoolSize?: number;
|
|
654
652
|
/** Custom title for chain selection step */
|
|
655
653
|
chainSelectionTitle?: string;
|
|
656
654
|
/** Custom description for chain selection step */
|
|
@@ -13,6 +13,6 @@ export interface CreateWagmiConfigOptions {
|
|
|
13
13
|
* @param options.connectors - Additional connectors to include
|
|
14
14
|
* @param options.overrideDefaultConnectors - If true, only use provided connectors (ignores defaults)
|
|
15
15
|
*/
|
|
16
|
-
export declare function createWagmiConfig(options: CreateWagmiConfigOptions): import("wagmi").Config<readonly [
|
|
17
|
-
[k: string]:
|
|
16
|
+
export declare function createWagmiConfig(options: CreateWagmiConfigOptions): import("wagmi").Config<readonly [any, ...any[]], {
|
|
17
|
+
[k: string]: any;
|
|
18
18
|
}, CreateConnectorFn[]>;
|
|
@@ -37,11 +37,23 @@ export declare const b3Mainnet: {
|
|
|
37
37
|
};
|
|
38
38
|
};
|
|
39
39
|
sourceId?: number | undefined | undefined;
|
|
40
|
+
supportsTransactionReplacementDetection?: boolean | undefined | undefined;
|
|
40
41
|
testnet?: boolean | undefined | undefined;
|
|
41
42
|
custom?: Record<string, unknown> | undefined;
|
|
43
|
+
extendSchema?: Record<string, unknown> | undefined;
|
|
42
44
|
fees?: import("viem").ChainFees<undefined> | undefined;
|
|
43
45
|
formatters?: undefined;
|
|
46
|
+
prepareTransactionRequest?: ((args: import("viem").PrepareTransactionRequestParameters, options: {
|
|
47
|
+
client: import("viem").Client;
|
|
48
|
+
phase: "beforeFillTransaction" | "beforeFillParameters" | "afterFillParameters";
|
|
49
|
+
}) => Promise<import("viem").PrepareTransactionRequestParameters>) | [fn: ((args: import("viem").PrepareTransactionRequestParameters, options: {
|
|
50
|
+
client: import("viem").Client;
|
|
51
|
+
phase: "beforeFillTransaction" | "beforeFillParameters" | "afterFillParameters";
|
|
52
|
+
}) => Promise<import("viem").PrepareTransactionRequestParameters>) | undefined, options: {
|
|
53
|
+
runAt: readonly ("beforeFillTransaction" | "beforeFillParameters" | "afterFillParameters")[];
|
|
54
|
+
}] | undefined;
|
|
44
55
|
serializers?: import("viem").ChainSerializers<undefined, import("viem").TransactionSerializable> | undefined;
|
|
56
|
+
verifyHash?: ((client: import("viem").Client, parameters: import("viem").VerifyHashActionParameters) => Promise<import("viem").VerifyHashActionReturnType>) | undefined;
|
|
45
57
|
readonly rpc: "https://mainnet-rpc.b3.fun";
|
|
46
58
|
readonly icon: {
|
|
47
59
|
readonly url: "https://cdn.b3.fun/b3_logo.svg";
|
|
@@ -85,11 +97,23 @@ export declare const b3Chain: Chain | {
|
|
|
85
97
|
};
|
|
86
98
|
};
|
|
87
99
|
sourceId?: number | undefined | undefined;
|
|
100
|
+
supportsTransactionReplacementDetection?: boolean | undefined | undefined;
|
|
88
101
|
testnet?: boolean | undefined | undefined;
|
|
89
102
|
custom?: Record<string, unknown> | undefined;
|
|
103
|
+
extendSchema?: Record<string, unknown> | undefined;
|
|
90
104
|
fees?: import("viem").ChainFees<undefined> | undefined;
|
|
91
105
|
formatters?: undefined;
|
|
106
|
+
prepareTransactionRequest?: ((args: import("viem").PrepareTransactionRequestParameters, options: {
|
|
107
|
+
client: import("viem").Client;
|
|
108
|
+
phase: "beforeFillTransaction" | "beforeFillParameters" | "afterFillParameters";
|
|
109
|
+
}) => Promise<import("viem").PrepareTransactionRequestParameters>) | [fn: ((args: import("viem").PrepareTransactionRequestParameters, options: {
|
|
110
|
+
client: import("viem").Client;
|
|
111
|
+
phase: "beforeFillTransaction" | "beforeFillParameters" | "afterFillParameters";
|
|
112
|
+
}) => Promise<import("viem").PrepareTransactionRequestParameters>) | undefined, options: {
|
|
113
|
+
runAt: readonly ("beforeFillTransaction" | "beforeFillParameters" | "afterFillParameters")[];
|
|
114
|
+
}] | undefined;
|
|
92
115
|
serializers?: import("viem").ChainSerializers<undefined, import("viem").TransactionSerializable> | undefined;
|
|
116
|
+
verifyHash?: ((client: import("viem").Client, parameters: import("viem").VerifyHashActionParameters) => Promise<import("viem").VerifyHashActionReturnType>) | undefined;
|
|
93
117
|
readonly rpc: "https://mainnet-rpc.b3.fun";
|
|
94
118
|
readonly icon: {
|
|
95
119
|
readonly url: "https://cdn.b3.fun/b3_logo.svg";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { Chain as ThirdwebChain } from "thirdweb";
|
|
2
|
-
export declare const supportedChains:
|
|
2
|
+
export declare const supportedChains: any;
|
|
3
3
|
export declare const supportedChainsTW: ThirdwebChain[];
|
|
4
|
-
export declare const supportedChainNetworks:
|
|
4
|
+
export declare const supportedChainNetworks: any;
|
|
5
5
|
export declare const coingeckoChains: Record<number, {
|
|
6
6
|
coingecko_id: string;
|
|
7
7
|
name: string;
|
|
@@ -15,7 +15,7 @@ export declare function getCoingeckoChainInfo(chainId: number): {
|
|
|
15
15
|
export declare const b3MainnetThirdWeb: Readonly<import("thirdweb/chains").ChainOptions & {
|
|
16
16
|
rpc: string;
|
|
17
17
|
}>;
|
|
18
|
-
export declare const b3Mainnet:
|
|
19
|
-
export declare const baseMainnet:
|
|
18
|
+
export declare const b3Mainnet: any;
|
|
19
|
+
export declare const baseMainnet: any;
|
|
20
20
|
export declare function getThirdwebChain(chainId: number): ThirdwebChain;
|
|
21
21
|
export declare function getChainLogo(chainId: number): string;
|
|
@@ -1,7 +1,11 @@
|
|
|
1
|
+
import type { Wallet } from "thirdweb/wallets";
|
|
1
2
|
export * from "./currency";
|
|
2
3
|
export declare const siteURL = "https://basement.fun";
|
|
3
4
|
export declare const b3CoinIcon = "https://cdn.b3.fun/b3-coin-3d.png";
|
|
4
5
|
export declare const ecosystemWalletId: `ecosystem.${string}`;
|
|
6
|
+
export type EcosystemWallet = Wallet<`ecosystem.${string}`> & {
|
|
7
|
+
getAuthToken: () => string | null;
|
|
8
|
+
};
|
|
5
9
|
export declare const tokenIcons: {
|
|
6
10
|
ETH: string;
|
|
7
11
|
WETH: string;
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Canonical browser-side translation of Zerion wallet positions into B3 balance rows.
|
|
3
|
+
*
|
|
4
|
+
* This lives in the published SDK because every browser consumer needs it — the apps in this repo
|
|
5
|
+
* and the sites that install `@b3dotfun/sdk` from npm — and the in-repo Zerion client is a private
|
|
6
|
+
* workspace package that a published package cannot depend on. Backend services keep their own
|
|
7
|
+
* translation: pulling a browser SDK into a Node service to share one function is a worse trade
|
|
8
|
+
* than the second copy.
|
|
9
|
+
*
|
|
10
|
+
* Only the HTTP layer differs between callers. The rules below — which row counts as the chain's
|
|
11
|
+
* native coin, and which rows have no usable identity — must not be re-derived anywhere else.
|
|
12
|
+
*/
|
|
13
|
+
/** Address B3 uses for a chain's native coin on EVM. Matches NATIVE_TOKEN_ADDRESSES. */
|
|
14
|
+
export declare const EVM_NATIVE_TOKEN_ADDRESS = "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee";
|
|
15
|
+
export declare const SOLANA_NATIVE_TOKEN_ADDRESS = "So11111111111111111111111111111111111111112";
|
|
16
|
+
export declare const SOLANA_ZERION_SLUG = "solana";
|
|
17
|
+
/** Solana's chain id as the chain registry defines it — the id every balance row is keyed by. */
|
|
18
|
+
export declare const SOLANA_CHAIN_ID = 7565164;
|
|
19
|
+
export declare function zerionSlugToChainId(slug: string): number | undefined;
|
|
20
|
+
export declare function chainIdToZerionSlug(chainId: number): string | undefined;
|
|
21
|
+
export interface ZerionPositionQuantity {
|
|
22
|
+
int?: string;
|
|
23
|
+
decimals?: number;
|
|
24
|
+
}
|
|
25
|
+
export interface ZerionPositionImplementation {
|
|
26
|
+
chain_id?: string;
|
|
27
|
+
address?: string | null;
|
|
28
|
+
decimals?: number;
|
|
29
|
+
}
|
|
30
|
+
export interface ZerionPositionFungibleInfo {
|
|
31
|
+
name?: string;
|
|
32
|
+
symbol?: string;
|
|
33
|
+
icon?: {
|
|
34
|
+
url?: string;
|
|
35
|
+
} | null;
|
|
36
|
+
implementations?: ZerionPositionImplementation[];
|
|
37
|
+
}
|
|
38
|
+
export interface ZerionPositionLike {
|
|
39
|
+
id?: string;
|
|
40
|
+
attributes?: {
|
|
41
|
+
quantity?: ZerionPositionQuantity;
|
|
42
|
+
value?: number | null;
|
|
43
|
+
price?: number | null;
|
|
44
|
+
fungible_info?: ZerionPositionFungibleInfo;
|
|
45
|
+
flags?: {
|
|
46
|
+
displayable?: boolean;
|
|
47
|
+
is_trash?: boolean;
|
|
48
|
+
};
|
|
49
|
+
};
|
|
50
|
+
relationships?: {
|
|
51
|
+
chain?: {
|
|
52
|
+
data?: {
|
|
53
|
+
id?: string;
|
|
54
|
+
};
|
|
55
|
+
};
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
/** One spendable holding. `amount` is the raw integer; pair it with `decimals` to display. */
|
|
59
|
+
export interface B3TokenBalance {
|
|
60
|
+
chain: string;
|
|
61
|
+
chain_id: number;
|
|
62
|
+
address: string;
|
|
63
|
+
amount: string;
|
|
64
|
+
symbol: string;
|
|
65
|
+
decimals: number;
|
|
66
|
+
/**
|
|
67
|
+
* Whether `address` is the native-coin sentinel rather than a real contract. Callers deciding
|
|
68
|
+
* between a value-bearing send and an ERC-20 `transfer` MUST branch on this, never on the
|
|
69
|
+
* sentinel string: getting it backwards spends gas and moves nothing.
|
|
70
|
+
*/
|
|
71
|
+
is_native: boolean;
|
|
72
|
+
name?: string;
|
|
73
|
+
price_usd?: number;
|
|
74
|
+
value_usd?: number;
|
|
75
|
+
token_metadata?: {
|
|
76
|
+
logo: string;
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
export declare function nativeTokenAddressForChain(slug: string): string;
|
|
80
|
+
/**
|
|
81
|
+
* Whether `balance` is the token identified by `tokenAddress`.
|
|
82
|
+
*
|
|
83
|
+
* Native coins are matched on the row's `is_native` flag rather than its printed address, because
|
|
84
|
+
* the caller and the adapter rarely spell the native coin the same way.
|
|
85
|
+
*/
|
|
86
|
+
export declare function balanceMatchesToken(balance: B3TokenBalance, tokenAddress: string): boolean;
|
|
87
|
+
/**
|
|
88
|
+
* Adapt raw Zerion positions into balance rows, dropping any row we cannot describe honestly.
|
|
89
|
+
*
|
|
90
|
+
* A row is dropped when its chain slug is absent or unmapped, or when neither the quantity nor the
|
|
91
|
+
* chain implementation carries decimals — an amount rendered against a guessed scale is a wrong
|
|
92
|
+
* number presented as a real one, which is worse for the reader than a missing row.
|
|
93
|
+
*
|
|
94
|
+
* @param slugToChainId overrides slug resolution; return undefined to skip a chain entirely.
|
|
95
|
+
*/
|
|
96
|
+
export declare function adaptZerionPositions(positions: ZerionPositionLike[], slugToChainId?: (slug: string) => number | undefined): B3TokenBalance[];
|