@gelatonetwork/smartwallet-react-privy 0.0.6 → 0.0.7
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 +11 -0
- package/_dist/provider.d.ts.map +1 -1
- package/_dist/provider.js +4 -4
- package/_dist/provider.js.map +1 -1
- package/_dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +5 -5
- package/src/provider.tsx +13 -10
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@gelatonetwork/smartwallet-react-privy",
|
3
|
-
"version": "0.0.
|
3
|
+
"version": "0.0.7",
|
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.29",
|
13
13
|
"wagmi": "~2.15",
|
14
|
-
"@gelatonetwork/smartwallet": "0.0.
|
15
|
-
"@gelatonetwork/smartwallet-react-types": "0.0.
|
14
|
+
"@gelatonetwork/smartwallet": "0.0.7",
|
15
|
+
"@gelatonetwork/smartwallet-react-types": "0.0.7"
|
16
16
|
},
|
17
17
|
"peerDependenciesMeta": {
|
18
18
|
"typescript": {
|
@@ -32,8 +32,8 @@
|
|
32
32
|
"viem": "~2.29",
|
33
33
|
"wagmi": "~2.15",
|
34
34
|
"zod": "3.24.4",
|
35
|
-
"@gelatonetwork/smartwallet": "0.0.
|
36
|
-
"@gelatonetwork/smartwallet-react-types": "0.0.
|
35
|
+
"@gelatonetwork/smartwallet": "0.0.7",
|
36
|
+
"@gelatonetwork/smartwallet-react-types": "0.0.7"
|
37
37
|
},
|
38
38
|
"devDependencies": {
|
39
39
|
"@types/react": "^18.3",
|
package/src/provider.tsx
CHANGED
@@ -3,13 +3,16 @@ import {
|
|
3
3
|
createGelatoSmartWalletClient
|
4
4
|
} from "@gelatonetwork/smartwallet";
|
5
5
|
import type { wallet } from "@gelatonetwork/smartwallet-react-types";
|
6
|
-
import type {
|
6
|
+
import type {
|
7
|
+
GelatoSmartAccount,
|
8
|
+
GelatoSmartAccountSCW
|
9
|
+
} from "@gelatonetwork/smartwallet/accounts";
|
7
10
|
import { PrivyProvider, usePrivy, useSignAuthorization, useWallets } from "@privy-io/react-auth";
|
8
11
|
import { WagmiProvider, createConfig } from "@privy-io/wagmi";
|
9
12
|
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
|
10
13
|
import { ChainId } from "caip";
|
11
|
-
import { createContext, useContext, useEffect, useState } from "react";
|
12
14
|
import type { FC, ReactNode } from "react";
|
15
|
+
import { createContext, useContext, useEffect, useState } from "react";
|
13
16
|
import {
|
14
17
|
type Account,
|
15
18
|
type Chain,
|
@@ -42,10 +45,10 @@ type GelatoSmartWalletPrivyContextProps = wallet.ProviderProps;
|
|
42
45
|
|
43
46
|
const GelatoSmartWalletPrivyInternal: FC<{
|
44
47
|
children: ReactNode;
|
48
|
+
scw: GelatoSmartAccountSCW;
|
45
49
|
wagmi: { config?: WagmiConfig };
|
46
50
|
apiKey?: string;
|
47
|
-
|
48
|
-
}> = ({ children, wagmi, apiKey, wallet }) => {
|
51
|
+
}> = ({ children, wagmi, apiKey, scw }) => {
|
49
52
|
const { ready, authenticated, logout } = usePrivy();
|
50
53
|
const { wallets, ready: walletsReady } = useWallets();
|
51
54
|
const { signAuthorization } = useSignAuthorization();
|
@@ -53,7 +56,7 @@ const GelatoSmartWalletPrivyInternal: FC<{
|
|
53
56
|
const [smartWalletClient, setSmartWalletClient] = useState<GelatoSmartWalletClient<
|
54
57
|
Transport,
|
55
58
|
Chain,
|
56
|
-
|
59
|
+
GelatoSmartAccount
|
57
60
|
> | null>(null);
|
58
61
|
|
59
62
|
const logoutWrapper = async () => {
|
@@ -123,9 +126,9 @@ const GelatoSmartWalletPrivyInternal: FC<{
|
|
123
126
|
return signedAuthorization;
|
124
127
|
};
|
125
128
|
|
126
|
-
const walletClientGelato = createGelatoSmartWalletClient<Transport, Chain, Account>(
|
129
|
+
const walletClientGelato = await createGelatoSmartWalletClient<Transport, Chain, Account>(
|
127
130
|
client,
|
128
|
-
{ apiKey,
|
131
|
+
{ apiKey, scw }
|
129
132
|
);
|
130
133
|
setSmartWalletClient(walletClientGelato);
|
131
134
|
} catch (error) {
|
@@ -134,13 +137,13 @@ const GelatoSmartWalletPrivyInternal: FC<{
|
|
134
137
|
};
|
135
138
|
|
136
139
|
fetchWalletClient();
|
137
|
-
}, [ready, wallets, walletsReady, authenticated, signAuthorization, apiKey,
|
140
|
+
}, [ready, wallets, walletsReady, authenticated, signAuthorization, apiKey, scw]);
|
138
141
|
|
139
142
|
return (
|
140
143
|
<GelatoSmartWalletPrivyProviderContext.Provider
|
141
144
|
value={{
|
142
145
|
gelato: {
|
143
|
-
client: smartWalletClient as GelatoSmartWalletClient<Transport, Chain,
|
146
|
+
client: smartWalletClient as GelatoSmartWalletClient<Transport, Chain, GelatoSmartAccount>
|
144
147
|
},
|
145
148
|
wagmi: {
|
146
149
|
config: wagmi.config
|
@@ -171,7 +174,7 @@ export const GelatoSmartWalletPrivyContextProvider: FC<GelatoSmartWalletPrivyCon
|
|
171
174
|
<GelatoSmartWalletPrivyInternal
|
172
175
|
wagmi={{ config: wagmiConfig }}
|
173
176
|
apiKey={settings.apiKey}
|
174
|
-
|
177
|
+
scw={settings.scw}
|
175
178
|
>
|
176
179
|
{wagmiConfig ? (
|
177
180
|
<QueryClientProvider client={queryClient}>
|