@b3dotfun/sdk 0.0.83-test.0 → 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 -12
- package/dist/cjs/anyspend/react/components/AnySpendCollectorClubPurchase.js +1 -1
- package/dist/cjs/anyspend/react/components/AnySpendCustom.js +4 -6
- package/dist/cjs/anyspend/react/components/common/CryptoPaySection.js +2 -4
- package/dist/cjs/anyspend/react/components/common/CryptoPaymentMethod.js +47 -177
- 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/useAnyspendFlow.js +0 -3
- 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 +58 -1
- package/dist/cjs/anyspend/utils/chain.js +94 -4
- package/dist/cjs/anyspend/utils/token.d.ts +4 -0
- package/dist/cjs/anyspend/utils/token.js +35 -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/SignInWithB3Flow.js +12 -57
- package/dist/cjs/global-account/react/components/SignInWithB3/steps/LoginStep.js +1 -1
- package/dist/cjs/global-account/react/hooks/index.d.ts +0 -2
- package/dist/cjs/global-account/react/hooks/index.js +1 -5
- package/dist/cjs/global-account/react/hooks/useAccountWallet.js +11 -10
- package/dist/cjs/global-account/react/hooks/useAuthentication.d.ts +2 -2
- package/dist/cjs/global-account/react/hooks/useAuthentication.js +63 -72
- package/dist/cjs/global-account/react/hooks/useTWAuth.d.ts +0 -3
- package/dist/cjs/global-account/react/hooks/useTWAuth.js +0 -8
- package/dist/cjs/global-account/react/hooks/useTurnkeyAuth.js +24 -54
- package/dist/cjs/global-account/react/hooks/useUserQuery.d.ts +1 -1
- 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 -13
- package/dist/esm/anyspend/react/components/AnySpendCollectorClubPurchase.js +1 -1
- package/dist/esm/anyspend/react/components/AnySpendCustom.js +5 -7
- package/dist/esm/anyspend/react/components/common/CryptoPaySection.js +4 -6
- package/dist/esm/anyspend/react/components/common/CryptoPaymentMethod.js +45 -175
- 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/useAnyspendFlow.js +0 -3
- 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 +58 -1
- package/dist/esm/anyspend/utils/chain.js +91 -4
- package/dist/esm/anyspend/utils/token.d.ts +4 -0
- package/dist/esm/anyspend/utils/token.js +32 -6
- 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/SignInWithB3Flow.js +12 -57
- package/dist/esm/global-account/react/components/SignInWithB3/steps/LoginStep.js +1 -1
- package/dist/esm/global-account/react/hooks/index.d.ts +0 -2
- package/dist/esm/global-account/react/hooks/index.js +0 -2
- package/dist/esm/global-account/react/hooks/useAccountWallet.js +11 -10
- package/dist/esm/global-account/react/hooks/useAuthentication.d.ts +2 -2
- package/dist/esm/global-account/react/hooks/useAuthentication.js +63 -72
- package/dist/esm/global-account/react/hooks/useTWAuth.d.ts +0 -3
- package/dist/esm/global-account/react/hooks/useTWAuth.js +0 -8
- package/dist/esm/global-account/react/hooks/useTurnkeyAuth.js +24 -54
- package/dist/esm/global-account/react/hooks/useUserQuery.d.ts +1 -1
- package/dist/esm/shared/utils/payment.utils.d.ts +1 -0
- package/dist/esm/shared/utils/payment.utils.js +9 -1
- package/dist/styles/index.css +1 -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 +58 -1
- package/dist/types/anyspend/utils/token.d.ts +4 -0
- package/dist/types/global-account/react/hooks/index.d.ts +0 -2
- package/dist/types/global-account/react/hooks/useAuthentication.d.ts +2 -2
- package/dist/types/global-account/react/hooks/useTWAuth.d.ts +0 -3
- package/dist/types/global-account/react/hooks/useUserQuery.d.ts +1 -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 -13
- package/src/anyspend/react/components/AnySpendCollectorClubPurchase.tsx +1 -1
- package/src/anyspend/react/components/AnySpendCustom.tsx +9 -29
- package/src/anyspend/react/components/common/CryptoPaySection.tsx +7 -30
- package/src/anyspend/react/components/common/CryptoPaymentMethod.tsx +22 -253
- 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/useAnyspendFlow.ts +0 -4
- 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 +115 -5
- package/src/anyspend/utils/token.ts +36 -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/SignInWithB3Flow.tsx +22 -77
- package/src/global-account/react/components/SignInWithB3/steps/LoginStep.tsx +1 -1
- package/src/global-account/react/hooks/index.ts +0 -2
- package/src/global-account/react/hooks/useAccountWallet.tsx +12 -11
- package/src/global-account/react/hooks/useAuthentication.ts +85 -88
- package/src/global-account/react/hooks/useTWAuth.tsx +0 -10
- package/src/global-account/react/hooks/useTurnkeyAuth.ts +26 -59
- package/src/shared/utils/payment.utils.ts +10 -1
- package/dist/cjs/anyspend/react/hooks/useAutoSetActiveWalletFromWagmi.d.ts +0 -10
- package/dist/cjs/anyspend/react/hooks/useAutoSetActiveWalletFromWagmi.js +0 -73
- package/dist/cjs/global-account/react/hooks/useAuth.d.ts +0 -76
- package/dist/cjs/global-account/react/hooks/useAuth.js +0 -338
- 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/anyspend/react/hooks/useAutoSetActiveWalletFromWagmi.d.ts +0 -10
- package/dist/esm/anyspend/react/hooks/useAutoSetActiveWalletFromWagmi.js +0 -70
- package/dist/esm/global-account/react/hooks/useAuth.d.ts +0 -76
- package/dist/esm/global-account/react/hooks/useAuth.js +0 -332
- 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/anyspend/react/hooks/useAutoSetActiveWalletFromWagmi.d.ts +0 -10
- package/dist/types/global-account/react/hooks/useAuth.d.ts +0 -76
- package/dist/types/global-account/react/hooks/useBestTransactionPath.d.ts +0 -41
- package/src/anyspend/react/hooks/useAutoSetActiveWalletFromWagmi.ts +0 -80
- package/src/global-account/react/hooks/useAuth.ts +0 -380
- package/src/global-account/react/hooks/useBestTransactionPath.tsx +0 -201
|
@@ -3,10 +3,17 @@ 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, getPolToken, getSolanaToken } 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
|
}
|
|
10
|
+
export const hyperEVM = defineChain({
|
|
11
|
+
id: HYPEREVM_CHAIN_ID,
|
|
12
|
+
name: "HyperEVM",
|
|
13
|
+
nativeCurrency: { name: "HyperEVM", symbol: "HYPE", decimals: 18 },
|
|
14
|
+
rpcUrls: { default: { http: ["https://rpc.hyperliquid.xyz/evm"] } },
|
|
15
|
+
blockExplorers: { default: { name: "HyperEVM Explorer", url: "https://hyperevmscan.io/" } },
|
|
16
|
+
});
|
|
10
17
|
// export const b4testnet = defineChain({
|
|
11
18
|
// id: 19934,
|
|
12
19
|
// name: "B4 Testnet",
|
|
@@ -150,6 +157,20 @@ export const EVM_MAINNET = {
|
|
|
150
157
|
coingeckoName: "abstract",
|
|
151
158
|
wethAddress: "0x3439153eb7af838ad19d56e1571fbd09333c2809",
|
|
152
159
|
},
|
|
160
|
+
[hyperEVM.id]: {
|
|
161
|
+
id: hyperEVM.id,
|
|
162
|
+
name: hyperEVM.name,
|
|
163
|
+
logoUrl: "https://s2.coinmarketcap.com/static/img/coins/64x64/32196.png",
|
|
164
|
+
type: ChainType.EVM,
|
|
165
|
+
nativeRequired: parseEther("0.01"),
|
|
166
|
+
canDepositNative: true,
|
|
167
|
+
defaultToken: getHyperEVMNativeToken(),
|
|
168
|
+
nativeToken: getHyperEVMNativeToken(),
|
|
169
|
+
viem: hyperEVM,
|
|
170
|
+
pollingInterval: 1000, // 1 second for Hyperliquid
|
|
171
|
+
coingeckoName: "hyperevm",
|
|
172
|
+
wethAddress: "0x5555555555555555555555555555555555555555",
|
|
173
|
+
},
|
|
153
174
|
};
|
|
154
175
|
export const EVM_TESTNET = {
|
|
155
176
|
// [sepolia.id]: {
|
|
@@ -211,9 +232,27 @@ export const SOLANA_MAINNET = {
|
|
|
211
232
|
nativeToken: getSolanaToken(),
|
|
212
233
|
coingeckoName: "solana",
|
|
213
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
|
+
};
|
|
214
250
|
export const EVM_CHAINS = { ...EVM_MAINNET, ...EVM_TESTNET };
|
|
215
251
|
export const SOLANA_CHAINS = { [RELAY_SOLANA_MAINNET_CHAIN_ID]: SOLANA_MAINNET };
|
|
216
|
-
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 };
|
|
217
256
|
export function getSolanaChains(network) {
|
|
218
257
|
invariant(network === "mainnet", "Solana chain is only supported on mainnet");
|
|
219
258
|
return SOLANA_MAINNET;
|
|
@@ -251,7 +290,7 @@ export function canDepositNative(chainId) {
|
|
|
251
290
|
return ALL_CHAINS[chainId].canDepositNative;
|
|
252
291
|
}
|
|
253
292
|
export function isMainnet(chainId) {
|
|
254
|
-
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);
|
|
255
294
|
}
|
|
256
295
|
export function isTestnet(chainId) {
|
|
257
296
|
return EVM_TESTNET[chainId] !== undefined;
|
|
@@ -262,7 +301,11 @@ export function getDefaultToken(chainId) {
|
|
|
262
301
|
}
|
|
263
302
|
export function getChainName(chainId) {
|
|
264
303
|
invariant(ALL_CHAINS[chainId], `Chain ${chainId} is not supported`);
|
|
265
|
-
|
|
304
|
+
const chain = ALL_CHAINS[chainId];
|
|
305
|
+
if (isEvmChain(chainId)) {
|
|
306
|
+
return chain.viem.name;
|
|
307
|
+
}
|
|
308
|
+
return chain.name;
|
|
266
309
|
}
|
|
267
310
|
export function getCoingeckoName(chainId) {
|
|
268
311
|
invariant(ALL_CHAINS[chainId], `Chain ${chainId} is not supported`);
|
|
@@ -411,6 +454,12 @@ export function getPaymentUrl(address, amount, currency, chainId, decimals) {
|
|
|
411
454
|
console.log("Solana URL (isNativeSOL:", isNativeSOL, "):", url);
|
|
412
455
|
return url;
|
|
413
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
|
+
}
|
|
414
463
|
default:
|
|
415
464
|
// Fallback to just the address if chain type is unknown
|
|
416
465
|
return address;
|
|
@@ -423,12 +472,20 @@ export function getExplorerTxUrl(chainId, txHash) {
|
|
|
423
472
|
if (EVM_CHAINS[chainId]) {
|
|
424
473
|
return EVM_CHAINS[chainId].viem.blockExplorers?.default.url + "/tx/" + txHash;
|
|
425
474
|
}
|
|
475
|
+
if (HYPERLIQUID_CHAINS[chainId]) {
|
|
476
|
+
return HYPERLIQUID_CHAINS[chainId].blockExplorer.url + "/tx/" + txHash;
|
|
477
|
+
}
|
|
478
|
+
// Default to Solscan for Solana transactions
|
|
426
479
|
return "https://solscan.io/tx/" + txHash;
|
|
427
480
|
}
|
|
428
481
|
export function getExplorerAddressUrl(chainId, address) {
|
|
429
482
|
if (EVM_CHAINS[chainId]) {
|
|
430
483
|
return EVM_CHAINS[chainId].viem.blockExplorers?.default.url + "/address/" + address;
|
|
431
484
|
}
|
|
485
|
+
if (HYPERLIQUID_CHAINS[chainId]) {
|
|
486
|
+
return HYPERLIQUID_CHAINS[chainId].blockExplorer.url + "/address/" + address;
|
|
487
|
+
}
|
|
488
|
+
// Default to Solscan for Solana addresses
|
|
432
489
|
return "https://solscan.io/account/" + address;
|
|
433
490
|
}
|
|
434
491
|
export function getMulticall3Address(chainId) {
|
|
@@ -445,3 +502,33 @@ export function getNativeToken(chainId) {
|
|
|
445
502
|
export function isEvmChain(chainId) {
|
|
446
503
|
return Boolean(EVM_CHAINS[chainId]);
|
|
447
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
|
+
}
|
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
import { components } from "../../anyspend/types/api";
|
|
2
|
+
export declare const HYPERLIQUID_CHAIN_ID = 1337;
|
|
3
|
+
export declare const HYPEREVM_CHAIN_ID = 999;
|
|
2
4
|
export declare function isNativeToken(address: string): boolean;
|
|
3
5
|
export declare function getSolanaToken(): components["schemas"]["Token"];
|
|
4
6
|
export declare function getEthToken(chainId: number): components["schemas"]["Token"];
|
|
5
7
|
export declare function getPolToken(): components["schemas"]["Token"];
|
|
6
8
|
export declare function getBnbToken(): components["schemas"]["Token"];
|
|
7
9
|
export declare function getAvaxToken(): components["schemas"]["Token"];
|
|
10
|
+
export declare function getHyperEVMNativeToken(): components["schemas"]["Token"];
|
|
11
|
+
export declare function getHyperliquidUSDCToken(): components["schemas"]["Token"];
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
+
import { RELAY_SOL_ADDRESS, RELAY_SOLANA_MAINNET_CHAIN_ID, ZERO_ADDRESS } from "../../anyspend/constants/index.js";
|
|
1
2
|
import { avalanche, bsc, polygon } from "viem/chains";
|
|
2
|
-
|
|
3
|
+
export const HYPERLIQUID_CHAIN_ID = 1337;
|
|
4
|
+
export const HYPEREVM_CHAIN_ID = 999;
|
|
3
5
|
export function isNativeToken(address) {
|
|
4
|
-
return address.toLowerCase() ===
|
|
6
|
+
return address.toLowerCase() === ZERO_ADDRESS || address.toLowerCase() === RELAY_SOL_ADDRESS;
|
|
5
7
|
}
|
|
6
8
|
export function getSolanaToken() {
|
|
7
9
|
return {
|
|
@@ -18,7 +20,7 @@ export function getSolanaToken() {
|
|
|
18
20
|
export function getEthToken(chainId) {
|
|
19
21
|
return {
|
|
20
22
|
chainId: chainId,
|
|
21
|
-
address:
|
|
23
|
+
address: ZERO_ADDRESS,
|
|
22
24
|
symbol: "ETH",
|
|
23
25
|
name: "Ethereum",
|
|
24
26
|
decimals: 18,
|
|
@@ -30,7 +32,7 @@ export function getEthToken(chainId) {
|
|
|
30
32
|
export function getPolToken() {
|
|
31
33
|
return {
|
|
32
34
|
chainId: polygon.id,
|
|
33
|
-
address:
|
|
35
|
+
address: ZERO_ADDRESS,
|
|
34
36
|
symbol: "POL",
|
|
35
37
|
name: "Polygon",
|
|
36
38
|
decimals: 18,
|
|
@@ -42,7 +44,7 @@ export function getPolToken() {
|
|
|
42
44
|
export function getBnbToken() {
|
|
43
45
|
return {
|
|
44
46
|
chainId: bsc.id,
|
|
45
|
-
address:
|
|
47
|
+
address: ZERO_ADDRESS,
|
|
46
48
|
symbol: "BNB",
|
|
47
49
|
name: "BNB",
|
|
48
50
|
decimals: 18,
|
|
@@ -54,7 +56,7 @@ export function getBnbToken() {
|
|
|
54
56
|
export function getAvaxToken() {
|
|
55
57
|
return {
|
|
56
58
|
chainId: avalanche.id,
|
|
57
|
-
address:
|
|
59
|
+
address: ZERO_ADDRESS,
|
|
58
60
|
symbol: "AVAX",
|
|
59
61
|
name: "AVAX",
|
|
60
62
|
decimals: 18,
|
|
@@ -63,3 +65,27 @@ export function getAvaxToken() {
|
|
|
63
65
|
},
|
|
64
66
|
};
|
|
65
67
|
}
|
|
68
|
+
export function getHyperEVMNativeToken() {
|
|
69
|
+
return {
|
|
70
|
+
chainId: HYPEREVM_CHAIN_ID,
|
|
71
|
+
address: ZERO_ADDRESS,
|
|
72
|
+
symbol: "HYPE",
|
|
73
|
+
name: "HYPE",
|
|
74
|
+
decimals: 18,
|
|
75
|
+
metadata: {
|
|
76
|
+
logoURI: "https://s2.coinmarketcap.com/static/img/coins/64x64/32196.png",
|
|
77
|
+
},
|
|
78
|
+
};
|
|
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);
|
|
@@ -3,7 +3,6 @@ import { Loading, useAuthStore, useB3, useGetAllTWSigners, useModalStore, } from
|
|
|
3
3
|
import { debugB3React } from "../../../../shared/utils/debug.js";
|
|
4
4
|
import { useCallback, useEffect, useState } from "react";
|
|
5
5
|
import { useActiveAccount } from "thirdweb/react";
|
|
6
|
-
import { TurnkeyAuthModal } from "../TurnkeyAuthModal.js";
|
|
7
6
|
import { SignInWithB3Privy } from "./SignInWithB3Privy.js";
|
|
8
7
|
import { LoginStep, LoginStepContainer } from "./steps/LoginStep.js";
|
|
9
8
|
import { LoginStepCustom } from "./steps/LoginStepCustom.js";
|
|
@@ -21,9 +20,7 @@ export function SignInWithB3Flow({ strategies, onLoginSuccess, onSessionKeySucce
|
|
|
21
20
|
const account = useActiveAccount();
|
|
22
21
|
const isAuthenticating = useAuthStore(state => state.isAuthenticating);
|
|
23
22
|
const isAuthenticated = useAuthStore(state => state.isAuthenticated);
|
|
24
|
-
const setIsAuthenticated = useAuthStore(state => state.setIsAuthenticated);
|
|
25
23
|
const isConnected = useAuthStore(state => state.isConnected);
|
|
26
|
-
const setIsConnected = useAuthStore(state => state.setIsConnected);
|
|
27
24
|
const setJustCompletedLogin = useAuthStore(state => state.setJustCompletedLogin);
|
|
28
25
|
const [refetchCount, setRefetchCount] = useState(0);
|
|
29
26
|
const [refetchError, setRefetchError] = useState(null);
|
|
@@ -125,10 +122,6 @@ export function SignInWithB3Flow({ strategies, onLoginSuccess, onSessionKeySucce
|
|
|
125
122
|
debug("Refetching user after Turnkey success...");
|
|
126
123
|
await refetchUser();
|
|
127
124
|
debug("User refetched successfully");
|
|
128
|
-
// Set authentication and connection state so UI updates properly
|
|
129
|
-
setIsAuthenticated(true);
|
|
130
|
-
setIsConnected(true);
|
|
131
|
-
setJustCompletedLogin(true);
|
|
132
125
|
// After user data is refreshed, close Turnkey modal and go back to sign-in flow
|
|
133
126
|
debug("Switching back to signInWithB3 modal");
|
|
134
127
|
setB3ModalContentType({
|
|
@@ -158,9 +151,6 @@ export function SignInWithB3Flow({ strategies, onLoginSuccess, onSessionKeySucce
|
|
|
158
151
|
closeAfterLogin,
|
|
159
152
|
source,
|
|
160
153
|
signersEnabled,
|
|
161
|
-
setIsAuthenticated,
|
|
162
|
-
setIsConnected,
|
|
163
|
-
setJustCompletedLogin,
|
|
164
154
|
]);
|
|
165
155
|
// Handle post-login flow after signers are loaded
|
|
166
156
|
useEffect(() => {
|
|
@@ -296,56 +286,21 @@ export function SignInWithB3Flow({ strategies, onLoginSuccess, onSessionKeySucce
|
|
|
296
286
|
if (refetchError) {
|
|
297
287
|
content = (_jsx(LoginStepContainer, { partnerId: partnerId, children: _jsx("div", { className: "p-4 text-center text-red-500", children: refetchError }) }));
|
|
298
288
|
}
|
|
289
|
+
else if (isAuthenticating || (isFetchingSigners && step === "login") || source === "requestPermissions") {
|
|
290
|
+
content = (_jsx(LoginStepContainer, { partnerId: partnerId, children: _jsx("div", { className: "my-8 flex min-h-[350px] items-center justify-center", children: _jsx(Loading, { variant: "white", size: "lg" }) }) }));
|
|
291
|
+
}
|
|
299
292
|
else if (step === "login") {
|
|
300
|
-
//
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
//
|
|
306
|
-
|
|
307
|
-
enableTurnkey,
|
|
308
|
-
turnkeyAuthCompleted,
|
|
309
|
-
isAuthenticated,
|
|
310
|
-
});
|
|
311
|
-
// Show Turnkey authentication as primary option
|
|
312
|
-
content = (_jsx(LoginStepContainer, { partnerId: partnerId, children: _jsx(TurnkeyAuthModal, { onSuccess: async (authenticatedUser) => {
|
|
313
|
-
debug("Turnkey authentication successful in primary flow", { authenticatedUser });
|
|
314
|
-
setTurnkeyAuthCompleted(true);
|
|
315
|
-
// After Turnkey auth, refetch user to get the full user object
|
|
316
|
-
await refetchUser();
|
|
317
|
-
// User is now authenticated via Turnkey
|
|
318
|
-
// Set both isAuthenticated and isConnected to true so UI updates properly
|
|
319
|
-
// Wallet connection is optional and can happen later for signing transactions
|
|
320
|
-
setIsAuthenticated(true);
|
|
321
|
-
setIsConnected(true);
|
|
322
|
-
setJustCompletedLogin(true);
|
|
323
|
-
// Call the login success callback
|
|
324
|
-
onLoginSuccess?.({});
|
|
325
|
-
}, onClose: () => {
|
|
326
|
-
// If user closes Turnkey modal, they can still use wallet connection as fallback
|
|
327
|
-
setTurnkeyAuthCompleted(true);
|
|
328
|
-
}, initialEmail: "", skipToOtp: false }) }));
|
|
293
|
+
// Custom strategy
|
|
294
|
+
if (strategies?.[0] === "privy") {
|
|
295
|
+
content = _jsx(SignInWithB3Privy, { onSuccess: handleLoginSuccess, chain: chain });
|
|
296
|
+
}
|
|
297
|
+
else if (strategies) {
|
|
298
|
+
// Strategies are explicitly provided
|
|
299
|
+
content = (_jsx(LoginStepCustom, { strategies: strategies, chain: chain, onSuccess: handleLoginSuccess, onError: onError, automaticallySetFirstEoa: !!automaticallySetFirstEoa }));
|
|
329
300
|
}
|
|
330
301
|
else {
|
|
331
|
-
//
|
|
332
|
-
|
|
333
|
-
content = (_jsx(LoginStepContainer, { partnerId: partnerId, children: _jsx("div", { className: "my-8 flex min-h-[350px] items-center justify-center", children: _jsx(Loading, { variant: "white", size: "lg" }) }) }));
|
|
334
|
-
}
|
|
335
|
-
else {
|
|
336
|
-
// Custom strategy
|
|
337
|
-
if (strategies?.[0] === "privy") {
|
|
338
|
-
content = _jsx(SignInWithB3Privy, { onSuccess: handleLoginSuccess, chain: chain });
|
|
339
|
-
}
|
|
340
|
-
else if (strategies) {
|
|
341
|
-
// Strategies are explicitly provided
|
|
342
|
-
content = (_jsx(LoginStepCustom, { strategies: strategies, chain: chain, onSuccess: handleLoginSuccess, onError: onError, automaticallySetFirstEoa: !!automaticallySetFirstEoa }));
|
|
343
|
-
}
|
|
344
|
-
else {
|
|
345
|
-
// Default to handle all strategies we support
|
|
346
|
-
content = _jsx(LoginStep, { chain: chain, onSuccess: handleLoginSuccess, onError: onError });
|
|
347
|
-
}
|
|
348
|
-
}
|
|
302
|
+
// Default to handle all strategies we support
|
|
303
|
+
content = _jsx(LoginStep, { chain: chain, onSuccess: handleLoginSuccess, onError: onError });
|
|
349
304
|
}
|
|
350
305
|
}
|
|
351
306
|
return content;
|
|
@@ -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();
|
|
@@ -3,11 +3,9 @@ export { useAccountAssets } from "./useAccountAssets";
|
|
|
3
3
|
export { useAccountWallet } from "./useAccountWallet";
|
|
4
4
|
export { useAddTWSessionKey } from "./useAddTWSessionKey";
|
|
5
5
|
export { useAnalytics } from "./useAnalytics";
|
|
6
|
-
export { useAuth } from "./useAuth";
|
|
7
6
|
export { useAuthentication } from "./useAuthentication";
|
|
8
7
|
export { useB3BalanceFromAddresses } from "./useB3BalanceFromAddresses";
|
|
9
8
|
export { useB3EnsName } from "./useB3EnsName";
|
|
10
|
-
export { useBestTransactionPath } from "./useBestTransactionPath";
|
|
11
9
|
export { useChainSwitchWithAction } from "./useChainSwitchWithAction";
|
|
12
10
|
export * from "./useClaim";
|
|
13
11
|
export { useClient } from "./useClient";
|
|
@@ -3,11 +3,9 @@ export { useAccountAssets } from "./useAccountAssets.js";
|
|
|
3
3
|
export { useAccountWallet } from "./useAccountWallet.js";
|
|
4
4
|
export { useAddTWSessionKey } from "./useAddTWSessionKey.js";
|
|
5
5
|
export { useAnalytics } from "./useAnalytics.js";
|
|
6
|
-
export { useAuth } from "./useAuth.js";
|
|
7
6
|
export { useAuthentication } from "./useAuthentication.js";
|
|
8
7
|
export { useB3BalanceFromAddresses } from "./useB3BalanceFromAddresses.js";
|
|
9
8
|
export { useB3EnsName } from "./useB3EnsName.js";
|
|
10
|
-
export { useBestTransactionPath } from "./useBestTransactionPath.js";
|
|
11
9
|
export { useChainSwitchWithAction } from "./useChainSwitchWithAction.js";
|
|
12
10
|
export * from "./useClaim.js";
|
|
13
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
|
}
|
|
@@ -41,8 +41,8 @@ export declare function useAuthentication(partnerId: string): {
|
|
|
41
41
|
name?: string | undefined;
|
|
42
42
|
address?: string | undefined;
|
|
43
43
|
email?: string | undefined;
|
|
44
|
-
phone?: string | undefined;
|
|
45
44
|
username?: string | undefined;
|
|
45
|
+
phone?: string | undefined;
|
|
46
46
|
fid?: string | undefined;
|
|
47
47
|
};
|
|
48
48
|
}[] | undefined;
|
|
@@ -63,6 +63,6 @@ export declare function useAuthentication(partnerId: string): {
|
|
|
63
63
|
turnkeyOtpId?: string | undefined;
|
|
64
64
|
};
|
|
65
65
|
} | undefined;
|
|
66
|
-
refetchUser: () => Promise<import("@feathersjs/authentication").AuthenticationResult>;
|
|
66
|
+
refetchUser: (wallet?: Wallet) => Promise<import("@feathersjs/authentication").AuthenticationResult>;
|
|
67
67
|
setUser: (newUser?: import("@b3dotfun/b3-api").Users) => void;
|
|
68
68
|
};
|