@human-protocol/sdk 5.0.0-beta.2 → 5.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/escrow.js CHANGED
@@ -142,8 +142,8 @@ class EscrowClient extends base_1.BaseEthersClient {
142
142
  /**
143
143
  * This function creates an escrow contract that uses the token passed to pay oracle fees and reward workers.
144
144
  *
145
- * @param {string} tokenAddress Token address to use for payouts.
146
- * @param {string} jobRequesterId Job Requester Id
145
+ * @param {string} tokenAddress - The address of the token to use for escrow funding.
146
+ * @param {string} jobRequesterId - Identifier for the job requester.
147
147
  * @param {Overrides} [txOptions] - Additional transaction parameters (optional, defaults to an empty object).
148
148
  * @returns {Promise<string>} Returns the address of the escrow created.
149
149
  *
@@ -184,6 +184,108 @@ class EscrowClient extends base_1.BaseEthersClient {
184
184
  return (0, utils_1.throwError)(e);
185
185
  }
186
186
  }
187
+ verifySetupParameters(escrowConfig) {
188
+ const { recordingOracle, reputationOracle, exchangeOracle, recordingOracleFee, reputationOracleFee, exchangeOracleFee, manifest, manifestHash, } = escrowConfig;
189
+ if (!ethers_1.ethers.isAddress(recordingOracle)) {
190
+ throw error_1.ErrorInvalidRecordingOracleAddressProvided;
191
+ }
192
+ if (!ethers_1.ethers.isAddress(reputationOracle)) {
193
+ throw error_1.ErrorInvalidReputationOracleAddressProvided;
194
+ }
195
+ if (!ethers_1.ethers.isAddress(exchangeOracle)) {
196
+ throw error_1.ErrorInvalidExchangeOracleAddressProvided;
197
+ }
198
+ if (recordingOracleFee <= 0 ||
199
+ reputationOracleFee <= 0 ||
200
+ exchangeOracleFee <= 0) {
201
+ throw error_1.ErrorAmountMustBeGreaterThanZero;
202
+ }
203
+ if (recordingOracleFee + reputationOracleFee + exchangeOracleFee > 100) {
204
+ throw error_1.ErrorTotalFeeMustBeLessThanHundred;
205
+ }
206
+ const isManifestValid = (0, utils_1.isValidUrl)(manifest) || (0, utils_1.isValidJson)(manifest);
207
+ if (!isManifestValid) {
208
+ throw error_1.ErrorInvalidManifest;
209
+ }
210
+ if (!manifestHash) {
211
+ throw error_1.ErrorHashIsEmptyString;
212
+ }
213
+ }
214
+ /**
215
+ * Creates, funds, and sets up a new escrow contract in a single transaction.
216
+ *
217
+ * @param {string} tokenAddress - The ERC-20 token address used to fund the escrow.
218
+ * @param {bigint} amount - The token amount to fund the escrow with.
219
+ * @param {string} jobRequesterId - An off-chain identifier for the job requester.
220
+ * @param {IEscrowConfig} escrowConfig - Configuration parameters for escrow setup:
221
+ * - `recordingOracle`: Address of the recording oracle.
222
+ * - `reputationOracle`: Address of the reputation oracle.
223
+ * - `exchangeOracle`: Address of the exchange oracle.
224
+ * - `recordingOracleFee`: Fee (in basis points or percentage * 100) for the recording oracle.
225
+ * - `reputationOracleFee`: Fee for the reputation oracle.
226
+ * - `exchangeOracleFee`: Fee for the exchange oracle.
227
+ * - `manifest`: URL to the manifest file.
228
+ * - `manifestHash`: Hash of the manifest content.
229
+ * @param {Overrides} [txOptions] - Additional transaction parameters (optional, defaults to an empty object).
230
+ *
231
+ * @returns {Promise<string>} Returns the address of the escrow created.
232
+ *
233
+ * @example
234
+ * import { Wallet, ethers } from 'ethers';
235
+ * import { EscrowClient, IERC20__factory } from '@human-protocol/sdk';
236
+ *
237
+ * const rpcUrl = 'YOUR_RPC_URL';
238
+ * const privateKey = 'YOUR_PRIVATE_KEY';
239
+ * const provider = new ethers.JsonRpcProvider(rpcUrl);
240
+ * const signer = new Wallet(privateKey, provider);
241
+ *
242
+ * const escrowClient = await EscrowClient.build(signer);
243
+ *
244
+ * const tokenAddress = '0xTokenAddress';
245
+ * const amount = ethers.parseUnits('1000', 18);
246
+ * const jobRequesterId = 'requester-123';
247
+ *
248
+ * const token = IERC20__factory.connect(tokenAddress, signer);
249
+ * await token.approve(escrowClient.escrowFactoryContract.target, amount);
250
+ *
251
+ * const escrowConfig = {
252
+ * recordingOracle: '0xRecordingOracle',
253
+ * reputationOracle: '0xReputationOracle',
254
+ * exchangeOracle: '0xExchangeOracle',
255
+ * recordingOracleFee: 5n,
256
+ * reputationOracleFee: 5n,
257
+ * exchangeOracleFee: 5n,
258
+ * manifest: 'https://example.com/manifest.json',
259
+ * manifestHash: 'manifestHash-123',
260
+ * } satisfies IEscrowConfig;
261
+ *
262
+ * const escrowAddress = await escrowClient.createFundAndSetupEscrow(
263
+ * tokenAddress,
264
+ * amount,
265
+ * jobRequesterId,
266
+ * escrowConfig
267
+ * );
268
+ *
269
+ * console.log('Escrow created at:', escrowAddress);
270
+ */
271
+ async createFundAndSetupEscrow(tokenAddress, amount, jobRequesterId, escrowConfig, txOptions = {}) {
272
+ if (!ethers_1.ethers.isAddress(tokenAddress)) {
273
+ throw error_1.ErrorInvalidTokenAddress;
274
+ }
275
+ this.verifySetupParameters(escrowConfig);
276
+ const { recordingOracle, reputationOracle, exchangeOracle, recordingOracleFee, reputationOracleFee, exchangeOracleFee, manifest, manifestHash, } = escrowConfig;
277
+ try {
278
+ const result = await (await this.escrowFactoryContract.createFundAndSetupEscrow(tokenAddress, amount, jobRequesterId, reputationOracle, recordingOracle, exchangeOracle, reputationOracleFee, recordingOracleFee, exchangeOracleFee, manifest, manifestHash, this.applyTxDefaults(txOptions))).wait();
279
+ const event = result?.logs?.find(({ topics }) => topics.includes(ethers_1.ethers.id('LaunchedV2(address,address,string)')))?.args;
280
+ if (!event) {
281
+ throw error_1.ErrorLaunchedEventIsNotEmitted;
282
+ }
283
+ return event.escrow;
284
+ }
285
+ catch (e) {
286
+ return (0, utils_1.throwError)(e);
287
+ }
288
+ }
187
289
  /**
188
290
  * This function sets up the parameters of the escrow.
189
291
  *
@@ -224,33 +326,10 @@ class EscrowClient extends base_1.BaseEthersClient {
224
326
  */
225
327
  async setup(escrowAddress, escrowConfig, txOptions = {}) {
226
328
  const { recordingOracle, reputationOracle, exchangeOracle, recordingOracleFee, reputationOracleFee, exchangeOracleFee, manifest, manifestHash, } = escrowConfig;
227
- if (!ethers_1.ethers.isAddress(recordingOracle)) {
228
- throw error_1.ErrorInvalidRecordingOracleAddressProvided;
229
- }
230
- if (!ethers_1.ethers.isAddress(reputationOracle)) {
231
- throw error_1.ErrorInvalidReputationOracleAddressProvided;
232
- }
233
- if (!ethers_1.ethers.isAddress(exchangeOracle)) {
234
- throw error_1.ErrorInvalidExchangeOracleAddressProvided;
235
- }
329
+ this.verifySetupParameters(escrowConfig);
236
330
  if (!ethers_1.ethers.isAddress(escrowAddress)) {
237
331
  throw error_1.ErrorInvalidEscrowAddressProvided;
238
332
  }
239
- if (recordingOracleFee <= 0 ||
240
- reputationOracleFee <= 0 ||
241
- exchangeOracleFee <= 0) {
242
- throw error_1.ErrorAmountMustBeGreaterThanZero;
243
- }
244
- if (recordingOracleFee + reputationOracleFee + exchangeOracleFee > 100) {
245
- throw error_1.ErrorTotalFeeMustBeLessThanHundred;
246
- }
247
- const isManifestValid = (0, utils_1.isValidUrl)(manifest) || (0, utils_1.isValidJson)(manifest);
248
- if (!isManifestValid) {
249
- throw error_1.ErrorInvalidManifest;
250
- }
251
- if (!manifestHash) {
252
- throw error_1.ErrorHashIsEmptyString;
253
- }
254
333
  if (!(await this.escrowFactoryContract.hasEscrow(escrowAddress))) {
255
334
  throw error_1.ErrorEscrowAddressIsNotProvidedByFactory;
256
335
  }
@@ -313,7 +392,7 @@ class EscrowClient extends base_1.BaseEthersClient {
313
392
  async storeResults(escrowAddress, url, hash, a, b) {
314
393
  const escrowContract = this.getEscrowContract(escrowAddress);
315
394
  const hasFundsToReserveParam = typeof a === 'bigint';
316
- const fundsToReserve = hasFundsToReserveParam ? a : undefined;
395
+ const fundsToReserve = hasFundsToReserveParam ? a : null;
317
396
  const txOptions = (hasFundsToReserveParam ? b : a) || {};
318
397
  // When fundsToReserve is provided and is 0, allow empty URL.
319
398
  // In this situation not solutions might have been provided so the escrow can be straight cancelled.
@@ -331,7 +410,7 @@ class EscrowClient extends base_1.BaseEthersClient {
331
410
  throw error_1.ErrorEscrowAddressIsNotProvidedByFactory;
332
411
  }
333
412
  try {
334
- if (fundsToReserve !== undefined) {
413
+ if (fundsToReserve !== null) {
335
414
  await (await escrowContract['storeResults(string,string,uint256)'](url, hash, fundsToReserve, this.applyTxDefaults(txOptions))).wait();
336
415
  }
337
416
  else {
@@ -496,7 +575,7 @@ class EscrowClient extends base_1.BaseEthersClient {
496
575
  * @param {string} escrowAddress Address of the escrow to withdraw.
497
576
  * @param {string} tokenAddress Address of the token to withdraw.
498
577
  * @param {Overrides} [txOptions] - Additional transaction parameters (optional, defaults to an empty object).
499
- * @returns {EscrowWithdraw} Returns the escrow withdrawal data including transaction hash and withdrawal amount. Throws error if any.
578
+ * @returns {IEscrowWithdraw} Returns the escrow withdrawal data including transaction hash and withdrawal amount. Throws error if any.
500
579
  *
501
580
  *
502
581
  * **Code example**
@@ -544,7 +623,7 @@ class EscrowClient extends base_1.BaseEthersClient {
544
623
  });
545
624
  const from = parsedLog?.args[0];
546
625
  if (parsedLog?.name === 'Transfer' && from === escrowAddress) {
547
- amountTransferred = parsedLog?.args[2];
626
+ amountTransferred = BigInt(parsedLog?.args[2]);
548
627
  break;
549
628
  }
550
629
  }
@@ -552,12 +631,11 @@ class EscrowClient extends base_1.BaseEthersClient {
552
631
  if (amountTransferred === undefined) {
553
632
  throw error_1.ErrorTransferEventNotFoundInTransactionLogs;
554
633
  }
555
- const escrowWithdrawData = {
634
+ return {
556
635
  txHash: transactionReceipt?.hash || '',
557
636
  tokenAddress,
558
637
  withdrawnAmount: amountTransferred,
559
638
  };
560
- return escrowWithdrawData;
561
639
  }
562
640
  catch (e) {
563
641
  return (0, utils_1.throwError)(e);
@@ -1185,6 +1263,12 @@ __decorate([
1185
1263
  __metadata("design:paramtypes", [String, String, Object]),
1186
1264
  __metadata("design:returntype", Promise)
1187
1265
  ], EscrowClient.prototype, "createEscrow", null);
1266
+ __decorate([
1267
+ decorators_1.requiresSigner,
1268
+ __metadata("design:type", Function),
1269
+ __metadata("design:paramtypes", [String, BigInt, String, Object, Object]),
1270
+ __metadata("design:returntype", Promise)
1271
+ ], EscrowClient.prototype, "createFundAndSetupEscrow", null);
1188
1272
  __decorate([
1189
1273
  decorators_1.requiresSigner,
1190
1274
  __metadata("design:type", Function),
@@ -1329,23 +1413,29 @@ class EscrowUtils {
1329
1413
  * interface IEscrow {
1330
1414
  * id: string;
1331
1415
  * address: string;
1332
- * amountPaid: string;
1333
- * balance: string;
1334
- * count: string;
1335
- * jobRequesterId: string;
1416
+ * amountPaid: bigint;
1417
+ * balance: bigint;
1418
+ * count: bigint;
1336
1419
  * factoryAddress: string;
1337
- * finalResultsUrl?: string;
1338
- * intermediateResultsUrl?: string;
1420
+ * finalResultsUrl: string | null;
1421
+ * finalResultsHash: string | null;
1422
+ * intermediateResultsUrl: string | null;
1423
+ * intermediateResultsHash: string | null;
1339
1424
  * launcher: string;
1340
- * manifestHash?: string;
1341
- * manifest?: string;
1342
- * recordingOracle?: string;
1343
- * reputationOracle?: string;
1344
- * exchangeOracle?: string;
1345
- * status: EscrowStatus;
1425
+ * jobRequesterId: string | null;
1426
+ * manifestHash: string | null;
1427
+ * manifest: string | null;
1428
+ * recordingOracle: string | null;
1429
+ * reputationOracle: string | null;
1430
+ * exchangeOracle: string | null;
1431
+ * recordingOracleFee: number | null;
1432
+ * reputationOracleFee: number | null;
1433
+ * exchangeOracleFee: number | null;
1434
+ * status: string;
1346
1435
  * token: string;
1347
- * totalFundedAmount: string;
1348
- * createdAt: string;
1436
+ * totalFundedAmount: bigint;
1437
+ * createdAt: number;
1438
+ * chainId: number;
1349
1439
  * };
1350
1440
  * ```
1351
1441
  *
@@ -1405,11 +1495,7 @@ class EscrowUtils {
1405
1495
  first: first,
1406
1496
  skip: skip,
1407
1497
  });
1408
- escrows.map((escrow) => (escrow.chainId = networkData.chainId));
1409
- if (!escrows) {
1410
- return [];
1411
- }
1412
- return escrows;
1498
+ return (escrows || []).map((e) => mapEscrow(e, networkData.chainId));
1413
1499
  }
1414
1500
  /**
1415
1501
  * This function returns the escrow data for a given address.
@@ -1435,23 +1521,29 @@ class EscrowUtils {
1435
1521
  * interface IEscrow {
1436
1522
  * id: string;
1437
1523
  * address: string;
1438
- * amountPaid: string;
1439
- * balance: string;
1440
- * count: string;
1441
- * jobRequesterId: string;
1524
+ * amountPaid: bigint;
1525
+ * balance: bigint;
1526
+ * count: bigint;
1442
1527
  * factoryAddress: string;
1443
- * finalResultsUrl?: string;
1444
- * intermediateResultsUrl?: string;
1528
+ * finalResultsUrl: string | null;
1529
+ * finalResultsHash: string | null;
1530
+ * intermediateResultsUrl: string | null;
1531
+ * intermediateResultsHash: string | null;
1445
1532
  * launcher: string;
1446
- * manifestHash?: string;
1447
- * manifest?: string;
1448
- * recordingOracle?: string;
1449
- * reputationOracle?: string;
1450
- * exchangeOracle?: string;
1451
- * status: EscrowStatus;
1533
+ * jobRequesterId: string | null;
1534
+ * manifestHash: string | null;
1535
+ * manifest: string | null;
1536
+ * recordingOracle: string | null;
1537
+ * reputationOracle: string | null;
1538
+ * exchangeOracle: string | null;
1539
+ * recordingOracleFee: number | null;
1540
+ * reputationOracleFee: number | null;
1541
+ * exchangeOracleFee: number | null;
1542
+ * status: string;
1452
1543
  * token: string;
1453
- * totalFundedAmount: string;
1454
- * createdAt: string;
1544
+ * totalFundedAmount: bigint;
1545
+ * createdAt: number;
1546
+ * chainId: number;
1455
1547
  * };
1456
1548
  * ```
1457
1549
  *
@@ -1477,7 +1569,9 @@ class EscrowUtils {
1477
1569
  throw error_1.ErrorInvalidAddress;
1478
1570
  }
1479
1571
  const { escrow } = await (0, graphql_request_1.default)((0, utils_1.getSubgraphUrl)(networkData), (0, graphql_1.GET_ESCROW_BY_ADDRESS_QUERY)(), { escrowAddress: escrowAddress.toLowerCase() });
1480
- return escrow || null;
1572
+ if (!escrow)
1573
+ return null;
1574
+ return mapEscrow(escrow, networkData.chainId);
1481
1575
  }
1482
1576
  /**
1483
1577
  * This function returns the status events for a given set of networks within an optional date range.
@@ -1566,12 +1660,12 @@ class EscrowUtils {
1566
1660
  if (!data || !data['escrowStatusEvents']) {
1567
1661
  return [];
1568
1662
  }
1569
- const statusEvents = data['escrowStatusEvents'];
1570
- const eventsWithChainId = statusEvents.map((event) => ({
1571
- ...event,
1663
+ return data['escrowStatusEvents'].map((event) => ({
1664
+ timestamp: Number(event.timestamp) * 1000,
1665
+ escrowAddress: event.escrowAddress,
1666
+ status: types_1.EscrowStatus[event.status],
1572
1667
  chainId,
1573
1668
  }));
1574
- return eventsWithChainId;
1575
1669
  }
1576
1670
  /**
1577
1671
  * This function returns the payouts for a given set of networks.
@@ -1582,7 +1676,7 @@ class EscrowUtils {
1582
1676
  * Fetch payouts from the subgraph.
1583
1677
  *
1584
1678
  * @param {IPayoutFilter} filter Filter parameters.
1585
- * @returns {Promise<Payout[]>} List of payouts matching the filters.
1679
+ * @returns {Promise<IPayout[]>} List of payouts matching the filters.
1586
1680
  *
1587
1681
  * **Code example**
1588
1682
  *
@@ -1622,7 +1716,16 @@ class EscrowUtils {
1622
1716
  skip,
1623
1717
  orderDirection,
1624
1718
  });
1625
- return payouts || [];
1719
+ if (!payouts) {
1720
+ return [];
1721
+ }
1722
+ return payouts.map((payout) => ({
1723
+ id: payout.id,
1724
+ escrowAddress: payout.escrowAddress,
1725
+ recipient: payout.recipient,
1726
+ amount: BigInt(payout.amount),
1727
+ createdAt: Number(payout.createdAt) * 1000,
1728
+ }));
1626
1729
  }
1627
1730
  /**
1628
1731
  * This function returns the cancellation refunds for a given set of networks.
@@ -1645,7 +1748,7 @@ class EscrowUtils {
1645
1748
  * ```
1646
1749
  *
1647
1750
  * ```ts
1648
- * type CancellationRefund = {
1751
+ * interface ICancellationRefund {
1649
1752
  * id: string;
1650
1753
  * escrowAddress: string;
1651
1754
  * receiver: string;
@@ -1658,7 +1761,7 @@ class EscrowUtils {
1658
1761
  *
1659
1762
  *
1660
1763
  * @param {Object} filter Filter parameters.
1661
- * @returns {Promise<CancellationRefund[]>} List of cancellation refunds matching the filters.
1764
+ * @returns {Promise<ICancellationRefund[]>} List of cancellation refunds matching the filters.
1662
1765
  *
1663
1766
  * **Code example**
1664
1767
  *
@@ -1694,7 +1797,18 @@ class EscrowUtils {
1694
1797
  skip,
1695
1798
  orderDirection,
1696
1799
  });
1697
- return cancellationRefundEvents || [];
1800
+ if (!cancellationRefundEvents || cancellationRefundEvents.length === 0) {
1801
+ return [];
1802
+ }
1803
+ return cancellationRefundEvents.map((event) => ({
1804
+ id: event.id,
1805
+ escrowAddress: event.escrowAddress,
1806
+ receiver: event.receiver,
1807
+ amount: BigInt(event.amount),
1808
+ block: Number(event.block),
1809
+ timestamp: Number(event.timestamp) * 1000,
1810
+ txHash: event.txHash,
1811
+ }));
1698
1812
  }
1699
1813
  /**
1700
1814
  * This function returns the cancellation refund for a given escrow address.
@@ -1717,7 +1831,7 @@ class EscrowUtils {
1717
1831
  * ```
1718
1832
  *
1719
1833
  * ```ts
1720
- * type CancellationRefund = {
1834
+ * interface ICancellationRefund {
1721
1835
  * id: string;
1722
1836
  * escrowAddress: string;
1723
1837
  * receiver: string;
@@ -1731,7 +1845,7 @@ class EscrowUtils {
1731
1845
  *
1732
1846
  * @param {ChainId} chainId Network in which the escrow has been deployed
1733
1847
  * @param {string} escrowAddress Address of the escrow
1734
- * @returns {Promise<CancellationRefund>} Cancellation refund data
1848
+ * @returns {Promise<ICancellationRefund>} Cancellation refund data
1735
1849
  *
1736
1850
  * **Code example**
1737
1851
  *
@@ -1749,7 +1863,51 @@ class EscrowUtils {
1749
1863
  throw error_1.ErrorInvalidEscrowAddressProvided;
1750
1864
  }
1751
1865
  const { cancellationRefundEvents } = await (0, graphql_request_1.default)((0, utils_1.getSubgraphUrl)(networkData), (0, graphql_1.GET_CANCELLATION_REFUND_BY_ADDRESS_QUERY)(), { escrowAddress: escrowAddress.toLowerCase() });
1752
- return cancellationRefundEvents?.[0] || null;
1866
+ if (!cancellationRefundEvents || cancellationRefundEvents.length === 0) {
1867
+ return null;
1868
+ }
1869
+ return {
1870
+ id: cancellationRefundEvents[0].id,
1871
+ escrowAddress: cancellationRefundEvents[0].escrowAddress,
1872
+ receiver: cancellationRefundEvents[0].receiver,
1873
+ amount: BigInt(cancellationRefundEvents[0].amount),
1874
+ block: Number(cancellationRefundEvents[0].block),
1875
+ timestamp: Number(cancellationRefundEvents[0].timestamp) * 1000,
1876
+ txHash: cancellationRefundEvents[0].txHash,
1877
+ };
1753
1878
  }
1754
1879
  }
1755
1880
  exports.EscrowUtils = EscrowUtils;
1881
+ function mapEscrow(e, chainId) {
1882
+ return {
1883
+ id: e.id,
1884
+ address: e.address,
1885
+ amountPaid: BigInt(e.amountPaid),
1886
+ balance: BigInt(e.balance),
1887
+ count: Number(e.count),
1888
+ factoryAddress: e.factoryAddress,
1889
+ finalResultsUrl: e.finalResultsUrl,
1890
+ finalResultsHash: e.finalResultsHash,
1891
+ intermediateResultsUrl: e.intermediateResultsUrl,
1892
+ intermediateResultsHash: e.intermediateResultsHash,
1893
+ launcher: e.launcher,
1894
+ jobRequesterId: e.jobRequesterId,
1895
+ manifestHash: e.manifestHash,
1896
+ manifest: e.manifest,
1897
+ recordingOracle: e.recordingOracle,
1898
+ reputationOracle: e.reputationOracle,
1899
+ exchangeOracle: e.exchangeOracle,
1900
+ recordingOracleFee: e.recordingOracleFee
1901
+ ? Number(e.recordingOracleFee)
1902
+ : null,
1903
+ reputationOracleFee: e.reputationOracleFee
1904
+ ? Number(e.reputationOracleFee)
1905
+ : null,
1906
+ exchangeOracleFee: e.exchangeOracleFee ? Number(e.exchangeOracleFee) : null,
1907
+ status: e.status,
1908
+ token: e.token,
1909
+ totalFundedAmount: BigInt(e.totalFundedAmount),
1910
+ createdAt: Number(e.createdAt) * 1000,
1911
+ chainId: Number(chainId),
1912
+ };
1913
+ }
@@ -1,4 +1,4 @@
1
- import { ChainId } from '../enums';
1
+ import { IReputationNetwork } from '../interfaces';
2
2
  export type EscrowData = {
3
3
  id: string;
4
4
  address: string;
@@ -6,24 +6,53 @@ export type EscrowData = {
6
6
  balance: string;
7
7
  count: string;
8
8
  factoryAddress: string;
9
- finalResultsUrl?: string;
10
- finalResultsHash?: string;
11
- intermediateResultsUrl?: string;
12
- intermediateResultsHash?: string;
9
+ finalResultsUrl: string | null;
10
+ finalResultsHash: string | null;
11
+ intermediateResultsUrl: string | null;
12
+ intermediateResultsHash: string | null;
13
13
  launcher: string;
14
- manifestHash?: string;
15
- manifestUrl?: string;
16
- recordingOracle?: string;
17
- reputationOracle?: string;
18
- exchangeOracle?: string;
19
- recordingOracleFee?: string;
20
- reputationOracleFee?: string;
21
- exchangeOracleFee?: string;
14
+ jobRequesterId: string | null;
15
+ manifestHash: string | null;
16
+ manifest: string | null;
17
+ recordingOracle: string | null;
18
+ reputationOracle: string | null;
19
+ exchangeOracle: string | null;
20
+ recordingOracleFee: string | null;
21
+ reputationOracleFee: string | null;
22
+ exchangeOracleFee: string | null;
22
23
  status: string;
23
24
  token: string;
24
25
  totalFundedAmount: string;
25
26
  createdAt: string;
26
- chainId: number;
27
+ };
28
+ export type WorkerData = {
29
+ id: string;
30
+ address: string;
31
+ totalHMTAmountReceived: string;
32
+ payoutCount: string;
33
+ };
34
+ export type InternalTransactionData = {
35
+ from: string;
36
+ to: string;
37
+ value: string;
38
+ method: string;
39
+ receiver: string | null;
40
+ escrow: string | null;
41
+ token: string | null;
42
+ id: string | null;
43
+ };
44
+ export type TransactionData = {
45
+ block: string;
46
+ txHash: string;
47
+ from: string;
48
+ to: string;
49
+ timestamp: string;
50
+ value: string;
51
+ method: string;
52
+ receiver: string | null;
53
+ escrow: string | null;
54
+ token: string | null;
55
+ internalTransactions: InternalTransactionData[];
27
56
  };
28
57
  export type HMTStatisticsData = {
29
58
  totalTransferEventCount: string;
@@ -71,72 +100,14 @@ export type RewardAddedEventData = {
71
100
  slasher: string;
72
101
  amount: string;
73
102
  };
74
- export type DailyEscrowData = {
75
- timestamp: Date;
76
- escrowsTotal: number;
77
- escrowsPending: number;
78
- escrowsSolved: number;
79
- escrowsPaid: number;
80
- escrowsCancelled: number;
81
- };
82
- export type EscrowStatistics = {
83
- totalEscrows: number;
84
- dailyEscrowsData: DailyEscrowData[];
85
- };
86
- export type DailyWorkerData = {
87
- timestamp: Date;
88
- activeWorkers: number;
89
- };
90
- export type WorkerStatistics = {
91
- dailyWorkersData: DailyWorkerData[];
92
- };
93
- export type DailyPaymentData = {
94
- timestamp: Date;
95
- totalAmountPaid: bigint;
96
- totalCount: number;
97
- averageAmountPerWorker: bigint;
98
- };
99
- export type PaymentStatistics = {
100
- dailyPaymentsData: DailyPaymentData[];
101
- };
102
103
  export type HMTHolderData = {
103
104
  address: string;
104
105
  balance: string;
105
106
  };
106
- export type HMTHolder = {
107
- address: string;
108
- balance: bigint;
109
- };
110
- export type DailyHMTData = {
111
- timestamp: Date;
112
- totalTransactionAmount: bigint;
113
- totalTransactionCount: number;
114
- dailyUniqueSenders: number;
115
- dailyUniqueReceivers: number;
116
- };
117
- export type HMTStatistics = {
118
- totalTransferAmount: bigint;
119
- totalTransferCount: number;
120
- totalHolders: number;
121
- };
122
- export type IMDataEntity = {
123
- served: number;
124
- solved: number;
125
- };
126
- export type IMData = Record<string, IMDataEntity>;
127
- export type DailyTaskData = {
128
- timestamp: Date;
129
- tasksTotal: number;
130
- tasksSolved: number;
131
- };
132
- export type TaskStatistics = {
133
- dailyTasksData: DailyTaskData[];
134
- };
135
107
  export type StatusEvent = {
136
- timestamp: number;
108
+ timestamp: string;
137
109
  escrowAddress: string;
138
110
  status: string;
139
- chainId: ChainId;
140
111
  };
141
112
  export type KVStoreData = {
142
113
  id: string;
@@ -144,6 +115,62 @@ export type KVStoreData = {
144
115
  key: string;
145
116
  value: string;
146
117
  timestamp: Date;
147
- block: number;
118
+ block: string;
119
+ };
120
+ export type StakerData = {
121
+ id: string;
122
+ address: string;
123
+ stakedAmount: string;
124
+ lockedAmount: string;
125
+ withdrawnAmount: string;
126
+ slashedAmount: string;
127
+ lockedUntilTimestamp: string;
128
+ lastDepositTimestamp: string;
129
+ };
130
+ export interface IOperatorSubgraph {
131
+ id: string;
132
+ address: string;
133
+ amountJobsProcessed: string;
134
+ role: string | null;
135
+ fee: string | null;
136
+ publicKey: string | null;
137
+ webhookUrl: string | null;
138
+ website: string | null;
139
+ url: string | null;
140
+ registrationNeeded: boolean | null;
141
+ registrationInstructions: string | null;
142
+ name: string | null;
143
+ category: string | null;
144
+ jobTypes: string | string[] | null;
145
+ reputationNetworks: {
146
+ address: string;
147
+ }[];
148
+ staker: {
149
+ stakedAmount: string;
150
+ lockedAmount: string;
151
+ lockedUntilTimestamp: string;
152
+ withdrawnAmount: string;
153
+ slashedAmount: string;
154
+ lastDepositTimestamp: string;
155
+ } | null;
156
+ }
157
+ export interface IReputationNetworkSubgraph extends Omit<IReputationNetwork, 'operators'> {
158
+ operators: IOperatorSubgraph[];
159
+ }
160
+ export type PayoutData = {
161
+ id: string;
162
+ escrowAddress: string;
163
+ recipient: string;
164
+ amount: string;
165
+ createdAt: string;
166
+ };
167
+ export type CancellationRefundData = {
168
+ id: string;
169
+ escrowAddress: string;
170
+ receiver: string;
171
+ amount: string;
172
+ block: string;
173
+ timestamp: string;
174
+ txHash: string;
148
175
  };
149
176
  //# sourceMappingURL=types.d.ts.map