@zerodev/wallet-react 0.0.1-alpha.7 → 0.0.1-alpha.9
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 +13 -0
- package/README.md +14 -4
- package/dist/_cjs/actions.js +12 -4
- package/dist/_cjs/hooks/useGetUserEmail.js +4 -4
- package/dist/_esm/actions.js +12 -4
- package/dist/_esm/hooks/useGetUserEmail.js +4 -4
- package/dist/_types/actions.d.ts +1 -7
- package/dist/_types/actions.d.ts.map +1 -1
- package/dist/_types/hooks/useGetUserEmail.d.ts +0 -2
- package/dist/_types/hooks/useGetUserEmail.d.ts.map +1 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +2 -2
- package/src/actions.ts +14 -13
- package/src/hooks/useGetUserEmail.ts +4 -6
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zerodev/wallet-react",
|
|
3
|
-
"version": "0.0.1-alpha.
|
|
3
|
+
"version": "0.0.1-alpha.9",
|
|
4
4
|
"description": "React hooks for ZeroDev Wallet SDK",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"main": "./dist/_cjs/index.js",
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
"wagmi": "^3.0.0",
|
|
31
31
|
"zustand": "^5.0.3",
|
|
32
32
|
"ox": "^0.3.0",
|
|
33
|
-
"@zerodev/wallet-core": "0.0.1-alpha.
|
|
33
|
+
"@zerodev/wallet-core": "0.0.1-alpha.8"
|
|
34
34
|
},
|
|
35
35
|
"devDependencies": {
|
|
36
36
|
"@types/react": "^19",
|
package/src/actions.ts
CHANGED
|
@@ -334,15 +334,8 @@ export declare namespace refreshSession {
|
|
|
334
334
|
/**
|
|
335
335
|
* Get user email
|
|
336
336
|
*/
|
|
337
|
-
export async function getUserEmail(
|
|
338
|
-
config
|
|
339
|
-
parameters: {
|
|
340
|
-
organizationId: string
|
|
341
|
-
projectId: string
|
|
342
|
-
connector?: Connector
|
|
343
|
-
},
|
|
344
|
-
): Promise<{ email: string }> {
|
|
345
|
-
const connector = parameters.connector ?? getZeroDevConnector(config)
|
|
337
|
+
export async function getUserEmail(config: Config): Promise<{ email: string }> {
|
|
338
|
+
const connector = getZeroDevConnector(config)
|
|
346
339
|
|
|
347
340
|
// @ts-expect-error - getStore is a custom method
|
|
348
341
|
const store = await connector.getStore()
|
|
@@ -350,17 +343,25 @@ export async function getUserEmail(
|
|
|
350
343
|
|
|
351
344
|
if (!wallet) throw new Error('Wallet not initialized')
|
|
352
345
|
|
|
346
|
+
const oauthConfig = store.getState().oauthConfig
|
|
347
|
+
if (!oauthConfig) {
|
|
348
|
+
throw new Error('Wallet not initialized. Please wait for connector setup.')
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
const session = store.getState().session
|
|
352
|
+
if (!session) {
|
|
353
|
+
throw new Error('No active session')
|
|
354
|
+
}
|
|
355
|
+
|
|
353
356
|
// Call the core SDK method
|
|
354
357
|
return await wallet.client.getUserEmail({
|
|
355
|
-
organizationId:
|
|
356
|
-
projectId:
|
|
358
|
+
organizationId: session.organizationId,
|
|
359
|
+
projectId: oauthConfig.projectId,
|
|
357
360
|
})
|
|
358
361
|
}
|
|
359
362
|
|
|
360
363
|
export declare namespace getUserEmail {
|
|
361
364
|
type Parameters = {
|
|
362
|
-
organizationId: string
|
|
363
|
-
projectId: string
|
|
364
365
|
connector?: Connector
|
|
365
366
|
}
|
|
366
367
|
type ReturnType = { email: string }
|
|
@@ -18,23 +18,21 @@ type ConfigParameter<config extends Config = Config> = {
|
|
|
18
18
|
export function useGetUserEmail<
|
|
19
19
|
config extends Config = ResolvedRegister['config'],
|
|
20
20
|
>(parameters: useGetUserEmail.Parameters<config>): useGetUserEmail.ReturnType {
|
|
21
|
-
const {
|
|
21
|
+
const { query } = parameters
|
|
22
22
|
const config = useConfig(parameters)
|
|
23
23
|
|
|
24
24
|
return useQuery({
|
|
25
25
|
...query,
|
|
26
|
-
queryKey: ['getUserEmail'
|
|
26
|
+
queryKey: ['getUserEmail'],
|
|
27
27
|
queryFn: async () => {
|
|
28
|
-
return getUserEmail(config
|
|
28
|
+
return getUserEmail(config)
|
|
29
29
|
},
|
|
30
|
-
enabled: Boolean(
|
|
30
|
+
enabled: Boolean(config),
|
|
31
31
|
})
|
|
32
32
|
}
|
|
33
33
|
|
|
34
34
|
export declare namespace useGetUserEmail {
|
|
35
35
|
type Parameters<config extends Config = Config> = ConfigParameter<config> & {
|
|
36
|
-
organizationId: string
|
|
37
|
-
projectId: string
|
|
38
36
|
query?:
|
|
39
37
|
| Omit<
|
|
40
38
|
UseQueryOptions<
|