@frak-labs/react-sdk 0.1.0 → 0.1.1-beta.4dfea079

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.
Files changed (38) hide show
  1. package/README.md +25 -0
  2. package/dist/index.cjs +1 -1
  3. package/dist/index.d.cts +332 -345
  4. package/dist/index.d.ts +332 -345
  5. package/dist/index.js +1 -1
  6. package/package.json +30 -15
  7. package/src/hook/helper/useReferralInteraction.test.ts +358 -0
  8. package/src/hook/helper/useReferralInteraction.ts +78 -0
  9. package/src/hook/index.ts +10 -0
  10. package/src/hook/useDisplayModal.test.ts +275 -0
  11. package/src/hook/useDisplayModal.ts +68 -0
  12. package/src/hook/useFrakClient.test.ts +119 -0
  13. package/src/hook/useFrakClient.ts +11 -0
  14. package/src/hook/useFrakConfig.test.ts +184 -0
  15. package/src/hook/useFrakConfig.ts +22 -0
  16. package/src/hook/useGetMerchantInformation.ts +52 -0
  17. package/src/hook/useOpenSso.test.ts +202 -0
  18. package/src/hook/useOpenSso.ts +51 -0
  19. package/src/hook/usePrepareSso.test.ts +197 -0
  20. package/src/hook/usePrepareSso.ts +55 -0
  21. package/src/hook/useSendTransaction.test.ts +218 -0
  22. package/src/hook/useSendTransaction.ts +62 -0
  23. package/src/hook/useSiweAuthenticate.test.ts +258 -0
  24. package/src/hook/useSiweAuthenticate.ts +66 -0
  25. package/src/hook/useWalletStatus.test.ts +112 -0
  26. package/src/hook/useWalletStatus.ts +55 -0
  27. package/src/hook/utils/useFrakContext.test.ts +157 -0
  28. package/src/hook/utils/useFrakContext.ts +42 -0
  29. package/src/hook/utils/useMounted.test.ts +70 -0
  30. package/src/hook/utils/useMounted.ts +12 -0
  31. package/src/hook/utils/useWindowLocation.test.ts +54 -0
  32. package/src/hook/utils/useWindowLocation.ts +40 -0
  33. package/src/index.ts +25 -0
  34. package/src/provider/FrakConfigProvider.test.ts +246 -0
  35. package/src/provider/FrakConfigProvider.ts +54 -0
  36. package/src/provider/FrakIFrameClientProvider.test.tsx +209 -0
  37. package/src/provider/FrakIFrameClientProvider.ts +86 -0
  38. package/src/provider/index.ts +7 -0
package/dist/index.d.cts CHANGED
@@ -1,345 +1,332 @@
1
- import { Context } from 'react';
2
- import { CSSProperties } from 'react';
3
- import type { DisplayEmbeddedWalletParamsType } from '@frak-labs/core-sdk';
4
- import type { DisplayModalParamsType } from '@frak-labs/core-sdk';
5
- import { FragmentProps } from 'react';
6
- import { FrakClient } from '@frak-labs/core-sdk';
7
- import { FrakRpcError } from '@frak-labs/frame-connector';
8
- import { FrakWalletSdkConfig } from '@frak-labs/core-sdk';
9
- import { FunctionComponentElement } from 'react';
10
- import type { GetProductInformationReturnType } from '@frak-labs/core-sdk';
11
- import { Hex } from 'viem';
12
- import type { ModalRpcStepsResultType } from '@frak-labs/core-sdk';
13
- import type { ModalStepTypes } from '@frak-labs/core-sdk';
14
- import type { OpenSsoParamsType } from '@frak-labs/core-sdk';
15
- import type { OpenSsoReturnType } from '@frak-labs/core-sdk';
16
- import { ProcessReferralOptions } from '@frak-labs/core-sdk/actions';
17
- import { PropsWithChildren } from 'react';
18
- import { ProviderProps } from 'react';
19
- import { ReactNode } from 'react';
20
- import type { SendInteractionParamsType } from '@frak-labs/core-sdk';
21
- import type { SendInteractionReturnType } from '@frak-labs/core-sdk';
22
- import { SendTransactionParams } from '@frak-labs/core-sdk/actions';
23
- import type { SendTransactionReturnType } from '@frak-labs/core-sdk';
24
- import { SiweAuthenticateModalParams } from '@frak-labs/core-sdk/actions';
25
- import type { SiweAuthenticateReturnType } from '@frak-labs/core-sdk';
26
- import { UseMutationOptions } from '@tanstack/react-query';
27
- import { UseMutationResult } from '@tanstack/react-query';
28
- import { UseQueryOptions } from '@tanstack/react-query';
29
- import { UseQueryResult } from '@tanstack/react-query';
30
- import type { WalletStatusReturnType } from '@frak-labs/core-sdk';
31
-
32
- /**
33
- * The context that will keep the Frak Wallet SDK configuration
34
- * @ignore
35
- */
36
- export declare const FrakConfigContext: Context<FrakWalletSdkConfig | undefined>;
37
-
38
- /**
39
- * Simple config provider for the Frak Wallet SDK
40
- *
41
- * Should be wrapped within a {@link @tanstack/react-query!QueryClientProvider | `QueryClientProvider`}
42
- *
43
- * @group provider
44
- *
45
- * @param parameters
46
- */
47
- export declare function FrakConfigProvider(parameters: PropsWithChildren<FrakConfigProviderProps>): FunctionComponentElement<ProviderProps<FrakWalletSdkConfig | undefined>>;
48
-
49
- /**
50
- * Props to instantiate the Frak Wallet SDK configuration provider
51
- *
52
- * @group provider
53
- */
54
- export declare type FrakConfigProviderProps = {
55
- /**
56
- * The wanted Frak configuration
57
- * @see {@link @frak-labs/core-sdk!index.FrakWalletSdkConfig | FrakWalletSdkConfig}
58
- */
59
- config: FrakWalletSdkConfig;
60
- };
61
-
62
- /**
63
- * The context that will keep the Frak Wallet SDK client
64
- * @ignore
65
- */
66
- export declare const FrakIFrameClientContext: Context<FrakClient | undefined>;
67
-
68
- /**
69
- * Props to instantiate the Frak Wallet SDK configuration provider
70
- *
71
- * @group provider
72
- */
73
- export declare type FrakIFrameClientProps = {
74
- config: FrakWalletSdkConfig;
75
- };
76
-
77
- /**
78
- * IFrame client provider for the Frak Wallet SDK
79
- * It will automatically create the frak wallet iFrame (required for the wallet to communicate with the SDK securely), and provide it in the context
80
- *
81
- * @group provider
82
- *
83
- * @remarks
84
- * This provider must be wrapped within a {@link FrakConfigProvider} to work properly
85
- *
86
- * @param args
87
- * @param args.style - Some custom styles to apply to the iFrame
88
- * @param args.children - Descedant components that will have access to the Frak Client
89
- */
90
- export declare function FrakIFrameClientProvider({ style, children, }: {
91
- style?: CSSProperties;
92
- children?: ReactNode;
93
- }): FunctionComponentElement<FragmentProps>;
94
-
95
- /** @ignore */
96
- declare type MutationOptions = Omit<UseMutationOptions<SendTransactionReturnType, FrakRpcError, SendTransactionParams>, "mutationFn" | "mutationKey">;
97
-
98
- /** @ignore */
99
- declare type MutationOptions_2 = Omit<UseMutationOptions<SendInteractionReturnType, FrakRpcError, SendInteractionParamsType>, "mutationFn" | "mutationKey">;
100
-
101
- /** @inline */
102
- declare type MutationOptions_3 = Omit<UseMutationOptions<SiweAuthenticateReturnType, FrakRpcError, SiweAuthenticateModalParams>, "mutationFn" | "mutationKey">;
103
-
104
- /** @ignore */
105
- declare type MutationOptions_4<T extends ModalStepTypes[]> = Omit<UseMutationOptions<ModalRpcStepsResultType<T>, FrakRpcError, DisplayModalParamsType<T>>, "mutationFn" | "mutationKey">;
106
-
107
- /** @ignore */
108
- declare type MutationOptions_5 = Omit<UseMutationOptions<OpenSsoReturnType, FrakRpcError, OpenSsoParamsType>, "mutationFn" | "mutationKey">;
109
-
110
- /** @ignore */
111
- declare type QueryOptions = Omit<UseQueryOptions<GetProductInformationReturnType, FrakRpcError, undefined>, "queryKey" | "queryFn">;
112
-
113
- /**
114
- * Hook that return a mutation helping to display a modal to the user
115
- *
116
- * It's a {@link @tanstack/react-query!home | `tanstack`} wrapper around the {@link @frak-labs/core-sdk!actions.displayModal | `displayModal()`} action
117
- *
118
- * @param args
119
- *
120
- * @typeParam T
121
- * The modal steps types to display (the result will correspond to the steps types asked in params)
122
- * An array of {@link @frak-labs/core-sdk!index.ModalStepTypes | `ModalStepTypes`}
123
- * If not provided, it will default to a generic array of `ModalStepTypes`
124
- *
125
- * @group hooks
126
- *
127
- * @returns
128
- * The mutation hook wrapping the `displayModal()` action
129
- * The `mutate` and `mutateAsync` argument is of type {@link @frak-labs/core-sdk!index.DisplayModalParamsType | `DisplayModalParamsType<T>`}, with type params `T` being the modal steps types to display
130
- * The `data` result is a {@link @frak-labs/core-sdk!index.ModalRpcStepsResultType | `ModalRpcStepsResultType`}
131
- *
132
- * @see {@link @frak-labs/core-sdk!actions.displayModal | `displayModal()`} for more info about the underlying action
133
- * @see {@link @tanstack/react-query!useMutation | `useMutation()`} for more info about the mutation options and response
134
- */
135
- export declare function useDisplayModal<T extends ModalStepTypes[] = ModalStepTypes[]>({ mutations, }?: UseDisplayModalParams<T>): UseMutationResult< { [K in T[number]["key"]]: Extract<T[number], {
136
- key: K;
137
- }>["returns"]; }, FrakRpcError<undefined>, DisplayModalParamsType<T>, unknown>;
138
-
139
- /** @inline */
140
- declare interface UseDisplayModalParams<T extends ModalStepTypes[] = ModalStepTypes[]> {
141
- /**
142
- * Optional mutation options, see {@link @tanstack/react-query!useMutation | `useMutation()`} for more infos
143
- */
144
- mutations?: MutationOptions_4<T>;
145
- }
146
-
147
- /**
148
- * Get the current Frak client
149
- *
150
- * @group hooks
151
- */
152
- export declare function useFrakClient(): FrakClient | undefined;
153
-
154
- /**
155
- * Get the current Frak config
156
- * @throws {FrakRpcError} if the config is not found (only if this hooks is used outside a FrakConfigProvider)
157
- * @group hooks
158
- *
159
- * @see {@link @frak-labs/react-sdk!FrakConfigProvider | FrakConfigProvider} for the config provider
160
- * @see {@link @frak-labs/core-sdk!index.FrakWalletSdkConfig | FrakWalletSdkConfig} for the config type
161
- */
162
- export declare function useFrakConfig(): FrakWalletSdkConfig;
163
-
164
- /**
165
- * Hook that return a query helping to get the current product information
166
- *
167
- * It's a {@link @tanstack/react-query!home | `tanstack`} wrapper around the {@link @frak-labs/core-sdk!actions.getProductInformation | `getProductInformation()`} action
168
- *
169
- * @param args
170
- *
171
- * @group hooks
172
- *
173
- * @returns
174
- * The query hook wrapping the `getProductInformation()` action
175
- * The `data` result is a {@link @frak-labs/core-sdk!index.GetProductInformationReturnType | `GetProductInformationReturnType`}
176
- *
177
- * @see {@link @frak-labs/core-sdk!actions.getProductInformation | `getProductInformation()`} for more info about the underlying action
178
- * @see {@link @tanstack/react-query!useQuery | `useQuery()`} for more info about the useQuery options and response
179
- */
180
- export declare function useGetProductInformation({ query, }?: UseGetProductInformationParams): UseQueryResult<undefined, FrakRpcError<undefined>>;
181
-
182
- /** @inline */
183
- declare interface UseGetProductInformationParams {
184
- /**
185
- * Optional query options, see {@link @tanstack/react-query!useQuery | `useQuery()`} for more infos
186
- */
187
- query?: QueryOptions;
188
- }
189
-
190
- /**
191
- * Hook that return a mutation helping to open the SSO page
192
- *
193
- * It's a {@link @tanstack/react-query!home | `tanstack`} wrapper around the {@link @frak-labs/core-sdk!actions.openSso | `openSso()`} action
194
- *
195
- * @param args
196
- *
197
- * @group hooks
198
- *
199
- * @returns
200
- * The mutation hook wrapping the `openSso()` action
201
- * The `mutate` and `mutateAsync` argument is of type {@link @frak-labs/core-sdk!index.OpenSsoParamsType | `OpenSsoParamsType`}
202
- * The mutation doesn't output any value
203
- *
204
- * @see {@link @frak-labs/core-sdk!actions.openSso | `openSso()`} for more info about the underlying action
205
- * @see {@link @tanstack/react-query!useMutation | `useMutation()`} for more info about the mutation options and response
206
- */
207
- export declare function useOpenSso({ mutations }?: UseOpenSsoParams): UseMutationResult< {
208
- wallet?: Hex;
209
- }, FrakRpcError<undefined>, OpenSsoParamsType, unknown>;
210
-
211
- /** @inline */
212
- declare interface UseOpenSsoParams {
213
- /**
214
- * Optional mutation options, see {@link @tanstack/react-query!useMutation | `useMutation()`} for more infos
215
- */
216
- mutations?: MutationOptions_5;
217
- }
218
-
219
- /**
220
- * Helper hook to automatically submit a referral interaction when detected
221
- *
222
- * @group hooks
223
- *
224
- * @param args
225
- * @param args.productId - The product id to interact with (if not specified will be recomputed from the current domain)
226
- * @param args.modalConfig - The modal configuration to display if the user is not logged in
227
- * @param args.options - Some options for the referral interaction
228
- *
229
- * @returns The resulting referral state, or a potential error
230
- *
231
- * @description This function will automatically handle the referral interaction process
232
- *
233
- * @see {@link @frak-labs/core-sdk!actions.processReferral | `processReferral()`} for more details on the automatic referral handling process
234
- */
235
- export declare function useReferralInteraction({ productId, modalConfig, options, }?: {
236
- productId?: Hex;
237
- modalConfig?: DisplayEmbeddedWalletParamsType;
238
- options?: ProcessReferralOptions;
239
- }): Error | ("error" | "no-referrer" | "idle" | "processing" | "success" | "no-wallet" | "no-session" | "self-referral");
240
-
241
- /**
242
- * Hook that return a mutation helping to send a user interaction
243
- *
244
- * It's a {@link @tanstack/react-query!home | `tanstack`} wrapper around the {@link @frak-labs/core-sdk!actions.sendInteraction | `sendInteraction()`} action
245
- *
246
- * @param args
247
- *
248
- * @group hooks
249
- *
250
- * @returns
251
- * The mutation hook wrapping the `sendInteraction()` action
252
- * The `mutate` and `mutateAsync` argument is of type {@link @frak-labs/core-sdk!index.SendInteractionParamsType | `SendInteractionParamsType`}
253
- * The `data` result is a {@link @frak-labs/core-sdk!index.SendInteractionReturnType | `SendInteractionReturnType`}
254
- *
255
- * @see {@link @frak-labs/core-sdk!actions.sendInteraction | `sendInteraction()`} for more info about the underlying action
256
- * @see {@link @tanstack/react-query!useMutation | `useMutation()`} for more info about the mutation options and response
257
- */
258
- export declare function useSendInteraction({ mutations, }?: UseSendInteractionParams): UseMutationResult< {
259
- delegationId: string;
260
- }, FrakRpcError<undefined>, SendInteractionParamsType, unknown>;
261
-
262
- /** @inline */
263
- declare interface UseSendInteractionParams {
264
- /**
265
- * Optional mutation options, see {@link @tanstack/react-query!useMutation | `useMutation()`} for more infos
266
- */
267
- mutations?: MutationOptions_2;
268
- }
269
-
270
- /**
271
- * Hook that return a mutation helping to send a transaction
272
- *
273
- * It's a {@link @tanstack/react-query!home | `tanstack`} wrapper around the {@link @frak-labs/core-sdk!actions.sendTransaction | `sendTransaction()`} action
274
- *
275
- * @param args
276
- *
277
- * @group hooks
278
- *
279
- * @returns
280
- * The mutation hook wrapping the `sendTransaction()` action
281
- * The `mutate` and `mutateAsync` argument is of type {@link @frak-labs/core-sdk!actions.SendTransactionParams | `SendTransactionParams`}
282
- * The `data` result is a {@link @frak-labs/core-sdk!index.SendTransactionReturnType | `SendTransactionReturnType`}
283
- *
284
- * @see {@link @frak-labs/core-sdk!actions.sendTransaction | `sendTransaction()`} for more info about the underlying action
285
- * @see {@link @tanstack/react-query!useMutation | `useMutation()`} for more info about the mutation options and response
286
- */
287
- export declare function useSendTransactionAction({ mutations, }?: UseSendTransactionParams): UseMutationResult< {
288
- hash: Hex;
289
- }, FrakRpcError<undefined>, SendTransactionParams, unknown>;
290
-
291
- /** @inline */
292
- declare interface UseSendTransactionParams {
293
- /**
294
- * Optional mutation options, see {@link @tanstack/react-query!useMutation | `useMutation()`} for more infos
295
- */
296
- mutations?: MutationOptions;
297
- }
298
-
299
- /**
300
- * Hook that return a mutation helping to send perform a SIWE authentication
301
- *
302
- * It's a {@link @tanstack/react-query!home | `tanstack`} wrapper around the {@link @frak-labs/core-sdk!actions.sendTransaction | `sendTransaction()`} action
303
- *
304
- * @param args
305
- *
306
- * @group hooks
307
- *
308
- * @returns
309
- * The mutation hook wrapping the `siweAuthenticate()` action
310
- * The `mutate` and `mutateAsync` argument is of type {@link @frak-labs/core-sdk!actions.SiweAuthenticateModalParams | `SiweAuthenticateModalParams`}
311
- * The `data` result is a {@link @frak-labs/core-sdk!index.SiweAuthenticateReturnType | `SiweAuthenticateReturnType`}
312
- *
313
- * @see {@link @frak-labs/core-sdk!actions.siweAuthenticate | `siweAuthenticate()`} for more info about the underlying action
314
- * @see {@link @tanstack/react-query!useMutation | `useMutation()`} for more info about the mutation options and response
315
- */
316
- export declare function useSiweAuthenticate({ mutations, }?: UseSiweAuthenticateParams): UseMutationResult< {
317
- signature: Hex;
318
- message: string;
319
- }, FrakRpcError<undefined>, SiweAuthenticateModalParams, unknown>;
320
-
321
- /** @ignore */
322
- declare interface UseSiweAuthenticateParams {
323
- /**
324
- * Optional mutation options, see {@link @tanstack/react-query!useMutation | `useMutation()`} for more infos
325
- */
326
- mutations?: MutationOptions_3;
327
- }
328
-
329
- /**
330
- * Hook that return a query helping to get the current wallet status.
331
- *
332
- * It's a {@link @tanstack/react-query!home | `tanstack`} wrapper around the {@link @frak-labs/core-sdk!actions.watchWalletStatus | `watchWalletStatus()`} action
333
- *
334
- * @group hooks
335
- *
336
- * @returns
337
- * The query hook wrapping the `watchWalletStatus()` action
338
- * The `data` result is a {@link @frak-labs/core-sdk!index.WalletStatusReturnType | `WalletStatusReturnType`}
339
- *
340
- * @see {@link @frak-labs/core-sdk!actions.watchWalletStatus | `watchWalletStatus()`} for more info about the underlying action
341
- * @see {@link @tanstack/react-query!useQuery | `useQuery()`} for more info about the useQuery response
342
- */
343
- export declare function useWalletStatus(): UseQueryResult<WalletStatusReturnType, Error>;
344
-
345
- export { }
1
+ import * as _frak_labs_core_sdk0 from "@frak-labs/core-sdk";
2
+ import { DisplayEmbeddedWalletParamsType, DisplayModalParamsType, FrakClient, FrakWalletSdkConfig, GetMerchantInformationReturnType, ModalRpcStepsResultType, ModalStepTypes, OpenSsoParamsType, OpenSsoReturnType, PrepareSsoParamsType, SendTransactionReturnType, SiweAuthenticateReturnType, WalletStatusReturnType } from "@frak-labs/core-sdk";
3
+ import { ProcessReferralOptions, SendTransactionParams, SiweAuthenticateModalParams } from "@frak-labs/core-sdk/actions";
4
+ import * as _tanstack_react_query0 from "@tanstack/react-query";
5
+ import { UseMutationOptions, UseQueryOptions } from "@tanstack/react-query";
6
+ import { FrakRpcError } from "@frak-labs/frame-connector";
7
+ import * as react from "react";
8
+ import { CSSProperties, PropsWithChildren, ReactNode } from "react";
9
+
10
+ //#region src/hook/helper/useReferralInteraction.d.ts
11
+ /**
12
+ * Helper hook to automatically submit a referral interaction when detected
13
+ *
14
+ * @group hooks
15
+ *
16
+ * @param args
17
+ * @param args.modalConfig - The modal configuration to display if the user is not logged in
18
+ * @param args.options - Some options for the referral interaction
19
+ *
20
+ * @returns The resulting referral state, or a potential error
21
+ *
22
+ * @description This function will automatically handle the referral interaction process
23
+ *
24
+ * @see {@link @frak-labs/core-sdk!actions.processReferral | `processReferral()`} for more details on the automatic referral handling process
25
+ */
26
+ declare function useReferralInteraction({
27
+ modalConfig,
28
+ options
29
+ }?: {
30
+ modalConfig?: DisplayEmbeddedWalletParamsType;
31
+ options?: ProcessReferralOptions;
32
+ }): Error | ("error" | "processing" | "no-referrer" | "idle" | "success" | "no-wallet" | "self-referral");
33
+ //#endregion
34
+ //#region src/hook/useDisplayModal.d.ts
35
+ /** @ignore */
36
+ type MutationOptions$3<T extends ModalStepTypes[]> = Omit<UseMutationOptions<ModalRpcStepsResultType<T>, FrakRpcError, DisplayModalParamsType<T>>, "mutationFn" | "mutationKey">;
37
+ /** @inline */
38
+ interface UseDisplayModalParams<T extends ModalStepTypes[] = ModalStepTypes[]> {
39
+ /**
40
+ * Optional mutation options, see {@link @tanstack/react-query!useMutation | `useMutation()`} for more infos
41
+ */
42
+ mutations?: MutationOptions$3<T>;
43
+ }
44
+ /**
45
+ * Hook that return a mutation helping to display a modal to the user
46
+ *
47
+ * It's a {@link @tanstack/react-query!home | `tanstack`} wrapper around the {@link @frak-labs/core-sdk!actions.displayModal | `displayModal()`} action
48
+ *
49
+ * @param args
50
+ *
51
+ * @typeParam T
52
+ * The modal steps types to display (the result will correspond to the steps types asked in params)
53
+ * An array of {@link @frak-labs/core-sdk!index.ModalStepTypes | `ModalStepTypes`}
54
+ * If not provided, it will default to a generic array of `ModalStepTypes`
55
+ *
56
+ * @group hooks
57
+ *
58
+ * @returns
59
+ * The mutation hook wrapping the `displayModal()` action
60
+ * The `mutate` and `mutateAsync` argument is of type {@link @frak-labs/core-sdk!index.DisplayModalParamsType | `DisplayModalParamsType<T>`}, with type params `T` being the modal steps types to display
61
+ * The `data` result is a {@link @frak-labs/core-sdk!index.ModalRpcStepsResultType | `ModalRpcStepsResultType`}
62
+ *
63
+ * @see {@link @frak-labs/core-sdk!actions.displayModal | `displayModal()`} for more info about the underlying action
64
+ * @see {@link @tanstack/react-query!useMutation | `useMutation()`} for more info about the mutation options and response
65
+ */
66
+ declare function useDisplayModal<T extends ModalStepTypes[] = ModalStepTypes[]>({
67
+ mutations
68
+ }?: UseDisplayModalParams<T>): _tanstack_react_query0.UseMutationResult<ModalRpcStepsResultType<T>, FrakRpcError<undefined>, DisplayModalParamsType<T>, unknown>;
69
+ //#endregion
70
+ //#region src/hook/useFrakClient.d.ts
71
+ /**
72
+ * Get the current Frak client
73
+ *
74
+ * @group hooks
75
+ */
76
+ declare function useFrakClient(): _frak_labs_core_sdk0.FrakClient | undefined;
77
+ //#endregion
78
+ //#region src/hook/useFrakConfig.d.ts
79
+ /**
80
+ * Get the current Frak config
81
+ * @throws {FrakRpcError} if the config is not found (only if this hooks is used outside a FrakConfigProvider)
82
+ * @group hooks
83
+ *
84
+ * @see {@link @frak-labs/react-sdk!FrakConfigProvider | FrakConfigProvider} for the config provider
85
+ * @see {@link @frak-labs/core-sdk!index.FrakWalletSdkConfig | FrakWalletSdkConfig} for the config type
86
+ */
87
+ declare function useFrakConfig(): _frak_labs_core_sdk0.FrakWalletSdkConfig;
88
+ //#endregion
89
+ //#region src/hook/useGetMerchantInformation.d.ts
90
+ /** @ignore */
91
+ type QueryOptions = Omit<UseQueryOptions<GetMerchantInformationReturnType, FrakRpcError, undefined>, "queryKey" | "queryFn">;
92
+ /** @inline */
93
+ interface UseGetMerchantInformationParams {
94
+ /**
95
+ * Optional query options, see {@link @tanstack/react-query!useQuery | `useQuery()`} for more infos
96
+ */
97
+ query?: QueryOptions;
98
+ }
99
+ /**
100
+ * Hook that return a query helping to get the current merchant information
101
+ *
102
+ * It's a {@link @tanstack/react-query!home | `tanstack`} wrapper around the {@link @frak-labs/core-sdk!actions.getMerchantInformation | `getMerchantInformation()`} action
103
+ *
104
+ * @param args
105
+ *
106
+ * @group hooks
107
+ *
108
+ * @returns
109
+ * The query hook wrapping the `getMerchantInformation()` action
110
+ * The `data` result is a {@link @frak-labs/core-sdk!index.GetMerchantInformationReturnType | `GetMerchantInformationReturnType`}
111
+ *
112
+ * @see {@link @frak-labs/core-sdk!actions.getMerchantInformation | `getMerchantInformation()`} for more info about the underlying action
113
+ * @see {@link @tanstack/react-query!useQuery | `useQuery()`} for more info about the useQuery options and response
114
+ */
115
+ declare function useGetMerchantInformation({
116
+ query
117
+ }?: UseGetMerchantInformationParams): _tanstack_react_query0.UseQueryResult<undefined, FrakRpcError<undefined>>;
118
+ //#endregion
119
+ //#region src/hook/useOpenSso.d.ts
120
+ /** @ignore */
121
+ type MutationOptions$2 = Omit<UseMutationOptions<OpenSsoReturnType, FrakRpcError, OpenSsoParamsType>, "mutationFn" | "mutationKey">;
122
+ /** @inline */
123
+ interface UseOpenSsoParams {
124
+ /**
125
+ * Optional mutation options, see {@link @tanstack/react-query!useMutation | `useMutation()`} for more infos
126
+ */
127
+ mutations?: MutationOptions$2;
128
+ }
129
+ /**
130
+ * Hook that return a mutation helping to open the SSO page
131
+ *
132
+ * It's a {@link @tanstack/react-query!home | `tanstack`} wrapper around the {@link @frak-labs/core-sdk!actions.openSso | `openSso()`} action
133
+ *
134
+ * @param args
135
+ *
136
+ * @group hooks
137
+ *
138
+ * @returns
139
+ * The mutation hook wrapping the `openSso()` action
140
+ * The `mutate` and `mutateAsync` argument is of type {@link @frak-labs/core-sdk!index.OpenSsoParamsType | `OpenSsoParamsType`}
141
+ * The mutation doesn't output any value
142
+ *
143
+ * @see {@link @frak-labs/core-sdk!actions.openSso | `openSso()`} for more info about the underlying action
144
+ * @see {@link @tanstack/react-query!useMutation | `useMutation()`} for more info about the mutation options and response
145
+ */
146
+ declare function useOpenSso({
147
+ mutations
148
+ }?: UseOpenSsoParams): _tanstack_react_query0.UseMutationResult<OpenSsoReturnType, FrakRpcError<undefined>, OpenSsoParamsType, unknown>;
149
+ //#endregion
150
+ //#region src/hook/usePrepareSso.d.ts
151
+ /**
152
+ * Hook that generates SSO URL for popup flow
153
+ *
154
+ * This is a **synchronous** hook (no async calls) that generates the SSO URL
155
+ * client-side without communicating with the wallet iframe.
156
+ *
157
+ * @param params - SSO parameters for URL generation
158
+ *
159
+ * @group hooks
160
+ *
161
+ * @returns
162
+ * Object containing:
163
+ * - `ssoUrl`: Generated SSO URL (or undefined if client not ready)
164
+ * - `isReady`: Boolean indicating if URL is available
165
+ *
166
+ * @example
167
+ * ```tsx
168
+ * function MyComponent() {
169
+ * const { data } = usePrepareSso({
170
+ * metadata: { logoUrl: "..." },
171
+ * directExit: true
172
+ * });
173
+ *
174
+ * const handleClick = () => {
175
+ * if (ssoUrl) {
176
+ * window.open(data?.ssoUrl, "_blank");
177
+ * }
178
+ * };
179
+ *
180
+ * return <button onClick={handleClick} disabled={!isReady}>Login</button>;
181
+ * }
182
+ * ```
183
+ *
184
+ * @see {@link @frak-labs/core-sdk!actions.prepareSso | `prepareSso()`} for the underlying action
185
+ * @see {@link @frak-labs/core-sdk!actions.openSso | `openSso()`} for the recommended high-level API
186
+ */
187
+ declare function usePrepareSso(params: PrepareSsoParamsType): _tanstack_react_query0.UseQueryResult<_frak_labs_core_sdk0.PrepareSsoReturnType, Error>;
188
+ //#endregion
189
+ //#region src/hook/useSendTransaction.d.ts
190
+ /** @ignore */
191
+ type MutationOptions$1 = Omit<UseMutationOptions<SendTransactionReturnType, FrakRpcError, SendTransactionParams>, "mutationFn" | "mutationKey">;
192
+ /** @inline */
193
+ interface UseSendTransactionParams {
194
+ /**
195
+ * Optional mutation options, see {@link @tanstack/react-query!useMutation | `useMutation()`} for more infos
196
+ */
197
+ mutations?: MutationOptions$1;
198
+ }
199
+ /**
200
+ * Hook that return a mutation helping to send a transaction
201
+ *
202
+ * It's a {@link @tanstack/react-query!home | `tanstack`} wrapper around the {@link @frak-labs/core-sdk!actions.sendTransaction | `sendTransaction()`} action
203
+ *
204
+ * @param args
205
+ *
206
+ * @group hooks
207
+ *
208
+ * @returns
209
+ * The mutation hook wrapping the `sendTransaction()` action
210
+ * The `mutate` and `mutateAsync` argument is of type {@link @frak-labs/core-sdk!actions.SendTransactionParams | `SendTransactionParams`}
211
+ * The `data` result is a {@link @frak-labs/core-sdk!index.SendTransactionReturnType | `SendTransactionReturnType`}
212
+ *
213
+ * @see {@link @frak-labs/core-sdk!actions.sendTransaction | `sendTransaction()`} for more info about the underlying action
214
+ * @see {@link @tanstack/react-query!useMutation | `useMutation()`} for more info about the mutation options and response
215
+ */
216
+ declare function useSendTransactionAction({
217
+ mutations
218
+ }?: UseSendTransactionParams): _tanstack_react_query0.UseMutationResult<SendTransactionReturnType, FrakRpcError<undefined>, SendTransactionParams, unknown>;
219
+ //#endregion
220
+ //#region src/hook/useSiweAuthenticate.d.ts
221
+ /** @inline */
222
+ type MutationOptions = Omit<UseMutationOptions<SiweAuthenticateReturnType, FrakRpcError, SiweAuthenticateModalParams>, "mutationFn" | "mutationKey">;
223
+ /** @ignore */
224
+ interface UseSiweAuthenticateParams {
225
+ /**
226
+ * Optional mutation options, see {@link @tanstack/react-query!useMutation | `useMutation()`} for more infos
227
+ */
228
+ mutations?: MutationOptions;
229
+ }
230
+ /**
231
+ * Hook that return a mutation helping to send perform a SIWE authentication
232
+ *
233
+ * It's a {@link @tanstack/react-query!home | `tanstack`} wrapper around the {@link @frak-labs/core-sdk!actions.sendTransaction | `sendTransaction()`} action
234
+ *
235
+ * @param args
236
+ *
237
+ * @group hooks
238
+ *
239
+ * @returns
240
+ * The mutation hook wrapping the `siweAuthenticate()` action
241
+ * The `mutate` and `mutateAsync` argument is of type {@link @frak-labs/core-sdk!actions.SiweAuthenticateModalParams | `SiweAuthenticateModalParams`}
242
+ * The `data` result is a {@link @frak-labs/core-sdk!index.SiweAuthenticateReturnType | `SiweAuthenticateReturnType`}
243
+ *
244
+ * @see {@link @frak-labs/core-sdk!actions.siweAuthenticate | `siweAuthenticate()`} for more info about the underlying action
245
+ * @see {@link @tanstack/react-query!useMutation | `useMutation()`} for more info about the mutation options and response
246
+ */
247
+ declare function useSiweAuthenticate({
248
+ mutations
249
+ }?: UseSiweAuthenticateParams): _tanstack_react_query0.UseMutationResult<SiweAuthenticateReturnType, FrakRpcError<undefined>, SiweAuthenticateModalParams, unknown>;
250
+ //#endregion
251
+ //#region src/hook/useWalletStatus.d.ts
252
+ /**
253
+ * Hook that return a query helping to get the current wallet status.
254
+ *
255
+ * It's a {@link @tanstack/react-query!home | `tanstack`} wrapper around the {@link @frak-labs/core-sdk!actions.watchWalletStatus | `watchWalletStatus()`} action
256
+ *
257
+ * @group hooks
258
+ *
259
+ * @returns
260
+ * The query hook wrapping the `watchWalletStatus()` action
261
+ * The `data` result is a {@link @frak-labs/core-sdk!index.WalletStatusReturnType | `WalletStatusReturnType`}
262
+ *
263
+ * @see {@link @frak-labs/core-sdk!actions.watchWalletStatus | `watchWalletStatus()`} for more info about the underlying action
264
+ * @see {@link @tanstack/react-query!useQuery | `useQuery()`} for more info about the useQuery response
265
+ */
266
+ declare function useWalletStatus(): _tanstack_react_query0.UseQueryResult<WalletStatusReturnType, Error>;
267
+ //#endregion
268
+ //#region src/provider/FrakConfigProvider.d.ts
269
+ /**
270
+ * The context that will keep the Frak Wallet SDK configuration
271
+ * @ignore
272
+ */
273
+ declare const FrakConfigContext: react.Context<FrakWalletSdkConfig | undefined>;
274
+ /**
275
+ * Props to instantiate the Frak Wallet SDK configuration provider
276
+ *
277
+ * @group provider
278
+ */
279
+ type FrakConfigProviderProps = {
280
+ /**
281
+ * The wanted Frak configuration
282
+ * @see {@link @frak-labs/core-sdk!index.FrakWalletSdkConfig | FrakWalletSdkConfig}
283
+ */
284
+ config: FrakWalletSdkConfig;
285
+ };
286
+ /**
287
+ * Simple config provider for the Frak Wallet SDK
288
+ *
289
+ * Should be wrapped within a {@link @tanstack/react-query!QueryClientProvider | `QueryClientProvider`}
290
+ *
291
+ * @group provider
292
+ *
293
+ * @param parameters
294
+ */
295
+ declare function FrakConfigProvider(parameters: PropsWithChildren<FrakConfigProviderProps>): react.FunctionComponentElement<react.ProviderProps<FrakWalletSdkConfig | undefined>>;
296
+ //#endregion
297
+ //#region src/provider/FrakIFrameClientProvider.d.ts
298
+ /**
299
+ * The context that will keep the Frak Wallet SDK client
300
+ * @ignore
301
+ */
302
+ declare const FrakIFrameClientContext: react.Context<FrakClient | undefined>;
303
+ /**
304
+ * Props to instantiate the Frak Wallet SDK configuration provider
305
+ *
306
+ * @group provider
307
+ */
308
+ type FrakIFrameClientProps = {
309
+ config: FrakWalletSdkConfig;
310
+ };
311
+ /**
312
+ * IFrame client provider for the Frak Wallet SDK
313
+ * It will automatically create the frak wallet iFrame (required for the wallet to communicate with the SDK securely), and provide it in the context
314
+ *
315
+ * @group provider
316
+ *
317
+ * @remarks
318
+ * This provider must be wrapped within a {@link FrakConfigProvider} to work properly
319
+ *
320
+ * @param args
321
+ * @param args.style - Some custom styles to apply to the iFrame
322
+ * @param args.children - Descedant components that will have access to the Frak Client
323
+ */
324
+ declare function FrakIFrameClientProvider({
325
+ style,
326
+ children
327
+ }: {
328
+ style?: CSSProperties;
329
+ children?: ReactNode;
330
+ }): react.FunctionComponentElement<react.FragmentProps>;
331
+ //#endregion
332
+ export { FrakConfigContext, FrakConfigProvider, type FrakConfigProviderProps, FrakIFrameClientContext, type FrakIFrameClientProps, FrakIFrameClientProvider, useDisplayModal, useFrakClient, useFrakConfig, useGetMerchantInformation, useOpenSso, usePrepareSso, useReferralInteraction, useSendTransactionAction, useSiweAuthenticate, useWalletStatus };