@human-protocol/sdk 1.1.18 → 2.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/base.d.ts +4 -13
- package/dist/base.d.ts.map +1 -1
- package/dist/base.js +3 -18
- package/dist/constants.d.ts +7 -0
- package/dist/constants.d.ts.map +1 -1
- package/dist/constants.js +18 -11
- package/dist/decorators.d.ts.map +1 -1
- package/dist/decorators.js +4 -2
- package/dist/encryption.d.ts +31 -0
- package/dist/encryption.d.ts.map +1 -1
- package/dist/encryption.js +37 -0
- package/dist/error.d.ts +0 -10
- package/dist/error.d.ts.map +1 -1
- package/dist/error.js +2 -18
- package/dist/escrow.d.ts +39 -33
- package/dist/escrow.d.ts.map +1 -1
- package/dist/escrow.js +121 -137
- 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 +14 -14
- package/dist/kvstore.d.ts.map +1 -1
- package/dist/kvstore.js +30 -48
- 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 +35 -95
- package/dist/staking.d.ts.map +1 -1
- package/dist/staking.js +73 -201
- 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 -15
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +9 -49
- package/package.json +4 -4
- package/src/base.ts +5 -30
- package/src/constants.ts +18 -10
- package/src/decorators.ts +3 -2
- package/src/encryption.ts +40 -0
- package/src/error.ts +0 -17
- package/src/escrow.ts +169 -178
- 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 +47 -59
- package/src/operator.ts +192 -0
- package/src/staking.ts +101 -213
- package/src/statistics.ts +8 -9
- package/src/types.ts +1 -3
- package/src/utils.ts +8 -58
- 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,22 +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
|
-
* @param {number | undefined} gasPriceMultiplier - The multiplier to apply to the gas price
|
|
87
85
|
*/
|
|
88
|
-
constructor(
|
|
86
|
+
constructor(runner: ContractRunner, networkData: NetworkData);
|
|
89
87
|
/**
|
|
90
|
-
* Creates an instance of StakingClient from a
|
|
88
|
+
* Creates an instance of StakingClient from a Runner.
|
|
91
89
|
*
|
|
92
|
-
* @param {
|
|
90
|
+
* @param {ContractRunner} runner - The Runner object to interact with the Ethereum network
|
|
93
91
|
* @param {number | undefined} gasPriceMultiplier - The multiplier to apply to the gas price
|
|
94
92
|
*
|
|
95
93
|
* @returns {Promise<StakingClient>} - An instance of StakingClient
|
|
96
94
|
* @throws {ErrorProviderDoesNotExist} - Thrown if the provider does not exist for the provided Signer
|
|
97
95
|
* @throws {ErrorUnsupportedChainID} - Thrown if the network's chainId is not supported
|
|
98
96
|
*/
|
|
99
|
-
static build(
|
|
97
|
+
static build(runner: ContractRunner): Promise<StakingClient>;
|
|
100
98
|
/**
|
|
101
99
|
* Check if escrow exists
|
|
102
100
|
*
|
|
@@ -106,7 +104,8 @@ export declare class StakingClient extends BaseEthersClient {
|
|
|
106
104
|
/**
|
|
107
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.
|
|
108
106
|
*
|
|
109
|
-
* @param {
|
|
107
|
+
* @param {bigint} amount Amount in WEI of tokens to approve for stake.
|
|
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
|
*
|
|
112
111
|
*
|
|
@@ -123,17 +122,18 @@ 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.
|
|
136
|
+
* @param {Overrides} [txOptions] - Additional transaction parameters (optional, defaults to an empty object).
|
|
137
137
|
* @returns Returns void if successful. Throws error if any.
|
|
138
138
|
*
|
|
139
139
|
*
|
|
@@ -150,18 +150,19 @@ export declare class StakingClient extends BaseEthersClient {
|
|
|
150
150
|
* const signer = new Wallet(privateKey, provider);
|
|
151
151
|
* const stakingClient = await StakingClient.build(signer);
|
|
152
152
|
*
|
|
153
|
-
* const amount = ethers.
|
|
153
|
+
* const amount = ethers.parseUnits(5, 'ether'); //convert from ETH to WEI
|
|
154
154
|
* await stakingClient.approveStake(amount); // if it was already approved before, this is not necessary
|
|
155
155
|
* await stakingClient.approveStake(amount);
|
|
156
156
|
* ```
|
|
157
157
|
*/
|
|
158
|
-
stake(amount:
|
|
158
|
+
stake(amount: bigint, txOptions?: Overrides): Promise<void>;
|
|
159
159
|
/**
|
|
160
160
|
* This function unstakes tokens from staking contract. The unstaked tokens stay locked for a period of time.
|
|
161
161
|
*
|
|
162
162
|
* > Must have tokens available to unstake
|
|
163
163
|
*
|
|
164
|
-
* @param {
|
|
164
|
+
* @param {bigint} amount Amount in WEI of tokens to unstake.
|
|
165
|
+
* @param {Overrides} [txOptions] - Additional transaction parameters (optional, defaults to an empty object).
|
|
165
166
|
* @returns Returns void if successful. Throws error if any.
|
|
166
167
|
*
|
|
167
168
|
*
|
|
@@ -178,16 +179,17 @@ export declare class StakingClient extends BaseEthersClient {
|
|
|
178
179
|
* const signer = new Wallet(privateKey, provider);
|
|
179
180
|
* const stakingClient = await StakingClient.build(signer);
|
|
180
181
|
*
|
|
181
|
-
* const amount = ethers.
|
|
182
|
+
* const amount = ethers.parseUnits(5, 'ether'); //convert from ETH to WEI
|
|
182
183
|
* await stakingClient.unstake(amount);
|
|
183
184
|
* ```
|
|
184
185
|
*/
|
|
185
|
-
unstake(amount:
|
|
186
|
+
unstake(amount: bigint, txOptions?: Overrides): Promise<void>;
|
|
186
187
|
/**
|
|
187
188
|
* This function withdraws unstaked and non locked tokens form staking contract to the user wallet.
|
|
188
189
|
*
|
|
189
190
|
* > Must have tokens available to withdraw
|
|
190
191
|
*
|
|
192
|
+
* @param {Overrides} [txOptions] - Additional transaction parameters (optional, defaults to an empty object).
|
|
191
193
|
* @returns Returns void if successful. Throws error if any.
|
|
192
194
|
*
|
|
193
195
|
*
|
|
@@ -207,14 +209,15 @@ export declare class StakingClient extends BaseEthersClient {
|
|
|
207
209
|
* await stakingClient.withdraw();
|
|
208
210
|
* ```
|
|
209
211
|
*/
|
|
210
|
-
withdraw(): Promise<void>;
|
|
212
|
+
withdraw(txOptions?: Overrides): Promise<void>;
|
|
211
213
|
/**
|
|
212
214
|
* This function reduces the allocated amount by an staker in an escrow and transfers those tokens to the reward pool. This allows the slasher to claim them later.
|
|
213
215
|
*
|
|
214
216
|
* @param {string} slasher Wallet address from who requested the slash
|
|
215
217
|
* @param {string} staker Wallet address from who is going to be slashed
|
|
216
218
|
* @param {string} escrowAddress Address of the escrow which allocation will be slashed
|
|
217
|
-
* @param {
|
|
219
|
+
* @param {Overrides} [txOptions] - Additional transaction parameters (optional, defaults to an empty object).
|
|
220
|
+
* @param {bigint} amount Amount in WEI of tokens to unstake.
|
|
218
221
|
* @returns Returns void if successful. Throws error if any.
|
|
219
222
|
*
|
|
220
223
|
*
|
|
@@ -231,18 +234,19 @@ export declare class StakingClient extends BaseEthersClient {
|
|
|
231
234
|
* const signer = new Wallet(privateKey, provider);
|
|
232
235
|
* const stakingClient = await StakingClient.build(signer);
|
|
233
236
|
*
|
|
234
|
-
* const amount = ethers.
|
|
237
|
+
* const amount = ethers.parseUnits(5, 'ether'); //convert from ETH to WEI
|
|
235
238
|
* await stakingClient.slash('0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266', '0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266', '0x62dD51230A30401C455c8398d06F85e4EaB6309f', amount);
|
|
236
239
|
* ```
|
|
237
240
|
*/
|
|
238
|
-
slash(slasher: string, staker: string, escrowAddress: string, amount:
|
|
241
|
+
slash(slasher: string, staker: string, escrowAddress: string, amount: bigint, txOptions?: Overrides): Promise<void>;
|
|
239
242
|
/**
|
|
240
243
|
* This function allocates a portion of the staked tokens to a specific escrow.
|
|
241
244
|
*
|
|
242
245
|
* > Must have tokens staked
|
|
243
246
|
*
|
|
244
247
|
* @param {string} escrowAddress Address of the escrow contract to allocate in.
|
|
245
|
-
* @param {
|
|
248
|
+
* @param {Overrides} [txOptions] - Additional transaction parameters (optional, defaults to an empty object).
|
|
249
|
+
* @param {bigint} amount Amount in WEI of tokens to allocate.
|
|
246
250
|
* @returns Returns void if successful. Throws error if any.
|
|
247
251
|
*
|
|
248
252
|
*
|
|
@@ -259,11 +263,11 @@ export declare class StakingClient extends BaseEthersClient {
|
|
|
259
263
|
* const signer = new Wallet(privateKey, provider);
|
|
260
264
|
* const stakingClient = await StakingClient.build(signer);
|
|
261
265
|
*
|
|
262
|
-
* const amount = ethers.
|
|
266
|
+
* const amount = ethers.parseUnits(5, 'ether'); //convert from ETH to WEI
|
|
263
267
|
* await stakingClient.allocate('0x62dD51230A30401C455c8398d06F85e4EaB6309f', amount);
|
|
264
268
|
* ```
|
|
265
269
|
*/
|
|
266
|
-
allocate(escrowAddress: string, amount:
|
|
270
|
+
allocate(escrowAddress: string, amount: bigint, txOptions?: Overrides): Promise<void>;
|
|
267
271
|
/**
|
|
268
272
|
* This function drops the allocation from a specific escrow.
|
|
269
273
|
*
|
|
@@ -271,6 +275,7 @@ export declare class StakingClient extends BaseEthersClient {
|
|
|
271
275
|
* > The escrow must be cancelled or completed.
|
|
272
276
|
*
|
|
273
277
|
* @param {string} escrowAddress Address of the escrow contract to close allocation from.
|
|
278
|
+
* @param {Overrides} [txOptions] - Additional transaction parameters (optional, defaults to an empty object).
|
|
274
279
|
* @returns Returns void if successful. Throws error if any.
|
|
275
280
|
*
|
|
276
281
|
*
|
|
@@ -290,13 +295,14 @@ export declare class StakingClient extends BaseEthersClient {
|
|
|
290
295
|
* await stakingClient.closeAllocation('0x62dD51230A30401C455c8398d06F85e4EaB6309f');
|
|
291
296
|
* ```
|
|
292
297
|
*/
|
|
293
|
-
closeAllocation(escrowAddress: string): Promise<void>;
|
|
298
|
+
closeAllocation(escrowAddress: string, txOptions?: Overrides): Promise<void>;
|
|
294
299
|
/**
|
|
295
300
|
* This function drops the allocation from a specific escrow.
|
|
296
301
|
*
|
|
297
302
|
* > The escrow must have rewards added
|
|
298
303
|
*
|
|
299
304
|
* @param {string} escrowAddress Escrow address from which rewards are distributed.
|
|
305
|
+
* @param {Overrides} [txOptions] - Additional transaction parameters (optional, defaults to an empty object).
|
|
300
306
|
* @returns Returns void if successful. Throws error if any.
|
|
301
307
|
*
|
|
302
308
|
*
|
|
@@ -316,51 +322,7 @@ export declare class StakingClient extends BaseEthersClient {
|
|
|
316
322
|
* await stakingClient.distributeReward('0x62dD51230A30401C455c8398d06F85e4EaB6309f');
|
|
317
323
|
* ```
|
|
318
324
|
*/
|
|
319
|
-
distributeReward(escrowAddress: string): Promise<void>;
|
|
320
|
-
/**
|
|
321
|
-
* This function returns all the leader details of the protocol.
|
|
322
|
-
*
|
|
323
|
-
* @param {ILeadersFilter} filter Filter for the leaders.
|
|
324
|
-
* @returns {ILeader[]} Returns an array with all the leader details.
|
|
325
|
-
*
|
|
326
|
-
*
|
|
327
|
-
* **Code example**
|
|
328
|
-
*
|
|
329
|
-
* ```ts
|
|
330
|
-
* import { StakingClient } from '@human-protocol/sdk';
|
|
331
|
-
* import { providers } from 'ethers';
|
|
332
|
-
*
|
|
333
|
-
* const rpcUrl = 'YOUR_RPC_URL';
|
|
334
|
-
*
|
|
335
|
-
* const provider = new providers.JsonRpcProvider(rpcUrl);
|
|
336
|
-
* const stakingClient = await StakingClient.build(provider);
|
|
337
|
-
*
|
|
338
|
-
* const leaders = await stakingClient.getLeaders();
|
|
339
|
-
* ```
|
|
340
|
-
*/
|
|
341
|
-
getLeader(address: string): Promise<ILeader>;
|
|
342
|
-
/**
|
|
343
|
-
* This function returns the leader data for the given address.
|
|
344
|
-
*
|
|
345
|
-
* @param {string} address Leader address.
|
|
346
|
-
* @returns {ILeader} Returns the leader details.
|
|
347
|
-
*
|
|
348
|
-
*
|
|
349
|
-
* **Code example**
|
|
350
|
-
*
|
|
351
|
-
* ```ts
|
|
352
|
-
* import { StakingClient } from '@human-protocol/sdk';
|
|
353
|
-
* import { providers } from 'ethers';
|
|
354
|
-
*
|
|
355
|
-
* const rpcUrl = 'YOUR_RPC_URL';
|
|
356
|
-
*
|
|
357
|
-
* const provider = new providers.JsonRpcProvider(rpcUrl);
|
|
358
|
-
* const stakingClient = await StakingClient.build(provider);
|
|
359
|
-
*
|
|
360
|
-
* const leader = await stakingClient.getLeader('0x62dD51230A30401C455c8398d06F85e4EaB6309f');
|
|
361
|
-
* ```
|
|
362
|
-
*/
|
|
363
|
-
getLeaders(filter?: ILeadersFilter): Promise<ILeader[]>;
|
|
325
|
+
distributeReward(escrowAddress: string, txOptions?: Overrides): Promise<void>;
|
|
364
326
|
/**
|
|
365
327
|
* This function returns information about the allocation of the specified escrow.
|
|
366
328
|
*
|
|
@@ -383,27 +345,5 @@ export declare class StakingClient extends BaseEthersClient {
|
|
|
383
345
|
* ```
|
|
384
346
|
*/
|
|
385
347
|
getAllocation(escrowAddress: string): Promise<IAllocation>;
|
|
386
|
-
/**
|
|
387
|
-
* This function returns information about the rewards for a given slasher address.
|
|
388
|
-
*
|
|
389
|
-
* @param {string} slasherAddress Slasher address.
|
|
390
|
-
* @returns {IReward[]} Returns an array of Reward objects that contain the rewards earned by the user through slashing other users.
|
|
391
|
-
*
|
|
392
|
-
*
|
|
393
|
-
* **Code example**
|
|
394
|
-
*
|
|
395
|
-
* ```ts
|
|
396
|
-
* import { StakingClient } from '@human-protocol/sdk';
|
|
397
|
-
* import { providers } from 'ethers';
|
|
398
|
-
*
|
|
399
|
-
* const rpcUrl = 'YOUR_RPC_URL';
|
|
400
|
-
*
|
|
401
|
-
* const provider = new providers.JsonRpcProvider(rpcUrl);
|
|
402
|
-
* const stakingClient = await StakingClient.build(provider);
|
|
403
|
-
*
|
|
404
|
-
* const rewards = await stakingClient.getRewards('0x62dD51230A30401C455c8398d06F85e4EaB6309f');
|
|
405
|
-
* ```
|
|
406
|
-
*/
|
|
407
|
-
getRewards(slasherAddress: string): Promise<IReward[]>;
|
|
408
348
|
}
|
|
409
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,SAAS,EAAU,MAAM,QAAQ,CAAC;AAC3D,OAAO,EAAE,gBAAgB,EAAE,MAAM,QAAQ,CAAC;AAc1C,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAC3C,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAGtC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoEG;AACH,qBAAa,aAAc,SAAQ,gBAAgB;IAC1C,aAAa,EAAE,OAAO,CAAC;IACvB,eAAe,EAAE,OAAO,CAAC;IACzB,qBAAqB,EAAE,aAAa,CAAC;IACrC,kBAAkB,EAAE,UAAU,CAAC;IAEtC;;;;;OAKG;gBACS,MAAM,EAAE,cAAc,EAAE,WAAW,EAAE,WAAW;IAwB5D;;;;;;;;;OASG;WACiB,KAAK,CAAC,MAAM,EAAE,cAAc;IAiBhD;;;;OAIG;YACW,gBAAgB;IAU9B;;;;;;;;;;;;;;;;;;;;;;;;OAwBG;IAEU,YAAY,CACvB,MAAM,EAAE,MAAM,EACd,SAAS,GAAE,SAAc,GACxB,OAAO,CAAC,IAAI,CAAC;IAuBhB;;;;;;;;;;;;;;;;;;;;;;;;;;;OA2BG;IAEU,KAAK,CAAC,MAAM,EAAE,MAAM,EAAE,SAAS,GAAE,SAAc,GAAG,OAAO,CAAC,IAAI,CAAC;IAiB5E;;;;;;;;;;;;;;;;;;;;;;;;;;OA0BG;IAEU,OAAO,CAClB,MAAM,EAAE,MAAM,EACd,SAAS,GAAE,SAAc,GACxB,OAAO,CAAC,IAAI,CAAC;IAiBhB;;;;;;;;;;;;;;;;;;;;;;;;OAwBG;IAEU,QAAQ,CAAC,SAAS,GAAE,SAAc,GAAG,OAAO,CAAC,IAAI,CAAC;IAS/D;;;;;;;;;;;;;;;;;;;;;;;;;;;OA2BG;IAEU,KAAK,CAChB,OAAO,EAAE,MAAM,EACf,MAAM,EAAE,MAAM,EACd,aAAa,EAAE,MAAM,EACrB,MAAM,EAAE,MAAM,EACd,SAAS,GAAE,SAAc,GACxB,OAAO,CAAC,IAAI,CAAC;IAoChB;;;;;;;;;;;;;;;;;;;;;;;;;;;OA2BG;IAEU,QAAQ,CACnB,aAAa,EAAE,MAAM,EACrB,MAAM,EAAE,MAAM,EACd,SAAS,GAAE,SAAc,GACxB,OAAO,CAAC,IAAI,CAAC;IAqBhB;;;;;;;;;;;;;;;;;;;;;;;;;;OA0BG;IAEU,eAAe,CAC1B,aAAa,EAAE,MAAM,EACrB,SAAS,GAAE,SAAc,GACxB,OAAO,CAAC,IAAI,CAAC;IAahB;;;;;;;;;;;;;;;;;;;;;;;;;OAyBG;IAEU,gBAAgB,CAC3B,aAAa,EAAE,MAAM,EACrB,SAAS,GAAE,SAAc,GACxB,OAAO,CAAC,IAAI,CAAC;IAahB;;;;;;;;;;;;;;;;;;;;OAoBG;IACU,aAAa,CAAC,aAAa,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC;CAUxE"}
|