@human-protocol/sdk 1.1.17 → 1.1.18
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/base.d.ts +29 -0
- package/dist/base.d.ts.map +1 -0
- package/dist/base.js +37 -0
- package/dist/error.d.ts +8 -0
- package/dist/error.d.ts.map +1 -1
- package/dist/error.js +9 -1
- package/dist/escrow.d.ts +13 -6
- package/dist/escrow.d.ts.map +1 -1
- package/dist/escrow.js +84 -50
- package/dist/kvstore.d.ts +60 -4
- package/dist/kvstore.d.ts.map +1 -1
- package/dist/kvstore.js +124 -8
- package/dist/staking.d.ts +17 -8
- package/dist/staking.d.ts.map +1 -1
- package/dist/staking.js +61 -54
- package/dist/statistics.d.ts +3 -3
- package/dist/statistics.d.ts.map +1 -1
- package/dist/statistics.js +10 -10
- package/dist/storage.d.ts.map +1 -1
- package/dist/storage.js +1 -0
- package/dist/utils.d.ts +8 -0
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +22 -2
- package/package.json +2 -1
- package/src/base.ts +49 -0
- package/src/error.ts +9 -0
- package/src/escrow.ts +116 -115
- package/src/kvstore.ts +141 -9
- package/src/staking.ts +74 -64
- package/src/statistics.ts +11 -11
- package/src/storage.ts +1 -0
- package/src/utils.ts +29 -1
package/dist/base.d.ts
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { Provider } from '@ethersproject/abstract-provider';
|
|
2
|
+
import { Signer, ethers } from 'ethers';
|
|
3
|
+
import { NetworkData } from './types';
|
|
4
|
+
/**
|
|
5
|
+
* ## Introduction
|
|
6
|
+
*
|
|
7
|
+
* This class is used as a base class for other clients making on-chain calls.
|
|
8
|
+
*
|
|
9
|
+
*/
|
|
10
|
+
export declare abstract class BaseEthersClient {
|
|
11
|
+
protected signerOrProvider: Signer | Provider;
|
|
12
|
+
protected gasPriceMultiplier?: number;
|
|
13
|
+
networkData: NetworkData;
|
|
14
|
+
/**
|
|
15
|
+
* **BaseClient constructor**
|
|
16
|
+
*
|
|
17
|
+
* @param {Signer | Provider} signerOrProvider The Signer or Provider object to interact with the Ethereum network
|
|
18
|
+
* @param {NetworkData} networkData The network information required to connect to the contracts
|
|
19
|
+
* @param {number | undefined} gasPriceMultiplier The multiplier to apply to the gas price
|
|
20
|
+
*/
|
|
21
|
+
constructor(signerOrProvider: Signer | Provider, networkData: NetworkData, gasPriceMultiplier?: number);
|
|
22
|
+
/**
|
|
23
|
+
* Adjust the gas price, and return as an option to be passed to a transaction
|
|
24
|
+
*
|
|
25
|
+
* @returns {Promise<{ gasPrice: BigNumber }>} Returns the gas price options
|
|
26
|
+
*/
|
|
27
|
+
protected gasPriceOptions(): Promise<Partial<ethers.Overrides>>;
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=base.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"base.d.ts","sourceRoot":"","sources":["../src/base.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,kCAAkC,CAAC;AAC5D,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AACxC,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAGtC;;;;;GAKG;AACH,8BAAsB,gBAAgB;IACpC,SAAS,CAAC,gBAAgB,EAAE,MAAM,GAAG,QAAQ,CAAC;IAC9C,SAAS,CAAC,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC/B,WAAW,EAAE,WAAW,CAAC;IAEhC;;;;;;OAMG;gBAED,gBAAgB,EAAE,MAAM,GAAG,QAAQ,EACnC,WAAW,EAAE,WAAW,EACxB,kBAAkB,CAAC,EAAE,MAAM;IAO7B;;;;OAIG;cACa,eAAe,IAAI,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;CAUtE"}
|
package/dist/base.js
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.BaseEthersClient = void 0;
|
|
4
|
+
const utils_1 = require("./utils");
|
|
5
|
+
/**
|
|
6
|
+
* ## Introduction
|
|
7
|
+
*
|
|
8
|
+
* This class is used as a base class for other clients making on-chain calls.
|
|
9
|
+
*
|
|
10
|
+
*/
|
|
11
|
+
class BaseEthersClient {
|
|
12
|
+
/**
|
|
13
|
+
* **BaseClient constructor**
|
|
14
|
+
*
|
|
15
|
+
* @param {Signer | Provider} signerOrProvider The Signer or Provider object to interact with the Ethereum network
|
|
16
|
+
* @param {NetworkData} networkData The network information required to connect to the contracts
|
|
17
|
+
* @param {number | undefined} gasPriceMultiplier The multiplier to apply to the gas price
|
|
18
|
+
*/
|
|
19
|
+
constructor(signerOrProvider, networkData, gasPriceMultiplier) {
|
|
20
|
+
this.networkData = networkData;
|
|
21
|
+
this.signerOrProvider = signerOrProvider;
|
|
22
|
+
this.gasPriceMultiplier = gasPriceMultiplier;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Adjust the gas price, and return as an option to be passed to a transaction
|
|
26
|
+
*
|
|
27
|
+
* @returns {Promise<{ gasPrice: BigNumber }>} Returns the gas price options
|
|
28
|
+
*/
|
|
29
|
+
async gasPriceOptions() {
|
|
30
|
+
return this.gasPriceMultiplier
|
|
31
|
+
? {
|
|
32
|
+
gasPrice: await (0, utils_1.gasPriceAdjusted)(this.signerOrProvider, this.gasPriceMultiplier),
|
|
33
|
+
}
|
|
34
|
+
: {};
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
exports.BaseEthersClient = BaseEthersClient;
|
package/dist/error.d.ts
CHANGED
|
@@ -201,4 +201,12 @@ export declare class ContractExecutionError extends EthereumError {
|
|
|
201
201
|
export declare class InvalidEthereumAddressError extends Error {
|
|
202
202
|
constructor(address: string);
|
|
203
203
|
}
|
|
204
|
+
/**
|
|
205
|
+
* @constant {Error} - The Hash does not match
|
|
206
|
+
*/
|
|
207
|
+
export declare const ErrorInvalidHash: Error;
|
|
208
|
+
/**
|
|
209
|
+
* @constant {Error} - The Hash does not match
|
|
210
|
+
*/
|
|
211
|
+
export declare const ErrorMissingGasPrice: Error;
|
|
204
212
|
//# sourceMappingURL=error.d.ts.map
|
package/dist/error.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"error.d.ts","sourceRoot":"","sources":["../src/error.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,eAAO,MAAM,mBAAmB,OAA2C,CAAC;AAE5E;;GAEG;AACH,eAAO,MAAM,gCAAgC,OAE5C,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,2BAA2B,OAEvC,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,8BAA8B,OAE1C,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,0BAA0B,OAAgC,CAAC;AAExE;;GAEG;AACH,eAAO,MAAM,wBAAwB,OAA8B,CAAC;AAEpE;;GAEG;AACH,eAAO,MAAM,2BAA2B,OAAiC,CAAC;AAE1E;;GAEG;AACH,eAAO,MAAM,oBAAoB,OAAoC,CAAC;AAEtE;;GAEG;AACH,eAAO,MAAM,uBAAuB,OAEnC,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,mBAAmB,OAA+B,CAAC;AAEhE;;GAEG;AACH,eAAO,MAAM,wBAAwB,OAAqC,CAAC;AAE3E;;GAEG;AACH,eAAO,MAAM,0CAA0C,OAEtD,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,2CAA2C,OAEvD,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,yCAAyC,OAErD,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,+BAA+B,OAE3C,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,4BAA4B,OAExC,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,4BAA4B,OAExC,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,kCAAkC,OAE9C,CAAC;AAEF;;GAEG;AACH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a,2BAA4B,SAAQ,KAAK;gBACxC,OAAO,EAAE,MAAM;CAG5B;AACD;;GAEG;AACH,eAAO,MAAM,gBAAgB,OAA4B,CAAC;AAE1D;;GAEG;AACH,eAAO,MAAM,oBAAoB,OAAiC,CAAC"}
|
package/dist/error.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.NumericFault = exports.ReplacementUnderpriced = exports.UnpredictableGasLimit = exports.OutOfGasError = exports.InvalidArgumentError = exports.EthereumError = exports.ErrorHashIsEmptyString = exports.ErrorLaunchedEventIsNotEmitted = exports.ErrorRecipientAndAmountsMustBeSameLength = exports.ErrorAmountsCannotBeEmptyArray = exports.ErrorEscrowDoesNotHaveEnoughBalance = exports.ErrorAmountMustBeGreaterThanZero = exports.ErrorRecipientCannotBeEmptyArray = exports.ErrorTotalFeeMustBeLessThanHundred = exports.ErrorFeeMustBeBetweenZeroAndHundred = exports.ErrorNoURLprovided = exports.ErrorListOfHandlersCannotBeEmpty = exports.ErrorUrlIsEmptyString = exports.ErrorInvalidUrl = exports.ErrorStorageClientDoesNotExist = exports.ErrorManifestFileDoesNotExist = exports.ErrorTransferEventNotFoundInTransactionLogs = exports.ErrorEscrowAddressIsNotProvidedByFactory = exports.ErrorSigner = exports.ErrorUnsupportedChainID = exports.ErrorProviderDoesNotExist = exports.ErrorHMTokenAmountNotApproved = exports.ErrorFailedToCheckAllowance = exports.ErrorFailedToApproveStakingAmountSignerDoesNotExist = exports.ErrorStakingGetStakers = exports.ErrorInvalidEscrowAddressProvided = exports.ErrorInvalidStakerAddressProvided = exports.ErrorInvalidSlasherAddressProvided = exports.ErrorInvalidStakingValueSign = exports.ErrorInvalidStakingValueType = exports.ErrorStakingValueMustBePositive = exports.ErrorInvalidExchangeOracleAddressProvided = exports.ErrorInvalidReputationOracleAddressProvided = exports.ErrorInvalidRecordingOracleAddressProvided = exports.ErrorInvalidTokenAddress = exports.ErrorInvalidAddress = exports.ErrorKVStoreArrayLength = exports.ErrorKVStoreEmptyKey = exports.ErrorStorageFileNotUploaded = exports.ErrorStorageFileNotFound = exports.ErrorStorageBucketNotFound = exports.ErrorStorageCredentialsMissing = exports.ErrorStorageClientNotExists = exports.ErrorStorageClientNotInitialized = exports.ErrorStakingMissing = void 0;
|
|
4
|
-
exports.InvalidEthereumAddressError = exports.ContractExecutionError = exports.TransactionReplaced = exports.NonceExpired = void 0;
|
|
4
|
+
exports.ErrorMissingGasPrice = exports.ErrorInvalidHash = exports.InvalidEthereumAddressError = exports.ContractExecutionError = exports.TransactionReplaced = exports.NonceExpired = void 0;
|
|
5
5
|
/**
|
|
6
6
|
* @constant {Error} - The Staking contract is missing.
|
|
7
7
|
*/
|
|
@@ -235,3 +235,11 @@ class InvalidEthereumAddressError extends Error {
|
|
|
235
235
|
}
|
|
236
236
|
}
|
|
237
237
|
exports.InvalidEthereumAddressError = InvalidEthereumAddressError;
|
|
238
|
+
/**
|
|
239
|
+
* @constant {Error} - The Hash does not match
|
|
240
|
+
*/
|
|
241
|
+
exports.ErrorInvalidHash = new Error('Invalid hash');
|
|
242
|
+
/**
|
|
243
|
+
* @constant {Error} - The Hash does not match
|
|
244
|
+
*/
|
|
245
|
+
exports.ErrorMissingGasPrice = new Error('Missing gas price');
|
package/dist/escrow.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Provider } from '@ethersproject/abstract-provider';
|
|
2
2
|
import { BigNumber, Signer } from 'ethers';
|
|
3
|
+
import { BaseEthersClient } from './base';
|
|
3
4
|
import { ChainId } from './enums';
|
|
4
5
|
import { IEscrowConfig, IEscrowsFilter } from './interfaces';
|
|
5
6
|
import { EscrowCancel, EscrowStatus, NetworkData } from './types';
|
|
@@ -73,27 +74,33 @@ import { EscrowData } from './graphql';
|
|
|
73
74
|
* const escrowClient = await EscrowClient.build(provider);
|
|
74
75
|
* ```
|
|
75
76
|
*/
|
|
76
|
-
export declare class EscrowClient {
|
|
77
|
+
export declare class EscrowClient extends BaseEthersClient {
|
|
77
78
|
private escrowFactoryContract;
|
|
78
|
-
private escrowContract?;
|
|
79
|
-
private signerOrProvider;
|
|
80
|
-
network: NetworkData;
|
|
81
79
|
/**
|
|
82
80
|
* **EscrowClient constructor**
|
|
83
81
|
*
|
|
84
82
|
* @param {Signer | Provider} signerOrProvider The Signer or Provider object to interact with the Ethereum network
|
|
85
83
|
* @param {NetworkData} network The network information required to connect to the Escrow contract
|
|
84
|
+
* @param {number | undefined} gasPriceMultiplier The multiplier to apply to the gas price
|
|
86
85
|
*/
|
|
87
|
-
constructor(signerOrProvider: Signer | Provider,
|
|
86
|
+
constructor(signerOrProvider: Signer | Provider, networkData: NetworkData, gasPriceMultiplier?: number);
|
|
88
87
|
/**
|
|
89
88
|
* Creates an instance of EscrowClient from a Signer or Provider.
|
|
90
89
|
*
|
|
91
90
|
* @param {Signer | Provider} signerOrProvider The Signer or Provider object to interact with the Ethereum network
|
|
91
|
+
* @param {number | undefined} gasPriceMultiplier The multiplier to apply to the gas price
|
|
92
|
+
*
|
|
92
93
|
* @returns {Promise<EscrowClient>} An instance of EscrowClient
|
|
93
94
|
* @throws {ErrorProviderDoesNotExist} Thrown if the provider does not exist for the provided Signer
|
|
94
95
|
* @throws {ErrorUnsupportedChainID} Thrown if the network's chainId is not supported
|
|
95
96
|
*/
|
|
96
|
-
static build(signerOrProvider: Signer | Provider): Promise<EscrowClient>;
|
|
97
|
+
static build(signerOrProvider: Signer | Provider, gasPriceMultiplier?: number): Promise<EscrowClient>;
|
|
98
|
+
/**
|
|
99
|
+
* Connects to the escrow contract
|
|
100
|
+
*
|
|
101
|
+
* @param escrowAddress Escrow address to connect to
|
|
102
|
+
*/
|
|
103
|
+
private getEscrowContract;
|
|
97
104
|
/**
|
|
98
105
|
* This function creates an escrow contract that uses the token passed to pay oracle fees and reward workers.
|
|
99
106
|
*
|
package/dist/escrow.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"escrow.d.ts","sourceRoot":"","sources":["../src/escrow.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,kCAAkC,CAAC;AAU5D,OAAO,EAAE,SAAS,EAAmB,MAAM,EAAU,MAAM,QAAQ,CAAC;
|
|
1
|
+
{"version":3,"file":"escrow.d.ts","sourceRoot":"","sources":["../src/escrow.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,kCAAkC,CAAC;AAU5D,OAAO,EAAE,SAAS,EAAmB,MAAM,EAAU,MAAM,QAAQ,CAAC;AAEpE,OAAO,EAAE,gBAAgB,EAAE,MAAM,QAAQ,CAAC;AAG1C,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAyBlC,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAC7D,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAElE,OAAO,EACL,UAAU,EAGX,MAAM,WAAW,CAAC;AAEnB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoEG;AACH,qBAAa,YAAa,SAAQ,gBAAgB;IAChD,OAAO,CAAC,qBAAqB,CAAgB;IAE7C;;;;;;OAMG;gBAED,gBAAgB,EAAE,MAAM,GAAG,QAAQ,EACnC,WAAW,EAAE,WAAW,EACxB,kBAAkB,CAAC,EAAE,MAAM;IAU7B;;;;;;;;;OASG;WACiB,KAAK,CACvB,gBAAgB,EAAE,MAAM,GAAG,QAAQ,EACnC,kBAAkB,CAAC,EAAE,MAAM;IAuB7B;;;;OAIG;IACH,OAAO,CAAC,iBAAiB;IAQzB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA6BG;IAEU,YAAY,CACvB,YAAY,EAAE,MAAM,EACpB,eAAe,EAAE,MAAM,EAAE,EACzB,cAAc,EAA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wBAAwB,CAAC,aAAa,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAkBtE;;;;;;;;;;;;;;;;;;;OAmBG;IACG,iBAAiB,CAAC,aAAa,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;CAiBhE;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,qBAAa,WAAW;IACtB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAgGG;WACiB,UAAU,CAC5B,MAAM,EAAE,cAAc,GACrB,OAAO,CAAC,UAAU,EAAE,CAAC;IAmExB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAmEG;WACiB,SAAS,CAC3B,OAAO,EAAE,OAAO,EAChB,aAAa,EAAE,MAAM,GACpB,OAAO,CAAC,UAAU,CAAC;CAuBvB"}
|
package/dist/escrow.js
CHANGED
|
@@ -16,6 +16,7 @@ exports.EscrowUtils = exports.EscrowClient = void 0;
|
|
|
16
16
|
const typechain_types_1 = require("@human-protocol/core/typechain-types");
|
|
17
17
|
const ethers_1 = require("ethers");
|
|
18
18
|
const graphql_request_1 = __importDefault(require("graphql-request"));
|
|
19
|
+
const base_1 = require("./base");
|
|
19
20
|
const constants_1 = require("./constants");
|
|
20
21
|
const decorators_1 = require("./decorators");
|
|
21
22
|
const error_1 = require("./error");
|
|
@@ -91,27 +92,29 @@ const graphql_1 = require("./graphql");
|
|
|
91
92
|
* const escrowClient = await EscrowClient.build(provider);
|
|
92
93
|
* ```
|
|
93
94
|
*/
|
|
94
|
-
class EscrowClient {
|
|
95
|
+
class EscrowClient extends base_1.BaseEthersClient {
|
|
95
96
|
/**
|
|
96
97
|
* **EscrowClient constructor**
|
|
97
98
|
*
|
|
98
99
|
* @param {Signer | Provider} signerOrProvider The Signer or Provider object to interact with the Ethereum network
|
|
99
100
|
* @param {NetworkData} network The network information required to connect to the Escrow contract
|
|
101
|
+
* @param {number | undefined} gasPriceMultiplier The multiplier to apply to the gas price
|
|
100
102
|
*/
|
|
101
|
-
constructor(signerOrProvider,
|
|
102
|
-
|
|
103
|
-
this.
|
|
104
|
-
this.signerOrProvider = signerOrProvider;
|
|
103
|
+
constructor(signerOrProvider, networkData, gasPriceMultiplier) {
|
|
104
|
+
super(signerOrProvider, networkData, gasPriceMultiplier);
|
|
105
|
+
this.escrowFactoryContract = typechain_types_1.EscrowFactory__factory.connect(networkData.factoryAddress, signerOrProvider);
|
|
105
106
|
}
|
|
106
107
|
/**
|
|
107
108
|
* Creates an instance of EscrowClient from a Signer or Provider.
|
|
108
109
|
*
|
|
109
110
|
* @param {Signer | Provider} signerOrProvider The Signer or Provider object to interact with the Ethereum network
|
|
111
|
+
* @param {number | undefined} gasPriceMultiplier The multiplier to apply to the gas price
|
|
112
|
+
*
|
|
110
113
|
* @returns {Promise<EscrowClient>} An instance of EscrowClient
|
|
111
114
|
* @throws {ErrorProviderDoesNotExist} Thrown if the provider does not exist for the provided Signer
|
|
112
115
|
* @throws {ErrorUnsupportedChainID} Thrown if the network's chainId is not supported
|
|
113
116
|
*/
|
|
114
|
-
static async build(signerOrProvider) {
|
|
117
|
+
static async build(signerOrProvider, gasPriceMultiplier) {
|
|
115
118
|
let network;
|
|
116
119
|
if (ethers_1.Signer.isSigner(signerOrProvider)) {
|
|
117
120
|
if (!signerOrProvider.provider) {
|
|
@@ -127,7 +130,20 @@ class EscrowClient {
|
|
|
127
130
|
if (!networkData) {
|
|
128
131
|
throw error_1.ErrorUnsupportedChainID;
|
|
129
132
|
}
|
|
130
|
-
return new EscrowClient(signerOrProvider, networkData);
|
|
133
|
+
return new EscrowClient(signerOrProvider, networkData, gasPriceMultiplier);
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* Connects to the escrow contract
|
|
137
|
+
*
|
|
138
|
+
* @param escrowAddress Escrow address to connect to
|
|
139
|
+
*/
|
|
140
|
+
getEscrowContract(escrowAddress) {
|
|
141
|
+
try {
|
|
142
|
+
return typechain_types_1.Escrow__factory.connect(escrowAddress, this.signerOrProvider);
|
|
143
|
+
}
|
|
144
|
+
catch (e) {
|
|
145
|
+
return (0, utils_1.throwError)(e);
|
|
146
|
+
}
|
|
131
147
|
}
|
|
132
148
|
/**
|
|
133
149
|
* This function creates an escrow contract that uses the token passed to pay oracle fees and reward workers.
|
|
@@ -169,7 +185,9 @@ class EscrowClient {
|
|
|
169
185
|
}
|
|
170
186
|
});
|
|
171
187
|
try {
|
|
172
|
-
const result = await (await this.escrowFactoryContract.createEscrow(tokenAddress, trustedHandlers, jobRequesterId
|
|
188
|
+
const result = await (await this.escrowFactoryContract.createEscrow(tokenAddress, trustedHandlers, jobRequesterId, {
|
|
189
|
+
...(await this.gasPriceOptions()),
|
|
190
|
+
})).wait();
|
|
173
191
|
const event = result.events?.find(({ topics }) => topics.includes(ethers_1.ethers.utils.id('LaunchedV2(address,address,string)')))?.args;
|
|
174
192
|
if (!event) {
|
|
175
193
|
throw error_1.ErrorLaunchedEventIsNotEmitted;
|
|
@@ -252,8 +270,10 @@ class EscrowClient {
|
|
|
252
270
|
throw error_1.ErrorEscrowAddressIsNotProvidedByFactory;
|
|
253
271
|
}
|
|
254
272
|
try {
|
|
255
|
-
|
|
256
|
-
await
|
|
273
|
+
const escrowContract = this.getEscrowContract(escrowAddress);
|
|
274
|
+
await escrowContract.setup(reputationOracle, recordingOracle, exchangeOracle, reputationOracleFee, recordingOracleFee, exchangeOracleFee, manifestUrl, manifestHash, {
|
|
275
|
+
...(await this.gasPriceOptions()),
|
|
276
|
+
});
|
|
257
277
|
return;
|
|
258
278
|
}
|
|
259
279
|
catch (e) {
|
|
@@ -347,10 +367,12 @@ class EscrowClient {
|
|
|
347
367
|
throw error_1.ErrorEscrowAddressIsNotProvidedByFactory;
|
|
348
368
|
}
|
|
349
369
|
try {
|
|
350
|
-
|
|
351
|
-
const tokenAddress = await
|
|
370
|
+
const escrowContract = this.getEscrowContract(escrowAddress);
|
|
371
|
+
const tokenAddress = await escrowContract.token();
|
|
352
372
|
const tokenContract = typechain_types_1.HMToken__factory.connect(tokenAddress, this.signerOrProvider);
|
|
353
|
-
await tokenContract.transfer(escrowAddress, amount
|
|
373
|
+
await tokenContract.transfer(escrowAddress, amount, {
|
|
374
|
+
...(await this.gasPriceOptions()),
|
|
375
|
+
});
|
|
354
376
|
return;
|
|
355
377
|
}
|
|
356
378
|
catch (e) {
|
|
@@ -401,8 +423,10 @@ class EscrowClient {
|
|
|
401
423
|
throw error_1.ErrorEscrowAddressIsNotProvidedByFactory;
|
|
402
424
|
}
|
|
403
425
|
try {
|
|
404
|
-
|
|
405
|
-
await
|
|
426
|
+
const escrowContract = this.getEscrowContract(escrowAddress);
|
|
427
|
+
await escrowContract.storeResults(url, hash, {
|
|
428
|
+
...(await this.gasPriceOptions()),
|
|
429
|
+
});
|
|
406
430
|
return;
|
|
407
431
|
}
|
|
408
432
|
catch (e) {
|
|
@@ -442,8 +466,10 @@ class EscrowClient {
|
|
|
442
466
|
throw error_1.ErrorEscrowAddressIsNotProvidedByFactory;
|
|
443
467
|
}
|
|
444
468
|
try {
|
|
445
|
-
|
|
446
|
-
await
|
|
469
|
+
const escrowContract = this.getEscrowContract(escrowAddress);
|
|
470
|
+
await escrowContract.complete({
|
|
471
|
+
...(await this.gasPriceOptions()),
|
|
472
|
+
});
|
|
447
473
|
return;
|
|
448
474
|
}
|
|
449
475
|
catch (e) {
|
|
@@ -523,8 +549,10 @@ class EscrowClient {
|
|
|
523
549
|
throw error_1.ErrorEscrowAddressIsNotProvidedByFactory;
|
|
524
550
|
}
|
|
525
551
|
try {
|
|
526
|
-
|
|
527
|
-
await
|
|
552
|
+
const escrowContract = this.getEscrowContract(escrowAddress);
|
|
553
|
+
await escrowContract.bulkPayOut(recipients, amounts, finalResultsUrl, finalResultsHash, constants_1.DEFAULT_TX_ID, {
|
|
554
|
+
...(await this.gasPriceOptions()),
|
|
555
|
+
});
|
|
528
556
|
return;
|
|
529
557
|
}
|
|
530
558
|
catch (e) {
|
|
@@ -564,11 +592,13 @@ class EscrowClient {
|
|
|
564
592
|
throw error_1.ErrorEscrowAddressIsNotProvidedByFactory;
|
|
565
593
|
}
|
|
566
594
|
try {
|
|
567
|
-
|
|
568
|
-
const tx = await
|
|
595
|
+
const escrowContract = this.getEscrowContract(escrowAddress);
|
|
596
|
+
const tx = await escrowContract.cancel({
|
|
597
|
+
...(await this.gasPriceOptions()),
|
|
598
|
+
});
|
|
569
599
|
const transactionReceipt = await tx.wait();
|
|
570
600
|
let amountTransferred = undefined;
|
|
571
|
-
const tokenAddress = await
|
|
601
|
+
const tokenAddress = await escrowContract.token();
|
|
572
602
|
const tokenContract = typechain_types_1.HMToken__factory.connect(tokenAddress, this.signerOrProvider);
|
|
573
603
|
for (const log of transactionReceipt.logs) {
|
|
574
604
|
if (log.address === tokenAddress) {
|
|
@@ -626,8 +656,10 @@ class EscrowClient {
|
|
|
626
656
|
throw error_1.ErrorEscrowAddressIsNotProvidedByFactory;
|
|
627
657
|
}
|
|
628
658
|
try {
|
|
629
|
-
|
|
630
|
-
await
|
|
659
|
+
const escrowContract = this.getEscrowContract(escrowAddress);
|
|
660
|
+
await escrowContract.abort({
|
|
661
|
+
...(await this.gasPriceOptions()),
|
|
662
|
+
});
|
|
631
663
|
return;
|
|
632
664
|
}
|
|
633
665
|
catch (e) {
|
|
@@ -677,8 +709,10 @@ class EscrowClient {
|
|
|
677
709
|
throw error_1.ErrorEscrowAddressIsNotProvidedByFactory;
|
|
678
710
|
}
|
|
679
711
|
try {
|
|
680
|
-
|
|
681
|
-
await
|
|
712
|
+
const escrowContract = this.getEscrowContract(escrowAddress);
|
|
713
|
+
await escrowContract.addTrustedHandlers(trustedHandlers, {
|
|
714
|
+
...(await this.gasPriceOptions()),
|
|
715
|
+
});
|
|
682
716
|
return;
|
|
683
717
|
}
|
|
684
718
|
catch (e) {
|
|
@@ -713,8 +747,8 @@ class EscrowClient {
|
|
|
713
747
|
throw error_1.ErrorEscrowAddressIsNotProvidedByFactory;
|
|
714
748
|
}
|
|
715
749
|
try {
|
|
716
|
-
|
|
717
|
-
return
|
|
750
|
+
const escrowContract = this.getEscrowContract(escrowAddress);
|
|
751
|
+
return escrowContract.getBalance();
|
|
718
752
|
}
|
|
719
753
|
catch (e) {
|
|
720
754
|
return (0, utils_1.throwError)(e);
|
|
@@ -748,8 +782,8 @@ class EscrowClient {
|
|
|
748
782
|
throw error_1.ErrorEscrowAddressIsNotProvidedByFactory;
|
|
749
783
|
}
|
|
750
784
|
try {
|
|
751
|
-
|
|
752
|
-
return
|
|
785
|
+
const escrowContract = this.getEscrowContract(escrowAddress);
|
|
786
|
+
return escrowContract.manifestHash();
|
|
753
787
|
}
|
|
754
788
|
catch (e) {
|
|
755
789
|
return (0, utils_1.throwError)(e);
|
|
@@ -783,8 +817,8 @@ class EscrowClient {
|
|
|
783
817
|
throw error_1.ErrorEscrowAddressIsNotProvidedByFactory;
|
|
784
818
|
}
|
|
785
819
|
try {
|
|
786
|
-
|
|
787
|
-
return
|
|
820
|
+
const escrowContract = this.getEscrowContract(escrowAddress);
|
|
821
|
+
return escrowContract.manifestUrl();
|
|
788
822
|
}
|
|
789
823
|
catch (e) {
|
|
790
824
|
return (0, utils_1.throwError)(e);
|
|
@@ -818,8 +852,8 @@ class EscrowClient {
|
|
|
818
852
|
throw error_1.ErrorEscrowAddressIsNotProvidedByFactory;
|
|
819
853
|
}
|
|
820
854
|
try {
|
|
821
|
-
|
|
822
|
-
return
|
|
855
|
+
const escrowContract = this.getEscrowContract(escrowAddress);
|
|
856
|
+
return escrowContract.finalResultsUrl();
|
|
823
857
|
}
|
|
824
858
|
catch (e) {
|
|
825
859
|
return (0, utils_1.throwError)(e);
|
|
@@ -853,8 +887,8 @@ class EscrowClient {
|
|
|
853
887
|
throw error_1.ErrorEscrowAddressIsNotProvidedByFactory;
|
|
854
888
|
}
|
|
855
889
|
try {
|
|
856
|
-
|
|
857
|
-
return
|
|
890
|
+
const escrowContract = this.getEscrowContract(escrowAddress);
|
|
891
|
+
return escrowContract.intermediateResultsUrl();
|
|
858
892
|
}
|
|
859
893
|
catch (e) {
|
|
860
894
|
return (0, utils_1.throwError)(e);
|
|
@@ -888,8 +922,8 @@ class EscrowClient {
|
|
|
888
922
|
throw error_1.ErrorEscrowAddressIsNotProvidedByFactory;
|
|
889
923
|
}
|
|
890
924
|
try {
|
|
891
|
-
|
|
892
|
-
return
|
|
925
|
+
const escrowContract = this.getEscrowContract(escrowAddress);
|
|
926
|
+
return escrowContract.token();
|
|
893
927
|
}
|
|
894
928
|
catch (e) {
|
|
895
929
|
return (0, utils_1.throwError)(e);
|
|
@@ -923,8 +957,8 @@ class EscrowClient {
|
|
|
923
957
|
throw error_1.ErrorEscrowAddressIsNotProvidedByFactory;
|
|
924
958
|
}
|
|
925
959
|
try {
|
|
926
|
-
|
|
927
|
-
return
|
|
960
|
+
const escrowContract = this.getEscrowContract(escrowAddress);
|
|
961
|
+
return escrowContract.status();
|
|
928
962
|
}
|
|
929
963
|
catch (e) {
|
|
930
964
|
return (0, utils_1.throwError)(e);
|
|
@@ -958,8 +992,8 @@ class EscrowClient {
|
|
|
958
992
|
throw error_1.ErrorEscrowAddressIsNotProvidedByFactory;
|
|
959
993
|
}
|
|
960
994
|
try {
|
|
961
|
-
|
|
962
|
-
return
|
|
995
|
+
const escrowContract = this.getEscrowContract(escrowAddress);
|
|
996
|
+
return escrowContract.recordingOracle();
|
|
963
997
|
}
|
|
964
998
|
catch (e) {
|
|
965
999
|
return (0, utils_1.throwError)(e);
|
|
@@ -993,8 +1027,8 @@ class EscrowClient {
|
|
|
993
1027
|
throw error_1.ErrorEscrowAddressIsNotProvidedByFactory;
|
|
994
1028
|
}
|
|
995
1029
|
try {
|
|
996
|
-
|
|
997
|
-
return
|
|
1030
|
+
const escrowContract = this.getEscrowContract(escrowAddress);
|
|
1031
|
+
return escrowContract.launcher();
|
|
998
1032
|
}
|
|
999
1033
|
catch (e) {
|
|
1000
1034
|
return (0, utils_1.throwError)(e);
|
|
@@ -1028,8 +1062,8 @@ class EscrowClient {
|
|
|
1028
1062
|
throw error_1.ErrorEscrowAddressIsNotProvidedByFactory;
|
|
1029
1063
|
}
|
|
1030
1064
|
try {
|
|
1031
|
-
|
|
1032
|
-
return
|
|
1065
|
+
const escrowContract = this.getEscrowContract(escrowAddress);
|
|
1066
|
+
return escrowContract.reputationOracle();
|
|
1033
1067
|
}
|
|
1034
1068
|
catch (e) {
|
|
1035
1069
|
return (0, utils_1.throwError)(e);
|
|
@@ -1063,8 +1097,8 @@ class EscrowClient {
|
|
|
1063
1097
|
throw error_1.ErrorEscrowAddressIsNotProvidedByFactory;
|
|
1064
1098
|
}
|
|
1065
1099
|
try {
|
|
1066
|
-
|
|
1067
|
-
return
|
|
1100
|
+
const escrowContract = this.getEscrowContract(escrowAddress);
|
|
1101
|
+
return escrowContract.exchangeOracle();
|
|
1068
1102
|
}
|
|
1069
1103
|
catch (e) {
|
|
1070
1104
|
return (0, utils_1.throwError)(e);
|
|
@@ -1098,8 +1132,8 @@ class EscrowClient {
|
|
|
1098
1132
|
throw error_1.ErrorEscrowAddressIsNotProvidedByFactory;
|
|
1099
1133
|
}
|
|
1100
1134
|
try {
|
|
1101
|
-
|
|
1102
|
-
return
|
|
1135
|
+
const escrowContract = this.getEscrowContract(escrowAddress);
|
|
1136
|
+
return escrowContract.escrowFactory();
|
|
1103
1137
|
}
|
|
1104
1138
|
catch (e) {
|
|
1105
1139
|
return (0, utils_1.throwError)(e);
|
package/dist/kvstore.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Provider } from '@ethersproject/abstract-provider';
|
|
2
2
|
import { Signer } from 'ethers';
|
|
3
|
+
import { BaseEthersClient } from './base';
|
|
3
4
|
import { NetworkData } from './types';
|
|
4
5
|
/**
|
|
5
6
|
* ## Introduction
|
|
@@ -70,25 +71,27 @@ import { NetworkData } from './types';
|
|
|
70
71
|
* const kvstoreClient = await KVStoreClient.build(signer);
|
|
71
72
|
* ```
|
|
72
73
|
*/
|
|
73
|
-
export declare class KVStoreClient {
|
|
74
|
+
export declare class KVStoreClient extends BaseEthersClient {
|
|
74
75
|
private contract;
|
|
75
|
-
private signerOrProvider;
|
|
76
76
|
/**
|
|
77
77
|
* **KVStoreClient constructor**
|
|
78
78
|
*
|
|
79
79
|
* @param {Signer | Provider} signerOrProvider - The Signer or Provider object to interact with the Ethereum network
|
|
80
80
|
* @param {NetworkData} network - The network information required to connect to the KVStore contract
|
|
81
|
+
* @param {number | undefined} gasPriceMultiplier - The multiplier to apply to the gas price
|
|
81
82
|
*/
|
|
82
|
-
constructor(signerOrProvider: Signer | Provider,
|
|
83
|
+
constructor(signerOrProvider: Signer | Provider, networkData: NetworkData, gasPriceMultiplier?: number);
|
|
83
84
|
/**
|
|
84
85
|
* Creates an instance of KVStoreClient from a Signer or Provider.
|
|
85
86
|
*
|
|
86
87
|
* @param {Signer | Provider} signerOrProvider - The Signer or Provider object to interact with the Ethereum network
|
|
88
|
+
* @param {number | undefined} gasPriceMultiplier - The multiplier to apply to the gas price
|
|
89
|
+
*
|
|
87
90
|
* @returns {Promise<KVStoreClient>} - An instance of KVStoreClient
|
|
88
91
|
* @throws {ErrorProviderDoesNotExist} - Thrown if the provider does not exist for the provided Signer
|
|
89
92
|
* @throws {ErrorUnsupportedChainID} - Thrown if the network's chainId is not supported
|
|
90
93
|
*/
|
|
91
|
-
static build(signerOrProvider: Signer | Provider): Promise<KVStoreClient>;
|
|
94
|
+
static build(signerOrProvider: Signer | Provider, gasPriceMultiplier?: number): Promise<KVStoreClient>;
|
|
92
95
|
/**
|
|
93
96
|
* This function sets a key-value pair associated with the address that submits the transaction.
|
|
94
97
|
*
|
|
@@ -145,6 +148,32 @@ export declare class KVStoreClient {
|
|
|
145
148
|
* ```
|
|
146
149
|
*/
|
|
147
150
|
setBulk(keys: string[], values: string[]): Promise<void>;
|
|
151
|
+
/**
|
|
152
|
+
* This function sets a URL value for the address that submits the transaction.
|
|
153
|
+
*
|
|
154
|
+
* @param {string} url URL to set
|
|
155
|
+
* @param {string | undefined} urlKey Configurable URL key. `url` by default.
|
|
156
|
+
* @returns Returns void if successful. Throws error if any.
|
|
157
|
+
*
|
|
158
|
+
*
|
|
159
|
+
* **Code example**
|
|
160
|
+
*
|
|
161
|
+
* ```ts
|
|
162
|
+
* import { Wallet, providers } from 'ethers';
|
|
163
|
+
* import { KVStoreClient } from '@human-protocol/sdk';
|
|
164
|
+
*
|
|
165
|
+
* const rpcUrl = 'YOUR_RPC_URL';
|
|
166
|
+
* const privateKey = 'YOUR_PRIVATE_KEY'
|
|
167
|
+
*
|
|
168
|
+
* const provider = new providers.JsonRpcProvider(rpcUrl);
|
|
169
|
+
* const signer = new Wallet(privateKey, provider);
|
|
170
|
+
* const kvstoreClient = await KVStoreClient.build(signer);
|
|
171
|
+
*
|
|
172
|
+
* await kvstoreClient.setURL('example.com');
|
|
173
|
+
* await kvstoreClient.setURL('linkedin.com/example', 'linkedinUrl);
|
|
174
|
+
* ```
|
|
175
|
+
*/
|
|
176
|
+
setURL(url: string, urlKey?: string): Promise<void>;
|
|
148
177
|
/**
|
|
149
178
|
* This function returns the value for a specified key and address.
|
|
150
179
|
*
|
|
@@ -170,5 +199,32 @@ export declare class KVStoreClient {
|
|
|
170
199
|
* ```
|
|
171
200
|
*/
|
|
172
201
|
get(address: string, key: string): Promise<string>;
|
|
202
|
+
/**
|
|
203
|
+
* This function returns the URL value for the given entity.
|
|
204
|
+
*
|
|
205
|
+
* @param {string} address Address from which to get the URL value.
|
|
206
|
+
* @param {string} urlKey Configurable URL key. `url` by default.
|
|
207
|
+
* @returns {string} URL value for the given address if exists, and the content is valid
|
|
208
|
+
*
|
|
209
|
+
*
|
|
210
|
+
* **Code example**
|
|
211
|
+
*
|
|
212
|
+
* ```ts
|
|
213
|
+
* import { providers } from 'ethers';
|
|
214
|
+
* import { KVStoreClient } from '@human-protocol/sdk';
|
|
215
|
+
*
|
|
216
|
+
* const rpcUrl = 'YOUR_RPC_URL';
|
|
217
|
+
*
|
|
218
|
+
* const provider = new providers.JsonRpcProvider(rpcUrl);
|
|
219
|
+
* const kvstoreClient = await KVStoreClient.build(provider);
|
|
220
|
+
*
|
|
221
|
+
* const url = await kvstoreClient.getURL('0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266');
|
|
222
|
+
* const linkedinUrl = await kvstoreClient.getURL(
|
|
223
|
+
* '0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266',
|
|
224
|
+
* 'linkedinUrl'
|
|
225
|
+
* );
|
|
226
|
+
* ```
|
|
227
|
+
*/
|
|
228
|
+
getURL(address: string, urlKey?: string): Promise<string>;
|
|
173
229
|
}
|
|
174
230
|
//# sourceMappingURL=kvstore.d.ts.map
|
package/dist/kvstore.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"kvstore.d.ts","sourceRoot":"","sources":["../src/kvstore.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,kCAAkC,CAAC;AAM5D,OAAO,EAAE,MAAM,EAAU,MAAM,QAAQ,CAAC;
|
|
1
|
+
{"version":3,"file":"kvstore.d.ts","sourceRoot":"","sources":["../src/kvstore.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,kCAAkC,CAAC;AAM5D,OAAO,EAAE,MAAM,EAAU,MAAM,QAAQ,CAAC;AACxC,OAAO,EAAE,gBAAgB,EAAE,MAAM,QAAQ,CAAC;AAc1C,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAGtC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoEG;AACH,qBAAa,aAAc,SAAQ,gBAAgB;IACjD,OAAO,CAAC,QAAQ,CAAU;IAE1B;;;;;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