@frak-labs/core-sdk 0.0.15 → 0.0.17

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.
@@ -0,0 +1,2022 @@
1
+ import { Address } from 'viem';
2
+ import { Hex } from 'viem';
3
+ import type { OpenPanel } from '@openpanel/web';
4
+ import type { Prettify } from 'viem/chains';
5
+ import type { RpcSchema } from 'viem';
6
+ import type { SiweMessage } from 'viem/siwe';
7
+
8
+ /**
9
+ * Decode a base64url encoded string
10
+ * @param value The value to decode
11
+ * @returns The decoded value
12
+ */
13
+ export declare function base64urlDecode(value: string): Uint8Array;
14
+
15
+ /**
16
+ * Encode a buffer to a base64url encoded string
17
+ * @param buffer The buffer to encode
18
+ * @returns The encoded string
19
+ */
20
+ export declare function base64urlEncode(buffer: Uint8Array): string;
21
+
22
+ /**
23
+ * Base props for the iframe
24
+ * @ignore
25
+ */
26
+ export declare const baseIframeProps: {
27
+ id: string;
28
+ name: string;
29
+ title: string;
30
+ allow: string;
31
+ style: {
32
+ width: string;
33
+ height: string;
34
+ border: string;
35
+ position: string;
36
+ zIndex: number;
37
+ top: string;
38
+ left: string;
39
+ colorScheme: string;
40
+ };
41
+ };
42
+
43
+ /**
44
+ * Event related to the iframe lifecycle
45
+ * @ignore
46
+ */
47
+ export declare type ClientLifecycleEvent = CustomCssEvent | CustomI18nEvent | RestoreBackupEvent | HearbeatEvent | HandshakeResponse;
48
+
49
+ /** @ignore */
50
+ export declare class ClientNotFound extends FrakRpcError {
51
+ constructor();
52
+ }
53
+
54
+ /**
55
+ * Compress the current Frak context
56
+ * @param context - The context to be compressed
57
+ * @returns A compressed string containing the Frak context
58
+ */
59
+ declare function compress(context?: Partial<FrakContext>): string | undefined;
60
+
61
+ /**
62
+ * The received encoded data from a client
63
+ * -> The encoded should contain a HashProtectedData once decoded
64
+ * @ignore
65
+ */
66
+ export declare type CompressedData = Uint8Array;
67
+
68
+ /**
69
+ * Compress json data
70
+ * @param data
71
+ * @ignore
72
+ */
73
+ export declare function compressJson(data: unknown): Uint8Array;
74
+
75
+ /**
76
+ * Compress json data
77
+ * @param data
78
+ * @ignore
79
+ */
80
+ export declare function compressJsonToB64(data: unknown): string;
81
+
82
+ /**
83
+ * Create the Frak iframe
84
+ * @param args
85
+ * @param args.walletBaseUrl - Use `config.walletUrl` instead. Will be removed in future versions.
86
+ * @param args.config - The configuration object containing iframe options, including the replacement for `walletBaseUrl`.
87
+ */
88
+ export declare function createIframe({ walletBaseUrl, config, }: {
89
+ walletBaseUrl?: string;
90
+ config?: FrakWalletSdkConfig;
91
+ }): Promise<HTMLIFrameElement | undefined>;
92
+
93
+ /**
94
+ * Create a new iframe Frak client
95
+ * @param args
96
+ * @param args.config - The configuration to use for the Frak Wallet SDK
97
+ * @param args.iframe - The iframe to use for the communication
98
+ * @returns The created Frak Client
99
+ *
100
+ * @example
101
+ * const frakConfig: FrakWalletSdkConfig = {
102
+ * metadata: {
103
+ * name: "My app title",
104
+ * },
105
+ * }
106
+ * const iframe = await createIframe({ config: frakConfig });
107
+ * const client = createIFrameFrakClient({ config: frakConfig, iframe });
108
+ */
109
+ export declare function createIFrameFrakClient({ config, iframe, }: {
110
+ config: FrakWalletSdkConfig;
111
+ iframe: HTMLIFrameElement;
112
+ }): FrakClient;
113
+
114
+ /**
115
+ * All the currencies available
116
+ * @category Config
117
+ */
118
+ export declare type Currency = "eur" | "usd" | "gbp";
119
+
120
+ declare type CustomCssEvent = {
121
+ clientLifecycle: "modal-css";
122
+ data: {
123
+ cssLink: string;
124
+ };
125
+ };
126
+
127
+ declare type CustomI18nEvent = {
128
+ clientLifecycle: "modal-i18n";
129
+ data: {
130
+ i18n: I18nConfig;
131
+ };
132
+ };
133
+
134
+ /** @ignore */
135
+ export declare class DebugInfoGatherer {
136
+ private config?;
137
+ private iframe?;
138
+ private isSetupDone;
139
+ private lastResponse;
140
+ private lastRequest;
141
+ constructor(config?: FrakWalletSdkConfig, iframe?: HTMLIFrameElement);
142
+ setLastResponse(event: MessageEvent<IFrameEvent>): void;
143
+ setLastRequest(event: IFrameEvent, target: string): void;
144
+ updateSetupStatus(status: boolean): void;
145
+ private base64Encode;
146
+ /**
147
+ * Extract information from the iframe status
148
+ */
149
+ private getIframeStatus;
150
+ private getNavigatorInfo;
151
+ private gatherDebugInfo;
152
+ static empty(): DebugInfoGatherer;
153
+ /**
154
+ * Format Frak debug information
155
+ */
156
+ formatDebugInfo(error: Error | unknown | string): string;
157
+ }
158
+
159
+ /**
160
+ * Decompress the given Frak context
161
+ * @param context - The raw context to be decompressed into a `FrakContext`
162
+ * @returns The decompressed Frak context, or undefined if it fails
163
+ */
164
+ declare function decompress(context?: string): FrakContext | undefined;
165
+
166
+ /**
167
+ * Decompress the given string
168
+ * @param compressedData The params to encode
169
+ * @ignore
170
+ */
171
+ export declare function decompressDataAndCheckHash<T>(compressedData: CompressedData): HashProtectedData<T>;
172
+
173
+ /**
174
+ * Decompress json data
175
+ * @param data
176
+ * @ignore
177
+ */
178
+ export declare function decompressJson<T>(data: Uint8Array): T | null;
179
+
180
+ /**
181
+ * Decompress json data
182
+ * @param data
183
+ * @ignore
184
+ */
185
+ export declare function decompressJsonFromB64<T>(data: string): T | null;
186
+
187
+ /**
188
+ * Simple deferred promise wrapper
189
+ * @ignore
190
+ */
191
+ export declare class Deferred<T> {
192
+ private readonly _promise;
193
+ private _resolve;
194
+ private _reject;
195
+ constructor();
196
+ get promise(): Promise<T>;
197
+ resolve: (value: T | PromiseLike<T>) => void;
198
+ reject: (reason?: unknown) => void;
199
+ }
200
+
201
+ /**
202
+ * Function used to display the Frak embedded wallet popup
203
+ * @param client - The current Frak Client
204
+ * @param params - The parameter used to customise the embedded wallet
205
+ */
206
+ export declare function displayEmbeddedWallet(client: FrakClient, params: DisplayEmbeddedWalletParamsType): Promise<DisplayEmbeddedWalletResultType>;
207
+
208
+ /**
209
+ * The params used to display the embedded wallet
210
+ *
211
+ * @group Embedded wallet
212
+ */
213
+ export declare type DisplayEmbeddedWalletParamsType = {
214
+ /**
215
+ * The embedded view to display once the user is logged in
216
+ */
217
+ loggedIn?: LoggedInEmbeddedView;
218
+ /**
219
+ * The embedded view to display once the user is logged out
220
+ */
221
+ loggedOut?: LoggedOutEmbeddedView;
222
+ /**
223
+ * Some metadata to customize the embedded view
224
+ */
225
+ metadata?: {
226
+ /**
227
+ * The logo to display on the embedded wallet
228
+ * If undefined, will default to no logo displayed
229
+ */
230
+ logo?: string;
231
+ /**
232
+ * Link to the homepage of the calling website
233
+ * If undefined, will default to the domain of the calling website
234
+ */
235
+ homepageLink?: string;
236
+ /**
237
+ * The target interaction behind this modal
238
+ */
239
+ targetInteraction?: FullInteractionTypesKey;
240
+ /**
241
+ * The position of the component
242
+ */
243
+ position?: "left" | "right";
244
+ /**
245
+ * Some i18n override for the displayed modal (i.e. update the displayed text only for this modal)
246
+ */
247
+ i18n?: I18nConfig;
248
+ };
249
+ };
250
+
251
+ /**
252
+ * The result of the display embedded wallet rpc request
253
+ *
254
+ * @group Embedded wallet
255
+ */
256
+ export declare type DisplayEmbeddedWalletResultType = {
257
+ wallet: Address;
258
+ };
259
+
260
+ /**
261
+ * Function used to display a modal
262
+ * @param client - The current Frak Client
263
+ * @param args
264
+ * @param args.steps - The different steps of the modal
265
+ * @param args.metadata - The metadata for the modal (customization, etc)
266
+ * @returns The result of each modal steps
267
+ *
268
+ * @description This function will display a modal to the user with the provided steps and metadata.
269
+ *
270
+ * @remarks
271
+ * - The UI of the displayed modal can be configured with the `customCss` property in the `customizations.css` field of the top-level config.
272
+ * - The `login` and `openSession` steps will be automatically skipped if the user is already logged in or has an active session. It's safe to include these steps in all cases to ensure proper user state.
273
+ * - Steps are automatically reordered in the following sequence:
274
+ * 1. `login` (if needed)
275
+ * 2. `openSession` (if needed)
276
+ * 3. All other steps in the order specified
277
+ * 4. `success` (if included, always last)
278
+ *
279
+ * @example
280
+ * Simple sharing modal with steps:
281
+ * 1. Login (Skipped if already logged in)
282
+ * 2. Open a session (Skipped if already opened)
283
+ * 3. Display a success message with sharing link option
284
+ *
285
+ * ```ts
286
+ * const results = await displayModal(frakConfig, {
287
+ * steps: {
288
+ * // Simple login with no SSO, nor customization
289
+ * login: { allowSso: false },
290
+ * // Simple session opening, with no customization
291
+ * openSession: {},
292
+ * // Success message
293
+ * final: {
294
+ * action: { key: "reward" },
295
+ * // Skip this step, it will be only displayed in the stepper within the modal
296
+ * autoSkip: true,
297
+ * },
298
+ * },
299
+ * });
300
+ *
301
+ * console.log("Login step - wallet", results.login.wallet);
302
+ * console.log("Open session step - start + end", {
303
+ * start: results.openSession.startTimestamp,
304
+ * end: results.openSession.endTimestamp,
305
+ * });
306
+ * ```
307
+ *
308
+ * @example
309
+ * A full modal example, with a few customization options, with the steps:
310
+ * 1. Login (Skipped if already logged in)
311
+ * 2. Open a session (Skipped if already opened)
312
+ * 3. Authenticate via SIWE
313
+ * 4. Send a transaction
314
+ * 5. Display a success message with sharing link options
315
+ *
316
+ * ```ts
317
+ * const results = await displayModal(frakConfig, {
318
+ * steps: {
319
+ * // Login step
320
+ * login: {
321
+ * allowSso: true,
322
+ * ssoMetadata: {
323
+ * logoUrl: "https://my-app.com/logo.png",
324
+ * homepageLink: "https://my-app.com",
325
+ * },
326
+ * },
327
+ * // Simple session opening, with no customisation
328
+ * openSession: {},
329
+ * // Siwe authentication
330
+ * siweAuthenticate: {
331
+ * siwe: {
332
+ * domain: "my-app.com",
333
+ * uri: "https://my-app.com/",
334
+ * nonce: generateSiweNonce(),
335
+ * version: "1",
336
+ * },
337
+ * },
338
+ * // Send batched transaction
339
+ * sendTransaction: {
340
+ * tx: [
341
+ * { to: "0xdeadbeef", data: "0xdeadbeef" },
342
+ * { to: "0xdeadbeef", data: "0xdeadbeef" },
343
+ * ],
344
+ * },
345
+ * // Success message with sharing options
346
+ * final: {
347
+ * action: {
348
+ * key: "sharing",
349
+ * options: {
350
+ * popupTitle: "Share the app",
351
+ * text: "Discover my super app website",
352
+ * link: "https://my-app.com",
353
+ * },
354
+ * },
355
+ * dismissedMetadata: {
356
+ * title: "Dismiss",
357
+ * description: "You won't be rewarded for this sharing action",
358
+ * },
359
+ * },
360
+ * },
361
+ * metadata: {
362
+ * // Header of desktop modals
363
+ * header: {
364
+ * title: "My-App",
365
+ * icon: "https://my-app.com/logo.png",
366
+ * },
367
+ * // Context that will be present in every modal steps
368
+ * context: "My-app overkill flow",
369
+ * },
370
+ * });
371
+ * ```
372
+ */
373
+ export declare function displayModal<T extends ModalStepTypes[] = ModalStepTypes[]>(client: FrakClient, { steps, metadata }: DisplayModalParamsType<T>): Promise<ModalRpcStepsResultType<T>>;
374
+
375
+ /**
376
+ * Params used to display a modal
377
+ * @typeParam T - The list of modal steps we expect to have in the modal
378
+ * @group Modal Display
379
+ */
380
+ export declare type DisplayModalParamsType<T extends ModalStepTypes[]> = {
381
+ steps: ModalRpcStepsInput<T>;
382
+ metadata?: ModalRpcMetadata;
383
+ };
384
+
385
+ declare type DoBackupEvent = {
386
+ iframeLifecycle: "do-backup";
387
+ data: {
388
+ backup?: string;
389
+ };
390
+ };
391
+
392
+ /**
393
+ * The action to display on the logged out embedded view when the user is referred
394
+ *
395
+ * @group Embedded wallet
396
+ */
397
+ export declare type EmbeddedViewActionReferred = {
398
+ key: "referred";
399
+ /**
400
+ * No options for a referred action
401
+ */
402
+ options?: never;
403
+ };
404
+
405
+ /**
406
+ * The different type of action we can have on the embedded view (once the user is logged in)
407
+ *
408
+ * @group Embedded wallet
409
+ */
410
+ export declare type EmbeddedViewActionSharing = {
411
+ key: "sharing";
412
+ /**
413
+ * Some sharing options
414
+ */
415
+ options?: {
416
+ /**
417
+ * The title that will be displayed on the system popup once the system sharing window is open
418
+ * @deprecated Use the top level `config.metadata.i18n` instead
419
+ */
420
+ popupTitle?: string;
421
+ /**
422
+ * The text that will be shared alongside the link.
423
+ * Can contain the variable {LINK} to specify where the link is placed, otherwise it will be added at the end
424
+ * @deprecated Use the top level `config.metadata.i18n` instead
425
+ */
426
+ text?: string;
427
+ /**
428
+ * The link to be shared (will be suffixed with the Frak sharing context)
429
+ */
430
+ link?: string;
431
+ };
432
+ };
433
+
434
+ declare type EventProps = Record<string, unknown>;
435
+
436
+ /**
437
+ * Type that extract the possible return type from a RPC Schema
438
+ * @ignore
439
+ */
440
+ declare type ExtractedMethodFromRpc<TRpcSchema extends RpcSchema, TMethod extends ExtractedParametersFromRpc<TRpcSchema>["method"] = ExtractedParametersFromRpc<TRpcSchema>["method"]> = Extract<TRpcSchema[number], {
441
+ Method: TMethod;
442
+ }>;
443
+
444
+ /**
445
+ * Type that extract the possible parameters from a RPC Schema
446
+ * @ignore
447
+ */
448
+ export declare type ExtractedParametersFromRpc<TRpcSchema extends RpcSchema> = {
449
+ [K in keyof TRpcSchema]: Prettify<{
450
+ method: TRpcSchema[K] extends TRpcSchema[number] ? TRpcSchema[K]["Method"] : string;
451
+ } & (TRpcSchema[K] extends TRpcSchema[number] ? TRpcSchema[K]["Parameters"] extends undefined ? {
452
+ params?: never;
453
+ } : {
454
+ params: TRpcSchema[K]["Parameters"];
455
+ } : never)>;
456
+ }[number];
457
+
458
+ /**
459
+ * Type that extract the possible return type from a RPC Schema
460
+ * @ignore
461
+ */
462
+ export declare type ExtractedReturnTypeFromRpc<TRpcSchema extends RpcSchema, TParameters extends ExtractedParametersFromRpc<TRpcSchema> = ExtractedParametersFromRpc<TRpcSchema>> = ExtractedMethodFromRpc<TRpcSchema, TParameters["method"]>["ReturnType"];
463
+
464
+ /**
465
+ * The different types of final actions we can display in the final step
466
+ * @group Modal Display
467
+ */
468
+ export declare type FinalActionType = {
469
+ key: "sharing";
470
+ options?: {
471
+ /**
472
+ * @deprecated Use the top level `config.metadata.i18n` instead
473
+ */
474
+ popupTitle?: string;
475
+ /**
476
+ * @deprecated Use the top level `config.metadata.i18n` instead
477
+ */
478
+ text?: string;
479
+ link?: string;
480
+ };
481
+ } | {
482
+ key: "reward";
483
+ options?: never;
484
+ };
485
+
486
+ /**
487
+ * The final modal step type, could be used to display sharing options or a success reward screen.
488
+ *
489
+ * **Input**: What type final step to display?
490
+ * **Output**: None
491
+ *
492
+ * @group Modal Display
493
+ */
494
+ export declare type FinalModalStepType = GenericModalStepType<"final", {
495
+ dismissedMetadata?: ModalStepMetadata["metadata"];
496
+ action: FinalActionType;
497
+ autoSkip?: boolean;
498
+ }, object>;
499
+
500
+ export declare function formatAmount(amount: number, currency?: Currency): string;
501
+
502
+ /**
503
+ * Representing a Frak client, used to interact with the Frak Wallet
504
+ */
505
+ export declare type FrakClient = {
506
+ config: FrakWalletSdkConfig;
507
+ debugInfo: {
508
+ formatDebugInfo: (error: Error | unknown | string) => string;
509
+ };
510
+ openPanel?: OpenPanel;
511
+ } & IFrameTransport;
512
+
513
+ /**
514
+ * The current Frak Context
515
+ *
516
+ * For now, only contain a referrer address.
517
+ *
518
+ * @ignore
519
+ */
520
+ export declare type FrakContext = {
521
+ r: Address;
522
+ };
523
+
524
+ /**
525
+ * Export our frak context "class"
526
+ */
527
+ export declare const FrakContextManager: {
528
+ compress: typeof compress;
529
+ decompress: typeof decompress;
530
+ parse: typeof parse;
531
+ update: typeof update;
532
+ remove: typeof remove;
533
+ replaceUrl: typeof replaceUrl;
534
+ };
535
+
536
+ declare type FrakEvent = "share_button_clicked" | "wallet_button_clicked" | "share_modal_error" | "user_referred";
537
+
538
+ /**
539
+ * Generic Frak RPC error
540
+ * @ignore
541
+ */
542
+ export declare class FrakRpcError<T = undefined> extends Error {
543
+ code: number;
544
+ data?: T | undefined;
545
+ constructor(code: number, message: string, data?: T | undefined);
546
+ }
547
+
548
+ /**
549
+ * Configuration for the Frak Wallet SDK
550
+ * @category Config
551
+ */
552
+ export declare type FrakWalletSdkConfig = {
553
+ /**
554
+ * The Frak wallet url
555
+ * @defaultValue "https://wallet.frak.id"
556
+ */
557
+ walletUrl?: string;
558
+ /**
559
+ * Some metadata about your implementation of the Frak SDK
560
+ */
561
+ metadata: {
562
+ /**
563
+ * Your application name (will be displayed in a few modals and in SSO)
564
+ */
565
+ name: string;
566
+ /**
567
+ * Language to display in the modal
568
+ * If undefined, will default to the browser language
569
+ */
570
+ lang?: Language;
571
+ /**
572
+ * The currency to display in the modal
573
+ * @defaultValue `"eur"`
574
+ */
575
+ currency?: Currency;
576
+ /**
577
+ * The logo URL that will be displayed in a few components
578
+ */
579
+ logoUrl?: string;
580
+ /**
581
+ * The homepage link that could be displayed in a few components
582
+ */
583
+ homepageLink?: string;
584
+ };
585
+ /**
586
+ * Some customization for the modal
587
+ */
588
+ customizations?: {
589
+ /**
590
+ * Custom CSS styles to apply to the modals and components
591
+ */
592
+ css?: `${string}.css`;
593
+ /**
594
+ * Custom i18n configuration for the modal
595
+ */
596
+ i18n?: I18nConfig;
597
+ };
598
+ /**
599
+ * The domain name of your application
600
+ * @defaultValue window.location.host
601
+ */
602
+ domain?: string;
603
+ };
604
+
605
+ /**
606
+ * The keys for each interaction types (e.g. `press.openArticle`) -> category_type.interaction_type
607
+ * @inline
608
+ */
609
+ export declare type FullInteractionTypesKey = {
610
+ [Category in keyof typeof interactionTypes]: `${Category & string}.${keyof (typeof interactionTypes)[Category] & string}`;
611
+ }[keyof typeof interactionTypes];
612
+
613
+ /**
614
+ * Represent a generic modal step type
615
+ * @ignore
616
+ * @inline
617
+ */
618
+ declare type GenericModalStepType<TKey, TParams, TReturns> = {
619
+ key: TKey;
620
+ params: TParams extends never ? ModalStepMetadata : ModalStepMetadata & TParams;
621
+ returns: TReturns;
622
+ };
623
+
624
+ /**
625
+ * Get the currency amount key for a given currency
626
+ * @param currency - The currency to use
627
+ * @returns The currency amount key
628
+ */
629
+ export declare function getCurrencyAmountKey(currency?: Currency): keyof TokenAmountType;
630
+
631
+ /**
632
+ * Function used to get the current product information
633
+ * @param client - The current Frak Client
634
+ * @returns The product information in a promise
635
+ */
636
+ export declare function getProductInformation(client: FrakClient): Promise<GetProductInformationReturnType>;
637
+
638
+ /**
639
+ * Response of the `frak_getProductInformation` RPC method
640
+ * @group RPC Schema
641
+ */
642
+ export declare type GetProductInformationReturnType = {
643
+ /**
644
+ * Current product id
645
+ */
646
+ id: Hex;
647
+ /**
648
+ * Some metadata
649
+ */
650
+ onChainMetadata: {
651
+ /**
652
+ * Name of the product on-chain
653
+ */
654
+ name: string;
655
+ /**
656
+ * Domain of the product on-chain
657
+ */
658
+ domain: string;
659
+ /**
660
+ * The supported product types
661
+ */
662
+ productTypes: ProductTypesKey[];
663
+ };
664
+ /**
665
+ * The max potential reward for the referrer
666
+ */
667
+ maxReferrer?: TokenAmountType;
668
+ /**
669
+ * The max potential reward for the referee
670
+ */
671
+ maxReferee?: TokenAmountType;
672
+ /**
673
+ * List of all the potentials reward arround this product
674
+ */
675
+ rewards: {
676
+ token: Address;
677
+ campaign: Address;
678
+ interactionTypeKey: FullInteractionTypesKey;
679
+ referrer: TokenAmountType;
680
+ referee: TokenAmountType;
681
+ }[];
682
+ };
683
+
684
+ /**
685
+ * Get the supported currency for a given currency
686
+ * @param currency - The currency to use
687
+ * @returns The supported currency
688
+ */
689
+ export declare function getSupportedCurrency(currency?: Currency): Currency;
690
+
691
+ /**
692
+ * Get the supported locale for a given currency
693
+ * @param currency - The currency to use
694
+ * @returns The supported locale
695
+ */
696
+ export declare function getSupportedLocale(currency?: Currency): (typeof locales)[LocalesKey];
697
+
698
+ declare type HandshakeRequestEvent = {
699
+ iframeLifecycle: "handshake";
700
+ data: {
701
+ token: string;
702
+ };
703
+ };
704
+
705
+ declare type HandshakeResponse = {
706
+ clientLifecycle: "handshake-response";
707
+ data: {
708
+ token: string;
709
+ currentUrl: string;
710
+ };
711
+ };
712
+
713
+ /**
714
+ * Compress the given params, and add hash protection to (rapidly) prevent interception modification
715
+ * @param data The params to encode
716
+ * @ignore
717
+ */
718
+ export declare function hashAndCompressData<T>(data: T): CompressedData;
719
+
720
+ /**
721
+ * The encoded data to send to a client / received by a client
722
+ * @ignore
723
+ */
724
+ export declare type HashProtectedData<DataType> = Readonly<DataType & {
725
+ validationHash: string;
726
+ }>;
727
+
728
+ declare type HearbeatEvent = {
729
+ clientLifecycle: "heartbeat";
730
+ };
731
+
732
+ /**
733
+ * Custom i18n configuration for the modal
734
+ * See [i18next json format](https://www.i18next.com/misc/json-format#i18next-json-v4)
735
+ *
736
+ * Available variables
737
+ * - `{{ productName }}` : The name of your website (`metadata.name`)
738
+ * - `{{ productOrigin }}` : The origin url of your website
739
+ * - `{{ estimatedReward }}` : The estimated reward for the user (based on the specific `targetInteraction` you can specify, or the max referrer reward if no target interaction is specified)
740
+ *
741
+ * Context of the translation [see i18n context](https://www.i18next.com/translation-function/context)
742
+ * - For modal display, the key of the final action (`sharing`, `reward`, or undefined)
743
+ * - For embedded wallet display, the key of the logged in action (`sharing` or undefined)
744
+ *
745
+ * @example
746
+ * ```ts
747
+ * // Multi language config
748
+ * const multiI18n = {
749
+ * fr: {
750
+ * "sdk.modal.title": "Titre de modal",
751
+ * "sdk.modal.description": "Description de modal, avec {{ estimatedReward }} de gains possible",
752
+ * },
753
+ * en: "https://example.com/en.json"
754
+ * }
755
+ *
756
+ * // Single language config
757
+ * const singleI18n = {
758
+ * "sdk.modal.title": "Modal title",
759
+ * "sdk.modal.description": "Modal description, with {{ estimatedReward }} of gains possible",
760
+ * }
761
+ * ```
762
+ *
763
+ * @category Config
764
+ */
765
+ export declare type I18nConfig = Record<Language, LocalizedI18nConfig> | LocalizedI18nConfig;
766
+
767
+ /**
768
+ * Represent an iframe event
769
+ */
770
+ export declare type IFrameEvent = IFrameRpcEvent | IFrameLifecycleEvent | ClientLifecycleEvent;
771
+
772
+ /**
773
+ * Event related to the iframe lifecycle
774
+ * @ignore
775
+ */
776
+ export declare type IFrameLifecycleEvent = {
777
+ iframeLifecycle: "connected" | "show" | "hide";
778
+ data?: never;
779
+ } | DoBackupEvent | RemoveBackupEvent | HandshakeRequestEvent | RedirectRequestEvent;
780
+
781
+ /**
782
+ * Represent an iframe rpc event
783
+ */
784
+ export declare type IFrameRpcEvent = {
785
+ id: string;
786
+ topic: ExtractedParametersFromRpc<IFrameRpcSchema>["method"];
787
+ data: CompressedData;
788
+ };
789
+
790
+ /**
791
+ * RPC interface that's used for the iframe communication
792
+ *
793
+ * Define all the methods available within the iFrame RPC client
794
+ *
795
+ * @group RPC Schema
796
+ *
797
+ * @remarks
798
+ * Here is the list of methods available:
799
+ *
800
+ * ### frak_listenToWalletStatus
801
+ * - Params: None
802
+ * - Returns: {@link WalletStatusReturnType}
803
+ *
804
+ * ### frak_displayModal
805
+ * - Params: [{@link ModalRpcStepsInput}, name: string, metadata?: {@link ModalRpcMetadata}]
806
+ * - Returns: {@link ModalRpcStepsResultType}
807
+ *
808
+ * ### frak_sendInteraction
809
+ * - Params: [productId: Hex, interaction: {@link PreparedInteraction}, signature?: Hex]
810
+ * - Returns: {@link SendInteractionReturnType}
811
+ *
812
+ * ### frak_sso
813
+ * - Params [params: {@link OpenSsoParamsType}, name: string, customCss?: string]
814
+ * - Returns: undefined
815
+ *
816
+ * ### frak_getProductInformation
817
+ * - Params: None
818
+ * - Returns: {@link GetProductInformationReturnType}
819
+ *
820
+ * ### frak_displayEmbeddedWallet
821
+ * - Params: [{@link DisplayEmbeddedWalletParamsType}]
822
+ * - Returns: {@link DisplayEmbeddedWalletResultType}
823
+ */
824
+ export declare type IFrameRpcSchema = [
825
+ /**
826
+ * Method used to listen to the wallet status
827
+ */
828
+ {
829
+ Method: "frak_listenToWalletStatus";
830
+ Parameters?: undefined;
831
+ ReturnType: WalletStatusReturnType;
832
+ },
833
+ /**
834
+ * Method to display a modal with the provided steps
835
+ */
836
+ {
837
+ Method: "frak_displayModal";
838
+ Parameters: [
839
+ requests: ModalRpcStepsInput,
840
+ metadata: ModalRpcMetadata | undefined,
841
+ configMetadata: FrakWalletSdkConfig["metadata"]
842
+ ];
843
+ ReturnType: ModalRpcStepsResultType;
844
+ },
845
+ /**
846
+ * Method to transmit a user interaction
847
+ */
848
+ {
849
+ Method: "frak_sendInteraction";
850
+ Parameters: [
851
+ productId: Hex,
852
+ interaction: PreparedInteraction,
853
+ signature?: Hex
854
+ ];
855
+ ReturnType: SendInteractionReturnType;
856
+ },
857
+ /**
858
+ * Method to start a SSO
859
+ * todo: Should also support direct tracking via a consumeKey
860
+ */
861
+ {
862
+ Method: "frak_sso";
863
+ Parameters: [
864
+ params: OpenSsoParamsType,
865
+ name: string,
866
+ customCss?: string
867
+ ];
868
+ ReturnType: undefined;
869
+ },
870
+ /**
871
+ * Method to get current product information's
872
+ * - Is product minted?
873
+ * - Does it have running campaign?
874
+ * - Estimated reward on actions
875
+ */
876
+ {
877
+ Method: "frak_getProductInformation";
878
+ Parameters?: undefined;
879
+ ReturnType: GetProductInformationReturnType;
880
+ },
881
+ /**
882
+ * Method to show the embedded wallet, with potential customization
883
+ */
884
+ {
885
+ Method: "frak_displayEmbeddedWallet";
886
+ Parameters: [
887
+ request: DisplayEmbeddedWalletParamsType,
888
+ metadata: FrakWalletSdkConfig["metadata"]
889
+ ];
890
+ ReturnType: DisplayEmbeddedWalletResultType;
891
+ }
892
+ ];
893
+
894
+ /**
895
+ * IFrame transport interface
896
+ */
897
+ export declare type IFrameTransport = {
898
+ /**
899
+ * Wait for the connection to be established
900
+ */
901
+ waitForConnection: Promise<boolean>;
902
+ /**
903
+ * Wait for the setup to be done
904
+ */
905
+ waitForSetup: Promise<void>;
906
+ /**
907
+ * Function used to perform a single request via the iframe transport
908
+ */
909
+ request: RequestFn<IFrameRpcSchema>;
910
+ /**
911
+ * Function used to listen to a request response via the iframe transport
912
+ */
913
+ listenerRequest: ListenerRequestFn<IFrameRpcSchema>;
914
+ /**
915
+ * Function used to destroy the iframe transport
916
+ */
917
+ destroy: () => Promise<void>;
918
+ };
919
+
920
+ /**
921
+ * Each interactions types according to the product types
922
+ */
923
+ export declare const interactionTypes: {
924
+ readonly press: {
925
+ readonly openArticle: "0xc0a24ffb";
926
+ readonly readArticle: "0xd5bd0fbe";
927
+ };
928
+ readonly dapp: {
929
+ readonly proofVerifiableStorageUpdate: "0x2ab2aeef";
930
+ readonly callableVerifiableStorageUpdate: "0xa07da986";
931
+ };
932
+ readonly webshop: {
933
+ readonly open: "0xb311798f";
934
+ };
935
+ readonly referral: {
936
+ readonly referred: "0x010cc3b9";
937
+ readonly createLink: "0xb2c0f17c";
938
+ };
939
+ readonly purchase: {
940
+ readonly started: "0xd87e90c3";
941
+ readonly completed: "0x8403aeb4";
942
+ readonly unsafeCompleted: "0x4d5b14e0";
943
+ };
944
+ readonly retail: {
945
+ readonly customerMeeting: "0x74489004";
946
+ };
947
+ };
948
+
949
+ /**
950
+ * The final keys for each interaction types (e.g. `openArticle`) -> interaction type
951
+ * @inline
952
+ */
953
+ export declare type InteractionTypesKey = {
954
+ [K in keyof typeof interactionTypes]: keyof (typeof interactionTypes)[K];
955
+ }[keyof typeof interactionTypes];
956
+
957
+ /**
958
+ * Represent a key provider used for the hashed and secure compression
959
+ * @ignore
960
+ */
961
+ export declare type KeyProvider<DataType> = (value: DataType) => string[];
962
+
963
+ /**
964
+ * All the languages available
965
+ * @category Config
966
+ */
967
+ export declare type Language = "fr" | "en";
968
+
969
+ /**
970
+ * Type used for a listening request
971
+ * @inline
972
+ */
973
+ declare type ListenerRequestFn<TRpcSchema extends RpcSchema> = <TParameters extends ExtractedParametersFromRpc<TRpcSchema> = ExtractedParametersFromRpc<TRpcSchema>, _ReturnType = ExtractedReturnTypeFromRpc<TRpcSchema, TParameters>>(args: TParameters, callback: (result: _ReturnType) => void) => Promise<void>;
974
+
975
+ /**
976
+ * Map the currency to the locale
977
+ */
978
+ export declare const locales: {
979
+ readonly eur: "fr-FR";
980
+ readonly usd: "en-US";
981
+ readonly gbp: "en-GB";
982
+ };
983
+
984
+ /**
985
+ * The keys for each locales
986
+ * @inline
987
+ */
988
+ export declare type LocalesKey = keyof typeof locales;
989
+
990
+ /**
991
+ * A localized i18n config
992
+ * @category Config
993
+ */
994
+ export declare type LocalizedI18nConfig = `${string}.css` | {
995
+ [key: string]: string;
996
+ };
997
+
998
+ /**
999
+ * Some configuration options for the embedded view
1000
+ *
1001
+ * @group Embedded wallet
1002
+ */
1003
+ export declare type LoggedInEmbeddedView = {
1004
+ /**
1005
+ * The main action to display on the logged in embedded view
1006
+ */
1007
+ action?: EmbeddedViewActionSharing | EmbeddedViewActionReferred;
1008
+ };
1009
+
1010
+ /**
1011
+ * The view when a user is logged out
1012
+ * @group Embedded wallet
1013
+ */
1014
+ export declare type LoggedOutEmbeddedView = {
1015
+ /**
1016
+ * Metadata option when displaying the embedded view
1017
+ */
1018
+ metadata?: {
1019
+ /**
1020
+ * The main CTA for the logged out view
1021
+ * - can include some variable, available ones are:
1022
+ * - {REWARD} -> The maximum reward a user can receive when interacting on your website
1023
+ * - can be formatted in markdown
1024
+ *
1025
+ * If not set, it will default to a internationalized message
1026
+ * @deprecated Use the top level `config.customizations.i18n`, or `metadata.i18n` instead
1027
+ */
1028
+ text?: string;
1029
+ /**
1030
+ * The text that will be displayed on the login button
1031
+ *
1032
+ * If not set, it will default to a internationalized message
1033
+ * @deprecated Use the top level `config.customizations.i18n`, or `metadata.i18n` instead
1034
+ */
1035
+ buttonText?: string;
1036
+ };
1037
+ };
1038
+
1039
+ /**
1040
+ * The login step for a Modal
1041
+ *
1042
+ * **Input**: Do we allow SSO or not? Is yes then the SSO metadata
1043
+ * **Output**: The logged in wallet address
1044
+ *
1045
+ * @group Modal Display
1046
+ */
1047
+ export declare type LoginModalStepType = GenericModalStepType<"login", LoginWithSso | LoginWithoutSso, {
1048
+ wallet: Address;
1049
+ }>;
1050
+
1051
+ /** @inline */
1052
+ declare type LoginWithoutSso = {
1053
+ allowSso?: false;
1054
+ ssoMetadata?: never;
1055
+ };
1056
+
1057
+ /** @inline */
1058
+ declare type LoginWithSso = {
1059
+ allowSso: true;
1060
+ ssoMetadata?: SsoMetadata;
1061
+ };
1062
+
1063
+ /**
1064
+ * Represent the output type of the modal builder
1065
+ */
1066
+ export declare type ModalBuilder = ModalStepBuilder<[
1067
+ LoginModalStepType,
1068
+ OpenInteractionSessionModalStepType
1069
+ ]>;
1070
+
1071
+ /**
1072
+ * Helper to craft Frak modal, and share a base initial config
1073
+ * @param client - The current Frak Client
1074
+ * @param args
1075
+ * @param args.metadata - Common modal metadata (customisation, language etc)
1076
+ * @param args.login - Login step parameters
1077
+ * @param args.openSession - Open session step parameters
1078
+ *
1079
+ * @description This function will create a modal builder with the provided metadata, login and open session parameters.
1080
+ *
1081
+ * @example
1082
+ * Here is an example of how to use the `modalBuilder` to create and display a sharing modal:
1083
+ *
1084
+ * ```js
1085
+ * // Create the modal builder
1086
+ * const modalBuilder = window.FrakSDK.modalBuilder(frakClient, baseModalConfig);
1087
+ *
1088
+ * // Configure the information to be shared via the sharing link
1089
+ * const sharingConfig = {
1090
+ * popupTitle: "Share this with your friends",
1091
+ * text: "Discover our product!",
1092
+ * link: window.location.href,
1093
+ * };
1094
+ *
1095
+ * // Display the sharing modal
1096
+ * function modalShare() {
1097
+ * modalBuilder.sharing(sharingConfig).display();
1098
+ * }
1099
+ * ```
1100
+ *
1101
+ * @see {@link ModalStepTypes} for more info about each modal step types and their parameters
1102
+ * @see {@link ModalRpcMetadata} for more info about the metadata that can be passed to the modal
1103
+ * @see {@link ModalRpcStepsResultType} for more info about the result of each modal steps
1104
+ * @see {@link displayModal} for more info about how the modal is displayed
1105
+ */
1106
+ export declare function modalBuilder(client: FrakClient, { metadata, login, openSession, }: {
1107
+ metadata?: ModalRpcMetadata;
1108
+ login?: LoginModalStepType["params"];
1109
+ openSession?: OpenInteractionSessionModalStepType["params"];
1110
+ }): ModalBuilder;
1111
+
1112
+ /**
1113
+ * RPC metadata for the modal, used on top level modal configuration
1114
+ * @group Modal Display
1115
+ * @group RPC Schema
1116
+ */
1117
+ export declare type ModalRpcMetadata = {
1118
+ header?: {
1119
+ title?: string;
1120
+ icon?: string;
1121
+ };
1122
+ targetInteraction?: FullInteractionTypesKey;
1123
+ /**
1124
+ * Some i18n override for the displayed modal (i.e. update the displayed text only for this modal)
1125
+ */
1126
+ i18n?: I18nConfig;
1127
+ } & ({
1128
+ isDismissible: true;
1129
+ /**
1130
+ * @deprecated Use `config.customizations.i18n` or `metadata.i18n` instead
1131
+ */
1132
+ dismissActionTxt?: string;
1133
+ } | {
1134
+ isDismissible?: false;
1135
+ dismissActionTxt?: never;
1136
+ });
1137
+
1138
+ /**
1139
+ * Type for the RPC input of a modal
1140
+ * Just the `params` type of each `ModalStepTypes`
1141
+ * @typeParam T - The list of modal steps we expect to have in the modal
1142
+ * @group Modal Display
1143
+ * @group RPC Schema
1144
+ */
1145
+ export declare type ModalRpcStepsInput<T extends ModalStepTypes[] = ModalStepTypes[]> = {
1146
+ [K in T[number]["key"]]?: Extract<T[number], {
1147
+ key: K;
1148
+ }>["params"];
1149
+ };
1150
+
1151
+ /**
1152
+ * Type for the result of a modal request
1153
+ * Just the `returns` type of each `ModalStepTypes`
1154
+ * @typeParam T - The list of modal steps we expect to have in the modal
1155
+ * @group Modal Display
1156
+ * @group RPC Schema
1157
+ */
1158
+ export declare type ModalRpcStepsResultType<T extends ModalStepTypes[] = ModalStepTypes[]> = {
1159
+ [K in T[number]["key"]]: Extract<T[number], {
1160
+ key: K;
1161
+ }>["returns"];
1162
+ };
1163
+
1164
+ /**
1165
+ * Represent the type of the modal step builder
1166
+ */
1167
+ export declare type ModalStepBuilder<Steps extends ModalStepTypes[] = ModalStepTypes[]> = {
1168
+ /**
1169
+ * The current modal params
1170
+ */
1171
+ params: DisplayModalParamsType<Steps>;
1172
+ /**
1173
+ * Add a send transaction step to the modal
1174
+ */
1175
+ sendTx: (options: SendTransactionModalStepType["params"]) => ModalStepBuilder<[...Steps, SendTransactionModalStepType]>;
1176
+ /**
1177
+ * Add a final step of type reward to the modal
1178
+ */
1179
+ reward: (options?: Omit<FinalModalStepType["params"], "action">) => ModalStepBuilder<[...Steps, FinalModalStepType]>;
1180
+ /**
1181
+ * Add a final step of type sharing to the modal
1182
+ */
1183
+ sharing: (sharingOptions?: Extract<FinalActionType, {
1184
+ key: "sharing";
1185
+ }>["options"], options?: Omit<FinalModalStepType["params"], "action">) => ModalStepBuilder<[...Steps, FinalModalStepType]>;
1186
+ /**
1187
+ * Display the modal
1188
+ * @param metadataOverride - Function returning optional metadata to override the current modal metadata
1189
+ */
1190
+ display: (metadataOverride?: (current?: ModalRpcMetadata) => ModalRpcMetadata | undefined) => Promise<ModalRpcStepsResultType<Steps>>;
1191
+ };
1192
+
1193
+ /**
1194
+ * Metadata that can be used to customize a modal step
1195
+ * @group Modal Display
1196
+ * @deprecated Use the top level `config.customizations.i18n`, or `metadata.i18n` instead
1197
+ */
1198
+ export declare type ModalStepMetadata = {
1199
+ metadata?: {
1200
+ /**
1201
+ * Custom title for the step
1202
+ * If none provided, it will use an internationalized text
1203
+ * @deprecated Use the top level `config.customizations.i18n`, or `metadata.i18n` instead
1204
+ */
1205
+ title?: string;
1206
+ /**
1207
+ * Custom description for the step
1208
+ * If none provided, it will use an internationalized text
1209
+ * @deprecated Use the top level `config.customizations.i18n`, or `metadata.i18n` instead
1210
+ */
1211
+ description?: string;
1212
+ /**
1213
+ * Custom text for the primary action of the step
1214
+ * If none provided, it will use an internationalized text
1215
+ * @deprecated Use the top level `config.customizations.i18n`, or `metadata.i18n` instead
1216
+ */
1217
+ primaryActionText?: string;
1218
+ /**
1219
+ * Custom text for the secondary action of the step
1220
+ * If none provided, it will use an internationalized text
1221
+ * @deprecated Use the top level `config.customizations.i18n`, or `metadata.i18n` instead
1222
+ */
1223
+ secondaryActionText?: string;
1224
+ };
1225
+ };
1226
+
1227
+ /**
1228
+ * Generic type of steps we will display in the modal to the end user
1229
+ * @group Modal Display
1230
+ */
1231
+ export declare type ModalStepTypes = LoginModalStepType | SiweAuthenticateModalStepType | SendTransactionModalStepType | OpenInteractionSessionModalStepType | FinalModalStepType;
1232
+
1233
+ /**
1234
+ * The open interaction session step for a Modal
1235
+ *
1236
+ * **Input**: None
1237
+ * **Output**: The interactions session period (start and end timestamp)
1238
+ *
1239
+ * @group Modal Display
1240
+ */
1241
+ export declare type OpenInteractionSessionModalStepType = GenericModalStepType<"openSession", object, OpenInteractionSessionReturnType>;
1242
+
1243
+ /**
1244
+ * Return type of the open session modal step
1245
+ * @inline
1246
+ * @ignore
1247
+ */
1248
+ export declare type OpenInteractionSessionReturnType = {
1249
+ startTimestamp: number;
1250
+ endTimestamp: number;
1251
+ };
1252
+
1253
+ /**
1254
+ * Function used to open the SSO
1255
+ * @param client - The current Frak Client
1256
+ * @param args - The SSO parameters
1257
+ *
1258
+ * @description This function will open the SSO with the provided parameters.
1259
+ *
1260
+ * @example
1261
+ * First we build the sso metadata
1262
+ * ```ts
1263
+ * // Build the metadata
1264
+ * const metadata: SsoMetadata = {
1265
+ * logoUrl: "https://my-app.com/logo.png",
1266
+ * homepageLink: "https://my-app.com",
1267
+ * };
1268
+ * ```
1269
+ *
1270
+ * Then, either use it with direct exit (and so user is directly redirected to your website), or a custom redirect URL
1271
+ * :::code-group
1272
+ * ```ts [Direct exit]
1273
+ * // Trigger an sso opening with redirection
1274
+ * await openSso(frakConfig, {
1275
+ * directExit: true,
1276
+ * metadata,
1277
+ * });
1278
+ * ```
1279
+ * ```ts [Redirection]
1280
+ * // Trigger an sso opening within a popup with direct exit
1281
+ * await openSso(frakConfig, {
1282
+ * redirectUrl: "https://my-app.com/frak-sso",
1283
+ * metadata,
1284
+ * });
1285
+ * ```
1286
+ * :::
1287
+ */
1288
+ export declare function openSso(client: FrakClient, args: OpenSsoParamsType): Promise<void>;
1289
+
1290
+ /**
1291
+ * Params to start a SSO
1292
+ * @group RPC Schema
1293
+ */
1294
+ export declare type OpenSsoParamsType = {
1295
+ /**
1296
+ * Redirect URL after the SSO (optional)
1297
+ */
1298
+ redirectUrl?: string;
1299
+ /**
1300
+ * If the SSO should directly exit after completion
1301
+ * @defaultValue true
1302
+ */
1303
+ directExit?: boolean;
1304
+ /**
1305
+ * Language of the SSO page (optional)
1306
+ * It will default to the current user language (or "en" if unsupported language)
1307
+ */
1308
+ lang?: "en" | "fr";
1309
+ /**
1310
+ * Custom SSO metadata
1311
+ */
1312
+ metadata: SsoMetadata;
1313
+ };
1314
+
1315
+ /**
1316
+ * Parse the current URL into a Frak Context
1317
+ * @param args
1318
+ * @param args.url - The url to parse
1319
+ * @returns The parsed Frak context
1320
+ */
1321
+ declare function parse({ url }: {
1322
+ url: string;
1323
+ }): FrakContext | null | undefined;
1324
+
1325
+ /**
1326
+ * Represent a prepared user interaction, ready to be sent on-chain via the wallet
1327
+ */
1328
+ export declare type PreparedInteraction = {
1329
+ handlerTypeDenominator: Hex;
1330
+ interactionData: Hex;
1331
+ };
1332
+
1333
+ /**
1334
+ * Press interactions allow you to track user engagement with articles or other press content on your platform.
1335
+ * After setting up these interactions, you can create acquisition campaign based on the user engagement with your press content.
1336
+ *
1337
+ * :::info
1338
+ * To properly handle press interactions, ensure that the "Press" product type is enabled in your Business dashboard.
1339
+ * :::
1340
+ *
1341
+ * @description Encode press related user interactions
1342
+ *
1343
+ * @group Interactions Encoder
1344
+ *
1345
+ * @see {@link PreparedInteraction} The prepared interaction object that can be sent
1346
+ * @see {@link !actions.sendInteraction | `sendInteraction()`} Action used to send the prepared interaction to the Frak Wallet
1347
+ */
1348
+ export declare const PressInteractionEncoder: {
1349
+ /**
1350
+ * Encode an open article interaction
1351
+ * @param args
1352
+ * @param args.articleId - The id of the article the user opened (32 bytes), could be a `keccak256` hash of the article slug, or your internal id
1353
+ */
1354
+ openArticle({ articleId }: {
1355
+ articleId: Hex;
1356
+ }): PreparedInteraction;
1357
+ /**
1358
+ * Encode a read article interaction
1359
+ * @param args
1360
+ * @param args.articleId - The id of the article the user opened (32 bytes), could be a `keccak256` hash of the article slug, or your internal id
1361
+ */
1362
+ readArticle({ articleId }: {
1363
+ articleId: Hex;
1364
+ }): PreparedInteraction;
1365
+ };
1366
+
1367
+ /**
1368
+ * This function handle all the heavy lifting of the referral interaction process
1369
+ * 1. Check if the user has been referred or not (if not, early exit)
1370
+ * 2. Then check if the user is logged in or not
1371
+ * 2.1 If not logged in, try a soft login, if it fail, display a modal for the user to login
1372
+ * 3. Check if that's not a self-referral (if yes, early exit)
1373
+ * 4. Check if the user has an interaction session or not
1374
+ * 4.1 If not, display a modal for the user to open a session
1375
+ * 5. Push the referred interaction
1376
+ * 6. Update the current url with the right data
1377
+ * 7. Return the resulting referral state
1378
+ *
1379
+ * If any error occurs during the process, the function will catch it and return an error state
1380
+ *
1381
+ * @param client - The current Frak Client
1382
+ * @param args
1383
+ * @param args.walletStatus - The current user wallet status
1384
+ * @param args.frakContext - The current frak context
1385
+ * @param args.modalConfig - The modal configuration to display if the user is not logged in
1386
+ * @param args.productId - The product id to interact with (if not specified will be recomputed from the current domain)
1387
+ * @param args.options - Some options for the referral interaction
1388
+ * @returns A promise with the resulting referral state
1389
+ *
1390
+ * @see {@link displayModal} for more details about the displayed modal
1391
+ * @see {@link sendInteraction} for more details on the interaction submission part
1392
+ * @see {@link ReferralInteractionEncoder} for more details about the referred interaction
1393
+ * @see {@link ModalStepTypes} for more details on each modal steps types
1394
+ */
1395
+ export declare function processReferral(client: FrakClient, { walletStatus, frakContext, modalConfig, productId, options, }: {
1396
+ walletStatus?: WalletStatusReturnType;
1397
+ frakContext?: Partial<FrakContext> | null;
1398
+ modalConfig?: DisplayEmbeddedWalletParamsType;
1399
+ productId?: Hex;
1400
+ options?: ProcessReferralOptions;
1401
+ }): Promise<ReferralState>;
1402
+
1403
+ /**
1404
+ * Options for the referral auto-interaction process
1405
+ */
1406
+ export declare type ProcessReferralOptions = {
1407
+ /**
1408
+ * If we want to always append the url with the frak context or not
1409
+ * @defaultValue false
1410
+ */
1411
+ alwaysAppendUrl?: boolean;
1412
+ };
1413
+
1414
+ /**
1415
+ * List of the product types per denominator
1416
+ */
1417
+ export declare const productTypes: {
1418
+ dapp: number;
1419
+ press: number;
1420
+ webshop: number;
1421
+ retail: number;
1422
+ referral: number;
1423
+ purchase: number;
1424
+ };
1425
+
1426
+ /**
1427
+ * The keys for each product types
1428
+ * @inline
1429
+ */
1430
+ export declare type ProductTypesKey = keyof typeof productTypes;
1431
+
1432
+ /**
1433
+ * Bitmask for each product types
1434
+ */
1435
+ export declare const productTypesMask: Record<ProductTypesKey, bigint>;
1436
+
1437
+ /**
1438
+ * Purchase interactions allow you to track user purchases on your platform.
1439
+ * After setting up these interactions, you can create acquisition campaign based on the user purchase (starting a new one, completed, or even purchase dropped).
1440
+ *
1441
+ * :::info
1442
+ * To properly handle purchase interactions, ensure that the "Purchase" product type is enabled in your Business dashboard, and that you have set up everything correctly in the `Purchasetracker` section.
1443
+ * :::
1444
+ *
1445
+ * :::note
1446
+ * The `purchaseId` is used on both interactions. It can be computed like this:
1447
+ *
1448
+ * ```ts
1449
+ * const purchaseId = keccak256(concatHex([productId, toHex(externalPurchaseId)]));
1450
+ * ```
1451
+ *
1452
+ * With:
1453
+ * - `productId`: The id of your product, you can find it in the product dashboard.
1454
+ * - `externalPurchaseId`: The id of the purchase in your system (e.g. the shopify `order_id`).
1455
+ * :::
1456
+ *
1457
+ * @description Encode purchase related user interactions
1458
+ *
1459
+ * @group Interactions Encoder
1460
+ *
1461
+ * @see {@link !actions.sendInteraction | `sendInteraction()`} Action used to send the prepared interaction to the Frak Wallet
1462
+ * @see {@link PreparedInteraction} The prepared interaction object that can be sent
1463
+ * @see {@link !actions.trackPurchaseStatus | `trackPurchaseStatus()`} Action that will automatically send the purchase upon completion
1464
+ * @see [Purchase Webhooks](/wallet-sdk/references-api/webhook) Webhooks to be implemented on your side to confirm a purchase
1465
+ * @see [Purchase Proof](/wallet-sdk/references-api/purchaseProof) Get a merklee proof for the purchase
1466
+ */
1467
+ export declare const PurchaseInteractionEncoder: {
1468
+ /**
1469
+ * Encode a start purchase interaction
1470
+ * @param args
1471
+ * @param args.purchaseId - The id of the purchase that is being started.
1472
+ */
1473
+ startPurchase({ purchaseId }: {
1474
+ purchaseId: Hex;
1475
+ }): PreparedInteraction;
1476
+ /**
1477
+ * Encode a complete purchase interaction
1478
+ * @param args
1479
+ * @param args.purchaseId - The id of the purchase that is being completed.
1480
+ * @param args.proof - The merkle proof that the user has completed the purchase (see [Purchase Webhooks](/wallet-sdk/references-api/webhook) for more details).
1481
+ */
1482
+ completedPurchase({ purchaseId, proof, }: {
1483
+ purchaseId: Hex;
1484
+ proof: Hex[];
1485
+ }): PreparedInteraction;
1486
+ /**
1487
+ * Encode an unsafe complete purchase interaction (when we can't provide the proof)
1488
+ * @param args
1489
+ * @param args.purchaseId - The id of the purchase that is being completed.
1490
+ */
1491
+ unsafeCompletedPurchase({ purchaseId, }: {
1492
+ purchaseId: Hex;
1493
+ }): PreparedInteraction;
1494
+ };
1495
+
1496
+ declare type RedirectRequestEvent = {
1497
+ iframeLifecycle: "redirect";
1498
+ data: {
1499
+ /**
1500
+ * The base url to redirect to (contain a query param `u`, the client need to suffix the current url to the base url)
1501
+ */
1502
+ baseRedirectUrl: string;
1503
+ };
1504
+ };
1505
+
1506
+ /**
1507
+ * Function used to display a modal
1508
+ * @param client - The current Frak Client
1509
+ * @param args
1510
+ * @param args.productId - The product id to interact with (if not specified will be recomputed from the current domain)
1511
+ * @param args.modalConfig - The modal configuration to display if the user is not logged in
1512
+ * @param args.options - Some options for the referral interaction
1513
+ *
1514
+ * @returns A promise with the resulting referral state, or undefined in case of an error
1515
+ *
1516
+ * @description This function will automatically handle the referral interaction process
1517
+ *
1518
+ * @see {@link processReferral} for more details on the automatic referral handling process
1519
+ * @see {@link ModalStepTypes} for more details on each modal steps types
1520
+ */
1521
+ export declare function referralInteraction(client: FrakClient, { productId, modalConfig, options, }?: {
1522
+ productId?: Hex;
1523
+ modalConfig?: DisplayEmbeddedWalletParamsType;
1524
+ options?: ProcessReferralOptions;
1525
+ }): Promise<("error" | "idle" | "processing" | "success" | "no-wallet" | "no-session" | "no-referrer" | "self-referral") | undefined>;
1526
+
1527
+ /**
1528
+ * Referral interactions allow you to track user sharing activities.
1529
+ * These interactions are essential for platforms looking to grow their user base through user-to-user referrals and reward systems.
1530
+ *
1531
+ * :::info
1532
+ * To properly handle referral interactions, ensure that the "Referral" product type is enabled in your Business dashboard.
1533
+ * :::
1534
+ *
1535
+ * @description Encode referral related user interactions
1536
+ *
1537
+ * @group Interactions Encoder
1538
+ *
1539
+ * @see {@link PreparedInteraction} The prepared interaction object that can be sent
1540
+ * @see {@link !actions.sendInteraction | `sendInteraction()`} Action used to send the prepared interaction to the Frak Wallet
1541
+ */
1542
+ export declare const ReferralInteractionEncoder: {
1543
+ /**
1544
+ * Records the event of a user creating a referral link. Note that this interaction doesn't actually create the link itself; it only sends an event to track that a link was created.
1545
+ */
1546
+ createLink(): PreparedInteraction;
1547
+ /**
1548
+ * Encode a referred interaction
1549
+ * @param args
1550
+ * @param args.referrer - The Ethereum address of the user who made the referral
1551
+ */
1552
+ referred({ referrer }: {
1553
+ referrer: Address;
1554
+ }): PreparedInteraction;
1555
+ };
1556
+
1557
+ /**
1558
+ * The different states of the referral process
1559
+ * @inline
1560
+ */
1561
+ declare type ReferralState = "idle" | "processing" | "success" | "no-wallet" | "no-session" | "error" | "no-referrer" | "self-referral";
1562
+
1563
+ /**
1564
+ * Remove Frak context from current url
1565
+ * @param url - The url to update
1566
+ * @returns The new url without the Frak context
1567
+ */
1568
+ declare function remove(url: string): string;
1569
+
1570
+ declare type RemoveBackupEvent = {
1571
+ iframeLifecycle: "remove-backup";
1572
+ };
1573
+
1574
+ /**
1575
+ * Replace the current url with the given Frak context
1576
+ * @param args
1577
+ * @param args.url - The url to update
1578
+ * @param args.context - The context to update
1579
+ */
1580
+ declare function replaceUrl({ url: baseUrl, context, }: {
1581
+ url?: string;
1582
+ context: Partial<FrakContext> | null;
1583
+ }): void;
1584
+
1585
+ /**
1586
+ * Type used for a one shot request function
1587
+ * @inline
1588
+ */
1589
+ declare type RequestFn<TRpcSchema extends RpcSchema> = <TParameters extends ExtractedParametersFromRpc<TRpcSchema> = ExtractedParametersFromRpc<TRpcSchema>, _ReturnType = ExtractedReturnTypeFromRpc<TRpcSchema, TParameters>>(args: TParameters) => Promise<_ReturnType>;
1590
+
1591
+ declare type RestoreBackupEvent = {
1592
+ clientLifecycle: "restore-backup";
1593
+ data: {
1594
+ backup: string;
1595
+ };
1596
+ };
1597
+
1598
+ /**
1599
+ * Retail interactions allow you to track user activities on your retails products.
1600
+ *
1601
+ * :::info
1602
+ * To properly handle retail interactions, ensure that the "Retail" product type is enabled in your Business dashboard.
1603
+ * :::
1604
+ *
1605
+ * @description Encode retail related user interactions
1606
+ *
1607
+ * @group Interactions Encoder
1608
+ *
1609
+ * @see {@link PreparedInteraction} The prepared interaction object that can be sent
1610
+ * @see {@link !actions.sendInteraction | `sendInteraction()`} Action used to send the prepared interaction to the Frak Wallet
1611
+ */
1612
+ export declare const RetailInteractionEncoder: {
1613
+ /**
1614
+ * Encode a customer meeting retail interaction
1615
+ * @param args
1616
+ * @param args.agencyId - The id of the agency that the customer is meeting with
1617
+ *
1618
+ */
1619
+ customerMeeting({ agencyId }: {
1620
+ agencyId: Hex;
1621
+ }): PreparedInteraction;
1622
+ };
1623
+
1624
+ /**
1625
+ * The different Frak RPC error codes
1626
+ */
1627
+ export declare const RpcErrorCodes: {
1628
+ readonly parseError: -32700;
1629
+ readonly invalidRequest: -32600;
1630
+ readonly methodNotFound: -32601;
1631
+ readonly invalidParams: -32602;
1632
+ readonly internalError: -32603;
1633
+ readonly serverError: -32000;
1634
+ readonly clientNotConnected: -32001;
1635
+ readonly configError: -32002;
1636
+ readonly corruptedResponse: -32003;
1637
+ readonly clientAborted: -32004;
1638
+ readonly walletNotConnected: -32005;
1639
+ readonly serverErrorForInteractionDelegation: -32006;
1640
+ };
1641
+
1642
+ /**
1643
+ * Raw response that we will receive after an rpc request
1644
+ * @ignore
1645
+ */
1646
+ export declare type RpcResponse<TRpcSchema extends RpcSchema, TMethod extends TRpcSchema[number]["Method"] = TRpcSchema[number]["Method"]> = {
1647
+ result: Extract<TRpcSchema[number], {
1648
+ Method: TMethod;
1649
+ }>["ReturnType"];
1650
+ error?: never;
1651
+ } | {
1652
+ result?: never;
1653
+ error: {
1654
+ code: number;
1655
+ message: string;
1656
+ data?: unknown;
1657
+ };
1658
+ };
1659
+
1660
+ /**
1661
+ * Function used to send an interaction
1662
+ * @param client - The current Frak Client
1663
+ * @param args
1664
+ *
1665
+ * @example
1666
+ * const interaction = PressInteractionEncoder.openArticle({
1667
+ * articleId: keccak256(toHex("article-slug")),
1668
+ * });
1669
+ * const { delegationId } = await sendInteraction(frakConfig, {
1670
+ * interaction,
1671
+ * });
1672
+ * console.log("Delegated interaction id", delegationId);
1673
+ */
1674
+ export declare function sendInteraction(client: FrakClient, { productId, interaction, validation }: SendInteractionParamsType): Promise<SendInteractionReturnType>;
1675
+
1676
+ /**
1677
+ * Parameters that will be used to send an interaction to the blockchain
1678
+ * @inline
1679
+ */
1680
+ export declare type SendInteractionParamsType = {
1681
+ /**
1682
+ * The product id where this interaction has been made
1683
+ * @defaultValue keccak256(toHex(window.location.host))
1684
+ */
1685
+ productId?: Hex;
1686
+ /**
1687
+ * The prepared interaction, built from an Interaction Encoder
1688
+ */
1689
+ interaction: PreparedInteraction;
1690
+ /**
1691
+ * A pre-computed interaction signature
1692
+ * If none provided, the delegated interaction validator of your product will sign it (you can manage it in the business dashboard)
1693
+ *
1694
+ * @defaultValue undefined
1695
+ */
1696
+ validation?: Hex;
1697
+ };
1698
+
1699
+ /**
1700
+ * Return type of the send interaction rpc request
1701
+ * @group RPC Schema
1702
+ */
1703
+ export declare type SendInteractionReturnType = {
1704
+ /**
1705
+ * The id of the interaction in the interaction pool
1706
+ */
1707
+ delegationId: string;
1708
+ };
1709
+
1710
+ /**
1711
+ * Function used to send a user transaction, simple wrapper around the displayModal function to ease the send transaction process
1712
+ * @param client - The current Frak Client
1713
+ * @param args - The parameters
1714
+ * @returns The hash of the transaction that was sent in a promise
1715
+ *
1716
+ * @description This function will display a modal to the user with the provided transaction and metadata.
1717
+ *
1718
+ * @example
1719
+ * const { hash } = await sendTransaction(frakConfig, {
1720
+ * tx: {
1721
+ * to: "0xdeadbeef",
1722
+ * value: toHex(100n),
1723
+ * },
1724
+ * metadata: {
1725
+ * header: {
1726
+ * title: "Sending eth",
1727
+ * },
1728
+ * context: "Send 100wei to 0xdeadbeef",
1729
+ * },
1730
+ * });
1731
+ * console.log("Transaction hash:", hash);
1732
+ */
1733
+ export declare function sendTransaction(client: FrakClient, { tx, metadata }: SendTransactionParams): Promise<SendTransactionReturnType>;
1734
+
1735
+ /**
1736
+ * The send transaction step for a Modal
1737
+ *
1738
+ * **Input**: Either a single tx or an array of tx to be sent
1739
+ * **Output**: The hash of the tx(s) hash (in case of multiple tx, still returns a single hash because it's bundled on the wallet level)
1740
+ *
1741
+ * @group Modal Display
1742
+ */
1743
+ export declare type SendTransactionModalStepType = GenericModalStepType<"sendTransaction", {
1744
+ tx: SendTransactionTxType | SendTransactionTxType[];
1745
+ }, SendTransactionReturnType>;
1746
+
1747
+ /**
1748
+ * Parameters to directly show a modal used to send a transaction
1749
+ * @inline
1750
+ */
1751
+ export declare type SendTransactionParams = {
1752
+ /**
1753
+ * The transaction to be sent (either a single tx or multiple ones)
1754
+ */
1755
+ tx: SendTransactionModalStepType["params"]["tx"];
1756
+ /**
1757
+ * Custom metadata to be passed to the modal
1758
+ */
1759
+ metadata?: ModalRpcMetadata;
1760
+ };
1761
+
1762
+ /**
1763
+ * Return type of the send transaction rpc request
1764
+ * @inline
1765
+ */
1766
+ export declare type SendTransactionReturnType = {
1767
+ hash: Hex;
1768
+ };
1769
+
1770
+ /**
1771
+ * Generic format representing a tx to be sent
1772
+ */
1773
+ export declare type SendTransactionTxType = {
1774
+ to: Address;
1775
+ data?: Hex;
1776
+ value?: Hex;
1777
+ };
1778
+
1779
+ /**
1780
+ * Directly setup the Frak client with an iframe
1781
+ * Return when the FrakClient is ready (setup and communication estbalished with the wallet)
1782
+ *
1783
+ * @param config - The configuration to use for the Frak Wallet SDK
1784
+ * @returns a Promise with the Frak Client
1785
+ *
1786
+ * @example
1787
+ * const frakConfig: FrakWalletSdkConfig = {
1788
+ * metadata: {
1789
+ * name: "My app title",
1790
+ * },
1791
+ * }
1792
+ * const client = await setupClient({ config: frakConfig });
1793
+ */
1794
+ export declare function setupClient({ config, }: {
1795
+ config: FrakWalletSdkConfig;
1796
+ }): Promise<FrakClient | undefined>;
1797
+
1798
+ /**
1799
+ * Function used to launch a siwe authentication
1800
+ * @param client - The current Frak Client
1801
+ * @param args - The parameters
1802
+ * @returns The SIWE authentication result (message + signature) in a promise
1803
+ *
1804
+ * @description This function will display a modal to the user with the provided SIWE parameters and metadata.
1805
+ *
1806
+ * @example
1807
+ * import { siweAuthenticate } from "@frak-labs/core-sdk/actions";
1808
+ * import { parseSiweMessage } from "viem/siwe";
1809
+ *
1810
+ * const { signature, message } = await siweAuthenticate(frakConfig, {
1811
+ * siwe: {
1812
+ * statement: "Sign in to My App",
1813
+ * domain: "my-app.com",
1814
+ * expirationTimeTimestamp: Date.now() + 1000 * 60 * 5,
1815
+ * },
1816
+ * metadata: {
1817
+ * header: {
1818
+ * title: "Sign in",
1819
+ * },
1820
+ * context: "Sign in to My App",
1821
+ * },
1822
+ * });
1823
+ * console.log("Parsed final message:", parseSiweMessage(message));
1824
+ * console.log("Siwe signature:", signature);
1825
+ */
1826
+ export declare function siweAuthenticate(client: FrakClient, { siwe, metadata }: SiweAuthenticateModalParams): Promise<SiweAuthenticateReturnType>;
1827
+
1828
+ /**
1829
+ * Parameter used to directly show a modal used to authenticate with SIWE
1830
+ * @inline
1831
+ */
1832
+ export declare type SiweAuthenticateModalParams = {
1833
+ /**
1834
+ * Partial SIWE params, since we can rebuild them from the SDK if they are empty
1835
+ *
1836
+ * If no parameters provider, some fields will be recomputed from the current configuration and environment.
1837
+ * - `statement` will be set to a default value
1838
+ * - `nonce` will be generated
1839
+ * - `uri` will be set to the current domain
1840
+ * - `version` will be set to "1"
1841
+ * - `domain` will be set to the current window domain
1842
+ *
1843
+ * @default {}
1844
+ */
1845
+ siwe?: Partial<SiweAuthenticationParams>;
1846
+ /**
1847
+ * Custom metadata to be passed to the modal
1848
+ */
1849
+ metadata?: ModalRpcMetadata;
1850
+ };
1851
+
1852
+ /**
1853
+ * The SIWE authentication step for a Modal
1854
+ *
1855
+ * **Input**: SIWE message parameters
1856
+ * **Output**: SIWE result (message signed and wallet signature)
1857
+ *
1858
+ * @group Modal Display
1859
+ */
1860
+ export declare type SiweAuthenticateModalStepType = GenericModalStepType<"siweAuthenticate", {
1861
+ siwe: SiweAuthenticationParams;
1862
+ }, SiweAuthenticateReturnType>;
1863
+
1864
+ /**
1865
+ * Return type of the Siwe transaction rpc request
1866
+ * @inline
1867
+ */
1868
+ export declare type SiweAuthenticateReturnType = {
1869
+ signature: Hex;
1870
+ message: string;
1871
+ };
1872
+
1873
+ /**
1874
+ * Parameters used send a SIWE rpc request
1875
+ */
1876
+ export declare type SiweAuthenticationParams = Omit<SiweMessage, "address" | "chainId" | "expirationTime" | "issuedAt" | "notBefore"> & {
1877
+ expirationTimeTimestamp?: number;
1878
+ notBeforeTimestamp?: number;
1879
+ };
1880
+
1881
+ /**
1882
+ * SSO Metadata
1883
+ */
1884
+ export declare type SsoMetadata = {
1885
+ /**
1886
+ * URL to your client, if provided will be displayed in the SSO header
1887
+ */
1888
+ logoUrl?: string;
1889
+ /**
1890
+ * Link to your homepage, if referenced your app name will contain a link on the sso page
1891
+ */
1892
+ homepageLink?: string;
1893
+ };
1894
+
1895
+ /**
1896
+ * The type for the amount of tokens
1897
+ */
1898
+ export declare type TokenAmountType = {
1899
+ amount: number;
1900
+ eurAmount: number;
1901
+ usdAmount: number;
1902
+ gbpAmount: number;
1903
+ };
1904
+
1905
+ export declare function trackEvent(client: FrakClient | undefined, event: FrakEvent, props?: EventProps): void;
1906
+
1907
+ /**
1908
+ * Function used to track the status of a purchase
1909
+ * when a purchase is tracked, the `purchaseCompleted` interactions will be automatically send for the user when we receive the purchase confirmation via webhook.
1910
+ *
1911
+ * @param args.customerId - The customer id that made the purchase (on your side)
1912
+ * @param args.orderId - The order id of the purchase (on your side)
1913
+ * @param args.token - The token of the purchase
1914
+ *
1915
+ * @description This function will send a request to the backend to listen for the purchase status.
1916
+ *
1917
+ * @example
1918
+ * async function trackPurchase(checkout) {
1919
+ * const payload = {
1920
+ * customerId: checkout.order.customer.id,
1921
+ * orderId: checkout.order.id,
1922
+ * token: checkout.token,
1923
+ * };
1924
+ *
1925
+ * await trackPurchaseStatus(payload);
1926
+ * }
1927
+ *
1928
+ * @remarks
1929
+ * - The `trackPurchaseStatus` function requires the `frak-wallet-interaction-token` stored in the session storage to authenticate the request.
1930
+ * - This function will print a warning if used in a non-browser environment or if the wallet interaction token is not available.
1931
+ */
1932
+ export declare function trackPurchaseStatus(args: {
1933
+ customerId: string | number;
1934
+ orderId: string | number;
1935
+ token: string;
1936
+ }): Promise<void>;
1937
+
1938
+ /**
1939
+ * Populate the current url with the given Frak context
1940
+ * @param args
1941
+ * @param args.url - The url to update
1942
+ * @param args.context - The context to update
1943
+ * @returns The new url with the Frak context
1944
+ */
1945
+ declare function update({ url, context, }: {
1946
+ url?: string;
1947
+ context: Partial<FrakContext>;
1948
+ }): string | null;
1949
+
1950
+ /**
1951
+ * @ignore
1952
+ * @inline
1953
+ */
1954
+ declare type WalletConnected = {
1955
+ key: "connected";
1956
+ wallet: Address;
1957
+ interactionToken?: string;
1958
+ interactionSession?: {
1959
+ startTimestamp: number;
1960
+ endTimestamp: number;
1961
+ };
1962
+ };
1963
+
1964
+ /**
1965
+ * @ignore
1966
+ * @inline
1967
+ */
1968
+ declare type WalletNotConnected = {
1969
+ key: "not-connected";
1970
+ wallet?: never;
1971
+ interactionToken?: never;
1972
+ interactionSession?: never;
1973
+ };
1974
+
1975
+ /**
1976
+ * RPC Response for the method `frak_listenToWalletStatus`
1977
+ * @group RPC Schema
1978
+ */
1979
+ export declare type WalletStatusReturnType = WalletConnected | WalletNotConnected;
1980
+
1981
+ /**
1982
+ * Function used to watch the current frak wallet status
1983
+ * @param client - The current Frak Client
1984
+ * @param callback - The callback that will receive any wallet status change
1985
+ * @returns A rpomise resolving with the initial wallet status
1986
+ *
1987
+ * @description This function will return the current wallet status, and will listen to any change in the wallet status.
1988
+ *
1989
+ * @example
1990
+ * await watchWalletStatus(frakConfig, (status: WalletStatusReturnType) => {
1991
+ * if (status.key === "connected") {
1992
+ * console.log("Wallet connected:", status.wallet);
1993
+ * console.log("Current interaction session:", status.interactionSession);
1994
+ * } else {
1995
+ * console.log("Wallet not connected");
1996
+ * }
1997
+ * });
1998
+ */
1999
+ export declare function watchWalletStatus(client: FrakClient, callback?: (status: WalletStatusReturnType) => void): Promise<WalletStatusReturnType>;
2000
+
2001
+ /**
2002
+ * Webshop interactions allow you to track user activities on your webshop.
2003
+ *
2004
+ * :::info
2005
+ * To properly handle webshop interactions, ensure that the "WebShop" product type is enabled in your Business dashboard.
2006
+ * :::
2007
+ *
2008
+ * @description Encode webshop related user interactions
2009
+ *
2010
+ * @group Interactions Encoder
2011
+ *
2012
+ * @see {@link PreparedInteraction} The prepared interaction object that can be sent
2013
+ * @see {@link !actions.sendInteraction | `sendInteraction()`} Action used to send the prepared interaction to the Frak Wallet
2014
+ */
2015
+ export declare const WebShopInteractionEncoder: {
2016
+ /**
2017
+ * Encode an open webshop interaction
2018
+ */
2019
+ open(): PreparedInteraction;
2020
+ };
2021
+
2022
+ export { }