@b3dotfun/sdk 0.0.83 → 0.0.84-alpha.0
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/constants/index.d.ts +1 -1
- package/dist/cjs/anyspend/constants/index.js +2 -2
- package/dist/cjs/anyspend/react/components/AnySpend.js +21 -9
- package/dist/cjs/anyspend/react/components/AnySpendCustom.js +4 -3
- package/dist/cjs/anyspend/react/components/common/CryptoPaySection.js +2 -4
- package/dist/cjs/anyspend/react/components/common/CryptoPaymentMethodDisplay.d.ts +15 -0
- package/dist/cjs/anyspend/react/components/common/CryptoPaymentMethodDisplay.js +28 -0
- package/dist/cjs/anyspend/react/components/common/InsufficientDepositPayment.js +1 -1
- package/dist/cjs/anyspend/react/components/common/OrderDetails.js +5 -4
- package/dist/cjs/anyspend/react/components/common/OrderToken.js +2 -2
- package/dist/cjs/anyspend/react/components/common/OrderTokenAmount.js +1 -1
- package/dist/cjs/anyspend/react/components/common/OrderTokenAmountFiat.js +1 -1
- package/dist/cjs/anyspend/react/components/common/OrderTokenAmountNew.js +2 -2
- package/dist/cjs/anyspend/react/components/common/PaymentStripeWeb2.js +4 -6
- package/dist/cjs/anyspend/react/components/common/PaymentVendorUI.js +41 -2
- package/dist/cjs/anyspend/react/components/common/TransferCryptoDetails.js +1 -1
- package/dist/cjs/anyspend/react/components/webview/WebviewOnrampPayment.js +2 -3
- package/dist/cjs/anyspend/react/hooks/index.d.ts +1 -0
- package/dist/cjs/anyspend/react/hooks/index.js +1 -0
- package/dist/cjs/anyspend/react/hooks/useConnectedUserProfile.d.ts +2 -1
- package/dist/cjs/anyspend/react/hooks/useConnectedUserProfile.js +5 -8
- package/dist/cjs/anyspend/react/hooks/useConnectedWalletDisplay.d.ts +0 -2
- package/dist/cjs/anyspend/react/hooks/useConnectedWalletDisplay.js +2 -12
- package/dist/cjs/anyspend/react/hooks/useHyperliquidTransfer.d.ts +37 -0
- package/dist/cjs/anyspend/react/hooks/useHyperliquidTransfer.js +133 -0
- package/dist/cjs/anyspend/react/providers/AnyspendProvider.js +1 -13
- package/dist/cjs/anyspend/types/chain.d.ts +10 -2
- package/dist/cjs/anyspend/types/chain.js +1 -0
- package/dist/cjs/anyspend/utils/address.d.ts +11 -0
- package/dist/cjs/anyspend/utils/address.js +15 -0
- package/dist/cjs/anyspend/utils/chain.d.ts +20 -1
- package/dist/cjs/anyspend/utils/chain.js +73 -4
- package/dist/cjs/anyspend/utils/token.d.ts +1 -0
- package/dist/cjs/anyspend/utils/token.js +19 -6
- package/dist/cjs/global-account/react/components/B3Provider/B3Provider.js +1 -1
- package/dist/cjs/global-account/react/components/SignInWithB3/SignIn.js +3 -4
- package/dist/cjs/global-account/react/components/SignInWithB3/steps/LoginStep.js +1 -1
- package/dist/cjs/global-account/react/hooks/index.d.ts +0 -1
- package/dist/cjs/global-account/react/hooks/index.js +1 -3
- package/dist/cjs/global-account/react/hooks/useAccountWallet.js +11 -10
- package/dist/cjs/shared/utils/payment.utils.d.ts +1 -0
- package/dist/cjs/shared/utils/payment.utils.js +9 -0
- package/dist/esm/anyspend/constants/index.d.ts +1 -1
- package/dist/esm/anyspend/constants/index.js +1 -1
- package/dist/esm/anyspend/react/components/AnySpend.js +22 -10
- package/dist/esm/anyspend/react/components/AnySpendCustom.js +5 -4
- package/dist/esm/anyspend/react/components/common/CryptoPaySection.js +4 -6
- package/dist/esm/anyspend/react/components/common/CryptoPaymentMethodDisplay.d.ts +15 -0
- package/dist/esm/anyspend/react/components/common/CryptoPaymentMethodDisplay.js +25 -0
- package/dist/esm/anyspend/react/components/common/InsufficientDepositPayment.js +2 -2
- package/dist/esm/anyspend/react/components/common/OrderDetails.js +6 -5
- package/dist/esm/anyspend/react/components/common/OrderToken.js +3 -3
- package/dist/esm/anyspend/react/components/common/OrderTokenAmount.js +2 -2
- package/dist/esm/anyspend/react/components/common/OrderTokenAmountFiat.js +2 -2
- package/dist/esm/anyspend/react/components/common/OrderTokenAmountNew.js +3 -3
- package/dist/esm/anyspend/react/components/common/PaymentStripeWeb2.js +2 -4
- package/dist/esm/anyspend/react/components/common/PaymentVendorUI.js +9 -3
- package/dist/esm/anyspend/react/components/common/TransferCryptoDetails.js +2 -2
- package/dist/esm/anyspend/react/components/webview/WebviewOnrampPayment.js +3 -4
- package/dist/esm/anyspend/react/hooks/index.d.ts +1 -0
- package/dist/esm/anyspend/react/hooks/index.js +1 -0
- package/dist/esm/anyspend/react/hooks/useConnectedUserProfile.d.ts +2 -1
- package/dist/esm/anyspend/react/hooks/useConnectedUserProfile.js +6 -9
- package/dist/esm/anyspend/react/hooks/useConnectedWalletDisplay.d.ts +0 -2
- package/dist/esm/anyspend/react/hooks/useConnectedWalletDisplay.js +2 -12
- package/dist/esm/anyspend/react/hooks/useHyperliquidTransfer.d.ts +37 -0
- package/dist/esm/anyspend/react/hooks/useHyperliquidTransfer.js +127 -0
- package/dist/esm/anyspend/react/providers/AnyspendProvider.js +1 -13
- package/dist/esm/anyspend/types/chain.d.ts +10 -2
- package/dist/esm/anyspend/types/chain.js +1 -0
- package/dist/esm/anyspend/utils/address.d.ts +11 -0
- package/dist/esm/anyspend/utils/address.js +14 -0
- package/dist/esm/anyspend/utils/chain.d.ts +20 -1
- package/dist/esm/anyspend/utils/chain.js +70 -4
- package/dist/esm/anyspend/utils/token.d.ts +1 -0
- package/dist/esm/anyspend/utils/token.js +19 -7
- package/dist/esm/global-account/react/components/B3Provider/B3Provider.js +2 -2
- package/dist/esm/global-account/react/components/SignInWithB3/SignIn.js +4 -5
- package/dist/esm/global-account/react/components/SignInWithB3/steps/LoginStep.js +1 -1
- package/dist/esm/global-account/react/hooks/index.d.ts +0 -1
- package/dist/esm/global-account/react/hooks/index.js +0 -1
- package/dist/esm/global-account/react/hooks/useAccountWallet.js +11 -10
- package/dist/esm/shared/utils/payment.utils.d.ts +1 -0
- package/dist/esm/shared/utils/payment.utils.js +9 -1
- package/dist/types/anyspend/constants/index.d.ts +1 -1
- package/dist/types/anyspend/react/components/common/CryptoPaymentMethodDisplay.d.ts +15 -0
- package/dist/types/anyspend/react/hooks/index.d.ts +1 -0
- package/dist/types/anyspend/react/hooks/useConnectedUserProfile.d.ts +2 -1
- package/dist/types/anyspend/react/hooks/useConnectedWalletDisplay.d.ts +0 -2
- package/dist/types/anyspend/react/hooks/useHyperliquidTransfer.d.ts +37 -0
- package/dist/types/anyspend/types/chain.d.ts +10 -2
- package/dist/types/anyspend/utils/address.d.ts +11 -0
- package/dist/types/anyspend/utils/chain.d.ts +20 -1
- package/dist/types/anyspend/utils/token.d.ts +1 -0
- package/dist/types/global-account/react/hooks/index.d.ts +0 -1
- package/dist/types/shared/utils/payment.utils.d.ts +1 -0
- package/package.json +1 -1
- package/src/anyspend/constants/index.ts +1 -1
- package/src/anyspend/react/components/AnySpend.tsx +31 -9
- package/src/anyspend/react/components/AnySpendCustom.tsx +9 -25
- package/src/anyspend/react/components/common/CryptoPaySection.tsx +7 -30
- package/src/anyspend/react/components/common/CryptoPaymentMethodDisplay.tsx +64 -0
- package/src/anyspend/react/components/common/InsufficientDepositPayment.tsx +2 -2
- package/src/anyspend/react/components/common/OrderDetails.tsx +6 -5
- package/src/anyspend/react/components/common/OrderToken.tsx +5 -5
- package/src/anyspend/react/components/common/OrderTokenAmount.tsx +3 -3
- package/src/anyspend/react/components/common/OrderTokenAmountFiat.tsx +3 -3
- package/src/anyspend/react/components/common/OrderTokenAmountNew.tsx +6 -6
- package/src/anyspend/react/components/common/PaymentStripeWeb2.tsx +3 -5
- package/src/anyspend/react/components/common/PaymentVendorUI.tsx +26 -2
- package/src/anyspend/react/components/common/TransferCryptoDetails.tsx +2 -2
- package/src/anyspend/react/components/webview/WebviewOnrampPayment.tsx +3 -5
- package/src/anyspend/react/hooks/index.ts +1 -0
- package/src/anyspend/react/hooks/useConnectedUserProfile.ts +7 -10
- package/src/anyspend/react/hooks/useConnectedWalletDisplay.ts +2 -15
- package/src/anyspend/react/hooks/useHyperliquidTransfer.ts +152 -0
- package/src/anyspend/react/providers/AnyspendProvider.tsx +7 -22
- package/src/anyspend/types/chain.ts +10 -1
- package/src/anyspend/utils/address.ts +15 -0
- package/src/anyspend/utils/chain.ts +84 -4
- package/src/anyspend/utils/token.ts +20 -7
- package/src/global-account/react/components/B3Provider/B3Provider.tsx +6 -2
- package/src/global-account/react/components/SignInWithB3/SignIn.tsx +4 -6
- package/src/global-account/react/components/SignInWithB3/steps/LoginStep.tsx +1 -1
- package/src/global-account/react/hooks/index.ts +0 -1
- package/src/global-account/react/hooks/useAccountWallet.tsx +12 -11
- package/src/shared/utils/payment.utils.ts +10 -1
- package/dist/cjs/global-account/react/hooks/useBestTransactionPath.d.ts +0 -41
- package/dist/cjs/global-account/react/hooks/useBestTransactionPath.js +0 -148
- package/dist/esm/global-account/react/hooks/useBestTransactionPath.d.ts +0 -41
- package/dist/esm/global-account/react/hooks/useBestTransactionPath.js +0 -145
- package/dist/types/global-account/react/hooks/useBestTransactionPath.d.ts +0 -41
- package/src/global-account/react/hooks/useBestTransactionPath.tsx +0 -201
|
@@ -3,7 +3,7 @@ import invariant from "invariant";
|
|
|
3
3
|
import { createPublicClient, createWalletClient, defineChain, http, parseEther, } from "viem";
|
|
4
4
|
import { abstract, arbitrum, avalanche, b3, base, bsc, mainnet, optimism, polygon } from "viem/chains";
|
|
5
5
|
import { ChainType } from "../types/chain.js";
|
|
6
|
-
import { getAvaxToken, getBnbToken, getEthToken, getHyperEVMNativeToken, getPolToken, getSolanaToken, HYPEREVM_CHAIN_ID, } from "./token.js";
|
|
6
|
+
import { getAvaxToken, getBnbToken, getEthToken, getHyperEVMNativeToken, getHyperliquidUSDCToken, getPolToken, getSolanaToken, HYPEREVM_CHAIN_ID, HYPERLIQUID_CHAIN_ID, } from "./token.js";
|
|
7
7
|
function getCustomEvmChain(chain, rpcUrl) {
|
|
8
8
|
return defineChain({ ...chain, rpcUrls: { default: { http: [rpcUrl] } } });
|
|
9
9
|
}
|
|
@@ -232,9 +232,27 @@ export const SOLANA_MAINNET = {
|
|
|
232
232
|
nativeToken: getSolanaToken(),
|
|
233
233
|
coingeckoName: "solana",
|
|
234
234
|
};
|
|
235
|
+
export const HYPERLIQUID_MAINNET = {
|
|
236
|
+
id: HYPERLIQUID_CHAIN_ID,
|
|
237
|
+
name: "Hyperliquid",
|
|
238
|
+
type: ChainType.HYPERLIQUID,
|
|
239
|
+
logoUrl: "https://s2.coinmarketcap.com/static/img/coins/64x64/32196.png",
|
|
240
|
+
nativeRequired: BigInt(0), // No native transfer needed - using Relay's useDepositAddress flow (USDC is native)
|
|
241
|
+
canDepositNative: true, // Can deposit USDC (native token)
|
|
242
|
+
defaultToken: getHyperliquidUSDCToken(),
|
|
243
|
+
nativeToken: getHyperliquidUSDCToken(),
|
|
244
|
+
coingeckoName: null,
|
|
245
|
+
apiUrl: "https://api.hyperliquid.xyz",
|
|
246
|
+
blockExplorer: {
|
|
247
|
+
url: "https://app.hyperliquid.xyz/explorer",
|
|
248
|
+
},
|
|
249
|
+
};
|
|
235
250
|
export const EVM_CHAINS = { ...EVM_MAINNET, ...EVM_TESTNET };
|
|
236
251
|
export const SOLANA_CHAINS = { [RELAY_SOLANA_MAINNET_CHAIN_ID]: SOLANA_MAINNET };
|
|
237
|
-
export const
|
|
252
|
+
export const HYPERLIQUID_CHAINS = {
|
|
253
|
+
[HYPERLIQUID_CHAIN_ID]: HYPERLIQUID_MAINNET,
|
|
254
|
+
};
|
|
255
|
+
export const ALL_CHAINS = { ...EVM_CHAINS, ...SOLANA_CHAINS, ...HYPERLIQUID_CHAINS };
|
|
238
256
|
export function getSolanaChains(network) {
|
|
239
257
|
invariant(network === "mainnet", "Solana chain is only supported on mainnet");
|
|
240
258
|
return SOLANA_MAINNET;
|
|
@@ -272,7 +290,7 @@ export function canDepositNative(chainId) {
|
|
|
272
290
|
return ALL_CHAINS[chainId].canDepositNative;
|
|
273
291
|
}
|
|
274
292
|
export function isMainnet(chainId) {
|
|
275
|
-
return EVM_MAINNET[chainId] !== undefined || RELAY_SOLANA_MAINNET_CHAIN_ID === chainId;
|
|
293
|
+
return (EVM_MAINNET[chainId] !== undefined || RELAY_SOLANA_MAINNET_CHAIN_ID === chainId || HYPERLIQUID_CHAIN_ID === chainId);
|
|
276
294
|
}
|
|
277
295
|
export function isTestnet(chainId) {
|
|
278
296
|
return EVM_TESTNET[chainId] !== undefined;
|
|
@@ -283,7 +301,11 @@ export function getDefaultToken(chainId) {
|
|
|
283
301
|
}
|
|
284
302
|
export function getChainName(chainId) {
|
|
285
303
|
invariant(ALL_CHAINS[chainId], `Chain ${chainId} is not supported`);
|
|
286
|
-
|
|
304
|
+
const chain = ALL_CHAINS[chainId];
|
|
305
|
+
if (isEvmChain(chainId)) {
|
|
306
|
+
return chain.viem.name;
|
|
307
|
+
}
|
|
308
|
+
return chain.name;
|
|
287
309
|
}
|
|
288
310
|
export function getCoingeckoName(chainId) {
|
|
289
311
|
invariant(ALL_CHAINS[chainId], `Chain ${chainId} is not supported`);
|
|
@@ -432,6 +454,12 @@ export function getPaymentUrl(address, amount, currency, chainId, decimals) {
|
|
|
432
454
|
console.log("Solana URL (isNativeSOL:", isNativeSOL, "):", url);
|
|
433
455
|
return url;
|
|
434
456
|
}
|
|
457
|
+
case ChainType.HYPERLIQUID: {
|
|
458
|
+
// NOTE: Hyperliquid is only supported as destination chain (not source chain).
|
|
459
|
+
// Payment URLs are not needed since users cannot send FROM Hyperliquid in our flow.
|
|
460
|
+
// Return address as placeholder (this code path should not be reached).
|
|
461
|
+
return address;
|
|
462
|
+
}
|
|
435
463
|
default:
|
|
436
464
|
// Fallback to just the address if chain type is unknown
|
|
437
465
|
return address;
|
|
@@ -444,12 +472,20 @@ export function getExplorerTxUrl(chainId, txHash) {
|
|
|
444
472
|
if (EVM_CHAINS[chainId]) {
|
|
445
473
|
return EVM_CHAINS[chainId].viem.blockExplorers?.default.url + "/tx/" + txHash;
|
|
446
474
|
}
|
|
475
|
+
if (HYPERLIQUID_CHAINS[chainId]) {
|
|
476
|
+
return HYPERLIQUID_CHAINS[chainId].blockExplorer.url + "/tx/" + txHash;
|
|
477
|
+
}
|
|
478
|
+
// Default to Solscan for Solana transactions
|
|
447
479
|
return "https://solscan.io/tx/" + txHash;
|
|
448
480
|
}
|
|
449
481
|
export function getExplorerAddressUrl(chainId, address) {
|
|
450
482
|
if (EVM_CHAINS[chainId]) {
|
|
451
483
|
return EVM_CHAINS[chainId].viem.blockExplorers?.default.url + "/address/" + address;
|
|
452
484
|
}
|
|
485
|
+
if (HYPERLIQUID_CHAINS[chainId]) {
|
|
486
|
+
return HYPERLIQUID_CHAINS[chainId].blockExplorer.url + "/address/" + address;
|
|
487
|
+
}
|
|
488
|
+
// Default to Solscan for Solana addresses
|
|
453
489
|
return "https://solscan.io/account/" + address;
|
|
454
490
|
}
|
|
455
491
|
export function getMulticall3Address(chainId) {
|
|
@@ -466,3 +502,33 @@ export function getNativeToken(chainId) {
|
|
|
466
502
|
export function isEvmChain(chainId) {
|
|
467
503
|
return Boolean(EVM_CHAINS[chainId]);
|
|
468
504
|
}
|
|
505
|
+
export function isHyperliquidChain(chainId) {
|
|
506
|
+
return HYPERLIQUID_CHAINS[chainId] !== undefined;
|
|
507
|
+
}
|
|
508
|
+
export function getHyperliquidChain(chainId) {
|
|
509
|
+
invariant(HYPERLIQUID_CHAINS[chainId], `Chain ${chainId} is not a Hyperliquid chain`);
|
|
510
|
+
return HYPERLIQUID_CHAINS[chainId];
|
|
511
|
+
}
|
|
512
|
+
/**
|
|
513
|
+
* Get available chain IDs for AnySpend based on context (source or destination).
|
|
514
|
+
* Filters out chains that shouldn't be available for the given context.
|
|
515
|
+
*
|
|
516
|
+
* @param context - "from" for source chains, "to" for destination chains
|
|
517
|
+
* @returns Array of available chain IDs
|
|
518
|
+
*
|
|
519
|
+
* @example
|
|
520
|
+
* // Get source chains (excludes Hyperliquid)
|
|
521
|
+
* const sourceChains = getAvailableChainIds("from") // [1, 8453, 137, ...]
|
|
522
|
+
*
|
|
523
|
+
* // Get destination chains (includes Hyperliquid)
|
|
524
|
+
* const destChains = getAvailableChainIds("to") // [1, 8453, 137, ..., 1337]
|
|
525
|
+
*/
|
|
526
|
+
export function getAvailableChainIds(context) {
|
|
527
|
+
const allChainIds = Object.values(ALL_CHAINS).map(chain => chain.id);
|
|
528
|
+
if (context === "from") {
|
|
529
|
+
// Hyperliquid is only supported as destination chain, not source chain
|
|
530
|
+
return allChainIds.filter(chainId => chainId !== HYPERLIQUID_CHAIN_ID);
|
|
531
|
+
}
|
|
532
|
+
// For destination ("to"), all chains are available including Hyperliquid
|
|
533
|
+
return allChainIds;
|
|
534
|
+
}
|
|
@@ -8,3 +8,4 @@ export declare function getPolToken(): components["schemas"]["Token"];
|
|
|
8
8
|
export declare function getBnbToken(): components["schemas"]["Token"];
|
|
9
9
|
export declare function getAvaxToken(): components["schemas"]["Token"];
|
|
10
10
|
export declare function getHyperEVMNativeToken(): components["schemas"]["Token"];
|
|
11
|
+
export declare function getHyperliquidUSDCToken(): components["schemas"]["Token"];
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { RELAY_SOL_ADDRESS, RELAY_SOLANA_MAINNET_CHAIN_ID, ZERO_ADDRESS } from "../../anyspend/constants/index.js";
|
|
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
5
|
export function isNativeToken(address) {
|
|
6
|
-
return address.toLowerCase() ===
|
|
6
|
+
return address.toLowerCase() === ZERO_ADDRESS || address.toLowerCase() === RELAY_SOL_ADDRESS;
|
|
7
7
|
}
|
|
8
8
|
export function getSolanaToken() {
|
|
9
9
|
return {
|
|
@@ -20,7 +20,7 @@ export function getSolanaToken() {
|
|
|
20
20
|
export function getEthToken(chainId) {
|
|
21
21
|
return {
|
|
22
22
|
chainId: chainId,
|
|
23
|
-
address:
|
|
23
|
+
address: ZERO_ADDRESS,
|
|
24
24
|
symbol: "ETH",
|
|
25
25
|
name: "Ethereum",
|
|
26
26
|
decimals: 18,
|
|
@@ -32,7 +32,7 @@ export function getEthToken(chainId) {
|
|
|
32
32
|
export function getPolToken() {
|
|
33
33
|
return {
|
|
34
34
|
chainId: polygon.id,
|
|
35
|
-
address:
|
|
35
|
+
address: ZERO_ADDRESS,
|
|
36
36
|
symbol: "POL",
|
|
37
37
|
name: "Polygon",
|
|
38
38
|
decimals: 18,
|
|
@@ -44,7 +44,7 @@ export function getPolToken() {
|
|
|
44
44
|
export function getBnbToken() {
|
|
45
45
|
return {
|
|
46
46
|
chainId: bsc.id,
|
|
47
|
-
address:
|
|
47
|
+
address: ZERO_ADDRESS,
|
|
48
48
|
symbol: "BNB",
|
|
49
49
|
name: "BNB",
|
|
50
50
|
decimals: 18,
|
|
@@ -56,7 +56,7 @@ export function getBnbToken() {
|
|
|
56
56
|
export function getAvaxToken() {
|
|
57
57
|
return {
|
|
58
58
|
chainId: avalanche.id,
|
|
59
|
-
address:
|
|
59
|
+
address: ZERO_ADDRESS,
|
|
60
60
|
symbol: "AVAX",
|
|
61
61
|
name: "AVAX",
|
|
62
62
|
decimals: 18,
|
|
@@ -68,7 +68,7 @@ export function getAvaxToken() {
|
|
|
68
68
|
export function getHyperEVMNativeToken() {
|
|
69
69
|
return {
|
|
70
70
|
chainId: HYPEREVM_CHAIN_ID,
|
|
71
|
-
address:
|
|
71
|
+
address: ZERO_ADDRESS,
|
|
72
72
|
symbol: "HYPE",
|
|
73
73
|
name: "HYPE",
|
|
74
74
|
decimals: 18,
|
|
@@ -77,3 +77,15 @@ export function getHyperEVMNativeToken() {
|
|
|
77
77
|
},
|
|
78
78
|
};
|
|
79
79
|
}
|
|
80
|
+
export function getHyperliquidUSDCToken() {
|
|
81
|
+
return {
|
|
82
|
+
chainId: HYPERLIQUID_CHAIN_ID,
|
|
83
|
+
address: ZERO_ADDRESS,
|
|
84
|
+
symbol: "USDC",
|
|
85
|
+
name: "USD Coin",
|
|
86
|
+
decimals: 6,
|
|
87
|
+
metadata: {
|
|
88
|
+
logoURI: "https://ethereum-optimism.github.io/data/USDC/logo.png",
|
|
89
|
+
},
|
|
90
|
+
};
|
|
91
|
+
}
|
|
@@ -5,7 +5,7 @@ import { loadGA4Script } from "../../../../global-account/utils/analytics.js";
|
|
|
5
5
|
import { debugB3React } from "../../../../shared/utils/debug.js";
|
|
6
6
|
import "@relayprotocol/relay-kit-ui/styles.css";
|
|
7
7
|
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
|
|
8
|
-
import { useCallback, useEffect, useState } from "react";
|
|
8
|
+
import { useCallback, useEffect, useMemo, useState } from "react";
|
|
9
9
|
import { getLastAuthProvider, ThirdwebProvider, useActiveAccount, useConnectedWallets, useSetActiveWallet, } from "thirdweb/react";
|
|
10
10
|
import { WagmiProvider } from "wagmi";
|
|
11
11
|
import { setClientType } from "../../../client-manager.js";
|
|
@@ -39,7 +39,7 @@ toaster: _toaster, clientType = "rest", rpcUrls, partnerId, onConnect, connector
|
|
|
39
39
|
useEffect(() => {
|
|
40
40
|
setClientType(clientType);
|
|
41
41
|
}, [clientType]);
|
|
42
|
-
const wagmiConfig = createWagmiConfig({ partnerId, rpcUrls, connectors, overrideDefaultConnectors });
|
|
42
|
+
const wagmiConfig = useMemo(() => createWagmiConfig({ partnerId, rpcUrls, connectors, overrideDefaultConnectors }), [partnerId, rpcUrls, connectors, overrideDefaultConnectors]);
|
|
43
43
|
return (_jsx(ThirdwebProvider, { children: _jsx(WagmiProvider, { config: wagmiConfig, reconnectOnMount: false, children: _jsx(QueryClientProvider, { client: queryClient, children: _jsx(TooltipProvider, { children: _jsx(ToastProvider, { children: _jsx(LocalSDKProvider, { onConnectCallback: onConnect, children: _jsxs(InnerProvider, { accountOverride: accountOverride, environment: environment, theme: theme, automaticallySetFirstEoa: !!automaticallySetFirstEoa, clientType: clientType, partnerId: partnerId, createClientReferenceId: createClientReferenceId, enableTurnkey: enableTurnkey, children: [_jsx(ToastContextConnector, {}), _jsxs(RelayKitProviderWrapper, { simDuneApiKey: simDuneApiKey, children: [children, _jsx(StyleRoot, { id: "b3-root" })] })] }) }) }) }) }) }) }));
|
|
44
44
|
}
|
|
45
45
|
/**
|
|
@@ -5,13 +5,13 @@ import { ecosystemWalletId } from "../../../../shared/constants/index.js";
|
|
|
5
5
|
import { cn, truncateAddress } from "../../../../shared/utils/index.js";
|
|
6
6
|
import { Menu, MenuButton, MenuItems, Transition } from "@headlessui/react";
|
|
7
7
|
import { useEffect } from "react";
|
|
8
|
-
import { useConnectedWallets, useSetActiveWallet } from "thirdweb/react";
|
|
9
|
-
import { useAccountWalletImage } from "../../hooks/useAccountWallet.js";
|
|
8
|
+
import { useConnectedWallets, useSetActiveWallet, useWalletImage } from "thirdweb/react";
|
|
10
9
|
import { ManageAccountButton } from "../custom/ManageAccountButton.js";
|
|
11
10
|
export function SignIn(props) {
|
|
12
11
|
const { className } = props;
|
|
13
12
|
const { automaticallySetFirstEoa, partnerId } = useB3();
|
|
14
|
-
const { address: globalAddress, ensName, connectedSmartWallet, connectedEOAWallet, isActiveSmartWallet, isActiveEOAWallet, smartWalletIcon,
|
|
13
|
+
const { address: globalAddress, ensName, connectedSmartWallet, connectedEOAWallet, isActiveSmartWallet, isActiveEOAWallet, smartWalletIcon, } = useAccountWallet();
|
|
14
|
+
const { data: walletImage } = useWalletImage(connectedEOAWallet?.id);
|
|
15
15
|
const isMobile = useIsMobile();
|
|
16
16
|
const { logout } = useAuthentication(partnerId);
|
|
17
17
|
const onDisconnect = async () => {
|
|
@@ -34,11 +34,10 @@ export function SignIn(props) {
|
|
|
34
34
|
setActiveWallet(connectedEOAWallet);
|
|
35
35
|
}
|
|
36
36
|
}, [connectedEOAWallet, isActiveEOAWallet, setActiveWallet, automaticallySetFirstEoa]);
|
|
37
|
-
const walletImage = useAccountWalletImage();
|
|
38
37
|
// Desktop version - original dropdown menu
|
|
39
38
|
return (_jsx(StyleRoot, { children: _jsx(Menu, { className: `relative flex items-center ${className || ""}`, as: "div", children: globalAddress ? (_jsxs(_Fragment, { children: [_jsxs(MenuButton, { className: "bg-b3-react-background group flex h-10 items-center gap-1 rounded-xl px-3 focus:outline-none", children: [!!walletImage && (_jsx(IPFSMediaRenderer, { src: walletImage, alt: "Wallet Image", className: "bg-b3-react-primary h-6 w-6 rounded-full object-cover opacity-100" })), _jsx("div", { className: "text-as-primary", children: ensName ? ensName : truncateAddress(globalAddress) })] }), _jsx(Transition, { enter: "duration-200 ease-out", enterFrom: "scale-95 opacity-0", enterTo: "scale-100 opacity-100", leave: "duration-300 ease-out", leaveFrom: "scale-100 opacity-100", leaveTo: "scale-95 opacity-0", children: _jsx(MenuItems, { className: "b3-root absolute -right-4 top-full min-w-64 rounded-2xl border focus:outline-none lg:right-0", modal: false,
|
|
40
39
|
// TODO: Figure out why setting anchor on mobile causes z-index issues where it appears under elements
|
|
41
|
-
anchor: isMobile ? "top end" : undefined, children: _jsxs("div", { className: "bg-b3-react-background", children: [connectedEOAWallet ? (_jsxs("div", { className: cn("border-b3-react-subtle bg-b3-react-background flex cursor-pointer items-center justify-between rounded-xl p-3"), onClick: () => handleSetActiveAccount(connectedEOAWallet?.id), children: [_jsxs("div", { className: "flex items-center", children: [_jsx("img", { className: "bg-b3-react-primary h-16 w-16 rounded-full opacity-100", src:
|
|
40
|
+
anchor: isMobile ? "top end" : undefined, children: _jsxs("div", { className: "bg-b3-react-background", children: [connectedEOAWallet ? (_jsxs("div", { className: cn("border-b3-react-subtle bg-b3-react-background flex cursor-pointer items-center justify-between rounded-xl p-3"), onClick: () => handleSetActiveAccount(connectedEOAWallet?.id), children: [_jsxs("div", { className: "flex items-center", children: [_jsx("img", { className: "bg-b3-react-primary h-16 w-16 rounded-full opacity-100", src: walletImage, alt: connectedEOAWallet?.id }), _jsxs("div", { className: "ml-4 grow", children: [ensName && _jsx("div", { children: ensName }), _jsx("div", { children: truncateAddress(globalAddress) })] })] }), isActiveEOAWallet && _jsx(Icon, { className: "fill-b3-react-primary", name: "check" })] })) : (connectedSmartWallet && (_jsxs("div", { className: cn("mb-2 flex cursor-pointer items-center justify-between rounded-xl p-3", isActiveSmartWallet
|
|
42
41
|
? "bg-b3-react-background"
|
|
43
42
|
: "bg-b3-react-background hover:bg-b3-react-background"), onClick: () => handleSetActiveAccount(connectedSmartWallet?.id), children: [_jsxs("div", { className: "flex items-center", children: [_jsx("img", { className: "bg-b3-react-primary h-16 w-16 rounded-full opacity-100", src: smartWalletIcon, alt: connectedSmartWallet?.id }), _jsxs("div", { className: "grow pl-4", children: [ensName && _jsx("div", { children: ensName }), _jsx("div", { children: truncateAddress(globalAddress) }), _jsx("div", { children: "Smart wallet" })] })] }), isActiveSmartWallet && _jsx(Icon, { className: "fill-b3-react-primary", name: "check" })] }))), _jsx("div", { className: "ml-3", children: _jsx(ManageAccountButton, { ...props, className: "w-[calc(100%-12px)]" }) }), _jsx("button", { className: "mb-2 w-full space-y-1", onClick: onDisconnect, children: _jsxs("div", { className: "hover:bg-b3-react-background group flex h-12 items-center rounded-xl px-4 transition-colors", children: [_jsx(Icon, { className: "fill-b3-react-primary mr-4 shrink-0 transition-colors", name: "logout" }), _jsx("div", { className: "text-b3-react-primary mr-auto transition-colors", children: "Disconnect" })] }) })] }) }) })] })) : (_jsx(SignInWithB3, { closeAfterLogin: true, onLoginSuccess: async (globalAccount) => {
|
|
44
43
|
console.log("User authenticated with Global Account!", globalAccount);
|
|
@@ -12,7 +12,7 @@ export function LoginStepContainer({ children, partnerId }) {
|
|
|
12
12
|
},
|
|
13
13
|
}, !!partnerId);
|
|
14
14
|
const partnerLogo = partner?.data?.[0]?.loginCustomization?.logoUrl;
|
|
15
|
-
return (_jsxs("div", { className: "flex flex-col items-center justify-center pt-6", children: [partnerLogo && (_jsx("img", { src: partnerLogo, alt: "Partner Logo", className: "partner-logo mb-6 h-12 w-auto object-contain" })), children] }));
|
|
15
|
+
return (_jsxs("div", { className: "bg-b3-react-background flex flex-col items-center justify-center pt-6", children: [partnerLogo && (_jsx("img", { src: partnerLogo, alt: "Partner Logo", className: "partner-logo mb-6 h-12 w-auto object-contain" })), children] }));
|
|
16
16
|
}
|
|
17
17
|
export function LoginStep({ onSuccess, chain }) {
|
|
18
18
|
const { partnerId, theme } = useB3();
|
|
@@ -6,7 +6,6 @@ export { useAnalytics } from "./useAnalytics";
|
|
|
6
6
|
export { useAuthentication } from "./useAuthentication";
|
|
7
7
|
export { useB3BalanceFromAddresses } from "./useB3BalanceFromAddresses";
|
|
8
8
|
export { useB3EnsName } from "./useB3EnsName";
|
|
9
|
-
export { useBestTransactionPath } from "./useBestTransactionPath";
|
|
10
9
|
export { useChainSwitchWithAction } from "./useChainSwitchWithAction";
|
|
11
10
|
export * from "./useClaim";
|
|
12
11
|
export { useClient } from "./useClient";
|
|
@@ -6,7 +6,6 @@ export { useAnalytics } from "./useAnalytics.js";
|
|
|
6
6
|
export { useAuthentication } from "./useAuthentication.js";
|
|
7
7
|
export { useB3BalanceFromAddresses } from "./useB3BalanceFromAddresses.js";
|
|
8
8
|
export { useB3EnsName } from "./useB3EnsName.js";
|
|
9
|
-
export { useBestTransactionPath } from "./useBestTransactionPath.js";
|
|
10
9
|
export { useChainSwitchWithAction } from "./useChainSwitchWithAction.js";
|
|
11
10
|
export * from "./useClaim.js";
|
|
12
11
|
export { useClient } from "./useClient.js";
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { useB3, useProfile } from "../../../global-account/react/index.js";
|
|
2
2
|
import { ecosystemWalletId } from "../../../shared/constants/index.js";
|
|
3
3
|
import { debugB3React } from "../../../shared/utils/debug.js";
|
|
4
|
-
import { getIpfsUrl } from "../../../shared/utils/ipfs.js";
|
|
5
4
|
import { useEffect, useMemo, useState } from "react";
|
|
6
5
|
import { getLastAuthProvider, useActiveWallet, useConnectedWallets, useWalletImage } from "thirdweb/react";
|
|
7
6
|
import { socialIcons } from "thirdweb/wallets/in-app";
|
|
@@ -18,7 +17,13 @@ function useLastAuthProvider() {
|
|
|
18
17
|
return lastAuthProvider;
|
|
19
18
|
}
|
|
20
19
|
export function useAccountWallet() {
|
|
21
|
-
|
|
20
|
+
// WOJ: --------------------
|
|
21
|
+
// values from in useB3:
|
|
22
|
+
// const activeAccount = useActiveAccount();
|
|
23
|
+
// const effectiveAccount = isAuthenticated ? accountOverride || activeAccount : undefined;
|
|
24
|
+
// can we possibly just use useActiveAccount here?
|
|
25
|
+
// --------------------
|
|
26
|
+
const { account } = useB3();
|
|
22
27
|
const activeWallet = useActiveWallet();
|
|
23
28
|
const connectedWallets = useConnectedWallets();
|
|
24
29
|
const connectedSmartWallet = connectedWallets.find(wallet => wallet.id === ecosystemWalletId);
|
|
@@ -31,7 +36,6 @@ export function useAccountWallet() {
|
|
|
31
36
|
debug("connectedEOAWallet", connectedEOAWallet);
|
|
32
37
|
debug("isActiveSmartWallet", isActiveSmartWallet);
|
|
33
38
|
debug("isActiveEOAWallet", isActiveEOAWallet);
|
|
34
|
-
const { data: walletImage } = useWalletImage(connectedEOAWallet?.id);
|
|
35
39
|
// If not EOA sign in, then we need to show the smart wallet icon
|
|
36
40
|
const lastAuthProvider = useLastAuthProvider();
|
|
37
41
|
const smartWalletIcon = lastAuthProvider && !connectedEOAWallet
|
|
@@ -39,13 +43,12 @@ export function useAccountWallet() {
|
|
|
39
43
|
: "https://gradvatar.com/0x0000000000000000000000000000000000000000"; // show smart wallet of eoa wallet is gradvatar
|
|
40
44
|
const { data: profileData } = useProfile({ address: account?.address });
|
|
41
45
|
const ensName = profileData?.displayName?.replace(/\.b3\.fun/g, "");
|
|
42
|
-
const avatarUrl = user?.avatar ? getIpfsUrl(user?.avatar) : profileData?.avatar;
|
|
43
46
|
const res = useMemo(() => ({
|
|
44
47
|
wallet: {
|
|
45
48
|
...account,
|
|
46
49
|
ensName,
|
|
47
50
|
meta: {
|
|
48
|
-
icon:
|
|
51
|
+
icon: "", // deprecated
|
|
49
52
|
},
|
|
50
53
|
},
|
|
51
54
|
address: account?.address,
|
|
@@ -55,22 +58,20 @@ export function useAccountWallet() {
|
|
|
55
58
|
isActiveSmartWallet: isActiveSmartWallet,
|
|
56
59
|
isActiveEOAWallet: isActiveEOAWallet,
|
|
57
60
|
smartWalletIcon: smartWalletIcon,
|
|
58
|
-
eoaWalletIcon:
|
|
61
|
+
eoaWalletIcon: "", // deprecated
|
|
59
62
|
}), [
|
|
60
63
|
account,
|
|
61
|
-
avatarUrl,
|
|
62
64
|
connectedEOAWallet,
|
|
63
65
|
connectedSmartWallet,
|
|
64
66
|
ensName,
|
|
65
67
|
isActiveEOAWallet,
|
|
66
68
|
isActiveSmartWallet,
|
|
67
69
|
smartWalletIcon,
|
|
68
|
-
walletImage,
|
|
69
70
|
]);
|
|
70
71
|
return res;
|
|
71
72
|
}
|
|
72
73
|
export function useAccountWalletImage() {
|
|
73
|
-
const { account
|
|
74
|
+
const { account } = useB3();
|
|
74
75
|
const activeWallet = useActiveWallet();
|
|
75
76
|
const connectedWallets = useConnectedWallets();
|
|
76
77
|
const connectedSmartWallet = connectedWallets.find(wallet => wallet.id === ecosystemWalletId);
|
|
@@ -83,6 +84,6 @@ export function useAccountWalletImage() {
|
|
|
83
84
|
? socialIcons[lastAuthProvider]
|
|
84
85
|
: "https://gradvatar.com/0x0000000000000000000000000000000000000000"; // show smart wallet of eoa wallet is gradvatar
|
|
85
86
|
const { data: profileData } = useProfile({ address: account?.address });
|
|
86
|
-
const avatarUrl =
|
|
87
|
+
const avatarUrl = profileData?.avatar;
|
|
87
88
|
return avatarUrl || (isActiveSmartWallet ? smartWalletIcon : walletImage) || "";
|
|
88
89
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { components } from "../../anyspend/types/api";
|
|
2
|
+
export declare function getStripePromise(): Promise<import("@stripe/stripe-js").Stripe | null>;
|
|
2
3
|
export declare function getVendorDisplayName(vendor?: components["schemas"]["OnrampMetadata"]["vendor"]): string;
|
|
3
4
|
export declare function getPaymentMethodDescription(vendor?: components["schemas"]["OnrampMetadata"]["vendor"]): string;
|
|
4
5
|
export declare function formatStripeAmount(amount: number): string;
|
|
@@ -1,4 +1,12 @@
|
|
|
1
|
-
import { VENDOR_DISPLAY_NAMES } from "../../anyspend/constants/index.js";
|
|
1
|
+
import { STRIPE_CONFIG, VENDOR_DISPLAY_NAMES } from "../../anyspend/constants/index.js";
|
|
2
|
+
import { loadStripe } from "@stripe/stripe-js";
|
|
3
|
+
let stripePromise = null;
|
|
4
|
+
export function getStripePromise() {
|
|
5
|
+
if (!stripePromise) {
|
|
6
|
+
stripePromise = loadStripe(STRIPE_CONFIG.publishableKey);
|
|
7
|
+
}
|
|
8
|
+
return stripePromise;
|
|
9
|
+
}
|
|
2
10
|
export function getVendorDisplayName(vendor) {
|
|
3
11
|
switch (vendor) {
|
|
4
12
|
case "coinbase":
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { components } from "../types/api";
|
|
2
2
|
export declare const ANYSPEND_MAINNET_BASE_URL: string;
|
|
3
|
-
export declare const
|
|
3
|
+
export declare const ZERO_ADDRESS = "0x0000000000000000000000000000000000000000";
|
|
4
4
|
export declare const RELAY_SOL_ADDRESS = "11111111111111111111111111111111";
|
|
5
5
|
export declare const RELAY_SOLANA_MAINNET_CHAIN_ID = 792703809;
|
|
6
6
|
export declare const SOLANA_ASSOCIATED_TOKEN_ACCOUNT_PROGRAM_ID = "ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL";
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { CryptoPaymentMethodType } from "./CryptoPaymentMethod";
|
|
2
|
+
interface CryptoPaymentMethodDisplayProps {
|
|
3
|
+
paymentMethod: CryptoPaymentMethodType;
|
|
4
|
+
connectedAddress?: string | null;
|
|
5
|
+
connectedName?: string | null;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Displays the selected crypto payment method with appropriate label
|
|
9
|
+
* - CONNECT_WALLET: Shows wallet address/name or "Connect wallet"
|
|
10
|
+
* - GLOBAL_WALLET: Shows "Global Account"
|
|
11
|
+
* - TRANSFER_CRYPTO: Shows "Transfer crypto"
|
|
12
|
+
* - NONE: Shows "Select payment method"
|
|
13
|
+
*/
|
|
14
|
+
export declare function CryptoPaymentMethodDisplay({ paymentMethod, connectedAddress, connectedName, }: CryptoPaymentMethodDisplayProps): import("react/jsx-runtime").JSX.Element;
|
|
15
|
+
export {};
|
|
@@ -8,6 +8,7 @@ export * from "./useCoinbaseOnrampOptions";
|
|
|
8
8
|
export * from "./useConnectedUserProfile";
|
|
9
9
|
export * from "./useGeoOnrampOptions";
|
|
10
10
|
export * from "./useGetGeo";
|
|
11
|
+
export * from "./useHyperliquidTransfer";
|
|
11
12
|
export * from "./useRecipientAddressState";
|
|
12
13
|
export * from "./useSigMint";
|
|
13
14
|
export * from "./useStripeClientSecret";
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
+
import { CryptoPaymentMethodType } from "../components/common/CryptoPaymentMethod";
|
|
1
2
|
/**
|
|
2
3
|
* Hook that provides connected user's address, profile, and cleaned display name
|
|
3
4
|
* Combines logic for getting connected address from either global account or thirdweb wallets
|
|
4
5
|
*/
|
|
5
|
-
export declare function useConnectedUserProfile(): {
|
|
6
|
+
export declare function useConnectedUserProfile(selectedCryptoPaymentMethod?: CryptoPaymentMethodType): {
|
|
6
7
|
address: string | undefined;
|
|
7
8
|
profile: import("@tanstack/react-query").UseQueryResult<import("@b3dotfun/sdk/global-account/react").CombinedProfile, Error>;
|
|
8
9
|
name: string | null | undefined;
|
|
@@ -2,8 +2,6 @@ import { CryptoPaymentMethodType } from "../components/common/CryptoPaymentMetho
|
|
|
2
2
|
interface UseConnectedWalletDisplayResult {
|
|
3
3
|
walletAddress: string | undefined;
|
|
4
4
|
shouldShowConnectedEOA: boolean;
|
|
5
|
-
shouldShowWagmiWallet: boolean;
|
|
6
|
-
isWalletDuplicated: boolean;
|
|
7
5
|
suggestedPaymentMethod: CryptoPaymentMethodType;
|
|
8
6
|
}
|
|
9
7
|
/**
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
interface HyperliquidTransferParams {
|
|
2
|
+
/** Amount in smallest unit (USDC has 6 decimals) */
|
|
3
|
+
amount: string;
|
|
4
|
+
/** Recipient address */
|
|
5
|
+
destination: string;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* @deprecated This hook is NOT USED in production.
|
|
9
|
+
*
|
|
10
|
+
* Hyperliquid is only supported as DESTINATION CHAIN (not source chain).
|
|
11
|
+
* Users cannot send FROM Hyperliquid in our flow, so EIP-712 signing is not needed.
|
|
12
|
+
*
|
|
13
|
+
* This hook was created during initial planning but is kept for:
|
|
14
|
+
* - Reference if we need to support source chain in the future
|
|
15
|
+
* - Understanding how Hyperliquid EIP-712 transfers work
|
|
16
|
+
*
|
|
17
|
+
* DO NOT USE THIS HOOK IN PRODUCTION CODE.
|
|
18
|
+
*
|
|
19
|
+
* Custom hook for handling Hyperliquid transfers via EIP-712 signature.
|
|
20
|
+
* Based on Relay SDK's Hyperliquid implementation.
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
* ```tsx
|
|
24
|
+
* const { initiateTransfer } = useHyperliquidTransfer();
|
|
25
|
+
*
|
|
26
|
+
* await initiateTransfer({
|
|
27
|
+
* amount: "1000000", // 1 USDC
|
|
28
|
+
* destination: "0x..."
|
|
29
|
+
* });
|
|
30
|
+
* ```
|
|
31
|
+
*/
|
|
32
|
+
export declare function useHyperliquidTransfer(): {
|
|
33
|
+
initiateTransfer: ({ amount, destination }: HyperliquidTransferParams) => Promise<void>;
|
|
34
|
+
getConnectedAddress: () => `0x${string}` | null;
|
|
35
|
+
isWalletConnected: boolean;
|
|
36
|
+
};
|
|
37
|
+
export {};
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import { Chain } from "viem";
|
|
2
1
|
import { components } from "@b3dotfun/sdk/anyspend/types/api";
|
|
2
|
+
import { Chain } from "viem";
|
|
3
3
|
export declare enum ChainType {
|
|
4
4
|
EVM = "evm",
|
|
5
|
-
SOLANA = "solana"
|
|
5
|
+
SOLANA = "solana",
|
|
6
|
+
HYPERLIQUID = "hyperliquid"
|
|
6
7
|
}
|
|
7
8
|
export interface IBaseChain {
|
|
8
9
|
id: number;
|
|
@@ -25,3 +26,10 @@ export interface IEVMChain extends IBaseChain {
|
|
|
25
26
|
export interface ISolanaChain extends IBaseChain {
|
|
26
27
|
type: ChainType.SOLANA;
|
|
27
28
|
}
|
|
29
|
+
export interface IHyperliquidChain extends IBaseChain {
|
|
30
|
+
type: ChainType.HYPERLIQUID;
|
|
31
|
+
apiUrl: string;
|
|
32
|
+
blockExplorer: {
|
|
33
|
+
url: string;
|
|
34
|
+
};
|
|
35
|
+
}
|
|
@@ -1,4 +1,15 @@
|
|
|
1
1
|
export declare function isSolanaAddress(address: string): boolean;
|
|
2
2
|
export declare function isEvmOrSolanaAddress(address: string): boolean;
|
|
3
|
+
/**
|
|
4
|
+
* Check if an address is Hyperliquid's special USDC address.
|
|
5
|
+
* Hyperliquid USDC uses a special 34-character format (0x + 32 hex digits)
|
|
6
|
+
* instead of the standard 42-character Ethereum address format.
|
|
7
|
+
* This is required by Relay SDK for Hyperliquid integration.
|
|
8
|
+
*
|
|
9
|
+
* @param chainId - The chain ID to check
|
|
10
|
+
* @param address - The token address to validate
|
|
11
|
+
* @returns true if the address is Hyperliquid USDC's special format
|
|
12
|
+
*/
|
|
13
|
+
export declare function isHyperliquidUSDC(chainId: number, address: string): boolean;
|
|
3
14
|
export declare function normalizeAddress(address: string): string;
|
|
4
15
|
export declare function eqci(a: string | null | undefined, b: string | null | undefined): boolean;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { components } from "@b3dotfun/sdk/anyspend/types/api";
|
|
2
2
|
import { Account, Chain, PublicClient, Transport, WalletClient } from "viem";
|
|
3
|
-
import { ChainType, IBaseChain, IEVMChain, ISolanaChain } from "../types/chain";
|
|
3
|
+
import { ChainType, IBaseChain, IEVMChain, IHyperliquidChain, ISolanaChain } from "../types/chain";
|
|
4
4
|
export declare const hyperEVM: {
|
|
5
5
|
blockExplorers: {
|
|
6
6
|
readonly default: {
|
|
@@ -42,8 +42,10 @@ export declare const hyperEVM: {
|
|
|
42
42
|
export declare const EVM_MAINNET: Record<number, IEVMChain>;
|
|
43
43
|
export declare const EVM_TESTNET: Record<number, IEVMChain>;
|
|
44
44
|
export declare const SOLANA_MAINNET: ISolanaChain;
|
|
45
|
+
export declare const HYPERLIQUID_MAINNET: IHyperliquidChain;
|
|
45
46
|
export declare const EVM_CHAINS: Record<number, IEVMChain>;
|
|
46
47
|
export declare const SOLANA_CHAINS: Record<number, ISolanaChain>;
|
|
48
|
+
export declare const HYPERLIQUID_CHAINS: Record<number, IHyperliquidChain>;
|
|
47
49
|
export declare const ALL_CHAINS: Record<number, IBaseChain>;
|
|
48
50
|
export declare function getSolanaChains(network: "mainnet" | "testnet"): ISolanaChain;
|
|
49
51
|
export declare function getAllEvmChains(network: "mainnet" | "testnet"): Record<number, IEVMChain>;
|
|
@@ -63,3 +65,20 @@ export declare function getExplorerAddressUrl(chainId: number, address: string):
|
|
|
63
65
|
export declare function getMulticall3Address(chainId: number): string;
|
|
64
66
|
export declare function getNativeToken(chainId: number): components["schemas"]["Token"];
|
|
65
67
|
export declare function isEvmChain(chainId: number): boolean;
|
|
68
|
+
export declare function isHyperliquidChain(chainId: number): boolean;
|
|
69
|
+
export declare function getHyperliquidChain(chainId: number): IHyperliquidChain;
|
|
70
|
+
/**
|
|
71
|
+
* Get available chain IDs for AnySpend based on context (source or destination).
|
|
72
|
+
* Filters out chains that shouldn't be available for the given context.
|
|
73
|
+
*
|
|
74
|
+
* @param context - "from" for source chains, "to" for destination chains
|
|
75
|
+
* @returns Array of available chain IDs
|
|
76
|
+
*
|
|
77
|
+
* @example
|
|
78
|
+
* // Get source chains (excludes Hyperliquid)
|
|
79
|
+
* const sourceChains = getAvailableChainIds("from") // [1, 8453, 137, ...]
|
|
80
|
+
*
|
|
81
|
+
* // Get destination chains (includes Hyperliquid)
|
|
82
|
+
* const destChains = getAvailableChainIds("to") // [1, 8453, 137, ..., 1337]
|
|
83
|
+
*/
|
|
84
|
+
export declare function getAvailableChainIds(context: "from" | "to"): number[];
|
|
@@ -8,3 +8,4 @@ export declare function getPolToken(): components["schemas"]["Token"];
|
|
|
8
8
|
export declare function getBnbToken(): components["schemas"]["Token"];
|
|
9
9
|
export declare function getAvaxToken(): components["schemas"]["Token"];
|
|
10
10
|
export declare function getHyperEVMNativeToken(): components["schemas"]["Token"];
|
|
11
|
+
export declare function getHyperliquidUSDCToken(): components["schemas"]["Token"];
|
|
@@ -6,7 +6,6 @@ export { useAnalytics } from "./useAnalytics";
|
|
|
6
6
|
export { useAuthentication } from "./useAuthentication";
|
|
7
7
|
export { useB3BalanceFromAddresses } from "./useB3BalanceFromAddresses";
|
|
8
8
|
export { useB3EnsName } from "./useB3EnsName";
|
|
9
|
-
export { useBestTransactionPath } from "./useBestTransactionPath";
|
|
10
9
|
export { useChainSwitchWithAction } from "./useChainSwitchWithAction";
|
|
11
10
|
export * from "./useClaim";
|
|
12
11
|
export { useClient } from "./useClient";
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { components } from "@b3dotfun/sdk/anyspend/types/api";
|
|
2
|
+
export declare function getStripePromise(): Promise<import("@stripe/stripe-js").Stripe | null>;
|
|
2
3
|
export declare function getVendorDisplayName(vendor?: components["schemas"]["OnrampMetadata"]["vendor"]): string;
|
|
3
4
|
export declare function getPaymentMethodDescription(vendor?: components["schemas"]["OnrampMetadata"]["vendor"]): string;
|
|
4
5
|
export declare function formatStripeAmount(amount: number): string;
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@ import { components } from "../types/api";
|
|
|
3
3
|
|
|
4
4
|
export const ANYSPEND_MAINNET_BASE_URL = process.env.NEXT_PUBLIC_ANYSPEND_BASE_URL || "https://mainnet.anyspend.com";
|
|
5
5
|
|
|
6
|
-
export const
|
|
6
|
+
export const ZERO_ADDRESS = "0x0000000000000000000000000000000000000000";
|
|
7
7
|
export const RELAY_SOL_ADDRESS = "11111111111111111111111111111111";
|
|
8
8
|
|
|
9
9
|
export const RELAY_SOLANA_MAINNET_CHAIN_ID = 792703809;
|