@frak-labs/core-sdk 0.0.7 → 0.0.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cdn/bundle.js +17 -31
- package/cdn/bundle.js.LICENSE.txt +10 -0
- package/dist/actions.cjs +1 -0
- package/dist/actions.d.cts +1285 -0
- package/dist/actions.d.ts +1285 -0
- package/dist/actions.js +1 -0
- package/dist/index.cjs +11 -487
- package/dist/index.d.cts +1152 -255
- package/dist/index.d.ts +1152 -255
- package/dist/index.js +11 -428
- package/dist/interactions.cjs +1 -0
- package/dist/{interactions/index.d.ts → interactions.d.cts} +182 -174
- package/dist/{interactions/index.d.cts → interactions.d.ts} +182 -174
- package/dist/interactions.js +1 -0
- package/package.json +14 -14
- package/dist/actions/index.cjs +0 -350
- package/dist/actions/index.d.cts +0 -501
- package/dist/actions/index.d.ts +0 -501
- package/dist/actions/index.js +0 -337
- package/dist/chunk-665P7NO4.cjs +0 -81
- package/dist/chunk-7YDJDVXY.cjs +0 -833
- package/dist/chunk-GTBCSNLF.js +0 -819
- package/dist/chunk-PHVGCFDX.cjs +0 -155
- package/dist/chunk-U2NTN5QZ.js +0 -75
- package/dist/chunk-VE6URIIJ.js +0 -149
- package/dist/context-D7aZDKLT.d.cts +0 -813
- package/dist/context-rDsQbSgB.d.ts +0 -813
- package/dist/interaction-CTQ5-kqe.d.cts +0 -43
- package/dist/interaction-CTQ5-kqe.d.ts +0 -43
- package/dist/interactions/index.cjs +0 -26
- package/dist/interactions/index.js +0 -1
|
@@ -1,813 +0,0 @@
|
|
|
1
|
-
import { Address, Hex, RpcSchema } from 'viem';
|
|
2
|
-
import { Prettify } from 'viem/chains';
|
|
3
|
-
import { SiweMessage } from 'viem/siwe';
|
|
4
|
-
import { P as PreparedInteraction, a as SendInteractionReturnType } from './interaction-CTQ5-kqe.js';
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Configuration for the Nexus Wallet SDK
|
|
8
|
-
*/
|
|
9
|
-
type FrakWalletSdkConfig = {
|
|
10
|
-
/**
|
|
11
|
-
* The Frak wallet url
|
|
12
|
-
* @defaultValue "https://wallet.frak.id"
|
|
13
|
-
*/
|
|
14
|
-
walletUrl?: string;
|
|
15
|
-
/**
|
|
16
|
-
* Some metadata about your implementation of the Frak SDK
|
|
17
|
-
*/
|
|
18
|
-
metadata: {
|
|
19
|
-
/**
|
|
20
|
-
* Your application name (will be displayed in a few modals and in SSO)
|
|
21
|
-
*/
|
|
22
|
-
name: string;
|
|
23
|
-
/**
|
|
24
|
-
* Custom CSS styles to apply to the modals and components
|
|
25
|
-
*/
|
|
26
|
-
css?: string;
|
|
27
|
-
};
|
|
28
|
-
/**
|
|
29
|
-
* The domain name of your application
|
|
30
|
-
* @defaultValue window.location.host
|
|
31
|
-
*/
|
|
32
|
-
domain?: string;
|
|
33
|
-
};
|
|
34
|
-
|
|
35
|
-
/**
|
|
36
|
-
* Event related to the iframe lifecycle
|
|
37
|
-
* @ignore
|
|
38
|
-
*/
|
|
39
|
-
type IFrameLifecycleEvent = {
|
|
40
|
-
iframeLifecycle: "connected" | "show" | "hide";
|
|
41
|
-
data?: never;
|
|
42
|
-
} | DoBackupEvent | RemoveBackupEvent | HandshakeRequestEvent;
|
|
43
|
-
type DoBackupEvent = {
|
|
44
|
-
iframeLifecycle: "do-backup";
|
|
45
|
-
data: {
|
|
46
|
-
backup?: string;
|
|
47
|
-
};
|
|
48
|
-
};
|
|
49
|
-
type RemoveBackupEvent = {
|
|
50
|
-
iframeLifecycle: "remove-backup";
|
|
51
|
-
};
|
|
52
|
-
type HandshakeRequestEvent = {
|
|
53
|
-
iframeLifecycle: "handshake";
|
|
54
|
-
data: {
|
|
55
|
-
token: string;
|
|
56
|
-
};
|
|
57
|
-
};
|
|
58
|
-
|
|
59
|
-
/**
|
|
60
|
-
* Event related to the iframe lifecycle
|
|
61
|
-
* @ignore
|
|
62
|
-
*/
|
|
63
|
-
type ClientLifecycleEvent = CustomCssEvent | RestoreBackupEvent | HearbeatEvent | HandshakeResponse;
|
|
64
|
-
type CustomCssEvent = {
|
|
65
|
-
clientLifecycle: "modal-css";
|
|
66
|
-
data: {
|
|
67
|
-
cssLink: string;
|
|
68
|
-
};
|
|
69
|
-
};
|
|
70
|
-
type RestoreBackupEvent = {
|
|
71
|
-
clientLifecycle: "restore-backup";
|
|
72
|
-
data: {
|
|
73
|
-
backup: string;
|
|
74
|
-
};
|
|
75
|
-
};
|
|
76
|
-
type HearbeatEvent = {
|
|
77
|
-
clientLifecycle: "heartbeat";
|
|
78
|
-
};
|
|
79
|
-
type HandshakeResponse = {
|
|
80
|
-
clientLifecycle: "handshake-response";
|
|
81
|
-
data: {
|
|
82
|
-
token: string;
|
|
83
|
-
currentUrl: string;
|
|
84
|
-
};
|
|
85
|
-
};
|
|
86
|
-
|
|
87
|
-
/**
|
|
88
|
-
* The final keys for each interaction types (e.g. `openArticle`) -> interaction type
|
|
89
|
-
* @inline
|
|
90
|
-
*/
|
|
91
|
-
type InteractionTypesKey = {
|
|
92
|
-
[K in keyof typeof interactionTypes]: keyof (typeof interactionTypes)[K];
|
|
93
|
-
}[keyof typeof interactionTypes];
|
|
94
|
-
/**
|
|
95
|
-
* The keys for each interaction types (e.g. `press.openArticle`) -> category_type.interaction_type
|
|
96
|
-
* @inline
|
|
97
|
-
*/
|
|
98
|
-
type FullInteractionTypesKey = {
|
|
99
|
-
[Category in keyof typeof interactionTypes]: `${Category & string}.${keyof (typeof interactionTypes)[Category] & string}`;
|
|
100
|
-
}[keyof typeof interactionTypes];
|
|
101
|
-
/**
|
|
102
|
-
* Each interactions types according to the product types
|
|
103
|
-
*/
|
|
104
|
-
declare const interactionTypes: {
|
|
105
|
-
readonly press: {
|
|
106
|
-
readonly openArticle: "0xc0a24ffb";
|
|
107
|
-
readonly readArticle: "0xd5bd0fbe";
|
|
108
|
-
};
|
|
109
|
-
readonly dapp: {
|
|
110
|
-
readonly proofVerifiableStorageUpdate: "0x2ab2aeef";
|
|
111
|
-
readonly callableVerifiableStorageUpdate: "0xa07da986";
|
|
112
|
-
};
|
|
113
|
-
readonly webshop: {
|
|
114
|
-
readonly open: "0xb311798f";
|
|
115
|
-
};
|
|
116
|
-
readonly referral: {
|
|
117
|
-
readonly referred: "0x010cc3b9";
|
|
118
|
-
readonly createLink: "0xb2c0f17c";
|
|
119
|
-
};
|
|
120
|
-
readonly purchase: {
|
|
121
|
-
readonly started: "0xd87e90c3";
|
|
122
|
-
readonly completed: "0x8403aeb4";
|
|
123
|
-
readonly unsafeCompleted: "0x4d5b14e0";
|
|
124
|
-
};
|
|
125
|
-
readonly retail: {
|
|
126
|
-
readonly customerMeeting: "0x74489004";
|
|
127
|
-
};
|
|
128
|
-
};
|
|
129
|
-
|
|
130
|
-
/**
|
|
131
|
-
* SSO Metadata
|
|
132
|
-
*/
|
|
133
|
-
type SsoMetadata = {
|
|
134
|
-
/**
|
|
135
|
-
* URL to your client, if provided will be displayed in the SSO header
|
|
136
|
-
*/
|
|
137
|
-
logoUrl?: string;
|
|
138
|
-
/**
|
|
139
|
-
* Link to your homepage, if referenced your app name will contain a link on the sso page
|
|
140
|
-
*/
|
|
141
|
-
homepageLink?: string;
|
|
142
|
-
};
|
|
143
|
-
/**
|
|
144
|
-
* Params to start a SSO
|
|
145
|
-
* @group RPC Schema
|
|
146
|
-
*/
|
|
147
|
-
type OpenSsoParamsType = {
|
|
148
|
-
/**
|
|
149
|
-
* Redirect URL after the SSO (optional)
|
|
150
|
-
*/
|
|
151
|
-
redirectUrl?: string;
|
|
152
|
-
/**
|
|
153
|
-
* If the SSO should directly exit after completion
|
|
154
|
-
* @defaultValue true
|
|
155
|
-
*/
|
|
156
|
-
directExit?: boolean;
|
|
157
|
-
/**
|
|
158
|
-
* Language of the SSO page (optional)
|
|
159
|
-
* It will default to the current user language (or "en" if unsupported language)
|
|
160
|
-
*/
|
|
161
|
-
lang?: "en" | "fr";
|
|
162
|
-
/**
|
|
163
|
-
* Custom SSO metadata
|
|
164
|
-
*/
|
|
165
|
-
metadata: SsoMetadata;
|
|
166
|
-
};
|
|
167
|
-
|
|
168
|
-
/**
|
|
169
|
-
* Represent a generic modal step type
|
|
170
|
-
* @ignore
|
|
171
|
-
* @inline
|
|
172
|
-
*/
|
|
173
|
-
type GenericModalStepType<TKey, TParams, TReturns> = {
|
|
174
|
-
key: TKey;
|
|
175
|
-
params: TParams extends never ? ModalStepMetadata : ModalStepMetadata & TParams;
|
|
176
|
-
returns: TReturns;
|
|
177
|
-
};
|
|
178
|
-
/**
|
|
179
|
-
* Metadata that can be used to customise a modal step
|
|
180
|
-
* @group Modal Display
|
|
181
|
-
*/
|
|
182
|
-
type ModalStepMetadata = {
|
|
183
|
-
metadata?: {
|
|
184
|
-
/**
|
|
185
|
-
* Custom title for the step
|
|
186
|
-
* If none provided, it will use an internationalised text
|
|
187
|
-
*/
|
|
188
|
-
title?: string;
|
|
189
|
-
/**
|
|
190
|
-
* Custom description for the step
|
|
191
|
-
* If none provided, it will use an internationalised text
|
|
192
|
-
*/
|
|
193
|
-
description?: string;
|
|
194
|
-
/**
|
|
195
|
-
* Custom text for the primary action of the step
|
|
196
|
-
* If none provided, it will use an internationalised text
|
|
197
|
-
*/
|
|
198
|
-
primaryActionText?: string;
|
|
199
|
-
/**
|
|
200
|
-
* Custom text for the secondary action of the step
|
|
201
|
-
* If none provided, it will use an internationalised text
|
|
202
|
-
*/
|
|
203
|
-
secondaryActionText?: string;
|
|
204
|
-
};
|
|
205
|
-
};
|
|
206
|
-
|
|
207
|
-
/** @inline */
|
|
208
|
-
type LoginWithSso = {
|
|
209
|
-
allowSso: true;
|
|
210
|
-
ssoMetadata: SsoMetadata;
|
|
211
|
-
};
|
|
212
|
-
/** @inline */
|
|
213
|
-
type LoginWithoutSso = {
|
|
214
|
-
allowSso?: false;
|
|
215
|
-
ssoMetadata?: never;
|
|
216
|
-
};
|
|
217
|
-
/**
|
|
218
|
-
* The login step for a Modal
|
|
219
|
-
*
|
|
220
|
-
* **Input**: Do we allow SSO or not? Is yes then the SSO metadata
|
|
221
|
-
* **Output**: The logged in wallet address
|
|
222
|
-
*
|
|
223
|
-
* @group Modal Display
|
|
224
|
-
*/
|
|
225
|
-
type LoginModalStepType = GenericModalStepType<"login", LoginWithSso | LoginWithoutSso, {
|
|
226
|
-
wallet: Address;
|
|
227
|
-
}>;
|
|
228
|
-
|
|
229
|
-
/**
|
|
230
|
-
* Parameters used send a SIWE rpc request
|
|
231
|
-
*/
|
|
232
|
-
type SiweAuthenticationParams = Omit<SiweMessage, "address" | "chainId" | "expirationTime" | "issuedAt" | "notBefore"> & {
|
|
233
|
-
expirationTimeTimestamp?: number;
|
|
234
|
-
notBeforeTimestamp?: number;
|
|
235
|
-
};
|
|
236
|
-
/**
|
|
237
|
-
* Return type of the Siwe transaction rpc request
|
|
238
|
-
* @inline
|
|
239
|
-
*/
|
|
240
|
-
type SiweAuthenticateReturnType = {
|
|
241
|
-
signature: Hex;
|
|
242
|
-
message: string;
|
|
243
|
-
};
|
|
244
|
-
/**
|
|
245
|
-
* The SIWE authentication step for a Modal
|
|
246
|
-
*
|
|
247
|
-
* **Input**: SIWE message parameters
|
|
248
|
-
* **Output**: SIWE result (message signed and wallet signature)
|
|
249
|
-
*
|
|
250
|
-
* @group Modal Display
|
|
251
|
-
*/
|
|
252
|
-
type SiweAuthenticateModalStepType = GenericModalStepType<"siweAuthenticate", {
|
|
253
|
-
siwe: SiweAuthenticationParams;
|
|
254
|
-
}, SiweAuthenticateReturnType>;
|
|
255
|
-
|
|
256
|
-
/**
|
|
257
|
-
* Generic format representing a tx to be sent
|
|
258
|
-
*/
|
|
259
|
-
type SendTransactionTxType = {
|
|
260
|
-
to: Address;
|
|
261
|
-
data?: Hex;
|
|
262
|
-
value?: Hex;
|
|
263
|
-
};
|
|
264
|
-
/**
|
|
265
|
-
* Return type of the send transaction rpc request
|
|
266
|
-
* @inline
|
|
267
|
-
*/
|
|
268
|
-
type SendTransactionReturnType = {
|
|
269
|
-
hash: Hex;
|
|
270
|
-
};
|
|
271
|
-
/**
|
|
272
|
-
* The send transaction step for a Modal
|
|
273
|
-
*
|
|
274
|
-
* **Input**: Either a single tx or an array of tx to be sent
|
|
275
|
-
* **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)
|
|
276
|
-
*
|
|
277
|
-
* @group Modal Display
|
|
278
|
-
*/
|
|
279
|
-
type SendTransactionModalStepType = GenericModalStepType<"sendTransaction", {
|
|
280
|
-
tx: SendTransactionTxType | SendTransactionTxType[];
|
|
281
|
-
}, SendTransactionReturnType>;
|
|
282
|
-
|
|
283
|
-
/**
|
|
284
|
-
* Return type of the open session modal step
|
|
285
|
-
* @inline
|
|
286
|
-
* @ignore
|
|
287
|
-
*/
|
|
288
|
-
type OpenInteractionSessionReturnType = {
|
|
289
|
-
startTimestamp: number;
|
|
290
|
-
endTimestamp: number;
|
|
291
|
-
};
|
|
292
|
-
/**
|
|
293
|
-
* The open interaction session step for a Modal
|
|
294
|
-
*
|
|
295
|
-
* **Input**: None
|
|
296
|
-
* **Output**: The interactions session period (start and end timestamp)
|
|
297
|
-
*
|
|
298
|
-
* @group Modal Display
|
|
299
|
-
*/
|
|
300
|
-
type OpenInteractionSessionModalStepType = GenericModalStepType<"openSession", object, OpenInteractionSessionReturnType>;
|
|
301
|
-
|
|
302
|
-
/**
|
|
303
|
-
* The final modal step type, could be used to display sharing options or a success reward screen.
|
|
304
|
-
*
|
|
305
|
-
* **Input**: What type final step to display?
|
|
306
|
-
* **Output**: None
|
|
307
|
-
*
|
|
308
|
-
* @group Modal Display
|
|
309
|
-
*/
|
|
310
|
-
type FinalModalStepType = GenericModalStepType<"final", {
|
|
311
|
-
dismissedMetadata?: ModalStepMetadata["metadata"];
|
|
312
|
-
action: FinalActionType;
|
|
313
|
-
autoSkip?: boolean;
|
|
314
|
-
}, object>;
|
|
315
|
-
/**
|
|
316
|
-
* The different types of final actions we can display in the final step
|
|
317
|
-
* @group Modal Display
|
|
318
|
-
*/
|
|
319
|
-
type FinalActionType = {
|
|
320
|
-
key: "sharing";
|
|
321
|
-
options?: {
|
|
322
|
-
popupTitle?: string;
|
|
323
|
-
text?: string;
|
|
324
|
-
link?: string;
|
|
325
|
-
};
|
|
326
|
-
} | {
|
|
327
|
-
key: "reward";
|
|
328
|
-
options?: never;
|
|
329
|
-
};
|
|
330
|
-
|
|
331
|
-
/**
|
|
332
|
-
* Generic type of steps we will display in the modal to the end user
|
|
333
|
-
* @group Modal Display
|
|
334
|
-
*/
|
|
335
|
-
type ModalStepTypes = LoginModalStepType | SiweAuthenticateModalStepType | SendTransactionModalStepType | OpenInteractionSessionModalStepType | FinalModalStepType;
|
|
336
|
-
/**
|
|
337
|
-
* Type for the result of a modal request
|
|
338
|
-
* Just the `returns` type of each `ModalStepTypes`
|
|
339
|
-
* @typeParam T - The list of modal steps we expect to have in the modal
|
|
340
|
-
* @group Modal Display
|
|
341
|
-
* @group RPC Schema
|
|
342
|
-
*/
|
|
343
|
-
type ModalRpcStepsResultType<T extends ModalStepTypes[] = ModalStepTypes[]> = {
|
|
344
|
-
[K in T[number]["key"]]: Extract<T[number], {
|
|
345
|
-
key: K;
|
|
346
|
-
}>["returns"];
|
|
347
|
-
};
|
|
348
|
-
/**
|
|
349
|
-
* Type for the RPC input of a modal
|
|
350
|
-
* Just the `params` type of each `ModalStepTypes`
|
|
351
|
-
* @typeParam T - The list of modal steps we expect to have in the modal
|
|
352
|
-
* @group Modal Display
|
|
353
|
-
* @group RPC Schema
|
|
354
|
-
*/
|
|
355
|
-
type ModalRpcStepsInput<T extends ModalStepTypes[] = ModalStepTypes[]> = {
|
|
356
|
-
[K in T[number]["key"]]?: Extract<T[number], {
|
|
357
|
-
key: K;
|
|
358
|
-
}>["params"];
|
|
359
|
-
};
|
|
360
|
-
/**
|
|
361
|
-
* RPC metadata for the modal, used on top level modal configuration
|
|
362
|
-
* @group Modal Display
|
|
363
|
-
* @group RPC Schema
|
|
364
|
-
*/
|
|
365
|
-
type ModalRpcMetadata = {
|
|
366
|
-
header?: {
|
|
367
|
-
title?: string;
|
|
368
|
-
icon?: string;
|
|
369
|
-
};
|
|
370
|
-
context?: string;
|
|
371
|
-
lang?: "en" | "fr";
|
|
372
|
-
targetInteraction?: FullInteractionTypesKey;
|
|
373
|
-
} & ({
|
|
374
|
-
isDismissible: true;
|
|
375
|
-
dismissActionTxt?: string;
|
|
376
|
-
} | {
|
|
377
|
-
isDismissible?: false;
|
|
378
|
-
dismissActionTxt?: never;
|
|
379
|
-
});
|
|
380
|
-
/**
|
|
381
|
-
* Params used to display a modal
|
|
382
|
-
* @typeParam T - The list of modal steps we expect to have in the modal
|
|
383
|
-
* @group Modal Display
|
|
384
|
-
*/
|
|
385
|
-
type DisplayModalParamsType<T extends ModalStepTypes[]> = {
|
|
386
|
-
steps: ModalRpcStepsInput<T>;
|
|
387
|
-
metadata?: ModalRpcMetadata;
|
|
388
|
-
};
|
|
389
|
-
|
|
390
|
-
/**
|
|
391
|
-
* The different type of action we can have on the embeded view (once the user is logged in)
|
|
392
|
-
*
|
|
393
|
-
* @group Embeded wallet
|
|
394
|
-
*/
|
|
395
|
-
type EmbededViewAction = {
|
|
396
|
-
key: "sharing";
|
|
397
|
-
/**
|
|
398
|
-
* Some sharing options
|
|
399
|
-
*/
|
|
400
|
-
options?: {
|
|
401
|
-
/**
|
|
402
|
-
* The title that will be displayed on the system popup once the system sharing window is open
|
|
403
|
-
*/
|
|
404
|
-
popupTitle?: string;
|
|
405
|
-
/**
|
|
406
|
-
* The text that will be shared alongside the link.
|
|
407
|
-
* Can contain the variable {LINK} to specify where the link is placed, otherwise it will be added at the end
|
|
408
|
-
*/
|
|
409
|
-
text?: string;
|
|
410
|
-
/**
|
|
411
|
-
* The link to be shared (will be suffixed with the Frak sharing context)
|
|
412
|
-
*/
|
|
413
|
-
link?: string;
|
|
414
|
-
};
|
|
415
|
-
};
|
|
416
|
-
/**
|
|
417
|
-
* Some configuration options for the embeded view
|
|
418
|
-
*
|
|
419
|
-
* @group Embeded wallet
|
|
420
|
-
*/
|
|
421
|
-
type LoggedInEmbededView = {
|
|
422
|
-
/**
|
|
423
|
-
* The main action to display on the logged in embeded view
|
|
424
|
-
* If none specified, the user will see his wallet with the activation button
|
|
425
|
-
*/
|
|
426
|
-
action?: EmbededViewAction;
|
|
427
|
-
};
|
|
428
|
-
|
|
429
|
-
/**
|
|
430
|
-
* The view when a user is logged out
|
|
431
|
-
* @group Embeded wallet
|
|
432
|
-
*/
|
|
433
|
-
type LoggedOutEmbededView = {
|
|
434
|
-
/**
|
|
435
|
-
* Metadata option when displaying the embeded view
|
|
436
|
-
*/
|
|
437
|
-
metadata?: {
|
|
438
|
-
/**
|
|
439
|
-
* The main CTA for the logged out view
|
|
440
|
-
* - can include some variable, available ones are:
|
|
441
|
-
* - {REWARD} -> The maximum reward a user can receive when itneracting on your website
|
|
442
|
-
* - can be formatted in markdown
|
|
443
|
-
*
|
|
444
|
-
* If not sert, it will default to a internalised message
|
|
445
|
-
*/
|
|
446
|
-
text?: string;
|
|
447
|
-
/**
|
|
448
|
-
* The text that will be displayed on the login button
|
|
449
|
-
*
|
|
450
|
-
* If not set, it will default to a internalised message
|
|
451
|
-
*/
|
|
452
|
-
buttonText?: string;
|
|
453
|
-
};
|
|
454
|
-
};
|
|
455
|
-
|
|
456
|
-
/**
|
|
457
|
-
* The params used to display the embeded wallet
|
|
458
|
-
*
|
|
459
|
-
* @group Embeded wallet
|
|
460
|
-
*/
|
|
461
|
-
type DisplayEmbededWalletParamsType = {
|
|
462
|
-
/**
|
|
463
|
-
* The embeded view to display once the user is logged in
|
|
464
|
-
*/
|
|
465
|
-
loggedIn?: LoggedInEmbededView;
|
|
466
|
-
/**
|
|
467
|
-
* The embeded view to display once the user is logged out
|
|
468
|
-
*/
|
|
469
|
-
loggedOut?: LoggedOutEmbededView;
|
|
470
|
-
/**
|
|
471
|
-
* Some metadata to customise the embeded view
|
|
472
|
-
*/
|
|
473
|
-
metadata?: {
|
|
474
|
-
/**
|
|
475
|
-
* Language of the embeded wallet
|
|
476
|
-
* If undefined, will default to the browser language
|
|
477
|
-
*/
|
|
478
|
-
lang?: "fr" | "en";
|
|
479
|
-
/**
|
|
480
|
-
* The logo to display on the embeded wallet
|
|
481
|
-
* If undefined, will default to no logo displayed
|
|
482
|
-
*/
|
|
483
|
-
logo?: string;
|
|
484
|
-
/**
|
|
485
|
-
* Link to the homepage of the calling website
|
|
486
|
-
* If unedfined, will default to the domain of the calling website
|
|
487
|
-
*/
|
|
488
|
-
homepageLink?: string;
|
|
489
|
-
/**
|
|
490
|
-
* The target interaction behind this modal
|
|
491
|
-
*/
|
|
492
|
-
targetInteraction?: FullInteractionTypesKey;
|
|
493
|
-
/**
|
|
494
|
-
* The position of the component
|
|
495
|
-
*/
|
|
496
|
-
position?: "left" | "right";
|
|
497
|
-
};
|
|
498
|
-
};
|
|
499
|
-
|
|
500
|
-
/**
|
|
501
|
-
* The keys for each product types
|
|
502
|
-
* @inline
|
|
503
|
-
*/
|
|
504
|
-
type ProductTypesKey = keyof typeof productTypes;
|
|
505
|
-
/**
|
|
506
|
-
* List of the product types per denominator
|
|
507
|
-
*/
|
|
508
|
-
declare const productTypes: {
|
|
509
|
-
dapp: number;
|
|
510
|
-
press: number;
|
|
511
|
-
webshop: number;
|
|
512
|
-
retail: number;
|
|
513
|
-
referral: number;
|
|
514
|
-
purchase: number;
|
|
515
|
-
};
|
|
516
|
-
/**
|
|
517
|
-
* Bitmask for each product types
|
|
518
|
-
*/
|
|
519
|
-
declare const productTypesMask: Record<ProductTypesKey, bigint>;
|
|
520
|
-
|
|
521
|
-
/**
|
|
522
|
-
* Response of the `frak_getProductInformation` RPC method
|
|
523
|
-
* @group RPC Schema
|
|
524
|
-
*/
|
|
525
|
-
type GetProductInformationReturnType = {
|
|
526
|
-
/**
|
|
527
|
-
* Current product id
|
|
528
|
-
*/
|
|
529
|
-
id: Hex;
|
|
530
|
-
/**
|
|
531
|
-
* Some metadata
|
|
532
|
-
*/
|
|
533
|
-
onChainMetadata: {
|
|
534
|
-
/**
|
|
535
|
-
* Name of the product on-chain
|
|
536
|
-
*/
|
|
537
|
-
name: string;
|
|
538
|
-
/**
|
|
539
|
-
* Domain of the product on-chain
|
|
540
|
-
*/
|
|
541
|
-
domain: string;
|
|
542
|
-
/**
|
|
543
|
-
* The supported product types
|
|
544
|
-
*/
|
|
545
|
-
productTypes: ProductTypesKey[];
|
|
546
|
-
};
|
|
547
|
-
/**
|
|
548
|
-
* The max potential reward in EUR for the given product
|
|
549
|
-
*/
|
|
550
|
-
estimatedEurReward?: string;
|
|
551
|
-
/**
|
|
552
|
-
* List of all the potentials reward arround this product
|
|
553
|
-
*/
|
|
554
|
-
rewards: {
|
|
555
|
-
token: Address;
|
|
556
|
-
campaign: Address;
|
|
557
|
-
interactionTypeKey: FullInteractionTypesKey;
|
|
558
|
-
referrer: {
|
|
559
|
-
amount: number;
|
|
560
|
-
eurAmount: number;
|
|
561
|
-
usdAmount: number;
|
|
562
|
-
};
|
|
563
|
-
referee: {
|
|
564
|
-
amount: number;
|
|
565
|
-
eurAmount: number;
|
|
566
|
-
usdAmount: number;
|
|
567
|
-
};
|
|
568
|
-
}[];
|
|
569
|
-
};
|
|
570
|
-
|
|
571
|
-
/**
|
|
572
|
-
* RPC Response for the method `frak_listenToWalletStatus`
|
|
573
|
-
* @group RPC Schema
|
|
574
|
-
*/
|
|
575
|
-
type WalletStatusReturnType = WalletConnected | WalletNotConnected;
|
|
576
|
-
/**
|
|
577
|
-
* @ignore
|
|
578
|
-
* @inline
|
|
579
|
-
*/
|
|
580
|
-
type WalletConnected = {
|
|
581
|
-
key: "connected";
|
|
582
|
-
wallet: Address;
|
|
583
|
-
interactionToken?: string;
|
|
584
|
-
interactionSession?: {
|
|
585
|
-
startTimestamp: number;
|
|
586
|
-
endTimestamp: number;
|
|
587
|
-
};
|
|
588
|
-
};
|
|
589
|
-
/**
|
|
590
|
-
* @ignore
|
|
591
|
-
* @inline
|
|
592
|
-
*/
|
|
593
|
-
type WalletNotConnected = {
|
|
594
|
-
key: "not-connected";
|
|
595
|
-
wallet?: never;
|
|
596
|
-
interactionToken?: never;
|
|
597
|
-
interactionSession?: never;
|
|
598
|
-
};
|
|
599
|
-
|
|
600
|
-
/**
|
|
601
|
-
* RPC interface that's used for the iframe communication
|
|
602
|
-
*
|
|
603
|
-
* Define all the methods available within the iFrame RPC client
|
|
604
|
-
*
|
|
605
|
-
* @group RPC Schema
|
|
606
|
-
*
|
|
607
|
-
* @remarks
|
|
608
|
-
* Here is the list of methods available:
|
|
609
|
-
*
|
|
610
|
-
* ### frak_listenToWalletStatus
|
|
611
|
-
* - Params: None
|
|
612
|
-
* - Returns: {@link WalletStatusReturnType}
|
|
613
|
-
*
|
|
614
|
-
* ### frak_displayModal
|
|
615
|
-
* - Params: [{@link ModalRpcStepsInput}, name: string, metadata?: {@link ModalRpcMetadata}]
|
|
616
|
-
* - Returns: {@link ModalRpcStepsResultType}
|
|
617
|
-
*
|
|
618
|
-
* ### frak_sendInteraction
|
|
619
|
-
* - Params: [productId: Hex, interaction: {@link PreparedInteraction}, signature?: Hex]
|
|
620
|
-
* - Returns: {@link SendInteractionReturnType}
|
|
621
|
-
*
|
|
622
|
-
* ### frak_sso
|
|
623
|
-
* - Params [params: {@link OpenSsoParamsType}, name: string, customCss?: string]
|
|
624
|
-
* - Returns: undefined
|
|
625
|
-
*
|
|
626
|
-
* ### frak_getProductInformation
|
|
627
|
-
* - Params: None
|
|
628
|
-
* - Returns: {@link GetProductInformationReturnType}
|
|
629
|
-
*
|
|
630
|
-
* ### frak_displayEmbededWallet
|
|
631
|
-
* - Params: [{@link DisplayEmbededWalletParamsType}]
|
|
632
|
-
* - Returns: undefined
|
|
633
|
-
*/
|
|
634
|
-
type IFrameRpcSchema = [
|
|
635
|
-
/**
|
|
636
|
-
* Method used to listen to the wallet status
|
|
637
|
-
*/
|
|
638
|
-
{
|
|
639
|
-
Method: "frak_listenToWalletStatus";
|
|
640
|
-
Parameters?: undefined;
|
|
641
|
-
ReturnType: WalletStatusReturnType;
|
|
642
|
-
},
|
|
643
|
-
/**
|
|
644
|
-
* Method to display a modal with the provided steps
|
|
645
|
-
*/
|
|
646
|
-
{
|
|
647
|
-
Method: "frak_displayModal";
|
|
648
|
-
Parameters: [
|
|
649
|
-
requests: ModalRpcStepsInput,
|
|
650
|
-
name: string,
|
|
651
|
-
metadata?: ModalRpcMetadata
|
|
652
|
-
];
|
|
653
|
-
ReturnType: ModalRpcStepsResultType;
|
|
654
|
-
},
|
|
655
|
-
/**
|
|
656
|
-
* Method to transmit a user interaction
|
|
657
|
-
*/
|
|
658
|
-
{
|
|
659
|
-
Method: "frak_sendInteraction";
|
|
660
|
-
Parameters: [
|
|
661
|
-
productId: Hex,
|
|
662
|
-
interaction: PreparedInteraction,
|
|
663
|
-
signature?: Hex
|
|
664
|
-
];
|
|
665
|
-
ReturnType: SendInteractionReturnType;
|
|
666
|
-
},
|
|
667
|
-
/**
|
|
668
|
-
* Method to start a SSO
|
|
669
|
-
* todo: Should also support direct tracking via a consumeKey
|
|
670
|
-
*/
|
|
671
|
-
{
|
|
672
|
-
Method: "frak_sso";
|
|
673
|
-
Parameters: [
|
|
674
|
-
params: OpenSsoParamsType,
|
|
675
|
-
name: string,
|
|
676
|
-
customCss?: string
|
|
677
|
-
];
|
|
678
|
-
ReturnType: undefined;
|
|
679
|
-
},
|
|
680
|
-
/**
|
|
681
|
-
* Method to get current product information's
|
|
682
|
-
* - Is product minted?
|
|
683
|
-
* - Does it have running campaign?
|
|
684
|
-
* - Estimated reward on actions
|
|
685
|
-
*/
|
|
686
|
-
{
|
|
687
|
-
Method: "frak_getProductInformation";
|
|
688
|
-
Parameters?: undefined;
|
|
689
|
-
ReturnType: GetProductInformationReturnType;
|
|
690
|
-
},
|
|
691
|
-
/**
|
|
692
|
-
* Method to show the embeded wallet, with potential customisation
|
|
693
|
-
*/
|
|
694
|
-
{
|
|
695
|
-
Method: "frak_displayEmbededWallet";
|
|
696
|
-
Parameters: [DisplayEmbededWalletParamsType, name: string];
|
|
697
|
-
ReturnType: undefined;
|
|
698
|
-
}
|
|
699
|
-
];
|
|
700
|
-
|
|
701
|
-
/**
|
|
702
|
-
* Type that extract the possible parameters from a RPC Schema
|
|
703
|
-
* @ignore
|
|
704
|
-
*/
|
|
705
|
-
type ExtractedParametersFromRpc<TRpcSchema extends RpcSchema> = {
|
|
706
|
-
[K in keyof TRpcSchema]: Prettify<{
|
|
707
|
-
method: TRpcSchema[K] extends TRpcSchema[number] ? TRpcSchema[K]["Method"] : string;
|
|
708
|
-
} & (TRpcSchema[K] extends TRpcSchema[number] ? TRpcSchema[K]["Parameters"] extends undefined ? {
|
|
709
|
-
params?: never;
|
|
710
|
-
} : {
|
|
711
|
-
params: TRpcSchema[K]["Parameters"];
|
|
712
|
-
} : never)>;
|
|
713
|
-
}[number];
|
|
714
|
-
/**
|
|
715
|
-
* Type that extract the possible return type from a RPC Schema
|
|
716
|
-
* @ignore
|
|
717
|
-
*/
|
|
718
|
-
type ExtractedReturnTypeFromRpc<TRpcSchema extends RpcSchema, TParameters extends ExtractedParametersFromRpc<TRpcSchema> = ExtractedParametersFromRpc<TRpcSchema>> = ExtractedMethodFromRpc<TRpcSchema, TParameters["method"]>["ReturnType"];
|
|
719
|
-
/**
|
|
720
|
-
* Type that extract the possible return type from a RPC Schema
|
|
721
|
-
* @ignore
|
|
722
|
-
*/
|
|
723
|
-
type ExtractedMethodFromRpc<TRpcSchema extends RpcSchema, TMethod extends ExtractedParametersFromRpc<TRpcSchema>["method"] = ExtractedParametersFromRpc<TRpcSchema>["method"]> = Extract<TRpcSchema[number], {
|
|
724
|
-
Method: TMethod;
|
|
725
|
-
}>;
|
|
726
|
-
/**
|
|
727
|
-
* Raw response that we will receive after an rpc request
|
|
728
|
-
* @ignore
|
|
729
|
-
*/
|
|
730
|
-
type RpcResponse<TRpcSchema extends RpcSchema, TMethod extends TRpcSchema[number]["Method"] = TRpcSchema[number]["Method"]> = {
|
|
731
|
-
result: Extract<TRpcSchema[number], {
|
|
732
|
-
Method: TMethod;
|
|
733
|
-
}>["ReturnType"];
|
|
734
|
-
error?: never;
|
|
735
|
-
} | {
|
|
736
|
-
result?: never;
|
|
737
|
-
error: {
|
|
738
|
-
code: number;
|
|
739
|
-
message: string;
|
|
740
|
-
data?: unknown;
|
|
741
|
-
};
|
|
742
|
-
};
|
|
743
|
-
/**
|
|
744
|
-
* Type used for a one shot request function
|
|
745
|
-
* @inline
|
|
746
|
-
*/
|
|
747
|
-
type RequestFn<TRpcSchema extends RpcSchema> = <TParameters extends ExtractedParametersFromRpc<TRpcSchema> = ExtractedParametersFromRpc<TRpcSchema>, _ReturnType = ExtractedReturnTypeFromRpc<TRpcSchema, TParameters>>(args: TParameters) => Promise<_ReturnType>;
|
|
748
|
-
/**
|
|
749
|
-
* Type used for a listening request
|
|
750
|
-
* @inline
|
|
751
|
-
*/
|
|
752
|
-
type ListenerRequestFn<TRpcSchema extends RpcSchema> = <TParameters extends ExtractedParametersFromRpc<TRpcSchema> = ExtractedParametersFromRpc<TRpcSchema>, _ReturnType = ExtractedReturnTypeFromRpc<TRpcSchema, TParameters>>(args: TParameters, callback: (result: _ReturnType) => void) => Promise<void>;
|
|
753
|
-
/**
|
|
754
|
-
* IFrame transport interface
|
|
755
|
-
*/
|
|
756
|
-
type IFrameTransport = {
|
|
757
|
-
/**
|
|
758
|
-
* Wait for the connection to be established
|
|
759
|
-
*/
|
|
760
|
-
waitForConnection: Promise<boolean>;
|
|
761
|
-
/**
|
|
762
|
-
* Wait for the setup to be done
|
|
763
|
-
*/
|
|
764
|
-
waitForSetup: Promise<void>;
|
|
765
|
-
/**
|
|
766
|
-
* Function used to perform a single request via the iframe transport
|
|
767
|
-
*/
|
|
768
|
-
request: RequestFn<IFrameRpcSchema>;
|
|
769
|
-
/**
|
|
770
|
-
* Function used to listen to a request response via the iframe transport
|
|
771
|
-
*/
|
|
772
|
-
listenerRequest: ListenerRequestFn<IFrameRpcSchema>;
|
|
773
|
-
/**
|
|
774
|
-
* Function used to destroy the iframe transport
|
|
775
|
-
*/
|
|
776
|
-
destroy: () => Promise<void>;
|
|
777
|
-
};
|
|
778
|
-
/**
|
|
779
|
-
* Represent an iframe event
|
|
780
|
-
*/
|
|
781
|
-
type IFrameEvent = IFrameRpcEvent | IFrameLifecycleEvent | ClientLifecycleEvent;
|
|
782
|
-
/**
|
|
783
|
-
* Represent an iframe rpc event
|
|
784
|
-
*/
|
|
785
|
-
type IFrameRpcEvent = {
|
|
786
|
-
id: string;
|
|
787
|
-
topic: ExtractedParametersFromRpc<IFrameRpcSchema>["method"];
|
|
788
|
-
data: {
|
|
789
|
-
compressed: string;
|
|
790
|
-
compressedHash: string;
|
|
791
|
-
};
|
|
792
|
-
};
|
|
793
|
-
|
|
794
|
-
/**
|
|
795
|
-
* Representing a Frak client, used to interact with the Frak Wallet
|
|
796
|
-
*/
|
|
797
|
-
type FrakClient = {
|
|
798
|
-
config: FrakWalletSdkConfig;
|
|
799
|
-
debugInfo: {
|
|
800
|
-
formatDebugInfo: (error: Error | unknown | string) => string;
|
|
801
|
-
};
|
|
802
|
-
} & IFrameTransport;
|
|
803
|
-
|
|
804
|
-
/**
|
|
805
|
-
* The current Frak Context
|
|
806
|
-
*
|
|
807
|
-
* For now, only contain a referrer address.
|
|
808
|
-
*/
|
|
809
|
-
type FrakContext = {
|
|
810
|
-
r: Address;
|
|
811
|
-
};
|
|
812
|
-
|
|
813
|
-
export { type IFrameRpcEvent as A, type IFrameLifecycleEvent as B, type ClientLifecycleEvent as C, type DisplayEmbededWalletParamsType as D, type EmbededViewAction as E, type FrakWalletSdkConfig as F, type GetProductInformationReturnType as G, type ExtractedParametersFromRpc as H, type IFrameEvent as I, type ExtractedReturnTypeFromRpc as J, type LoggedOutEmbededView as L, type ModalStepTypes as M, type OpenSsoParamsType as O, type ProductTypesKey as P, type RpcResponse as R, type SsoMetadata as S, type WalletStatusReturnType as W, type FrakClient as a, type FrakContext as b, productTypesMask as c, type InteractionTypesKey as d, type FullInteractionTypesKey as e, type IFrameRpcSchema as f, type LoggedInEmbededView as g, type ModalRpcMetadata as h, interactionTypes as i, type DisplayModalParamsType as j, type ModalRpcStepsInput as k, type ModalRpcStepsResultType as l, type ModalStepMetadata as m, type LoginModalStepType as n, type SiweAuthenticateModalStepType as o, productTypes as p, type SiweAuthenticationParams as q, type SiweAuthenticateReturnType as r, type SendTransactionTxType as s, type SendTransactionModalStepType as t, type SendTransactionReturnType as u, type OpenInteractionSessionReturnType as v, type OpenInteractionSessionModalStepType as w, type FinalModalStepType as x, type FinalActionType as y, type IFrameTransport as z };
|