@human-protocol/sdk 5.0.0 → 5.2.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/base.d.ts +1 -10
- package/dist/base.d.ts.map +1 -1
- package/dist/base.js +0 -21
- package/dist/constants.d.ts +0 -1
- package/dist/constants.d.ts.map +1 -1
- package/dist/constants.js +7 -22
- package/dist/encryption.js +1 -1
- package/dist/enums.d.ts +0 -1
- package/dist/enums.d.ts.map +1 -1
- package/dist/enums.js +0 -1
- 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 +14 -17
- package/dist/escrow.d.ts.map +1 -1
- package/dist/escrow.js +34 -33
- package/dist/interfaces.d.ts +14 -0
- package/dist/interfaces.d.ts.map +1 -1
- package/dist/kvstore.d.ts +9 -5
- package/dist/kvstore.d.ts.map +1 -1
- package/dist/kvstore.js +15 -15
- package/dist/operator.d.ts +9 -5
- package/dist/operator.d.ts.map +1 -1
- package/dist/operator.js +16 -16
- package/dist/staking.d.ts +6 -3
- package/dist/staking.d.ts.map +1 -1
- package/dist/staking.js +13 -15
- package/dist/statistics.d.ts +13 -7
- package/dist/statistics.d.ts.map +1 -1
- package/dist/statistics.js +24 -22
- package/dist/storage.js +4 -4
- package/dist/transaction.d.ts +5 -3
- package/dist/transaction.d.ts.map +1 -1
- package/dist/transaction.js +8 -11
- package/dist/utils.d.ts +7 -0
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +66 -1
- package/dist/worker.d.ts +5 -3
- package/dist/worker.d.ts.map +1 -1
- package/dist/worker.js +8 -10
- package/package.json +8 -5
- package/src/base.ts +1 -23
- package/src/constants.ts +6 -24
- package/src/encryption.ts +1 -1
- package/src/enums.ts +0 -1
- package/src/error.ts +14 -0
- package/src/escrow.ts +70 -64
- package/src/interfaces.ts +15 -0
- package/src/kvstore.ts +26 -24
- package/src/operator.ts +54 -26
- package/src/staking.ts +28 -27
- package/src/statistics.ts +87 -47
- package/src/storage.ts +4 -4
- package/src/transaction.ts +39 -26
- package/src/utils.ts +81 -0
- package/src/worker.ts +32 -17
package/dist/escrow.js
CHANGED
|
@@ -8,15 +8,11 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
8
8
|
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
9
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
10
|
};
|
|
11
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
-
};
|
|
14
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
12
|
exports.EscrowUtils = exports.EscrowClient = void 0;
|
|
16
13
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
17
14
|
const typechain_types_1 = require("@human-protocol/core/typechain-types");
|
|
18
15
|
const ethers_1 = require("ethers");
|
|
19
|
-
const graphql_request_1 = __importDefault(require("graphql-request"));
|
|
20
16
|
const base_1 = require("./base");
|
|
21
17
|
const constants_1 = require("./constants");
|
|
22
18
|
const decorators_1 = require("./decorators");
|
|
@@ -173,7 +169,7 @@ class EscrowClient extends base_1.BaseEthersClient {
|
|
|
173
169
|
throw error_1.ErrorInvalidTokenAddress;
|
|
174
170
|
}
|
|
175
171
|
try {
|
|
176
|
-
const result = await (await this.escrowFactoryContract.createEscrow(tokenAddress, jobRequesterId,
|
|
172
|
+
const result = await (await this.escrowFactoryContract.createEscrow(tokenAddress, jobRequesterId, txOptions)).wait();
|
|
177
173
|
const event = result?.logs?.find(({ topics }) => topics.includes(ethers_1.ethers.id('LaunchedV2(address,address,string)')))?.args;
|
|
178
174
|
if (!event) {
|
|
179
175
|
throw error_1.ErrorLaunchedEventIsNotEmitted;
|
|
@@ -275,7 +271,7 @@ class EscrowClient extends base_1.BaseEthersClient {
|
|
|
275
271
|
this.verifySetupParameters(escrowConfig);
|
|
276
272
|
const { recordingOracle, reputationOracle, exchangeOracle, recordingOracleFee, reputationOracleFee, exchangeOracleFee, manifest, manifestHash, } = escrowConfig;
|
|
277
273
|
try {
|
|
278
|
-
const result = await (await this.escrowFactoryContract.createFundAndSetupEscrow(tokenAddress, amount, jobRequesterId, reputationOracle, recordingOracle, exchangeOracle, reputationOracleFee, recordingOracleFee, exchangeOracleFee, manifest, manifestHash,
|
|
274
|
+
const result = await (await this.escrowFactoryContract.createFundAndSetupEscrow(tokenAddress, amount, jobRequesterId, reputationOracle, recordingOracle, exchangeOracle, reputationOracleFee, recordingOracleFee, exchangeOracleFee, manifest, manifestHash, txOptions)).wait();
|
|
279
275
|
const event = result?.logs?.find(({ topics }) => topics.includes(ethers_1.ethers.id('LaunchedV2(address,address,string)')))?.args;
|
|
280
276
|
if (!event) {
|
|
281
277
|
throw error_1.ErrorLaunchedEventIsNotEmitted;
|
|
@@ -335,7 +331,7 @@ class EscrowClient extends base_1.BaseEthersClient {
|
|
|
335
331
|
}
|
|
336
332
|
try {
|
|
337
333
|
const escrowContract = this.getEscrowContract(escrowAddress);
|
|
338
|
-
await (await escrowContract.setup(reputationOracle, recordingOracle, exchangeOracle, reputationOracleFee, recordingOracleFee, exchangeOracleFee, manifest, manifestHash,
|
|
334
|
+
await (await escrowContract.setup(reputationOracle, recordingOracle, exchangeOracle, reputationOracleFee, recordingOracleFee, exchangeOracleFee, manifest, manifestHash, txOptions)).wait();
|
|
339
335
|
return;
|
|
340
336
|
}
|
|
341
337
|
catch (e) {
|
|
@@ -382,7 +378,7 @@ class EscrowClient extends base_1.BaseEthersClient {
|
|
|
382
378
|
const escrowContract = this.getEscrowContract(escrowAddress);
|
|
383
379
|
const tokenAddress = await escrowContract.token();
|
|
384
380
|
const tokenContract = typechain_types_1.HMToken__factory.connect(tokenAddress, this.runner);
|
|
385
|
-
await (await tokenContract.transfer(escrowAddress, amount,
|
|
381
|
+
await (await tokenContract.transfer(escrowAddress, amount, txOptions)).wait();
|
|
386
382
|
return;
|
|
387
383
|
}
|
|
388
384
|
catch (e) {
|
|
@@ -411,10 +407,10 @@ class EscrowClient extends base_1.BaseEthersClient {
|
|
|
411
407
|
}
|
|
412
408
|
try {
|
|
413
409
|
if (fundsToReserve !== null) {
|
|
414
|
-
await (await escrowContract['storeResults(string,string,uint256)'](url, hash, fundsToReserve,
|
|
410
|
+
await (await escrowContract['storeResults(string,string,uint256)'](url, hash, fundsToReserve, txOptions)).wait();
|
|
415
411
|
}
|
|
416
412
|
else {
|
|
417
|
-
await (await escrowContract['storeResults(string,string)'](url, hash,
|
|
413
|
+
await (await escrowContract['storeResults(string,string)'](url, hash, txOptions)).wait();
|
|
418
414
|
}
|
|
419
415
|
}
|
|
420
416
|
catch (e) {
|
|
@@ -461,7 +457,7 @@ class EscrowClient extends base_1.BaseEthersClient {
|
|
|
461
457
|
}
|
|
462
458
|
try {
|
|
463
459
|
const escrowContract = this.getEscrowContract(escrowAddress);
|
|
464
|
-
await (await escrowContract.complete(
|
|
460
|
+
await (await escrowContract.complete(txOptions)).wait();
|
|
465
461
|
return;
|
|
466
462
|
}
|
|
467
463
|
catch (e) {
|
|
@@ -474,10 +470,10 @@ class EscrowClient extends base_1.BaseEthersClient {
|
|
|
474
470
|
const idIsString = typeof id === 'string';
|
|
475
471
|
try {
|
|
476
472
|
if (idIsString) {
|
|
477
|
-
await (await escrowContract['bulkPayOut(address[],uint256[],string,string,string,bool)'](recipients, amounts, finalResultsUrl, finalResultsHash, id, forceComplete,
|
|
473
|
+
await (await escrowContract['bulkPayOut(address[],uint256[],string,string,string,bool)'](recipients, amounts, finalResultsUrl, finalResultsHash, id, forceComplete, txOptions)).wait();
|
|
478
474
|
}
|
|
479
475
|
else {
|
|
480
|
-
await (await escrowContract['bulkPayOut(address[],uint256[],string,string,uint256,bool)'](recipients, amounts, finalResultsUrl, finalResultsHash, id, forceComplete,
|
|
476
|
+
await (await escrowContract['bulkPayOut(address[],uint256[],string,string,uint256,bool)'](recipients, amounts, finalResultsUrl, finalResultsHash, id, forceComplete, txOptions)).wait();
|
|
481
477
|
}
|
|
482
478
|
}
|
|
483
479
|
catch (e) {
|
|
@@ -523,7 +519,7 @@ class EscrowClient extends base_1.BaseEthersClient {
|
|
|
523
519
|
}
|
|
524
520
|
try {
|
|
525
521
|
const escrowContract = this.getEscrowContract(escrowAddress);
|
|
526
|
-
await (await escrowContract.cancel(
|
|
522
|
+
await (await escrowContract.cancel(txOptions)).wait();
|
|
527
523
|
}
|
|
528
524
|
catch (e) {
|
|
529
525
|
return (0, utils_1.throwError)(e);
|
|
@@ -563,7 +559,7 @@ class EscrowClient extends base_1.BaseEthersClient {
|
|
|
563
559
|
}
|
|
564
560
|
try {
|
|
565
561
|
const escrowContract = this.getEscrowContract(escrowAddress);
|
|
566
|
-
await (await escrowContract.requestCancellation(
|
|
562
|
+
await (await escrowContract.requestCancellation(txOptions)).wait();
|
|
567
563
|
}
|
|
568
564
|
catch (e) {
|
|
569
565
|
return (0, utils_1.throwError)(e);
|
|
@@ -611,7 +607,7 @@ class EscrowClient extends base_1.BaseEthersClient {
|
|
|
611
607
|
}
|
|
612
608
|
try {
|
|
613
609
|
const escrowContract = this.getEscrowContract(escrowAddress);
|
|
614
|
-
const transactionReceipt = await (await escrowContract.withdraw(tokenAddress,
|
|
610
|
+
const transactionReceipt = await (await escrowContract.withdraw(tokenAddress, txOptions)).wait();
|
|
615
611
|
let amountTransferred = undefined;
|
|
616
612
|
const tokenContract = typechain_types_1.ERC20__factory.connect(tokenAddress, this.runner);
|
|
617
613
|
if (transactionReceipt)
|
|
@@ -682,7 +678,6 @@ class EscrowClient extends base_1.BaseEthersClient {
|
|
|
682
678
|
* (await signer.sendTransaction(rawTransaction)).wait();
|
|
683
679
|
*/
|
|
684
680
|
async createBulkPayoutTransaction(escrowAddress, recipients, amounts, finalResultsUrl, finalResultsHash, payoutId, forceComplete = false, txOptions = {}) {
|
|
685
|
-
txOptions = this.applyTxDefaults(txOptions);
|
|
686
681
|
await this.ensureCorrectBulkPayoutInput(escrowAddress, recipients, amounts, finalResultsUrl, finalResultsHash);
|
|
687
682
|
const signer = this.runner;
|
|
688
683
|
try {
|
|
@@ -1441,6 +1436,7 @@ class EscrowUtils {
|
|
|
1441
1436
|
*
|
|
1442
1437
|
*
|
|
1443
1438
|
* @param {IEscrowsFilter} filter Filter parameters.
|
|
1439
|
+
* @param {SubgraphOptions} options Optional configuration for subgraph requests.
|
|
1444
1440
|
* @returns {IEscrow[]} List of escrows that match the filter.
|
|
1445
1441
|
*
|
|
1446
1442
|
* **Code example**
|
|
@@ -1457,7 +1453,7 @@ class EscrowUtils {
|
|
|
1457
1453
|
* const escrows = await EscrowUtils.getEscrows(filters);
|
|
1458
1454
|
* ```
|
|
1459
1455
|
*/
|
|
1460
|
-
static async getEscrows(filter) {
|
|
1456
|
+
static async getEscrows(filter, options) {
|
|
1461
1457
|
if (filter.launcher && !ethers_1.ethers.isAddress(filter.launcher)) {
|
|
1462
1458
|
throw error_1.ErrorInvalidAddress;
|
|
1463
1459
|
}
|
|
@@ -1482,7 +1478,7 @@ class EscrowUtils {
|
|
|
1482
1478
|
statuses = Array.isArray(filter.status) ? filter.status : [filter.status];
|
|
1483
1479
|
statuses = statuses.map((status) => types_1.EscrowStatus[status]);
|
|
1484
1480
|
}
|
|
1485
|
-
const { escrows } = await (0,
|
|
1481
|
+
const { escrows } = await (0, utils_1.customGqlFetch)((0, utils_1.getSubgraphUrl)(networkData), (0, graphql_1.GET_ESCROWS_QUERY)(filter), {
|
|
1486
1482
|
...filter,
|
|
1487
1483
|
launcher: filter.launcher?.toLowerCase(),
|
|
1488
1484
|
reputationOracle: filter.reputationOracle?.toLowerCase(),
|
|
@@ -1494,7 +1490,7 @@ class EscrowUtils {
|
|
|
1494
1490
|
orderDirection: orderDirection,
|
|
1495
1491
|
first: first,
|
|
1496
1492
|
skip: skip,
|
|
1497
|
-
});
|
|
1493
|
+
}, options);
|
|
1498
1494
|
return (escrows || []).map((e) => mapEscrow(e, networkData.chainId));
|
|
1499
1495
|
}
|
|
1500
1496
|
/**
|
|
@@ -1550,6 +1546,7 @@ class EscrowUtils {
|
|
|
1550
1546
|
*
|
|
1551
1547
|
* @param {ChainId} chainId Network in which the escrow has been deployed
|
|
1552
1548
|
* @param {string} escrowAddress Address of the escrow
|
|
1549
|
+
* @param {SubgraphOptions} options Optional configuration for subgraph requests.
|
|
1553
1550
|
* @returns {Promise<IEscrow | null>} - Escrow data or null if not found.
|
|
1554
1551
|
*
|
|
1555
1552
|
* **Code example**
|
|
@@ -1560,7 +1557,7 @@ class EscrowUtils {
|
|
|
1560
1557
|
* const escrow = new EscrowUtils.getEscrow(ChainId.POLYGON_AMOY, "0x1234567890123456789012345678901234567890");
|
|
1561
1558
|
* ```
|
|
1562
1559
|
*/
|
|
1563
|
-
static async getEscrow(chainId, escrowAddress) {
|
|
1560
|
+
static async getEscrow(chainId, escrowAddress, options) {
|
|
1564
1561
|
const networkData = constants_1.NETWORKS[chainId];
|
|
1565
1562
|
if (!networkData) {
|
|
1566
1563
|
throw error_1.ErrorUnsupportedChainID;
|
|
@@ -1568,7 +1565,7 @@ class EscrowUtils {
|
|
|
1568
1565
|
if (escrowAddress && !ethers_1.ethers.isAddress(escrowAddress)) {
|
|
1569
1566
|
throw error_1.ErrorInvalidAddress;
|
|
1570
1567
|
}
|
|
1571
|
-
const { escrow } = await (0,
|
|
1568
|
+
const { escrow } = await (0, utils_1.customGqlFetch)((0, utils_1.getSubgraphUrl)(networkData), (0, graphql_1.GET_ESCROW_BY_ADDRESS_QUERY)(), { escrowAddress: escrowAddress.toLowerCase() }, options);
|
|
1572
1569
|
if (!escrow)
|
|
1573
1570
|
return null;
|
|
1574
1571
|
return mapEscrow(escrow, networkData.chainId);
|
|
@@ -1609,6 +1606,7 @@ class EscrowUtils {
|
|
|
1609
1606
|
* ```
|
|
1610
1607
|
*
|
|
1611
1608
|
* @param {IStatusEventFilter} filter Filter parameters.
|
|
1609
|
+
* @param {SubgraphOptions} options Optional configuration for subgraph requests.
|
|
1612
1610
|
* @returns {Promise<StatusEvent[]>} - Array of status events with their corresponding statuses.
|
|
1613
1611
|
*
|
|
1614
1612
|
* **Code example**
|
|
@@ -1629,7 +1627,7 @@ class EscrowUtils {
|
|
|
1629
1627
|
* })();
|
|
1630
1628
|
* ```
|
|
1631
1629
|
*/
|
|
1632
|
-
static async getStatusEvents(filter) {
|
|
1630
|
+
static async getStatusEvents(filter, options) {
|
|
1633
1631
|
const { chainId, statuses, from, to, launcher, first = 10, skip = 0, orderDirection = enums_1.OrderDirection.DESC, } = filter;
|
|
1634
1632
|
if (launcher && !ethers_1.ethers.isAddress(launcher)) {
|
|
1635
1633
|
throw error_1.ErrorInvalidAddress;
|
|
@@ -1648,7 +1646,7 @@ class EscrowUtils {
|
|
|
1648
1646
|
types_1.EscrowStatus.Cancelled,
|
|
1649
1647
|
];
|
|
1650
1648
|
const statusNames = effectiveStatuses.map((status) => types_1.EscrowStatus[status]);
|
|
1651
|
-
const data = await (0,
|
|
1649
|
+
const data = await (0, utils_1.customGqlFetch)((0, utils_1.getSubgraphUrl)(networkData), (0, graphql_1.GET_STATUS_UPDATES_QUERY)(from, to, launcher), {
|
|
1652
1650
|
status: statusNames,
|
|
1653
1651
|
from: from ? (0, utils_1.getUnixTimestamp)(from) : undefined,
|
|
1654
1652
|
to: to ? (0, utils_1.getUnixTimestamp)(to) : undefined,
|
|
@@ -1656,7 +1654,7 @@ class EscrowUtils {
|
|
|
1656
1654
|
orderDirection,
|
|
1657
1655
|
first: Math.min(first, 1000),
|
|
1658
1656
|
skip,
|
|
1659
|
-
});
|
|
1657
|
+
}, options);
|
|
1660
1658
|
if (!data || !data['escrowStatusEvents']) {
|
|
1661
1659
|
return [];
|
|
1662
1660
|
}
|
|
@@ -1676,6 +1674,7 @@ class EscrowUtils {
|
|
|
1676
1674
|
* Fetch payouts from the subgraph.
|
|
1677
1675
|
*
|
|
1678
1676
|
* @param {IPayoutFilter} filter Filter parameters.
|
|
1677
|
+
* @param {SubgraphOptions} options Optional configuration for subgraph requests.
|
|
1679
1678
|
* @returns {Promise<IPayout[]>} List of payouts matching the filters.
|
|
1680
1679
|
*
|
|
1681
1680
|
* **Code example**
|
|
@@ -1693,7 +1692,7 @@ class EscrowUtils {
|
|
|
1693
1692
|
* console.log(payouts);
|
|
1694
1693
|
* ```
|
|
1695
1694
|
*/
|
|
1696
|
-
static async getPayouts(filter) {
|
|
1695
|
+
static async getPayouts(filter, options) {
|
|
1697
1696
|
const networkData = constants_1.NETWORKS[filter.chainId];
|
|
1698
1697
|
if (!networkData) {
|
|
1699
1698
|
throw error_1.ErrorUnsupportedChainID;
|
|
@@ -1707,7 +1706,7 @@ class EscrowUtils {
|
|
|
1707
1706
|
const first = filter.first !== undefined ? Math.min(filter.first, 1000) : 10;
|
|
1708
1707
|
const skip = filter.skip || 0;
|
|
1709
1708
|
const orderDirection = filter.orderDirection || enums_1.OrderDirection.DESC;
|
|
1710
|
-
const { payouts } = await (0,
|
|
1709
|
+
const { payouts } = await (0, utils_1.customGqlFetch)((0, utils_1.getSubgraphUrl)(networkData), (0, graphql_1.GET_PAYOUTS_QUERY)(filter), {
|
|
1711
1710
|
escrowAddress: filter.escrowAddress?.toLowerCase(),
|
|
1712
1711
|
recipient: filter.recipient?.toLowerCase(),
|
|
1713
1712
|
from: filter.from ? (0, utils_1.getUnixTimestamp)(filter.from) : undefined,
|
|
@@ -1715,7 +1714,7 @@ class EscrowUtils {
|
|
|
1715
1714
|
first: Math.min(first, 1000),
|
|
1716
1715
|
skip,
|
|
1717
1716
|
orderDirection,
|
|
1718
|
-
});
|
|
1717
|
+
}, options);
|
|
1719
1718
|
if (!payouts) {
|
|
1720
1719
|
return [];
|
|
1721
1720
|
}
|
|
@@ -1761,6 +1760,7 @@ class EscrowUtils {
|
|
|
1761
1760
|
*
|
|
1762
1761
|
*
|
|
1763
1762
|
* @param {Object} filter Filter parameters.
|
|
1763
|
+
* @param {SubgraphOptions} options Optional configuration for subgraph requests.
|
|
1764
1764
|
* @returns {Promise<ICancellationRefund[]>} List of cancellation refunds matching the filters.
|
|
1765
1765
|
*
|
|
1766
1766
|
* **Code example**
|
|
@@ -1775,7 +1775,7 @@ class EscrowUtils {
|
|
|
1775
1775
|
* console.log(cancellationRefunds);
|
|
1776
1776
|
* ```
|
|
1777
1777
|
*/
|
|
1778
|
-
static async getCancellationRefunds(filter) {
|
|
1778
|
+
static async getCancellationRefunds(filter, options) {
|
|
1779
1779
|
const networkData = constants_1.NETWORKS[filter.chainId];
|
|
1780
1780
|
if (!networkData)
|
|
1781
1781
|
throw error_1.ErrorUnsupportedChainID;
|
|
@@ -1788,7 +1788,7 @@ class EscrowUtils {
|
|
|
1788
1788
|
const first = filter.first !== undefined ? Math.min(filter.first, 1000) : 10;
|
|
1789
1789
|
const skip = filter.skip || 0;
|
|
1790
1790
|
const orderDirection = filter.orderDirection || enums_1.OrderDirection.DESC;
|
|
1791
|
-
const { cancellationRefundEvents } = await (0,
|
|
1791
|
+
const { cancellationRefundEvents } = await (0, utils_1.customGqlFetch)((0, utils_1.getSubgraphUrl)(networkData), (0, graphql_1.GET_CANCELLATION_REFUNDS_QUERY)(filter), {
|
|
1792
1792
|
escrowAddress: filter.escrowAddress?.toLowerCase(),
|
|
1793
1793
|
receiver: filter.receiver?.toLowerCase(),
|
|
1794
1794
|
from: filter.from ? (0, utils_1.getUnixTimestamp)(filter.from) : undefined,
|
|
@@ -1796,7 +1796,7 @@ class EscrowUtils {
|
|
|
1796
1796
|
first,
|
|
1797
1797
|
skip,
|
|
1798
1798
|
orderDirection,
|
|
1799
|
-
});
|
|
1799
|
+
}, options);
|
|
1800
1800
|
if (!cancellationRefundEvents || cancellationRefundEvents.length === 0) {
|
|
1801
1801
|
return [];
|
|
1802
1802
|
}
|
|
@@ -1845,6 +1845,7 @@ class EscrowUtils {
|
|
|
1845
1845
|
*
|
|
1846
1846
|
* @param {ChainId} chainId Network in which the escrow has been deployed
|
|
1847
1847
|
* @param {string} escrowAddress Address of the escrow
|
|
1848
|
+
* @param {SubgraphOptions} options Optional configuration for subgraph requests.
|
|
1848
1849
|
* @returns {Promise<ICancellationRefund>} Cancellation refund data
|
|
1849
1850
|
*
|
|
1850
1851
|
* **Code example**
|
|
@@ -1855,14 +1856,14 @@ class EscrowUtils {
|
|
|
1855
1856
|
* const cancellationRefund = await EscrowUtils.getCancellationRefund(ChainId.POLYGON_AMOY, "0x1234567890123456789012345678901234567890");
|
|
1856
1857
|
* ```
|
|
1857
1858
|
*/
|
|
1858
|
-
static async getCancellationRefund(chainId, escrowAddress) {
|
|
1859
|
+
static async getCancellationRefund(chainId, escrowAddress, options) {
|
|
1859
1860
|
const networkData = constants_1.NETWORKS[chainId];
|
|
1860
1861
|
if (!networkData)
|
|
1861
1862
|
throw error_1.ErrorUnsupportedChainID;
|
|
1862
1863
|
if (!ethers_1.ethers.isAddress(escrowAddress)) {
|
|
1863
1864
|
throw error_1.ErrorInvalidEscrowAddressProvided;
|
|
1864
1865
|
}
|
|
1865
|
-
const { cancellationRefundEvents } = await (0,
|
|
1866
|
+
const { cancellationRefundEvents } = await (0, utils_1.customGqlFetch)((0, utils_1.getSubgraphUrl)(networkData), (0, graphql_1.GET_CANCELLATION_REFUND_BY_ADDRESS_QUERY)(), { escrowAddress: escrowAddress.toLowerCase() }, options);
|
|
1866
1867
|
if (!cancellationRefundEvents || cancellationRefundEvents.length === 0) {
|
|
1867
1868
|
return null;
|
|
1868
1869
|
}
|
package/dist/interfaces.d.ts
CHANGED
|
@@ -272,4 +272,18 @@ export interface IEscrowWithdraw {
|
|
|
272
272
|
tokenAddress: string;
|
|
273
273
|
withdrawnAmount: bigint;
|
|
274
274
|
}
|
|
275
|
+
/**
|
|
276
|
+
* Configuration options for subgraph requests with retry logic.
|
|
277
|
+
*/
|
|
278
|
+
export interface SubgraphOptions {
|
|
279
|
+
/** Maximum number of retry attempts */
|
|
280
|
+
maxRetries?: number;
|
|
281
|
+
/** Base delay between retries in milliseconds */
|
|
282
|
+
baseDelay?: number;
|
|
283
|
+
/**
|
|
284
|
+
* Optional indexer identifier. When provided, requests target
|
|
285
|
+
* `{gateway}/deployments/id/<DEPLOYMENT_ID>/indexers/id/<INDEXER_ID>`.
|
|
286
|
+
*/
|
|
287
|
+
indexerId?: string;
|
|
288
|
+
}
|
|
275
289
|
//# sourceMappingURL=interfaces.d.ts.map
|
package/dist/interfaces.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"interfaces.d.ts","sourceRoot":"","sources":["../src/interfaces.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,OAAO,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAElD,MAAM,WAAW,OAAO;IACtB,aAAa,EAAE,MAAM,CAAC;IACtB,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,SAAS;IACxB,EAAE,EAAE,MAAM,CAAC;IACX,OAAO,EAAE,OAAO,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,YAAY,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,YAAY,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,oBAAoB,EAAE,MAAM,GAAG,IAAI,CAAC;IACpC,eAAe,EAAE,MAAM,GAAG,IAAI,CAAC;IAC/B,aAAa,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,mBAAmB,EAAE,MAAM,GAAG,IAAI,CAAC;IACnC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IACpB,GAAG,EAAE,MAAM,GAAG,IAAI,CAAC;IACnB,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,GAAG,EAAE,MAAM,GAAG,IAAI,CAAC;IACnB,QAAQ,EAAE,MAAM,EAAE,GAAG,IAAI,CAAC;IAC1B,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|
package/dist/kvstore.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { ContractRunner, Overrides } from 'ethers';
|
|
|
2
2
|
import { BaseEthersClient } from './base';
|
|
3
3
|
import { ChainId } from './enums';
|
|
4
4
|
import { NetworkData } from './types';
|
|
5
|
-
import { IKVStore } from './interfaces';
|
|
5
|
+
import { IKVStore, SubgraphOptions } from './interfaces';
|
|
6
6
|
/**
|
|
7
7
|
* ## Introduction
|
|
8
8
|
*
|
|
@@ -181,6 +181,7 @@ export declare class KVStoreClient extends BaseEthersClient {
|
|
|
181
181
|
*
|
|
182
182
|
* @param {string} address Address from which to get the key value.
|
|
183
183
|
* @param {string} key Key to obtain the value.
|
|
184
|
+
* @param {SubgraphOptions} options Optional configuration for subgraph requests.
|
|
184
185
|
* @returns {string} Value of the key.
|
|
185
186
|
*
|
|
186
187
|
*
|
|
@@ -240,6 +241,7 @@ export declare class KVStoreUtils {
|
|
|
240
241
|
*
|
|
241
242
|
* @param {ChainId} chainId Network in which the KVStore is deployed
|
|
242
243
|
* @param {string} address Address of the KVStore
|
|
244
|
+
* @param {SubgraphOptions} options Optional configuration for subgraph requests.
|
|
243
245
|
* @returns {Promise<IKVStore[]>} KVStore data
|
|
244
246
|
* @throws {ErrorUnsupportedChainID} - Thrown if the network's chainId is not supported
|
|
245
247
|
* @throws {ErrorInvalidAddress} - Thrown if the Address sent is invalid
|
|
@@ -253,13 +255,14 @@ export declare class KVStoreUtils {
|
|
|
253
255
|
* console.log(kvStoreData);
|
|
254
256
|
* ```
|
|
255
257
|
*/
|
|
256
|
-
static getKVStoreData(chainId: ChainId, address: string): Promise<IKVStore[]>;
|
|
258
|
+
static getKVStoreData(chainId: ChainId, address: string, options?: SubgraphOptions): Promise<IKVStore[]>;
|
|
257
259
|
/**
|
|
258
260
|
* Gets the value of a key-value pair in the KVStore using the subgraph.
|
|
259
261
|
*
|
|
260
262
|
* @param {ChainId} chainId Network in which the KVStore is deployed
|
|
261
263
|
* @param {string} address Address from which to get the key value.
|
|
262
264
|
* @param {string} key Key to obtain the value.
|
|
265
|
+
* @param {SubgraphOptions} options Optional configuration for subgraph requests.
|
|
263
266
|
* @returns {Promise<string>} Value of the key.
|
|
264
267
|
* @throws {ErrorUnsupportedChainID} - Thrown if the network's chainId is not supported
|
|
265
268
|
* @throws {ErrorInvalidAddress} - Thrown if the Address sent is invalid
|
|
@@ -278,13 +281,14 @@ export declare class KVStoreUtils {
|
|
|
278
281
|
* console.log(value);
|
|
279
282
|
* ```
|
|
280
283
|
*/
|
|
281
|
-
static get(chainId: ChainId, address: string, key: string): Promise<string>;
|
|
284
|
+
static get(chainId: ChainId, address: string, key: string, options?: SubgraphOptions): Promise<string>;
|
|
282
285
|
/**
|
|
283
286
|
* Gets the URL value of the given entity, and verifies its hash.
|
|
284
287
|
*
|
|
285
288
|
* @param {ChainId} chainId Network in which the KVStore is deployed
|
|
286
289
|
* @param {string} address Address from which to get the URL value.
|
|
287
290
|
* @param {string} urlKey Configurable URL key. `url` by default.
|
|
291
|
+
* @param {SubgraphOptions} options Optional configuration for subgraph requests.
|
|
288
292
|
* @returns {Promise<string>} URL value for the given address if it exists, and the content is valid
|
|
289
293
|
*
|
|
290
294
|
* **Code example**
|
|
@@ -299,7 +303,7 @@ export declare class KVStoreUtils {
|
|
|
299
303
|
* console.log(url);
|
|
300
304
|
* ```
|
|
301
305
|
*/
|
|
302
|
-
static getFileUrlAndVerifyHash(chainId: ChainId, address: string, urlKey?: string): Promise<string>;
|
|
306
|
+
static getFileUrlAndVerifyHash(chainId: ChainId, address: string, urlKey?: string, options?: SubgraphOptions): Promise<string>;
|
|
303
307
|
/**
|
|
304
308
|
* Gets the public key of the given entity, and verifies its hash.
|
|
305
309
|
*
|
|
@@ -319,6 +323,6 @@ export declare class KVStoreUtils {
|
|
|
319
323
|
* console.log(publicKey);
|
|
320
324
|
* ```
|
|
321
325
|
*/
|
|
322
|
-
static getPublicKey(chainId: ChainId, address: string): Promise<string>;
|
|
326
|
+
static getPublicKey(chainId: ChainId, address: string, options?: SubgraphOptions): Promise<string>;
|
|
323
327
|
}
|
|
324
328
|
//# 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":"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;
|
|
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;AAWlC,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAOtC,OAAO,EAAE,QAAQ,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AACzD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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;IAShB;;;;;;;;;;;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-8,9 +8,6 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
8
8
|
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
9
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
10
|
};
|
|
11
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
-
};
|
|
14
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
12
|
exports.KVStoreUtils = exports.KVStoreClient = void 0;
|
|
16
13
|
const typechain_types_1 = require("@human-protocol/core/typechain-types");
|
|
@@ -19,7 +16,6 @@ const base_1 = require("./base");
|
|
|
19
16
|
const constants_1 = require("./constants");
|
|
20
17
|
const decorators_1 = require("./decorators");
|
|
21
18
|
const error_1 = require("./error");
|
|
22
|
-
const graphql_request_1 = __importDefault(require("graphql-request"));
|
|
23
19
|
const utils_1 = require("./utils");
|
|
24
20
|
const kvstore_1 = require("./graphql/queries/kvstore");
|
|
25
21
|
/**
|
|
@@ -154,7 +150,7 @@ class KVStoreClient extends base_1.BaseEthersClient {
|
|
|
154
150
|
if (key === '')
|
|
155
151
|
throw error_1.ErrorKVStoreEmptyKey;
|
|
156
152
|
try {
|
|
157
|
-
await (await this.contract.set(key, value,
|
|
153
|
+
await (await this.contract.set(key, value, txOptions)).wait();
|
|
158
154
|
}
|
|
159
155
|
catch (e) {
|
|
160
156
|
if (e instanceof Error)
|
|
@@ -196,7 +192,7 @@ class KVStoreClient extends base_1.BaseEthersClient {
|
|
|
196
192
|
if (keys.includes(''))
|
|
197
193
|
throw error_1.ErrorKVStoreEmptyKey;
|
|
198
194
|
try {
|
|
199
|
-
await (await this.contract.setBulk(keys, values,
|
|
195
|
+
await (await this.contract.setBulk(keys, values, txOptions)).wait();
|
|
200
196
|
}
|
|
201
197
|
catch (e) {
|
|
202
198
|
if (e instanceof Error)
|
|
@@ -237,7 +233,7 @@ class KVStoreClient extends base_1.BaseEthersClient {
|
|
|
237
233
|
const contentHash = ethers_1.ethers.keccak256(ethers_1.ethers.toUtf8Bytes(content));
|
|
238
234
|
const hashKey = urlKey + '_hash';
|
|
239
235
|
try {
|
|
240
|
-
await (await this.contract.setBulk([urlKey, hashKey], [url, contentHash],
|
|
236
|
+
await (await this.contract.setBulk([urlKey, hashKey], [url, contentHash], txOptions)).wait();
|
|
241
237
|
}
|
|
242
238
|
catch (e) {
|
|
243
239
|
if (e instanceof Error)
|
|
@@ -249,6 +245,7 @@ class KVStoreClient extends base_1.BaseEthersClient {
|
|
|
249
245
|
*
|
|
250
246
|
* @param {string} address Address from which to get the key value.
|
|
251
247
|
* @param {string} key Key to obtain the value.
|
|
248
|
+
* @param {SubgraphOptions} options Optional configuration for subgraph requests.
|
|
252
249
|
* @returns {string} Value of the key.
|
|
253
250
|
*
|
|
254
251
|
*
|
|
@@ -341,6 +338,7 @@ class KVStoreUtils {
|
|
|
341
338
|
*
|
|
342
339
|
* @param {ChainId} chainId Network in which the KVStore is deployed
|
|
343
340
|
* @param {string} address Address of the KVStore
|
|
341
|
+
* @param {SubgraphOptions} options Optional configuration for subgraph requests.
|
|
344
342
|
* @returns {Promise<IKVStore[]>} KVStore data
|
|
345
343
|
* @throws {ErrorUnsupportedChainID} - Thrown if the network's chainId is not supported
|
|
346
344
|
* @throws {ErrorInvalidAddress} - Thrown if the Address sent is invalid
|
|
@@ -354,7 +352,7 @@ class KVStoreUtils {
|
|
|
354
352
|
* console.log(kvStoreData);
|
|
355
353
|
* ```
|
|
356
354
|
*/
|
|
357
|
-
static async getKVStoreData(chainId, address) {
|
|
355
|
+
static async getKVStoreData(chainId, address, options) {
|
|
358
356
|
const networkData = constants_1.NETWORKS[chainId];
|
|
359
357
|
if (!networkData) {
|
|
360
358
|
throw error_1.ErrorUnsupportedChainID;
|
|
@@ -362,7 +360,7 @@ class KVStoreUtils {
|
|
|
362
360
|
if (address && !ethers_1.ethers.isAddress(address)) {
|
|
363
361
|
throw error_1.ErrorInvalidAddress;
|
|
364
362
|
}
|
|
365
|
-
const { kvstores } = await (0,
|
|
363
|
+
const { kvstores } = await (0, utils_1.customGqlFetch)((0, utils_1.getSubgraphUrl)(networkData), (0, kvstore_1.GET_KVSTORE_BY_ADDRESS_QUERY)(), { address: address.toLowerCase() }, options);
|
|
366
364
|
const kvStoreData = kvstores.map((item) => ({
|
|
367
365
|
key: item.key,
|
|
368
366
|
value: item.value,
|
|
@@ -375,6 +373,7 @@ class KVStoreUtils {
|
|
|
375
373
|
* @param {ChainId} chainId Network in which the KVStore is deployed
|
|
376
374
|
* @param {string} address Address from which to get the key value.
|
|
377
375
|
* @param {string} key Key to obtain the value.
|
|
376
|
+
* @param {SubgraphOptions} options Optional configuration for subgraph requests.
|
|
378
377
|
* @returns {Promise<string>} Value of the key.
|
|
379
378
|
* @throws {ErrorUnsupportedChainID} - Thrown if the network's chainId is not supported
|
|
380
379
|
* @throws {ErrorInvalidAddress} - Thrown if the Address sent is invalid
|
|
@@ -393,7 +392,7 @@ class KVStoreUtils {
|
|
|
393
392
|
* console.log(value);
|
|
394
393
|
* ```
|
|
395
394
|
*/
|
|
396
|
-
static async get(chainId, address, key) {
|
|
395
|
+
static async get(chainId, address, key, options) {
|
|
397
396
|
if (key === '')
|
|
398
397
|
throw error_1.ErrorKVStoreEmptyKey;
|
|
399
398
|
if (!ethers_1.ethers.isAddress(address))
|
|
@@ -402,7 +401,7 @@ class KVStoreUtils {
|
|
|
402
401
|
if (!networkData) {
|
|
403
402
|
throw error_1.ErrorUnsupportedChainID;
|
|
404
403
|
}
|
|
405
|
-
const { kvstores } = await (0,
|
|
404
|
+
const { kvstores } = await (0, utils_1.customGqlFetch)((0, utils_1.getSubgraphUrl)(networkData), (0, kvstore_1.GET_KVSTORE_BY_ADDRESS_AND_KEY_QUERY)(), { address: address.toLowerCase(), key }, options);
|
|
406
405
|
if (!kvstores || kvstores.length === 0) {
|
|
407
406
|
throw new error_1.InvalidKeyError(key, address);
|
|
408
407
|
}
|
|
@@ -414,6 +413,7 @@ class KVStoreUtils {
|
|
|
414
413
|
* @param {ChainId} chainId Network in which the KVStore is deployed
|
|
415
414
|
* @param {string} address Address from which to get the URL value.
|
|
416
415
|
* @param {string} urlKey Configurable URL key. `url` by default.
|
|
416
|
+
* @param {SubgraphOptions} options Optional configuration for subgraph requests.
|
|
417
417
|
* @returns {Promise<string>} URL value for the given address if it exists, and the content is valid
|
|
418
418
|
*
|
|
419
419
|
* **Code example**
|
|
@@ -428,13 +428,13 @@ class KVStoreUtils {
|
|
|
428
428
|
* console.log(url);
|
|
429
429
|
* ```
|
|
430
430
|
*/
|
|
431
|
-
static async getFileUrlAndVerifyHash(chainId, address, urlKey = 'url') {
|
|
431
|
+
static async getFileUrlAndVerifyHash(chainId, address, urlKey = 'url', options) {
|
|
432
432
|
if (!ethers_1.ethers.isAddress(address))
|
|
433
433
|
throw error_1.ErrorInvalidAddress;
|
|
434
434
|
const hashKey = urlKey + '_hash';
|
|
435
435
|
let url = '', hash = '';
|
|
436
436
|
try {
|
|
437
|
-
url = await this.get(chainId, address, urlKey);
|
|
437
|
+
url = await this.get(chainId, address, urlKey, options);
|
|
438
438
|
}
|
|
439
439
|
catch (e) {
|
|
440
440
|
if (e instanceof Error)
|
|
@@ -479,8 +479,8 @@ class KVStoreUtils {
|
|
|
479
479
|
* console.log(publicKey);
|
|
480
480
|
* ```
|
|
481
481
|
*/
|
|
482
|
-
static async getPublicKey(chainId, address) {
|
|
483
|
-
const publicKeyUrl = await this.getFileUrlAndVerifyHash(chainId, address, constants_1.KVStoreKeys.publicKey);
|
|
482
|
+
static async getPublicKey(chainId, address, options) {
|
|
483
|
+
const publicKeyUrl = await this.getFileUrlAndVerifyHash(chainId, address, constants_1.KVStoreKeys.publicKey, options);
|
|
484
484
|
if (publicKeyUrl === '') {
|
|
485
485
|
return '';
|
|
486
486
|
}
|
package/dist/operator.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { IOperator, IOperatorsFilter, IReward } from './interfaces';
|
|
1
|
+
import { IOperator, IOperatorsFilter, IReward, SubgraphOptions } from './interfaces';
|
|
2
2
|
import { ChainId } from './enums';
|
|
3
3
|
export declare class OperatorUtils {
|
|
4
4
|
/**
|
|
@@ -6,6 +6,7 @@ export declare class OperatorUtils {
|
|
|
6
6
|
*
|
|
7
7
|
* @param {ChainId} chainId Network in which the operator is deployed
|
|
8
8
|
* @param {string} address Operator address.
|
|
9
|
+
* @param {SubgraphOptions} options Optional configuration for subgraph requests.
|
|
9
10
|
* @returns {Promise<IOperator | null>} - Returns the operator details or null if not found.
|
|
10
11
|
*
|
|
11
12
|
* **Code example**
|
|
@@ -16,11 +17,12 @@ export declare class OperatorUtils {
|
|
|
16
17
|
* const operator = await OperatorUtils.getOperator(ChainId.POLYGON_AMOY, '0x62dD51230A30401C455c8398d06F85e4EaB6309f');
|
|
17
18
|
* ```
|
|
18
19
|
*/
|
|
19
|
-
static getOperator(chainId: ChainId, address: string): Promise<IOperator | null>;
|
|
20
|
+
static getOperator(chainId: ChainId, address: string, options?: SubgraphOptions): Promise<IOperator | null>;
|
|
20
21
|
/**
|
|
21
22
|
* This function returns all the operator details of the protocol.
|
|
22
23
|
*
|
|
23
24
|
* @param {IOperatorsFilter} filter Filter for the operators.
|
|
25
|
+
* @param {SubgraphOptions} options Optional configuration for subgraph requests.
|
|
24
26
|
* @returns {Promise<IOperator[]>} Returns an array with all the operator details.
|
|
25
27
|
*
|
|
26
28
|
* **Code example**
|
|
@@ -34,13 +36,14 @@ export declare class OperatorUtils {
|
|
|
34
36
|
* const operators = await OperatorUtils.getOperators(filter);
|
|
35
37
|
* ```
|
|
36
38
|
*/
|
|
37
|
-
static getOperators(filter: IOperatorsFilter): Promise<IOperator[]>;
|
|
39
|
+
static getOperators(filter: IOperatorsFilter, options?: SubgraphOptions): Promise<IOperator[]>;
|
|
38
40
|
/**
|
|
39
41
|
* Retrieves the reputation network operators of the specified address.
|
|
40
42
|
*
|
|
41
43
|
* @param {ChainId} chainId Network in which the reputation network is deployed
|
|
42
44
|
* @param {string} address Address of the reputation oracle.
|
|
43
45
|
* @param {string} [role] - (Optional) Role of the operator.
|
|
46
|
+
* @param {SubgraphOptions} options Optional configuration for subgraph requests.
|
|
44
47
|
* @returns {Promise<IOperator[]>} - Returns an array of operator details.
|
|
45
48
|
*
|
|
46
49
|
* **Code example**
|
|
@@ -51,12 +54,13 @@ export declare class OperatorUtils {
|
|
|
51
54
|
* const operators = await OperatorUtils.getReputationNetworkOperators(ChainId.POLYGON_AMOY, '0x62dD51230A30401C455c8398d06F85e4EaB6309f');
|
|
52
55
|
* ```
|
|
53
56
|
*/
|
|
54
|
-
static getReputationNetworkOperators(chainId: ChainId, address: string, role?: string): Promise<IOperator[]>;
|
|
57
|
+
static getReputationNetworkOperators(chainId: ChainId, address: string, role?: string, options?: SubgraphOptions): Promise<IOperator[]>;
|
|
55
58
|
/**
|
|
56
59
|
* This function returns information about the rewards for a given slasher address.
|
|
57
60
|
*
|
|
58
61
|
* @param {ChainId} chainId Network in which the rewards are deployed
|
|
59
62
|
* @param {string} slasherAddress Slasher address.
|
|
63
|
+
* @param {SubgraphOptions} options Optional configuration for subgraph requests.
|
|
60
64
|
* @returns {Promise<IReward[]>} Returns an array of Reward objects that contain the rewards earned by the user through slashing other users.
|
|
61
65
|
*
|
|
62
66
|
* **Code example**
|
|
@@ -67,6 +71,6 @@ export declare class OperatorUtils {
|
|
|
67
71
|
* const rewards = await OperatorUtils.getRewards(ChainId.POLYGON_AMOY, '0x62dD51230A30401C455c8398d06F85e4EaB6309f');
|
|
68
72
|
* ```
|
|
69
73
|
*/
|
|
70
|
-
static getRewards(chainId: ChainId, slasherAddress: string): Promise<IReward[]>;
|
|
74
|
+
static getRewards(chainId: ChainId, slasherAddress: string, options?: SubgraphOptions): Promise<IReward[]>;
|
|
71
75
|
}
|
|
72
76
|
//# sourceMappingURL=operator.d.ts.map
|
package/dist/operator.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"operator.d.ts","sourceRoot":"","sources":["../src/operator.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"operator.d.ts","sourceRoot":"","sources":["../src/operator.ts"],"names":[],"mappings":"AACA,OAAO,EACL,SAAS,EACT,gBAAgB,EAChB,OAAO,EACP,eAAe,EAChB,MAAM,cAAc,CAAC;AAmBtB,OAAO,EAAE,OAAO,EAAkB,MAAM,SAAS,CAAC;AAGlD,qBAAa,aAAa;IACxB;;;;;;;;;;;;;;;OAeG;WACiB,WAAW,CAC7B,OAAO,EAAE,OAAO,EAChB,OAAO,EAAE,MAAM,EACf,OAAO,CAAC,EAAE,eAAe,GACxB,OAAO,CAAC,SAAS,GAAG,IAAI,CAAC;IAwB5B;;;;;;;;;;;;;;;;;OAiBG;WACiB,YAAY,CAC9B,MAAM,EAAE,gBAAgB,EACxB,OAAO,CAAC,EAAE,eAAe,GACxB,OAAO,CAAC,SAAS,EAAE,CAAC;IA+CvB;;;;;;;;;;;;;;;;OAgBG;WACiB,6BAA6B,CAC/C,OAAO,EAAE,OAAO,EAChB,OAAO,EAAE,MAAM,EACf,IAAI,CAAC,EAAE,MAAM,EACb,OAAO,CAAC,EAAE,eAAe,GACxB,OAAO,CAAC,SAAS,EAAE,CAAC;IAyBvB;;;;;;;;;;;;;;;OAeG;WACiB,UAAU,CAC5B,OAAO,EAAE,OAAO,EAChB,cAAc,EAAE,MAAM,EACtB,OAAO,CAAC,EAAE,eAAe,GACxB,OAAO,CAAC,OAAO,EAAE,CAAC;CA8BtB"}
|