@human-protocol/sdk 5.0.0-beta.2 → 5.0.0-beta.3

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.
@@ -1,5 +1,4 @@
1
- import { EscrowStatistics, HMTStatistics, PaymentStatistics, WorkerStatistics, HMTHolder, DailyHMTData } from './graphql';
2
- import { IHMTHoldersParams, IStatisticsFilter } from './interfaces';
1
+ import { IDailyHMT, IEscrowStatistics, IHMTHolder, IHMTHoldersParams, IHMTStatistics, IPaymentStatistics, IStatisticsFilter, IWorkerStatistics } from './interfaces';
3
2
  import { NetworkData } from './types';
4
3
  /**
5
4
  * ## Introduction
@@ -58,8 +57,8 @@ export declare class StatisticsClient {
58
57
  * ```
59
58
  *
60
59
  * ```ts
61
- * type DailyEscrowsData = {
62
- * timestamp: Date;
60
+ * interface IDailyEscrow {
61
+ * timestamp: number;
63
62
  * escrowsTotal: number;
64
63
  * escrowsPending: number;
65
64
  * escrowsSolved: number;
@@ -67,14 +66,14 @@ export declare class StatisticsClient {
67
66
  * escrowsCancelled: number;
68
67
  * };
69
68
  *
70
- * type EscrowStatistics = {
69
+ * interface IEscrowStatistics {
71
70
  * totalEscrows: number;
72
- * dailyEscrowsData: DailyEscrowsData[];
71
+ * dailyEscrowsData: IDailyEscrow[];
73
72
  * };
74
73
  * ```
75
74
  *
76
75
  * @param {IStatisticsFilter} filter Statistics params with duration data
77
- * @returns {Promise<EscrowStatistics>} Escrow statistics data.
76
+ * @returns {Promise<IEscrowStatistics>} Escrow statistics data.
78
77
  *
79
78
  * **Code example**
80
79
  *
@@ -90,7 +89,7 @@ export declare class StatisticsClient {
90
89
  * });
91
90
  * ```
92
91
  */
93
- getEscrowStatistics(filter?: IStatisticsFilter): Promise<EscrowStatistics>;
92
+ getEscrowStatistics(filter?: IStatisticsFilter): Promise<IEscrowStatistics>;
94
93
  /**
95
94
  * This function returns the statistical data of workers.
96
95
  *
@@ -107,18 +106,18 @@ export declare class StatisticsClient {
107
106
  * ```
108
107
  *
109
108
  * ```ts
110
- * type DailyWorkerData = {
111
- * timestamp: Date;
109
+ * interface IDailyWorker {
110
+ * timestamp: number;
112
111
  * activeWorkers: number;
113
112
  * };
114
113
  *
115
- * type WorkerStatistics = {
116
- * dailyWorkersData: DailyWorkerData[];
114
+ * interface IWorkerStatistics {
115
+ * dailyWorkersData: IDailyWorker[];
117
116
  * };
118
117
  * ```
119
118
  *
120
119
  * @param {IStatisticsFilter} filter Statistics params with duration data
121
- * @returns {Promise<WorkerStatistics>} Worker statistics data.
120
+ * @returns {Promise<IWorkerStatistics>} Worker statistics data.
122
121
  *
123
122
  * **Code example**
124
123
  *
@@ -134,7 +133,7 @@ export declare class StatisticsClient {
134
133
  * });
135
134
  * ```
136
135
  */
137
- getWorkerStatistics(filter?: IStatisticsFilter): Promise<WorkerStatistics>;
136
+ getWorkerStatistics(filter?: IStatisticsFilter): Promise<IWorkerStatistics>;
138
137
  /**
139
138
  * This function returns the statistical data of payments.
140
139
  *
@@ -151,20 +150,20 @@ export declare class StatisticsClient {
151
150
  * ```
152
151
  *
153
152
  * ```ts
154
- * type DailyPaymentData = {
155
- * timestamp: Date;
156
- * totalAmountPaid: BigNumber;
153
+ * interface IDailyPayment {
154
+ * timestamp: number;
155
+ * totalAmountPaid: bigint;
157
156
  * totalCount: number;
158
- * averageAmountPerWorker: BigNumber;
157
+ * averageAmountPerWorker: bigint;
159
158
  * };
160
159
  *
161
- * type PaymentStatistics = {
162
- * dailyPaymentsData: DailyPaymentData[];
160
+ * interface IPaymentStatistics {
161
+ * dailyPaymentsData: IDailyPayment[];
163
162
  * };
164
163
  * ```
165
164
  *
166
165
  * @param {IStatisticsFilter} filter Statistics params with duration data
167
- * @returns {Promise<PaymentStatistics>} Payment statistics data.
166
+ * @returns {Promise<IPaymentStatistics>} Payment statistics data.
168
167
  *
169
168
  * **Code example**
170
169
  *
@@ -201,19 +200,19 @@ export declare class StatisticsClient {
201
200
  * );
202
201
  * ```
203
202
  */
204
- getPaymentStatistics(filter?: IStatisticsFilter): Promise<PaymentStatistics>;
203
+ getPaymentStatistics(filter?: IStatisticsFilter): Promise<IPaymentStatistics>;
205
204
  /**
206
205
  * This function returns the statistical data of HMToken.
207
206
  *
208
207
  * ```ts
209
- * type HMTStatistics = {
210
- * totalTransferAmount: BigNumber;
211
- * totalTransferCount: BigNumber;
208
+ * interface IHMTStatistics {
209
+ * totalTransferAmount: bigint;
210
+ * totalTransferCount: number;
212
211
  * totalHolders: number;
213
212
  * };
214
213
  * ```
215
214
  *
216
- * @returns {Promise<HMTStatistics>} HMToken statistics data.
215
+ * @returns {Promise<IHMTStatistics>} HMToken statistics data.
217
216
  *
218
217
  * **Code example**
219
218
  *
@@ -230,14 +229,14 @@ export declare class StatisticsClient {
230
229
  * });
231
230
  * ```
232
231
  */
233
- getHMTStatistics(): Promise<HMTStatistics>;
232
+ getHMTStatistics(): Promise<IHMTStatistics>;
234
233
  /**
235
234
  * This function returns the holders of the HMToken with optional filters and ordering.
236
235
  *
237
236
  * **Input parameters**
238
237
  *
239
238
  * @param {IHMTHoldersParams} params HMT Holders params with filters and ordering
240
- * @returns {Promise<HMTHolder[]>} List of HMToken holders.
239
+ * @returns {Promise<IHMTHolder[]>} List of HMToken holders.
241
240
  *
242
241
  * **Code example**
243
242
  *
@@ -256,7 +255,7 @@ export declare class StatisticsClient {
256
255
  * })));
257
256
  * ```
258
257
  */
259
- getHMTHolders(params?: IHMTHoldersParams): Promise<HMTHolder[]>;
258
+ getHMTHolders(params?: IHMTHoldersParams): Promise<IHMTHolder[]>;
260
259
  /**
261
260
  * This function returns the statistical data of HMToken day by day.
262
261
  *
@@ -273,8 +272,8 @@ export declare class StatisticsClient {
273
272
  * ```
274
273
  *
275
274
  * ```ts
276
- * type DailyHMTData = {
277
- * timestamp: Date;
275
+ * interface IDailyHMT {
276
+ * timestamp: number;
278
277
  * totalTransactionAmount: bigint;
279
278
  * totalTransactionCount: number;
280
279
  * dailyUniqueSenders: number;
@@ -283,7 +282,7 @@ export declare class StatisticsClient {
283
282
  * ```
284
283
  *
285
284
  * @param {IStatisticsFilter} filter Statistics params with duration data
286
- * @returns {Promise<DailyHMTData[]>} Daily HMToken statistics data.
285
+ * @returns {Promise<IDailyHMT[]>} Daily HMToken statistics data.
287
286
  *
288
287
  * **Code example**
289
288
  *
@@ -304,6 +303,6 @@ export declare class StatisticsClient {
304
303
  * console.log('HMT statistics from 5/8 - 6/8:', hmtStatisticsRange);
305
304
  * ```
306
305
  */
307
- getHMTDailyData(filter?: IStatisticsFilter): Promise<DailyHMTData[]>;
306
+ getHMTDailyData(filter?: IStatisticsFilter): Promise<IDailyHMT[]>;
308
307
  }
309
308
  //# sourceMappingURL=statistics.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"statistics.d.ts","sourceRoot":"","sources":["../src/statistics.ts"],"names":[],"mappings":"AAIA,OAAO,EAKL,gBAAgB,EAGhB,aAAa,EAEb,iBAAiB,EACjB,gBAAgB,EAEhB,SAAS,EACT,YAAY,EACb,MAAM,WAAW,CAAC;AACnB,OAAO,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AACpE,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAItC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,qBAAa,gBAAgB;IACpB,WAAW,EAAE,WAAW,CAAC;IACzB,WAAW,EAAE,MAAM,CAAC;IAE3B;;;;OAIG;gBACS,WAAW,EAAE,WAAW;IAKpC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA+CG;IACG,mBAAmB,CACvB,MAAM,GAAE,iBAAsB,GAC7B,OAAO,CAAC,gBAAgB,CAAC;IAuC5B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA0CG;IACG,mBAAmB,CACvB,MAAM,GAAE,iBAAsB,GAC7B,OAAO,CAAC,gBAAgB,CAAC;IA4B5B;;;;;;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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAiEG;IACG,oBAAoB,CACxB,MAAM,GAAE,iBAAsB,GAC7B,OAAO,CAAC,kBAAkB,CAAC;IAkC9B;;;;;;;;;;;;;;;;;;;;;;;;;;;OA2BG;IACG,gBAAgB,IAAI,OAAO,CAAC,cAAc,CAAC;IAgBjD;;;;;;;;;;;;;;;;;;;;;;;;OAwBG;IACG,aAAa,CAAC,MAAM,GAAE,iBAAsB,GAAG,OAAO,CAAC,UAAU,EAAE,CAAC;IAwB1E;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA8CG;IACG,eAAe,CAAC,MAAM,GAAE,iBAAsB,GAAG,OAAO,CAAC,SAAS,EAAE,CAAC;CA4B5E"}
@@ -5,11 +5,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.StatisticsClient = void 0;
7
7
  /* eslint-disable @typescript-eslint/no-explicit-any */
8
- const ethers_1 = require("ethers");
9
8
  const graphql_request_1 = __importDefault(require("graphql-request"));
9
+ const enums_1 = require("./enums");
10
10
  const graphql_1 = require("./graphql");
11
11
  const utils_1 = require("./utils");
12
- const enums_1 = require("./enums");
13
12
  /**
14
13
  * ## Introduction
15
14
  *
@@ -68,8 +67,8 @@ class StatisticsClient {
68
67
  * ```
69
68
  *
70
69
  * ```ts
71
- * type DailyEscrowsData = {
72
- * timestamp: Date;
70
+ * interface IDailyEscrow {
71
+ * timestamp: number;
73
72
  * escrowsTotal: number;
74
73
  * escrowsPending: number;
75
74
  * escrowsSolved: number;
@@ -77,14 +76,14 @@ class StatisticsClient {
77
76
  * escrowsCancelled: number;
78
77
  * };
79
78
  *
80
- * type EscrowStatistics = {
79
+ * interface IEscrowStatistics {
81
80
  * totalEscrows: number;
82
- * dailyEscrowsData: DailyEscrowsData[];
81
+ * dailyEscrowsData: IDailyEscrow[];
83
82
  * };
84
83
  * ```
85
84
  *
86
85
  * @param {IStatisticsFilter} filter Statistics params with duration data
87
- * @returns {Promise<EscrowStatistics>} Escrow statistics data.
86
+ * @returns {Promise<IEscrowStatistics>} Escrow statistics data.
88
87
  *
89
88
  * **Code example**
90
89
  *
@@ -118,7 +117,7 @@ class StatisticsClient {
118
117
  ? +escrowStatistics.totalEscrowCount
119
118
  : 0,
120
119
  dailyEscrowsData: eventDayDatas.map((eventDayData) => ({
121
- timestamp: new Date(+eventDayData.timestamp * 1000),
120
+ timestamp: +eventDayData.timestamp * 1000,
122
121
  escrowsTotal: +eventDayData.dailyEscrowCount,
123
122
  escrowsPending: +eventDayData.dailyPendingStatusEventCount,
124
123
  escrowsSolved: +eventDayData.dailyCompletedStatusEventCount,
@@ -147,18 +146,18 @@ class StatisticsClient {
147
146
  * ```
148
147
  *
149
148
  * ```ts
150
- * type DailyWorkerData = {
151
- * timestamp: Date;
149
+ * interface IDailyWorker {
150
+ * timestamp: number;
152
151
  * activeWorkers: number;
153
152
  * };
154
153
  *
155
- * type WorkerStatistics = {
156
- * dailyWorkersData: DailyWorkerData[];
154
+ * interface IWorkerStatistics {
155
+ * dailyWorkersData: IDailyWorker[];
157
156
  * };
158
157
  * ```
159
158
  *
160
159
  * @param {IStatisticsFilter} filter Statistics params with duration data
161
- * @returns {Promise<WorkerStatistics>} Worker statistics data.
160
+ * @returns {Promise<IWorkerStatistics>} Worker statistics data.
162
161
  *
163
162
  * **Code example**
164
163
  *
@@ -188,7 +187,7 @@ class StatisticsClient {
188
187
  });
189
188
  return {
190
189
  dailyWorkersData: eventDayDatas.map((eventDayData) => ({
191
- timestamp: new Date(+eventDayData.timestamp * 1000),
190
+ timestamp: +eventDayData.timestamp * 1000,
192
191
  activeWorkers: +eventDayData.dailyWorkerCount,
193
192
  })),
194
193
  };
@@ -213,20 +212,20 @@ class StatisticsClient {
213
212
  * ```
214
213
  *
215
214
  * ```ts
216
- * type DailyPaymentData = {
217
- * timestamp: Date;
218
- * totalAmountPaid: BigNumber;
215
+ * interface IDailyPayment {
216
+ * timestamp: number;
217
+ * totalAmountPaid: bigint;
219
218
  * totalCount: number;
220
- * averageAmountPerWorker: BigNumber;
219
+ * averageAmountPerWorker: bigint;
221
220
  * };
222
221
  *
223
- * type PaymentStatistics = {
224
- * dailyPaymentsData: DailyPaymentData[];
222
+ * interface IPaymentStatistics {
223
+ * dailyPaymentsData: IDailyPayment[];
225
224
  * };
226
225
  * ```
227
226
  *
228
227
  * @param {IStatisticsFilter} filter Statistics params with duration data
229
- * @returns {Promise<PaymentStatistics>} Payment statistics data.
228
+ * @returns {Promise<IPaymentStatistics>} Payment statistics data.
230
229
  *
231
230
  * **Code example**
232
231
  *
@@ -277,13 +276,13 @@ class StatisticsClient {
277
276
  });
278
277
  return {
279
278
  dailyPaymentsData: eventDayDatas.map((eventDayData) => ({
280
- timestamp: new Date(+eventDayData.timestamp * 1000),
281
- totalAmountPaid: ethers_1.ethers.toBigInt(eventDayData.dailyHMTPayoutAmount),
279
+ timestamp: +eventDayData.timestamp * 1000,
280
+ totalAmountPaid: BigInt(eventDayData.dailyHMTPayoutAmount),
282
281
  totalCount: +eventDayData.dailyPayoutCount,
283
282
  averageAmountPerWorker: eventDayData.dailyWorkerCount === '0'
284
- ? ethers_1.ethers.toBigInt(0)
285
- : ethers_1.ethers.toBigInt(eventDayData.dailyHMTPayoutAmount) /
286
- ethers_1.ethers.toBigInt(eventDayData.dailyWorkerCount),
283
+ ? BigInt(0)
284
+ : BigInt(eventDayData.dailyHMTPayoutAmount) /
285
+ BigInt(eventDayData.dailyWorkerCount),
287
286
  })),
288
287
  };
289
288
  }
@@ -295,14 +294,14 @@ class StatisticsClient {
295
294
  * This function returns the statistical data of HMToken.
296
295
  *
297
296
  * ```ts
298
- * type HMTStatistics = {
299
- * totalTransferAmount: BigNumber;
300
- * totalTransferCount: BigNumber;
297
+ * interface IHMTStatistics {
298
+ * totalTransferAmount: bigint;
299
+ * totalTransferCount: number;
301
300
  * totalHolders: number;
302
301
  * };
303
302
  * ```
304
303
  *
305
- * @returns {Promise<HMTStatistics>} HMToken statistics data.
304
+ * @returns {Promise<IHMTStatistics>} HMToken statistics data.
306
305
  *
307
306
  * **Code example**
308
307
  *
@@ -323,8 +322,8 @@ class StatisticsClient {
323
322
  try {
324
323
  const { hmtokenStatistics } = await (0, graphql_request_1.default)(this.subgraphUrl, graphql_1.GET_HMTOKEN_STATISTICS_QUERY);
325
324
  return {
326
- totalTransferAmount: ethers_1.ethers.toBigInt(hmtokenStatistics.totalValueTransfered),
327
- totalTransferCount: Number(hmtokenStatistics.totalTransferEventCount),
325
+ totalTransferAmount: BigInt(hmtokenStatistics.totalValueTransfered),
326
+ totalTransferCount: +hmtokenStatistics.totalTransferEventCount,
328
327
  totalHolders: +hmtokenStatistics.holders,
329
328
  };
330
329
  }
@@ -338,7 +337,7 @@ class StatisticsClient {
338
337
  * **Input parameters**
339
338
  *
340
339
  * @param {IHMTHoldersParams} params HMT Holders params with filters and ordering
341
- * @returns {Promise<HMTHolder[]>} List of HMToken holders.
340
+ * @returns {Promise<IHMTHolder[]>} List of HMToken holders.
342
341
  *
343
342
  * **Code example**
344
343
  *
@@ -368,7 +367,7 @@ class StatisticsClient {
368
367
  });
369
368
  return holders.map((holder) => ({
370
369
  address: holder.address,
371
- balance: ethers_1.ethers.toBigInt(holder.balance),
370
+ balance: BigInt(holder.balance),
372
371
  }));
373
372
  }
374
373
  catch (e) {
@@ -391,8 +390,8 @@ class StatisticsClient {
391
390
  * ```
392
391
  *
393
392
  * ```ts
394
- * type DailyHMTData = {
395
- * timestamp: Date;
393
+ * interface IDailyHMT {
394
+ * timestamp: number;
396
395
  * totalTransactionAmount: bigint;
397
396
  * totalTransactionCount: number;
398
397
  * dailyUniqueSenders: number;
@@ -401,7 +400,7 @@ class StatisticsClient {
401
400
  * ```
402
401
  *
403
402
  * @param {IStatisticsFilter} filter Statistics params with duration data
404
- * @returns {Promise<DailyHMTData[]>} Daily HMToken statistics data.
403
+ * @returns {Promise<IDailyHMT[]>} Daily HMToken statistics data.
405
404
  *
406
405
  * **Code example**
407
406
  *
@@ -435,8 +434,8 @@ class StatisticsClient {
435
434
  skip: skip,
436
435
  });
437
436
  return eventDayDatas.map((eventDayData) => ({
438
- timestamp: new Date(+eventDayData.timestamp * 1000),
439
- totalTransactionAmount: ethers_1.ethers.toBigInt(eventDayData.dailyHMTTransferAmount),
437
+ timestamp: +eventDayData.timestamp * 1000,
438
+ totalTransactionAmount: BigInt(eventDayData.dailyHMTTransferAmount),
440
439
  totalTransactionCount: +eventDayData.dailyHMTTransferCount,
441
440
  dailyUniqueSenders: +eventDayData.dailyUniqueSenders,
442
441
  dailyUniqueReceivers: +eventDayData.dailyUniqueReceivers,
@@ -11,7 +11,7 @@ export declare class TransactionUtils {
11
11
  * from: string;
12
12
  * to: string;
13
13
  * timestamp: bigint;
14
- * value: string;
14
+ * value: bigint;
15
15
  * method: string;
16
16
  * receiver?: string;
17
17
  * escrow?: string;
@@ -20,6 +20,18 @@ export declare class TransactionUtils {
20
20
  * };
21
21
  * ```
22
22
  *
23
+ * ```ts
24
+ * type InternalTransaction = {
25
+ * from: string;
26
+ * to: string;
27
+ * value: bigint;
28
+ * method: string;
29
+ * receiver?: string;
30
+ * escrow?: string;
31
+ * token?: string;
32
+ * };
33
+ * ```
34
+ *
23
35
  * @param {ChainId} chainId The chain ID.
24
36
  * @param {string} hash The transaction hash.
25
37
  * @returns {Promise<ITransaction | null>} - Returns the transaction details or null if not found.
@@ -56,6 +68,18 @@ export declare class TransactionUtils {
56
68
  * skip?: number; // (Optional) Number of transactions to skip. Default is 0.
57
69
  * orderDirection?: OrderDirection; // (Optional) Order of the results. Default is DESC.
58
70
  * }
71
+ *
72
+ *
73
+ * ```ts
74
+ * type InternalTransaction = {
75
+ * from: string;
76
+ * to: string;
77
+ * value: bigint;
78
+ * method: string;
79
+ * receiver?: string;
80
+ * escrow?: string;
81
+ * token?: string;
82
+ * };
59
83
  * ```
60
84
  *
61
85
  * ```ts
@@ -65,7 +89,7 @@ export declare class TransactionUtils {
65
89
  * from: string;
66
90
  * to: string;
67
91
  * timestamp: bigint;
68
- * value: string;
92
+ * value: bigint;
69
93
  * method: string;
70
94
  * receiver?: string;
71
95
  * escrow?: string;
@@ -1 +1 @@
1
- {"version":3,"file":"transaction.d.ts","sourceRoot":"","sources":["../src/transaction.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,OAAO,EAAkB,MAAM,SAAS,CAAC;AAUlD,OAAO,EAAE,YAAY,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AAGjE,qBAAa,gBAAgB;IAC3B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA8BG;WACiB,cAAc,CAChC,OAAO,EAAE,OAAO,EAChB,IAAI,EAAE,MAAM,GACX,OAAO,CAAC,YAAY,GAAG,IAAI,CAAC;IAmB/B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA2DG;WACiB,eAAe,CACjC,MAAM,EAAE,mBAAmB,GAC1B,OAAO,CAAC,YAAY,EAAE,CAAC;CA2C3B"}
1
+ {"version":3,"file":"transaction.d.ts","sourceRoot":"","sources":["../src/transaction.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,OAAO,EAAkB,MAAM,SAAS,CAAC;AAWlD,OAAO,EAEL,YAAY,EACZ,mBAAmB,EACpB,MAAM,cAAc,CAAC;AAGtB,qBAAa,gBAAgB;IAC3B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA0CG;WACiB,cAAc,CAChC,OAAO,EAAE,OAAO,EAChB,IAAI,EAAE,MAAM,GACX,OAAO,CAAC,YAAY,GAAG,IAAI,CAAC;IAoB/B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAuEG;WACiB,eAAe,CACjC,MAAM,EAAE,mBAAmB,GAC1B,OAAO,CAAC,YAAY,EAAE,CAAC;CA2C3B"}
@@ -23,7 +23,7 @@ class TransactionUtils {
23
23
  * from: string;
24
24
  * to: string;
25
25
  * timestamp: bigint;
26
- * value: string;
26
+ * value: bigint;
27
27
  * method: string;
28
28
  * receiver?: string;
29
29
  * escrow?: string;
@@ -32,6 +32,18 @@ class TransactionUtils {
32
32
  * };
33
33
  * ```
34
34
  *
35
+ * ```ts
36
+ * type InternalTransaction = {
37
+ * from: string;
38
+ * to: string;
39
+ * value: bigint;
40
+ * method: string;
41
+ * receiver?: string;
42
+ * escrow?: string;
43
+ * token?: string;
44
+ * };
45
+ * ```
46
+ *
35
47
  * @param {ChainId} chainId The chain ID.
36
48
  * @param {string} hash The transaction hash.
37
49
  * @returns {Promise<ITransaction | null>} - Returns the transaction details or null if not found.
@@ -55,7 +67,9 @@ class TransactionUtils {
55
67
  const { transaction } = await (0, graphql_request_1.default)((0, utils_1.getSubgraphUrl)(networkData), transaction_1.GET_TRANSACTION_QUERY, {
56
68
  hash: hash.toLowerCase(),
57
69
  });
58
- return transaction || null;
70
+ if (!transaction)
71
+ return null;
72
+ return mapTransaction(transaction);
59
73
  }
60
74
  /**
61
75
  * This function returns all transaction details based on the provided filter.
@@ -80,6 +94,18 @@ class TransactionUtils {
80
94
  * skip?: number; // (Optional) Number of transactions to skip. Default is 0.
81
95
  * orderDirection?: OrderDirection; // (Optional) Order of the results. Default is DESC.
82
96
  * }
97
+ *
98
+ *
99
+ * ```ts
100
+ * type InternalTransaction = {
101
+ * from: string;
102
+ * to: string;
103
+ * value: bigint;
104
+ * method: string;
105
+ * receiver?: string;
106
+ * escrow?: string;
107
+ * token?: string;
108
+ * };
83
109
  * ```
84
110
  *
85
111
  * ```ts
@@ -89,7 +115,7 @@ class TransactionUtils {
89
115
  * from: string;
90
116
  * to: string;
91
117
  * timestamp: bigint;
92
- * value: string;
118
+ * value: bigint;
93
119
  * method: string;
94
120
  * receiver?: string;
95
121
  * escrow?: string;
@@ -148,7 +174,31 @@ class TransactionUtils {
148
174
  if (!transactions) {
149
175
  return [];
150
176
  }
151
- return transactions;
177
+ return transactions.map((transaction) => mapTransaction(transaction));
152
178
  }
153
179
  }
154
180
  exports.TransactionUtils = TransactionUtils;
181
+ function mapTransaction(t) {
182
+ const internalTransactions = (t.internalTransactions || []).map((itx) => ({
183
+ from: itx.from,
184
+ to: itx.to,
185
+ value: BigInt(itx.value),
186
+ method: itx.method,
187
+ receiver: itx.receiver,
188
+ escrow: itx.escrow,
189
+ token: itx.token,
190
+ }));
191
+ return {
192
+ block: BigInt(t.block),
193
+ txHash: t.txHash,
194
+ from: t.from,
195
+ to: t.to,
196
+ timestamp: Number(t.timestamp) * 1000,
197
+ value: BigInt(t.value),
198
+ method: t.method,
199
+ receiver: t.receiver,
200
+ escrow: t.escrow,
201
+ token: t.token,
202
+ internalTransactions,
203
+ };
204
+ }
package/dist/types.d.ts CHANGED
@@ -137,81 +137,6 @@ export type NetworkData = {
137
137
  */
138
138
  oldFactoryAddress: string;
139
139
  };
140
- /**
141
- * Represents the response data for an escrow withdrawal.
142
- */
143
- export type EscrowWithdraw = {
144
- /**
145
- * The hash of the transaction associated with the escrow withdrawal.
146
- */
147
- txHash: string;
148
- /**
149
- * The address of the token used for the withdrawal.
150
- */
151
- tokenAddress: string;
152
- /**
153
- * The amount withdrawn from the escrow.
154
- */
155
- withdrawnAmount: bigint;
156
- };
157
- /**
158
- * Represents a payout from an escrow.
159
- */
160
- export type Payout = {
161
- /**
162
- * Unique identifier of the payout.
163
- */
164
- id: string;
165
- /**
166
- * The address of the escrow associated with the payout.
167
- */
168
- escrowAddress: string;
169
- /**
170
- * The address of the recipient who received the payout.
171
- */
172
- recipient: string;
173
- /**
174
- * The amount paid to the recipient.
175
- */
176
- amount: bigint;
177
- /**
178
- * The timestamp when the payout was created (in UNIX format).
179
- */
180
- createdAt: number;
181
- };
182
- /**
183
- * Represents a cancellation refund event.
184
- */
185
- export type CancellationRefund = {
186
- /**
187
- * Unique identifier of the cancellation refund event.
188
- */
189
- id: string;
190
- /**
191
- * The address of the escrow associated with the cancellation refund.
192
- */
193
- escrowAddress: string;
194
- /**
195
- * The address of the receiver who received the refund.
196
- */
197
- receiver: string;
198
- /**
199
- * The amount refunded to the receiver.
200
- */
201
- amount: bigint;
202
- /**
203
- * The block number in which the cancellation refund event occurred.
204
- */
205
- block: number;
206
- /**
207
- * The timestamp when the cancellation refund event occurred (in UNIX format).
208
- */
209
- timestamp: number;
210
- /**
211
- * The transaction hash of the cancellation refund event.
212
- */
213
- txHash: string;
214
- };
215
140
  export type TransactionLikeWithNonce = TransactionLike & {
216
141
  nonce: number;
217
142
  };
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,QAAQ,CAAC;AAEzC;;;;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;;;;GAIG;AACH,MAAM,MAAM,kBAAkB,GAAG;IAC/B;;OAEG;IACH,SAAS,EAAE,MAAM,CAAC;IAClB;;OAEG;IACH,SAAS,EAAE,MAAM,CAAC;CACnB,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,aAAa,GAAG;IAC1B;;OAEG;IACH,QAAQ,EAAE,MAAM,CAAC;IACjB;;OAEG;IACH,MAAM,EAAE,OAAO,CAAC;IAChB;;OAEG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;OAEG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;CACf,CAAC;AAEF;;;GAGG;AACH,MAAM,MAAM,UAAU,GAAG;IACvB;;OAEG;IACH,GAAG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M,MAAM,WAAW,GAAG;IACxB;;OAEG;IACH,OAAO,EAAE,MAAM,CAAC;IAChB;;OAEG;IACH,KAAK,EAAE,MAAM,CAAC;IACd;;OAEG;IACH,OAAO,EAAE,MAAM,CAAC;IAChB;;OAEG;IACH,UAAU,EAAE,MAAM,CAAC;IACnB;;OAEG;IACH,cAAc,EAAE,MAAM,CAAC;IACvB;;OAEG;IACH,cAAc,EAAE,MAAM,CAAC;IACvB;;OAEG;IACH,cAAc,EAAE,MAAM,CAAC;IACvB;;OAEG;IACH,WAAW,EAAE,MAAM,CAAC;IACpB;;OAEG;IACH,iBAAiB,EAAE,MAAM,CAAC;IAC1B;;OAEG;IACH,cAAc,EAAE,MAAM,CAAC;IACvB;;OAEG;IACH,iBAAiB,EAAE,MAAM,CAAC;CAC3B,CAAC;AAEF,MAAM,MAAM,wBAAwB,GAAG,eAAe,GAAG;IAAE,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC"}
package/dist/worker.d.ts CHANGED
@@ -37,7 +37,7 @@ export declare class WorkerUtils {
37
37
  * type IWorker = {
38
38
  * id: string;
39
39
  * address: string;
40
- * totalHMTAmountReceived: string;
40
+ * totalHMTAmountReceived: bigint;
41
41
  * payoutCount: number;
42
42
  * };
43
43
  * ```
@@ -1 +1 @@
1
- {"version":3,"file":"worker.d.ts","sourceRoot":"","sources":["../src/worker.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,EAAkB,MAAM,SAAS,CAAC;AAGlD,OAAO,EAAE,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAIvD,qBAAa,WAAW;IACtB;;;;;;;;;;;;;;OAcG;WACiB,SAAS,CAC3B,OAAO,EAAE,OAAO,EAChB,OAAO,EAAE,MAAM,GACd,OAAO,CAAC,OAAO,GAAG,IAAI,CAAC;IAmB1B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAwCG;WACiB,UAAU,CAAC,MAAM,EAAE,cAAc,GAAG,OAAO,CAAC,OAAO,EAAE,CAAC;CA+B3E"}
1
+ {"version":3,"file":"worker.d.ts","sourceRoot":"","sources":["../src/worker.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,OAAO,EAAkB,MAAM,SAAS,CAAC;AAIlD,OAAO,EAAE,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAGvD,qBAAa,WAAW;IACtB;;;;;;;;;;;;;;OAcG;WACiB,SAAS,CAC3B,OAAO,EAAE,OAAO,EAChB,OAAO,EAAE,MAAM,GACd,OAAO,CAAC,OAAO,GAAG,IAAI,CAAC;IAqB1B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAwCG;WACiB,UAAU,CAAC,MAAM,EAAE,cAAc,GAAG,OAAO,CAAC,OAAO,EAAE,CAAC;CA+B3E"}