@frak-labs/core-sdk 0.0.2
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/LICENSE +674 -0
- package/README.md +8 -0
- package/cdn/bundle.js +21 -0
- package/dist/actions/index.cjs +352 -0
- package/dist/actions/index.d.cts +503 -0
- package/dist/actions/index.d.ts +503 -0
- package/dist/actions/index.js +352 -0
- package/dist/chunk-K5SAPMC2.js +842 -0
- package/dist/chunk-NJJQPEEL.cjs +842 -0
- package/dist/chunk-PR3T7O5I.cjs +79 -0
- package/dist/chunk-QZL2KCSB.js +79 -0
- package/dist/chunk-RAPLRHQ4.cjs +140 -0
- package/dist/chunk-VAINYZSV.js +140 -0
- package/dist/context-B0trlYGx.d.ts +626 -0
- package/dist/context-GkNATUkF.d.cts +626 -0
- package/dist/index.cjs +326 -0
- package/dist/index.d.cts +269 -0
- package/dist/index.d.ts +269 -0
- package/dist/index.js +326 -0
- package/dist/interaction-CTQ5-kqe.d.cts +43 -0
- package/dist/interaction-CTQ5-kqe.d.ts +43 -0
- package/dist/interactions/index.cjs +13 -0
- package/dist/interactions/index.d.cts +140 -0
- package/dist/interactions/index.d.ts +140 -0
- package/dist/interactions/index.js +13 -0
- package/package.json +95 -0
|
@@ -0,0 +1,626 @@
|
|
|
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" | "heartbeat" | "show" | "hide";
|
|
41
|
+
data?: never;
|
|
42
|
+
} | DoBackupEvent | RemoveBackupEvent;
|
|
43
|
+
type DoBackupEvent = {
|
|
44
|
+
iframeLifecycle: "do-backup";
|
|
45
|
+
data: {
|
|
46
|
+
backup?: string;
|
|
47
|
+
};
|
|
48
|
+
};
|
|
49
|
+
type RemoveBackupEvent = {
|
|
50
|
+
iframeLifecycle: "remove-backup";
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Event related to the iframe lifecycle
|
|
55
|
+
* @ignore
|
|
56
|
+
*/
|
|
57
|
+
type ClientLifecycleEvent = CustomCssEvent | RestoreBackupEvent;
|
|
58
|
+
type CustomCssEvent = {
|
|
59
|
+
clientLifecycle: "modal-css";
|
|
60
|
+
data: {
|
|
61
|
+
cssLink: string;
|
|
62
|
+
};
|
|
63
|
+
};
|
|
64
|
+
type RestoreBackupEvent = {
|
|
65
|
+
clientLifecycle: "restore-backup";
|
|
66
|
+
data: {
|
|
67
|
+
backup: string;
|
|
68
|
+
};
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* SSO Metadata
|
|
73
|
+
*/
|
|
74
|
+
type SsoMetadata = {
|
|
75
|
+
/**
|
|
76
|
+
* URL to your client, if provided will be displayed in the SSO header
|
|
77
|
+
*/
|
|
78
|
+
logoUrl?: string;
|
|
79
|
+
/**
|
|
80
|
+
* Link to your homepage, if referenced your app name will contain a link on the sso page
|
|
81
|
+
*/
|
|
82
|
+
homepageLink?: string;
|
|
83
|
+
/**
|
|
84
|
+
* A few links that will be displayed in the footer
|
|
85
|
+
*/
|
|
86
|
+
links?: {
|
|
87
|
+
/**
|
|
88
|
+
* URL to your confidentiality page
|
|
89
|
+
*/
|
|
90
|
+
confidentialityLink?: string;
|
|
91
|
+
/**
|
|
92
|
+
* URL to your help page
|
|
93
|
+
*/
|
|
94
|
+
helpLink?: string;
|
|
95
|
+
/**
|
|
96
|
+
* URL to your CGU page
|
|
97
|
+
*/
|
|
98
|
+
cguLink?: string;
|
|
99
|
+
};
|
|
100
|
+
};
|
|
101
|
+
/**
|
|
102
|
+
* Params to start a SSO
|
|
103
|
+
* @group RPC Schema
|
|
104
|
+
*/
|
|
105
|
+
type OpenSsoParamsType = {
|
|
106
|
+
/**
|
|
107
|
+
* Redirect URL after the SSO (optional)
|
|
108
|
+
*/
|
|
109
|
+
redirectUrl?: string;
|
|
110
|
+
/**
|
|
111
|
+
* If the SSO should directly exit after completion
|
|
112
|
+
* @defaultValue true
|
|
113
|
+
*/
|
|
114
|
+
directExit?: boolean;
|
|
115
|
+
/**
|
|
116
|
+
* Language of the SSO page (optional)
|
|
117
|
+
* It will default to the current user language (or "en" if unsupported language)
|
|
118
|
+
*/
|
|
119
|
+
lang?: "en" | "fr";
|
|
120
|
+
/**
|
|
121
|
+
* Custom SSO metadata
|
|
122
|
+
*/
|
|
123
|
+
metadata: SsoMetadata;
|
|
124
|
+
};
|
|
125
|
+
|
|
126
|
+
/**
|
|
127
|
+
* Represent a generic modal step type
|
|
128
|
+
* @ignore
|
|
129
|
+
* @inline
|
|
130
|
+
*/
|
|
131
|
+
type GenericModalStepType<TKey, TParams, TReturns> = {
|
|
132
|
+
key: TKey;
|
|
133
|
+
params: TParams extends never ? ModalStepMetadata : ModalStepMetadata & TParams;
|
|
134
|
+
returns: TReturns;
|
|
135
|
+
};
|
|
136
|
+
/**
|
|
137
|
+
* Metadata that can be used to customise a modal step
|
|
138
|
+
* @group Modal Display
|
|
139
|
+
*/
|
|
140
|
+
type ModalStepMetadata = {
|
|
141
|
+
metadata?: {
|
|
142
|
+
/**
|
|
143
|
+
* Custom title for the step
|
|
144
|
+
* If none provided, it will use an internationalised text
|
|
145
|
+
*/
|
|
146
|
+
title?: string;
|
|
147
|
+
/**
|
|
148
|
+
* Custom description for the step
|
|
149
|
+
* If none provided, it will use an internationalised text
|
|
150
|
+
*/
|
|
151
|
+
description?: string;
|
|
152
|
+
/**
|
|
153
|
+
* Custom text for the primary action of the step
|
|
154
|
+
* If none provided, it will use an internationalised text
|
|
155
|
+
*/
|
|
156
|
+
primaryActionText?: string;
|
|
157
|
+
/**
|
|
158
|
+
* Custom text for the secondary action of the step
|
|
159
|
+
* If none provided, it will use an internationalised text
|
|
160
|
+
*/
|
|
161
|
+
secondaryActionText?: string;
|
|
162
|
+
};
|
|
163
|
+
};
|
|
164
|
+
|
|
165
|
+
/** @inline */
|
|
166
|
+
type LoginWithSso = {
|
|
167
|
+
allowSso: true;
|
|
168
|
+
ssoMetadata: SsoMetadata;
|
|
169
|
+
};
|
|
170
|
+
/** @inline */
|
|
171
|
+
type LoginWithoutSso = {
|
|
172
|
+
allowSso?: false;
|
|
173
|
+
ssoMetadata?: never;
|
|
174
|
+
};
|
|
175
|
+
/**
|
|
176
|
+
* The login step for a Modal
|
|
177
|
+
*
|
|
178
|
+
* **Input**: Do we allow SSO or not? Is yes then the SSO metadata
|
|
179
|
+
* **Output**: The logged in wallet address
|
|
180
|
+
*
|
|
181
|
+
* @group Modal Display
|
|
182
|
+
*/
|
|
183
|
+
type LoginModalStepType = GenericModalStepType<"login", LoginWithSso | LoginWithoutSso, {
|
|
184
|
+
wallet: Address;
|
|
185
|
+
}>;
|
|
186
|
+
|
|
187
|
+
/**
|
|
188
|
+
* Parameters used send a SIWE rpc request
|
|
189
|
+
*/
|
|
190
|
+
type SiweAuthenticationParams = Omit<SiweMessage, "address" | "chainId" | "expirationTime" | "issuedAt" | "notBefore"> & {
|
|
191
|
+
expirationTimeTimestamp?: number;
|
|
192
|
+
notBeforeTimestamp?: number;
|
|
193
|
+
};
|
|
194
|
+
/**
|
|
195
|
+
* Return type of the Siwe transaction rpc request
|
|
196
|
+
* @inline
|
|
197
|
+
*/
|
|
198
|
+
type SiweAuthenticateReturnType = {
|
|
199
|
+
signature: Hex;
|
|
200
|
+
message: string;
|
|
201
|
+
};
|
|
202
|
+
/**
|
|
203
|
+
* The SIWE authentication step for a Modal
|
|
204
|
+
*
|
|
205
|
+
* **Input**: SIWE message parameters
|
|
206
|
+
* **Output**: SIWE result (message signed and wallet signature)
|
|
207
|
+
*
|
|
208
|
+
* @group Modal Display
|
|
209
|
+
*/
|
|
210
|
+
type SiweAuthenticateModalStepType = GenericModalStepType<"siweAuthenticate", {
|
|
211
|
+
siwe: SiweAuthenticationParams;
|
|
212
|
+
}, SiweAuthenticateReturnType>;
|
|
213
|
+
|
|
214
|
+
/**
|
|
215
|
+
* Generic format representing a tx to be sent
|
|
216
|
+
*/
|
|
217
|
+
type SendTransactionTxType = {
|
|
218
|
+
to: Address;
|
|
219
|
+
data?: Hex;
|
|
220
|
+
value?: Hex;
|
|
221
|
+
};
|
|
222
|
+
/**
|
|
223
|
+
* Return type of the send transaction rpc request
|
|
224
|
+
* @inline
|
|
225
|
+
*/
|
|
226
|
+
type SendTransactionReturnType = {
|
|
227
|
+
hash: Hex;
|
|
228
|
+
};
|
|
229
|
+
/**
|
|
230
|
+
* The send transaction step for a Modal
|
|
231
|
+
*
|
|
232
|
+
* **Input**: Either a single tx or an array of tx to be sent
|
|
233
|
+
* **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)
|
|
234
|
+
*
|
|
235
|
+
* @group Modal Display
|
|
236
|
+
*/
|
|
237
|
+
type SendTransactionModalStepType = GenericModalStepType<"sendTransaction", {
|
|
238
|
+
tx: SendTransactionTxType | SendTransactionTxType[];
|
|
239
|
+
}, SendTransactionReturnType>;
|
|
240
|
+
|
|
241
|
+
/**
|
|
242
|
+
* Return type of the open session modal step
|
|
243
|
+
* @inline
|
|
244
|
+
* @ignore
|
|
245
|
+
*/
|
|
246
|
+
type OpenInteractionSessionReturnType = {
|
|
247
|
+
startTimestamp: number;
|
|
248
|
+
endTimestamp: number;
|
|
249
|
+
};
|
|
250
|
+
/**
|
|
251
|
+
* The open interaction session step for a Modal
|
|
252
|
+
*
|
|
253
|
+
* **Input**: None
|
|
254
|
+
* **Output**: The interactions session period (start and end timestamp)
|
|
255
|
+
*
|
|
256
|
+
* @group Modal Display
|
|
257
|
+
*/
|
|
258
|
+
type OpenInteractionSessionModalStepType = GenericModalStepType<"openSession", object, OpenInteractionSessionReturnType>;
|
|
259
|
+
|
|
260
|
+
/**
|
|
261
|
+
* The final modal step type, could be used to display sharing options or a success reward screen.
|
|
262
|
+
*
|
|
263
|
+
* **Input**: What type final step to display?
|
|
264
|
+
* **Output**: None
|
|
265
|
+
*
|
|
266
|
+
* @group Modal Display
|
|
267
|
+
*/
|
|
268
|
+
type FinalModalStepType = GenericModalStepType<"final", {
|
|
269
|
+
dismissedMetadata?: ModalStepMetadata["metadata"];
|
|
270
|
+
action: FinalActionType;
|
|
271
|
+
autoSkip?: boolean;
|
|
272
|
+
}, object>;
|
|
273
|
+
/**
|
|
274
|
+
* The different types of final actions we can display in the final step
|
|
275
|
+
* @group Modal Display
|
|
276
|
+
*/
|
|
277
|
+
type FinalActionType = {
|
|
278
|
+
key: "sharing";
|
|
279
|
+
options?: {
|
|
280
|
+
popupTitle?: string;
|
|
281
|
+
text?: string;
|
|
282
|
+
link?: string;
|
|
283
|
+
};
|
|
284
|
+
} | {
|
|
285
|
+
key: "reward";
|
|
286
|
+
options?: never;
|
|
287
|
+
};
|
|
288
|
+
|
|
289
|
+
/**
|
|
290
|
+
* Generic type of steps we will display in the modal to the end user
|
|
291
|
+
* @group Modal Display
|
|
292
|
+
*/
|
|
293
|
+
type ModalStepTypes = LoginModalStepType | SiweAuthenticateModalStepType | SendTransactionModalStepType | OpenInteractionSessionModalStepType | FinalModalStepType;
|
|
294
|
+
/**
|
|
295
|
+
* Type for the result of a modal request
|
|
296
|
+
* Just the `returns` type of each `ModalStepTypes`
|
|
297
|
+
* @typeParam T - The list of modal steps we expect to have in the modal
|
|
298
|
+
* @group Modal Display
|
|
299
|
+
* @group RPC Schema
|
|
300
|
+
*/
|
|
301
|
+
type ModalRpcStepsResultType<T extends ModalStepTypes[] = ModalStepTypes[]> = {
|
|
302
|
+
[K in T[number]["key"]]: Extract<T[number], {
|
|
303
|
+
key: K;
|
|
304
|
+
}>["returns"];
|
|
305
|
+
};
|
|
306
|
+
/**
|
|
307
|
+
* Type for the RPC input of a modal
|
|
308
|
+
* Just the `params` type of each `ModalStepTypes`
|
|
309
|
+
* @typeParam T - The list of modal steps we expect to have in the modal
|
|
310
|
+
* @group Modal Display
|
|
311
|
+
* @group RPC Schema
|
|
312
|
+
*/
|
|
313
|
+
type ModalRpcStepsInput<T extends ModalStepTypes[] = ModalStepTypes[]> = {
|
|
314
|
+
[K in T[number]["key"]]?: Extract<T[number], {
|
|
315
|
+
key: K;
|
|
316
|
+
}>["params"];
|
|
317
|
+
};
|
|
318
|
+
/**
|
|
319
|
+
* RPC metadata for the modal, used on top level modal configuration
|
|
320
|
+
* @group Modal Display
|
|
321
|
+
* @group RPC Schema
|
|
322
|
+
*/
|
|
323
|
+
type ModalRpcMetadata = {
|
|
324
|
+
header?: {
|
|
325
|
+
title?: string;
|
|
326
|
+
icon?: string;
|
|
327
|
+
};
|
|
328
|
+
context?: string;
|
|
329
|
+
lang?: "en" | "fr";
|
|
330
|
+
} & ({
|
|
331
|
+
isDismissible: true;
|
|
332
|
+
dismissActionTxt?: string;
|
|
333
|
+
} | {
|
|
334
|
+
isDismissible?: false;
|
|
335
|
+
dismissActionTxt?: never;
|
|
336
|
+
});
|
|
337
|
+
/**
|
|
338
|
+
* Params used to display a modal
|
|
339
|
+
* @typeParam T - The list of modal steps we expect to have in the modal
|
|
340
|
+
* @group Modal Display
|
|
341
|
+
*/
|
|
342
|
+
type DisplayModalParamsType<T extends ModalStepTypes[]> = {
|
|
343
|
+
steps: ModalRpcStepsInput<T>;
|
|
344
|
+
metadata?: ModalRpcMetadata;
|
|
345
|
+
};
|
|
346
|
+
|
|
347
|
+
/**
|
|
348
|
+
* The keys for each product types
|
|
349
|
+
* @inline
|
|
350
|
+
*/
|
|
351
|
+
type ProductTypesKey = keyof typeof productTypes;
|
|
352
|
+
/**
|
|
353
|
+
* List of the product types per denominator
|
|
354
|
+
*/
|
|
355
|
+
declare const productTypes: {
|
|
356
|
+
dapp: number;
|
|
357
|
+
press: number;
|
|
358
|
+
webshop: number;
|
|
359
|
+
referral: number;
|
|
360
|
+
purchase: number;
|
|
361
|
+
};
|
|
362
|
+
/**
|
|
363
|
+
* Bitmask for each product types
|
|
364
|
+
*/
|
|
365
|
+
declare const productTypesMask: Record<ProductTypesKey, bigint>;
|
|
366
|
+
|
|
367
|
+
/**
|
|
368
|
+
* Response of the `frak_getProductInformation` RPC method
|
|
369
|
+
* @group RPC Schema
|
|
370
|
+
*/
|
|
371
|
+
type GetProductInformationReturnType = {
|
|
372
|
+
/**
|
|
373
|
+
* Current product id
|
|
374
|
+
*/
|
|
375
|
+
id: Hex;
|
|
376
|
+
/**
|
|
377
|
+
* Some metadata
|
|
378
|
+
*/
|
|
379
|
+
onChainMetadata: {
|
|
380
|
+
/**
|
|
381
|
+
* Name of the product on-chain
|
|
382
|
+
*/
|
|
383
|
+
name: string;
|
|
384
|
+
/**
|
|
385
|
+
* Domain of the product on-chain
|
|
386
|
+
*/
|
|
387
|
+
domain: string;
|
|
388
|
+
/**
|
|
389
|
+
* The supported product types
|
|
390
|
+
*/
|
|
391
|
+
productTypes: ProductTypesKey[];
|
|
392
|
+
};
|
|
393
|
+
/**
|
|
394
|
+
* Current the current estimated product reward
|
|
395
|
+
*/
|
|
396
|
+
estimatedEurReward?: string;
|
|
397
|
+
};
|
|
398
|
+
|
|
399
|
+
/**
|
|
400
|
+
* RPC Response for the method `frak_listenToWalletStatus`
|
|
401
|
+
* @group RPC Schema
|
|
402
|
+
*/
|
|
403
|
+
type WalletStatusReturnType = WalletConnected | WalletNotConnected;
|
|
404
|
+
/**
|
|
405
|
+
* @ignore
|
|
406
|
+
* @inline
|
|
407
|
+
*/
|
|
408
|
+
type WalletConnected = {
|
|
409
|
+
key: "connected";
|
|
410
|
+
wallet: Address;
|
|
411
|
+
interactionToken?: string;
|
|
412
|
+
interactionSession?: {
|
|
413
|
+
startTimestamp: number;
|
|
414
|
+
endTimestamp: number;
|
|
415
|
+
};
|
|
416
|
+
};
|
|
417
|
+
/**
|
|
418
|
+
* @ignore
|
|
419
|
+
* @inline
|
|
420
|
+
*/
|
|
421
|
+
type WalletNotConnected = {
|
|
422
|
+
key: "not-connected";
|
|
423
|
+
wallet?: never;
|
|
424
|
+
interactionToken?: never;
|
|
425
|
+
interactionSession?: never;
|
|
426
|
+
};
|
|
427
|
+
|
|
428
|
+
/**
|
|
429
|
+
* RPC interface that's used for the iframe communication
|
|
430
|
+
*
|
|
431
|
+
* Define all the methods available within the iFrame RPC client
|
|
432
|
+
*
|
|
433
|
+
* @group RPC Schema
|
|
434
|
+
*
|
|
435
|
+
* @remarks
|
|
436
|
+
* Here is the list of methods available:
|
|
437
|
+
*
|
|
438
|
+
* ### frak_listenToWalletStatus
|
|
439
|
+
* - Params: None
|
|
440
|
+
* - Returns: {@link WalletStatusReturnType}
|
|
441
|
+
*
|
|
442
|
+
* ### frak_displayModal
|
|
443
|
+
* - Params: [{@link ModalRpcStepsInput}, name: string, metadata?: {@link ModalRpcMetadata}]
|
|
444
|
+
* - Returns: {@link ModalRpcStepsResultType}
|
|
445
|
+
*
|
|
446
|
+
* ### frak_sendInteraction
|
|
447
|
+
* - Params: [productId: Hex, interaction: {@link PreparedInteraction}, signature?: Hex]
|
|
448
|
+
* - Returns: {@link SendInteractionReturnType}
|
|
449
|
+
*
|
|
450
|
+
* ### frak_sso
|
|
451
|
+
* - Params [params: {@link OpenSsoParamsType}, name: string, customCss?: string]
|
|
452
|
+
* - Returns: undefined
|
|
453
|
+
*
|
|
454
|
+
* ### frak_getProductInformation
|
|
455
|
+
* - Params: None
|
|
456
|
+
* - Returns: {@link GetProductInformationReturnType}
|
|
457
|
+
*/
|
|
458
|
+
type IFrameRpcSchema = [
|
|
459
|
+
/**
|
|
460
|
+
* Method used to listen to the wallet status
|
|
461
|
+
*/
|
|
462
|
+
{
|
|
463
|
+
Method: "frak_listenToWalletStatus";
|
|
464
|
+
Parameters?: undefined;
|
|
465
|
+
ReturnType: WalletStatusReturnType;
|
|
466
|
+
},
|
|
467
|
+
/**
|
|
468
|
+
* Method to transmit a user interaction
|
|
469
|
+
*/
|
|
470
|
+
{
|
|
471
|
+
Method: "frak_displayModal";
|
|
472
|
+
Parameters: [
|
|
473
|
+
requests: ModalRpcStepsInput,
|
|
474
|
+
name: string,
|
|
475
|
+
metadata?: ModalRpcMetadata
|
|
476
|
+
];
|
|
477
|
+
ReturnType: ModalRpcStepsResultType;
|
|
478
|
+
},
|
|
479
|
+
/**
|
|
480
|
+
* Method to transmit a user interaction
|
|
481
|
+
*/
|
|
482
|
+
{
|
|
483
|
+
Method: "frak_sendInteraction";
|
|
484
|
+
Parameters: [
|
|
485
|
+
productId: Hex,
|
|
486
|
+
interaction: PreparedInteraction,
|
|
487
|
+
signature?: Hex
|
|
488
|
+
];
|
|
489
|
+
ReturnType: SendInteractionReturnType;
|
|
490
|
+
},
|
|
491
|
+
/**
|
|
492
|
+
* Method to start a SSO
|
|
493
|
+
* todo: Should also support direct tracking via a consumeKey
|
|
494
|
+
*/
|
|
495
|
+
{
|
|
496
|
+
Method: "frak_sso";
|
|
497
|
+
Parameters: [
|
|
498
|
+
params: OpenSsoParamsType,
|
|
499
|
+
name: string,
|
|
500
|
+
customCss?: string
|
|
501
|
+
];
|
|
502
|
+
ReturnType: undefined;
|
|
503
|
+
},
|
|
504
|
+
/**
|
|
505
|
+
* Method to get current product information's
|
|
506
|
+
* - Is product minted?
|
|
507
|
+
* - Does it have running campaign?
|
|
508
|
+
* - Estimated reward on actions
|
|
509
|
+
*/
|
|
510
|
+
{
|
|
511
|
+
Method: "frak_getProductInformation";
|
|
512
|
+
Parameters?: undefined;
|
|
513
|
+
ReturnType: GetProductInformationReturnType;
|
|
514
|
+
}
|
|
515
|
+
];
|
|
516
|
+
|
|
517
|
+
/**
|
|
518
|
+
* Type that extract the possible parameters from a RPC Schema
|
|
519
|
+
* @ignore
|
|
520
|
+
*/
|
|
521
|
+
type ExtractedParametersFromRpc<TRpcSchema extends RpcSchema> = {
|
|
522
|
+
[K in keyof TRpcSchema]: Prettify<{
|
|
523
|
+
method: TRpcSchema[K] extends TRpcSchema[number] ? TRpcSchema[K]["Method"] : string;
|
|
524
|
+
} & (TRpcSchema[K] extends TRpcSchema[number] ? TRpcSchema[K]["Parameters"] extends undefined ? {
|
|
525
|
+
params?: never;
|
|
526
|
+
} : {
|
|
527
|
+
params: TRpcSchema[K]["Parameters"];
|
|
528
|
+
} : never)>;
|
|
529
|
+
}[number];
|
|
530
|
+
/**
|
|
531
|
+
* Type that extract the possible return type from a RPC Schema
|
|
532
|
+
* @ignore
|
|
533
|
+
*/
|
|
534
|
+
type ExtractedReturnTypeFromRpc<TRpcSchema extends RpcSchema, TParameters extends ExtractedParametersFromRpc<TRpcSchema> = ExtractedParametersFromRpc<TRpcSchema>> = ExtractedMethodFromRpc<TRpcSchema, TParameters["method"]>["ReturnType"];
|
|
535
|
+
/**
|
|
536
|
+
* Type that extract the possible return type from a RPC Schema
|
|
537
|
+
* @ignore
|
|
538
|
+
*/
|
|
539
|
+
type ExtractedMethodFromRpc<TRpcSchema extends RpcSchema, TMethod extends ExtractedParametersFromRpc<TRpcSchema>["method"] = ExtractedParametersFromRpc<TRpcSchema>["method"]> = Extract<TRpcSchema[number], {
|
|
540
|
+
Method: TMethod;
|
|
541
|
+
}>;
|
|
542
|
+
/**
|
|
543
|
+
* Raw response that we will receive after an rpc request
|
|
544
|
+
* @ignore
|
|
545
|
+
*/
|
|
546
|
+
type RpcResponse<TRpcSchema extends RpcSchema, TMethod extends TRpcSchema[number]["Method"] = TRpcSchema[number]["Method"]> = {
|
|
547
|
+
result: Extract<TRpcSchema[number], {
|
|
548
|
+
Method: TMethod;
|
|
549
|
+
}>["ReturnType"];
|
|
550
|
+
error?: never;
|
|
551
|
+
} | {
|
|
552
|
+
result?: never;
|
|
553
|
+
error: {
|
|
554
|
+
code: number;
|
|
555
|
+
message: string;
|
|
556
|
+
data?: unknown;
|
|
557
|
+
};
|
|
558
|
+
};
|
|
559
|
+
/**
|
|
560
|
+
* Type used for a one shot request function
|
|
561
|
+
* @inline
|
|
562
|
+
*/
|
|
563
|
+
type RequestFn<TRpcSchema extends RpcSchema> = <TParameters extends ExtractedParametersFromRpc<TRpcSchema> = ExtractedParametersFromRpc<TRpcSchema>, _ReturnType = ExtractedReturnTypeFromRpc<TRpcSchema, TParameters>>(args: TParameters) => Promise<_ReturnType>;
|
|
564
|
+
/**
|
|
565
|
+
* Type used for a listening request
|
|
566
|
+
* @inline
|
|
567
|
+
*/
|
|
568
|
+
type ListenerRequestFn<TRpcSchema extends RpcSchema> = <TParameters extends ExtractedParametersFromRpc<TRpcSchema> = ExtractedParametersFromRpc<TRpcSchema>, _ReturnType = ExtractedReturnTypeFromRpc<TRpcSchema, TParameters>>(args: TParameters, callback: (result: _ReturnType) => void) => Promise<void>;
|
|
569
|
+
/**
|
|
570
|
+
* IFrame transport interface
|
|
571
|
+
*/
|
|
572
|
+
type IFrameTransport = {
|
|
573
|
+
/**
|
|
574
|
+
* Wait for the connection to be established
|
|
575
|
+
*/
|
|
576
|
+
waitForConnection: Promise<boolean>;
|
|
577
|
+
/**
|
|
578
|
+
* Wait for the setup to be done
|
|
579
|
+
*/
|
|
580
|
+
waitForSetup: Promise<void>;
|
|
581
|
+
/**
|
|
582
|
+
* Function used to perform a single request via the iframe transport
|
|
583
|
+
*/
|
|
584
|
+
request: RequestFn<IFrameRpcSchema>;
|
|
585
|
+
/**
|
|
586
|
+
* Function used to listen to a request response via the iframe transport
|
|
587
|
+
*/
|
|
588
|
+
listenerRequest: ListenerRequestFn<IFrameRpcSchema>;
|
|
589
|
+
/**
|
|
590
|
+
* Function used to destroy the iframe transport
|
|
591
|
+
*/
|
|
592
|
+
destroy: () => Promise<void>;
|
|
593
|
+
};
|
|
594
|
+
/**
|
|
595
|
+
* Represent an iframe event
|
|
596
|
+
*/
|
|
597
|
+
type IFrameEvent = IFrameRpcEvent | IFrameLifecycleEvent | ClientLifecycleEvent;
|
|
598
|
+
/**
|
|
599
|
+
* Represent an iframe rpc event
|
|
600
|
+
*/
|
|
601
|
+
type IFrameRpcEvent = {
|
|
602
|
+
id: string;
|
|
603
|
+
topic: ExtractedParametersFromRpc<IFrameRpcSchema>["method"];
|
|
604
|
+
data: {
|
|
605
|
+
compressed: string;
|
|
606
|
+
compressedHash: string;
|
|
607
|
+
};
|
|
608
|
+
};
|
|
609
|
+
|
|
610
|
+
/**
|
|
611
|
+
* Representing a Frak client, used to interact with the Frak Wallet
|
|
612
|
+
*/
|
|
613
|
+
type FrakClient = {
|
|
614
|
+
config: FrakWalletSdkConfig;
|
|
615
|
+
} & IFrameTransport;
|
|
616
|
+
|
|
617
|
+
/**
|
|
618
|
+
* The current Frak Context
|
|
619
|
+
*
|
|
620
|
+
* For now, only contain a referrer address.
|
|
621
|
+
*/
|
|
622
|
+
type FrakContext = {
|
|
623
|
+
r: Address;
|
|
624
|
+
};
|
|
625
|
+
|
|
626
|
+
export { type ClientLifecycleEvent as C, type DisplayModalParamsType as D, type ExtractedParametersFromRpc as E, type FrakWalletSdkConfig as F, type GetProductInformationReturnType as G, type IFrameRpcSchema as I, type LoginModalStepType 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 ModalRpcMetadata as d, type ModalRpcStepsInput as e, type ModalRpcStepsResultType as f, type ModalStepMetadata as g, type SiweAuthenticateModalStepType as h, type SiweAuthenticationParams as i, type SiweAuthenticateReturnType as j, type SendTransactionTxType as k, type SendTransactionModalStepType as l, type SendTransactionReturnType as m, type OpenInteractionSessionReturnType as n, type OpenInteractionSessionModalStepType as o, productTypes as p, type FinalModalStepType as q, type FinalActionType as r, type IFrameTransport as s, type IFrameRpcEvent as t, type IFrameEvent as u, type IFrameLifecycleEvent as v, type ExtractedReturnTypeFromRpc as w };
|