@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
|
@@ -5,7 +5,7 @@ import {
|
|
|
5
5
|
StyleRoot,
|
|
6
6
|
useAccountWallet,
|
|
7
7
|
useAuthentication,
|
|
8
|
-
|
|
8
|
+
useB3,
|
|
9
9
|
useIsMobile,
|
|
10
10
|
} from "@b3dotfun/sdk/global-account/react";
|
|
11
11
|
import Icon from "@b3dotfun/sdk/global-account/react/components/custom/Icon";
|
|
@@ -30,7 +30,7 @@ type SignInWithB3Props = Omit<SignInWithB3ModalProps, "type" | "showBackButton">
|
|
|
30
30
|
|
|
31
31
|
export function SignIn(props: SignInWithB3Props) {
|
|
32
32
|
const { className } = props;
|
|
33
|
-
const { automaticallySetFirstEoa, partnerId } =
|
|
33
|
+
const { automaticallySetFirstEoa, partnerId } = useB3();
|
|
34
34
|
const {
|
|
35
35
|
address: globalAddress,
|
|
36
36
|
ensName,
|
|
@@ -3,12 +3,12 @@ import {
|
|
|
3
3
|
SignInWithB3ModalProps,
|
|
4
4
|
useAuthentication,
|
|
5
5
|
useAuthStore,
|
|
6
|
-
|
|
6
|
+
useB3,
|
|
7
7
|
useGetAllTWSigners,
|
|
8
8
|
useModalStore,
|
|
9
9
|
} from "@b3dotfun/sdk/global-account/react";
|
|
10
10
|
import { debugB3React } from "@b3dotfun/sdk/shared/utils/debug";
|
|
11
|
-
import { useCallback, useEffect, useState } from "react";
|
|
11
|
+
import { useCallback, useEffect, useRef, useState } from "react";
|
|
12
12
|
import { useActiveAccount } from "thirdweb/react";
|
|
13
13
|
import { Account } from "thirdweb/wallets";
|
|
14
14
|
import { TurnkeyAuthModal } from "../TurnkeyAuthModal";
|
|
@@ -35,8 +35,19 @@ export function SignInWithB3Flow({
|
|
|
35
35
|
source = "signInWithB3Button",
|
|
36
36
|
signersEnabled = false,
|
|
37
37
|
}: SignInWithB3ModalProps) {
|
|
38
|
-
const { automaticallySetFirstEoa, enableTurnkey } =
|
|
39
|
-
const { user, refetchUser } = useAuthentication(partnerId);
|
|
38
|
+
const { automaticallySetFirstEoa, enableTurnkey } = useB3();
|
|
39
|
+
const { user, refetchUser, logout } = useAuthentication(partnerId);
|
|
40
|
+
|
|
41
|
+
// FIXME Logout before login to ensure a clean state
|
|
42
|
+
const hasLoggedOutRef = useRef(false);
|
|
43
|
+
useEffect(() => {
|
|
44
|
+
if (hasLoggedOutRef.current) return;
|
|
45
|
+
if (source !== "requestPermissions") {
|
|
46
|
+
debug("Logging out before login");
|
|
47
|
+
logout();
|
|
48
|
+
hasLoggedOutRef.current = true;
|
|
49
|
+
}
|
|
50
|
+
}, [source, logout]);
|
|
40
51
|
|
|
41
52
|
const [step, setStep] = useState<"login" | "permissions" | null>(source === "requestPermissions" ? null : "login");
|
|
42
53
|
const [sessionKeyAdded, setSessionKeyAdded] = useState(source === "requestPermissions" ? true : false);
|
|
@@ -2,7 +2,7 @@ import {
|
|
|
2
2
|
Loading,
|
|
3
3
|
useAuthentication,
|
|
4
4
|
useAuthStore,
|
|
5
|
-
|
|
5
|
+
useB3,
|
|
6
6
|
useHandleConnectWithPrivy,
|
|
7
7
|
} from "@b3dotfun/sdk/global-account/react";
|
|
8
8
|
import { debugB3React } from "@b3dotfun/sdk/shared/utils/debug";
|
|
@@ -19,7 +19,7 @@ interface SignInWithB3PrivyProps {
|
|
|
19
19
|
}
|
|
20
20
|
|
|
21
21
|
export function SignInWithB3Privy({ onSuccess, onError, chain }: SignInWithB3PrivyProps) {
|
|
22
|
-
const { partnerId } =
|
|
22
|
+
const { partnerId } = useB3();
|
|
23
23
|
const { isLoading, connectTw, fullToken } = useHandleConnectWithPrivy(chain, onSuccess);
|
|
24
24
|
const setIsAuthenticating = useAuthStore(state => state.setIsAuthenticating);
|
|
25
25
|
const setIsAuthenticated = useAuthStore(state => state.setIsAuthenticated);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { useAuthentication,
|
|
1
|
+
import { useAuthentication, useB3, useQueryB3 } from "@b3dotfun/sdk/global-account/react";
|
|
2
2
|
import { ecosystemWalletId } from "@b3dotfun/sdk/shared/constants";
|
|
3
3
|
import { client } from "@b3dotfun/sdk/shared/utils/thirdweb";
|
|
4
4
|
import { Chain } from "thirdweb";
|
|
@@ -50,7 +50,7 @@ export function LoginStepContainer({ children, partnerId }: LoginStepContainerPr
|
|
|
50
50
|
}
|
|
51
51
|
|
|
52
52
|
export function LoginStep({ onSuccess, chain }: LoginStepProps) {
|
|
53
|
-
const { partnerId, theme } =
|
|
53
|
+
const { partnerId, theme } = useB3();
|
|
54
54
|
const wallet = ecosystemWallet(ecosystemWalletId, {
|
|
55
55
|
partnerId: partnerId,
|
|
56
56
|
});
|
|
@@ -7,7 +7,7 @@ import {
|
|
|
7
7
|
LoginStepContainer,
|
|
8
8
|
useAuthentication,
|
|
9
9
|
useAuthStore,
|
|
10
|
-
|
|
10
|
+
useB3,
|
|
11
11
|
useConnect,
|
|
12
12
|
WalletRow,
|
|
13
13
|
} from "@b3dotfun/sdk/global-account/react";
|
|
@@ -37,7 +37,7 @@ export function LoginStepCustom({
|
|
|
37
37
|
maxInitialWallets = 2,
|
|
38
38
|
automaticallySetFirstEoa,
|
|
39
39
|
}: LoginStepCustomProps) {
|
|
40
|
-
const { partnerId } =
|
|
40
|
+
const { partnerId } = useB3();
|
|
41
41
|
const [isLoading, setIsLoading] = useState(false);
|
|
42
42
|
const [showAllWallets, setShowAllWallets] = useState(false);
|
|
43
43
|
const { connect } = useConnect(partnerId, chain);
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { PropsWithChildren } from "react";
|
|
2
|
-
import {
|
|
2
|
+
import { useB3 } from "./B3Provider/useB3";
|
|
3
3
|
|
|
4
4
|
export function StyleRoot({ children, id }: PropsWithChildren<{ id?: string }>) {
|
|
5
|
-
const { theme } =
|
|
5
|
+
const { theme } = useB3();
|
|
6
6
|
|
|
7
7
|
return (
|
|
8
8
|
<div className="b3-root" id={id} data-theme={theme}>
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import { Button, StyleRoot,
|
|
1
|
+
import { Button, StyleRoot, useAuthentication, useB3, useModalStore } from "@b3dotfun/sdk/global-account/react";
|
|
2
2
|
import { cn } from "@b3dotfun/sdk/shared/utils";
|
|
3
3
|
import { SignInWithB3Props } from "../SignInWithB3/SignInWithB3";
|
|
4
4
|
|
|
5
5
|
export function ManageAccountButton(props: SignInWithB3Props & { className?: string }) {
|
|
6
|
+
const { partnerId } = useB3();
|
|
6
7
|
const { setB3ModalOpen, setB3ModalContentType } = useModalStore();
|
|
7
|
-
const { isConnected } =
|
|
8
|
+
const { isConnected } = useAuthentication(partnerId);
|
|
8
9
|
|
|
9
10
|
const handleClickManageAccount = () => {
|
|
10
11
|
setB3ModalContentType({
|
|
@@ -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";
|
|
4
|
-
export { B3Provider } from "./B3Provider/B3Provider";
|
|
4
|
+
export { B3Provider, InnerProvider } from "./B3Provider/B3Provider";
|
|
5
5
|
export { RelayKitProviderWrapper } from "./B3Provider/RelayKitProviderWrapper";
|
|
6
|
+
export { B3Context, type B3ContextType } from "./B3Provider/types";
|
|
6
7
|
export { useB3 } from "./B3Provider/useB3";
|
|
7
8
|
export { useB3Account } from "./B3Provider/useB3Account";
|
|
8
9
|
export { useB3Config } from "./B3Provider/useB3Config";
|
|
@@ -39,7 +39,8 @@ export { useQueryBSMNT } from "./useQueryBSMNT";
|
|
|
39
39
|
export { useRemoveSessionKey } from "./useRemoveSessionKey";
|
|
40
40
|
export { useRouter } from "./useRouter";
|
|
41
41
|
export { useSearchParamsSSR } from "./useSearchParamsSSR";
|
|
42
|
-
export { useSimBalance, useSimSvmBalance } from "./useSimBalance";
|
|
42
|
+
export { useSimBalance, useSimSvmBalance, useSimTokenBalance } from "./useSimBalance";
|
|
43
|
+
export { useSimCollectibles } from "./useSimCollectibles";
|
|
43
44
|
export { useSiwe } from "./useSiwe";
|
|
44
45
|
export { useTokenBalance } from "./useTokenBalance";
|
|
45
46
|
export { useTokenBalanceDirect } from "./useTokenBalanceDirect";
|
|
@@ -52,4 +53,3 @@ export { useTokensFromAddress } from "./useTokensFromAddress";
|
|
|
52
53
|
export { useTurnkeyAuth } from "./useTurnkeyAuth";
|
|
53
54
|
export { useUnifiedChainSwitchAndExecute } from "./useUnifiedChainSwitchAndExecute";
|
|
54
55
|
export { useURLParams } from "./useURLParams";
|
|
55
|
-
export { useUser } from "./useUser";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import app from "@b3dotfun/sdk/global-account/app";
|
|
2
2
|
import { authenticateWithB3JWT } from "@b3dotfun/sdk/global-account/bsmnt";
|
|
3
|
-
import { useAuthStore,
|
|
3
|
+
import { useAuthStore, useB3 } from "@b3dotfun/sdk/global-account/react";
|
|
4
4
|
import { ecosystemWalletId } from "@b3dotfun/sdk/shared/constants";
|
|
5
5
|
import { debugB3React } from "@b3dotfun/sdk/shared/utils/debug";
|
|
6
6
|
import { client } from "@b3dotfun/sdk/shared/utils/thirdweb";
|
|
@@ -47,7 +47,7 @@ export function useAuth() {
|
|
|
47
47
|
const hasStartedConnecting = useAuthStore(state => state.hasStartedConnecting);
|
|
48
48
|
const useAutoConnectLoadingPrevious = useRef(false);
|
|
49
49
|
const referralCode = useSearchParam("referralCode");
|
|
50
|
-
const { partnerId } =
|
|
50
|
+
const { partnerId } = useB3();
|
|
51
51
|
const wagmiConfig = createWagmiConfig({ partnerId });
|
|
52
52
|
const { connect } = useConnect();
|
|
53
53
|
const activeWagmiAccount = useAccount();
|
|
@@ -330,7 +330,7 @@ export function useAuth() {
|
|
|
330
330
|
|
|
331
331
|
setIsAuthenticated(false);
|
|
332
332
|
setIsConnected(false);
|
|
333
|
-
setUser();
|
|
333
|
+
setUser(undefined);
|
|
334
334
|
callback?.();
|
|
335
335
|
},
|
|
336
336
|
[activeWallet, disconnect, wallets, setIsAuthenticated, setUser, setIsConnected],
|
|
@@ -179,7 +179,7 @@ export function useAuthentication(partnerId: string) {
|
|
|
179
179
|
|
|
180
180
|
setIsAuthenticated(false);
|
|
181
181
|
setIsConnected(false);
|
|
182
|
-
setUser();
|
|
182
|
+
setUser(undefined);
|
|
183
183
|
callback?.();
|
|
184
184
|
},
|
|
185
185
|
[activeWallet, disconnect, wallets, setIsAuthenticated, setUser, setIsConnected],
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { useB3 } from "@b3dotfun/sdk/global-account/react";
|
|
2
2
|
import { useCallback } from "react";
|
|
3
3
|
import {
|
|
4
4
|
ClientType,
|
|
@@ -13,7 +13,7 @@ import {
|
|
|
13
13
|
* Hook to access the current FeathersJS client and client management utilities
|
|
14
14
|
*/
|
|
15
15
|
export function useClient() {
|
|
16
|
-
const { clientType } =
|
|
16
|
+
const { clientType } = useB3();
|
|
17
17
|
|
|
18
18
|
const getCurrentClient = useCallback(() => {
|
|
19
19
|
return getClient();
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { useB3, useConnect } from "@b3dotfun/sdk/global-account/react";
|
|
2
2
|
import { debugB3React } from "@b3dotfun/sdk/shared/utils/debug";
|
|
3
3
|
import { useIdentityToken, usePrivy } from "@privy-io/react-auth";
|
|
4
4
|
import { useCallback, useRef, useState } from "react";
|
|
@@ -11,7 +11,7 @@ const debug = debugB3React("@@b3:useHandleConnectWithPrivy");
|
|
|
11
11
|
* Currently, this is for the basement-privy strategy
|
|
12
12
|
*/
|
|
13
13
|
export function useHandleConnectWithPrivy(chain?: Chain, onSuccess?: (account: Account) => void) {
|
|
14
|
-
const { partnerId } =
|
|
14
|
+
const { partnerId } = useB3();
|
|
15
15
|
if (!chain) {
|
|
16
16
|
throw new Error("Chain is required");
|
|
17
17
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { useB3 } from "@b3dotfun/sdk/global-account/react";
|
|
2
2
|
import { getAuthToken } from "@b3dotfun/sdk/shared/utils/auth-token";
|
|
3
3
|
import { debugB3React } from "@b3dotfun/sdk/shared/utils/debug";
|
|
4
4
|
import { useCallback, useEffect, useState } from "react";
|
|
@@ -56,7 +56,7 @@ export interface UseNotificationsReturn {
|
|
|
56
56
|
*/
|
|
57
57
|
export function useNotifications(): UseNotificationsReturn {
|
|
58
58
|
const { user } = useUserQuery();
|
|
59
|
-
const { partnerId } =
|
|
59
|
+
const { partnerId } = useB3();
|
|
60
60
|
const [userData, setUserData] = useState<UserData | null>(null);
|
|
61
61
|
const [loading, setLoading] = useState(true);
|
|
62
62
|
const [error, setError] = useState<string | null>(null);
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { useQuery } from "@tanstack/react-query";
|
|
2
|
+
import { buildSimduneUrl } from "../utils/simdune";
|
|
2
3
|
|
|
3
4
|
export interface SimTokenMetadata {
|
|
4
5
|
logo?: string;
|
|
@@ -60,11 +61,12 @@ async function fetchSimBalance(address: string, chainIdsParam: number[]): Promis
|
|
|
60
61
|
if (!address) throw new Error("Address is required");
|
|
61
62
|
|
|
62
63
|
const chainIds = chainIdsParam.length === 0 ? "mainnet" : chainIdsParam.join(",");
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
64
|
+
const queryParams = new URLSearchParams();
|
|
65
|
+
queryParams.append("metadata", "logo");
|
|
66
|
+
queryParams.append("chain_ids", chainIds);
|
|
67
|
+
queryParams.append("exclude_spam_tokens", "true");
|
|
67
68
|
|
|
69
|
+
const url = buildSimduneUrl(`/v1/evm/balances/${address}`, queryParams);
|
|
68
70
|
const response = await fetch(url);
|
|
69
71
|
|
|
70
72
|
if (!response.ok) {
|
|
@@ -75,6 +77,29 @@ async function fetchSimBalance(address: string, chainIdsParam: number[]): Promis
|
|
|
75
77
|
return balanceData;
|
|
76
78
|
}
|
|
77
79
|
|
|
80
|
+
async function fetchSimTokenBalance(
|
|
81
|
+
walletAddress: string,
|
|
82
|
+
tokenAddress: string,
|
|
83
|
+
chainId: number,
|
|
84
|
+
): Promise<SimBalanceResponse> {
|
|
85
|
+
if (!walletAddress) throw new Error("Wallet address is required");
|
|
86
|
+
if (!tokenAddress) throw new Error("Token address is required");
|
|
87
|
+
if (!chainId) throw new Error("Chain ID is required");
|
|
88
|
+
|
|
89
|
+
const queryParams = new URLSearchParams();
|
|
90
|
+
queryParams.append("chain_ids", chainId.toString());
|
|
91
|
+
|
|
92
|
+
const url = buildSimduneUrl(`/v1/evm/balances/${walletAddress}/token/${tokenAddress}`, queryParams);
|
|
93
|
+
const response = await fetch(url);
|
|
94
|
+
|
|
95
|
+
if (!response.ok) {
|
|
96
|
+
throw new Error(`Failed to fetch token balance: ${response.statusText}`);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
const balanceData: SimBalanceResponse = await response.json();
|
|
100
|
+
return balanceData;
|
|
101
|
+
}
|
|
102
|
+
|
|
78
103
|
async function fetchSimSvmBalance(address: string, chains?: string[], limit?: number): Promise<SvmBalanceResponse> {
|
|
79
104
|
if (!address) throw new Error("Address is required");
|
|
80
105
|
|
|
@@ -86,14 +111,7 @@ async function fetchSimSvmBalance(address: string, chains?: string[], limit?: nu
|
|
|
86
111
|
queryParams.append("limit", limit.toString());
|
|
87
112
|
}
|
|
88
113
|
|
|
89
|
-
|
|
90
|
-
if (queryParams.toString()) {
|
|
91
|
-
url += `?${queryParams.toString()}`;
|
|
92
|
-
}
|
|
93
|
-
if (process.env.NEXT_PUBLIC_LOCAL_SIMDUNE_KEY) {
|
|
94
|
-
url += `${queryParams.toString() ? "&" : "?"}localkey=${process.env.NEXT_PUBLIC_LOCAL_SIMDUNE_KEY}`;
|
|
95
|
-
}
|
|
96
|
-
|
|
114
|
+
const url = buildSimduneUrl(`/beta/svm/balances/${address}`, queryParams.toString() ? queryParams : undefined);
|
|
97
115
|
const response = await fetch(url);
|
|
98
116
|
|
|
99
117
|
if (!response.ok) {
|
|
@@ -125,3 +143,22 @@ export function useSimSvmBalance(address?: string, chains?: ("solana" | "eclipse
|
|
|
125
143
|
enabled: Boolean(address),
|
|
126
144
|
});
|
|
127
145
|
}
|
|
146
|
+
|
|
147
|
+
/**
|
|
148
|
+
* Hook to fetch a single token balance for a wallet.
|
|
149
|
+
* @param walletAddress - The wallet address to fetch balance for
|
|
150
|
+
* @param tokenAddress - The token contract address, or "native" for native token (ETH, etc.)
|
|
151
|
+
* @param chainId - Chain ID to query (defaults to 1 for Ethereum mainnet)
|
|
152
|
+
*/
|
|
153
|
+
export function useSimTokenBalance(walletAddress?: string, tokenAddress?: string, chainId?: number) {
|
|
154
|
+
return useQuery({
|
|
155
|
+
queryKey: ["simTokenBalance", walletAddress, tokenAddress, chainId],
|
|
156
|
+
queryFn: () => {
|
|
157
|
+
if (!walletAddress || !tokenAddress || !chainId) {
|
|
158
|
+
throw new Error("Missing required parameters");
|
|
159
|
+
}
|
|
160
|
+
return fetchSimTokenBalance(walletAddress, tokenAddress, chainId);
|
|
161
|
+
},
|
|
162
|
+
enabled: Boolean(walletAddress) && Boolean(tokenAddress),
|
|
163
|
+
});
|
|
164
|
+
}
|
|
@@ -0,0 +1,238 @@
|
|
|
1
|
+
import type { NFT, SimpleHashNFTResponse } from "@b3dotfun/sdk/global-account/types/simplehash.types";
|
|
2
|
+
import { useQuery } from "@tanstack/react-query";
|
|
3
|
+
import { buildSimduneUrl } from "../utils/simdune";
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Safely parse a balance string to a number, capping at MAX_SAFE_INTEGER
|
|
7
|
+
* to prevent overflow issues with large ERC1155 balances.
|
|
8
|
+
*/
|
|
9
|
+
function safeParseBalance(balance: string | undefined): number {
|
|
10
|
+
if (!balance) return 1;
|
|
11
|
+
const parsed = parseInt(balance, 10);
|
|
12
|
+
if (Number.isNaN(parsed)) return 1;
|
|
13
|
+
return Math.min(parsed, Number.MAX_SAFE_INTEGER);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
// Simdune Collectibles types
|
|
17
|
+
export interface SimCollectibleMetadata {
|
|
18
|
+
uri: string;
|
|
19
|
+
attributes?: Array<{
|
|
20
|
+
trait_type: string;
|
|
21
|
+
value: string;
|
|
22
|
+
display_type?: string | null;
|
|
23
|
+
}>;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export interface SimCollectibleEntry {
|
|
27
|
+
contract_address: string;
|
|
28
|
+
token_standard: "ERC721" | "ERC1155";
|
|
29
|
+
token_id: string;
|
|
30
|
+
chain: string;
|
|
31
|
+
chain_id: number;
|
|
32
|
+
name?: string;
|
|
33
|
+
description?: string;
|
|
34
|
+
symbol?: string;
|
|
35
|
+
image_url?: string;
|
|
36
|
+
last_sale_price?: string;
|
|
37
|
+
metadata?: SimCollectibleMetadata;
|
|
38
|
+
is_spam?: boolean;
|
|
39
|
+
spam_score?: number;
|
|
40
|
+
explanations?: string[];
|
|
41
|
+
balance?: string;
|
|
42
|
+
last_acquired?: string;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export interface SimCollectiblesResponse {
|
|
46
|
+
address: string;
|
|
47
|
+
entries: SimCollectibleEntry[];
|
|
48
|
+
next_offset?: string;
|
|
49
|
+
request_time: string;
|
|
50
|
+
response_time: string;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
async function fetchSimCollectibles(
|
|
54
|
+
address: string,
|
|
55
|
+
chainIdsParam?: number[],
|
|
56
|
+
options?: { limit?: number; filterSpam?: boolean },
|
|
57
|
+
): Promise<SimCollectiblesResponse> {
|
|
58
|
+
if (!address) throw new Error("Address is required");
|
|
59
|
+
|
|
60
|
+
const queryParams = new URLSearchParams();
|
|
61
|
+
if (chainIdsParam && chainIdsParam.length > 0) {
|
|
62
|
+
queryParams.append("chain_ids", chainIdsParam.join(","));
|
|
63
|
+
}
|
|
64
|
+
if (options?.limit) {
|
|
65
|
+
queryParams.append("limit", options.limit.toString());
|
|
66
|
+
}
|
|
67
|
+
if (options?.filterSpam !== undefined) {
|
|
68
|
+
queryParams.append("filter_spam", options.filterSpam.toString());
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
const url = buildSimduneUrl(`/v1/evm/collectibles/${address}`, queryParams);
|
|
72
|
+
const response = await fetch(url);
|
|
73
|
+
|
|
74
|
+
if (!response.ok) {
|
|
75
|
+
throw new Error(`Failed to fetch collectibles: ${response.statusText}`);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
const data: SimCollectiblesResponse = await response.json();
|
|
79
|
+
return data;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* Transforms Simdune collectibles response to SimpleHash NFT format
|
|
84
|
+
* for compatibility with existing AccountAssets component
|
|
85
|
+
*/
|
|
86
|
+
function transformToSimpleHashFormat(data: SimCollectiblesResponse): SimpleHashNFTResponse {
|
|
87
|
+
const nfts: NFT[] = data.entries.map(entry => ({
|
|
88
|
+
nft_id: `${entry.chain}.${entry.contract_address}.${entry.token_id}`,
|
|
89
|
+
chain: entry.chain,
|
|
90
|
+
contract_address: entry.contract_address,
|
|
91
|
+
token_id: entry.token_id,
|
|
92
|
+
name: entry.name || "",
|
|
93
|
+
description: entry.description || "",
|
|
94
|
+
previews: {
|
|
95
|
+
image_small_url: entry.image_url || "",
|
|
96
|
+
image_medium_url: entry.image_url || "",
|
|
97
|
+
image_large_url: entry.image_url || "",
|
|
98
|
+
image_opengraph_url: entry.image_url || "",
|
|
99
|
+
blurhash: "",
|
|
100
|
+
predominant_color: "",
|
|
101
|
+
},
|
|
102
|
+
image_url: entry.image_url || "",
|
|
103
|
+
image_properties: {
|
|
104
|
+
width: 0,
|
|
105
|
+
height: 0,
|
|
106
|
+
size: 0,
|
|
107
|
+
mime_type: "",
|
|
108
|
+
exif_orientation: null,
|
|
109
|
+
},
|
|
110
|
+
video_url: null,
|
|
111
|
+
video_properties: null,
|
|
112
|
+
audio_url: null,
|
|
113
|
+
audio_properties: null,
|
|
114
|
+
model_url: null,
|
|
115
|
+
model_properties: null,
|
|
116
|
+
other_url: null,
|
|
117
|
+
other_properties: null,
|
|
118
|
+
background_color: null,
|
|
119
|
+
external_url: null,
|
|
120
|
+
created_date: "",
|
|
121
|
+
status: "minted",
|
|
122
|
+
token_count: 1,
|
|
123
|
+
owner_count: 1,
|
|
124
|
+
owners: [
|
|
125
|
+
{
|
|
126
|
+
owner_address: data.address,
|
|
127
|
+
quantity: safeParseBalance(entry.balance),
|
|
128
|
+
quantity_string: entry.balance || "1",
|
|
129
|
+
first_acquired_date: entry.last_acquired || "",
|
|
130
|
+
last_acquired_date: entry.last_acquired || "",
|
|
131
|
+
},
|
|
132
|
+
],
|
|
133
|
+
contract: {
|
|
134
|
+
type: entry.token_standard,
|
|
135
|
+
name: entry.name || "",
|
|
136
|
+
symbol: entry.symbol || null,
|
|
137
|
+
deployed_by: "",
|
|
138
|
+
deployed_via_contract: "",
|
|
139
|
+
owned_by: "",
|
|
140
|
+
has_multiple_collections: false,
|
|
141
|
+
},
|
|
142
|
+
collection: {
|
|
143
|
+
collection_id: entry.contract_address,
|
|
144
|
+
name: entry.symbol || "Unknown Collection",
|
|
145
|
+
description: null,
|
|
146
|
+
image_url: entry.image_url || "",
|
|
147
|
+
image_properties: {
|
|
148
|
+
width: 0,
|
|
149
|
+
height: 0,
|
|
150
|
+
mime_type: "",
|
|
151
|
+
},
|
|
152
|
+
banner_image_url: null,
|
|
153
|
+
category: null,
|
|
154
|
+
is_nsfw: null,
|
|
155
|
+
external_url: null,
|
|
156
|
+
twitter_username: null,
|
|
157
|
+
discord_url: null,
|
|
158
|
+
instagram_username: null,
|
|
159
|
+
medium_username: null,
|
|
160
|
+
telegram_url: null,
|
|
161
|
+
marketplace_pages: [],
|
|
162
|
+
metaplex_mint: null,
|
|
163
|
+
metaplex_candy_machine: null,
|
|
164
|
+
metaplex_first_verified_creator: null,
|
|
165
|
+
floor_prices: [],
|
|
166
|
+
top_bids: [],
|
|
167
|
+
distinct_owner_count: 0,
|
|
168
|
+
distinct_nft_count: 0,
|
|
169
|
+
total_quantity: 0,
|
|
170
|
+
chains: [entry.chain],
|
|
171
|
+
top_contracts: [entry.contract_address],
|
|
172
|
+
collection_royalties: [],
|
|
173
|
+
},
|
|
174
|
+
last_sale: entry.last_sale_price
|
|
175
|
+
? {
|
|
176
|
+
price: entry.last_sale_price,
|
|
177
|
+
}
|
|
178
|
+
: null,
|
|
179
|
+
primary_sale: null,
|
|
180
|
+
first_created: {
|
|
181
|
+
minted_to: data.address,
|
|
182
|
+
quantity: 1,
|
|
183
|
+
quantity_string: "1",
|
|
184
|
+
timestamp: "",
|
|
185
|
+
block_number: 0,
|
|
186
|
+
transaction: "",
|
|
187
|
+
transaction_initiator: "",
|
|
188
|
+
},
|
|
189
|
+
rarity: {
|
|
190
|
+
rank: null,
|
|
191
|
+
score: null,
|
|
192
|
+
unique_attributes: null,
|
|
193
|
+
},
|
|
194
|
+
royalty: [],
|
|
195
|
+
extra_metadata: {
|
|
196
|
+
attributes: (entry.metadata?.attributes || []).map(attr => ({
|
|
197
|
+
trait_type: attr.trait_type,
|
|
198
|
+
value: attr.value,
|
|
199
|
+
display_type: attr.display_type ?? null,
|
|
200
|
+
})),
|
|
201
|
+
image_original_url: entry.image_url || "",
|
|
202
|
+
animation_original_url: null,
|
|
203
|
+
metadata_original_url: entry.metadata?.uri || "",
|
|
204
|
+
},
|
|
205
|
+
}));
|
|
206
|
+
|
|
207
|
+
return {
|
|
208
|
+
next_cursor: data.next_offset || null,
|
|
209
|
+
next: null,
|
|
210
|
+
previous: null,
|
|
211
|
+
nfts,
|
|
212
|
+
};
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
/**
|
|
216
|
+
* Hook to fetch NFT collectibles from Simdune API.
|
|
217
|
+
* Returns data in SimpleHash format for compatibility with AccountAssets component.
|
|
218
|
+
* @param address - Wallet address to fetch collectibles for
|
|
219
|
+
* @param chainIdsParam - Optional array of chain IDs to filter by
|
|
220
|
+
* @param options - Optional parameters (limit, filterSpam)
|
|
221
|
+
*/
|
|
222
|
+
export function useSimCollectibles(
|
|
223
|
+
address?: string,
|
|
224
|
+
chainIdsParam?: number[],
|
|
225
|
+
options?: { limit?: number; filterSpam?: boolean },
|
|
226
|
+
) {
|
|
227
|
+
return useQuery({
|
|
228
|
+
queryKey: ["simCollectibles", address, chainIdsParam, options],
|
|
229
|
+
queryFn: async () => {
|
|
230
|
+
if (!address) throw new Error("Address is required");
|
|
231
|
+
const data = await fetchSimCollectibles(address, chainIdsParam, options);
|
|
232
|
+
return transformToSimpleHashFormat(data);
|
|
233
|
+
},
|
|
234
|
+
enabled: Boolean(address),
|
|
235
|
+
staleTime: 30 * 1000,
|
|
236
|
+
gcTime: 5 * 60 * 1000,
|
|
237
|
+
});
|
|
238
|
+
}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
|
|
3
3
|
import { isNativeToken } from "@b3dotfun/sdk/anyspend";
|
|
4
|
-
import {
|
|
5
|
-
import { useAccountWallet, useAuthStore } from "@b3dotfun/sdk/global-account/react";
|
|
4
|
+
import { useB3, useAccountWallet } from "@b3dotfun/sdk/global-account/react";
|
|
6
5
|
import { formatTokenAmount } from "@b3dotfun/sdk/shared/utils/number";
|
|
7
6
|
import { getERC20Balances, getNativeTokenBalance } from "@b3dotfun/sdk/shared/utils/thirdweb-insights";
|
|
8
7
|
import { useQuery } from "@tanstack/react-query";
|
|
9
8
|
import { useEffect } from "react";
|
|
9
|
+
import { components } from "@b3dotfun/sdk/anyspend/types/api";
|
|
10
10
|
|
|
11
11
|
interface UseTokenBalanceProps {
|
|
12
12
|
token: components["schemas"]["Token"];
|
|
@@ -20,8 +20,7 @@ export interface TokenBalanceResult {
|
|
|
20
20
|
}
|
|
21
21
|
|
|
22
22
|
export function useTokenBalance({ token, address }: UseTokenBalanceProps): TokenBalanceResult {
|
|
23
|
-
const
|
|
24
|
-
|
|
23
|
+
const { ready } = useB3();
|
|
25
24
|
const account = useAccountWallet();
|
|
26
25
|
|
|
27
26
|
const effectiveAddress = address || account?.address;
|
|
@@ -61,7 +60,7 @@ export function useTokenBalance({ token, address }: UseTokenBalanceProps): Token
|
|
|
61
60
|
}
|
|
62
61
|
return { formatted: "0", raw: null };
|
|
63
62
|
},
|
|
64
|
-
enabled:
|
|
63
|
+
enabled: ready && !!effectiveAddress,
|
|
65
64
|
staleTime: 30000,
|
|
66
65
|
gcTime: 5 * 60 * 1000,
|
|
67
66
|
retry: 2,
|
|
@@ -70,13 +69,13 @@ export function useTokenBalance({ token, address }: UseTokenBalanceProps): Token
|
|
|
70
69
|
|
|
71
70
|
// Force a refetch when the wallet or token changes
|
|
72
71
|
useEffect(() => {
|
|
73
|
-
if (
|
|
72
|
+
if (ready && effectiveAddress) {
|
|
74
73
|
refetch();
|
|
75
74
|
}
|
|
76
|
-
}, [
|
|
75
|
+
}, [ready, effectiveAddress, token.address, token.chainId, token.symbol, refetch]);
|
|
77
76
|
|
|
78
77
|
// Determine if we're actually loading
|
|
79
|
-
const isActuallyLoading = !
|
|
78
|
+
const isActuallyLoading = !ready || !effectiveAddress || isLoading || (isFetching && !tokenBalance);
|
|
80
79
|
|
|
81
80
|
return {
|
|
82
81
|
rawBalance: tokenBalance?.raw || BigInt(0),
|
|
@@ -2,7 +2,7 @@ import { TurnkeyAuthInitResponse } from "@b3dotfun/b3-api";
|
|
|
2
2
|
import { debugB3React } from "@b3dotfun/sdk/shared/utils/debug";
|
|
3
3
|
import { useCallback, useState } from "react";
|
|
4
4
|
import app from "../../app";
|
|
5
|
-
import {
|
|
5
|
+
import { useB3 } from "../components";
|
|
6
6
|
import { useAuthStore } from "../stores";
|
|
7
7
|
import { useAuth } from "./useAuth";
|
|
8
8
|
|
|
@@ -33,7 +33,7 @@ export function useTurnkeyAuth(): UseTurnkeyAuthReturn {
|
|
|
33
33
|
const [error, setError] = useState<string | null>(null);
|
|
34
34
|
const setIsAuthenticating = useAuthStore(state => state.setIsAuthenticating);
|
|
35
35
|
const setIsAuthenticated = useAuthStore(state => state.setIsAuthenticated);
|
|
36
|
-
const { partnerId } =
|
|
36
|
+
const { partnerId } = useB3();
|
|
37
37
|
const { authenticate } = useAuth();
|
|
38
38
|
|
|
39
39
|
/**
|