@b3dotfun/sdk 0.1.1-test.0 → 0.1.2-test.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/anyspend/react/components/AnySpend.js +2 -2
- package/dist/cjs/anyspend/react/components/AnySpendDeposit.d.ts +15 -10
- package/dist/cjs/anyspend/react/components/AnySpendDeposit.js +22 -14
- package/dist/cjs/anyspend/react/components/QRDeposit.js +31 -5
- package/dist/cjs/anyspend/react/components/common/CryptoPaymentMethod.js +9 -2
- package/dist/cjs/anyspend/react/components/common/OrderDetails.js +1 -1
- package/dist/cjs/anyspend/react/components/common/PaymentStripeWeb2.js +1 -1
- package/dist/cjs/anyspend/react/components/common/TransferResultScreen.d.ts +22 -0
- package/dist/cjs/anyspend/react/components/common/TransferResultScreen.js +25 -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/useAnyspendCreateOnrampOrder.js +1 -1
- package/dist/cjs/anyspend/react/hooks/useAnyspendCreateOrder.js +1 -1
- package/dist/cjs/anyspend/react/hooks/useCreateDepositFirstOrder.js +1 -1
- package/dist/cjs/anyspend/react/hooks/useValidatedClientReferenceId.js +1 -1
- package/dist/cjs/anyspend/react/hooks/useWatchTransfer.d.ts +41 -0
- package/dist/cjs/anyspend/react/hooks/useWatchTransfer.js +75 -0
- package/dist/cjs/anyspend/utils/address.d.ts +5 -0
- package/dist/cjs/anyspend/utils/address.js +8 -0
- package/dist/cjs/global-account/react/components/AvatarEditor/AvatarEditor.js +1 -1
- package/dist/cjs/global-account/react/components/B3DynamicModal.js +5 -1
- package/dist/cjs/global-account/react/components/B3Provider/AuthenticationProvider.d.ts +5 -0
- package/dist/cjs/global-account/react/components/B3Provider/AuthenticationProvider.js +12 -0
- package/dist/cjs/global-account/react/components/B3Provider/B3ConfigProvider.d.ts +31 -0
- package/dist/cjs/global-account/react/components/B3Provider/B3ConfigProvider.js +37 -0
- package/dist/cjs/global-account/react/components/B3Provider/B3Provider.d.ts +3 -18
- package/dist/cjs/global-account/react/components/B3Provider/B3Provider.js +7 -57
- package/dist/cjs/global-account/react/components/B3Provider/B3Provider.native.d.ts +6 -6
- package/dist/cjs/global-account/react/components/B3Provider/B3Provider.native.js +11 -35
- package/dist/cjs/global-account/react/components/B3Provider/LocalSDKProvider.d.ts +3 -1
- package/dist/cjs/global-account/react/components/B3Provider/LocalSDKProvider.js +3 -1
- package/dist/cjs/global-account/react/components/B3Provider/useB3.d.ts +3 -3
- package/dist/cjs/global-account/react/components/B3Provider/useB3.js +4 -10
- package/dist/cjs/global-account/react/components/B3Provider/useB3Account.js +5 -2
- package/dist/cjs/global-account/react/components/B3Provider/useB3Config.d.ts +1 -9
- package/dist/cjs/global-account/react/components/B3Provider/useB3Config.js +2 -20
- package/dist/cjs/global-account/react/components/ManageAccount/ProfileSection.js +1 -2
- package/dist/cjs/global-account/react/components/ManageAccount/SettingsProfileCard.js +1 -1
- package/dist/cjs/global-account/react/components/ManageAccount/channels/DiscordChannel.js +1 -1
- package/dist/cjs/global-account/react/components/ManageAccount/channels/EmailChannel.js +1 -1
- package/dist/cjs/global-account/react/components/ManageAccount/channels/PhoneChannel.js +1 -1
- package/dist/cjs/global-account/react/components/ManageAccount/channels/TelegramChannel.js +1 -1
- package/dist/cjs/global-account/react/components/RequestPermissions/RequestPermissions.js +1 -1
- package/dist/cjs/global-account/react/components/SignInWithB3/SignIn.js +1 -1
- package/dist/cjs/global-account/react/components/SignInWithB3/SignInWithB3Flow.d.ts +1 -1
- package/dist/cjs/global-account/react/components/SignInWithB3/SignInWithB3Flow.js +4 -2
- package/dist/cjs/global-account/react/components/SignInWithB3/SignInWithB3Privy.js +1 -1
- package/dist/cjs/global-account/react/components/SignInWithB3/steps/LoginStep.js +1 -1
- package/dist/cjs/global-account/react/components/SignInWithB3/steps/LoginStepCustom.js +1 -1
- package/dist/cjs/global-account/react/components/SingleUserSearchSelector/SingleUserSearchSelector.d.ts +64 -0
- package/dist/cjs/global-account/react/components/SingleUserSearchSelector/SingleUserSearchSelector.js +163 -0
- package/dist/cjs/global-account/react/components/SingleUserSearchSelector/index.d.ts +2 -0
- package/dist/cjs/global-account/react/components/SingleUserSearchSelector/index.js +5 -0
- package/dist/cjs/global-account/react/components/StyleRoot.js +2 -2
- package/dist/cjs/global-account/react/components/WalletImage/WalletImage.d.ts +1 -1
- package/dist/cjs/global-account/react/components/custom/ManageAccountButton.js +1 -2
- package/dist/cjs/global-account/react/components/index.d.ts +3 -2
- package/dist/cjs/global-account/react/components/index.js +6 -6
- package/dist/cjs/global-account/react/hooks/index.d.ts +1 -0
- package/dist/cjs/global-account/react/hooks/index.js +3 -1
- package/dist/cjs/global-account/react/hooks/useAuth.d.ts +2 -2
- package/dist/cjs/global-account/react/hooks/useAuth.js +2 -2
- package/dist/cjs/global-account/react/hooks/useAuthentication.d.ts +2 -2
- package/dist/cjs/global-account/react/hooks/useAuthentication.js +6 -3
- package/dist/cjs/global-account/react/hooks/useClient.js +1 -1
- package/dist/cjs/global-account/react/hooks/useHandleConnectWithPrivy.js +1 -1
- package/dist/cjs/global-account/react/hooks/useNotifications.js +1 -1
- package/dist/cjs/global-account/react/hooks/useProfile.js +4 -23
- package/dist/cjs/global-account/react/hooks/useTokenBalance.js +5 -5
- package/dist/cjs/global-account/react/hooks/useTurnkeyAuth.js +1 -1
- package/dist/cjs/global-account/react/hooks/useUser.d.ts +60 -0
- package/dist/cjs/global-account/react/hooks/useUser.js +20 -0
- package/dist/cjs/global-account/react/hooks/useUserQuery.d.ts +6 -7
- package/dist/cjs/global-account/react/hooks/useUserQuery.js +64 -39
- package/dist/cjs/global-account/react/index.native.d.ts +0 -2
- package/dist/cjs/global-account/react/index.native.js +1 -5
- package/dist/cjs/global-account/react/stores/useModalStore.d.ts +66 -1
- package/dist/cjs/global-account/react/stores/useModalStore.js +3 -0
- package/dist/cjs/global-account/react/stores/userStore.d.ts +22 -0
- package/dist/cjs/global-account/react/stores/userStore.js +30 -0
- package/dist/cjs/global-account/react/utils/profileApi.d.ts +13 -0
- package/dist/cjs/global-account/react/utils/profileApi.js +29 -0
- package/dist/esm/anyspend/react/components/AnySpend.js +3 -3
- package/dist/esm/anyspend/react/components/AnySpendDeposit.d.ts +15 -10
- package/dist/esm/anyspend/react/components/AnySpendDeposit.js +23 -15
- package/dist/esm/anyspend/react/components/QRDeposit.js +32 -6
- package/dist/esm/anyspend/react/components/common/CryptoPaymentMethod.js +10 -3
- package/dist/esm/anyspend/react/components/common/OrderDetails.js +2 -2
- package/dist/esm/anyspend/react/components/common/PaymentStripeWeb2.js +2 -2
- package/dist/esm/anyspend/react/components/common/TransferResultScreen.d.ts +22 -0
- package/dist/esm/anyspend/react/components/common/TransferResultScreen.js +22 -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/useAnyspendCreateOnrampOrder.js +2 -2
- package/dist/esm/anyspend/react/hooks/useAnyspendCreateOrder.js +2 -2
- package/dist/esm/anyspend/react/hooks/useCreateDepositFirstOrder.js +2 -2
- package/dist/esm/anyspend/react/hooks/useValidatedClientReferenceId.js +2 -2
- package/dist/esm/anyspend/react/hooks/useWatchTransfer.d.ts +41 -0
- package/dist/esm/anyspend/react/hooks/useWatchTransfer.js +72 -0
- package/dist/esm/anyspend/utils/address.d.ts +5 -0
- package/dist/esm/anyspend/utils/address.js +7 -0
- package/dist/esm/global-account/react/components/AvatarEditor/AvatarEditor.js +2 -2
- package/dist/esm/global-account/react/components/B3DynamicModal.js +6 -2
- package/dist/esm/global-account/react/components/B3Provider/AuthenticationProvider.d.ts +5 -0
- package/dist/esm/global-account/react/components/B3Provider/AuthenticationProvider.js +10 -0
- package/dist/esm/global-account/react/components/B3Provider/B3ConfigProvider.d.ts +31 -0
- package/dist/esm/global-account/react/components/B3Provider/B3ConfigProvider.js +33 -0
- package/dist/esm/global-account/react/components/B3Provider/B3Provider.d.ts +3 -18
- package/dist/esm/global-account/react/components/B3Provider/B3Provider.js +6 -58
- package/dist/esm/global-account/react/components/B3Provider/B3Provider.native.d.ts +6 -6
- package/dist/esm/global-account/react/components/B3Provider/B3Provider.native.js +10 -37
- package/dist/esm/global-account/react/components/B3Provider/LocalSDKProvider.d.ts +3 -1
- package/dist/esm/global-account/react/components/B3Provider/LocalSDKProvider.js +3 -1
- package/dist/esm/global-account/react/components/B3Provider/useB3.d.ts +3 -3
- package/dist/esm/global-account/react/components/B3Provider/useB3.js +4 -10
- package/dist/esm/global-account/react/components/B3Provider/useB3Account.js +5 -2
- package/dist/esm/global-account/react/components/B3Provider/useB3Config.d.ts +1 -9
- package/dist/esm/global-account/react/components/B3Provider/useB3Config.js +1 -19
- package/dist/esm/global-account/react/components/ManageAccount/ProfileSection.js +2 -3
- package/dist/esm/global-account/react/components/ManageAccount/SettingsProfileCard.js +2 -2
- package/dist/esm/global-account/react/components/ManageAccount/channels/DiscordChannel.js +2 -2
- package/dist/esm/global-account/react/components/ManageAccount/channels/EmailChannel.js +2 -2
- package/dist/esm/global-account/react/components/ManageAccount/channels/PhoneChannel.js +2 -2
- package/dist/esm/global-account/react/components/ManageAccount/channels/TelegramChannel.js +2 -2
- package/dist/esm/global-account/react/components/RequestPermissions/RequestPermissions.js +2 -2
- package/dist/esm/global-account/react/components/SignInWithB3/SignIn.js +2 -2
- package/dist/esm/global-account/react/components/SignInWithB3/SignInWithB3Flow.d.ts +1 -1
- package/dist/esm/global-account/react/components/SignInWithB3/SignInWithB3Flow.js +5 -3
- package/dist/esm/global-account/react/components/SignInWithB3/SignInWithB3Privy.js +2 -2
- package/dist/esm/global-account/react/components/SignInWithB3/steps/LoginStep.js +2 -2
- package/dist/esm/global-account/react/components/SignInWithB3/steps/LoginStepCustom.js +2 -2
- package/dist/esm/global-account/react/components/SingleUserSearchSelector/SingleUserSearchSelector.d.ts +64 -0
- package/dist/esm/global-account/react/components/SingleUserSearchSelector/SingleUserSearchSelector.js +160 -0
- package/dist/esm/global-account/react/components/SingleUserSearchSelector/index.d.ts +2 -0
- package/dist/esm/global-account/react/components/SingleUserSearchSelector/index.js +1 -0
- package/dist/esm/global-account/react/components/StyleRoot.js +2 -2
- package/dist/esm/global-account/react/components/WalletImage/WalletImage.d.ts +1 -1
- package/dist/esm/global-account/react/components/custom/ManageAccountButton.js +2 -3
- package/dist/esm/global-account/react/components/index.d.ts +3 -2
- package/dist/esm/global-account/react/components/index.js +3 -2
- package/dist/esm/global-account/react/hooks/index.d.ts +1 -0
- package/dist/esm/global-account/react/hooks/index.js +1 -0
- package/dist/esm/global-account/react/hooks/useAuth.d.ts +2 -2
- package/dist/esm/global-account/react/hooks/useAuth.js +3 -3
- package/dist/esm/global-account/react/hooks/useAuthentication.d.ts +2 -2
- package/dist/esm/global-account/react/hooks/useAuthentication.js +6 -3
- package/dist/esm/global-account/react/hooks/useClient.js +2 -2
- package/dist/esm/global-account/react/hooks/useHandleConnectWithPrivy.js +2 -2
- package/dist/esm/global-account/react/hooks/useNotifications.js +2 -2
- package/dist/esm/global-account/react/hooks/useProfile.js +1 -20
- package/dist/esm/global-account/react/hooks/useTokenBalance.js +6 -6
- package/dist/esm/global-account/react/hooks/useTurnkeyAuth.js +2 -2
- package/dist/esm/global-account/react/hooks/useUser.d.ts +60 -0
- package/dist/esm/global-account/react/hooks/useUser.js +17 -0
- package/dist/esm/global-account/react/hooks/useUserQuery.d.ts +6 -7
- package/dist/esm/global-account/react/hooks/useUserQuery.js +63 -37
- package/dist/esm/global-account/react/index.native.d.ts +0 -2
- package/dist/esm/global-account/react/index.native.js +0 -2
- package/dist/esm/global-account/react/stores/useModalStore.d.ts +66 -1
- package/dist/esm/global-account/react/stores/useModalStore.js +3 -0
- package/dist/esm/global-account/react/stores/userStore.d.ts +22 -0
- package/dist/esm/global-account/react/stores/userStore.js +27 -0
- package/dist/esm/global-account/react/utils/profileApi.d.ts +13 -0
- package/dist/esm/global-account/react/utils/profileApi.js +25 -0
- package/dist/styles/index.css +1 -1
- package/dist/types/anyspend/react/components/AnySpendDeposit.d.ts +15 -10
- package/dist/types/anyspend/react/components/common/TransferResultScreen.d.ts +22 -0
- package/dist/types/anyspend/react/hooks/index.d.ts +1 -0
- package/dist/types/anyspend/react/hooks/useWatchTransfer.d.ts +41 -0
- package/dist/types/anyspend/utils/address.d.ts +5 -0
- package/dist/types/global-account/react/components/B3Provider/AuthenticationProvider.d.ts +5 -0
- package/dist/types/global-account/react/components/B3Provider/B3ConfigProvider.d.ts +31 -0
- package/dist/types/global-account/react/components/B3Provider/B3Provider.d.ts +3 -18
- package/dist/types/global-account/react/components/B3Provider/B3Provider.native.d.ts +6 -6
- package/dist/types/global-account/react/components/B3Provider/LocalSDKProvider.d.ts +3 -1
- package/dist/types/global-account/react/components/B3Provider/useB3.d.ts +3 -3
- package/dist/types/global-account/react/components/B3Provider/useB3Config.d.ts +1 -9
- package/dist/types/global-account/react/components/SignInWithB3/SignInWithB3Flow.d.ts +1 -1
- package/dist/types/global-account/react/components/SingleUserSearchSelector/SingleUserSearchSelector.d.ts +64 -0
- package/dist/types/global-account/react/components/SingleUserSearchSelector/index.d.ts +2 -0
- package/dist/types/global-account/react/components/WalletImage/WalletImage.d.ts +1 -1
- package/dist/types/global-account/react/components/index.d.ts +3 -2
- package/dist/types/global-account/react/hooks/index.d.ts +1 -0
- package/dist/types/global-account/react/hooks/useAuth.d.ts +2 -2
- package/dist/types/global-account/react/hooks/useAuthentication.d.ts +2 -2
- package/dist/types/global-account/react/hooks/useUser.d.ts +60 -0
- package/dist/types/global-account/react/hooks/useUserQuery.d.ts +6 -7
- package/dist/types/global-account/react/index.native.d.ts +0 -2
- package/dist/types/global-account/react/stores/useModalStore.d.ts +66 -1
- package/dist/types/global-account/react/stores/userStore.d.ts +22 -0
- package/dist/types/global-account/react/utils/profileApi.d.ts +13 -0
- package/package.json +6 -1
- package/src/anyspend/react/components/AnySpend.tsx +3 -2
- package/src/anyspend/react/components/AnySpendDeposit.tsx +60 -42
- package/src/anyspend/react/components/QRDeposit.tsx +57 -5
- package/src/anyspend/react/components/common/CryptoPaymentMethod.tsx +13 -3
- package/src/anyspend/react/components/common/OrderDetails.tsx +2 -2
- package/src/anyspend/react/components/common/PaymentStripeWeb2.tsx +2 -2
- package/src/anyspend/react/components/common/TransferResultScreen.tsx +107 -0
- package/src/anyspend/react/hooks/index.ts +1 -0
- package/src/anyspend/react/hooks/useAnyspendCreateOnrampOrder.ts +2 -2
- package/src/anyspend/react/hooks/useAnyspendCreateOrder.ts +2 -2
- package/src/anyspend/react/hooks/useCreateDepositFirstOrder.ts +2 -2
- package/src/anyspend/react/hooks/useValidatedClientReferenceId.ts +2 -2
- package/src/anyspend/react/hooks/useWatchTransfer.ts +114 -0
- package/src/anyspend/utils/address.ts +13 -0
- package/src/global-account/react/components/AvatarEditor/AvatarEditor.tsx +2 -2
- package/src/global-account/react/components/B3DynamicModal.tsx +6 -2
- package/src/global-account/react/components/B3Provider/AuthenticationProvider.tsx +19 -0
- package/src/global-account/react/components/B3Provider/B3ConfigProvider.tsx +84 -0
- package/src/global-account/react/components/B3Provider/B3Provider.native.tsx +26 -45
- package/src/global-account/react/components/B3Provider/B3Provider.tsx +15 -103
- package/src/global-account/react/components/B3Provider/LocalSDKProvider.tsx +5 -0
- package/src/global-account/react/components/B3Provider/useB3.ts +4 -12
- package/src/global-account/react/components/B3Provider/useB3Account.ts +6 -2
- package/src/global-account/react/components/B3Provider/useB3Config.ts +1 -34
- package/src/global-account/react/components/ManageAccount/ProfileSection.tsx +2 -4
- package/src/global-account/react/components/ManageAccount/SettingsProfileCard.tsx +2 -2
- package/src/global-account/react/components/ManageAccount/channels/DiscordChannel.tsx +2 -2
- package/src/global-account/react/components/ManageAccount/channels/EmailChannel.tsx +2 -2
- package/src/global-account/react/components/ManageAccount/channels/PhoneChannel.tsx +2 -2
- package/src/global-account/react/components/ManageAccount/channels/TelegramChannel.tsx +2 -2
- package/src/global-account/react/components/RequestPermissions/RequestPermissions.tsx +2 -2
- package/src/global-account/react/components/SignInWithB3/SignIn.tsx +2 -2
- package/src/global-account/react/components/SignInWithB3/SignInWithB3Flow.tsx +7 -3
- package/src/global-account/react/components/SignInWithB3/SignInWithB3Privy.tsx +2 -2
- package/src/global-account/react/components/SignInWithB3/steps/LoginStep.tsx +2 -2
- package/src/global-account/react/components/SignInWithB3/steps/LoginStepCustom.tsx +2 -2
- package/src/global-account/react/components/SingleUserSearchSelector/README.md +266 -0
- package/src/global-account/react/components/SingleUserSearchSelector/SingleUserSearchSelector.tsx +330 -0
- package/src/global-account/react/components/SingleUserSearchSelector/index.ts +2 -0
- package/src/global-account/react/components/StyleRoot.tsx +2 -2
- package/src/global-account/react/components/custom/ManageAccountButton.tsx +2 -3
- package/src/global-account/react/components/index.ts +8 -2
- package/src/global-account/react/hooks/index.ts +1 -0
- package/src/global-account/react/hooks/useAuth.ts +3 -3
- package/src/global-account/react/hooks/useAuthentication.ts +7 -3
- package/src/global-account/react/hooks/useClient.ts +2 -2
- package/src/global-account/react/hooks/useHandleConnectWithPrivy.tsx +2 -2
- package/src/global-account/react/hooks/useNotifications.ts +2 -2
- package/src/global-account/react/hooks/useProfile.ts +1 -32
- package/src/global-account/react/hooks/useTokenBalance.tsx +8 -7
- package/src/global-account/react/hooks/useTurnkeyAuth.ts +2 -2
- package/src/global-account/react/hooks/useUser.ts +20 -0
- package/src/global-account/react/hooks/useUserQuery.ts +64 -51
- package/src/global-account/react/index.native.ts +0 -2
- package/src/global-account/react/stores/useModalStore.ts +70 -1
- package/src/global-account/react/stores/userStore.ts +41 -0
- package/src/global-account/react/utils/profileApi.ts +38 -0
- package/dist/cjs/global-account/react/components/B3Provider/types.d.ts +0 -27
- package/dist/cjs/global-account/react/components/B3Provider/types.js +0 -24
- package/dist/esm/global-account/react/components/B3Provider/types.d.ts +0 -27
- package/dist/esm/global-account/react/components/B3Provider/types.js +0 -21
- package/dist/types/global-account/react/components/B3Provider/types.d.ts +0 -27
- package/src/global-account/react/components/B3Provider/types.ts +0 -50
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useWatchTransfer = useWatchTransfer;
|
|
4
|
+
const react_1 = require("react");
|
|
5
|
+
const viem_1 = require("viem");
|
|
6
|
+
const wagmi_1 = require("wagmi");
|
|
7
|
+
const utils_1 = require("../../utils");
|
|
8
|
+
/**
|
|
9
|
+
* Hook to watch for incoming transfers to an address by monitoring balance changes.
|
|
10
|
+
* When a transfer is detected (balance increases), it captures the amount and notifies.
|
|
11
|
+
*/
|
|
12
|
+
function useWatchTransfer({ address, chainId, tokenAddress, tokenDecimals, enabled = true, onTransferDetected, }) {
|
|
13
|
+
const [transferResult, setTransferResult] = (0, react_1.useState)(null);
|
|
14
|
+
const [isWatching, setIsWatching] = (0, react_1.useState)(false);
|
|
15
|
+
const initialBalanceRef = (0, react_1.useRef)(null);
|
|
16
|
+
const transferDetectedRef = (0, react_1.useRef)(false);
|
|
17
|
+
const isNative = (0, utils_1.isNativeToken)(tokenAddress);
|
|
18
|
+
// Get current balance
|
|
19
|
+
const { data: balanceData, refetch: refetchBalance } = (0, wagmi_1.useBalance)({
|
|
20
|
+
address: address,
|
|
21
|
+
chainId,
|
|
22
|
+
token: isNative ? undefined : tokenAddress,
|
|
23
|
+
query: {
|
|
24
|
+
enabled: enabled && !!address,
|
|
25
|
+
refetchInterval: 3000,
|
|
26
|
+
},
|
|
27
|
+
});
|
|
28
|
+
// Initialize or update the initial balance
|
|
29
|
+
(0, react_1.useEffect)(() => {
|
|
30
|
+
if (balanceData && initialBalanceRef.current === null && enabled) {
|
|
31
|
+
initialBalanceRef.current = balanceData.value;
|
|
32
|
+
setIsWatching(true);
|
|
33
|
+
}
|
|
34
|
+
}, [balanceData, enabled]);
|
|
35
|
+
// Check for balance increase (transfer detected)
|
|
36
|
+
(0, react_1.useEffect)(() => {
|
|
37
|
+
if (!enabled || transferDetectedRef.current || initialBalanceRef.current === null || !balanceData) {
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
const currentBalance = balanceData.value;
|
|
41
|
+
const initialBalance = initialBalanceRef.current;
|
|
42
|
+
if (currentBalance > initialBalance) {
|
|
43
|
+
const transferAmount = currentBalance - initialBalance;
|
|
44
|
+
const formattedAmount = (0, viem_1.formatUnits)(transferAmount, tokenDecimals);
|
|
45
|
+
const result = {
|
|
46
|
+
amount: transferAmount.toString(),
|
|
47
|
+
formattedAmount,
|
|
48
|
+
timestamp: Date.now(),
|
|
49
|
+
};
|
|
50
|
+
transferDetectedRef.current = true;
|
|
51
|
+
setTransferResult(result);
|
|
52
|
+
setIsWatching(false);
|
|
53
|
+
onTransferDetected?.(result);
|
|
54
|
+
}
|
|
55
|
+
}, [balanceData, enabled, tokenDecimals, onTransferDetected]);
|
|
56
|
+
// Reset function to start watching again
|
|
57
|
+
const reset = (0, react_1.useCallback)(() => {
|
|
58
|
+
transferDetectedRef.current = false;
|
|
59
|
+
initialBalanceRef.current = null;
|
|
60
|
+
setTransferResult(null);
|
|
61
|
+
setIsWatching(false);
|
|
62
|
+
}, []);
|
|
63
|
+
return (0, react_1.useMemo)(() => ({
|
|
64
|
+
/** Whether currently watching for transfers */
|
|
65
|
+
isWatching,
|
|
66
|
+
/** The detected transfer result, if any */
|
|
67
|
+
transferResult,
|
|
68
|
+
/** Whether a transfer has been detected */
|
|
69
|
+
hasTransfer: transferResult !== null,
|
|
70
|
+
/** Reset and start watching again */
|
|
71
|
+
reset,
|
|
72
|
+
/** Manually refetch balance */
|
|
73
|
+
refetchBalance,
|
|
74
|
+
}), [isWatching, transferResult, reset, refetchBalance]);
|
|
75
|
+
}
|
|
@@ -13,3 +13,8 @@ export declare function isEvmOrSolanaAddress(address: string): boolean;
|
|
|
13
13
|
export declare function isHyperliquidUSDC(chainId: number, address: string): boolean;
|
|
14
14
|
export declare function normalizeAddress(address: string): string;
|
|
15
15
|
export declare function eqci(a: string | null | undefined, b: string | null | undefined): boolean;
|
|
16
|
+
/**
|
|
17
|
+
* Check if source and destination represent the same token on the same chain.
|
|
18
|
+
* When true, this is a pure transfer (no swap/bridge needed).
|
|
19
|
+
*/
|
|
20
|
+
export declare function isSameChainAndToken(sourceChainId: number, sourceTokenAddress: string, destinationChainId: number, destinationTokenAddress: string): boolean;
|
|
@@ -5,6 +5,7 @@ exports.isEvmOrSolanaAddress = isEvmOrSolanaAddress;
|
|
|
5
5
|
exports.isHyperliquidUSDC = isHyperliquidUSDC;
|
|
6
6
|
exports.normalizeAddress = normalizeAddress;
|
|
7
7
|
exports.eqci = eqci;
|
|
8
|
+
exports.isSameChainAndToken = isSameChainAndToken;
|
|
8
9
|
const viem_1 = require("viem");
|
|
9
10
|
const token_1 = require("./token");
|
|
10
11
|
function isSolanaAddress(address) {
|
|
@@ -42,3 +43,10 @@ function eqci(a, b) {
|
|
|
42
43
|
return false;
|
|
43
44
|
return a.toLowerCase() === b.toLowerCase();
|
|
44
45
|
}
|
|
46
|
+
/**
|
|
47
|
+
* Check if source and destination represent the same token on the same chain.
|
|
48
|
+
* When true, this is a pure transfer (no swap/bridge needed).
|
|
49
|
+
*/
|
|
50
|
+
function isSameChainAndToken(sourceChainId, sourceTokenAddress, destinationChainId, destinationTokenAddress) {
|
|
51
|
+
return sourceChainId === destinationChainId && eqci(sourceTokenAddress, destinationTokenAddress);
|
|
52
|
+
}
|
|
@@ -43,7 +43,7 @@ function AvatarEditor({ onSetAvatar, className }) {
|
|
|
43
43
|
const [zoom, setZoom] = (0, react_2.useState)(1);
|
|
44
44
|
const [croppedAreaPixels, setCroppedAreaPixels] = (0, react_2.useState)(null);
|
|
45
45
|
const fileInputRef = (0, react_2.useRef)(null);
|
|
46
|
-
const { partnerId } = (0, react_1.
|
|
46
|
+
const { partnerId } = (0, react_1.useB3Config)();
|
|
47
47
|
const { user, setUser } = (0, react_1.useAuthentication)(partnerId);
|
|
48
48
|
const setB3ModalContentType = (0, stores_1.useModalStore)(state => state.setB3ModalContentType);
|
|
49
49
|
const contentType = (0, stores_1.useModalStore)(state => state.contentType);
|
|
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.B3DynamicModal = B3DynamicModal;
|
|
7
7
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
8
8
|
const react_1 = require("../../../anyspend/react");
|
|
9
|
+
const AnySpendDeposit_1 = require("../../../anyspend/react/components/AnySpendDeposit");
|
|
9
10
|
const AnyspendDepositHype_1 = require("../../../anyspend/react/components/AnyspendDepositHype");
|
|
10
11
|
const AnySpendDepositUpside_1 = require("../../../anyspend/react/components/AnySpendDepositUpside");
|
|
11
12
|
const AnySpendStakeUpside_1 = require("../../../anyspend/react/components/AnySpendStakeUpside");
|
|
@@ -33,7 +34,7 @@ function B3DynamicModal() {
|
|
|
33
34
|
const setB3ModalOpen = (0, react_2.useModalStore)(state => state.setB3ModalOpen);
|
|
34
35
|
const contentType = (0, react_2.useModalStore)(state => state.contentType);
|
|
35
36
|
const navigateBack = (0, react_2.useModalStore)(state => state.navigateBack);
|
|
36
|
-
const { theme } = (0, react_2.
|
|
37
|
+
const { theme } = (0, react_2.useB3Config)();
|
|
37
38
|
const isMobile = (0, react_2.useIsMobile)();
|
|
38
39
|
const { toasts, removeToast } = (0, index_1.useToastContext)();
|
|
39
40
|
// Define arrays for different modal type groups
|
|
@@ -58,6 +59,7 @@ function B3DynamicModal() {
|
|
|
58
59
|
"deposit",
|
|
59
60
|
"send",
|
|
60
61
|
"notifications",
|
|
62
|
+
"anySpendDeposit",
|
|
61
63
|
];
|
|
62
64
|
const freestyleTypes = [
|
|
63
65
|
"anySpendNft",
|
|
@@ -128,6 +130,8 @@ function B3DynamicModal() {
|
|
|
128
130
|
return (0, jsx_runtime_1.jsx)(AnyspendDepositHype_1.AnySpendDepositHype, { ...contentType, mode: "modal" });
|
|
129
131
|
case "anySpendCollectorClubPurchase":
|
|
130
132
|
return (0, jsx_runtime_1.jsx)(react_1.AnySpendCollectorClubPurchase, { ...contentType, mode: "modal" });
|
|
133
|
+
case "anySpendDeposit":
|
|
134
|
+
return (0, jsx_runtime_1.jsx)(AnySpendDeposit_1.AnySpendDeposit, { ...contentType, mode: "modal" });
|
|
131
135
|
case "avatarEditor":
|
|
132
136
|
return (0, jsx_runtime_1.jsx)(AvatarEditor_1.AvatarEditor, { onSetAvatar: contentType.onSuccess });
|
|
133
137
|
case "deposit":
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const hooks_1 = require("../../hooks");
|
|
4
|
+
const useAutoSelectWallet_1 = require("../../hooks/useAutoSelectWallet");
|
|
5
|
+
const AuthenticationProvider = ({ partnerId, automaticallySetFirstEoa, }) => {
|
|
6
|
+
(0, hooks_1.useAuthentication)(partnerId);
|
|
7
|
+
(0, useAutoSelectWallet_1.useAutoSelectWallet)({
|
|
8
|
+
enabled: automaticallySetFirstEoa,
|
|
9
|
+
});
|
|
10
|
+
return null;
|
|
11
|
+
};
|
|
12
|
+
exports.default = AuthenticationProvider;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { CreateOnrampOrderParams } from "../../../../anyspend/react/hooks/useAnyspendCreateOnrampOrder";
|
|
2
|
+
import { CreateOrderParams } from "../../../../anyspend/react/hooks/useAnyspendCreateOrder";
|
|
3
|
+
import { PermissionsConfig } from "../../../../global-account/types/permissions";
|
|
4
|
+
import { Account } from "thirdweb/wallets";
|
|
5
|
+
import { ClientType } from "../../../client-manager";
|
|
6
|
+
export interface B3ConfigContextType {
|
|
7
|
+
accountOverride?: Account;
|
|
8
|
+
automaticallySetFirstEoa: boolean;
|
|
9
|
+
environment: "development" | "production";
|
|
10
|
+
defaultPermissions: PermissionsConfig;
|
|
11
|
+
theme: "light" | "dark";
|
|
12
|
+
clientType: ClientType;
|
|
13
|
+
partnerId: string;
|
|
14
|
+
stripePublishableKey?: string;
|
|
15
|
+
createClientReferenceId?: (params: CreateOrderParams | CreateOnrampOrderParams) => Promise<string>;
|
|
16
|
+
enableTurnkey: boolean;
|
|
17
|
+
}
|
|
18
|
+
export declare function B3ConfigProvider({ children, accountOverride, environment, defaultPermissions, automaticallySetFirstEoa, theme, clientType, partnerId, stripePublishableKey, createClientReferenceId, enableTurnkey, }: {
|
|
19
|
+
children: React.ReactNode;
|
|
20
|
+
accountOverride?: Account;
|
|
21
|
+
environment?: "development" | "production";
|
|
22
|
+
defaultPermissions?: PermissionsConfig;
|
|
23
|
+
automaticallySetFirstEoa?: boolean;
|
|
24
|
+
theme?: "light" | "dark";
|
|
25
|
+
clientType?: ClientType;
|
|
26
|
+
partnerId: string;
|
|
27
|
+
stripePublishableKey?: string;
|
|
28
|
+
createClientReferenceId?: (params: CreateOrderParams | CreateOnrampOrderParams) => Promise<string>;
|
|
29
|
+
enableTurnkey?: boolean;
|
|
30
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
31
|
+
export declare function useB3Config(): B3ConfigContextType;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.B3ConfigProvider = B3ConfigProvider;
|
|
4
|
+
exports.useB3Config = useB3Config;
|
|
5
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
6
|
+
const react_1 = require("react");
|
|
7
|
+
/**
|
|
8
|
+
* Default permissions configuration for B3 provider
|
|
9
|
+
*/
|
|
10
|
+
const DEFAULT_PERMISSIONS = {
|
|
11
|
+
approvedTargets: ["0xa8e42121e318e3D3BeD7f5969AF6D360045317DD"],
|
|
12
|
+
nativeTokenLimitPerTransaction: 0.1,
|
|
13
|
+
startDate: new Date(),
|
|
14
|
+
endDate: new Date(Date.now() + 1000 * 60 * 60 * 24 * 365), // 1 year from now
|
|
15
|
+
};
|
|
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, enableTurnkey = false, }) {
|
|
18
|
+
return ((0, jsx_runtime_1.jsx)(B3ConfigContext.Provider, { value: {
|
|
19
|
+
accountOverride,
|
|
20
|
+
environment,
|
|
21
|
+
defaultPermissions,
|
|
22
|
+
automaticallySetFirstEoa,
|
|
23
|
+
theme,
|
|
24
|
+
clientType,
|
|
25
|
+
partnerId,
|
|
26
|
+
stripePublishableKey,
|
|
27
|
+
createClientReferenceId,
|
|
28
|
+
enableTurnkey,
|
|
29
|
+
}, children: children }));
|
|
30
|
+
}
|
|
31
|
+
function useB3Config() {
|
|
32
|
+
const context = (0, react_1.useContext)(B3ConfigContext);
|
|
33
|
+
if (!context) {
|
|
34
|
+
throw new Error("useB3Config must be used within a B3ConfigProvider");
|
|
35
|
+
}
|
|
36
|
+
return context;
|
|
37
|
+
}
|
|
@@ -5,15 +5,14 @@ import "@relayprotocol/relay-kit-ui/styles.css";
|
|
|
5
5
|
import { Account, Wallet } from "thirdweb/wallets";
|
|
6
6
|
import { CreateConnectorFn } from "wagmi";
|
|
7
7
|
import { ClientType } from "../../../client-manager";
|
|
8
|
-
import { B3ContextType } from "./types";
|
|
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, connectors, overrideDefaultConnectors, createClientReferenceId, enableTurnkey, }: {
|
|
11
|
+
export declare function B3Provider({ theme, children, accountOverride, environment, automaticallySetFirstEoa, simDuneApiKey, toaster: _toaster, clientType, rpcUrls, partnerId, stripePublishableKey, onConnect, onLogout, connectors, overrideDefaultConnectors, createClientReferenceId, enableTurnkey, defaultPermissions, }: {
|
|
13
12
|
theme: "light" | "dark";
|
|
14
13
|
children: React.ReactNode;
|
|
15
14
|
accountOverride?: Account;
|
|
16
|
-
environment
|
|
15
|
+
environment?: "development" | "production";
|
|
17
16
|
automaticallySetFirstEoa?: boolean;
|
|
18
17
|
simDuneApiKey?: string;
|
|
19
18
|
toaster?: {
|
|
@@ -26,24 +25,10 @@ export declare function B3Provider({ theme, children, accountOverride, environme
|
|
|
26
25
|
/** Partner-specific Stripe publishable key. If not provided, uses default B3 Stripe account. */
|
|
27
26
|
stripePublishableKey?: string;
|
|
28
27
|
onConnect?: (wallet: Wallet, b3Jwt: string) => void | Promise<void>;
|
|
28
|
+
onLogout?: () => void | Promise<void>;
|
|
29
29
|
connectors?: CreateConnectorFn[];
|
|
30
30
|
overrideDefaultConnectors?: boolean;
|
|
31
31
|
createClientReferenceId?: (params: CreateOrderParams | CreateOnrampOrderParams) => Promise<string>;
|
|
32
32
|
enableTurnkey?: boolean;
|
|
33
|
-
}): import("react/jsx-runtime").JSX.Element;
|
|
34
|
-
/**
|
|
35
|
-
* Inner provider component that provides the actual B3Context
|
|
36
|
-
*/
|
|
37
|
-
export declare function InnerProvider({ children, accountOverride, environment, defaultPermissions, automaticallySetFirstEoa, theme, clientType, partnerId, stripePublishableKey, createClientReferenceId, enableTurnkey, }: {
|
|
38
|
-
children: React.ReactNode;
|
|
39
|
-
accountOverride?: Account;
|
|
40
|
-
environment: B3ContextType["environment"];
|
|
41
33
|
defaultPermissions?: PermissionsConfig;
|
|
42
|
-
automaticallySetFirstEoa: boolean;
|
|
43
|
-
theme: "light" | "dark";
|
|
44
|
-
clientType?: ClientType;
|
|
45
|
-
partnerId: string;
|
|
46
|
-
stripePublishableKey?: string;
|
|
47
|
-
createClientReferenceId?: (params: CreateOrderParams | CreateOnrampOrderParams) => Promise<string>;
|
|
48
|
-
enableTurnkey?: boolean;
|
|
49
34
|
}): import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
6
|
exports.B3Provider = B3Provider;
|
|
4
|
-
exports.InnerProvider = InnerProvider;
|
|
5
7
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
6
8
|
const react_1 = require("../../../../global-account/react");
|
|
7
|
-
const useAutoSelectWallet_1 = require("../../../../global-account/react/hooks/useAutoSelectWallet");
|
|
8
9
|
const createWagmiConfig_1 = require("../../../../global-account/react/utils/createWagmiConfig");
|
|
9
10
|
const analytics_1 = require("../../../../global-account/utils/analytics");
|
|
10
11
|
require("@relayprotocol/relay-kit-ui/styles.css");
|
|
@@ -15,17 +16,9 @@ const wagmi_1 = require("wagmi");
|
|
|
15
16
|
const client_manager_1 = require("../../../client-manager");
|
|
16
17
|
const StyleRoot_1 = require("../StyleRoot");
|
|
17
18
|
const index_1 = require("../Toast/index");
|
|
19
|
+
const AuthenticationProvider_1 = __importDefault(require("./AuthenticationProvider"));
|
|
20
|
+
const B3ConfigProvider_1 = require("./B3ConfigProvider");
|
|
18
21
|
const LocalSDKProvider_1 = require("./LocalSDKProvider");
|
|
19
|
-
const types_1 = require("./types");
|
|
20
|
-
/**
|
|
21
|
-
* Default permissions configuration for B3 provider
|
|
22
|
-
*/
|
|
23
|
-
const DEFAULT_PERMISSIONS = {
|
|
24
|
-
approvedTargets: ["0xa8e42121e318e3D3BeD7f5969AF6D360045317DD"], // Example contract
|
|
25
|
-
nativeTokenLimitPerTransaction: 0.1, // in ETH
|
|
26
|
-
startDate: new Date(),
|
|
27
|
-
endDate: new Date(Date.now() + 1000 * 60 * 60 * 24 * 365), // 1 year from now
|
|
28
|
-
};
|
|
29
22
|
// Create queryClient instance
|
|
30
23
|
const queryClient = new react_query_1.QueryClient();
|
|
31
24
|
/**
|
|
@@ -33,7 +26,7 @@ const queryClient = new react_query_1.QueryClient();
|
|
|
33
26
|
*/
|
|
34
27
|
function B3Provider({ theme = "light", children, accountOverride, environment, automaticallySetFirstEoa, simDuneApiKey,
|
|
35
28
|
// deprecated since v0.0.87
|
|
36
|
-
toaster: _toaster, clientType = "rest", rpcUrls, partnerId, stripePublishableKey, onConnect, connectors, overrideDefaultConnectors = false, createClientReferenceId, enableTurnkey = false, }) {
|
|
29
|
+
toaster: _toaster, clientType = "rest", rpcUrls, partnerId, stripePublishableKey, onConnect, onLogout, connectors, overrideDefaultConnectors = false, createClientReferenceId, enableTurnkey = false, defaultPermissions, }) {
|
|
37
30
|
// Initialize Google Analytics on mount
|
|
38
31
|
(0, react_2.useEffect)(() => {
|
|
39
32
|
(0, analytics_1.loadGA4Script)();
|
|
@@ -43,50 +36,7 @@ toaster: _toaster, clientType = "rest", rpcUrls, partnerId, stripePublishableKey
|
|
|
43
36
|
(0, client_manager_1.setClientType)(clientType);
|
|
44
37
|
}, [clientType]);
|
|
45
38
|
const wagmiConfig = (0, react_2.useMemo)(() => (0, createWagmiConfig_1.createWagmiConfig)({ partnerId, rpcUrls, connectors, overrideDefaultConnectors }), [partnerId, rpcUrls, connectors, overrideDefaultConnectors]);
|
|
46
|
-
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, children: (0, jsx_runtime_1.jsxs)(
|
|
47
|
-
}
|
|
48
|
-
/**
|
|
49
|
-
* Inner provider component that provides the actual B3Context
|
|
50
|
-
*/
|
|
51
|
-
function InnerProvider({ children, accountOverride, environment, defaultPermissions = DEFAULT_PERMISSIONS, automaticallySetFirstEoa, theme = "light", clientType = "socket", partnerId, stripePublishableKey, createClientReferenceId, enableTurnkey, }) {
|
|
52
|
-
const activeAccount = (0, react_3.useActiveAccount)();
|
|
53
|
-
const isAuthenticated = (0, react_1.useAuthStore)(state => state.isAuthenticated);
|
|
54
|
-
//const isConnected = useAuthStore(state => state.isConnected);
|
|
55
|
-
//const justCompletedLogin = useAuthStore(state => state.justCompletedLogin);
|
|
56
|
-
// Note: This fixes a bug where useAuthentication is no longer rendered on every page, as of this PR https://github.com/b3-fun/b3/pull/385/files#diff-3ef996931b8fc8e49021ba1b42ddaa97535214681610dc5fdacf63542e261af7
|
|
57
|
-
// The above PR removes useAuthentication from the overall B3Provider. useAuthentication should be everywhere the provider is, since it sets the overall auth state
|
|
58
|
-
// By just calling it manually, we fix that issue
|
|
59
|
-
// As a follow up, we should fix the SDK directly
|
|
60
|
-
(0, react_1.useAuthentication)(partnerId);
|
|
61
|
-
// Use given accountOverride or activeAccount from thirdweb
|
|
62
|
-
// WOJ: why if isAuthenticated is false, we don't use activeAccount, which should be undefined?
|
|
63
|
-
// skip isAuthenticated check ?
|
|
64
|
-
const effectiveAccount = isAuthenticated ? accountOverride || activeAccount : undefined;
|
|
65
|
-
// Wrapper to set active wallet via thirdweb
|
|
66
|
-
// Note: `wallet` in context is deprecated - use useActiveWallet() from thirdweb/react instead
|
|
67
|
-
// Auto-select first EOA wallet when enabled
|
|
68
|
-
(0, useAutoSelectWallet_1.useAutoSelectWallet)({
|
|
69
|
-
enabled: automaticallySetFirstEoa,
|
|
70
|
-
});
|
|
71
|
-
return ((0, jsx_runtime_1.jsx)(types_1.B3Context.Provider, { value: {
|
|
72
|
-
account: effectiveAccount,
|
|
73
|
-
// setWallet,
|
|
74
|
-
//wallet: undefined, // Deprecated: use useActiveWallet() from thirdweb/react instead
|
|
75
|
-
//user,
|
|
76
|
-
//setUser,
|
|
77
|
-
//refetchUser,
|
|
78
|
-
initialized: true,
|
|
79
|
-
ready: !!effectiveAccount,
|
|
80
|
-
automaticallySetFirstEoa,
|
|
81
|
-
environment,
|
|
82
|
-
defaultPermissions,
|
|
83
|
-
theme,
|
|
84
|
-
clientType,
|
|
85
|
-
partnerId: partnerId,
|
|
86
|
-
stripePublishableKey,
|
|
87
|
-
createClientReferenceId,
|
|
88
|
-
enableTurnkey,
|
|
89
|
-
}, children: children }));
|
|
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, enableTurnkey: enableTurnkey, 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 })] }) }) }) }) }) }) }));
|
|
90
40
|
}
|
|
91
41
|
/**
|
|
92
42
|
* Component to connect the toast context to the global toast API
|
|
@@ -1,27 +1,27 @@
|
|
|
1
1
|
import { PermissionsConfig } from "../../../../global-account/types/permissions";
|
|
2
2
|
import { Account, Wallet } from "thirdweb/wallets";
|
|
3
3
|
import { ClientType } from "../../../client-manager";
|
|
4
|
-
import { B3ContextType } from "./types";
|
|
5
4
|
/**
|
|
6
|
-
* Main B3Provider component
|
|
5
|
+
* Main B3Provider component
|
|
7
6
|
*/
|
|
8
|
-
export declare function B3Provider({ theme, children, accountOverride, environment, clientType, partnerId, rpcUrls, onConnect, }: {
|
|
7
|
+
export declare function B3Provider({ theme, children, accountOverride, environment, clientType, partnerId, rpcUrls, onConnect, defaultPermissions, }: {
|
|
9
8
|
theme: "light" | "dark";
|
|
10
9
|
children: React.ReactNode;
|
|
11
10
|
accountOverride?: Account;
|
|
12
|
-
environment
|
|
11
|
+
environment?: "development" | "production";
|
|
13
12
|
clientType?: ClientType;
|
|
14
13
|
partnerId: string;
|
|
15
14
|
rpcUrls?: Record<number, string>;
|
|
16
15
|
onConnect?: (wallet: Wallet, b3Jwt: string) => void | Promise<void>;
|
|
16
|
+
defaultPermissions?: PermissionsConfig;
|
|
17
17
|
}): import("react/jsx-runtime").JSX.Element;
|
|
18
18
|
/**
|
|
19
|
-
* Inner provider component
|
|
19
|
+
* Inner provider component for native
|
|
20
20
|
*/
|
|
21
21
|
export declare function InnerProvider({ children, accountOverride, environment, defaultPermissions, theme, clientType, partnerId, rpcUrls, }: {
|
|
22
22
|
children: React.ReactNode;
|
|
23
23
|
accountOverride?: Account;
|
|
24
|
-
environment
|
|
24
|
+
environment?: "development" | "production";
|
|
25
25
|
defaultPermissions?: PermissionsConfig;
|
|
26
26
|
theme: "light" | "dark";
|
|
27
27
|
clientType?: ClientType;
|
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
6
|
exports.B3Provider = B3Provider;
|
|
4
7
|
exports.InnerProvider = InnerProvider;
|
|
@@ -7,48 +10,21 @@ const react_query_1 = require("@tanstack/react-query");
|
|
|
7
10
|
const react_1 = require("thirdweb/react");
|
|
8
11
|
const wagmi_1 = require("wagmi");
|
|
9
12
|
const createWagmiConfig_1 = require("../../utils/createWagmiConfig");
|
|
13
|
+
const AuthenticationProvider_1 = __importDefault(require("./AuthenticationProvider"));
|
|
14
|
+
const B3ConfigProvider_1 = require("./B3ConfigProvider");
|
|
10
15
|
const LocalSDKProvider_1 = require("./LocalSDKProvider");
|
|
11
|
-
const types_1 = require("./types");
|
|
12
|
-
/**
|
|
13
|
-
* Default permissions configuration for B3 provider
|
|
14
|
-
*/
|
|
15
|
-
const DEFAULT_PERMISSIONS = {
|
|
16
|
-
approvedTargets: ["0xa8e42121e318e3D3BeD7f5969AF6D360045317DD"], // Example contract
|
|
17
|
-
nativeTokenLimitPerTransaction: 0.1, // in ETH
|
|
18
|
-
startDate: new Date(),
|
|
19
|
-
endDate: new Date(Date.now() + 1000 * 60 * 60 * 24 * 365), // 1 year from now
|
|
20
|
-
};
|
|
21
16
|
// Create queryClient instance
|
|
22
17
|
const queryClient = new react_query_1.QueryClient();
|
|
23
18
|
/**
|
|
24
|
-
* Main B3Provider component
|
|
19
|
+
* Main B3Provider component
|
|
25
20
|
*/
|
|
26
|
-
function B3Provider({ theme, children, accountOverride, environment, clientType, partnerId, rpcUrls, onConnect, }) {
|
|
27
|
-
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.
|
|
21
|
+
function B3Provider({ theme = "light", children, accountOverride, environment, clientType = "socket", partnerId, rpcUrls, onConnect, defaultPermissions, }) {
|
|
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 })] }) }) }));
|
|
28
23
|
}
|
|
29
24
|
/**
|
|
30
|
-
* Inner provider component
|
|
25
|
+
* Inner provider component for native
|
|
31
26
|
*/
|
|
32
|
-
function InnerProvider({ children, accountOverride, environment, defaultPermissions
|
|
33
|
-
const activeAccount = (0, react_1.useActiveAccount)();
|
|
34
|
-
//const { user, setUser, refetchUser } = useAuthentication(partnerId);
|
|
27
|
+
function InnerProvider({ children, accountOverride, environment, defaultPermissions, theme = "light", clientType = "socket", partnerId, rpcUrls, }) {
|
|
35
28
|
const wagmiConfig = (0, createWagmiConfig_1.createWagmiConfig)({ partnerId, rpcUrls });
|
|
36
|
-
|
|
37
|
-
const effectiveAccount = accountOverride || activeAccount;
|
|
38
|
-
return ((0, jsx_runtime_1.jsx)(wagmi_1.WagmiProvider, { config: wagmiConfig, children: (0, jsx_runtime_1.jsx)(react_query_1.QueryClientProvider, { client: queryClient, children: (0, jsx_runtime_1.jsx)(types_1.B3Context.Provider, { value: {
|
|
39
|
-
//account: effectiveAccount,
|
|
40
|
-
automaticallySetFirstEoa: false,
|
|
41
|
-
//setWallet: () => {},
|
|
42
|
-
wallet: undefined,
|
|
43
|
-
//user,
|
|
44
|
-
//setUser,
|
|
45
|
-
initialized: true,
|
|
46
|
-
ready: !!effectiveAccount,
|
|
47
|
-
environment,
|
|
48
|
-
defaultPermissions,
|
|
49
|
-
theme,
|
|
50
|
-
clientType,
|
|
51
|
-
partnerId,
|
|
52
|
-
//refetchUser,
|
|
53
|
-
}, children: children }) }) }));
|
|
29
|
+
return ((0, jsx_runtime_1.jsx)(wagmi_1.WagmiProvider, { config: wagmiConfig, children: (0, jsx_runtime_1.jsx)(react_query_1.QueryClientProvider, { client: queryClient, children: (0, jsx_runtime_1.jsx)(B3ConfigProvider_1.B3ConfigProvider, { accountOverride: accountOverride, environment: environment, automaticallySetFirstEoa: false, theme: theme, clientType: clientType, partnerId: partnerId, defaultPermissions: defaultPermissions, children: children }) }) }));
|
|
54
30
|
}
|
|
@@ -5,12 +5,14 @@ import { Wallet } from "thirdweb/wallets";
|
|
|
5
5
|
*/
|
|
6
6
|
export interface LocalSDKContextType {
|
|
7
7
|
onConnectCallback?: (wallet: Wallet, b3Jwt: string) => void | Promise<void>;
|
|
8
|
+
onLogoutCallback?: () => void | Promise<void>;
|
|
8
9
|
}
|
|
9
10
|
export declare const LocalSDKContext: import("react").Context<LocalSDKContextType>;
|
|
10
11
|
/**
|
|
11
12
|
* Local SDK Provider that wraps the app and provides internal SDK state
|
|
12
13
|
*/
|
|
13
|
-
export declare function LocalSDKProvider({ children, onConnectCallback, }: {
|
|
14
|
+
export declare function LocalSDKProvider({ children, onConnectCallback, onLogoutCallback, }: {
|
|
14
15
|
children: React.ReactNode;
|
|
15
16
|
onConnectCallback?: (wallet: Wallet, b3Jwt: string) => void | Promise<void>;
|
|
17
|
+
onLogoutCallback?: () => void | Promise<void>;
|
|
16
18
|
}): import("react/jsx-runtime").JSX.Element;
|
|
@@ -6,12 +6,14 @@ const jsx_runtime_1 = require("react/jsx-runtime");
|
|
|
6
6
|
const react_1 = require("react");
|
|
7
7
|
exports.LocalSDKContext = (0, react_1.createContext)({
|
|
8
8
|
onConnectCallback: undefined,
|
|
9
|
+
onLogoutCallback: undefined,
|
|
9
10
|
});
|
|
10
11
|
/**
|
|
11
12
|
* Local SDK Provider that wraps the app and provides internal SDK state
|
|
12
13
|
*/
|
|
13
|
-
function LocalSDKProvider({ children, onConnectCallback, }) {
|
|
14
|
+
function LocalSDKProvider({ children, onConnectCallback, onLogoutCallback, }) {
|
|
14
15
|
return ((0, jsx_runtime_1.jsx)(exports.LocalSDKContext.Provider, { value: {
|
|
15
16
|
onConnectCallback,
|
|
17
|
+
onLogoutCallback,
|
|
16
18
|
}, children: children }));
|
|
17
19
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Hook to access the B3
|
|
3
|
-
* @
|
|
2
|
+
* Hook to access the B3 configuration
|
|
3
|
+
* @deprecated This is just an alias for useB3Config. Use useB3Config directly instead.
|
|
4
4
|
*/
|
|
5
|
-
export declare function useB3(): import("./
|
|
5
|
+
export declare function useB3(): import("./B3ConfigProvider").B3ConfigContextType;
|
|
@@ -1,17 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.useB3 = useB3;
|
|
4
|
-
const
|
|
5
|
-
const types_1 = require("./types");
|
|
4
|
+
const useB3Config_1 = require("./useB3Config");
|
|
6
5
|
/**
|
|
7
|
-
* Hook to access the B3
|
|
8
|
-
* @
|
|
6
|
+
* Hook to access the B3 configuration
|
|
7
|
+
* @deprecated This is just an alias for useB3Config. Use useB3Config directly instead.
|
|
9
8
|
*/
|
|
10
9
|
function useB3() {
|
|
11
|
-
|
|
12
|
-
if (!context.initialized) {
|
|
13
|
-
throw new Error("useB3 must be used within a B3Provider");
|
|
14
|
-
}
|
|
15
|
-
// Return a stable reference
|
|
16
|
-
return (0, react_1.useMemo)(() => context, [context]);
|
|
10
|
+
return (0, useB3Config_1.useB3Config)();
|
|
17
11
|
}
|
|
@@ -2,9 +2,12 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.useB3Account = void 0;
|
|
4
4
|
const react_1 = require("thirdweb/react");
|
|
5
|
+
const useAuthStore_1 = require("../../stores/useAuthStore");
|
|
5
6
|
// Wrapper around useActiveAccount
|
|
6
7
|
const useB3Account = () => {
|
|
7
|
-
const
|
|
8
|
-
|
|
8
|
+
const isAuthenticated = (0, useAuthStore_1.useAuthStore)(state => state.isAuthenticated);
|
|
9
|
+
const activeAccount = (0, react_1.useActiveAccount)();
|
|
10
|
+
const effectiveAccount = isAuthenticated ? activeAccount : undefined;
|
|
11
|
+
return effectiveAccount;
|
|
9
12
|
};
|
|
10
13
|
exports.useB3Account = useB3Account;
|
|
@@ -1,9 +1 @@
|
|
|
1
|
-
export
|
|
2
|
-
automaticallySetFirstEoa: boolean;
|
|
3
|
-
environment: "development" | "production" | undefined;
|
|
4
|
-
theme: "light" | "dark";
|
|
5
|
-
clientType: import("../../../client-manager").ClientType;
|
|
6
|
-
partnerId: string;
|
|
7
|
-
createClientReferenceId: ((params: import("../../../../anyspend/react").CreateOrderParams | import("../../../../anyspend/react").CreateOnrampOrderParams) => Promise<string>) | undefined;
|
|
8
|
-
enableTurnkey: boolean | undefined;
|
|
9
|
-
};
|
|
1
|
+
export { useB3Config } from "./B3ConfigProvider";
|
|
@@ -1,23 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.useB3Config = void 0;
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
const useB3Config = () => {
|
|
7
|
-
const context = (0, react_1.useContext)(types_1.B3Context);
|
|
8
|
-
if (!context) {
|
|
9
|
-
throw new Error("useB3 must be used within a B3Provider");
|
|
10
|
-
}
|
|
11
|
-
const { automaticallySetFirstEoa, environment, theme, clientType, partnerId, createClientReferenceId, enableTurnkey, } = context;
|
|
12
|
-
// Return a stable reference
|
|
13
|
-
return (0, react_1.useMemo)(() => ({
|
|
14
|
-
automaticallySetFirstEoa,
|
|
15
|
-
environment,
|
|
16
|
-
theme,
|
|
17
|
-
clientType,
|
|
18
|
-
partnerId,
|
|
19
|
-
createClientReferenceId,
|
|
20
|
-
enableTurnkey,
|
|
21
|
-
}), [automaticallySetFirstEoa, environment, theme, clientType, partnerId, createClientReferenceId, enableTurnkey]);
|
|
22
|
-
};
|
|
23
|
-
exports.useB3Config = useB3Config;
|
|
4
|
+
var B3ConfigProvider_1 = require("./B3ConfigProvider");
|
|
5
|
+
Object.defineProperty(exports, "useB3Config", { enumerable: true, get: function () { return B3ConfigProvider_1.useB3Config; } });
|
|
@@ -17,8 +17,7 @@ const ProfileSection = () => {
|
|
|
17
17
|
address: eoaAddress || account?.address,
|
|
18
18
|
fresh: true,
|
|
19
19
|
});
|
|
20
|
-
const {
|
|
21
|
-
const { user } = (0, react_1.useAuthentication)(partnerId);
|
|
20
|
+
const { user } = (0, react_1.useUser)();
|
|
22
21
|
const setB3ModalOpen = (0, react_1.useModalStore)(state => state.setB3ModalOpen);
|
|
23
22
|
const setB3ModalContentType = (0, react_1.useModalStore)(state => state.setB3ModalContentType);
|
|
24
23
|
const navigateBack = (0, react_1.useModalStore)(state => state.navigateBack);
|
|
@@ -20,7 +20,7 @@ const SettingsProfileCard = () => {
|
|
|
20
20
|
address: eoaAddress || account?.address,
|
|
21
21
|
fresh: true,
|
|
22
22
|
});
|
|
23
|
-
const { partnerId } = (0, react_1.
|
|
23
|
+
const { partnerId } = (0, react_1.useB3Config)();
|
|
24
24
|
const { user, setUser } = (0, react_1.useAuthentication)(partnerId);
|
|
25
25
|
const setB3ModalOpen = (0, react_1.useModalStore)(state => state.setB3ModalOpen);
|
|
26
26
|
const setB3ModalContentType = (0, react_1.useModalStore)(state => state.setB3ModalContentType);
|
|
@@ -10,7 +10,7 @@ const toastApi_1 = require("../../Toast/toastApi");
|
|
|
10
10
|
const NotificationChannel_1 = require("../NotificationChannel");
|
|
11
11
|
const debug = (0, debug_1.debugB3React)("DiscordChannel");
|
|
12
12
|
const DiscordChannel = ({ userId, jwtToken, discordChannel, isConnected, isOptimisticallyConnected, onConnectionChange, onToggle, }) => {
|
|
13
|
-
const { partnerId } = (0, react_1.
|
|
13
|
+
const { partnerId } = (0, react_1.useB3Config)();
|
|
14
14
|
const [discordId, setDiscordId] = (0, react_2.useState)("");
|
|
15
15
|
const [isConnecting, setIsConnecting] = (0, react_2.useState)(false);
|
|
16
16
|
const [showInput, setShowInput] = (0, react_2.useState)(false);
|