@b3dotfun/sdk 0.1.2 → 0.1.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/anyspend/react/components/AnySpend.d.ts +7 -1
- package/dist/cjs/anyspend/react/components/AnySpend.js +66 -15
- package/dist/cjs/anyspend/react/components/AnySpendCollectorClubPurchase.d.ts +6 -2
- package/dist/cjs/anyspend/react/components/AnySpendCollectorClubPurchase.js +4 -4
- package/dist/cjs/anyspend/react/components/AnySpendCustomExactIn.d.ts +6 -0
- package/dist/cjs/anyspend/react/components/AnySpendCustomExactIn.js +185 -50
- package/dist/cjs/anyspend/react/components/AnySpendDeposit.d.ts +6 -1
- package/dist/cjs/anyspend/react/components/AnySpendDeposit.js +19 -4
- package/dist/cjs/anyspend/react/components/AnySpendStakeUpsideExactIn.d.ts +2 -1
- package/dist/cjs/anyspend/react/components/AnySpendStakeUpsideExactIn.js +2 -2
- package/dist/cjs/anyspend/react/components/QRDeposit.d.ts +4 -1
- package/dist/cjs/anyspend/react/components/QRDeposit.js +12 -4
- package/dist/cjs/anyspend/react/components/common/CryptoPaySection.d.ts +3 -1
- package/dist/cjs/anyspend/react/components/common/CryptoPaySection.js +7 -5
- package/dist/cjs/anyspend/react/components/common/CryptoPaymentMethod.d.ts +3 -1
- package/dist/cjs/anyspend/react/components/common/CryptoPaymentMethod.js +4 -3
- package/dist/cjs/anyspend/react/components/common/CryptoReceiveSection.d.ts +3 -1
- package/dist/cjs/anyspend/react/components/common/CryptoReceiveSection.js +7 -6
- package/dist/cjs/anyspend/react/components/common/FeeDetailPanel.d.ts +3 -1
- package/dist/cjs/anyspend/react/components/common/FeeDetailPanel.js +15 -6
- package/dist/cjs/anyspend/react/components/common/FiatPaymentMethod.d.ts +3 -1
- package/dist/cjs/anyspend/react/components/common/FiatPaymentMethod.js +10 -6
- package/dist/cjs/anyspend/react/components/common/OrderDetails.d.ts +3 -0
- package/dist/cjs/anyspend/react/components/common/OrderDetails.js +11 -10
- package/dist/cjs/anyspend/react/components/common/OrderDetailsCollapsible.d.ts +2 -0
- package/dist/cjs/anyspend/react/components/common/OrderDetailsCollapsible.js +9 -9
- package/dist/cjs/anyspend/react/components/common/OrderHistory.js +2 -1
- package/dist/cjs/anyspend/react/components/common/PanelOnramp.d.ts +3 -1
- package/dist/cjs/anyspend/react/components/common/PanelOnramp.js +2 -2
- package/dist/cjs/anyspend/react/components/common/PanelOnrampPayment.d.ts +2 -0
- package/dist/cjs/anyspend/react/components/common/PanelOnrampPayment.js +20 -7
- package/dist/cjs/anyspend/react/components/common/PointsDetailPanel.d.ts +3 -1
- package/dist/cjs/anyspend/react/components/common/PointsDetailPanel.js +3 -2
- package/dist/cjs/anyspend/react/components/common/RecipientSelection.d.ts +6 -1
- package/dist/cjs/anyspend/react/components/common/RecipientSelection.js +5 -2
- package/dist/cjs/anyspend/react/components/common/TabSection.d.ts +3 -1
- package/dist/cjs/anyspend/react/components/common/TabSection.js +16 -7
- package/dist/cjs/anyspend/react/components/common/TransferCryptoDetails.d.ts +2 -0
- package/dist/cjs/anyspend/react/components/common/TransferCryptoDetails.js +3 -2
- package/dist/cjs/anyspend/react/components/common/WarningText.d.ts +8 -7
- package/dist/cjs/anyspend/react/components/common/WarningText.js +5 -6
- package/dist/cjs/anyspend/react/components/index.d.ts +1 -0
- package/dist/cjs/anyspend/react/components/types/classes.d.ts +390 -0
- package/dist/cjs/anyspend/react/components/types/classes.js +6 -0
- 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 +22 -2
- package/dist/cjs/anyspend/react/hooks/useAnyspendFlow.js +119 -15
- package/dist/cjs/anyspend/react/hooks/useDirectTransfer.d.ts +17 -0
- package/dist/cjs/anyspend/react/hooks/useDirectTransfer.js +46 -0
- package/dist/cjs/anyspend/react/hooks/useRecipientAddressState.js +1 -1
- package/dist/cjs/anyspend/utils/format.js +12 -2
- package/dist/cjs/global-account/react/components/B3DynamicModal.js +1 -5
- package/dist/cjs/global-account/react/components/B3Provider/B3ConfigProvider.d.ts +1 -3
- package/dist/cjs/global-account/react/components/B3Provider/B3ConfigProvider.js +1 -2
- package/dist/cjs/global-account/react/components/B3Provider/B3Provider.d.ts +1 -4
- package/dist/cjs/global-account/react/components/B3Provider/B3Provider.js +2 -2
- package/dist/cjs/global-account/react/components/B3Provider/B3Provider.native.d.ts +1 -1
- package/dist/cjs/global-account/react/components/B3Provider/B3Provider.native.js +1 -1
- package/dist/cjs/global-account/react/components/B3Provider/LocalSDKProvider.d.ts +1 -4
- package/dist/cjs/global-account/react/components/B3Provider/LocalSDKProvider.js +1 -3
- package/dist/cjs/global-account/react/components/B3Provider/RelayKitProviderWrapper.js +1 -3
- package/dist/cjs/global-account/react/components/ManageAccount/SettingsContent.js +17 -3
- package/dist/cjs/global-account/react/components/SignInWithB3/SignInWithB3Flow.js +19 -152
- package/dist/cjs/global-account/react/components/index.d.ts +0 -1
- package/dist/cjs/global-account/react/components/index.js +3 -6
- package/dist/cjs/global-account/react/hooks/index.d.ts +0 -1
- package/dist/cjs/global-account/react/hooks/index.js +2 -4
- package/dist/cjs/global-account/react/hooks/useAuth.d.ts +2 -3
- package/dist/cjs/global-account/react/hooks/useAuth.js +14 -31
- package/dist/cjs/global-account/react/hooks/useTWAuth.d.ts +1 -1
- package/dist/cjs/global-account/react/hooks/useTWAuth.js +3 -3
- package/dist/cjs/global-account/react/stores/useModalStore.d.ts +8 -19
- package/dist/esm/anyspend/react/components/AnySpend.d.ts +7 -1
- package/dist/esm/anyspend/react/components/AnySpend.js +68 -17
- package/dist/esm/anyspend/react/components/AnySpendCollectorClubPurchase.d.ts +6 -2
- package/dist/esm/anyspend/react/components/AnySpendCollectorClubPurchase.js +4 -4
- package/dist/esm/anyspend/react/components/AnySpendCustomExactIn.d.ts +6 -0
- package/dist/esm/anyspend/react/components/AnySpendCustomExactIn.js +189 -54
- package/dist/esm/anyspend/react/components/AnySpendDeposit.d.ts +6 -1
- package/dist/esm/anyspend/react/components/AnySpendDeposit.js +19 -4
- package/dist/esm/anyspend/react/components/AnySpendStakeUpsideExactIn.d.ts +2 -1
- package/dist/esm/anyspend/react/components/AnySpendStakeUpsideExactIn.js +2 -2
- package/dist/esm/anyspend/react/components/QRDeposit.d.ts +4 -1
- package/dist/esm/anyspend/react/components/QRDeposit.js +12 -4
- package/dist/esm/anyspend/react/components/common/CryptoPaySection.d.ts +3 -1
- package/dist/esm/anyspend/react/components/common/CryptoPaySection.js +7 -5
- package/dist/esm/anyspend/react/components/common/CryptoPaymentMethod.d.ts +3 -1
- package/dist/esm/anyspend/react/components/common/CryptoPaymentMethod.js +4 -3
- package/dist/esm/anyspend/react/components/common/CryptoReceiveSection.d.ts +3 -1
- package/dist/esm/anyspend/react/components/common/CryptoReceiveSection.js +7 -6
- package/dist/esm/anyspend/react/components/common/FeeDetailPanel.d.ts +3 -1
- package/dist/esm/anyspend/react/components/common/FeeDetailPanel.js +15 -6
- package/dist/esm/anyspend/react/components/common/FiatPaymentMethod.d.ts +3 -1
- package/dist/esm/anyspend/react/components/common/FiatPaymentMethod.js +10 -6
- package/dist/esm/anyspend/react/components/common/OrderDetails.d.ts +3 -0
- package/dist/esm/anyspend/react/components/common/OrderDetails.js +11 -10
- package/dist/esm/anyspend/react/components/common/OrderDetailsCollapsible.d.ts +2 -0
- package/dist/esm/anyspend/react/components/common/OrderDetailsCollapsible.js +9 -9
- package/dist/esm/anyspend/react/components/common/OrderHistory.js +2 -1
- package/dist/esm/anyspend/react/components/common/PanelOnramp.d.ts +3 -1
- package/dist/esm/anyspend/react/components/common/PanelOnramp.js +2 -2
- package/dist/esm/anyspend/react/components/common/PanelOnrampPayment.d.ts +2 -0
- package/dist/esm/anyspend/react/components/common/PanelOnrampPayment.js +20 -7
- package/dist/esm/anyspend/react/components/common/PointsDetailPanel.d.ts +3 -1
- package/dist/esm/anyspend/react/components/common/PointsDetailPanel.js +3 -2
- package/dist/esm/anyspend/react/components/common/RecipientSelection.d.ts +6 -1
- package/dist/esm/anyspend/react/components/common/RecipientSelection.js +5 -2
- package/dist/esm/anyspend/react/components/common/TabSection.d.ts +3 -1
- package/dist/esm/anyspend/react/components/common/TabSection.js +16 -7
- package/dist/esm/anyspend/react/components/common/TransferCryptoDetails.d.ts +2 -0
- package/dist/esm/anyspend/react/components/common/TransferCryptoDetails.js +3 -2
- package/dist/esm/anyspend/react/components/common/WarningText.d.ts +8 -7
- package/dist/esm/anyspend/react/components/common/WarningText.js +5 -6
- package/dist/esm/anyspend/react/components/index.d.ts +1 -0
- package/dist/esm/anyspend/react/components/types/classes.d.ts +390 -0
- package/dist/esm/anyspend/react/components/types/classes.js +5 -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 +22 -2
- package/dist/esm/anyspend/react/hooks/useAnyspendFlow.js +119 -16
- package/dist/esm/anyspend/react/hooks/useDirectTransfer.d.ts +17 -0
- package/dist/esm/anyspend/react/hooks/useDirectTransfer.js +43 -0
- package/dist/esm/anyspend/react/hooks/useRecipientAddressState.js +1 -1
- package/dist/esm/anyspend/utils/format.js +12 -2
- package/dist/esm/global-account/react/components/B3DynamicModal.js +1 -5
- package/dist/esm/global-account/react/components/B3Provider/B3ConfigProvider.d.ts +1 -3
- package/dist/esm/global-account/react/components/B3Provider/B3ConfigProvider.js +1 -2
- package/dist/esm/global-account/react/components/B3Provider/B3Provider.d.ts +1 -4
- package/dist/esm/global-account/react/components/B3Provider/B3Provider.js +2 -2
- package/dist/esm/global-account/react/components/B3Provider/B3Provider.native.d.ts +1 -1
- package/dist/esm/global-account/react/components/B3Provider/B3Provider.native.js +1 -1
- package/dist/esm/global-account/react/components/B3Provider/LocalSDKProvider.d.ts +1 -4
- package/dist/esm/global-account/react/components/B3Provider/LocalSDKProvider.js +1 -3
- package/dist/esm/global-account/react/components/B3Provider/RelayKitProviderWrapper.js +1 -3
- package/dist/esm/global-account/react/components/ManageAccount/SettingsContent.js +16 -2
- package/dist/esm/global-account/react/components/SignInWithB3/SignInWithB3Flow.js +20 -153
- package/dist/esm/global-account/react/components/index.d.ts +0 -1
- package/dist/esm/global-account/react/components/index.js +0 -2
- 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/useAuth.d.ts +2 -3
- package/dist/esm/global-account/react/hooks/useAuth.js +14 -31
- package/dist/esm/global-account/react/hooks/useTWAuth.d.ts +1 -1
- package/dist/esm/global-account/react/hooks/useTWAuth.js +3 -3
- package/dist/esm/global-account/react/stores/useModalStore.d.ts +8 -19
- package/dist/styles/index.css +1 -1
- package/dist/types/anyspend/react/components/AnySpend.d.ts +7 -1
- package/dist/types/anyspend/react/components/AnySpendCollectorClubPurchase.d.ts +6 -2
- package/dist/types/anyspend/react/components/AnySpendCustomExactIn.d.ts +6 -0
- package/dist/types/anyspend/react/components/AnySpendDeposit.d.ts +6 -1
- package/dist/types/anyspend/react/components/AnySpendStakeUpsideExactIn.d.ts +2 -1
- package/dist/types/anyspend/react/components/QRDeposit.d.ts +4 -1
- package/dist/types/anyspend/react/components/common/CryptoPaySection.d.ts +3 -1
- package/dist/types/anyspend/react/components/common/CryptoPaymentMethod.d.ts +3 -1
- package/dist/types/anyspend/react/components/common/CryptoReceiveSection.d.ts +3 -1
- package/dist/types/anyspend/react/components/common/FeeDetailPanel.d.ts +3 -1
- package/dist/types/anyspend/react/components/common/FiatPaymentMethod.d.ts +3 -1
- package/dist/types/anyspend/react/components/common/OrderDetails.d.ts +3 -0
- package/dist/types/anyspend/react/components/common/OrderDetailsCollapsible.d.ts +2 -0
- package/dist/types/anyspend/react/components/common/PanelOnramp.d.ts +3 -1
- package/dist/types/anyspend/react/components/common/PanelOnrampPayment.d.ts +2 -0
- package/dist/types/anyspend/react/components/common/PointsDetailPanel.d.ts +3 -1
- package/dist/types/anyspend/react/components/common/RecipientSelection.d.ts +6 -1
- package/dist/types/anyspend/react/components/common/TabSection.d.ts +3 -1
- package/dist/types/anyspend/react/components/common/TransferCryptoDetails.d.ts +2 -0
- package/dist/types/anyspend/react/components/common/WarningText.d.ts +8 -7
- package/dist/types/anyspend/react/components/index.d.ts +1 -0
- package/dist/types/anyspend/react/components/types/classes.d.ts +390 -0
- package/dist/types/anyspend/react/hooks/index.d.ts +1 -0
- package/dist/types/anyspend/react/hooks/useAnyspendFlow.d.ts +22 -2
- package/dist/types/anyspend/react/hooks/useDirectTransfer.d.ts +17 -0
- package/dist/types/global-account/react/components/B3Provider/B3ConfigProvider.d.ts +1 -3
- package/dist/types/global-account/react/components/B3Provider/B3Provider.d.ts +1 -4
- package/dist/types/global-account/react/components/B3Provider/B3Provider.native.d.ts +1 -1
- package/dist/types/global-account/react/components/B3Provider/LocalSDKProvider.d.ts +1 -4
- package/dist/types/global-account/react/components/index.d.ts +0 -1
- package/dist/types/global-account/react/hooks/index.d.ts +0 -1
- package/dist/types/global-account/react/hooks/useAuth.d.ts +2 -3
- package/dist/types/global-account/react/hooks/useTWAuth.d.ts +1 -1
- package/dist/types/global-account/react/stores/useModalStore.d.ts +8 -19
- package/package.json +1 -1
- package/src/anyspend/react/components/AnySpend.tsx +164 -36
- package/src/anyspend/react/components/AnySpendCollectorClubPurchase.tsx +11 -6
- package/src/anyspend/react/components/AnySpendCustomExactIn.tsx +278 -69
- package/src/anyspend/react/components/AnySpendDeposit.tsx +176 -52
- package/src/anyspend/react/components/AnySpendStakeUpsideExactIn.tsx +3 -0
- package/src/anyspend/react/components/QRDeposit.tsx +91 -35
- package/src/anyspend/react/components/common/CryptoPaySection.tsx +31 -19
- package/src/anyspend/react/components/common/CryptoPaymentMethod.tsx +14 -4
- package/src/anyspend/react/components/common/CryptoReceiveSection.tsx +43 -23
- package/src/anyspend/react/components/common/FeeDetailPanel.tsx +53 -32
- package/src/anyspend/react/components/common/FiatPaymentMethod.tsx +26 -13
- package/src/anyspend/react/components/common/OrderDetails.tsx +20 -9
- package/src/anyspend/react/components/common/OrderDetailsCollapsible.tsx +12 -7
- package/src/anyspend/react/components/common/OrderHistory.tsx +2 -1
- package/src/anyspend/react/components/common/PanelOnramp.tsx +4 -1
- package/src/anyspend/react/components/common/PanelOnrampPayment.tsx +118 -40
- package/src/anyspend/react/components/common/PointsDetailPanel.tsx +28 -14
- package/src/anyspend/react/components/common/RecipientSelection.tsx +20 -5
- package/src/anyspend/react/components/common/TabSection.tsx +21 -12
- package/src/anyspend/react/components/common/TransferCryptoDetails.tsx +12 -4
- package/src/anyspend/react/components/common/WarningText.tsx +10 -10
- package/src/anyspend/react/components/index.ts +16 -0
- package/src/anyspend/react/components/types/classes.ts +476 -0
- package/src/anyspend/react/hooks/index.ts +1 -0
- package/src/anyspend/react/hooks/useAnyspendFlow.ts +141 -17
- package/src/anyspend/react/hooks/useDirectTransfer.ts +67 -0
- package/src/anyspend/react/hooks/useRecipientAddressState.ts +1 -1
- package/src/anyspend/utils/format.ts +13 -2
- package/src/global-account/react/components/B3DynamicModal.tsx +0 -5
- package/src/global-account/react/components/B3Provider/B3ConfigProvider.tsx +0 -4
- package/src/global-account/react/components/B3Provider/B3Provider.native.tsx +1 -1
- package/src/global-account/react/components/B3Provider/B3Provider.tsx +1 -11
- package/src/global-account/react/components/B3Provider/LocalSDKProvider.tsx +0 -6
- package/src/global-account/react/components/B3Provider/RelayKitProviderWrapper.tsx +1 -4
- package/src/global-account/react/components/ManageAccount/SettingsContent.tsx +33 -1
- package/src/global-account/react/components/SignInWithB3/SignInWithB3Flow.tsx +27 -184
- package/src/global-account/react/components/index.ts +0 -3
- package/src/global-account/react/hooks/index.ts +0 -1
- package/src/global-account/react/hooks/useAuth.ts +14 -31
- package/src/global-account/react/hooks/useTWAuth.tsx +3 -5
- package/src/global-account/react/stores/useModalStore.ts +7 -20
- package/dist/cjs/global-account/react/components/TurnkeyAuthModal.d.ts +0 -8
- package/dist/cjs/global-account/react/components/TurnkeyAuthModal.js +0 -86
- package/dist/cjs/global-account/react/hooks/useTurnkeyAuth.d.ts +0 -20
- package/dist/cjs/global-account/react/hooks/useTurnkeyAuth.js +0 -142
- package/dist/esm/global-account/react/components/TurnkeyAuthModal.d.ts +0 -8
- package/dist/esm/global-account/react/components/TurnkeyAuthModal.js +0 -83
- package/dist/esm/global-account/react/hooks/useTurnkeyAuth.d.ts +0 -20
- package/dist/esm/global-account/react/hooks/useTurnkeyAuth.js +0 -136
- package/dist/types/global-account/react/components/TurnkeyAuthModal.d.ts +0 -8
- package/dist/types/global-account/react/hooks/useTurnkeyAuth.d.ts +0 -20
- package/src/global-account/react/components/TurnkeyAuthModal.tsx +0 -243
- package/src/global-account/react/hooks/useTurnkeyAuth.ts +0 -171
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { CryptoPaymentMethodType } from "../components/common/CryptoPaymentMethod";
|
|
2
|
+
interface DirectTransferParams {
|
|
3
|
+
chainId: number;
|
|
4
|
+
tokenAddress: string;
|
|
5
|
+
recipientAddress: string;
|
|
6
|
+
amount: bigint;
|
|
7
|
+
method: CryptoPaymentMethodType;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Hook for executing direct token transfers (same chain, same token)
|
|
11
|
+
* bypassing the swap backend.
|
|
12
|
+
*/
|
|
13
|
+
export declare function useDirectTransfer(): {
|
|
14
|
+
executeDirectTransfer: ({ chainId, tokenAddress, recipientAddress, amount, method, }: DirectTransferParams) => Promise<string | undefined>;
|
|
15
|
+
isTransferring: boolean;
|
|
16
|
+
};
|
|
17
|
+
export {};
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useDirectTransfer = useDirectTransfer;
|
|
4
|
+
const react_1 = require("../../../global-account/react");
|
|
5
|
+
const token_1 = require("../../../anyspend/utils/token");
|
|
6
|
+
const viem_1 = require("viem");
|
|
7
|
+
const react_2 = require("react");
|
|
8
|
+
const CryptoPaymentMethod_1 = require("../components/common/CryptoPaymentMethod");
|
|
9
|
+
/**
|
|
10
|
+
* Hook for executing direct token transfers (same chain, same token)
|
|
11
|
+
* bypassing the swap backend.
|
|
12
|
+
*/
|
|
13
|
+
function useDirectTransfer() {
|
|
14
|
+
const { switchChainAndExecute, switchChainAndExecuteWithEOA, isSwitchingOrExecuting } = (0, react_1.useUnifiedChainSwitchAndExecute)();
|
|
15
|
+
const executeDirectTransfer = (0, react_2.useCallback)(async ({ chainId, tokenAddress, recipientAddress, amount, method, }) => {
|
|
16
|
+
const isNative = (0, token_1.isNativeToken)(tokenAddress);
|
|
17
|
+
// Choose the correct execution function based on payment method
|
|
18
|
+
const execute = method === CryptoPaymentMethod_1.CryptoPaymentMethodType.CONNECT_WALLET ? switchChainAndExecuteWithEOA : switchChainAndExecute;
|
|
19
|
+
let txHash;
|
|
20
|
+
if (isNative) {
|
|
21
|
+
// Native token transfer (ETH, etc.)
|
|
22
|
+
txHash = await execute(chainId, {
|
|
23
|
+
to: recipientAddress,
|
|
24
|
+
value: amount,
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
else {
|
|
28
|
+
// ERC20 token transfer
|
|
29
|
+
const transferData = (0, viem_1.encodeFunctionData)({
|
|
30
|
+
abi: viem_1.erc20Abi,
|
|
31
|
+
functionName: "transfer",
|
|
32
|
+
args: [recipientAddress, amount],
|
|
33
|
+
});
|
|
34
|
+
txHash = await execute(chainId, {
|
|
35
|
+
to: tokenAddress,
|
|
36
|
+
data: transferData,
|
|
37
|
+
value: BigInt(0),
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
return txHash;
|
|
41
|
+
}, [switchChainAndExecute, switchChainAndExecuteWithEOA]);
|
|
42
|
+
return {
|
|
43
|
+
executeDirectTransfer,
|
|
44
|
+
isTransferring: isSwitchingOrExecuting,
|
|
45
|
+
};
|
|
46
|
+
}
|
|
@@ -38,7 +38,7 @@ function useRecipientAddressState({ recipientAddressFromProps, walletAddress, gl
|
|
|
38
38
|
// selectedRecipientAddress: explicitly selected by user (undefined means no explicit selection)
|
|
39
39
|
const [selectedRecipientAddress, setSelectedRecipientAddress] = (0, react_1.useState)(undefined);
|
|
40
40
|
// The effective recipient address, derived on each render, respecting priority.
|
|
41
|
-
const effectiveRecipientAddress =
|
|
41
|
+
const effectiveRecipientAddress = selectedRecipientAddress || recipientAddressFromProps || walletAddress || globalAddress;
|
|
42
42
|
// Helper function to reset user's manual selection.
|
|
43
43
|
const resetRecipientAddress = () => {
|
|
44
44
|
setSelectedRecipientAddress(undefined);
|
|
@@ -6,7 +6,11 @@ const getStatusDisplay = (order) => {
|
|
|
6
6
|
const srcToken = order.metadata?.srcToken;
|
|
7
7
|
const dstToken = order.metadata?.dstToken;
|
|
8
8
|
const formattedSrcAmount = srcToken ? (0, number_1.formatTokenAmount)(BigInt(order.srcAmount), srcToken.decimals) : undefined;
|
|
9
|
-
|
|
9
|
+
// For custom orders, use payload.amount as fallback if actualDstAmount is not available
|
|
10
|
+
const actualDstAmount = order.settlement?.actualDstAmount ||
|
|
11
|
+
(order.type === "custom" || order.type === "custom_exact_in" || order.type === "deposit_first"
|
|
12
|
+
? order.payload.amount?.toString()
|
|
13
|
+
: undefined);
|
|
10
14
|
const formattedActualDstAmount = actualDstAmount && dstToken ? (0, number_1.formatTokenAmount)(BigInt(actualDstAmount), dstToken.decimals) : undefined;
|
|
11
15
|
switch (order.status) {
|
|
12
16
|
case "scanning_deposit_transaction": {
|
|
@@ -43,6 +47,7 @@ const getStatusDisplay = (order) => {
|
|
|
43
47
|
};
|
|
44
48
|
case "executed": {
|
|
45
49
|
const receivedText = formattedActualDstAmount && dstToken ? `Received ${formattedActualDstAmount} ${dstToken.symbol}` : undefined;
|
|
50
|
+
const actionText = order.metadata?.action || "Order";
|
|
46
51
|
const { text, description } = order.type === "swap"
|
|
47
52
|
? { text: receivedText || "Swap Complete", description: "Your swap has been completed successfully." }
|
|
48
53
|
: order.type === "mint_nft"
|
|
@@ -51,7 +56,12 @@ const getStatusDisplay = (order) => {
|
|
|
51
56
|
? { text: "Tournament Joined", description: "You have joined the tournament" }
|
|
52
57
|
: order.type === "fund_tournament"
|
|
53
58
|
? { text: "Tournament Funded", description: "You have funded the tournament" }
|
|
54
|
-
:
|
|
59
|
+
: order.type === "custom" || order.type === "custom_exact_in"
|
|
60
|
+
? {
|
|
61
|
+
text: receivedText || `${actionText} Complete`,
|
|
62
|
+
description: "Your order has been completed successfully.",
|
|
63
|
+
}
|
|
64
|
+
: { text: receivedText || "Order Complete", description: "Your order has been completed" };
|
|
55
65
|
return { text, status: "success", description };
|
|
56
66
|
}
|
|
57
67
|
case "refunding":
|
|
@@ -25,7 +25,6 @@ const RequestPermissions_1 = require("./RequestPermissions/RequestPermissions");
|
|
|
25
25
|
const Send_1 = require("./Send/Send");
|
|
26
26
|
const SignInWithB3Flow_1 = require("./SignInWithB3/SignInWithB3Flow");
|
|
27
27
|
const index_1 = require("./Toast/index");
|
|
28
|
-
const TurnkeyAuthModal_1 = require("./TurnkeyAuthModal");
|
|
29
28
|
const dialog_1 = require("./ui/dialog");
|
|
30
29
|
const drawer_1 = require("./ui/drawer");
|
|
31
30
|
const debug = (0, debug_1.debugB3React)("B3DynamicModal");
|
|
@@ -50,7 +49,6 @@ function B3DynamicModal() {
|
|
|
50
49
|
"anySpendBuySpin",
|
|
51
50
|
"anySpendOrderHistory",
|
|
52
51
|
"signInWithB3",
|
|
53
|
-
"turnkeyAuth",
|
|
54
52
|
"anySpendSignatureMint",
|
|
55
53
|
"anySpendBondKit",
|
|
56
54
|
"linkAccount",
|
|
@@ -80,7 +78,7 @@ function B3DynamicModal() {
|
|
|
80
78
|
const hideCloseButton = true;
|
|
81
79
|
// Build content class using cn utility
|
|
82
80
|
// eslint-disable-next-line tailwindcss/no-custom-classname
|
|
83
|
-
const contentClass = (0, cn_1.cn)("b3-modal", theme === "dark" && "dark", fullWidthTypes.includes(contentType?.type) && "w-full", isFreestyleType && "b3-modal-freestyle", contentType?.type === "signInWithB3" && "p-0", contentType?.type === "
|
|
81
|
+
const contentClass = (0, cn_1.cn)("b3-modal", theme === "dark" && "dark", fullWidthTypes.includes(contentType?.type) && "w-full", isFreestyleType && "b3-modal-freestyle", contentType?.type === "signInWithB3" && "p-0", contentType?.type === "anySpend" && "md:p-0", contentType?.type === "send" && "p-0", contentType?.type === "manageAccount" && " md:p-0 md:pt-2", contentType?.type === "linkAccount" && "md:p-0");
|
|
84
82
|
debug("contentType", contentType);
|
|
85
83
|
const renderContent = () => {
|
|
86
84
|
if (!contentType)
|
|
@@ -88,8 +86,6 @@ function B3DynamicModal() {
|
|
|
88
86
|
switch (contentType.type) {
|
|
89
87
|
case "signInWithB3":
|
|
90
88
|
return (0, jsx_runtime_1.jsx)(SignInWithB3Flow_1.SignInWithB3Flow, { ...contentType });
|
|
91
|
-
case "turnkeyAuth":
|
|
92
|
-
return (0, jsx_runtime_1.jsx)(TurnkeyAuthModal_1.TurnkeyAuthModal, { ...contentType });
|
|
93
89
|
case "requestPermissions":
|
|
94
90
|
return (0, jsx_runtime_1.jsx)(RequestPermissions_1.RequestPermissions, { ...contentType });
|
|
95
91
|
case "manageAccount":
|
|
@@ -13,9 +13,8 @@ export interface B3ConfigContextType {
|
|
|
13
13
|
partnerId: string;
|
|
14
14
|
stripePublishableKey?: string;
|
|
15
15
|
createClientReferenceId?: (params: CreateOrderParams | CreateOnrampOrderParams) => Promise<string>;
|
|
16
|
-
enableTurnkey: boolean;
|
|
17
16
|
}
|
|
18
|
-
export declare function B3ConfigProvider({ children, accountOverride, environment, defaultPermissions, automaticallySetFirstEoa, theme, clientType, partnerId, stripePublishableKey, createClientReferenceId,
|
|
17
|
+
export declare function B3ConfigProvider({ children, accountOverride, environment, defaultPermissions, automaticallySetFirstEoa, theme, clientType, partnerId, stripePublishableKey, createClientReferenceId, }: {
|
|
19
18
|
children: React.ReactNode;
|
|
20
19
|
accountOverride?: Account;
|
|
21
20
|
environment?: "development" | "production";
|
|
@@ -26,6 +25,5 @@ export declare function B3ConfigProvider({ children, accountOverride, environmen
|
|
|
26
25
|
partnerId: string;
|
|
27
26
|
stripePublishableKey?: string;
|
|
28
27
|
createClientReferenceId?: (params: CreateOrderParams | CreateOnrampOrderParams) => Promise<string>;
|
|
29
|
-
enableTurnkey?: boolean;
|
|
30
28
|
}): import("react/jsx-runtime").JSX.Element;
|
|
31
29
|
export declare function useB3Config(): B3ConfigContextType;
|
|
@@ -14,7 +14,7 @@ const DEFAULT_PERMISSIONS = {
|
|
|
14
14
|
endDate: new Date(Date.now() + 1000 * 60 * 60 * 24 * 365), // 1 year from now
|
|
15
15
|
};
|
|
16
16
|
const B3ConfigContext = (0, react_1.createContext)(null);
|
|
17
|
-
function B3ConfigProvider({ children, accountOverride, environment = "development", defaultPermissions = DEFAULT_PERMISSIONS, automaticallySetFirstEoa = false, theme = "light", clientType = "rest", partnerId, stripePublishableKey, createClientReferenceId,
|
|
17
|
+
function B3ConfigProvider({ children, accountOverride, environment = "development", defaultPermissions = DEFAULT_PERMISSIONS, automaticallySetFirstEoa = false, theme = "light", clientType = "rest", partnerId, stripePublishableKey, createClientReferenceId, }) {
|
|
18
18
|
return ((0, jsx_runtime_1.jsx)(B3ConfigContext.Provider, { value: {
|
|
19
19
|
accountOverride,
|
|
20
20
|
environment,
|
|
@@ -25,7 +25,6 @@ function B3ConfigProvider({ children, accountOverride, environment = "developmen
|
|
|
25
25
|
partnerId,
|
|
26
26
|
stripePublishableKey,
|
|
27
27
|
createClientReferenceId,
|
|
28
|
-
enableTurnkey,
|
|
29
28
|
}, children: children }));
|
|
30
29
|
}
|
|
31
30
|
function useB3Config() {
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { Users } from "@b3dotfun/b3-api";
|
|
2
1
|
import { CreateOnrampOrderParams } from "../../../../anyspend/react/hooks/useAnyspendCreateOnrampOrder";
|
|
3
2
|
import { CreateOrderParams } from "../../../../anyspend/react/hooks/useAnyspendCreateOrder";
|
|
4
3
|
import { PermissionsConfig } from "../../../../global-account/types/permissions";
|
|
@@ -9,7 +8,7 @@ import { ClientType } from "../../../client-manager";
|
|
|
9
8
|
/**
|
|
10
9
|
* Main B3Provider component
|
|
11
10
|
*/
|
|
12
|
-
export declare function B3Provider({ theme, children, accountOverride, environment, automaticallySetFirstEoa, simDuneApiKey, toaster: _toaster, clientType, rpcUrls, partnerId, stripePublishableKey, onConnect, onLogout, connectors, overrideDefaultConnectors, createClientReferenceId,
|
|
11
|
+
export declare function B3Provider({ theme, children, accountOverride, environment, automaticallySetFirstEoa, simDuneApiKey, toaster: _toaster, clientType, rpcUrls, partnerId, stripePublishableKey, onConnect, onLogout, connectors, overrideDefaultConnectors, createClientReferenceId, defaultPermissions, }: {
|
|
13
12
|
theme: "light" | "dark";
|
|
14
13
|
children: React.ReactNode;
|
|
15
14
|
accountOverride?: Account;
|
|
@@ -30,7 +29,5 @@ export declare function B3Provider({ theme, children, accountOverride, environme
|
|
|
30
29
|
connectors?: CreateConnectorFn[];
|
|
31
30
|
overrideDefaultConnectors?: boolean;
|
|
32
31
|
createClientReferenceId?: (params: CreateOrderParams | CreateOnrampOrderParams) => Promise<string>;
|
|
33
|
-
enableTurnkey?: boolean;
|
|
34
32
|
defaultPermissions?: PermissionsConfig;
|
|
35
|
-
onTurnkeyConnect?: (user: Users) => void | Promise<void>;
|
|
36
33
|
}): import("react/jsx-runtime").JSX.Element;
|
|
@@ -26,7 +26,7 @@ const queryClient = new react_query_1.QueryClient();
|
|
|
26
26
|
*/
|
|
27
27
|
function B3Provider({ theme = "light", children, accountOverride, environment, automaticallySetFirstEoa, simDuneApiKey,
|
|
28
28
|
// deprecated since v0.0.87
|
|
29
|
-
toaster: _toaster, clientType = "rest", rpcUrls, partnerId, stripePublishableKey, onConnect, onLogout, connectors, overrideDefaultConnectors = false, createClientReferenceId,
|
|
29
|
+
toaster: _toaster, clientType = "rest", rpcUrls, partnerId, stripePublishableKey, onConnect, onLogout, connectors, overrideDefaultConnectors = false, createClientReferenceId, defaultPermissions, }) {
|
|
30
30
|
// Initialize Google Analytics on mount
|
|
31
31
|
(0, react_2.useEffect)(() => {
|
|
32
32
|
(0, analytics_1.loadGA4Script)();
|
|
@@ -36,7 +36,7 @@ toaster: _toaster, clientType = "rest", rpcUrls, partnerId, stripePublishableKey
|
|
|
36
36
|
(0, client_manager_1.setClientType)(clientType);
|
|
37
37
|
}, [clientType]);
|
|
38
38
|
const wagmiConfig = (0, react_2.useMemo)(() => (0, createWagmiConfig_1.createWagmiConfig)({ partnerId, rpcUrls, connectors, overrideDefaultConnectors }), [partnerId, rpcUrls, connectors, overrideDefaultConnectors]);
|
|
39
|
-
return ((0, jsx_runtime_1.jsx)(react_3.ThirdwebProvider, { children: (0, jsx_runtime_1.jsx)(wagmi_1.WagmiProvider, { config: wagmiConfig, reconnectOnMount: false, children: (0, jsx_runtime_1.jsx)(react_query_1.QueryClientProvider, { client: queryClient, children: (0, jsx_runtime_1.jsx)(react_1.TooltipProvider, { children: (0, jsx_runtime_1.jsx)(index_1.ToastProvider, { children: (0, jsx_runtime_1.jsx)(LocalSDKProvider_1.LocalSDKProvider, { onConnectCallback: onConnect, onLogoutCallback: onLogout,
|
|
39
|
+
return ((0, jsx_runtime_1.jsx)(react_3.ThirdwebProvider, { children: (0, jsx_runtime_1.jsx)(wagmi_1.WagmiProvider, { config: wagmiConfig, reconnectOnMount: false, children: (0, jsx_runtime_1.jsx)(react_query_1.QueryClientProvider, { client: queryClient, children: (0, jsx_runtime_1.jsx)(react_1.TooltipProvider, { children: (0, jsx_runtime_1.jsx)(index_1.ToastProvider, { children: (0, jsx_runtime_1.jsx)(LocalSDKProvider_1.LocalSDKProvider, { onConnectCallback: onConnect, onLogoutCallback: onLogout, children: (0, jsx_runtime_1.jsxs)(B3ConfigProvider_1.B3ConfigProvider, { accountOverride: accountOverride, environment: environment, automaticallySetFirstEoa: !!automaticallySetFirstEoa, theme: theme, clientType: clientType, partnerId: partnerId, stripePublishableKey: stripePublishableKey, createClientReferenceId: createClientReferenceId, defaultPermissions: defaultPermissions, children: [(0, jsx_runtime_1.jsx)(ToastContextConnector, {}), (0, jsx_runtime_1.jsxs)(react_1.RelayKitProviderWrapper, { simDuneApiKey: simDuneApiKey, children: [children, (0, jsx_runtime_1.jsx)(StyleRoot_1.StyleRoot, { id: "b3-root" })] }), (0, jsx_runtime_1.jsx)(AuthenticationProvider_1.default, { partnerId: partnerId, automaticallySetFirstEoa: !!automaticallySetFirstEoa })] }) }) }) }) }) }) }));
|
|
40
40
|
}
|
|
41
41
|
/**
|
|
42
42
|
* Component to connect the toast context to the global toast API
|
|
@@ -4,7 +4,7 @@ import { ClientType } from "../../../client-manager";
|
|
|
4
4
|
/**
|
|
5
5
|
* Main B3Provider component
|
|
6
6
|
*/
|
|
7
|
-
export declare function B3Provider({ theme, children, accountOverride, environment, clientType, partnerId, rpcUrls, onConnect, defaultPermissions, }: {
|
|
7
|
+
export declare function B3Provider({ theme, children, accountOverride, environment, clientType, partnerId, rpcUrls: _rpcUrls, onConnect, defaultPermissions, }: {
|
|
8
8
|
theme: "light" | "dark";
|
|
9
9
|
children: React.ReactNode;
|
|
10
10
|
accountOverride?: Account;
|
|
@@ -18,7 +18,7 @@ const queryClient = new react_query_1.QueryClient();
|
|
|
18
18
|
/**
|
|
19
19
|
* Main B3Provider component
|
|
20
20
|
*/
|
|
21
|
-
function B3Provider({ theme = "light", children, accountOverride, environment, clientType = "socket", partnerId, rpcUrls, onConnect, defaultPermissions, }) {
|
|
21
|
+
function B3Provider({ theme = "light", children, accountOverride, environment, clientType = "socket", partnerId, rpcUrls: _rpcUrls, onConnect, defaultPermissions, }) {
|
|
22
22
|
return ((0, jsx_runtime_1.jsx)(react_1.ThirdwebProvider, { children: (0, jsx_runtime_1.jsx)(LocalSDKProvider_1.LocalSDKProvider, { onConnectCallback: onConnect, children: (0, jsx_runtime_1.jsxs)(B3ConfigProvider_1.B3ConfigProvider, { accountOverride: accountOverride, environment: environment, automaticallySetFirstEoa: false, theme: theme, clientType: clientType, partnerId: partnerId, defaultPermissions: defaultPermissions, children: [children, (0, jsx_runtime_1.jsx)(AuthenticationProvider_1.default, { partnerId: partnerId, automaticallySetFirstEoa: false })] }) }) }));
|
|
23
23
|
}
|
|
24
24
|
/**
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { Users } from "@b3dotfun/b3-api";
|
|
2
1
|
import { Wallet } from "thirdweb/wallets";
|
|
3
2
|
/**
|
|
4
3
|
* Local SDK Context for internal SDK state (like authentication callbacks)
|
|
@@ -7,15 +6,13 @@ import { Wallet } from "thirdweb/wallets";
|
|
|
7
6
|
export interface LocalSDKContextType {
|
|
8
7
|
onConnectCallback?: (wallet: Wallet, b3Jwt: string) => void | Promise<void>;
|
|
9
8
|
onLogoutCallback?: () => void | Promise<void>;
|
|
10
|
-
onTurnkeyConnect?: (user: Users) => void | Promise<void>;
|
|
11
9
|
}
|
|
12
10
|
export declare const LocalSDKContext: import("react").Context<LocalSDKContextType>;
|
|
13
11
|
/**
|
|
14
12
|
* Local SDK Provider that wraps the app and provides internal SDK state
|
|
15
13
|
*/
|
|
16
|
-
export declare function LocalSDKProvider({ children, onConnectCallback, onLogoutCallback,
|
|
14
|
+
export declare function LocalSDKProvider({ children, onConnectCallback, onLogoutCallback, }: {
|
|
17
15
|
children: React.ReactNode;
|
|
18
16
|
onConnectCallback?: (wallet: Wallet, b3Jwt: string) => void | Promise<void>;
|
|
19
17
|
onLogoutCallback?: () => void | Promise<void>;
|
|
20
|
-
onTurnkeyConnect?: (user: Users) => void | Promise<void>;
|
|
21
18
|
}): import("react/jsx-runtime").JSX.Element;
|
|
@@ -7,15 +7,13 @@ const react_1 = require("react");
|
|
|
7
7
|
exports.LocalSDKContext = (0, react_1.createContext)({
|
|
8
8
|
onConnectCallback: undefined,
|
|
9
9
|
onLogoutCallback: undefined,
|
|
10
|
-
onTurnkeyConnect: undefined,
|
|
11
10
|
});
|
|
12
11
|
/**
|
|
13
12
|
* Local SDK Provider that wraps the app and provides internal SDK state
|
|
14
13
|
*/
|
|
15
|
-
function LocalSDKProvider({ children, onConnectCallback, onLogoutCallback,
|
|
14
|
+
function LocalSDKProvider({ children, onConnectCallback, onLogoutCallback, }) {
|
|
16
15
|
return ((0, jsx_runtime_1.jsx)(exports.LocalSDKContext.Provider, { value: {
|
|
17
16
|
onConnectCallback,
|
|
18
17
|
onLogoutCallback,
|
|
19
|
-
onTurnkeyConnect,
|
|
20
18
|
}, children: children }));
|
|
21
19
|
}
|
|
@@ -14,8 +14,6 @@ function RelayKitProviderWrapper({ children, simDuneApiKey, }) {
|
|
|
14
14
|
};
|
|
15
15
|
fetchChains();
|
|
16
16
|
}, []);
|
|
17
|
-
const isTurnkeyPrimary = process.env.NEXT_PUBLIC_TURNKEY_PRIMARY === "true";
|
|
18
|
-
const appName = isTurnkeyPrimary ? "Smart Wallet" : "AnySpend";
|
|
19
17
|
return ((0, jsx_runtime_1.jsx)(relay_kit_ui_1.RelayKitProvider, { options: {
|
|
20
18
|
baseApiUrl: relay_sdk_1.MAINNET_RELAY_API,
|
|
21
19
|
source: "anyspend",
|
|
@@ -25,7 +23,7 @@ function RelayKitProviderWrapper({ children, simDuneApiKey, }) {
|
|
|
25
23
|
},
|
|
26
24
|
chains: relayChains,
|
|
27
25
|
privateChainIds: undefined,
|
|
28
|
-
appName,
|
|
26
|
+
appName: "AnySpend",
|
|
29
27
|
useGasFeeEstimations: true,
|
|
30
28
|
}, children: (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: children }) }));
|
|
31
29
|
}
|
|
@@ -6,14 +6,19 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
7
7
|
const react_1 = require("../../../../global-account/react");
|
|
8
8
|
const thirdweb_1 = require("../../../../shared/utils/thirdweb");
|
|
9
|
-
const
|
|
9
|
+
const lucide_react_1 = require("lucide-react");
|
|
10
|
+
const react_2 = require("react");
|
|
11
|
+
const react_3 = require("thirdweb/react");
|
|
12
|
+
const SignOutIcon_1 = __importDefault(require("../icons/SignOutIcon"));
|
|
10
13
|
const ModalHeader_1 = __importDefault(require("../ModalHeader/ModalHeader"));
|
|
11
14
|
const SettingsMenuItem_1 = __importDefault(require("./SettingsMenuItem"));
|
|
12
15
|
const SettingsProfileCard_1 = __importDefault(require("./SettingsProfileCard"));
|
|
13
16
|
const SettingsContent = ({ partnerId, onLogout, chain, }) => {
|
|
14
17
|
const setB3ModalContentType = (0, react_1.useModalStore)(state => state.setB3ModalContentType);
|
|
15
18
|
const setB3ModalOpen = (0, react_1.useModalStore)(state => state.setB3ModalOpen);
|
|
16
|
-
const {
|
|
19
|
+
const { logout } = (0, react_1.useAuthentication)(partnerId);
|
|
20
|
+
const [logoutLoading, setLogoutLoading] = (0, react_2.useState)(false);
|
|
21
|
+
const { data: profilesRaw = [] } = (0, react_3.useProfiles)({ client: thirdweb_1.client });
|
|
17
22
|
const profiles = profilesRaw.filter((profile) => !["custom_auth_endpoint"].includes(profile.type));
|
|
18
23
|
const handleNavigate = (type) => {
|
|
19
24
|
if (type === "home") {
|
|
@@ -55,6 +60,15 @@ const SettingsContent = ({ partnerId, onLogout, chain, }) => {
|
|
|
55
60
|
}
|
|
56
61
|
setB3ModalOpen(true);
|
|
57
62
|
};
|
|
58
|
-
|
|
63
|
+
const onLogoutEnhanced = async () => {
|
|
64
|
+
setLogoutLoading(true);
|
|
65
|
+
await logout();
|
|
66
|
+
onLogout?.();
|
|
67
|
+
setB3ModalOpen(false);
|
|
68
|
+
setLogoutLoading(false);
|
|
69
|
+
};
|
|
70
|
+
return ((0, jsx_runtime_1.jsxs)("div", { className: "flex h-[470px] flex-col", children: [(0, jsx_runtime_1.jsx)(ModalHeader_1.default, { showBackButton: false, showCloseButton: false, title: "Settings" }), (0, jsx_runtime_1.jsx)("div", { className: "p-5", children: (0, jsx_runtime_1.jsx)("div", { className: "b3-modal-settings-profile-card dark:border-b3-line dark:bg-b3-background flex items-center rounded-xl border border-[#e4e4e7] bg-[#f4f4f5] p-4", children: (0, jsx_runtime_1.jsx)(SettingsProfileCard_1.default, {}) }) }), (0, jsx_runtime_1.jsxs)("div", { className: "space-y-3 px-5", children: [(0, jsx_runtime_1.jsx)(SettingsMenuItem_1.default, { icon: (0, jsx_runtime_1.jsx)("svg", { width: "40", height: "40", viewBox: "0 0 40 40", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: (0, jsx_runtime_1.jsx)("path", { d: "M0 12C0 5.37258 5.37258 0 12 0H28C34.6274 0 40 5.37258 40 12V28C40 34.6274 34.6274 40 28 40H12C5.37258 40 0 34.6274 0 28V12Z", fill: "#F4F4F5" }) }), title: "Linked Accounts", subtitle: `${profiles.length} connected account${profiles.length > 1 ? "s" : ""}`, onClick: () => handleNavigate("linkAccount") }), (0, jsx_runtime_1.jsx)(SettingsMenuItem_1.default, { icon: (0, jsx_runtime_1.jsx)("svg", { width: "40", height: "40", viewBox: "0 0 40 40", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: (0, jsx_runtime_1.jsx)("path", { d: "M0 12C0 5.37258 5.37258 0 12 0H28C34.6274 0 40 5.37258 40 12V28C40 34.6274 34.6274 40 28 40H12C5.37258 40 0 34.6274 0 28V12Z", fill: "#F4F4F5" }) }), title: "Notifications", subtitle: "Manage your notifications", onClick: () => handleNavigate("notifications") })] }), (0, jsx_runtime_1.jsx)("div", { className: "mt-auto px-5 pb-5", children: (0, jsx_runtime_1.jsxs)("button", { className: "b3-modal-sign-out-button border-b3-line hover:bg-b3-line bg-b3-background dark:bg-b3-background dark:border-b3-line dark:hover:bg-b3-line/80 flex w-full items-center justify-center gap-1.5 rounded-xl border border-solid p-3 transition-colors", onClick: onLogoutEnhanced, disabled: logoutLoading, style: {
|
|
71
|
+
boxShadow: "inset 0px 0px 0px 1px rgba(10,13,18,0.18), inset 0px -2px 0px 0px rgba(10,13,18,0.05)",
|
|
72
|
+
}, children: [logoutLoading ? ((0, jsx_runtime_1.jsx)(lucide_react_1.Loader2, { className: "text-b3-grey animate-spin", size: 20 })) : ((0, jsx_runtime_1.jsx)(SignOutIcon_1.default, { size: 20, className: "text-b3-grey", color: "currentColor" })), (0, jsx_runtime_1.jsx)("p", { className: "text-b3-grey dark:text-b3-foreground-muted font-neue-montreal-semibold text-base", children: "Sign out" })] }) })] }));
|
|
59
73
|
};
|
|
60
74
|
exports.default = SettingsContent;
|
|
@@ -6,8 +6,6 @@ const react_1 = require("../../../../global-account/react");
|
|
|
6
6
|
const debug_1 = require("../../../../shared/utils/debug");
|
|
7
7
|
const react_2 = require("react");
|
|
8
8
|
const react_3 = require("thirdweb/react");
|
|
9
|
-
const LocalSDKProvider_1 = require("../B3Provider/LocalSDKProvider");
|
|
10
|
-
const TurnkeyAuthModal_1 = require("../TurnkeyAuthModal");
|
|
11
9
|
const SignInWithB3Privy_1 = require("./SignInWithB3Privy");
|
|
12
10
|
const LoginStep_1 = require("./steps/LoginStep");
|
|
13
11
|
const LoginStepCustom_1 = require("./steps/LoginStepCustom");
|
|
@@ -18,9 +16,8 @@ const MAX_REFETCH_ATTEMPTS = 20;
|
|
|
18
16
|
* Handles different login providers, authentication steps, and session key management
|
|
19
17
|
*/
|
|
20
18
|
function SignInWithB3Flow({ strategies, onLoginSuccess, onSessionKeySuccess, onError, chain, sessionKeyAddress, partnerId, closeAfterLogin = false, source = "signInWithB3Button", signersEnabled = false, }) {
|
|
21
|
-
const { automaticallySetFirstEoa
|
|
22
|
-
const { user,
|
|
23
|
-
const { onTurnkeyConnect } = (0, react_2.useContext)(LocalSDKProvider_1.LocalSDKContext);
|
|
19
|
+
const { automaticallySetFirstEoa } = (0, react_1.useB3Config)();
|
|
20
|
+
const { user, logout } = (0, react_1.useAuthentication)(partnerId);
|
|
24
21
|
// FIXME Logout before login to ensure a clean state
|
|
25
22
|
const hasLoggedOutRef = (0, react_2.useRef)(false);
|
|
26
23
|
(0, react_2.useEffect)(() => {
|
|
@@ -38,13 +35,10 @@ function SignInWithB3Flow({ strategies, onLoginSuccess, onSessionKeySuccess, onE
|
|
|
38
35
|
const account = (0, react_3.useActiveAccount)();
|
|
39
36
|
const isAuthenticating = (0, react_1.useAuthStore)(state => state.isAuthenticating);
|
|
40
37
|
const isAuthenticated = (0, react_1.useAuthStore)(state => state.isAuthenticated);
|
|
41
|
-
const setIsAuthenticated = (0, react_1.useAuthStore)(state => state.setIsAuthenticated);
|
|
42
38
|
const isConnected = (0, react_1.useAuthStore)(state => state.isConnected);
|
|
43
|
-
const setIsConnected = (0, react_1.useAuthStore)(state => state.setIsConnected);
|
|
44
39
|
const setJustCompletedLogin = (0, react_1.useAuthStore)(state => state.setJustCompletedLogin);
|
|
45
40
|
const [refetchCount, setRefetchCount] = (0, react_2.useState)(0);
|
|
46
41
|
const [refetchError, setRefetchError] = (0, react_2.useState)(null);
|
|
47
|
-
const [turnkeyAuthCompleted, setTurnkeyAuthCompleted] = (0, react_2.useState)(false);
|
|
48
42
|
const { data: signers, refetch: refetchSigners, isFetching: isFetchingSigners, } = (0, react_1.useGetAllTWSigners)({
|
|
49
43
|
chain,
|
|
50
44
|
accountAddress: account?.address,
|
|
@@ -77,8 +71,8 @@ function SignInWithB3Flow({ strategies, onLoginSuccess, onSessionKeySuccess, onE
|
|
|
77
71
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
78
72
|
}, [refetchCount, refetchSigners, onError, refetchQueued]);
|
|
79
73
|
// Extract the completion flow logic to be reused
|
|
80
|
-
const
|
|
81
|
-
debug("Running post-
|
|
74
|
+
const handlePostAuthFlow = (0, react_2.useCallback)(() => {
|
|
75
|
+
debug("Running post-authentication flow logic");
|
|
82
76
|
// Check if we already have a signer for this partner
|
|
83
77
|
const hasExistingSigner = signers?.some(signer => signer.partner.id === partnerId);
|
|
84
78
|
if (hasExistingSigner) {
|
|
@@ -135,56 +129,6 @@ function SignInWithB3Flow({ strategies, onLoginSuccess, onSessionKeySuccess, onE
|
|
|
135
129
|
handleRefetchSigners,
|
|
136
130
|
setSessionKeyAdded,
|
|
137
131
|
]);
|
|
138
|
-
// Define handleTurnkeySuccess before the useEffect that uses it
|
|
139
|
-
const handleTurnkeySuccess = (0, react_2.useCallback)(async (user) => {
|
|
140
|
-
debug("Turnkey authentication successful - setting completed flag", { user, onTurnkeyConnect });
|
|
141
|
-
// Call the onTurnkeyConnect callback
|
|
142
|
-
onTurnkeyConnect?.(user);
|
|
143
|
-
// Set completed flag FIRST before any async operations
|
|
144
|
-
setTurnkeyAuthCompleted(true);
|
|
145
|
-
// Refetch user to update the user state with Turnkey ID
|
|
146
|
-
debug("Refetching user after Turnkey success...");
|
|
147
|
-
// TODO: See why sometimes this fails with "No wallet found during auto-connect"
|
|
148
|
-
await refetchUser();
|
|
149
|
-
debug("User refetched successfully");
|
|
150
|
-
// Set authentication and connection state so UI updates properly
|
|
151
|
-
setIsAuthenticated(true);
|
|
152
|
-
setIsConnected(true);
|
|
153
|
-
setJustCompletedLogin(true);
|
|
154
|
-
// After user data is refreshed, close Turnkey modal and go back to sign-in flow
|
|
155
|
-
debug("Switching back to signInWithB3 modal");
|
|
156
|
-
setB3ModalContentType({
|
|
157
|
-
type: "signInWithB3",
|
|
158
|
-
strategies,
|
|
159
|
-
onLoginSuccess,
|
|
160
|
-
onSessionKeySuccess,
|
|
161
|
-
onError,
|
|
162
|
-
chain,
|
|
163
|
-
sessionKeyAddress,
|
|
164
|
-
partnerId,
|
|
165
|
-
closeAfterLogin,
|
|
166
|
-
source,
|
|
167
|
-
signersEnabled,
|
|
168
|
-
});
|
|
169
|
-
// The useEffect will re-run with updated user data to complete the sign-in process
|
|
170
|
-
}, [
|
|
171
|
-
onTurnkeyConnect,
|
|
172
|
-
refetchUser,
|
|
173
|
-
strategies,
|
|
174
|
-
onLoginSuccess,
|
|
175
|
-
onSessionKeySuccess,
|
|
176
|
-
onError,
|
|
177
|
-
chain,
|
|
178
|
-
sessionKeyAddress,
|
|
179
|
-
partnerId,
|
|
180
|
-
closeAfterLogin,
|
|
181
|
-
source,
|
|
182
|
-
signersEnabled,
|
|
183
|
-
setB3ModalContentType,
|
|
184
|
-
setIsAuthenticated,
|
|
185
|
-
setIsConnected,
|
|
186
|
-
setJustCompletedLogin,
|
|
187
|
-
]);
|
|
188
132
|
// Handle post-login flow after signers are loaded
|
|
189
133
|
(0, react_2.useEffect)(() => {
|
|
190
134
|
debug("@@SignInWithB3Flow:useEffect", {
|
|
@@ -197,49 +141,11 @@ function SignInWithB3Flow({ strategies, onLoginSuccess, onSessionKeySuccess, onE
|
|
|
197
141
|
});
|
|
198
142
|
if (isConnected && isAuthenticated && user) {
|
|
199
143
|
// Mark that login just completed BEFORE opening manage account or closing modal
|
|
200
|
-
// This allows Turnkey modal to show (if enableTurnkey is true)
|
|
201
144
|
if (closeAfterLogin) {
|
|
202
145
|
setJustCompletedLogin(true);
|
|
203
146
|
}
|
|
204
|
-
//
|
|
205
|
-
|
|
206
|
-
// - enableTurnkey={true} is set on B3Provider
|
|
207
|
-
// - NEXT_PUBLIC_TURNKEY_PRIMARY is NOT set to true (otherwise Turnkey shows as primary)
|
|
208
|
-
// - User just logged in AND hasn't completed Turnkey auth in this session
|
|
209
|
-
// For new users (!turnkeyId): Show email form
|
|
210
|
-
// For returning users (turnkeyId && turnkeyEmail): Auto-skip to OTP
|
|
211
|
-
// Also check that we're not already showing the Turnkey modal
|
|
212
|
-
const hasTurnkeyId = user?.partnerIds?.turnkeyId;
|
|
213
|
-
const hasTurnkeyEmail = !!user?.email;
|
|
214
|
-
const isTurnkeyModalCurrentlyOpen = contentType?.type === "turnkeyAuth";
|
|
215
|
-
const isTurnkeyPrimary = process.env.NEXT_PUBLIC_TURNKEY_PRIMARY === "true";
|
|
216
|
-
const shouldShowTurnkeyModal = enableTurnkey &&
|
|
217
|
-
!isTurnkeyPrimary &&
|
|
218
|
-
user &&
|
|
219
|
-
!turnkeyAuthCompleted &&
|
|
220
|
-
!isTurnkeyModalCurrentlyOpen &&
|
|
221
|
-
(!hasTurnkeyId || (hasTurnkeyId && hasTurnkeyEmail));
|
|
222
|
-
if (shouldShowTurnkeyModal) {
|
|
223
|
-
// Extract email from user object - check partnerIds.turnkeyEmail first, then twProfiles, then user.email
|
|
224
|
-
const email = user?.email || user?.twProfiles?.find((profile) => profile.details?.email)?.details?.email;
|
|
225
|
-
// Open Turnkey modal through the modal store
|
|
226
|
-
setB3ModalContentType({
|
|
227
|
-
type: "turnkeyAuth",
|
|
228
|
-
onSuccess: handleTurnkeySuccess,
|
|
229
|
-
onClose: () => {
|
|
230
|
-
// After closing Turnkey modal, continue with the rest of the flow
|
|
231
|
-
setTurnkeyAuthCompleted(true);
|
|
232
|
-
debug("Turnkey modal closed, running post-Turnkey flow");
|
|
233
|
-
handlePostTurnkeyFlow();
|
|
234
|
-
},
|
|
235
|
-
initialEmail: email,
|
|
236
|
-
skipToOtp: !!(hasTurnkeyId && hasTurnkeyEmail),
|
|
237
|
-
closable: false, // Turnkey modal cannot be closed until auth is complete
|
|
238
|
-
});
|
|
239
|
-
return;
|
|
240
|
-
}
|
|
241
|
-
// Normal flow continues after Turnkey auth is complete (or if not needed)
|
|
242
|
-
handlePostTurnkeyFlow();
|
|
147
|
+
// Normal flow continues
|
|
148
|
+
handlePostAuthFlow();
|
|
243
149
|
}
|
|
244
150
|
},
|
|
245
151
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
@@ -260,11 +166,8 @@ function SignInWithB3Flow({ strategies, onLoginSuccess, onSessionKeySuccess, onE
|
|
|
260
166
|
isAuthenticated,
|
|
261
167
|
isOpen,
|
|
262
168
|
user,
|
|
263
|
-
enableTurnkey,
|
|
264
|
-
turnkeyAuthCompleted,
|
|
265
|
-
// handleTurnkeySuccess, // This is causing infinite loops
|
|
266
169
|
contentType,
|
|
267
|
-
|
|
170
|
+
handlePostAuthFlow,
|
|
268
171
|
]);
|
|
269
172
|
debug("render", {
|
|
270
173
|
step,
|
|
@@ -328,58 +231,22 @@ function SignInWithB3Flow({ strategies, onLoginSuccess, onSessionKeySuccess, onE
|
|
|
328
231
|
content = ((0, jsx_runtime_1.jsx)(LoginStep_1.LoginStepContainer, { partnerId: partnerId, children: (0, jsx_runtime_1.jsx)("div", { className: "p-4 text-center text-red-500", children: refetchError }) }));
|
|
329
232
|
}
|
|
330
233
|
else if (step === "login") {
|
|
331
|
-
//
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
const shouldShowTurnkeyFirst = isTurnkeyPrimary && !turnkeyAuthCompleted;
|
|
335
|
-
if (shouldShowTurnkeyFirst) {
|
|
336
|
-
// Don't show loading spinner for Turnkey - let the modal handle its own loading state
|
|
337
|
-
// This prevents the infinite loop where isAuthenticating causes the modal to be replaced
|
|
338
|
-
debug("Showing Turnkey as primary authentication option", {
|
|
339
|
-
isTurnkeyPrimary,
|
|
340
|
-
turnkeyAuthCompleted,
|
|
341
|
-
isAuthenticated,
|
|
342
|
-
});
|
|
343
|
-
// Show Turnkey authentication as primary option
|
|
344
|
-
content = ((0, jsx_runtime_1.jsx)(LoginStep_1.LoginStepContainer, { partnerId: partnerId, children: (0, jsx_runtime_1.jsx)(TurnkeyAuthModal_1.TurnkeyAuthModal, { onSuccess: async (authenticatedUser) => {
|
|
345
|
-
debug("Turnkey authentication successful in primary flow", { authenticatedUser });
|
|
346
|
-
setTurnkeyAuthCompleted(true);
|
|
347
|
-
// User is now authenticated via Turnkey
|
|
348
|
-
// Set both isAuthenticated and isConnected to true so UI updates properly
|
|
349
|
-
// Wallet connection is optional and can happen later for signing transactions
|
|
350
|
-
setIsAuthenticated(true);
|
|
351
|
-
setIsConnected(true);
|
|
352
|
-
setJustCompletedLogin(true);
|
|
353
|
-
// Call the login success callback
|
|
354
|
-
onLoginSuccess?.({});
|
|
355
|
-
// Call the onTurnkeyConnect callback
|
|
356
|
-
onTurnkeyConnect?.(authenticatedUser);
|
|
357
|
-
// After Turnkey auth, refetch user to get the full user object
|
|
358
|
-
// TODO: See why sometimes this fails with "No wallet found during auto-connect"
|
|
359
|
-
await refetchUser();
|
|
360
|
-
}, onClose: () => {
|
|
361
|
-
// If user closes Turnkey modal, they can still use wallet connection as fallback
|
|
362
|
-
setTurnkeyAuthCompleted(true);
|
|
363
|
-
}, initialEmail: "", skipToOtp: false }) }));
|
|
234
|
+
// Show loading spinner
|
|
235
|
+
if (isAuthenticating || (isFetchingSigners && step === "login") || source === "requestPermissions") {
|
|
236
|
+
content = ((0, jsx_runtime_1.jsx)(LoginStep_1.LoginStepContainer, { partnerId: partnerId, children: (0, jsx_runtime_1.jsx)("div", { className: "my-8 flex min-h-[350px] items-center justify-center", children: (0, jsx_runtime_1.jsx)(react_1.Loading, { variant: "white", size: "lg" }) }) }));
|
|
364
237
|
}
|
|
365
238
|
else {
|
|
366
|
-
//
|
|
367
|
-
if (
|
|
368
|
-
content = (
|
|
239
|
+
// Custom strategy
|
|
240
|
+
if (strategies?.[0] === "privy") {
|
|
241
|
+
content = (0, jsx_runtime_1.jsx)(SignInWithB3Privy_1.SignInWithB3Privy, { onSuccess: handleLoginSuccess, chain: chain });
|
|
242
|
+
}
|
|
243
|
+
else if (strategies) {
|
|
244
|
+
// Strategies are explicitly provided
|
|
245
|
+
content = ((0, jsx_runtime_1.jsx)(LoginStepCustom_1.LoginStepCustom, { strategies: strategies, chain: chain, onSuccess: handleLoginSuccess, onError: onError, automaticallySetFirstEoa: !!automaticallySetFirstEoa }));
|
|
369
246
|
}
|
|
370
247
|
else {
|
|
371
|
-
//
|
|
372
|
-
|
|
373
|
-
content = (0, jsx_runtime_1.jsx)(SignInWithB3Privy_1.SignInWithB3Privy, { onSuccess: handleLoginSuccess, chain: chain });
|
|
374
|
-
}
|
|
375
|
-
else if (strategies) {
|
|
376
|
-
// Strategies are explicitly provided
|
|
377
|
-
content = ((0, jsx_runtime_1.jsx)(LoginStepCustom_1.LoginStepCustom, { strategies: strategies, chain: chain, onSuccess: handleLoginSuccess, onError: onError, automaticallySetFirstEoa: !!automaticallySetFirstEoa }));
|
|
378
|
-
}
|
|
379
|
-
else {
|
|
380
|
-
// Default to handle all strategies we support
|
|
381
|
-
content = (0, jsx_runtime_1.jsx)(LoginStep_1.LoginStep, { chain: chain, onSuccess: handleLoginSuccess, onError: onError });
|
|
382
|
-
}
|
|
248
|
+
// Default to handle all strategies we support
|
|
249
|
+
content = (0, jsx_runtime_1.jsx)(LoginStep_1.LoginStep, { chain: chain, onSuccess: handleLoginSuccess, onError: onError });
|
|
383
250
|
}
|
|
384
251
|
}
|
|
385
252
|
}
|
|
@@ -13,7 +13,6 @@ export { SignInWithB3Flow } from "./SignInWithB3/SignInWithB3Flow";
|
|
|
13
13
|
export { SignInWithB3Privy } from "./SignInWithB3/SignInWithB3Privy";
|
|
14
14
|
export { LoginStepContainer } from "./SignInWithB3/steps/LoginStep";
|
|
15
15
|
export { getConnectOptionsFromStrategy, isWalletType, type AllowedStrategy } from "./SignInWithB3/utils/signInUtils";
|
|
16
|
-
export { TurnkeyAuthModal } from "./TurnkeyAuthModal";
|
|
17
16
|
export { ManageAccount } from "./ManageAccount/ManageAccount";
|
|
18
17
|
export { Deposit } from "./Deposit/Deposit";
|
|
19
18
|
export { Send } from "./Send/Send";
|