@human-protocol/sdk 5.0.0-beta.0 → 5.0.0-beta.1
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 +10 -1
- package/dist/base.d.ts.map +1 -1
- package/dist/base.js +21 -0
- package/dist/constants.d.ts +1 -0
- package/dist/constants.d.ts.map +1 -1
- package/dist/constants.js +3 -1
- package/dist/escrow.d.ts.map +1 -1
- package/dist/escrow.js +12 -11
- package/dist/kvstore.d.ts +25 -0
- package/dist/kvstore.d.ts.map +1 -1
- package/dist/kvstore.js +42 -3
- package/dist/staking.d.ts.map +1 -1
- package/dist/staking.js +5 -5
- package/package.json +5 -5
- package/src/base.ts +23 -1
- package/src/constants.ts +3 -0
- package/src/escrow.ts +27 -11
- package/src/kvstore.ts +47 -3
- package/src/staking.ts +17 -5
package/dist/base.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ContractRunner } from 'ethers';
|
|
1
|
+
import { ContractRunner, Overrides } from 'ethers';
|
|
2
2
|
import { NetworkData } from './types';
|
|
3
3
|
/**
|
|
4
4
|
* ## Introduction
|
|
@@ -16,5 +16,14 @@ export declare abstract class BaseEthersClient {
|
|
|
16
16
|
* @param {NetworkData} networkData The network information required to connect to the contracts
|
|
17
17
|
*/
|
|
18
18
|
constructor(runner: ContractRunner, networkData: NetworkData);
|
|
19
|
+
/**
|
|
20
|
+
* Internal helper to enrich transaction overrides with network specific defaults.
|
|
21
|
+
*
|
|
22
|
+
* Aurora networks use a fixed gas price. We always override any user provided
|
|
23
|
+
* gasPrice with the canonical DEFAULT_AURORA_GAS_PRICE to avoid mismatches
|
|
24
|
+
* or tx failures due to an unexpected value. For other networks the user
|
|
25
|
+
* supplied fee parameters are left untouched.
|
|
26
|
+
*/
|
|
27
|
+
protected applyTxDefaults(txOptions?: Overrides): Overrides;
|
|
19
28
|
}
|
|
20
29
|
//# sourceMappingURL=base.d.ts.map
|
package/dist/base.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"base.d.ts","sourceRoot":"","sources":["../src/base.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,QAAQ,CAAC;
|
|
1
|
+
{"version":3,"file":"base.d.ts","sourceRoot":"","sources":["../src/base.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC;AACnD,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAItC;;;;;GAKG;AACH,8BAAsB,gBAAgB;IACpC,SAAS,CAAC,MAAM,EAAE,cAAc,CAAC;IAC1B,WAAW,EAAE,WAAW,CAAC;IAEhC;;;;;OAKG;gBACS,MAAM,EAAE,cAAc,EAAE,WAAW,EAAE,WAAW;IAK5D;;;;;;;OAOG;IACH,SAAS,CAAC,eAAe,CAAC,SAAS,GAAE,SAAc,GAAG,SAAS;CAWhE"}
|
package/dist/base.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.BaseEthersClient = void 0;
|
|
4
|
+
const enums_1 = require("./enums");
|
|
5
|
+
const constants_1 = require("./constants");
|
|
4
6
|
/**
|
|
5
7
|
* ## Introduction
|
|
6
8
|
*
|
|
@@ -18,5 +20,24 @@ class BaseEthersClient {
|
|
|
18
20
|
this.networkData = networkData;
|
|
19
21
|
this.runner = runner;
|
|
20
22
|
}
|
|
23
|
+
/**
|
|
24
|
+
* Internal helper to enrich transaction overrides with network specific defaults.
|
|
25
|
+
*
|
|
26
|
+
* Aurora networks use a fixed gas price. We always override any user provided
|
|
27
|
+
* gasPrice with the canonical DEFAULT_AURORA_GAS_PRICE to avoid mismatches
|
|
28
|
+
* or tx failures due to an unexpected value. For other networks the user
|
|
29
|
+
* supplied fee parameters are left untouched.
|
|
30
|
+
*/
|
|
31
|
+
applyTxDefaults(txOptions = {}) {
|
|
32
|
+
if (this.networkData.chainId === enums_1.ChainId.AURORA_TESTNET) {
|
|
33
|
+
return {
|
|
34
|
+
...txOptions,
|
|
35
|
+
gasPrice: constants_1.DEFAULT_AURORA_GAS_PRICE,
|
|
36
|
+
maxFeePerGas: undefined,
|
|
37
|
+
maxPriorityFeePerGas: undefined,
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
return txOptions;
|
|
41
|
+
}
|
|
21
42
|
}
|
|
22
43
|
exports.BaseEthersClient = BaseEthersClient;
|
package/dist/constants.d.ts
CHANGED
|
@@ -5,6 +5,7 @@ export declare const DEFAULT_ENDPOINT = "localhost";
|
|
|
5
5
|
export declare const DEFAULT_REGION = "eu";
|
|
6
6
|
export declare const DEFAULT_PORT = 9000;
|
|
7
7
|
export declare const DEFAULT_USE_SSL = false;
|
|
8
|
+
export declare const DEFAULT_AURORA_GAS_PRICE: bigint;
|
|
8
9
|
export declare enum HttpStatus {
|
|
9
10
|
OK = 200,
|
|
10
11
|
CREATED = 201,
|
package/dist/constants.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAClC,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAEtC,eAAO,MAAM,qBAAqB,0BAA0B,CAAC;AAE7D,eAAO,MAAM,gBAAgB,cAAc,CAAC;AAE5C,eAAO,MAAM,cAAc,OAAO,CAAC;AAEnC,eAAO,MAAM,YAAY,OAAO,CAAC;AAEjC,eAAO,MAAM,eAAe,QAAQ,CAAC;AAErC,eAAO,MAAM,wBAAwB,QAAoC,CAAC;AAE1E,oBAAY,UAAU;IACpB,EAAE,MAAM;IACR,OAAO,MAAM;IACb,WAAW,MAAM;IACjB,YAAY,MAAM;IAClB,gBAAgB,MAAM;IACtB,SAAS,MAAM;IACf,SAAS,MAAM;IACf,qBAAqB,MAAM;CAC5B;AAED,eAAO,MAAM,QAAQ,EAAE;KACpB,OAAO,IAAI,OAAO,CAAC,CAAC,EAAE,WAAW;CA0HnC,CAAC;AAEF,eAAO,MAAM,WAAW;;;;;;;;;;;;;CAavB,CAAC;AAEF,eAAO,MAAM,IAAI;;;;;CAKhB,CAAC;AAEF,eAAO,MAAM,4BAA4B,uBAAuB,CAAC;AAEjE,eAAO,MAAM,4BAA4B,KAAK,CAAC"}
|
package/dist/constants.js
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ESCROW_BULK_PAYOUT_MAX_ITEMS = exports.SUBGRAPH_API_KEY_PLACEHOLDER = exports.Role = exports.KVStoreKeys = exports.NETWORKS = exports.HttpStatus = exports.DEFAULT_USE_SSL = exports.DEFAULT_PORT = exports.DEFAULT_REGION = exports.DEFAULT_ENDPOINT = exports.DEFAULT_PUBLIC_BUCKET = void 0;
|
|
3
|
+
exports.ESCROW_BULK_PAYOUT_MAX_ITEMS = exports.SUBGRAPH_API_KEY_PLACEHOLDER = exports.Role = exports.KVStoreKeys = exports.NETWORKS = exports.HttpStatus = exports.DEFAULT_AURORA_GAS_PRICE = exports.DEFAULT_USE_SSL = exports.DEFAULT_PORT = exports.DEFAULT_REGION = exports.DEFAULT_ENDPOINT = exports.DEFAULT_PUBLIC_BUCKET = void 0;
|
|
4
|
+
const ethers_1 = require("ethers");
|
|
4
5
|
const enums_1 = require("./enums");
|
|
5
6
|
exports.DEFAULT_PUBLIC_BUCKET = 'escrow-public-results';
|
|
6
7
|
exports.DEFAULT_ENDPOINT = 'localhost';
|
|
7
8
|
exports.DEFAULT_REGION = 'eu';
|
|
8
9
|
exports.DEFAULT_PORT = 9000;
|
|
9
10
|
exports.DEFAULT_USE_SSL = false;
|
|
11
|
+
exports.DEFAULT_AURORA_GAS_PRICE = ethers_1.ethers.parseUnits('0.07', 'gwei');
|
|
10
12
|
var HttpStatus;
|
|
11
13
|
(function (HttpStatus) {
|
|
12
14
|
HttpStatus[HttpStatus["OK"] = 200] = "OK";
|
package/dist/escrow.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"escrow.d.ts","sourceRoot":"","sources":["../src/escrow.ts"],"names":[],"mappings":"AAWA,OAAO,EAAE,cAAc,EAAY,SAAS,EAAkB,MAAM,QAAQ,CAAC;AAE7E,OAAO,EAAE,gBAAgB,EAAE,MAAM,QAAQ,CAAC;AAG1C,OAAO,EAAE,OAAO,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AA4BlD,OAAO,EAQL,WAAW,EACZ,MAAM,WAAW,CAAC;AACnB,OAAO,EACL,OAAO,EACP,aAAa,EACb,cAAc,EACd,aAAa,EACb,kBAAkB,EACnB,MAAM,cAAc,CAAC;AACtB,OAAO,EACL,YAAY,EACZ,cAAc,EACd,WAAW,EACX,wBAAwB,EACxB,MAAM,EACN,kBAAkB,EACnB,MAAM,SAAS,CAAC;AASjB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoEG;AACH,qBAAa,YAAa,SAAQ,gBAAgB;IAChD,OAAO,CAAC,qBAAqB,CAAgB;IAE7C;;;;;OAKG;gBACS,MAAM,EAAE,cAAc,EAAE,WAAW,EAAE,WAAW;IAS5D;;;;;;;;OAQG;WACiB,KAAK,CAAC,MAAM,EAAE,cAAc,GAAG,OAAO,CAAC,YAAY,CAAC;IAiBxE;;;;OAIG;IACH,OAAO,CAAC,iBAAiB;IAQzB;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA4BG;IAEU,YAAY,CACvB,YAAY,EAAE,MAAM,EACpB,cAAc,EAAE,MAAM,EACtB,SAAS,GAAE,SAAc,GAC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EAAE,cAAc,CAAC;KACjC,GAAG,OAAO,CAAC,kBAAkB,EAAE,CAAC;IA8BjC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA4CG;WACiB,qBAAqB,CACvC,OAAO,EAAE,OAAO,EAChB,aAAa,EAAE,MAAM,GACpB,OAAO,CAAC,kBAAkB,CAAC;CAkB/B"}
|
package/dist/escrow.js
CHANGED
|
@@ -173,7 +173,7 @@ class EscrowClient extends base_1.BaseEthersClient {
|
|
|
173
173
|
throw error_1.ErrorInvalidTokenAddress;
|
|
174
174
|
}
|
|
175
175
|
try {
|
|
176
|
-
const result = await (await this.escrowFactoryContract.createEscrow(tokenAddress, jobRequesterId, txOptions)).wait();
|
|
176
|
+
const result = await (await this.escrowFactoryContract.createEscrow(tokenAddress, jobRequesterId, this.applyTxDefaults(txOptions))).wait();
|
|
177
177
|
const event = result?.logs?.find(({ topics }) => topics.includes(ethers_1.ethers.id('LaunchedV2(address,address,string)')))?.args;
|
|
178
178
|
if (!event) {
|
|
179
179
|
throw error_1.ErrorLaunchedEventIsNotEmitted;
|
|
@@ -256,7 +256,7 @@ class EscrowClient extends base_1.BaseEthersClient {
|
|
|
256
256
|
}
|
|
257
257
|
try {
|
|
258
258
|
const escrowContract = this.getEscrowContract(escrowAddress);
|
|
259
|
-
await (await escrowContract.setup(reputationOracle, recordingOracle, exchangeOracle, reputationOracleFee, recordingOracleFee, exchangeOracleFee, manifest, manifestHash, txOptions)).wait();
|
|
259
|
+
await (await escrowContract.setup(reputationOracle, recordingOracle, exchangeOracle, reputationOracleFee, recordingOracleFee, exchangeOracleFee, manifest, manifestHash, this.applyTxDefaults(txOptions))).wait();
|
|
260
260
|
return;
|
|
261
261
|
}
|
|
262
262
|
catch (e) {
|
|
@@ -303,7 +303,7 @@ class EscrowClient extends base_1.BaseEthersClient {
|
|
|
303
303
|
const escrowContract = this.getEscrowContract(escrowAddress);
|
|
304
304
|
const tokenAddress = await escrowContract.token();
|
|
305
305
|
const tokenContract = typechain_types_1.HMToken__factory.connect(tokenAddress, this.runner);
|
|
306
|
-
await (await tokenContract.transfer(escrowAddress, amount, txOptions)).wait();
|
|
306
|
+
await (await tokenContract.transfer(escrowAddress, amount, this.applyTxDefaults(txOptions))).wait();
|
|
307
307
|
return;
|
|
308
308
|
}
|
|
309
309
|
catch (e) {
|
|
@@ -332,10 +332,10 @@ class EscrowClient extends base_1.BaseEthersClient {
|
|
|
332
332
|
}
|
|
333
333
|
try {
|
|
334
334
|
if (fundsToReserve !== undefined) {
|
|
335
|
-
await (await escrowContract['storeResults(string,string,uint256)'](url, hash, fundsToReserve, txOptions)).wait();
|
|
335
|
+
await (await escrowContract['storeResults(string,string,uint256)'](url, hash, fundsToReserve, this.applyTxDefaults(txOptions))).wait();
|
|
336
336
|
}
|
|
337
337
|
else {
|
|
338
|
-
await (await escrowContract['storeResults(string,string)'](url, hash, txOptions)).wait();
|
|
338
|
+
await (await escrowContract['storeResults(string,string)'](url, hash, this.applyTxDefaults(txOptions))).wait();
|
|
339
339
|
}
|
|
340
340
|
}
|
|
341
341
|
catch (e) {
|
|
@@ -382,7 +382,7 @@ class EscrowClient extends base_1.BaseEthersClient {
|
|
|
382
382
|
}
|
|
383
383
|
try {
|
|
384
384
|
const escrowContract = this.getEscrowContract(escrowAddress);
|
|
385
|
-
await (await escrowContract.complete(txOptions)).wait();
|
|
385
|
+
await (await escrowContract.complete(this.applyTxDefaults(txOptions))).wait();
|
|
386
386
|
return;
|
|
387
387
|
}
|
|
388
388
|
catch (e) {
|
|
@@ -395,10 +395,10 @@ class EscrowClient extends base_1.BaseEthersClient {
|
|
|
395
395
|
const idIsString = typeof id === 'string';
|
|
396
396
|
try {
|
|
397
397
|
if (idIsString) {
|
|
398
|
-
await (await escrowContract['bulkPayOut(address[],uint256[],string,string,string,bool)'](recipients, amounts, finalResultsUrl, finalResultsHash, id, forceComplete, txOptions)).wait();
|
|
398
|
+
await (await escrowContract['bulkPayOut(address[],uint256[],string,string,string,bool)'](recipients, amounts, finalResultsUrl, finalResultsHash, id, forceComplete, this.applyTxDefaults(txOptions))).wait();
|
|
399
399
|
}
|
|
400
400
|
else {
|
|
401
|
-
await (await escrowContract['bulkPayOut(address[],uint256[],string,string,uint256,bool)'](recipients, amounts, finalResultsUrl, finalResultsHash, id, forceComplete, txOptions)).wait();
|
|
401
|
+
await (await escrowContract['bulkPayOut(address[],uint256[],string,string,uint256,bool)'](recipients, amounts, finalResultsUrl, finalResultsHash, id, forceComplete, this.applyTxDefaults(txOptions))).wait();
|
|
402
402
|
}
|
|
403
403
|
}
|
|
404
404
|
catch (e) {
|
|
@@ -444,7 +444,7 @@ class EscrowClient extends base_1.BaseEthersClient {
|
|
|
444
444
|
}
|
|
445
445
|
try {
|
|
446
446
|
const escrowContract = this.getEscrowContract(escrowAddress);
|
|
447
|
-
await (await escrowContract.cancel(txOptions)).wait();
|
|
447
|
+
await (await escrowContract.cancel(this.applyTxDefaults(txOptions))).wait();
|
|
448
448
|
}
|
|
449
449
|
catch (e) {
|
|
450
450
|
return (0, utils_1.throwError)(e);
|
|
@@ -484,7 +484,7 @@ class EscrowClient extends base_1.BaseEthersClient {
|
|
|
484
484
|
}
|
|
485
485
|
try {
|
|
486
486
|
const escrowContract = this.getEscrowContract(escrowAddress);
|
|
487
|
-
await (await escrowContract.requestCancellation(txOptions)).wait();
|
|
487
|
+
await (await escrowContract.requestCancellation(this.applyTxDefaults(txOptions))).wait();
|
|
488
488
|
}
|
|
489
489
|
catch (e) {
|
|
490
490
|
return (0, utils_1.throwError)(e);
|
|
@@ -532,7 +532,7 @@ class EscrowClient extends base_1.BaseEthersClient {
|
|
|
532
532
|
}
|
|
533
533
|
try {
|
|
534
534
|
const escrowContract = this.getEscrowContract(escrowAddress);
|
|
535
|
-
const transactionReceipt = await (await escrowContract.withdraw(tokenAddress, txOptions)).wait();
|
|
535
|
+
const transactionReceipt = await (await escrowContract.withdraw(tokenAddress, this.applyTxDefaults(txOptions))).wait();
|
|
536
536
|
let amountTransferred = undefined;
|
|
537
537
|
const tokenContract = typechain_types_1.ERC20__factory.connect(tokenAddress, this.runner);
|
|
538
538
|
if (transactionReceipt)
|
|
@@ -604,6 +604,7 @@ class EscrowClient extends base_1.BaseEthersClient {
|
|
|
604
604
|
* (await signer.sendTransaction(rawTransaction)).wait();
|
|
605
605
|
*/
|
|
606
606
|
async createBulkPayoutTransaction(escrowAddress, recipients, amounts, finalResultsUrl, finalResultsHash, payoutId, forceComplete = false, txOptions = {}) {
|
|
607
|
+
txOptions = this.applyTxDefaults(txOptions);
|
|
607
608
|
await this.ensureCorrectBulkPayoutInput(escrowAddress, recipients, amounts, finalResultsUrl, finalResultsHash);
|
|
608
609
|
const signer = this.runner;
|
|
609
610
|
try {
|
package/dist/kvstore.d.ts
CHANGED
|
@@ -176,6 +176,31 @@ export declare class KVStoreClient extends BaseEthersClient {
|
|
|
176
176
|
* ```
|
|
177
177
|
*/
|
|
178
178
|
setFileUrlAndHash(url: string, urlKey?: string, txOptions?: Overrides): Promise<void>;
|
|
179
|
+
/**
|
|
180
|
+
* Gets the value of a key-value pair in the contract.
|
|
181
|
+
*
|
|
182
|
+
* @param {string} address Address from which to get the key value.
|
|
183
|
+
* @param {string} key Key to obtain the value.
|
|
184
|
+
* @returns {string} Value of the key.
|
|
185
|
+
*
|
|
186
|
+
*
|
|
187
|
+
* **Code example**
|
|
188
|
+
*
|
|
189
|
+
* > Need to have available stake.
|
|
190
|
+
*
|
|
191
|
+
* ```ts
|
|
192
|
+
* import { providers } from 'ethers';
|
|
193
|
+
* import { KVStoreClient } from '@human-protocol/sdk';
|
|
194
|
+
*
|
|
195
|
+
* const rpcUrl = 'YOUR_RPC_URL';
|
|
196
|
+
*
|
|
197
|
+
* const provider = new providers.JsonRpcProvider(rpcUrl);
|
|
198
|
+
* const kvstoreClient = await KVStoreClient.build(provider);
|
|
199
|
+
*
|
|
200
|
+
* const value = await kvstoreClient.get('0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266', 'Role');
|
|
201
|
+
* ```
|
|
202
|
+
*/
|
|
203
|
+
get(address: string, key: string): Promise<string>;
|
|
179
204
|
}
|
|
180
205
|
/**
|
|
181
206
|
* ## Introduction
|
package/dist/kvstore.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"kvstore.d.ts","sourceRoot":"","sources":["../src/kvstore.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,cAAc,EAAE,SAAS,EAAU,MAAM,QAAQ,CAAC;AAC3D,OAAO,EAAE,gBAAgB,EAAE,MAAM,QAAQ,CAAC;AAG1C,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAYlC,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAOtC,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AACxC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoEG;AAEH,qBAAa,aAAc,SAAQ,gBAAgB;IACjD,OAAO,CAAC,QAAQ,CAAU;IAE1B;;;;;OAKG;gBACS,MAAM,EAAE,cAAc,EAAE,WAAW,EAAE,WAAW;IAS5D;;;;;;;;OAQG;WACiB,KAAK,CAAC,MAAM,EAAE,cAAc,GAAG,OAAO,CAAC,aAAa,CAAC;IAiBzE;;;;;;;;;;;;;;;;;;;;;;;;;;OA0BG;IAEU,GAAG,CACd,GAAG,EAAE,MAAM,EACX,KAAK,EAAE,MAAM,EACb,SAAS,GAAE,SAAc,GACxB,OAAO,CAAC,IAAI,CAAC;
|
|
1
|
+
{"version":3,"file":"kvstore.d.ts","sourceRoot":"","sources":["../src/kvstore.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,cAAc,EAAE,SAAS,EAAU,MAAM,QAAQ,CAAC;AAC3D,OAAO,EAAE,gBAAgB,EAAE,MAAM,QAAQ,CAAC;AAG1C,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;A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yBtB;;;;;;;;;;;;;;;;;;;;;;;OAuBG;WACiB,GAAG,CACrB,OAAO,EAAE,OAAO,EAChB,OAAO,EAAE,MAAM,EACf,GAAG,EAAE,MAAM,GACV,OAAO,CAAC,MAAM,CAAC;IAuBlB;;;;;;;;;;;;;;;;;;;OAmBG;WACiB,uBAAuB,CACzC,OAAO,EAAE,OAAO,EAChB,OAAO,EAAE,MAAM,EACf,MAAM,SAAQ,GACb,OAAO,CAAC,MAAM,CAAC;IAqClB;;;;;;;;;;;;;;;;;;OAkBG;WACiB,YAAY,CAC9B,OAAO,EAAE,OAAO,EAChB,OAAO,EAAE,MAAM,GACd,OAAO,CAAC,MAAM,CAAC;CAenB"}
|
package/dist/kvstore.js
CHANGED
|
@@ -154,7 +154,7 @@ class KVStoreClient extends base_1.BaseEthersClient {
|
|
|
154
154
|
if (key === '')
|
|
155
155
|
throw error_1.ErrorKVStoreEmptyKey;
|
|
156
156
|
try {
|
|
157
|
-
await (await this.contract.set(key, value, txOptions)).wait();
|
|
157
|
+
await (await this.contract.set(key, value, this.applyTxDefaults(txOptions))).wait();
|
|
158
158
|
}
|
|
159
159
|
catch (e) {
|
|
160
160
|
if (e instanceof Error)
|
|
@@ -196,7 +196,7 @@ class KVStoreClient extends base_1.BaseEthersClient {
|
|
|
196
196
|
if (keys.includes(''))
|
|
197
197
|
throw error_1.ErrorKVStoreEmptyKey;
|
|
198
198
|
try {
|
|
199
|
-
await (await this.contract.setBulk(keys, values, txOptions)).wait();
|
|
199
|
+
await (await this.contract.setBulk(keys, values, this.applyTxDefaults(txOptions))).wait();
|
|
200
200
|
}
|
|
201
201
|
catch (e) {
|
|
202
202
|
if (e instanceof Error)
|
|
@@ -237,13 +237,52 @@ class KVStoreClient extends base_1.BaseEthersClient {
|
|
|
237
237
|
const contentHash = ethers_1.ethers.keccak256(ethers_1.ethers.toUtf8Bytes(content));
|
|
238
238
|
const hashKey = urlKey + '_hash';
|
|
239
239
|
try {
|
|
240
|
-
await (await this.contract.setBulk([urlKey, hashKey], [url, contentHash], txOptions)).wait();
|
|
240
|
+
await (await this.contract.setBulk([urlKey, hashKey], [url, contentHash], this.applyTxDefaults(txOptions))).wait();
|
|
241
241
|
}
|
|
242
242
|
catch (e) {
|
|
243
243
|
if (e instanceof Error)
|
|
244
244
|
throw Error(`Failed to set URL and hash: ${e.message}`);
|
|
245
245
|
}
|
|
246
246
|
}
|
|
247
|
+
/**
|
|
248
|
+
* Gets the value of a key-value pair in the contract.
|
|
249
|
+
*
|
|
250
|
+
* @param {string} address Address from which to get the key value.
|
|
251
|
+
* @param {string} key Key to obtain the value.
|
|
252
|
+
* @returns {string} Value of the key.
|
|
253
|
+
*
|
|
254
|
+
*
|
|
255
|
+
* **Code example**
|
|
256
|
+
*
|
|
257
|
+
* > Need to have available stake.
|
|
258
|
+
*
|
|
259
|
+
* ```ts
|
|
260
|
+
* import { providers } from 'ethers';
|
|
261
|
+
* import { KVStoreClient } from '@human-protocol/sdk';
|
|
262
|
+
*
|
|
263
|
+
* const rpcUrl = 'YOUR_RPC_URL';
|
|
264
|
+
*
|
|
265
|
+
* const provider = new providers.JsonRpcProvider(rpcUrl);
|
|
266
|
+
* const kvstoreClient = await KVStoreClient.build(provider);
|
|
267
|
+
*
|
|
268
|
+
* const value = await kvstoreClient.get('0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266', 'Role');
|
|
269
|
+
* ```
|
|
270
|
+
*/
|
|
271
|
+
async get(address, key) {
|
|
272
|
+
if (key === '')
|
|
273
|
+
throw error_1.ErrorKVStoreEmptyKey;
|
|
274
|
+
if (!ethers_1.ethers.isAddress(address))
|
|
275
|
+
throw error_1.ErrorInvalidAddress;
|
|
276
|
+
try {
|
|
277
|
+
const result = await this.contract?.get(address, key);
|
|
278
|
+
return result;
|
|
279
|
+
}
|
|
280
|
+
catch (e) {
|
|
281
|
+
if (e instanceof Error)
|
|
282
|
+
throw Error(`Failed to get value: ${e.message}`);
|
|
283
|
+
return e;
|
|
284
|
+
}
|
|
285
|
+
}
|
|
247
286
|
}
|
|
248
287
|
exports.KVStoreClient = KVStoreClient;
|
|
249
288
|
__decorate([
|
package/dist/staking.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"staking.d.ts","sourceRoot":"","sources":["../src/staking.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,aAAa,EAEb,OAAO,EAEP,OAAO,EAER,MAAM,sCAAsC,CAAC;AAC9C,OAAO,EAAE,cAAc,EAAE,SAAS,EAAU,MAAM,QAAQ,CAAC;AAE3D,OAAO,EAAE,gBAAgB,EAAE,MAAM,QAAQ,CAAC;AAG1C,OAAO,EAAE,OAAO,EAAkB,MAAM,SAAS,CAAC;AAYlD,OAAO,EAAE,OAAO,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AACnE,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAOtC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoEG;AACH,qBAAa,aAAc,SAAQ,gBAAgB;IAC1C,aAAa,EAAE,OAAO,CAAC;IACvB,eAAe,EAAE,OAAO,CAAC;IACzB,qBAAqB,EAAE,aAAa,CAAC;IAE5C;;;;;OAKG;gBACS,MAAM,EAAE,cAAc,EAAE,WAAW,EAAE,WAAW;IAmB5D;;;;;;;;OAQG;WACiB,KAAK,CAAC,MAAM,EAAE,cAAc,GAAG,OAAO,CAAC,aAAa,CAAC;IAiBzE;;;;OAIG;YACW,gBAAgB;IAU9B;;;;;;;;;;;;;;;;;;;;;;;OAuBG;IAEU,YAAY,CACvB,MAAM,EAAE,MAAM,EACd,SAAS,GAAE,SAAc,GACxB,OAAO,CAAC,IAAI,CAAC;IAuBhB;;;;;;;;;;;;;;;;;;;;;;;;;;OA0BG;IAEU,KAAK,CAAC,MAAM,EAAE,MAAM,EAAE,SAAS,GAAE,SAAc,GAAG,OAAO,CAAC,IAAI,C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AAC,IAAI,CAAC;IAsBhB;;;;;;;;;;;;;;;;;;;;;;;OAuBG;IAEU,QAAQ,CAAC,SAAS,GAAE,SAAc,GAAG,OAAO,CAAC,IAAI,CAAC;IAW/D;;;;;;;;;;;;;;;;;;;;;;;;;;OA0BG;IAEU,KAAK,CAChB,OAAO,EAAE,MAAM,EACf,MAAM,EAAE,MAAM,EACd,aAAa,EAAE,MAAM,EACrB,MAAM,EAAE,MAAM,EACd,SAAS,GAAE,SAAc,GACxB,OAAO,CAAC,IAAI,CAAC;IAoChB;;;;;;;;;;;;;;;;;;;OAmBG;IACU,aAAa,CAAC,aAAa,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC;CAiCvE;AAED;;GAEG;AACH,qBAAa,YAAY;IACvB;;;;;;OAMG;WACiB,SAAS,CAC3B,OAAO,EAAE,OAAO,EAChB,aAAa,EAAE,MAAM,GACpB,OAAO,CAAC,OAAO,CAAC;IAuBnB;;;;OAIG;WACiB,UAAU,CAAC,MAAM,EAAE,cAAc,GAAG,OAAO,CAAC,OAAO,EAAE,CAAC;CAoD3E"}
|
package/dist/staking.js
CHANGED
|
@@ -171,7 +171,7 @@ class StakingClient extends base_1.BaseEthersClient {
|
|
|
171
171
|
throw error_1.ErrorInvalidStakingValueSign;
|
|
172
172
|
}
|
|
173
173
|
try {
|
|
174
|
-
await (await this.tokenContract.approve(await this.stakingContract.getAddress(), amount, txOptions)).wait();
|
|
174
|
+
await (await this.tokenContract.approve(await this.stakingContract.getAddress(), amount, this.applyTxDefaults(txOptions))).wait();
|
|
175
175
|
return;
|
|
176
176
|
}
|
|
177
177
|
catch (e) {
|
|
@@ -213,7 +213,7 @@ class StakingClient extends base_1.BaseEthersClient {
|
|
|
213
213
|
throw error_1.ErrorInvalidStakingValueSign;
|
|
214
214
|
}
|
|
215
215
|
try {
|
|
216
|
-
await (await this.stakingContract.stake(amount, txOptions)).wait();
|
|
216
|
+
await (await this.stakingContract.stake(amount, this.applyTxDefaults(txOptions))).wait();
|
|
217
217
|
return;
|
|
218
218
|
}
|
|
219
219
|
catch (e) {
|
|
@@ -254,7 +254,7 @@ class StakingClient extends base_1.BaseEthersClient {
|
|
|
254
254
|
throw error_1.ErrorInvalidStakingValueSign;
|
|
255
255
|
}
|
|
256
256
|
try {
|
|
257
|
-
await (await this.stakingContract.unstake(amount, txOptions)).wait();
|
|
257
|
+
await (await this.stakingContract.unstake(amount, this.applyTxDefaults(txOptions))).wait();
|
|
258
258
|
return;
|
|
259
259
|
}
|
|
260
260
|
catch (e) {
|
|
@@ -287,7 +287,7 @@ class StakingClient extends base_1.BaseEthersClient {
|
|
|
287
287
|
*/
|
|
288
288
|
async withdraw(txOptions = {}) {
|
|
289
289
|
try {
|
|
290
|
-
await (await this.stakingContract.withdraw(txOptions)).wait();
|
|
290
|
+
await (await this.stakingContract.withdraw(this.applyTxDefaults(txOptions))).wait();
|
|
291
291
|
return;
|
|
292
292
|
}
|
|
293
293
|
catch (e) {
|
|
@@ -336,7 +336,7 @@ class StakingClient extends base_1.BaseEthersClient {
|
|
|
336
336
|
}
|
|
337
337
|
await this.checkValidEscrow(escrowAddress);
|
|
338
338
|
try {
|
|
339
|
-
await (await this.stakingContract.slash(slasher, staker, escrowAddress, amount, txOptions)).wait();
|
|
339
|
+
await (await this.stakingContract.slash(slasher, staker, escrowAddress, amount, this.applyTxDefaults(txOptions))).wait();
|
|
340
340
|
return;
|
|
341
341
|
}
|
|
342
342
|
catch (e) {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@human-protocol/sdk",
|
|
3
3
|
"description": "Human Protocol SDK",
|
|
4
|
-
"version": "5.0.0-beta.
|
|
4
|
+
"version": "5.0.0-beta.1",
|
|
5
5
|
"files": [
|
|
6
6
|
"src",
|
|
7
7
|
"dist"
|
|
@@ -11,13 +11,13 @@
|
|
|
11
11
|
"scripts": {
|
|
12
12
|
"clean": "tsc --build --clean && rm -rf ./dist",
|
|
13
13
|
"clean:doc": "rm -rf ../../../../docs/sdk/typescript/",
|
|
14
|
-
"build": "tsc --build",
|
|
14
|
+
"build": "yarn clean && tsc --build",
|
|
15
15
|
"build:doc": "yarn clean:doc && typedoc --plugin typedoc-plugin-markdown --out ../../../../docs/sdk/typescript/",
|
|
16
|
-
"prepublish": "yarn build",
|
|
17
16
|
"test": "vitest -u",
|
|
18
17
|
"lint": "eslint .",
|
|
19
18
|
"lint:fix": "eslint . --fix",
|
|
20
|
-
"format": "prettier --write '**/*.{ts,json}'"
|
|
19
|
+
"format": "prettier --write '**/*.{ts,json}'",
|
|
20
|
+
"prepack": "[ \"${SKIP_PREPACK:-}\" = \"true\" ] && exit 0 || yarn build"
|
|
21
21
|
},
|
|
22
22
|
"repository": {
|
|
23
23
|
"url": "https://github.com/humanprotocol/human-protocol.git",
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
]
|
|
39
39
|
},
|
|
40
40
|
"dependencies": {
|
|
41
|
-
"@human-protocol/core": "
|
|
41
|
+
"@human-protocol/core": "5.0.0-beta.1",
|
|
42
42
|
"axios": "^1.4.0",
|
|
43
43
|
"ethers": "~6.15.0",
|
|
44
44
|
"graphql": "^16.8.1",
|
package/src/base.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
import { ContractRunner } from 'ethers';
|
|
1
|
+
import { ContractRunner, Overrides } from 'ethers';
|
|
2
2
|
import { NetworkData } from './types';
|
|
3
|
+
import { ChainId } from './enums';
|
|
4
|
+
import { DEFAULT_AURORA_GAS_PRICE } from './constants';
|
|
3
5
|
|
|
4
6
|
/**
|
|
5
7
|
* ## Introduction
|
|
@@ -21,4 +23,24 @@ export abstract class BaseEthersClient {
|
|
|
21
23
|
this.networkData = networkData;
|
|
22
24
|
this.runner = runner;
|
|
23
25
|
}
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Internal helper to enrich transaction overrides with network specific defaults.
|
|
29
|
+
*
|
|
30
|
+
* Aurora networks use a fixed gas price. We always override any user provided
|
|
31
|
+
* gasPrice with the canonical DEFAULT_AURORA_GAS_PRICE to avoid mismatches
|
|
32
|
+
* or tx failures due to an unexpected value. For other networks the user
|
|
33
|
+
* supplied fee parameters are left untouched.
|
|
34
|
+
*/
|
|
35
|
+
protected applyTxDefaults(txOptions: Overrides = {}): Overrides {
|
|
36
|
+
if (this.networkData.chainId === ChainId.AURORA_TESTNET) {
|
|
37
|
+
return {
|
|
38
|
+
...txOptions,
|
|
39
|
+
gasPrice: DEFAULT_AURORA_GAS_PRICE,
|
|
40
|
+
maxFeePerGas: undefined,
|
|
41
|
+
maxPriorityFeePerGas: undefined,
|
|
42
|
+
} as Overrides;
|
|
43
|
+
}
|
|
44
|
+
return txOptions;
|
|
45
|
+
}
|
|
24
46
|
}
|
package/src/constants.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { ethers } from 'ethers';
|
|
1
2
|
import { ChainId } from './enums';
|
|
2
3
|
import { NetworkData } from './types';
|
|
3
4
|
|
|
@@ -11,6 +12,8 @@ export const DEFAULT_PORT = 9000;
|
|
|
11
12
|
|
|
12
13
|
export const DEFAULT_USE_SSL = false;
|
|
13
14
|
|
|
15
|
+
export const DEFAULT_AURORA_GAS_PRICE = ethers.parseUnits('0.07', 'gwei');
|
|
16
|
+
|
|
14
17
|
export enum HttpStatus {
|
|
15
18
|
OK = 200,
|
|
16
19
|
CREATED = 201,
|
package/src/escrow.ts
CHANGED
|
@@ -245,7 +245,7 @@ export class EscrowClient extends BaseEthersClient {
|
|
|
245
245
|
await this.escrowFactoryContract.createEscrow(
|
|
246
246
|
tokenAddress,
|
|
247
247
|
jobRequesterId,
|
|
248
|
-
txOptions
|
|
248
|
+
this.applyTxDefaults(txOptions)
|
|
249
249
|
)
|
|
250
250
|
).wait();
|
|
251
251
|
|
|
@@ -374,7 +374,7 @@ export class EscrowClient extends BaseEthersClient {
|
|
|
374
374
|
exchangeOracleFee,
|
|
375
375
|
manifest,
|
|
376
376
|
manifestHash,
|
|
377
|
-
txOptions
|
|
377
|
+
this.applyTxDefaults(txOptions)
|
|
378
378
|
)
|
|
379
379
|
).wait();
|
|
380
380
|
|
|
@@ -438,7 +438,11 @@ export class EscrowClient extends BaseEthersClient {
|
|
|
438
438
|
this.runner
|
|
439
439
|
);
|
|
440
440
|
await (
|
|
441
|
-
await tokenContract.transfer(
|
|
441
|
+
await tokenContract.transfer(
|
|
442
|
+
escrowAddress,
|
|
443
|
+
amount,
|
|
444
|
+
this.applyTxDefaults(txOptions)
|
|
445
|
+
)
|
|
442
446
|
).wait();
|
|
443
447
|
|
|
444
448
|
return;
|
|
@@ -559,7 +563,7 @@ export class EscrowClient extends BaseEthersClient {
|
|
|
559
563
|
url,
|
|
560
564
|
hash,
|
|
561
565
|
fundsToReserve,
|
|
562
|
-
txOptions
|
|
566
|
+
this.applyTxDefaults(txOptions)
|
|
563
567
|
)
|
|
564
568
|
).wait();
|
|
565
569
|
} else {
|
|
@@ -567,7 +571,7 @@ export class EscrowClient extends BaseEthersClient {
|
|
|
567
571
|
await escrowContract['storeResults(string,string)'](
|
|
568
572
|
url,
|
|
569
573
|
hash,
|
|
570
|
-
txOptions
|
|
574
|
+
this.applyTxDefaults(txOptions)
|
|
571
575
|
)
|
|
572
576
|
).wait();
|
|
573
577
|
}
|
|
@@ -623,7 +627,9 @@ export class EscrowClient extends BaseEthersClient {
|
|
|
623
627
|
try {
|
|
624
628
|
const escrowContract = this.getEscrowContract(escrowAddress);
|
|
625
629
|
|
|
626
|
-
await (
|
|
630
|
+
await (
|
|
631
|
+
await escrowContract.complete(this.applyTxDefaults(txOptions))
|
|
632
|
+
).wait();
|
|
627
633
|
return;
|
|
628
634
|
} catch (e) {
|
|
629
635
|
return throwError(e);
|
|
@@ -763,7 +769,7 @@ export class EscrowClient extends BaseEthersClient {
|
|
|
763
769
|
finalResultsHash,
|
|
764
770
|
id,
|
|
765
771
|
forceComplete,
|
|
766
|
-
txOptions
|
|
772
|
+
this.applyTxDefaults(txOptions)
|
|
767
773
|
)
|
|
768
774
|
).wait();
|
|
769
775
|
} else {
|
|
@@ -777,7 +783,7 @@ export class EscrowClient extends BaseEthersClient {
|
|
|
777
783
|
finalResultsHash,
|
|
778
784
|
id,
|
|
779
785
|
forceComplete,
|
|
780
|
-
txOptions
|
|
786
|
+
this.applyTxDefaults(txOptions)
|
|
781
787
|
)
|
|
782
788
|
).wait();
|
|
783
789
|
}
|
|
@@ -831,7 +837,9 @@ export class EscrowClient extends BaseEthersClient {
|
|
|
831
837
|
|
|
832
838
|
try {
|
|
833
839
|
const escrowContract = this.getEscrowContract(escrowAddress);
|
|
834
|
-
await (
|
|
840
|
+
await (
|
|
841
|
+
await escrowContract.cancel(this.applyTxDefaults(txOptions))
|
|
842
|
+
).wait();
|
|
835
843
|
} catch (e) {
|
|
836
844
|
return throwError(e);
|
|
837
845
|
}
|
|
@@ -877,7 +885,11 @@ export class EscrowClient extends BaseEthersClient {
|
|
|
877
885
|
|
|
878
886
|
try {
|
|
879
887
|
const escrowContract = this.getEscrowContract(escrowAddress);
|
|
880
|
-
await (
|
|
888
|
+
await (
|
|
889
|
+
await escrowContract.requestCancellation(
|
|
890
|
+
this.applyTxDefaults(txOptions)
|
|
891
|
+
)
|
|
892
|
+
).wait();
|
|
881
893
|
} catch (e) {
|
|
882
894
|
return throwError(e);
|
|
883
895
|
}
|
|
@@ -935,7 +947,10 @@ export class EscrowClient extends BaseEthersClient {
|
|
|
935
947
|
const escrowContract = this.getEscrowContract(escrowAddress);
|
|
936
948
|
|
|
937
949
|
const transactionReceipt = await (
|
|
938
|
-
await escrowContract.withdraw(
|
|
950
|
+
await escrowContract.withdraw(
|
|
951
|
+
tokenAddress,
|
|
952
|
+
this.applyTxDefaults(txOptions)
|
|
953
|
+
)
|
|
939
954
|
).wait();
|
|
940
955
|
|
|
941
956
|
let amountTransferred: bigint | undefined = undefined;
|
|
@@ -1027,6 +1042,7 @@ export class EscrowClient extends BaseEthersClient {
|
|
|
1027
1042
|
forceComplete = false,
|
|
1028
1043
|
txOptions: Overrides = {}
|
|
1029
1044
|
): Promise<TransactionLikeWithNonce> {
|
|
1045
|
+
txOptions = this.applyTxDefaults(txOptions);
|
|
1030
1046
|
await this.ensureCorrectBulkPayoutInput(
|
|
1031
1047
|
escrowAddress,
|
|
1032
1048
|
recipients,
|
package/src/kvstore.ts
CHANGED
|
@@ -175,7 +175,9 @@ export class KVStoreClient extends BaseEthersClient {
|
|
|
175
175
|
): Promise<void> {
|
|
176
176
|
if (key === '') throw ErrorKVStoreEmptyKey;
|
|
177
177
|
try {
|
|
178
|
-
await (
|
|
178
|
+
await (
|
|
179
|
+
await this.contract.set(key, value, this.applyTxDefaults(txOptions))
|
|
180
|
+
).wait();
|
|
179
181
|
} catch (e) {
|
|
180
182
|
if (e instanceof Error) throw Error(`Failed to set value: ${e.message}`);
|
|
181
183
|
}
|
|
@@ -220,7 +222,13 @@ export class KVStoreClient extends BaseEthersClient {
|
|
|
220
222
|
if (keys.includes('')) throw ErrorKVStoreEmptyKey;
|
|
221
223
|
|
|
222
224
|
try {
|
|
223
|
-
await (
|
|
225
|
+
await (
|
|
226
|
+
await this.contract.setBulk(
|
|
227
|
+
keys,
|
|
228
|
+
values,
|
|
229
|
+
this.applyTxDefaults(txOptions)
|
|
230
|
+
)
|
|
231
|
+
).wait();
|
|
224
232
|
} catch (e) {
|
|
225
233
|
if (e instanceof Error)
|
|
226
234
|
throw Error(`Failed to set bulk values: ${e.message}`);
|
|
@@ -273,7 +281,7 @@ export class KVStoreClient extends BaseEthersClient {
|
|
|
273
281
|
await this.contract.setBulk(
|
|
274
282
|
[urlKey, hashKey],
|
|
275
283
|
[url, contentHash],
|
|
276
|
-
txOptions
|
|
284
|
+
this.applyTxDefaults(txOptions)
|
|
277
285
|
)
|
|
278
286
|
).wait();
|
|
279
287
|
} catch (e) {
|
|
@@ -281,6 +289,42 @@ export class KVStoreClient extends BaseEthersClient {
|
|
|
281
289
|
throw Error(`Failed to set URL and hash: ${e.message}`);
|
|
282
290
|
}
|
|
283
291
|
}
|
|
292
|
+
/**
|
|
293
|
+
* Gets the value of a key-value pair in the contract.
|
|
294
|
+
*
|
|
295
|
+
* @param {string} address Address from which to get the key value.
|
|
296
|
+
* @param {string} key Key to obtain the value.
|
|
297
|
+
* @returns {string} Value of the key.
|
|
298
|
+
*
|
|
299
|
+
*
|
|
300
|
+
* **Code example**
|
|
301
|
+
*
|
|
302
|
+
* > Need to have available stake.
|
|
303
|
+
*
|
|
304
|
+
* ```ts
|
|
305
|
+
* import { providers } from 'ethers';
|
|
306
|
+
* import { KVStoreClient } from '@human-protocol/sdk';
|
|
307
|
+
*
|
|
308
|
+
* const rpcUrl = 'YOUR_RPC_URL';
|
|
309
|
+
*
|
|
310
|
+
* const provider = new providers.JsonRpcProvider(rpcUrl);
|
|
311
|
+
* const kvstoreClient = await KVStoreClient.build(provider);
|
|
312
|
+
*
|
|
313
|
+
* const value = await kvstoreClient.get('0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266', 'Role');
|
|
314
|
+
* ```
|
|
315
|
+
*/
|
|
316
|
+
public async get(address: string, key: string): Promise<string> {
|
|
317
|
+
if (key === '') throw ErrorKVStoreEmptyKey;
|
|
318
|
+
if (!ethers.isAddress(address)) throw ErrorInvalidAddress;
|
|
319
|
+
|
|
320
|
+
try {
|
|
321
|
+
const result = await this.contract?.get(address, key);
|
|
322
|
+
return result;
|
|
323
|
+
} catch (e) {
|
|
324
|
+
if (e instanceof Error) throw Error(`Failed to get value: ${e.message}`);
|
|
325
|
+
return e;
|
|
326
|
+
}
|
|
327
|
+
}
|
|
284
328
|
}
|
|
285
329
|
|
|
286
330
|
/**
|
package/src/staking.ts
CHANGED
|
@@ -213,7 +213,7 @@ export class StakingClient extends BaseEthersClient {
|
|
|
213
213
|
await this.tokenContract.approve(
|
|
214
214
|
await this.stakingContract.getAddress(),
|
|
215
215
|
amount,
|
|
216
|
-
txOptions
|
|
216
|
+
this.applyTxDefaults(txOptions)
|
|
217
217
|
)
|
|
218
218
|
).wait();
|
|
219
219
|
return;
|
|
@@ -260,7 +260,12 @@ export class StakingClient extends BaseEthersClient {
|
|
|
260
260
|
}
|
|
261
261
|
|
|
262
262
|
try {
|
|
263
|
-
await (
|
|
263
|
+
await (
|
|
264
|
+
await this.stakingContract.stake(
|
|
265
|
+
amount,
|
|
266
|
+
this.applyTxDefaults(txOptions)
|
|
267
|
+
)
|
|
268
|
+
).wait();
|
|
264
269
|
return;
|
|
265
270
|
} catch (e) {
|
|
266
271
|
return throwError(e);
|
|
@@ -307,7 +312,12 @@ export class StakingClient extends BaseEthersClient {
|
|
|
307
312
|
}
|
|
308
313
|
|
|
309
314
|
try {
|
|
310
|
-
await (
|
|
315
|
+
await (
|
|
316
|
+
await this.stakingContract.unstake(
|
|
317
|
+
amount,
|
|
318
|
+
this.applyTxDefaults(txOptions)
|
|
319
|
+
)
|
|
320
|
+
).wait();
|
|
311
321
|
return;
|
|
312
322
|
} catch (e) {
|
|
313
323
|
return throwError(e);
|
|
@@ -341,7 +351,9 @@ export class StakingClient extends BaseEthersClient {
|
|
|
341
351
|
@requiresSigner
|
|
342
352
|
public async withdraw(txOptions: Overrides = {}): Promise<void> {
|
|
343
353
|
try {
|
|
344
|
-
await (
|
|
354
|
+
await (
|
|
355
|
+
await this.stakingContract.withdraw(this.applyTxDefaults(txOptions))
|
|
356
|
+
).wait();
|
|
345
357
|
return;
|
|
346
358
|
} catch (e) {
|
|
347
359
|
return throwError(e);
|
|
@@ -408,7 +420,7 @@ export class StakingClient extends BaseEthersClient {
|
|
|
408
420
|
staker,
|
|
409
421
|
escrowAddress,
|
|
410
422
|
amount,
|
|
411
|
-
txOptions
|
|
423
|
+
this.applyTxDefaults(txOptions)
|
|
412
424
|
)
|
|
413
425
|
).wait();
|
|
414
426
|
|