@human-protocol/sdk 3.0.7 → 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 +2 -25
- package/dist/constants.d.ts.map +1 -1
- package/dist/constants.js +25 -66
- 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 +34 -36
- 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 +118 -112
- package/dist/escrow.d.ts.map +1 -1
- package/dist/escrow.js +254 -180
- package/dist/graphql/queries/operator.d.ts.map +1 -1
- package/dist/graphql/queries/operator.js +15 -7
- package/dist/graphql/queries/statistics.d.ts.map +1 -1
- package/dist/graphql/queries/statistics.js +0 -2
- package/dist/graphql/queries/transaction.d.ts.map +1 -1
- package/dist/graphql/queries/transaction.js +23 -10
- package/dist/graphql/types.d.ts +0 -2
- package/dist/graphql/types.d.ts.map +1 -1
- package/dist/interfaces.d.ts +29 -12
- package/dist/interfaces.d.ts.map +1 -1
- package/dist/kvstore.d.ts +16 -16
- package/dist/kvstore.d.ts.map +1 -1
- package/dist/kvstore.js +16 -16
- package/dist/operator.d.ts +11 -10
- package/dist/operator.d.ts.map +1 -1
- package/dist/operator.js +36 -11
- package/dist/staking.d.ts +26 -118
- package/dist/staking.d.ts.map +1 -1
- package/dist/staking.js +46 -173
- package/dist/statistics.d.ts +10 -29
- package/dist/statistics.d.ts.map +1 -1
- package/dist/statistics.js +13 -30
- package/dist/storage.d.ts +13 -18
- package/dist/storage.d.ts.map +1 -1
- package/dist/storage.js +30 -25
- package/dist/transaction.js +1 -1
- package/dist/types.d.ts +23 -6
- 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 +8 -4
- package/src/constants.ts +25 -66
- package/src/decorators.ts +1 -1
- package/src/encryption.ts +21 -29
- package/src/error.ts +39 -37
- package/src/escrow.ts +360 -216
- package/src/graphql/queries/operator.ts +15 -7
- package/src/graphql/queries/statistics.ts +0 -2
- package/src/graphql/queries/transaction.ts +23 -13
- package/src/graphql/types.ts +0 -2
- package/src/interfaces.ts +30 -13
- package/src/kvstore.ts +17 -17
- package/src/operator.ts +47 -12
- package/src/staking.ts +53 -187
- package/src/statistics.ts +13 -30
- package/src/storage.ts +13 -18
- package/src/transaction.ts +2 -2
- package/src/types.ts +24 -6
- package/src/utils.ts +0 -1
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
|
*
|
|
@@ -43,28 +44,33 @@ class OperatorUtils {
|
|
|
43
44
|
return leader || null;
|
|
44
45
|
}
|
|
45
46
|
let jobTypes = [];
|
|
47
|
+
let reputationNetworks = [];
|
|
46
48
|
if (typeof leader.jobTypes === 'string') {
|
|
47
49
|
jobTypes = leader.jobTypes.split(',');
|
|
48
50
|
}
|
|
49
51
|
else if (Array.isArray(leader.jobTypes)) {
|
|
50
52
|
jobTypes = leader.jobTypes;
|
|
51
53
|
}
|
|
54
|
+
if (leader.reputationNetworks && Array.isArray(leader.reputationNetworks)) {
|
|
55
|
+
reputationNetworks = leader.reputationNetworks.map((network) => network.address);
|
|
56
|
+
}
|
|
52
57
|
return {
|
|
53
58
|
...leader,
|
|
54
59
|
jobTypes,
|
|
60
|
+
reputationNetworks,
|
|
61
|
+
chainId,
|
|
55
62
|
};
|
|
56
63
|
}
|
|
57
64
|
/**
|
|
58
65
|
* This function returns all the leader details of the protocol.
|
|
59
66
|
*
|
|
60
67
|
* @param {ILeadersFilter} filter Filter for the leaders.
|
|
61
|
-
* @returns {ILeader[]} Returns an array with all the leader details.
|
|
62
|
-
*
|
|
68
|
+
* @returns {Promise<ILeader[]>} Returns an array with all the leader details.
|
|
63
69
|
*
|
|
64
70
|
* **Code example**
|
|
65
71
|
*
|
|
66
72
|
* ```ts
|
|
67
|
-
* import { OperatorUtils } from '@human-protocol/sdk';
|
|
73
|
+
* import { OperatorUtils, ChainId } from '@human-protocol/sdk';
|
|
68
74
|
*
|
|
69
75
|
* const filter: ILeadersFilter = {
|
|
70
76
|
* chainId: ChainId.POLYGON
|
|
@@ -74,27 +80,44 @@ class OperatorUtils {
|
|
|
74
80
|
*/
|
|
75
81
|
static async getLeaders(filter) {
|
|
76
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;
|
|
77
88
|
const networkData = constants_1.NETWORKS[filter.chainId];
|
|
78
89
|
if (!networkData) {
|
|
79
90
|
throw error_1.ErrorUnsupportedChainID;
|
|
80
91
|
}
|
|
81
92
|
const { leaders } = await (0, graphql_request_1.default)((0, utils_1.getSubgraphUrl)(networkData), (0, operator_1.GET_LEADERS_QUERY)(filter), {
|
|
82
|
-
|
|
93
|
+
minAmountStaked: filter?.minAmountStaked,
|
|
94
|
+
roles: filter?.roles,
|
|
95
|
+
orderBy: filter?.orderBy,
|
|
96
|
+
orderDirection: orderDirection,
|
|
97
|
+
first: first,
|
|
98
|
+
skip: skip,
|
|
83
99
|
});
|
|
84
100
|
if (!leaders) {
|
|
85
101
|
return [];
|
|
86
102
|
}
|
|
87
103
|
leaders_data = leaders_data.concat(leaders.map((leader) => {
|
|
88
104
|
let jobTypes = [];
|
|
105
|
+
let reputationNetworks = [];
|
|
89
106
|
if (typeof leader.jobTypes === 'string') {
|
|
90
107
|
jobTypes = leader.jobTypes.split(',');
|
|
91
108
|
}
|
|
92
109
|
else if (Array.isArray(leader.jobTypes)) {
|
|
93
110
|
jobTypes = leader.jobTypes;
|
|
94
111
|
}
|
|
112
|
+
if (leader.reputationNetworks &&
|
|
113
|
+
Array.isArray(leader.reputationNetworks)) {
|
|
114
|
+
reputationNetworks = leader.reputationNetworks.map((network) => network.address);
|
|
115
|
+
}
|
|
95
116
|
return {
|
|
96
117
|
...leader,
|
|
97
118
|
jobTypes,
|
|
119
|
+
reputationNetworks,
|
|
120
|
+
chainId: filter.chainId,
|
|
98
121
|
};
|
|
99
122
|
}));
|
|
100
123
|
return leaders_data;
|
|
@@ -102,12 +125,14 @@ class OperatorUtils {
|
|
|
102
125
|
/**
|
|
103
126
|
* Retrieves the reputation network operators of the specified address.
|
|
104
127
|
*
|
|
105
|
-
* @param {
|
|
128
|
+
* @param {ChainId} chainId Network in which the reputation network is deployed
|
|
129
|
+
* @param {string} address Address of the reputation oracle.
|
|
106
130
|
* @param {string} [role] - (Optional) Role of the operator.
|
|
107
131
|
* @returns {Promise<IOperator[]>} - Returns an array of operator details.
|
|
108
132
|
*
|
|
109
|
-
*
|
|
110
|
-
*
|
|
133
|
+
* **Code example**
|
|
134
|
+
*
|
|
135
|
+
* ```ts
|
|
111
136
|
* import { OperatorUtils, ChainId } from '@human-protocol/sdk';
|
|
112
137
|
*
|
|
113
138
|
* const operators = await OperatorUtils.getReputationNetworkOperators(ChainId.POLYGON_AMOY, '0x62dD51230A30401C455c8398d06F85e4EaB6309f');
|
|
@@ -141,9 +166,9 @@ class OperatorUtils {
|
|
|
141
166
|
/**
|
|
142
167
|
* This function returns information about the rewards for a given slasher address.
|
|
143
168
|
*
|
|
169
|
+
* @param {ChainId} chainId Network in which the rewards are deployed
|
|
144
170
|
* @param {string} slasherAddress Slasher address.
|
|
145
|
-
* @returns {IReward[]} Returns an array of Reward objects that contain the rewards earned by the user through slashing other users.
|
|
146
|
-
*
|
|
171
|
+
* @returns {Promise<IReward[]>} Returns an array of Reward objects that contain the rewards earned by the user through slashing other users.
|
|
147
172
|
*
|
|
148
173
|
* **Code example**
|
|
149
174
|
*
|
package/dist/staking.d.ts
CHANGED
|
@@ -1,24 +1,24 @@
|
|
|
1
|
-
import { EscrowFactory, HMToken,
|
|
1
|
+
import { EscrowFactory, HMToken, Staking } from '@human-protocol/core/typechain-types';
|
|
2
2
|
import { ContractRunner, Overrides } from 'ethers';
|
|
3
3
|
import { BaseEthersClient } from './base';
|
|
4
|
-
import { IAllocation } from './interfaces';
|
|
5
4
|
import { NetworkData } from './types';
|
|
5
|
+
import { StakerInfo } from './interfaces';
|
|
6
6
|
/**
|
|
7
7
|
* ## Introduction
|
|
8
8
|
*
|
|
9
|
-
* This client enables
|
|
9
|
+
* This client enables performing actions on staking contracts and obtaining staking 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<StakingClient>;
|
|
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 { NetworkData } from './types';
|
|
|
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 { StakingClient } 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 stakingClient = await StakingClient.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';
|
|
@@ -76,19 +76,17 @@ export declare class StakingClient extends BaseEthersClient {
|
|
|
76
76
|
tokenContract: HMToken;
|
|
77
77
|
stakingContract: Staking;
|
|
78
78
|
escrowFactoryContract: EscrowFactory;
|
|
79
|
-
rewardPoolContract: RewardPool;
|
|
80
79
|
/**
|
|
81
80
|
* **StakingClient constructor**
|
|
82
81
|
*
|
|
83
82
|
* @param {ContractRunner} runner - The Runner object to interact with the Ethereum network
|
|
84
|
-
* @param {NetworkData}
|
|
83
|
+
* @param {NetworkData} networkData - The network information required to connect to the Staking contract
|
|
85
84
|
*/
|
|
86
85
|
constructor(runner: ContractRunner, networkData: NetworkData);
|
|
87
86
|
/**
|
|
88
87
|
* Creates an instance of StakingClient from a Runner.
|
|
89
88
|
*
|
|
90
89
|
* @param {ContractRunner} runner - The Runner object to interact with the Ethereum network
|
|
91
|
-
* @param {number | undefined} gasPriceMultiplier - The multiplier to apply to the gas price
|
|
92
90
|
*
|
|
93
91
|
* @returns {Promise<StakingClient>} - An instance of StakingClient
|
|
94
92
|
* @throws {ErrorProviderDoesNotExist} - Thrown if the provider does not exist for the provided Signer
|
|
@@ -108,7 +106,6 @@ export declare class StakingClient extends BaseEthersClient {
|
|
|
108
106
|
* @param {Overrides} [txOptions] - Additional transaction parameters (optional, defaults to an empty object).
|
|
109
107
|
* @returns Returns void if successful. Throws error if any.
|
|
110
108
|
*
|
|
111
|
-
*
|
|
112
109
|
* **Code example**
|
|
113
110
|
*
|
|
114
111
|
* ```ts
|
|
@@ -116,7 +113,7 @@ export declare class StakingClient extends BaseEthersClient {
|
|
|
116
113
|
* import { StakingClient } from '@human-protocol/sdk';
|
|
117
114
|
*
|
|
118
115
|
* const rpcUrl = 'YOUR_RPC_URL';
|
|
119
|
-
* const privateKey = 'YOUR_PRIVATE_KEY'
|
|
116
|
+
* const privateKey = 'YOUR_PRIVATE_KEY';
|
|
120
117
|
*
|
|
121
118
|
* const provider = new providers.JsonRpcProvider(rpcUrl);
|
|
122
119
|
* const signer = new Wallet(privateKey, provider);
|
|
@@ -136,7 +133,6 @@ export declare class StakingClient extends BaseEthersClient {
|
|
|
136
133
|
* @param {Overrides} [txOptions] - Additional transaction parameters (optional, defaults to an empty object).
|
|
137
134
|
* @returns Returns void if successful. Throws error if any.
|
|
138
135
|
*
|
|
139
|
-
*
|
|
140
136
|
* **Code example**
|
|
141
137
|
*
|
|
142
138
|
* ```ts
|
|
@@ -144,7 +140,7 @@ export declare class StakingClient extends BaseEthersClient {
|
|
|
144
140
|
* import { StakingClient } from '@human-protocol/sdk';
|
|
145
141
|
*
|
|
146
142
|
* const rpcUrl = 'YOUR_RPC_URL';
|
|
147
|
-
* const privateKey = 'YOUR_PRIVATE_KEY'
|
|
143
|
+
* const privateKey = 'YOUR_PRIVATE_KEY';
|
|
148
144
|
*
|
|
149
145
|
* const provider = new providers.JsonRpcProvider(rpcUrl);
|
|
150
146
|
* const signer = new Wallet(privateKey, provider);
|
|
@@ -152,7 +148,7 @@ export declare class StakingClient extends BaseEthersClient {
|
|
|
152
148
|
*
|
|
153
149
|
* const amount = ethers.parseUnits(5, 'ether'); //convert from ETH to WEI
|
|
154
150
|
* await stakingClient.approveStake(amount); // if it was already approved before, this is not necessary
|
|
155
|
-
* await stakingClient.
|
|
151
|
+
* await stakingClient.stake(amount);
|
|
156
152
|
* ```
|
|
157
153
|
*/
|
|
158
154
|
stake(amount: bigint, txOptions?: Overrides): Promise<void>;
|
|
@@ -165,7 +161,6 @@ export declare class StakingClient extends BaseEthersClient {
|
|
|
165
161
|
* @param {Overrides} [txOptions] - Additional transaction parameters (optional, defaults to an empty object).
|
|
166
162
|
* @returns Returns void if successful. Throws error if any.
|
|
167
163
|
*
|
|
168
|
-
*
|
|
169
164
|
* **Code example**
|
|
170
165
|
*
|
|
171
166
|
* ```ts
|
|
@@ -173,7 +168,7 @@ export declare class StakingClient extends BaseEthersClient {
|
|
|
173
168
|
* import { StakingClient } from '@human-protocol/sdk';
|
|
174
169
|
*
|
|
175
170
|
* const rpcUrl = 'YOUR_RPC_URL';
|
|
176
|
-
* const privateKey = 'YOUR_PRIVATE_KEY'
|
|
171
|
+
* const privateKey = 'YOUR_PRIVATE_KEY';
|
|
177
172
|
*
|
|
178
173
|
* const provider = new providers.JsonRpcProvider(rpcUrl);
|
|
179
174
|
* const signer = new Wallet(privateKey, provider);
|
|
@@ -185,14 +180,13 @@ export declare class StakingClient extends BaseEthersClient {
|
|
|
185
180
|
*/
|
|
186
181
|
unstake(amount: bigint, txOptions?: Overrides): Promise<void>;
|
|
187
182
|
/**
|
|
188
|
-
* This function withdraws unstaked and non
|
|
183
|
+
* This function withdraws unstaked and non-locked tokens from staking contract to the user wallet.
|
|
189
184
|
*
|
|
190
185
|
* > Must have tokens available to withdraw
|
|
191
186
|
*
|
|
192
187
|
* @param {Overrides} [txOptions] - Additional transaction parameters (optional, defaults to an empty object).
|
|
193
188
|
* @returns Returns void if successful. Throws error if any.
|
|
194
189
|
*
|
|
195
|
-
*
|
|
196
190
|
* **Code example**
|
|
197
191
|
*
|
|
198
192
|
* ```ts
|
|
@@ -200,7 +194,7 @@ export declare class StakingClient extends BaseEthersClient {
|
|
|
200
194
|
* import { StakingClient } from '@human-protocol/sdk';
|
|
201
195
|
*
|
|
202
196
|
* const rpcUrl = 'YOUR_RPC_URL';
|
|
203
|
-
* const privateKey = 'YOUR_PRIVATE_KEY'
|
|
197
|
+
* const privateKey = 'YOUR_PRIVATE_KEY';
|
|
204
198
|
*
|
|
205
199
|
* const provider = new providers.JsonRpcProvider(rpcUrl);
|
|
206
200
|
* const signer = new Wallet(privateKey, provider);
|
|
@@ -211,16 +205,15 @@ export declare class StakingClient extends BaseEthersClient {
|
|
|
211
205
|
*/
|
|
212
206
|
withdraw(txOptions?: Overrides): Promise<void>;
|
|
213
207
|
/**
|
|
214
|
-
* 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.
|
|
215
209
|
*
|
|
216
210
|
* @param {string} slasher Wallet address from who requested the slash
|
|
217
211
|
* @param {string} staker Wallet address from who is going to be slashed
|
|
218
|
-
* @param {string} escrowAddress Address of the escrow
|
|
212
|
+
* @param {string} escrowAddress Address of the escrow that the slash is made
|
|
213
|
+
* @param {bigint} amount Amount in WEI of tokens to slash.
|
|
219
214
|
* @param {Overrides} [txOptions] - Additional transaction parameters (optional, defaults to an empty object).
|
|
220
|
-
* @param {bigint} amount Amount in WEI of tokens to unstake.
|
|
221
215
|
* @returns Returns void if successful. Throws error if any.
|
|
222
216
|
*
|
|
223
|
-
*
|
|
224
217
|
* **Code example**
|
|
225
218
|
*
|
|
226
219
|
* ```ts
|
|
@@ -228,7 +221,7 @@ export declare class StakingClient extends BaseEthersClient {
|
|
|
228
221
|
* import { StakingClient } from '@human-protocol/sdk';
|
|
229
222
|
*
|
|
230
223
|
* const rpcUrl = 'YOUR_RPC_URL';
|
|
231
|
-
* const privateKey = 'YOUR_PRIVATE_KEY'
|
|
224
|
+
* const privateKey = 'YOUR_PRIVATE_KEY';
|
|
232
225
|
*
|
|
233
226
|
* const provider = new providers.JsonRpcProvider(rpcUrl);
|
|
234
227
|
* const signer = new Wallet(privateKey, provider);
|
|
@@ -240,110 +233,25 @@ export declare class StakingClient extends BaseEthersClient {
|
|
|
240
233
|
*/
|
|
241
234
|
slash(slasher: string, staker: string, escrowAddress: string, amount: bigint, txOptions?: Overrides): Promise<void>;
|
|
242
235
|
/**
|
|
243
|
-
*
|
|
244
|
-
*
|
|
245
|
-
* > Must have tokens staked
|
|
246
|
-
*
|
|
247
|
-
* @param {string} escrowAddress Address of the escrow contract to allocate in.
|
|
248
|
-
* @param {Overrides} [txOptions] - Additional transaction parameters (optional, defaults to an empty object).
|
|
249
|
-
* @param {bigint} amount Amount in WEI of tokens to allocate.
|
|
250
|
-
* @returns Returns void if successful. Throws error if any.
|
|
251
|
-
*
|
|
252
|
-
*
|
|
253
|
-
* **Code example**
|
|
254
|
-
*
|
|
255
|
-
* ```ts
|
|
256
|
-
* import { ethers, Wallet, providers } from 'ethers';
|
|
257
|
-
* import { StakingClient } from '@human-protocol/sdk';
|
|
258
|
-
*
|
|
259
|
-
* const rpcUrl = 'YOUR_RPC_URL';
|
|
260
|
-
* const privateKey = 'YOUR_PRIVATE_KEY'
|
|
261
|
-
*
|
|
262
|
-
* const provider = new providers.JsonRpcProvider(rpcUrl);
|
|
263
|
-
* const signer = new Wallet(privateKey, provider);
|
|
264
|
-
* const stakingClient = await StakingClient.build(signer);
|
|
265
|
-
*
|
|
266
|
-
* const amount = ethers.parseUnits(5, 'ether'); //convert from ETH to WEI
|
|
267
|
-
* await stakingClient.allocate('0x62dD51230A30401C455c8398d06F85e4EaB6309f', amount);
|
|
268
|
-
* ```
|
|
269
|
-
*/
|
|
270
|
-
allocate(escrowAddress: string, amount: bigint, txOptions?: Overrides): Promise<void>;
|
|
271
|
-
/**
|
|
272
|
-
* This function drops the allocation from a specific escrow.
|
|
273
|
-
*
|
|
274
|
-
* > The escrow must have allocation
|
|
275
|
-
* > The escrow must be cancelled or completed.
|
|
276
|
-
*
|
|
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).
|
|
279
|
-
* @returns Returns void if successful. Throws error if any.
|
|
280
|
-
*
|
|
281
|
-
*
|
|
282
|
-
* **Code example**
|
|
283
|
-
*
|
|
284
|
-
* ```ts
|
|
285
|
-
* import { Wallet, providers } from 'ethers';
|
|
286
|
-
* import { StakingClient } from '@human-protocol/sdk';
|
|
287
|
-
*
|
|
288
|
-
* const rpcUrl = 'YOUR_RPC_URL';
|
|
289
|
-
* const privateKey = 'YOUR_PRIVATE_KEY'
|
|
290
|
-
*
|
|
291
|
-
* const provider = new providers.JsonRpcProvider(rpcUrl);
|
|
292
|
-
* const signer = new Wallet(privateKey, provider);
|
|
293
|
-
* const stakingClient = await StakingClient.build(signer);
|
|
294
|
-
*
|
|
295
|
-
* await stakingClient.closeAllocation('0x62dD51230A30401C455c8398d06F85e4EaB6309f');
|
|
296
|
-
* ```
|
|
297
|
-
*/
|
|
298
|
-
closeAllocation(escrowAddress: string, txOptions?: Overrides): Promise<void>;
|
|
299
|
-
/**
|
|
300
|
-
* This function drops the allocation from a specific escrow.
|
|
301
|
-
*
|
|
302
|
-
* > The escrow must have rewards added
|
|
303
|
-
*
|
|
304
|
-
* @param {string} escrowAddress Escrow address from which rewards are distributed.
|
|
305
|
-
* @param {Overrides} [txOptions] - Additional transaction parameters (optional, defaults to an empty object).
|
|
306
|
-
* @returns Returns void if successful. Throws error if any.
|
|
307
|
-
*
|
|
308
|
-
*
|
|
309
|
-
* **Code example**
|
|
310
|
-
*
|
|
311
|
-
* ```ts
|
|
312
|
-
* import { Wallet, providers } from 'ethers';
|
|
313
|
-
* import { StakingClient } from '@human-protocol/sdk';
|
|
314
|
-
*
|
|
315
|
-
* const rpcUrl = 'YOUR_RPC_URL';
|
|
316
|
-
* const privateKey = 'YOUR_PRIVATE_KEY'
|
|
317
|
-
*
|
|
318
|
-
* const provider = new providers.JsonRpcProvider(rpcUrl);
|
|
319
|
-
* const signer = new Wallet(privateKey, provider);
|
|
320
|
-
* const stakingClient = await StakingClient.build(signer);
|
|
321
|
-
*
|
|
322
|
-
* await stakingClient.distributeReward('0x62dD51230A30401C455c8398d06F85e4EaB6309f');
|
|
323
|
-
* ```
|
|
324
|
-
*/
|
|
325
|
-
distributeReward(escrowAddress: string, txOptions?: Overrides): Promise<void>;
|
|
326
|
-
/**
|
|
327
|
-
* This function returns information about the allocation of the specified escrow.
|
|
328
|
-
*
|
|
329
|
-
* @param {string} escrowAddress Escrow address from which we want to get allocation information.
|
|
330
|
-
* @returns {IAllocation} Returns allocation info if exists.
|
|
236
|
+
* Retrieves comprehensive staking information for a staker.
|
|
331
237
|
*
|
|
238
|
+
* @param {string} stakerAddress - The address of the staker.
|
|
239
|
+
* @returns {Promise<StakerInfo>}
|
|
332
240
|
*
|
|
333
241
|
* **Code example**
|
|
334
242
|
*
|
|
335
243
|
* ```ts
|
|
336
244
|
* import { StakingClient } from '@human-protocol/sdk';
|
|
337
|
-
* import { providers } from 'ethers';
|
|
338
245
|
*
|
|
339
246
|
* const rpcUrl = 'YOUR_RPC_URL';
|
|
340
247
|
*
|
|
341
248
|
* const provider = new providers.JsonRpcProvider(rpcUrl);
|
|
342
249
|
* const stakingClient = await StakingClient.build(provider);
|
|
343
250
|
*
|
|
344
|
-
* const
|
|
251
|
+
* const stakingInfo = await stakingClient.getStakerInfo('0xYourStakerAddress');
|
|
252
|
+
* console.log(stakingInfo.tokensStaked);
|
|
345
253
|
* ```
|
|
346
254
|
*/
|
|
347
|
-
|
|
255
|
+
getStakerInfo(stakerAddress: string): Promise<StakerInfo>;
|
|
348
256
|
}
|
|
349
257
|
//# sourceMappingURL=staking.d.ts.map
|
package/dist/staking.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"staking.d.ts","sourceRoot":"","sources":["../src/staking.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,aAAa,EAEb,OAAO,EAEP,
|
|
1
|
+
{"version":3,"file":"staking.d.ts","sourceRoot":"","sources":["../src/staking.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,aAAa,EAEb,OAAO,EAEP,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,SAAS,CAAC;AAEtC,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE1C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoEG;AACH,qBAAa,aAAc,SAAQ,gBAAgB;IAC1C,aAAa,EAAE,OAAO,CAAC;IACvB,eAAe,EAAE,OAAO,CAAC;IACzB,qBAAqB,EAAE,aAAa,CAAC;IAE5C;;;;;OAKG;gBACS,MAAM,EAAE,cAAc,EAAE,WAAW,EAAE,WAAW;IAmB5D;;;;;;;;OAQG;WACiB,KAAK,CAAC,MAAM,EAAE,cAAc,GAAG,OAAO,CAAC,aAAa,CAAC;IAiBzE;;;;OAIG;YACW,gBAAgB;IAU9B;;;;;;;;;;;;;;;;;;;;;;;OAuBG;IAEU,YAAY,CACvB,MAAM,EAAE,MAAM,EACd,SAAS,GAAE,SAAc,GACxB,OAAO,CAAC,IAAI,CAAC;IAuBhB;;;;;;;;;;;;;;;;;;;;;;;;;;OA0BG;IAEU,KAAK,CAAC,MAAM,EAAE,MAAM,EAAE,SAAS,GAAE,SAAc,GAAG,OAAO,CAAC,IAAI,CAAC;IAiB5E;;;;;;;;;;;;;;;;;;;;;;;;;OAyBG;IAEU,OAAO,CAClB,MAAM,EAAE,MAAM,EACd,SAAS,GAAE,SAAc,GACxB,OAAO,CAAC,IAAI,CAAC;IAiBhB;;;;;;;;;;;;;;;;;;;;;;;OAuBG;IAEU,QAAQ,CAAC,SAAS,GAAE,SAAc,GAAG,OAAO,CAAC,IAAI,CAAC;IAS/D;;;;;;;;;;;;;;;;;;;;;;;;;;OA0BG;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;;;;;;;;;;;;;;;;;;;OAmBG;IACU,aAAa,CAAC,aAAa,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC;CAgCvE"}
|