@b3dotfun/sdk 0.0.47-test.4 → 0.0.47
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -3
- package/dist/cjs/global-account/react/components/B3Provider/B3Provider.d.ts +2 -3
- package/dist/cjs/global-account/react/components/B3Provider/B3Provider.js +64 -15
- package/dist/cjs/global-account/react/components/B3Provider/B3Provider.native.d.ts +2 -6
- package/dist/cjs/global-account/react/components/B3Provider/B3Provider.native.js +21 -26
- package/dist/cjs/global-account/react/components/B3Provider/types.d.ts +0 -2
- package/dist/cjs/global-account/react/components/B3Provider/types.js +0 -2
- package/dist/cjs/global-account/react/components/ManageAccount/BalanceContent.d.ts +2 -1
- package/dist/cjs/global-account/react/components/ManageAccount/BalanceContent.js +2 -2
- package/dist/cjs/global-account/react/components/ManageAccount/ManageAccount.js +1 -1
- package/dist/cjs/global-account/react/components/SignInWithB3/SignIn.js +2 -2
- package/dist/cjs/global-account/react/components/SignInWithB3/SignInWithB3.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 +22 -6
- package/dist/cjs/global-account/react/components/SignInWithB3/SignInWithB3Privy.d.ts +2 -1
- package/dist/cjs/global-account/react/components/SignInWithB3/SignInWithB3Privy.js +2 -3
- package/dist/cjs/global-account/react/components/SignInWithB3/steps/LoginStep.d.ts +2 -1
- package/dist/cjs/global-account/react/components/SignInWithB3/steps/LoginStep.js +45 -10
- package/dist/cjs/global-account/react/components/SignInWithB3/steps/LoginStepCustom.d.ts +2 -1
- package/dist/cjs/global-account/react/components/SignInWithB3/steps/LoginStepCustom.js +1 -2
- package/dist/cjs/global-account/react/components/custom/ManageAccountButton.js +1 -2
- package/dist/cjs/global-account/react/hooks/useAuthentication.d.ts +2 -51
- package/dist/cjs/global-account/react/hooks/useAuthentication.js +84 -134
- package/dist/cjs/global-account/react/hooks/useHandleConnectWithPrivy.d.ts +1 -1
- package/dist/cjs/global-account/react/hooks/useHandleConnectWithPrivy.js +1 -2
- package/dist/cjs/global-account/react/stores/useModalStore.d.ts +2 -0
- package/dist/esm/global-account/react/components/B3Provider/B3Provider.d.ts +2 -3
- package/dist/esm/global-account/react/components/B3Provider/B3Provider.js +68 -19
- package/dist/esm/global-account/react/components/B3Provider/B3Provider.native.d.ts +2 -6
- package/dist/esm/global-account/react/components/B3Provider/B3Provider.native.js +19 -24
- package/dist/esm/global-account/react/components/B3Provider/types.d.ts +0 -2
- package/dist/esm/global-account/react/components/B3Provider/types.js +0 -2
- package/dist/esm/global-account/react/components/ManageAccount/BalanceContent.d.ts +2 -1
- package/dist/esm/global-account/react/components/ManageAccount/BalanceContent.js +2 -2
- package/dist/esm/global-account/react/components/ManageAccount/ManageAccount.js +1 -1
- package/dist/esm/global-account/react/components/SignInWithB3/SignIn.js +2 -2
- package/dist/esm/global-account/react/components/SignInWithB3/SignInWithB3.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 +23 -7
- package/dist/esm/global-account/react/components/SignInWithB3/SignInWithB3Privy.d.ts +2 -1
- package/dist/esm/global-account/react/components/SignInWithB3/SignInWithB3Privy.js +3 -4
- package/dist/esm/global-account/react/components/SignInWithB3/steps/LoginStep.d.ts +2 -1
- package/dist/esm/global-account/react/components/SignInWithB3/steps/LoginStep.js +46 -11
- package/dist/esm/global-account/react/components/SignInWithB3/steps/LoginStepCustom.d.ts +2 -1
- package/dist/esm/global-account/react/components/SignInWithB3/steps/LoginStepCustom.js +2 -3
- package/dist/esm/global-account/react/components/custom/ManageAccountButton.js +2 -3
- package/dist/esm/global-account/react/hooks/useAuthentication.d.ts +2 -51
- package/dist/esm/global-account/react/hooks/useAuthentication.js +87 -137
- package/dist/esm/global-account/react/hooks/useHandleConnectWithPrivy.d.ts +1 -1
- package/dist/esm/global-account/react/hooks/useHandleConnectWithPrivy.js +2 -3
- package/dist/esm/global-account/react/stores/useModalStore.d.ts +2 -0
- package/dist/types/global-account/react/components/B3Provider/B3Provider.d.ts +2 -3
- package/dist/types/global-account/react/components/B3Provider/B3Provider.native.d.ts +2 -6
- package/dist/types/global-account/react/components/B3Provider/types.d.ts +0 -2
- package/dist/types/global-account/react/components/ManageAccount/BalanceContent.d.ts +2 -1
- package/dist/types/global-account/react/components/SignInWithB3/SignInWithB3Flow.d.ts +1 -1
- package/dist/types/global-account/react/components/SignInWithB3/SignInWithB3Privy.d.ts +2 -1
- package/dist/types/global-account/react/components/SignInWithB3/steps/LoginStep.d.ts +2 -1
- package/dist/types/global-account/react/components/SignInWithB3/steps/LoginStepCustom.d.ts +2 -1
- package/dist/types/global-account/react/hooks/useAuthentication.d.ts +2 -51
- package/dist/types/global-account/react/hooks/useHandleConnectWithPrivy.d.ts +1 -1
- package/dist/types/global-account/react/stores/useModalStore.d.ts +2 -0
- package/package.json +3 -3
- package/src/global-account/react/components/B3Provider/B3Provider.native.tsx +35 -51
- package/src/global-account/react/components/B3Provider/B3Provider.tsx +72 -28
- package/src/global-account/react/components/B3Provider/types.ts +0 -4
- package/src/global-account/react/components/ManageAccount/BalanceContent.tsx +3 -2
- package/src/global-account/react/components/ManageAccount/ManageAccount.tsx +1 -1
- package/src/global-account/react/components/SignInWithB3/SignIn.tsx +2 -2
- package/src/global-account/react/components/SignInWithB3/SignInWithB3.tsx +2 -2
- package/src/global-account/react/components/SignInWithB3/SignInWithB3Flow.tsx +23 -4
- package/src/global-account/react/components/SignInWithB3/SignInWithB3Privy.tsx +3 -4
- package/src/global-account/react/components/SignInWithB3/steps/LoginStep.tsx +46 -8
- package/src/global-account/react/components/SignInWithB3/steps/LoginStepCustom.tsx +2 -2
- package/src/global-account/react/components/custom/ManageAccountButton.tsx +2 -3
- package/src/global-account/react/hooks/useAuthentication.ts +90 -159
- package/src/global-account/react/hooks/useHandleConnectWithPrivy.tsx +2 -3
- package/src/global-account/react/stores/useModalStore.ts +2 -0
- package/dist/cjs/global-account/react/hooks/useUserQuery.d.ts +0 -58
- package/dist/cjs/global-account/react/hooks/useUserQuery.js +0 -86
- package/dist/cjs/global-account/react/hooks/useWagmiConfig.d.ts +0 -13
- package/dist/cjs/global-account/react/hooks/useWagmiConfig.js +0 -42
- package/dist/esm/global-account/react/hooks/useUserQuery.d.ts +0 -58
- package/dist/esm/global-account/react/hooks/useUserQuery.js +0 -83
- package/dist/esm/global-account/react/hooks/useWagmiConfig.d.ts +0 -13
- package/dist/esm/global-account/react/hooks/useWagmiConfig.js +0 -39
- package/dist/types/global-account/react/hooks/useUserQuery.d.ts +0 -58
- package/dist/types/global-account/react/hooks/useWagmiConfig.d.ts +0 -13
- package/src/global-account/react/hooks/useUserQuery.ts +0 -95
- package/src/global-account/react/hooks/useWagmiConfig.tsx +0 -44
|
@@ -17,14 +17,14 @@ function centerTruncate(str, length = 4) {
|
|
|
17
17
|
return str;
|
|
18
18
|
return `${str.slice(0, length)}...${str.slice(-length)}`;
|
|
19
19
|
}
|
|
20
|
-
export function BalanceContent({ onLogout, showDeposit = true, showSwap = true }) {
|
|
20
|
+
export function BalanceContent({ onLogout, partnerId, showDeposit = true, showSwap = true }) {
|
|
21
21
|
const account = useActiveAccount();
|
|
22
22
|
const { address: eoaAddress, info: eoaInfo } = useFirstEOA();
|
|
23
23
|
const { data: profile } = useProfile({
|
|
24
24
|
address: eoaAddress || account?.address,
|
|
25
25
|
fresh: true,
|
|
26
26
|
});
|
|
27
|
-
const { user
|
|
27
|
+
const { user } = useB3();
|
|
28
28
|
const { setB3ModalOpen, setB3ModalContentType, navigateBack } = useModalStore();
|
|
29
29
|
const { logout } = useAuthentication(partnerId);
|
|
30
30
|
const [logoutLoading, setLogoutLoading] = useState(false);
|
|
@@ -196,5 +196,5 @@ export function ManageAccount({ onLogout, onSwap: _onSwap, onDeposit: _onDeposit
|
|
|
196
196
|
if (["overview", "tokens", "nfts", "apps", "settings"].includes(tab)) {
|
|
197
197
|
setActiveTab?.(tab);
|
|
198
198
|
}
|
|
199
|
-
}, children: [_jsx("div", { className: "px-4", children: _jsxs(TabsListPrimitive, { className: "grid h-auto grid-cols-2 grid-rows-2 gap-3 rounded-none border-none bg-transparent", children: [_jsxs(TabTriggerPrimitive, { value: "overview", className: "data-[state=active]:bg-b3-primary-blue data-[state=active]:hover:bg-b3-primary-blue data-[state=active]:border-b3-primary-blue group flex h-12 w-full items-center justify-center gap-2 rounded-xl border border-gray-200 bg-white p-2 text-center shadow-sm transition-all duration-200 hover:bg-gray-50 hover:shadow-md data-[state=active]:shadow-lg", children: [_jsx(BarChart3, { size: 20, className: "text-b3-primary-blue shrink-0 group-data-[state=active]:text-white" }), _jsx("span", { className: "text-b3-grey font-neue-montreal-semibold text-sm group-data-[state=active]:text-white", children: "Overview" })] }), _jsxs(TabTriggerPrimitive, { value: "tokens", className: "data-[state=active]:bg-b3-primary-blue data-[state=active]:hover:bg-b3-primary-blue data-[state=active]:border-b3-primary-blue group flex h-12 w-full items-center justify-center gap-2 rounded-xl border border-gray-200 bg-white p-2 text-center shadow-sm transition-all duration-200 hover:bg-gray-50 hover:shadow-md data-[state=active]:shadow-lg", children: [_jsx(Coins, { size: 20, className: "text-b3-primary-blue shrink-0 group-data-[state=active]:text-white" }), _jsx("span", { className: "text-b3-grey font-neue-montreal-semibold text-sm group-data-[state=active]:text-white", children: "Tokens" })] }), _jsxs(TabTriggerPrimitive, { value: "nfts", className: "data-[state=active]:bg-b3-primary-blue data-[state=active]:hover:bg-b3-primary-blue data-[state=active]:border-b3-primary-blue group flex h-12 w-full items-center justify-center gap-2 rounded-xl border border-gray-200 bg-white p-2 text-center shadow-sm transition-all duration-200 hover:bg-gray-50 hover:shadow-md data-[state=active]:shadow-lg", children: [_jsx(Image, { size: 20, className: "text-b3-primary-blue shrink-0 group-data-[state=active]:text-white" }), _jsx("span", { className: "text-b3-grey font-neue-montreal-semibold text-sm group-data-[state=active]:text-white", children: "NFTs" })] }), _jsxs(TabTriggerPrimitive, { value: "settings", className: "data-[state=active]:bg-b3-primary-blue data-[state=active]:hover:bg-b3-primary-blue data-[state=active]:border-b3-primary-blue group flex h-12 w-full items-center justify-center gap-2 rounded-xl border border-gray-200 bg-white p-2 text-center shadow-sm transition-all duration-200 hover:bg-gray-50 hover:shadow-md data-[state=active]:shadow-lg", children: [_jsx(Settings, { size: 20, className: "text-b3-primary-blue shrink-0 group-data-[state=active]:text-white" }), _jsx("span", { className: "text-b3-grey font-neue-montreal-semibold text-sm group-data-[state=active]:text-white", children: "Settings" })] })] }) }), _jsx(TabsContentPrimitive, { value: "overview", className: "px-4 pb-4 pt-2", children: _jsx(BalanceContent, { onLogout: onLogout, showDeposit: showDeposit, showSwap: showSwap }) }), _jsx(TabsContentPrimitive, { value: "tokens", className: "px-4 pb-4 pt-2", children: _jsx(ContentTokens, { activeTab: activeTab }) }), _jsx(TabsContentPrimitive, { value: "nfts", className: "px-4 pb-4 pt-2", children: _jsx("div", { className: "grid grid-cols-3 gap-4", children: nfts?.nftResponse ? (_jsx(AccountAssets, { nfts: nfts.nftResponse, isLoading: isLoading })) : (_jsx("div", { className: "col-span-3 py-12 text-center text-gray-500", children: "No NFTs found" })) }) }), _jsx(TabsContentPrimitive, { value: "apps", className: "px-4 pb-4 pt-2", children: _jsx(AppsContent, {}) }), _jsx(TabsContentPrimitive, { value: "settings", className: "px-4 pb-4 pt-2", children: _jsx(SettingsContent, {}) })] }) }) }));
|
|
199
|
+
}, children: [_jsx("div", { className: "px-4", children: _jsxs(TabsListPrimitive, { className: "grid h-auto grid-cols-2 grid-rows-2 gap-3 rounded-none border-none bg-transparent", children: [_jsxs(TabTriggerPrimitive, { value: "overview", className: "data-[state=active]:bg-b3-primary-blue data-[state=active]:hover:bg-b3-primary-blue data-[state=active]:border-b3-primary-blue group flex h-12 w-full items-center justify-center gap-2 rounded-xl border border-gray-200 bg-white p-2 text-center shadow-sm transition-all duration-200 hover:bg-gray-50 hover:shadow-md data-[state=active]:shadow-lg", children: [_jsx(BarChart3, { size: 20, className: "text-b3-primary-blue shrink-0 group-data-[state=active]:text-white" }), _jsx("span", { className: "text-b3-grey font-neue-montreal-semibold text-sm group-data-[state=active]:text-white", children: "Overview" })] }), _jsxs(TabTriggerPrimitive, { value: "tokens", className: "data-[state=active]:bg-b3-primary-blue data-[state=active]:hover:bg-b3-primary-blue data-[state=active]:border-b3-primary-blue group flex h-12 w-full items-center justify-center gap-2 rounded-xl border border-gray-200 bg-white p-2 text-center shadow-sm transition-all duration-200 hover:bg-gray-50 hover:shadow-md data-[state=active]:shadow-lg", children: [_jsx(Coins, { size: 20, className: "text-b3-primary-blue shrink-0 group-data-[state=active]:text-white" }), _jsx("span", { className: "text-b3-grey font-neue-montreal-semibold text-sm group-data-[state=active]:text-white", children: "Tokens" })] }), _jsxs(TabTriggerPrimitive, { value: "nfts", className: "data-[state=active]:bg-b3-primary-blue data-[state=active]:hover:bg-b3-primary-blue data-[state=active]:border-b3-primary-blue group flex h-12 w-full items-center justify-center gap-2 rounded-xl border border-gray-200 bg-white p-2 text-center shadow-sm transition-all duration-200 hover:bg-gray-50 hover:shadow-md data-[state=active]:shadow-lg", children: [_jsx(Image, { size: 20, className: "text-b3-primary-blue shrink-0 group-data-[state=active]:text-white" }), _jsx("span", { className: "text-b3-grey font-neue-montreal-semibold text-sm group-data-[state=active]:text-white", children: "NFTs" })] }), _jsxs(TabTriggerPrimitive, { value: "settings", className: "data-[state=active]:bg-b3-primary-blue data-[state=active]:hover:bg-b3-primary-blue data-[state=active]:border-b3-primary-blue group flex h-12 w-full items-center justify-center gap-2 rounded-xl border border-gray-200 bg-white p-2 text-center shadow-sm transition-all duration-200 hover:bg-gray-50 hover:shadow-md data-[state=active]:shadow-lg", children: [_jsx(Settings, { size: 20, className: "text-b3-primary-blue shrink-0 group-data-[state=active]:text-white" }), _jsx("span", { className: "text-b3-grey font-neue-montreal-semibold text-sm group-data-[state=active]:text-white", children: "Settings" })] })] }) }), _jsx(TabsContentPrimitive, { value: "overview", className: "px-4 pb-4 pt-2", children: _jsx(BalanceContent, { onLogout: onLogout, partnerId: partnerId, showDeposit: showDeposit, showSwap: showSwap }) }), _jsx(TabsContentPrimitive, { value: "tokens", className: "px-4 pb-4 pt-2", children: _jsx(ContentTokens, { activeTab: activeTab }) }), _jsx(TabsContentPrimitive, { value: "nfts", className: "px-4 pb-4 pt-2", children: _jsx("div", { className: "grid grid-cols-3 gap-4", children: nfts?.nftResponse ? (_jsx(AccountAssets, { nfts: nfts.nftResponse, isLoading: isLoading })) : (_jsx("div", { className: "col-span-3 py-12 text-center text-gray-500", children: "No NFTs found" })) }) }), _jsx(TabsContentPrimitive, { value: "apps", className: "px-4 pb-4 pt-2", children: _jsx(AppsContent, {}) }), _jsx(TabsContentPrimitive, { value: "settings", className: "px-4 pb-4 pt-2", children: _jsx(SettingsContent, {}) })] }) }) }));
|
|
200
200
|
}
|
|
@@ -9,10 +9,10 @@ import { useConnectedWallets, useSetActiveWallet, useWalletInfo } from "thirdweb
|
|
|
9
9
|
import { ManageAccountButton } from "../custom/ManageAccountButton.js";
|
|
10
10
|
export function SignIn(props) {
|
|
11
11
|
const { className } = props;
|
|
12
|
-
const { automaticallySetFirstEoa
|
|
12
|
+
const { automaticallySetFirstEoa } = useB3();
|
|
13
13
|
const { wallet, address: globalAddress, ensName, connectedSmartWallet, connectedEOAWallet, isActiveSmartWallet, isActiveEOAWallet, smartWalletIcon, eoaWalletIcon, } = useAccountWallet();
|
|
14
14
|
const isMobile = useIsMobile();
|
|
15
|
-
const { logout } = useAuthentication(
|
|
15
|
+
const { logout } = useAuthentication(String(process.env.NEXT_PUBLIC_THIRDWEB_PARTNER_ID));
|
|
16
16
|
const onDisconnect = async () => {
|
|
17
17
|
await logout();
|
|
18
18
|
};
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
-
import { Button, StyleRoot,
|
|
2
|
+
import { Button, StyleRoot, useAuthentication, useB3, useIsMobile, useModalStore, } from "../../../../global-account/react/index.js";
|
|
3
3
|
import { useEffect } from "react";
|
|
4
4
|
import { ManageAccountButton } from "../custom/ManageAccountButton.js";
|
|
5
5
|
import { Loading } from "../ui/Loading.js";
|
|
6
6
|
export function SignInWithB3(props) {
|
|
7
7
|
const { setB3ModalOpen, setB3ModalContentType, setEcoSystemAccountAddress } = useModalStore();
|
|
8
8
|
const { account } = useB3();
|
|
9
|
-
const { isAuthenticating, isAuthenticated } =
|
|
9
|
+
const { isAuthenticating, isAuthenticated } = useAuthentication(props.partnerId, props.loginWithSiwe);
|
|
10
10
|
const isMobile = useIsMobile();
|
|
11
11
|
useEffect(() => {
|
|
12
12
|
if (account) {
|
|
@@ -3,4 +3,4 @@ import { SignInWithB3ModalProps } from "../../../../global-account/react";
|
|
|
3
3
|
* Component that manages the authentication flow for Sign In With B3
|
|
4
4
|
* Handles different login providers, authentication steps, and session key management
|
|
5
5
|
*/
|
|
6
|
-
export declare function SignInWithB3Flow({ strategies, onLoginSuccess, onSessionKeySuccess, onError, chain, sessionKeyAddress, partnerId, closeAfterLogin, source, signersEnabled, }: SignInWithB3ModalProps): import("react/jsx-runtime").JSX.Element | null;
|
|
6
|
+
export declare function SignInWithB3Flow({ strategies, onLoginSuccess, onSessionKeySuccess, onError, chain, sessionKeyAddress, partnerId, closeAfterLogin, loginWithSiwe, source, signersEnabled, }: SignInWithB3ModalProps): import("react/jsx-runtime").JSX.Element | null;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { Loading, useAuthStore, useB3, useGetAllTWSigners, useModalStore, } from "../../../../global-account/react/index.js";
|
|
2
|
+
import { Loading, useAuthStore, useB3, useGetAllTWSigners, useModalStore, useSiwe, } from "../../../../global-account/react/index.js";
|
|
3
3
|
import { debugB3React } from "../../../../shared/utils/debug.js";
|
|
4
4
|
import { useCallback, useEffect, useState } from "react";
|
|
5
5
|
import { useActiveAccount } from "thirdweb/react";
|
|
@@ -12,14 +12,16 @@ const MAX_REFETCH_ATTEMPTS = 20;
|
|
|
12
12
|
* Component that manages the authentication flow for Sign In With B3
|
|
13
13
|
* Handles different login providers, authentication steps, and session key management
|
|
14
14
|
*/
|
|
15
|
-
export function SignInWithB3Flow({ strategies, onLoginSuccess, onSessionKeySuccess, onError, chain, sessionKeyAddress, partnerId, closeAfterLogin = false, source = "signInWithB3Button", signersEnabled = false, }) {
|
|
16
|
-
const { automaticallySetFirstEoa } = useB3();
|
|
15
|
+
export function SignInWithB3Flow({ strategies, onLoginSuccess, onSessionKeySuccess, onError, chain, sessionKeyAddress, partnerId, closeAfterLogin = false, loginWithSiwe = false, source = "signInWithB3Button", signersEnabled = false, }) {
|
|
16
|
+
const { setUser, automaticallySetFirstEoa } = useB3();
|
|
17
17
|
const [step, setStep] = useState(source === "requestPermissions" ? null : "login");
|
|
18
18
|
const [sessionKeyAdded, setSessionKeyAdded] = useState(source === "requestPermissions" ? true : false);
|
|
19
19
|
const { setB3ModalContentType, setB3ModalOpen, isOpen } = useModalStore();
|
|
20
20
|
const account = useActiveAccount();
|
|
21
|
+
const setIsAuthenticating = useAuthStore(state => state.setIsAuthenticating);
|
|
21
22
|
const isAuthenticating = useAuthStore(state => state.isAuthenticating);
|
|
22
23
|
const isConnected = useAuthStore(state => state.isConnected);
|
|
24
|
+
const setIsConnected = useAuthStore(state => state.setIsConnected);
|
|
23
25
|
const [refetchCount, setRefetchCount] = useState(0);
|
|
24
26
|
const [refetchError, setRefetchError] = useState(null);
|
|
25
27
|
const { data: signers, refetch: refetchSigners, isFetching: isFetchingSigners, } = useGetAllTWSigners({
|
|
@@ -29,6 +31,7 @@ export function SignInWithB3Flow({ strategies, onLoginSuccess, onSessionKeySucce
|
|
|
29
31
|
enabled: signersEnabled,
|
|
30
32
|
},
|
|
31
33
|
});
|
|
34
|
+
const { authenticate } = useSiwe();
|
|
32
35
|
const [refetchQueued, setRefetchQueued] = useState(false);
|
|
33
36
|
// Enhanced refetchSigners function that tracks number of attempts
|
|
34
37
|
const handleRefetchSigners = useCallback(() => {
|
|
@@ -139,11 +142,13 @@ export function SignInWithB3Flow({ strategies, onLoginSuccess, onSessionKeySucce
|
|
|
139
142
|
sessionKeyAddress,
|
|
140
143
|
partnerId,
|
|
141
144
|
closeAfterLogin,
|
|
145
|
+
loginWithSiwe,
|
|
142
146
|
source: "requestPermissions",
|
|
143
147
|
});
|
|
144
148
|
}, [
|
|
145
149
|
chain,
|
|
146
150
|
closeAfterLogin,
|
|
151
|
+
loginWithSiwe,
|
|
147
152
|
onError,
|
|
148
153
|
onLoginSuccess,
|
|
149
154
|
onSessionKeySuccess,
|
|
@@ -153,8 +158,19 @@ export function SignInWithB3Flow({ strategies, onLoginSuccess, onSessionKeySucce
|
|
|
153
158
|
strategies,
|
|
154
159
|
]);
|
|
155
160
|
const handleLoginSuccess = useCallback(async (account) => {
|
|
161
|
+
debug("Authenticating with B3 via SIWE");
|
|
162
|
+
setIsConnected(true);
|
|
163
|
+
if (loginWithSiwe) {
|
|
164
|
+
debug("setIsAuthenticating:true:1");
|
|
165
|
+
setIsAuthenticating(true);
|
|
166
|
+
const userAuth = await authenticate(account, partnerId);
|
|
167
|
+
setUser(userAuth.user);
|
|
168
|
+
}
|
|
169
|
+
debug("handleLoginSuccess:account", account);
|
|
156
170
|
onLoginSuccess?.(account);
|
|
157
|
-
|
|
171
|
+
debug("setIsAuthenticating:false:1");
|
|
172
|
+
setIsAuthenticating(false);
|
|
173
|
+
}, [loginWithSiwe, onLoginSuccess, authenticate, partnerId, setUser, setIsConnected, setIsAuthenticating]);
|
|
158
174
|
useEffect(() => {
|
|
159
175
|
if (step === "permissions") {
|
|
160
176
|
setB3ModalContentType({
|
|
@@ -176,14 +192,14 @@ export function SignInWithB3Flow({ strategies, onLoginSuccess, onSessionKeySucce
|
|
|
176
192
|
if (step === "login") {
|
|
177
193
|
// Custom strategy
|
|
178
194
|
if (strategies?.[0] === "privy") {
|
|
179
|
-
return _jsx(SignInWithB3Privy, { onSuccess: handleLoginSuccess, chain: chain });
|
|
195
|
+
return _jsx(SignInWithB3Privy, { onSuccess: handleLoginSuccess, partnerId: partnerId, chain: chain });
|
|
180
196
|
}
|
|
181
197
|
// Strategies are explicitly provided
|
|
182
198
|
if (strategies) {
|
|
183
|
-
return (_jsx(LoginStepCustom, { strategies: strategies, chain: chain, onSuccess: handleLoginSuccess, onError: onError, automaticallySetFirstEoa: !!automaticallySetFirstEoa }));
|
|
199
|
+
return (_jsx(LoginStepCustom, { strategies: strategies, partnerId: partnerId, chain: chain, onSuccess: handleLoginSuccess, onError: onError, automaticallySetFirstEoa: !!automaticallySetFirstEoa }));
|
|
184
200
|
}
|
|
185
201
|
// Default to handle all strategies we support
|
|
186
|
-
return _jsx(LoginStep, { chain: chain, onSuccess: handleLoginSuccess, onError: onError });
|
|
202
|
+
return _jsx(LoginStep, { partnerId: partnerId, chain: chain, onSuccess: handleLoginSuccess, onError: onError });
|
|
187
203
|
}
|
|
188
204
|
return null;
|
|
189
205
|
}
|
|
@@ -4,7 +4,8 @@ interface SignInWithB3PrivyProps {
|
|
|
4
4
|
onError?: (error: Error) => Promise<void>;
|
|
5
5
|
onSuccess: (account: Account) => Promise<void>;
|
|
6
6
|
accessToken?: string;
|
|
7
|
+
partnerId: string;
|
|
7
8
|
chain: Chain;
|
|
8
9
|
}
|
|
9
|
-
export declare function SignInWithB3Privy({ onSuccess, onError, chain }: SignInWithB3PrivyProps): import("react/jsx-runtime").JSX.Element;
|
|
10
|
+
export declare function SignInWithB3Privy({ onSuccess, onError, partnerId, chain }: SignInWithB3PrivyProps): import("react/jsx-runtime").JSX.Element;
|
|
10
11
|
export {};
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { Loading, useAuthentication, useAuthStore,
|
|
2
|
+
import { Loading, useAuthentication, useAuthStore, 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
|
-
export function SignInWithB3Privy({ onSuccess, onError, chain }) {
|
|
7
|
-
const {
|
|
8
|
-
const { isLoading, connectTw, fullToken } = useHandleConnectWithPrivy(chain, onSuccess);
|
|
6
|
+
export function SignInWithB3Privy({ onSuccess, onError, partnerId, chain }) {
|
|
7
|
+
const { isLoading, connectTw, fullToken } = useHandleConnectWithPrivy(partnerId, chain, onSuccess);
|
|
9
8
|
const setIsAuthenticating = useAuthStore(state => state.setIsAuthenticating);
|
|
10
9
|
const setIsAuthenticated = useAuthStore(state => state.setIsAuthenticated);
|
|
11
10
|
const { logout } = useAuthentication(partnerId);
|
|
@@ -9,6 +9,7 @@ interface LoginStepProps {
|
|
|
9
9
|
/** Optional callback function called when an error occurs */
|
|
10
10
|
onError?: (error: Error) => Promise<void>;
|
|
11
11
|
/** Partner ID used for authentication */
|
|
12
|
+
partnerId: string;
|
|
12
13
|
/** Blockchain chain information */
|
|
13
14
|
chain: Chain;
|
|
14
15
|
/** Optional authentication strategy options */
|
|
@@ -19,5 +20,5 @@ interface LoginStepContainerProps {
|
|
|
19
20
|
partnerId?: string;
|
|
20
21
|
}
|
|
21
22
|
export declare function LoginStepContainer({ children, partnerId }: LoginStepContainerProps): import("react/jsx-runtime").JSX.Element;
|
|
22
|
-
export declare function LoginStep({ onSuccess, chain }: LoginStepProps): import("react/jsx-runtime").JSX.Element;
|
|
23
|
+
export declare function LoginStep({ onSuccess, onError, partnerId, chain }: LoginStepProps): import("react/jsx-runtime").JSX.Element;
|
|
23
24
|
export {};
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { useAuthentication, useB3, useQueryB3 } from "../../../../../global-account/react/index.js";
|
|
2
|
+
import { useAuthentication, useAuthStore, useB3, useQueryB3 } from "../../../../../global-account/react/index.js";
|
|
3
3
|
import { ecosystemWalletId } from "../../../../../shared/constants/index.js";
|
|
4
|
+
import { debug } from "../../../../../shared/utils/debug.js";
|
|
4
5
|
import { client } from "../../../../../shared/utils/thirdweb.js";
|
|
5
6
|
import { ConnectEmbed, darkTheme, lightTheme } from "thirdweb/react";
|
|
6
7
|
import { ecosystemWallet } from "thirdweb/wallets";
|
|
@@ -14,12 +15,14 @@ export function LoginStepContainer({ children, partnerId }) {
|
|
|
14
15
|
const partnerLogo = partner?.data?.[0]?.loginCustomization?.logoUrl;
|
|
15
16
|
return (_jsxs("div", { className: "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, _jsxs("h2", { className: "mt-6 flex items-center gap-2 text-lg font-bold", children: ["Powered by", _jsx("img", { alt: "B3 Logo", className: "h-5", src: "https://cdn.b3.fun/b3_logo.svg" }), "Connect"] })] }));
|
|
16
17
|
}
|
|
17
|
-
export function LoginStep({ onSuccess, chain }) {
|
|
18
|
-
const { partnerId, theme } = useB3();
|
|
18
|
+
export function LoginStep({ onSuccess, onError, partnerId, chain }) {
|
|
19
19
|
const wallet = ecosystemWallet(ecosystemWalletId, {
|
|
20
20
|
partnerId: partnerId,
|
|
21
21
|
});
|
|
22
|
-
const {
|
|
22
|
+
const { theme } = useB3();
|
|
23
|
+
const setIsAuthenticating = useAuthStore(state => state.setIsAuthenticating);
|
|
24
|
+
const setIsAuthenticated = useAuthStore(state => state.setIsAuthenticated);
|
|
25
|
+
const { logout } = useAuthentication(partnerId);
|
|
23
26
|
return (_jsx(LoginStepContainer, { partnerId: partnerId, children: _jsx(ConnectEmbed, { showThirdwebBranding: false, client: client, chain: chain, wallets: [wallet], theme: theme === "light"
|
|
24
27
|
? lightTheme({
|
|
25
28
|
colors: {
|
|
@@ -30,18 +33,50 @@ export function LoginStep({ onSuccess, chain }) {
|
|
|
30
33
|
colors: {
|
|
31
34
|
modalBg: "hsl(var(--b3-react-background))",
|
|
32
35
|
},
|
|
33
|
-
}), style: {
|
|
36
|
+
}), autoConnect: true, style: {
|
|
34
37
|
width: "100%",
|
|
35
38
|
height: "100%",
|
|
36
39
|
border: 0,
|
|
37
|
-
},
|
|
40
|
+
},
|
|
41
|
+
// TODO: Integrate with SIWE in useSIWE
|
|
42
|
+
// auth={{
|
|
43
|
+
// isLoggedIn: async (address) => {
|
|
44
|
+
// console.log("checking if logged in!", { address });
|
|
45
|
+
// return await isLoggedIn();
|
|
46
|
+
// },
|
|
47
|
+
// doLogin: async (params) => {
|
|
48
|
+
// console.log("logging in!");
|
|
49
|
+
// await login(params);
|
|
50
|
+
// },
|
|
51
|
+
// getLoginPayload: async ({ address }) =>
|
|
52
|
+
// generatePayload({ address }),
|
|
53
|
+
// doLogout: async () => {
|
|
54
|
+
// console.log("logging out!");
|
|
55
|
+
// await logout();
|
|
56
|
+
// },
|
|
57
|
+
// }}
|
|
58
|
+
header: {
|
|
38
59
|
title: "Sign in with B3",
|
|
39
60
|
titleIcon: "https://cdn.b3.fun/b3_logo.svg",
|
|
40
61
|
}, className: "b3-login-step", onConnect: async (wallet) => {
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
62
|
+
try {
|
|
63
|
+
setIsAuthenticating(true);
|
|
64
|
+
debug("setIsAuthenticating:true:6");
|
|
65
|
+
const account = wallet.getAccount();
|
|
66
|
+
if (!account)
|
|
67
|
+
throw new Error("No account found");
|
|
68
|
+
await onSuccess(account);
|
|
69
|
+
setIsAuthenticated(true);
|
|
70
|
+
console.log("connected!", wallet.id);
|
|
71
|
+
}
|
|
72
|
+
catch (error) {
|
|
73
|
+
await onError?.(error);
|
|
74
|
+
await logout();
|
|
75
|
+
setIsAuthenticated(false);
|
|
76
|
+
}
|
|
77
|
+
finally {
|
|
78
|
+
debug("setIsAuthenticating:false:6");
|
|
79
|
+
setIsAuthenticating(false);
|
|
80
|
+
}
|
|
46
81
|
} }) }));
|
|
47
82
|
}
|
|
@@ -5,9 +5,10 @@ interface LoginStepCustomProps {
|
|
|
5
5
|
automaticallySetFirstEoa: boolean;
|
|
6
6
|
onSuccess: (account: Account) => Promise<void>;
|
|
7
7
|
onError?: (error: Error) => Promise<void>;
|
|
8
|
+
partnerId: string;
|
|
8
9
|
chain: Chain;
|
|
9
10
|
strategies: AllowedStrategy[];
|
|
10
11
|
maxInitialWallets?: number;
|
|
11
12
|
}
|
|
12
|
-
export declare function LoginStepCustom({ onSuccess, onError, chain, strategies, maxInitialWallets, automaticallySetFirstEoa, }: LoginStepCustomProps): import("react/jsx-runtime").JSX.Element;
|
|
13
|
+
export declare function LoginStepCustom({ onSuccess, onError, partnerId, chain, strategies, maxInitialWallets, automaticallySetFirstEoa, }: LoginStepCustomProps): import("react/jsx-runtime").JSX.Element;
|
|
13
14
|
export {};
|
|
@@ -1,13 +1,12 @@
|
|
|
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, 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";
|
|
6
6
|
import { useConnect as useConnectTW } from "thirdweb/react";
|
|
7
7
|
import { createWallet } from "thirdweb/wallets";
|
|
8
8
|
const debug = debugB3React("LoginStepCustom");
|
|
9
|
-
export function LoginStepCustom({ onSuccess, onError, chain, strategies, maxInitialWallets = 2, automaticallySetFirstEoa, }) {
|
|
10
|
-
const { partnerId } = useB3();
|
|
9
|
+
export function LoginStepCustom({ onSuccess, onError, partnerId, chain, strategies, maxInitialWallets = 2, automaticallySetFirstEoa, }) {
|
|
11
10
|
const [isLoading, setIsLoading] = useState(false);
|
|
12
11
|
const [showAllWallets, setShowAllWallets] = useState(false);
|
|
13
12
|
const { connect } = useConnect(partnerId, chain);
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { Button, StyleRoot, useAuthentication,
|
|
2
|
+
import { Button, StyleRoot, useAuthentication, 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();
|
|
6
5
|
const { setB3ModalOpen, setB3ModalContentType } = useModalStore();
|
|
7
|
-
const { isConnected } = useAuthentication(partnerId);
|
|
6
|
+
const { isConnected } = useAuthentication(props.partnerId, props.loginWithSiwe);
|
|
8
7
|
const handleClickManageAccount = () => {
|
|
9
8
|
setB3ModalContentType({
|
|
10
9
|
...props,
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { Wallet } from "thirdweb/wallets";
|
|
2
1
|
import { preAuthenticate } from "thirdweb/wallets/in-app";
|
|
3
|
-
export declare function useAuthentication(partnerId: string): {
|
|
2
|
+
export declare function useAuthentication(partnerId: string, loginWithSiwe?: boolean): {
|
|
4
3
|
logout: (callback?: () => void) => Promise<void>;
|
|
5
4
|
isAuthenticated: boolean;
|
|
6
5
|
isReady: boolean;
|
|
@@ -8,54 +7,6 @@ export declare function useAuthentication(partnerId: string): {
|
|
|
8
7
|
isConnected: boolean;
|
|
9
8
|
wallet: import("thirdweb/dist/types/wallets/in-app/core/wallet/types").EcosystemWallet;
|
|
10
9
|
preAuthenticate: typeof preAuthenticate;
|
|
11
|
-
connect: (
|
|
10
|
+
connect: (strategyOptions?: import("thirdweb/wallets").SingleStepAuthArgsType) => Promise<import("thirdweb/wallets").Wallet | null>;
|
|
12
11
|
isAuthenticating: boolean;
|
|
13
|
-
onConnect: (wallet: Wallet) => Promise<void>;
|
|
14
|
-
user: {
|
|
15
|
-
email?: string | undefined;
|
|
16
|
-
username?: string | undefined;
|
|
17
|
-
telNumber?: string | undefined;
|
|
18
|
-
ens?: string | undefined;
|
|
19
|
-
avatar?: string | undefined;
|
|
20
|
-
preferences?: {} | undefined;
|
|
21
|
-
referredBy?: string | {} | undefined;
|
|
22
|
-
sourceApp?: string | undefined;
|
|
23
|
-
referralCode?: string | undefined;
|
|
24
|
-
userGroups?: number[] | undefined;
|
|
25
|
-
isMigratedFromBSMNT?: boolean | undefined;
|
|
26
|
-
privyLinkedAccounts?: {
|
|
27
|
-
name?: string | undefined;
|
|
28
|
-
address?: string | undefined;
|
|
29
|
-
email?: string | undefined;
|
|
30
|
-
chain_type?: string | undefined;
|
|
31
|
-
lv?: number | undefined;
|
|
32
|
-
wallet_client_type?: string | undefined;
|
|
33
|
-
smart_wallet_type?: string | undefined;
|
|
34
|
-
subject?: string | undefined;
|
|
35
|
-
type: string;
|
|
36
|
-
}[] | undefined;
|
|
37
|
-
twProfiles?: {
|
|
38
|
-
type: string;
|
|
39
|
-
details: {
|
|
40
|
-
id?: string | undefined;
|
|
41
|
-
name?: string | undefined;
|
|
42
|
-
address?: string | undefined;
|
|
43
|
-
email?: string | undefined;
|
|
44
|
-
phone?: string | undefined;
|
|
45
|
-
username?: string | undefined;
|
|
46
|
-
fid?: string | undefined;
|
|
47
|
-
};
|
|
48
|
-
}[] | undefined;
|
|
49
|
-
_id: string | {};
|
|
50
|
-
userId: string;
|
|
51
|
-
smartAccountAddress: string;
|
|
52
|
-
createdAt: number;
|
|
53
|
-
updatedAt: number;
|
|
54
|
-
partnerIds: {
|
|
55
|
-
privyId?: string | undefined;
|
|
56
|
-
thirdwebId?: string | undefined;
|
|
57
|
-
};
|
|
58
|
-
} | undefined;
|
|
59
|
-
refetchUser: (wallet?: Wallet) => Promise<void>;
|
|
60
|
-
setUser: (newUser?: import("@b3dotfun/b3-api").Users) => void;
|
|
61
12
|
};
|