@b3dotfun/sdk 0.1.0 → 0.1.1-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 +1 -1
- package/dist/cjs/anyspend/react/components/common/GasIndicator.d.ts +1 -1
- package/dist/cjs/anyspend/react/components/common/GasIndicator.js +6 -16
- 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/TokenBalance.js +15 -4
- 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/providers/AnyspendProvider.js +1 -2
- package/dist/cjs/global-account/react/components/AccountAssets/AccountAssets.js +7 -3
- package/dist/cjs/global-account/react/components/AvatarEditor/AvatarEditor.js +1 -1
- package/dist/cjs/global-account/react/components/B3DynamicModal.js +1 -15
- package/dist/cjs/global-account/react/components/B3Provider/B3Provider.d.ts +18 -2
- package/dist/cjs/global-account/react/components/B3Provider/B3Provider.js +57 -35
- 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 +36 -39
- package/dist/cjs/global-account/react/components/B3Provider/types.d.ts +27 -0
- package/dist/cjs/global-account/react/components/B3Provider/types.js +24 -0
- package/dist/cjs/global-account/react/components/B3Provider/useB3.d.ts +3 -14
- package/dist/cjs/global-account/react/components/B3Provider/useB3.js +10 -4
- package/dist/cjs/global-account/react/components/B3Provider/useB3Account.js +2 -5
- package/dist/cjs/global-account/react/components/B3Provider/useB3Config.d.ts +2 -10
- package/dist/cjs/global-account/react/components/B3Provider/useB3Config.js +17 -18
- package/dist/cjs/global-account/react/components/ManageAccount/NFTContent.js +2 -2
- package/dist/cjs/global-account/react/components/ManageAccount/ProfileSection.js +2 -1
- 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.js +13 -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/StyleRoot.js +2 -2
- package/dist/cjs/global-account/react/components/custom/ManageAccountButton.js +2 -1
- package/dist/cjs/global-account/react/components/index.d.ts +2 -1
- package/dist/cjs/global-account/react/components/index.js +6 -3
- package/dist/cjs/global-account/react/hooks/index.d.ts +2 -2
- package/dist/cjs/global-account/react/hooks/index.js +5 -3
- 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 +1 -1
- 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/useSimBalance.d.ts +7 -0
- package/dist/cjs/global-account/react/hooks/useSimBalance.js +43 -11
- package/dist/cjs/global-account/react/hooks/useSimCollectibles.d.ts +45 -0
- package/dist/cjs/global-account/react/hooks/useSimCollectibles.js +190 -0
- 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/useUserQuery.d.ts +7 -6
- package/dist/cjs/global-account/react/hooks/useUserQuery.js +39 -64
- package/dist/cjs/global-account/react/index.native.d.ts +2 -0
- package/dist/cjs/global-account/react/index.native.js +5 -1
- package/dist/cjs/global-account/react/stores/index.d.ts +0 -1
- package/dist/cjs/global-account/react/stores/index.js +1 -3
- package/dist/cjs/global-account/react/utils/simdune.d.ts +7 -0
- package/dist/cjs/global-account/react/utils/simdune.js +21 -0
- package/dist/esm/anyspend/react/components/AnySpend.js +2 -2
- package/dist/esm/anyspend/react/components/common/GasIndicator.d.ts +1 -1
- package/dist/esm/anyspend/react/components/common/GasIndicator.js +7 -17
- 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/TokenBalance.js +16 -5
- 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/providers/AnyspendProvider.js +1 -2
- package/dist/esm/global-account/react/components/AccountAssets/AccountAssets.js +7 -3
- package/dist/esm/global-account/react/components/AvatarEditor/AvatarEditor.js +2 -2
- package/dist/esm/global-account/react/components/B3DynamicModal.js +2 -16
- package/dist/esm/global-account/react/components/B3Provider/B3Provider.d.ts +18 -2
- package/dist/esm/global-account/react/components/B3Provider/B3Provider.js +58 -34
- 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 +37 -37
- package/dist/esm/global-account/react/components/B3Provider/types.d.ts +27 -0
- package/dist/esm/global-account/react/components/B3Provider/types.js +21 -0
- package/dist/esm/global-account/react/components/B3Provider/useB3.d.ts +3 -14
- package/dist/esm/global-account/react/components/B3Provider/useB3.js +10 -4
- package/dist/esm/global-account/react/components/B3Provider/useB3Account.js +2 -5
- package/dist/esm/global-account/react/components/B3Provider/useB3Config.d.ts +2 -10
- package/dist/esm/global-account/react/components/B3Provider/useB3Config.js +17 -18
- package/dist/esm/global-account/react/components/ManageAccount/NFTContent.js +3 -3
- package/dist/esm/global-account/react/components/ManageAccount/ProfileSection.js +3 -2
- 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.js +15 -4
- 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/StyleRoot.js +2 -2
- package/dist/esm/global-account/react/components/custom/ManageAccountButton.js +3 -2
- package/dist/esm/global-account/react/components/index.d.ts +2 -1
- package/dist/esm/global-account/react/components/index.js +2 -1
- package/dist/esm/global-account/react/hooks/index.d.ts +2 -2
- package/dist/esm/global-account/react/hooks/index.js +2 -2
- 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 +1 -1
- 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/useSimBalance.d.ts +7 -0
- package/dist/esm/global-account/react/hooks/useSimBalance.js +42 -11
- package/dist/esm/global-account/react/hooks/useSimCollectibles.d.ts +45 -0
- package/dist/esm/global-account/react/hooks/useSimCollectibles.js +187 -0
- 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/useUserQuery.d.ts +7 -6
- package/dist/esm/global-account/react/hooks/useUserQuery.js +37 -63
- package/dist/esm/global-account/react/index.native.d.ts +2 -0
- package/dist/esm/global-account/react/index.native.js +2 -0
- package/dist/esm/global-account/react/stores/index.d.ts +0 -1
- package/dist/esm/global-account/react/stores/index.js +0 -1
- package/dist/esm/global-account/react/utils/simdune.d.ts +7 -0
- package/dist/esm/global-account/react/utils/simdune.js +17 -0
- package/dist/styles/index.css +1 -1
- package/dist/types/anyspend/react/components/common/GasIndicator.d.ts +1 -1
- package/dist/types/global-account/react/components/B3Provider/B3Provider.d.ts +18 -2
- package/dist/types/global-account/react/components/B3Provider/B3Provider.native.d.ts +6 -6
- package/dist/types/global-account/react/components/B3Provider/types.d.ts +27 -0
- package/dist/types/global-account/react/components/B3Provider/useB3.d.ts +3 -14
- package/dist/types/global-account/react/components/B3Provider/useB3Config.d.ts +2 -10
- package/dist/types/global-account/react/components/index.d.ts +2 -1
- package/dist/types/global-account/react/hooks/index.d.ts +2 -2
- 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/useSimBalance.d.ts +7 -0
- package/dist/types/global-account/react/hooks/useSimCollectibles.d.ts +45 -0
- package/dist/types/global-account/react/hooks/useUserQuery.d.ts +7 -6
- package/dist/types/global-account/react/index.native.d.ts +2 -0
- package/dist/types/global-account/react/stores/index.d.ts +0 -1
- package/dist/types/global-account/react/utils/simdune.d.ts +7 -0
- package/package.json +1 -1
- package/src/anyspend/react/components/AnySpend.tsx +2 -2
- package/src/anyspend/react/components/common/GasIndicator.tsx +11 -30
- 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/TokenBalance.tsx +17 -5
- 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/providers/AnyspendProvider.tsx +2 -5
- package/src/global-account/react/components/AccountAssets/AccountAssets.tsx +25 -13
- package/src/global-account/react/components/AvatarEditor/AvatarEditor.tsx +2 -2
- package/src/global-account/react/components/B3DynamicModal.tsx +2 -18
- package/src/global-account/react/components/B3Provider/B3Provider.native.tsx +57 -46
- package/src/global-account/react/components/B3Provider/B3Provider.tsx +117 -44
- package/src/global-account/react/components/B3Provider/types.ts +50 -0
- package/src/global-account/react/components/B3Provider/useB3.ts +12 -4
- package/src/global-account/react/components/B3Provider/useB3Account.ts +2 -6
- package/src/global-account/react/components/B3Provider/useB3Config.ts +31 -18
- package/src/global-account/react/components/ManageAccount/NFTContent.tsx +4 -4
- package/src/global-account/react/components/ManageAccount/ProfileSection.tsx +4 -2
- 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 +15 -4
- 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/StyleRoot.tsx +2 -2
- package/src/global-account/react/components/custom/ManageAccountButton.tsx +3 -2
- package/src/global-account/react/components/index.ts +2 -1
- package/src/global-account/react/hooks/index.ts +2 -2
- package/src/global-account/react/hooks/useAuth.ts +3 -3
- package/src/global-account/react/hooks/useAuthentication.ts +1 -1
- 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/useSimBalance.ts +49 -12
- package/src/global-account/react/hooks/useSimCollectibles.ts +238 -0
- package/src/global-account/react/hooks/useTokenBalance.tsx +7 -8
- package/src/global-account/react/hooks/useTurnkeyAuth.ts +2 -2
- package/src/global-account/react/hooks/useUserQuery.ts +51 -64
- package/src/global-account/react/index.native.ts +2 -0
- package/src/global-account/react/stores/index.ts +0 -1
- package/src/global-account/react/utils/simdune.ts +20 -0
- package/dist/cjs/global-account/react/components/B3Provider/AuthenticationProvider.d.ts +0 -5
- package/dist/cjs/global-account/react/components/B3Provider/AuthenticationProvider.js +0 -12
- package/dist/cjs/global-account/react/hooks/useUser.d.ts +0 -60
- package/dist/cjs/global-account/react/hooks/useUser.js +0 -20
- package/dist/cjs/global-account/react/stores/configStore.d.ts +0 -24
- package/dist/cjs/global-account/react/stores/configStore.js +0 -30
- package/dist/cjs/global-account/react/stores/userStore.d.ts +0 -22
- package/dist/cjs/global-account/react/stores/userStore.js +0 -30
- package/dist/esm/global-account/react/components/B3Provider/AuthenticationProvider.d.ts +0 -5
- package/dist/esm/global-account/react/components/B3Provider/AuthenticationProvider.js +0 -10
- package/dist/esm/global-account/react/hooks/useUser.d.ts +0 -60
- package/dist/esm/global-account/react/hooks/useUser.js +0 -17
- package/dist/esm/global-account/react/stores/configStore.d.ts +0 -24
- package/dist/esm/global-account/react/stores/configStore.js +0 -27
- package/dist/esm/global-account/react/stores/userStore.d.ts +0 -22
- package/dist/esm/global-account/react/stores/userStore.js +0 -27
- package/dist/types/global-account/react/components/B3Provider/AuthenticationProvider.d.ts +0 -5
- package/dist/types/global-account/react/hooks/useUser.d.ts +0 -60
- package/dist/types/global-account/react/stores/configStore.d.ts +0 -24
- package/dist/types/global-account/react/stores/userStore.d.ts +0 -22
- package/src/global-account/react/components/B3Provider/AuthenticationProvider.tsx +0 -19
- package/src/global-account/react/hooks/useUser.ts +0 -20
- package/src/global-account/react/stores/configStore.ts +0 -51
- package/src/global-account/react/stores/userStore.ts +0 -41
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import {
|
|
2
|
+
import { useB3 } from "../../../../../global-account/react/index.js";
|
|
3
3
|
import { debugB3React } from "../../../../../shared/utils/debug.js";
|
|
4
4
|
import { useState } from "react";
|
|
5
5
|
import { notificationsAPI } from "../../../utils/notificationsAPI.js";
|
|
@@ -7,7 +7,7 @@ import { toast } from "../../Toast/toastApi.js";
|
|
|
7
7
|
import { NotificationChannel } from "../NotificationChannel.js";
|
|
8
8
|
const debug = debugB3React("DiscordChannel");
|
|
9
9
|
export const DiscordChannel = ({ userId, jwtToken, discordChannel, isConnected, isOptimisticallyConnected, onConnectionChange, onToggle, }) => {
|
|
10
|
-
const { partnerId } =
|
|
10
|
+
const { partnerId } = useB3();
|
|
11
11
|
const [discordId, setDiscordId] = useState("");
|
|
12
12
|
const [isConnecting, setIsConnecting] = useState(false);
|
|
13
13
|
const [showInput, setShowInput] = useState(false);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import {
|
|
2
|
+
import { useB3 } from "../../../../../global-account/react/index.js";
|
|
3
3
|
import { debugB3React } from "../../../../../shared/utils/debug.js";
|
|
4
4
|
import { useState } from "react";
|
|
5
5
|
import { notificationsAPI } from "../../../utils/notificationsAPI.js";
|
|
@@ -11,7 +11,7 @@ const validateEmail = (email) => {
|
|
|
11
11
|
return emailRegex.test(email);
|
|
12
12
|
};
|
|
13
13
|
export const EmailChannel = ({ userId, jwtToken, emailChannel, isConnected, isOptimisticallyConnected, onConnectionChange, onToggle, }) => {
|
|
14
|
-
const { partnerId } =
|
|
14
|
+
const { partnerId } = useB3();
|
|
15
15
|
const [email, setEmail] = useState("");
|
|
16
16
|
const [emailError, setEmailError] = useState(null);
|
|
17
17
|
const [isConnecting, setIsConnecting] = useState(false);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
-
import {
|
|
2
|
+
import { useB3 } from "../../../../../global-account/react/index.js";
|
|
3
3
|
import { debugB3React } from "../../../../../shared/utils/debug.js";
|
|
4
4
|
import { useState } from "react";
|
|
5
5
|
import { notificationsAPI } from "../../../utils/notificationsAPI.js";
|
|
@@ -7,7 +7,7 @@ import { toast } from "../../Toast/toastApi.js";
|
|
|
7
7
|
import { NotificationChannel } from "../NotificationChannel.js";
|
|
8
8
|
const debug = debugB3React("PhoneChannel");
|
|
9
9
|
export const PhoneChannel = ({ userId, jwtToken, smsChannel, whatsappChannel, isSMSConnected, isWhatsAppConnected, isOptimisticallySMSConnected, isOptimisticallyWhatsAppConnected, onConnectionChange, onToggle, }) => {
|
|
10
|
-
const { partnerId } =
|
|
10
|
+
const { partnerId } = useB3();
|
|
11
11
|
const [phoneNumber, setPhoneNumber] = useState("");
|
|
12
12
|
const [isConnectingSMS, setIsConnectingSMS] = useState(false);
|
|
13
13
|
const [isConnectingWhatsApp, setIsConnectingWhatsApp] = useState(false);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import {
|
|
2
|
+
import { useB3 } from "../../../../../global-account/react/index.js";
|
|
3
3
|
import { debugB3React } from "../../../../../shared/utils/debug.js";
|
|
4
4
|
import { useState } from "react";
|
|
5
5
|
import { notificationsAPI } from "../../../utils/notificationsAPI.js";
|
|
@@ -7,7 +7,7 @@ import { toast } from "../../Toast/toastApi.js";
|
|
|
7
7
|
import { NotificationChannel } from "../NotificationChannel.js";
|
|
8
8
|
const debug = debugB3React("TelegramChannel");
|
|
9
9
|
export const TelegramChannel = ({ userId, jwtToken, telegramChannel, isConnected, isOptimisticallyConnected, onConnectionChange, onToggle, }) => {
|
|
10
|
-
const { partnerId } =
|
|
10
|
+
const { partnerId } = useB3();
|
|
11
11
|
const [isConnecting, setIsConnecting] = useState(false);
|
|
12
12
|
const [status, setStatus] = useState("idle");
|
|
13
13
|
// Detect if we're disconnecting
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { Button, PermissionItem, useAddTWSessionKey,
|
|
2
|
+
import { Button, PermissionItem, useAddTWSessionKey, useB3, useGetAllTWSigners, } from "../../../../global-account/react/index.js";
|
|
3
3
|
import { debugB3React } from "../../../../shared/utils/debug.js";
|
|
4
4
|
import { formatAddress } from "../../../../shared/utils/formatAddress.js";
|
|
5
5
|
import { CreditCard, Eye } from "lucide-react";
|
|
@@ -14,7 +14,7 @@ const debug = debugB3React("RequestPermissions");
|
|
|
14
14
|
export function RequestPermissions({ onSuccess, onError, chain, sessionKeyAddress, permissions, }) {
|
|
15
15
|
const [isApproving, setIsApproving] = useState(false);
|
|
16
16
|
const account = useActiveAccount();
|
|
17
|
-
const { defaultPermissions } =
|
|
17
|
+
const { defaultPermissions } = useB3();
|
|
18
18
|
const DEFAULT_PERMISSIONS = useMemo(() => permissions ?? defaultPermissions, [defaultPermissions, permissions]);
|
|
19
19
|
const { refetch: refetchSigners } = useGetAllTWSigners({
|
|
20
20
|
chain,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
-
import { IPFSMediaRenderer, SignInWithB3, StyleRoot, useAccountWallet, useAuthentication,
|
|
2
|
+
import { IPFSMediaRenderer, SignInWithB3, StyleRoot, useAccountWallet, useAuthentication, useB3, useIsMobile, } from "../../../../global-account/react/index.js";
|
|
3
3
|
import Icon from "../../../../global-account/react/components/custom/Icon.js";
|
|
4
4
|
import { ecosystemWalletId } from "../../../../shared/constants/index.js";
|
|
5
5
|
import { cn, truncateAddress } from "../../../../shared/utils/index.js";
|
|
@@ -9,7 +9,7 @@ import { useConnectedWallets, useSetActiveWallet, useWalletImage } from "thirdwe
|
|
|
9
9
|
import { ManageAccountButton } from "../custom/ManageAccountButton.js";
|
|
10
10
|
export function SignIn(props) {
|
|
11
11
|
const { className } = props;
|
|
12
|
-
const { automaticallySetFirstEoa, partnerId } =
|
|
12
|
+
const { automaticallySetFirstEoa, partnerId } = useB3();
|
|
13
13
|
const { address: globalAddress, ensName, connectedSmartWallet, connectedEOAWallet, isActiveSmartWallet, isActiveEOAWallet, smartWalletIcon, } = useAccountWallet();
|
|
14
14
|
const { data: walletImage } = useWalletImage(connectedEOAWallet?.id);
|
|
15
15
|
const isMobile = useIsMobile();
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { Loading, useAuthentication, useAuthStore,
|
|
2
|
+
import { Loading, useAuthentication, useAuthStore, useB3, useGetAllTWSigners, useModalStore, } from "../../../../global-account/react/index.js";
|
|
3
3
|
import { debugB3React } from "../../../../shared/utils/debug.js";
|
|
4
|
-
import { useCallback, useEffect, useState } from "react";
|
|
4
|
+
import { useCallback, useEffect, useRef, useState } from "react";
|
|
5
5
|
import { useActiveAccount } from "thirdweb/react";
|
|
6
6
|
import { TurnkeyAuthModal } from "../TurnkeyAuthModal.js";
|
|
7
7
|
import { SignInWithB3Privy } from "./SignInWithB3Privy.js";
|
|
@@ -14,8 +14,19 @@ const MAX_REFETCH_ATTEMPTS = 20;
|
|
|
14
14
|
* Handles different login providers, authentication steps, and session key management
|
|
15
15
|
*/
|
|
16
16
|
export function SignInWithB3Flow({ strategies, onLoginSuccess, onSessionKeySuccess, onError, chain, sessionKeyAddress, partnerId, closeAfterLogin = false, source = "signInWithB3Button", signersEnabled = false, }) {
|
|
17
|
-
const { automaticallySetFirstEoa, enableTurnkey } =
|
|
18
|
-
const { user, refetchUser } = useAuthentication(partnerId);
|
|
17
|
+
const { automaticallySetFirstEoa, enableTurnkey } = useB3();
|
|
18
|
+
const { user, refetchUser, logout } = useAuthentication(partnerId);
|
|
19
|
+
// FIXME Logout before login to ensure a clean state
|
|
20
|
+
const hasLoggedOutRef = useRef(false);
|
|
21
|
+
useEffect(() => {
|
|
22
|
+
if (hasLoggedOutRef.current)
|
|
23
|
+
return;
|
|
24
|
+
if (source !== "requestPermissions") {
|
|
25
|
+
debug("Logging out before login");
|
|
26
|
+
logout();
|
|
27
|
+
hasLoggedOutRef.current = true;
|
|
28
|
+
}
|
|
29
|
+
}, [source, logout]);
|
|
19
30
|
const [step, setStep] = useState(source === "requestPermissions" ? null : "login");
|
|
20
31
|
const [sessionKeyAdded, setSessionKeyAdded] = useState(source === "requestPermissions" ? true : false);
|
|
21
32
|
const { setB3ModalContentType, setB3ModalOpen, isOpen, contentType } = useModalStore();
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { Loading, useAuthentication, useAuthStore,
|
|
2
|
+
import { Loading, useAuthentication, useAuthStore, useB3, useHandleConnectWithPrivy, } from "../../../../global-account/react/index.js";
|
|
3
3
|
import { debugB3React } from "../../../../shared/utils/debug.js";
|
|
4
4
|
import { useEffect } from "react";
|
|
5
5
|
const debug = debugB3React("SignInWithB3Privy");
|
|
6
6
|
export function SignInWithB3Privy({ onSuccess, onError, chain }) {
|
|
7
|
-
const { partnerId } =
|
|
7
|
+
const { partnerId } = useB3();
|
|
8
8
|
const { isLoading, connectTw, fullToken } = useHandleConnectWithPrivy(chain, onSuccess);
|
|
9
9
|
const setIsAuthenticating = useAuthStore(state => state.setIsAuthenticating);
|
|
10
10
|
const setIsAuthenticated = useAuthStore(state => state.setIsAuthenticated);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { useAuthentication,
|
|
2
|
+
import { useAuthentication, useB3, useQueryB3 } from "../../../../../global-account/react/index.js";
|
|
3
3
|
import { ecosystemWalletId } from "../../../../../shared/constants/index.js";
|
|
4
4
|
import { client } from "../../../../../shared/utils/thirdweb.js";
|
|
5
5
|
import { ConnectEmbed, darkTheme, lightTheme } from "thirdweb/react";
|
|
@@ -15,7 +15,7 @@ export function LoginStepContainer({ children, partnerId }) {
|
|
|
15
15
|
return (_jsxs("div", { className: "bg-b3-react-background flex flex-col items-center justify-center pt-6", children: [partnerLogo && (_jsx("img", { src: partnerLogo, alt: "Partner Logo", className: "partner-logo mb-6 h-12 w-auto object-contain" })), children] }));
|
|
16
16
|
}
|
|
17
17
|
export function LoginStep({ onSuccess, chain }) {
|
|
18
|
-
const { partnerId, theme } =
|
|
18
|
+
const { partnerId, theme } = useB3();
|
|
19
19
|
const wallet = ecosystemWallet(ecosystemWalletId, {
|
|
20
20
|
partnerId: partnerId,
|
|
21
21
|
});
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { AuthButton, Button, getConnectOptionsFromStrategy, isWalletType, LoginStepContainer, useAuthentication, useAuthStore,
|
|
2
|
+
import { AuthButton, Button, getConnectOptionsFromStrategy, isWalletType, LoginStepContainer, useAuthentication, useAuthStore, useB3, useConnect, WalletRow, } from "../../../../../global-account/react/index.js";
|
|
3
3
|
import { debugB3React } from "../../../../../shared/utils/debug.js";
|
|
4
4
|
import { client } from "../../../../../shared/utils/thirdweb.js";
|
|
5
5
|
import { useState } from "react";
|
|
@@ -7,7 +7,7 @@ import { useConnect as useConnectTW } from "thirdweb/react";
|
|
|
7
7
|
import { createWallet } from "thirdweb/wallets";
|
|
8
8
|
const debug = debugB3React("LoginStepCustom");
|
|
9
9
|
export function LoginStepCustom({ onSuccess, onError, chain, strategies, maxInitialWallets = 2, automaticallySetFirstEoa, }) {
|
|
10
|
-
const { partnerId } =
|
|
10
|
+
const { partnerId } = useB3();
|
|
11
11
|
const [isLoading, setIsLoading] = useState(false);
|
|
12
12
|
const [showAllWallets, setShowAllWallets] = useState(false);
|
|
13
13
|
const { connect } = useConnect(partnerId, chain);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import {
|
|
2
|
+
import { useB3 } from "./B3Provider/useB3.js";
|
|
3
3
|
export function StyleRoot({ children, id }) {
|
|
4
|
-
const { theme } =
|
|
4
|
+
const { theme } = useB3();
|
|
5
5
|
return (_jsx("div", { className: "b3-root", id: id, "data-theme": theme, children: children }));
|
|
6
6
|
}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { Button, StyleRoot,
|
|
2
|
+
import { Button, StyleRoot, useAuthentication, useB3, useModalStore } from "../../../../global-account/react/index.js";
|
|
3
3
|
import { cn } from "../../../../shared/utils/index.js";
|
|
4
4
|
export function ManageAccountButton(props) {
|
|
5
|
+
const { partnerId } = useB3();
|
|
5
6
|
const { setB3ModalOpen, setB3ModalContentType } = useModalStore();
|
|
6
|
-
const { isConnected } =
|
|
7
|
+
const { isConnected } = useAuthentication(partnerId);
|
|
7
8
|
const handleClickManageAccount = () => {
|
|
8
9
|
setB3ModalContentType({
|
|
9
10
|
...props,
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export { B3DynamicModal } from "./B3DynamicModal";
|
|
2
|
-
export { B3Provider } from "./B3Provider/B3Provider";
|
|
2
|
+
export { B3Provider, InnerProvider } from "./B3Provider/B3Provider";
|
|
3
3
|
export { RelayKitProviderWrapper } from "./B3Provider/RelayKitProviderWrapper";
|
|
4
|
+
export { B3Context, type B3ContextType } from "./B3Provider/types";
|
|
4
5
|
export { useB3 } from "./B3Provider/useB3";
|
|
5
6
|
export { useB3Account } from "./B3Provider/useB3Account";
|
|
6
7
|
export { useB3Config } from "./B3Provider/useB3Config";
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
// TODO woj: Barrel file for all components, this might be reason of bundle size issues
|
|
2
2
|
// Core Components
|
|
3
3
|
export { B3DynamicModal } from "./B3DynamicModal.js";
|
|
4
|
-
export { B3Provider } from "./B3Provider/B3Provider.js";
|
|
4
|
+
export { B3Provider, InnerProvider } from "./B3Provider/B3Provider.js";
|
|
5
5
|
export { RelayKitProviderWrapper } from "./B3Provider/RelayKitProviderWrapper.js";
|
|
6
|
+
export { B3Context } from "./B3Provider/types.js";
|
|
6
7
|
export { useB3 } from "./B3Provider/useB3.js";
|
|
7
8
|
export { useB3Account } from "./B3Provider/useB3Account.js";
|
|
8
9
|
export { useB3Config } from "./B3Provider/useB3Config.js";
|
|
@@ -30,7 +30,8 @@ export { useQueryBSMNT } from "./useQueryBSMNT";
|
|
|
30
30
|
export { useRemoveSessionKey } from "./useRemoveSessionKey";
|
|
31
31
|
export { useRouter } from "./useRouter";
|
|
32
32
|
export { useSearchParamsSSR } from "./useSearchParamsSSR";
|
|
33
|
-
export { useSimBalance, useSimSvmBalance } from "./useSimBalance";
|
|
33
|
+
export { useSimBalance, useSimSvmBalance, useSimTokenBalance } from "./useSimBalance";
|
|
34
|
+
export { useSimCollectibles } from "./useSimCollectibles";
|
|
34
35
|
export { useSiwe } from "./useSiwe";
|
|
35
36
|
export { useTokenBalance } from "./useTokenBalance";
|
|
36
37
|
export { useTokenBalanceDirect } from "./useTokenBalanceDirect";
|
|
@@ -43,4 +44,3 @@ export { useTokensFromAddress } from "./useTokensFromAddress";
|
|
|
43
44
|
export { useTurnkeyAuth } from "./useTurnkeyAuth";
|
|
44
45
|
export { useUnifiedChainSwitchAndExecute } from "./useUnifiedChainSwitchAndExecute";
|
|
45
46
|
export { useURLParams } from "./useURLParams";
|
|
46
|
-
export { useUser } from "./useUser";
|
|
@@ -30,7 +30,8 @@ export { useQueryBSMNT } from "./useQueryBSMNT.js";
|
|
|
30
30
|
export { useRemoveSessionKey } from "./useRemoveSessionKey.js";
|
|
31
31
|
export { useRouter } from "./useRouter.js";
|
|
32
32
|
export { useSearchParamsSSR } from "./useSearchParamsSSR.js";
|
|
33
|
-
export { useSimBalance, useSimSvmBalance } from "./useSimBalance.js";
|
|
33
|
+
export { useSimBalance, useSimSvmBalance, useSimTokenBalance } from "./useSimBalance.js";
|
|
34
|
+
export { useSimCollectibles } from "./useSimCollectibles.js";
|
|
34
35
|
export { useSiwe } from "./useSiwe.js";
|
|
35
36
|
export { useTokenBalance } from "./useTokenBalance.js";
|
|
36
37
|
export { useTokenBalanceDirect } from "./useTokenBalanceDirect.js";
|
|
@@ -43,4 +44,3 @@ export { useTokensFromAddress } from "./useTokensFromAddress.js";
|
|
|
43
44
|
export { useTurnkeyAuth } from "./useTurnkeyAuth.js";
|
|
44
45
|
export { useUnifiedChainSwitchAndExecute } from "./useUnifiedChainSwitchAndExecute.js";
|
|
45
46
|
export { useURLParams } from "./useURLParams.js";
|
|
46
|
-
export { useUser } from "./useUser.js";
|
|
@@ -70,7 +70,7 @@ export declare function useAuth(): {
|
|
|
70
70
|
turnkeyId?: string | undefined;
|
|
71
71
|
turnkeyOtpId?: string | undefined;
|
|
72
72
|
};
|
|
73
|
-
} |
|
|
73
|
+
} | null;
|
|
74
74
|
refetchUser: () => Promise<import("@feathersjs/authentication").AuthenticationResult>;
|
|
75
|
-
setUser: (
|
|
75
|
+
setUser: (user: import("@b3dotfun/b3-api").Users | undefined) => void;
|
|
76
76
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import app from "../../../global-account/app.js";
|
|
2
2
|
import { authenticateWithB3JWT } from "../../../global-account/bsmnt.js";
|
|
3
|
-
import { useAuthStore,
|
|
3
|
+
import { useAuthStore, useB3 } from "../../../global-account/react/index.js";
|
|
4
4
|
import { ecosystemWalletId } from "../../../shared/constants/index.js";
|
|
5
5
|
import { debugB3React } from "../../../shared/utils/debug.js";
|
|
6
6
|
import { client } from "../../../shared/utils/thirdweb.js";
|
|
@@ -38,7 +38,7 @@ export function useAuth() {
|
|
|
38
38
|
const hasStartedConnecting = useAuthStore(state => state.hasStartedConnecting);
|
|
39
39
|
const useAutoConnectLoadingPrevious = useRef(false);
|
|
40
40
|
const referralCode = useSearchParam("referralCode");
|
|
41
|
-
const { partnerId } =
|
|
41
|
+
const { partnerId } = useB3();
|
|
42
42
|
const wagmiConfig = createWagmiConfig({ partnerId });
|
|
43
43
|
const { connect } = useConnect();
|
|
44
44
|
const activeWagmiAccount = useAccount();
|
|
@@ -288,7 +288,7 @@ export function useAuth() {
|
|
|
288
288
|
debug("@@logout:loggedOut");
|
|
289
289
|
setIsAuthenticated(false);
|
|
290
290
|
setIsConnected(false);
|
|
291
|
-
setUser();
|
|
291
|
+
setUser(undefined);
|
|
292
292
|
callback?.();
|
|
293
293
|
}, [activeWallet, disconnect, wallets, setIsAuthenticated, setUser, setIsConnected]);
|
|
294
294
|
const { isLoading: useAutoConnectLoading } = useAutoConnect({
|
|
@@ -62,7 +62,7 @@ export declare function useAuthentication(partnerId: string): {
|
|
|
62
62
|
turnkeyId?: string | undefined;
|
|
63
63
|
turnkeyOtpId?: string | undefined;
|
|
64
64
|
};
|
|
65
|
-
} |
|
|
65
|
+
} | null;
|
|
66
66
|
refetchUser: (wallet?: Wallet) => Promise<import("@feathersjs/authentication").AuthenticationResult>;
|
|
67
|
-
setUser: (
|
|
67
|
+
setUser: (user: import("@b3dotfun/b3-api").Users | undefined) => void;
|
|
68
68
|
};
|
|
@@ -148,7 +148,7 @@ export function useAuthentication(partnerId) {
|
|
|
148
148
|
debug("@@logout:loggedOut");
|
|
149
149
|
setIsAuthenticated(false);
|
|
150
150
|
setIsConnected(false);
|
|
151
|
-
setUser();
|
|
151
|
+
setUser(undefined);
|
|
152
152
|
callback?.();
|
|
153
153
|
}, [activeWallet, disconnect, wallets, setIsAuthenticated, setUser, setIsConnected]);
|
|
154
154
|
const onConnect = useCallback(async (_walleAutoConnectedWith, allConnectedWallets) => {
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { useB3 } from "../../../global-account/react/index.js";
|
|
2
2
|
import { useCallback } from "react";
|
|
3
3
|
import { authenticateBoth, authenticateWithClient, getClient, getClientByType, setClientType, } from "../../client-manager.js";
|
|
4
4
|
/**
|
|
5
5
|
* Hook to access the current FeathersJS client and client management utilities
|
|
6
6
|
*/
|
|
7
7
|
export function useClient() {
|
|
8
|
-
const { clientType } =
|
|
8
|
+
const { clientType } = useB3();
|
|
9
9
|
const getCurrentClient = useCallback(() => {
|
|
10
10
|
return getClient();
|
|
11
11
|
}, []);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { useB3, useConnect } from "../../../global-account/react/index.js";
|
|
2
2
|
import { debugB3React } from "../../../shared/utils/debug.js";
|
|
3
3
|
import { useIdentityToken, usePrivy } from "@privy-io/react-auth";
|
|
4
4
|
import { useCallback, useRef, useState } from "react";
|
|
@@ -8,7 +8,7 @@ const debug = debugB3React("@@b3:useHandleConnectWithPrivy");
|
|
|
8
8
|
* Currently, this is for the basement-privy strategy
|
|
9
9
|
*/
|
|
10
10
|
export function useHandleConnectWithPrivy(chain, onSuccess) {
|
|
11
|
-
const { partnerId } =
|
|
11
|
+
const { partnerId } = useB3();
|
|
12
12
|
if (!chain) {
|
|
13
13
|
throw new Error("Chain is required");
|
|
14
14
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { useB3 } from "../../../global-account/react/index.js";
|
|
2
2
|
import { getAuthToken } from "../../../shared/utils/auth-token.js";
|
|
3
3
|
import { debugB3React } from "../../../shared/utils/debug.js";
|
|
4
4
|
import { useCallback, useEffect, useState } from "react";
|
|
@@ -27,7 +27,7 @@ const debug = debugB3React("useNotifications");
|
|
|
27
27
|
*/
|
|
28
28
|
export function useNotifications() {
|
|
29
29
|
const { user } = useUserQuery();
|
|
30
|
-
const { partnerId } =
|
|
30
|
+
const { partnerId } = useB3();
|
|
31
31
|
const [userData, setUserData] = useState(null);
|
|
32
32
|
const [loading, setLoading] = useState(true);
|
|
33
33
|
const [error, setError] = useState(null);
|
|
@@ -50,3 +50,10 @@ export interface SvmBalanceResponse {
|
|
|
50
50
|
}
|
|
51
51
|
export declare function useSimBalance(address?: string, chainIdsParam?: number[]): import("@tanstack/react-query").UseQueryResult<SimBalanceResponse, Error>;
|
|
52
52
|
export declare function useSimSvmBalance(address?: string, chains?: ("solana" | "eclipse")[], limit?: number): import("@tanstack/react-query").UseQueryResult<SvmBalanceResponse, Error>;
|
|
53
|
+
/**
|
|
54
|
+
* Hook to fetch a single token balance for a wallet.
|
|
55
|
+
* @param walletAddress - The wallet address to fetch balance for
|
|
56
|
+
* @param tokenAddress - The token contract address, or "native" for native token (ETH, etc.)
|
|
57
|
+
* @param chainId - Chain ID to query (defaults to 1 for Ethereum mainnet)
|
|
58
|
+
*/
|
|
59
|
+
export declare function useSimTokenBalance(walletAddress?: string, tokenAddress?: string, chainId?: number): import("@tanstack/react-query").UseQueryResult<SimBalanceResponse, Error>;
|
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import { useQuery } from "@tanstack/react-query";
|
|
2
|
+
import { buildSimduneUrl } from "../utils/simdune.js";
|
|
2
3
|
async function fetchSimBalance(address, chainIdsParam) {
|
|
3
4
|
if (!address)
|
|
4
5
|
throw new Error("Address is required");
|
|
5
6
|
const chainIds = chainIdsParam.length === 0 ? "mainnet" : chainIdsParam.join(",");
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
const queryParams = new URLSearchParams();
|
|
8
|
+
queryParams.append("metadata", "logo");
|
|
9
|
+
queryParams.append("chain_ids", chainIds);
|
|
10
|
+
queryParams.append("exclude_spam_tokens", "true");
|
|
11
|
+
const url = buildSimduneUrl(`/v1/evm/balances/${address}`, queryParams);
|
|
10
12
|
const response = await fetch(url);
|
|
11
13
|
if (!response.ok) {
|
|
12
14
|
throw new Error(`Failed to fetch balance: ${response.statusText}`);
|
|
@@ -14,6 +16,23 @@ async function fetchSimBalance(address, chainIdsParam) {
|
|
|
14
16
|
const balanceData = await response.json();
|
|
15
17
|
return balanceData;
|
|
16
18
|
}
|
|
19
|
+
async function fetchSimTokenBalance(walletAddress, tokenAddress, chainId) {
|
|
20
|
+
if (!walletAddress)
|
|
21
|
+
throw new Error("Wallet address is required");
|
|
22
|
+
if (!tokenAddress)
|
|
23
|
+
throw new Error("Token address is required");
|
|
24
|
+
if (!chainId)
|
|
25
|
+
throw new Error("Chain ID is required");
|
|
26
|
+
const queryParams = new URLSearchParams();
|
|
27
|
+
queryParams.append("chain_ids", chainId.toString());
|
|
28
|
+
const url = buildSimduneUrl(`/v1/evm/balances/${walletAddress}/token/${tokenAddress}`, queryParams);
|
|
29
|
+
const response = await fetch(url);
|
|
30
|
+
if (!response.ok) {
|
|
31
|
+
throw new Error(`Failed to fetch token balance: ${response.statusText}`);
|
|
32
|
+
}
|
|
33
|
+
const balanceData = await response.json();
|
|
34
|
+
return balanceData;
|
|
35
|
+
}
|
|
17
36
|
async function fetchSimSvmBalance(address, chains, limit) {
|
|
18
37
|
if (!address)
|
|
19
38
|
throw new Error("Address is required");
|
|
@@ -24,13 +43,7 @@ async function fetchSimSvmBalance(address, chains, limit) {
|
|
|
24
43
|
if (limit) {
|
|
25
44
|
queryParams.append("limit", limit.toString());
|
|
26
45
|
}
|
|
27
|
-
|
|
28
|
-
if (queryParams.toString()) {
|
|
29
|
-
url += `?${queryParams.toString()}`;
|
|
30
|
-
}
|
|
31
|
-
if (process.env.NEXT_PUBLIC_LOCAL_SIMDUNE_KEY) {
|
|
32
|
-
url += `${queryParams.toString() ? "&" : "?"}localkey=${process.env.NEXT_PUBLIC_LOCAL_SIMDUNE_KEY}`;
|
|
33
|
-
}
|
|
46
|
+
const url = buildSimduneUrl(`/beta/svm/balances/${address}`, queryParams.toString() ? queryParams : undefined);
|
|
34
47
|
const response = await fetch(url);
|
|
35
48
|
if (!response.ok) {
|
|
36
49
|
throw new Error(`Failed to fetch SVM balance: ${response.statusText}`);
|
|
@@ -60,3 +73,21 @@ export function useSimSvmBalance(address, chains, limit) {
|
|
|
60
73
|
enabled: Boolean(address),
|
|
61
74
|
});
|
|
62
75
|
}
|
|
76
|
+
/**
|
|
77
|
+
* Hook to fetch a single token balance for a wallet.
|
|
78
|
+
* @param walletAddress - The wallet address to fetch balance for
|
|
79
|
+
* @param tokenAddress - The token contract address, or "native" for native token (ETH, etc.)
|
|
80
|
+
* @param chainId - Chain ID to query (defaults to 1 for Ethereum mainnet)
|
|
81
|
+
*/
|
|
82
|
+
export function useSimTokenBalance(walletAddress, tokenAddress, chainId) {
|
|
83
|
+
return useQuery({
|
|
84
|
+
queryKey: ["simTokenBalance", walletAddress, tokenAddress, chainId],
|
|
85
|
+
queryFn: () => {
|
|
86
|
+
if (!walletAddress || !tokenAddress || !chainId) {
|
|
87
|
+
throw new Error("Missing required parameters");
|
|
88
|
+
}
|
|
89
|
+
return fetchSimTokenBalance(walletAddress, tokenAddress, chainId);
|
|
90
|
+
},
|
|
91
|
+
enabled: Boolean(walletAddress) && Boolean(tokenAddress),
|
|
92
|
+
});
|
|
93
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import type { SimpleHashNFTResponse } from "../../../global-account/types/simplehash.types";
|
|
2
|
+
export interface SimCollectibleMetadata {
|
|
3
|
+
uri: string;
|
|
4
|
+
attributes?: Array<{
|
|
5
|
+
trait_type: string;
|
|
6
|
+
value: string;
|
|
7
|
+
display_type?: string | null;
|
|
8
|
+
}>;
|
|
9
|
+
}
|
|
10
|
+
export interface SimCollectibleEntry {
|
|
11
|
+
contract_address: string;
|
|
12
|
+
token_standard: "ERC721" | "ERC1155";
|
|
13
|
+
token_id: string;
|
|
14
|
+
chain: string;
|
|
15
|
+
chain_id: number;
|
|
16
|
+
name?: string;
|
|
17
|
+
description?: string;
|
|
18
|
+
symbol?: string;
|
|
19
|
+
image_url?: string;
|
|
20
|
+
last_sale_price?: string;
|
|
21
|
+
metadata?: SimCollectibleMetadata;
|
|
22
|
+
is_spam?: boolean;
|
|
23
|
+
spam_score?: number;
|
|
24
|
+
explanations?: string[];
|
|
25
|
+
balance?: string;
|
|
26
|
+
last_acquired?: string;
|
|
27
|
+
}
|
|
28
|
+
export interface SimCollectiblesResponse {
|
|
29
|
+
address: string;
|
|
30
|
+
entries: SimCollectibleEntry[];
|
|
31
|
+
next_offset?: string;
|
|
32
|
+
request_time: string;
|
|
33
|
+
response_time: string;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Hook to fetch NFT collectibles from Simdune API.
|
|
37
|
+
* Returns data in SimpleHash format for compatibility with AccountAssets component.
|
|
38
|
+
* @param address - Wallet address to fetch collectibles for
|
|
39
|
+
* @param chainIdsParam - Optional array of chain IDs to filter by
|
|
40
|
+
* @param options - Optional parameters (limit, filterSpam)
|
|
41
|
+
*/
|
|
42
|
+
export declare function useSimCollectibles(address?: string, chainIdsParam?: number[], options?: {
|
|
43
|
+
limit?: number;
|
|
44
|
+
filterSpam?: boolean;
|
|
45
|
+
}): import("@tanstack/react-query").UseQueryResult<SimpleHashNFTResponse, Error>;
|