@b3dotfun/sdk 0.0.40-alpha.6 → 0.0.40-alpha.8
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/AnyspendDepositHype.js +1 -1
- package/dist/cjs/anyspend/react/components/common/CryptoReceiveSection.js +38 -36
- package/dist/cjs/anyspend/react/components/common/PanelOnramp.d.ts +3 -1
- package/dist/cjs/anyspend/react/components/common/PanelOnramp.js +7 -6
- package/dist/cjs/anyspend/react/contexts/FeatureFlagsContext.d.ts +11 -0
- package/dist/cjs/anyspend/react/contexts/FeatureFlagsContext.js +21 -0
- package/dist/cjs/anyspend/react/hooks/useAnyspendFlow.d.ts +1 -65
- package/dist/cjs/anyspend/react/providers/AnyspendProvider.d.ts +5 -2
- package/dist/cjs/anyspend/react/providers/AnyspendProvider.js +5 -3
- package/dist/cjs/anyspend/react/providers/index.d.ts +1 -0
- package/dist/cjs/anyspend/react/providers/index.js +3 -0
- package/dist/cjs/anyspend/types/api_req_res.d.ts +8 -1
- package/dist/cjs/global-account/react/components/B3Provider/B3Provider.d.ts +3 -2
- package/dist/cjs/global-account/react/components/B3Provider/B3Provider.js +35 -16
- package/dist/cjs/global-account/react/components/SignInWithB3/steps/LoginStepCustom.js +4 -3
- package/dist/cjs/global-account/react/hooks/useAuthentication.js +1 -2
- package/dist/esm/anyspend/react/components/AnySpend.js +1 -1
- package/dist/esm/anyspend/react/components/AnyspendDepositHype.js +1 -1
- package/dist/esm/anyspend/react/components/common/CryptoReceiveSection.js +38 -36
- package/dist/esm/anyspend/react/components/common/PanelOnramp.d.ts +3 -1
- package/dist/esm/anyspend/react/components/common/PanelOnramp.js +7 -6
- package/dist/esm/anyspend/react/contexts/FeatureFlagsContext.d.ts +11 -0
- package/dist/esm/anyspend/react/contexts/FeatureFlagsContext.js +17 -0
- package/dist/esm/anyspend/react/hooks/useAnyspendFlow.d.ts +1 -65
- package/dist/esm/anyspend/react/providers/AnyspendProvider.d.ts +5 -2
- package/dist/esm/anyspend/react/providers/AnyspendProvider.js +5 -3
- package/dist/esm/anyspend/react/providers/index.d.ts +1 -0
- package/dist/esm/anyspend/react/providers/index.js +1 -0
- package/dist/esm/anyspend/types/api_req_res.d.ts +8 -1
- package/dist/esm/global-account/react/components/B3Provider/B3Provider.d.ts +3 -2
- package/dist/esm/global-account/react/components/B3Provider/B3Provider.js +36 -17
- package/dist/esm/global-account/react/components/SignInWithB3/steps/LoginStepCustom.js +3 -2
- package/dist/esm/global-account/react/hooks/useAuthentication.js +1 -2
- package/dist/types/anyspend/react/components/common/PanelOnramp.d.ts +3 -1
- package/dist/types/anyspend/react/contexts/FeatureFlagsContext.d.ts +11 -0
- package/dist/types/anyspend/react/hooks/useAnyspendFlow.d.ts +1 -65
- package/dist/types/anyspend/react/providers/AnyspendProvider.d.ts +5 -2
- package/dist/types/anyspend/react/providers/index.d.ts +1 -0
- package/dist/types/anyspend/types/api_req_res.d.ts +8 -1
- package/dist/types/global-account/react/components/B3Provider/B3Provider.d.ts +3 -2
- package/package.json +6 -5
- package/src/anyspend/react/components/AnySpend.tsx +1 -0
- package/src/anyspend/react/components/AnyspendDepositHype.tsx +1 -0
- package/src/anyspend/react/components/common/CryptoReceiveSection.tsx +56 -45
- package/src/anyspend/react/components/common/PanelOnramp.tsx +22 -16
- package/src/anyspend/react/contexts/FeatureFlagsContext.tsx +34 -0
- package/src/anyspend/react/providers/AnyspendProvider.tsx +11 -6
- package/src/anyspend/react/providers/index.ts +1 -0
- package/src/anyspend/types/api_req_res.ts +10 -1
- package/src/global-account/react/components/B3Provider/B3Provider.tsx +49 -24
- package/src/global-account/react/components/SignInWithB3/steps/LoginStepCustom.tsx +4 -2
- package/src/global-account/react/hooks/useAuthentication.ts +1 -2
|
@@ -1,9 +1,15 @@
|
|
|
1
|
+
import { Users } from "@b3dotfun/b3-api";
|
|
1
2
|
import { RelayKitProviderWrapper, TooltipProvider, useAuthStore } from "@b3dotfun/sdk/global-account/react";
|
|
2
3
|
import { PermissionsConfig } from "@b3dotfun/sdk/global-account/types/permissions";
|
|
3
4
|
import { loadGA4Script } from "@b3dotfun/sdk/global-account/utils/analytics";
|
|
5
|
+
import { ecosystemWalletId } from "@b3dotfun/sdk/shared/constants";
|
|
4
6
|
import { supportedChains } from "@b3dotfun/sdk/shared/constants/chains/supported";
|
|
7
|
+
import { debugB3React } from "@b3dotfun/sdk/shared/utils/debug";
|
|
8
|
+
import { client } from "@b3dotfun/sdk/shared/utils/thirdweb";
|
|
9
|
+
import "@reservoir0x/relay-kit-ui/styles.css";
|
|
5
10
|
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
|
|
6
|
-
import {
|
|
11
|
+
import { inAppWalletConnector } from "@thirdweb-dev/wagmi-adapter";
|
|
12
|
+
import { useCallback, useEffect, useMemo, useState } from "react";
|
|
7
13
|
import { Toaster } from "sonner";
|
|
8
14
|
import {
|
|
9
15
|
getLastAuthProvider,
|
|
@@ -18,8 +24,7 @@ import { ClientType, setClientType } from "../../../client-manager";
|
|
|
18
24
|
import { StyleRoot } from "../StyleRoot";
|
|
19
25
|
import { B3Context, B3ContextType } from "./types";
|
|
20
26
|
|
|
21
|
-
|
|
22
|
-
import "@reservoir0x/relay-kit-ui/styles.css";
|
|
27
|
+
const debug = debugB3React("B3Provider");
|
|
23
28
|
|
|
24
29
|
/**
|
|
25
30
|
* Default permissions configuration for B3 provider
|
|
@@ -31,17 +36,6 @@ const DEFAULT_PERMISSIONS = {
|
|
|
31
36
|
endDate: new Date(Date.now() + 1000 * 60 * 60 * 24 * 365), // 1 year from now
|
|
32
37
|
};
|
|
33
38
|
|
|
34
|
-
/**
|
|
35
|
-
* Creates wagmi config with optional custom RPC URLs
|
|
36
|
-
* @param rpcUrls - Optional mapping of chain IDs to RPC URLs
|
|
37
|
-
*/
|
|
38
|
-
function createWagmiConfig(rpcUrls?: Record<number, string>) {
|
|
39
|
-
return createConfig({
|
|
40
|
-
chains: [supportedChains[0], ...supportedChains.slice(1)],
|
|
41
|
-
transports: Object.fromEntries(supportedChains.map(chain => [chain.id, http(rpcUrls?.[chain.id])])) as any,
|
|
42
|
-
});
|
|
43
|
-
}
|
|
44
|
-
|
|
45
39
|
// Create queryClient instance
|
|
46
40
|
const queryClient = new QueryClient();
|
|
47
41
|
|
|
@@ -58,6 +52,7 @@ export function B3Provider({
|
|
|
58
52
|
toaster,
|
|
59
53
|
clientType = "rest",
|
|
60
54
|
rpcUrls,
|
|
55
|
+
partnerId,
|
|
61
56
|
}: {
|
|
62
57
|
theme: "light" | "dark";
|
|
63
58
|
children: React.ReactNode;
|
|
@@ -71,10 +66,8 @@ export function B3Provider({
|
|
|
71
66
|
};
|
|
72
67
|
clientType?: ClientType;
|
|
73
68
|
rpcUrls?: Record<number, string>;
|
|
69
|
+
partnerId?: string;
|
|
74
70
|
}) {
|
|
75
|
-
// Create wagmi config with custom RPC URLs if provided
|
|
76
|
-
const [wagmiConfig] = useState(() => createWagmiConfig(rpcUrls));
|
|
77
|
-
|
|
78
71
|
// Initialize Google Analytics on mount
|
|
79
72
|
useEffect(() => {
|
|
80
73
|
loadGA4Script();
|
|
@@ -85,10 +78,41 @@ export function B3Provider({
|
|
|
85
78
|
setClientType(clientType);
|
|
86
79
|
}, [clientType]);
|
|
87
80
|
|
|
81
|
+
const ecocystemConfig = useMemo(() => {
|
|
82
|
+
if (!partnerId) return undefined;
|
|
83
|
+
|
|
84
|
+
return {
|
|
85
|
+
ecosystemId: ecosystemWalletId,
|
|
86
|
+
partnerId: partnerId,
|
|
87
|
+
client,
|
|
88
|
+
};
|
|
89
|
+
}, [partnerId]);
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* Creates wagmi config with optional custom RPC URLs
|
|
93
|
+
* @param rpcUrls - Optional mapping of chain IDs to RPC URLs
|
|
94
|
+
*/
|
|
95
|
+
const wagmiConfig = useMemo(
|
|
96
|
+
() =>
|
|
97
|
+
createConfig({
|
|
98
|
+
chains: [supportedChains[0], ...supportedChains.slice(1)],
|
|
99
|
+
transports: Object.fromEntries(supportedChains.map(chain => [chain.id, http(rpcUrls?.[chain.id])])) as any,
|
|
100
|
+
connectors: [
|
|
101
|
+
inAppWalletConnector({
|
|
102
|
+
...(ecocystemConfig || {}),
|
|
103
|
+
client,
|
|
104
|
+
}),
|
|
105
|
+
// injected(),
|
|
106
|
+
// coinbaseWallet({ appName: "HypeDuel" }),
|
|
107
|
+
],
|
|
108
|
+
}),
|
|
109
|
+
[partnerId],
|
|
110
|
+
);
|
|
111
|
+
|
|
88
112
|
return (
|
|
89
|
-
<
|
|
90
|
-
<
|
|
91
|
-
<
|
|
113
|
+
<ThirdwebProvider>
|
|
114
|
+
<WagmiProvider config={wagmiConfig}>
|
|
115
|
+
<QueryClientProvider client={queryClient}>
|
|
92
116
|
<TooltipProvider>
|
|
93
117
|
<InnerProvider
|
|
94
118
|
accountOverride={accountOverride}
|
|
@@ -105,9 +129,9 @@ export function B3Provider({
|
|
|
105
129
|
</RelayKitProviderWrapper>
|
|
106
130
|
</InnerProvider>
|
|
107
131
|
</TooltipProvider>
|
|
108
|
-
</
|
|
109
|
-
</
|
|
110
|
-
</
|
|
132
|
+
</QueryClientProvider>
|
|
133
|
+
</WagmiProvider>
|
|
134
|
+
</ThirdwebProvider>
|
|
111
135
|
);
|
|
112
136
|
}
|
|
113
137
|
|
|
@@ -136,6 +160,7 @@ export function InnerProvider({
|
|
|
136
160
|
const wallets = useConnectedWallets();
|
|
137
161
|
const setActiveWallet = useSetActiveWallet();
|
|
138
162
|
const isAuthenticated = useAuthStore(state => state.isAuthenticated);
|
|
163
|
+
debug("@@wallets", wallets);
|
|
139
164
|
|
|
140
165
|
const [user, setUser] = useState<Users | undefined>(() => {
|
|
141
166
|
// Try to restore user from localStorage on initialization
|
|
@@ -169,7 +194,7 @@ export function InnerProvider({
|
|
|
169
194
|
(wallet: Wallet) => {
|
|
170
195
|
setManuallySelectedWallet(wallet);
|
|
171
196
|
const account = wallet.getAccount();
|
|
172
|
-
|
|
197
|
+
debug("@@setWallet", wallet.id, account?.address);
|
|
173
198
|
setActiveWallet(wallet);
|
|
174
199
|
},
|
|
175
200
|
[setManuallySelectedWallet, setActiveWallet],
|
|
@@ -10,7 +10,7 @@ import {
|
|
|
10
10
|
useConnect,
|
|
11
11
|
WalletRow,
|
|
12
12
|
} from "@b3dotfun/sdk/global-account/react";
|
|
13
|
-
import {
|
|
13
|
+
import { debugB3React } from "@b3dotfun/sdk/shared/utils/debug";
|
|
14
14
|
import { client } from "@b3dotfun/sdk/shared/utils/thirdweb";
|
|
15
15
|
import { useState } from "react";
|
|
16
16
|
import { Chain } from "thirdweb";
|
|
@@ -27,6 +27,8 @@ interface LoginStepCustomProps {
|
|
|
27
27
|
maxInitialWallets?: number;
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
+
const debug = debugB3React("LoginStepCustom");
|
|
31
|
+
|
|
30
32
|
export function LoginStepCustom({
|
|
31
33
|
onSuccess,
|
|
32
34
|
onError,
|
|
@@ -76,7 +78,7 @@ export function LoginStepCustom({
|
|
|
76
78
|
}
|
|
77
79
|
|
|
78
80
|
const account = connectResult?.getAccount();
|
|
79
|
-
|
|
81
|
+
debug("@@connectResult", { connectResult, account, options });
|
|
80
82
|
if (!account) throw new Error("Failed to connect");
|
|
81
83
|
await onSuccess(account);
|
|
82
84
|
setIsAuthenticated(true);
|
|
@@ -124,8 +124,7 @@ export function useAuthentication(partnerId: string, loginWithSiwe?: boolean) {
|
|
|
124
124
|
if (activeWallet) {
|
|
125
125
|
debug("@@logout:activeWallet", activeWallet);
|
|
126
126
|
disconnect(activeWallet);
|
|
127
|
-
debug("@@logout:
|
|
128
|
-
console.log("@@gio:logout:activeWallet", activeWallet);
|
|
127
|
+
debug("@@logout:activeWallet", activeWallet);
|
|
129
128
|
}
|
|
130
129
|
|
|
131
130
|
// Log out of each wallet
|