@human-protocol/sdk 1.1.19 → 2.1.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/base.d.ts +4 -5
- package/dist/base.d.ts.map +1 -1
- package/dist/base.js +3 -3
- package/dist/constants.js +3 -3
- package/dist/decorators.d.ts.map +1 -1
- package/dist/decorators.js +4 -2
- package/dist/error.d.ts +0 -6
- package/dist/error.d.ts.map +1 -1
- package/dist/error.js +2 -14
- package/dist/escrow.d.ts +23 -24
- package/dist/escrow.d.ts.map +1 -1
- package/dist/escrow.js +86 -90
- package/dist/graphql/queries/{staking.d.ts → operator.d.ts} +2 -1
- package/dist/graphql/queries/operator.d.ts.map +1 -0
- package/dist/graphql/queries/{staking.js → operator.js} +24 -1
- package/dist/graphql/types.d.ts +5 -6
- package/dist/graphql/types.d.ts.map +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -1
- package/dist/interfaces.d.ts +28 -18
- package/dist/interfaces.d.ts.map +1 -1
- package/dist/kvstore.d.ts +41 -20
- package/dist/kvstore.d.ts.map +1 -1
- package/dist/kvstore.js +61 -45
- package/dist/operator.d.ts +68 -0
- package/dist/operator.d.ts.map +1 -0
- package/dist/operator.js +153 -0
- package/dist/staking.d.ts +24 -91
- package/dist/staking.d.ts.map +1 -1
- package/dist/staking.js +47 -166
- package/dist/statistics.d.ts.map +1 -1
- package/dist/statistics.js +7 -6
- package/dist/types.d.ts +1 -2
- package/dist/types.d.ts.map +1 -1
- package/dist/utils.d.ts +0 -7
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +8 -28
- package/package.json +4 -4
- package/src/base.ts +5 -6
- package/src/constants.ts +3 -3
- package/src/decorators.ts +3 -2
- package/src/error.ts +0 -12
- package/src/escrow.ts +101 -114
- package/src/graphql/queries/{staking.ts → operator.ts} +24 -0
- package/src/graphql/types.ts +5 -7
- package/src/index.ts +2 -0
- package/src/interfaces.ts +30 -18
- package/src/kvstore.ts +73 -52
- package/src/operator.ts +192 -0
- package/src/staking.ts +49 -182
- package/src/statistics.ts +8 -9
- package/src/types.ts +1 -3
- package/src/utils.ts +7 -29
- package/dist/graphql/queries/staking.d.ts.map +0 -1
package/dist/operator.js
ADDED
|
@@ -0,0 +1,153 @@
|
|
|
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.OperatorUtils = void 0;
|
|
7
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
8
|
+
const graphql_request_1 = __importDefault(require("graphql-request"));
|
|
9
|
+
const reward_1 = require("./graphql/queries/reward");
|
|
10
|
+
const operator_1 = require("./graphql/queries/operator");
|
|
11
|
+
const ethers_1 = require("ethers");
|
|
12
|
+
const error_1 = require("./error");
|
|
13
|
+
const utils_1 = require("./utils");
|
|
14
|
+
const enums_1 = require("./enums");
|
|
15
|
+
const constants_1 = require("./constants");
|
|
16
|
+
class OperatorUtils {
|
|
17
|
+
/**
|
|
18
|
+
* This function returns the leader data for the given address.
|
|
19
|
+
*
|
|
20
|
+
* @param {string} address Leader address.
|
|
21
|
+
* @returns {ILeader} Returns the leader details.
|
|
22
|
+
*
|
|
23
|
+
*
|
|
24
|
+
* **Code example**
|
|
25
|
+
*
|
|
26
|
+
* ```ts
|
|
27
|
+
* import { OperatorUtils, ChainId } from '@human-protocol/sdk';
|
|
28
|
+
*
|
|
29
|
+
* const leader = await OperatorUtils.getLeader(ChainId.POLYGON_MUMBAI, '0x62dD51230A30401C455c8398d06F85e4EaB6309f');
|
|
30
|
+
* ```
|
|
31
|
+
*/
|
|
32
|
+
static async getLeader(chainId, address) {
|
|
33
|
+
if (!ethers_1.ethers.isAddress(address)) {
|
|
34
|
+
throw error_1.ErrorInvalidStakerAddressProvided;
|
|
35
|
+
}
|
|
36
|
+
const networkData = constants_1.NETWORKS[chainId];
|
|
37
|
+
if (!networkData) {
|
|
38
|
+
throw error_1.ErrorUnsupportedChainID;
|
|
39
|
+
}
|
|
40
|
+
try {
|
|
41
|
+
const { leader } = await (0, graphql_request_1.default)(networkData.subgraphUrl, operator_1.GET_LEADER_QUERY, {
|
|
42
|
+
address: address.toLowerCase(),
|
|
43
|
+
});
|
|
44
|
+
return leader;
|
|
45
|
+
}
|
|
46
|
+
catch (e) {
|
|
47
|
+
return (0, utils_1.throwError)(e);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* This function returns all the leader details of the protocol.
|
|
52
|
+
*
|
|
53
|
+
* @param {ILeadersFilter} filter Filter for the leaders.
|
|
54
|
+
* @returns {ILeader[]} Returns an array with all the leader details.
|
|
55
|
+
*
|
|
56
|
+
*
|
|
57
|
+
* **Code example**
|
|
58
|
+
*
|
|
59
|
+
* ```ts
|
|
60
|
+
* import { OperatorUtils } from '@human-protocol/sdk';
|
|
61
|
+
*
|
|
62
|
+
* const leaders = await OperatorUtils.getLeaders();
|
|
63
|
+
* ```
|
|
64
|
+
*/
|
|
65
|
+
static async getLeaders(filter = { networks: [enums_1.ChainId.POLYGON_MUMBAI] }) {
|
|
66
|
+
try {
|
|
67
|
+
let leaders_data = [];
|
|
68
|
+
for (const chainId of filter.networks) {
|
|
69
|
+
const networkData = constants_1.NETWORKS[chainId];
|
|
70
|
+
if (!networkData) {
|
|
71
|
+
throw error_1.ErrorUnsupportedChainID;
|
|
72
|
+
}
|
|
73
|
+
const { leaders } = await (0, graphql_request_1.default)(networkData.subgraphUrl, (0, operator_1.GET_LEADERS_QUERY)(filter), {
|
|
74
|
+
role: filter.role,
|
|
75
|
+
});
|
|
76
|
+
leaders_data = leaders_data.concat(leaders);
|
|
77
|
+
}
|
|
78
|
+
return leaders_data;
|
|
79
|
+
}
|
|
80
|
+
catch (e) {
|
|
81
|
+
return (0, utils_1.throwError)(e);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Retrieves the reputation network operators of the specified address.
|
|
86
|
+
*
|
|
87
|
+
* @param {string} address - Address of the reputation oracle.
|
|
88
|
+
* @param {string} [role] - (Optional) Role of the operator.
|
|
89
|
+
* @returns {Promise<IOperator[]>} - Returns an array of operator details.
|
|
90
|
+
*
|
|
91
|
+
* @example
|
|
92
|
+
* ```typescript
|
|
93
|
+
* import { OperatorUtils, ChainId } from '@human-protocol/sdk';
|
|
94
|
+
*
|
|
95
|
+
* const operators = await OperatorUtils.getReputationNetworkOperators(ChainId.POLYGON_MUMBAI, '0x62dD51230A30401C455c8398d06F85e4EaB6309f');
|
|
96
|
+
* ```
|
|
97
|
+
*/
|
|
98
|
+
static async getReputationNetworkOperators(chainId, address, role) {
|
|
99
|
+
const networkData = constants_1.NETWORKS[chainId];
|
|
100
|
+
if (!networkData) {
|
|
101
|
+
throw error_1.ErrorUnsupportedChainID;
|
|
102
|
+
}
|
|
103
|
+
try {
|
|
104
|
+
const { reputationNetwork } = await (0, graphql_request_1.default)(networkData.subgraphUrl, (0, operator_1.GET_REPUTATION_NETWORK_QUERY)(role), {
|
|
105
|
+
address: address,
|
|
106
|
+
role: role,
|
|
107
|
+
});
|
|
108
|
+
return reputationNetwork.operators;
|
|
109
|
+
}
|
|
110
|
+
catch (e) {
|
|
111
|
+
return (0, utils_1.throwError)(e);
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* This function returns information about the rewards for a given slasher address.
|
|
116
|
+
*
|
|
117
|
+
* @param {string} slasherAddress Slasher address.
|
|
118
|
+
* @returns {IReward[]} Returns an array of Reward objects that contain the rewards earned by the user through slashing other users.
|
|
119
|
+
*
|
|
120
|
+
*
|
|
121
|
+
* **Code example**
|
|
122
|
+
*
|
|
123
|
+
* ```ts
|
|
124
|
+
* import { OperatorUtils, ChainId } from '@human-protocol/sdk';
|
|
125
|
+
*
|
|
126
|
+
* const rewards = await OperatorUtils.getRewards(ChainId.POLYGON_MUMBAI, '0x62dD51230A30401C455c8398d06F85e4EaB6309f');
|
|
127
|
+
* ```
|
|
128
|
+
*/
|
|
129
|
+
static async getRewards(chainId, slasherAddress) {
|
|
130
|
+
if (!ethers_1.ethers.isAddress(slasherAddress)) {
|
|
131
|
+
throw error_1.ErrorInvalidSlasherAddressProvided;
|
|
132
|
+
}
|
|
133
|
+
const networkData = constants_1.NETWORKS[chainId];
|
|
134
|
+
if (!networkData) {
|
|
135
|
+
throw error_1.ErrorUnsupportedChainID;
|
|
136
|
+
}
|
|
137
|
+
try {
|
|
138
|
+
const { rewardAddedEvents } = await (0, graphql_request_1.default)(networkData.subgraphUrl, reward_1.GET_REWARD_ADDED_EVENTS_QUERY, {
|
|
139
|
+
slasherAddress: slasherAddress.toLowerCase(),
|
|
140
|
+
});
|
|
141
|
+
return rewardAddedEvents.map((reward) => {
|
|
142
|
+
return {
|
|
143
|
+
escrowAddress: reward.escrow,
|
|
144
|
+
amount: reward.amount,
|
|
145
|
+
};
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
catch (e) {
|
|
149
|
+
return (0, utils_1.throwError)(e);
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
exports.OperatorUtils = OperatorUtils;
|
package/dist/staking.d.ts
CHANGED
|
@@ -1,19 +1,18 @@
|
|
|
1
|
-
import { Provider } from '@ethersproject/abstract-provider';
|
|
2
1
|
import { EscrowFactory, HMToken, RewardPool, Staking } from '@human-protocol/core/typechain-types';
|
|
3
|
-
import {
|
|
2
|
+
import { ContractRunner, Overrides } from 'ethers';
|
|
4
3
|
import { BaseEthersClient } from './base';
|
|
5
|
-
import { IAllocation
|
|
4
|
+
import { IAllocation } from './interfaces';
|
|
6
5
|
import { NetworkData } from './types';
|
|
7
6
|
/**
|
|
8
7
|
* ## Introduction
|
|
9
8
|
*
|
|
10
9
|
* This client enables to perform actions on staking contracts and obtain staking information from both the contracts and subgraph.
|
|
11
10
|
*
|
|
12
|
-
* Internally, the SDK will use one network or another according to the network ID of the `
|
|
11
|
+
* Internally, the SDK will use one network or another according to the network ID of the `runner`.
|
|
13
12
|
* To use this client, it is recommended to initialize it using the static `build` method.
|
|
14
13
|
*
|
|
15
14
|
* ```ts
|
|
16
|
-
* static async build(
|
|
15
|
+
* static async build(runner: ContractRunner);
|
|
17
16
|
* ```
|
|
18
17
|
*
|
|
19
18
|
* A `Signer` or a `Provider` should be passed depending on the use case of this module:
|
|
@@ -81,21 +80,21 @@ export declare class StakingClient extends BaseEthersClient {
|
|
|
81
80
|
/**
|
|
82
81
|
* **StakingClient constructor**
|
|
83
82
|
*
|
|
84
|
-
* @param {
|
|
83
|
+
* @param {ContractRunner} runner - The Runner object to interact with the Ethereum network
|
|
85
84
|
* @param {NetworkData} network - The network information required to connect to the Staking contract
|
|
86
85
|
*/
|
|
87
|
-
constructor(
|
|
86
|
+
constructor(runner: ContractRunner, networkData: NetworkData);
|
|
88
87
|
/**
|
|
89
|
-
* Creates an instance of StakingClient from a
|
|
88
|
+
* Creates an instance of StakingClient from a Runner.
|
|
90
89
|
*
|
|
91
|
-
* @param {
|
|
90
|
+
* @param {ContractRunner} runner - The Runner object to interact with the Ethereum network
|
|
92
91
|
* @param {number | undefined} gasPriceMultiplier - The multiplier to apply to the gas price
|
|
93
92
|
*
|
|
94
93
|
* @returns {Promise<StakingClient>} - An instance of StakingClient
|
|
95
94
|
* @throws {ErrorProviderDoesNotExist} - Thrown if the provider does not exist for the provided Signer
|
|
96
95
|
* @throws {ErrorUnsupportedChainID} - Thrown if the network's chainId is not supported
|
|
97
96
|
*/
|
|
98
|
-
static build(
|
|
97
|
+
static build(runner: ContractRunner): Promise<StakingClient>;
|
|
99
98
|
/**
|
|
100
99
|
* Check if escrow exists
|
|
101
100
|
*
|
|
@@ -105,7 +104,7 @@ export declare class StakingClient extends BaseEthersClient {
|
|
|
105
104
|
/**
|
|
106
105
|
* This function approves the staking contract to transfer a specified amount of tokens when the user stakes. It increases the allowance for the staking contract.
|
|
107
106
|
*
|
|
108
|
-
* @param {
|
|
107
|
+
* @param {bigint} amount Amount in WEI of tokens to approve for stake.
|
|
109
108
|
* @param {Overrides} [txOptions] - Additional transaction parameters (optional, defaults to an empty object).
|
|
110
109
|
* @returns Returns void if successful. Throws error if any.
|
|
111
110
|
*
|
|
@@ -123,17 +122,17 @@ export declare class StakingClient extends BaseEthersClient {
|
|
|
123
122
|
* const signer = new Wallet(privateKey, provider);
|
|
124
123
|
* const stakingClient = await StakingClient.build(signer);
|
|
125
124
|
*
|
|
126
|
-
* const amount = ethers.
|
|
125
|
+
* const amount = ethers.parseUnits(5, 'ether'); //convert from ETH to WEI
|
|
127
126
|
* await stakingClient.approveStake(amount);
|
|
128
127
|
* ```
|
|
129
128
|
*/
|
|
130
|
-
approveStake(amount:
|
|
129
|
+
approveStake(amount: bigint, txOptions?: Overrides): Promise<void>;
|
|
131
130
|
/**
|
|
132
131
|
* This function stakes a specified amount of tokens on a specific network.
|
|
133
132
|
*
|
|
134
133
|
* > `approveStake` must be called before
|
|
135
134
|
*
|
|
136
|
-
* @param {
|
|
135
|
+
* @param {bigint} amount Amount in WEI of tokens to stake.
|
|
137
136
|
* @param {Overrides} [txOptions] - Additional transaction parameters (optional, defaults to an empty object).
|
|
138
137
|
* @returns Returns void if successful. Throws error if any.
|
|
139
138
|
*
|
|
@@ -151,18 +150,18 @@ export declare class StakingClient extends BaseEthersClient {
|
|
|
151
150
|
* const signer = new Wallet(privateKey, provider);
|
|
152
151
|
* const stakingClient = await StakingClient.build(signer);
|
|
153
152
|
*
|
|
154
|
-
* const amount = ethers.
|
|
153
|
+
* const amount = ethers.parseUnits(5, 'ether'); //convert from ETH to WEI
|
|
155
154
|
* await stakingClient.approveStake(amount); // if it was already approved before, this is not necessary
|
|
156
155
|
* await stakingClient.approveStake(amount);
|
|
157
156
|
* ```
|
|
158
157
|
*/
|
|
159
|
-
stake(amount:
|
|
158
|
+
stake(amount: bigint, txOptions?: Overrides): Promise<void>;
|
|
160
159
|
/**
|
|
161
160
|
* This function unstakes tokens from staking contract. The unstaked tokens stay locked for a period of time.
|
|
162
161
|
*
|
|
163
162
|
* > Must have tokens available to unstake
|
|
164
163
|
*
|
|
165
|
-
* @param {
|
|
164
|
+
* @param {bigint} amount Amount in WEI of tokens to unstake.
|
|
166
165
|
* @param {Overrides} [txOptions] - Additional transaction parameters (optional, defaults to an empty object).
|
|
167
166
|
* @returns Returns void if successful. Throws error if any.
|
|
168
167
|
*
|
|
@@ -180,11 +179,11 @@ export declare class StakingClient extends BaseEthersClient {
|
|
|
180
179
|
* const signer = new Wallet(privateKey, provider);
|
|
181
180
|
* const stakingClient = await StakingClient.build(signer);
|
|
182
181
|
*
|
|
183
|
-
* const amount = ethers.
|
|
182
|
+
* const amount = ethers.parseUnits(5, 'ether'); //convert from ETH to WEI
|
|
184
183
|
* await stakingClient.unstake(amount);
|
|
185
184
|
* ```
|
|
186
185
|
*/
|
|
187
|
-
unstake(amount:
|
|
186
|
+
unstake(amount: bigint, txOptions?: Overrides): Promise<void>;
|
|
188
187
|
/**
|
|
189
188
|
* This function withdraws unstaked and non locked tokens form staking contract to the user wallet.
|
|
190
189
|
*
|
|
@@ -218,7 +217,7 @@ export declare class StakingClient extends BaseEthersClient {
|
|
|
218
217
|
* @param {string} staker Wallet address from who is going to be slashed
|
|
219
218
|
* @param {string} escrowAddress Address of the escrow which allocation will be slashed
|
|
220
219
|
* @param {Overrides} [txOptions] - Additional transaction parameters (optional, defaults to an empty object).
|
|
221
|
-
* @param {
|
|
220
|
+
* @param {bigint} amount Amount in WEI of tokens to unstake.
|
|
222
221
|
* @returns Returns void if successful. Throws error if any.
|
|
223
222
|
*
|
|
224
223
|
*
|
|
@@ -235,11 +234,11 @@ export declare class StakingClient extends BaseEthersClient {
|
|
|
235
234
|
* const signer = new Wallet(privateKey, provider);
|
|
236
235
|
* const stakingClient = await StakingClient.build(signer);
|
|
237
236
|
*
|
|
238
|
-
* const amount = ethers.
|
|
237
|
+
* const amount = ethers.parseUnits(5, 'ether'); //convert from ETH to WEI
|
|
239
238
|
* await stakingClient.slash('0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266', '0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266', '0x62dD51230A30401C455c8398d06F85e4EaB6309f', amount);
|
|
240
239
|
* ```
|
|
241
240
|
*/
|
|
242
|
-
slash(slasher: string, staker: string, escrowAddress: string, amount:
|
|
241
|
+
slash(slasher: string, staker: string, escrowAddress: string, amount: bigint, txOptions?: Overrides): Promise<void>;
|
|
243
242
|
/**
|
|
244
243
|
* This function allocates a portion of the staked tokens to a specific escrow.
|
|
245
244
|
*
|
|
@@ -247,7 +246,7 @@ export declare class StakingClient extends BaseEthersClient {
|
|
|
247
246
|
*
|
|
248
247
|
* @param {string} escrowAddress Address of the escrow contract to allocate in.
|
|
249
248
|
* @param {Overrides} [txOptions] - Additional transaction parameters (optional, defaults to an empty object).
|
|
250
|
-
* @param {
|
|
249
|
+
* @param {bigint} amount Amount in WEI of tokens to allocate.
|
|
251
250
|
* @returns Returns void if successful. Throws error if any.
|
|
252
251
|
*
|
|
253
252
|
*
|
|
@@ -264,11 +263,11 @@ export declare class StakingClient extends BaseEthersClient {
|
|
|
264
263
|
* const signer = new Wallet(privateKey, provider);
|
|
265
264
|
* const stakingClient = await StakingClient.build(signer);
|
|
266
265
|
*
|
|
267
|
-
* const amount = ethers.
|
|
266
|
+
* const amount = ethers.parseUnits(5, 'ether'); //convert from ETH to WEI
|
|
268
267
|
* await stakingClient.allocate('0x62dD51230A30401C455c8398d06F85e4EaB6309f', amount);
|
|
269
268
|
* ```
|
|
270
269
|
*/
|
|
271
|
-
allocate(escrowAddress: string, amount:
|
|
270
|
+
allocate(escrowAddress: string, amount: bigint, txOptions?: Overrides): Promise<void>;
|
|
272
271
|
/**
|
|
273
272
|
* This function drops the allocation from a specific escrow.
|
|
274
273
|
*
|
|
@@ -324,50 +323,6 @@ export declare class StakingClient extends BaseEthersClient {
|
|
|
324
323
|
* ```
|
|
325
324
|
*/
|
|
326
325
|
distributeReward(escrowAddress: string, txOptions?: Overrides): Promise<void>;
|
|
327
|
-
/**
|
|
328
|
-
* This function returns all the leader details of the protocol.
|
|
329
|
-
*
|
|
330
|
-
* @param {ILeadersFilter} filter Filter for the leaders.
|
|
331
|
-
* @returns {ILeader[]} Returns an array with all the leader details.
|
|
332
|
-
*
|
|
333
|
-
*
|
|
334
|
-
* **Code example**
|
|
335
|
-
*
|
|
336
|
-
* ```ts
|
|
337
|
-
* import { StakingClient } from '@human-protocol/sdk';
|
|
338
|
-
* import { providers } from 'ethers';
|
|
339
|
-
*
|
|
340
|
-
* const rpcUrl = 'YOUR_RPC_URL';
|
|
341
|
-
*
|
|
342
|
-
* const provider = new providers.JsonRpcProvider(rpcUrl);
|
|
343
|
-
* const stakingClient = await StakingClient.build(provider);
|
|
344
|
-
*
|
|
345
|
-
* const leaders = await stakingClient.getLeaders();
|
|
346
|
-
* ```
|
|
347
|
-
*/
|
|
348
|
-
getLeader(address: string): Promise<ILeader>;
|
|
349
|
-
/**
|
|
350
|
-
* This function returns the leader data for the given address.
|
|
351
|
-
*
|
|
352
|
-
* @param {string} address Leader address.
|
|
353
|
-
* @returns {ILeader} Returns the leader details.
|
|
354
|
-
*
|
|
355
|
-
*
|
|
356
|
-
* **Code example**
|
|
357
|
-
*
|
|
358
|
-
* ```ts
|
|
359
|
-
* import { StakingClient } from '@human-protocol/sdk';
|
|
360
|
-
* import { providers } from 'ethers';
|
|
361
|
-
*
|
|
362
|
-
* const rpcUrl = 'YOUR_RPC_URL';
|
|
363
|
-
*
|
|
364
|
-
* const provider = new providers.JsonRpcProvider(rpcUrl);
|
|
365
|
-
* const stakingClient = await StakingClient.build(provider);
|
|
366
|
-
*
|
|
367
|
-
* const leader = await stakingClient.getLeader('0x62dD51230A30401C455c8398d06F85e4EaB6309f');
|
|
368
|
-
* ```
|
|
369
|
-
*/
|
|
370
|
-
getLeaders(filter?: ILeadersFilter): Promise<ILeader[]>;
|
|
371
326
|
/**
|
|
372
327
|
* This function returns information about the allocation of the specified escrow.
|
|
373
328
|
*
|
|
@@ -390,27 +345,5 @@ export declare class StakingClient extends BaseEthersClient {
|
|
|
390
345
|
* ```
|
|
391
346
|
*/
|
|
392
347
|
getAllocation(escrowAddress: string): Promise<IAllocation>;
|
|
393
|
-
/**
|
|
394
|
-
* This function returns information about the rewards for a given slasher address.
|
|
395
|
-
*
|
|
396
|
-
* @param {string} slasherAddress Slasher address.
|
|
397
|
-
* @returns {IReward[]} Returns an array of Reward objects that contain the rewards earned by the user through slashing other users.
|
|
398
|
-
*
|
|
399
|
-
*
|
|
400
|
-
* **Code example**
|
|
401
|
-
*
|
|
402
|
-
* ```ts
|
|
403
|
-
* import { StakingClient } from '@human-protocol/sdk';
|
|
404
|
-
* import { providers } from 'ethers';
|
|
405
|
-
*
|
|
406
|
-
* const rpcUrl = 'YOUR_RPC_URL';
|
|
407
|
-
*
|
|
408
|
-
* const provider = new providers.JsonRpcProvider(rpcUrl);
|
|
409
|
-
* const stakingClient = await StakingClient.build(provider);
|
|
410
|
-
*
|
|
411
|
-
* const rewards = await stakingClient.getRewards('0x62dD51230A30401C455c8398d06F85e4EaB6309f');
|
|
412
|
-
* ```
|
|
413
|
-
*/
|
|
414
|
-
getRewards(slasherAddress: string): Promise<IReward[]>;
|
|
415
348
|
}
|
|
416
349
|
//# 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":"
|
|
1
|
+
{"version":3,"file":"staking.d.ts","sourceRoot":"","sources":["../src/staking.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,aAAa,EAEb,OAAO,EAEP,UAAU,EAEV,OAAO,EAER,MAAM,sCAAsC,CAAC;AAC9C,OAAO,EAAE,cAAc,EAAE,SAA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