@human-protocol/sdk 1.0.4 → 1.0.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.
- package/dist/escrow.d.ts +8 -0
- package/dist/escrow.d.ts.map +1 -1
- package/dist/escrow.js +23 -0
- package/dist/staking.d.ts.map +1 -1
- package/dist/storage.d.ts.map +1 -1
- package/dist/storage.js +1 -0
- package/package.json +3 -5
- package/src/escrow.ts +29 -2
- package/src/staking.ts +1 -0
- package/src/storage.ts +1 -0
- package/test/escrow.test.ts +0 -1339
- package/test/init.test.ts +0 -88
- package/test/kvstore.test.ts +0 -208
- package/test/staking.test.ts +0 -640
- package/test/storage.test.ts +0 -422
- package/test/utils/constants.ts +0 -67
package/dist/escrow.d.ts
CHANGED
|
@@ -172,5 +172,13 @@ export default class EscrowClient {
|
|
|
172
172
|
* @throws {Error} - An error object if an error occurred.
|
|
173
173
|
*/
|
|
174
174
|
getRecordingOracleAddress(escrowAddress: string): Promise<string>;
|
|
175
|
+
/**
|
|
176
|
+
* Returns the reputation oracle address of given escrow
|
|
177
|
+
*
|
|
178
|
+
* @param {string} escrowAddress - Address of the escrow.
|
|
179
|
+
* @returns {Promise<string>} - Address of the reputation oracle.
|
|
180
|
+
* @throws {Error} - An error object if an error occurred.
|
|
181
|
+
*/
|
|
182
|
+
getReputationOracleAddress(escrowAddress: string): Promise<string>;
|
|
175
183
|
}
|
|
176
184
|
//# sourceMappingURL=escrow.d.ts.map
|
package/dist/escrow.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"escrow.d.ts","sourceRoot":"","sources":["../src/escrow.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"escrow.d.ts","sourceRoot":"","sources":["../src/escrow.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,SAAS,EAAmC,MAAM,QAAQ,CAAC;AAsBpE,OAAO,EACL,aAAa,EACb,aAAa,EACb,cAAc,EACd,sBAAsB,EAC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eof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
12
13
|
const typechain_types_1 = require("@human-protocol/core/typechain-types");
|
|
13
14
|
const ethers_1 = require("ethers");
|
|
14
15
|
const error_1 = require("./error");
|
|
@@ -526,6 +527,28 @@ class EscrowClient {
|
|
|
526
527
|
return (0, utils_1.throwError)(e);
|
|
527
528
|
}
|
|
528
529
|
}
|
|
530
|
+
/**
|
|
531
|
+
* Returns the reputation oracle address of given escrow
|
|
532
|
+
*
|
|
533
|
+
* @param {string} escrowAddress - Address of the escrow.
|
|
534
|
+
* @returns {Promise<string>} - Address of the reputation oracle.
|
|
535
|
+
* @throws {Error} - An error object if an error occurred.
|
|
536
|
+
*/
|
|
537
|
+
async getReputationOracleAddress(escrowAddress) {
|
|
538
|
+
if (!ethers_1.ethers.utils.isAddress(escrowAddress)) {
|
|
539
|
+
throw error_1.ErrorInvalidEscrowAddressProvided;
|
|
540
|
+
}
|
|
541
|
+
if (!(await this.escrowFactoryContract.hasEscrow(escrowAddress))) {
|
|
542
|
+
throw error_1.ErrorEscrowAddressIsNotProvidedByFactory;
|
|
543
|
+
}
|
|
544
|
+
try {
|
|
545
|
+
this.escrowContract = typechain_types_1.Escrow__factory.connect(escrowAddress, this.signerOrProvider);
|
|
546
|
+
return this.escrowContract.reputationOracle();
|
|
547
|
+
}
|
|
548
|
+
catch (e) {
|
|
549
|
+
return (0, utils_1.throwError)(e);
|
|
550
|
+
}
|
|
551
|
+
}
|
|
529
552
|
}
|
|
530
553
|
__decorate([
|
|
531
554
|
decorators_1.requiresSigner,
|
package/dist/staking.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"staking.d.ts","sourceRoot":"","sources":["../src/staking.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"staking.d.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AC,IAAI,CAAC;IAyBhB;;;;;;OAMG;IAEU,eAAe,CAAC,aAAa,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAiBlE;;;;;;OAMG;IAEU,iBAAiB,CAAC,aAAa,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAsBpE;;;;;;OAMG;IACU,SAAS,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IA6BxD;;;;;OAKG;IACU,aAAa,IAAI,OAAO,CAAC,OAAO,EAAE,CAAC;IA+BhD;;;;;;OAMG;IACU,aAAa,CAAC,aAAa,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC;IAiBvE;;;;;;OAMG;IACU,UAAU,CAAC,cAAc,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,EAAE,CAAC;CAqBpE"}
|
package/dist/storage.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"storage.d.ts","sourceRoot":"","sources":["../src/storage.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"storage.d.ts","sourceRoot":"","sources":["../src/storage.ts"],"names":[],"mappings":"AAWA,OAAO,EAAE,UAAU,EAAE,kBAAkB,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAIxE,MAAM,CAAC,OAAO,OAAO,aAAa;IAChC,OAAO,CAAC,MAAM,CAAe;IAE7B;;;;;OAKG;gBACS,WAAW,EAAE,kBAAkB,EAAE,MAAM,EAAE,aAAa;IAYlE;;;;;OAKG;IACU,aAAa,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC;IAoB1E;;;;;OAKG;WACiB,mBAAmB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC;IAsBlE;;;;;;OAMG;IACU,WAAW,CACtB,KAAK,EAAE,GAAG,EAAE,EACZ,MAAM,EAAE,MAAM,GACb,OAAO,CAAC,UAAU,EAAE,CAAC;IA0BxB;;;;;OAKG;IACU,YAAY,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAI3D;;;;;OAKG;IACU,WAAW,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC;CAqB5D"}
|
package/dist/storage.js
CHANGED
|
@@ -26,6 +26,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
26
26
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
27
|
};
|
|
28
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
29
30
|
const axios_1 = __importDefault(require("axios"));
|
|
30
31
|
const crypto_1 = __importDefault(require("crypto"));
|
|
31
32
|
const Minio = __importStar(require("minio"));
|
package/package.json
CHANGED
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@human-protocol/sdk",
|
|
3
3
|
"description": "Human Protocol SDK",
|
|
4
|
-
"version": "1.0.
|
|
4
|
+
"version": "1.0.6",
|
|
5
5
|
"files": [
|
|
6
6
|
"src",
|
|
7
|
-
"dist"
|
|
8
|
-
"example",
|
|
9
|
-
"test"
|
|
7
|
+
"dist"
|
|
10
8
|
],
|
|
11
9
|
"main": "dist/index.js",
|
|
12
10
|
"types": "dist/index.d.ts",
|
|
@@ -38,7 +36,7 @@
|
|
|
38
36
|
]
|
|
39
37
|
},
|
|
40
38
|
"dependencies": {
|
|
41
|
-
"@human-protocol/core": "
|
|
39
|
+
"@human-protocol/core": "*",
|
|
42
40
|
"aws-sdk": "^2.1255.0",
|
|
43
41
|
"crypto": "^1.0.1",
|
|
44
42
|
"ethers": "^5.7.2",
|
package/src/escrow.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
1
2
|
import {
|
|
2
3
|
HMToken__factory,
|
|
3
4
|
HMToken,
|
|
@@ -6,7 +7,7 @@ import {
|
|
|
6
7
|
EscrowFactory__factory,
|
|
7
8
|
Escrow__factory,
|
|
8
9
|
} from '@human-protocol/core/typechain-types';
|
|
9
|
-
import { BigNumber, ContractReceipt, Signer, ethers
|
|
10
|
+
import { BigNumber, ContractReceipt, Signer, ethers } from 'ethers';
|
|
10
11
|
import { Provider } from '@ethersproject/abstract-provider';
|
|
11
12
|
import {
|
|
12
13
|
ErrorAmountMustBeGreaterThanZero,
|
|
@@ -24,7 +25,6 @@ import {
|
|
|
24
25
|
ErrorListOfHandlersCannotBeEmpty,
|
|
25
26
|
ErrorRecipientAndAmountsMustBeSameLength,
|
|
26
27
|
ErrorRecipientCannotBeEmptyArray,
|
|
27
|
-
ErrorSigner,
|
|
28
28
|
ErrorTotalFeeMustBeLessThanHundred,
|
|
29
29
|
ErrorUrlIsEmptyString,
|
|
30
30
|
InvalidEthereumAddressError,
|
|
@@ -751,4 +751,31 @@ export default class EscrowClient {
|
|
|
751
751
|
return throwError(e);
|
|
752
752
|
}
|
|
753
753
|
}
|
|
754
|
+
|
|
755
|
+
/**
|
|
756
|
+
* Returns the reputation oracle address of given escrow
|
|
757
|
+
*
|
|
758
|
+
* @param {string} escrowAddress - Address of the escrow.
|
|
759
|
+
* @returns {Promise<string>} - Address of the reputation oracle.
|
|
760
|
+
* @throws {Error} - An error object if an error occurred.
|
|
761
|
+
*/
|
|
762
|
+
async getReputationOracleAddress(escrowAddress: string): Promise<string> {
|
|
763
|
+
if (!ethers.utils.isAddress(escrowAddress)) {
|
|
764
|
+
throw ErrorInvalidEscrowAddressProvided;
|
|
765
|
+
}
|
|
766
|
+
|
|
767
|
+
if (!(await this.escrowFactoryContract.hasEscrow(escrowAddress))) {
|
|
768
|
+
throw ErrorEscrowAddressIsNotProvidedByFactory;
|
|
769
|
+
}
|
|
770
|
+
|
|
771
|
+
try {
|
|
772
|
+
this.escrowContract = Escrow__factory.connect(
|
|
773
|
+
escrowAddress,
|
|
774
|
+
this.signerOrProvider
|
|
775
|
+
);
|
|
776
|
+
return this.escrowContract.reputationOracle();
|
|
777
|
+
} catch (e: any) {
|
|
778
|
+
return throwError(e);
|
|
779
|
+
}
|
|
780
|
+
}
|
|
754
781
|
}
|
package/src/staking.ts
CHANGED
package/src/storage.ts
CHANGED