@human-protocol/sdk 3.0.8 → 4.0.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.d.ts +1 -1
- package/dist/constants.d.ts.map +1 -1
- package/dist/constants.js +2 -2
- package/dist/decorators.js +1 -1
- package/dist/encryption.d.ts +21 -29
- package/dist/encryption.d.ts.map +1 -1
- package/dist/encryption.js +17 -29
- package/dist/error.d.ts +31 -28
- package/dist/error.d.ts.map +1 -1
- package/dist/error.js +36 -33
- package/dist/escrow.d.ts +102 -59
- package/dist/escrow.d.ts.map +1 -1
- package/dist/escrow.js +186 -98
- package/dist/graphql/queries/operator.d.ts.map +1 -1
- package/dist/graphql/queries/operator.js +13 -5
- package/dist/interfaces.d.ts +10 -2
- package/dist/interfaces.d.ts.map +1 -1
- package/dist/kvstore.d.ts +15 -15
- package/dist/kvstore.d.ts.map +1 -1
- package/dist/kvstore.js +15 -15
- package/dist/operator.d.ts +11 -10
- package/dist/operator.d.ts.map +1 -1
- package/dist/operator.js +23 -11
- package/dist/staking.d.ts +38 -21
- package/dist/staking.d.ts.map +1 -1
- package/dist/staking.js +62 -21
- package/dist/statistics.d.ts +10 -29
- package/dist/statistics.d.ts.map +1 -1
- package/dist/statistics.js +10 -29
- package/dist/storage.d.ts +13 -18
- package/dist/storage.d.ts.map +1 -1
- package/dist/storage.js +13 -18
- package/dist/transaction.js +1 -1
- package/dist/types.d.ts +6 -2
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +1 -1
- package/dist/utils.d.ts +0 -1
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +0 -1
- package/package.json +1 -1
- package/src/constants.ts +2 -2
- package/src/decorators.ts +1 -1
- package/src/encryption.ts +21 -29
- package/src/error.ts +39 -37
- package/src/escrow.ts +245 -117
- package/src/graphql/queries/operator.ts +13 -5
- package/src/interfaces.ts +11 -2
- package/src/kvstore.ts +16 -16
- package/src/operator.ts +26 -12
- package/src/staking.ts +71 -22
- package/src/statistics.ts +10 -29
- package/src/storage.ts +13 -18
- package/src/transaction.ts +2 -2
- package/src/types.ts +6 -2
- package/src/utils.ts +0 -1
|
@@ -29,20 +29,28 @@ const LEADER_FRAGMENT = (0, graphql_tag_1.default) `
|
|
|
29
29
|
}
|
|
30
30
|
`;
|
|
31
31
|
const GET_LEADERS_QUERY = (filter) => {
|
|
32
|
-
const {
|
|
32
|
+
const { roles, minAmountStaked } = filter;
|
|
33
33
|
const WHERE_CLAUSE = `
|
|
34
34
|
where: {
|
|
35
|
-
${
|
|
35
|
+
${minAmountStaked ? `amountStaked_gte: $minAmountStaked` : ''}
|
|
36
|
+
${roles ? `role_in: $roles` : ''}
|
|
36
37
|
}
|
|
37
38
|
`;
|
|
38
39
|
return (0, graphql_tag_1.default) `
|
|
39
40
|
query getLeaders(
|
|
40
|
-
$
|
|
41
|
+
$minAmountStaked: Int,
|
|
42
|
+
$roles: [String!]
|
|
43
|
+
$first: Int
|
|
44
|
+
$skip: Int
|
|
45
|
+
$orderBy: String
|
|
46
|
+
$orderDirection: String
|
|
41
47
|
) {
|
|
42
48
|
leaders(
|
|
43
49
|
${WHERE_CLAUSE}
|
|
44
|
-
|
|
45
|
-
|
|
50
|
+
first: $first
|
|
51
|
+
skip: $skip
|
|
52
|
+
orderBy: $orderBy
|
|
53
|
+
orderDirection: $orderDirection
|
|
46
54
|
) {
|
|
47
55
|
...LeaderFields
|
|
48
56
|
}
|
package/dist/interfaces.d.ts
CHANGED
|
@@ -32,9 +32,11 @@ export interface ILeaderSubgraph extends Omit<ILeader, 'jobTypes' | 'reputationN
|
|
|
32
32
|
address: string;
|
|
33
33
|
}[];
|
|
34
34
|
}
|
|
35
|
-
export interface ILeadersFilter {
|
|
35
|
+
export interface ILeadersFilter extends IPagination {
|
|
36
36
|
chainId: ChainId;
|
|
37
|
-
|
|
37
|
+
roles?: string[];
|
|
38
|
+
minAmountStaked?: number;
|
|
39
|
+
orderBy?: string;
|
|
38
40
|
}
|
|
39
41
|
export interface IReputationNetwork {
|
|
40
42
|
id: string;
|
|
@@ -135,4 +137,10 @@ export interface IPagination {
|
|
|
135
137
|
skip?: number;
|
|
136
138
|
orderDirection?: OrderDirection;
|
|
137
139
|
}
|
|
140
|
+
export interface StakerInfo {
|
|
141
|
+
stakedAmount: bigint;
|
|
142
|
+
lockedAmount: bigint;
|
|
143
|
+
lockedUntil: bigint;
|
|
144
|
+
withdrawableAmount: bigint;
|
|
145
|
+
}
|
|
138
146
|
//# 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,OAAO;IACtB,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,MAAM,EAAE,MAAM,CAAC;IACf,mBAAmB,EAAE,MAAM,CAAC;IAC5B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,QAAQ,CAAC,EAAE,MA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|
6
6
|
/**
|
|
7
7
|
* ## Introduction
|
|
8
8
|
*
|
|
9
|
-
* This client enables
|
|
9
|
+
* This client enables performing actions on KVStore contract and obtaining information from both the contracts and subgraph.
|
|
10
10
|
*
|
|
11
11
|
* Internally, the SDK will use one network or another according to the network ID of the `runner`.
|
|
12
12
|
* To use this client, it is recommended to initialize it using the static `build` method.
|
|
13
13
|
*
|
|
14
14
|
* ```ts
|
|
15
|
-
* static async build(runner: ContractRunner)
|
|
15
|
+
* static async build(runner: ContractRunner): Promise<KVStoreClient>;
|
|
16
16
|
* ```
|
|
17
17
|
*
|
|
18
18
|
* A `Signer` or a `Provider` should be passed depending on the use case of this module:
|
|
19
19
|
*
|
|
20
|
-
* - **Signer**: when the user wants to use this model
|
|
21
|
-
* - **Provider**: when the user wants to use this model
|
|
20
|
+
* - **Signer**: when the user wants to use this model to send transactions calling the contract functions.
|
|
21
|
+
* - **Provider**: when the user wants to use this model to get information from the contracts or subgraph.
|
|
22
22
|
*
|
|
23
23
|
* ## Installation
|
|
24
24
|
*
|
|
@@ -36,21 +36,21 @@ import { IKVStore } from './interfaces';
|
|
|
36
36
|
*
|
|
37
37
|
* ### Signer
|
|
38
38
|
*
|
|
39
|
-
* **Using private key(backend)**
|
|
39
|
+
* **Using private key (backend)**
|
|
40
40
|
*
|
|
41
41
|
* ```ts
|
|
42
42
|
* import { KVStoreClient } from '@human-protocol/sdk';
|
|
43
43
|
* import { Wallet, providers } from 'ethers';
|
|
44
44
|
*
|
|
45
45
|
* const rpcUrl = 'YOUR_RPC_URL';
|
|
46
|
-
* const privateKey = 'YOUR_PRIVATE_KEY'
|
|
46
|
+
* const privateKey = 'YOUR_PRIVATE_KEY';
|
|
47
47
|
*
|
|
48
48
|
* const provider = new providers.JsonRpcProvider(rpcUrl);
|
|
49
49
|
* const signer = new Wallet(privateKey, provider);
|
|
50
50
|
* const kvstoreClient = await KVStoreClient.build(signer);
|
|
51
51
|
* ```
|
|
52
52
|
*
|
|
53
|
-
* **Using Wagmi(frontend)**
|
|
53
|
+
* **Using Wagmi (frontend)**
|
|
54
54
|
*
|
|
55
55
|
* ```ts
|
|
56
56
|
* import { useSigner, useChainId } from 'wagmi';
|
|
@@ -69,7 +69,7 @@ import { IKVStore } from './interfaces';
|
|
|
69
69
|
* const rpcUrl = 'YOUR_RPC_URL';
|
|
70
70
|
*
|
|
71
71
|
* const provider = new providers.JsonRpcProvider(rpcUrl);
|
|
72
|
-
* const kvstoreClient = await KVStoreClient.build(
|
|
72
|
+
* const kvstoreClient = await KVStoreClient.build(provider);
|
|
73
73
|
* ```
|
|
74
74
|
*/
|
|
75
75
|
export declare class KVStoreClient extends BaseEthersClient {
|
|
@@ -109,7 +109,7 @@ export declare class KVStoreClient extends BaseEthersClient {
|
|
|
109
109
|
* import { KVStoreClient } from '@human-protocol/sdk';
|
|
110
110
|
*
|
|
111
111
|
* const rpcUrl = 'YOUR_RPC_URL';
|
|
112
|
-
* const privateKey = 'YOUR_PRIVATE_KEY'
|
|
112
|
+
* const privateKey = 'YOUR_PRIVATE_KEY';
|
|
113
113
|
*
|
|
114
114
|
* const provider = new providers.JsonRpcProvider(rpcUrl);
|
|
115
115
|
* const signer = new Wallet(privateKey, provider);
|
|
@@ -137,7 +137,7 @@ export declare class KVStoreClient extends BaseEthersClient {
|
|
|
137
137
|
* import { KVStoreClient } from '@human-protocol/sdk';
|
|
138
138
|
*
|
|
139
139
|
* const rpcUrl = 'YOUR_RPC_URL';
|
|
140
|
-
* const privateKey = 'YOUR_PRIVATE_KEY'
|
|
140
|
+
* const privateKey = 'YOUR_PRIVATE_KEY';
|
|
141
141
|
*
|
|
142
142
|
* const provider = new providers.JsonRpcProvider(rpcUrl);
|
|
143
143
|
* const signer = new Wallet(privateKey, provider);
|
|
@@ -145,7 +145,7 @@ export declare class KVStoreClient extends BaseEthersClient {
|
|
|
145
145
|
*
|
|
146
146
|
* const keys = ['role', 'webhook_url'];
|
|
147
147
|
* const values = ['RecordingOracle', 'http://localhost'];
|
|
148
|
-
* await kvstoreClient.
|
|
148
|
+
* await kvstoreClient.setBulk(keys, values);
|
|
149
149
|
* ```
|
|
150
150
|
*/
|
|
151
151
|
setBulk(keys: string[], values: string[], txOptions?: Overrides): Promise<void>;
|
|
@@ -165,14 +165,14 @@ export declare class KVStoreClient extends BaseEthersClient {
|
|
|
165
165
|
* import { KVStoreClient } from '@human-protocol/sdk';
|
|
166
166
|
*
|
|
167
167
|
* const rpcUrl = 'YOUR_RPC_URL';
|
|
168
|
-
* const privateKey = 'YOUR_PRIVATE_KEY'
|
|
168
|
+
* const privateKey = 'YOUR_PRIVATE_KEY';
|
|
169
169
|
*
|
|
170
170
|
* const provider = new providers.JsonRpcProvider(rpcUrl);
|
|
171
171
|
* const signer = new Wallet(privateKey, provider);
|
|
172
172
|
* const kvstoreClient = await KVStoreClient.build(signer);
|
|
173
173
|
*
|
|
174
174
|
* await kvstoreClient.setFileUrlAndHash('example.com');
|
|
175
|
-
* await kvstoreClient.setFileUrlAndHash('linkedin.com/example', 'linkedin_url);
|
|
175
|
+
* await kvstoreClient.setFileUrlAndHash('linkedin.com/example', 'linkedin_url');
|
|
176
176
|
* ```
|
|
177
177
|
*/
|
|
178
178
|
setFileUrlAndHash(url: string, urlKey?: string, txOptions?: Overrides): Promise<void>;
|
|
@@ -203,9 +203,9 @@ export declare class KVStoreClient extends BaseEthersClient {
|
|
|
203
203
|
* ```ts
|
|
204
204
|
* import { ChainId, KVStoreUtils } from '@human-protocol/sdk';
|
|
205
205
|
*
|
|
206
|
-
* const KVStoreAddresses =
|
|
206
|
+
* const KVStoreAddresses = await KVStoreUtils.getKVStoreData(
|
|
207
207
|
* ChainId.POLYGON_AMOY,
|
|
208
|
-
* "0x1234567890123456789012345678901234567890"
|
|
208
|
+
* "0x1234567890123456789012345678901234567890"
|
|
209
209
|
* );
|
|
210
210
|
* ```
|
|
211
211
|
*/
|
package/dist/kvstore.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"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|
25
25
|
/**
|
|
26
26
|
* ## Introduction
|
|
27
27
|
*
|
|
28
|
-
* This client enables
|
|
28
|
+
* This client enables performing actions on KVStore contract and obtaining information from both the contracts and subgraph.
|
|
29
29
|
*
|
|
30
30
|
* Internally, the SDK will use one network or another according to the network ID of the `runner`.
|
|
31
31
|
* To use this client, it is recommended to initialize it using the static `build` method.
|
|
32
32
|
*
|
|
33
33
|
* ```ts
|
|
34
|
-
* static async build(runner: ContractRunner)
|
|
34
|
+
* static async build(runner: ContractRunner): Promise<KVStoreClient>;
|
|
35
35
|
* ```
|
|
36
36
|
*
|
|
37
37
|
* A `Signer` or a `Provider` should be passed depending on the use case of this module:
|
|
38
38
|
*
|
|
39
|
-
* - **Signer**: when the user wants to use this model
|
|
40
|
-
* - **Provider**: when the user wants to use this model
|
|
39
|
+
* - **Signer**: when the user wants to use this model to send transactions calling the contract functions.
|
|
40
|
+
* - **Provider**: when the user wants to use this model to get information from the contracts or subgraph.
|
|
41
41
|
*
|
|
42
42
|
* ## Installation
|
|
43
43
|
*
|
|
@@ -55,21 +55,21 @@ const kvstore_1 = require("./graphql/queries/kvstore");
|
|
|
55
55
|
*
|
|
56
56
|
* ### Signer
|
|
57
57
|
*
|
|
58
|
-
* **Using private key(backend)**
|
|
58
|
+
* **Using private key (backend)**
|
|
59
59
|
*
|
|
60
60
|
* ```ts
|
|
61
61
|
* import { KVStoreClient } from '@human-protocol/sdk';
|
|
62
62
|
* import { Wallet, providers } from 'ethers';
|
|
63
63
|
*
|
|
64
64
|
* const rpcUrl = 'YOUR_RPC_URL';
|
|
65
|
-
* const privateKey = 'YOUR_PRIVATE_KEY'
|
|
65
|
+
* const privateKey = 'YOUR_PRIVATE_KEY';
|
|
66
66
|
*
|
|
67
67
|
* const provider = new providers.JsonRpcProvider(rpcUrl);
|
|
68
68
|
* const signer = new Wallet(privateKey, provider);
|
|
69
69
|
* const kvstoreClient = await KVStoreClient.build(signer);
|
|
70
70
|
* ```
|
|
71
71
|
*
|
|
72
|
-
* **Using Wagmi(frontend)**
|
|
72
|
+
* **Using Wagmi (frontend)**
|
|
73
73
|
*
|
|
74
74
|
* ```ts
|
|
75
75
|
* import { useSigner, useChainId } from 'wagmi';
|
|
@@ -88,7 +88,7 @@ const kvstore_1 = require("./graphql/queries/kvstore");
|
|
|
88
88
|
* const rpcUrl = 'YOUR_RPC_URL';
|
|
89
89
|
*
|
|
90
90
|
* const provider = new providers.JsonRpcProvider(rpcUrl);
|
|
91
|
-
* const kvstoreClient = await KVStoreClient.build(
|
|
91
|
+
* const kvstoreClient = await KVStoreClient.build(provider);
|
|
92
92
|
* ```
|
|
93
93
|
*/
|
|
94
94
|
class KVStoreClient extends base_1.BaseEthersClient {
|
|
@@ -141,7 +141,7 @@ class KVStoreClient extends base_1.BaseEthersClient {
|
|
|
141
141
|
* import { KVStoreClient } from '@human-protocol/sdk';
|
|
142
142
|
*
|
|
143
143
|
* const rpcUrl = 'YOUR_RPC_URL';
|
|
144
|
-
* const privateKey = 'YOUR_PRIVATE_KEY'
|
|
144
|
+
* const privateKey = 'YOUR_PRIVATE_KEY';
|
|
145
145
|
*
|
|
146
146
|
* const provider = new providers.JsonRpcProvider(rpcUrl);
|
|
147
147
|
* const signer = new Wallet(privateKey, provider);
|
|
@@ -179,7 +179,7 @@ class KVStoreClient extends base_1.BaseEthersClient {
|
|
|
179
179
|
* import { KVStoreClient } from '@human-protocol/sdk';
|
|
180
180
|
*
|
|
181
181
|
* const rpcUrl = 'YOUR_RPC_URL';
|
|
182
|
-
* const privateKey = 'YOUR_PRIVATE_KEY'
|
|
182
|
+
* const privateKey = 'YOUR_PRIVATE_KEY';
|
|
183
183
|
*
|
|
184
184
|
* const provider = new providers.JsonRpcProvider(rpcUrl);
|
|
185
185
|
* const signer = new Wallet(privateKey, provider);
|
|
@@ -187,7 +187,7 @@ class KVStoreClient extends base_1.BaseEthersClient {
|
|
|
187
187
|
*
|
|
188
188
|
* const keys = ['role', 'webhook_url'];
|
|
189
189
|
* const values = ['RecordingOracle', 'http://localhost'];
|
|
190
|
-
* await kvstoreClient.
|
|
190
|
+
* await kvstoreClient.setBulk(keys, values);
|
|
191
191
|
* ```
|
|
192
192
|
*/
|
|
193
193
|
async setBulk(keys, values, txOptions = {}) {
|
|
@@ -219,14 +219,14 @@ class KVStoreClient extends base_1.BaseEthersClient {
|
|
|
219
219
|
* import { KVStoreClient } from '@human-protocol/sdk';
|
|
220
220
|
*
|
|
221
221
|
* const rpcUrl = 'YOUR_RPC_URL';
|
|
222
|
-
* const privateKey = 'YOUR_PRIVATE_KEY'
|
|
222
|
+
* const privateKey = 'YOUR_PRIVATE_KEY';
|
|
223
223
|
*
|
|
224
224
|
* const provider = new providers.JsonRpcProvider(rpcUrl);
|
|
225
225
|
* const signer = new Wallet(privateKey, provider);
|
|
226
226
|
* const kvstoreClient = await KVStoreClient.build(signer);
|
|
227
227
|
*
|
|
228
228
|
* await kvstoreClient.setFileUrlAndHash('example.com');
|
|
229
|
-
* await kvstoreClient.setFileUrlAndHash('linkedin.com/example', 'linkedin_url);
|
|
229
|
+
* await kvstoreClient.setFileUrlAndHash('linkedin.com/example', 'linkedin_url');
|
|
230
230
|
* ```
|
|
231
231
|
*/
|
|
232
232
|
async setFileUrlAndHash(url, urlKey = 'url', txOptions = {}) {
|
|
@@ -290,9 +290,9 @@ __decorate([
|
|
|
290
290
|
* ```ts
|
|
291
291
|
* import { ChainId, KVStoreUtils } from '@human-protocol/sdk';
|
|
292
292
|
*
|
|
293
|
-
* const KVStoreAddresses =
|
|
293
|
+
* const KVStoreAddresses = await KVStoreUtils.getKVStoreData(
|
|
294
294
|
* ChainId.POLYGON_AMOY,
|
|
295
|
-
* "0x1234567890123456789012345678901234567890"
|
|
295
|
+
* "0x1234567890123456789012345678901234567890"
|
|
296
296
|
* );
|
|
297
297
|
* ```
|
|
298
298
|
*/
|
package/dist/operator.d.ts
CHANGED
|
@@ -4,9 +4,9 @@ export declare class OperatorUtils {
|
|
|
4
4
|
/**
|
|
5
5
|
* This function returns the leader data for the given address.
|
|
6
6
|
*
|
|
7
|
+
* @param {ChainId} chainId Network in which the leader is deployed
|
|
7
8
|
* @param {string} address Leader address.
|
|
8
|
-
* @returns {ILeader} Returns the leader details.
|
|
9
|
-
*
|
|
9
|
+
* @returns {Promise<ILeader>} Returns the leader details.
|
|
10
10
|
*
|
|
11
11
|
* **Code example**
|
|
12
12
|
*
|
|
@@ -21,13 +21,12 @@ export declare class OperatorUtils {
|
|
|
21
21
|
* This function returns all the leader details of the protocol.
|
|
22
22
|
*
|
|
23
23
|
* @param {ILeadersFilter} filter Filter for the leaders.
|
|
24
|
-
* @returns {ILeader[]} Returns an array with all the leader details.
|
|
25
|
-
*
|
|
24
|
+
* @returns {Promise<ILeader[]>} Returns an array with all the leader details.
|
|
26
25
|
*
|
|
27
26
|
* **Code example**
|
|
28
27
|
*
|
|
29
28
|
* ```ts
|
|
30
|
-
* import { OperatorUtils } from '@human-protocol/sdk';
|
|
29
|
+
* import { OperatorUtils, ChainId } from '@human-protocol/sdk';
|
|
31
30
|
*
|
|
32
31
|
* const filter: ILeadersFilter = {
|
|
33
32
|
* chainId: ChainId.POLYGON
|
|
@@ -39,12 +38,14 @@ export declare class OperatorUtils {
|
|
|
39
38
|
/**
|
|
40
39
|
* Retrieves the reputation network operators of the specified address.
|
|
41
40
|
*
|
|
42
|
-
* @param {
|
|
41
|
+
* @param {ChainId} chainId Network in which the reputation network is deployed
|
|
42
|
+
* @param {string} address Address of the reputation oracle.
|
|
43
43
|
* @param {string} [role] - (Optional) Role of the operator.
|
|
44
44
|
* @returns {Promise<IOperator[]>} - Returns an array of operator details.
|
|
45
45
|
*
|
|
46
|
-
*
|
|
47
|
-
*
|
|
46
|
+
* **Code example**
|
|
47
|
+
*
|
|
48
|
+
* ```ts
|
|
48
49
|
* import { OperatorUtils, ChainId } from '@human-protocol/sdk';
|
|
49
50
|
*
|
|
50
51
|
* const operators = await OperatorUtils.getReputationNetworkOperators(ChainId.POLYGON_AMOY, '0x62dD51230A30401C455c8398d06F85e4EaB6309f');
|
|
@@ -54,9 +55,9 @@ export declare class OperatorUtils {
|
|
|
54
55
|
/**
|
|
55
56
|
* This function returns information about the rewards for a given slasher address.
|
|
56
57
|
*
|
|
58
|
+
* @param {ChainId} chainId Network in which the rewards are deployed
|
|
57
59
|
* @param {string} slasherAddress Slasher address.
|
|
58
|
-
* @returns {IReward[]} Returns an array of Reward objects that contain the rewards earned by the user through slashing other users.
|
|
59
|
-
*
|
|
60
|
+
* @returns {Promise<IReward[]>} Returns an array of Reward objects that contain the rewards earned by the user through slashing other users.
|
|
60
61
|
*
|
|
61
62
|
* **Code example**
|
|
62
63
|
*
|
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,OAAO,EAEP,cAAc,EACd,SAAS,EAET,OAAO,EACR,MAAM,cAAc,CAAC;AAetB,OAAO,EAAE,OAAO,
|
|
1
|
+
{"version":3,"file":"operator.d.ts","sourceRoot":"","sources":["../src/operator.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,OAAO,EAEP,cAAc,EACd,SAAS,EAET,OAAO,EACR,MAAM,cAAc,CAAC;AAetB,OAAO,EAAE,OAAO,EAAkB,MAAM,SAAS,CAAC;AAGlD,qBAAa,aAAa;IACxB;;;;;;;;;;;;;;OAcG;WACiB,SAAS,CAC3B,OAAO,EAAE,OAAO,EAChB,OAAO,EAAE,MAAM,GACd,OAAO,CAAC,OAAO,CAAC;IA2CnB;;;;;;;;;;;;;;;;OAgBG;WACiB,UAAU,CAAC,MAAM,EAAE,cAAc,GAAG,OAAO,CAAC,OAAO,EAAE,CAAC;IA+D1E;;;;;;;;;;;;;;;OAeG;WACiB,6BAA6B,CAC/C,OAAO,EAAE,OAAO,EAChB,OAAO,EAAE,MAAM,EACf,IAAI,CAAC,EAAE,MAAM,GACZ,OAAO,CAAC,SAAS,EAAE,CAAC;IA+BvB;;;;;;;;;;;;;;OAcG;WACiB,UAAU,CAC5B,OAAO,EAAE,OAAO,EAChB,cAAc,EAAE,MAAM,GACrB,OAAO,CAAC,OAAO,EAAE,CAAC;CAyBtB"}
|
package/dist/operator.js
CHANGED
|
@@ -11,14 +11,15 @@ const operator_1 = require("./graphql/queries/operator");
|
|
|
11
11
|
const ethers_1 = require("ethers");
|
|
12
12
|
const error_1 = require("./error");
|
|
13
13
|
const utils_1 = require("./utils");
|
|
14
|
+
const enums_1 = require("./enums");
|
|
14
15
|
const constants_1 = require("./constants");
|
|
15
16
|
class OperatorUtils {
|
|
16
17
|
/**
|
|
17
18
|
* This function returns the leader data for the given address.
|
|
18
19
|
*
|
|
20
|
+
* @param {ChainId} chainId Network in which the leader is deployed
|
|
19
21
|
* @param {string} address Leader address.
|
|
20
|
-
* @returns {ILeader} Returns the leader details.
|
|
21
|
-
*
|
|
22
|
+
* @returns {Promise<ILeader>} Returns the leader details.
|
|
22
23
|
*
|
|
23
24
|
* **Code example**
|
|
24
25
|
*
|
|
@@ -64,13 +65,12 @@ class OperatorUtils {
|
|
|
64
65
|
* This function returns all the leader details of the protocol.
|
|
65
66
|
*
|
|
66
67
|
* @param {ILeadersFilter} filter Filter for the leaders.
|
|
67
|
-
* @returns {ILeader[]} Returns an array with all the leader details.
|
|
68
|
-
*
|
|
68
|
+
* @returns {Promise<ILeader[]>} Returns an array with all the leader details.
|
|
69
69
|
*
|
|
70
70
|
* **Code example**
|
|
71
71
|
*
|
|
72
72
|
* ```ts
|
|
73
|
-
* import { OperatorUtils } from '@human-protocol/sdk';
|
|
73
|
+
* import { OperatorUtils, ChainId } from '@human-protocol/sdk';
|
|
74
74
|
*
|
|
75
75
|
* const filter: ILeadersFilter = {
|
|
76
76
|
* chainId: ChainId.POLYGON
|
|
@@ -80,12 +80,22 @@ class OperatorUtils {
|
|
|
80
80
|
*/
|
|
81
81
|
static async getLeaders(filter) {
|
|
82
82
|
let leaders_data = [];
|
|
83
|
+
const first = filter.first !== undefined && filter.first > 0
|
|
84
|
+
? Math.min(filter.first, 1000)
|
|
85
|
+
: 10;
|
|
86
|
+
const skip = filter.skip !== undefined && filter.skip >= 0 ? filter.skip : 0;
|
|
87
|
+
const orderDirection = filter.orderDirection || enums_1.OrderDirection.DESC;
|
|
83
88
|
const networkData = constants_1.NETWORKS[filter.chainId];
|
|
84
89
|
if (!networkData) {
|
|
85
90
|
throw error_1.ErrorUnsupportedChainID;
|
|
86
91
|
}
|
|
87
92
|
const { leaders } = await (0, graphql_request_1.default)((0, utils_1.getSubgraphUrl)(networkData), (0, operator_1.GET_LEADERS_QUERY)(filter), {
|
|
88
|
-
|
|
93
|
+
minAmountStaked: filter?.minAmountStaked,
|
|
94
|
+
roles: filter?.roles,
|
|
95
|
+
orderBy: filter?.orderBy,
|
|
96
|
+
orderDirection: orderDirection,
|
|
97
|
+
first: first,
|
|
98
|
+
skip: skip,
|
|
89
99
|
});
|
|
90
100
|
if (!leaders) {
|
|
91
101
|
return [];
|
|
@@ -115,12 +125,14 @@ class OperatorUtils {
|
|
|
115
125
|
/**
|
|
116
126
|
* Retrieves the reputation network operators of the specified address.
|
|
117
127
|
*
|
|
118
|
-
* @param {
|
|
128
|
+
* @param {ChainId} chainId Network in which the reputation network is deployed
|
|
129
|
+
* @param {string} address Address of the reputation oracle.
|
|
119
130
|
* @param {string} [role] - (Optional) Role of the operator.
|
|
120
131
|
* @returns {Promise<IOperator[]>} - Returns an array of operator details.
|
|
121
132
|
*
|
|
122
|
-
*
|
|
123
|
-
*
|
|
133
|
+
* **Code example**
|
|
134
|
+
*
|
|
135
|
+
* ```ts
|
|
124
136
|
* import { OperatorUtils, ChainId } from '@human-protocol/sdk';
|
|
125
137
|
*
|
|
126
138
|
* const operators = await OperatorUtils.getReputationNetworkOperators(ChainId.POLYGON_AMOY, '0x62dD51230A30401C455c8398d06F85e4EaB6309f');
|
|
@@ -154,9 +166,9 @@ class OperatorUtils {
|
|
|
154
166
|
/**
|
|
155
167
|
* This function returns information about the rewards for a given slasher address.
|
|
156
168
|
*
|
|
169
|
+
* @param {ChainId} chainId Network in which the rewards are deployed
|
|
157
170
|
* @param {string} slasherAddress Slasher address.
|
|
158
|
-
* @returns {IReward[]} Returns an array of Reward objects that contain the rewards earned by the user through slashing other users.
|
|
159
|
-
*
|
|
171
|
+
* @returns {Promise<IReward[]>} Returns an array of Reward objects that contain the rewards earned by the user through slashing other users.
|
|
160
172
|
*
|
|
161
173
|
* **Code example**
|
|
162
174
|
*
|
package/dist/staking.d.ts
CHANGED
|
@@ -2,22 +2,23 @@ import { EscrowFactory, HMToken, Staking } from '@human-protocol/core/typechain-
|
|
|
2
2
|
import { ContractRunner, Overrides } from 'ethers';
|
|
3
3
|
import { BaseEthersClient } from './base';
|
|
4
4
|
import { NetworkData } from './types';
|
|
5
|
+
import { StakerInfo } from './interfaces';
|
|
5
6
|
/**
|
|
6
7
|
* ## Introduction
|
|
7
8
|
*
|
|
8
|
-
* This client enables
|
|
9
|
+
* This client enables performing actions on staking contracts and obtaining staking information from both the contracts and subgraph.
|
|
9
10
|
*
|
|
10
11
|
* Internally, the SDK will use one network or another according to the network ID of the `runner`.
|
|
11
12
|
* To use this client, it is recommended to initialize it using the static `build` method.
|
|
12
13
|
*
|
|
13
14
|
* ```ts
|
|
14
|
-
* static async build(runner: ContractRunner)
|
|
15
|
+
* static async build(runner: ContractRunner): Promise<StakingClient>;
|
|
15
16
|
* ```
|
|
16
17
|
*
|
|
17
18
|
* A `Signer` or a `Provider` should be passed depending on the use case of this module:
|
|
18
19
|
*
|
|
19
|
-
* - **Signer**: when the user wants to use this model
|
|
20
|
-
* - **Provider**: when the user wants to use this model
|
|
20
|
+
* - **Signer**: when the user wants to use this model to send transactions calling the contract functions.
|
|
21
|
+
* - **Provider**: when the user wants to use this model to get information from the contracts or subgraph.
|
|
21
22
|
*
|
|
22
23
|
* ## Installation
|
|
23
24
|
*
|
|
@@ -35,21 +36,21 @@ import { NetworkData } from './types';
|
|
|
35
36
|
*
|
|
36
37
|
* ### Signer
|
|
37
38
|
*
|
|
38
|
-
* **Using private key(backend)**
|
|
39
|
+
* **Using private key (backend)**
|
|
39
40
|
*
|
|
40
41
|
* ```ts
|
|
41
42
|
* import { StakingClient } from '@human-protocol/sdk';
|
|
42
43
|
* import { Wallet, providers } from 'ethers';
|
|
43
44
|
*
|
|
44
45
|
* const rpcUrl = 'YOUR_RPC_URL';
|
|
45
|
-
* const privateKey = 'YOUR_PRIVATE_KEY'
|
|
46
|
+
* const privateKey = 'YOUR_PRIVATE_KEY';
|
|
46
47
|
*
|
|
47
48
|
* const provider = new providers.JsonRpcProvider(rpcUrl);
|
|
48
49
|
* const signer = new Wallet(privateKey, provider);
|
|
49
50
|
* const stakingClient = await StakingClient.build(signer);
|
|
50
51
|
* ```
|
|
51
52
|
*
|
|
52
|
-
* **Using Wagmi(frontend)**
|
|
53
|
+
* **Using Wagmi (frontend)**
|
|
53
54
|
*
|
|
54
55
|
* ```ts
|
|
55
56
|
* import { useSigner, useChainId } from 'wagmi';
|
|
@@ -105,7 +106,6 @@ export declare class StakingClient extends BaseEthersClient {
|
|
|
105
106
|
* @param {Overrides} [txOptions] - Additional transaction parameters (optional, defaults to an empty object).
|
|
106
107
|
* @returns Returns void if successful. Throws error if any.
|
|
107
108
|
*
|
|
108
|
-
*
|
|
109
109
|
* **Code example**
|
|
110
110
|
*
|
|
111
111
|
* ```ts
|
|
@@ -113,7 +113,7 @@ export declare class StakingClient extends BaseEthersClient {
|
|
|
113
113
|
* import { StakingClient } from '@human-protocol/sdk';
|
|
114
114
|
*
|
|
115
115
|
* const rpcUrl = 'YOUR_RPC_URL';
|
|
116
|
-
* const privateKey = 'YOUR_PRIVATE_KEY'
|
|
116
|
+
* const privateKey = 'YOUR_PRIVATE_KEY';
|
|
117
117
|
*
|
|
118
118
|
* const provider = new providers.JsonRpcProvider(rpcUrl);
|
|
119
119
|
* const signer = new Wallet(privateKey, provider);
|
|
@@ -133,7 +133,6 @@ export declare class StakingClient extends BaseEthersClient {
|
|
|
133
133
|
* @param {Overrides} [txOptions] - Additional transaction parameters (optional, defaults to an empty object).
|
|
134
134
|
* @returns Returns void if successful. Throws error if any.
|
|
135
135
|
*
|
|
136
|
-
*
|
|
137
136
|
* **Code example**
|
|
138
137
|
*
|
|
139
138
|
* ```ts
|
|
@@ -141,7 +140,7 @@ export declare class StakingClient extends BaseEthersClient {
|
|
|
141
140
|
* import { StakingClient } from '@human-protocol/sdk';
|
|
142
141
|
*
|
|
143
142
|
* const rpcUrl = 'YOUR_RPC_URL';
|
|
144
|
-
* const privateKey = 'YOUR_PRIVATE_KEY'
|
|
143
|
+
* const privateKey = 'YOUR_PRIVATE_KEY';
|
|
145
144
|
*
|
|
146
145
|
* const provider = new providers.JsonRpcProvider(rpcUrl);
|
|
147
146
|
* const signer = new Wallet(privateKey, provider);
|
|
@@ -149,7 +148,7 @@ export declare class StakingClient extends BaseEthersClient {
|
|
|
149
148
|
*
|
|
150
149
|
* const amount = ethers.parseUnits(5, 'ether'); //convert from ETH to WEI
|
|
151
150
|
* await stakingClient.approveStake(amount); // if it was already approved before, this is not necessary
|
|
152
|
-
* await stakingClient.
|
|
151
|
+
* await stakingClient.stake(amount);
|
|
153
152
|
* ```
|
|
154
153
|
*/
|
|
155
154
|
stake(amount: bigint, txOptions?: Overrides): Promise<void>;
|
|
@@ -162,7 +161,6 @@ export declare class StakingClient extends BaseEthersClient {
|
|
|
162
161
|
* @param {Overrides} [txOptions] - Additional transaction parameters (optional, defaults to an empty object).
|
|
163
162
|
* @returns Returns void if successful. Throws error if any.
|
|
164
163
|
*
|
|
165
|
-
*
|
|
166
164
|
* **Code example**
|
|
167
165
|
*
|
|
168
166
|
* ```ts
|
|
@@ -170,7 +168,7 @@ export declare class StakingClient extends BaseEthersClient {
|
|
|
170
168
|
* import { StakingClient } from '@human-protocol/sdk';
|
|
171
169
|
*
|
|
172
170
|
* const rpcUrl = 'YOUR_RPC_URL';
|
|
173
|
-
* const privateKey = 'YOUR_PRIVATE_KEY'
|
|
171
|
+
* const privateKey = 'YOUR_PRIVATE_KEY';
|
|
174
172
|
*
|
|
175
173
|
* const provider = new providers.JsonRpcProvider(rpcUrl);
|
|
176
174
|
* const signer = new Wallet(privateKey, provider);
|
|
@@ -182,14 +180,13 @@ export declare class StakingClient extends BaseEthersClient {
|
|
|
182
180
|
*/
|
|
183
181
|
unstake(amount: bigint, txOptions?: Overrides): Promise<void>;
|
|
184
182
|
/**
|
|
185
|
-
* This function withdraws unstaked and non
|
|
183
|
+
* This function withdraws unstaked and non-locked tokens from staking contract to the user wallet.
|
|
186
184
|
*
|
|
187
185
|
* > Must have tokens available to withdraw
|
|
188
186
|
*
|
|
189
187
|
* @param {Overrides} [txOptions] - Additional transaction parameters (optional, defaults to an empty object).
|
|
190
188
|
* @returns Returns void if successful. Throws error if any.
|
|
191
189
|
*
|
|
192
|
-
*
|
|
193
190
|
* **Code example**
|
|
194
191
|
*
|
|
195
192
|
* ```ts
|
|
@@ -197,7 +194,7 @@ export declare class StakingClient extends BaseEthersClient {
|
|
|
197
194
|
* import { StakingClient } from '@human-protocol/sdk';
|
|
198
195
|
*
|
|
199
196
|
* const rpcUrl = 'YOUR_RPC_URL';
|
|
200
|
-
* const privateKey = 'YOUR_PRIVATE_KEY'
|
|
197
|
+
* const privateKey = 'YOUR_PRIVATE_KEY';
|
|
201
198
|
*
|
|
202
199
|
* const provider = new providers.JsonRpcProvider(rpcUrl);
|
|
203
200
|
* const signer = new Wallet(privateKey, provider);
|
|
@@ -208,16 +205,15 @@ export declare class StakingClient extends BaseEthersClient {
|
|
|
208
205
|
*/
|
|
209
206
|
withdraw(txOptions?: Overrides): Promise<void>;
|
|
210
207
|
/**
|
|
211
|
-
* This function reduces the allocated amount by
|
|
208
|
+
* This function reduces the allocated amount by a staker in an escrow and transfers those tokens to the reward pool. This allows the slasher to claim them later.
|
|
212
209
|
*
|
|
213
210
|
* @param {string} slasher Wallet address from who requested the slash
|
|
214
211
|
* @param {string} staker Wallet address from who is going to be slashed
|
|
215
212
|
* @param {string} escrowAddress Address of the escrow that the slash is made
|
|
213
|
+
* @param {bigint} amount Amount in WEI of tokens to slash.
|
|
216
214
|
* @param {Overrides} [txOptions] - Additional transaction parameters (optional, defaults to an empty object).
|
|
217
|
-
* @param {bigint} amount Amount in WEI of tokens to unstake.
|
|
218
215
|
* @returns Returns void if successful. Throws error if any.
|
|
219
216
|
*
|
|
220
|
-
*
|
|
221
217
|
* **Code example**
|
|
222
218
|
*
|
|
223
219
|
* ```ts
|
|
@@ -225,7 +221,7 @@ export declare class StakingClient extends BaseEthersClient {
|
|
|
225
221
|
* import { StakingClient } from '@human-protocol/sdk';
|
|
226
222
|
*
|
|
227
223
|
* const rpcUrl = 'YOUR_RPC_URL';
|
|
228
|
-
* const privateKey = 'YOUR_PRIVATE_KEY'
|
|
224
|
+
* const privateKey = 'YOUR_PRIVATE_KEY';
|
|
229
225
|
*
|
|
230
226
|
* const provider = new providers.JsonRpcProvider(rpcUrl);
|
|
231
227
|
* const signer = new Wallet(privateKey, provider);
|
|
@@ -236,5 +232,26 @@ export declare class StakingClient extends BaseEthersClient {
|
|
|
236
232
|
* ```
|
|
237
233
|
*/
|
|
238
234
|
slash(slasher: string, staker: string, escrowAddress: string, amount: bigint, txOptions?: Overrides): Promise<void>;
|
|
235
|
+
/**
|
|
236
|
+
* Retrieves comprehensive staking information for a staker.
|
|
237
|
+
*
|
|
238
|
+
* @param {string} stakerAddress - The address of the staker.
|
|
239
|
+
* @returns {Promise<StakerInfo>}
|
|
240
|
+
*
|
|
241
|
+
* **Code example**
|
|
242
|
+
*
|
|
243
|
+
* ```ts
|
|
244
|
+
* import { StakingClient } from '@human-protocol/sdk';
|
|
245
|
+
*
|
|
246
|
+
* const rpcUrl = 'YOUR_RPC_URL';
|
|
247
|
+
*
|
|
248
|
+
* const provider = new providers.JsonRpcProvider(rpcUrl);
|
|
249
|
+
* const stakingClient = await StakingClient.build(provider);
|
|
250
|
+
*
|
|
251
|
+
* const stakingInfo = await stakingClient.getStakerInfo('0xYourStakerAddress');
|
|
252
|
+
* console.log(stakingInfo.tokensStaked);
|
|
253
|
+
* ```
|
|
254
|
+
*/
|
|
255
|
+
getStakerInfo(stakerAddress: string): Promise<StakerInfo>;
|
|
239
256
|
}
|
|
240
257
|
//# sourceMappingURL=staking.d.ts.map
|