@human-protocol/sdk 3.0.6 → 3.0.8
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 -24
- package/dist/constants.d.ts.map +1 -1
- package/dist/constants.js +23 -64
- package/dist/encryption.d.ts +6 -4
- package/dist/encryption.d.ts.map +1 -1
- package/dist/encryption.js +52 -16
- package/dist/escrow.d.ts +20 -57
- package/dist/escrow.d.ts.map +1 -1
- package/dist/escrow.js +74 -88
- package/dist/graphql/queries/operator.js +2 -2
- 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 +19 -10
- package/dist/interfaces.d.ts.map +1 -1
- package/dist/kvstore.d.ts +1 -1
- package/dist/kvstore.js +1 -1
- package/dist/operator.d.ts.map +1 -1
- package/dist/operator.js +13 -0
- package/dist/staking.d.ts +3 -112
- package/dist/staking.d.ts.map +1 -1
- package/dist/staking.js +2 -170
- package/dist/statistics.d.ts.map +1 -1
- package/dist/statistics.js +3 -1
- package/dist/storage.js +17 -7
- package/dist/types.d.ts +17 -4
- package/dist/types.d.ts.map +1 -1
- package/package.json +8 -4
- package/src/constants.ts +23 -64
- package/src/encryption.ts +47 -15
- package/src/escrow.ts +119 -103
- package/src/graphql/queries/operator.ts +2 -2
- 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 +19 -11
- package/src/kvstore.ts +1 -1
- package/src/operator.ts +21 -0
- package/src/staking.ts +2 -185
- package/src/statistics.ts +3 -1
- package/src/types.ts +18 -4
package/dist/staking.d.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
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';
|
|
6
5
|
/**
|
|
7
6
|
* ## Introduction
|
|
@@ -76,19 +75,17 @@ export declare class StakingClient extends BaseEthersClient {
|
|
|
76
75
|
tokenContract: HMToken;
|
|
77
76
|
stakingContract: Staking;
|
|
78
77
|
escrowFactoryContract: EscrowFactory;
|
|
79
|
-
rewardPoolContract: RewardPool;
|
|
80
78
|
/**
|
|
81
79
|
* **StakingClient constructor**
|
|
82
80
|
*
|
|
83
81
|
* @param {ContractRunner} runner - The Runner object to interact with the Ethereum network
|
|
84
|
-
* @param {NetworkData}
|
|
82
|
+
* @param {NetworkData} networkData - The network information required to connect to the Staking contract
|
|
85
83
|
*/
|
|
86
84
|
constructor(runner: ContractRunner, networkData: NetworkData);
|
|
87
85
|
/**
|
|
88
86
|
* Creates an instance of StakingClient from a Runner.
|
|
89
87
|
*
|
|
90
88
|
* @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
89
|
*
|
|
93
90
|
* @returns {Promise<StakingClient>} - An instance of StakingClient
|
|
94
91
|
* @throws {ErrorProviderDoesNotExist} - Thrown if the provider does not exist for the provided Signer
|
|
@@ -215,7 +212,7 @@ export declare class StakingClient extends BaseEthersClient {
|
|
|
215
212
|
*
|
|
216
213
|
* @param {string} slasher Wallet address from who requested the slash
|
|
217
214
|
* @param {string} staker Wallet address from who is going to be slashed
|
|
218
|
-
* @param {string} escrowAddress Address of the escrow
|
|
215
|
+
* @param {string} escrowAddress Address of the escrow that the slash is made
|
|
219
216
|
* @param {Overrides} [txOptions] - Additional transaction parameters (optional, defaults to an empty object).
|
|
220
217
|
* @param {bigint} amount Amount in WEI of tokens to unstake.
|
|
221
218
|
* @returns Returns void if successful. Throws error if any.
|
|
@@ -239,111 +236,5 @@ export declare class StakingClient extends BaseEthersClient {
|
|
|
239
236
|
* ```
|
|
240
237
|
*/
|
|
241
238
|
slash(slasher: string, staker: string, escrowAddress: string, amount: bigint, txOptions?: Overrides): Promise<void>;
|
|
242
|
-
/**
|
|
243
|
-
* This function allocates a portion of the staked tokens to a specific escrow.
|
|
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.
|
|
331
|
-
*
|
|
332
|
-
*
|
|
333
|
-
* **Code example**
|
|
334
|
-
*
|
|
335
|
-
* ```ts
|
|
336
|
-
* import { StakingClient } from '@human-protocol/sdk';
|
|
337
|
-
* import { providers } from 'ethers';
|
|
338
|
-
*
|
|
339
|
-
* const rpcUrl = 'YOUR_RPC_URL';
|
|
340
|
-
*
|
|
341
|
-
* const provider = new providers.JsonRpcProvider(rpcUrl);
|
|
342
|
-
* const stakingClient = await StakingClient.build(provider);
|
|
343
|
-
*
|
|
344
|
-
* const allocationInfo = await stakingClient.getAllocation('0x62dD51230A30401C455c8398d06F85e4EaB6309f');
|
|
345
|
-
* ```
|
|
346
|
-
*/
|
|
347
|
-
getAllocation(escrowAddress: string): Promise<IAllocation>;
|
|
348
239
|
}
|
|
349
240
|
//# 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,EAE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ACrB,MAAM,EAAE,MAAM,EACd,SAAS,GAAE,SAAc,GACxB,OAAO,CAAC,IAAI,CAAC;CAmCjB"}
|
package/dist/staking.js
CHANGED
|
@@ -91,20 +91,18 @@ class StakingClient extends base_1.BaseEthersClient {
|
|
|
91
91
|
* **StakingClient constructor**
|
|
92
92
|
*
|
|
93
93
|
* @param {ContractRunner} runner - The Runner object to interact with the Ethereum network
|
|
94
|
-
* @param {NetworkData}
|
|
94
|
+
* @param {NetworkData} networkData - The network information required to connect to the Staking contract
|
|
95
95
|
*/
|
|
96
96
|
constructor(runner, networkData) {
|
|
97
97
|
super(runner, networkData);
|
|
98
98
|
this.stakingContract = typechain_types_1.Staking__factory.connect(networkData.stakingAddress, runner);
|
|
99
99
|
this.escrowFactoryContract = typechain_types_1.EscrowFactory__factory.connect(networkData.factoryAddress, runner);
|
|
100
100
|
this.tokenContract = typechain_types_1.HMToken__factory.connect(networkData.hmtAddress, runner);
|
|
101
|
-
this.rewardPoolContract = typechain_types_1.RewardPool__factory.connect(networkData.rewardPoolAddress, this.runner);
|
|
102
101
|
}
|
|
103
102
|
/**
|
|
104
103
|
* Creates an instance of StakingClient from a Runner.
|
|
105
104
|
*
|
|
106
105
|
* @param {ContractRunner} runner - The Runner object to interact with the Ethereum network
|
|
107
|
-
* @param {number | undefined} gasPriceMultiplier - The multiplier to apply to the gas price
|
|
108
106
|
*
|
|
109
107
|
* @returns {Promise<StakingClient>} - An instance of StakingClient
|
|
110
108
|
* @throws {ErrorProviderDoesNotExist} - Thrown if the provider does not exist for the provided Signer
|
|
@@ -299,7 +297,7 @@ class StakingClient extends base_1.BaseEthersClient {
|
|
|
299
297
|
*
|
|
300
298
|
* @param {string} slasher Wallet address from who requested the slash
|
|
301
299
|
* @param {string} staker Wallet address from who is going to be slashed
|
|
302
|
-
* @param {string} escrowAddress Address of the escrow
|
|
300
|
+
* @param {string} escrowAddress Address of the escrow that the slash is made
|
|
303
301
|
* @param {Overrides} [txOptions] - Additional transaction parameters (optional, defaults to an empty object).
|
|
304
302
|
* @param {bigint} amount Amount in WEI of tokens to unstake.
|
|
305
303
|
* @returns Returns void if successful. Throws error if any.
|
|
@@ -344,154 +342,6 @@ class StakingClient extends base_1.BaseEthersClient {
|
|
|
344
342
|
return (0, utils_1.throwError)(e);
|
|
345
343
|
}
|
|
346
344
|
}
|
|
347
|
-
/**
|
|
348
|
-
* This function allocates a portion of the staked tokens to a specific escrow.
|
|
349
|
-
*
|
|
350
|
-
* > Must have tokens staked
|
|
351
|
-
*
|
|
352
|
-
* @param {string} escrowAddress Address of the escrow contract to allocate in.
|
|
353
|
-
* @param {Overrides} [txOptions] - Additional transaction parameters (optional, defaults to an empty object).
|
|
354
|
-
* @param {bigint} amount Amount in WEI of tokens to allocate.
|
|
355
|
-
* @returns Returns void if successful. Throws error if any.
|
|
356
|
-
*
|
|
357
|
-
*
|
|
358
|
-
* **Code example**
|
|
359
|
-
*
|
|
360
|
-
* ```ts
|
|
361
|
-
* import { ethers, Wallet, providers } from 'ethers';
|
|
362
|
-
* import { StakingClient } from '@human-protocol/sdk';
|
|
363
|
-
*
|
|
364
|
-
* const rpcUrl = 'YOUR_RPC_URL';
|
|
365
|
-
* const privateKey = 'YOUR_PRIVATE_KEY'
|
|
366
|
-
*
|
|
367
|
-
* const provider = new providers.JsonRpcProvider(rpcUrl);
|
|
368
|
-
* const signer = new Wallet(privateKey, provider);
|
|
369
|
-
* const stakingClient = await StakingClient.build(signer);
|
|
370
|
-
*
|
|
371
|
-
* const amount = ethers.parseUnits(5, 'ether'); //convert from ETH to WEI
|
|
372
|
-
* await stakingClient.allocate('0x62dD51230A30401C455c8398d06F85e4EaB6309f', amount);
|
|
373
|
-
* ```
|
|
374
|
-
*/
|
|
375
|
-
async allocate(escrowAddress, amount, txOptions = {}) {
|
|
376
|
-
if (typeof amount !== 'bigint') {
|
|
377
|
-
throw error_1.ErrorInvalidStakingValueType;
|
|
378
|
-
}
|
|
379
|
-
if (amount < 0n) {
|
|
380
|
-
throw error_1.ErrorInvalidStakingValueSign;
|
|
381
|
-
}
|
|
382
|
-
await this.checkValidEscrow(escrowAddress);
|
|
383
|
-
try {
|
|
384
|
-
await (await this.stakingContract.allocate(escrowAddress, amount, txOptions)).wait();
|
|
385
|
-
return;
|
|
386
|
-
}
|
|
387
|
-
catch (e) {
|
|
388
|
-
return (0, utils_1.throwError)(e);
|
|
389
|
-
}
|
|
390
|
-
}
|
|
391
|
-
/**
|
|
392
|
-
* This function drops the allocation from a specific escrow.
|
|
393
|
-
*
|
|
394
|
-
* > The escrow must have allocation
|
|
395
|
-
* > The escrow must be cancelled or completed.
|
|
396
|
-
*
|
|
397
|
-
* @param {string} escrowAddress Address of the escrow contract to close allocation from.
|
|
398
|
-
* @param {Overrides} [txOptions] - Additional transaction parameters (optional, defaults to an empty object).
|
|
399
|
-
* @returns Returns void if successful. Throws error if any.
|
|
400
|
-
*
|
|
401
|
-
*
|
|
402
|
-
* **Code example**
|
|
403
|
-
*
|
|
404
|
-
* ```ts
|
|
405
|
-
* import { Wallet, providers } from 'ethers';
|
|
406
|
-
* import { StakingClient } from '@human-protocol/sdk';
|
|
407
|
-
*
|
|
408
|
-
* const rpcUrl = 'YOUR_RPC_URL';
|
|
409
|
-
* const privateKey = 'YOUR_PRIVATE_KEY'
|
|
410
|
-
*
|
|
411
|
-
* const provider = new providers.JsonRpcProvider(rpcUrl);
|
|
412
|
-
* const signer = new Wallet(privateKey, provider);
|
|
413
|
-
* const stakingClient = await StakingClient.build(signer);
|
|
414
|
-
*
|
|
415
|
-
* await stakingClient.closeAllocation('0x62dD51230A30401C455c8398d06F85e4EaB6309f');
|
|
416
|
-
* ```
|
|
417
|
-
*/
|
|
418
|
-
async closeAllocation(escrowAddress, txOptions = {}) {
|
|
419
|
-
await this.checkValidEscrow(escrowAddress);
|
|
420
|
-
try {
|
|
421
|
-
await (await this.stakingContract.closeAllocation(escrowAddress, txOptions)).wait();
|
|
422
|
-
return;
|
|
423
|
-
}
|
|
424
|
-
catch (e) {
|
|
425
|
-
return (0, utils_1.throwError)(e);
|
|
426
|
-
}
|
|
427
|
-
}
|
|
428
|
-
/**
|
|
429
|
-
* This function drops the allocation from a specific escrow.
|
|
430
|
-
*
|
|
431
|
-
* > The escrow must have rewards added
|
|
432
|
-
*
|
|
433
|
-
* @param {string} escrowAddress Escrow address from which rewards are distributed.
|
|
434
|
-
* @param {Overrides} [txOptions] - Additional transaction parameters (optional, defaults to an empty object).
|
|
435
|
-
* @returns Returns void if successful. Throws error if any.
|
|
436
|
-
*
|
|
437
|
-
*
|
|
438
|
-
* **Code example**
|
|
439
|
-
*
|
|
440
|
-
* ```ts
|
|
441
|
-
* import { Wallet, providers } from 'ethers';
|
|
442
|
-
* import { StakingClient } from '@human-protocol/sdk';
|
|
443
|
-
*
|
|
444
|
-
* const rpcUrl = 'YOUR_RPC_URL';
|
|
445
|
-
* const privateKey = 'YOUR_PRIVATE_KEY'
|
|
446
|
-
*
|
|
447
|
-
* const provider = new providers.JsonRpcProvider(rpcUrl);
|
|
448
|
-
* const signer = new Wallet(privateKey, provider);
|
|
449
|
-
* const stakingClient = await StakingClient.build(signer);
|
|
450
|
-
*
|
|
451
|
-
* await stakingClient.distributeReward('0x62dD51230A30401C455c8398d06F85e4EaB6309f');
|
|
452
|
-
* ```
|
|
453
|
-
*/
|
|
454
|
-
async distributeReward(escrowAddress, txOptions = {}) {
|
|
455
|
-
await this.checkValidEscrow(escrowAddress);
|
|
456
|
-
try {
|
|
457
|
-
(await this.rewardPoolContract.distributeReward(escrowAddress, txOptions)).wait();
|
|
458
|
-
return;
|
|
459
|
-
}
|
|
460
|
-
catch (e) {
|
|
461
|
-
return (0, utils_1.throwError)(e);
|
|
462
|
-
}
|
|
463
|
-
}
|
|
464
|
-
/**
|
|
465
|
-
* This function returns information about the allocation of the specified escrow.
|
|
466
|
-
*
|
|
467
|
-
* @param {string} escrowAddress Escrow address from which we want to get allocation information.
|
|
468
|
-
* @returns {IAllocation} Returns allocation info if exists.
|
|
469
|
-
*
|
|
470
|
-
*
|
|
471
|
-
* **Code example**
|
|
472
|
-
*
|
|
473
|
-
* ```ts
|
|
474
|
-
* import { StakingClient } from '@human-protocol/sdk';
|
|
475
|
-
* import { providers } from 'ethers';
|
|
476
|
-
*
|
|
477
|
-
* const rpcUrl = 'YOUR_RPC_URL';
|
|
478
|
-
*
|
|
479
|
-
* const provider = new providers.JsonRpcProvider(rpcUrl);
|
|
480
|
-
* const stakingClient = await StakingClient.build(provider);
|
|
481
|
-
*
|
|
482
|
-
* const allocationInfo = await stakingClient.getAllocation('0x62dD51230A30401C455c8398d06F85e4EaB6309f');
|
|
483
|
-
* ```
|
|
484
|
-
*/
|
|
485
|
-
async getAllocation(escrowAddress) {
|
|
486
|
-
await this.checkValidEscrow(escrowAddress);
|
|
487
|
-
try {
|
|
488
|
-
const result = await this.stakingContract.getAllocation(escrowAddress);
|
|
489
|
-
return result;
|
|
490
|
-
}
|
|
491
|
-
catch (e) {
|
|
492
|
-
return (0, utils_1.throwError)(e);
|
|
493
|
-
}
|
|
494
|
-
}
|
|
495
345
|
}
|
|
496
346
|
exports.StakingClient = StakingClient;
|
|
497
347
|
__decorate([
|
|
@@ -524,21 +374,3 @@ __decorate([
|
|
|
524
374
|
__metadata("design:paramtypes", [String, String, String, BigInt, Object]),
|
|
525
375
|
__metadata("design:returntype", Promise)
|
|
526
376
|
], StakingClient.prototype, "slash", null);
|
|
527
|
-
__decorate([
|
|
528
|
-
decorators_1.requiresSigner,
|
|
529
|
-
__metadata("design:type", Function),
|
|
530
|
-
__metadata("design:paramtypes", [String, BigInt, Object]),
|
|
531
|
-
__metadata("design:returntype", Promise)
|
|
532
|
-
], StakingClient.prototype, "allocate", null);
|
|
533
|
-
__decorate([
|
|
534
|
-
decorators_1.requiresSigner,
|
|
535
|
-
__metadata("design:type", Function),
|
|
536
|
-
__metadata("design:paramtypes", [String, Object]),
|
|
537
|
-
__metadata("design:returntype", Promise)
|
|
538
|
-
], StakingClient.prototype, "closeAllocation", null);
|
|
539
|
-
__decorate([
|
|
540
|
-
decorators_1.requiresSigner,
|
|
541
|
-
__metadata("design:type", Function),
|
|
542
|
-
__metadata("design:paramtypes", [String, Object]),
|
|
543
|
-
__metadata("design:returntype", Promise)
|
|
544
|
-
], StakingClient.prototype, "distributeReward", null);
|
package/dist/statistics.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"statistics.d.ts","sourceRoot":"","sources":["../src/statistics.ts"],"names":[],"mappings":"AAIA,OAAO,EAKL,gBAAgB,EAGhB,aAAa,EAEb,iBAAiB,EACjB,gBAAgB,EAEhB,SAAS,EACT,YAAY,EACb,MAAM,WAAW,CAAC;AACnB,OAAO,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AACpE,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAItC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AACH,qBAAa,gBAAgB;IACpB,WAAW,EAAE,WAAW,CAAC;IACzB,WAAW,EAAE,MAAM,CAAC;IAE3B;;;;OAIG;gBACS,WAAW,EAAE,WAAW;IAKpC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAkDG;IACG,mBAAmB,CACvB,MAAM,GAAE,iBAAsB,GAC7B,OAAO,CAAC,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"statistics.d.ts","sourceRoot":"","sources":["../src/statistics.ts"],"names":[],"mappings":"AAIA,OAAO,EAKL,gBAAgB,EAGhB,aAAa,EAEb,iBAAiB,EACjB,gBAAgB,EAEhB,SAAS,EACT,YAAY,EACb,MAAM,WAAW,CAAC;AACnB,OAAO,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AACpE,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAItC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AACH,qBAAa,gBAAgB;IACpB,WAAW,EAAE,WAAW,CAAC;IACzB,WAAW,EAAE,MAAM,CAAC;IAE3B;;;;OAIG;gBACS,WAAW,EAAE,WAAW;IAKpC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAkDG;IACG,mBAAmB,CACvB,MAAM,GAAE,iBAAsB,GAC7B,OAAO,CAAC,gBAAgB,CAAC;IAuC5B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA6CG;IACG,mBAAmB,CACvB,MAAM,GAAE,iBAAsB,GAC7B,OAAO,CAAC,gBAAgB,CAAC;IA4B5B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAoEG;IACG,oBAAoB,CACxB,MAAM,GAAE,iBAAsB,GAC7B,OAAO,CAAC,iBAAiB,CAAC;IAkC7B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA6BG;IACG,gBAAgB,IAAI,OAAO,CAAC,aAAa,CAAC;IAkBhD;;;;;;;;;;;;;;;;;;;;;;;;OAwBG;IACG,aAAa,CAAC,MAAM,GAAE,iBAAsB,GAAG,OAAO,CAAC,SAAS,EAAE,CAAC;IAwBzE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAiDG;IACG,eAAe,CACnB,MAAM,GAAE,iBAAsB,GAC7B,OAAO,CAAC,YAAY,EAAE,CAAC;CA8B3B"}
|
package/dist/statistics.js
CHANGED
|
@@ -122,7 +122,9 @@ class StatisticsClient {
|
|
|
122
122
|
skip: skip,
|
|
123
123
|
});
|
|
124
124
|
return {
|
|
125
|
-
totalEscrows:
|
|
125
|
+
totalEscrows: escrowStatistics?.totalEscrowCount
|
|
126
|
+
? +escrowStatistics.totalEscrowCount
|
|
127
|
+
: 0,
|
|
126
128
|
dailyEscrowsData: eventDayDatas.map((eventDayData) => ({
|
|
127
129
|
timestamp: new Date(+eventDayData.timestamp * 1000),
|
|
128
130
|
escrowsTotal: +eventDayData.dailyEscrowCount,
|
package/dist/storage.js
CHANGED
|
@@ -15,13 +15,23 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
|
|
|
15
15
|
}) : function(o, v) {
|
|
16
16
|
o["default"] = v;
|
|
17
17
|
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
};
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
25
35
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
36
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
37
|
};
|
package/dist/types.d.ts
CHANGED
|
@@ -111,10 +111,6 @@ export type NetworkData = {
|
|
|
111
111
|
* Staking contract address
|
|
112
112
|
*/
|
|
113
113
|
stakingAddress: string;
|
|
114
|
-
/**
|
|
115
|
-
* RewardPool contract address
|
|
116
|
-
*/
|
|
117
|
-
rewardPoolAddress: string;
|
|
118
114
|
/**
|
|
119
115
|
* KVStore contract address
|
|
120
116
|
*/
|
|
@@ -149,4 +145,21 @@ export type EscrowCancel = {
|
|
|
149
145
|
*/
|
|
150
146
|
amountRefunded: bigint;
|
|
151
147
|
};
|
|
148
|
+
/**
|
|
149
|
+
* Represents the response data for an escrow withdrawal.
|
|
150
|
+
*/
|
|
151
|
+
export type EscrowWithdraw = {
|
|
152
|
+
/**
|
|
153
|
+
* The hash of the transaction associated with the escrow withdrawal.
|
|
154
|
+
*/
|
|
155
|
+
txHash: string;
|
|
156
|
+
/**
|
|
157
|
+
* The address of the token used for the withdrawal.
|
|
158
|
+
*/
|
|
159
|
+
tokenAddress: string;
|
|
160
|
+
/**
|
|
161
|
+
* The amount withdrawn from the escrow.
|
|
162
|
+
*/
|
|
163
|
+
amountWithdrawn: bigint;
|
|
164
|
+
};
|
|
152
165
|
//# sourceMappingURL=types.d.ts.map
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,oBAAY,YAAY;IACtB;;OAEG;IACH,QAAQ,IAAA;IACR;;OAEG;IACH,OAAO,IAAA;IACP;;OAEG;IACH,OAAO,IAAA;IACP;;OAEG;IACH,IAAI,IAAA;IACJ;;OAEG;IACH,QAAQ,IAAA;IACR;;OAEG;IACH,SAAS,IAAA;CACV;AAED;;;;GAIG;AACH,MAAM,MAAM,kBAAkB,GAAG;IAC/B;;OAEG;IACH,SAAS,EAAE,MAAM,CAAC;IAClB;;OAEG;IACH,SAAS,EAAE,MAAM,CAAC;CACnB,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,aAAa,GAAG;IAC1B;;OAEG;IACH,QAAQ,EAAE,MAAM,CAAC;IACjB;;OAEG;IACH,MAAM,EAAE,OAAO,CAAC;IAChB;;OAEG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;OAEG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;CACf,CAAC;AAEF;;;GAGG;AACH,MAAM,MAAM,UAAU,GAAG;I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MAAM,CAAC;IACZ;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;CACd,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,WAAW,GAAG;IACxB;;OAEG;IACH,OAAO,EAAE,MAAM,CAAC;IAChB;;OAEG;IACH,KAAK,EAAE,MAAM,CAAC;IACd;;OAEG;IACH,OAAO,EAAE,MAAM,CAAC;IAChB;;OAEG;IACH,UAAU,EAAE,MAAM,CAAC;IACnB;;OAEG;IACH,cAAc,EAAE,MAAM,CAAC;IACvB;;OAEG;IACH,cAAc,EAAE,MAAM,CAAC;IACvB;;OAEG;IACH,cAAc,EAAE,MAAM,CAAC;IACvB;;OAEG;IACH,WAAW,EAAE,MAAM,CAAC;IACpB;;OAEG;IACH,iBAAiB,EAAE,MAAM,CAAC;IAC1B;;OAEG;IACH,cAAc,EAAE,MAAM,CAAC;IACvB;;OAEG;IACH,iBAAiB,EAAE,MAAM,CAAC;CAC3B,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,YAAY,GAAG;IACzB;;OAEG;IACH,MAAM,EAAE,MAAM,CAAC;IACf;;OAEG;IACH,cAAc,EAAE,MAAM,CAAC;CACxB,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,cAAc,GAAG;IAC3B;;OAEG;IACH,MAAM,EAAE,MAAM,CAAC;IACf;;OAEG;IACH,YAAY,EAAE,MAAM,CAAC;IACrB;;OAEG;IACH,eAAe,EAAE,MAAM,CAAC;CACzB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@human-protocol/sdk",
|
|
3
3
|
"description": "Human Protocol SDK",
|
|
4
|
-
"version": "3.0.
|
|
4
|
+
"version": "3.0.8",
|
|
5
5
|
"files": [
|
|
6
6
|
"src",
|
|
7
7
|
"dist"
|
|
@@ -46,11 +46,11 @@
|
|
|
46
46
|
"graphql-tag": "^2.12.6",
|
|
47
47
|
"minio": "7.1.3",
|
|
48
48
|
"openpgp": "^5.11.2",
|
|
49
|
-
"secp256k1": "^
|
|
49
|
+
"secp256k1": "^5.0.1",
|
|
50
50
|
"vitest": "^1.6.0"
|
|
51
51
|
},
|
|
52
52
|
"devDependencies": {
|
|
53
|
-
"typedoc": "^0.
|
|
53
|
+
"typedoc": "^0.27.5",
|
|
54
54
|
"typedoc-plugin-markdown": "^4.2.3"
|
|
55
55
|
},
|
|
56
56
|
"typedocOptions": {
|
|
@@ -63,7 +63,11 @@
|
|
|
63
63
|
"./src/staking.ts",
|
|
64
64
|
"./src/storage.ts",
|
|
65
65
|
"./src/statistics.ts",
|
|
66
|
-
"./src/transaction.ts"
|
|
66
|
+
"./src/transaction.ts",
|
|
67
|
+
"./src/enums.ts",
|
|
68
|
+
"./src/graphql/types.ts",
|
|
69
|
+
"./src/interfaces.ts",
|
|
70
|
+
"./src/types.ts"
|
|
67
71
|
]
|
|
68
72
|
}
|
|
69
73
|
}
|