@prosopo/provider 0.2.5 → 0.2.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (55) hide show
  1. package/dist/cjs/contracts/captcha/dist/contract-info/captcha.cjs +2 -2
  2. package/dist/tests/accounts.d.ts +11 -0
  3. package/dist/tests/accounts.d.ts.map +1 -0
  4. package/dist/tests/accounts.js +47 -0
  5. package/dist/tests/accounts.js.map +1 -0
  6. package/dist/tests/batch/commitments.test.d.ts +6 -0
  7. package/dist/tests/batch/commitments.test.d.ts.map +1 -0
  8. package/dist/tests/batch/commitments.test.js +217 -0
  9. package/dist/tests/batch/commitments.test.js.map +1 -0
  10. package/dist/tests/contract/helpers.test.d.ts +6 -0
  11. package/dist/tests/contract/helpers.test.d.ts.map +1 -0
  12. package/dist/tests/contract/helpers.test.js +58 -0
  13. package/dist/tests/contract/helpers.test.js.map +1 -0
  14. package/dist/tests/data/captchas.d.ts +37 -0
  15. package/dist/tests/data/captchas.d.ts.map +1 -0
  16. package/dist/tests/data/captchas.js +902 -0
  17. package/dist/tests/data/captchas.js.map +1 -0
  18. package/dist/tests/data/captchas1.json +53 -0
  19. package/dist/tests/data/captchas2.json +69 -0
  20. package/dist/tests/data/captchas3.json +54 -0
  21. package/dist/tests/data/captchas4.json +53 -0
  22. package/dist/tests/dataUtils/DatabaseAccounts.d.ts +35 -0
  23. package/dist/tests/dataUtils/DatabaseAccounts.d.ts.map +1 -0
  24. package/dist/tests/dataUtils/DatabaseAccounts.js +85 -0
  25. package/dist/tests/dataUtils/DatabaseAccounts.js.map +1 -0
  26. package/dist/tests/dataUtils/DatabasePopulator.d.ts +66 -0
  27. package/dist/tests/dataUtils/DatabasePopulator.d.ts.map +1 -0
  28. package/dist/tests/dataUtils/DatabasePopulator.js +264 -0
  29. package/dist/tests/dataUtils/DatabasePopulator.js.map +1 -0
  30. package/dist/tests/dataUtils/dapp-example-contract/dapp.json +648 -0
  31. package/dist/tests/dataUtils/dapp-example-contract/loadFiles.d.ts +4 -0
  32. package/dist/tests/dataUtils/dapp-example-contract/loadFiles.d.ts.map +1 -0
  33. package/dist/tests/dataUtils/dapp-example-contract/loadFiles.js +41 -0
  34. package/dist/tests/dataUtils/dapp-example-contract/loadFiles.js.map +1 -0
  35. package/dist/tests/dataUtils/funds.d.ts +23 -0
  36. package/dist/tests/dataUtils/funds.d.ts.map +1 -0
  37. package/dist/tests/dataUtils/funds.js +102 -0
  38. package/dist/tests/dataUtils/funds.js.map +1 -0
  39. package/dist/tests/dataUtils/populateDatabase.d.ts +15 -0
  40. package/dist/tests/dataUtils/populateDatabase.d.ts.map +1 -0
  41. package/dist/tests/dataUtils/populateDatabase.js +76 -0
  42. package/dist/tests/dataUtils/populateDatabase.js.map +1 -0
  43. package/dist/tests/getUser.d.ts +5 -0
  44. package/dist/tests/getUser.d.ts.map +1 -0
  45. package/dist/tests/getUser.js +18 -0
  46. package/dist/tests/getUser.js.map +1 -0
  47. package/dist/tests/tasks/tasks.test.d.ts +7 -0
  48. package/dist/tests/tasks/tasks.test.d.ts.map +1 -0
  49. package/dist/tests/tasks/tasks.test.js +719 -0
  50. package/dist/tests/tasks/tasks.test.js.map +1 -0
  51. package/dist/tests/util.test.d.ts +2 -0
  52. package/dist/tests/util.test.d.ts.map +1 -0
  53. package/dist/tests/util.test.js +51 -0
  54. package/dist/tests/util.test.js.map +1 -0
  55. package/package.json +10 -10
@@ -0,0 +1,648 @@
1
+ {
2
+ "source": {
3
+ "hash": "0xe161583d273075a0b18d1b9f2b924b9c9ee517ff865c98a31c1cd0897181a9bc",
4
+ "language": "ink! 4.0.1",
5
+ "compiler": "rustc 1.67.0",
6
+ "build_info": {
7
+ "build_mode": "Release",
8
+ "cargo_contract_version": "2.0.1",
9
+ "rust_toolchain": "stable-x86_64-unknown-linux-gnu",
10
+ "wasm_opt_settings": {
11
+ "keep_debug_symbols": true,
12
+ "optimization_passes": "Z"
13
+ }
14
+ }
15
+ },
16
+ "contract": {
17
+ "name": "dapp",
18
+ "version": "4.0.0",
19
+ "authors": ["Chris Taylor chris@prosopo.io"]
20
+ },
21
+ "spec": {
22
+ "constructors": [
23
+ {
24
+ "args": [
25
+ {
26
+ "label": "initial_supply",
27
+ "type": {
28
+ "displayName": ["Balance"],
29
+ "type": 0
30
+ }
31
+ },
32
+ {
33
+ "label": "faucet_amount",
34
+ "type": {
35
+ "displayName": ["Balance"],
36
+ "type": 0
37
+ }
38
+ },
39
+ {
40
+ "label": "prosopo_account",
41
+ "type": {
42
+ "displayName": ["AccountId"],
43
+ "type": 1
44
+ }
45
+ },
46
+ {
47
+ "label": "human_threshold",
48
+ "type": {
49
+ "displayName": ["u8"],
50
+ "type": 3
51
+ }
52
+ },
53
+ {
54
+ "label": "recency_threshold",
55
+ "type": {
56
+ "displayName": ["u32"],
57
+ "type": 4
58
+ }
59
+ }
60
+ ],
61
+ "docs": [
62
+ "Creates a new contract with the specified initial supply and loads an instance of the",
63
+ "`prosopo` contract"
64
+ ],
65
+ "label": "new",
66
+ "payable": true,
67
+ "returnType": {
68
+ "displayName": ["ink_primitives", "ConstructorResult"],
69
+ "type": 5
70
+ },
71
+ "selector": "0x9bae9d5e"
72
+ }
73
+ ],
74
+ "docs": [],
75
+ "events": [
76
+ {
77
+ "args": [
78
+ {
79
+ "docs": [],
80
+ "indexed": true,
81
+ "label": "from",
82
+ "type": {
83
+ "displayName": ["Option"],
84
+ "type": 14
85
+ }
86
+ },
87
+ {
88
+ "docs": [],
89
+ "indexed": true,
90
+ "label": "to",
91
+ "type": {
92
+ "displayName": ["Option"],
93
+ "type": 14
94
+ }
95
+ },
96
+ {
97
+ "docs": [],
98
+ "indexed": false,
99
+ "label": "value",
100
+ "type": {
101
+ "displayName": ["Balance"],
102
+ "type": 0
103
+ }
104
+ }
105
+ ],
106
+ "docs": [" Event emitted when a token transfer occurs."],
107
+ "label": "Transfer"
108
+ }
109
+ ],
110
+ "lang_error": {
111
+ "displayName": ["ink", "LangError"],
112
+ "type": 7
113
+ },
114
+ "messages": [
115
+ {
116
+ "args": [
117
+ {
118
+ "label": "accountid",
119
+ "type": {
120
+ "displayName": ["AccountId"],
121
+ "type": 1
122
+ }
123
+ }
124
+ ],
125
+ "docs": [" Faucet function for sending tokens to humans"],
126
+ "label": "faucet",
127
+ "mutates": true,
128
+ "payable": false,
129
+ "returnType": {
130
+ "displayName": ["ink", "MessageResult"],
131
+ "type": 8
132
+ },
133
+ "selector": "0x91bd0a53"
134
+ },
135
+ {
136
+ "args": [
137
+ {
138
+ "label": "accountid",
139
+ "type": {
140
+ "displayName": ["AccountId"],
141
+ "type": 1
142
+ }
143
+ },
144
+ {
145
+ "label": "threshold",
146
+ "type": {
147
+ "displayName": ["u8"],
148
+ "type": 3
149
+ }
150
+ },
151
+ {
152
+ "label": "recency",
153
+ "type": {
154
+ "displayName": ["u32"],
155
+ "type": 4
156
+ }
157
+ }
158
+ ],
159
+ "docs": [" Calls the `Prosopo` contract to check if `accountid` is human"],
160
+ "label": "is_human",
161
+ "mutates": false,
162
+ "payable": false,
163
+ "returnType": {
164
+ "displayName": ["ink", "MessageResult"],
165
+ "type": 11
166
+ },
167
+ "selector": "0x47e27f92"
168
+ },
169
+ {
170
+ "args": [
171
+ {
172
+ "label": "to",
173
+ "type": {
174
+ "displayName": ["AccountId"],
175
+ "type": 1
176
+ }
177
+ },
178
+ {
179
+ "label": "value",
180
+ "type": {
181
+ "displayName": ["Balance"],
182
+ "type": 0
183
+ }
184
+ }
185
+ ],
186
+ "docs": [
187
+ " Transfers `value` amount of tokens from the caller's account to account `to`.",
188
+ "",
189
+ " On success a `Transfer` event is emitted.",
190
+ "",
191
+ " # Errors",
192
+ "",
193
+ " Returns `InsufficientBalance` error if there are not enough tokens on",
194
+ " the caller's account balance."
195
+ ],
196
+ "label": "transfer",
197
+ "mutates": true,
198
+ "payable": false,
199
+ "returnType": {
200
+ "displayName": ["ink", "MessageResult"],
201
+ "type": 8
202
+ },
203
+ "selector": "0x84a15da1"
204
+ },
205
+ {
206
+ "args": [
207
+ {
208
+ "label": "owner",
209
+ "type": {
210
+ "displayName": ["AccountId"],
211
+ "type": 1
212
+ }
213
+ }
214
+ ],
215
+ "docs": [
216
+ " Returns the account balance for the specified `owner`.",
217
+ "",
218
+ " Returns `0` if the account is non-existent."
219
+ ],
220
+ "label": "balance_of",
221
+ "mutates": false,
222
+ "payable": false,
223
+ "returnType": {
224
+ "displayName": ["ink", "MessageResult"],
225
+ "type": 13
226
+ },
227
+ "selector": "0x0f755a56"
228
+ }
229
+ ]
230
+ },
231
+ "storage": {
232
+ "root": {
233
+ "layout": {
234
+ "struct": {
235
+ "fields": [
236
+ {
237
+ "layout": {
238
+ "leaf": {
239
+ "key": "0x00000000",
240
+ "ty": 0
241
+ }
242
+ },
243
+ "name": "total_supply"
244
+ },
245
+ {
246
+ "layout": {
247
+ "root": {
248
+ "layout": {
249
+ "leaf": {
250
+ "key": "0x28424af0",
251
+ "ty": 0
252
+ }
253
+ },
254
+ "root_key": "0x28424af0"
255
+ }
256
+ },
257
+ "name": "balances"
258
+ },
259
+ {
260
+ "layout": {
261
+ "leaf": {
262
+ "key": "0x00000000",
263
+ "ty": 0
264
+ }
265
+ },
266
+ "name": "faucet_amount"
267
+ },
268
+ {
269
+ "layout": {
270
+ "leaf": {
271
+ "key": "0x00000000",
272
+ "ty": 1
273
+ }
274
+ },
275
+ "name": "token_holder"
276
+ },
277
+ {
278
+ "layout": {
279
+ "leaf": {
280
+ "key": "0x00000000",
281
+ "ty": 3
282
+ }
283
+ },
284
+ "name": "human_threshold"
285
+ },
286
+ {
287
+ "layout": {
288
+ "leaf": {
289
+ "key": "0x00000000",
290
+ "ty": 4
291
+ }
292
+ },
293
+ "name": "recency_threshold"
294
+ },
295
+ {
296
+ "layout": {
297
+ "leaf": {
298
+ "key": "0x00000000",
299
+ "ty": 1
300
+ }
301
+ },
302
+ "name": "prosopo_account"
303
+ }
304
+ ],
305
+ "name": "Dapp"
306
+ }
307
+ },
308
+ "root_key": "0x00000000"
309
+ }
310
+ },
311
+ "types": [
312
+ {
313
+ "id": 0,
314
+ "type": {
315
+ "def": {
316
+ "primitive": "u128"
317
+ }
318
+ }
319
+ },
320
+ {
321
+ "id": 1,
322
+ "type": {
323
+ "def": {
324
+ "composite": {
325
+ "fields": [
326
+ {
327
+ "type": 2,
328
+ "typeName": "[u8; 32]"
329
+ }
330
+ ]
331
+ }
332
+ },
333
+ "path": ["ink_primitives", "types", "AccountId"]
334
+ }
335
+ },
336
+ {
337
+ "id": 2,
338
+ "type": {
339
+ "def": {
340
+ "array": {
341
+ "len": 32,
342
+ "type": 3
343
+ }
344
+ }
345
+ }
346
+ },
347
+ {
348
+ "id": 3,
349
+ "type": {
350
+ "def": {
351
+ "primitive": "u8"
352
+ }
353
+ }
354
+ },
355
+ {
356
+ "id": 4,
357
+ "type": {
358
+ "def": {
359
+ "primitive": "u32"
360
+ }
361
+ }
362
+ },
363
+ {
364
+ "id": 5,
365
+ "type": {
366
+ "def": {
367
+ "variant": {
368
+ "variants": [
369
+ {
370
+ "fields": [
371
+ {
372
+ "type": 6
373
+ }
374
+ ],
375
+ "index": 0,
376
+ "name": "Ok"
377
+ },
378
+ {
379
+ "fields": [
380
+ {
381
+ "type": 7
382
+ }
383
+ ],
384
+ "index": 1,
385
+ "name": "Err"
386
+ }
387
+ ]
388
+ }
389
+ },
390
+ "params": [
391
+ {
392
+ "name": "T",
393
+ "type": 6
394
+ },
395
+ {
396
+ "name": "E",
397
+ "type": 7
398
+ }
399
+ ],
400
+ "path": ["Result"]
401
+ }
402
+ },
403
+ {
404
+ "id": 6,
405
+ "type": {
406
+ "def": {
407
+ "tuple": []
408
+ }
409
+ }
410
+ },
411
+ {
412
+ "id": 7,
413
+ "type": {
414
+ "def": {
415
+ "variant": {
416
+ "variants": [
417
+ {
418
+ "index": 1,
419
+ "name": "CouldNotReadInput"
420
+ }
421
+ ]
422
+ }
423
+ },
424
+ "path": ["ink_primitives", "LangError"]
425
+ }
426
+ },
427
+ {
428
+ "id": 8,
429
+ "type": {
430
+ "def": {
431
+ "variant": {
432
+ "variants": [
433
+ {
434
+ "fields": [
435
+ {
436
+ "type": 9
437
+ }
438
+ ],
439
+ "index": 0,
440
+ "name": "Ok"
441
+ },
442
+ {
443
+ "fields": [
444
+ {
445
+ "type": 7
446
+ }
447
+ ],
448
+ "index": 1,
449
+ "name": "Err"
450
+ }
451
+ ]
452
+ }
453
+ },
454
+ "params": [
455
+ {
456
+ "name": "T",
457
+ "type": 9
458
+ },
459
+ {
460
+ "name": "E",
461
+ "type": 7
462
+ }
463
+ ],
464
+ "path": ["Result"]
465
+ }
466
+ },
467
+ {
468
+ "id": 9,
469
+ "type": {
470
+ "def": {
471
+ "variant": {
472
+ "variants": [
473
+ {
474
+ "fields": [
475
+ {
476
+ "type": 6
477
+ }
478
+ ],
479
+ "index": 0,
480
+ "name": "Ok"
481
+ },
482
+ {
483
+ "fields": [
484
+ {
485
+ "type": 10
486
+ }
487
+ ],
488
+ "index": 1,
489
+ "name": "Err"
490
+ }
491
+ ]
492
+ }
493
+ },
494
+ "params": [
495
+ {
496
+ "name": "T",
497
+ "type": 6
498
+ },
499
+ {
500
+ "name": "E",
501
+ "type": 10
502
+ }
503
+ ],
504
+ "path": ["Result"]
505
+ }
506
+ },
507
+ {
508
+ "id": 10,
509
+ "type": {
510
+ "def": {
511
+ "variant": {
512
+ "variants": [
513
+ {
514
+ "index": 0,
515
+ "name": "InsufficientBalance"
516
+ },
517
+ {
518
+ "index": 1,
519
+ "name": "UserNotHuman"
520
+ }
521
+ ]
522
+ }
523
+ },
524
+ "path": ["dapp", "dapp", "Error"]
525
+ }
526
+ },
527
+ {
528
+ "id": 11,
529
+ "type": {
530
+ "def": {
531
+ "variant": {
532
+ "variants": [
533
+ {
534
+ "fields": [
535
+ {
536
+ "type": 12
537
+ }
538
+ ],
539
+ "index": 0,
540
+ "name": "Ok"
541
+ },
542
+ {
543
+ "fields": [
544
+ {
545
+ "type": 7
546
+ }
547
+ ],
548
+ "index": 1,
549
+ "name": "Err"
550
+ }
551
+ ]
552
+ }
553
+ },
554
+ "params": [
555
+ {
556
+ "name": "T",
557
+ "type": 12
558
+ },
559
+ {
560
+ "name": "E",
561
+ "type": 7
562
+ }
563
+ ],
564
+ "path": ["Result"]
565
+ }
566
+ },
567
+ {
568
+ "id": 12,
569
+ "type": {
570
+ "def": {
571
+ "primitive": "bool"
572
+ }
573
+ }
574
+ },
575
+ {
576
+ "id": 13,
577
+ "type": {
578
+ "def": {
579
+ "variant": {
580
+ "variants": [
581
+ {
582
+ "fields": [
583
+ {
584
+ "type": 0
585
+ }
586
+ ],
587
+ "index": 0,
588
+ "name": "Ok"
589
+ },
590
+ {
591
+ "fields": [
592
+ {
593
+ "type": 7
594
+ }
595
+ ],
596
+ "index": 1,
597
+ "name": "Err"
598
+ }
599
+ ]
600
+ }
601
+ },
602
+ "params": [
603
+ {
604
+ "name": "T",
605
+ "type": 0
606
+ },
607
+ {
608
+ "name": "E",
609
+ "type": 7
610
+ }
611
+ ],
612
+ "path": ["Result"]
613
+ }
614
+ },
615
+ {
616
+ "id": 14,
617
+ "type": {
618
+ "def": {
619
+ "variant": {
620
+ "variants": [
621
+ {
622
+ "index": 0,
623
+ "name": "None"
624
+ },
625
+ {
626
+ "fields": [
627
+ {
628
+ "type": 1
629
+ }
630
+ ],
631
+ "index": 1,
632
+ "name": "Some"
633
+ }
634
+ ]
635
+ }
636
+ },
637
+ "params": [
638
+ {
639
+ "name": "T",
640
+ "type": 1
641
+ }
642
+ ],
643
+ "path": ["Option"]
644
+ }
645
+ }
646
+ ],
647
+ "version": "4"
648
+ }
@@ -0,0 +1,4 @@
1
+ import { Abi } from '@polkadot/api-contract';
2
+ export declare function DappAbiJSON(): Promise<Abi>;
3
+ export declare function DappWasm(): Promise<Uint8Array>;
4
+ //# sourceMappingURL=loadFiles.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"loadFiles.d.ts","sourceRoot":"","sources":["../../../../src/tests/dataUtils/dapp-example-contract/loadFiles.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,GAAG,EAAE,MAAM,wBAAwB,CAAA;AAO5C,wBAAsB,WAAW,IAAI,OAAO,CAAC,GAAG,CAAC,CAQhD;AAED,wBAAsB,QAAQ,IAAI,OAAO,CAAC,UAAU,CAAC,CASpD"}
@@ -0,0 +1,41 @@
1
+ // Copyright 2021-2023 Prosopo (UK) Ltd.
2
+ //
3
+ // Licensed under the Apache License, Version 2.0 (the "License");
4
+ // you may not use this file except in compliance with the License.
5
+ // You may obtain a copy of the License at
6
+ //
7
+ // http://www.apache.org/licenses/LICENSE-2.0
8
+ //
9
+ // Unless required by applicable law or agreed to in writing, software
10
+ // distributed under the License is distributed on an "AS IS" BASIS,
11
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ // See the License for the specific language governing permissions and
13
+ // limitations under the License.
14
+ import { Abi } from '@polkadot/api-contract';
15
+ import { hexToU8a, isWasm } from '@polkadot/util';
16
+ import fse from 'fs-extra';
17
+ import path from 'path';
18
+ // TODO use the .contract file instead of the .json and .wasm files. Polkadot-JS apps is also erroring out when using
19
+ // the .wasm and .json files. The .contract file works but I don't know why.
20
+ export async function DappAbiJSON() {
21
+ try {
22
+ const json = JSON.parse(await fse.readFile(path.resolve(__dirname, 'dapp.contract'), { encoding: 'utf8' }));
23
+ return new Abi(json);
24
+ }
25
+ catch (e) {
26
+ console.error(`Error loading dapp.json: ${e}`);
27
+ process.exit(1);
28
+ }
29
+ }
30
+ export async function DappWasm() {
31
+ const wasm = `0x${fse.readFileSync(path.resolve(__dirname, './dapp.wasm')).toString('hex')}`;
32
+ const wasmBytes = hexToU8a(wasm);
33
+ if (isWasm(wasmBytes)) {
34
+ return wasmBytes;
35
+ }
36
+ else {
37
+ console.error(`Error loading dapp.wasm: ${wasm.slice(0, 10)}...`);
38
+ process.exit(1);
39
+ }
40
+ }
41
+ //# sourceMappingURL=loadFiles.js.map