@human-protocol/sdk 5.0.0-beta.2 → 5.0.0-beta.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/escrow.d.ts +53 -42
- package/dist/escrow.d.ts.map +1 -1
- package/dist/escrow.js +125 -52
- package/dist/graphql/types.d.ts +101 -74
- package/dist/graphql/types.d.ts.map +1 -1
- package/dist/interfaces.d.ts +119 -77
- package/dist/interfaces.d.ts.map +1 -1
- package/dist/operator.d.ts.map +1 -1
- package/dist/operator.js +13 -7
- package/dist/staking.d.ts.map +1 -1
- package/dist/staking.js +13 -2
- package/dist/statistics.d.ts +32 -33
- package/dist/statistics.d.ts.map +1 -1
- package/dist/statistics.js +38 -39
- package/dist/transaction.d.ts +26 -2
- package/dist/transaction.d.ts.map +1 -1
- package/dist/transaction.js +54 -4
- package/dist/types.d.ts +0 -75
- package/dist/types.d.ts.map +1 -1
- package/dist/worker.d.ts +1 -1
- package/dist/worker.d.ts.map +1 -1
- package/dist/worker.js +14 -4
- package/package.json +1 -1
- package/src/escrow.ts +143 -74
- package/src/graphql/types.ts +108 -87
- package/src/interfaces.ts +132 -78
- package/src/operator.ts +17 -13
- package/src/staking.ts +17 -4
- package/src/statistics.ts +58 -62
- package/src/transaction.ts +66 -8
- package/src/types.ts +0 -79
- package/src/worker.ts +18 -6
package/dist/escrow.d.ts
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import { ContractRunner, Overrides } from 'ethers';
|
|
2
2
|
import { BaseEthersClient } from './base';
|
|
3
3
|
import { ChainId, OrderDirection } from './enums';
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import { EscrowStatus, EscrowWithdraw, NetworkData, TransactionLikeWithNonce, Payout, CancellationRefund } from './types';
|
|
4
|
+
import { IEscrow, IEscrowConfig, IEscrowsFilter, IPayoutFilter, IStatusEventFilter, IStatusEvent, ICancellationRefund, IPayout, IEscrowWithdraw } from './interfaces';
|
|
5
|
+
import { EscrowStatus, NetworkData, TransactionLikeWithNonce } from './types';
|
|
7
6
|
/**
|
|
8
7
|
* ## Introduction
|
|
9
8
|
*
|
|
@@ -417,7 +416,7 @@ export declare class EscrowClient extends BaseEthersClient {
|
|
|
417
416
|
* @param {string} escrowAddress Address of the escrow to withdraw.
|
|
418
417
|
* @param {string} tokenAddress Address of the token to withdraw.
|
|
419
418
|
* @param {Overrides} [txOptions] - Additional transaction parameters (optional, defaults to an empty object).
|
|
420
|
-
* @returns {
|
|
419
|
+
* @returns {IEscrowWithdraw} Returns the escrow withdrawal data including transaction hash and withdrawal amount. Throws error if any.
|
|
421
420
|
*
|
|
422
421
|
*
|
|
423
422
|
* **Code example**
|
|
@@ -441,7 +440,7 @@ export declare class EscrowClient extends BaseEthersClient {
|
|
|
441
440
|
* );
|
|
442
441
|
* ```
|
|
443
442
|
*/
|
|
444
|
-
withdraw(escrowAddress: string, tokenAddress: string, txOptions?: Overrides): Promise<
|
|
443
|
+
withdraw(escrowAddress: string, tokenAddress: string, txOptions?: Overrides): Promise<IEscrowWithdraw>;
|
|
445
444
|
/**
|
|
446
445
|
* Creates a prepared transaction for bulk payout without immediately sending it.
|
|
447
446
|
* @param {string} escrowAddress Escrow address to payout.
|
|
@@ -869,23 +868,29 @@ export declare class EscrowUtils {
|
|
|
869
868
|
* interface IEscrow {
|
|
870
869
|
* id: string;
|
|
871
870
|
* address: string;
|
|
872
|
-
* amountPaid:
|
|
873
|
-
* balance:
|
|
874
|
-
* count:
|
|
875
|
-
* jobRequesterId: string;
|
|
871
|
+
* amountPaid: bigint;
|
|
872
|
+
* balance: bigint;
|
|
873
|
+
* count: bigint;
|
|
876
874
|
* factoryAddress: string;
|
|
877
|
-
* finalResultsUrl
|
|
878
|
-
*
|
|
875
|
+
* finalResultsUrl: string | null;
|
|
876
|
+
* finalResultsHash: string | null;
|
|
877
|
+
* intermediateResultsUrl: string | null;
|
|
878
|
+
* intermediateResultsHash: string | null;
|
|
879
879
|
* launcher: string;
|
|
880
|
-
*
|
|
881
|
-
*
|
|
882
|
-
*
|
|
883
|
-
*
|
|
884
|
-
*
|
|
885
|
-
*
|
|
880
|
+
* jobRequesterId: string | null;
|
|
881
|
+
* manifestHash: string | null;
|
|
882
|
+
* manifest: string | null;
|
|
883
|
+
* recordingOracle: string | null;
|
|
884
|
+
* reputationOracle: string | null;
|
|
885
|
+
* exchangeOracle: string | null;
|
|
886
|
+
* recordingOracleFee: number | null;
|
|
887
|
+
* reputationOracleFee: number | null;
|
|
888
|
+
* exchangeOracleFee: number | null;
|
|
889
|
+
* status: string;
|
|
886
890
|
* token: string;
|
|
887
|
-
* totalFundedAmount:
|
|
888
|
-
* createdAt:
|
|
891
|
+
* totalFundedAmount: bigint;
|
|
892
|
+
* createdAt: number;
|
|
893
|
+
* chainId: number;
|
|
889
894
|
* };
|
|
890
895
|
* ```
|
|
891
896
|
*
|
|
@@ -932,23 +937,29 @@ export declare class EscrowUtils {
|
|
|
932
937
|
* interface IEscrow {
|
|
933
938
|
* id: string;
|
|
934
939
|
* address: string;
|
|
935
|
-
* amountPaid:
|
|
936
|
-
* balance:
|
|
937
|
-
* count:
|
|
938
|
-
* jobRequesterId: string;
|
|
940
|
+
* amountPaid: bigint;
|
|
941
|
+
* balance: bigint;
|
|
942
|
+
* count: bigint;
|
|
939
943
|
* factoryAddress: string;
|
|
940
|
-
* finalResultsUrl
|
|
941
|
-
*
|
|
944
|
+
* finalResultsUrl: string | null;
|
|
945
|
+
* finalResultsHash: string | null;
|
|
946
|
+
* intermediateResultsUrl: string | null;
|
|
947
|
+
* intermediateResultsHash: string | null;
|
|
942
948
|
* launcher: string;
|
|
943
|
-
*
|
|
944
|
-
*
|
|
945
|
-
*
|
|
946
|
-
*
|
|
947
|
-
*
|
|
948
|
-
*
|
|
949
|
+
* jobRequesterId: string | null;
|
|
950
|
+
* manifestHash: string | null;
|
|
951
|
+
* manifest: string | null;
|
|
952
|
+
* recordingOracle: string | null;
|
|
953
|
+
* reputationOracle: string | null;
|
|
954
|
+
* exchangeOracle: string | null;
|
|
955
|
+
* recordingOracleFee: number | null;
|
|
956
|
+
* reputationOracleFee: number | null;
|
|
957
|
+
* exchangeOracleFee: number | null;
|
|
958
|
+
* status: string;
|
|
949
959
|
* token: string;
|
|
950
|
-
* totalFundedAmount:
|
|
951
|
-
* createdAt:
|
|
960
|
+
* totalFundedAmount: bigint;
|
|
961
|
+
* createdAt: number;
|
|
962
|
+
* chainId: number;
|
|
952
963
|
* };
|
|
953
964
|
* ```
|
|
954
965
|
*
|
|
@@ -1022,7 +1033,7 @@ export declare class EscrowUtils {
|
|
|
1022
1033
|
* })();
|
|
1023
1034
|
* ```
|
|
1024
1035
|
*/
|
|
1025
|
-
static getStatusEvents(filter: IStatusEventFilter): Promise<
|
|
1036
|
+
static getStatusEvents(filter: IStatusEventFilter): Promise<IStatusEvent[]>;
|
|
1026
1037
|
/**
|
|
1027
1038
|
* This function returns the payouts for a given set of networks.
|
|
1028
1039
|
*
|
|
@@ -1032,7 +1043,7 @@ export declare class EscrowUtils {
|
|
|
1032
1043
|
* Fetch payouts from the subgraph.
|
|
1033
1044
|
*
|
|
1034
1045
|
* @param {IPayoutFilter} filter Filter parameters.
|
|
1035
|
-
* @returns {Promise<
|
|
1046
|
+
* @returns {Promise<IPayout[]>} List of payouts matching the filters.
|
|
1036
1047
|
*
|
|
1037
1048
|
* **Code example**
|
|
1038
1049
|
*
|
|
@@ -1049,7 +1060,7 @@ export declare class EscrowUtils {
|
|
|
1049
1060
|
* console.log(payouts);
|
|
1050
1061
|
* ```
|
|
1051
1062
|
*/
|
|
1052
|
-
static getPayouts(filter: IPayoutFilter): Promise<
|
|
1063
|
+
static getPayouts(filter: IPayoutFilter): Promise<IPayout[]>;
|
|
1053
1064
|
/**
|
|
1054
1065
|
* This function returns the cancellation refunds for a given set of networks.
|
|
1055
1066
|
*
|
|
@@ -1071,7 +1082,7 @@ export declare class EscrowUtils {
|
|
|
1071
1082
|
* ```
|
|
1072
1083
|
*
|
|
1073
1084
|
* ```ts
|
|
1074
|
-
*
|
|
1085
|
+
* interface ICancellationRefund {
|
|
1075
1086
|
* id: string;
|
|
1076
1087
|
* escrowAddress: string;
|
|
1077
1088
|
* receiver: string;
|
|
@@ -1084,7 +1095,7 @@ export declare class EscrowUtils {
|
|
|
1084
1095
|
*
|
|
1085
1096
|
*
|
|
1086
1097
|
* @param {Object} filter Filter parameters.
|
|
1087
|
-
* @returns {Promise<
|
|
1098
|
+
* @returns {Promise<ICancellationRefund[]>} List of cancellation refunds matching the filters.
|
|
1088
1099
|
*
|
|
1089
1100
|
* **Code example**
|
|
1090
1101
|
*
|
|
@@ -1107,7 +1118,7 @@ export declare class EscrowUtils {
|
|
|
1107
1118
|
first?: number;
|
|
1108
1119
|
skip?: number;
|
|
1109
1120
|
orderDirection?: OrderDirection;
|
|
1110
|
-
}): Promise<
|
|
1121
|
+
}): Promise<ICancellationRefund[]>;
|
|
1111
1122
|
/**
|
|
1112
1123
|
* This function returns the cancellation refund for a given escrow address.
|
|
1113
1124
|
*
|
|
@@ -1129,7 +1140,7 @@ export declare class EscrowUtils {
|
|
|
1129
1140
|
* ```
|
|
1130
1141
|
*
|
|
1131
1142
|
* ```ts
|
|
1132
|
-
*
|
|
1143
|
+
* interface ICancellationRefund {
|
|
1133
1144
|
* id: string;
|
|
1134
1145
|
* escrowAddress: string;
|
|
1135
1146
|
* receiver: string;
|
|
@@ -1143,7 +1154,7 @@ export declare class EscrowUtils {
|
|
|
1143
1154
|
*
|
|
1144
1155
|
* @param {ChainId} chainId Network in which the escrow has been deployed
|
|
1145
1156
|
* @param {string} escrowAddress Address of the escrow
|
|
1146
|
-
* @returns {Promise<
|
|
1157
|
+
* @returns {Promise<ICancellationRefund>} Cancellation refund data
|
|
1147
1158
|
*
|
|
1148
1159
|
* **Code example**
|
|
1149
1160
|
*
|
|
@@ -1153,6 +1164,6 @@ export declare class EscrowUtils {
|
|
|
1153
1164
|
* const cancellationRefund = await EscrowUtils.getCancellationRefund(ChainId.POLYGON_AMOY, "0x1234567890123456789012345678901234567890");
|
|
1154
1165
|
* ```
|
|
1155
1166
|
*/
|
|
1156
|
-
static getCancellationRefund(chainId: ChainId, escrowAddress: string): Promise<
|
|
1167
|
+
static getCancellationRefund(chainId: ChainId, escrowAddress: string): Promise<ICancellationRefund | null>;
|
|
1157
1168
|
}
|
|
1158
1169
|
//# sourceMappingURL=escrow.d.ts.map
|
package/dist/escrow.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"escrow.d.ts","sourceRoot":"","sources":["../src/escrow.ts"],"names":[],"mappings":"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;
|
|
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;AAwClD,OAAO,EACL,OAAO,EACP,aAAa,EACb,cAAc,EACd,aAAa,EACb,kBAAkB,EAClB,YAAY,EACZ,mBAAmB,EACnB,OAAO,EACP,eAAe,EAChB,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,wBAAwB,EAAE,MAAM,SAAS,CAAC;AAS9E;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoEG;AACH,qBAAa,YAAa,SAAQ,gBAAgB;IAChD,OAAO,CAAC,qBAAqB,CAAgB;IAE7C;;;;;OAKG;gBACS,MAAM,EA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AAC;QACvB,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,IAAI,CAAC,EAAE,IAAI,CAAC;QACZ,EAAE,CAAC,EAAE,IAAI,CAAC;QACV,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,cAAc,CAAC,EAAE,cAAc,CAAC;KACjC,GAAG,OAAO,CAAC,mBAAmB,EAAE,CAAC;IA0ClC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA4CG;WACiB,qBAAqB,CACvC,OAAO,EAAE,OAAO,EAChB,aAAa,EAAE,MAAM,GACpB,OAAO,CAAC,mBAAmB,GAAG,IAAI,CAAC;CA8BvC"}
|
package/dist/escrow.js
CHANGED
|
@@ -313,7 +313,7 @@ class EscrowClient extends base_1.BaseEthersClient {
|
|
|
313
313
|
async storeResults(escrowAddress, url, hash, a, b) {
|
|
314
314
|
const escrowContract = this.getEscrowContract(escrowAddress);
|
|
315
315
|
const hasFundsToReserveParam = typeof a === 'bigint';
|
|
316
|
-
const fundsToReserve = hasFundsToReserveParam ? a :
|
|
316
|
+
const fundsToReserve = hasFundsToReserveParam ? a : null;
|
|
317
317
|
const txOptions = (hasFundsToReserveParam ? b : a) || {};
|
|
318
318
|
// When fundsToReserve is provided and is 0, allow empty URL.
|
|
319
319
|
// In this situation not solutions might have been provided so the escrow can be straight cancelled.
|
|
@@ -331,7 +331,7 @@ class EscrowClient extends base_1.BaseEthersClient {
|
|
|
331
331
|
throw error_1.ErrorEscrowAddressIsNotProvidedByFactory;
|
|
332
332
|
}
|
|
333
333
|
try {
|
|
334
|
-
if (fundsToReserve !==
|
|
334
|
+
if (fundsToReserve !== null) {
|
|
335
335
|
await (await escrowContract['storeResults(string,string,uint256)'](url, hash, fundsToReserve, this.applyTxDefaults(txOptions))).wait();
|
|
336
336
|
}
|
|
337
337
|
else {
|
|
@@ -496,7 +496,7 @@ class EscrowClient extends base_1.BaseEthersClient {
|
|
|
496
496
|
* @param {string} escrowAddress Address of the escrow to withdraw.
|
|
497
497
|
* @param {string} tokenAddress Address of the token to withdraw.
|
|
498
498
|
* @param {Overrides} [txOptions] - Additional transaction parameters (optional, defaults to an empty object).
|
|
499
|
-
* @returns {
|
|
499
|
+
* @returns {IEscrowWithdraw} Returns the escrow withdrawal data including transaction hash and withdrawal amount. Throws error if any.
|
|
500
500
|
*
|
|
501
501
|
*
|
|
502
502
|
* **Code example**
|
|
@@ -544,7 +544,7 @@ class EscrowClient extends base_1.BaseEthersClient {
|
|
|
544
544
|
});
|
|
545
545
|
const from = parsedLog?.args[0];
|
|
546
546
|
if (parsedLog?.name === 'Transfer' && from === escrowAddress) {
|
|
547
|
-
amountTransferred = parsedLog?.args[2];
|
|
547
|
+
amountTransferred = BigInt(parsedLog?.args[2]);
|
|
548
548
|
break;
|
|
549
549
|
}
|
|
550
550
|
}
|
|
@@ -552,12 +552,11 @@ class EscrowClient extends base_1.BaseEthersClient {
|
|
|
552
552
|
if (amountTransferred === undefined) {
|
|
553
553
|
throw error_1.ErrorTransferEventNotFoundInTransactionLogs;
|
|
554
554
|
}
|
|
555
|
-
|
|
555
|
+
return {
|
|
556
556
|
txHash: transactionReceipt?.hash || '',
|
|
557
557
|
tokenAddress,
|
|
558
558
|
withdrawnAmount: amountTransferred,
|
|
559
559
|
};
|
|
560
|
-
return escrowWithdrawData;
|
|
561
560
|
}
|
|
562
561
|
catch (e) {
|
|
563
562
|
return (0, utils_1.throwError)(e);
|
|
@@ -1329,23 +1328,29 @@ class EscrowUtils {
|
|
|
1329
1328
|
* interface IEscrow {
|
|
1330
1329
|
* id: string;
|
|
1331
1330
|
* address: string;
|
|
1332
|
-
* amountPaid:
|
|
1333
|
-
* balance:
|
|
1334
|
-
* count:
|
|
1335
|
-
* jobRequesterId: string;
|
|
1331
|
+
* amountPaid: bigint;
|
|
1332
|
+
* balance: bigint;
|
|
1333
|
+
* count: bigint;
|
|
1336
1334
|
* factoryAddress: string;
|
|
1337
|
-
* finalResultsUrl
|
|
1338
|
-
*
|
|
1335
|
+
* finalResultsUrl: string | null;
|
|
1336
|
+
* finalResultsHash: string | null;
|
|
1337
|
+
* intermediateResultsUrl: string | null;
|
|
1338
|
+
* intermediateResultsHash: string | null;
|
|
1339
1339
|
* launcher: string;
|
|
1340
|
-
*
|
|
1341
|
-
*
|
|
1342
|
-
*
|
|
1343
|
-
*
|
|
1344
|
-
*
|
|
1345
|
-
*
|
|
1340
|
+
* jobRequesterId: string | null;
|
|
1341
|
+
* manifestHash: string | null;
|
|
1342
|
+
* manifest: string | null;
|
|
1343
|
+
* recordingOracle: string | null;
|
|
1344
|
+
* reputationOracle: string | null;
|
|
1345
|
+
* exchangeOracle: string | null;
|
|
1346
|
+
* recordingOracleFee: number | null;
|
|
1347
|
+
* reputationOracleFee: number | null;
|
|
1348
|
+
* exchangeOracleFee: number | null;
|
|
1349
|
+
* status: string;
|
|
1346
1350
|
* token: string;
|
|
1347
|
-
* totalFundedAmount:
|
|
1348
|
-
* createdAt:
|
|
1351
|
+
* totalFundedAmount: bigint;
|
|
1352
|
+
* createdAt: number;
|
|
1353
|
+
* chainId: number;
|
|
1349
1354
|
* };
|
|
1350
1355
|
* ```
|
|
1351
1356
|
*
|
|
@@ -1405,11 +1410,7 @@ class EscrowUtils {
|
|
|
1405
1410
|
first: first,
|
|
1406
1411
|
skip: skip,
|
|
1407
1412
|
});
|
|
1408
|
-
escrows.map((
|
|
1409
|
-
if (!escrows) {
|
|
1410
|
-
return [];
|
|
1411
|
-
}
|
|
1412
|
-
return escrows;
|
|
1413
|
+
return (escrows || []).map((e) => mapEscrow(e, networkData.chainId));
|
|
1413
1414
|
}
|
|
1414
1415
|
/**
|
|
1415
1416
|
* This function returns the escrow data for a given address.
|
|
@@ -1435,23 +1436,29 @@ class EscrowUtils {
|
|
|
1435
1436
|
* interface IEscrow {
|
|
1436
1437
|
* id: string;
|
|
1437
1438
|
* address: string;
|
|
1438
|
-
* amountPaid:
|
|
1439
|
-
* balance:
|
|
1440
|
-
* count:
|
|
1441
|
-
* jobRequesterId: string;
|
|
1439
|
+
* amountPaid: bigint;
|
|
1440
|
+
* balance: bigint;
|
|
1441
|
+
* count: bigint;
|
|
1442
1442
|
* factoryAddress: string;
|
|
1443
|
-
* finalResultsUrl
|
|
1444
|
-
*
|
|
1443
|
+
* finalResultsUrl: string | null;
|
|
1444
|
+
* finalResultsHash: string | null;
|
|
1445
|
+
* intermediateResultsUrl: string | null;
|
|
1446
|
+
* intermediateResultsHash: string | null;
|
|
1445
1447
|
* launcher: string;
|
|
1446
|
-
*
|
|
1447
|
-
*
|
|
1448
|
-
*
|
|
1449
|
-
*
|
|
1450
|
-
*
|
|
1451
|
-
*
|
|
1448
|
+
* jobRequesterId: string | null;
|
|
1449
|
+
* manifestHash: string | null;
|
|
1450
|
+
* manifest: string | null;
|
|
1451
|
+
* recordingOracle: string | null;
|
|
1452
|
+
* reputationOracle: string | null;
|
|
1453
|
+
* exchangeOracle: string | null;
|
|
1454
|
+
* recordingOracleFee: number | null;
|
|
1455
|
+
* reputationOracleFee: number | null;
|
|
1456
|
+
* exchangeOracleFee: number | null;
|
|
1457
|
+
* status: string;
|
|
1452
1458
|
* token: string;
|
|
1453
|
-
* totalFundedAmount:
|
|
1454
|
-
* createdAt:
|
|
1459
|
+
* totalFundedAmount: bigint;
|
|
1460
|
+
* createdAt: number;
|
|
1461
|
+
* chainId: number;
|
|
1455
1462
|
* };
|
|
1456
1463
|
* ```
|
|
1457
1464
|
*
|
|
@@ -1477,7 +1484,9 @@ class EscrowUtils {
|
|
|
1477
1484
|
throw error_1.ErrorInvalidAddress;
|
|
1478
1485
|
}
|
|
1479
1486
|
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
|
-
|
|
1487
|
+
if (!escrow)
|
|
1488
|
+
return null;
|
|
1489
|
+
return mapEscrow(escrow, networkData.chainId);
|
|
1481
1490
|
}
|
|
1482
1491
|
/**
|
|
1483
1492
|
* This function returns the status events for a given set of networks within an optional date range.
|
|
@@ -1566,12 +1575,12 @@ class EscrowUtils {
|
|
|
1566
1575
|
if (!data || !data['escrowStatusEvents']) {
|
|
1567
1576
|
return [];
|
|
1568
1577
|
}
|
|
1569
|
-
|
|
1570
|
-
|
|
1571
|
-
|
|
1578
|
+
return data['escrowStatusEvents'].map((event) => ({
|
|
1579
|
+
timestamp: Number(event.timestamp) * 1000,
|
|
1580
|
+
escrowAddress: event.escrowAddress,
|
|
1581
|
+
status: types_1.EscrowStatus[event.status],
|
|
1572
1582
|
chainId,
|
|
1573
1583
|
}));
|
|
1574
|
-
return eventsWithChainId;
|
|
1575
1584
|
}
|
|
1576
1585
|
/**
|
|
1577
1586
|
* This function returns the payouts for a given set of networks.
|
|
@@ -1582,7 +1591,7 @@ class EscrowUtils {
|
|
|
1582
1591
|
* Fetch payouts from the subgraph.
|
|
1583
1592
|
*
|
|
1584
1593
|
* @param {IPayoutFilter} filter Filter parameters.
|
|
1585
|
-
* @returns {Promise<
|
|
1594
|
+
* @returns {Promise<IPayout[]>} List of payouts matching the filters.
|
|
1586
1595
|
*
|
|
1587
1596
|
* **Code example**
|
|
1588
1597
|
*
|
|
@@ -1622,7 +1631,16 @@ class EscrowUtils {
|
|
|
1622
1631
|
skip,
|
|
1623
1632
|
orderDirection,
|
|
1624
1633
|
});
|
|
1625
|
-
|
|
1634
|
+
if (!payouts) {
|
|
1635
|
+
return [];
|
|
1636
|
+
}
|
|
1637
|
+
return payouts.map((payout) => ({
|
|
1638
|
+
id: payout.id,
|
|
1639
|
+
escrowAddress: payout.escrowAddress,
|
|
1640
|
+
recipient: payout.recipient,
|
|
1641
|
+
amount: BigInt(payout.amount),
|
|
1642
|
+
createdAt: Number(payout.createdAt) * 1000,
|
|
1643
|
+
}));
|
|
1626
1644
|
}
|
|
1627
1645
|
/**
|
|
1628
1646
|
* This function returns the cancellation refunds for a given set of networks.
|
|
@@ -1645,7 +1663,7 @@ class EscrowUtils {
|
|
|
1645
1663
|
* ```
|
|
1646
1664
|
*
|
|
1647
1665
|
* ```ts
|
|
1648
|
-
*
|
|
1666
|
+
* interface ICancellationRefund {
|
|
1649
1667
|
* id: string;
|
|
1650
1668
|
* escrowAddress: string;
|
|
1651
1669
|
* receiver: string;
|
|
@@ -1658,7 +1676,7 @@ class EscrowUtils {
|
|
|
1658
1676
|
*
|
|
1659
1677
|
*
|
|
1660
1678
|
* @param {Object} filter Filter parameters.
|
|
1661
|
-
* @returns {Promise<
|
|
1679
|
+
* @returns {Promise<ICancellationRefund[]>} List of cancellation refunds matching the filters.
|
|
1662
1680
|
*
|
|
1663
1681
|
* **Code example**
|
|
1664
1682
|
*
|
|
@@ -1694,7 +1712,18 @@ class EscrowUtils {
|
|
|
1694
1712
|
skip,
|
|
1695
1713
|
orderDirection,
|
|
1696
1714
|
});
|
|
1697
|
-
|
|
1715
|
+
if (!cancellationRefundEvents || cancellationRefundEvents.length === 0) {
|
|
1716
|
+
return [];
|
|
1717
|
+
}
|
|
1718
|
+
return cancellationRefundEvents.map((event) => ({
|
|
1719
|
+
id: event.id,
|
|
1720
|
+
escrowAddress: event.escrowAddress,
|
|
1721
|
+
receiver: event.receiver,
|
|
1722
|
+
amount: BigInt(event.amount),
|
|
1723
|
+
block: Number(event.block),
|
|
1724
|
+
timestamp: Number(event.timestamp) * 1000,
|
|
1725
|
+
txHash: event.txHash,
|
|
1726
|
+
}));
|
|
1698
1727
|
}
|
|
1699
1728
|
/**
|
|
1700
1729
|
* This function returns the cancellation refund for a given escrow address.
|
|
@@ -1717,7 +1746,7 @@ class EscrowUtils {
|
|
|
1717
1746
|
* ```
|
|
1718
1747
|
*
|
|
1719
1748
|
* ```ts
|
|
1720
|
-
*
|
|
1749
|
+
* interface ICancellationRefund {
|
|
1721
1750
|
* id: string;
|
|
1722
1751
|
* escrowAddress: string;
|
|
1723
1752
|
* receiver: string;
|
|
@@ -1731,7 +1760,7 @@ class EscrowUtils {
|
|
|
1731
1760
|
*
|
|
1732
1761
|
* @param {ChainId} chainId Network in which the escrow has been deployed
|
|
1733
1762
|
* @param {string} escrowAddress Address of the escrow
|
|
1734
|
-
* @returns {Promise<
|
|
1763
|
+
* @returns {Promise<ICancellationRefund>} Cancellation refund data
|
|
1735
1764
|
*
|
|
1736
1765
|
* **Code example**
|
|
1737
1766
|
*
|
|
@@ -1749,7 +1778,51 @@ class EscrowUtils {
|
|
|
1749
1778
|
throw error_1.ErrorInvalidEscrowAddressProvided;
|
|
1750
1779
|
}
|
|
1751
1780
|
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
|
-
|
|
1781
|
+
if (!cancellationRefundEvents || cancellationRefundEvents.length === 0) {
|
|
1782
|
+
return null;
|
|
1783
|
+
}
|
|
1784
|
+
return {
|
|
1785
|
+
id: cancellationRefundEvents[0].id,
|
|
1786
|
+
escrowAddress: cancellationRefundEvents[0].escrowAddress,
|
|
1787
|
+
receiver: cancellationRefundEvents[0].receiver,
|
|
1788
|
+
amount: BigInt(cancellationRefundEvents[0].amount),
|
|
1789
|
+
block: Number(cancellationRefundEvents[0].block),
|
|
1790
|
+
timestamp: Number(cancellationRefundEvents[0].timestamp) * 1000,
|
|
1791
|
+
txHash: cancellationRefundEvents[0].txHash,
|
|
1792
|
+
};
|
|
1753
1793
|
}
|
|
1754
1794
|
}
|
|
1755
1795
|
exports.EscrowUtils = EscrowUtils;
|
|
1796
|
+
function mapEscrow(e, chainId) {
|
|
1797
|
+
return {
|
|
1798
|
+
id: e.id,
|
|
1799
|
+
address: e.address,
|
|
1800
|
+
amountPaid: BigInt(e.amountPaid),
|
|
1801
|
+
balance: BigInt(e.balance),
|
|
1802
|
+
count: Number(e.count),
|
|
1803
|
+
factoryAddress: e.factoryAddress,
|
|
1804
|
+
finalResultsUrl: e.finalResultsUrl,
|
|
1805
|
+
finalResultsHash: e.finalResultsHash,
|
|
1806
|
+
intermediateResultsUrl: e.intermediateResultsUrl,
|
|
1807
|
+
intermediateResultsHash: e.intermediateResultsHash,
|
|
1808
|
+
launcher: e.launcher,
|
|
1809
|
+
jobRequesterId: e.jobRequesterId,
|
|
1810
|
+
manifestHash: e.manifestHash,
|
|
1811
|
+
manifest: e.manifest,
|
|
1812
|
+
recordingOracle: e.recordingOracle,
|
|
1813
|
+
reputationOracle: e.reputationOracle,
|
|
1814
|
+
exchangeOracle: e.exchangeOracle,
|
|
1815
|
+
recordingOracleFee: e.recordingOracleFee
|
|
1816
|
+
? Number(e.recordingOracleFee)
|
|
1817
|
+
: null,
|
|
1818
|
+
reputationOracleFee: e.reputationOracleFee
|
|
1819
|
+
? Number(e.reputationOracleFee)
|
|
1820
|
+
: null,
|
|
1821
|
+
exchangeOracleFee: e.exchangeOracleFee ? Number(e.exchangeOracleFee) : null,
|
|
1822
|
+
status: e.status,
|
|
1823
|
+
token: e.token,
|
|
1824
|
+
totalFundedAmount: BigInt(e.totalFundedAmount),
|
|
1825
|
+
createdAt: Number(e.createdAt) * 1000,
|
|
1826
|
+
chainId: Number(chainId),
|
|
1827
|
+
};
|
|
1828
|
+
}
|