@human-protocol/sdk 1.1.11 → 1.1.12
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/README.md +2 -0
- 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 +28 -8
- package/dist/escrow.d.ts.map +1 -1
- package/dist/escrow.js +109 -34
- package/dist/graphql/queries/escrow.d.ts +1 -0
- package/dist/graphql/queries/escrow.d.ts.map +1 -1
- package/dist/graphql/queries/escrow.js +18 -2
- package/dist/graphql/queries/index.d.ts +1 -0
- package/dist/graphql/queries/index.d.ts.map +1 -1
- package/dist/graphql/queries/index.js +1 -0
- package/dist/graphql/queries/payout.d.ts +3 -0
- package/dist/graphql/queries/payout.d.ts.map +1 -0
- package/dist/graphql/queries/payout.js +43 -0
- package/dist/graphql/queries/staking.d.ts +4 -0
- package/dist/graphql/queries/staking.d.ts.map +1 -0
- package/dist/graphql/queries/staking.js +58 -0
- package/dist/graphql/queries/statistics.d.ts.map +1 -1
- package/dist/graphql/queries/statistics.js +10 -2
- package/dist/graphql/types.d.ts +23 -0
- package/dist/graphql/types.d.ts.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -1
- package/dist/interfaces.d.ts +34 -9
- package/dist/interfaces.d.ts.map +1 -1
- package/dist/staking.d.ts +8 -8
- package/dist/staking.d.ts.map +1 -1
- package/dist/staking.js +16 -38
- package/dist/statistics.d.ts +19 -2
- package/dist/statistics.d.ts.map +1 -1
- package/dist/statistics.js +93 -13
- package/dist/storage.d.ts +3 -0
- package/dist/storage.d.ts.map +1 -1
- package/dist/storage.js +3 -0
- package/dist/types.d.ts +4 -0
- package/dist/types.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/error.ts +7 -0
- package/src/escrow.ts +152 -41
- package/src/graphql/queries/escrow.ts +26 -2
- package/src/graphql/queries/index.ts +1 -0
- package/src/graphql/queries/payout.ts +41 -0
- package/src/graphql/queries/staking.ts +57 -0
- package/src/graphql/queries/statistics.ts +10 -2
- package/src/graphql/types.ts +28 -0
- package/src/index.ts +2 -1
- package/src/interfaces.ts +35 -14
- package/src/staking.ts +23 -53
- package/src/statistics.ts +133 -17
- package/src/storage.ts +3 -0
- package/src/types.ts +4 -0
package/dist/graphql/types.d.ts
CHANGED
|
@@ -15,10 +15,20 @@ export type EscrowData = {
|
|
|
15
15
|
recordingOracleFee?: string;
|
|
16
16
|
reputationOracle?: string;
|
|
17
17
|
reputationOracleFee?: string;
|
|
18
|
+
exchangeOracle?: string;
|
|
19
|
+
exchangeOracleFee?: string;
|
|
18
20
|
status: string;
|
|
19
21
|
token: string;
|
|
20
22
|
totalFundedAmount: string;
|
|
21
23
|
createdAt: string;
|
|
24
|
+
chainId: number;
|
|
25
|
+
};
|
|
26
|
+
export type PayoutData = {
|
|
27
|
+
id: string;
|
|
28
|
+
escrowAddress: string;
|
|
29
|
+
recipient: string;
|
|
30
|
+
amount: string;
|
|
31
|
+
createdAt: string;
|
|
22
32
|
};
|
|
23
33
|
export type HMTStatisticsData = {
|
|
24
34
|
totalTransferEventCount: string;
|
|
@@ -115,4 +125,17 @@ export type HMTStatistics = {
|
|
|
115
125
|
holders: HMTHolder[];
|
|
116
126
|
dailyHMTData: DailyHMTData[];
|
|
117
127
|
};
|
|
128
|
+
export type IMDataEntity = {
|
|
129
|
+
served: number;
|
|
130
|
+
solved: number;
|
|
131
|
+
};
|
|
132
|
+
export type IMData = Record<string, IMDataEntity>;
|
|
133
|
+
export type DailyTaskData = {
|
|
134
|
+
timestamp: Date;
|
|
135
|
+
tasksTotal: number;
|
|
136
|
+
tasksSolved: number;
|
|
137
|
+
};
|
|
138
|
+
export type TaskStatistics = {
|
|
139
|
+
dailyTasksData: DailyTaskData[];
|
|
140
|
+
};
|
|
118
141
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"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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/index.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { StakingClient } from './staking';
|
|
2
2
|
import { StorageClient } from './storage';
|
|
3
3
|
import { KVStoreClient } from './kvstore';
|
|
4
|
-
import { EscrowClient } from './escrow';
|
|
4
|
+
import { EscrowClient, EscrowUtils } from './escrow';
|
|
5
5
|
import { StatisticsClient } from './statistics';
|
|
6
6
|
export * from './constants';
|
|
7
7
|
export * from './types';
|
|
8
8
|
export * from './enums';
|
|
9
9
|
export * from './interfaces';
|
|
10
|
-
export { StakingClient, StorageClient, KVStoreClient, EscrowClient, StatisticsClient, };
|
|
10
|
+
export { StakingClient, StorageClient, KVStoreClient, EscrowClient, EscrowUtils, StatisticsClient, };
|
|
11
11
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AACrD,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAEhD,cAAc,aAAa,CAAC;AAC5B,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC;AACxB,cAAc,cAAc,CAAC;AAE7B,OAAO,EACL,aAAa,EACb,aAAa,EACb,aAAa,EACb,YAAY,EACZ,WAAW,EACX,gBAAgB,GACjB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -14,7 +14,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.StatisticsClient = exports.EscrowClient = exports.KVStoreClient = exports.StorageClient = exports.StakingClient = void 0;
|
|
17
|
+
exports.StatisticsClient = exports.EscrowUtils = exports.EscrowClient = exports.KVStoreClient = exports.StorageClient = exports.StakingClient = void 0;
|
|
18
18
|
const staking_1 = require("./staking");
|
|
19
19
|
Object.defineProperty(exports, "StakingClient", { enumerable: true, get: function () { return staking_1.StakingClient; } });
|
|
20
20
|
const storage_1 = require("./storage");
|
|
@@ -23,6 +23,7 @@ const kvstore_1 = require("./kvstore");
|
|
|
23
23
|
Object.defineProperty(exports, "KVStoreClient", { enumerable: true, get: function () { return kvstore_1.KVStoreClient; } });
|
|
24
24
|
const escrow_1 = require("./escrow");
|
|
25
25
|
Object.defineProperty(exports, "EscrowClient", { enumerable: true, get: function () { return escrow_1.EscrowClient; } });
|
|
26
|
+
Object.defineProperty(exports, "EscrowUtils", { enumerable: true, get: function () { return escrow_1.EscrowUtils; } });
|
|
26
27
|
const statistics_1 = require("./statistics");
|
|
27
28
|
Object.defineProperty(exports, "StatisticsClient", { enumerable: true, get: function () { return statistics_1.StatisticsClient; } });
|
|
28
29
|
__exportStar(require("./constants"), exports);
|
package/dist/interfaces.d.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { BigNumber } from 'ethers';
|
|
2
|
+
import { EscrowStatus } from './types';
|
|
3
|
+
import { ChainId } from './enums';
|
|
2
4
|
export interface IAllocation {
|
|
3
5
|
escrowAddress: string;
|
|
4
6
|
staker: string;
|
|
@@ -10,28 +12,45 @@ export interface IReward {
|
|
|
10
12
|
escrowAddress: string;
|
|
11
13
|
amount: BigNumber;
|
|
12
14
|
}
|
|
13
|
-
export interface
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
15
|
+
export interface ILeader {
|
|
16
|
+
id: string;
|
|
17
|
+
address: string;
|
|
18
|
+
amountStaked: BigNumber;
|
|
19
|
+
amountAllocated: BigNumber;
|
|
20
|
+
amountLocked: BigNumber;
|
|
21
|
+
lockedUntilTimestamp: BigNumber;
|
|
22
|
+
amountWithdrawn: BigNumber;
|
|
23
|
+
amountSlashed: BigNumber;
|
|
24
|
+
reputation: BigNumber;
|
|
25
|
+
reward: BigNumber;
|
|
26
|
+
amountJobsLaunched: BigNumber;
|
|
27
|
+
role?: string;
|
|
28
|
+
fee?: BigNumber;
|
|
29
|
+
publicKey?: string;
|
|
30
|
+
webhookUrl?: string;
|
|
31
|
+
url?: string;
|
|
32
|
+
}
|
|
33
|
+
export interface ILeadersFilter {
|
|
34
|
+
role?: string;
|
|
20
35
|
}
|
|
21
|
-
type EscrowStatus = 'Launched' | 'Pending' | 'Partial' | 'Paid' | 'Complete' | 'Cancelled';
|
|
22
36
|
export interface IEscrowsFilter {
|
|
23
37
|
launcher?: string;
|
|
24
38
|
reputationOracle?: string;
|
|
25
39
|
recordingOracle?: string;
|
|
40
|
+
exchangeOracle?: string;
|
|
41
|
+
jobRequesterId?: string;
|
|
26
42
|
status?: EscrowStatus;
|
|
27
43
|
from?: Date;
|
|
28
44
|
to?: Date;
|
|
45
|
+
networks: ChainId[];
|
|
29
46
|
}
|
|
30
47
|
export interface IEscrowConfig {
|
|
31
48
|
recordingOracle: string;
|
|
32
49
|
reputationOracle: string;
|
|
50
|
+
exchangeOracle: string;
|
|
33
51
|
recordingOracleFee: BigNumber;
|
|
34
52
|
reputationOracleFee: BigNumber;
|
|
53
|
+
exchangeOracleFee: BigNumber;
|
|
35
54
|
manifestUrl: string;
|
|
36
55
|
manifestHash: string;
|
|
37
56
|
}
|
|
@@ -44,6 +63,12 @@ export interface IKeyPair {
|
|
|
44
63
|
export interface IStatisticsParams {
|
|
45
64
|
from?: Date;
|
|
46
65
|
to?: Date;
|
|
66
|
+
limit?: number;
|
|
67
|
+
}
|
|
68
|
+
export interface IPayoutFilter {
|
|
69
|
+
escrowAddress?: string;
|
|
70
|
+
recipient?: string;
|
|
71
|
+
from?: Date;
|
|
72
|
+
to?: Date;
|
|
47
73
|
}
|
|
48
|
-
export {};
|
|
49
74
|
//# sourceMappingURL=interfaces.d.ts.map
|
package/dist/interfaces.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"interfaces.d.ts","sourceRoot":"","sources":["../src/interfaces.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC;
|
|
1
|
+
{"version":3,"file":"interfaces.d.ts","sourceRoot":"","sources":["../src/interfaces.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC;AACnC,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,OAAO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Q,EAAE,OAAO,EAAE,CAAC;CACrB;AAED,MAAM,WAAW,aAAa;IAC5B,eAAe,EAAE,MAAM,CAAC;IACxB,gBAAgB,EAAE,MAAM,CAAC;IACzB,cAAc,EAAE,MAAM,CAAC;IACvB,kBAAkB,EAAE,SAAS,CAAC;IAC9B,mBAAmB,EAAE,SAAS,CAAC;IAC/B,iBAAiB,EAAE,SAAS,CAAC;IAC7B,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,WAAW,QAAQ;IACvB,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;IACnB,qBAAqB,CAAC,EAAE,MAAM,CAAC;CAChC;AAED,MAAM,WAAW,iBAAiB;IAChC,IAAI,CAAC,EAAE,IAAI,CAAC;IACZ,EAAE,CAAC,EAAE,IAAI,CAAC;IACV,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,aAAa;IAC5B,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,IAAI,CAAC,EAAE,IAAI,CAAC;IACZ,EAAE,CAAC,EAAE,IAAI,CAAC;CACX"}
|
package/dist/staking.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Provider } from '@ethersproject/abstract-provider';
|
|
2
2
|
import { EscrowFactory, HMToken, Staking } from '@human-protocol/core/typechain-types';
|
|
3
3
|
import { BigNumber, Signer } from 'ethers';
|
|
4
|
-
import { IAllocation,
|
|
4
|
+
import { IAllocation, ILeader, ILeadersFilter, IReward } from './interfaces';
|
|
5
5
|
import { NetworkData } from './types';
|
|
6
6
|
export declare class StakingClient {
|
|
7
7
|
signerOrProvider: Signer | Provider;
|
|
@@ -96,20 +96,20 @@ export declare class StakingClient {
|
|
|
96
96
|
*/
|
|
97
97
|
distributeRewards(escrowAddress: string): Promise<void>;
|
|
98
98
|
/**
|
|
99
|
-
* **Returns the
|
|
99
|
+
* **Returns the leader details for a given address**
|
|
100
100
|
*
|
|
101
|
-
* @param {string}
|
|
102
|
-
* @returns {Promise<
|
|
101
|
+
* @param {string} address - Leader address
|
|
102
|
+
* @returns {Promise<ILeader>} - Return leader details
|
|
103
103
|
* @throws {Error} - An error object if an error occurred, result otherwise
|
|
104
104
|
*/
|
|
105
|
-
|
|
105
|
+
getLeader(address: string): Promise<ILeader>;
|
|
106
106
|
/**
|
|
107
|
-
* **Returns the
|
|
107
|
+
* **Returns the leaders data **
|
|
108
108
|
*
|
|
109
|
-
* @returns {Promise<
|
|
109
|
+
* @returns {Promise<ILeader[]>} - Return an array with leaders data
|
|
110
110
|
* @throws {Error} - An error object if an error occurred, results otherwise
|
|
111
111
|
*/
|
|
112
|
-
|
|
112
|
+
getLeaders(filter?: ILeadersFilter): Promise<ILeader[]>;
|
|
113
113
|
/**
|
|
114
114
|
* **Returns information about the allocation of the specified escrow.*
|
|
115
115
|
*
|
package/dist/staking.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"staking.d.ts","sourceRoot":"","sources":["../src/staking.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,kCAAkC,CAAC;AAE5D,OAAO,EACL,aAAa,EAEb,OAAO,EAIP,OAAO,EAER,MAAM,sCAAsC,CAAC;AAC9C,OAAO,EAAE,SAAS,EAAE,MAAM,EAAU,MAAM,QAAQ,CAAC;
|
|
1
|
+
{"version":3,"file":"staking.d.ts","sourceRoot":"","sources":["../src/staking.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,kCAAkC,CAAC;AAE5D,OAAO,EACL,aAAa,EAEb,OAAO,EAIP,OAAO,EAER,MAAM,sCAAsC,CAAC;AAC9C,OAAO,EAAE,SAAS,EAAE,MAAM,EAAU,MAAM,QAAQ,CAAC;AAenD,OAAO,EAAE,WAAW,EAAE,OA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AMG;IACU,SAAS,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAkBzD;;;;;OAKG;IACU,UAAU,CAAC,MAAM,GAAE,cAAmB,GAAG,OAAO,CAAC,OAAO,EAAE,CAAC;IAcxE;;;;;;OAMG;IACU,aAAa,CAAC,aAAa,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC;IAiBvE;;;;;;OAMG;IACU,UAAU,CAAC,cAAc,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,EAAE,CAAC;CAsBpE"}
|
package/dist/staking.js
CHANGED
|
@@ -21,6 +21,7 @@ const decorators_1 = require("./decorators");
|
|
|
21
21
|
const error_1 = require("./error");
|
|
22
22
|
const utils_1 = require("./utils");
|
|
23
23
|
const reward_1 = require("./graphql/queries/reward");
|
|
24
|
+
const staking_1 = require("./graphql/queries/staking");
|
|
24
25
|
class StakingClient {
|
|
25
26
|
/**
|
|
26
27
|
* **StakingClient constructor**
|
|
@@ -257,61 +258,38 @@ class StakingClient {
|
|
|
257
258
|
}
|
|
258
259
|
}
|
|
259
260
|
/**
|
|
260
|
-
* **Returns the
|
|
261
|
+
* **Returns the leader details for a given address**
|
|
261
262
|
*
|
|
262
|
-
* @param {string}
|
|
263
|
-
* @returns {Promise<
|
|
263
|
+
* @param {string} address - Leader address
|
|
264
|
+
* @returns {Promise<ILeader>} - Return leader details
|
|
264
265
|
* @throws {Error} - An error object if an error occurred, result otherwise
|
|
265
266
|
*/
|
|
266
|
-
async
|
|
267
|
-
if (!ethers_1.ethers.utils.isAddress(
|
|
267
|
+
async getLeader(address) {
|
|
268
|
+
if (!ethers_1.ethers.utils.isAddress(address)) {
|
|
268
269
|
throw error_1.ErrorInvalidStakerAddressProvided;
|
|
269
270
|
}
|
|
270
271
|
try {
|
|
271
|
-
const
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
.sub(tokensLocked);
|
|
276
|
-
return {
|
|
277
|
-
staker,
|
|
278
|
-
tokensStaked,
|
|
279
|
-
tokensAllocated,
|
|
280
|
-
tokensLocked,
|
|
281
|
-
tokensLockedUntil,
|
|
282
|
-
tokensAvailable,
|
|
283
|
-
};
|
|
272
|
+
const { leader } = await (0, graphql_request_1.default)(this.network.subgraphUrl, staking_1.GET_LEADER_QUERY, {
|
|
273
|
+
address,
|
|
274
|
+
});
|
|
275
|
+
return leader;
|
|
284
276
|
}
|
|
285
277
|
catch (e) {
|
|
286
278
|
return (0, utils_1.throwError)(e);
|
|
287
279
|
}
|
|
288
280
|
}
|
|
289
281
|
/**
|
|
290
|
-
* **Returns the
|
|
282
|
+
* **Returns the leaders data **
|
|
291
283
|
*
|
|
292
|
-
* @returns {Promise<
|
|
284
|
+
* @returns {Promise<ILeader[]>} - Return an array with leaders data
|
|
293
285
|
* @throws {Error} - An error object if an error occurred, results otherwise
|
|
294
286
|
*/
|
|
295
|
-
async
|
|
287
|
+
async getLeaders(filter = {}) {
|
|
296
288
|
try {
|
|
297
|
-
const
|
|
298
|
-
|
|
299
|
-
throw error_1.ErrorStakingGetStakers;
|
|
300
|
-
}
|
|
301
|
-
return result[1].map((staker, index) => {
|
|
302
|
-
const tokensStaked = ethers_1.BigNumber.from(staker.tokensStaked), tokensAllocated = ethers_1.BigNumber.from(staker.tokensAllocated), tokensLocked = ethers_1.BigNumber.from(staker.tokensLocked), tokensLockedUntil = ethers_1.BigNumber.from(staker.tokensLockedUntil);
|
|
303
|
-
const tokensAvailable = tokensStaked
|
|
304
|
-
.sub(tokensAllocated)
|
|
305
|
-
.sub(tokensLocked);
|
|
306
|
-
return {
|
|
307
|
-
staker: result[0][index],
|
|
308
|
-
tokensStaked,
|
|
309
|
-
tokensAllocated,
|
|
310
|
-
tokensLocked,
|
|
311
|
-
tokensLockedUntil,
|
|
312
|
-
tokensAvailable,
|
|
313
|
-
};
|
|
289
|
+
const { leaders } = await (0, graphql_request_1.default)(this.network.subgraphUrl, (0, staking_1.GET_LEADERS_QUERY)(filter), {
|
|
290
|
+
role: filter.role,
|
|
314
291
|
});
|
|
292
|
+
return leaders;
|
|
315
293
|
}
|
|
316
294
|
catch (e) {
|
|
317
295
|
return (0, utils_1.throwError)(e);
|
package/dist/statistics.d.ts
CHANGED
|
@@ -1,14 +1,30 @@
|
|
|
1
|
-
import { EscrowStatistics, HMTStatistics, PaymentStatistics, WorkerStatistics } from './graphql';
|
|
1
|
+
import { EscrowStatistics, HMTStatistics, PaymentStatistics, WorkerStatistics, TaskStatistics } 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;
|
|
6
7
|
/**
|
|
7
8
|
* **StatisticsClient constructor**
|
|
8
9
|
*
|
|
9
10
|
* @param {NetworkData} network - The network information required to connect to the Statistics contract
|
|
10
11
|
*/
|
|
11
|
-
constructor(network: NetworkData);
|
|
12
|
+
constructor(network: NetworkData, IMAPIKey?: string);
|
|
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;
|
|
12
28
|
/**
|
|
13
29
|
* Returns the escrow statistics data for the given date range
|
|
14
30
|
*
|
|
@@ -17,6 +33,7 @@ export declare class StatisticsClient {
|
|
|
17
33
|
* @throws {Error} - An error object if an error occurred.
|
|
18
34
|
*/
|
|
19
35
|
getEscrowStatistics(params?: IStatisticsParams): Promise<EscrowStatistics>;
|
|
36
|
+
getTaskStatistics(params?: IStatisticsParams): Promise<TaskStatistics>;
|
|
20
37
|
/**
|
|
21
38
|
* Returns the worker statistics data for the given date range
|
|
22
39
|
*
|
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":"AAMA,OAAO,EAML,gBAAgB,EAGhB,aAAa,EAEb,iBAAiB,EACjB,gBAAgB,EAEhB,cAAc,EAGf,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;IAC5B,OAAO,CAAC,QAAQ,CAAS;IAEzB;;;;OAIG;gBACS,OAAO,EAAE,WAAW,EAAE,QAAQ,SAAK;IAK/C;;;;;;;;;;;;;OAaG;YACW,SAAS;IAwDvB;;;;;;OAMG;IACG,mBAAmB,CACvB,MAAM,GAAE,iBAAsB,GAC7B,OAAO,CAAC,gBAAgB,CAAC;IA6BtB,iBAAiB,CACrB,MAAM,GAAE,iBAAsB,GAC7B,OAAO,CAAC,cAAc,CAAC;IAgB1B;;;;;;OAMG;IACG,mBAAmB,CACvB,MAAM,GAAE,iBAAsB,GAC7B,OAAO,CAAC,gBAAgB,CAAC;IA6C5B;;;;;;OAMG;IACG,oBAAoB,CACxB,MAAM,GAAE,iBAAsB,GAC7B,OAAO,CAAC,iBAAiB,CAAC;IAiC7B;;;;;;OAMG;IACG,gBAAgB,CACpB,MAAM,GAAE,iBAAsB,GAC7B,OAAO,CAAC,aAAa,CAAC;CAsC1B"}
|
package/dist/statistics.js
CHANGED
|
@@ -5,18 +5,73 @@ 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
|
+
const ethers_1 = require("ethers");
|
|
8
10
|
const graphql_request_1 = __importDefault(require("graphql-request"));
|
|
11
|
+
const enums_1 = require("./enums");
|
|
9
12
|
const graphql_1 = require("./graphql");
|
|
10
13
|
const utils_1 = require("./utils");
|
|
11
|
-
const ethers_1 = require("ethers");
|
|
12
14
|
class StatisticsClient {
|
|
13
15
|
/**
|
|
14
16
|
* **StatisticsClient constructor**
|
|
15
17
|
*
|
|
16
18
|
* @param {NetworkData} network - The network information required to connect to the Statistics contract
|
|
17
19
|
*/
|
|
18
|
-
constructor(network) {
|
|
20
|
+
constructor(network, IMAPIKey = '') {
|
|
19
21
|
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
|
+
}), {}));
|
|
20
75
|
}
|
|
21
76
|
/**
|
|
22
77
|
* Returns the escrow statistics data for the given date range
|
|
@@ -48,6 +103,21 @@ class StatisticsClient {
|
|
|
48
103
|
return (0, utils_1.throwError)(e);
|
|
49
104
|
}
|
|
50
105
|
}
|
|
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
|
+
}
|
|
51
121
|
/**
|
|
52
122
|
* Returns the worker statistics data for the given date range
|
|
53
123
|
*
|
|
@@ -57,18 +127,28 @@ class StatisticsClient {
|
|
|
57
127
|
*/
|
|
58
128
|
async getWorkerStatistics(params = {}) {
|
|
59
129
|
try {
|
|
60
|
-
const
|
|
61
|
-
from: params.from ? params.from.getTime() / 1000 : undefined,
|
|
62
|
-
to: params.to ? params.to.getTime() / 1000 : undefined,
|
|
63
|
-
});
|
|
130
|
+
const data = await this.getIMData(params);
|
|
64
131
|
return {
|
|
65
|
-
dailyWorkersData:
|
|
66
|
-
timestamp
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
132
|
+
dailyWorkersData: await Promise.all(Object.entries(data).map(async ([key, value]) => {
|
|
133
|
+
const timestamp = new Date(key);
|
|
134
|
+
const fromDate = new Date(key);
|
|
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
|
+
};
|
|
72
152
|
})),
|
|
73
153
|
};
|
|
74
154
|
}
|
package/dist/storage.d.ts
CHANGED
package/dist/storage.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"storage.d.ts","sourceRoot":"","sources":["../src/storage.ts"],"names":[],"mappings":"AAWA,OAAO,EAAE,UAAU,EAAE,kBAAkB,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAIxE,qBAAa,aAAa;IACxB,OAAO,CAAC,MAAM,CAAe;IAC7B,OAAO,CAAC,YAAY,CAAgB;IAEpC;;;;;OAKG;gBACS,MAAM,EAAE,aAAa,EAAE,WAAW,CAAC,EAAE,kBAAkB;IAcnE;;;;;OAKG;IACU,aAAa,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC;IAoB1E;;;;;OAKG;WACiB,mBAAmB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC;IAsBlE;;;;;;OAMG;IACU,WAAW,CACtB,KAAK,EAAE,GAAG,EAAE,EACZ,MAAM,EAAE,MAAM,GACb,OAAO,CAAC,UAAU,EAAE,CAAC;IAkCxB;;;;;OAKG;IACU,YAAY,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAI3D;;;;;OAKG;IACU,WAAW,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC;CAqB5D"}
|
|
1
|
+
{"version":3,"file":"storage.d.ts","sourceRoot":"","sources":["../src/storage.ts"],"names":[],"mappings":"AAWA,OAAO,EAAE,UAAU,EAAE,kBAAkB,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAIxE;;GAEG;AACH,qBAAa,aAAa;IACxB,OAAO,CAAC,MAAM,CAAe;IAC7B,OAAO,CAAC,YAAY,CAAgB;IAEpC;;;;;OAKG;gBACS,MAAM,EAAE,aAAa,EAAE,WAAW,CAAC,EAAE,kBAAkB;IAcnE;;;;;OAKG;IACU,aAAa,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC;IAoB1E;;;;;OAKG;WACiB,mBAAmB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC;IAsBlE;;;;;;OAMG;IACU,WAAW,CACtB,KAAK,EAAE,GAAG,EAAE,EACZ,MAAM,EAAE,MAAM,GACb,OAAO,CAAC,UAAU,EAAE,CAAC;IAkCxB;;;;;OAKG;IACU,YAAY,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAI3D;;;;;OAKG;IACU,WAAW,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC;CAqB5D"}
|
package/dist/storage.js
CHANGED
|
@@ -34,6 +34,9 @@ const Minio = __importStar(require("minio"));
|
|
|
34
34
|
const error_1 = require("./error");
|
|
35
35
|
const utils_1 = require("./utils");
|
|
36
36
|
const constants_1 = require("./constants");
|
|
37
|
+
/**
|
|
38
|
+
* @deprecated StorageClient is deprecated. Use Minio.Client directly.
|
|
39
|
+
*/
|
|
37
40
|
class StorageClient {
|
|
38
41
|
/**
|
|
39
42
|
* **Storage client constructor**
|
package/dist/types.d.ts
CHANGED
|
@@ -32,6 +32,7 @@ export declare enum EscrowStatus {
|
|
|
32
32
|
/**
|
|
33
33
|
* AWS/GCP cloud storage access data
|
|
34
34
|
* @readonly
|
|
35
|
+
* @deprecated StorageClient is deprecated. Use Minio.Client directly.
|
|
35
36
|
*/
|
|
36
37
|
export type StorageCredentials = {
|
|
37
38
|
/**
|
|
@@ -43,6 +44,9 @@ export type StorageCredentials = {
|
|
|
43
44
|
*/
|
|
44
45
|
secretKey: string;
|
|
45
46
|
};
|
|
47
|
+
/**
|
|
48
|
+
* @deprecated StorageClient is deprecated. Use Minio.Client directly.
|
|
49
|
+
*/
|
|
46
50
|
export type StorageParams = {
|
|
47
51
|
/**
|
|
48
52
|
* Request endPoint
|
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
|
|
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;IACH,SAAS,EAAE,MAAM,CAAC;IAClB;;OAEG;IACH,SAAS,EAAE,MAAM,CAAC;CACnB,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,aAAa,GAAG;IAC1B;;OAEG;IACH,QAAQ,EAAE,MAAM,CAAC;IACjB;;OAEG;IACH,MAAM,EAAE,OAAO,CAAC;IAChB;;OAEG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;OAEG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;CACf,CAAC;AAEF;;;GAGG;AACH,MAAM,MAAM,UAAU,GAAG;IACvB;;OAEG;IACH,GAAG,EAAE,MAAM,CAAC;IACZ;;OAEG;IACH,GAAG,EAAE,MAAM,CAAC;IACZ;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;CACd,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,WAAW,GAAG;IACxB;;OAEG;IACH,OAAO,EAAE,MAAM,CAAC;IAChB;;OAEG;IACH,KAAK,EAAE,MAAM,CAAC;IACd;;OAEG;IACH,OAAO,EAAE,MAAM,CAAC;IAChB;;OAEG;IACH,UAAU,EAAE,MAAM,CAAC;IACnB;;OAEG;IACH,cAAc,EAAE,MAAM,CAAC;IACvB;;OAEG;IACH,cAAc,EAAE,MAAM,CAAC;IACvB;;OAEG;IACH,iBAAiB,EAAE,MAAM,CAAC;IAC1B;;OAEG;IACH,cAAc,EAAE,MAAM,CAAC;IACvB;;OAEG;IACH,WAAW,EAAE,MAAM,CAAC;IACpB;;OAEG;IACH,cAAc,EAAE,MAAM,CAAC;IACvB;;OAEG;IACH,iBAAiB,EAAE,MAAM,CAAC;CAC3B,CAAC"}
|
package/package.json
CHANGED
package/src/error.ts
CHANGED
|
@@ -75,6 +75,13 @@ export const ErrorInvalidReputationOracleAddressProvided = new Error(
|
|
|
75
75
|
'Invalid reputation oracle address provided'
|
|
76
76
|
);
|
|
77
77
|
|
|
78
|
+
/**
|
|
79
|
+
* @constant {Error} - Invalid reputation oracle address provided.
|
|
80
|
+
*/
|
|
81
|
+
export const ErrorInvalidExchangeOracleAddressProvided = new Error(
|
|
82
|
+
'Invalid exchange oracle address provided'
|
|
83
|
+
);
|
|
84
|
+
|
|
78
85
|
/**
|
|
79
86
|
* @constant {Error} - The Staking value must be positive.
|
|
80
87
|
*/
|