@human-protocol/sdk 6.0.0 → 7.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/CHANGELOG.md +34 -0
- package/dist/base.d.ts +4 -2
- package/dist/base.d.ts.map +1 -1
- package/dist/base.js +14 -0
- package/dist/constants.d.ts +0 -1
- package/dist/constants.d.ts.map +1 -1
- package/dist/constants.js +27 -16
- package/dist/encryption/encryption.d.ts +84 -0
- package/dist/encryption/encryption.d.ts.map +1 -0
- package/dist/{encryption.js → encryption/encryption.js} +3 -161
- package/dist/encryption/encryption_utils.d.ts +101 -0
- package/dist/encryption/encryption_utils.d.ts.map +1 -0
- package/dist/encryption/encryption_utils.js +191 -0
- package/dist/encryption/index.d.ts +4 -0
- package/dist/encryption/index.d.ts.map +1 -0
- package/dist/encryption/index.js +7 -0
- package/dist/encryption/types.d.ts +9 -0
- package/dist/encryption/types.d.ts.map +1 -0
- package/dist/encryption/types.js +9 -0
- package/dist/error.d.ts +6 -10
- package/dist/error.d.ts.map +1 -1
- package/dist/error.js +12 -14
- package/dist/{escrow.d.ts → escrow/escrow_client.d.ts} +16 -196
- package/dist/escrow/escrow_client.d.ts.map +1 -0
- package/dist/{escrow.js → escrow/escrow_client.js} +50 -430
- package/dist/escrow/escrow_utils.d.ts +172 -0
- package/dist/escrow/escrow_utils.d.ts.map +1 -0
- package/dist/escrow/escrow_utils.js +388 -0
- package/dist/escrow/index.d.ts +3 -0
- package/dist/escrow/index.d.ts.map +1 -0
- package/dist/escrow/index.js +7 -0
- package/dist/graphql/queries/statistics.d.ts +1 -0
- package/dist/graphql/queries/statistics.d.ts.map +1 -1
- package/dist/graphql/queries/statistics.js +36 -2
- package/dist/graphql/types.d.ts +3 -1
- package/dist/graphql/types.d.ts.map +1 -1
- package/dist/index.d.ts +10 -10
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +23 -22
- package/dist/interfaces.d.ts +2 -7
- package/dist/interfaces.d.ts.map +1 -1
- package/dist/kvstore/index.d.ts +3 -0
- package/dist/kvstore/index.d.ts.map +1 -0
- package/dist/kvstore/index.js +7 -0
- package/dist/{kvstore.d.ts → kvstore/kvstore_client.d.ts} +7 -112
- package/dist/kvstore/kvstore_client.d.ts.map +1 -0
- package/dist/{kvstore.js → kvstore/kvstore_client.js} +25 -187
- package/dist/kvstore/kvstore_utils.d.ts +105 -0
- package/dist/kvstore/kvstore_utils.d.ts.map +1 -0
- package/dist/kvstore/kvstore_utils.js +184 -0
- package/dist/operator/index.d.ts +2 -0
- package/dist/operator/index.d.ts.map +1 -0
- package/dist/operator/index.js +5 -0
- package/dist/{operator.d.ts → operator/operator_utils.d.ts} +3 -3
- package/dist/operator/operator_utils.d.ts.map +1 -0
- package/dist/{operator.js → operator/operator_utils.js} +6 -6
- package/dist/staking/index.d.ts +3 -0
- package/dist/staking/index.d.ts.map +1 -0
- package/dist/staking/index.js +7 -0
- package/dist/{staking.d.ts → staking/staking_client.d.ts} +10 -71
- package/dist/staking/staking_client.d.ts.map +1 -0
- package/dist/{staking.js → staking/staking_client.js} +11 -141
- package/dist/staking/staking_utils.d.ts +63 -0
- package/dist/staking/staking_utils.d.ts.map +1 -0
- package/dist/staking/staking_utils.js +137 -0
- package/dist/statistics/index.d.ts +2 -0
- package/dist/statistics/index.d.ts.map +1 -0
- package/dist/statistics/index.js +5 -0
- package/dist/{statistics.d.ts → statistics/statistics_utils.d.ts} +4 -13
- package/dist/statistics/statistics_utils.d.ts.map +1 -0
- package/dist/{statistics.js → statistics/statistics_utils.js} +8 -22
- package/dist/transaction/index.d.ts +2 -0
- package/dist/transaction/index.d.ts.map +1 -0
- package/dist/transaction/index.js +5 -0
- package/dist/{transaction.d.ts → transaction/transaction_utils.d.ts} +5 -5
- package/dist/transaction/transaction_utils.d.ts.map +1 -0
- package/dist/{transaction.js → transaction/transaction_utils.js} +9 -9
- package/dist/types.d.ts +22 -1
- package/dist/types.d.ts.map +1 -1
- package/dist/utils.d.ts +16 -1
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +72 -6
- package/dist/worker/index.d.ts +2 -0
- package/dist/worker/index.d.ts.map +1 -0
- package/dist/worker/index.js +5 -0
- package/dist/{worker.d.ts → worker/worker_utils.d.ts} +3 -3
- package/dist/worker/worker_utils.d.ts.map +1 -0
- package/dist/{worker.js → worker/worker_utils.js} +5 -5
- package/package.json +5 -5
- package/src/base.ts +38 -2
- package/src/constants.ts +38 -16
- package/src/{encryption.ts → encryption/encryption.ts} +1 -193
- package/src/encryption/encryption_utils.ts +179 -0
- package/src/encryption/index.ts +3 -0
- package/src/encryption/types.ts +15 -0
- package/src/error.ts +11 -17
- package/src/{escrow.ts → escrow/escrow_client.ts} +151 -659
- package/src/escrow/escrow_utils.ts +510 -0
- package/src/escrow/index.ts +2 -0
- package/src/graphql/queries/statistics.ts +37 -1
- package/src/graphql/types.ts +4 -1
- package/src/index.ts +11 -25
- package/src/interfaces.ts +2 -7
- package/src/kvstore/index.ts +2 -0
- package/src/kvstore/kvstore_client.ts +291 -0
- package/src/kvstore/kvstore_utils.ts +244 -0
- package/src/operator/index.ts +1 -0
- package/src/{operator.ts → operator/operator_utils.ts} +8 -8
- package/src/staking/index.ts +2 -0
- package/src/{staking.ts → staking/staking_client.ts} +49 -199
- package/src/staking/staking_utils.ts +170 -0
- package/src/statistics/index.ts +1 -0
- package/src/{statistics.ts → statistics/statistics_utils.ts} +14 -26
- package/src/transaction/index.ts +1 -0
- package/src/{transaction.ts → transaction/transaction_utils.ts} +11 -11
- package/src/types.ts +24 -1
- package/src/utils.ts +82 -9
- package/src/worker/index.ts +1 -0
- package/src/{worker.ts → worker/worker_utils.ts} +7 -7
- package/dist/encryption.d.ts +0 -189
- package/dist/encryption.d.ts.map +0 -1
- package/dist/escrow.d.ts.map +0 -1
- package/dist/kvstore.d.ts.map +0 -1
- package/dist/operator.d.ts.map +0 -1
- package/dist/staking.d.ts.map +0 -1
- package/dist/statistics.d.ts.map +0 -1
- package/dist/transaction.d.ts.map +0 -1
- package/dist/worker.d.ts.map +0 -1
- package/src/kvstore.ts +0 -497
|
@@ -9,16 +9,14 @@ var __metadata = (this && this.__metadata) || function (k, v) {
|
|
|
9
9
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.
|
|
12
|
+
exports.StakingClient = void 0;
|
|
13
13
|
const typechain_types_1 = require("@human-protocol/core/typechain-types");
|
|
14
14
|
const ethers_1 = require("ethers");
|
|
15
|
-
const base_1 = require("
|
|
16
|
-
const constants_1 = require("
|
|
17
|
-
const decorators_1 = require("
|
|
18
|
-
const
|
|
19
|
-
const
|
|
20
|
-
const utils_1 = require("./utils");
|
|
21
|
-
const staking_1 = require("./graphql/queries/staking");
|
|
15
|
+
const base_1 = require("../base");
|
|
16
|
+
const constants_1 = require("../constants");
|
|
17
|
+
const decorators_1 = require("../decorators");
|
|
18
|
+
const error_1 = require("../error");
|
|
19
|
+
const utils_1 = require("../utils");
|
|
22
20
|
/**
|
|
23
21
|
* Client for staking actions on HUMAN Protocol.
|
|
24
22
|
*
|
|
@@ -158,7 +156,7 @@ class StakingClient extends base_1.BaseEthersClient {
|
|
|
158
156
|
throw error_1.ErrorInvalidStakingValueSign;
|
|
159
157
|
}
|
|
160
158
|
try {
|
|
161
|
-
await (
|
|
159
|
+
await this.sendTxAndWait(async (overrides) => this.tokenContract.approve(await this.stakingContract.getAddress(), amount, overrides), txOptions);
|
|
162
160
|
return;
|
|
163
161
|
}
|
|
164
162
|
catch (e) {
|
|
@@ -194,7 +192,7 @@ class StakingClient extends base_1.BaseEthersClient {
|
|
|
194
192
|
throw error_1.ErrorInvalidStakingValueSign;
|
|
195
193
|
}
|
|
196
194
|
try {
|
|
197
|
-
await (
|
|
195
|
+
await this.sendTxAndWait((overrides) => this.stakingContract.stake(amount, overrides), txOptions);
|
|
198
196
|
return;
|
|
199
197
|
}
|
|
200
198
|
catch (e) {
|
|
@@ -229,7 +227,7 @@ class StakingClient extends base_1.BaseEthersClient {
|
|
|
229
227
|
throw error_1.ErrorInvalidStakingValueSign;
|
|
230
228
|
}
|
|
231
229
|
try {
|
|
232
|
-
await (
|
|
230
|
+
await this.sendTxAndWait((overrides) => this.stakingContract.unstake(amount, overrides), txOptions);
|
|
233
231
|
return;
|
|
234
232
|
}
|
|
235
233
|
catch (e) {
|
|
@@ -251,7 +249,7 @@ class StakingClient extends base_1.BaseEthersClient {
|
|
|
251
249
|
*/
|
|
252
250
|
async withdraw(txOptions = {}) {
|
|
253
251
|
try {
|
|
254
|
-
await (
|
|
252
|
+
await this.sendTxAndWait((overrides) => this.stakingContract.withdraw(overrides), txOptions);
|
|
255
253
|
return;
|
|
256
254
|
}
|
|
257
255
|
catch (e) {
|
|
@@ -302,7 +300,7 @@ class StakingClient extends base_1.BaseEthersClient {
|
|
|
302
300
|
}
|
|
303
301
|
await this.checkValidEscrow(escrowAddress);
|
|
304
302
|
try {
|
|
305
|
-
await (
|
|
303
|
+
await this.sendTxAndWait((overrides) => this.stakingContract.slash(slasher, staker, escrowAddress, amount, overrides), txOptions);
|
|
306
304
|
return;
|
|
307
305
|
}
|
|
308
306
|
catch (e) {
|
|
@@ -380,131 +378,3 @@ __decorate([
|
|
|
380
378
|
__metadata("design:paramtypes", [String, String, String, BigInt, Object]),
|
|
381
379
|
__metadata("design:returntype", Promise)
|
|
382
380
|
], StakingClient.prototype, "slash", null);
|
|
383
|
-
/**
|
|
384
|
-
* Utility helpers for Staking-related queries.
|
|
385
|
-
*
|
|
386
|
-
* @example
|
|
387
|
-
* ```ts
|
|
388
|
-
* import { StakingUtils, ChainId } from '@human-protocol/sdk';
|
|
389
|
-
*
|
|
390
|
-
* const staker = await StakingUtils.getStaker(
|
|
391
|
-
* ChainId.POLYGON_AMOY,
|
|
392
|
-
* '0xYourStakerAddress'
|
|
393
|
-
* );
|
|
394
|
-
* console.log('Staked amount:', staker.stakedAmount);
|
|
395
|
-
* ```
|
|
396
|
-
*/
|
|
397
|
-
class StakingUtils {
|
|
398
|
-
/**
|
|
399
|
-
* Gets staking info for a staker from the subgraph.
|
|
400
|
-
*
|
|
401
|
-
* @param chainId - Network in which the staking contract is deployed
|
|
402
|
-
* @param stakerAddress - Address of the staker
|
|
403
|
-
* @param options - Optional configuration for subgraph requests.
|
|
404
|
-
* @returns Staker info from subgraph
|
|
405
|
-
* @throws ErrorInvalidStakerAddressProvided If the staker address is invalid
|
|
406
|
-
* @throws ErrorUnsupportedChainID If the chain ID is not supported
|
|
407
|
-
* @throws ErrorStakerNotFound If the staker is not found
|
|
408
|
-
*
|
|
409
|
-
* @example
|
|
410
|
-
* ```ts
|
|
411
|
-
* import { StakingUtils, ChainId } from '@human-protocol/sdk';
|
|
412
|
-
*
|
|
413
|
-
* const staker = await StakingUtils.getStaker(
|
|
414
|
-
* ChainId.POLYGON_AMOY,
|
|
415
|
-
* '0xYourStakerAddress'
|
|
416
|
-
* );
|
|
417
|
-
* console.log('Staked amount:', staker.stakedAmount);
|
|
418
|
-
* ```
|
|
419
|
-
*/
|
|
420
|
-
static async getStaker(chainId, stakerAddress, options) {
|
|
421
|
-
if (!ethers_1.ethers.isAddress(stakerAddress)) {
|
|
422
|
-
throw error_1.ErrorInvalidStakerAddressProvided;
|
|
423
|
-
}
|
|
424
|
-
const networkData = constants_1.NETWORKS[chainId];
|
|
425
|
-
if (!networkData) {
|
|
426
|
-
throw error_1.ErrorUnsupportedChainID;
|
|
427
|
-
}
|
|
428
|
-
const { staker } = await (0, utils_1.customGqlFetch)((0, utils_1.getSubgraphUrl)(networkData), staking_1.GET_STAKER_BY_ADDRESS_QUERY, { id: stakerAddress.toLowerCase() }, options);
|
|
429
|
-
if (!staker) {
|
|
430
|
-
throw error_1.ErrorStakerNotFound;
|
|
431
|
-
}
|
|
432
|
-
return mapStaker(staker);
|
|
433
|
-
}
|
|
434
|
-
/**
|
|
435
|
-
* Gets all stakers from the subgraph with filters, pagination and ordering.
|
|
436
|
-
*
|
|
437
|
-
* @param filter - Stakers filter with pagination and ordering
|
|
438
|
-
* @param options - Optional configuration for subgraph requests.
|
|
439
|
-
* @returns Array of stakers
|
|
440
|
-
* @throws ErrorUnsupportedChainID If the chain ID is not supported
|
|
441
|
-
*
|
|
442
|
-
* @example
|
|
443
|
-
* ```ts
|
|
444
|
-
* import { ChainId } from '@human-protocol/sdk';
|
|
445
|
-
*
|
|
446
|
-
* const filter = {
|
|
447
|
-
* chainId: ChainId.POLYGON_AMOY,
|
|
448
|
-
* minStakedAmount: '1000000000000000000', // 1 token in WEI
|
|
449
|
-
* };
|
|
450
|
-
* const stakers = await StakingUtils.getStakers(filter);
|
|
451
|
-
* console.log('Stakers:', stakers.length);
|
|
452
|
-
* ```
|
|
453
|
-
*/
|
|
454
|
-
static async getStakers(filter, options) {
|
|
455
|
-
const first = filter.first !== undefined ? Math.min(filter.first, 1000) : 10;
|
|
456
|
-
const skip = filter.skip || 0;
|
|
457
|
-
const orderDirection = filter.orderDirection || enums_1.OrderDirection.DESC;
|
|
458
|
-
const orderBy = filter.orderBy || 'lastDepositTimestamp';
|
|
459
|
-
const networkData = constants_1.NETWORKS[filter.chainId];
|
|
460
|
-
if (!networkData) {
|
|
461
|
-
throw error_1.ErrorUnsupportedChainID;
|
|
462
|
-
}
|
|
463
|
-
const { stakers } = await (0, utils_1.customGqlFetch)((0, utils_1.getSubgraphUrl)(networkData), (0, staking_1.GET_STAKERS_QUERY)(filter), {
|
|
464
|
-
minStakedAmount: filter.minStakedAmount
|
|
465
|
-
? filter.minStakedAmount
|
|
466
|
-
: undefined,
|
|
467
|
-
maxStakedAmount: filter.maxStakedAmount
|
|
468
|
-
? filter.maxStakedAmount
|
|
469
|
-
: undefined,
|
|
470
|
-
minLockedAmount: filter.minLockedAmount
|
|
471
|
-
? filter.minLockedAmount
|
|
472
|
-
: undefined,
|
|
473
|
-
maxLockedAmount: filter.maxLockedAmount
|
|
474
|
-
? filter.maxLockedAmount
|
|
475
|
-
: undefined,
|
|
476
|
-
minWithdrawnAmount: filter.minWithdrawnAmount
|
|
477
|
-
? filter.minWithdrawnAmount
|
|
478
|
-
: undefined,
|
|
479
|
-
maxWithdrawnAmount: filter.maxWithdrawnAmount
|
|
480
|
-
? filter.maxWithdrawnAmount
|
|
481
|
-
: undefined,
|
|
482
|
-
minSlashedAmount: filter.minSlashedAmount
|
|
483
|
-
? filter.minSlashedAmount
|
|
484
|
-
: undefined,
|
|
485
|
-
maxSlashedAmount: filter.maxSlashedAmount
|
|
486
|
-
? filter.maxSlashedAmount
|
|
487
|
-
: undefined,
|
|
488
|
-
orderBy: orderBy,
|
|
489
|
-
orderDirection: orderDirection,
|
|
490
|
-
first: first,
|
|
491
|
-
skip: skip,
|
|
492
|
-
}, options);
|
|
493
|
-
if (!stakers) {
|
|
494
|
-
return [];
|
|
495
|
-
}
|
|
496
|
-
return stakers.map((s) => mapStaker(s));
|
|
497
|
-
}
|
|
498
|
-
}
|
|
499
|
-
exports.StakingUtils = StakingUtils;
|
|
500
|
-
function mapStaker(s) {
|
|
501
|
-
return {
|
|
502
|
-
address: s.address,
|
|
503
|
-
stakedAmount: BigInt(s.stakedAmount),
|
|
504
|
-
lockedAmount: BigInt(s.lockedAmount),
|
|
505
|
-
withdrawableAmount: BigInt(s.withdrawnAmount),
|
|
506
|
-
slashedAmount: BigInt(s.slashedAmount),
|
|
507
|
-
lockedUntil: Number(s.lockedUntilTimestamp) * 1000,
|
|
508
|
-
lastDepositTimestamp: Number(s.lastDepositTimestamp) * 1000,
|
|
509
|
-
};
|
|
510
|
-
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { ChainId } from '../enums';
|
|
2
|
+
import { IStaker, IStakersFilter, SubgraphOptions } from '../interfaces';
|
|
3
|
+
/**
|
|
4
|
+
* Utility helpers for Staking-related queries.
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* ```ts
|
|
8
|
+
* import { StakingUtils, ChainId } from '@human-protocol/sdk';
|
|
9
|
+
*
|
|
10
|
+
* const staker = await StakingUtils.getStaker(
|
|
11
|
+
* ChainId.POLYGON_AMOY,
|
|
12
|
+
* '0xYourStakerAddress'
|
|
13
|
+
* );
|
|
14
|
+
* console.log('Staked amount:', staker.stakedAmount);
|
|
15
|
+
* ```
|
|
16
|
+
*/
|
|
17
|
+
export declare class StakingUtils {
|
|
18
|
+
/**
|
|
19
|
+
* Gets staking info for a staker from the subgraph.
|
|
20
|
+
*
|
|
21
|
+
* @param chainId - Network in which the staking contract is deployed
|
|
22
|
+
* @param stakerAddress - Address of the staker
|
|
23
|
+
* @param options - Optional configuration for subgraph requests.
|
|
24
|
+
* @returns Staker info from subgraph
|
|
25
|
+
* @throws ErrorInvalidStakerAddressProvided If the staker address is invalid
|
|
26
|
+
* @throws ErrorUnsupportedChainID If the chain ID is not supported
|
|
27
|
+
* @throws ErrorStakerNotFound If the staker is not found
|
|
28
|
+
*
|
|
29
|
+
* @example
|
|
30
|
+
* ```ts
|
|
31
|
+
* import { StakingUtils, ChainId } from '@human-protocol/sdk';
|
|
32
|
+
*
|
|
33
|
+
* const staker = await StakingUtils.getStaker(
|
|
34
|
+
* ChainId.POLYGON_AMOY,
|
|
35
|
+
* '0xYourStakerAddress'
|
|
36
|
+
* );
|
|
37
|
+
* console.log('Staked amount:', staker.stakedAmount);
|
|
38
|
+
* ```
|
|
39
|
+
*/
|
|
40
|
+
static getStaker(chainId: ChainId, stakerAddress: string, options?: SubgraphOptions): Promise<IStaker>;
|
|
41
|
+
/**
|
|
42
|
+
* Gets all stakers from the subgraph with filters, pagination and ordering.
|
|
43
|
+
*
|
|
44
|
+
* @param filter - Stakers filter with pagination and ordering
|
|
45
|
+
* @param options - Optional configuration for subgraph requests.
|
|
46
|
+
* @returns Array of stakers
|
|
47
|
+
* @throws ErrorUnsupportedChainID If the chain ID is not supported
|
|
48
|
+
*
|
|
49
|
+
* @example
|
|
50
|
+
* ```ts
|
|
51
|
+
* import { ChainId } from '@human-protocol/sdk';
|
|
52
|
+
*
|
|
53
|
+
* const filter = {
|
|
54
|
+
* chainId: ChainId.POLYGON_AMOY,
|
|
55
|
+
* minStakedAmount: '1000000000000000000', // 1 token in WEI
|
|
56
|
+
* };
|
|
57
|
+
* const stakers = await StakingUtils.getStakers(filter);
|
|
58
|
+
* console.log('Stakers:', stakers.length);
|
|
59
|
+
* ```
|
|
60
|
+
*/
|
|
61
|
+
static getStakers(filter: IStakersFilter, options?: SubgraphOptions): Promise<IStaker[]>;
|
|
62
|
+
}
|
|
63
|
+
//# sourceMappingURL=staking_utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"staking_utils.d.ts","sourceRoot":"","sources":["../../src/staking/staking_utils.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,EAAkB,MAAM,UAAU,CAAC;AAWnD,OAAO,EAAE,OAAO,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAGzE;;;;;;;;;;;;;GAaG;AACH,qBAAa,YAAY;IACvB;;;;;;;;;;;;;;;;;;;;;OAqBG;WACiB,SAAS,CAC3B,OAAO,EAAE,OAAO,EAChB,aAAa,EAAE,MAAM,EACrB,OAAO,CAAC,EAAE,eAAe,GACxB,OAAO,CAAC,OAAO,CAAC;IAwBnB;;;;;;;;;;;;;;;;;;;OAmBG;WACiB,UAAU,CAC5B,MAAM,EAAE,cAAc,EACtB,OAAO,CAAC,EAAE,eAAe,GACxB,OAAO,CAAC,OAAO,EAAE,CAAC;CAqDtB"}
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.StakingUtils = void 0;
|
|
4
|
+
const ethers_1 = require("ethers");
|
|
5
|
+
const constants_1 = require("../constants");
|
|
6
|
+
const enums_1 = require("../enums");
|
|
7
|
+
const error_1 = require("../error");
|
|
8
|
+
const staking_1 = require("../graphql/queries/staking");
|
|
9
|
+
const utils_1 = require("../utils");
|
|
10
|
+
/**
|
|
11
|
+
* Utility helpers for Staking-related queries.
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* ```ts
|
|
15
|
+
* import { StakingUtils, ChainId } from '@human-protocol/sdk';
|
|
16
|
+
*
|
|
17
|
+
* const staker = await StakingUtils.getStaker(
|
|
18
|
+
* ChainId.POLYGON_AMOY,
|
|
19
|
+
* '0xYourStakerAddress'
|
|
20
|
+
* );
|
|
21
|
+
* console.log('Staked amount:', staker.stakedAmount);
|
|
22
|
+
* ```
|
|
23
|
+
*/
|
|
24
|
+
class StakingUtils {
|
|
25
|
+
/**
|
|
26
|
+
* Gets staking info for a staker from the subgraph.
|
|
27
|
+
*
|
|
28
|
+
* @param chainId - Network in which the staking contract is deployed
|
|
29
|
+
* @param stakerAddress - Address of the staker
|
|
30
|
+
* @param options - Optional configuration for subgraph requests.
|
|
31
|
+
* @returns Staker info from subgraph
|
|
32
|
+
* @throws ErrorInvalidStakerAddressProvided If the staker address is invalid
|
|
33
|
+
* @throws ErrorUnsupportedChainID If the chain ID is not supported
|
|
34
|
+
* @throws ErrorStakerNotFound If the staker is not found
|
|
35
|
+
*
|
|
36
|
+
* @example
|
|
37
|
+
* ```ts
|
|
38
|
+
* import { StakingUtils, ChainId } from '@human-protocol/sdk';
|
|
39
|
+
*
|
|
40
|
+
* const staker = await StakingUtils.getStaker(
|
|
41
|
+
* ChainId.POLYGON_AMOY,
|
|
42
|
+
* '0xYourStakerAddress'
|
|
43
|
+
* );
|
|
44
|
+
* console.log('Staked amount:', staker.stakedAmount);
|
|
45
|
+
* ```
|
|
46
|
+
*/
|
|
47
|
+
static async getStaker(chainId, stakerAddress, options) {
|
|
48
|
+
if (!ethers_1.ethers.isAddress(stakerAddress)) {
|
|
49
|
+
throw error_1.ErrorInvalidStakerAddressProvided;
|
|
50
|
+
}
|
|
51
|
+
const networkData = constants_1.NETWORKS[chainId];
|
|
52
|
+
if (!networkData) {
|
|
53
|
+
throw error_1.ErrorUnsupportedChainID;
|
|
54
|
+
}
|
|
55
|
+
const { staker } = await (0, utils_1.customGqlFetch)((0, utils_1.getSubgraphUrl)(networkData), staking_1.GET_STAKER_BY_ADDRESS_QUERY, { id: stakerAddress.toLowerCase() }, options);
|
|
56
|
+
if (!staker) {
|
|
57
|
+
throw error_1.ErrorStakerNotFound;
|
|
58
|
+
}
|
|
59
|
+
return mapStaker(staker);
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Gets all stakers from the subgraph with filters, pagination and ordering.
|
|
63
|
+
*
|
|
64
|
+
* @param filter - Stakers filter with pagination and ordering
|
|
65
|
+
* @param options - Optional configuration for subgraph requests.
|
|
66
|
+
* @returns Array of stakers
|
|
67
|
+
* @throws ErrorUnsupportedChainID If the chain ID is not supported
|
|
68
|
+
*
|
|
69
|
+
* @example
|
|
70
|
+
* ```ts
|
|
71
|
+
* import { ChainId } from '@human-protocol/sdk';
|
|
72
|
+
*
|
|
73
|
+
* const filter = {
|
|
74
|
+
* chainId: ChainId.POLYGON_AMOY,
|
|
75
|
+
* minStakedAmount: '1000000000000000000', // 1 token in WEI
|
|
76
|
+
* };
|
|
77
|
+
* const stakers = await StakingUtils.getStakers(filter);
|
|
78
|
+
* console.log('Stakers:', stakers.length);
|
|
79
|
+
* ```
|
|
80
|
+
*/
|
|
81
|
+
static async getStakers(filter, options) {
|
|
82
|
+
const first = filter.first !== undefined ? Math.min(filter.first, 1000) : 10;
|
|
83
|
+
const skip = filter.skip || 0;
|
|
84
|
+
const orderDirection = filter.orderDirection || enums_1.OrderDirection.DESC;
|
|
85
|
+
const orderBy = filter.orderBy || 'lastDepositTimestamp';
|
|
86
|
+
const networkData = constants_1.NETWORKS[filter.chainId];
|
|
87
|
+
if (!networkData) {
|
|
88
|
+
throw error_1.ErrorUnsupportedChainID;
|
|
89
|
+
}
|
|
90
|
+
const { stakers } = await (0, utils_1.customGqlFetch)((0, utils_1.getSubgraphUrl)(networkData), (0, staking_1.GET_STAKERS_QUERY)(filter), {
|
|
91
|
+
minStakedAmount: filter.minStakedAmount
|
|
92
|
+
? filter.minStakedAmount
|
|
93
|
+
: undefined,
|
|
94
|
+
maxStakedAmount: filter.maxStakedAmount
|
|
95
|
+
? filter.maxStakedAmount
|
|
96
|
+
: undefined,
|
|
97
|
+
minLockedAmount: filter.minLockedAmount
|
|
98
|
+
? filter.minLockedAmount
|
|
99
|
+
: undefined,
|
|
100
|
+
maxLockedAmount: filter.maxLockedAmount
|
|
101
|
+
? filter.maxLockedAmount
|
|
102
|
+
: undefined,
|
|
103
|
+
minWithdrawnAmount: filter.minWithdrawnAmount
|
|
104
|
+
? filter.minWithdrawnAmount
|
|
105
|
+
: undefined,
|
|
106
|
+
maxWithdrawnAmount: filter.maxWithdrawnAmount
|
|
107
|
+
? filter.maxWithdrawnAmount
|
|
108
|
+
: undefined,
|
|
109
|
+
minSlashedAmount: filter.minSlashedAmount
|
|
110
|
+
? filter.minSlashedAmount
|
|
111
|
+
: undefined,
|
|
112
|
+
maxSlashedAmount: filter.maxSlashedAmount
|
|
113
|
+
? filter.maxSlashedAmount
|
|
114
|
+
: undefined,
|
|
115
|
+
orderBy: orderBy,
|
|
116
|
+
orderDirection: orderDirection,
|
|
117
|
+
first: first,
|
|
118
|
+
skip: skip,
|
|
119
|
+
}, options);
|
|
120
|
+
if (!stakers) {
|
|
121
|
+
return [];
|
|
122
|
+
}
|
|
123
|
+
return stakers.map((s) => mapStaker(s));
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
exports.StakingUtils = StakingUtils;
|
|
127
|
+
function mapStaker(s) {
|
|
128
|
+
return {
|
|
129
|
+
address: s.address,
|
|
130
|
+
stakedAmount: BigInt(s.stakedAmount),
|
|
131
|
+
lockedAmount: BigInt(s.lockedAmount),
|
|
132
|
+
withdrawableAmount: BigInt(s.withdrawnAmount),
|
|
133
|
+
slashedAmount: BigInt(s.slashedAmount),
|
|
134
|
+
lockedUntil: Number(s.lockedUntilTimestamp) * 1000,
|
|
135
|
+
lastDepositTimestamp: Number(s.lastDepositTimestamp) * 1000,
|
|
136
|
+
};
|
|
137
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/statistics/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.StatisticsUtils = void 0;
|
|
4
|
+
var statistics_utils_1 = require("./statistics_utils");
|
|
5
|
+
Object.defineProperty(exports, "StatisticsUtils", { enumerable: true, get: function () { return statistics_utils_1.StatisticsUtils; } });
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { IDailyHMT, IEscrowStatistics, IHMTHolder, IHMTHoldersParams, IHMTStatistics, IPaymentStatistics, IStatisticsFilter, IWorkerStatistics, SubgraphOptions } from '
|
|
2
|
-
import { NetworkData } from '
|
|
1
|
+
import { IDailyHMT, IEscrowStatistics, IHMTHolder, IHMTHoldersParams, IHMTStatistics, IPaymentStatistics, IStatisticsFilter, IWorkerStatistics, SubgraphOptions } from '../interfaces';
|
|
2
|
+
import { NetworkData } from '../types';
|
|
3
3
|
/**
|
|
4
4
|
* Utility class for statistics-related queries.
|
|
5
5
|
*
|
|
@@ -139,9 +139,7 @@ export declare class StatisticsUtils {
|
|
|
139
139
|
* ```ts
|
|
140
140
|
* interface IDailyPayment {
|
|
141
141
|
* timestamp: number;
|
|
142
|
-
* totalAmountPaid: bigint;
|
|
143
142
|
* totalCount: number;
|
|
144
|
-
* averageAmountPerWorker: bigint;
|
|
145
143
|
* };
|
|
146
144
|
*
|
|
147
145
|
* interface IPaymentStatistics {
|
|
@@ -160,14 +158,7 @@ export declare class StatisticsUtils {
|
|
|
160
158
|
*
|
|
161
159
|
* const networkData = NETWORKS[ChainId.POLYGON_AMOY];
|
|
162
160
|
* const paymentStats = await StatisticsUtils.getPaymentStatistics(networkData);
|
|
163
|
-
* console.log(
|
|
164
|
-
* 'Payment statistics:',
|
|
165
|
-
* paymentStats.dailyPaymentsData.map((p) => ({
|
|
166
|
-
* ...p,
|
|
167
|
-
* totalAmountPaid: p.totalAmountPaid.toString(),
|
|
168
|
-
* averageAmountPerWorker: p.averageAmountPerWorker.toString(),
|
|
169
|
-
* }))
|
|
170
|
-
* );
|
|
161
|
+
* console.log('Payment statistics:', paymentStats.dailyPaymentsData);
|
|
171
162
|
*
|
|
172
163
|
* const paymentStatsRange = await StatisticsUtils.getPaymentStatistics(
|
|
173
164
|
* networkData,
|
|
@@ -281,4 +272,4 @@ export declare class StatisticsUtils {
|
|
|
281
272
|
*/
|
|
282
273
|
static getHMTDailyData(networkData: NetworkData, filter?: IStatisticsFilter, options?: SubgraphOptions): Promise<IDailyHMT[]>;
|
|
283
274
|
}
|
|
284
|
-
//# sourceMappingURL=
|
|
275
|
+
//# sourceMappingURL=statistics_utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"statistics_utils.d.ts","sourceRoot":"","sources":["../../src/statistics/statistics_utils.ts"],"names":[],"mappings":"AAcA,OAAO,EACL,SAAS,EACT,iBAAiB,EACjB,UAAU,EACV,iBAAiB,EACjB,cAAc,EACd,kBAAkB,EAClB,iBAAiB,EACjB,iBAAiB,EACjB,eAAe,EAChB,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AASvC;;;;;;;;;;;;;;GAcG;AACH,qBAAa,eAAe;IAC1B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAqDG;WACU,mBAAmB,CAC9B,WAAW,EAAE,WAAW,EACxB,MAAM,GAAE,iBAAsB,EAC9B,OAAO,CAAC,EAAE,eAAe,GACxB,OAAO,CAAC,iBAAiB,CAAC;IA6C7B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAgDG;WACU,mBAAmB,CAC9B,WAAW,EAAE,WAAW,EACxB,MAAM,GAAE,iBAAsB,EAC9B,OAAO,CAAC,EAAE,eAAe,GACxB,OAAO,CAAC,iBAAiB,CAAC;IAkC7B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAgDG;WACU,oBAAoB,CAC/B,WAAW,EAAE,WAAW,EACxB,MAAM,GAAE,iBAAsB,EAC9B,OAAO,CAAC,EAAE,eAAe,GACxB,OAAO,CAAC,kBAAkB,CAAC;IAkC9B;;;;;;;;;;;;;;;;;;;;;;;;;;OA0BG;WACU,gBAAgB,CAC3B,WAAW,EAAE,WAAW,EACxB,OAAO,CAAC,EAAE,eAAe,GACxB,OAAO,CAAC,cAAc,CAAC;IAiB1B;;;;;;;;;;;;;;;;;;;;;OAqBG;WACU,aAAa,CACxB,WAAW,EAAE,WAAW,EACxB,MAAM,GAAE,iBAAsB,EAC9B,OAAO,CAAC,EAAE,eAAe,GACxB,OAAO,CAAC,UAAU,EAAE,CAAC;IA0BxB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA+CG;WACU,eAAe,CAC1B,WAAW,EAAE,WAAW,EACxB,MAAM,GAAE,iBAAsB,EAC9B,OAAO,CAAC,EAAE,eAAe,GACxB,OAAO,CAAC,SAAS,EAAE,CAAC;CAkCxB"}
|
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.StatisticsUtils = void 0;
|
|
4
4
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
5
|
-
const enums_1 = require("
|
|
6
|
-
const graphql_1 = require("
|
|
7
|
-
const utils_1 = require("
|
|
5
|
+
const enums_1 = require("../enums");
|
|
6
|
+
const graphql_1 = require("../graphql");
|
|
7
|
+
const utils_1 = require("../utils");
|
|
8
8
|
/**
|
|
9
9
|
* Utility class for statistics-related queries.
|
|
10
10
|
*
|
|
@@ -198,9 +198,7 @@ class StatisticsUtils {
|
|
|
198
198
|
* ```ts
|
|
199
199
|
* interface IDailyPayment {
|
|
200
200
|
* timestamp: number;
|
|
201
|
-
* totalAmountPaid: bigint;
|
|
202
201
|
* totalCount: number;
|
|
203
|
-
* averageAmountPerWorker: bigint;
|
|
204
202
|
* };
|
|
205
203
|
*
|
|
206
204
|
* interface IPaymentStatistics {
|
|
@@ -219,14 +217,7 @@ class StatisticsUtils {
|
|
|
219
217
|
*
|
|
220
218
|
* const networkData = NETWORKS[ChainId.POLYGON_AMOY];
|
|
221
219
|
* const paymentStats = await StatisticsUtils.getPaymentStatistics(networkData);
|
|
222
|
-
* console.log(
|
|
223
|
-
* 'Payment statistics:',
|
|
224
|
-
* paymentStats.dailyPaymentsData.map((p) => ({
|
|
225
|
-
* ...p,
|
|
226
|
-
* totalAmountPaid: p.totalAmountPaid.toString(),
|
|
227
|
-
* averageAmountPerWorker: p.averageAmountPerWorker.toString(),
|
|
228
|
-
* }))
|
|
229
|
-
* );
|
|
220
|
+
* console.log('Payment statistics:', paymentStats.dailyPaymentsData);
|
|
230
221
|
*
|
|
231
222
|
* const paymentStatsRange = await StatisticsUtils.getPaymentStatistics(
|
|
232
223
|
* networkData,
|
|
@@ -254,12 +245,7 @@ class StatisticsUtils {
|
|
|
254
245
|
return {
|
|
255
246
|
dailyPaymentsData: eventDayDatas.map((eventDayData) => ({
|
|
256
247
|
timestamp: +eventDayData.timestamp * 1000,
|
|
257
|
-
totalAmountPaid: BigInt(eventDayData.dailyHMTPayoutAmount),
|
|
258
248
|
totalCount: +eventDayData.dailyPayoutCount,
|
|
259
|
-
averageAmountPerWorker: eventDayData.dailyWorkerCount === '0'
|
|
260
|
-
? BigInt(0)
|
|
261
|
-
: BigInt(eventDayData.dailyHMTPayoutAmount) /
|
|
262
|
-
BigInt(eventDayData.dailyWorkerCount),
|
|
263
249
|
})),
|
|
264
250
|
};
|
|
265
251
|
}
|
|
@@ -296,7 +282,7 @@ class StatisticsUtils {
|
|
|
296
282
|
*/
|
|
297
283
|
static async getHMTStatistics(networkData, options) {
|
|
298
284
|
try {
|
|
299
|
-
const subgraphUrl = (0, utils_1.
|
|
285
|
+
const subgraphUrl = (0, utils_1.getHMTSubgraphUrl)(networkData);
|
|
300
286
|
const { hmtokenStatistics } = await (0, utils_1.customGqlFetch)(subgraphUrl, graphql_1.GET_HMTOKEN_STATISTICS_QUERY, options);
|
|
301
287
|
return {
|
|
302
288
|
totalTransferAmount: BigInt(hmtokenStatistics.totalValueTransfered),
|
|
@@ -332,7 +318,7 @@ class StatisticsUtils {
|
|
|
332
318
|
*/
|
|
333
319
|
static async getHMTHolders(networkData, params = {}, options) {
|
|
334
320
|
try {
|
|
335
|
-
const subgraphUrl = (0, utils_1.
|
|
321
|
+
const subgraphUrl = (0, utils_1.getHMTSubgraphUrl)(networkData);
|
|
336
322
|
const { address, orderDirection } = params;
|
|
337
323
|
const query = (0, graphql_1.GET_HOLDERS_QUERY)(address);
|
|
338
324
|
const { holders } = await (0, utils_1.customGqlFetch)(subgraphUrl, query, {
|
|
@@ -399,11 +385,11 @@ class StatisticsUtils {
|
|
|
399
385
|
*/
|
|
400
386
|
static async getHMTDailyData(networkData, filter = {}, options) {
|
|
401
387
|
try {
|
|
402
|
-
const subgraphUrl = (0, utils_1.
|
|
388
|
+
const subgraphUrl = (0, utils_1.getHMTSubgraphUrl)(networkData);
|
|
403
389
|
const first = filter.first !== undefined ? Math.min(filter.first, 1000) : 10;
|
|
404
390
|
const skip = filter.skip || 0;
|
|
405
391
|
const orderDirection = filter.orderDirection || enums_1.OrderDirection.ASC;
|
|
406
|
-
const { eventDayDatas } = await (0, utils_1.customGqlFetch)(subgraphUrl, (0, graphql_1.
|
|
392
|
+
const { eventDayDatas } = await (0, utils_1.customGqlFetch)(subgraphUrl, (0, graphql_1.GET_HMT_EVENT_DAY_DATA_QUERY)(filter), {
|
|
407
393
|
from: filter.from ? (0, utils_1.getUnixTimestamp)(filter.from) : undefined,
|
|
408
394
|
to: filter.to ? (0, utils_1.getUnixTimestamp)(filter.to) : undefined,
|
|
409
395
|
orderDirection: orderDirection,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/transaction/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TransactionUtils = void 0;
|
|
4
|
+
var transaction_utils_1 = require("./transaction_utils");
|
|
5
|
+
Object.defineProperty(exports, "TransactionUtils", { enumerable: true, get: function () { return transaction_utils_1.TransactionUtils; } });
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ChainId } from '
|
|
2
|
-
import { ITransaction, ITransactionsFilter, SubgraphOptions } from '
|
|
1
|
+
import { ChainId } from '../enums';
|
|
2
|
+
import { ITransaction, ITransactionsFilter, SubgraphOptions } from '../interfaces';
|
|
3
3
|
/**
|
|
4
4
|
* Utility class for transaction-related queries.
|
|
5
5
|
*
|
|
@@ -82,8 +82,8 @@ export declare class TransactionUtils {
|
|
|
82
82
|
* token?: string; // (Optional) The token address to filter transactions.
|
|
83
83
|
* startDate?: Date; // (Optional) The start date to filter transactions (inclusive).
|
|
84
84
|
* endDate?: Date; // (Optional) The end date to filter transactions (inclusive).
|
|
85
|
-
* startBlock?: number; // (Optional) The start block
|
|
86
|
-
* endBlock?: number; // (Optional) The end block
|
|
85
|
+
* startBlock?: bigint | number; // (Optional) The start block to filter transactions (inclusive).
|
|
86
|
+
* endBlock?: bigint | number; // (Optional) The end block to filter transactions (inclusive).
|
|
87
87
|
* first?: number; // (Optional) Number of transactions per page. Default is 10.
|
|
88
88
|
* skip?: number; // (Optional) Number of transactions to skip. Default is 0.
|
|
89
89
|
* orderDirection?: OrderDirection; // (Optional) Order of the results. Default is DESC.
|
|
@@ -142,4 +142,4 @@ export declare class TransactionUtils {
|
|
|
142
142
|
*/
|
|
143
143
|
static getTransactions(filter: ITransactionsFilter, options?: SubgraphOptions): Promise<ITransaction[]>;
|
|
144
144
|
}
|
|
145
|
-
//# sourceMappingURL=
|
|
145
|
+
//# sourceMappingURL=transaction_utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transaction_utils.d.ts","sourceRoot":"","sources":["../../src/transaction/transaction_utils.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,EAAkB,MAAM,UAAU,CAAC;AAWnD,OAAO,EAEL,YAAY,EACZ,mBAAmB,EACnB,eAAe,EAChB,MAAM,eAAe,CAAC;AAGvB;;;;;;;;;;;;;GAaG;AACH,qBAAa,gBAAgB;IAC3B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAgDG;WACiB,cAAc,CAChC,OAAO,EAAE,OAAO,EAChB,IAAI,EAAE,MAAM,EACZ,OAAO,CAAC,EAAE,eAAe,GACxB,OAAO,CAAC,YAAY,GAAG,IAAI,CAAC;IAyB/B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA0EG;WACiB,eAAe,CACjC,MAAM,EAAE,mBAAmB,EAC3B,OAAO,CAAC,EAAE,eAAe,GACxB,OAAO,CAAC,YAAY,EAAE,CAAC;CAgD3B"}
|
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.TransactionUtils = void 0;
|
|
4
4
|
const ethers_1 = require("ethers");
|
|
5
|
-
const constants_1 = require("
|
|
6
|
-
const enums_1 = require("
|
|
7
|
-
const error_1 = require("
|
|
8
|
-
const transaction_1 = require("
|
|
9
|
-
const utils_1 = require("
|
|
5
|
+
const constants_1 = require("../constants");
|
|
6
|
+
const enums_1 = require("../enums");
|
|
7
|
+
const error_1 = require("../error");
|
|
8
|
+
const transaction_1 = require("../graphql/queries/transaction");
|
|
9
|
+
const utils_1 = require("../utils");
|
|
10
10
|
/**
|
|
11
11
|
* Utility class for transaction-related queries.
|
|
12
12
|
*
|
|
@@ -103,8 +103,8 @@ class TransactionUtils {
|
|
|
103
103
|
* token?: string; // (Optional) The token address to filter transactions.
|
|
104
104
|
* startDate?: Date; // (Optional) The start date to filter transactions (inclusive).
|
|
105
105
|
* endDate?: Date; // (Optional) The end date to filter transactions (inclusive).
|
|
106
|
-
* startBlock?: number; // (Optional) The start block
|
|
107
|
-
* endBlock?: number; // (Optional) The end block
|
|
106
|
+
* startBlock?: bigint | number; // (Optional) The start block to filter transactions (inclusive).
|
|
107
|
+
* endBlock?: bigint | number; // (Optional) The end block to filter transactions (inclusive).
|
|
108
108
|
* first?: number; // (Optional) Number of transactions per page. Default is 10.
|
|
109
109
|
* skip?: number; // (Optional) Number of transactions to skip. Default is 0.
|
|
110
110
|
* orderDirection?: OrderDirection; // (Optional) Order of the results. Default is DESC.
|
|
@@ -180,8 +180,8 @@ class TransactionUtils {
|
|
|
180
180
|
? (0, utils_1.getUnixTimestamp)(filter?.startDate)
|
|
181
181
|
: undefined,
|
|
182
182
|
endDate: filter.endDate ? (0, utils_1.getUnixTimestamp)(filter.endDate) : undefined,
|
|
183
|
-
startBlock: filter.startBlock ? filter.startBlock : undefined,
|
|
184
|
-
endBlock: filter.endBlock ? filter.endBlock : undefined,
|
|
183
|
+
startBlock: filter.startBlock ? Number(filter.startBlock) : undefined,
|
|
184
|
+
endBlock: filter.endBlock ? Number(filter.endBlock) : undefined,
|
|
185
185
|
method: filter.method ? filter.method : undefined,
|
|
186
186
|
escrow: filter.escrow ? filter.escrow : undefined,
|
|
187
187
|
token: filter.token ? filter.token : undefined,
|