@human-protocol/sdk 0.0.10

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/src/types.ts ADDED
@@ -0,0 +1,676 @@
1
+ import {
2
+ Escrow,
3
+ EscrowFactory,
4
+ HMToken,
5
+ Staking,
6
+ } from '@human-protocol/core/typechain-types';
7
+ import { ethers } from 'ethers';
8
+
9
+ /**
10
+ * Enum for escrow statuses.
11
+ * @readonly
12
+ * @enum {number}
13
+ */
14
+ export enum EscrowStatus {
15
+ /**
16
+ * Escrow is launched.
17
+ */
18
+ Launched,
19
+ /**
20
+ * Escrow is funded, and waiting for the results to be submitted.
21
+ */
22
+ Pending,
23
+ /**
24
+ * Escrow is partially paid out.
25
+ */
26
+ Partial,
27
+ /**
28
+ * Escrow is fully paid.
29
+ */
30
+ Paid,
31
+ /**
32
+ * Escrow is finished..
33
+ */
34
+ Complete,
35
+ /**
36
+ * Escrow is cancelled.
37
+ */
38
+ Cancelled,
39
+ }
40
+
41
+ /**
42
+ * Payout item
43
+ * @readonly
44
+ */
45
+ export type Payout = {
46
+ /**
47
+ * Payout address
48
+ */
49
+ address: string;
50
+ /**
51
+ * Payout amount
52
+ */
53
+ amount: number;
54
+ };
55
+
56
+ /**
57
+ * Job mode
58
+ */
59
+ export type JobMode = 'batch' | 'online' | 'instance_delivery';
60
+
61
+ /**
62
+ * Base job types
63
+ */
64
+ export type BaseJobTypes =
65
+ | 'image_label_binary'
66
+ | 'image_label_multiple_choice'
67
+ | 'text_free_entry'
68
+ | 'text_multiple_choice_one_option'
69
+ | 'text_multiple_choice_multiple_options'
70
+ | 'image_label_area_adjust'
71
+ | 'image_label_area_select'
72
+ | 'image_label_single_polygon'
73
+ | 'image_label_multiple_polygons'
74
+ | 'image_label_semantic_segmentation_one_option'
75
+ | 'image_label_semantic_segmentation_multiple_options'
76
+ | 'image_label_text';
77
+
78
+ /**
79
+ * Shape type of request config
80
+ */
81
+ export type ShapeType = 'point' | 'bounding_box' | 'polygon';
82
+
83
+ /**
84
+ * Request config item
85
+ */
86
+ export type RequestConfig = {
87
+ /**
88
+ * Version
89
+ */
90
+ version?: number;
91
+ /**
92
+ * Shape type
93
+ */
94
+ shape_type?: ShapeType;
95
+ /**
96
+ * Minimum points
97
+ */
98
+ min_points?: number;
99
+ /**
100
+ * Maximum points
101
+ */
102
+ max_points?: number;
103
+ /**
104
+ * Minimum shapes per image
105
+ */
106
+ min_shapes_per_image?: number;
107
+ /**
108
+ * Maximum shapes per image
109
+ */
110
+ max_shapes_per_image?: number;
111
+ /**
112
+ * Restrict to coordinates
113
+ */
114
+ restrict_to_coords?: boolean;
115
+ /**
116
+ * Minimum selection area per shape
117
+ */
118
+ minimum_selection_area_per_shape?: number;
119
+ /**
120
+ * Maximum choices for multiple choice
121
+ */
122
+ multiple_choice_max_choices?: number;
123
+ /**
124
+ * Minimum choices for multiple choice
125
+ */
126
+ multiple_choice_min_choices?: number;
127
+ };
128
+
129
+ /**
130
+ * Webhook item
131
+ */
132
+ export type Webhook = {
133
+ /**
134
+ * Webhook id
135
+ */
136
+ webhook_id: string;
137
+ /**
138
+ * Completed chunks
139
+ */
140
+ chunk_completed?: string[];
141
+ /**
142
+ * Completed jobs
143
+ */
144
+ job_completed?: string[];
145
+ };
146
+
147
+ /**
148
+ * Task data item
149
+ */
150
+ export type TaskData = {
151
+ /**
152
+ * Task key
153
+ */
154
+ task_key: string;
155
+ /**
156
+ * Datapoint URI
157
+ */
158
+ datapoint_uri: string;
159
+ /**
160
+ * Datapoint hash
161
+ */
162
+ datapoint_hash: string;
163
+ };
164
+
165
+ /**
166
+ * Internal config item
167
+ */
168
+ export type InternalConfig = {
169
+ /**
170
+ * Exchange Oracle
171
+ */
172
+ exchange?: Record<string, string | number>;
173
+ /**
174
+ * Recording Oracle
175
+ */
176
+ reco?: Record<string, string | number>;
177
+ /**
178
+ * Reputation Oracle
179
+ */
180
+ repo?: Record<string, string | number>;
181
+ /**
182
+ * Other trusted handlers
183
+ */
184
+ other?: Record<string, string | number>;
185
+ /**
186
+ * MITL???
187
+ */
188
+ mitl?: string | number | Record<string, string | number>;
189
+ };
190
+
191
+ /**
192
+ * Score item
193
+ */
194
+ export type Score = {
195
+ /**
196
+ * Score
197
+ */
198
+ score: number;
199
+ };
200
+
201
+ /**
202
+ * Restricted audience item
203
+ */
204
+ export type RestrictedAudience = {
205
+ /**
206
+ * Lang score
207
+ */
208
+ lang?: Score[];
209
+ /**
210
+ * Country score
211
+ */
212
+ country?: Score[];
213
+ /**
214
+ * Browser score
215
+ */
216
+ browser?: Score[];
217
+ /**
218
+ * Sitekey Score
219
+ */
220
+ sitekey?: Score[];
221
+ /**
222
+ * Server domain score
223
+ */
224
+ serverdomain?: Score[];
225
+ /**
226
+ * Confidence score
227
+ */
228
+ confidence?: Score[];
229
+
230
+ /**
231
+ * Minimum difficulty
232
+ */
233
+ min_difficulty?: number;
234
+ /**
235
+ * Minimum user score
236
+ */
237
+ min_user_score?: number;
238
+ /**
239
+ * Maximum user score
240
+ */
241
+ max_user_score?: number;
242
+
243
+ /**
244
+ * Launch group ID
245
+ */
246
+ launch_group_id?: number;
247
+ };
248
+
249
+ /**
250
+ * Nested manifest item
251
+ */
252
+ export type NestedManifest = Pick<
253
+ Manifest,
254
+ | 'job_id'
255
+ | 'requester_restricted_answer_set'
256
+ | 'requester_description'
257
+ | 'requester_max_repeats'
258
+ | 'requester_min_repeats'
259
+ | 'requester_question'
260
+ | 'requester_question_example'
261
+ | 'unsafe_content'
262
+ | 'requester_accuracy_target'
263
+ | 'request_type'
264
+ | 'request_config'
265
+ | 'groundtruth_uri'
266
+ | 'groundtruth'
267
+ | 'confcalc_configuration_id'
268
+ | 'webhook'
269
+ >;
270
+
271
+ /**
272
+ * Manifest item
273
+ * @readonly
274
+ * @todo Confirm data type
275
+ */
276
+ export type Manifest = {
277
+ /**
278
+ * Job Mode
279
+ */
280
+ job_mode: JobMode;
281
+ /**
282
+ * Job API Key
283
+ */
284
+ job_api_key?: string;
285
+ /**
286
+ * Job ID
287
+ */
288
+ job_id?: string;
289
+ /**
290
+ * Total tasks in the job
291
+ */
292
+ job_total_tasks: number;
293
+ /**
294
+ * Requester's restricted answer set
295
+ */
296
+ requester_restricted_answer_set?: Record<string, Record<string, string>>;
297
+ /**
298
+ * Requester's description
299
+ */
300
+ requester_description?: string;
301
+ /**
302
+ * Maximum repeat count of the requester
303
+ */
304
+ requester_max_repeats?: number;
305
+ /**
306
+ * Minimum repeat count of the requester
307
+ */
308
+ requester_min_repeats?: number;
309
+ /**
310
+ * Requester's question
311
+ */
312
+ requester_question?: Record<string, string>;
313
+ /**
314
+ * Requester's question example
315
+ */
316
+ requester_question_example?: string | string[];
317
+ /**
318
+ * Flag for unsafe content
319
+ */
320
+ unsafe_content?: boolean;
321
+ /**
322
+ * Bid price for the task
323
+ */
324
+ task_bid_price: number;
325
+ /**
326
+ * Staking amount for oracles
327
+ */
328
+ oracle_stake: number;
329
+ /**
330
+ * Job expiration date
331
+ */
332
+ expiration_date?: number;
333
+ /**
334
+ * Requester's accuracy target
335
+ */
336
+ requester_accuracy_target?: number;
337
+ /**
338
+ * Smart bounty address
339
+ */
340
+ manifest_smart_bounty_addr?: string;
341
+ /**
342
+ * HMT token address
343
+ */
344
+ hmtoken_addr?: string;
345
+ /**
346
+ * Minimum trust of the server
347
+ */
348
+ minimum_trust_server?: number;
349
+ /**
350
+ * Minimum trust of the client
351
+ */
352
+ minimum_trust_client?: number;
353
+ /**
354
+ * Recording oracle address
355
+ */
356
+ recording_oracle_addr: string;
357
+ /**
358
+ * Reputation oracle address
359
+ */
360
+ reputation_oracle_addr: string;
361
+ /**
362
+ * Reputation agent address
363
+ */
364
+ reputation_agent_addr: string;
365
+ /**
366
+ * Requester's PGP public key
367
+ */
368
+ requester_pgp_public_key?: string;
369
+ /**
370
+ * RO URI
371
+ */
372
+ ro_uri?: string;
373
+ /**
374
+ * Repo URI
375
+ */
376
+ repo_uri?: string;
377
+
378
+ /**
379
+ * Batch result delivery webhook
380
+ */
381
+ batch_result_delivery_webhook?: string;
382
+ /**
383
+ * Online result delivery webhook
384
+ */
385
+ online_result_delivery_webhook?: string;
386
+ /**
387
+ * Instant result delivery webhook
388
+ */
389
+ instant_result_delivery_webhook?: string;
390
+
391
+ /**
392
+ * Multi challenge manifests
393
+ */
394
+ multi_challenge_manifests?: NestedManifest[];
395
+
396
+ /**
397
+ * Request type
398
+ */
399
+ request_type: BaseJobTypes | 'multi_challenge';
400
+
401
+ /**
402
+ * Request config
403
+ */
404
+ request_config?: RequestConfig;
405
+
406
+ /**
407
+ * Task data
408
+ */
409
+ taskdata?: TaskData[];
410
+
411
+ /**
412
+ * Task data URI for external task
413
+ */
414
+ taskdata_uri?: string;
415
+
416
+ /**
417
+ * Groundtruth URI
418
+ * Groundtruth data is stored as a URL or optionally as an inline json-serialized string
419
+ */
420
+ groundtruth_uri?: string;
421
+ /**
422
+ * Groundtruth
423
+ */
424
+ groundtruth?: string;
425
+
426
+ /**
427
+ * Rejected URI
428
+ */
429
+ rejected_uri?: string;
430
+ /**
431
+ * Rejected count
432
+ */
433
+ rejected_count?: number;
434
+
435
+ /**
436
+ * Internal config
437
+ */
438
+ internal_config?: InternalConfig;
439
+
440
+ /**
441
+ * Confcalc configuratoin ID
442
+ */
443
+ confcalc_configuration_id?: string;
444
+
445
+ /**
446
+ * Restricted audience
447
+ */
448
+ restricted_audience?: RestrictedAudience;
449
+
450
+ /**
451
+ * Webhook
452
+ */
453
+ webhook?: Webhook;
454
+ };
455
+
456
+ /**
457
+ * Cloud storage object link
458
+ * @readonly
459
+ */
460
+ export type StorageObjectLink = {
461
+ /**
462
+ * Storage object URL
463
+ */
464
+ url: string;
465
+ /**
466
+ * Storage object content hash
467
+ */
468
+ hash: string;
469
+ };
470
+
471
+ /**
472
+ * Ethers provider data
473
+ * @readonly
474
+ */
475
+ export type ProviderData = {
476
+ /**
477
+ * Ethers provider
478
+ */
479
+ provider: ethers.providers.BaseProvider;
480
+ /**
481
+ * Gas payer wallet
482
+ */
483
+ gasPayer?: ethers.Wallet;
484
+ /**
485
+ * Reputation oracle wallet
486
+ */
487
+ reputationOracle?: ethers.Wallet;
488
+ /**
489
+ * Other trusted handlers for the job
490
+ */
491
+ trustedHandlers?: Array<ethers.Wallet>;
492
+ };
493
+
494
+ /**
495
+ * AWS/GCP cloud storage access data
496
+ * @readonly
497
+ */
498
+ export type StorageAccessData = {
499
+ /**
500
+ * Access Key ID
501
+ */
502
+ accessKeyId: string;
503
+ /**
504
+ * Secret Access Key
505
+ */
506
+ secretAccessKey: string;
507
+ /**
508
+ * Region
509
+ */
510
+ region?: string;
511
+ /**
512
+ * Request endpoint
513
+ */
514
+ endpoint?: string;
515
+ /**
516
+ * Storage bucket (private)
517
+ */
518
+ bucket: string;
519
+ /**
520
+ * Storage bucket (public)
521
+ */
522
+ publicBucket: string;
523
+ };
524
+
525
+ /**
526
+ * Manifest data
527
+ */
528
+ export type ManifestData = {
529
+ /**
530
+ * Manifest
531
+ */
532
+ manifest?: Manifest;
533
+ /**
534
+ * Manifest link
535
+ */
536
+ manifestlink?: StorageObjectLink;
537
+ /**
538
+ * Intermediate result link
539
+ */
540
+ intermediateResultLink?: StorageObjectLink;
541
+ };
542
+
543
+ /**
544
+ * Contract data
545
+ */
546
+ export type ContractData = {
547
+ /**
548
+ * Factory contract address
549
+ */
550
+ factoryAddr?: string;
551
+ /**
552
+ * Factory contract instance
553
+ */
554
+ factory?: EscrowFactory;
555
+ /**
556
+ * Escrow contract address
557
+ */
558
+ escrowAddr?: string;
559
+ /**
560
+ * Escrow contract instance
561
+ */
562
+ escrow?: Escrow;
563
+ /**
564
+ * HMToken contract address
565
+ */
566
+ hmTokenAddr: string;
567
+ /**
568
+ * HMToken contract instance
569
+ */
570
+ hmToken?: HMToken;
571
+ /**
572
+ * Staking contract address
573
+ */
574
+ stakingAddr?: string;
575
+ /**
576
+ * Staking contract instance
577
+ */
578
+ staking?: Staking;
579
+ };
580
+
581
+ /**
582
+ * Generic result data
583
+ * @readonly
584
+ */
585
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
586
+ export type Result = Record<string, any>;
587
+
588
+ /**
589
+ * Upload result data
590
+ * @readonly
591
+ */
592
+ export type UploadResult = {
593
+ /**
594
+ * Uploaded object key
595
+ */
596
+ key: string;
597
+ /**
598
+ * Hash of uploaded object key
599
+ */
600
+ hash: string;
601
+ };
602
+
603
+ /**
604
+ * Job arguments
605
+ * @readonly
606
+ */
607
+ export type JobArguments = {
608
+ /**
609
+ * Network
610
+ */
611
+ network?: string;
612
+ /**
613
+ * Infura project id
614
+ */
615
+ infuraKey?: string;
616
+ /**
617
+ * Alchemy API token
618
+ */
619
+ alchemyKey?: string;
620
+ /**
621
+ * Gas payer wallet / private key
622
+ */
623
+ gasPayer: ethers.Wallet | string;
624
+ /**
625
+ * Reputation oracle wallet / private key
626
+ */
627
+ reputationOracle: ethers.Wallet | string;
628
+ /**
629
+ * Trusted handlers wallet / private key
630
+ */
631
+ trustedHandlers?: Array<ethers.Wallet | string>;
632
+ /**
633
+ * HMToken address
634
+ */
635
+ hmTokenAddr: string;
636
+ /**
637
+ * Factory contract address
638
+ */
639
+ stakingAddr?: string;
640
+ /**
641
+ * Staking contract address
642
+ */
643
+ factoryAddr?: string;
644
+ /**
645
+ * Escrow contract address
646
+ */
647
+ escrowAddr?: string;
648
+ /**
649
+ * Job manifest
650
+ */
651
+ manifest?: Manifest;
652
+ /**
653
+ * AWS/GCP Access Key ID
654
+ */
655
+ storageAccessKeyId?: string;
656
+ /**
657
+ * AWS/GCP Secret Access Key
658
+ */
659
+ storageSecretAccessKey?: string;
660
+ /**
661
+ * AWS/GCP bucket endpoint
662
+ */
663
+ storageEndpoint?: string;
664
+ /**
665
+ * AWS/GCP public bucket name
666
+ */
667
+ storagePublicBucket?: string;
668
+ /**
669
+ * AWS/GCP private bucket name
670
+ */
671
+ storageBucket?: string;
672
+ /**
673
+ * Log level
674
+ */
675
+ logLevel?: 'debug' | 'info' | 'warn' | 'error';
676
+ };