@gelatonetwork/smartwallet-react-privy 0.0.2-alpha.4 → 0.0.2-alpha.6
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/CHANGELOG.md +27 -0
- package/_dist/provider.d.ts.map +1 -1
- package/_dist/provider.js +8 -8
- package/_dist/provider.js.map +1 -1
- package/_dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +8 -8
- package/src/provider.tsx +16 -10
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@gelatonetwork/smartwallet-react-privy",
|
3
|
-
"version": "0.0.2-alpha.
|
3
|
+
"version": "0.0.2-alpha.6",
|
4
4
|
"author": "Gelato",
|
5
5
|
"type": "module",
|
6
6
|
"description": "Context provider supporting Privy WaaS",
|
@@ -11,8 +11,8 @@
|
|
11
11
|
"typescript": "^5.3",
|
12
12
|
"viem": "^2.28",
|
13
13
|
"wagmi": "^2.15",
|
14
|
-
"@gelatonetwork/smartwallet
|
15
|
-
"@gelatonetwork/smartwallet": "0.0.2-alpha.
|
14
|
+
"@gelatonetwork/smartwallet": "0.0.2-alpha.6",
|
15
|
+
"@gelatonetwork/smartwallet-react-types": "0.0.2-alpha.6"
|
16
16
|
},
|
17
17
|
"peerDependenciesMeta": {
|
18
18
|
"typescript": {
|
@@ -23,17 +23,17 @@
|
|
23
23
|
}
|
24
24
|
},
|
25
25
|
"dependencies": {
|
26
|
-
"@privy-io/react-auth": "^2.
|
26
|
+
"@privy-io/react-auth": "^2.13.0",
|
27
27
|
"@privy-io/wagmi": "^1.0.3",
|
28
28
|
"@tanstack/react-query": "^5.74",
|
29
|
-
"caip": "^1",
|
29
|
+
"caip": "^1.1.1",
|
30
30
|
"react": "^18.2",
|
31
31
|
"react-dom": "^18.2",
|
32
32
|
"viem": "^2.28",
|
33
33
|
"wagmi": "^2.15",
|
34
|
-
"zod": "^3.24.
|
35
|
-
"@gelatonetwork/smartwallet
|
36
|
-
"@gelatonetwork/smartwallet": "0.0.2-alpha.
|
34
|
+
"zod": "^3.24.4",
|
35
|
+
"@gelatonetwork/smartwallet": "0.0.2-alpha.6",
|
36
|
+
"@gelatonetwork/smartwallet-react-types": "0.0.2-alpha.6"
|
37
37
|
},
|
38
38
|
"devDependencies": {
|
39
39
|
"@types/react": "^18",
|
package/src/provider.tsx
CHANGED
@@ -3,6 +3,7 @@ import {
|
|
3
3
|
createGelatoSmartWalletClient
|
4
4
|
} from "@gelatonetwork/smartwallet";
|
5
5
|
import type { wallet } from "@gelatonetwork/smartwallet-react-types";
|
6
|
+
import type { Wallet } from "@gelatonetwork/smartwallet/constants";
|
6
7
|
import { PrivyProvider, usePrivy, useSignAuthorization, useWallets } from "@privy-io/react-auth";
|
7
8
|
import { WagmiProvider, createConfig } from "@privy-io/wagmi";
|
8
9
|
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
|
@@ -41,9 +42,10 @@ type GelatoSmartWalletPrivyContextProps = wallet.ProviderProps;
|
|
41
42
|
|
42
43
|
const GelatoSmartWalletPrivyInternal: FC<{
|
43
44
|
children: ReactNode;
|
44
|
-
wagmi: { config
|
45
|
-
apiKey?: string
|
46
|
-
|
45
|
+
wagmi: { config?: WagmiConfig };
|
46
|
+
apiKey?: string;
|
47
|
+
wallet?: Wallet;
|
48
|
+
}> = ({ children, wagmi, apiKey, wallet }) => {
|
47
49
|
const { ready, authenticated, logout } = usePrivy();
|
48
50
|
const { wallets, ready: walletsReady } = useWallets();
|
49
51
|
const { signAuthorization } = useSignAuthorization();
|
@@ -63,15 +65,15 @@ const GelatoSmartWalletPrivyInternal: FC<{
|
|
63
65
|
await logout();
|
64
66
|
};
|
65
67
|
|
66
|
-
const switchNetwork = async (
|
68
|
+
const switchNetwork = async (chainId: number) => {
|
67
69
|
if (!smartWalletClient) {
|
68
70
|
return;
|
69
71
|
}
|
70
72
|
|
71
73
|
const primaryWallet = wallets[0];
|
72
74
|
|
73
|
-
await primaryWallet.switchChain(
|
74
|
-
smartWalletClient.switchChain({ id:
|
75
|
+
await primaryWallet.switchChain(chainId);
|
76
|
+
smartWalletClient.switchChain({ id: chainId });
|
75
77
|
};
|
76
78
|
|
77
79
|
useEffect(() => {
|
@@ -123,7 +125,7 @@ const GelatoSmartWalletPrivyInternal: FC<{
|
|
123
125
|
|
124
126
|
const walletClientGelato = createGelatoSmartWalletClient<Transport, Chain, Account>(
|
125
127
|
client,
|
126
|
-
apiKey
|
128
|
+
{ apiKey, wallet }
|
127
129
|
);
|
128
130
|
setSmartWalletClient(walletClientGelato);
|
129
131
|
} catch (error) {
|
@@ -132,7 +134,7 @@ const GelatoSmartWalletPrivyInternal: FC<{
|
|
132
134
|
};
|
133
135
|
|
134
136
|
fetchWalletClient();
|
135
|
-
}, [ready, wallets, walletsReady, authenticated, signAuthorization, apiKey]);
|
137
|
+
}, [ready, wallets, walletsReady, authenticated, signAuthorization, apiKey, wallet]);
|
136
138
|
|
137
139
|
return (
|
138
140
|
<GelatoSmartWalletPrivyProviderContext.Provider
|
@@ -163,10 +165,14 @@ export const GelatoSmartWalletPrivyContextProvider: FC<GelatoSmartWalletPrivyCon
|
|
163
165
|
<PrivyProvider
|
164
166
|
appId={settings.waas.appId}
|
165
167
|
config={{
|
166
|
-
defaultChain: settings.defaultChain ?? chains.sepolia
|
168
|
+
defaultChain: settings.defaultChain ?? settings.wagmi?.config?.chains?.[0] ?? chains.sepolia
|
167
169
|
}}
|
168
170
|
>
|
169
|
-
<GelatoSmartWalletPrivyInternal
|
171
|
+
<GelatoSmartWalletPrivyInternal
|
172
|
+
wagmi={{ config: wagmiConfig }}
|
173
|
+
apiKey={settings.apiKey}
|
174
|
+
wallet={settings.wallet}
|
175
|
+
>
|
170
176
|
{wagmiConfig ? (
|
171
177
|
<QueryClientProvider client={queryClient}>
|
172
178
|
<WagmiProvider config={wagmiConfig}>{children}</WagmiProvider>
|