@human-protocol/sdk 4.0.1 → 4.0.3-beta
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 +8 -8
- package/dist/constants.js +18 -18
- package/dist/enums.d.ts +1 -1
- package/dist/enums.d.ts.map +1 -1
- package/dist/enums.js +6 -6
- package/dist/graphql/queries/operator.d.ts +2 -2
- package/dist/graphql/queries/operator.d.ts.map +1 -1
- package/dist/graphql/queries/operator.js +9 -13
- package/dist/interfaces.d.ts +3 -6
- package/dist/interfaces.d.ts.map +1 -1
- package/dist/operator.d.ts +13 -13
- package/dist/operator.d.ts.map +1 -1
- package/dist/operator.js +38 -35
- package/package.json +1 -1
- package/src/constants.ts +18 -18
- package/src/enums.ts +1 -1
- package/src/graphql/queries/operator.ts +11 -15
- package/src/interfaces.ts +4 -8
- package/src/operator.ts +50 -42
package/dist/constants.d.ts
CHANGED
|
@@ -19,18 +19,18 @@ export declare const NETWORKS: {
|
|
|
19
19
|
[chainId in ChainId]?: NetworkData;
|
|
20
20
|
};
|
|
21
21
|
export declare const KVStoreKeys: {
|
|
22
|
-
|
|
22
|
+
category: string;
|
|
23
23
|
fee: string;
|
|
24
|
+
jobTypes: string;
|
|
25
|
+
operatorName: string;
|
|
24
26
|
publicKey: string;
|
|
25
27
|
publicKeyHash: string;
|
|
26
|
-
webhookUrl: string;
|
|
27
|
-
website: string;
|
|
28
|
-
url: string;
|
|
29
|
-
jobTypes: string;
|
|
30
|
-
registrationNeeded: string;
|
|
31
28
|
registrationInstructions: string;
|
|
32
|
-
|
|
33
|
-
|
|
29
|
+
registrationNeeded: string;
|
|
30
|
+
role: string;
|
|
31
|
+
url: string;
|
|
32
|
+
website: string;
|
|
33
|
+
webhookUrl: string;
|
|
34
34
|
};
|
|
35
35
|
export declare const Role: {
|
|
36
36
|
JobLauncher: string;
|
package/dist/constants.js
CHANGED
|
@@ -28,7 +28,7 @@ exports.NETWORKS = {
|
|
|
28
28
|
stakingAddress: '0xEf6Da3aB52c33925Be3F84038193a7e1331F51E6',
|
|
29
29
|
kvstoreAddress: '0xB6d36B1CDaD50302BCB3DB43bAb0D349458e1b8D',
|
|
30
30
|
subgraphUrl: 'https://api.studio.thegraph.com/query/74256/ethereum/version/latest',
|
|
31
|
-
subgraphUrlApiKey: 'https://gateway-arbitrum.network.thegraph.com/api/[SUBGRAPH_API_KEY]/deployments/id/
|
|
31
|
+
subgraphUrlApiKey: 'https://gateway-arbitrum.network.thegraph.com/api/[SUBGRAPH_API_KEY]/deployments/id/QmawHPbwEhAvmWgHQUH9Qgx5AqrXmq1uhfj69CGv9LLzNb',
|
|
32
32
|
oldSubgraphUrl: '',
|
|
33
33
|
oldFactoryAddress: '',
|
|
34
34
|
},
|
|
@@ -41,7 +41,7 @@ exports.NETWORKS = {
|
|
|
41
41
|
stakingAddress: '0x2163e3A40032Af1C359ac731deaB48258b317890',
|
|
42
42
|
kvstoreAddress: '0xCc0AF0635aa19fE799B6aFDBe28fcFAeA7f00a60',
|
|
43
43
|
subgraphUrl: 'https://api.studio.thegraph.com/query/74256/sepolia/version/latest',
|
|
44
|
-
subgraphUrlApiKey: 'https://gateway-arbitrum.network.thegraph.com/api/[SUBGRAPH_API_KEY]/deployments/id/
|
|
44
|
+
subgraphUrlApiKey: 'https://gateway-arbitrum.network.thegraph.com/api/[SUBGRAPH_API_KEY]/deployments/id/QmYx4iD24iBTBgxhK95WV4u4o4QSFQFJxuvSNwwSEvCMsE',
|
|
45
45
|
oldSubgraphUrl: '',
|
|
46
46
|
oldFactoryAddress: '',
|
|
47
47
|
},
|
|
@@ -54,7 +54,7 @@ exports.NETWORKS = {
|
|
|
54
54
|
stakingAddress: '0xE24e5C08E28331D24758b69A5E9f383D2bDD1c98',
|
|
55
55
|
kvstoreAddress: '0x21A0C4CED7aE447fCf87D9FE3A29FA9B3AB20Ff1',
|
|
56
56
|
subgraphUrl: 'https://api.studio.thegraph.com/query/74256/bsc/version/latest',
|
|
57
|
-
subgraphUrlApiKey: 'https://gateway-arbitrum.network.thegraph.com/api/[SUBGRAPH_API_KEY]/deployments/id/
|
|
57
|
+
subgraphUrlApiKey: 'https://gateway-arbitrum.network.thegraph.com/api/[SUBGRAPH_API_KEY]/deployments/id/Qmai26kHVvYnn59QzGyBAfVWTQ98utfA2bJxQTMV2NeU8K',
|
|
58
58
|
oldSubgraphUrl: 'https://api.thegraph.com/subgraphs/name/humanprotocol/bsc',
|
|
59
59
|
oldFactoryAddress: '0xc88bC422cAAb2ac8812de03176402dbcA09533f4',
|
|
60
60
|
},
|
|
@@ -67,7 +67,7 @@ exports.NETWORKS = {
|
|
|
67
67
|
stakingAddress: '0xD6D347ba6987519B4e42EcED43dF98eFf5465a23',
|
|
68
68
|
kvstoreAddress: '0x32e27177BA6Ea91cf28dfd91a0Da9822A4b74EcF',
|
|
69
69
|
subgraphUrl: 'https://api.studio.thegraph.com/query/74256/bsc-testnet/version/latest',
|
|
70
|
-
subgraphUrlApiKey: 'https://gateway-arbitrum.network.thegraph.com/api/[SUBGRAPH_API_KEY]/deployments/id/
|
|
70
|
+
subgraphUrlApiKey: 'https://gateway-arbitrum.network.thegraph.com/api/[SUBGRAPH_API_KEY]/deployments/id/QmbPzZWJMqCzdc6ZJir1Z2Va5mpLo8haGxAkfMySwfGxqs',
|
|
71
71
|
oldSubgraphUrl: 'https://api.thegraph.com/subgraphs/name/humanprotocol/bsctest',
|
|
72
72
|
oldFactoryAddress: '0xaae6a2646c1f88763e62e0cd08ad050ea66ac46f',
|
|
73
73
|
},
|
|
@@ -80,7 +80,7 @@ exports.NETWORKS = {
|
|
|
80
80
|
stakingAddress: '0x01D115E9E8bF0C58318793624CC662a030D07F1D',
|
|
81
81
|
kvstoreAddress: '0xbcB28672F826a50B03EE91B28145EAbddA73B2eD',
|
|
82
82
|
subgraphUrl: 'https://api.studio.thegraph.com/query/74256/polygon/version/latest',
|
|
83
|
-
subgraphUrlApiKey: 'https://gateway-arbitrum.network.thegraph.com/api/[SUBGRAPH_API_KEY]/deployments/id/
|
|
83
|
+
subgraphUrlApiKey: 'https://gateway-arbitrum.network.thegraph.com/api/[SUBGRAPH_API_KEY]/deployments/id/QmSyLqu2injQHCrMg68Wvp6n39J5piCDQkwHGWhKBqxhvV',
|
|
84
84
|
oldSubgraphUrl: 'https://api.thegraph.com/subgraphs/name/humanprotocol/polygon',
|
|
85
85
|
oldFactoryAddress: '0x45eBc3eAE6DA485097054ae10BA1A0f8e8c7f794',
|
|
86
86
|
},
|
|
@@ -93,7 +93,7 @@ exports.NETWORKS = {
|
|
|
93
93
|
stakingAddress: '0xffE496683F842a923110415b7278ded3F265f2C5',
|
|
94
94
|
kvstoreAddress: '0x724AeFC243EdacCA27EAB86D3ec5a76Af4436Fc7',
|
|
95
95
|
subgraphUrl: 'https://api.studio.thegraph.com/query/74256/amoy/version/latest',
|
|
96
|
-
subgraphUrlApiKey: 'https://gateway-arbitrum.network.thegraph.com/api/[SUBGRAPH_API_KEY]/deployments/id/
|
|
96
|
+
subgraphUrlApiKey: 'https://gateway-arbitrum.network.thegraph.com/api/[SUBGRAPH_API_KEY]/deployments/id/QmYtZEaay5cX5XwGmoN8NpwfpFMbyqiKvtA1ub4GvavH2P',
|
|
97
97
|
oldSubgraphUrl: '',
|
|
98
98
|
oldFactoryAddress: '',
|
|
99
99
|
},
|
|
@@ -112,24 +112,24 @@ exports.NETWORKS = {
|
|
|
112
112
|
},
|
|
113
113
|
};
|
|
114
114
|
exports.KVStoreKeys = {
|
|
115
|
-
|
|
115
|
+
category: 'category',
|
|
116
116
|
fee: 'fee',
|
|
117
|
+
jobTypes: 'job_types',
|
|
118
|
+
operatorName: 'name',
|
|
117
119
|
publicKey: 'public_key',
|
|
118
120
|
publicKeyHash: 'public_key_hash',
|
|
119
|
-
webhookUrl: 'webhook_url',
|
|
120
|
-
website: 'website',
|
|
121
|
-
url: 'url',
|
|
122
|
-
jobTypes: 'job_types',
|
|
123
|
-
registrationNeeded: 'registration_needed',
|
|
124
121
|
registrationInstructions: 'registration_instructions',
|
|
125
|
-
|
|
126
|
-
|
|
122
|
+
registrationNeeded: 'registration_needed',
|
|
123
|
+
role: 'role',
|
|
124
|
+
url: 'url',
|
|
125
|
+
website: 'website',
|
|
126
|
+
webhookUrl: 'webhook_url',
|
|
127
127
|
};
|
|
128
128
|
exports.Role = {
|
|
129
|
-
JobLauncher: '
|
|
130
|
-
ExchangeOracle: '
|
|
131
|
-
ReputationOracle: '
|
|
132
|
-
RecordingOracle: '
|
|
129
|
+
JobLauncher: 'job_launcher',
|
|
130
|
+
ExchangeOracle: 'exchange_oracle',
|
|
131
|
+
ReputationOracle: 'reputation_oracle',
|
|
132
|
+
RecordingOracle: 'recording_oracle',
|
|
133
133
|
};
|
|
134
134
|
exports.SUBGRAPH_API_KEY_PLACEHOLDER = '[SUBGRAPH_API_KEY]';
|
|
135
135
|
exports.ESCROW_BULK_PAYOUT_MAX_ITEMS = 99;
|
package/dist/enums.d.ts
CHANGED
package/dist/enums.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"enums.d.ts","sourceRoot":"","sources":["../src/enums.ts"],"names":[],"mappings":"AAAA,oBAAY,OAAO;IACjB,GAAG,KAAK;IACR,OAAO,IAAI;IACX,OAAO,WAAW;IAClB,WAAW,KAAK;IAChB,WAAW,KAAK;IAChB,OAAO,MAAM;IACb,YAAY,QAAQ;IACpB,SAAS,OAAO;CACjB;AAED,oBAAY,cAAc;IACxB,GAAG,QAAQ;IACX,IAAI,SAAS;CACd;AAED,oBAAY,
|
|
1
|
+
{"version":3,"file":"enums.d.ts","sourceRoot":"","sources":["../src/enums.ts"],"names":[],"mappings":"AAAA,oBAAY,OAAO;IACjB,GAAG,KAAK;IACR,OAAO,IAAI;IACX,OAAO,WAAW;IAClB,WAAW,KAAK;IAChB,WAAW,KAAK;IAChB,OAAO,MAAM;IACb,YAAY,QAAQ;IACpB,SAAS,OAAO;CACjB;AAED,oBAAY,cAAc;IACxB,GAAG,QAAQ;IACX,IAAI,SAAS;CACd;AAED,oBAAY,gBAAgB;IAC1B,gBAAgB,qBAAqB;IACrC,aAAa,kBAAkB;CAChC"}
|
package/dist/enums.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.OperatorCategory = exports.OrderDirection = exports.ChainId = void 0;
|
|
4
4
|
var ChainId;
|
|
5
5
|
(function (ChainId) {
|
|
6
6
|
ChainId[ChainId["ALL"] = -1] = "ALL";
|
|
@@ -17,8 +17,8 @@ var OrderDirection;
|
|
|
17
17
|
OrderDirection["ASC"] = "asc";
|
|
18
18
|
OrderDirection["DESC"] = "desc";
|
|
19
19
|
})(OrderDirection || (exports.OrderDirection = OrderDirection = {}));
|
|
20
|
-
var
|
|
21
|
-
(function (
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
})(
|
|
20
|
+
var OperatorCategory;
|
|
21
|
+
(function (OperatorCategory) {
|
|
22
|
+
OperatorCategory["MACHINE_LEARNING"] = "machine_learning";
|
|
23
|
+
OperatorCategory["MARKET_MAKING"] = "market_making";
|
|
24
|
+
})(OperatorCategory || (exports.OperatorCategory = OperatorCategory = {}));
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export declare const GET_LEADERS_QUERY: (filter:
|
|
1
|
+
import { IOperatorsFilter } from 'src/interfaces';
|
|
2
|
+
export declare const GET_LEADERS_QUERY: (filter: IOperatorsFilter) => import("graphql").DocumentNode;
|
|
3
3
|
export declare const GET_REPUTATION_NETWORK_QUERY: (role?: string) => import("graphql").DocumentNode;
|
|
4
4
|
export declare const GET_LEADER_QUERY: import("graphql").DocumentNode;
|
|
5
5
|
//# sourceMappingURL=operator.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"operator.d.ts","sourceRoot":"","sources":["../../../src/graphql/queries/operator.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"operator.d.ts","sourceRoot":"","sources":["../../../src/graphql/queries/operator.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AA4BlD,eAAO,MAAM,iBAAiB,WAAY,gBAAgB,mCA+BzD,CAAC;AAEF,eAAO,MAAM,4BAA4B,UAAW,MAAM,mCAsBzD,CAAC;AAEF,eAAO,MAAM,gBAAgB,gCAO5B,CAAC"}
|
|
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.GET_LEADER_QUERY = exports.GET_REPUTATION_NETWORK_QUERY = exports.GET_LEADERS_QUERY = void 0;
|
|
7
7
|
const graphql_tag_1 = __importDefault(require("graphql-tag"));
|
|
8
8
|
const LEADER_FRAGMENT = (0, graphql_tag_1.default) `
|
|
9
|
-
fragment
|
|
9
|
+
fragment OperatorFields on Operator {
|
|
10
10
|
id
|
|
11
11
|
address
|
|
12
12
|
amountStaked
|
|
@@ -39,7 +39,7 @@ const GET_LEADERS_QUERY = (filter) => {
|
|
|
39
39
|
}
|
|
40
40
|
`;
|
|
41
41
|
return (0, graphql_tag_1.default) `
|
|
42
|
-
query
|
|
42
|
+
query getOperators(
|
|
43
43
|
$minAmountStaked: Int,
|
|
44
44
|
$roles: [String!]
|
|
45
45
|
$first: Int
|
|
@@ -47,14 +47,14 @@ const GET_LEADERS_QUERY = (filter) => {
|
|
|
47
47
|
$orderBy: String
|
|
48
48
|
$orderDirection: String
|
|
49
49
|
) {
|
|
50
|
-
|
|
50
|
+
operators(
|
|
51
51
|
${WHERE_CLAUSE}
|
|
52
52
|
first: $first
|
|
53
53
|
skip: $skip
|
|
54
54
|
orderBy: $orderBy
|
|
55
55
|
orderDirection: $orderDirection
|
|
56
56
|
) {
|
|
57
|
-
...
|
|
57
|
+
...OperatorFields
|
|
58
58
|
}
|
|
59
59
|
}
|
|
60
60
|
${LEADER_FRAGMENT}
|
|
@@ -76,22 +76,18 @@ const GET_REPUTATION_NETWORK_QUERY = (role) => {
|
|
|
76
76
|
operators(
|
|
77
77
|
${WHERE_CLAUSE}
|
|
78
78
|
) {
|
|
79
|
-
|
|
80
|
-
role,
|
|
81
|
-
url,
|
|
82
|
-
jobTypes,
|
|
83
|
-
registrationNeeded,
|
|
84
|
-
registrationInstructions
|
|
79
|
+
...OperatorFields
|
|
85
80
|
}
|
|
86
81
|
}
|
|
87
82
|
}
|
|
83
|
+
${LEADER_FRAGMENT}
|
|
88
84
|
`;
|
|
89
85
|
};
|
|
90
86
|
exports.GET_REPUTATION_NETWORK_QUERY = GET_REPUTATION_NETWORK_QUERY;
|
|
91
87
|
exports.GET_LEADER_QUERY = (0, graphql_tag_1.default) `
|
|
92
|
-
query
|
|
93
|
-
|
|
94
|
-
...
|
|
88
|
+
query getOperator($address: String!) {
|
|
89
|
+
operator(id: $address) {
|
|
90
|
+
...OperatorFields
|
|
95
91
|
}
|
|
96
92
|
}
|
|
97
93
|
${LEADER_FRAGMENT}
|
package/dist/interfaces.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ export interface IReward {
|
|
|
4
4
|
escrowAddress: string;
|
|
5
5
|
amount: bigint;
|
|
6
6
|
}
|
|
7
|
-
export interface
|
|
7
|
+
export interface IOperator {
|
|
8
8
|
id: string;
|
|
9
9
|
chainId: ChainId;
|
|
10
10
|
address: string;
|
|
@@ -28,13 +28,13 @@ export interface ILeader {
|
|
|
28
28
|
name?: string;
|
|
29
29
|
category?: string;
|
|
30
30
|
}
|
|
31
|
-
export interface
|
|
31
|
+
export interface IOperatorSubgraph extends Omit<IOperator, 'jobTypes' | 'reputationNetworks' | 'chainId'> {
|
|
32
32
|
jobTypes?: string;
|
|
33
33
|
reputationNetworks?: {
|
|
34
34
|
address: string;
|
|
35
35
|
}[];
|
|
36
36
|
}
|
|
37
|
-
export interface
|
|
37
|
+
export interface IOperatorsFilter extends IPagination {
|
|
38
38
|
chainId: ChainId;
|
|
39
39
|
roles?: string[];
|
|
40
40
|
minAmountStaked?: number;
|
|
@@ -56,9 +56,6 @@ export interface IOperator {
|
|
|
56
56
|
registrationNeeded?: boolean;
|
|
57
57
|
registrationInstructions?: string;
|
|
58
58
|
}
|
|
59
|
-
export interface IOperatorSubgraph extends Omit<IOperator, 'jobTypes'> {
|
|
60
|
-
jobTypes?: string;
|
|
61
|
-
}
|
|
62
59
|
export interface IEscrowsFilter extends IPagination {
|
|
63
60
|
launcher?: string;
|
|
64
61
|
reputationOracle?: string;
|
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,
|
|
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;IACt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AAC;IACd,cAAc,CAAC,EAAE,cAAc,CAAC;CACjC;AAED,MAAM,WAAW,UAAU;IACzB,YAAY,EAAE,MAAM,CAAC;IACrB,YAAY,EAAE,MAAM,CAAC;IACrB,WAAW,EAAE,MAAM,CAAC;IACpB,kBAAkB,EAAE,MAAM,CAAC;CAC5B"}
|
package/dist/operator.d.ts
CHANGED
|
@@ -1,40 +1,40 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { IOperator, IOperatorsFilter, IReward } from './interfaces';
|
|
2
2
|
import { ChainId } from './enums';
|
|
3
3
|
export declare class OperatorUtils {
|
|
4
4
|
/**
|
|
5
|
-
* This function returns the
|
|
5
|
+
* This function returns the operator data for the given address.
|
|
6
6
|
*
|
|
7
|
-
* @param {ChainId} chainId Network in which the
|
|
8
|
-
* @param {string} address
|
|
9
|
-
* @returns {Promise<
|
|
7
|
+
* @param {ChainId} chainId Network in which the operator is deployed
|
|
8
|
+
* @param {string} address Operator address.
|
|
9
|
+
* @returns {Promise<IOperator>} Returns the operator details.
|
|
10
10
|
*
|
|
11
11
|
* **Code example**
|
|
12
12
|
*
|
|
13
13
|
* ```ts
|
|
14
14
|
* import { OperatorUtils, ChainId } from '@human-protocol/sdk';
|
|
15
15
|
*
|
|
16
|
-
* const
|
|
16
|
+
* const operator = await OperatorUtils.getOperator(ChainId.POLYGON_AMOY, '0x62dD51230A30401C455c8398d06F85e4EaB6309f');
|
|
17
17
|
* ```
|
|
18
18
|
*/
|
|
19
|
-
static
|
|
19
|
+
static getOperator(chainId: ChainId, address: string): Promise<IOperator>;
|
|
20
20
|
/**
|
|
21
|
-
* This function returns all the
|
|
21
|
+
* This function returns all the operator details of the protocol.
|
|
22
22
|
*
|
|
23
|
-
* @param {
|
|
24
|
-
* @returns {Promise<
|
|
23
|
+
* @param {IOperatorsFilter} filter Filter for the operators.
|
|
24
|
+
* @returns {Promise<IOperator[]>} Returns an array with all the operator details.
|
|
25
25
|
*
|
|
26
26
|
* **Code example**
|
|
27
27
|
*
|
|
28
28
|
* ```ts
|
|
29
29
|
* import { OperatorUtils, ChainId } from '@human-protocol/sdk';
|
|
30
30
|
*
|
|
31
|
-
* const filter:
|
|
31
|
+
* const filter: IOperatorsFilter = {
|
|
32
32
|
* chainId: ChainId.POLYGON
|
|
33
33
|
* };
|
|
34
|
-
* const
|
|
34
|
+
* const operators = await OperatorUtils.getOperators(filter);
|
|
35
35
|
* ```
|
|
36
36
|
*/
|
|
37
|
-
static
|
|
37
|
+
static getOperators(filter: IOperatorsFilter): Promise<IOperator[]>;
|
|
38
38
|
/**
|
|
39
39
|
* Retrieves the reputation network operators of the specified address.
|
|
40
40
|
*
|
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,
|
|
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;IA8CrB;;;;;;;;;;;;;;;;OAgBG;WACiB,YAAY,CAC9B,MAAM,EAAE,gBAAgB,GACvB,OAAO,CAAC,SAAS,EAAE,CAAC;IA+DvB;;;;;;;;;;;;;;;OAeG;WACiB,6BAA6B,CAC/C,OAAO,EAAE,OAAO,EAChB,OAAO,EAAE,MAAM,EACf,IAAI,CAAC,EAAE,MAAM,GACZ,OAAO,CAAC,SAAS,EAAE,CAAC;IAmCvB;;;;;;;;;;;;;;OAcG;WACiB,UAAU,CAC5B,OAAO,EAAE,OAAO,EAChB,cAAc,EAAE,MAAM,GACrB,OAAO,CAAC,OAAO,EAAE,CAAC;CAyBtB"}
|
package/dist/operator.js
CHANGED
|
@@ -15,21 +15,21 @@ const enums_1 = require("./enums");
|
|
|
15
15
|
const constants_1 = require("./constants");
|
|
16
16
|
class OperatorUtils {
|
|
17
17
|
/**
|
|
18
|
-
* This function returns the
|
|
18
|
+
* This function returns the operator data for the given address.
|
|
19
19
|
*
|
|
20
|
-
* @param {ChainId} chainId Network in which the
|
|
21
|
-
* @param {string} address
|
|
22
|
-
* @returns {Promise<
|
|
20
|
+
* @param {ChainId} chainId Network in which the operator is deployed
|
|
21
|
+
* @param {string} address Operator address.
|
|
22
|
+
* @returns {Promise<IOperator>} Returns the operator details.
|
|
23
23
|
*
|
|
24
24
|
* **Code example**
|
|
25
25
|
*
|
|
26
26
|
* ```ts
|
|
27
27
|
* import { OperatorUtils, ChainId } from '@human-protocol/sdk';
|
|
28
28
|
*
|
|
29
|
-
* const
|
|
29
|
+
* const operator = await OperatorUtils.getOperator(ChainId.POLYGON_AMOY, '0x62dD51230A30401C455c8398d06F85e4EaB6309f');
|
|
30
30
|
* ```
|
|
31
31
|
*/
|
|
32
|
-
static async
|
|
32
|
+
static async getOperator(chainId, address) {
|
|
33
33
|
if (!ethers_1.ethers.isAddress(address)) {
|
|
34
34
|
throw error_1.ErrorInvalidStakerAddressProvided;
|
|
35
35
|
}
|
|
@@ -37,49 +37,50 @@ class OperatorUtils {
|
|
|
37
37
|
if (!networkData) {
|
|
38
38
|
throw error_1.ErrorUnsupportedChainID;
|
|
39
39
|
}
|
|
40
|
-
const {
|
|
40
|
+
const { operator } = await (0, graphql_request_1.default)((0, utils_1.getSubgraphUrl)(networkData), operator_1.GET_LEADER_QUERY, {
|
|
41
41
|
address: address.toLowerCase(),
|
|
42
42
|
});
|
|
43
|
-
if (!
|
|
44
|
-
return
|
|
43
|
+
if (!operator) {
|
|
44
|
+
return operator || null;
|
|
45
45
|
}
|
|
46
46
|
let jobTypes = [];
|
|
47
47
|
let reputationNetworks = [];
|
|
48
|
-
if (typeof
|
|
49
|
-
jobTypes =
|
|
48
|
+
if (typeof operator.jobTypes === 'string') {
|
|
49
|
+
jobTypes = operator.jobTypes.split(',');
|
|
50
50
|
}
|
|
51
|
-
else if (Array.isArray(
|
|
52
|
-
jobTypes =
|
|
51
|
+
else if (Array.isArray(operator.jobTypes)) {
|
|
52
|
+
jobTypes = operator.jobTypes;
|
|
53
53
|
}
|
|
54
|
-
if (
|
|
55
|
-
|
|
54
|
+
if (operator.reputationNetworks &&
|
|
55
|
+
Array.isArray(operator.reputationNetworks)) {
|
|
56
|
+
reputationNetworks = operator.reputationNetworks.map((network) => network.address);
|
|
56
57
|
}
|
|
57
58
|
return {
|
|
58
|
-
...
|
|
59
|
+
...operator,
|
|
59
60
|
jobTypes,
|
|
60
61
|
reputationNetworks,
|
|
61
62
|
chainId,
|
|
62
63
|
};
|
|
63
64
|
}
|
|
64
65
|
/**
|
|
65
|
-
* This function returns all the
|
|
66
|
+
* This function returns all the operator details of the protocol.
|
|
66
67
|
*
|
|
67
|
-
* @param {
|
|
68
|
-
* @returns {Promise<
|
|
68
|
+
* @param {IOperatorsFilter} filter Filter for the operators.
|
|
69
|
+
* @returns {Promise<IOperator[]>} Returns an array with all the operator details.
|
|
69
70
|
*
|
|
70
71
|
* **Code example**
|
|
71
72
|
*
|
|
72
73
|
* ```ts
|
|
73
74
|
* import { OperatorUtils, ChainId } from '@human-protocol/sdk';
|
|
74
75
|
*
|
|
75
|
-
* const filter:
|
|
76
|
+
* const filter: IOperatorsFilter = {
|
|
76
77
|
* chainId: ChainId.POLYGON
|
|
77
78
|
* };
|
|
78
|
-
* const
|
|
79
|
+
* const operators = await OperatorUtils.getOperators(filter);
|
|
79
80
|
* ```
|
|
80
81
|
*/
|
|
81
|
-
static async
|
|
82
|
-
let
|
|
82
|
+
static async getOperators(filter) {
|
|
83
|
+
let operators_data = [];
|
|
83
84
|
const first = filter.first !== undefined && filter.first > 0
|
|
84
85
|
? Math.min(filter.first, 1000)
|
|
85
86
|
: 10;
|
|
@@ -89,7 +90,7 @@ class OperatorUtils {
|
|
|
89
90
|
if (!networkData) {
|
|
90
91
|
throw error_1.ErrorUnsupportedChainID;
|
|
91
92
|
}
|
|
92
|
-
const {
|
|
93
|
+
const { operators } = await (0, graphql_request_1.default)((0, utils_1.getSubgraphUrl)(networkData), (0, operator_1.GET_LEADERS_QUERY)(filter), {
|
|
93
94
|
minAmountStaked: filter?.minAmountStaked,
|
|
94
95
|
roles: filter?.roles,
|
|
95
96
|
orderBy: filter?.orderBy,
|
|
@@ -97,30 +98,30 @@ class OperatorUtils {
|
|
|
97
98
|
first: first,
|
|
98
99
|
skip: skip,
|
|
99
100
|
});
|
|
100
|
-
if (!
|
|
101
|
+
if (!operators) {
|
|
101
102
|
return [];
|
|
102
103
|
}
|
|
103
|
-
|
|
104
|
+
operators_data = operators_data.concat(operators.map((operator) => {
|
|
104
105
|
let jobTypes = [];
|
|
105
106
|
let reputationNetworks = [];
|
|
106
|
-
if (typeof
|
|
107
|
-
jobTypes =
|
|
107
|
+
if (typeof operator.jobTypes === 'string') {
|
|
108
|
+
jobTypes = operator.jobTypes.split(',');
|
|
108
109
|
}
|
|
109
|
-
else if (Array.isArray(
|
|
110
|
-
jobTypes =
|
|
110
|
+
else if (Array.isArray(operator.jobTypes)) {
|
|
111
|
+
jobTypes = operator.jobTypes;
|
|
111
112
|
}
|
|
112
|
-
if (
|
|
113
|
-
Array.isArray(
|
|
114
|
-
reputationNetworks =
|
|
113
|
+
if (operator.reputationNetworks &&
|
|
114
|
+
Array.isArray(operator.reputationNetworks)) {
|
|
115
|
+
reputationNetworks = operator.reputationNetworks.map((network) => network.address);
|
|
115
116
|
}
|
|
116
117
|
return {
|
|
117
|
-
...
|
|
118
|
+
...operator,
|
|
118
119
|
jobTypes,
|
|
119
120
|
reputationNetworks,
|
|
120
121
|
chainId: filter.chainId,
|
|
121
122
|
};
|
|
122
123
|
}));
|
|
123
|
-
return
|
|
124
|
+
return operators_data;
|
|
124
125
|
}
|
|
125
126
|
/**
|
|
126
127
|
* Retrieves the reputation network operators of the specified address.
|
|
@@ -158,8 +159,10 @@ class OperatorUtils {
|
|
|
158
159
|
jobTypes = operator.jobTypes;
|
|
159
160
|
}
|
|
160
161
|
return {
|
|
162
|
+
chainId,
|
|
161
163
|
...operator,
|
|
162
164
|
jobTypes,
|
|
165
|
+
reputationNetworks: operator.reputationNetworks?.map((network) => network.address),
|
|
163
166
|
};
|
|
164
167
|
});
|
|
165
168
|
}
|
package/package.json
CHANGED
package/src/constants.ts
CHANGED
|
@@ -36,7 +36,7 @@ export const NETWORKS: {
|
|
|
36
36
|
subgraphUrl:
|
|
37
37
|
'https://api.studio.thegraph.com/query/74256/ethereum/version/latest',
|
|
38
38
|
subgraphUrlApiKey:
|
|
39
|
-
'https://gateway-arbitrum.network.thegraph.com/api/[SUBGRAPH_API_KEY]/deployments/id/
|
|
39
|
+
'https://gateway-arbitrum.network.thegraph.com/api/[SUBGRAPH_API_KEY]/deployments/id/QmawHPbwEhAvmWgHQUH9Qgx5AqrXmq1uhfj69CGv9LLzNb',
|
|
40
40
|
oldSubgraphUrl: '',
|
|
41
41
|
oldFactoryAddress: '',
|
|
42
42
|
},
|
|
@@ -51,7 +51,7 @@ export const NETWORKS: {
|
|
|
51
51
|
subgraphUrl:
|
|
52
52
|
'https://api.studio.thegraph.com/query/74256/sepolia/version/latest',
|
|
53
53
|
subgraphUrlApiKey:
|
|
54
|
-
'https://gateway-arbitrum.network.thegraph.com/api/[SUBGRAPH_API_KEY]/deployments/id/
|
|
54
|
+
'https://gateway-arbitrum.network.thegraph.com/api/[SUBGRAPH_API_KEY]/deployments/id/QmYx4iD24iBTBgxhK95WV4u4o4QSFQFJxuvSNwwSEvCMsE',
|
|
55
55
|
oldSubgraphUrl: '',
|
|
56
56
|
oldFactoryAddress: '',
|
|
57
57
|
},
|
|
@@ -66,7 +66,7 @@ export const NETWORKS: {
|
|
|
66
66
|
subgraphUrl:
|
|
67
67
|
'https://api.studio.thegraph.com/query/74256/bsc/version/latest',
|
|
68
68
|
subgraphUrlApiKey:
|
|
69
|
-
'https://gateway-arbitrum.network.thegraph.com/api/[SUBGRAPH_API_KEY]/deployments/id/
|
|
69
|
+
'https://gateway-arbitrum.network.thegraph.com/api/[SUBGRAPH_API_KEY]/deployments/id/Qmai26kHVvYnn59QzGyBAfVWTQ98utfA2bJxQTMV2NeU8K',
|
|
70
70
|
oldSubgraphUrl: 'https://api.thegraph.com/subgraphs/name/humanprotocol/bsc',
|
|
71
71
|
oldFactoryAddress: '0xc88bC422cAAb2ac8812de03176402dbcA09533f4',
|
|
72
72
|
},
|
|
@@ -81,7 +81,7 @@ export const NETWORKS: {
|
|
|
81
81
|
subgraphUrl:
|
|
82
82
|
'https://api.studio.thegraph.com/query/74256/bsc-testnet/version/latest',
|
|
83
83
|
subgraphUrlApiKey:
|
|
84
|
-
'https://gateway-arbitrum.network.thegraph.com/api/[SUBGRAPH_API_KEY]/deployments/id/
|
|
84
|
+
'https://gateway-arbitrum.network.thegraph.com/api/[SUBGRAPH_API_KEY]/deployments/id/QmbPzZWJMqCzdc6ZJir1Z2Va5mpLo8haGxAkfMySwfGxqs',
|
|
85
85
|
oldSubgraphUrl:
|
|
86
86
|
'https://api.thegraph.com/subgraphs/name/humanprotocol/bsctest',
|
|
87
87
|
oldFactoryAddress: '0xaae6a2646c1f88763e62e0cd08ad050ea66ac46f',
|
|
@@ -97,7 +97,7 @@ export const NETWORKS: {
|
|
|
97
97
|
subgraphUrl:
|
|
98
98
|
'https://api.studio.thegraph.com/query/74256/polygon/version/latest',
|
|
99
99
|
subgraphUrlApiKey:
|
|
100
|
-
'https://gateway-arbitrum.network.thegraph.com/api/[SUBGRAPH_API_KEY]/deployments/id/
|
|
100
|
+
'https://gateway-arbitrum.network.thegraph.com/api/[SUBGRAPH_API_KEY]/deployments/id/QmSyLqu2injQHCrMg68Wvp6n39J5piCDQkwHGWhKBqxhvV',
|
|
101
101
|
oldSubgraphUrl:
|
|
102
102
|
'https://api.thegraph.com/subgraphs/name/humanprotocol/polygon',
|
|
103
103
|
oldFactoryAddress: '0x45eBc3eAE6DA485097054ae10BA1A0f8e8c7f794',
|
|
@@ -113,7 +113,7 @@ export const NETWORKS: {
|
|
|
113
113
|
subgraphUrl:
|
|
114
114
|
'https://api.studio.thegraph.com/query/74256/amoy/version/latest',
|
|
115
115
|
subgraphUrlApiKey:
|
|
116
|
-
'https://gateway-arbitrum.network.thegraph.com/api/[SUBGRAPH_API_KEY]/deployments/id/
|
|
116
|
+
'https://gateway-arbitrum.network.thegraph.com/api/[SUBGRAPH_API_KEY]/deployments/id/QmYtZEaay5cX5XwGmoN8NpwfpFMbyqiKvtA1ub4GvavH2P',
|
|
117
117
|
oldSubgraphUrl: '',
|
|
118
118
|
oldFactoryAddress: '',
|
|
119
119
|
},
|
|
@@ -133,25 +133,25 @@ export const NETWORKS: {
|
|
|
133
133
|
};
|
|
134
134
|
|
|
135
135
|
export const KVStoreKeys = {
|
|
136
|
-
|
|
136
|
+
category: 'category',
|
|
137
137
|
fee: 'fee',
|
|
138
|
+
jobTypes: 'job_types',
|
|
139
|
+
operatorName: 'name',
|
|
138
140
|
publicKey: 'public_key',
|
|
139
141
|
publicKeyHash: 'public_key_hash',
|
|
140
|
-
webhookUrl: 'webhook_url',
|
|
141
|
-
website: 'website',
|
|
142
|
-
url: 'url',
|
|
143
|
-
jobTypes: 'job_types',
|
|
144
|
-
registrationNeeded: 'registration_needed',
|
|
145
142
|
registrationInstructions: 'registration_instructions',
|
|
146
|
-
|
|
147
|
-
|
|
143
|
+
registrationNeeded: 'registration_needed',
|
|
144
|
+
role: 'role',
|
|
145
|
+
url: 'url',
|
|
146
|
+
website: 'website',
|
|
147
|
+
webhookUrl: 'webhook_url',
|
|
148
148
|
};
|
|
149
149
|
|
|
150
150
|
export const Role = {
|
|
151
|
-
JobLauncher: '
|
|
152
|
-
ExchangeOracle: '
|
|
153
|
-
ReputationOracle: '
|
|
154
|
-
RecordingOracle: '
|
|
151
|
+
JobLauncher: 'job_launcher',
|
|
152
|
+
ExchangeOracle: 'exchange_oracle',
|
|
153
|
+
ReputationOracle: 'reputation_oracle',
|
|
154
|
+
RecordingOracle: 'recording_oracle',
|
|
155
155
|
};
|
|
156
156
|
|
|
157
157
|
export const SUBGRAPH_API_KEY_PLACEHOLDER = '[SUBGRAPH_API_KEY]';
|
package/src/enums.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import gql from 'graphql-tag';
|
|
2
|
-
import {
|
|
2
|
+
import { IOperatorsFilter } from 'src/interfaces';
|
|
3
3
|
|
|
4
4
|
const LEADER_FRAGMENT = gql`
|
|
5
|
-
fragment
|
|
5
|
+
fragment OperatorFields on Operator {
|
|
6
6
|
id
|
|
7
7
|
address
|
|
8
8
|
amountStaked
|
|
@@ -27,7 +27,7 @@ const LEADER_FRAGMENT = gql`
|
|
|
27
27
|
}
|
|
28
28
|
`;
|
|
29
29
|
|
|
30
|
-
export const GET_LEADERS_QUERY = (filter:
|
|
30
|
+
export const GET_LEADERS_QUERY = (filter: IOperatorsFilter) => {
|
|
31
31
|
const { roles, minAmountStaked } = filter;
|
|
32
32
|
|
|
33
33
|
const WHERE_CLAUSE = `
|
|
@@ -38,7 +38,7 @@ export const GET_LEADERS_QUERY = (filter: ILeadersFilter) => {
|
|
|
38
38
|
`;
|
|
39
39
|
|
|
40
40
|
return gql`
|
|
41
|
-
query
|
|
41
|
+
query getOperators(
|
|
42
42
|
$minAmountStaked: Int,
|
|
43
43
|
$roles: [String!]
|
|
44
44
|
$first: Int
|
|
@@ -46,14 +46,14 @@ export const GET_LEADERS_QUERY = (filter: ILeadersFilter) => {
|
|
|
46
46
|
$orderBy: String
|
|
47
47
|
$orderDirection: String
|
|
48
48
|
) {
|
|
49
|
-
|
|
49
|
+
operators(
|
|
50
50
|
${WHERE_CLAUSE}
|
|
51
51
|
first: $first
|
|
52
52
|
skip: $skip
|
|
53
53
|
orderBy: $orderBy
|
|
54
54
|
orderDirection: $orderDirection
|
|
55
55
|
) {
|
|
56
|
-
...
|
|
56
|
+
...OperatorFields
|
|
57
57
|
}
|
|
58
58
|
}
|
|
59
59
|
${LEADER_FRAGMENT}
|
|
@@ -76,22 +76,18 @@ export const GET_REPUTATION_NETWORK_QUERY = (role?: string) => {
|
|
|
76
76
|
operators(
|
|
77
77
|
${WHERE_CLAUSE}
|
|
78
78
|
) {
|
|
79
|
-
|
|
80
|
-
role,
|
|
81
|
-
url,
|
|
82
|
-
jobTypes,
|
|
83
|
-
registrationNeeded,
|
|
84
|
-
registrationInstructions
|
|
79
|
+
...OperatorFields
|
|
85
80
|
}
|
|
86
81
|
}
|
|
87
82
|
}
|
|
83
|
+
${LEADER_FRAGMENT}
|
|
88
84
|
`;
|
|
89
85
|
};
|
|
90
86
|
|
|
91
87
|
export const GET_LEADER_QUERY = gql`
|
|
92
|
-
query
|
|
93
|
-
|
|
94
|
-
...
|
|
88
|
+
query getOperator($address: String!) {
|
|
89
|
+
operator(id: $address) {
|
|
90
|
+
...OperatorFields
|
|
95
91
|
}
|
|
96
92
|
}
|
|
97
93
|
${LEADER_FRAGMENT}
|
package/src/interfaces.ts
CHANGED
|
@@ -6,7 +6,7 @@ export interface IReward {
|
|
|
6
6
|
amount: bigint;
|
|
7
7
|
}
|
|
8
8
|
|
|
9
|
-
export interface
|
|
9
|
+
export interface IOperator {
|
|
10
10
|
id: string;
|
|
11
11
|
chainId: ChainId;
|
|
12
12
|
address: string;
|
|
@@ -31,13 +31,13 @@ export interface ILeader {
|
|
|
31
31
|
category?: string;
|
|
32
32
|
}
|
|
33
33
|
|
|
34
|
-
export interface
|
|
35
|
-
extends Omit<
|
|
34
|
+
export interface IOperatorSubgraph
|
|
35
|
+
extends Omit<IOperator, 'jobTypes' | 'reputationNetworks' | 'chainId'> {
|
|
36
36
|
jobTypes?: string;
|
|
37
37
|
reputationNetworks?: { address: string }[];
|
|
38
38
|
}
|
|
39
39
|
|
|
40
|
-
export interface
|
|
40
|
+
export interface IOperatorsFilter extends IPagination {
|
|
41
41
|
chainId: ChainId;
|
|
42
42
|
roles?: string[];
|
|
43
43
|
minAmountStaked?: number;
|
|
@@ -64,10 +64,6 @@ export interface IOperator {
|
|
|
64
64
|
registrationInstructions?: string;
|
|
65
65
|
}
|
|
66
66
|
|
|
67
|
-
export interface IOperatorSubgraph extends Omit<IOperator, 'jobTypes'> {
|
|
68
|
-
jobTypes?: string;
|
|
69
|
-
}
|
|
70
|
-
|
|
71
67
|
export interface IEscrowsFilter extends IPagination {
|
|
72
68
|
launcher?: string;
|
|
73
69
|
reputationOracle?: string;
|
package/src/operator.ts
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
2
2
|
import gqlFetch from 'graphql-request';
|
|
3
3
|
import {
|
|
4
|
-
ILeader,
|
|
5
|
-
ILeaderSubgraph,
|
|
6
|
-
ILeadersFilter,
|
|
7
4
|
IOperator,
|
|
5
|
+
IOperatorSubgraph,
|
|
6
|
+
IOperatorsFilter,
|
|
8
7
|
IReputationNetworkSubgraph,
|
|
9
8
|
IReward,
|
|
10
9
|
} from './interfaces';
|
|
@@ -27,24 +26,24 @@ import { NETWORKS } from './constants';
|
|
|
27
26
|
|
|
28
27
|
export class OperatorUtils {
|
|
29
28
|
/**
|
|
30
|
-
* This function returns the
|
|
29
|
+
* This function returns the operator data for the given address.
|
|
31
30
|
*
|
|
32
|
-
* @param {ChainId} chainId Network in which the
|
|
33
|
-
* @param {string} address
|
|
34
|
-
* @returns {Promise<
|
|
31
|
+
* @param {ChainId} chainId Network in which the operator is deployed
|
|
32
|
+
* @param {string} address Operator address.
|
|
33
|
+
* @returns {Promise<IOperator>} Returns the operator details.
|
|
35
34
|
*
|
|
36
35
|
* **Code example**
|
|
37
36
|
*
|
|
38
37
|
* ```ts
|
|
39
38
|
* import { OperatorUtils, ChainId } from '@human-protocol/sdk';
|
|
40
39
|
*
|
|
41
|
-
* const
|
|
40
|
+
* const operator = await OperatorUtils.getOperator(ChainId.POLYGON_AMOY, '0x62dD51230A30401C455c8398d06F85e4EaB6309f');
|
|
42
41
|
* ```
|
|
43
42
|
*/
|
|
44
|
-
public static async
|
|
43
|
+
public static async getOperator(
|
|
45
44
|
chainId: ChainId,
|
|
46
45
|
address: string
|
|
47
|
-
): Promise<
|
|
46
|
+
): Promise<IOperator> {
|
|
48
47
|
if (!ethers.isAddress(address)) {
|
|
49
48
|
throw ErrorInvalidStakerAddressProvided;
|
|
50
49
|
}
|
|
@@ -54,33 +53,36 @@ export class OperatorUtils {
|
|
|
54
53
|
throw ErrorUnsupportedChainID;
|
|
55
54
|
}
|
|
56
55
|
|
|
57
|
-
const {
|
|
58
|
-
|
|
56
|
+
const { operator } = await gqlFetch<{
|
|
57
|
+
operator: IOperatorSubgraph;
|
|
59
58
|
}>(getSubgraphUrl(networkData), GET_LEADER_QUERY, {
|
|
60
59
|
address: address.toLowerCase(),
|
|
61
60
|
});
|
|
62
61
|
|
|
63
|
-
if (!
|
|
64
|
-
return (
|
|
62
|
+
if (!operator) {
|
|
63
|
+
return (operator as IOperator) || null;
|
|
65
64
|
}
|
|
66
65
|
|
|
67
66
|
let jobTypes: string[] = [];
|
|
68
67
|
let reputationNetworks: string[] = [];
|
|
69
68
|
|
|
70
|
-
if (typeof
|
|
71
|
-
jobTypes =
|
|
72
|
-
} else if (Array.isArray(
|
|
73
|
-
jobTypes =
|
|
69
|
+
if (typeof operator.jobTypes === 'string') {
|
|
70
|
+
jobTypes = operator.jobTypes.split(',');
|
|
71
|
+
} else if (Array.isArray(operator.jobTypes)) {
|
|
72
|
+
jobTypes = operator.jobTypes;
|
|
74
73
|
}
|
|
75
74
|
|
|
76
|
-
if (
|
|
77
|
-
reputationNetworks
|
|
75
|
+
if (
|
|
76
|
+
operator.reputationNetworks &&
|
|
77
|
+
Array.isArray(operator.reputationNetworks)
|
|
78
|
+
) {
|
|
79
|
+
reputationNetworks = operator.reputationNetworks.map(
|
|
78
80
|
(network) => network.address
|
|
79
81
|
);
|
|
80
82
|
}
|
|
81
83
|
|
|
82
84
|
return {
|
|
83
|
-
...
|
|
85
|
+
...operator,
|
|
84
86
|
jobTypes,
|
|
85
87
|
reputationNetworks,
|
|
86
88
|
chainId,
|
|
@@ -88,24 +90,26 @@ export class OperatorUtils {
|
|
|
88
90
|
}
|
|
89
91
|
|
|
90
92
|
/**
|
|
91
|
-
* This function returns all the
|
|
93
|
+
* This function returns all the operator details of the protocol.
|
|
92
94
|
*
|
|
93
|
-
* @param {
|
|
94
|
-
* @returns {Promise<
|
|
95
|
+
* @param {IOperatorsFilter} filter Filter for the operators.
|
|
96
|
+
* @returns {Promise<IOperator[]>} Returns an array with all the operator details.
|
|
95
97
|
*
|
|
96
98
|
* **Code example**
|
|
97
99
|
*
|
|
98
100
|
* ```ts
|
|
99
101
|
* import { OperatorUtils, ChainId } from '@human-protocol/sdk';
|
|
100
102
|
*
|
|
101
|
-
* const filter:
|
|
103
|
+
* const filter: IOperatorsFilter = {
|
|
102
104
|
* chainId: ChainId.POLYGON
|
|
103
105
|
* };
|
|
104
|
-
* const
|
|
106
|
+
* const operators = await OperatorUtils.getOperators(filter);
|
|
105
107
|
* ```
|
|
106
108
|
*/
|
|
107
|
-
public static async
|
|
108
|
-
|
|
109
|
+
public static async getOperators(
|
|
110
|
+
filter: IOperatorsFilter
|
|
111
|
+
): Promise<IOperator[]> {
|
|
112
|
+
let operators_data: IOperator[] = [];
|
|
109
113
|
|
|
110
114
|
const first =
|
|
111
115
|
filter.first !== undefined && filter.first > 0
|
|
@@ -121,8 +125,8 @@ export class OperatorUtils {
|
|
|
121
125
|
throw ErrorUnsupportedChainID;
|
|
122
126
|
}
|
|
123
127
|
|
|
124
|
-
const {
|
|
125
|
-
|
|
128
|
+
const { operators } = await gqlFetch<{
|
|
129
|
+
operators: IOperatorSubgraph[];
|
|
126
130
|
}>(getSubgraphUrl(networkData), GET_LEADERS_QUERY(filter), {
|
|
127
131
|
minAmountStaked: filter?.minAmountStaked,
|
|
128
132
|
roles: filter?.roles,
|
|
@@ -132,39 +136,39 @@ export class OperatorUtils {
|
|
|
132
136
|
skip: skip,
|
|
133
137
|
});
|
|
134
138
|
|
|
135
|
-
if (!
|
|
139
|
+
if (!operators) {
|
|
136
140
|
return [];
|
|
137
141
|
}
|
|
138
142
|
|
|
139
|
-
|
|
140
|
-
|
|
143
|
+
operators_data = operators_data.concat(
|
|
144
|
+
operators.map((operator) => {
|
|
141
145
|
let jobTypes: string[] = [];
|
|
142
146
|
let reputationNetworks: string[] = [];
|
|
143
147
|
|
|
144
|
-
if (typeof
|
|
145
|
-
jobTypes =
|
|
146
|
-
} else if (Array.isArray(
|
|
147
|
-
jobTypes =
|
|
148
|
+
if (typeof operator.jobTypes === 'string') {
|
|
149
|
+
jobTypes = operator.jobTypes.split(',');
|
|
150
|
+
} else if (Array.isArray(operator.jobTypes)) {
|
|
151
|
+
jobTypes = operator.jobTypes;
|
|
148
152
|
}
|
|
149
153
|
|
|
150
154
|
if (
|
|
151
|
-
|
|
152
|
-
Array.isArray(
|
|
155
|
+
operator.reputationNetworks &&
|
|
156
|
+
Array.isArray(operator.reputationNetworks)
|
|
153
157
|
) {
|
|
154
|
-
reputationNetworks =
|
|
158
|
+
reputationNetworks = operator.reputationNetworks.map(
|
|
155
159
|
(network) => network.address
|
|
156
160
|
);
|
|
157
161
|
}
|
|
158
162
|
|
|
159
163
|
return {
|
|
160
|
-
...
|
|
164
|
+
...operator,
|
|
161
165
|
jobTypes,
|
|
162
166
|
reputationNetworks,
|
|
163
167
|
chainId: filter.chainId,
|
|
164
168
|
};
|
|
165
169
|
})
|
|
166
170
|
);
|
|
167
|
-
return
|
|
171
|
+
return operators_data;
|
|
168
172
|
}
|
|
169
173
|
|
|
170
174
|
/**
|
|
@@ -212,8 +216,12 @@ export class OperatorUtils {
|
|
|
212
216
|
}
|
|
213
217
|
|
|
214
218
|
return {
|
|
219
|
+
chainId,
|
|
215
220
|
...operator,
|
|
216
221
|
jobTypes,
|
|
222
|
+
reputationNetworks: operator.reputationNetworks?.map(
|
|
223
|
+
(network) => network.address
|
|
224
|
+
),
|
|
217
225
|
};
|
|
218
226
|
});
|
|
219
227
|
}
|