@b3dotfun/sdk 0.0.84-alpha.0 → 0.0.84-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/anyspend/react/components/AnySpend.js +4 -2
- package/dist/cjs/anyspend/react/components/common/CryptoReceiveSection.js +2 -1
- package/dist/cjs/anyspend/utils/token.d.ts +6 -0
- package/dist/cjs/anyspend/utils/token.js +9 -3
- package/dist/cjs/global-account/react/hooks/useFirstEOA.d.ts +2 -2
- package/dist/esm/anyspend/react/components/AnySpend.js +5 -3
- package/dist/esm/anyspend/react/components/common/CryptoReceiveSection.js +2 -1
- package/dist/esm/anyspend/utils/token.d.ts +6 -0
- package/dist/esm/anyspend/utils/token.js +8 -2
- package/dist/esm/global-account/react/hooks/useFirstEOA.d.ts +2 -2
- package/dist/types/anyspend/utils/token.d.ts +6 -0
- package/dist/types/global-account/react/hooks/useFirstEOA.d.ts +2 -2
- package/package.json +1 -1
- package/src/anyspend/react/components/AnySpend.tsx +7 -2
- package/src/anyspend/react/components/common/CryptoReceiveSection.tsx +16 -5
- package/src/anyspend/utils/token.ts +9 -2
|
@@ -113,9 +113,11 @@ function AnySpendInner({ destinationTokenAddress, destinationTokenChainId, mode
|
|
|
113
113
|
const [srcAmountOnRamp, setSrcAmountOnRamp] = (0, react_4.useState)(searchParams.get("fromAmount") || "5");
|
|
114
114
|
// State for destination chain/token selection
|
|
115
115
|
const [selectedDstChainId, setSelectedDstChainId] = (0, react_4.useState)(initialDstChainId);
|
|
116
|
+
// Helper to check if address is Hyperliquid USDC (supports both 34-char and 42-char formats)
|
|
117
|
+
const isHyperliquidUSDCAddress = (address) => (0, anyspend_1.eqci)(address, anyspend_1.HYPERLIQUID_USDC_ADDRESS) || (0, anyspend_1.eqci)(address, anyspend_1.ZERO_ADDRESS);
|
|
116
118
|
const defaultDstToken = isBuyMode
|
|
117
119
|
? // Special case: Hyperliquid uses zero address for USDC
|
|
118
|
-
destinationTokenChainId === anyspend_1.HYPERLIQUID_CHAIN_ID && (
|
|
120
|
+
destinationTokenChainId === anyspend_1.HYPERLIQUID_CHAIN_ID && isHyperliquidUSDCAddress(destinationTokenAddress)
|
|
119
121
|
? (0, anyspend_1.getHyperliquidUSDCToken)()
|
|
120
122
|
: {
|
|
121
123
|
symbol: "",
|
|
@@ -163,7 +165,7 @@ function AnySpendInner({ destinationTokenAddress, destinationTokenChainId, mode
|
|
|
163
165
|
(0, react_4.useEffect)(() => {
|
|
164
166
|
if (selectedDstToken && dstTokenMetadata && !appliedDstMetadataRef.current) {
|
|
165
167
|
// Skip metadata enhancement for Hyperliquid USDC - we already have correct metadata from getHyperliquidUSDCToken()
|
|
166
|
-
if (selectedDstToken.chainId === anyspend_1.HYPERLIQUID_CHAIN_ID && (
|
|
168
|
+
if (selectedDstToken.chainId === anyspend_1.HYPERLIQUID_CHAIN_ID && isHyperliquidUSDCAddress(selectedDstToken.address)) {
|
|
167
169
|
appliedDstMetadataRef.current = true;
|
|
168
170
|
return;
|
|
169
171
|
}
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.CryptoReceiveSection = CryptoReceiveSection;
|
|
4
4
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const anyspend_1 = require("../../../../anyspend");
|
|
5
6
|
const utils_1 = require("../../../../shared/utils");
|
|
6
7
|
const cn_1 = require("../../../../shared/utils/cn");
|
|
7
8
|
const formatAddress_1 = require("../../../../shared/utils/formatAddress");
|
|
@@ -13,7 +14,7 @@ const PointsBadge_1 = require("./PointsBadge");
|
|
|
13
14
|
function CryptoReceiveSection({ isDepositMode = false, isBuyMode = false, effectiveRecipientAddress, recipientName, onSelectRecipient, dstAmount, dstToken, selectedDstChainId, setSelectedDstChainId, setSelectedDstToken, isSrcInputDirty, onChangeDstAmount, anyspendQuote, dstTokenSymbol, dstTokenLogoURI, onShowPointsDetail, onShowFeeDetail, }) {
|
|
14
15
|
return ((0, jsx_runtime_1.jsxs)(react_1.motion.div, { initial: { opacity: 0, y: 20, filter: "blur(10px)" }, animate: { opacity: 1, y: 0, filter: "blur(0px)" }, transition: { duration: 0.3, delay: 0.1, ease: "easeInOut" }, className: "receive-section bg-as-surface-secondary border-as-border-secondary relative flex w-full flex-col gap-2 rounded-2xl border p-4 sm:p-6", children: [(0, jsx_runtime_1.jsxs)("div", { className: "flex w-full items-center justify-between", children: [(0, jsx_runtime_1.jsxs)("div", { className: "text-as-primary/50 flex h-7 items-center gap-1.5 text-sm", children: [isDepositMode ? "Deposit" : "Receive", isSrcInputDirty && anyspendQuote?.data?.fee && onShowFeeDetail && ((0, jsx_runtime_1.jsx)("button", { onClick: onShowFeeDetail, className: "text-as-primary/40 hover:text-as-primary/60 transition-colors", children: (0, jsx_runtime_1.jsx)(lucide_react_1.Info, { className: "h-4 w-4" }) }))] }), effectiveRecipientAddress ? ((0, jsx_runtime_1.jsx)("button", { className: (0, cn_1.cn)("text-as-tertiarry flex h-7 items-center gap-2 rounded-lg"), onClick: onSelectRecipient, children: (0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("span", { className: "text-as-tertiarry flex items-center gap-1 text-sm", children: recipientName ? (0, utils_1.formatUsername)(recipientName) : (0, formatAddress_1.shortenAddress)(effectiveRecipientAddress || "") }), (0, jsx_runtime_1.jsx)(lucide_react_1.ChevronRight, { className: "h-4 w-4" })] }) })) : ((0, jsx_runtime_1.jsx)("button", { className: "text-as-primary/70 flex items-center gap-1 rounded-lg", onClick: onSelectRecipient, children: (0, jsx_runtime_1.jsx)("div", { className: "text-sm font-medium", children: "Select recipient" }) }))] }), isBuyMode || isDepositMode ? (
|
|
15
16
|
// Fixed destination token display for buy mode and deposit mode
|
|
16
|
-
(0, jsx_runtime_1.jsxs)("div", { className: "flex items-center justify-between", children: [(0, jsx_runtime_1.jsx)("div", { className: "text-as-primary text-2xl font-bold", children: dstAmount || "0" }), (0, jsx_runtime_1.jsxs)("div", { className: "bg-as-brand/10 border-as-brand/30 flex items-center gap-3 rounded-xl border px-4 py-3", children: [(dstTokenLogoURI || dstToken.metadata?.logoURI) && ((0, jsx_runtime_1.jsx)("img", { src: dstTokenLogoURI || dstToken.metadata?.logoURI, alt: dstTokenSymbol || dstToken.symbol, className: "h-8 w-8 rounded-full" })), (0, jsx_runtime_1.jsx)("span", { className: "text-as-brand text-lg font-bold", children: dstTokenSymbol || dstToken.symbol })] })] })) : (
|
|
17
|
+
(0, jsx_runtime_1.jsxs)("div", { className: "flex items-center justify-between", children: [(0, jsx_runtime_1.jsx)("div", { className: "text-as-primary text-2xl font-bold", children: dstAmount || "0" }), (0, jsx_runtime_1.jsxs)("div", { className: "bg-as-brand/10 border-as-brand/30 flex items-center gap-3 rounded-xl border px-4 py-3", children: [(dstTokenLogoURI || dstToken.metadata?.logoURI) && ((0, jsx_runtime_1.jsxs)("div", { className: "relative", children: [(0, jsx_runtime_1.jsx)("img", { src: dstTokenLogoURI || dstToken.metadata?.logoURI, alt: dstTokenSymbol || dstToken.symbol, className: "h-8 w-8 rounded-full" }), anyspend_1.ALL_CHAINS[dstToken.chainId]?.logoUrl && ((0, jsx_runtime_1.jsx)("img", { src: anyspend_1.ALL_CHAINS[dstToken.chainId].logoUrl, alt: "Chain", className: "absolute -bottom-1 -right-1 h-4 w-4 rounded-full border border-white" }))] })), (0, jsx_runtime_1.jsx)("span", { className: "text-as-brand text-lg font-bold", children: dstTokenSymbol || dstToken.symbol })] })] })) : (
|
|
17
18
|
// Token selection for regular swap mode
|
|
18
19
|
(0, jsx_runtime_1.jsx)(OrderTokenAmount_1.OrderTokenAmount, { address: effectiveRecipientAddress, context: "to", inputValue: dstAmount, onChangeInput: onChangeDstAmount || (() => { }), chainId: selectedDstChainId || dstToken.chainId, setChainId: setSelectedDstChainId || (() => { }), token: dstToken, setToken: setSelectedDstToken || (() => { }) })), (0, jsx_runtime_1.jsxs)("div", { className: "text-as-primary/50 flex h-5 items-center justify-start gap-2 text-sm", children: [(0, jsx_runtime_1.jsxs)("div", { className: "flex items-center gap-2", children: [(0, number_1.formatDisplayNumber)(anyspendQuote?.data?.currencyOut?.amountUsd, {
|
|
19
20
|
style: "currency",
|
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
import { components } from "../../anyspend/types/api";
|
|
2
2
|
export declare const HYPERLIQUID_CHAIN_ID = 1337;
|
|
3
3
|
export declare const HYPEREVM_CHAIN_ID = 999;
|
|
4
|
+
/**
|
|
5
|
+
* Hyperliquid uses a special 34-character USDC address format (0x + 32 hex digits)
|
|
6
|
+
* instead of the standard 42-character EVM address format.
|
|
7
|
+
* This is required by Relay SDK for Hyperliquid integration.
|
|
8
|
+
*/
|
|
9
|
+
export declare const HYPERLIQUID_USDC_ADDRESS = "0x00000000000000000000000000000000";
|
|
4
10
|
export declare function isNativeToken(address: string): boolean;
|
|
5
11
|
export declare function getSolanaToken(): components["schemas"]["Token"];
|
|
6
12
|
export declare function getEthToken(chainId: number): components["schemas"]["Token"];
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.HYPEREVM_CHAIN_ID = exports.HYPERLIQUID_CHAIN_ID = void 0;
|
|
3
|
+
exports.HYPERLIQUID_USDC_ADDRESS = exports.HYPEREVM_CHAIN_ID = exports.HYPERLIQUID_CHAIN_ID = void 0;
|
|
4
4
|
exports.isNativeToken = isNativeToken;
|
|
5
5
|
exports.getSolanaToken = getSolanaToken;
|
|
6
6
|
exports.getEthToken = getEthToken;
|
|
@@ -13,6 +13,12 @@ const constants_1 = require("../../anyspend/constants");
|
|
|
13
13
|
const chains_1 = require("viem/chains");
|
|
14
14
|
exports.HYPERLIQUID_CHAIN_ID = 1337;
|
|
15
15
|
exports.HYPEREVM_CHAIN_ID = 999;
|
|
16
|
+
/**
|
|
17
|
+
* Hyperliquid uses a special 34-character USDC address format (0x + 32 hex digits)
|
|
18
|
+
* instead of the standard 42-character EVM address format.
|
|
19
|
+
* This is required by Relay SDK for Hyperliquid integration.
|
|
20
|
+
*/
|
|
21
|
+
exports.HYPERLIQUID_USDC_ADDRESS = "0x00000000000000000000000000000000";
|
|
16
22
|
function isNativeToken(address) {
|
|
17
23
|
return address.toLowerCase() === constants_1.ZERO_ADDRESS || address.toLowerCase() === constants_1.RELAY_SOL_ADDRESS;
|
|
18
24
|
}
|
|
@@ -91,10 +97,10 @@ function getHyperEVMNativeToken() {
|
|
|
91
97
|
function getHyperliquidUSDCToken() {
|
|
92
98
|
return {
|
|
93
99
|
chainId: exports.HYPERLIQUID_CHAIN_ID,
|
|
94
|
-
address:
|
|
100
|
+
address: exports.HYPERLIQUID_USDC_ADDRESS,
|
|
95
101
|
symbol: "USDC",
|
|
96
102
|
name: "USD Coin",
|
|
97
|
-
decimals: 6
|
|
103
|
+
decimals: 8, // Hyperliquid USDC uses 8 decimals, not 6
|
|
98
104
|
metadata: {
|
|
99
105
|
logoURI: "https://ethereum-optimism.github.io/data/USDC/logo.png",
|
|
100
106
|
},
|
|
@@ -7454,12 +7454,12 @@ export declare function useFirstEOA(chain?: {
|
|
|
7454
7454
|
[x: `bytes18[${string}]`]: undefined;
|
|
7455
7455
|
[x: `bytes6[${string}]`]: undefined;
|
|
7456
7456
|
[x: `bytes9[${string}]`]: undefined;
|
|
7457
|
+
[x: `bytes8[${string}]`]: undefined;
|
|
7457
7458
|
[x: `bytes2[${string}]`]: undefined;
|
|
7458
7459
|
[x: `bytes3[${string}]`]: undefined;
|
|
7459
7460
|
[x: `bytes4[${string}]`]: undefined;
|
|
7460
7461
|
[x: `bytes5[${string}]`]: undefined;
|
|
7461
7462
|
[x: `bytes7[${string}]`]: undefined;
|
|
7462
|
-
[x: `bytes8[${string}]`]: undefined;
|
|
7463
7463
|
[x: `bytes10[${string}]`]: undefined;
|
|
7464
7464
|
[x: `bytes11[${string}]`]: undefined;
|
|
7465
7465
|
[x: `bytes12[${string}]`]: undefined;
|
|
@@ -7556,12 +7556,12 @@ export declare function useFirstEOA(chain?: {
|
|
|
7556
7556
|
bytes18?: undefined;
|
|
7557
7557
|
bytes6?: undefined;
|
|
7558
7558
|
bytes9?: undefined;
|
|
7559
|
+
bytes8?: undefined;
|
|
7559
7560
|
bytes2?: undefined;
|
|
7560
7561
|
bytes3?: undefined;
|
|
7561
7562
|
bytes4?: undefined;
|
|
7562
7563
|
bytes5?: undefined;
|
|
7563
7564
|
bytes7?: undefined;
|
|
7564
|
-
bytes8?: undefined;
|
|
7565
7565
|
bytes10?: undefined;
|
|
7566
7566
|
bytes11?: undefined;
|
|
7567
7567
|
bytes12?: undefined;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
-
import { eqci, getDefaultToken, getHyperliquidUSDCToken, HYPERLIQUID_CHAIN_ID, USDC_BASE, ZERO_ADDRESS, } from "../../../anyspend/index.js";
|
|
3
|
+
import { eqci, getDefaultToken, getHyperliquidUSDCToken, HYPERLIQUID_CHAIN_ID, HYPERLIQUID_USDC_ADDRESS, USDC_BASE, ZERO_ADDRESS, } from "../../../anyspend/index.js";
|
|
4
4
|
import { useAnyspendCreateOnrampOrder, useAnyspendCreateOrder, useAnyspendOrderAndTransactions, useAnyspendQuote, useGeoOnrampOptions, } from "../../../anyspend/react/index.js";
|
|
5
5
|
import { Button, ShinyButton, StyleRoot, TabsPrimitive, toast, TransitionPanel, useAccountWallet, useB3, 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";
|
|
@@ -106,9 +106,11 @@ function AnySpendInner({ destinationTokenAddress, destinationTokenChainId, mode
|
|
|
106
106
|
const [srcAmountOnRamp, setSrcAmountOnRamp] = useState(searchParams.get("fromAmount") || "5");
|
|
107
107
|
// State for destination chain/token selection
|
|
108
108
|
const [selectedDstChainId, setSelectedDstChainId] = useState(initialDstChainId);
|
|
109
|
+
// Helper to check if address is Hyperliquid USDC (supports both 34-char and 42-char formats)
|
|
110
|
+
const isHyperliquidUSDCAddress = (address) => eqci(address, HYPERLIQUID_USDC_ADDRESS) || eqci(address, ZERO_ADDRESS);
|
|
109
111
|
const defaultDstToken = isBuyMode
|
|
110
112
|
? // Special case: Hyperliquid uses zero address for USDC
|
|
111
|
-
destinationTokenChainId === HYPERLIQUID_CHAIN_ID &&
|
|
113
|
+
destinationTokenChainId === HYPERLIQUID_CHAIN_ID && isHyperliquidUSDCAddress(destinationTokenAddress)
|
|
112
114
|
? getHyperliquidUSDCToken()
|
|
113
115
|
: {
|
|
114
116
|
symbol: "",
|
|
@@ -156,7 +158,7 @@ function AnySpendInner({ destinationTokenAddress, destinationTokenChainId, mode
|
|
|
156
158
|
useEffect(() => {
|
|
157
159
|
if (selectedDstToken && dstTokenMetadata && !appliedDstMetadataRef.current) {
|
|
158
160
|
// Skip metadata enhancement for Hyperliquid USDC - we already have correct metadata from getHyperliquidUSDCToken()
|
|
159
|
-
if (selectedDstToken.chainId === HYPERLIQUID_CHAIN_ID &&
|
|
161
|
+
if (selectedDstToken.chainId === HYPERLIQUID_CHAIN_ID && isHyperliquidUSDCAddress(selectedDstToken.address)) {
|
|
160
162
|
appliedDstMetadataRef.current = true;
|
|
161
163
|
return;
|
|
162
164
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { ALL_CHAINS } from "../../../../anyspend/index.js";
|
|
2
3
|
import { formatUsername } from "../../../../shared/utils/index.js";
|
|
3
4
|
import { cn } from "../../../../shared/utils/cn.js";
|
|
4
5
|
import { shortenAddress } from "../../../../shared/utils/formatAddress.js";
|
|
@@ -10,7 +11,7 @@ import { PointsBadge } from "./PointsBadge.js";
|
|
|
10
11
|
export function CryptoReceiveSection({ isDepositMode = false, isBuyMode = false, effectiveRecipientAddress, recipientName, onSelectRecipient, dstAmount, dstToken, selectedDstChainId, setSelectedDstChainId, setSelectedDstToken, isSrcInputDirty, onChangeDstAmount, anyspendQuote, dstTokenSymbol, dstTokenLogoURI, onShowPointsDetail, onShowFeeDetail, }) {
|
|
11
12
|
return (_jsxs(motion.div, { initial: { opacity: 0, y: 20, filter: "blur(10px)" }, animate: { opacity: 1, y: 0, filter: "blur(0px)" }, transition: { duration: 0.3, delay: 0.1, ease: "easeInOut" }, className: "receive-section bg-as-surface-secondary border-as-border-secondary relative flex w-full flex-col gap-2 rounded-2xl border p-4 sm:p-6", children: [_jsxs("div", { className: "flex w-full items-center justify-between", children: [_jsxs("div", { className: "text-as-primary/50 flex h-7 items-center gap-1.5 text-sm", children: [isDepositMode ? "Deposit" : "Receive", isSrcInputDirty && anyspendQuote?.data?.fee && onShowFeeDetail && (_jsx("button", { onClick: onShowFeeDetail, className: "text-as-primary/40 hover:text-as-primary/60 transition-colors", children: _jsx(Info, { className: "h-4 w-4" }) }))] }), effectiveRecipientAddress ? (_jsx("button", { className: cn("text-as-tertiarry flex h-7 items-center gap-2 rounded-lg"), onClick: onSelectRecipient, children: _jsxs(_Fragment, { children: [_jsx("span", { className: "text-as-tertiarry flex items-center gap-1 text-sm", children: recipientName ? formatUsername(recipientName) : shortenAddress(effectiveRecipientAddress || "") }), _jsx(ChevronRight, { className: "h-4 w-4" })] }) })) : (_jsx("button", { className: "text-as-primary/70 flex items-center gap-1 rounded-lg", onClick: onSelectRecipient, children: _jsx("div", { className: "text-sm font-medium", children: "Select recipient" }) }))] }), isBuyMode || isDepositMode ? (
|
|
12
13
|
// Fixed destination token display for buy mode and deposit mode
|
|
13
|
-
_jsxs("div", { className: "flex items-center justify-between", children: [_jsx("div", { className: "text-as-primary text-2xl font-bold", children: dstAmount || "0" }), _jsxs("div", { className: "bg-as-brand/10 border-as-brand/30 flex items-center gap-3 rounded-xl border px-4 py-3", children: [(dstTokenLogoURI || dstToken.metadata?.logoURI) && (_jsx("img", { src: dstTokenLogoURI || dstToken.metadata?.logoURI, alt: dstTokenSymbol || dstToken.symbol, className: "h-8 w-8 rounded-full" })), _jsx("span", { className: "text-as-brand text-lg font-bold", children: dstTokenSymbol || dstToken.symbol })] })] })) : (
|
|
14
|
+
_jsxs("div", { className: "flex items-center justify-between", children: [_jsx("div", { className: "text-as-primary text-2xl font-bold", children: dstAmount || "0" }), _jsxs("div", { className: "bg-as-brand/10 border-as-brand/30 flex items-center gap-3 rounded-xl border px-4 py-3", children: [(dstTokenLogoURI || dstToken.metadata?.logoURI) && (_jsxs("div", { className: "relative", children: [_jsx("img", { src: dstTokenLogoURI || dstToken.metadata?.logoURI, alt: dstTokenSymbol || dstToken.symbol, className: "h-8 w-8 rounded-full" }), ALL_CHAINS[dstToken.chainId]?.logoUrl && (_jsx("img", { src: ALL_CHAINS[dstToken.chainId].logoUrl, alt: "Chain", className: "absolute -bottom-1 -right-1 h-4 w-4 rounded-full border border-white" }))] })), _jsx("span", { className: "text-as-brand text-lg font-bold", children: dstTokenSymbol || dstToken.symbol })] })] })) : (
|
|
14
15
|
// Token selection for regular swap mode
|
|
15
16
|
_jsx(OrderTokenAmount, { address: effectiveRecipientAddress, context: "to", inputValue: dstAmount, onChangeInput: onChangeDstAmount || (() => { }), chainId: selectedDstChainId || dstToken.chainId, setChainId: setSelectedDstChainId || (() => { }), token: dstToken, setToken: setSelectedDstToken || (() => { }) })), _jsxs("div", { className: "text-as-primary/50 flex h-5 items-center justify-start gap-2 text-sm", children: [_jsxs("div", { className: "flex items-center gap-2", children: [formatDisplayNumber(anyspendQuote?.data?.currencyOut?.amountUsd, {
|
|
16
17
|
style: "currency",
|
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
import { components } from "../../anyspend/types/api";
|
|
2
2
|
export declare const HYPERLIQUID_CHAIN_ID = 1337;
|
|
3
3
|
export declare const HYPEREVM_CHAIN_ID = 999;
|
|
4
|
+
/**
|
|
5
|
+
* Hyperliquid uses a special 34-character USDC address format (0x + 32 hex digits)
|
|
6
|
+
* instead of the standard 42-character EVM address format.
|
|
7
|
+
* This is required by Relay SDK for Hyperliquid integration.
|
|
8
|
+
*/
|
|
9
|
+
export declare const HYPERLIQUID_USDC_ADDRESS = "0x00000000000000000000000000000000";
|
|
4
10
|
export declare function isNativeToken(address: string): boolean;
|
|
5
11
|
export declare function getSolanaToken(): components["schemas"]["Token"];
|
|
6
12
|
export declare function getEthToken(chainId: number): components["schemas"]["Token"];
|
|
@@ -2,6 +2,12 @@ import { RELAY_SOL_ADDRESS, RELAY_SOLANA_MAINNET_CHAIN_ID, ZERO_ADDRESS } from "
|
|
|
2
2
|
import { avalanche, bsc, polygon } from "viem/chains";
|
|
3
3
|
export const HYPERLIQUID_CHAIN_ID = 1337;
|
|
4
4
|
export const HYPEREVM_CHAIN_ID = 999;
|
|
5
|
+
/**
|
|
6
|
+
* Hyperliquid uses a special 34-character USDC address format (0x + 32 hex digits)
|
|
7
|
+
* instead of the standard 42-character EVM address format.
|
|
8
|
+
* This is required by Relay SDK for Hyperliquid integration.
|
|
9
|
+
*/
|
|
10
|
+
export const HYPERLIQUID_USDC_ADDRESS = "0x00000000000000000000000000000000";
|
|
5
11
|
export function isNativeToken(address) {
|
|
6
12
|
return address.toLowerCase() === ZERO_ADDRESS || address.toLowerCase() === RELAY_SOL_ADDRESS;
|
|
7
13
|
}
|
|
@@ -80,10 +86,10 @@ export function getHyperEVMNativeToken() {
|
|
|
80
86
|
export function getHyperliquidUSDCToken() {
|
|
81
87
|
return {
|
|
82
88
|
chainId: HYPERLIQUID_CHAIN_ID,
|
|
83
|
-
address:
|
|
89
|
+
address: HYPERLIQUID_USDC_ADDRESS,
|
|
84
90
|
symbol: "USDC",
|
|
85
91
|
name: "USD Coin",
|
|
86
|
-
decimals: 6
|
|
92
|
+
decimals: 8, // Hyperliquid USDC uses 8 decimals, not 6
|
|
87
93
|
metadata: {
|
|
88
94
|
logoURI: "https://ethereum-optimism.github.io/data/USDC/logo.png",
|
|
89
95
|
},
|
|
@@ -7454,12 +7454,12 @@ export declare function useFirstEOA(chain?: {
|
|
|
7454
7454
|
[x: `bytes18[${string}]`]: undefined;
|
|
7455
7455
|
[x: `bytes6[${string}]`]: undefined;
|
|
7456
7456
|
[x: `bytes9[${string}]`]: undefined;
|
|
7457
|
+
[x: `bytes8[${string}]`]: undefined;
|
|
7457
7458
|
[x: `bytes2[${string}]`]: undefined;
|
|
7458
7459
|
[x: `bytes3[${string}]`]: undefined;
|
|
7459
7460
|
[x: `bytes4[${string}]`]: undefined;
|
|
7460
7461
|
[x: `bytes5[${string}]`]: undefined;
|
|
7461
7462
|
[x: `bytes7[${string}]`]: undefined;
|
|
7462
|
-
[x: `bytes8[${string}]`]: undefined;
|
|
7463
7463
|
[x: `bytes10[${string}]`]: undefined;
|
|
7464
7464
|
[x: `bytes11[${string}]`]: undefined;
|
|
7465
7465
|
[x: `bytes12[${string}]`]: undefined;
|
|
@@ -7556,12 +7556,12 @@ export declare function useFirstEOA(chain?: {
|
|
|
7556
7556
|
bytes18?: undefined;
|
|
7557
7557
|
bytes6?: undefined;
|
|
7558
7558
|
bytes9?: undefined;
|
|
7559
|
+
bytes8?: undefined;
|
|
7559
7560
|
bytes2?: undefined;
|
|
7560
7561
|
bytes3?: undefined;
|
|
7561
7562
|
bytes4?: undefined;
|
|
7562
7563
|
bytes5?: undefined;
|
|
7563
7564
|
bytes7?: undefined;
|
|
7564
|
-
bytes8?: undefined;
|
|
7565
7565
|
bytes10?: undefined;
|
|
7566
7566
|
bytes11?: undefined;
|
|
7567
7567
|
bytes12?: undefined;
|
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
import { components } from "@b3dotfun/sdk/anyspend/types/api";
|
|
2
2
|
export declare const HYPERLIQUID_CHAIN_ID = 1337;
|
|
3
3
|
export declare const HYPEREVM_CHAIN_ID = 999;
|
|
4
|
+
/**
|
|
5
|
+
* Hyperliquid uses a special 34-character USDC address format (0x + 32 hex digits)
|
|
6
|
+
* instead of the standard 42-character EVM address format.
|
|
7
|
+
* This is required by Relay SDK for Hyperliquid integration.
|
|
8
|
+
*/
|
|
9
|
+
export declare const HYPERLIQUID_USDC_ADDRESS = "0x00000000000000000000000000000000";
|
|
4
10
|
export declare function isNativeToken(address: string): boolean;
|
|
5
11
|
export declare function getSolanaToken(): components["schemas"]["Token"];
|
|
6
12
|
export declare function getEthToken(chainId: number): components["schemas"]["Token"];
|
|
@@ -7454,12 +7454,12 @@ export declare function useFirstEOA(chain?: {
|
|
|
7454
7454
|
[x: `bytes18[${string}]`]: undefined;
|
|
7455
7455
|
[x: `bytes6[${string}]`]: undefined;
|
|
7456
7456
|
[x: `bytes9[${string}]`]: undefined;
|
|
7457
|
+
[x: `bytes8[${string}]`]: undefined;
|
|
7457
7458
|
[x: `bytes2[${string}]`]: undefined;
|
|
7458
7459
|
[x: `bytes3[${string}]`]: undefined;
|
|
7459
7460
|
[x: `bytes4[${string}]`]: undefined;
|
|
7460
7461
|
[x: `bytes5[${string}]`]: undefined;
|
|
7461
7462
|
[x: `bytes7[${string}]`]: undefined;
|
|
7462
|
-
[x: `bytes8[${string}]`]: undefined;
|
|
7463
7463
|
[x: `bytes10[${string}]`]: undefined;
|
|
7464
7464
|
[x: `bytes11[${string}]`]: undefined;
|
|
7465
7465
|
[x: `bytes12[${string}]`]: undefined;
|
|
@@ -7556,12 +7556,12 @@ export declare function useFirstEOA(chain?: {
|
|
|
7556
7556
|
bytes18?: undefined;
|
|
7557
7557
|
bytes6?: undefined;
|
|
7558
7558
|
bytes9?: undefined;
|
|
7559
|
+
bytes8?: undefined;
|
|
7559
7560
|
bytes2?: undefined;
|
|
7560
7561
|
bytes3?: undefined;
|
|
7561
7562
|
bytes4?: undefined;
|
|
7562
7563
|
bytes5?: undefined;
|
|
7563
7564
|
bytes7?: undefined;
|
|
7564
|
-
bytes8?: undefined;
|
|
7565
7565
|
bytes10?: undefined;
|
|
7566
7566
|
bytes11?: undefined;
|
|
7567
7567
|
bytes12?: undefined;
|
package/package.json
CHANGED
|
@@ -5,6 +5,7 @@ import {
|
|
|
5
5
|
getDefaultToken,
|
|
6
6
|
getHyperliquidUSDCToken,
|
|
7
7
|
HYPERLIQUID_CHAIN_ID,
|
|
8
|
+
HYPERLIQUID_USDC_ADDRESS,
|
|
8
9
|
USDC_BASE,
|
|
9
10
|
ZERO_ADDRESS,
|
|
10
11
|
} from "@b3dotfun/sdk/anyspend";
|
|
@@ -230,9 +231,13 @@ function AnySpendInner({
|
|
|
230
231
|
|
|
231
232
|
// State for destination chain/token selection
|
|
232
233
|
const [selectedDstChainId, setSelectedDstChainId] = useState<number>(initialDstChainId);
|
|
234
|
+
// Helper to check if address is Hyperliquid USDC (supports both 34-char and 42-char formats)
|
|
235
|
+
const isHyperliquidUSDCAddress = (address?: string) =>
|
|
236
|
+
eqci(address, HYPERLIQUID_USDC_ADDRESS) || eqci(address, ZERO_ADDRESS);
|
|
237
|
+
|
|
233
238
|
const defaultDstToken = isBuyMode
|
|
234
239
|
? // Special case: Hyperliquid uses zero address for USDC
|
|
235
|
-
destinationTokenChainId === HYPERLIQUID_CHAIN_ID &&
|
|
240
|
+
destinationTokenChainId === HYPERLIQUID_CHAIN_ID && isHyperliquidUSDCAddress(destinationTokenAddress)
|
|
236
241
|
? getHyperliquidUSDCToken()
|
|
237
242
|
: {
|
|
238
243
|
symbol: "",
|
|
@@ -288,7 +293,7 @@ function AnySpendInner({
|
|
|
288
293
|
useEffect(() => {
|
|
289
294
|
if (selectedDstToken && dstTokenMetadata && !appliedDstMetadataRef.current) {
|
|
290
295
|
// Skip metadata enhancement for Hyperliquid USDC - we already have correct metadata from getHyperliquidUSDCToken()
|
|
291
|
-
if (selectedDstToken.chainId === HYPERLIQUID_CHAIN_ID &&
|
|
296
|
+
if (selectedDstToken.chainId === HYPERLIQUID_CHAIN_ID && isHyperliquidUSDCAddress(selectedDstToken.address)) {
|
|
292
297
|
appliedDstMetadataRef.current = true;
|
|
293
298
|
return;
|
|
294
299
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { ALL_CHAINS } from "@b3dotfun/sdk/anyspend";
|
|
1
2
|
import { formatUsername } from "@b3dotfun/sdk/shared/utils";
|
|
2
3
|
import { cn } from "@b3dotfun/sdk/shared/utils/cn";
|
|
3
4
|
import { shortenAddress } from "@b3dotfun/sdk/shared/utils/formatAddress";
|
|
@@ -94,11 +95,21 @@ export function CryptoReceiveSection({
|
|
|
94
95
|
<div className="text-as-primary text-2xl font-bold">{dstAmount || "0"}</div>
|
|
95
96
|
<div className="bg-as-brand/10 border-as-brand/30 flex items-center gap-3 rounded-xl border px-4 py-3">
|
|
96
97
|
{(dstTokenLogoURI || dstToken.metadata?.logoURI) && (
|
|
97
|
-
<
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
98
|
+
<div className="relative">
|
|
99
|
+
<img
|
|
100
|
+
src={dstTokenLogoURI || dstToken.metadata?.logoURI}
|
|
101
|
+
alt={dstTokenSymbol || dstToken.symbol}
|
|
102
|
+
className="h-8 w-8 rounded-full"
|
|
103
|
+
/>
|
|
104
|
+
{/* Chain logo overlay */}
|
|
105
|
+
{ALL_CHAINS[dstToken.chainId]?.logoUrl && (
|
|
106
|
+
<img
|
|
107
|
+
src={ALL_CHAINS[dstToken.chainId].logoUrl}
|
|
108
|
+
alt="Chain"
|
|
109
|
+
className="absolute -bottom-1 -right-1 h-4 w-4 rounded-full border border-white"
|
|
110
|
+
/>
|
|
111
|
+
)}
|
|
112
|
+
</div>
|
|
102
113
|
)}
|
|
103
114
|
<span className="text-as-brand text-lg font-bold">{dstTokenSymbol || dstToken.symbol}</span>
|
|
104
115
|
</div>
|
|
@@ -5,6 +5,13 @@ import { avalanche, bsc, polygon } from "viem/chains";
|
|
|
5
5
|
export const HYPERLIQUID_CHAIN_ID = 1337;
|
|
6
6
|
export const HYPEREVM_CHAIN_ID = 999;
|
|
7
7
|
|
|
8
|
+
/**
|
|
9
|
+
* Hyperliquid uses a special 34-character USDC address format (0x + 32 hex digits)
|
|
10
|
+
* instead of the standard 42-character EVM address format.
|
|
11
|
+
* This is required by Relay SDK for Hyperliquid integration.
|
|
12
|
+
*/
|
|
13
|
+
export const HYPERLIQUID_USDC_ADDRESS = "0x00000000000000000000000000000000";
|
|
14
|
+
|
|
8
15
|
export function isNativeToken(address: string): boolean {
|
|
9
16
|
return address.toLowerCase() === ZERO_ADDRESS || address.toLowerCase() === RELAY_SOL_ADDRESS;
|
|
10
17
|
}
|
|
@@ -90,10 +97,10 @@ export function getHyperEVMNativeToken(): components["schemas"]["Token"] {
|
|
|
90
97
|
export function getHyperliquidUSDCToken(): components["schemas"]["Token"] {
|
|
91
98
|
return {
|
|
92
99
|
chainId: HYPERLIQUID_CHAIN_ID,
|
|
93
|
-
address:
|
|
100
|
+
address: HYPERLIQUID_USDC_ADDRESS,
|
|
94
101
|
symbol: "USDC",
|
|
95
102
|
name: "USD Coin",
|
|
96
|
-
decimals: 6
|
|
103
|
+
decimals: 8, // Hyperliquid USDC uses 8 decimals, not 6
|
|
97
104
|
metadata: {
|
|
98
105
|
logoURI: "https://ethereum-optimism.github.io/data/USDC/logo.png",
|
|
99
106
|
},
|