@human-protocol/sdk 5.0.0 → 5.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/base.d.ts +1 -10
- package/dist/base.d.ts.map +1 -1
- package/dist/base.js +0 -21
- package/dist/constants.d.ts +0 -1
- package/dist/constants.d.ts.map +1 -1
- package/dist/constants.js +7 -22
- package/dist/encryption.js +1 -1
- package/dist/enums.d.ts +0 -1
- package/dist/enums.d.ts.map +1 -1
- package/dist/enums.js +0 -1
- package/dist/error.d.ts +8 -0
- package/dist/error.d.ts.map +1 -1
- package/dist/error.js +9 -1
- package/dist/escrow.d.ts +14 -17
- package/dist/escrow.d.ts.map +1 -1
- package/dist/escrow.js +34 -33
- package/dist/interfaces.d.ts +14 -0
- package/dist/interfaces.d.ts.map +1 -1
- package/dist/kvstore.d.ts +9 -5
- package/dist/kvstore.d.ts.map +1 -1
- package/dist/kvstore.js +15 -15
- package/dist/operator.d.ts +9 -5
- package/dist/operator.d.ts.map +1 -1
- package/dist/operator.js +16 -16
- package/dist/staking.d.ts +6 -3
- package/dist/staking.d.ts.map +1 -1
- package/dist/staking.js +13 -15
- package/dist/statistics.d.ts +13 -7
- package/dist/statistics.d.ts.map +1 -1
- package/dist/statistics.js +24 -22
- package/dist/storage.js +4 -4
- package/dist/transaction.d.ts +5 -3
- package/dist/transaction.d.ts.map +1 -1
- package/dist/transaction.js +8 -11
- package/dist/utils.d.ts +7 -0
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +66 -1
- package/dist/worker.d.ts +5 -3
- package/dist/worker.d.ts.map +1 -1
- package/dist/worker.js +8 -10
- package/package.json +8 -5
- package/src/base.ts +1 -23
- package/src/constants.ts +6 -24
- package/src/encryption.ts +1 -1
- package/src/enums.ts +0 -1
- package/src/error.ts +14 -0
- package/src/escrow.ts +70 -64
- package/src/interfaces.ts +15 -0
- package/src/kvstore.ts +26 -24
- package/src/operator.ts +54 -26
- package/src/staking.ts +28 -27
- package/src/statistics.ts +87 -47
- package/src/storage.ts +4 -4
- package/src/transaction.ts +39 -26
- package/src/utils.ts +81 -0
- package/src/worker.ts +32 -17
package/dist/operator.js
CHANGED
|
@@ -1,11 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
3
|
exports.OperatorUtils = void 0;
|
|
7
|
-
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
8
|
-
const graphql_request_1 = __importDefault(require("graphql-request"));
|
|
9
4
|
const reward_1 = require("./graphql/queries/reward");
|
|
10
5
|
const operator_1 = require("./graphql/queries/operator");
|
|
11
6
|
const ethers_1 = require("ethers");
|
|
@@ -19,6 +14,7 @@ class OperatorUtils {
|
|
|
19
14
|
*
|
|
20
15
|
* @param {ChainId} chainId Network in which the operator is deployed
|
|
21
16
|
* @param {string} address Operator address.
|
|
17
|
+
* @param {SubgraphOptions} options Optional configuration for subgraph requests.
|
|
22
18
|
* @returns {Promise<IOperator | null>} - Returns the operator details or null if not found.
|
|
23
19
|
*
|
|
24
20
|
* **Code example**
|
|
@@ -29,7 +25,7 @@ class OperatorUtils {
|
|
|
29
25
|
* const operator = await OperatorUtils.getOperator(ChainId.POLYGON_AMOY, '0x62dD51230A30401C455c8398d06F85e4EaB6309f');
|
|
30
26
|
* ```
|
|
31
27
|
*/
|
|
32
|
-
static async getOperator(chainId, address) {
|
|
28
|
+
static async getOperator(chainId, address, options) {
|
|
33
29
|
if (!ethers_1.ethers.isAddress(address)) {
|
|
34
30
|
throw error_1.ErrorInvalidStakerAddressProvided;
|
|
35
31
|
}
|
|
@@ -37,8 +33,9 @@ class OperatorUtils {
|
|
|
37
33
|
if (!networkData) {
|
|
38
34
|
throw error_1.ErrorUnsupportedChainID;
|
|
39
35
|
}
|
|
40
|
-
const { operator } = await (0,
|
|
36
|
+
const { operator } = await (0, utils_1.customGqlFetch)((0, utils_1.getSubgraphUrl)(networkData), operator_1.GET_LEADER_QUERY, {
|
|
41
37
|
address: address.toLowerCase(),
|
|
38
|
+
options,
|
|
42
39
|
});
|
|
43
40
|
if (!operator) {
|
|
44
41
|
return null;
|
|
@@ -49,6 +46,7 @@ class OperatorUtils {
|
|
|
49
46
|
* This function returns all the operator details of the protocol.
|
|
50
47
|
*
|
|
51
48
|
* @param {IOperatorsFilter} filter Filter for the operators.
|
|
49
|
+
* @param {SubgraphOptions} options Optional configuration for subgraph requests.
|
|
52
50
|
* @returns {Promise<IOperator[]>} Returns an array with all the operator details.
|
|
53
51
|
*
|
|
54
52
|
* **Code example**
|
|
@@ -62,7 +60,7 @@ class OperatorUtils {
|
|
|
62
60
|
* const operators = await OperatorUtils.getOperators(filter);
|
|
63
61
|
* ```
|
|
64
62
|
*/
|
|
65
|
-
static async getOperators(filter) {
|
|
63
|
+
static async getOperators(filter, options) {
|
|
66
64
|
const first = filter.first !== undefined && filter.first > 0
|
|
67
65
|
? Math.min(filter.first, 1000)
|
|
68
66
|
: 10;
|
|
@@ -81,14 +79,14 @@ class OperatorUtils {
|
|
|
81
79
|
if (!networkData) {
|
|
82
80
|
throw error_1.ErrorUnsupportedChainID;
|
|
83
81
|
}
|
|
84
|
-
const { operators } = await (0,
|
|
82
|
+
const { operators } = await (0, utils_1.customGqlFetch)((0, utils_1.getSubgraphUrl)(networkData), (0, operator_1.GET_LEADERS_QUERY)(filter), {
|
|
85
83
|
minStakedAmount: filter?.minStakedAmount,
|
|
86
84
|
roles: filter?.roles,
|
|
87
85
|
orderBy: orderBy,
|
|
88
86
|
orderDirection: orderDirection,
|
|
89
87
|
first: first,
|
|
90
88
|
skip: skip,
|
|
91
|
-
});
|
|
89
|
+
}, options);
|
|
92
90
|
if (!operators) {
|
|
93
91
|
return [];
|
|
94
92
|
}
|
|
@@ -100,6 +98,7 @@ class OperatorUtils {
|
|
|
100
98
|
* @param {ChainId} chainId Network in which the reputation network is deployed
|
|
101
99
|
* @param {string} address Address of the reputation oracle.
|
|
102
100
|
* @param {string} [role] - (Optional) Role of the operator.
|
|
101
|
+
* @param {SubgraphOptions} options Optional configuration for subgraph requests.
|
|
103
102
|
* @returns {Promise<IOperator[]>} - Returns an array of operator details.
|
|
104
103
|
*
|
|
105
104
|
* **Code example**
|
|
@@ -110,15 +109,15 @@ class OperatorUtils {
|
|
|
110
109
|
* const operators = await OperatorUtils.getReputationNetworkOperators(ChainId.POLYGON_AMOY, '0x62dD51230A30401C455c8398d06F85e4EaB6309f');
|
|
111
110
|
* ```
|
|
112
111
|
*/
|
|
113
|
-
static async getReputationNetworkOperators(chainId, address, role) {
|
|
112
|
+
static async getReputationNetworkOperators(chainId, address, role, options) {
|
|
114
113
|
const networkData = constants_1.NETWORKS[chainId];
|
|
115
114
|
if (!networkData) {
|
|
116
115
|
throw error_1.ErrorUnsupportedChainID;
|
|
117
116
|
}
|
|
118
|
-
const { reputationNetwork } = await (0,
|
|
117
|
+
const { reputationNetwork } = await (0, utils_1.customGqlFetch)((0, utils_1.getSubgraphUrl)(networkData), (0, operator_1.GET_REPUTATION_NETWORK_QUERY)(role), {
|
|
119
118
|
address: address.toLowerCase(),
|
|
120
119
|
role: role,
|
|
121
|
-
});
|
|
120
|
+
}, options);
|
|
122
121
|
if (!reputationNetwork)
|
|
123
122
|
return [];
|
|
124
123
|
return reputationNetwork.operators.map((operator) => mapOperator(operator, chainId));
|
|
@@ -128,6 +127,7 @@ class OperatorUtils {
|
|
|
128
127
|
*
|
|
129
128
|
* @param {ChainId} chainId Network in which the rewards are deployed
|
|
130
129
|
* @param {string} slasherAddress Slasher address.
|
|
130
|
+
* @param {SubgraphOptions} options Optional configuration for subgraph requests.
|
|
131
131
|
* @returns {Promise<IReward[]>} Returns an array of Reward objects that contain the rewards earned by the user through slashing other users.
|
|
132
132
|
*
|
|
133
133
|
* **Code example**
|
|
@@ -138,7 +138,7 @@ class OperatorUtils {
|
|
|
138
138
|
* const rewards = await OperatorUtils.getRewards(ChainId.POLYGON_AMOY, '0x62dD51230A30401C455c8398d06F85e4EaB6309f');
|
|
139
139
|
* ```
|
|
140
140
|
*/
|
|
141
|
-
static async getRewards(chainId, slasherAddress) {
|
|
141
|
+
static async getRewards(chainId, slasherAddress, options) {
|
|
142
142
|
if (!ethers_1.ethers.isAddress(slasherAddress)) {
|
|
143
143
|
throw error_1.ErrorInvalidSlasherAddressProvided;
|
|
144
144
|
}
|
|
@@ -146,9 +146,9 @@ class OperatorUtils {
|
|
|
146
146
|
if (!networkData) {
|
|
147
147
|
throw error_1.ErrorUnsupportedChainID;
|
|
148
148
|
}
|
|
149
|
-
const { rewardAddedEvents } = await (0,
|
|
149
|
+
const { rewardAddedEvents } = await (0, utils_1.customGqlFetch)((0, utils_1.getSubgraphUrl)(networkData), reward_1.GET_REWARD_ADDED_EVENTS_QUERY, {
|
|
150
150
|
slasherAddress: slasherAddress.toLowerCase(),
|
|
151
|
-
});
|
|
151
|
+
}, options);
|
|
152
152
|
if (!rewardAddedEvents)
|
|
153
153
|
return [];
|
|
154
154
|
return rewardAddedEvents.map((reward) => {
|
package/dist/staking.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { EscrowFactory, HMToken, Staking } from '@human-protocol/core/typechain-
|
|
|
2
2
|
import { ContractRunner, Overrides } from 'ethers';
|
|
3
3
|
import { BaseEthersClient } from './base';
|
|
4
4
|
import { ChainId } from './enums';
|
|
5
|
-
import { IStaker, IStakersFilter, StakerInfo } from './interfaces';
|
|
5
|
+
import { IStaker, IStakersFilter, StakerInfo, SubgraphOptions } from './interfaces';
|
|
6
6
|
import { NetworkData } from './types';
|
|
7
7
|
/**
|
|
8
8
|
* ## Introduction
|
|
@@ -264,14 +264,17 @@ export declare class StakingUtils {
|
|
|
264
264
|
*
|
|
265
265
|
* @param {ChainId} chainId Network in which the staking contract is deployed
|
|
266
266
|
* @param {string} stakerAddress Address of the staker
|
|
267
|
+
* @param {SubgraphOptions} options Optional configuration for subgraph requests.
|
|
267
268
|
* @returns {Promise<IStaker>} Staker info from subgraph
|
|
268
269
|
*/
|
|
269
|
-
static getStaker(chainId: ChainId, stakerAddress: string): Promise<IStaker>;
|
|
270
|
+
static getStaker(chainId: ChainId, stakerAddress: string, options?: SubgraphOptions): Promise<IStaker>;
|
|
270
271
|
/**
|
|
271
272
|
* Gets all stakers from the subgraph with filters, pagination and ordering.
|
|
272
273
|
*
|
|
274
|
+
* @param {IStakersFilter} filter Stakers filter with pagination and ordering
|
|
275
|
+
* @param {SubgraphOptions} options Optional configuration for subgraph requests.
|
|
273
276
|
* @returns {Promise<IStaker[]>} Array of stakers
|
|
274
277
|
*/
|
|
275
|
-
static getStakers(filter: IStakersFilter): Promise<IStaker[]>;
|
|
278
|
+
static getStakers(filter: IStakersFilter, options?: SubgraphOptions): Promise<IStaker[]>;
|
|
276
279
|
}
|
|
277
280
|
//# 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,OAAO,EAER,MAAM,sCAAsC,CAAC;AAC9C,OAAO,EAAE,cAAc,EAAE,SAAS,EAAU,MAAM,QAAQ,CAAC;
|
|
1
|
+
{"version":3,"file":"staking.d.ts","sourceRoot":"","sources":["../src/staking.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,aAAa,EAEb,OAAO,EAEP,OAAO,EAER,MAAM,sCAAsC,CAAC;AAC9C,OAAO,EAAE,cAAc,EAAE,SAAS,EAAU,MAAM,QAAQ,CAAC;AAC3D,OAAO,EAAE,gBAAgB,EAAE,MAAM,QAAQ,CAAC;AAG1C,OAAO,EAAE,OAAO,EAAkB,MAAM,SAAS,CAAC;AAYlD,OAAO,EACL,OAAO,EACP,cAAc,EACd,UAAU,EACV,eAAe,EAChB,MAAM,cAAc,CAAC;AAEtB,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAOtC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoEG;AACH,qBAAa,aAAc,SAAQ,gBAAgB;IAC1C,aAAa,EAAE,OAAO,CAAC;IACvB,eAAe,EAAE,OAAO,CAAC;IACzB,qBAAqB,EAAE,aAAa,CAAC;IAE5C;;;;;OAKG;gBACS,MAAM,EAAE,cAAc,EAAE,WAAW,EAAE,WAAW;IAmB5D;;;;;;;;OAQG;WACiB,KAAK,CAAC,MAAM,EAAE,cAAc,GAAG,OAAO,CAAC,aAAa,CAAC;IAiBzE;;;;OAIG;YACW,gBAAgB;IAU9B;;;;;;;;;;;;;;;;;;;;;;;OAuBG;IAEU,YAAY,CACvB,MAAM,EAAE,MAAM,EACd,SAAS,GAAE,SAAc,GACxB,OAAO,CAAC,IAAI,CAAC;IAuBhB;;;;;;;;;;;;;;;;;;;;;;;;;;OA0BG;IAEU,KAAK,CAAC,MAAM,EAAE,MAAM,EAAE,SAAS,GAAE,SAAc,GAAG,OAAO,CAAC,IAAI,CAAC;IAiB5E;;;;;;;;;;;;;;;;;;;;;;;;;OAyBG;IAEU,OAAO,CAClB,MAAM,EAAE,MAAM,EACd,SAAS,GAAE,SAAc,GACxB,OAAO,CAAC,IAAI,CAAC;IAiBhB;;;;;;;;;;;;;;;;;;;;;;;OAuBG;IAEU,QAAQ,CAAC,SAAS,GAAE,SAAc,GAAG,OAAO,CAAC,IAAI,CAAC;IAS/D;;;;;;;;;;;;;;;;;;;;;;;;;;OA0BG;IAEU,KAAK,CAChB,OAAO,EAAE,MAAM,EACf,MAAM,EAAE,MAAM,EACd,aAAa,EAAE,MAAM,EACrB,MAAM,EAAE,MAAM,EACd,SAAS,GAAE,SAAc,GACxB,OAAO,CAAC,IAAI,CAAC;IAoChB;;;;;;;;;;;;;;;;;;;OAmBG;IACU,aAAa,CAAC,aAAa,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC;CAiCvE;AAED;;GAEG;AACH,qBAAa,YAAY;IACvB;;;;;;;OAOG;WACiB,SAAS,CAC3B,OAAO,EAAE,OAAO,EAChB,aAAa,EAAE,MAAM,EACrB,OAAO,CAAC,EAAE,eAAe,GACxB,OAAO,CAAC,OAAO,CAAC;IAwBnB;;;;;;OAMG;WACiB,UAAU,CAC5B,MAAM,EAAE,cAAc,EACtB,OAAO,CAAC,EAAE,eAAe,GACxB,OAAO,CAAC,OAAO,EAAE,CAAC;CAqDtB"}
|
package/dist/staking.js
CHANGED
|
@@ -8,14 +8,10 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
8
8
|
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
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
-
};
|
|
14
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
12
|
exports.StakingUtils = exports.StakingClient = void 0;
|
|
16
13
|
const typechain_types_1 = require("@human-protocol/core/typechain-types");
|
|
17
14
|
const ethers_1 = require("ethers");
|
|
18
|
-
const graphql_request_1 = __importDefault(require("graphql-request"));
|
|
19
15
|
const base_1 = require("./base");
|
|
20
16
|
const constants_1 = require("./constants");
|
|
21
17
|
const decorators_1 = require("./decorators");
|
|
@@ -171,7 +167,7 @@ class StakingClient extends base_1.BaseEthersClient {
|
|
|
171
167
|
throw error_1.ErrorInvalidStakingValueSign;
|
|
172
168
|
}
|
|
173
169
|
try {
|
|
174
|
-
await (await this.tokenContract.approve(await this.stakingContract.getAddress(), amount,
|
|
170
|
+
await (await this.tokenContract.approve(await this.stakingContract.getAddress(), amount, txOptions)).wait();
|
|
175
171
|
return;
|
|
176
172
|
}
|
|
177
173
|
catch (e) {
|
|
@@ -213,7 +209,7 @@ class StakingClient extends base_1.BaseEthersClient {
|
|
|
213
209
|
throw error_1.ErrorInvalidStakingValueSign;
|
|
214
210
|
}
|
|
215
211
|
try {
|
|
216
|
-
await (await this.stakingContract.stake(amount,
|
|
212
|
+
await (await this.stakingContract.stake(amount, txOptions)).wait();
|
|
217
213
|
return;
|
|
218
214
|
}
|
|
219
215
|
catch (e) {
|
|
@@ -254,7 +250,7 @@ class StakingClient extends base_1.BaseEthersClient {
|
|
|
254
250
|
throw error_1.ErrorInvalidStakingValueSign;
|
|
255
251
|
}
|
|
256
252
|
try {
|
|
257
|
-
await (await this.stakingContract.unstake(amount,
|
|
253
|
+
await (await this.stakingContract.unstake(amount, txOptions)).wait();
|
|
258
254
|
return;
|
|
259
255
|
}
|
|
260
256
|
catch (e) {
|
|
@@ -287,7 +283,7 @@ class StakingClient extends base_1.BaseEthersClient {
|
|
|
287
283
|
*/
|
|
288
284
|
async withdraw(txOptions = {}) {
|
|
289
285
|
try {
|
|
290
|
-
await (await this.stakingContract.withdraw(
|
|
286
|
+
await (await this.stakingContract.withdraw(txOptions)).wait();
|
|
291
287
|
return;
|
|
292
288
|
}
|
|
293
289
|
catch (e) {
|
|
@@ -336,7 +332,7 @@ class StakingClient extends base_1.BaseEthersClient {
|
|
|
336
332
|
}
|
|
337
333
|
await this.checkValidEscrow(escrowAddress);
|
|
338
334
|
try {
|
|
339
|
-
await (await this.stakingContract.slash(slasher, staker, escrowAddress, amount,
|
|
335
|
+
await (await this.stakingContract.slash(slasher, staker, escrowAddress, amount, txOptions)).wait();
|
|
340
336
|
return;
|
|
341
337
|
}
|
|
342
338
|
catch (e) {
|
|
@@ -369,7 +365,6 @@ class StakingClient extends base_1.BaseEthersClient {
|
|
|
369
365
|
}
|
|
370
366
|
try {
|
|
371
367
|
const stakerInfo = await this.stakingContract.stakes(stakerAddress);
|
|
372
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
373
368
|
const currentBlock = await this.runner.provider.getBlockNumber();
|
|
374
369
|
const tokensWithdrawable = stakerInfo.tokensLockedUntil !== 0n &&
|
|
375
370
|
currentBlock >= stakerInfo.tokensLockedUntil
|
|
@@ -431,9 +426,10 @@ class StakingUtils {
|
|
|
431
426
|
*
|
|
432
427
|
* @param {ChainId} chainId Network in which the staking contract is deployed
|
|
433
428
|
* @param {string} stakerAddress Address of the staker
|
|
429
|
+
* @param {SubgraphOptions} options Optional configuration for subgraph requests.
|
|
434
430
|
* @returns {Promise<IStaker>} Staker info from subgraph
|
|
435
431
|
*/
|
|
436
|
-
static async getStaker(chainId, stakerAddress) {
|
|
432
|
+
static async getStaker(chainId, stakerAddress, options) {
|
|
437
433
|
if (!ethers_1.ethers.isAddress(stakerAddress)) {
|
|
438
434
|
throw error_1.ErrorInvalidStakerAddressProvided;
|
|
439
435
|
}
|
|
@@ -441,7 +437,7 @@ class StakingUtils {
|
|
|
441
437
|
if (!networkData) {
|
|
442
438
|
throw error_1.ErrorUnsupportedChainID;
|
|
443
439
|
}
|
|
444
|
-
const { staker } = await (0,
|
|
440
|
+
const { staker } = await (0, utils_1.customGqlFetch)((0, utils_1.getSubgraphUrl)(networkData), staking_1.GET_STAKER_BY_ADDRESS_QUERY, { id: stakerAddress.toLowerCase() }, options);
|
|
445
441
|
if (!staker) {
|
|
446
442
|
throw error_1.ErrorStakerNotFound;
|
|
447
443
|
}
|
|
@@ -450,9 +446,11 @@ class StakingUtils {
|
|
|
450
446
|
/**
|
|
451
447
|
* Gets all stakers from the subgraph with filters, pagination and ordering.
|
|
452
448
|
*
|
|
449
|
+
* @param {IStakersFilter} filter Stakers filter with pagination and ordering
|
|
450
|
+
* @param {SubgraphOptions} options Optional configuration for subgraph requests.
|
|
453
451
|
* @returns {Promise<IStaker[]>} Array of stakers
|
|
454
452
|
*/
|
|
455
|
-
static async getStakers(filter) {
|
|
453
|
+
static async getStakers(filter, options) {
|
|
456
454
|
const first = filter.first !== undefined ? Math.min(filter.first, 1000) : 10;
|
|
457
455
|
const skip = filter.skip || 0;
|
|
458
456
|
const orderDirection = filter.orderDirection || enums_1.OrderDirection.DESC;
|
|
@@ -461,7 +459,7 @@ class StakingUtils {
|
|
|
461
459
|
if (!networkData) {
|
|
462
460
|
throw error_1.ErrorUnsupportedChainID;
|
|
463
461
|
}
|
|
464
|
-
const { stakers } = await (0,
|
|
462
|
+
const { stakers } = await (0, utils_1.customGqlFetch)((0, utils_1.getSubgraphUrl)(networkData), (0, staking_1.GET_STAKERS_QUERY)(filter), {
|
|
465
463
|
minStakedAmount: filter.minStakedAmount
|
|
466
464
|
? filter.minStakedAmount
|
|
467
465
|
: undefined,
|
|
@@ -490,7 +488,7 @@ class StakingUtils {
|
|
|
490
488
|
orderDirection: orderDirection,
|
|
491
489
|
first: first,
|
|
492
490
|
skip: skip,
|
|
493
|
-
});
|
|
491
|
+
}, options);
|
|
494
492
|
if (!stakers) {
|
|
495
493
|
return [];
|
|
496
494
|
}
|
package/dist/statistics.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { IDailyHMT, IEscrowStatistics, IHMTHolder, IHMTHoldersParams, IHMTStatistics, IPaymentStatistics, IStatisticsFilter, IWorkerStatistics } from './interfaces';
|
|
1
|
+
import { IDailyHMT, IEscrowStatistics, IHMTHolder, IHMTHoldersParams, IHMTStatistics, IPaymentStatistics, IStatisticsFilter, IWorkerStatistics, SubgraphOptions } from './interfaces';
|
|
2
2
|
import { NetworkData } from './types';
|
|
3
3
|
/**
|
|
4
4
|
* ## Introduction
|
|
@@ -73,6 +73,7 @@ export declare class StatisticsClient {
|
|
|
73
73
|
* ```
|
|
74
74
|
*
|
|
75
75
|
* @param {IStatisticsFilter} filter Statistics params with duration data
|
|
76
|
+
* @param {SubgraphOptions} options Optional configuration for subgraph requests.
|
|
76
77
|
* @returns {Promise<IEscrowStatistics>} Escrow statistics data.
|
|
77
78
|
*
|
|
78
79
|
* **Code example**
|
|
@@ -89,7 +90,7 @@ export declare class StatisticsClient {
|
|
|
89
90
|
* });
|
|
90
91
|
* ```
|
|
91
92
|
*/
|
|
92
|
-
getEscrowStatistics(filter?: IStatisticsFilter): Promise<IEscrowStatistics>;
|
|
93
|
+
getEscrowStatistics(filter?: IStatisticsFilter, options?: SubgraphOptions): Promise<IEscrowStatistics>;
|
|
93
94
|
/**
|
|
94
95
|
* This function returns the statistical data of workers.
|
|
95
96
|
*
|
|
@@ -117,6 +118,7 @@ export declare class StatisticsClient {
|
|
|
117
118
|
* ```
|
|
118
119
|
*
|
|
119
120
|
* @param {IStatisticsFilter} filter Statistics params with duration data
|
|
121
|
+
* @param {SubgraphOptions} options Optional configuration for subgraph requests.
|
|
120
122
|
* @returns {Promise<IWorkerStatistics>} Worker statistics data.
|
|
121
123
|
*
|
|
122
124
|
* **Code example**
|
|
@@ -133,7 +135,7 @@ export declare class StatisticsClient {
|
|
|
133
135
|
* });
|
|
134
136
|
* ```
|
|
135
137
|
*/
|
|
136
|
-
getWorkerStatistics(filter?: IStatisticsFilter): Promise<IWorkerStatistics>;
|
|
138
|
+
getWorkerStatistics(filter?: IStatisticsFilter, options?: SubgraphOptions): Promise<IWorkerStatistics>;
|
|
137
139
|
/**
|
|
138
140
|
* This function returns the statistical data of payments.
|
|
139
141
|
*
|
|
@@ -163,6 +165,7 @@ export declare class StatisticsClient {
|
|
|
163
165
|
* ```
|
|
164
166
|
*
|
|
165
167
|
* @param {IStatisticsFilter} filter Statistics params with duration data
|
|
168
|
+
* @param {SubgraphOptions} options Optional configuration for subgraph requests.
|
|
166
169
|
* @returns {Promise<IPaymentStatistics>} Payment statistics data.
|
|
167
170
|
*
|
|
168
171
|
* **Code example**
|
|
@@ -200,7 +203,7 @@ export declare class StatisticsClient {
|
|
|
200
203
|
* );
|
|
201
204
|
* ```
|
|
202
205
|
*/
|
|
203
|
-
getPaymentStatistics(filter?: IStatisticsFilter): Promise<IPaymentStatistics>;
|
|
206
|
+
getPaymentStatistics(filter?: IStatisticsFilter, options?: SubgraphOptions): Promise<IPaymentStatistics>;
|
|
204
207
|
/**
|
|
205
208
|
* This function returns the statistical data of HMToken.
|
|
206
209
|
*
|
|
@@ -212,6 +215,7 @@ export declare class StatisticsClient {
|
|
|
212
215
|
* };
|
|
213
216
|
* ```
|
|
214
217
|
*
|
|
218
|
+
* @param {SubgraphOptions} options Optional configuration for subgraph requests.
|
|
215
219
|
* @returns {Promise<IHMTStatistics>} HMToken statistics data.
|
|
216
220
|
*
|
|
217
221
|
* **Code example**
|
|
@@ -229,13 +233,14 @@ export declare class StatisticsClient {
|
|
|
229
233
|
* });
|
|
230
234
|
* ```
|
|
231
235
|
*/
|
|
232
|
-
getHMTStatistics(): Promise<IHMTStatistics>;
|
|
236
|
+
getHMTStatistics(options?: SubgraphOptions): Promise<IHMTStatistics>;
|
|
233
237
|
/**
|
|
234
238
|
* This function returns the holders of the HMToken with optional filters and ordering.
|
|
235
239
|
*
|
|
236
240
|
* **Input parameters**
|
|
237
241
|
*
|
|
238
242
|
* @param {IHMTHoldersParams} params HMT Holders params with filters and ordering
|
|
243
|
+
* @param {SubgraphOptions} options Optional configuration for subgraph requests.
|
|
239
244
|
* @returns {Promise<IHMTHolder[]>} List of HMToken holders.
|
|
240
245
|
*
|
|
241
246
|
* **Code example**
|
|
@@ -255,7 +260,7 @@ export declare class StatisticsClient {
|
|
|
255
260
|
* })));
|
|
256
261
|
* ```
|
|
257
262
|
*/
|
|
258
|
-
getHMTHolders(params?: IHMTHoldersParams): Promise<IHMTHolder[]>;
|
|
263
|
+
getHMTHolders(params?: IHMTHoldersParams, options?: SubgraphOptions): Promise<IHMTHolder[]>;
|
|
259
264
|
/**
|
|
260
265
|
* This function returns the statistical data of HMToken day by day.
|
|
261
266
|
*
|
|
@@ -282,6 +287,7 @@ export declare class StatisticsClient {
|
|
|
282
287
|
* ```
|
|
283
288
|
*
|
|
284
289
|
* @param {IStatisticsFilter} filter Statistics params with duration data
|
|
290
|
+
* @param {SubgraphOptions} options Optional configuration for subgraph requests.
|
|
285
291
|
* @returns {Promise<IDailyHMT[]>} Daily HMToken statistics data.
|
|
286
292
|
*
|
|
287
293
|
* **Code example**
|
|
@@ -303,6 +309,6 @@ export declare class StatisticsClient {
|
|
|
303
309
|
* console.log('HMT statistics from 5/8 - 6/8:', hmtStatisticsRange);
|
|
304
310
|
* ```
|
|
305
311
|
*/
|
|
306
|
-
getHMTDailyData(filter?: IStatisticsFilter): Promise<IDailyHMT[]>;
|
|
312
|
+
getHMTDailyData(filter?: IStatisticsFilter, options?: SubgraphOptions): Promise<IDailyHMT[]>;
|
|
307
313
|
}
|
|
308
314
|
//# sourceMappingURL=statistics.d.ts.map
|
package/dist/statistics.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"statistics.d.ts","sourceRoot":"","sources":["../src/statistics.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"statistics.d.ts","sourceRoot":"","sources":["../src/statistics.ts"],"names":[],"mappings":"AAYA,OAAO,EACL,SAAS,EACT,iBAAiB,EACjB,UAAU,EACV,iBAAiB,EACjB,cAAc,EACd,kBAAkB,EAClB,iBAAiB,EACjB,iBAAiB,EACjB,eAAe,EAChB,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAQtC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,qBAAa,gBAAgB;IACpB,WAAW,EAAE,WAAW,CAAC;IACzB,WAAW,EAAE,MAAM,CAAC;IAE3B;;;;OAIG;gBACS,WAAW,EAAE,WAAW;IAKpC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAgDG;IACG,mBAAmB,CACvB,MAAM,GAAE,iBAAsB,EAC9B,OAAO,CAAC,EAAE,eAAe,GACxB,OAAO,CAAC,iBAAiB,CAAC;IA4C7B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA2CG;IACG,mBAAmB,CACvB,MAAM,GAAE,iBAAsB,EAC9B,OAAO,CAAC,EAAE,eAAe,GACxB,OAAO,CAAC,iBAAiB,CAAC;IAiC7B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAkEG;IACG,oBAAoB,CACxB,MAAM,GAAE,iBAAsB,EAC9B,OAAO,CAAC,EAAE,eAAe,GACxB,OAAO,CAAC,kBAAkB,CAAC;IAuC9B;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA4BG;IACG,gBAAgB,CAAC,OAAO,CAAC,EAAE,eAAe,GAAG,OAAO,CAAC,cAAc,CAAC;IAgB1E;;;;;;;;;;;;;;;;;;;;;;;;;OAyBG;IACG,aAAa,CACjB,MAAM,GAAE,iBAAsB,EAC9B,OAAO,CAAC,EAAE,eAAe,GACxB,OAAO,CAAC,UAAU,EAAE,CAAC;IAyBxB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA+CG;IACG,eAAe,CACnB,MAAM,GAAE,iBAAsB,EAC9B,OAAO,CAAC,EAAE,eAAe,GACxB,OAAO,CAAC,SAAS,EAAE,CAAC;CAiCxB"}
|
package/dist/statistics.js
CHANGED
|
@@ -1,11 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
3
|
exports.StatisticsClient = void 0;
|
|
7
4
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
8
|
-
const graphql_request_1 = __importDefault(require("graphql-request"));
|
|
9
5
|
const enums_1 = require("./enums");
|
|
10
6
|
const graphql_1 = require("./graphql");
|
|
11
7
|
const utils_1 = require("./utils");
|
|
@@ -83,6 +79,7 @@ class StatisticsClient {
|
|
|
83
79
|
* ```
|
|
84
80
|
*
|
|
85
81
|
* @param {IStatisticsFilter} filter Statistics params with duration data
|
|
82
|
+
* @param {SubgraphOptions} options Optional configuration for subgraph requests.
|
|
86
83
|
* @returns {Promise<IEscrowStatistics>} Escrow statistics data.
|
|
87
84
|
*
|
|
88
85
|
* **Code example**
|
|
@@ -99,19 +96,19 @@ class StatisticsClient {
|
|
|
99
96
|
* });
|
|
100
97
|
* ```
|
|
101
98
|
*/
|
|
102
|
-
async getEscrowStatistics(filter = {}) {
|
|
99
|
+
async getEscrowStatistics(filter = {}, options) {
|
|
103
100
|
try {
|
|
104
101
|
const first = filter.first !== undefined ? Math.min(filter.first, 1000) : 10;
|
|
105
102
|
const skip = filter.skip || 0;
|
|
106
103
|
const orderDirection = filter.orderDirection || enums_1.OrderDirection.ASC;
|
|
107
|
-
const { escrowStatistics } = await (0,
|
|
108
|
-
const { eventDayDatas } = await (0,
|
|
104
|
+
const { escrowStatistics } = await (0, utils_1.customGqlFetch)(this.subgraphUrl, graphql_1.GET_ESCROW_STATISTICS_QUERY, options);
|
|
105
|
+
const { eventDayDatas } = await (0, utils_1.customGqlFetch)(this.subgraphUrl, (0, graphql_1.GET_EVENT_DAY_DATA_QUERY)(filter), {
|
|
109
106
|
from: filter.from ? (0, utils_1.getUnixTimestamp)(filter.from) : undefined,
|
|
110
107
|
to: filter.to ? (0, utils_1.getUnixTimestamp)(filter.to) : undefined,
|
|
111
108
|
orderDirection: orderDirection,
|
|
112
109
|
first: first,
|
|
113
110
|
skip: skip,
|
|
114
|
-
});
|
|
111
|
+
}, options);
|
|
115
112
|
return {
|
|
116
113
|
totalEscrows: escrowStatistics?.totalEscrowCount
|
|
117
114
|
? +escrowStatistics.totalEscrowCount
|
|
@@ -157,6 +154,7 @@ class StatisticsClient {
|
|
|
157
154
|
* ```
|
|
158
155
|
*
|
|
159
156
|
* @param {IStatisticsFilter} filter Statistics params with duration data
|
|
157
|
+
* @param {SubgraphOptions} options Optional configuration for subgraph requests.
|
|
160
158
|
* @returns {Promise<IWorkerStatistics>} Worker statistics data.
|
|
161
159
|
*
|
|
162
160
|
* **Code example**
|
|
@@ -173,18 +171,18 @@ class StatisticsClient {
|
|
|
173
171
|
* });
|
|
174
172
|
* ```
|
|
175
173
|
*/
|
|
176
|
-
async getWorkerStatistics(filter = {}) {
|
|
174
|
+
async getWorkerStatistics(filter = {}, options) {
|
|
177
175
|
try {
|
|
178
176
|
const first = filter.first !== undefined ? Math.min(filter.first, 1000) : 10;
|
|
179
177
|
const skip = filter.skip || 0;
|
|
180
178
|
const orderDirection = filter.orderDirection || enums_1.OrderDirection.ASC;
|
|
181
|
-
const { eventDayDatas } = await (0,
|
|
179
|
+
const { eventDayDatas } = await (0, utils_1.customGqlFetch)(this.subgraphUrl, (0, graphql_1.GET_EVENT_DAY_DATA_QUERY)(filter), {
|
|
182
180
|
from: filter.from ? (0, utils_1.getUnixTimestamp)(filter.from) : undefined,
|
|
183
181
|
to: filter.to ? (0, utils_1.getUnixTimestamp)(filter.to) : undefined,
|
|
184
182
|
orderDirection: orderDirection,
|
|
185
183
|
first: first,
|
|
186
184
|
skip: skip,
|
|
187
|
-
});
|
|
185
|
+
}, options);
|
|
188
186
|
return {
|
|
189
187
|
dailyWorkersData: eventDayDatas.map((eventDayData) => ({
|
|
190
188
|
timestamp: +eventDayData.timestamp * 1000,
|
|
@@ -225,6 +223,7 @@ class StatisticsClient {
|
|
|
225
223
|
* ```
|
|
226
224
|
*
|
|
227
225
|
* @param {IStatisticsFilter} filter Statistics params with duration data
|
|
226
|
+
* @param {SubgraphOptions} options Optional configuration for subgraph requests.
|
|
228
227
|
* @returns {Promise<IPaymentStatistics>} Payment statistics data.
|
|
229
228
|
*
|
|
230
229
|
* **Code example**
|
|
@@ -262,18 +261,18 @@ class StatisticsClient {
|
|
|
262
261
|
* );
|
|
263
262
|
* ```
|
|
264
263
|
*/
|
|
265
|
-
async getPaymentStatistics(filter = {}) {
|
|
264
|
+
async getPaymentStatistics(filter = {}, options) {
|
|
266
265
|
try {
|
|
267
266
|
const first = filter.first !== undefined ? Math.min(filter.first, 1000) : 10;
|
|
268
267
|
const skip = filter.skip || 0;
|
|
269
268
|
const orderDirection = filter.orderDirection || enums_1.OrderDirection.ASC;
|
|
270
|
-
const { eventDayDatas } = await (0,
|
|
269
|
+
const { eventDayDatas } = await (0, utils_1.customGqlFetch)(this.subgraphUrl, (0, graphql_1.GET_EVENT_DAY_DATA_QUERY)(filter), {
|
|
271
270
|
from: filter.from ? (0, utils_1.getUnixTimestamp)(filter.from) : undefined,
|
|
272
271
|
to: filter.to ? (0, utils_1.getUnixTimestamp)(filter.to) : undefined,
|
|
273
272
|
orderDirection: orderDirection,
|
|
274
273
|
first: first,
|
|
275
274
|
skip: skip,
|
|
276
|
-
});
|
|
275
|
+
}, options);
|
|
277
276
|
return {
|
|
278
277
|
dailyPaymentsData: eventDayDatas.map((eventDayData) => ({
|
|
279
278
|
timestamp: +eventDayData.timestamp * 1000,
|
|
@@ -301,6 +300,7 @@ class StatisticsClient {
|
|
|
301
300
|
* };
|
|
302
301
|
* ```
|
|
303
302
|
*
|
|
303
|
+
* @param {SubgraphOptions} options Optional configuration for subgraph requests.
|
|
304
304
|
* @returns {Promise<IHMTStatistics>} HMToken statistics data.
|
|
305
305
|
*
|
|
306
306
|
* **Code example**
|
|
@@ -318,9 +318,9 @@ class StatisticsClient {
|
|
|
318
318
|
* });
|
|
319
319
|
* ```
|
|
320
320
|
*/
|
|
321
|
-
async getHMTStatistics() {
|
|
321
|
+
async getHMTStatistics(options) {
|
|
322
322
|
try {
|
|
323
|
-
const { hmtokenStatistics } = await (0,
|
|
323
|
+
const { hmtokenStatistics } = await (0, utils_1.customGqlFetch)(this.subgraphUrl, graphql_1.GET_HMTOKEN_STATISTICS_QUERY, options);
|
|
324
324
|
return {
|
|
325
325
|
totalTransferAmount: BigInt(hmtokenStatistics.totalValueTransfered),
|
|
326
326
|
totalTransferCount: +hmtokenStatistics.totalTransferEventCount,
|
|
@@ -337,6 +337,7 @@ class StatisticsClient {
|
|
|
337
337
|
* **Input parameters**
|
|
338
338
|
*
|
|
339
339
|
* @param {IHMTHoldersParams} params HMT Holders params with filters and ordering
|
|
340
|
+
* @param {SubgraphOptions} options Optional configuration for subgraph requests.
|
|
340
341
|
* @returns {Promise<IHMTHolder[]>} List of HMToken holders.
|
|
341
342
|
*
|
|
342
343
|
* **Code example**
|
|
@@ -356,15 +357,15 @@ class StatisticsClient {
|
|
|
356
357
|
* })));
|
|
357
358
|
* ```
|
|
358
359
|
*/
|
|
359
|
-
async getHMTHolders(params = {}) {
|
|
360
|
+
async getHMTHolders(params = {}, options) {
|
|
360
361
|
try {
|
|
361
362
|
const { address, orderDirection } = params;
|
|
362
363
|
const query = (0, graphql_1.GET_HOLDERS_QUERY)(address);
|
|
363
|
-
const { holders } = await (0,
|
|
364
|
+
const { holders } = await (0, utils_1.customGqlFetch)(this.subgraphUrl, query, {
|
|
364
365
|
address,
|
|
365
366
|
orderBy: 'balance',
|
|
366
367
|
orderDirection,
|
|
367
|
-
});
|
|
368
|
+
}, options);
|
|
368
369
|
return holders.map((holder) => ({
|
|
369
370
|
address: holder.address,
|
|
370
371
|
balance: BigInt(holder.balance),
|
|
@@ -400,6 +401,7 @@ class StatisticsClient {
|
|
|
400
401
|
* ```
|
|
401
402
|
*
|
|
402
403
|
* @param {IStatisticsFilter} filter Statistics params with duration data
|
|
404
|
+
* @param {SubgraphOptions} options Optional configuration for subgraph requests.
|
|
403
405
|
* @returns {Promise<IDailyHMT[]>} Daily HMToken statistics data.
|
|
404
406
|
*
|
|
405
407
|
* **Code example**
|
|
@@ -421,18 +423,18 @@ class StatisticsClient {
|
|
|
421
423
|
* console.log('HMT statistics from 5/8 - 6/8:', hmtStatisticsRange);
|
|
422
424
|
* ```
|
|
423
425
|
*/
|
|
424
|
-
async getHMTDailyData(filter = {}) {
|
|
426
|
+
async getHMTDailyData(filter = {}, options) {
|
|
425
427
|
try {
|
|
426
428
|
const first = filter.first !== undefined ? Math.min(filter.first, 1000) : 10;
|
|
427
429
|
const skip = filter.skip || 0;
|
|
428
430
|
const orderDirection = filter.orderDirection || enums_1.OrderDirection.ASC;
|
|
429
|
-
const { eventDayDatas } = await (0,
|
|
431
|
+
const { eventDayDatas } = await (0, utils_1.customGqlFetch)(this.subgraphUrl, (0, graphql_1.GET_EVENT_DAY_DATA_QUERY)(filter), {
|
|
430
432
|
from: filter.from ? (0, utils_1.getUnixTimestamp)(filter.from) : undefined,
|
|
431
433
|
to: filter.to ? (0, utils_1.getUnixTimestamp)(filter.to) : undefined,
|
|
432
434
|
orderDirection: orderDirection,
|
|
433
435
|
first: first,
|
|
434
436
|
skip: skip,
|
|
435
|
-
});
|
|
437
|
+
}, options);
|
|
436
438
|
return eventDayDatas.map((eventDayData) => ({
|
|
437
439
|
timestamp: +eventDayData.timestamp * 1000,
|
|
438
440
|
totalTransactionAmount: BigInt(eventDayData.dailyHMTTransferAmount),
|
package/dist/storage.js
CHANGED
|
@@ -107,7 +107,7 @@ class StorageClient {
|
|
|
107
107
|
secretKey: credentials?.secretKey ?? '',
|
|
108
108
|
});
|
|
109
109
|
}
|
|
110
|
-
catch
|
|
110
|
+
catch {
|
|
111
111
|
throw error_1.ErrorStorageClientNotInitialized;
|
|
112
112
|
}
|
|
113
113
|
}
|
|
@@ -147,7 +147,7 @@ class StorageClient {
|
|
|
147
147
|
const content = response?.read();
|
|
148
148
|
return { key, content: JSON.parse(content?.toString('utf-8') || '') };
|
|
149
149
|
}
|
|
150
|
-
catch
|
|
150
|
+
catch {
|
|
151
151
|
throw error_1.ErrorStorageFileNotFound;
|
|
152
152
|
}
|
|
153
153
|
}));
|
|
@@ -181,7 +181,7 @@ class StorageClient {
|
|
|
181
181
|
}
|
|
182
182
|
return data;
|
|
183
183
|
}
|
|
184
|
-
catch
|
|
184
|
+
catch {
|
|
185
185
|
throw error_1.ErrorStorageFileNotFound;
|
|
186
186
|
}
|
|
187
187
|
}
|
|
@@ -235,7 +235,7 @@ class StorageClient {
|
|
|
235
235
|
hash,
|
|
236
236
|
};
|
|
237
237
|
}
|
|
238
|
-
catch
|
|
238
|
+
catch {
|
|
239
239
|
throw error_1.ErrorStorageFileNotUploaded;
|
|
240
240
|
}
|
|
241
241
|
}));
|
package/dist/transaction.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ChainId } from './enums';
|
|
2
|
-
import { ITransaction, ITransactionsFilter } from './interfaces';
|
|
2
|
+
import { ITransaction, ITransactionsFilter, SubgraphOptions } from './interfaces';
|
|
3
3
|
export declare class TransactionUtils {
|
|
4
4
|
/**
|
|
5
5
|
* This function returns the transaction data for the given hash.
|
|
@@ -34,6 +34,7 @@ export declare class TransactionUtils {
|
|
|
34
34
|
*
|
|
35
35
|
* @param {ChainId} chainId The chain ID.
|
|
36
36
|
* @param {string} hash The transaction hash.
|
|
37
|
+
* @param {SubgraphOptions} options Optional configuration for subgraph requests.
|
|
37
38
|
* @returns {Promise<ITransaction | null>} - Returns the transaction details or null if not found.
|
|
38
39
|
*
|
|
39
40
|
* **Code example**
|
|
@@ -44,7 +45,7 @@ export declare class TransactionUtils {
|
|
|
44
45
|
* const transaction = await TransactionUtils.getTransaction(ChainId.POLYGON, '0x62dD51230A30401C455c8398d06F85e4EaB6309f');
|
|
45
46
|
* ```
|
|
46
47
|
*/
|
|
47
|
-
static getTransaction(chainId: ChainId, hash: string): Promise<ITransaction | null>;
|
|
48
|
+
static getTransaction(chainId: ChainId, hash: string, options?: SubgraphOptions): Promise<ITransaction | null>;
|
|
48
49
|
/**
|
|
49
50
|
* This function returns all transaction details based on the provided filter.
|
|
50
51
|
*
|
|
@@ -99,6 +100,7 @@ export declare class TransactionUtils {
|
|
|
99
100
|
* ```
|
|
100
101
|
*
|
|
101
102
|
* @param {ITransactionsFilter} filter Filter for the transactions.
|
|
103
|
+
* @param {SubgraphOptions} options Optional configuration for subgraph requests.
|
|
102
104
|
* @returns {Promise<ITransaction[]>} Returns an array with all the transaction details.
|
|
103
105
|
*
|
|
104
106
|
* **Code example**
|
|
@@ -117,6 +119,6 @@ export declare class TransactionUtils {
|
|
|
117
119
|
* const transactions = await TransactionUtils.getTransactions(filter);
|
|
118
120
|
* ```
|
|
119
121
|
*/
|
|
120
|
-
static getTransactions(filter: ITransactionsFilter): Promise<ITransaction[]>;
|
|
122
|
+
static getTransactions(filter: ITransactionsFilter, options?: SubgraphOptions): Promise<ITransaction[]>;
|
|
121
123
|
}
|
|
122
124
|
//# sourceMappingURL=transaction.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transaction.d.ts","sourceRoot":"","sources":["../src/transaction.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"transaction.d.ts","sourceRoot":"","sources":["../src/transaction.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,EAAkB,MAAM,SAAS,CAAC;AAWlD,OAAO,EAEL,YAAY,EACZ,mBAAmB,EACnB,eAAe,EAChB,MAAM,cAAc,CAAC;AAGtB,qBAAa,gBAAgB;IAC3B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA2CG;WACiB,cAAc,CAChC,OAAO,EAAE,OAAO,EAChB,IAAI,EAAE,MAAM,EACZ,OAAO,CAAC,EAAE,eAAe,GACxB,OAAO,CAAC,YAAY,GAAG,IAAI,CAAC;IAyB/B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAwEG;WACiB,eAAe,CACjC,MAAM,EAAE,mBAAmB,EAC3B,OAAO,CAAC,EAAE,eAAe,GACxB,OAAO,CAAC,YAAY,EAAE,CAAC;CAgD3B"}
|