@human-protocol/sdk 1.1.12 → 1.1.14
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/constants.d.ts.map +1 -1
- package/dist/constants.js +14 -14
- package/dist/error.d.ts +4 -0
- package/dist/error.d.ts.map +1 -1
- package/dist/error.js +6 -2
- package/dist/escrow.d.ts +3 -3
- package/dist/escrow.d.ts.map +1 -1
- package/dist/escrow.js +24 -3
- package/dist/graphql/queries/payout.d.ts.map +1 -1
- package/dist/graphql/queries/payout.js +7 -1
- package/dist/graphql/types.d.ts +1 -2
- package/dist/graphql/types.d.ts.map +1 -1
- package/dist/statistics.d.ts +2 -19
- package/dist/statistics.d.ts.map +1 -1
- package/dist/statistics.js +9 -95
- package/dist/types.d.ts +14 -0
- package/dist/types.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/constants.ts +16 -14
- package/src/error.ts +7 -0
- package/src/escrow.ts +37 -5
- package/src/graphql/queries/payout.ts +7 -1
- package/src/graphql/types.ts +1 -2
- package/src/statistics.ts +12 -138
- package/src/types.ts +16 -0
package/dist/constants.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAClC,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAEtC;;GAEG;AACH,eAAO,MAAM,qBAAqB,0BAA0B,CAAC;AAE7D;;GAEG;AACH,eAAO,MAAM,gBAAgB,cAAc,CAAC;AAE5C;;GAEG;AACH,eAAO,MAAM,cAAc,OAAO,CAAC;AAEnC;;GAEG;AACH,eAAO,MAAM,YAAY,OAAO,CAAC;AAEjC;;GAEG;AACH,eAAO,MAAM,eAAe,QAAQ,CAAC;AAErC;;GAEG;AACH,eAAO,MAAM,aAAa,IAAI,CAAC;AAE/B;;GAEG;AACH,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;;GAEG;AACH,eAAO,MAAM,QAAQ,EAAE;KACpB,OAAO,IAAI,OAAO,CAAC,CAAC,EAAE,WAAW;
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAClC,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAEtC;;GAEG;AACH,eAAO,MAAM,qBAAqB,0BAA0B,CAAC;AAE7D;;GAEG;AACH,eAAO,MAAM,gBAAgB,cAAc,CAAC;AAE5C;;GAEG;AACH,eAAO,MAAM,cAAc,OAAO,CAAC;AAEnC;;GAEG;AACH,eAAO,MAAM,YAAY,OAAO,CAAC;AAEjC;;GAEG;AACH,eAAO,MAAM,eAAe,QAAQ,CAAC;AAErC;;GAEG;AACH,eAAO,MAAM,aAAa,IAAI,CAAC;AAE/B;;GAEG;AACH,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;;GAEG;AACH,eAAO,MAAM,QAAQ,EAAE;KACpB,OAAO,IAAI,OAAO,CAAC,CAAC,EAAE,WAAW;CA4LnC,CAAC;AAEF,eAAO,MAAM,WAAW;;;;;CAKvB,CAAC"}
|
package/dist/constants.js
CHANGED
|
@@ -165,27 +165,27 @@ exports.NETWORKS = {
|
|
|
165
165
|
chainId: enums_1.ChainId.AVALANCHE_TESTNET,
|
|
166
166
|
title: 'Fuji C-Chain',
|
|
167
167
|
scanUrl: 'https://testnet.snowtrace.io',
|
|
168
|
-
factoryAddress: '
|
|
168
|
+
factoryAddress: '0x56C2ba540726ED4f46E7a134b6b9Ee9C867FcF92',
|
|
169
169
|
hmtAddress: '0x9406d5c635AD22b0d76c75E52De57A2177919ca3',
|
|
170
|
-
stakingAddress: '',
|
|
171
|
-
rewardPoolAddress: '',
|
|
172
|
-
kvstoreAddress: '
|
|
173
|
-
subgraphUrl: 'https://api.thegraph.com/subgraphs/name/humanprotocol/fuji',
|
|
174
|
-
oldSubgraphUrl: '',
|
|
175
|
-
oldFactoryAddress: '',
|
|
170
|
+
stakingAddress: '0x9890473B0b93E24d6D1a8Dfb739D577C6f25FFd3',
|
|
171
|
+
rewardPoolAddress: '0x5517fE916Fe9F8dB15B0DDc76ebDf0BdDCd4ed18',
|
|
172
|
+
kvstoreAddress: '0x707fb5A5d36BC15275Af3f73262bf9a1D8C470EB',
|
|
173
|
+
subgraphUrl: 'https://api.thegraph.com/subgraphs/name/humanprotocol/fuji-v2',
|
|
174
|
+
oldSubgraphUrl: 'https://api.thegraph.com/subgraphs/name/humanprotocol/fuji',
|
|
175
|
+
oldFactoryAddress: '0xfb4469201951C3B9a7F1996c477cb7BDBEcE0A88',
|
|
176
176
|
},
|
|
177
177
|
[enums_1.ChainId.AVALANCHE]: {
|
|
178
178
|
chainId: enums_1.ChainId.AVALANCHE,
|
|
179
179
|
title: 'Avalanche C-Chain Mainnet',
|
|
180
180
|
scanUrl: 'https://snowtrace.io',
|
|
181
|
-
factoryAddress: '
|
|
181
|
+
factoryAddress: '0xD9c75a1Aa4237BB72a41E5E26bd8384f10c1f55a',
|
|
182
182
|
hmtAddress: '0x12365293cb6477d4fc2686e46BB97E3Fb64f1550',
|
|
183
|
-
stakingAddress: '',
|
|
184
|
-
rewardPoolAddress: '',
|
|
185
|
-
kvstoreAddress: '
|
|
186
|
-
subgraphUrl: 'https://api.thegraph.com/subgraphs/name/humanprotocol/avalanche',
|
|
187
|
-
oldSubgraphUrl: '',
|
|
188
|
-
oldFactoryAddress: '',
|
|
183
|
+
stakingAddress: '0x05398211bA2046E296fBc9a9D3EB49e3F15C3123',
|
|
184
|
+
rewardPoolAddress: '0x4A5963Dd6792692e9147EdC7659936b96251917a',
|
|
185
|
+
kvstoreAddress: '0x70671167176C4934204B1C7e97F5e86695857ef2',
|
|
186
|
+
subgraphUrl: 'https://api.thegraph.com/subgraphs/name/humanprotocol/avalanche-v2',
|
|
187
|
+
oldSubgraphUrl: 'https://api.thegraph.com/subgraphs/name/humanprotocol/avalanche',
|
|
188
|
+
oldFactoryAddress: '0x9767a578ba7a5FA1563c8229943cB01cd8446BB4',
|
|
189
189
|
},
|
|
190
190
|
[enums_1.ChainId.SKALE]: {
|
|
191
191
|
chainId: enums_1.ChainId.SKALE,
|
package/dist/error.d.ts
CHANGED
|
@@ -107,6 +107,10 @@ export declare const ErrorSigner: Error;
|
|
|
107
107
|
* @constant {Error} - Escrow address is not provided by the factory.
|
|
108
108
|
*/
|
|
109
109
|
export declare const ErrorEscrowAddressIsNotProvidedByFactory: Error;
|
|
110
|
+
/**
|
|
111
|
+
* @constant {Error} - Transfer event not found in transaction logs.
|
|
112
|
+
*/
|
|
113
|
+
export declare const ErrorTransferEventNotFoundInTransactionLogs: Error;
|
|
110
114
|
/**
|
|
111
115
|
* @constant {Error} - Manifest file does not exist.
|
|
112
116
|
*/
|
package/dist/error.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"error.d.ts","sourceRoot":"","sources":["../src/error.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,eAAO,MAAM,mBAAmB,OAA2C,CAAC;AAE5E;;GAEG;AACH,eAAO,MAAM,gCAAgC,OAE5C,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,2BAA2B,OAEvC,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,8BAA8B,OAE1C,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,0BAA0B,OAAgC,CAAC;AAExE;;GAEG;AACH,eAAO,MAAM,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,CAAC;AAE3E,qBAAa,aAAc,SAAQ,KAAK;gBAC1B,OAAO,EAAE,MAAM;CAG5B;AAED,qBAAa,oBAAqB,SAAQ,aAAa;gBACzC,OAAO,EAAE,MAAM;CAG5B;AAED,qBAAa,aAAc,SAAQ,aAAa;gBAClC,OAAO,EAAE,MAAM;CAG5B;AAED,qBAAa,qBAAsB,SAAQ,aAAa;gBAC1C,OAAO,EAAE,MAAM;CAG5B;AAED,qBAAa,sBAAuB,SAAQ,aAAa;gBAC3C,OAAO,EAAE,MAAM;CAG5B;AAED,qBAAa,YAAa,SAAQ,aAAa;gBACjC,OAAO,EAAE,MAAM;CAG5B;AAED,qBAAa,YAAa,SAAQ,aAAa;gBACjC,OAAO,EAAE,MAAM;CAG5B;AAED,qBAAa,mBAAoB,SAAQ,aAAa;gBACxC,OAAO,EAAE,MAAM;CAG5B;AAED,qBAAa,sBAAuB,SAAQ,aAAa;gBAC3C,MAAM,EAAE,MAAM;CAG3B;AAED,qBAAa,2BAA4B,SAAQ,KAAK;gBACxC,OAAO,EAAE,MAAM;CAG5B"}
|
package/dist/error.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
exports.InvalidEthereumAddressError = exports.ContractExecutionError = exports.TransactionReplaced = void 0;
|
|
3
|
+
exports.NumericFault = exports.ReplacementUnderpriced = exports.UnpredictableGasLimit = exports.OutOfGasError = exports.InvalidArgumentError = exports.EthereumError = exports.ErrorHashIsEmptyString = exports.ErrorLaunchedEventIsNotEmitted = exports.ErrorRecipientAndAmountsMustBeSameLength = exports.ErrorAmountsCannotBeEmptyArray = exports.ErrorEscrowDoesNotHaveEnoughBalance = exports.ErrorAmountMustBeGreaterThanZero = exports.ErrorRecipientCannotBeEmptyArray = exports.ErrorTotalFeeMustBeLessThanHundred = exports.ErrorFeeMustBeBetweenZeroAndHundred = exports.ErrorNoURLprovided = exports.ErrorListOfHandlersCannotBeEmpty = exports.ErrorUrlIsEmptyString = exports.ErrorInvalidUrl = exports.ErrorStorageClientDoesNotExist = exports.ErrorManifestFileDoesNotExist = exports.ErrorTransferEventNotFoundInTransactionLogs = exports.ErrorEscrowAddressIsNotProvidedByFactory = exports.ErrorSigner = exports.ErrorUnsupportedChainID = exports.ErrorProviderDoesNotExist = exports.ErrorHMTokenAmountNotApproved = exports.ErrorFailedToCheckAllowance = exports.ErrorFailedToApproveStakingAmountSignerDoesNotExist = exports.ErrorStakingGetStakers = exports.ErrorInvalidEscrowAddressProvided = exports.ErrorInvalidStakerAddressProvided = exports.ErrorInvalidSlasherAddressProvided = exports.ErrorInvalidStakingValueSign = exports.ErrorInvalidStakingValueType = exports.ErrorStakingValueMustBePositive = exports.ErrorInvalidExchangeOracleAddressProvided = exports.ErrorInvalidReputationOracleAddressProvided = exports.ErrorInvalidRecordingOracleAddressProvided = exports.ErrorInvalidTokenAddress = exports.ErrorInvalidAddress = exports.ErrorKVStoreArrayLength = exports.ErrorKVStoreEmptyKey = exports.ErrorStorageFileNotUploaded = exports.ErrorStorageFileNotFound = exports.ErrorStorageBucketNotFound = exports.ErrorStorageCredentialsMissing = exports.ErrorStorageClientNotExists = exports.ErrorStorageClientNotInitialized = exports.ErrorStakingMissing = void 0;
|
|
4
|
+
exports.InvalidEthereumAddressError = exports.ContractExecutionError = exports.TransactionReplaced = exports.NonceExpired = void 0;
|
|
5
5
|
/**
|
|
6
6
|
* @constant {Error} - The Staking contract is missing.
|
|
7
7
|
*/
|
|
@@ -111,6 +111,10 @@ exports.ErrorSigner = new Error('Signer required');
|
|
|
111
111
|
* @constant {Error} - Escrow address is not provided by the factory.
|
|
112
112
|
*/
|
|
113
113
|
exports.ErrorEscrowAddressIsNotProvidedByFactory = new Error('Escrow address is not provided by the factory');
|
|
114
|
+
/**
|
|
115
|
+
* @constant {Error} - Transfer event not found in transaction logs.
|
|
116
|
+
*/
|
|
117
|
+
exports.ErrorTransferEventNotFoundInTransactionLogs = new Error('Transfer event not found in transaction logs');
|
|
114
118
|
/**
|
|
115
119
|
* @constant {Error} - Manifest file does not exist.
|
|
116
120
|
*/
|
package/dist/escrow.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { Provider } from '@ethersproject/abstract-provider';
|
|
|
2
2
|
import { BigNumber, Signer } from 'ethers';
|
|
3
3
|
import { ChainId } from './enums';
|
|
4
4
|
import { IEscrowConfig, IEscrowsFilter } from './interfaces';
|
|
5
|
-
import { EscrowStatus, NetworkData } from './types';
|
|
5
|
+
import { EscrowCancel, EscrowStatus, NetworkData } from './types';
|
|
6
6
|
import { EscrowData } from './graphql';
|
|
7
7
|
export declare class EscrowClient {
|
|
8
8
|
private escrowFactoryContract;
|
|
@@ -98,10 +98,10 @@ export declare class EscrowClient {
|
|
|
98
98
|
* Cancels the specified escrow and sends the balance to the canceler.
|
|
99
99
|
*
|
|
100
100
|
* @param {string} escrowAddress - Address of the escrow.
|
|
101
|
-
* @returns {Promise<
|
|
101
|
+
* @returns {Promise<EscrowCancel>}
|
|
102
102
|
* @throws {Error} - An error object if an error occurred.
|
|
103
103
|
*/
|
|
104
|
-
cancel(escrowAddress: string): Promise<
|
|
104
|
+
cancel(escrowAddress: string): Promise<EscrowCancel>;
|
|
105
105
|
/**
|
|
106
106
|
* Cancels the specified escrow, sends the balance to the canceler and selfdestructs the escrow contract.
|
|
107
107
|
*
|
package/dist/escrow.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"escrow.d.ts","sourceRoot":"","sources":["../src/escrow.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,kCAAkC,CAAC;AAU5D,OAAO,EAAE,SAAS,EAAmB,MAAM,EAAU,MAAM,QAAQ,CAAC;AAIpE,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"escrow.d.ts","sourceRoot":"","sources":["../src/escrow.ts"],"names":[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C,aAAa,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,CAAC;IAoB7D;;;;;;OAMG;IACG,yBAAyB,CAAC,aAAa,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAoBvE;;;;;;OAMG;IACG,qBAAqB,CAAC,aAAa,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAoBnE;;;;;;OAMG;IACG,0BAA0B,CAAC,aAAa,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAoBxE;;;;;;OAMG;IACG,wBAAwB,CAAC,aAAa,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAoBtE;;;;;;OAMG;IACG,iBAAiB,CAAC,aAAa,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;CAmBhE;AAED,qBAAa,WAAW;IACtB;;;;;;OAMG;WACiB,UAAU,CAC5B,MAAM,EAAE,cAAc,GACrB,OAAO,CAAC,UAAU,EAAE,CAAC;IA8DxB;;;;;;;OAOG;WACiB,SAAS,CAC3B,OAAO,EAAE,OAAO,EAChB,aAAa,EAAE,MAAM,GACpB,OAAO,CAAC,UAAU,CAAC;CAuBvB"}
|
package/dist/escrow.js
CHANGED
|
@@ -309,7 +309,7 @@ class EscrowClient {
|
|
|
309
309
|
* Cancels the specified escrow and sends the balance to the canceler.
|
|
310
310
|
*
|
|
311
311
|
* @param {string} escrowAddress - Address of the escrow.
|
|
312
|
-
* @returns {Promise<
|
|
312
|
+
* @returns {Promise<EscrowCancel>}
|
|
313
313
|
* @throws {Error} - An error object if an error occurred.
|
|
314
314
|
*/
|
|
315
315
|
async cancel(escrowAddress) {
|
|
@@ -321,8 +321,29 @@ class EscrowClient {
|
|
|
321
321
|
}
|
|
322
322
|
try {
|
|
323
323
|
this.escrowContract = typechain_types_1.Escrow__factory.connect(escrowAddress, this.signerOrProvider);
|
|
324
|
-
await this.escrowContract.cancel();
|
|
325
|
-
|
|
324
|
+
const tx = await this.escrowContract.cancel();
|
|
325
|
+
const transactionReceipt = await tx.wait();
|
|
326
|
+
let amountTransferred = undefined;
|
|
327
|
+
const tokenAddress = await this.escrowContract.token();
|
|
328
|
+
const tokenContract = typechain_types_1.HMToken__factory.connect(tokenAddress, this.signerOrProvider);
|
|
329
|
+
for (const log of transactionReceipt.logs) {
|
|
330
|
+
if (log.address === tokenAddress) {
|
|
331
|
+
const parsedLog = tokenContract.interface.parseLog(log);
|
|
332
|
+
const from = parsedLog.args[0];
|
|
333
|
+
if (parsedLog.name === 'Transfer' && from === escrowAddress) {
|
|
334
|
+
amountTransferred = parsedLog.args[2];
|
|
335
|
+
break;
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
if (amountTransferred === undefined) {
|
|
340
|
+
throw error_1.ErrorTransferEventNotFoundInTransactionLogs;
|
|
341
|
+
}
|
|
342
|
+
const escrowCancelData = {
|
|
343
|
+
txHash: transactionReceipt.transactionHash,
|
|
344
|
+
amountRefunded: amountTransferred,
|
|
345
|
+
};
|
|
346
|
+
return escrowCancelData;
|
|
326
347
|
}
|
|
327
348
|
catch (e) {
|
|
328
349
|
return (0, utils_1.throwError)(e);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"payout.d.ts","sourceRoot":"","sources":["../../../src/graphql/queries/payout.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAYjD,eAAO,MAAM,iBAAiB,WAAY,aAAa,
|
|
1
|
+
{"version":3,"file":"payout.d.ts","sourceRoot":"","sources":["../../../src/graphql/queries/payout.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAYjD,eAAO,MAAM,iBAAiB,WAAY,aAAa,mCAiCtD,CAAC"}
|
|
@@ -21,8 +21,11 @@ const GET_PAYOUTS_QUERY = (filter) => {
|
|
|
21
21
|
${escrowAddress ? `escrowAddress: $escrowAddress` : ''}
|
|
22
22
|
${recipient ? `recipient: $recipient` : ''}
|
|
23
23
|
${from ? `createdAt_gte: $from` : ''}
|
|
24
|
-
${to ? `
|
|
24
|
+
${to ? `createdAt_lt: $to` : ''}
|
|
25
25
|
}
|
|
26
|
+
`;
|
|
27
|
+
const LIMIT_CLAUSE = `
|
|
28
|
+
first: 1000
|
|
26
29
|
`;
|
|
27
30
|
return (0, graphql_tag_1.default) `
|
|
28
31
|
query getPayouts(
|
|
@@ -33,6 +36,9 @@ const GET_PAYOUTS_QUERY = (filter) => {
|
|
|
33
36
|
) {
|
|
34
37
|
payouts(
|
|
35
38
|
${WHERE_CLAUSE}
|
|
39
|
+
orderBy: createdAt,
|
|
40
|
+
orderDirection: desc,
|
|
41
|
+
${LIMIT_CLAUSE}
|
|
36
42
|
) {
|
|
37
43
|
...PayoutFields
|
|
38
44
|
}
|
package/dist/graphql/types.d.ts
CHANGED
|
@@ -91,7 +91,6 @@ export type EscrowStatistics = {
|
|
|
91
91
|
export type DailyWorkerData = {
|
|
92
92
|
timestamp: Date;
|
|
93
93
|
activeWorkers: number;
|
|
94
|
-
averageJobsSolved: number;
|
|
95
94
|
};
|
|
96
95
|
export type WorkerStatistics = {
|
|
97
96
|
dailyWorkersData: DailyWorkerData[];
|
|
@@ -100,7 +99,6 @@ export type DailyPaymentData = {
|
|
|
100
99
|
timestamp: Date;
|
|
101
100
|
totalAmountPaid: BigNumber;
|
|
102
101
|
totalCount: number;
|
|
103
|
-
averageAmountPerJob: BigNumber;
|
|
104
102
|
averageAmountPerWorker: BigNumber;
|
|
105
103
|
};
|
|
106
104
|
export type PaymentStatistics = {
|
|
@@ -121,6 +119,7 @@ export type DailyHMTData = {
|
|
|
121
119
|
};
|
|
122
120
|
export type HMTStatistics = {
|
|
123
121
|
totalTransferAmount: BigNumber;
|
|
122
|
+
totalTransferCount: number;
|
|
124
123
|
totalHolders: number;
|
|
125
124
|
holders: HMTHolder[];
|
|
126
125
|
dailyHMTData: DailyHMTData[];
|
|
@@ -1 +1 @@
|
|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AAG;IAC9B,iBAAiB,EAAE,gBAAgB,EAAE,CAAC;CACvC,CAAC;AAEF,MAAM,MAAM,aAAa,GAAG;IAC1B,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,MAAM,MAAM,SAAS,GAAG;IACtB,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,SAAS,CAAC;CACpB,CAAC;AAEF,MAAM,MAAM,YAAY,GAAG;IACzB,SAAS,EAAE,IAAI,CAAC;IAChB,sBAAsB,EAAE,SAAS,CAAC;IAClC,qBAAqB,EAAE,MAAM,CAAC;CAC/B,CAAC;AAEF,MAAM,MAAM,aAAa,GAAG;IAC1B,mBAAmB,EAAE,SAAS,CAAC;IAC/B,kBAAkB,EAAE,MAAM,CAAC;IAC3B,YAAY,EAAE,MAAM,CAAC;IACrB,OAAO,EAAE,SAAS,EAAE,CAAC;IACrB,YAAY,EAAE,YAAY,EAAE,CAAC;CAC9B,CAAC;AAEF,MAAM,MAAM,YAAY,GAAG;IACzB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,MAAM,MAAM,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC;AAElD,MAAM,MAAM,aAAa,GAAG;IAC1B,SAAS,EAAE,IAAI,CAAC;IAChB,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,MAAM,CAAC;CACrB,CAAC;AAEF,MAAM,MAAM,cAAc,GAAG;IAC3B,cAAc,EAAE,aAAa,EAAE,CAAC;CACjC,CAAC"}
|
package/dist/statistics.d.ts
CHANGED
|
@@ -1,30 +1,14 @@
|
|
|
1
|
-
import { EscrowStatistics, HMTStatistics, PaymentStatistics, WorkerStatistics
|
|
1
|
+
import { EscrowStatistics, HMTStatistics, PaymentStatistics, WorkerStatistics } from './graphql';
|
|
2
2
|
import { IStatisticsParams } from './interfaces';
|
|
3
3
|
import { NetworkData } from './types';
|
|
4
4
|
export declare class StatisticsClient {
|
|
5
5
|
network: NetworkData;
|
|
6
|
-
private IMAPIKey;
|
|
7
6
|
/**
|
|
8
7
|
* **StatisticsClient constructor**
|
|
9
8
|
*
|
|
10
9
|
* @param {NetworkData} network - The network information required to connect to the Statistics contract
|
|
11
10
|
*/
|
|
12
|
-
constructor(network: NetworkData
|
|
13
|
-
/**
|
|
14
|
-
* Gets the IM data for the given date range
|
|
15
|
-
* IM API now limits the date range to 60 days, so we need to make multiple requests
|
|
16
|
-
* if the date range is greater than 60 days
|
|
17
|
-
*
|
|
18
|
-
* If the filter is empty, returns the last 60 days of data
|
|
19
|
-
*
|
|
20
|
-
* If the network is not Polygon, returns an empty object
|
|
21
|
-
* TODO: Remove this once the IM API is available on all networks
|
|
22
|
-
*
|
|
23
|
-
* @param {IStatisticsParams} params - Filter parameters.
|
|
24
|
-
* @returns {Promise<IMData>}
|
|
25
|
-
* @throws {Error} - An error object if an error occurred.
|
|
26
|
-
*/
|
|
27
|
-
private getIMData;
|
|
11
|
+
constructor(network: NetworkData);
|
|
28
12
|
/**
|
|
29
13
|
* Returns the escrow statistics data for the given date range
|
|
30
14
|
*
|
|
@@ -33,7 +17,6 @@ export declare class StatisticsClient {
|
|
|
33
17
|
* @throws {Error} - An error object if an error occurred.
|
|
34
18
|
*/
|
|
35
19
|
getEscrowStatistics(params?: IStatisticsParams): Promise<EscrowStatistics>;
|
|
36
|
-
getTaskStatistics(params?: IStatisticsParams): Promise<TaskStatistics>;
|
|
37
20
|
/**
|
|
38
21
|
* Returns the worker statistics data for the given date range
|
|
39
22
|
*
|
package/dist/statistics.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"statistics.d.ts","sourceRoot":"","sources":["../src/statistics.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"statistics.d.ts","sourceRoot":"","sources":["../src/statistics.ts"],"names":[],"mappings":"AAIA,OAAO,EAKL,gBAAgB,EAGhB,aAAa,EAEb,iBAAiB,EACjB,gBAAgB,EAEjB,MAAM,WAAW,CAAC;AACnB,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AACjD,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAGtC,qBAAa,gBAAgB;IACpB,OAAO,EAAE,WAAW,CAAC;IAE5B;;;;OAIG;gBACS,OAAO,EAAE,WAAW;IAIhC;;;;;;OAMG;IACG,mBAAmB,CACvB,MAAM,GAAE,iBAAsB,GAC7B,OAAO,CAAC,gBAAgB,CAAC;IA6B5B;;;;;;OAMG;IACG,mBAAmB,CACvB,MAAM,GAAE,iBAAsB,GAC7B,OAAO,CAAC,gBAAgB,CAAC;IAoB5B;;;;;;OAMG;IACG,oBAAoB,CACxB,MAAM,GAAE,iBAAsB,GAC7B,OAAO,CAAC,iBAAiB,CAAC;IA2B7B;;;;;;OAMG;IACG,gBAAgB,CACpB,MAAM,GAAE,iBAAsB,GAC7B,OAAO,CAAC,aAAa,CAAC;CAuC1B"}
|
package/dist/statistics.js
CHANGED
|
@@ -5,10 +5,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.StatisticsClient = void 0;
|
|
7
7
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
8
|
-
const axios_1 = __importDefault(require("axios"));
|
|
9
8
|
const ethers_1 = require("ethers");
|
|
10
9
|
const graphql_request_1 = __importDefault(require("graphql-request"));
|
|
11
|
-
const enums_1 = require("./enums");
|
|
12
10
|
const graphql_1 = require("./graphql");
|
|
13
11
|
const utils_1 = require("./utils");
|
|
14
12
|
class StatisticsClient {
|
|
@@ -17,61 +15,8 @@ class StatisticsClient {
|
|
|
17
15
|
*
|
|
18
16
|
* @param {NetworkData} network - The network information required to connect to the Statistics contract
|
|
19
17
|
*/
|
|
20
|
-
constructor(network
|
|
18
|
+
constructor(network) {
|
|
21
19
|
this.network = network;
|
|
22
|
-
this.IMAPIKey = IMAPIKey;
|
|
23
|
-
}
|
|
24
|
-
/**
|
|
25
|
-
* Gets the IM data for the given date range
|
|
26
|
-
* IM API now limits the date range to 60 days, so we need to make multiple requests
|
|
27
|
-
* if the date range is greater than 60 days
|
|
28
|
-
*
|
|
29
|
-
* If the filter is empty, returns the last 60 days of data
|
|
30
|
-
*
|
|
31
|
-
* If the network is not Polygon, returns an empty object
|
|
32
|
-
* TODO: Remove this once the IM API is available on all networks
|
|
33
|
-
*
|
|
34
|
-
* @param {IStatisticsParams} params - Filter parameters.
|
|
35
|
-
* @returns {Promise<IMData>}
|
|
36
|
-
* @throws {Error} - An error object if an error occurred.
|
|
37
|
-
*/
|
|
38
|
-
async getIMData(params = {}) {
|
|
39
|
-
if (this.network.chainId !== enums_1.ChainId.POLYGON) {
|
|
40
|
-
return {};
|
|
41
|
-
}
|
|
42
|
-
const now = new Date();
|
|
43
|
-
const today = new Date(now.getFullYear(), now.getMonth(), now.getDate());
|
|
44
|
-
const defaultFromDate = new Date(now.getFullYear(), now.getMonth(), now.getDate());
|
|
45
|
-
defaultFromDate.setDate(today.getDate() - 60);
|
|
46
|
-
const from = params.from ? new Date(params.from) : defaultFromDate;
|
|
47
|
-
const to = params.to ? new Date(params.to) : today;
|
|
48
|
-
// IM API now limits the date range to 60 days, so we need to make multiple requests
|
|
49
|
-
// if the date range is greater than 60 days
|
|
50
|
-
const chunks = [];
|
|
51
|
-
let start = from;
|
|
52
|
-
while (start < to) {
|
|
53
|
-
const end = new Date(start);
|
|
54
|
-
end.setDate(start.getDate() + 60);
|
|
55
|
-
chunks.push({ from: start, to: end.getDate() < to.getDate() ? end : to });
|
|
56
|
-
start = end;
|
|
57
|
-
}
|
|
58
|
-
return await Promise.all(chunks.map(({ from, to }) => axios_1.default
|
|
59
|
-
.get('/support/summary-stats', {
|
|
60
|
-
baseURL: 'https://foundation-accounts.hmt.ai',
|
|
61
|
-
method: 'GET',
|
|
62
|
-
params: {
|
|
63
|
-
start_date: from.toISOString().slice(0, 10),
|
|
64
|
-
end_date: to.toISOString().slice(0, 10),
|
|
65
|
-
api_key: this.IMAPIKey,
|
|
66
|
-
},
|
|
67
|
-
})
|
|
68
|
-
.then((res) => res.data))).then((chunks) => chunks.reduce(
|
|
69
|
-
// Exclude total from the aggregated data
|
|
70
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
71
|
-
(aggregated, { total, ...chunkData }) => ({
|
|
72
|
-
...aggregated,
|
|
73
|
-
...chunkData,
|
|
74
|
-
}), {}));
|
|
75
20
|
}
|
|
76
21
|
/**
|
|
77
22
|
* Returns the escrow statistics data for the given date range
|
|
@@ -103,21 +48,6 @@ class StatisticsClient {
|
|
|
103
48
|
return (0, utils_1.throwError)(e);
|
|
104
49
|
}
|
|
105
50
|
}
|
|
106
|
-
async getTaskStatistics(params = {}) {
|
|
107
|
-
try {
|
|
108
|
-
const data = await this.getIMData(params);
|
|
109
|
-
return {
|
|
110
|
-
dailyTasksData: Object.entries(data).map(([key, value]) => ({
|
|
111
|
-
timestamp: new Date(key),
|
|
112
|
-
tasksTotal: value.served,
|
|
113
|
-
tasksSolved: value.solved,
|
|
114
|
-
})),
|
|
115
|
-
};
|
|
116
|
-
}
|
|
117
|
-
catch (e) {
|
|
118
|
-
return (0, utils_1.throwError)(e);
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
51
|
/**
|
|
122
52
|
* Returns the worker statistics data for the given date range
|
|
123
53
|
*
|
|
@@ -127,28 +57,14 @@ class StatisticsClient {
|
|
|
127
57
|
*/
|
|
128
58
|
async getWorkerStatistics(params = {}) {
|
|
129
59
|
try {
|
|
130
|
-
const
|
|
60
|
+
const { eventDayDatas } = await (0, graphql_request_1.default)(this.network.subgraphUrl, (0, graphql_1.GET_EVENT_DAY_DATA_QUERY)(params), {
|
|
61
|
+
from: params.from ? params.from.getTime() / 1000 : undefined,
|
|
62
|
+
to: params.to ? params.to.getTime() / 1000 : undefined,
|
|
63
|
+
});
|
|
131
64
|
return {
|
|
132
|
-
dailyWorkersData:
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
const toDate = new Date(key);
|
|
136
|
-
toDate.setDate(toDate.getDate() + 1);
|
|
137
|
-
const { payouts } = await (0, graphql_request_1.default)(this.network.subgraphUrl, (0, graphql_1.GET_PAYOUTS_QUERY)({
|
|
138
|
-
from: fromDate,
|
|
139
|
-
to: toDate,
|
|
140
|
-
}), {
|
|
141
|
-
from: fromDate.getTime() / 1000,
|
|
142
|
-
to: toDate.getTime() / 1000,
|
|
143
|
-
});
|
|
144
|
-
const activeWorkers = new Set(payouts.map(({ recipient }) => recipient)).size;
|
|
145
|
-
return {
|
|
146
|
-
timestamp,
|
|
147
|
-
activeWorkers,
|
|
148
|
-
averageJobsSolved: activeWorkers
|
|
149
|
-
? value.solved / activeWorkers
|
|
150
|
-
: 0,
|
|
151
|
-
};
|
|
65
|
+
dailyWorkersData: eventDayDatas.map((eventDayData) => ({
|
|
66
|
+
timestamp: new Date(+eventDayData.timestamp * 1000),
|
|
67
|
+
activeWorkers: +eventDayData.dailyWorkerCount,
|
|
152
68
|
})),
|
|
153
69
|
};
|
|
154
70
|
}
|
|
@@ -174,9 +90,6 @@ class StatisticsClient {
|
|
|
174
90
|
timestamp: new Date(+eventDayData.timestamp * 1000),
|
|
175
91
|
totalAmountPaid: ethers_1.BigNumber.from(eventDayData.dailyPayoutAmount),
|
|
176
92
|
totalCount: +eventDayData.dailyPayoutCount,
|
|
177
|
-
averageAmountPerJob: eventDayData.dailyBulkPayoutEventCount === '0'
|
|
178
|
-
? ethers_1.BigNumber.from(0)
|
|
179
|
-
: ethers_1.BigNumber.from(eventDayData.dailyPayoutAmount).div(eventDayData.dailyBulkPayoutEventCount),
|
|
180
93
|
averageAmountPerWorker: eventDayData.dailyWorkerCount === '0'
|
|
181
94
|
? ethers_1.BigNumber.from(0)
|
|
182
95
|
: ethers_1.BigNumber.from(eventDayData.dailyPayoutAmount).div(eventDayData.dailyWorkerCount),
|
|
@@ -204,6 +117,7 @@ class StatisticsClient {
|
|
|
204
117
|
});
|
|
205
118
|
return {
|
|
206
119
|
totalTransferAmount: ethers_1.BigNumber.from(hmtokenStatistics.totalValueTransfered),
|
|
120
|
+
totalTransferCount: Number(hmtokenStatistics.totalTransferEventCount),
|
|
207
121
|
totalHolders: +hmtokenStatistics.holders,
|
|
208
122
|
holders: holders.map((holder) => ({
|
|
209
123
|
address: holder.address,
|
package/dist/types.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { BigNumber } from 'ethers';
|
|
1
2
|
/**
|
|
2
3
|
* Enum for escrow statuses.
|
|
3
4
|
* @readonly
|
|
@@ -132,4 +133,17 @@ export type NetworkData = {
|
|
|
132
133
|
*/
|
|
133
134
|
oldFactoryAddress: string;
|
|
134
135
|
};
|
|
136
|
+
/**
|
|
137
|
+
* Represents the response data for an escrow cancellation.
|
|
138
|
+
*/
|
|
139
|
+
export type EscrowCancel = {
|
|
140
|
+
/**
|
|
141
|
+
* The hash of the transaction associated with the escrow cancellation.
|
|
142
|
+
*/
|
|
143
|
+
txHash: string;
|
|
144
|
+
/**
|
|
145
|
+
* The amount refunded in the escrow cancellation.
|
|
146
|
+
*/
|
|
147
|
+
amountRefunded: BigNumber;
|
|
148
|
+
};
|
|
135
149
|
//# sourceMappingURL=types.d.ts.map
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,oBAAY,YAAY;IACtB;;OAEG;IACH,QAAQ,IAAA;IACR;;OAEG;IACH,OAAO,IAAA;IACP;;OAEG;IACH,OAAO,IAAA;IACP;;OAEG;IACH,IAAI,IAAA;IACJ;;OAEG;IACH,QAAQ,IAAA;IACR;;OAEG;IACH,SAAS,IAAA;CACV;AAED;;;;GAIG;AACH,MAAM,MAAM,kBAAkB,GAAG;IAC/B;;OAEG;I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MAAM,MAAM,YAAY,GAAG;IACzB;;OAEG;IACH,MAAM,EAAE,MAAM,CAAC;IACf;;OAEG;IACH,cAAc,EAAE,SAAS,CAAC;CAC3B,CAAC"}
|
package/package.json
CHANGED
package/src/constants.ts
CHANGED
|
@@ -184,29 +184,31 @@ export const NETWORKS: {
|
|
|
184
184
|
chainId: ChainId.AVALANCHE_TESTNET,
|
|
185
185
|
title: 'Fuji C-Chain',
|
|
186
186
|
scanUrl: 'https://testnet.snowtrace.io',
|
|
187
|
-
factoryAddress: '
|
|
187
|
+
factoryAddress: '0x56C2ba540726ED4f46E7a134b6b9Ee9C867FcF92',
|
|
188
188
|
hmtAddress: '0x9406d5c635AD22b0d76c75E52De57A2177919ca3',
|
|
189
|
-
stakingAddress: '',
|
|
190
|
-
rewardPoolAddress: '',
|
|
191
|
-
kvstoreAddress: '
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
oldSubgraphUrl:
|
|
195
|
-
|
|
189
|
+
stakingAddress: '0x9890473B0b93E24d6D1a8Dfb739D577C6f25FFd3',
|
|
190
|
+
rewardPoolAddress: '0x5517fE916Fe9F8dB15B0DDc76ebDf0BdDCd4ed18',
|
|
191
|
+
kvstoreAddress: '0x707fb5A5d36BC15275Af3f73262bf9a1D8C470EB',
|
|
192
|
+
subgraphUrl:
|
|
193
|
+
'https://api.thegraph.com/subgraphs/name/humanprotocol/fuji-v2',
|
|
194
|
+
oldSubgraphUrl:
|
|
195
|
+
'https://api.thegraph.com/subgraphs/name/humanprotocol/fuji',
|
|
196
|
+
oldFactoryAddress: '0xfb4469201951C3B9a7F1996c477cb7BDBEcE0A88',
|
|
196
197
|
},
|
|
197
198
|
[ChainId.AVALANCHE]: {
|
|
198
199
|
chainId: ChainId.AVALANCHE,
|
|
199
200
|
title: 'Avalanche C-Chain Mainnet',
|
|
200
201
|
scanUrl: 'https://snowtrace.io',
|
|
201
|
-
factoryAddress: '
|
|
202
|
+
factoryAddress: '0xD9c75a1Aa4237BB72a41E5E26bd8384f10c1f55a',
|
|
202
203
|
hmtAddress: '0x12365293cb6477d4fc2686e46BB97E3Fb64f1550',
|
|
203
|
-
stakingAddress: '',
|
|
204
|
-
rewardPoolAddress: '',
|
|
205
|
-
kvstoreAddress: '
|
|
204
|
+
stakingAddress: '0x05398211bA2046E296fBc9a9D3EB49e3F15C3123',
|
|
205
|
+
rewardPoolAddress: '0x4A5963Dd6792692e9147EdC7659936b96251917a',
|
|
206
|
+
kvstoreAddress: '0x70671167176C4934204B1C7e97F5e86695857ef2',
|
|
206
207
|
subgraphUrl:
|
|
208
|
+
'https://api.thegraph.com/subgraphs/name/humanprotocol/avalanche-v2',
|
|
209
|
+
oldSubgraphUrl:
|
|
207
210
|
'https://api.thegraph.com/subgraphs/name/humanprotocol/avalanche',
|
|
208
|
-
|
|
209
|
-
oldFactoryAddress: '',
|
|
211
|
+
oldFactoryAddress: '0x9767a578ba7a5FA1563c8229943cB01cd8446BB4',
|
|
210
212
|
},
|
|
211
213
|
[ChainId.SKALE]: {
|
|
212
214
|
chainId: ChainId.SKALE,
|
package/src/error.ts
CHANGED
|
@@ -167,6 +167,13 @@ export const ErrorEscrowAddressIsNotProvidedByFactory = new Error(
|
|
|
167
167
|
'Escrow address is not provided by the factory'
|
|
168
168
|
);
|
|
169
169
|
|
|
170
|
+
/**
|
|
171
|
+
* @constant {Error} - Transfer event not found in transaction logs.
|
|
172
|
+
*/
|
|
173
|
+
export const ErrorTransferEventNotFoundInTransactionLogs = new Error(
|
|
174
|
+
'Transfer event not found in transaction logs'
|
|
175
|
+
);
|
|
176
|
+
|
|
170
177
|
/**
|
|
171
178
|
* @constant {Error} - Manifest file does not exist.
|
|
172
179
|
*/
|
package/src/escrow.ts
CHANGED
|
@@ -36,9 +36,10 @@ import {
|
|
|
36
36
|
ErrorUrlIsEmptyString,
|
|
37
37
|
InvalidEthereumAddressError,
|
|
38
38
|
ErrorInvalidExchangeOracleAddressProvided,
|
|
39
|
+
ErrorTransferEventNotFoundInTransactionLogs,
|
|
39
40
|
} from './error';
|
|
40
41
|
import { IEscrowConfig, IEscrowsFilter } from './interfaces';
|
|
41
|
-
import { EscrowStatus, NetworkData } from './types';
|
|
42
|
+
import { EscrowCancel, EscrowStatus, NetworkData } from './types';
|
|
42
43
|
import { isValidUrl, throwError } from './utils';
|
|
43
44
|
import {
|
|
44
45
|
EscrowData,
|
|
@@ -480,11 +481,11 @@ export class EscrowClient {
|
|
|
480
481
|
* Cancels the specified escrow and sends the balance to the canceler.
|
|
481
482
|
*
|
|
482
483
|
* @param {string} escrowAddress - Address of the escrow.
|
|
483
|
-
* @returns {Promise<
|
|
484
|
+
* @returns {Promise<EscrowCancel>}
|
|
484
485
|
* @throws {Error} - An error object if an error occurred.
|
|
485
486
|
*/
|
|
486
487
|
@requiresSigner
|
|
487
|
-
async cancel(escrowAddress: string): Promise<
|
|
488
|
+
async cancel(escrowAddress: string): Promise<EscrowCancel> {
|
|
488
489
|
if (!ethers.utils.isAddress(escrowAddress)) {
|
|
489
490
|
throw ErrorInvalidEscrowAddressProvided;
|
|
490
491
|
}
|
|
@@ -498,8 +499,39 @@ export class EscrowClient {
|
|
|
498
499
|
escrowAddress,
|
|
499
500
|
this.signerOrProvider
|
|
500
501
|
);
|
|
501
|
-
await this.escrowContract.cancel();
|
|
502
|
-
|
|
502
|
+
const tx = await this.escrowContract.cancel();
|
|
503
|
+
const transactionReceipt = await tx.wait();
|
|
504
|
+
|
|
505
|
+
let amountTransferred: BigNumber | undefined = undefined;
|
|
506
|
+
const tokenAddress = await this.escrowContract.token();
|
|
507
|
+
|
|
508
|
+
const tokenContract: HMToken = HMToken__factory.connect(
|
|
509
|
+
tokenAddress,
|
|
510
|
+
this.signerOrProvider
|
|
511
|
+
);
|
|
512
|
+
|
|
513
|
+
for (const log of transactionReceipt.logs) {
|
|
514
|
+
if (log.address === tokenAddress) {
|
|
515
|
+
const parsedLog = tokenContract.interface.parseLog(log);
|
|
516
|
+
|
|
517
|
+
const from = parsedLog.args[0];
|
|
518
|
+
if (parsedLog.name === 'Transfer' && from === escrowAddress) {
|
|
519
|
+
amountTransferred = parsedLog.args[2];
|
|
520
|
+
break;
|
|
521
|
+
}
|
|
522
|
+
}
|
|
523
|
+
}
|
|
524
|
+
|
|
525
|
+
if (amountTransferred === undefined) {
|
|
526
|
+
throw ErrorTransferEventNotFoundInTransactionLogs;
|
|
527
|
+
}
|
|
528
|
+
|
|
529
|
+
const escrowCancelData: EscrowCancel = {
|
|
530
|
+
txHash: transactionReceipt.transactionHash,
|
|
531
|
+
amountRefunded: amountTransferred,
|
|
532
|
+
};
|
|
533
|
+
|
|
534
|
+
return escrowCancelData;
|
|
503
535
|
} catch (e) {
|
|
504
536
|
return throwError(e);
|
|
505
537
|
}
|
|
@@ -19,9 +19,12 @@ export const GET_PAYOUTS_QUERY = (filter: IPayoutFilter) => {
|
|
|
19
19
|
${escrowAddress ? `escrowAddress: $escrowAddress` : ''}
|
|
20
20
|
${recipient ? `recipient: $recipient` : ''}
|
|
21
21
|
${from ? `createdAt_gte: $from` : ''}
|
|
22
|
-
${to ? `
|
|
22
|
+
${to ? `createdAt_lt: $to` : ''}
|
|
23
23
|
}
|
|
24
24
|
`;
|
|
25
|
+
const LIMIT_CLAUSE = `
|
|
26
|
+
first: 1000
|
|
27
|
+
`;
|
|
25
28
|
|
|
26
29
|
return gql`
|
|
27
30
|
query getPayouts(
|
|
@@ -32,6 +35,9 @@ export const GET_PAYOUTS_QUERY = (filter: IPayoutFilter) => {
|
|
|
32
35
|
) {
|
|
33
36
|
payouts(
|
|
34
37
|
${WHERE_CLAUSE}
|
|
38
|
+
orderBy: createdAt,
|
|
39
|
+
orderDirection: desc,
|
|
40
|
+
${LIMIT_CLAUSE}
|
|
35
41
|
) {
|
|
36
42
|
...PayoutFields
|
|
37
43
|
}
|
package/src/graphql/types.ts
CHANGED
|
@@ -100,7 +100,6 @@ export type EscrowStatistics = {
|
|
|
100
100
|
export type DailyWorkerData = {
|
|
101
101
|
timestamp: Date;
|
|
102
102
|
activeWorkers: number;
|
|
103
|
-
averageJobsSolved: number;
|
|
104
103
|
};
|
|
105
104
|
|
|
106
105
|
export type WorkerStatistics = {
|
|
@@ -111,7 +110,6 @@ export type DailyPaymentData = {
|
|
|
111
110
|
timestamp: Date;
|
|
112
111
|
totalAmountPaid: BigNumber;
|
|
113
112
|
totalCount: number;
|
|
114
|
-
averageAmountPerJob: BigNumber;
|
|
115
113
|
averageAmountPerWorker: BigNumber;
|
|
116
114
|
};
|
|
117
115
|
|
|
@@ -137,6 +135,7 @@ export type DailyHMTData = {
|
|
|
137
135
|
|
|
138
136
|
export type HMTStatistics = {
|
|
139
137
|
totalTransferAmount: BigNumber;
|
|
138
|
+
totalTransferCount: number;
|
|
140
139
|
totalHolders: number;
|
|
141
140
|
holders: HMTHolder[];
|
|
142
141
|
dailyHMTData: DailyHMTData[];
|
package/src/statistics.ts
CHANGED
|
@@ -1,15 +1,12 @@
|
|
|
1
1
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
2
|
-
import axios from 'axios';
|
|
3
2
|
import { BigNumber } from 'ethers';
|
|
4
3
|
import gqlFetch from 'graphql-request';
|
|
5
4
|
|
|
6
|
-
import { ChainId } from './enums';
|
|
7
5
|
import {
|
|
8
6
|
GET_ESCROW_STATISTICS_QUERY,
|
|
9
7
|
GET_EVENT_DAY_DATA_QUERY,
|
|
10
8
|
GET_HOLDERS_QUERY,
|
|
11
9
|
GET_HMTOKEN_STATISTICS_QUERY,
|
|
12
|
-
GET_PAYOUTS_QUERY,
|
|
13
10
|
EscrowStatistics,
|
|
14
11
|
EscrowStatisticsData,
|
|
15
12
|
EventDayData,
|
|
@@ -18,9 +15,6 @@ import {
|
|
|
18
15
|
PaymentStatistics,
|
|
19
16
|
WorkerStatistics,
|
|
20
17
|
HMTHolderData,
|
|
21
|
-
TaskStatistics,
|
|
22
|
-
IMData,
|
|
23
|
-
PayoutData,
|
|
24
18
|
} from './graphql';
|
|
25
19
|
import { IStatisticsParams } from './interfaces';
|
|
26
20
|
import { NetworkData } from './types';
|
|
@@ -28,86 +22,14 @@ import { throwError } from './utils';
|
|
|
28
22
|
|
|
29
23
|
export class StatisticsClient {
|
|
30
24
|
public network: NetworkData;
|
|
31
|
-
private IMAPIKey: string;
|
|
32
25
|
|
|
33
26
|
/**
|
|
34
27
|
* **StatisticsClient constructor**
|
|
35
28
|
*
|
|
36
29
|
* @param {NetworkData} network - The network information required to connect to the Statistics contract
|
|
37
30
|
*/
|
|
38
|
-
constructor(network: NetworkData
|
|
31
|
+
constructor(network: NetworkData) {
|
|
39
32
|
this.network = network;
|
|
40
|
-
this.IMAPIKey = IMAPIKey;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
/**
|
|
44
|
-
* Gets the IM data for the given date range
|
|
45
|
-
* IM API now limits the date range to 60 days, so we need to make multiple requests
|
|
46
|
-
* if the date range is greater than 60 days
|
|
47
|
-
*
|
|
48
|
-
* If the filter is empty, returns the last 60 days of data
|
|
49
|
-
*
|
|
50
|
-
* If the network is not Polygon, returns an empty object
|
|
51
|
-
* TODO: Remove this once the IM API is available on all networks
|
|
52
|
-
*
|
|
53
|
-
* @param {IStatisticsParams} params - Filter parameters.
|
|
54
|
-
* @returns {Promise<IMData>}
|
|
55
|
-
* @throws {Error} - An error object if an error occurred.
|
|
56
|
-
*/
|
|
57
|
-
private async getIMData(params: IStatisticsParams = {}): Promise<IMData> {
|
|
58
|
-
if (this.network.chainId !== ChainId.POLYGON) {
|
|
59
|
-
return {};
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
const now = new Date();
|
|
63
|
-
const today = new Date(now.getFullYear(), now.getMonth(), now.getDate());
|
|
64
|
-
|
|
65
|
-
const defaultFromDate = new Date(
|
|
66
|
-
now.getFullYear(),
|
|
67
|
-
now.getMonth(),
|
|
68
|
-
now.getDate()
|
|
69
|
-
);
|
|
70
|
-
defaultFromDate.setDate(today.getDate() - 60);
|
|
71
|
-
|
|
72
|
-
const from = params.from ? new Date(params.from) : defaultFromDate;
|
|
73
|
-
const to = params.to ? new Date(params.to) : today;
|
|
74
|
-
|
|
75
|
-
// IM API now limits the date range to 60 days, so we need to make multiple requests
|
|
76
|
-
// if the date range is greater than 60 days
|
|
77
|
-
const chunks = [];
|
|
78
|
-
let start = from;
|
|
79
|
-
while (start < to) {
|
|
80
|
-
const end = new Date(start);
|
|
81
|
-
end.setDate(start.getDate() + 60);
|
|
82
|
-
chunks.push({ from: start, to: end.getDate() < to.getDate() ? end : to });
|
|
83
|
-
start = end;
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
return await Promise.all(
|
|
87
|
-
chunks.map(({ from, to }) =>
|
|
88
|
-
axios
|
|
89
|
-
.get('/support/summary-stats', {
|
|
90
|
-
baseURL: 'https://foundation-accounts.hmt.ai',
|
|
91
|
-
method: 'GET',
|
|
92
|
-
params: {
|
|
93
|
-
start_date: from.toISOString().slice(0, 10),
|
|
94
|
-
end_date: to.toISOString().slice(0, 10),
|
|
95
|
-
api_key: this.IMAPIKey,
|
|
96
|
-
},
|
|
97
|
-
})
|
|
98
|
-
.then((res) => res.data)
|
|
99
|
-
)
|
|
100
|
-
).then((chunks) =>
|
|
101
|
-
chunks.reduce(
|
|
102
|
-
// Exclude total from the aggregated data
|
|
103
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
104
|
-
(aggregated, { total, ...chunkData }) => ({
|
|
105
|
-
...aggregated,
|
|
106
|
-
...chunkData,
|
|
107
|
-
}),
|
|
108
|
-
{}
|
|
109
|
-
)
|
|
110
|
-
);
|
|
111
33
|
}
|
|
112
34
|
|
|
113
35
|
/**
|
|
@@ -148,24 +70,6 @@ export class StatisticsClient {
|
|
|
148
70
|
}
|
|
149
71
|
}
|
|
150
72
|
|
|
151
|
-
async getTaskStatistics(
|
|
152
|
-
params: IStatisticsParams = {}
|
|
153
|
-
): Promise<TaskStatistics> {
|
|
154
|
-
try {
|
|
155
|
-
const data = await this.getIMData(params);
|
|
156
|
-
|
|
157
|
-
return {
|
|
158
|
-
dailyTasksData: Object.entries(data).map(([key, value]) => ({
|
|
159
|
-
timestamp: new Date(key),
|
|
160
|
-
tasksTotal: value.served,
|
|
161
|
-
tasksSolved: value.solved,
|
|
162
|
-
})),
|
|
163
|
-
};
|
|
164
|
-
} catch (e: any) {
|
|
165
|
-
return throwError(e);
|
|
166
|
-
}
|
|
167
|
-
}
|
|
168
|
-
|
|
169
73
|
/**
|
|
170
74
|
* Returns the worker statistics data for the given date range
|
|
171
75
|
*
|
|
@@ -177,43 +81,18 @@ export class StatisticsClient {
|
|
|
177
81
|
params: IStatisticsParams = {}
|
|
178
82
|
): Promise<WorkerStatistics> {
|
|
179
83
|
try {
|
|
180
|
-
const
|
|
84
|
+
const { eventDayDatas } = await gqlFetch<{
|
|
85
|
+
eventDayDatas: EventDayData[];
|
|
86
|
+
}>(this.network.subgraphUrl, GET_EVENT_DAY_DATA_QUERY(params), {
|
|
87
|
+
from: params.from ? params.from.getTime() / 1000 : undefined,
|
|
88
|
+
to: params.to ? params.to.getTime() / 1000 : undefined,
|
|
89
|
+
});
|
|
181
90
|
|
|
182
91
|
return {
|
|
183
|
-
dailyWorkersData:
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
const toDate = new Date(key);
|
|
188
|
-
toDate.setDate(toDate.getDate() + 1);
|
|
189
|
-
|
|
190
|
-
const { payouts } = await gqlFetch<{
|
|
191
|
-
payouts: PayoutData[];
|
|
192
|
-
}>(
|
|
193
|
-
this.network.subgraphUrl,
|
|
194
|
-
GET_PAYOUTS_QUERY({
|
|
195
|
-
from: fromDate,
|
|
196
|
-
to: toDate,
|
|
197
|
-
}),
|
|
198
|
-
{
|
|
199
|
-
from: fromDate.getTime() / 1000,
|
|
200
|
-
to: toDate.getTime() / 1000,
|
|
201
|
-
}
|
|
202
|
-
);
|
|
203
|
-
|
|
204
|
-
const activeWorkers = new Set(
|
|
205
|
-
payouts.map(({ recipient }) => recipient)
|
|
206
|
-
).size;
|
|
207
|
-
|
|
208
|
-
return {
|
|
209
|
-
timestamp,
|
|
210
|
-
activeWorkers,
|
|
211
|
-
averageJobsSolved: activeWorkers
|
|
212
|
-
? value.solved / activeWorkers
|
|
213
|
-
: 0,
|
|
214
|
-
};
|
|
215
|
-
})
|
|
216
|
-
),
|
|
92
|
+
dailyWorkersData: eventDayDatas.map((eventDayData) => ({
|
|
93
|
+
timestamp: new Date(+eventDayData.timestamp * 1000),
|
|
94
|
+
activeWorkers: +eventDayData.dailyWorkerCount,
|
|
95
|
+
})),
|
|
217
96
|
};
|
|
218
97
|
} catch (e: any) {
|
|
219
98
|
return throwError(e);
|
|
@@ -243,12 +122,6 @@ export class StatisticsClient {
|
|
|
243
122
|
timestamp: new Date(+eventDayData.timestamp * 1000),
|
|
244
123
|
totalAmountPaid: BigNumber.from(eventDayData.dailyPayoutAmount),
|
|
245
124
|
totalCount: +eventDayData.dailyPayoutCount,
|
|
246
|
-
averageAmountPerJob:
|
|
247
|
-
eventDayData.dailyBulkPayoutEventCount === '0'
|
|
248
|
-
? BigNumber.from(0)
|
|
249
|
-
: BigNumber.from(eventDayData.dailyPayoutAmount).div(
|
|
250
|
-
eventDayData.dailyBulkPayoutEventCount
|
|
251
|
-
),
|
|
252
125
|
averageAmountPerWorker:
|
|
253
126
|
eventDayData.dailyWorkerCount === '0'
|
|
254
127
|
? BigNumber.from(0)
|
|
@@ -292,6 +165,7 @@ export class StatisticsClient {
|
|
|
292
165
|
totalTransferAmount: BigNumber.from(
|
|
293
166
|
hmtokenStatistics.totalValueTransfered
|
|
294
167
|
),
|
|
168
|
+
totalTransferCount: Number(hmtokenStatistics.totalTransferEventCount),
|
|
295
169
|
totalHolders: +hmtokenStatistics.holders,
|
|
296
170
|
holders: holders.map((holder) => ({
|
|
297
171
|
address: holder.address,
|
package/src/types.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { BigNumber } from 'ethers';
|
|
2
|
+
|
|
1
3
|
/**
|
|
2
4
|
* Enum for escrow statuses.
|
|
3
5
|
* @readonly
|
|
@@ -136,3 +138,17 @@ export type NetworkData = {
|
|
|
136
138
|
*/
|
|
137
139
|
oldFactoryAddress: string;
|
|
138
140
|
};
|
|
141
|
+
|
|
142
|
+
/**
|
|
143
|
+
* Represents the response data for an escrow cancellation.
|
|
144
|
+
*/
|
|
145
|
+
export type EscrowCancel = {
|
|
146
|
+
/**
|
|
147
|
+
* The hash of the transaction associated with the escrow cancellation.
|
|
148
|
+
*/
|
|
149
|
+
txHash: string;
|
|
150
|
+
/**
|
|
151
|
+
* The amount refunded in the escrow cancellation.
|
|
152
|
+
*/
|
|
153
|
+
amountRefunded: BigNumber;
|
|
154
|
+
};
|