@b3dotfun/sdk 0.1.70-alpha.19 → 0.1.70-alpha.20
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/dist/cjs/anyspend/react/components/AnySpend.js +1 -2
- package/dist/cjs/anyspend/react/components/AnySpendCustomExactIn.js +4 -9
- package/dist/cjs/anyspend/react/components/checkout/CryptoPayPanel.js +2 -3
- package/dist/cjs/anyspend/utils/address.d.ts +2 -1
- package/dist/cjs/anyspend/utils/address.js +12 -9
- package/dist/cjs/global-account/react/utils/createWagmiConfig.d.ts +2 -2
- package/dist/cjs/shared/constants/chains/supported.d.ts +4 -4
- package/dist/cjs/shared/constants/chains/supported.js +4 -4
- package/dist/cjs/shared/utils/zerionPositions.d.ts +3 -3
- package/dist/cjs/shared/utils/zerionPositions.js +12 -10
- package/dist/cjs/wallet/utils/createWalletConfig.d.ts +2 -2
- package/dist/esm/anyspend/react/components/AnySpend.js +2 -3
- package/dist/esm/anyspend/react/components/AnySpendCustomExactIn.js +5 -10
- package/dist/esm/anyspend/react/components/checkout/CryptoPayPanel.js +3 -4
- package/dist/esm/anyspend/utils/address.d.ts +2 -1
- package/dist/esm/anyspend/utils/address.js +9 -6
- package/dist/esm/global-account/react/utils/createWagmiConfig.d.ts +2 -2
- package/dist/esm/shared/constants/chains/supported.d.ts +4 -4
- package/dist/esm/shared/constants/chains/supported.js +1 -1
- package/dist/esm/shared/utils/zerionPositions.d.ts +3 -3
- package/dist/esm/shared/utils/zerionPositions.js +5 -3
- package/dist/esm/wallet/utils/createWalletConfig.d.ts +2 -2
- package/dist/types/anyspend/utils/address.d.ts +2 -1
- package/dist/types/global-account/react/utils/createWagmiConfig.d.ts +2 -2
- package/dist/types/shared/constants/chains/supported.d.ts +4 -4
- package/dist/types/shared/utils/zerionPositions.d.ts +3 -3
- package/dist/types/wallet/utils/createWalletConfig.d.ts +2 -2
- package/node_modules/@b3/chain-registry/chains.json +38 -1
- package/node_modules/@b3/chain-registry/dist/chains.json +1225 -0
- package/node_modules/@b3/chain-registry/dist/index.cjs +1676 -0
- package/node_modules/@b3/chain-registry/dist/index.d.cts +195 -0
- package/node_modules/@b3/chain-registry/dist/index.d.ts +195 -0
- package/node_modules/@b3/chain-registry/dist/index.mjs +1604 -0
- package/node_modules/@b3/chain-registry/dist/src/index.d.ts +193 -0
- package/node_modules/@b3/chain-registry/dist/src/index.js +408 -0
- package/node_modules/@b3/chain-registry/package.json +44 -8
- package/node_modules/@b3/chain-registry/src/index.test.ts +432 -0
- package/node_modules/@b3/chain-registry/src/index.ts +672 -0
- package/package.json +5 -2
- package/src/anyspend/react/components/AnySpend.tsx +2 -2
- package/src/anyspend/react/components/AnySpendCustomExactIn.tsx +5 -10
- package/src/anyspend/react/components/__tests__/QRDeposit.test.tsx +39 -1
- package/src/anyspend/react/components/checkout/CryptoPayPanel.tsx +13 -4
- package/src/anyspend/services/gas.test.ts +95 -18
- package/src/anyspend/utils/__tests__/address.test.ts +39 -0
- package/src/anyspend/utils/address.ts +8 -6
- package/src/shared/constants/chains/supported.ts +1 -1
- package/src/shared/react/hooks/__tests__/useCurrencyConversion.test.ts +54 -43
- package/src/shared/utils/__tests__/zerionPositions.test.ts +23 -1
- package/src/shared/utils/zerionPositions.ts +6 -3
|
@@ -649,8 +649,7 @@ function AnySpendInner({ sourceChainId, destinationTokenAddress, destinationToke
|
|
|
649
649
|
// Check if it's a same-chain same-token swap
|
|
650
650
|
const isSameChainSameToken = (0, react_4.useMemo)(() => {
|
|
651
651
|
return (activeTab === "crypto" &&
|
|
652
|
-
selectedSrcChainId
|
|
653
|
-
selectedSrcToken.address.toLowerCase() === selectedDstToken.address.toLowerCase());
|
|
652
|
+
(0, anyspend_1.isSameChainAndToken)(selectedSrcChainId, selectedSrcToken.address, selectedDstChainId, selectedDstToken.address));
|
|
654
653
|
}, [activeTab, selectedSrcChainId, selectedDstChainId, selectedSrcToken.address, selectedDstToken.address]);
|
|
655
654
|
// Check if this is a direct transfer (same chain/token with allowDirectTransfer enabled)
|
|
656
655
|
const isDirectTransfer = isSameChainSameToken && allowDirectTransfer;
|
|
@@ -67,15 +67,10 @@ function AnySpendCustomExactInInner({ loadOrder, mode = "modal", recipientAddres
|
|
|
67
67
|
// Check if source and destination are the same token on the same chain
|
|
68
68
|
const isSameChainSameToken = (0, react_4.useMemo)(() => {
|
|
69
69
|
return (effectivePaymentType === "crypto" &&
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
selectedSrcChainId,
|
|
75
|
-
selectedDstChainId,
|
|
76
|
-
selectedSrcToken?.address,
|
|
77
|
-
selectedDstToken?.address,
|
|
78
|
-
]);
|
|
70
|
+
selectedSrcToken != null &&
|
|
71
|
+
selectedDstToken != null &&
|
|
72
|
+
(0, utils_1.isSameChainAndToken)(selectedSrcChainId, selectedSrcToken.address, selectedDstChainId, selectedDstToken.address));
|
|
73
|
+
}, [effectivePaymentType, selectedSrcChainId, selectedDstChainId, selectedSrcToken, selectedDstToken]);
|
|
79
74
|
// Check if this is a direct transfer
|
|
80
75
|
const isDirectTransfer = isSameChainSameToken && allowDirectTransfer;
|
|
81
76
|
// State for direct transfer success
|
|
@@ -54,9 +54,8 @@ function CryptoPayPanel({ recipientAddress, destinationTokenAddress, destination
|
|
|
54
54
|
});
|
|
55
55
|
}
|
|
56
56
|
}, [selectedSrcToken, dstTokenData, destinationTokenAddress, destinationTokenChainId]);
|
|
57
|
-
const isSameToken = selectedSrcToken &&
|
|
58
|
-
selectedSrcToken.address
|
|
59
|
-
selectedSrcToken.chainId === destinationTokenChainId;
|
|
57
|
+
const isSameToken = selectedSrcToken !== null &&
|
|
58
|
+
(0, anyspend_1.isSameChainAndToken)(selectedSrcToken.chainId, selectedSrcToken.address, destinationTokenChainId, destinationTokenAddress);
|
|
60
59
|
const { anyspendQuote, isLoadingAnyspendQuote } = (0, useAnyspendQuote_1.useAnyspendQuote)({
|
|
61
60
|
type: "swap",
|
|
62
61
|
srcChain: selectedSrcChainId,
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
|
|
1
|
+
import { isSolanaAddress } from "@b3/chain-registry/runtime";
|
|
2
|
+
export { isSolanaAddress };
|
|
2
3
|
export declare function isEvmOrSolanaAddress(address: string): boolean;
|
|
3
4
|
/**
|
|
4
5
|
* Check if an address is Hyperliquid's special USDC address.
|
|
@@ -1,20 +1,18 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.isSolanaAddress =
|
|
3
|
+
exports.isSolanaAddress = void 0;
|
|
4
4
|
exports.isEvmOrSolanaAddress = isEvmOrSolanaAddress;
|
|
5
5
|
exports.isHyperliquidUSDC = isHyperliquidUSDC;
|
|
6
6
|
exports.normalizeAddress = normalizeAddress;
|
|
7
7
|
exports.eqci = eqci;
|
|
8
8
|
exports.isSameChainAndToken = isSameChainAndToken;
|
|
9
|
+
const runtime_1 = require("@b3/chain-registry/runtime");
|
|
10
|
+
Object.defineProperty(exports, "isSolanaAddress", { enumerable: true, get: function () { return runtime_1.isSolanaAddress; } });
|
|
9
11
|
const viem_1 = require("viem");
|
|
12
|
+
const constants_1 = require("../constants");
|
|
10
13
|
const token_1 = require("./token");
|
|
11
|
-
function isSolanaAddress(address) {
|
|
12
|
-
// Solana addresses are 32-byte base58 strings (usually 32-44 characters)
|
|
13
|
-
const solanaAddressRegex = /^[1-9A-HJ-NP-Za-km-z]{32,44}$/;
|
|
14
|
-
return solanaAddressRegex.test(address);
|
|
15
|
-
}
|
|
16
14
|
function isEvmOrSolanaAddress(address) {
|
|
17
|
-
return (0, viem_1.isAddress)(address) || isSolanaAddress(address);
|
|
15
|
+
return (0, viem_1.isAddress)(address) || (0, runtime_1.isSolanaAddress)(address);
|
|
18
16
|
}
|
|
19
17
|
/**
|
|
20
18
|
* Check if an address is Hyperliquid's special USDC address.
|
|
@@ -30,7 +28,7 @@ function isHyperliquidUSDC(chainId, address) {
|
|
|
30
28
|
return chainId === token_1.HYPERLIQUID_CHAIN_ID && address.toLowerCase() === "0x00000000000000000000000000000000";
|
|
31
29
|
}
|
|
32
30
|
function normalizeAddress(address) {
|
|
33
|
-
if (isSolanaAddress(address)) {
|
|
31
|
+
if ((0, runtime_1.isSolanaAddress)(address)) {
|
|
34
32
|
return address;
|
|
35
33
|
}
|
|
36
34
|
return address.toLowerCase(); // EVM address will normalize to lower case
|
|
@@ -48,5 +46,10 @@ function eqci(a, b) {
|
|
|
48
46
|
* When true, this is a pure transfer (no swap/bridge needed).
|
|
49
47
|
*/
|
|
50
48
|
function isSameChainAndToken(sourceChainId, sourceTokenAddress, destinationChainId, destinationTokenAddress) {
|
|
51
|
-
|
|
49
|
+
if (sourceChainId !== destinationChainId)
|
|
50
|
+
return false;
|
|
51
|
+
if ((0, runtime_1.chainTypeForIdentifier)(String(sourceChainId)) === "solana" || sourceChainId === constants_1.RELAY_SOLANA_MAINNET_CHAIN_ID) {
|
|
52
|
+
return sourceTokenAddress === destinationTokenAddress;
|
|
53
|
+
}
|
|
54
|
+
return sourceTokenAddress.toLowerCase() === destinationTokenAddress.toLowerCase();
|
|
52
55
|
}
|
|
@@ -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 [import("viem").Chain, ...import("viem").Chain[]], {
|
|
17
|
+
[k: string]: import("viem").HttpTransport<undefined, false>;
|
|
18
18
|
}, CreateConnectorFn[]>;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { Chain as ThirdwebChain } from "thirdweb";
|
|
2
|
-
export declare const supportedChains:
|
|
2
|
+
export declare const supportedChains: import("viem").Chain[];
|
|
3
3
|
export declare const supportedChainsTW: ThirdwebChain[];
|
|
4
|
-
export declare const supportedChainNetworks:
|
|
4
|
+
export declare const supportedChainNetworks: import("@b3/chain-registry/runtime").ChainDefinition[];
|
|
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: import("viem").Chain;
|
|
19
|
+
export declare const baseMainnet: import("viem").Chain;
|
|
20
20
|
export declare function getThirdwebChain(chainId: number): ThirdwebChain;
|
|
21
21
|
export declare function getChainLogo(chainId: number): string;
|
|
@@ -7,15 +7,15 @@ exports.baseMainnet = exports.b3Mainnet = exports.b3MainnetThirdWeb = exports.co
|
|
|
7
7
|
exports.getCoingeckoChainInfo = getCoingeckoChainInfo;
|
|
8
8
|
exports.getThirdwebChain = getThirdwebChain;
|
|
9
9
|
exports.getChainLogo = getChainLogo;
|
|
10
|
-
const
|
|
10
|
+
const runtime_1 = require("@b3/chain-registry/runtime");
|
|
11
11
|
const chain_transformers_1 = require("../../../shared/utils/chain-transformers");
|
|
12
12
|
const invariant_1 = __importDefault(require("invariant"));
|
|
13
13
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
14
14
|
// @ts-ignore
|
|
15
15
|
const coingecko_chains_json_1 = __importDefault(require("../../generated/coingecko-chains.json"));
|
|
16
|
-
exports.supportedChains =
|
|
17
|
-
exports.supportedChainsTW =
|
|
18
|
-
exports.supportedChainNetworks =
|
|
16
|
+
exports.supportedChains = runtime_1.ANYSPEND_EVM_CHAINS.map(chain_transformers_1.toViemChain);
|
|
17
|
+
exports.supportedChainsTW = runtime_1.ANYSPEND_EVM_CHAINS.map(chain_transformers_1.toThirdwebChain);
|
|
18
|
+
exports.supportedChainNetworks = runtime_1.ANYSPEND_EVM_CHAINS;
|
|
19
19
|
exports.coingeckoChains = coingecko_chains_json_1.default;
|
|
20
20
|
function getCoingeckoChainInfo(chainId) {
|
|
21
21
|
return exports.coingeckoChains[chainId];
|
|
@@ -12,10 +12,10 @@
|
|
|
12
12
|
*/
|
|
13
13
|
/** Address B3 uses for a chain's native coin on EVM. Matches NATIVE_TOKEN_ADDRESSES. */
|
|
14
14
|
export declare const EVM_NATIVE_TOKEN_ADDRESS = "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee";
|
|
15
|
-
export declare const SOLANA_NATIVE_TOKEN_ADDRESS
|
|
16
|
-
export declare const SOLANA_ZERION_SLUG
|
|
15
|
+
export declare const SOLANA_NATIVE_TOKEN_ADDRESS: "So11111111111111111111111111111111111111112";
|
|
16
|
+
export declare const SOLANA_ZERION_SLUG: "solana";
|
|
17
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
|
|
18
|
+
export declare const SOLANA_CHAIN_ID: 7565164;
|
|
19
19
|
export declare function zerionSlugToChainId(slug: string): number | undefined;
|
|
20
20
|
export declare function chainIdToZerionSlug(chainId: number): string | undefined;
|
|
21
21
|
export interface ZerionPositionQuantity {
|
|
@@ -1,4 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SOLANA_CHAIN_ID = exports.SOLANA_ZERION_SLUG = exports.SOLANA_NATIVE_TOKEN_ADDRESS = exports.EVM_NATIVE_TOKEN_ADDRESS = void 0;
|
|
4
|
+
exports.zerionSlugToChainId = zerionSlugToChainId;
|
|
5
|
+
exports.chainIdToZerionSlug = chainIdToZerionSlug;
|
|
6
|
+
exports.nativeTokenAddressForChain = nativeTokenAddressForChain;
|
|
7
|
+
exports.balanceMatchesToken = balanceMatchesToken;
|
|
8
|
+
exports.adaptZerionPositions = adaptZerionPositions;
|
|
9
|
+
const runtime_1 = require("@b3/chain-registry/runtime");
|
|
2
10
|
/**
|
|
3
11
|
* Canonical browser-side translation of Zerion wallet positions into B3 balance rows.
|
|
4
12
|
*
|
|
@@ -11,21 +19,15 @@
|
|
|
11
19
|
* Only the HTTP layer differs between callers. The rules below — which row counts as the chain's
|
|
12
20
|
* native coin, and which rows have no usable identity — must not be re-derived anywhere else.
|
|
13
21
|
*/
|
|
14
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
exports.SOLANA_CHAIN_ID = exports.SOLANA_ZERION_SLUG = exports.SOLANA_NATIVE_TOKEN_ADDRESS = exports.EVM_NATIVE_TOKEN_ADDRESS = void 0;
|
|
16
|
-
exports.zerionSlugToChainId = zerionSlugToChainId;
|
|
17
|
-
exports.chainIdToZerionSlug = chainIdToZerionSlug;
|
|
18
|
-
exports.nativeTokenAddressForChain = nativeTokenAddressForChain;
|
|
19
|
-
exports.balanceMatchesToken = balanceMatchesToken;
|
|
20
|
-
exports.adaptZerionPositions = adaptZerionPositions;
|
|
21
22
|
/** Address B3 uses for a chain's native coin on EVM. Matches NATIVE_TOKEN_ADDRESSES. */
|
|
22
23
|
exports.EVM_NATIVE_TOKEN_ADDRESS = "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee";
|
|
23
|
-
exports.SOLANA_NATIVE_TOKEN_ADDRESS =
|
|
24
|
-
|
|
24
|
+
exports.SOLANA_NATIVE_TOKEN_ADDRESS = runtime_1.SOLANA_NATIVE_ASSET.wrapped
|
|
25
|
+
.address;
|
|
26
|
+
exports.SOLANA_ZERION_SLUG = runtime_1.SOLANA_NATIVE_ASSET.chain;
|
|
25
27
|
/** What Zerion's `quantity.int` is: a base-10 integer, unbounded in length. */
|
|
26
28
|
const DECIMAL_INTEGER_PATTERN = /^\d+$/;
|
|
27
29
|
/** Solana's chain id as the chain registry defines it — the id every balance row is keyed by. */
|
|
28
|
-
exports.SOLANA_CHAIN_ID =
|
|
30
|
+
exports.SOLANA_CHAIN_ID = runtime_1.SOLANA_NATIVE_ASSET.chainId;
|
|
29
31
|
/**
|
|
30
32
|
* Zerion chain slug → numeric chain id. Slugs are Zerion's own vocabulary and do not always match
|
|
31
33
|
* the chain's common name — Gnosis is `xdai`, Metis is `metis-andromeda` — so an entry invented
|
|
@@ -16,6 +16,6 @@ export interface CreateWalletConfigOptions {
|
|
|
16
16
|
* Creates a generic wagmi config with sensible defaults.
|
|
17
17
|
* No ecosystem wallet, no B3-specific concerns.
|
|
18
18
|
*/
|
|
19
|
-
export declare function createWalletConfig(options?: CreateWalletConfigOptions): import("wagmi").Config<readonly [
|
|
20
|
-
[k: string]:
|
|
19
|
+
export declare function createWalletConfig(options?: CreateWalletConfigOptions): import("wagmi").Config<readonly [Chain, ...Chain[]], {
|
|
20
|
+
[k: string]: import("viem").HttpTransport<undefined, false>;
|
|
21
21
|
}, CreateConnectorFn[]>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
-
import { eqci, getChainName, getDefaultToken, getExplorerTxUrl, getHyperliquidUSDCToken, HYPERLIQUID_CHAIN_ID, HYPERLIQUID_USDC_ADDRESS, USDC_BASE, ZERO_ADDRESS, } from "../../../anyspend/index.js";
|
|
3
|
+
import { eqci, getChainName, getDefaultToken, getExplorerTxUrl, getHyperliquidUSDCToken, isSameChainAndToken, HYPERLIQUID_CHAIN_ID, HYPERLIQUID_USDC_ADDRESS, USDC_BASE, ZERO_ADDRESS, } from "../../../anyspend/index.js";
|
|
4
4
|
import { useAnyspendCreateOnrampOrder, useAnyspendCreateOrder, useAnyspendOrderAndTransactions, useAnyspendQuote, useGasPrice, useGeoOnrampOptions, } from "../../../anyspend/react/index.js";
|
|
5
5
|
import { Button, ShinyButton, StyleRoot, TabsPrimitive, toast, TransitionPanel, useAccountWallet, useAuth, useAuthStore, useB3Config, useModalStore, useProfile, useRouter, useSearchParamsSSR, useTokenBalanceDirect, useTokenData, useTokenFromUrl, } from "../../../global-account/react/index.js";
|
|
6
6
|
import BottomNavigation from "../../../global-account/react/components/ManageAccount/BottomNavigation.js";
|
|
@@ -642,8 +642,7 @@ function AnySpendInner({ sourceChainId, destinationTokenAddress, destinationToke
|
|
|
642
642
|
// Check if it's a same-chain same-token swap
|
|
643
643
|
const isSameChainSameToken = useMemo(() => {
|
|
644
644
|
return (activeTab === "crypto" &&
|
|
645
|
-
selectedSrcChainId
|
|
646
|
-
selectedSrcToken.address.toLowerCase() === selectedDstToken.address.toLowerCase());
|
|
645
|
+
isSameChainAndToken(selectedSrcChainId, selectedSrcToken.address, selectedDstChainId, selectedDstToken.address));
|
|
647
646
|
}, [activeTab, selectedSrcChainId, selectedDstChainId, selectedSrcToken.address, selectedDstToken.address]);
|
|
648
647
|
// Check if this is a direct transfer (same chain/token with allowDirectTransfer enabled)
|
|
649
648
|
const isDirectTransfer = isSameChainSameToken && allowDirectTransfer;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
2
|
import { getChainName, getExplorerTxUrl } from "../../../anyspend/index.js";
|
|
3
3
|
import { useGasPrice } from "../../../anyspend/react/index.js";
|
|
4
|
-
import { normalizeAddress } from "../../../anyspend/utils/index.js";
|
|
4
|
+
import { isSameChainAndToken, normalizeAddress } from "../../../anyspend/utils/index.js";
|
|
5
5
|
import { Button, ShinyButton, StyleRoot, toast, TransitionPanel, useAccountWallet, useModalStore, } from "../../../global-account/react/index.js";
|
|
6
6
|
import { cn } from "../../../shared/utils/cn.js";
|
|
7
7
|
import { formatUnits } from "../../../shared/utils/number.js";
|
|
@@ -61,15 +61,10 @@ function AnySpendCustomExactInInner({ loadOrder, mode = "modal", recipientAddres
|
|
|
61
61
|
// Check if source and destination are the same token on the same chain
|
|
62
62
|
const isSameChainSameToken = useMemo(() => {
|
|
63
63
|
return (effectivePaymentType === "crypto" &&
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
selectedSrcChainId,
|
|
69
|
-
selectedDstChainId,
|
|
70
|
-
selectedSrcToken?.address,
|
|
71
|
-
selectedDstToken?.address,
|
|
72
|
-
]);
|
|
64
|
+
selectedSrcToken != null &&
|
|
65
|
+
selectedDstToken != null &&
|
|
66
|
+
isSameChainAndToken(selectedSrcChainId, selectedSrcToken.address, selectedDstChainId, selectedDstToken.address));
|
|
67
|
+
}, [effectivePaymentType, selectedSrcChainId, selectedDstChainId, selectedSrcToken, selectedDstToken]);
|
|
73
68
|
// Check if this is a direct transfer
|
|
74
69
|
const isDirectTransfer = isSameChainSameToken && allowDirectTransfer;
|
|
75
70
|
// State for direct transfer success
|
|
@@ -5,7 +5,7 @@ import { useAnyspendCreateOrder } from "../../../../anyspend/react/hooks/useAnys
|
|
|
5
5
|
import { useAnyspendOrderAndTransactions } from "../../../../anyspend/react/hooks/useAnyspendOrderAndTransactions.js";
|
|
6
6
|
import { useCreateDepositFirstOrder } from "../../../../anyspend/react/hooks/useCreateDepositFirstOrder.js";
|
|
7
7
|
import { useOnOrderSuccess } from "../../../../anyspend/react/hooks/useOnOrderSuccess.js";
|
|
8
|
-
import { ALL_CHAINS, RELAY_SOLANA_MAINNET_CHAIN_ID, getAvailableChainIds } from "../../../../anyspend/index.js";
|
|
8
|
+
import { ALL_CHAINS, RELAY_SOLANA_MAINNET_CHAIN_ID, getAvailableChainIds, isSameChainAndToken, } from "../../../../anyspend/index.js";
|
|
9
9
|
import { getPaymentUrl, toRegistryChainId } from "../../../../anyspend/utils/chain.js";
|
|
10
10
|
import { isNativeToken } from "../../../../anyspend/utils/token.js";
|
|
11
11
|
import { useAccountWallet, useIsMobile, usePortfolioTokenBalance, useTokenData, useUnifiedChainSwitchAndExecute, } from "../../../../global-account/react/index.js";
|
|
@@ -51,9 +51,8 @@ export function CryptoPayPanel({ recipientAddress, destinationTokenAddress, dest
|
|
|
51
51
|
});
|
|
52
52
|
}
|
|
53
53
|
}, [selectedSrcToken, dstTokenData, destinationTokenAddress, destinationTokenChainId]);
|
|
54
|
-
const isSameToken = selectedSrcToken &&
|
|
55
|
-
selectedSrcToken.address
|
|
56
|
-
selectedSrcToken.chainId === destinationTokenChainId;
|
|
54
|
+
const isSameToken = selectedSrcToken !== null &&
|
|
55
|
+
isSameChainAndToken(selectedSrcToken.chainId, selectedSrcToken.address, destinationTokenChainId, destinationTokenAddress);
|
|
57
56
|
const { anyspendQuote, isLoadingAnyspendQuote } = useAnyspendQuote({
|
|
58
57
|
type: "swap",
|
|
59
58
|
srcChain: selectedSrcChainId,
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
|
|
1
|
+
import { isSolanaAddress } from "@b3/chain-registry/runtime";
|
|
2
|
+
export { isSolanaAddress };
|
|
2
3
|
export declare function isEvmOrSolanaAddress(address: string): boolean;
|
|
3
4
|
/**
|
|
4
5
|
* Check if an address is Hyperliquid's special USDC address.
|
|
@@ -1,10 +1,8 @@
|
|
|
1
|
+
import { chainTypeForIdentifier, isSolanaAddress } from "@b3/chain-registry/runtime";
|
|
1
2
|
import { isAddress } from "viem";
|
|
3
|
+
import { RELAY_SOLANA_MAINNET_CHAIN_ID } from "../constants/index.js";
|
|
2
4
|
import { HYPERLIQUID_CHAIN_ID } from "./token.js";
|
|
3
|
-
export
|
|
4
|
-
// Solana addresses are 32-byte base58 strings (usually 32-44 characters)
|
|
5
|
-
const solanaAddressRegex = /^[1-9A-HJ-NP-Za-km-z]{32,44}$/;
|
|
6
|
-
return solanaAddressRegex.test(address);
|
|
7
|
-
}
|
|
5
|
+
export { isSolanaAddress };
|
|
8
6
|
export function isEvmOrSolanaAddress(address) {
|
|
9
7
|
return isAddress(address) || isSolanaAddress(address);
|
|
10
8
|
}
|
|
@@ -40,5 +38,10 @@ export function eqci(a, b) {
|
|
|
40
38
|
* When true, this is a pure transfer (no swap/bridge needed).
|
|
41
39
|
*/
|
|
42
40
|
export function isSameChainAndToken(sourceChainId, sourceTokenAddress, destinationChainId, destinationTokenAddress) {
|
|
43
|
-
|
|
41
|
+
if (sourceChainId !== destinationChainId)
|
|
42
|
+
return false;
|
|
43
|
+
if (chainTypeForIdentifier(String(sourceChainId)) === "solana" || sourceChainId === RELAY_SOLANA_MAINNET_CHAIN_ID) {
|
|
44
|
+
return sourceTokenAddress === destinationTokenAddress;
|
|
45
|
+
}
|
|
46
|
+
return sourceTokenAddress.toLowerCase() === destinationTokenAddress.toLowerCase();
|
|
44
47
|
}
|
|
@@ -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 [import("viem").Chain, ...import("viem").Chain[]], {
|
|
17
|
+
[k: string]: import("viem").HttpTransport<undefined, false>;
|
|
18
18
|
}, CreateConnectorFn[]>;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { Chain as ThirdwebChain } from "thirdweb";
|
|
2
|
-
export declare const supportedChains:
|
|
2
|
+
export declare const supportedChains: import("viem").Chain[];
|
|
3
3
|
export declare const supportedChainsTW: ThirdwebChain[];
|
|
4
|
-
export declare const supportedChainNetworks:
|
|
4
|
+
export declare const supportedChainNetworks: import("@b3/chain-registry/runtime").ChainDefinition[];
|
|
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: import("viem").Chain;
|
|
19
|
+
export declare const baseMainnet: import("viem").Chain;
|
|
20
20
|
export declare function getThirdwebChain(chainId: number): ThirdwebChain;
|
|
21
21
|
export declare function getChainLogo(chainId: number): string;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ANYSPEND_EVM_CHAINS } from "@b3/chain-registry";
|
|
1
|
+
import { ANYSPEND_EVM_CHAINS } from "@b3/chain-registry/runtime";
|
|
2
2
|
import { toThirdwebChain, toViemChain } from "../../../shared/utils/chain-transformers.js";
|
|
3
3
|
import invariant from "invariant";
|
|
4
4
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
@@ -12,10 +12,10 @@
|
|
|
12
12
|
*/
|
|
13
13
|
/** Address B3 uses for a chain's native coin on EVM. Matches NATIVE_TOKEN_ADDRESSES. */
|
|
14
14
|
export declare const EVM_NATIVE_TOKEN_ADDRESS = "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee";
|
|
15
|
-
export declare const SOLANA_NATIVE_TOKEN_ADDRESS
|
|
16
|
-
export declare const SOLANA_ZERION_SLUG
|
|
15
|
+
export declare const SOLANA_NATIVE_TOKEN_ADDRESS: "So11111111111111111111111111111111111111112";
|
|
16
|
+
export declare const SOLANA_ZERION_SLUG: "solana";
|
|
17
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
|
|
18
|
+
export declare const SOLANA_CHAIN_ID: 7565164;
|
|
19
19
|
export declare function zerionSlugToChainId(slug: string): number | undefined;
|
|
20
20
|
export declare function chainIdToZerionSlug(chainId: number): string | undefined;
|
|
21
21
|
export interface ZerionPositionQuantity {
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { SOLANA_NATIVE_ASSET } from "@b3/chain-registry/runtime";
|
|
1
2
|
/**
|
|
2
3
|
* Canonical browser-side translation of Zerion wallet positions into B3 balance rows.
|
|
3
4
|
*
|
|
@@ -12,12 +13,13 @@
|
|
|
12
13
|
*/
|
|
13
14
|
/** Address B3 uses for a chain's native coin on EVM. Matches NATIVE_TOKEN_ADDRESSES. */
|
|
14
15
|
export const EVM_NATIVE_TOKEN_ADDRESS = "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee";
|
|
15
|
-
export const SOLANA_NATIVE_TOKEN_ADDRESS =
|
|
16
|
-
|
|
16
|
+
export const SOLANA_NATIVE_TOKEN_ADDRESS = SOLANA_NATIVE_ASSET.wrapped
|
|
17
|
+
.address;
|
|
18
|
+
export const SOLANA_ZERION_SLUG = SOLANA_NATIVE_ASSET.chain;
|
|
17
19
|
/** What Zerion's `quantity.int` is: a base-10 integer, unbounded in length. */
|
|
18
20
|
const DECIMAL_INTEGER_PATTERN = /^\d+$/;
|
|
19
21
|
/** Solana's chain id as the chain registry defines it — the id every balance row is keyed by. */
|
|
20
|
-
export const SOLANA_CHAIN_ID =
|
|
22
|
+
export const SOLANA_CHAIN_ID = SOLANA_NATIVE_ASSET.chainId;
|
|
21
23
|
/**
|
|
22
24
|
* Zerion chain slug → numeric chain id. Slugs are Zerion's own vocabulary and do not always match
|
|
23
25
|
* the chain's common name — Gnosis is `xdai`, Metis is `metis-andromeda` — so an entry invented
|
|
@@ -16,6 +16,6 @@ export interface CreateWalletConfigOptions {
|
|
|
16
16
|
* Creates a generic wagmi config with sensible defaults.
|
|
17
17
|
* No ecosystem wallet, no B3-specific concerns.
|
|
18
18
|
*/
|
|
19
|
-
export declare function createWalletConfig(options?: CreateWalletConfigOptions): import("wagmi").Config<readonly [
|
|
20
|
-
[k: string]:
|
|
19
|
+
export declare function createWalletConfig(options?: CreateWalletConfigOptions): import("wagmi").Config<readonly [Chain, ...Chain[]], {
|
|
20
|
+
[k: string]: import("viem").HttpTransport<undefined, false>;
|
|
21
21
|
}, CreateConnectorFn[]>;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
|
|
1
|
+
import { isSolanaAddress } from "@b3/chain-registry/runtime";
|
|
2
|
+
export { isSolanaAddress };
|
|
2
3
|
export declare function isEvmOrSolanaAddress(address: string): boolean;
|
|
3
4
|
/**
|
|
4
5
|
* Check if an address is Hyperliquid's special USDC address.
|
|
@@ -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 [import("viem").Chain, ...import("viem").Chain[]], {
|
|
17
|
+
[k: string]: import("viem").HttpTransport<undefined, false>;
|
|
18
18
|
}, CreateConnectorFn[]>;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { Chain as ThirdwebChain } from "thirdweb";
|
|
2
|
-
export declare const supportedChains:
|
|
2
|
+
export declare const supportedChains: import("viem").Chain[];
|
|
3
3
|
export declare const supportedChainsTW: ThirdwebChain[];
|
|
4
|
-
export declare const supportedChainNetworks:
|
|
4
|
+
export declare const supportedChainNetworks: import("@b3/chain-registry/runtime").ChainDefinition[];
|
|
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: import("viem").Chain;
|
|
19
|
+
export declare const baseMainnet: import("viem").Chain;
|
|
20
20
|
export declare function getThirdwebChain(chainId: number): ThirdwebChain;
|
|
21
21
|
export declare function getChainLogo(chainId: number): string;
|
|
@@ -12,10 +12,10 @@
|
|
|
12
12
|
*/
|
|
13
13
|
/** Address B3 uses for a chain's native coin on EVM. Matches NATIVE_TOKEN_ADDRESSES. */
|
|
14
14
|
export declare const EVM_NATIVE_TOKEN_ADDRESS = "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee";
|
|
15
|
-
export declare const SOLANA_NATIVE_TOKEN_ADDRESS
|
|
16
|
-
export declare const SOLANA_ZERION_SLUG
|
|
15
|
+
export declare const SOLANA_NATIVE_TOKEN_ADDRESS: "So11111111111111111111111111111111111111112";
|
|
16
|
+
export declare const SOLANA_ZERION_SLUG: "solana";
|
|
17
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
|
|
18
|
+
export declare const SOLANA_CHAIN_ID: 7565164;
|
|
19
19
|
export declare function zerionSlugToChainId(slug: string): number | undefined;
|
|
20
20
|
export declare function chainIdToZerionSlug(chainId: number): string | undefined;
|
|
21
21
|
export interface ZerionPositionQuantity {
|
|
@@ -16,6 +16,6 @@ export interface CreateWalletConfigOptions {
|
|
|
16
16
|
* Creates a generic wagmi config with sensible defaults.
|
|
17
17
|
* No ecosystem wallet, no B3-specific concerns.
|
|
18
18
|
*/
|
|
19
|
-
export declare function createWalletConfig(options?: CreateWalletConfigOptions): import("wagmi").Config<readonly [
|
|
20
|
-
[k: string]:
|
|
19
|
+
export declare function createWalletConfig(options?: CreateWalletConfigOptions): import("wagmi").Config<readonly [Chain, ...Chain[]], {
|
|
20
|
+
[k: string]: import("viem").HttpTransport<undefined, false>;
|
|
21
21
|
}, CreateConnectorFn[]>;
|