@b3dotfun/sdk 0.0.87 → 0.0.88
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -1
- package/dist/cjs/anyspend/react/components/AnySpend.d.ts +5 -0
- package/dist/cjs/anyspend/react/components/AnySpend.js +77 -73
- package/dist/cjs/anyspend/react/components/AnySpendCustom.js +0 -1
- package/dist/cjs/anyspend/react/components/AnySpendCustomExactIn.d.ts +1 -1
- package/dist/cjs/anyspend/react/components/AnySpendCustomExactIn.js +1 -2
- package/dist/cjs/anyspend/react/components/AnySpendDeposit.d.ts +122 -0
- package/dist/cjs/anyspend/react/components/AnySpendDeposit.js +190 -0
- package/dist/cjs/anyspend/react/components/QRDeposit.d.ts +43 -0
- package/dist/cjs/anyspend/react/components/QRDeposit.js +146 -0
- package/dist/cjs/anyspend/react/components/common/OrderDetails.js +17 -12
- package/dist/cjs/anyspend/react/components/common/OrderDetailsCollapsible.d.ts +2 -0
- package/dist/cjs/anyspend/react/components/common/OrderDetailsCollapsible.js +12 -5
- package/dist/cjs/anyspend/react/components/common/OrderStatus.js +2 -2
- package/dist/cjs/anyspend/react/components/common/WarningText.d.ts +32 -0
- package/dist/cjs/anyspend/react/components/common/WarningText.js +36 -0
- package/dist/cjs/anyspend/react/components/icons/CreditCardIcon.d.ts +6 -0
- package/dist/cjs/anyspend/react/components/icons/CreditCardIcon.js +6 -0
- package/dist/cjs/anyspend/react/components/icons/QrCodeIcon.d.ts +6 -0
- package/dist/cjs/anyspend/react/components/icons/QrCodeIcon.js +6 -0
- package/dist/cjs/anyspend/react/components/index.d.ts +2 -0
- package/dist/cjs/anyspend/react/components/index.js +3 -1
- 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.d.ts +2 -2
- package/dist/cjs/anyspend/react/hooks/useAnyspendFlow.js +35 -11
- package/dist/cjs/anyspend/react/hooks/useCreateDepositFirstOrder.d.ts +24 -0
- package/dist/cjs/anyspend/react/hooks/useCreateDepositFirstOrder.js +86 -0
- package/dist/cjs/anyspend/react/hooks/useSigMint.d.ts +1 -1
- package/dist/cjs/anyspend/utils/format.js +28 -5
- package/dist/cjs/global-account/react/components/AvatarEditor/AvatarEditor.js +2 -1
- package/dist/cjs/global-account/react/components/B3Provider/B3Provider.js +17 -47
- package/dist/cjs/global-account/react/components/B3Provider/B3Provider.native.js +6 -7
- package/dist/cjs/global-account/react/components/B3Provider/types.d.ts +0 -5
- package/dist/cjs/global-account/react/components/B3Provider/types.js +4 -4
- package/dist/cjs/global-account/react/components/B3Provider/useB3.d.ts +1 -0
- package/dist/cjs/global-account/react/components/B3Provider/useB3.js +1 -0
- package/dist/cjs/global-account/react/components/B3Provider/useB3Account.d.ts +1 -0
- package/dist/cjs/global-account/react/components/B3Provider/useB3Account.js +10 -0
- package/dist/cjs/global-account/react/components/B3Provider/useB3Config.d.ts +9 -0
- package/dist/cjs/global-account/react/components/B3Provider/useB3Config.js +23 -0
- package/dist/cjs/global-account/react/components/LinkAccount/LinkAccount.js +1 -1
- package/dist/cjs/global-account/react/components/LinkAccount/LinkNewAccount.js +1 -2
- package/dist/cjs/global-account/react/components/ManageAccount/ProfileSection.js +2 -1
- package/dist/cjs/global-account/react/components/ManageAccount/SettingsProfileCard.js +2 -1
- package/dist/cjs/global-account/react/components/SignInWithB3/SignInWithB3.js +2 -1
- package/dist/cjs/global-account/react/components/SignInWithB3/SignInWithB3Flow.js +2 -1
- package/dist/cjs/global-account/react/components/index.d.ts +2 -0
- package/dist/cjs/global-account/react/components/index.js +7 -3
- package/dist/cjs/global-account/react/hooks/useAccountWallet.js +3 -2
- package/dist/cjs/global-account/react/hooks/useAuthentication.d.ts +1 -1
- package/dist/cjs/global-account/react/hooks/useAutoSelectWallet.d.ts +7 -0
- package/dist/cjs/global-account/react/hooks/useAutoSelectWallet.js +42 -0
- package/dist/cjs/global-account/react/hooks/useTurnkeyAuth.js +6 -4
- package/dist/cjs/global-account/react/hooks/useUnifiedChainSwitchAndExecute.js +2 -2
- package/dist/cjs/global-account/react/hooks/useUserQuery.d.ts +1 -1
- package/dist/cjs/global-account/react/stores/useModalStore.d.ts +4 -0
- package/dist/esm/anyspend/react/components/AnySpend.d.ts +5 -0
- package/dist/esm/anyspend/react/components/AnySpend.js +77 -73
- package/dist/esm/anyspend/react/components/AnySpendCustom.js +0 -1
- package/dist/esm/anyspend/react/components/AnySpendCustomExactIn.d.ts +1 -1
- package/dist/esm/anyspend/react/components/AnySpendCustomExactIn.js +1 -2
- package/dist/esm/anyspend/react/components/AnySpendDeposit.d.ts +122 -0
- package/dist/esm/anyspend/react/components/AnySpendDeposit.js +187 -0
- package/dist/esm/anyspend/react/components/QRDeposit.d.ts +43 -0
- package/dist/esm/anyspend/react/components/QRDeposit.js +143 -0
- package/dist/esm/anyspend/react/components/common/OrderDetails.js +17 -12
- package/dist/esm/anyspend/react/components/common/OrderDetailsCollapsible.d.ts +2 -0
- package/dist/esm/anyspend/react/components/common/OrderDetailsCollapsible.js +12 -5
- package/dist/esm/anyspend/react/components/common/OrderStatus.js +2 -2
- package/dist/esm/anyspend/react/components/common/WarningText.d.ts +32 -0
- package/dist/esm/anyspend/react/components/common/WarningText.js +32 -0
- package/dist/esm/anyspend/react/components/icons/CreditCardIcon.d.ts +6 -0
- package/dist/esm/anyspend/react/components/icons/CreditCardIcon.js +2 -0
- package/dist/esm/anyspend/react/components/icons/QrCodeIcon.d.ts +6 -0
- package/dist/esm/anyspend/react/components/icons/QrCodeIcon.js +2 -0
- package/dist/esm/anyspend/react/components/index.d.ts +2 -0
- package/dist/esm/anyspend/react/components/index.js +1 -0
- 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.d.ts +2 -2
- package/dist/esm/anyspend/react/hooks/useAnyspendFlow.js +35 -11
- package/dist/esm/anyspend/react/hooks/useCreateDepositFirstOrder.d.ts +24 -0
- package/dist/esm/anyspend/react/hooks/useCreateDepositFirstOrder.js +83 -0
- package/dist/esm/anyspend/react/hooks/useSigMint.d.ts +1 -1
- package/dist/esm/anyspend/utils/format.js +28 -5
- package/dist/esm/global-account/react/components/AvatarEditor/AvatarEditor.js +3 -2
- package/dist/esm/global-account/react/components/B3Provider/B3Provider.js +21 -51
- package/dist/esm/global-account/react/components/B3Provider/B3Provider.native.js +6 -7
- package/dist/esm/global-account/react/components/B3Provider/types.d.ts +0 -5
- package/dist/esm/global-account/react/components/B3Provider/types.js +4 -4
- package/dist/esm/global-account/react/components/B3Provider/useB3.d.ts +1 -0
- package/dist/esm/global-account/react/components/B3Provider/useB3.js +1 -0
- package/dist/esm/global-account/react/components/B3Provider/useB3Account.d.ts +1 -0
- package/dist/esm/global-account/react/components/B3Provider/useB3Account.js +6 -0
- package/dist/esm/global-account/react/components/B3Provider/useB3Config.d.ts +9 -0
- package/dist/esm/global-account/react/components/B3Provider/useB3Config.js +19 -0
- package/dist/esm/global-account/react/components/LinkAccount/LinkAccount.js +2 -2
- package/dist/esm/global-account/react/components/LinkAccount/LinkNewAccount.js +2 -3
- package/dist/esm/global-account/react/components/ManageAccount/ProfileSection.js +3 -2
- package/dist/esm/global-account/react/components/ManageAccount/SettingsProfileCard.js +3 -2
- package/dist/esm/global-account/react/components/SignInWithB3/SignInWithB3.js +3 -2
- package/dist/esm/global-account/react/components/SignInWithB3/SignInWithB3Flow.js +3 -2
- package/dist/esm/global-account/react/components/index.d.ts +2 -0
- package/dist/esm/global-account/react/components/index.js +2 -0
- package/dist/esm/global-account/react/hooks/useAccountWallet.js +4 -3
- package/dist/esm/global-account/react/hooks/useAuthentication.d.ts +1 -1
- package/dist/esm/global-account/react/hooks/useAutoSelectWallet.d.ts +7 -0
- package/dist/esm/global-account/react/hooks/useAutoSelectWallet.js +39 -0
- package/dist/esm/global-account/react/hooks/useTurnkeyAuth.js +6 -4
- package/dist/esm/global-account/react/hooks/useUnifiedChainSwitchAndExecute.js +2 -2
- package/dist/esm/global-account/react/hooks/useUserQuery.d.ts +1 -1
- package/dist/esm/global-account/react/stores/useModalStore.d.ts +4 -0
- package/dist/styles/index.css +1 -1
- package/dist/types/anyspend/react/components/AnySpend.d.ts +5 -0
- package/dist/types/anyspend/react/components/AnySpendCustomExactIn.d.ts +1 -1
- package/dist/types/anyspend/react/components/AnySpendDeposit.d.ts +122 -0
- package/dist/types/anyspend/react/components/QRDeposit.d.ts +43 -0
- package/dist/types/anyspend/react/components/common/OrderDetailsCollapsible.d.ts +2 -0
- package/dist/types/anyspend/react/components/common/WarningText.d.ts +32 -0
- package/dist/types/anyspend/react/components/icons/CreditCardIcon.d.ts +6 -0
- package/dist/types/anyspend/react/components/icons/QrCodeIcon.d.ts +6 -0
- package/dist/types/anyspend/react/components/index.d.ts +2 -0
- package/dist/types/anyspend/react/hooks/index.d.ts +1 -0
- package/dist/types/anyspend/react/hooks/useAnyspendFlow.d.ts +2 -2
- package/dist/types/anyspend/react/hooks/useCreateDepositFirstOrder.d.ts +24 -0
- package/dist/types/anyspend/react/hooks/useSigMint.d.ts +1 -1
- package/dist/types/global-account/react/components/B3Provider/types.d.ts +0 -5
- package/dist/types/global-account/react/components/B3Provider/useB3.d.ts +1 -0
- package/dist/types/global-account/react/components/B3Provider/useB3Account.d.ts +1 -0
- package/dist/types/global-account/react/components/B3Provider/useB3Config.d.ts +9 -0
- package/dist/types/global-account/react/components/index.d.ts +2 -0
- package/dist/types/global-account/react/hooks/useAuthentication.d.ts +1 -1
- package/dist/types/global-account/react/hooks/useAutoSelectWallet.d.ts +7 -0
- package/dist/types/global-account/react/hooks/useUserQuery.d.ts +1 -1
- package/dist/types/global-account/react/stores/useModalStore.d.ts +4 -0
- package/package.json +1 -1
- package/src/anyspend/react/components/AnySpend.tsx +105 -85
- package/src/anyspend/react/components/AnySpendCustom.tsx +0 -2
- package/src/anyspend/react/components/AnySpendCustomExactIn.tsx +2 -3
- package/src/anyspend/react/components/AnySpendDeposit.tsx +578 -0
- package/src/anyspend/react/components/QRDeposit.tsx +348 -0
- package/src/anyspend/react/components/common/OrderDetails.tsx +26 -8
- package/src/anyspend/react/components/common/OrderDetailsCollapsible.tsx +20 -8
- package/src/anyspend/react/components/common/OrderStatus.tsx +2 -2
- package/src/anyspend/react/components/common/WarningText.tsx +52 -0
- package/src/anyspend/react/components/icons/CreditCardIcon.tsx +25 -0
- package/src/anyspend/react/components/icons/QrCodeIcon.tsx +25 -0
- package/src/anyspend/react/components/icons/credit-card.svg +5 -0
- package/src/anyspend/react/components/icons/qr-code.svg +5 -0
- package/src/anyspend/react/components/index.ts +2 -0
- package/src/anyspend/react/hooks/index.ts +1 -0
- package/src/anyspend/react/hooks/useAnyspendFlow.ts +37 -12
- package/src/anyspend/react/hooks/useCreateDepositFirstOrder.ts +110 -0
- package/src/anyspend/utils/format.ts +33 -5
- package/src/global-account/react/components/AvatarEditor/AvatarEditor.tsx +10 -2
- package/src/global-account/react/components/B3Provider/B3Provider.native.tsx +6 -7
- package/src/global-account/react/components/B3Provider/B3Provider.tsx +20 -71
- package/src/global-account/react/components/B3Provider/types.ts +8 -9
- package/src/global-account/react/components/B3Provider/useB3.ts +1 -0
- package/src/global-account/react/components/B3Provider/useB3Account.ts +7 -0
- package/src/global-account/react/components/B3Provider/useB3Config.ts +34 -0
- package/src/global-account/react/components/LinkAccount/LinkAccount.tsx +2 -2
- package/src/global-account/react/components/LinkAccount/LinkNewAccount.tsx +2 -3
- package/src/global-account/react/components/ManageAccount/ProfileSection.tsx +10 -2
- package/src/global-account/react/components/ManageAccount/SettingsProfileCard.tsx +3 -2
- package/src/global-account/react/components/SignInWithB3/SignInWithB3.tsx +2 -2
- package/src/global-account/react/components/SignInWithB3/SignInWithB3Flow.tsx +5 -2
- package/src/global-account/react/components/index.ts +2 -0
- package/src/global-account/react/hooks/useAccountWallet.tsx +4 -3
- package/src/global-account/react/hooks/useAutoSelectWallet.ts +51 -0
- package/src/global-account/react/hooks/useTurnkeyAuth.ts +7 -5
- package/src/global-account/react/hooks/useUnifiedChainSwitchAndExecute.ts +2 -2
- package/src/global-account/react/stores/useModalStore.ts +4 -0
- package/src/styles/index.css +2 -0
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
<svg width="40" height="40" viewBox="0 0 40 40" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
2
|
+
<path d="M8 0.5H32C36.1421 0.5 39.5 3.85786 39.5 8V32C39.5 36.1421 36.1421 39.5 32 39.5H8C3.85786 39.5 0.5 36.1421 0.5 32V8C0.5 3.85786 3.85786 0.5 8 0.5Z" fill="#F4F4F5"/>
|
|
3
|
+
<path d="M8 0.5H32C36.1421 0.5 39.5 3.85786 39.5 8V32C39.5 36.1421 36.1421 39.5 32 39.5H8C3.85786 39.5 0.5 36.1421 0.5 32V8C0.5 3.85786 3.85786 0.5 8 0.5Z" stroke="#E4E4E7"/>
|
|
4
|
+
<path d="M15 20H20V25M11.01 20H11M16.01 25H16M20.01 29H20M29.01 20H29M11 25H12.5M23.5 20H25.5M11 29H16M20 10V16M25.6 29H27.4C27.9601 29 28.2401 29 28.454 28.891C28.6422 28.7951 28.7951 28.6422 28.891 28.454C29 28.2401 29 27.9601 29 27.4V25.6C29 25.0399 29 24.7599 28.891 24.546C28.7951 24.3578 28.6422 24.2049 28.454 24.109C28.2401 24 27.9601 24 27.4 24H25.6C25.0399 24 24.7599 24 24.546 24.109C24.3578 24.2049 24.2049 24.3578 24.109 24.546C24 24.7599 24 25.0399 24 25.6V27.4C24 27.9601 24 28.2401 24.109 28.454C24.2049 28.6422 24.3578 28.7951 24.546 28.891C24.7599 29 25.0399 29 25.6 29ZM25.6 16H27.4C27.9601 16 28.2401 16 28.454 15.891C28.6422 15.7951 28.7951 15.6422 28.891 15.454C29 15.2401 29 14.9601 29 14.4V12.6C29 12.0399 29 11.7599 28.891 11.546C28.7951 11.3578 28.6422 11.2049 28.454 11.109C28.2401 11 27.9601 11 27.4 11H25.6C25.0399 11 24.7599 11 24.546 11.109C24.3578 11.2049 24.2049 11.3578 24.109 11.546C24 11.7599 24 12.0399 24 12.6V14.4C24 14.9601 24 15.2401 24.109 15.454C24.2049 15.6422 24.3578 15.7951 24.546 15.891C24.7599 16 25.0399 16 25.6 16ZM12.6 16H14.4C14.9601 16 15.2401 16 15.454 15.891C15.6422 15.7951 15.7951 15.6422 15.891 15.454C16 15.2401 16 14.9601 16 14.4V12.6C16 12.0399 16 11.7599 15.891 11.546C15.7951 11.3578 15.6422 11.2049 15.454 11.109C15.2401 11 14.9601 11 14.4 11H12.6C12.0399 11 11.7599 11 11.546 11.109C11.3578 11.2049 11.2049 11.3578 11.109 11.546C11 11.7599 11 12.0399 11 12.6V14.4C11 14.9601 11 15.2401 11.109 15.454C11.2049 15.6422 11.3578 15.7951 11.546 15.891C11.7599 16 12.0399 16 12.6 16Z" stroke="#51525C" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
|
|
5
|
+
</svg>
|
|
@@ -5,6 +5,8 @@ export { AnySpendBuySpin } from "./AnySpendBuySpin";
|
|
|
5
5
|
export { AnySpendCollectorClubPurchase } from "./AnySpendCollectorClubPurchase";
|
|
6
6
|
export { AnySpendCustom } from "./AnySpendCustom";
|
|
7
7
|
export { AnySpendCustomExactIn } from "./AnySpendCustomExactIn";
|
|
8
|
+
export { AnySpendDeposit } from "./AnySpendDeposit";
|
|
9
|
+
export type { AnySpendDepositProps, ChainConfig, DepositContractConfig } from "./AnySpendDeposit";
|
|
8
10
|
export { AnySpendDepositHype, HYPE_TOKEN_DETAILS } from "./AnyspendDepositHype";
|
|
9
11
|
export * from "./AnySpendFingerprintWrapper";
|
|
10
12
|
export { AnySpendNFT } from "./AnySpendNFT";
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export * from "./useAnyspendCreateOnrampOrder";
|
|
2
2
|
export * from "./useAnyspendCreateOrder";
|
|
3
|
+
export * from "./useCreateDepositFirstOrder";
|
|
3
4
|
export * from "./useAnyspendOrderAndTransactions";
|
|
4
5
|
export * from "./useAnyspendOrderHistory";
|
|
5
6
|
export * from "./useAnyspendQuote";
|
|
@@ -21,6 +21,7 @@ import { useEffect, useMemo, useState } from "react";
|
|
|
21
21
|
import { parseUnits } from "viem";
|
|
22
22
|
import { base, mainnet } from "viem/chains";
|
|
23
23
|
import { components } from "../../types/api";
|
|
24
|
+
import { GetQuoteRequest } from "../../types/api_req_res";
|
|
24
25
|
import { CryptoPaymentMethodType } from "../components/common/CryptoPaymentMethod";
|
|
25
26
|
import { FiatPaymentMethod } from "../components/common/FiatPaymentMethod";
|
|
26
27
|
import { useAutoSelectCryptoPaymentMethod } from "./useAutoSelectCryptoPaymentMethod";
|
|
@@ -52,7 +53,7 @@ interface UseAnyspendFlowProps {
|
|
|
52
53
|
destinationTokenChainId?: number;
|
|
53
54
|
slippage?: number;
|
|
54
55
|
disableUrlParamManagement?: boolean;
|
|
55
|
-
orderType?: "hype_duel" | "custom_exact_in";
|
|
56
|
+
orderType?: "hype_duel" | "custom_exact_in" | "swap";
|
|
56
57
|
}
|
|
57
58
|
|
|
58
59
|
// This hook serves for order hype_duel and custom_exact_in
|
|
@@ -60,7 +61,6 @@ export function useAnyspendFlow({
|
|
|
60
61
|
paymentType = "crypto",
|
|
61
62
|
recipientAddress,
|
|
62
63
|
loadOrder,
|
|
63
|
-
isDepositMode = false,
|
|
64
64
|
onOrderSuccess,
|
|
65
65
|
onTransactionSuccess,
|
|
66
66
|
sourceTokenAddress,
|
|
@@ -199,16 +199,41 @@ export function useAnyspendFlow({
|
|
|
199
199
|
// For fiat payments, always use USDC decimals (6) regardless of selectedSrcToken
|
|
200
200
|
const effectiveDecimals = paymentType === "fiat" ? USDC_BASE.decimals : selectedSrcToken.decimals;
|
|
201
201
|
const activeInputAmountInWei = parseUnits(srcAmount.replace(/,/g, ""), effectiveDecimals).toString();
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
202
|
+
|
|
203
|
+
// Build quote request based on order type
|
|
204
|
+
const quoteRequest: GetQuoteRequest = (() => {
|
|
205
|
+
const baseParams = {
|
|
206
|
+
srcChain: paymentType === "fiat" ? base.id : selectedSrcChainId,
|
|
207
|
+
dstChain: selectedDstChainId ?? base.id,
|
|
208
|
+
srcTokenAddress: paymentType === "fiat" ? USDC_BASE.address : selectedSrcToken.address,
|
|
209
|
+
dstTokenAddress: selectedDstToken.address,
|
|
210
|
+
recipientAddress: effectiveRecipientAddress,
|
|
211
|
+
onrampVendor: paymentType === "fiat" ? getOnrampVendor(selectedFiatPaymentMethod) : undefined,
|
|
212
|
+
};
|
|
213
|
+
|
|
214
|
+
if (orderType === "swap") {
|
|
215
|
+
return {
|
|
216
|
+
...baseParams,
|
|
217
|
+
type: "swap" as const,
|
|
218
|
+
tradeType: "EXACT_INPUT" as const,
|
|
219
|
+
amount: activeInputAmountInWei,
|
|
220
|
+
};
|
|
221
|
+
} else if (orderType === "hype_duel") {
|
|
222
|
+
return {
|
|
223
|
+
...baseParams,
|
|
224
|
+
type: "hype_duel" as const,
|
|
225
|
+
amount: activeInputAmountInWei,
|
|
226
|
+
};
|
|
227
|
+
} else {
|
|
228
|
+
return {
|
|
229
|
+
...baseParams,
|
|
230
|
+
type: "custom_exact_in" as const,
|
|
231
|
+
amount: activeInputAmountInWei,
|
|
232
|
+
};
|
|
233
|
+
}
|
|
234
|
+
})();
|
|
235
|
+
|
|
236
|
+
const { anyspendQuote, isLoadingAnyspendQuote, getAnyspendQuoteError } = useAnyspendQuote(quoteRequest);
|
|
212
237
|
|
|
213
238
|
// Get geo options for fiat
|
|
214
239
|
const { geoData, coinbaseAvailablePaymentMethods, stripeWeb2Support } = useGeoOnrampOptions(
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import { anyspendService } from "@b3dotfun/sdk/anyspend/services/anyspend";
|
|
2
|
+
import { components } from "@b3dotfun/sdk/anyspend/types/api";
|
|
3
|
+
import { VisitorData } from "@b3dotfun/sdk/anyspend/types/fingerprint";
|
|
4
|
+
import { normalizeAddress } from "@b3dotfun/sdk/anyspend/utils";
|
|
5
|
+
import { useB3 } from "@b3dotfun/sdk/global-account/react";
|
|
6
|
+
import { useVisitorData } from "@fingerprintjs/fingerprintjs-pro-react";
|
|
7
|
+
import { useMutation } from "@tanstack/react-query";
|
|
8
|
+
import { useMemo } from "react";
|
|
9
|
+
import { DepositContractConfig } from "../components/AnySpendDeposit";
|
|
10
|
+
|
|
11
|
+
export type CreateDepositFirstOrderParams = {
|
|
12
|
+
recipientAddress: string;
|
|
13
|
+
srcChain: number;
|
|
14
|
+
dstChain: number;
|
|
15
|
+
srcToken: components["schemas"]["Token"];
|
|
16
|
+
dstToken: components["schemas"]["Token"];
|
|
17
|
+
creatorAddress?: string;
|
|
18
|
+
/** Optional contract config for custom execution after deposit */
|
|
19
|
+
contractConfig?: DepositContractConfig;
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
export type UseCreateDepositFirstOrderProps = {
|
|
23
|
+
onSuccess?: (data: any) => void;
|
|
24
|
+
onError?: (error: Error) => void;
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Hook for creating deposit_first orders in the Anyspend protocol.
|
|
29
|
+
* This order type doesn't require srcAmount - the user deposits tokens after the order is created.
|
|
30
|
+
*/
|
|
31
|
+
export function useCreateDepositFirstOrder({ onSuccess, onError }: UseCreateDepositFirstOrderProps = {}) {
|
|
32
|
+
const { partnerId } = useB3();
|
|
33
|
+
|
|
34
|
+
const { data: fpData } = useVisitorData({ extendedResult: true }, { immediate: true });
|
|
35
|
+
const visitorData: VisitorData | undefined = fpData && {
|
|
36
|
+
requestId: fpData.requestId,
|
|
37
|
+
visitorId: fpData.visitorId,
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
const { mutate: createOrder, isPending } = useMutation({
|
|
41
|
+
mutationFn: async (params: CreateDepositFirstOrderParams) => {
|
|
42
|
+
const { recipientAddress, srcChain, dstChain, srcToken, dstToken, creatorAddress, contractConfig } = params;
|
|
43
|
+
|
|
44
|
+
// Build payload based on whether we have a contract config
|
|
45
|
+
const payload = contractConfig
|
|
46
|
+
? {
|
|
47
|
+
functionAbi: contractConfig.functionAbi,
|
|
48
|
+
functionName: contractConfig.functionName,
|
|
49
|
+
functionArgs: contractConfig.functionArgs,
|
|
50
|
+
to: normalizeAddress(contractConfig.to),
|
|
51
|
+
spenderAddress: contractConfig.spenderAddress ? normalizeAddress(contractConfig.spenderAddress) : undefined,
|
|
52
|
+
action: contractConfig.action,
|
|
53
|
+
}
|
|
54
|
+
: {};
|
|
55
|
+
|
|
56
|
+
try {
|
|
57
|
+
return await anyspendService.createOrder({
|
|
58
|
+
recipientAddress: normalizeAddress(recipientAddress),
|
|
59
|
+
type: "deposit_first",
|
|
60
|
+
srcChain,
|
|
61
|
+
dstChain,
|
|
62
|
+
srcTokenAddress: normalizeAddress(srcToken.address),
|
|
63
|
+
dstTokenAddress: normalizeAddress(dstToken.address),
|
|
64
|
+
srcAmount: "", // Not required for deposit_first
|
|
65
|
+
payload,
|
|
66
|
+
metadata: {
|
|
67
|
+
srcToken: {
|
|
68
|
+
chainId: srcToken.chainId,
|
|
69
|
+
address: srcToken.address,
|
|
70
|
+
symbol: srcToken.symbol,
|
|
71
|
+
name: srcToken.name,
|
|
72
|
+
decimals: srcToken.decimals,
|
|
73
|
+
metadata: srcToken.metadata || {},
|
|
74
|
+
},
|
|
75
|
+
dstToken: {
|
|
76
|
+
chainId: dstToken.chainId,
|
|
77
|
+
address: dstToken.address,
|
|
78
|
+
symbol: dstToken.symbol,
|
|
79
|
+
name: dstToken.name,
|
|
80
|
+
decimals: dstToken.decimals,
|
|
81
|
+
metadata: dstToken.metadata || {},
|
|
82
|
+
},
|
|
83
|
+
},
|
|
84
|
+
creatorAddress: creatorAddress ? normalizeAddress(creatorAddress) : undefined,
|
|
85
|
+
partnerId,
|
|
86
|
+
visitorData,
|
|
87
|
+
});
|
|
88
|
+
} catch (error: any) {
|
|
89
|
+
if (error?.data) {
|
|
90
|
+
throw error.data;
|
|
91
|
+
}
|
|
92
|
+
throw error;
|
|
93
|
+
}
|
|
94
|
+
},
|
|
95
|
+
onSuccess: (data: any) => {
|
|
96
|
+
onSuccess?.(data);
|
|
97
|
+
},
|
|
98
|
+
onError: (error: Error) => {
|
|
99
|
+
onError?.(error);
|
|
100
|
+
},
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
return useMemo(
|
|
104
|
+
() => ({
|
|
105
|
+
createOrder,
|
|
106
|
+
isCreatingOrder: isPending,
|
|
107
|
+
}),
|
|
108
|
+
[createOrder, isPending],
|
|
109
|
+
);
|
|
110
|
+
}
|
|
@@ -1,14 +1,29 @@
|
|
|
1
1
|
import { components } from "@b3dotfun/sdk/anyspend/types/api";
|
|
2
|
+
import { formatTokenAmount } from "@b3dotfun/sdk/shared/utils/number";
|
|
2
3
|
|
|
3
4
|
export const getStatusDisplay = (
|
|
4
5
|
order: components["schemas"]["Order"],
|
|
5
6
|
): { text: string; status: "processing" | "success" | "failure"; description?: string } => {
|
|
7
|
+
const srcToken = order.metadata?.srcToken;
|
|
8
|
+
const dstToken = order.metadata?.dstToken;
|
|
9
|
+
const formattedSrcAmount = srcToken ? formatTokenAmount(BigInt(order.srcAmount), srcToken.decimals) : undefined;
|
|
10
|
+
const actualDstAmount = order.settlement?.actualDstAmount;
|
|
11
|
+
const formattedActualDstAmount =
|
|
12
|
+
actualDstAmount && dstToken ? formatTokenAmount(BigInt(actualDstAmount), dstToken.decimals) : undefined;
|
|
13
|
+
|
|
6
14
|
switch (order.status) {
|
|
7
|
-
case "scanning_deposit_transaction":
|
|
15
|
+
case "scanning_deposit_transaction": {
|
|
16
|
+
const depositText =
|
|
17
|
+
formattedSrcAmount && srcToken
|
|
18
|
+
? `Awaiting ${formattedSrcAmount} ${srcToken.symbol}`
|
|
19
|
+
: order.onrampMetadata
|
|
20
|
+
? "Awaiting Payment"
|
|
21
|
+
: "Awaiting Deposit";
|
|
8
22
|
return {
|
|
9
|
-
text:
|
|
23
|
+
text: depositText,
|
|
10
24
|
status: "processing",
|
|
11
25
|
};
|
|
26
|
+
}
|
|
12
27
|
case "waiting_stripe_payment":
|
|
13
28
|
return {
|
|
14
29
|
text: "Awaiting Payment",
|
|
@@ -34,16 +49,18 @@ export const getStatusDisplay = (
|
|
|
34
49
|
description: "It will take approximately one minute to complete.",
|
|
35
50
|
};
|
|
36
51
|
case "executed": {
|
|
52
|
+
const receivedText =
|
|
53
|
+
formattedActualDstAmount && dstToken ? `Received ${formattedActualDstAmount} ${dstToken.symbol}` : undefined;
|
|
37
54
|
const { text, description } =
|
|
38
55
|
order.type === "swap"
|
|
39
|
-
? { text: "Swap Complete", description: "Your swap has been completed successfully." }
|
|
56
|
+
? { text: receivedText || "Swap Complete", description: "Your swap has been completed successfully." }
|
|
40
57
|
: order.type === "mint_nft"
|
|
41
58
|
? { text: "NFT Minted", description: "Your NFT has been minted" }
|
|
42
59
|
: order.type === "join_tournament"
|
|
43
60
|
? { text: "Tournament Joined", description: "You have joined the tournament" }
|
|
44
61
|
: order.type === "fund_tournament"
|
|
45
62
|
? { text: "Tournament Funded", description: "You have funded the tournament" }
|
|
46
|
-
: { text: "Order Complete", description: "Your order has been completed" };
|
|
63
|
+
: { text: receivedText || "Order Complete", description: "Your order has been completed" };
|
|
47
64
|
return { text, status: "success", description };
|
|
48
65
|
}
|
|
49
66
|
|
|
@@ -59,8 +76,19 @@ export const getStatusDisplay = (
|
|
|
59
76
|
description: "This order has failed. Please try again or contact support.",
|
|
60
77
|
};
|
|
61
78
|
|
|
79
|
+
case "quoting_after_deposit": {
|
|
80
|
+
return {
|
|
81
|
+
text: "Quoting After Deposit",
|
|
82
|
+
status: "processing",
|
|
83
|
+
description: "Getting quote for the order",
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
|
|
62
87
|
default:
|
|
63
|
-
|
|
88
|
+
return {
|
|
89
|
+
text: order.status,
|
|
90
|
+
status: "processing",
|
|
91
|
+
};
|
|
64
92
|
}
|
|
65
93
|
};
|
|
66
94
|
|
|
@@ -1,7 +1,14 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
|
|
3
3
|
import app from "@b3dotfun/sdk/global-account/app";
|
|
4
|
-
import {
|
|
4
|
+
import {
|
|
5
|
+
Button,
|
|
6
|
+
IPFSMediaRenderer,
|
|
7
|
+
toast,
|
|
8
|
+
useAuthentication,
|
|
9
|
+
useB3Config,
|
|
10
|
+
useProfile,
|
|
11
|
+
} from "@b3dotfun/sdk/global-account/react";
|
|
5
12
|
import { validateImageUrl } from "@b3dotfun/sdk/global-account/react/utils/profileDisplay";
|
|
6
13
|
import { cn } from "@b3dotfun/sdk/shared/utils/cn";
|
|
7
14
|
import { debugB3React } from "@b3dotfun/sdk/shared/utils/debug";
|
|
@@ -50,7 +57,8 @@ export function AvatarEditor({ onSetAvatar, className }: AvatarEditorProps) {
|
|
|
50
57
|
const [zoom, setZoom] = useState(1);
|
|
51
58
|
const [croppedAreaPixels, setCroppedAreaPixels] = useState<Area | null>(null);
|
|
52
59
|
const fileInputRef = useRef<HTMLInputElement>(null);
|
|
53
|
-
const {
|
|
60
|
+
const { partnerId } = useB3Config();
|
|
61
|
+
const { user, setUser } = useAuthentication(partnerId);
|
|
54
62
|
const setB3ModalContentType = useModalStore(state => state.setB3ModalContentType);
|
|
55
63
|
const contentType = useModalStore(state => state.contentType);
|
|
56
64
|
|
|
@@ -6,7 +6,6 @@ import { Account, Wallet } from "thirdweb/wallets";
|
|
|
6
6
|
import { ClientType } from "../../../client-manager";
|
|
7
7
|
|
|
8
8
|
import { WagmiProvider } from "wagmi";
|
|
9
|
-
import { useAuthentication } from "../../hooks/useAuthentication";
|
|
10
9
|
import { createWagmiConfig } from "../../utils/createWagmiConfig";
|
|
11
10
|
import { LocalSDKProvider } from "./LocalSDKProvider";
|
|
12
11
|
import { B3Context, B3ContextType } from "./types";
|
|
@@ -89,7 +88,7 @@ export function InnerProvider({
|
|
|
89
88
|
rpcUrls?: Record<number, string>;
|
|
90
89
|
}) {
|
|
91
90
|
const activeAccount = useActiveAccount();
|
|
92
|
-
const { user, setUser, refetchUser } = useAuthentication(partnerId);
|
|
91
|
+
//const { user, setUser, refetchUser } = useAuthentication(partnerId);
|
|
93
92
|
const wagmiConfig = createWagmiConfig({ partnerId, rpcUrls });
|
|
94
93
|
|
|
95
94
|
// Use given accountOverride or activeAccount from thirdweb
|
|
@@ -100,12 +99,12 @@ export function InnerProvider({
|
|
|
100
99
|
<QueryClientProvider client={queryClient}>
|
|
101
100
|
<B3Context.Provider
|
|
102
101
|
value={{
|
|
103
|
-
account: effectiveAccount,
|
|
102
|
+
//account: effectiveAccount,
|
|
104
103
|
automaticallySetFirstEoa: false,
|
|
105
|
-
setWallet: () => {},
|
|
104
|
+
//setWallet: () => {},
|
|
106
105
|
wallet: undefined,
|
|
107
|
-
user,
|
|
108
|
-
setUser,
|
|
106
|
+
//user,
|
|
107
|
+
//setUser,
|
|
109
108
|
initialized: true,
|
|
110
109
|
ready: !!effectiveAccount,
|
|
111
110
|
environment,
|
|
@@ -113,7 +112,7 @@ export function InnerProvider({
|
|
|
113
112
|
theme,
|
|
114
113
|
clientType,
|
|
115
114
|
partnerId,
|
|
116
|
-
refetchUser,
|
|
115
|
+
//refetchUser,
|
|
117
116
|
}}
|
|
118
117
|
>
|
|
119
118
|
{children}
|
|
@@ -1,25 +1,14 @@
|
|
|
1
1
|
import { CreateOnrampOrderParams } from "@b3dotfun/sdk/anyspend/react/hooks/useAnyspendCreateOnrampOrder";
|
|
2
2
|
import { CreateOrderParams } from "@b3dotfun/sdk/anyspend/react/hooks/useAnyspendCreateOrder";
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
TooltipProvider,
|
|
6
|
-
useAuthentication,
|
|
7
|
-
useAuthStore,
|
|
8
|
-
} from "@b3dotfun/sdk/global-account/react";
|
|
3
|
+
import { RelayKitProviderWrapper, TooltipProvider, useAuthStore } from "@b3dotfun/sdk/global-account/react";
|
|
4
|
+
import { useAutoSelectWallet } from "@b3dotfun/sdk/global-account/react/hooks/useAutoSelectWallet";
|
|
9
5
|
import { createWagmiConfig } from "@b3dotfun/sdk/global-account/react/utils/createWagmiConfig";
|
|
10
6
|
import { PermissionsConfig } from "@b3dotfun/sdk/global-account/types/permissions";
|
|
11
7
|
import { loadGA4Script } from "@b3dotfun/sdk/global-account/utils/analytics";
|
|
12
|
-
import { debugB3React } from "@b3dotfun/sdk/shared/utils/debug";
|
|
13
8
|
import "@relayprotocol/relay-kit-ui/styles.css";
|
|
14
9
|
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
17
|
-
getLastAuthProvider,
|
|
18
|
-
ThirdwebProvider,
|
|
19
|
-
useActiveAccount,
|
|
20
|
-
useConnectedWallets,
|
|
21
|
-
useSetActiveWallet,
|
|
22
|
-
} from "thirdweb/react";
|
|
10
|
+
import { useEffect, useMemo } from "react";
|
|
11
|
+
import { ThirdwebProvider, useActiveAccount } from "thirdweb/react";
|
|
23
12
|
import { Account, Wallet } from "thirdweb/wallets";
|
|
24
13
|
import { CreateConnectorFn, WagmiProvider } from "wagmi";
|
|
25
14
|
import { ClientType, setClientType } from "../../../client-manager";
|
|
@@ -28,8 +17,6 @@ import { setToastContext, ToastProvider, useToastContext } from "../Toast/index"
|
|
|
28
17
|
import { LocalSDKProvider } from "./LocalSDKProvider";
|
|
29
18
|
import { B3Context, B3ContextType } from "./types";
|
|
30
19
|
|
|
31
|
-
const debug = debugB3React("B3Provider");
|
|
32
|
-
|
|
33
20
|
/**
|
|
34
21
|
* Default permissions configuration for B3 provider
|
|
35
22
|
*/
|
|
@@ -164,66 +151,32 @@ export function InnerProvider({
|
|
|
164
151
|
enableTurnkey?: boolean;
|
|
165
152
|
}) {
|
|
166
153
|
const activeAccount = useActiveAccount();
|
|
167
|
-
const [manuallySelectedWallet, setManuallySelectedWallet] = useState<Wallet | undefined>(undefined);
|
|
168
|
-
const wallets = useConnectedWallets();
|
|
169
154
|
const isAuthenticated = useAuthStore(state => state.isAuthenticated);
|
|
170
|
-
const isConnected = useAuthStore(state => state.isConnected);
|
|
171
|
-
const justCompletedLogin = useAuthStore(state => state.justCompletedLogin);
|
|
172
|
-
const setActiveWallet = useSetActiveWallet();
|
|
173
|
-
const { user, setUser, refetchUser } = useAuthentication(partnerId);
|
|
174
|
-
|
|
175
|
-
debug("@@B3Provider:isConnected", isConnected);
|
|
176
|
-
debug("@@wallets", wallets);
|
|
177
|
-
debug("@@B3Provider:user", user);
|
|
178
|
-
debug("@@B3Provider:justCompletedLogin", justCompletedLogin);
|
|
155
|
+
//const isConnected = useAuthStore(state => state.isConnected);
|
|
156
|
+
//const justCompletedLogin = useAuthStore(state => state.justCompletedLogin);
|
|
179
157
|
|
|
180
158
|
// Use given accountOverride or activeAccount from thirdweb
|
|
159
|
+
// WOJ: why if isAuthenticated is false, we don't use activeAccount, which should be undefined?
|
|
160
|
+
// skip isAuthenticated check ?
|
|
181
161
|
const effectiveAccount = isAuthenticated ? accountOverride || activeAccount : undefined;
|
|
182
162
|
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
setManuallySelectedWallet(wallet);
|
|
186
|
-
const account = wallet.getAccount();
|
|
187
|
-
debug("@@setWallet", wallet.id, account?.address);
|
|
188
|
-
setActiveWallet(wallet);
|
|
189
|
-
},
|
|
190
|
-
[setManuallySelectedWallet, setActiveWallet],
|
|
191
|
-
);
|
|
192
|
-
|
|
193
|
-
useEffect(() => {
|
|
194
|
-
const autoSelectFirstEOAWallet = async () => {
|
|
195
|
-
// Only proceed if auto-selection is enabled and user is authenticated
|
|
196
|
-
if (!automaticallySetFirstEoa || !isAuthenticated) {
|
|
197
|
-
return;
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
// Find the first EOA wallet (excluding ecosystem wallets)
|
|
201
|
-
const isEOAWallet = (wallet: Wallet) => !wallet.id.startsWith("ecosystem.");
|
|
202
|
-
const firstEOAWallet = wallets.find(isEOAWallet);
|
|
203
|
-
|
|
204
|
-
if (firstEOAWallet) {
|
|
205
|
-
// Only auto-select if the last auth was via wallet or no previous auth provider
|
|
206
|
-
const lastAuthProvider = await getLastAuthProvider();
|
|
207
|
-
const shouldAutoSelect = lastAuthProvider === null || lastAuthProvider === "wallet";
|
|
208
|
-
|
|
209
|
-
if (shouldAutoSelect) {
|
|
210
|
-
setWallet(firstEOAWallet);
|
|
211
|
-
}
|
|
212
|
-
}
|
|
213
|
-
};
|
|
163
|
+
// Wrapper to set active wallet via thirdweb
|
|
164
|
+
// Note: `wallet` in context is deprecated - use useActiveWallet() from thirdweb/react instead
|
|
214
165
|
|
|
215
|
-
|
|
216
|
-
|
|
166
|
+
// Auto-select first EOA wallet when enabled
|
|
167
|
+
useAutoSelectWallet({
|
|
168
|
+
enabled: automaticallySetFirstEoa,
|
|
169
|
+
});
|
|
217
170
|
|
|
218
171
|
return (
|
|
219
172
|
<B3Context.Provider
|
|
220
173
|
value={{
|
|
221
174
|
account: effectiveAccount,
|
|
222
|
-
setWallet,
|
|
223
|
-
wallet:
|
|
224
|
-
user,
|
|
225
|
-
setUser,
|
|
226
|
-
refetchUser,
|
|
175
|
+
// setWallet,
|
|
176
|
+
//wallet: undefined, // Deprecated: use useActiveWallet() from thirdweb/react instead
|
|
177
|
+
//user,
|
|
178
|
+
//setUser,
|
|
179
|
+
//refetchUser,
|
|
227
180
|
initialized: true,
|
|
228
181
|
ready: !!effectiveAccount,
|
|
229
182
|
automaticallySetFirstEoa,
|
|
@@ -237,15 +190,11 @@ export function InnerProvider({
|
|
|
237
190
|
enableTurnkey,
|
|
238
191
|
}}
|
|
239
192
|
>
|
|
240
|
-
|
|
193
|
+
{children}
|
|
241
194
|
</B3Context.Provider>
|
|
242
195
|
);
|
|
243
196
|
}
|
|
244
197
|
|
|
245
|
-
const InnerProvider2 = ({ children }: { children: React.ReactNode }) => {
|
|
246
|
-
return <>{children}</>;
|
|
247
|
-
};
|
|
248
|
-
|
|
249
198
|
/**
|
|
250
199
|
* Component to connect the toast context to the global toast API
|
|
251
200
|
*/
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { Users } from "@b3dotfun/b3-api";
|
|
2
1
|
import { CreateOnrampOrderParams } from "@b3dotfun/sdk/anyspend/react/hooks/useAnyspendCreateOnrampOrder";
|
|
3
2
|
import { CreateOrderParams } from "@b3dotfun/sdk/anyspend/react/hooks/useAnyspendCreateOrder";
|
|
4
3
|
import { PermissionsConfig } from "@b3dotfun/sdk/global-account/types/permissions";
|
|
@@ -12,11 +11,11 @@ import { ClientType } from "../../../client-manager";
|
|
|
12
11
|
export interface B3ContextType {
|
|
13
12
|
account?: Account;
|
|
14
13
|
automaticallySetFirstEoa: boolean;
|
|
15
|
-
user?: Users;
|
|
16
|
-
setWallet: (wallet: Wallet) => void;
|
|
14
|
+
//user?: Users;
|
|
15
|
+
//setWallet: (wallet: Wallet) => void;
|
|
17
16
|
wallet?: Wallet;
|
|
18
|
-
setUser: (user?: Users) => void;
|
|
19
|
-
refetchUser: () => Promise<any>;
|
|
17
|
+
//setUser: (user?: Users) => void;
|
|
18
|
+
//refetchUser: () => Promise<any>;
|
|
20
19
|
initialized: boolean;
|
|
21
20
|
ready: boolean;
|
|
22
21
|
environment?: "development" | "production";
|
|
@@ -35,11 +34,11 @@ export interface B3ContextType {
|
|
|
35
34
|
export const B3Context = createContext<B3ContextType>({
|
|
36
35
|
account: undefined,
|
|
37
36
|
automaticallySetFirstEoa: false,
|
|
38
|
-
user: undefined,
|
|
39
|
-
setWallet: () => {},
|
|
37
|
+
//user: undefined,
|
|
38
|
+
//setWallet: () => {},
|
|
40
39
|
wallet: undefined,
|
|
41
|
-
setUser: () => {},
|
|
42
|
-
refetchUser: async () => {},
|
|
40
|
+
//setUser: () => {},
|
|
41
|
+
//refetchUser: async () => {},
|
|
43
42
|
initialized: false,
|
|
44
43
|
ready: false,
|
|
45
44
|
environment: "development",
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { useContext, useMemo } from "react";
|
|
2
|
+
import { B3Context } from "./types";
|
|
3
|
+
|
|
4
|
+
export const useB3Config = () => {
|
|
5
|
+
const context = useContext(B3Context);
|
|
6
|
+
|
|
7
|
+
if (!context) {
|
|
8
|
+
throw new Error("useB3 must be used within a B3Provider");
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
const {
|
|
12
|
+
automaticallySetFirstEoa,
|
|
13
|
+
environment,
|
|
14
|
+
theme,
|
|
15
|
+
clientType,
|
|
16
|
+
partnerId,
|
|
17
|
+
createClientReferenceId,
|
|
18
|
+
enableTurnkey,
|
|
19
|
+
} = context;
|
|
20
|
+
|
|
21
|
+
// Return a stable reference
|
|
22
|
+
return useMemo(
|
|
23
|
+
() => ({
|
|
24
|
+
automaticallySetFirstEoa,
|
|
25
|
+
environment,
|
|
26
|
+
theme,
|
|
27
|
+
clientType,
|
|
28
|
+
partnerId,
|
|
29
|
+
createClientReferenceId,
|
|
30
|
+
enableTurnkey,
|
|
31
|
+
}),
|
|
32
|
+
[automaticallySetFirstEoa, environment, theme, clientType, partnerId, createClientReferenceId, enableTurnkey],
|
|
33
|
+
);
|
|
34
|
+
};
|
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
Button,
|
|
4
4
|
ManageAccountModalProps,
|
|
5
5
|
toast,
|
|
6
|
-
|
|
6
|
+
useAuthentication,
|
|
7
7
|
useModalStore,
|
|
8
8
|
useQueryB3,
|
|
9
9
|
} from "@b3dotfun/sdk/global-account/react";
|
|
@@ -37,7 +37,7 @@ export const LinkAccount = ({
|
|
|
37
37
|
const isLinking = useModalStore(state => state.isLinking);
|
|
38
38
|
const setB3ModalOpen = useModalStore(state => state.setB3ModalOpen);
|
|
39
39
|
const contentType = useModalStore(state => state.contentType);
|
|
40
|
-
const { user, setUser } =
|
|
40
|
+
const { user, setUser } = useAuthentication(partnerId);
|
|
41
41
|
const [isUpdatingCode, setIsUpdatingCode] = useState(false);
|
|
42
42
|
const [newReferralCode, setNewReferralCode] = useState("");
|
|
43
43
|
const [isEditingCode, setIsEditingCode] = useState(false);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import app from "@b3dotfun/sdk/global-account/app";
|
|
2
|
-
import { toast } from "@b3dotfun/sdk/global-account/react";
|
|
2
|
+
import { toast, useB3Account } from "@b3dotfun/sdk/global-account/react";
|
|
3
3
|
import { ecosystemWalletId } from "@b3dotfun/sdk/shared/constants";
|
|
4
4
|
import { thirdwebB3Mainnet } from "@b3dotfun/sdk/shared/constants/chains/b3Chain";
|
|
5
5
|
import { client } from "@b3dotfun/sdk/shared/utils/thirdweb";
|
|
@@ -11,7 +11,6 @@ import { createWallet, preAuthenticate, WalletId } from "thirdweb/wallets";
|
|
|
11
11
|
import { WalletRow } from "../..";
|
|
12
12
|
import { LinkNewAccountModalProps, useModalStore } from "../../stores/useModalStore";
|
|
13
13
|
import { getProfileDisplayInfo } from "../../utils/profileDisplay";
|
|
14
|
-
import { useB3 } from "../B3Provider/useB3";
|
|
15
14
|
import { AppleIcon } from "../icons/AppleIcon";
|
|
16
15
|
import { DiscordIcon } from "../icons/DiscordIcon";
|
|
17
16
|
import { FarcasterIcon } from "../icons/FarcasterIcon";
|
|
@@ -117,7 +116,7 @@ export function LinkNewAccount({
|
|
|
117
116
|
originalProfile: profile,
|
|
118
117
|
}));
|
|
119
118
|
|
|
120
|
-
const
|
|
119
|
+
const account = useB3Account();
|
|
121
120
|
const { mutate: linkProfile } = useLinkProfile();
|
|
122
121
|
|
|
123
122
|
const onSuccess = useCallback(async () => {
|
|
@@ -1,4 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
useAccountWallet,
|
|
3
|
+
useAuthentication,
|
|
4
|
+
useB3Config,
|
|
5
|
+
useModalStore,
|
|
6
|
+
useProfile,
|
|
7
|
+
useSimBalance,
|
|
8
|
+
} from "@b3dotfun/sdk/global-account/react";
|
|
2
9
|
import { formatUsername } from "@b3dotfun/sdk/shared/utils";
|
|
3
10
|
import { formatDisplayNumber } from "@b3dotfun/sdk/shared/utils/number";
|
|
4
11
|
import { Pencil } from "lucide-react";
|
|
@@ -15,7 +22,8 @@ const ProfileSection = () => {
|
|
|
15
22
|
address: eoaAddress || account?.address,
|
|
16
23
|
fresh: true,
|
|
17
24
|
});
|
|
18
|
-
const {
|
|
25
|
+
const { partnerId } = useB3Config();
|
|
26
|
+
const { user } = useAuthentication(partnerId);
|
|
19
27
|
const setB3ModalOpen = useModalStore(state => state.setB3ModalOpen);
|
|
20
28
|
const setB3ModalContentType = useModalStore(state => state.setB3ModalContentType);
|
|
21
29
|
const navigateBack = useModalStore(state => state.navigateBack);
|