@human-protocol/sdk 6.1.0 → 7.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +32 -0
- package/dist/constants.d.ts.map +1 -1
- package/dist/constants.js +26 -14
- 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} +4 -184
- package/dist/{escrow.d.ts.map → escrow/escrow_client.d.ts.map} +1 -1
- package/dist/{escrow.js → escrow/escrow_client.js} +35 -411
- 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 +394 -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/escrow.d.ts +1 -1
- package/dist/graphql/queries/escrow.d.ts.map +1 -1
- package/dist/graphql/queries/escrow.js +5 -1
- 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/queries/worker.d.ts.map +1 -1
- package/dist/graphql/queries/worker.js +0 -2
- package/dist/graphql/types.d.ts +5 -2
- 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 +4 -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} +3 -108
- package/dist/kvstore/kvstore_client.d.ts.map +1 -0
- package/dist/{kvstore.js → kvstore/kvstore_client.js} +22 -184
- 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} +4 -65
- package/dist/staking/staking_client.d.ts.map +1 -0
- package/dist/{staking.js → staking/staking_client.js} +6 -136
- 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} +3 -3
- package/dist/transaction/transaction_utils.d.ts.map +1 -0
- package/dist/{transaction.js → transaction/transaction_utils.js} +5 -5
- package/dist/types.d.ts +8 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/utils.d.ts +15 -0
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +71 -4
- 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 -4
- package/dist/worker/worker_utils.d.ts.map +1 -0
- package/dist/{worker.js → worker/worker_utils.js} +5 -7
- package/package.json +12 -8
- package/src/constants.ts +38 -14
- 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} +36 -556
- package/src/escrow/escrow_utils.ts +518 -0
- package/src/escrow/index.ts +2 -0
- package/src/graphql/queries/escrow.ts +6 -1
- package/src/graphql/queries/statistics.ts +37 -1
- package/src/graphql/queries/worker.ts +0 -2
- package/src/graphql/types.ts +6 -2
- package/src/index.ts +11 -25
- package/src/interfaces.ts +4 -7
- package/src/kvstore/index.ts +2 -0
- package/src/{kvstore.ts → kvstore/kvstore_client.ts} +27 -241
- 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} +8 -174
- 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} +7 -7
- package/src/types.ts +8 -0
- package/src/utils.ts +80 -3
- package/src/worker/index.ts +1 -0
- package/src/{worker.ts → worker/worker_utils.ts} +7 -9
- package/dist/encryption.d.ts +0 -189
- package/dist/encryption.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
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import { EscrowFactory, HMToken, Staking } from '@human-protocol/core/typechain-types';
|
|
2
2
|
import { ContractRunner } from 'ethers';
|
|
3
|
-
import { BaseEthersClient } from '
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import { NetworkData, TransactionOverrides } from './types';
|
|
3
|
+
import { BaseEthersClient } from '../base';
|
|
4
|
+
import { StakerInfo } from '../interfaces';
|
|
5
|
+
import { NetworkData, TransactionOverrides } from '../types';
|
|
7
6
|
/**
|
|
8
7
|
* Client for staking actions on HUMAN Protocol.
|
|
9
8
|
*
|
|
@@ -218,64 +217,4 @@ export declare class StakingClient extends BaseEthersClient {
|
|
|
218
217
|
*/
|
|
219
218
|
getStakerInfo(stakerAddress: string): Promise<StakerInfo>;
|
|
220
219
|
}
|
|
221
|
-
|
|
222
|
-
* Utility helpers for Staking-related queries.
|
|
223
|
-
*
|
|
224
|
-
* @example
|
|
225
|
-
* ```ts
|
|
226
|
-
* import { StakingUtils, ChainId } from '@human-protocol/sdk';
|
|
227
|
-
*
|
|
228
|
-
* const staker = await StakingUtils.getStaker(
|
|
229
|
-
* ChainId.POLYGON_AMOY,
|
|
230
|
-
* '0xYourStakerAddress'
|
|
231
|
-
* );
|
|
232
|
-
* console.log('Staked amount:', staker.stakedAmount);
|
|
233
|
-
* ```
|
|
234
|
-
*/
|
|
235
|
-
export declare class StakingUtils {
|
|
236
|
-
/**
|
|
237
|
-
* Gets staking info for a staker from the subgraph.
|
|
238
|
-
*
|
|
239
|
-
* @param chainId - Network in which the staking contract is deployed
|
|
240
|
-
* @param stakerAddress - Address of the staker
|
|
241
|
-
* @param options - Optional configuration for subgraph requests.
|
|
242
|
-
* @returns Staker info from subgraph
|
|
243
|
-
* @throws ErrorInvalidStakerAddressProvided If the staker address is invalid
|
|
244
|
-
* @throws ErrorUnsupportedChainID If the chain ID is not supported
|
|
245
|
-
* @throws ErrorStakerNotFound If the staker is not found
|
|
246
|
-
*
|
|
247
|
-
* @example
|
|
248
|
-
* ```ts
|
|
249
|
-
* import { StakingUtils, ChainId } from '@human-protocol/sdk';
|
|
250
|
-
*
|
|
251
|
-
* const staker = await StakingUtils.getStaker(
|
|
252
|
-
* ChainId.POLYGON_AMOY,
|
|
253
|
-
* '0xYourStakerAddress'
|
|
254
|
-
* );
|
|
255
|
-
* console.log('Staked amount:', staker.stakedAmount);
|
|
256
|
-
* ```
|
|
257
|
-
*/
|
|
258
|
-
static getStaker(chainId: ChainId, stakerAddress: string, options?: SubgraphOptions): Promise<IStaker>;
|
|
259
|
-
/**
|
|
260
|
-
* Gets all stakers from the subgraph with filters, pagination and ordering.
|
|
261
|
-
*
|
|
262
|
-
* @param filter - Stakers filter with pagination and ordering
|
|
263
|
-
* @param options - Optional configuration for subgraph requests.
|
|
264
|
-
* @returns Array of stakers
|
|
265
|
-
* @throws ErrorUnsupportedChainID If the chain ID is not supported
|
|
266
|
-
*
|
|
267
|
-
* @example
|
|
268
|
-
* ```ts
|
|
269
|
-
* import { ChainId } from '@human-protocol/sdk';
|
|
270
|
-
*
|
|
271
|
-
* const filter = {
|
|
272
|
-
* chainId: ChainId.POLYGON_AMOY,
|
|
273
|
-
* minStakedAmount: '1000000000000000000', // 1 token in WEI
|
|
274
|
-
* };
|
|
275
|
-
* const stakers = await StakingUtils.getStakers(filter);
|
|
276
|
-
* console.log('Stakers:', stakers.length);
|
|
277
|
-
* ```
|
|
278
|
-
*/
|
|
279
|
-
static getStakers(filter: IStakersFilter, options?: SubgraphOptions): Promise<IStaker[]>;
|
|
280
|
-
}
|
|
281
|
-
//# sourceMappingURL=staking.d.ts.map
|
|
220
|
+
//# sourceMappingURL=staking_client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
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,CAAC,IAAI,CAAC;IAY1E;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA4BG;IAEU,KAAK,CAChB,OAAO,EAAE,MAAM,EACf,MAAM,EAAE,MAAM,EACd,aAAa,EAAE,MAAM,EACrB,MAAM,EAAE,MAAM,EACd,SAAS,GAAE,oBAAyB,GACnC,OAAO,CAAC,IAAI,CAAC;IAsChB;;;;;;;;;;;;OAYG;IACU,aAAa,CAAC,aAAa,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC;CAiCvE"}
|
|
@@ -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
|
*
|
|
@@ -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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= 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
|
*
|
|
@@ -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
|
*
|
package/dist/types.d.ts
CHANGED
|
@@ -74,6 +74,14 @@ export type NetworkData = {
|
|
|
74
74
|
* Subgraph URL API key
|
|
75
75
|
*/
|
|
76
76
|
subgraphUrlApiKey: string;
|
|
77
|
+
/**
|
|
78
|
+
* HMT statistics subgraph URL
|
|
79
|
+
*/
|
|
80
|
+
hmtSubgraphUrl?: string;
|
|
81
|
+
/**
|
|
82
|
+
* HMT statistics subgraph URL API key
|
|
83
|
+
*/
|
|
84
|
+
hmtSubgraphUrlApiKey?: string;
|
|
77
85
|
/**
|
|
78
86
|
* Old subgraph URL
|
|
79
87
|
*/
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,QAAQ,CAAC;AAEpD;;;;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;IACT;;OAEG;IACH,QAAQ,IAAA;CACT;AAED;;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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