@human-protocol/sdk 3.0.8 → 4.0.0
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/dist/constants.d.ts +1 -1
- package/dist/constants.d.ts.map +1 -1
- package/dist/constants.js +2 -2
- package/dist/decorators.js +1 -1
- package/dist/encryption.d.ts +21 -29
- package/dist/encryption.d.ts.map +1 -1
- package/dist/encryption.js +17 -29
- package/dist/error.d.ts +31 -28
- package/dist/error.d.ts.map +1 -1
- package/dist/error.js +36 -33
- package/dist/escrow.d.ts +102 -59
- package/dist/escrow.d.ts.map +1 -1
- package/dist/escrow.js +186 -98
- package/dist/graphql/queries/operator.d.ts.map +1 -1
- package/dist/graphql/queries/operator.js +13 -5
- package/dist/interfaces.d.ts +10 -2
- package/dist/interfaces.d.ts.map +1 -1
- package/dist/kvstore.d.ts +15 -15
- package/dist/kvstore.d.ts.map +1 -1
- package/dist/kvstore.js +15 -15
- package/dist/operator.d.ts +11 -10
- package/dist/operator.d.ts.map +1 -1
- package/dist/operator.js +23 -11
- package/dist/staking.d.ts +38 -21
- package/dist/staking.d.ts.map +1 -1
- package/dist/staking.js +62 -21
- package/dist/statistics.d.ts +10 -29
- package/dist/statistics.d.ts.map +1 -1
- package/dist/statistics.js +10 -29
- package/dist/storage.d.ts +13 -18
- package/dist/storage.d.ts.map +1 -1
- package/dist/storage.js +13 -18
- package/dist/transaction.js +1 -1
- package/dist/types.d.ts +6 -2
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +1 -1
- package/dist/utils.d.ts +0 -1
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +0 -1
- package/package.json +1 -1
- package/src/constants.ts +2 -2
- package/src/decorators.ts +1 -1
- package/src/encryption.ts +21 -29
- package/src/error.ts +39 -37
- package/src/escrow.ts +245 -117
- package/src/graphql/queries/operator.ts +13 -5
- package/src/interfaces.ts +11 -2
- package/src/kvstore.ts +16 -16
- package/src/operator.ts +26 -12
- package/src/staking.ts +71 -22
- package/src/statistics.ts +10 -29
- package/src/storage.ts +13 -18
- package/src/transaction.ts +2 -2
- package/src/types.ts +6 -2
- package/src/utils.ts +0 -1
package/src/storage.ts
CHANGED
|
@@ -19,7 +19,7 @@ import { HttpStatus } from './constants';
|
|
|
19
19
|
*
|
|
20
20
|
* ## Introduction
|
|
21
21
|
*
|
|
22
|
-
* This client enables
|
|
22
|
+
* This client enables interacting with S3 cloud storage services like Amazon S3 Bucket, Google Cloud Storage, and others.
|
|
23
23
|
*
|
|
24
24
|
* The instance creation of `StorageClient` should be made using its constructor:
|
|
25
25
|
*
|
|
@@ -27,7 +27,7 @@ import { HttpStatus } from './constants';
|
|
|
27
27
|
* constructor(params: StorageParams, credentials?: StorageCredentials)
|
|
28
28
|
* ```
|
|
29
29
|
*
|
|
30
|
-
* > If credentials
|
|
30
|
+
* > If credentials are not provided, it uses anonymous access to the bucket for downloading files.
|
|
31
31
|
*
|
|
32
32
|
* ## Installation
|
|
33
33
|
*
|
|
@@ -68,7 +68,7 @@ export class StorageClient {
|
|
|
68
68
|
* **Storage client constructor**
|
|
69
69
|
*
|
|
70
70
|
* @param {StorageParams} params - Cloud storage params
|
|
71
|
-
* @param {StorageCredentials} credentials - Optional. Cloud storage access data. If credentials
|
|
71
|
+
* @param {StorageCredentials} credentials - Optional. Cloud storage access data. If credentials are not provided - use anonymous access to the bucket
|
|
72
72
|
*/
|
|
73
73
|
constructor(params: StorageParams, credentials?: StorageCredentials) {
|
|
74
74
|
try {
|
|
@@ -89,8 +89,7 @@ export class StorageClient {
|
|
|
89
89
|
*
|
|
90
90
|
* @param {string[]} keys Array of filenames to download.
|
|
91
91
|
* @param {string} bucket Bucket name.
|
|
92
|
-
* @returns {any[]} Returns an array of
|
|
93
|
-
*
|
|
92
|
+
* @returns {Promise<any[]>} Returns an array of JSON files downloaded and parsed into objects.
|
|
94
93
|
*
|
|
95
94
|
* **Code example**
|
|
96
95
|
*
|
|
@@ -131,18 +130,17 @@ export class StorageClient {
|
|
|
131
130
|
}
|
|
132
131
|
|
|
133
132
|
/**
|
|
134
|
-
* This function downloads files from a
|
|
135
|
-
*
|
|
136
|
-
* @param {string} url Url of the file to download.
|
|
137
|
-
* @returns {any} Returns the JSON file downloaded and parsed into object.
|
|
133
|
+
* This function downloads files from a URL.
|
|
138
134
|
*
|
|
135
|
+
* @param {string} url URL of the file to download.
|
|
136
|
+
* @returns {Promise<any>} Returns the JSON file downloaded and parsed into an object.
|
|
139
137
|
*
|
|
140
138
|
* **Code example**
|
|
141
139
|
*
|
|
142
140
|
* ```ts
|
|
143
141
|
* import { StorageClient } from '@human-protocol/sdk';
|
|
144
142
|
*
|
|
145
|
-
* const file = await
|
|
143
|
+
* const file = await StorageClient.downloadFileFromUrl('http://localhost/file.json');
|
|
146
144
|
* ```
|
|
147
145
|
*/
|
|
148
146
|
public static async downloadFileFromUrl(url: string): Promise<any> {
|
|
@@ -170,10 +168,9 @@ export class StorageClient {
|
|
|
170
168
|
/**
|
|
171
169
|
* This function uploads files to a bucket.
|
|
172
170
|
*
|
|
173
|
-
* @param {any[]} files Array of objects to upload serialized into
|
|
171
|
+
* @param {any[]} files Array of objects to upload serialized into JSON.
|
|
174
172
|
* @param {string} bucket Bucket name.
|
|
175
|
-
* @returns {UploadFile[]} Returns an array of
|
|
176
|
-
*
|
|
173
|
+
* @returns {Promise<UploadFile[]>} Returns an array of uploaded file metadata.
|
|
177
174
|
*
|
|
178
175
|
* **Code example**
|
|
179
176
|
*
|
|
@@ -240,8 +237,7 @@ export class StorageClient {
|
|
|
240
237
|
* This function checks if a bucket exists.
|
|
241
238
|
*
|
|
242
239
|
* @param {string} bucket Bucket name.
|
|
243
|
-
* @returns {boolean} Returns `true` if exists, `false` if it doesn't.
|
|
244
|
-
*
|
|
240
|
+
* @returns {Promise<boolean>} Returns `true` if exists, `false` if it doesn't.
|
|
245
241
|
*
|
|
246
242
|
* **Code example**
|
|
247
243
|
*
|
|
@@ -268,11 +264,10 @@ export class StorageClient {
|
|
|
268
264
|
}
|
|
269
265
|
|
|
270
266
|
/**
|
|
271
|
-
* This function
|
|
267
|
+
* This function lists all file names contained in the bucket.
|
|
272
268
|
*
|
|
273
269
|
* @param {string} bucket Bucket name.
|
|
274
|
-
* @returns {
|
|
275
|
-
*
|
|
270
|
+
* @returns {Promise<string[]>} Returns the list of file names contained in the bucket.
|
|
276
271
|
*
|
|
277
272
|
* **Code example**
|
|
278
273
|
*
|
package/src/transaction.ts
CHANGED
|
@@ -5,7 +5,7 @@ import { NETWORKS } from './constants';
|
|
|
5
5
|
import { ChainId, OrderDirection } from './enums';
|
|
6
6
|
import {
|
|
7
7
|
ErrorCannotUseDateAndBlockSimultaneously,
|
|
8
|
-
|
|
8
|
+
ErrorInvalidHashProvided,
|
|
9
9
|
ErrorUnsupportedChainID,
|
|
10
10
|
} from './error';
|
|
11
11
|
import {
|
|
@@ -36,7 +36,7 @@ export class TransactionUtils {
|
|
|
36
36
|
hash: string
|
|
37
37
|
): Promise<ITransaction> {
|
|
38
38
|
if (!ethers.isHexString(hash)) {
|
|
39
|
-
throw
|
|
39
|
+
throw ErrorInvalidHashProvided;
|
|
40
40
|
}
|
|
41
41
|
const networkData = NETWORKS[chainId];
|
|
42
42
|
|
package/src/types.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { TransactionLike } from 'ethers';
|
|
2
|
+
|
|
1
3
|
/**
|
|
2
4
|
* Enum for escrow statuses.
|
|
3
5
|
* @readonly
|
|
@@ -21,7 +23,7 @@ export enum EscrowStatus {
|
|
|
21
23
|
*/
|
|
22
24
|
Paid,
|
|
23
25
|
/**
|
|
24
|
-
* Escrow is finished
|
|
26
|
+
* Escrow is finished.
|
|
25
27
|
*/
|
|
26
28
|
Complete,
|
|
27
29
|
/**
|
|
@@ -124,7 +126,7 @@ export type NetworkData = {
|
|
|
124
126
|
*/
|
|
125
127
|
subgraphUrl: string;
|
|
126
128
|
/**
|
|
127
|
-
* Subgraph URL
|
|
129
|
+
* Subgraph URL API key
|
|
128
130
|
*/
|
|
129
131
|
subgraphUrlApiKey: string;
|
|
130
132
|
/**
|
|
@@ -168,3 +170,5 @@ export type EscrowWithdraw = {
|
|
|
168
170
|
*/
|
|
169
171
|
amountWithdrawn: bigint;
|
|
170
172
|
};
|
|
173
|
+
|
|
174
|
+
export type TransactionLikeWithNonce = TransactionLike & { nonce: number };
|