@zerodev/wallet-react 0.0.1-alpha.7 → 0.0.1-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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zerodev/wallet-react",
3
- "version": "0.0.1-alpha.7",
3
+ "version": "0.0.1-alpha.8",
4
4
  "description": "React hooks for ZeroDev Wallet SDK",
5
5
  "sideEffects": false,
6
6
  "main": "./dist/_cjs/index.js",
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: 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: parameters.organizationId,
356
- projectId: parameters.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 { organizationId, projectId, query } = parameters
21
+ const { query } = parameters
22
22
  const config = useConfig(parameters)
23
23
 
24
24
  return useQuery({
25
25
  ...query,
26
- queryKey: ['getUserEmail', { organizationId, projectId }],
26
+ queryKey: ['getUserEmail'],
27
27
  queryFn: async () => {
28
- return getUserEmail(config, { organizationId, projectId })
28
+ return getUserEmail(config)
29
29
  },
30
- enabled: Boolean(organizationId && projectId),
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<