@human-protocol/sdk 4.2.0 → 5.0.0-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/constants.js +4 -4
- package/dist/error.d.ts +16 -4
- package/dist/error.d.ts.map +1 -1
- package/dist/error.js +18 -6
- package/dist/escrow.d.ts +238 -28
- package/dist/escrow.d.ts.map +1 -1
- package/dist/escrow.js +255 -152
- package/dist/graphql/queries/escrow.d.ts +3 -1
- package/dist/graphql/queries/escrow.d.ts.map +1 -1
- package/dist/graphql/queries/escrow.js +49 -1
- package/dist/graphql/queries/operator.d.ts.map +1 -1
- package/dist/graphql/queries/operator.js +11 -9
- 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 +71 -0
- 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 +56 -16
- package/dist/interfaces.d.ts.map +1 -1
- package/dist/operator.d.ts.map +1 -1
- package/dist/operator.js +53 -58
- package/dist/staking.d.ts +21 -1
- package/dist/staking.d.ts.map +1 -1
- package/dist/staking.js +84 -1
- package/dist/types.d.ts +39 -15
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +4 -0
- package/package.json +2 -2
- package/src/constants.ts +4 -4
- package/src/error.ts +25 -7
- package/src/escrow.ts +416 -113
- package/src/graphql/queries/escrow.ts +52 -1
- package/src/graphql/queries/operator.ts +11 -9
- package/src/graphql/queries/staking.ts +80 -0
- package/src/index.ts +2 -1
- package/src/interfaces.ts +63 -18
- package/src/operator.ts +62 -76
- package/src/staking.ts +106 -3
- package/src/types.ts +40 -15
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.GET_STATUS_UPDATES_QUERY = exports.GET_ESCROWS_QUERY = exports.GET_ESCROW_BY_ADDRESS_QUERY = void 0;
|
|
6
|
+
exports.GET_CANCELLATION_REFUND_BY_ADDRESS_QUERY = exports.GET_CANCELLATION_REFUNDS_QUERY = exports.GET_STATUS_UPDATES_QUERY = exports.GET_ESCROWS_QUERY = exports.GET_ESCROW_BY_ADDRESS_QUERY = void 0;
|
|
7
7
|
const graphql_tag_1 = __importDefault(require("graphql-tag"));
|
|
8
8
|
const ESCROW_FRAGMENT = (0, graphql_tag_1.default) `
|
|
9
9
|
fragment EscrowFields on Escrow {
|
|
@@ -28,6 +28,17 @@ const ESCROW_FRAGMENT = (0, graphql_tag_1.default) `
|
|
|
28
28
|
createdAt
|
|
29
29
|
}
|
|
30
30
|
`;
|
|
31
|
+
const CANCELLATION_REFUND_FRAGMENT = (0, graphql_tag_1.default) `
|
|
32
|
+
fragment CancellationRefundFields on CancellationRefundEvent {
|
|
33
|
+
id
|
|
34
|
+
escrowAddress
|
|
35
|
+
receiver
|
|
36
|
+
amount
|
|
37
|
+
block
|
|
38
|
+
timestamp
|
|
39
|
+
txHash
|
|
40
|
+
}
|
|
41
|
+
`;
|
|
31
42
|
const GET_ESCROW_BY_ADDRESS_QUERY = () => (0, graphql_tag_1.default) `
|
|
32
43
|
query getEscrowByAddress($escrowAddress: String!) {
|
|
33
44
|
escrow(id: $escrowAddress) {
|
|
@@ -113,3 +124,40 @@ const GET_STATUS_UPDATES_QUERY = (from, to, launcher) => {
|
|
|
113
124
|
`;
|
|
114
125
|
};
|
|
115
126
|
exports.GET_STATUS_UPDATES_QUERY = GET_STATUS_UPDATES_QUERY;
|
|
127
|
+
const GET_CANCELLATION_REFUNDS_QUERY = (filter) => (0, graphql_tag_1.default) `
|
|
128
|
+
query CancellationRefundEvents(
|
|
129
|
+
$escrowAddress: Bytes
|
|
130
|
+
$receiver: Bytes
|
|
131
|
+
$from: Int
|
|
132
|
+
$to: Int
|
|
133
|
+
$first: Int
|
|
134
|
+
$skip: Int
|
|
135
|
+
$orderDirection: OrderDirection
|
|
136
|
+
) {
|
|
137
|
+
cancellationRefundEvents(
|
|
138
|
+
where: {
|
|
139
|
+
${filter.escrowAddress ? 'escrowAddress: $escrowAddress' : ''}
|
|
140
|
+
${filter.receiver ? 'receiver: $receiver' : ''}
|
|
141
|
+
${filter.from ? 'timestamp_gte: $from' : ''}
|
|
142
|
+
${filter.to ? 'timestamp_lte: $to' : ''}
|
|
143
|
+
}
|
|
144
|
+
first: $first
|
|
145
|
+
skip: $skip
|
|
146
|
+
orderBy: timestamp
|
|
147
|
+
orderDirection: $orderDirection
|
|
148
|
+
) {
|
|
149
|
+
...CancellationRefundFields
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
${CANCELLATION_REFUND_FRAGMENT}
|
|
153
|
+
`;
|
|
154
|
+
exports.GET_CANCELLATION_REFUNDS_QUERY = GET_CANCELLATION_REFUNDS_QUERY;
|
|
155
|
+
const GET_CANCELLATION_REFUND_BY_ADDRESS_QUERY = () => (0, graphql_tag_1.default) `
|
|
156
|
+
query getCancellationRefundByAddress($escrowAddress: String!) {
|
|
157
|
+
cancellationRefundEvents(where: { escrowAddress: $escrowAddress }) {
|
|
158
|
+
...CancellationRefundFields
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
${CANCELLATION_REFUND_FRAGMENT}
|
|
162
|
+
`;
|
|
163
|
+
exports.GET_CANCELLATION_REFUND_BY_ADDRESS_QUERY = GET_CANCELLATION_REFUND_BY_ADDRESS_QUERY;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"operator.d.ts","sourceRoot":"","sources":["../../../src/graphql/queries/operator.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"operator.d.ts","sourceRoot":"","sources":["../../../src/graphql/queries/operator.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AA8BlD,eAAO,MAAM,iBAAiB,GAAI,QAAQ,gBAAgB,mCA+BzD,CAAC;AAEF,eAAO,MAAM,4BAA4B,GAAI,OAAO,MAAM,mCAsBzD,CAAC;AAEF,eAAO,MAAM,gBAAgB,gCAO5B,CAAC"}
|
|
@@ -9,12 +9,6 @@ const LEADER_FRAGMENT = (0, graphql_tag_1.default) `
|
|
|
9
9
|
fragment OperatorFields on Operator {
|
|
10
10
|
id
|
|
11
11
|
address
|
|
12
|
-
amountStaked
|
|
13
|
-
amountLocked
|
|
14
|
-
lockedUntilTimestamp
|
|
15
|
-
amountWithdrawn
|
|
16
|
-
amountSlashed
|
|
17
|
-
reward
|
|
18
12
|
amountJobsProcessed
|
|
19
13
|
role
|
|
20
14
|
fee
|
|
@@ -28,19 +22,27 @@ const LEADER_FRAGMENT = (0, graphql_tag_1.default) `
|
|
|
28
22
|
reputationNetworks
|
|
29
23
|
name
|
|
30
24
|
category
|
|
25
|
+
staker {
|
|
26
|
+
stakedAmount
|
|
27
|
+
lockedAmount
|
|
28
|
+
withdrawnAmount
|
|
29
|
+
slashedAmount
|
|
30
|
+
lockedUntilTimestamp
|
|
31
|
+
lastDepositTimestamp
|
|
32
|
+
}
|
|
31
33
|
}
|
|
32
34
|
`;
|
|
33
35
|
const GET_LEADERS_QUERY = (filter) => {
|
|
34
|
-
const { roles,
|
|
36
|
+
const { roles, minStakedAmount } = filter;
|
|
35
37
|
const WHERE_CLAUSE = `
|
|
36
38
|
where: {
|
|
37
|
-
${
|
|
39
|
+
${minStakedAmount ? `staker_: { stakedAmount_gte: $minStakedAmount }` : ''}
|
|
38
40
|
${roles ? `role_in: $roles` : ''}
|
|
39
41
|
}
|
|
40
42
|
`;
|
|
41
43
|
return (0, graphql_tag_1.default) `
|
|
42
44
|
query getOperators(
|
|
43
|
-
$
|
|
45
|
+
$minStakedAmount: Int,
|
|
44
46
|
$roles: [String!]
|
|
45
47
|
$first: Int
|
|
46
48
|
$skip: Int
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { IStakersFilter } from '../../interfaces';
|
|
2
|
+
export declare const GET_STAKERS_QUERY: (filter: IStakersFilter) => import("graphql").DocumentNode;
|
|
3
|
+
export declare const GET_STAKER_BY_ADDRESS_QUERY: import("graphql").DocumentNode;
|
|
4
|
+
//# sourceMappingURL=staking.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"staking.d.ts","sourceRoot":"","sources":["../../../src/graphql/queries/staking.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAelD,eAAO,MAAM,iBAAiB,GAAI,QAAQ,cAAc,mCAsDvD,CAAC;AAEF,eAAO,MAAM,2BAA2B,gCAOvC,CAAC"}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.GET_STAKER_BY_ADDRESS_QUERY = exports.GET_STAKERS_QUERY = void 0;
|
|
7
|
+
const graphql_tag_1 = __importDefault(require("graphql-tag"));
|
|
8
|
+
const STAKER_FRAGMENT = (0, graphql_tag_1.default) `
|
|
9
|
+
fragment StakerFields on Staker {
|
|
10
|
+
id
|
|
11
|
+
address
|
|
12
|
+
stakedAmount
|
|
13
|
+
lockedAmount
|
|
14
|
+
withdrawnAmount
|
|
15
|
+
slashedAmount
|
|
16
|
+
lockedUntilTimestamp
|
|
17
|
+
lastDepositTimestamp
|
|
18
|
+
}
|
|
19
|
+
`;
|
|
20
|
+
const GET_STAKERS_QUERY = (filter) => {
|
|
21
|
+
const { minStakedAmount, maxStakedAmount, minLockedAmount, maxLockedAmount, minWithdrawnAmount, maxWithdrawnAmount, minSlashedAmount, maxSlashedAmount, } = filter;
|
|
22
|
+
const whereFields = [
|
|
23
|
+
minStakedAmount ? `stakedAmount_gte: $minStakedAmount` : '',
|
|
24
|
+
maxStakedAmount ? `stakedAmount_lte: $maxStakedAmount` : '',
|
|
25
|
+
minLockedAmount ? `lockedAmount_gte: $minLockedAmount` : '',
|
|
26
|
+
maxLockedAmount ? `lockedAmount_lte: $maxLockedAmount` : '',
|
|
27
|
+
minWithdrawnAmount ? `withdrawnAmount_gte: $minWithdrawnAmount` : '',
|
|
28
|
+
maxWithdrawnAmount ? `withdrawnAmount_lte: $maxWithdrawnAmount` : '',
|
|
29
|
+
minSlashedAmount ? `slashedAmount_gte: $minSlashedAmount` : '',
|
|
30
|
+
maxSlashedAmount ? `slashedAmount_lte: $maxSlashedAmount` : '',
|
|
31
|
+
].filter(Boolean);
|
|
32
|
+
const WHERE_CLAUSE = whereFields.length
|
|
33
|
+
? `where: { ${whereFields.join(', ')} }`
|
|
34
|
+
: '';
|
|
35
|
+
return (0, graphql_tag_1.default) `
|
|
36
|
+
query getStakers(
|
|
37
|
+
$minStakedAmount: BigInt
|
|
38
|
+
$maxStakedAmount: BigInt
|
|
39
|
+
$minLockedAmount: BigInt
|
|
40
|
+
$maxLockedAmount: BigInt
|
|
41
|
+
$minWithdrawnAmount: BigInt
|
|
42
|
+
$maxWithdrawnAmount: BigInt
|
|
43
|
+
$minSlashedAmount: BigInt
|
|
44
|
+
$maxSlashedAmount: BigInt
|
|
45
|
+
$orderBy: String
|
|
46
|
+
$orderDirection: OrderDirection
|
|
47
|
+
$first: Int
|
|
48
|
+
$skip: Int
|
|
49
|
+
) {
|
|
50
|
+
stakers(
|
|
51
|
+
${WHERE_CLAUSE}
|
|
52
|
+
orderBy: $orderBy
|
|
53
|
+
orderDirection: $orderDirection
|
|
54
|
+
first: $first
|
|
55
|
+
skip: $skip
|
|
56
|
+
) {
|
|
57
|
+
...StakerFields
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
${STAKER_FRAGMENT}
|
|
61
|
+
`;
|
|
62
|
+
};
|
|
63
|
+
exports.GET_STAKERS_QUERY = GET_STAKERS_QUERY;
|
|
64
|
+
exports.GET_STAKER_BY_ADDRESS_QUERY = (0, graphql_tag_1.default) `
|
|
65
|
+
query getStaker($id: String!) {
|
|
66
|
+
staker(id: $id) {
|
|
67
|
+
...StakerFields
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
${STAKER_FRAGMENT}
|
|
71
|
+
`;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { StakingClient } from './staking';
|
|
1
|
+
import { StakingClient, StakingUtils } from './staking';
|
|
2
2
|
import { StorageClient } from './storage';
|
|
3
3
|
import { KVStoreClient, KVStoreUtils } from './kvstore';
|
|
4
4
|
import { EscrowClient, EscrowUtils } from './escrow';
|
|
@@ -11,5 +11,5 @@ export * from './constants';
|
|
|
11
11
|
export * from './types';
|
|
12
12
|
export * from './enums';
|
|
13
13
|
export * from './interfaces';
|
|
14
|
-
export { StakingClient, StorageClient, KVStoreClient, KVStoreUtils, EscrowClient, EscrowUtils, StatisticsClient, Encryption, EncryptionUtils, OperatorUtils, TransactionUtils, WorkerUtils, };
|
|
14
|
+
export { StakingClient, StorageClient, KVStoreClient, KVStoreUtils, EscrowClient, EscrowUtils, StatisticsClient, Encryption, EncryptionUtils, OperatorUtils, TransactionUtils, WorkerUtils, StakingUtils, };
|
|
15
15
|
//# 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;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AACxD,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AACxD,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AACrD,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAChD,OAAO,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAC3D,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAC3C,OAAO,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AACjD,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAEvC,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,YAAY,EACZ,WAAW,EACX,gBAAgB,EAChB,UAAU,EACV,eAAe,EACf,aAAa,EACb,gBAAgB,EAChB,WAAW,EACX,YAAY,GACb,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -14,9 +14,10 @@ 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.WorkerUtils = exports.TransactionUtils = exports.OperatorUtils = exports.EncryptionUtils = exports.Encryption = exports.StatisticsClient = exports.EscrowUtils = exports.EscrowClient = exports.KVStoreUtils = exports.KVStoreClient = exports.StorageClient = exports.StakingClient = void 0;
|
|
17
|
+
exports.StakingUtils = exports.WorkerUtils = exports.TransactionUtils = exports.OperatorUtils = exports.EncryptionUtils = exports.Encryption = exports.StatisticsClient = exports.EscrowUtils = exports.EscrowClient = exports.KVStoreUtils = 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
|
+
Object.defineProperty(exports, "StakingUtils", { enumerable: true, get: function () { return staking_1.StakingUtils; } });
|
|
20
21
|
const storage_1 = require("./storage");
|
|
21
22
|
Object.defineProperty(exports, "StorageClient", { enumerable: true, get: function () { return storage_1.StorageClient; } });
|
|
22
23
|
const kvstore_1 = require("./kvstore");
|
package/dist/interfaces.d.ts
CHANGED
|
@@ -8,12 +8,11 @@ export interface IOperator {
|
|
|
8
8
|
id: string;
|
|
9
9
|
chainId: ChainId;
|
|
10
10
|
address: string;
|
|
11
|
-
|
|
12
|
-
|
|
11
|
+
stakedAmount: bigint;
|
|
12
|
+
lockedAmount: bigint;
|
|
13
13
|
lockedUntilTimestamp: bigint;
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
reward: bigint;
|
|
14
|
+
withdrawnAmount: bigint;
|
|
15
|
+
slashedAmount: bigint;
|
|
17
16
|
amountJobsProcessed: bigint;
|
|
18
17
|
role?: string;
|
|
19
18
|
fee?: bigint;
|
|
@@ -28,16 +27,37 @@ export interface IOperator {
|
|
|
28
27
|
name?: string;
|
|
29
28
|
category?: string;
|
|
30
29
|
}
|
|
31
|
-
export interface IOperatorSubgraph
|
|
32
|
-
|
|
30
|
+
export interface IOperatorSubgraph {
|
|
31
|
+
id: string;
|
|
32
|
+
address: string;
|
|
33
|
+
amountJobsProcessed: bigint;
|
|
34
|
+
role?: string;
|
|
35
|
+
fee?: bigint;
|
|
36
|
+
publicKey?: string;
|
|
37
|
+
webhookUrl?: string;
|
|
38
|
+
website?: string;
|
|
39
|
+
url?: string;
|
|
40
|
+
registrationNeeded?: boolean;
|
|
41
|
+
registrationInstructions?: string;
|
|
42
|
+
name?: string;
|
|
43
|
+
category?: string;
|
|
44
|
+
jobTypes?: string | string[];
|
|
33
45
|
reputationNetworks?: {
|
|
34
46
|
address: string;
|
|
35
47
|
}[];
|
|
48
|
+
staker?: {
|
|
49
|
+
stakedAmount: bigint;
|
|
50
|
+
lockedAmount: bigint;
|
|
51
|
+
lockedUntilTimestamp: bigint;
|
|
52
|
+
withdrawnAmount: bigint;
|
|
53
|
+
slashedAmount: bigint;
|
|
54
|
+
lastDepositTimestamp: bigint;
|
|
55
|
+
};
|
|
36
56
|
}
|
|
37
57
|
export interface IOperatorsFilter extends IPagination {
|
|
38
58
|
chainId: ChainId;
|
|
39
59
|
roles?: string[];
|
|
40
|
-
|
|
60
|
+
minStakedAmount?: number;
|
|
41
61
|
orderBy?: string;
|
|
42
62
|
}
|
|
43
63
|
export interface IReputationNetwork {
|
|
@@ -48,14 +68,6 @@ export interface IReputationNetwork {
|
|
|
48
68
|
export interface IReputationNetworkSubgraph extends Omit<IReputationNetwork, 'operators'> {
|
|
49
69
|
operators: IOperatorSubgraph[];
|
|
50
70
|
}
|
|
51
|
-
export interface IOperator {
|
|
52
|
-
address: string;
|
|
53
|
-
role?: string;
|
|
54
|
-
url?: string;
|
|
55
|
-
jobTypes?: string[];
|
|
56
|
-
registrationNeeded?: boolean;
|
|
57
|
-
registrationInstructions?: string;
|
|
58
|
-
}
|
|
59
71
|
export interface IEscrow {
|
|
60
72
|
id: string;
|
|
61
73
|
address: string;
|
|
@@ -185,4 +197,32 @@ export interface IWorkersFilter extends IPagination {
|
|
|
185
197
|
address?: string;
|
|
186
198
|
orderBy?: string;
|
|
187
199
|
}
|
|
200
|
+
export interface IStaker {
|
|
201
|
+
address: string;
|
|
202
|
+
stakedAmount: bigint;
|
|
203
|
+
lockedAmount: bigint;
|
|
204
|
+
lockedUntil: bigint;
|
|
205
|
+
withdrawableAmount: bigint;
|
|
206
|
+
slashedAmount: bigint;
|
|
207
|
+
lastDepositTimestamp: bigint;
|
|
208
|
+
}
|
|
209
|
+
export interface IStakersFilter extends IPagination {
|
|
210
|
+
chainId: ChainId;
|
|
211
|
+
minStakedAmount?: string;
|
|
212
|
+
maxStakedAmount?: string;
|
|
213
|
+
minLockedAmount?: string;
|
|
214
|
+
maxLockedAmount?: string;
|
|
215
|
+
minWithdrawnAmount?: string;
|
|
216
|
+
maxWithdrawnAmount?: string;
|
|
217
|
+
minSlashedAmount?: string;
|
|
218
|
+
maxSlashedAmount?: string;
|
|
219
|
+
orderBy?: 'stakedAmount' | 'lockedAmount' | 'withdrawnAmount' | 'slashedAmount' | 'lastDepositTimestamp';
|
|
220
|
+
}
|
|
221
|
+
export interface ICancellationRefundFilter extends IPagination {
|
|
222
|
+
chainId: ChainId;
|
|
223
|
+
escrowAddress?: string;
|
|
224
|
+
receiver?: string;
|
|
225
|
+
from?: Date;
|
|
226
|
+
to?: Date;
|
|
227
|
+
}
|
|
188
228
|
//# sourceMappingURL=interfaces.d.ts.map
|
package/dist/interfaces.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"interfaces.d.ts","sourceRoot":"","sources":["../src/interfaces.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,OAAO,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAElD,MAAM,WAAW,OAAO;IACtB,aAAa,EAAE,MAAM,CAAC;IACtB,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,SAAS;IACxB,EAAE,EAAE,MAAM,CAAC;IACX,OAAO,EAAE,OAAO,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,YAAY,EAAE,MAAM,CAAC;IACrB,YAAY,EAAE,MAAM,CAAC;IACrB,oBAAoB,EAAE,MAAM,CAAC;IAC7B,eAAe,EAAE,MAAM,CAAC;IACxB,aAAa,EAAE,MAAM,CAAC;IACtB,
|
|
1
|
+
{"version":3,"file":"interfaces.d.ts","sourceRoot":"","sources":["../src/interfaces.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,E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AM,CAAC;IAC3B,aAAa,EAAE,MAAM,CAAC;IACtB,oBAAoB,EAAE,MAAM,CAAC;CAC9B;AAED,MAAM,WAAW,cAAe,SAAQ,WAAW;IACjD,OAAO,EAAE,OAAO,CAAC;IACjB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,OAAO,CAAC,EACJ,cAAc,GACd,cAAc,GACd,iBAAiB,GACjB,eAAe,GACf,sBAAsB,CAAC;CAC5B;AACD,MAAM,WAAW,yBAA0B,SAAQ,WAAW;IAC5D,OAAO,EAAE,OAAO,CAAC;IACjB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,IAAI,CAAC,EAAE,IAAI,CAAC;IACZ,EAAE,CAAC,EAAE,IAAI,CAAC;CACX"}
|
package/dist/operator.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"operator.d.ts","sourceRoot":"","sources":["../src/operator.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,SAAS,EAET,gBAAgB,EAEhB,OAAO,EACR,MAAM,cAAc,CAAC;AAetB,OAAO,EAAE,OAAO,EAAkB,MAAM,SAAS,CAAC;AAGlD,qBAAa,aAAa;IACxB;;;;;;;;;;;;;;OAcG;WACiB,WAAW,CAC7B,OAAO,EAAE,OAAO,EAChB,OAAO,EAAE,MAAM,GACd,OAAO,CAAC,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"operator.d.ts","sourceRoot":"","sources":["../src/operator.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,SAAS,EAET,gBAAgB,EAEhB,OAAO,EACR,MAAM,cAAc,CAAC;AAetB,OAAO,EAAE,OAAO,EAAkB,MAAM,SAAS,CAAC;AAGlD,qBAAa,aAAa;IACxB;;;;;;;;;;;;;;OAcG;WACiB,WAAW,CAC7B,OAAO,EAAE,OAAO,EAChB,OAAO,EAAE,MAAM,GACd,OAAO,CAAC,SAAS,CAAC;IAuBrB;;;;;;;;;;;;;;;;OAgBG;WACiB,YAAY,CAC9B,MAAM,EAAE,gBAAgB,GACvB,OAAO,CAAC,SAAS,EAAE,CAAC;IA0CvB;;;;;;;;;;;;;;;OAeG;WACiB,6BAA6B,CAC/C,OAAO,EAAE,OAAO,EAChB,OAAO,EAAE,MAAM,EACf,IAAI,CAAC,EAAE,MAAM,GACZ,OAAO,CAAC,SAAS,EAAE,CAAC;IAoBvB;;;;;;;;;;;;;;OAcG;WACiB,UAAU,CAC5B,OAAO,EAAE,OAAO,EAChB,cAAc,EAAE,MAAM,GACrB,OAAO,CAAC,OAAO,EAAE,CAAC;CAyBtB"}
|
package/dist/operator.js
CHANGED
|
@@ -41,26 +41,9 @@ class OperatorUtils {
|
|
|
41
41
|
address: address.toLowerCase(),
|
|
42
42
|
});
|
|
43
43
|
if (!operator) {
|
|
44
|
-
return
|
|
44
|
+
return null;
|
|
45
45
|
}
|
|
46
|
-
|
|
47
|
-
let reputationNetworks = [];
|
|
48
|
-
if (typeof operator.jobTypes === 'string') {
|
|
49
|
-
jobTypes = operator.jobTypes.split(',');
|
|
50
|
-
}
|
|
51
|
-
else if (Array.isArray(operator.jobTypes)) {
|
|
52
|
-
jobTypes = operator.jobTypes;
|
|
53
|
-
}
|
|
54
|
-
if (operator.reputationNetworks &&
|
|
55
|
-
Array.isArray(operator.reputationNetworks)) {
|
|
56
|
-
reputationNetworks = operator.reputationNetworks.map((network) => network.address);
|
|
57
|
-
}
|
|
58
|
-
return {
|
|
59
|
-
...operator,
|
|
60
|
-
jobTypes,
|
|
61
|
-
reputationNetworks,
|
|
62
|
-
chainId,
|
|
63
|
-
};
|
|
46
|
+
return mapOperator(operator, chainId);
|
|
64
47
|
}
|
|
65
48
|
/**
|
|
66
49
|
* This function returns all the operator details of the protocol.
|
|
@@ -80,20 +63,28 @@ class OperatorUtils {
|
|
|
80
63
|
* ```
|
|
81
64
|
*/
|
|
82
65
|
static async getOperators(filter) {
|
|
83
|
-
let operators_data = [];
|
|
84
66
|
const first = filter.first !== undefined && filter.first > 0
|
|
85
67
|
? Math.min(filter.first, 1000)
|
|
86
68
|
: 10;
|
|
87
69
|
const skip = filter.skip !== undefined && filter.skip >= 0 ? filter.skip : 0;
|
|
88
70
|
const orderDirection = filter.orderDirection || enums_1.OrderDirection.DESC;
|
|
71
|
+
let orderBy = filter.orderBy;
|
|
72
|
+
if (filter.orderBy === 'stakedAmount')
|
|
73
|
+
orderBy = 'staker__stakedAmount';
|
|
74
|
+
else if (filter.orderBy === 'lockedAmount')
|
|
75
|
+
orderBy = 'staker__lockedAmount';
|
|
76
|
+
else if (filter.orderBy === 'withdrawnAmount')
|
|
77
|
+
orderBy = 'staker__withdrawnAmount';
|
|
78
|
+
else if (filter.orderBy === 'slashedAmount')
|
|
79
|
+
orderBy = 'staker__slashedAmount';
|
|
89
80
|
const networkData = constants_1.NETWORKS[filter.chainId];
|
|
90
81
|
if (!networkData) {
|
|
91
82
|
throw error_1.ErrorUnsupportedChainID;
|
|
92
83
|
}
|
|
93
84
|
const { operators } = await (0, graphql_request_1.default)((0, utils_1.getSubgraphUrl)(networkData), (0, operator_1.GET_LEADERS_QUERY)(filter), {
|
|
94
|
-
|
|
85
|
+
minStakedAmount: filter?.minStakedAmount,
|
|
95
86
|
roles: filter?.roles,
|
|
96
|
-
orderBy:
|
|
87
|
+
orderBy: orderBy,
|
|
97
88
|
orderDirection: orderDirection,
|
|
98
89
|
first: first,
|
|
99
90
|
skip: skip,
|
|
@@ -101,27 +92,7 @@ class OperatorUtils {
|
|
|
101
92
|
if (!operators) {
|
|
102
93
|
return [];
|
|
103
94
|
}
|
|
104
|
-
|
|
105
|
-
let jobTypes = [];
|
|
106
|
-
let reputationNetworks = [];
|
|
107
|
-
if (typeof operator.jobTypes === 'string') {
|
|
108
|
-
jobTypes = operator.jobTypes.split(',');
|
|
109
|
-
}
|
|
110
|
-
else if (Array.isArray(operator.jobTypes)) {
|
|
111
|
-
jobTypes = operator.jobTypes;
|
|
112
|
-
}
|
|
113
|
-
if (operator.reputationNetworks &&
|
|
114
|
-
Array.isArray(operator.reputationNetworks)) {
|
|
115
|
-
reputationNetworks = operator.reputationNetworks.map((network) => network.address);
|
|
116
|
-
}
|
|
117
|
-
return {
|
|
118
|
-
...operator,
|
|
119
|
-
jobTypes,
|
|
120
|
-
reputationNetworks,
|
|
121
|
-
chainId: filter.chainId,
|
|
122
|
-
};
|
|
123
|
-
}));
|
|
124
|
-
return operators_data;
|
|
95
|
+
return operators.map((operator) => mapOperator(operator, filter.chainId));
|
|
125
96
|
}
|
|
126
97
|
/**
|
|
127
98
|
* Retrieves the reputation network operators of the specified address.
|
|
@@ -150,21 +121,7 @@ class OperatorUtils {
|
|
|
150
121
|
});
|
|
151
122
|
if (!reputationNetwork)
|
|
152
123
|
return [];
|
|
153
|
-
return reputationNetwork.operators.map((operator) =>
|
|
154
|
-
let jobTypes = [];
|
|
155
|
-
if (typeof operator.jobTypes === 'string') {
|
|
156
|
-
jobTypes = operator.jobTypes.split(',');
|
|
157
|
-
}
|
|
158
|
-
else if (Array.isArray(operator.jobTypes)) {
|
|
159
|
-
jobTypes = operator.jobTypes;
|
|
160
|
-
}
|
|
161
|
-
return {
|
|
162
|
-
chainId,
|
|
163
|
-
...operator,
|
|
164
|
-
jobTypes,
|
|
165
|
-
reputationNetworks: operator.reputationNetworks?.map((network) => network.address),
|
|
166
|
-
};
|
|
167
|
-
});
|
|
124
|
+
return reputationNetwork.operators.map((operator) => mapOperator(operator, chainId));
|
|
168
125
|
}
|
|
169
126
|
/**
|
|
170
127
|
* This function returns information about the rewards for a given slasher address.
|
|
@@ -203,3 +160,41 @@ class OperatorUtils {
|
|
|
203
160
|
}
|
|
204
161
|
}
|
|
205
162
|
exports.OperatorUtils = OperatorUtils;
|
|
163
|
+
function mapOperator(operator, chainId) {
|
|
164
|
+
const staker = operator?.staker;
|
|
165
|
+
let jobTypes = [];
|
|
166
|
+
let reputationNetworks = [];
|
|
167
|
+
if (typeof operator.jobTypes === 'string') {
|
|
168
|
+
jobTypes = operator.jobTypes.split(',');
|
|
169
|
+
}
|
|
170
|
+
else if (Array.isArray(operator.jobTypes)) {
|
|
171
|
+
jobTypes = operator.jobTypes;
|
|
172
|
+
}
|
|
173
|
+
if (operator.reputationNetworks &&
|
|
174
|
+
Array.isArray(operator.reputationNetworks)) {
|
|
175
|
+
reputationNetworks = operator.reputationNetworks.map((network) => network.address);
|
|
176
|
+
}
|
|
177
|
+
return {
|
|
178
|
+
id: operator.id,
|
|
179
|
+
chainId,
|
|
180
|
+
address: operator.address,
|
|
181
|
+
stakedAmount: BigInt(staker?.stakedAmount || 0),
|
|
182
|
+
lockedAmount: BigInt(staker?.lockedAmount || 0),
|
|
183
|
+
lockedUntilTimestamp: BigInt(staker?.lockedUntilTimestamp || 0),
|
|
184
|
+
withdrawnAmount: BigInt(staker?.withdrawnAmount || 0),
|
|
185
|
+
slashedAmount: BigInt(staker?.slashedAmount || 0),
|
|
186
|
+
amountJobsProcessed: BigInt(operator.amountJobsProcessed || 0),
|
|
187
|
+
role: operator.role,
|
|
188
|
+
fee: operator.fee ? BigInt(operator.fee) : undefined,
|
|
189
|
+
publicKey: operator.publicKey,
|
|
190
|
+
webhookUrl: operator.webhookUrl,
|
|
191
|
+
website: operator.website,
|
|
192
|
+
url: operator.url,
|
|
193
|
+
jobTypes,
|
|
194
|
+
registrationNeeded: operator.registrationNeeded,
|
|
195
|
+
registrationInstructions: operator.registrationInstructions,
|
|
196
|
+
reputationNetworks,
|
|
197
|
+
name: operator.name,
|
|
198
|
+
category: operator.category,
|
|
199
|
+
};
|
|
200
|
+
}
|
package/dist/staking.d.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { EscrowFactory, HMToken, Staking } from '@human-protocol/core/typechain-types';
|
|
2
2
|
import { ContractRunner, Overrides } from 'ethers';
|
|
3
3
|
import { BaseEthersClient } from './base';
|
|
4
|
+
import { ChainId } from './enums';
|
|
5
|
+
import { IStaker, IStakersFilter, StakerInfo } from './interfaces';
|
|
4
6
|
import { NetworkData } from './types';
|
|
5
|
-
import { StakerInfo } from './interfaces';
|
|
6
7
|
/**
|
|
7
8
|
* ## Introduction
|
|
8
9
|
*
|
|
@@ -254,4 +255,23 @@ export declare class StakingClient extends BaseEthersClient {
|
|
|
254
255
|
*/
|
|
255
256
|
getStakerInfo(stakerAddress: string): Promise<StakerInfo>;
|
|
256
257
|
}
|
|
258
|
+
/**
|
|
259
|
+
* Utility class for Staking-related subgraph queries.
|
|
260
|
+
*/
|
|
261
|
+
export declare class StakingUtils {
|
|
262
|
+
/**
|
|
263
|
+
* Gets staking info for a staker from the subgraph.
|
|
264
|
+
*
|
|
265
|
+
* @param {ChainId} chainId Network in which the staking contract is deployed
|
|
266
|
+
* @param {string} stakerAddress Address of the staker
|
|
267
|
+
* @returns {Promise<IStaker>} Staker info from subgraph
|
|
268
|
+
*/
|
|
269
|
+
static getStaker(chainId: ChainId, stakerAddress: string): Promise<IStaker>;
|
|
270
|
+
/**
|
|
271
|
+
* Gets all stakers from the subgraph with filters, pagination and ordering.
|
|
272
|
+
*
|
|
273
|
+
* @returns {Promise<IStaker[]>} Array of stakers
|
|
274
|
+
*/
|
|
275
|
+
static getStakers(filter: IStakersFilter): Promise<IStaker[]>;
|
|
276
|
+
}
|
|
257
277
|
//# sourceMappingURL=staking.d.ts.map
|
package/dist/staking.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"staking.d.ts","sourceRoot":"","sources":["../src/staking.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,aA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