@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
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
import { ChainId } from '../enums';
|
|
2
|
+
import { ICancellationRefund, ICancellationRefundFilter, IEscrow, IEscrowsFilter, IPayout, IPayoutFilter, IStatusEvent, IStatusEventFilter, SubgraphOptions } from '../interfaces';
|
|
3
|
+
/**
|
|
4
|
+
* Utility helpers for escrow-related queries.
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* ```ts
|
|
8
|
+
* import { ChainId, EscrowUtils } from '@human-protocol/sdk';
|
|
9
|
+
*
|
|
10
|
+
* const escrows = await EscrowUtils.getEscrows({
|
|
11
|
+
* chainId: ChainId.POLYGON_AMOY
|
|
12
|
+
* });
|
|
13
|
+
* console.log('Escrows:', escrows);
|
|
14
|
+
* ```
|
|
15
|
+
*/
|
|
16
|
+
export declare class EscrowUtils {
|
|
17
|
+
/**
|
|
18
|
+
* This function returns an array of escrows based on the specified filter parameters.
|
|
19
|
+
*
|
|
20
|
+
* @param filter - Filter parameters.
|
|
21
|
+
* @param options - Optional configuration for subgraph requests.
|
|
22
|
+
* @returns List of escrows that match the filter.
|
|
23
|
+
* @throws ErrorInvalidAddress If any filter address is invalid
|
|
24
|
+
* @throws ErrorUnsupportedChainID If the chain ID is not supported
|
|
25
|
+
*
|
|
26
|
+
* @example
|
|
27
|
+
* ```ts
|
|
28
|
+
* import { ChainId, EscrowStatus } from '@human-protocol/sdk';
|
|
29
|
+
*
|
|
30
|
+
* const filters = {
|
|
31
|
+
* status: EscrowStatus.Pending,
|
|
32
|
+
* from: new Date(2023, 4, 8),
|
|
33
|
+
* to: new Date(2023, 5, 8),
|
|
34
|
+
* chainId: ChainId.POLYGON_AMOY
|
|
35
|
+
* };
|
|
36
|
+
* const escrows = await EscrowUtils.getEscrows(filters);
|
|
37
|
+
* console.log('Found escrows:', escrows.length);
|
|
38
|
+
* ```
|
|
39
|
+
*/
|
|
40
|
+
static getEscrows(filter: IEscrowsFilter, options?: SubgraphOptions): Promise<IEscrow[]>;
|
|
41
|
+
/**
|
|
42
|
+
* This function returns the escrow data for a given address.
|
|
43
|
+
*
|
|
44
|
+
* > This uses Subgraph
|
|
45
|
+
*
|
|
46
|
+
* @param chainId - Network in which the escrow has been deployed
|
|
47
|
+
* @param escrowAddress - Address of the escrow
|
|
48
|
+
* @param options - Optional configuration for subgraph requests.
|
|
49
|
+
* @returns Escrow data or null if not found.
|
|
50
|
+
* @throws ErrorUnsupportedChainID If the chain ID is not supported
|
|
51
|
+
* @throws ErrorInvalidAddress If the escrow address is invalid
|
|
52
|
+
*
|
|
53
|
+
* @example
|
|
54
|
+
* ```ts
|
|
55
|
+
* import { ChainId } from '@human-protocol/sdk';
|
|
56
|
+
*
|
|
57
|
+
* const escrow = await EscrowUtils.getEscrow(
|
|
58
|
+
* ChainId.POLYGON_AMOY,
|
|
59
|
+
* "0x1234567890123456789012345678901234567890"
|
|
60
|
+
* );
|
|
61
|
+
* if (escrow) {
|
|
62
|
+
* console.log('Escrow status:', escrow.status);
|
|
63
|
+
* }
|
|
64
|
+
* ```
|
|
65
|
+
*/
|
|
66
|
+
static getEscrow(chainId: ChainId, escrowAddress: string, options?: SubgraphOptions): Promise<IEscrow | null>;
|
|
67
|
+
/**
|
|
68
|
+
* This function returns the status events for a given set of networks within an optional date range.
|
|
69
|
+
*
|
|
70
|
+
* > This uses Subgraph
|
|
71
|
+
*
|
|
72
|
+
* @param filter - Filter parameters.
|
|
73
|
+
* @param options - Optional configuration for subgraph requests.
|
|
74
|
+
* @returns Array of status events with their corresponding statuses.
|
|
75
|
+
* @throws ErrorInvalidAddress If the launcher address is invalid
|
|
76
|
+
* @throws ErrorUnsupportedChainID If the chain ID is not supported
|
|
77
|
+
*
|
|
78
|
+
* @example
|
|
79
|
+
* ```ts
|
|
80
|
+
* import { ChainId, EscrowStatus } from '@human-protocol/sdk';
|
|
81
|
+
*
|
|
82
|
+
* const fromDate = new Date('2023-01-01');
|
|
83
|
+
* const toDate = new Date('2023-12-31');
|
|
84
|
+
* const statusEvents = await EscrowUtils.getStatusEvents({
|
|
85
|
+
* chainId: ChainId.POLYGON,
|
|
86
|
+
* statuses: [EscrowStatus.Pending, EscrowStatus.Complete],
|
|
87
|
+
* from: fromDate,
|
|
88
|
+
* to: toDate
|
|
89
|
+
* });
|
|
90
|
+
* console.log('Status events:', statusEvents.length);
|
|
91
|
+
* ```
|
|
92
|
+
*/
|
|
93
|
+
static getStatusEvents(filter: IStatusEventFilter, options?: SubgraphOptions): Promise<IStatusEvent[]>;
|
|
94
|
+
/**
|
|
95
|
+
* This function returns the payouts for a given set of networks.
|
|
96
|
+
*
|
|
97
|
+
* > This uses Subgraph
|
|
98
|
+
*
|
|
99
|
+
* @param filter - Filter parameters.
|
|
100
|
+
* @param options - Optional configuration for subgraph requests.
|
|
101
|
+
* @returns List of payouts matching the filters.
|
|
102
|
+
* @throws ErrorUnsupportedChainID If the chain ID is not supported
|
|
103
|
+
* @throws ErrorInvalidAddress If any filter address is invalid
|
|
104
|
+
*
|
|
105
|
+
* @example
|
|
106
|
+
* ```ts
|
|
107
|
+
* import { ChainId } from '@human-protocol/sdk';
|
|
108
|
+
*
|
|
109
|
+
* const payouts = await EscrowUtils.getPayouts({
|
|
110
|
+
* chainId: ChainId.POLYGON,
|
|
111
|
+
* escrowAddress: '0x1234567890123456789012345678901234567890',
|
|
112
|
+
* recipient: '0xabcdefabcdefabcdefabcdefabcdefabcdefabcdef',
|
|
113
|
+
* from: new Date('2023-01-01'),
|
|
114
|
+
* to: new Date('2023-12-31')
|
|
115
|
+
* });
|
|
116
|
+
* console.log('Payouts:', payouts.length);
|
|
117
|
+
* ```
|
|
118
|
+
*/
|
|
119
|
+
static getPayouts(filter: IPayoutFilter, options?: SubgraphOptions): Promise<IPayout[]>;
|
|
120
|
+
/**
|
|
121
|
+
* This function returns the cancellation refunds for a given set of networks.
|
|
122
|
+
*
|
|
123
|
+
* > This uses Subgraph
|
|
124
|
+
*
|
|
125
|
+
* @param filter - Filter parameters.
|
|
126
|
+
* @param options - Optional configuration for subgraph requests.
|
|
127
|
+
* @returns List of cancellation refunds matching the filters.
|
|
128
|
+
* @throws ErrorUnsupportedChainID If the chain ID is not supported
|
|
129
|
+
* @throws ErrorInvalidEscrowAddressProvided If the escrow address is invalid
|
|
130
|
+
* @throws ErrorInvalidAddress If the receiver address is invalid
|
|
131
|
+
*
|
|
132
|
+
* @example
|
|
133
|
+
* ```ts
|
|
134
|
+
* import { ChainId } from '@human-protocol/sdk';
|
|
135
|
+
*
|
|
136
|
+
* const cancellationRefunds = await EscrowUtils.getCancellationRefunds({
|
|
137
|
+
* chainId: ChainId.POLYGON_AMOY,
|
|
138
|
+
* escrowAddress: '0x1234567890123456789012345678901234567890',
|
|
139
|
+
* });
|
|
140
|
+
* console.log('Cancellation refunds:', cancellationRefunds.length);
|
|
141
|
+
* ```
|
|
142
|
+
*/
|
|
143
|
+
static getCancellationRefunds(filter: ICancellationRefundFilter, options?: SubgraphOptions): Promise<ICancellationRefund[]>;
|
|
144
|
+
/**
|
|
145
|
+
* This function returns the cancellation refund for a given escrow address.
|
|
146
|
+
*
|
|
147
|
+
* > This uses Subgraph
|
|
148
|
+
*
|
|
149
|
+
* @param chainId - Network in which the escrow has been deployed
|
|
150
|
+
* @param escrowAddress - Address of the escrow
|
|
151
|
+
* @param options - Optional configuration for subgraph requests.
|
|
152
|
+
* @returns Cancellation refund data or null if not found.
|
|
153
|
+
* @throws ErrorUnsupportedChainID If the chain ID is not supported
|
|
154
|
+
* @throws ErrorInvalidEscrowAddressProvided If the escrow address is invalid
|
|
155
|
+
*
|
|
156
|
+
* @example
|
|
157
|
+
* ```ts
|
|
158
|
+
* import { ChainId } from '@human-protocol/sdk';
|
|
159
|
+
*
|
|
160
|
+
*
|
|
161
|
+
* const cancellationRefund = await EscrowUtils.getCancellationRefund(
|
|
162
|
+
* ChainId.POLYGON_AMOY,
|
|
163
|
+
* "0x1234567890123456789012345678901234567890"
|
|
164
|
+
* );
|
|
165
|
+
* if (cancellationRefund) {
|
|
166
|
+
* console.log('Refund amount:', cancellationRefund.amount);
|
|
167
|
+
* }
|
|
168
|
+
* ```
|
|
169
|
+
*/
|
|
170
|
+
static getCancellationRefund(chainId: ChainId, escrowAddress: string, options?: SubgraphOptions): Promise<ICancellationRefund | null>;
|
|
171
|
+
}
|
|
172
|
+
//# sourceMappingURL=escrow_utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"escrow_utils.d.ts","sourceRoot":"","sources":["../../src/escrow/escrow_utils.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,EAAkB,MAAM,UAAU,CAAC;AAkBnD,OAAO,EACL,mBAAmB,EACnB,yBAAyB,EACzB,OAAO,EACP,cAAc,EACd,OAAO,EACP,aAAa,EACb,YAAY,EACZ,kBAAkB,EAClB,eAAe,EAChB,MAAM,eAAe,CAAC;AAGvB;;;;;;;;;;;;GAYG;AACH,qBAAa,WAAW;IACtB;;;;;;;;;;;;;;;;;;;;;;OAsBG;WACiB,UAAU,CAC5B,MAAM,EAAE,cAAc,EACtB,OAAO,CAAC,EAAE,eAAe,GACxB,OAAO,CAAC,OAAO,EAAE,CAAC;IAsDrB;;;;;;;;;;;;;;;;;;;;;;;;OAwBG;WACiB,SAAS,CAC3B,OAAO,EAAE,OAAO,EAChB,aAAa,EAAE,MAAM,EACrB,OAAO,CAAC,EAAE,eAAe,GACxB,OAAO,CAAC,OAAO,GAAG,IAAI,CAAC;IAsB1B;;;;;;;;;;;;;;;;;;;;;;;;;OAyBG;WACiB,eAAe,CACjC,MAAM,EAAE,kBAAkB,EAC1B,OAAO,CAAC,EAAE,eAAe,GACxB,OAAO,CAAC,YAAY,EAAE,CAAC;IAsE1B;;;;;;;;;;;;;;;;;;;;;;;;OAwBG;WACiB,UAAU,CAC5B,MAAM,EAAE,aAAa,EACrB,OAAO,CAAC,EAAE,eAAe,GACxB,OAAO,CAAC,OAAO,EAAE,CAAC;IA4CrB;;;;;;;;;;;;;;;;;;;;;;OAsBG;WACiB,sBAAsB,CACxC,MAAM,EAAE,yBAAyB,EACjC,OAAO,CAAC,EAAE,eAAe,GACxB,OAAO,CAAC,mBAAmB,EAAE,CAAC;IA+CjC;;;;;;;;;;;;;;;;;;;;;;;;;OAyBG;WACiB,qBAAqB,CACvC,OAAO,EAAE,OAAO,EAChB,aAAa,EAAE,MAAM,EACrB,OAAO,CAAC,EAAE,eAAe,GACxB,OAAO,CAAC,mBAAmB,GAAG,IAAI,CAAC;CA+BvC"}
|
|
@@ -0,0 +1,394 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.EscrowUtils = 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 graphql_1 = require("../graphql");
|
|
9
|
+
const types_1 = require("../types");
|
|
10
|
+
const utils_1 = require("../utils");
|
|
11
|
+
/**
|
|
12
|
+
* Utility helpers for escrow-related queries.
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* ```ts
|
|
16
|
+
* import { ChainId, EscrowUtils } from '@human-protocol/sdk';
|
|
17
|
+
*
|
|
18
|
+
* const escrows = await EscrowUtils.getEscrows({
|
|
19
|
+
* chainId: ChainId.POLYGON_AMOY
|
|
20
|
+
* });
|
|
21
|
+
* console.log('Escrows:', escrows);
|
|
22
|
+
* ```
|
|
23
|
+
*/
|
|
24
|
+
class EscrowUtils {
|
|
25
|
+
/**
|
|
26
|
+
* This function returns an array of escrows based on the specified filter parameters.
|
|
27
|
+
*
|
|
28
|
+
* @param filter - Filter parameters.
|
|
29
|
+
* @param options - Optional configuration for subgraph requests.
|
|
30
|
+
* @returns List of escrows that match the filter.
|
|
31
|
+
* @throws ErrorInvalidAddress If any filter address is invalid
|
|
32
|
+
* @throws ErrorUnsupportedChainID If the chain ID is not supported
|
|
33
|
+
*
|
|
34
|
+
* @example
|
|
35
|
+
* ```ts
|
|
36
|
+
* import { ChainId, EscrowStatus } from '@human-protocol/sdk';
|
|
37
|
+
*
|
|
38
|
+
* const filters = {
|
|
39
|
+
* status: EscrowStatus.Pending,
|
|
40
|
+
* from: new Date(2023, 4, 8),
|
|
41
|
+
* to: new Date(2023, 5, 8),
|
|
42
|
+
* chainId: ChainId.POLYGON_AMOY
|
|
43
|
+
* };
|
|
44
|
+
* const escrows = await EscrowUtils.getEscrows(filters);
|
|
45
|
+
* console.log('Found escrows:', escrows.length);
|
|
46
|
+
* ```
|
|
47
|
+
*/
|
|
48
|
+
static async getEscrows(filter, options) {
|
|
49
|
+
if (filter.launcher && !ethers_1.ethers.isAddress(filter.launcher)) {
|
|
50
|
+
throw error_1.ErrorInvalidAddress;
|
|
51
|
+
}
|
|
52
|
+
if (filter.recordingOracle && !ethers_1.ethers.isAddress(filter.recordingOracle)) {
|
|
53
|
+
throw error_1.ErrorInvalidAddress;
|
|
54
|
+
}
|
|
55
|
+
if (filter.reputationOracle && !ethers_1.ethers.isAddress(filter.reputationOracle)) {
|
|
56
|
+
throw error_1.ErrorInvalidAddress;
|
|
57
|
+
}
|
|
58
|
+
if (filter.exchangeOracle && !ethers_1.ethers.isAddress(filter.exchangeOracle)) {
|
|
59
|
+
throw error_1.ErrorInvalidAddress;
|
|
60
|
+
}
|
|
61
|
+
const first = filter.first !== undefined ? Math.min(filter.first, 1000) : 10;
|
|
62
|
+
const skip = filter.skip || 0;
|
|
63
|
+
const orderDirection = filter.orderDirection || enums_1.OrderDirection.DESC;
|
|
64
|
+
const networkData = constants_1.NETWORKS[filter.chainId];
|
|
65
|
+
if (!networkData) {
|
|
66
|
+
throw error_1.ErrorUnsupportedChainID;
|
|
67
|
+
}
|
|
68
|
+
let statuses;
|
|
69
|
+
if (filter.status !== undefined) {
|
|
70
|
+
statuses = Array.isArray(filter.status) ? filter.status : [filter.status];
|
|
71
|
+
statuses = statuses.map((status) => types_1.EscrowStatus[status]);
|
|
72
|
+
}
|
|
73
|
+
const { escrows } = await (0, utils_1.customGqlFetch)((0, utils_1.getSubgraphUrl)(networkData), (0, graphql_1.GET_ESCROWS_QUERY)(filter), {
|
|
74
|
+
...filter,
|
|
75
|
+
launcher: filter.launcher?.toLowerCase(),
|
|
76
|
+
reputationOracle: filter.reputationOracle?.toLowerCase(),
|
|
77
|
+
recordingOracle: filter.recordingOracle?.toLowerCase(),
|
|
78
|
+
exchangeOracle: filter.exchangeOracle?.toLowerCase(),
|
|
79
|
+
status: statuses,
|
|
80
|
+
from: filter.from ? (0, utils_1.getUnixTimestamp)(filter.from) : undefined,
|
|
81
|
+
to: filter.to ? (0, utils_1.getUnixTimestamp)(filter.to) : undefined,
|
|
82
|
+
orderDirection: orderDirection,
|
|
83
|
+
first: first,
|
|
84
|
+
skip: skip,
|
|
85
|
+
}, options);
|
|
86
|
+
return (escrows || []).map((e) => mapEscrow(e, networkData.chainId));
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* This function returns the escrow data for a given address.
|
|
90
|
+
*
|
|
91
|
+
* > This uses Subgraph
|
|
92
|
+
*
|
|
93
|
+
* @param chainId - Network in which the escrow has been deployed
|
|
94
|
+
* @param escrowAddress - Address of the escrow
|
|
95
|
+
* @param options - Optional configuration for subgraph requests.
|
|
96
|
+
* @returns Escrow data or null if not found.
|
|
97
|
+
* @throws ErrorUnsupportedChainID If the chain ID is not supported
|
|
98
|
+
* @throws ErrorInvalidAddress If the escrow address is invalid
|
|
99
|
+
*
|
|
100
|
+
* @example
|
|
101
|
+
* ```ts
|
|
102
|
+
* import { ChainId } from '@human-protocol/sdk';
|
|
103
|
+
*
|
|
104
|
+
* const escrow = await EscrowUtils.getEscrow(
|
|
105
|
+
* ChainId.POLYGON_AMOY,
|
|
106
|
+
* "0x1234567890123456789012345678901234567890"
|
|
107
|
+
* );
|
|
108
|
+
* if (escrow) {
|
|
109
|
+
* console.log('Escrow status:', escrow.status);
|
|
110
|
+
* }
|
|
111
|
+
* ```
|
|
112
|
+
*/
|
|
113
|
+
static async getEscrow(chainId, escrowAddress, options) {
|
|
114
|
+
const networkData = constants_1.NETWORKS[chainId];
|
|
115
|
+
if (!networkData) {
|
|
116
|
+
throw error_1.ErrorUnsupportedChainID;
|
|
117
|
+
}
|
|
118
|
+
if (escrowAddress && !ethers_1.ethers.isAddress(escrowAddress)) {
|
|
119
|
+
throw error_1.ErrorInvalidAddress;
|
|
120
|
+
}
|
|
121
|
+
const { escrow } = await (0, utils_1.customGqlFetch)((0, utils_1.getSubgraphUrl)(networkData), (0, graphql_1.GET_ESCROW_BY_ADDRESS_QUERY)(), { escrowAddress: escrowAddress.toLowerCase() }, options);
|
|
122
|
+
if (!escrow)
|
|
123
|
+
return null;
|
|
124
|
+
return mapEscrow(escrow, networkData.chainId);
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* This function returns the status events for a given set of networks within an optional date range.
|
|
128
|
+
*
|
|
129
|
+
* > This uses Subgraph
|
|
130
|
+
*
|
|
131
|
+
* @param filter - Filter parameters.
|
|
132
|
+
* @param options - Optional configuration for subgraph requests.
|
|
133
|
+
* @returns Array of status events with their corresponding statuses.
|
|
134
|
+
* @throws ErrorInvalidAddress If the launcher address is invalid
|
|
135
|
+
* @throws ErrorUnsupportedChainID If the chain ID is not supported
|
|
136
|
+
*
|
|
137
|
+
* @example
|
|
138
|
+
* ```ts
|
|
139
|
+
* import { ChainId, EscrowStatus } from '@human-protocol/sdk';
|
|
140
|
+
*
|
|
141
|
+
* const fromDate = new Date('2023-01-01');
|
|
142
|
+
* const toDate = new Date('2023-12-31');
|
|
143
|
+
* const statusEvents = await EscrowUtils.getStatusEvents({
|
|
144
|
+
* chainId: ChainId.POLYGON,
|
|
145
|
+
* statuses: [EscrowStatus.Pending, EscrowStatus.Complete],
|
|
146
|
+
* from: fromDate,
|
|
147
|
+
* to: toDate
|
|
148
|
+
* });
|
|
149
|
+
* console.log('Status events:', statusEvents.length);
|
|
150
|
+
* ```
|
|
151
|
+
*/
|
|
152
|
+
static async getStatusEvents(filter, options) {
|
|
153
|
+
const { chainId, statuses, from, to, launcher, escrowAddress, first = 10, skip = 0, orderDirection = enums_1.OrderDirection.DESC, } = filter;
|
|
154
|
+
if (launcher && !ethers_1.ethers.isAddress(launcher)) {
|
|
155
|
+
throw error_1.ErrorInvalidAddress;
|
|
156
|
+
}
|
|
157
|
+
if (escrowAddress && !ethers_1.ethers.isAddress(escrowAddress)) {
|
|
158
|
+
throw error_1.ErrorInvalidAddress;
|
|
159
|
+
}
|
|
160
|
+
const networkData = constants_1.NETWORKS[chainId];
|
|
161
|
+
if (!networkData) {
|
|
162
|
+
throw error_1.ErrorUnsupportedChainID;
|
|
163
|
+
}
|
|
164
|
+
// If statuses are not provided, use all statuses except Launched
|
|
165
|
+
const effectiveStatuses = statuses ?? [
|
|
166
|
+
types_1.EscrowStatus.Launched,
|
|
167
|
+
types_1.EscrowStatus.Pending,
|
|
168
|
+
types_1.EscrowStatus.Partial,
|
|
169
|
+
types_1.EscrowStatus.Paid,
|
|
170
|
+
types_1.EscrowStatus.Complete,
|
|
171
|
+
types_1.EscrowStatus.Cancelled,
|
|
172
|
+
];
|
|
173
|
+
const statusNames = effectiveStatuses.map((status) => types_1.EscrowStatus[status]);
|
|
174
|
+
const data = await (0, utils_1.customGqlFetch)((0, utils_1.getSubgraphUrl)(networkData), (0, graphql_1.GET_STATUS_UPDATES_QUERY)(from, to, launcher, escrowAddress), {
|
|
175
|
+
status: statusNames,
|
|
176
|
+
from: from ? (0, utils_1.getUnixTimestamp)(from) : undefined,
|
|
177
|
+
to: to ? (0, utils_1.getUnixTimestamp)(to) : undefined,
|
|
178
|
+
launcher: launcher || undefined,
|
|
179
|
+
escrowAddress: escrowAddress || undefined,
|
|
180
|
+
orderDirection,
|
|
181
|
+
first: Math.min(first, 1000),
|
|
182
|
+
skip,
|
|
183
|
+
}, options);
|
|
184
|
+
if (!data || !data['escrowStatusEvents']) {
|
|
185
|
+
return [];
|
|
186
|
+
}
|
|
187
|
+
return data['escrowStatusEvents'].map((event) => ({
|
|
188
|
+
timestamp: Number(event.timestamp) * 1000,
|
|
189
|
+
escrowAddress: event.escrowAddress,
|
|
190
|
+
status: event.status,
|
|
191
|
+
chainId,
|
|
192
|
+
block: BigInt(event.block),
|
|
193
|
+
txHash: event.txHash,
|
|
194
|
+
}));
|
|
195
|
+
}
|
|
196
|
+
/**
|
|
197
|
+
* This function returns the payouts for a given set of networks.
|
|
198
|
+
*
|
|
199
|
+
* > This uses Subgraph
|
|
200
|
+
*
|
|
201
|
+
* @param filter - Filter parameters.
|
|
202
|
+
* @param options - Optional configuration for subgraph requests.
|
|
203
|
+
* @returns List of payouts matching the filters.
|
|
204
|
+
* @throws ErrorUnsupportedChainID If the chain ID is not supported
|
|
205
|
+
* @throws ErrorInvalidAddress If any filter address is invalid
|
|
206
|
+
*
|
|
207
|
+
* @example
|
|
208
|
+
* ```ts
|
|
209
|
+
* import { ChainId } from '@human-protocol/sdk';
|
|
210
|
+
*
|
|
211
|
+
* const payouts = await EscrowUtils.getPayouts({
|
|
212
|
+
* chainId: ChainId.POLYGON,
|
|
213
|
+
* escrowAddress: '0x1234567890123456789012345678901234567890',
|
|
214
|
+
* recipient: '0xabcdefabcdefabcdefabcdefabcdefabcdefabcdef',
|
|
215
|
+
* from: new Date('2023-01-01'),
|
|
216
|
+
* to: new Date('2023-12-31')
|
|
217
|
+
* });
|
|
218
|
+
* console.log('Payouts:', payouts.length);
|
|
219
|
+
* ```
|
|
220
|
+
*/
|
|
221
|
+
static async getPayouts(filter, options) {
|
|
222
|
+
const networkData = constants_1.NETWORKS[filter.chainId];
|
|
223
|
+
if (!networkData) {
|
|
224
|
+
throw error_1.ErrorUnsupportedChainID;
|
|
225
|
+
}
|
|
226
|
+
if (filter.escrowAddress && !ethers_1.ethers.isAddress(filter.escrowAddress)) {
|
|
227
|
+
throw error_1.ErrorInvalidAddress;
|
|
228
|
+
}
|
|
229
|
+
if (filter.recipient && !ethers_1.ethers.isAddress(filter.recipient)) {
|
|
230
|
+
throw error_1.ErrorInvalidAddress;
|
|
231
|
+
}
|
|
232
|
+
const first = filter.first !== undefined ? Math.min(filter.first, 1000) : 10;
|
|
233
|
+
const skip = filter.skip || 0;
|
|
234
|
+
const orderDirection = filter.orderDirection || enums_1.OrderDirection.DESC;
|
|
235
|
+
const { payouts } = await (0, utils_1.customGqlFetch)((0, utils_1.getSubgraphUrl)(networkData), (0, graphql_1.GET_PAYOUTS_QUERY)(filter), {
|
|
236
|
+
escrowAddress: filter.escrowAddress?.toLowerCase(),
|
|
237
|
+
recipient: filter.recipient?.toLowerCase(),
|
|
238
|
+
from: filter.from ? (0, utils_1.getUnixTimestamp)(filter.from) : undefined,
|
|
239
|
+
to: filter.to ? (0, utils_1.getUnixTimestamp)(filter.to) : undefined,
|
|
240
|
+
first: Math.min(first, 1000),
|
|
241
|
+
skip,
|
|
242
|
+
orderDirection,
|
|
243
|
+
}, options);
|
|
244
|
+
if (!payouts) {
|
|
245
|
+
return [];
|
|
246
|
+
}
|
|
247
|
+
return payouts.map((payout) => ({
|
|
248
|
+
id: payout.id,
|
|
249
|
+
escrowAddress: payout.escrowAddress,
|
|
250
|
+
recipient: payout.recipient,
|
|
251
|
+
amount: BigInt(payout.amount),
|
|
252
|
+
createdAt: Number(payout.createdAt) * 1000,
|
|
253
|
+
}));
|
|
254
|
+
}
|
|
255
|
+
/**
|
|
256
|
+
* This function returns the cancellation refunds for a given set of networks.
|
|
257
|
+
*
|
|
258
|
+
* > This uses Subgraph
|
|
259
|
+
*
|
|
260
|
+
* @param filter - Filter parameters.
|
|
261
|
+
* @param options - Optional configuration for subgraph requests.
|
|
262
|
+
* @returns List of cancellation refunds matching the filters.
|
|
263
|
+
* @throws ErrorUnsupportedChainID If the chain ID is not supported
|
|
264
|
+
* @throws ErrorInvalidEscrowAddressProvided If the escrow address is invalid
|
|
265
|
+
* @throws ErrorInvalidAddress If the receiver address is invalid
|
|
266
|
+
*
|
|
267
|
+
* @example
|
|
268
|
+
* ```ts
|
|
269
|
+
* import { ChainId } from '@human-protocol/sdk';
|
|
270
|
+
*
|
|
271
|
+
* const cancellationRefunds = await EscrowUtils.getCancellationRefunds({
|
|
272
|
+
* chainId: ChainId.POLYGON_AMOY,
|
|
273
|
+
* escrowAddress: '0x1234567890123456789012345678901234567890',
|
|
274
|
+
* });
|
|
275
|
+
* console.log('Cancellation refunds:', cancellationRefunds.length);
|
|
276
|
+
* ```
|
|
277
|
+
*/
|
|
278
|
+
static async getCancellationRefunds(filter, options) {
|
|
279
|
+
const networkData = constants_1.NETWORKS[filter.chainId];
|
|
280
|
+
if (!networkData)
|
|
281
|
+
throw error_1.ErrorUnsupportedChainID;
|
|
282
|
+
if (filter.escrowAddress && !ethers_1.ethers.isAddress(filter.escrowAddress)) {
|
|
283
|
+
throw error_1.ErrorInvalidEscrowAddressProvided;
|
|
284
|
+
}
|
|
285
|
+
if (filter.receiver && !ethers_1.ethers.isAddress(filter.receiver)) {
|
|
286
|
+
throw error_1.ErrorInvalidAddress;
|
|
287
|
+
}
|
|
288
|
+
const first = filter.first !== undefined ? Math.min(filter.first, 1000) : 10;
|
|
289
|
+
const skip = filter.skip || 0;
|
|
290
|
+
const orderDirection = filter.orderDirection || enums_1.OrderDirection.DESC;
|
|
291
|
+
const { cancellationRefundEvents } = await (0, utils_1.customGqlFetch)((0, utils_1.getSubgraphUrl)(networkData), (0, graphql_1.GET_CANCELLATION_REFUNDS_QUERY)(filter), {
|
|
292
|
+
escrowAddress: filter.escrowAddress?.toLowerCase(),
|
|
293
|
+
receiver: filter.receiver?.toLowerCase(),
|
|
294
|
+
from: filter.from ? (0, utils_1.getUnixTimestamp)(filter.from) : undefined,
|
|
295
|
+
to: filter.to ? (0, utils_1.getUnixTimestamp)(filter.to) : undefined,
|
|
296
|
+
first,
|
|
297
|
+
skip,
|
|
298
|
+
orderDirection,
|
|
299
|
+
}, options);
|
|
300
|
+
if (!cancellationRefundEvents || cancellationRefundEvents.length === 0) {
|
|
301
|
+
return [];
|
|
302
|
+
}
|
|
303
|
+
return cancellationRefundEvents.map((event) => ({
|
|
304
|
+
id: event.id,
|
|
305
|
+
escrowAddress: event.escrowAddress,
|
|
306
|
+
receiver: event.receiver,
|
|
307
|
+
amount: BigInt(event.amount),
|
|
308
|
+
block: Number(event.block),
|
|
309
|
+
timestamp: Number(event.timestamp) * 1000,
|
|
310
|
+
txHash: event.txHash,
|
|
311
|
+
}));
|
|
312
|
+
}
|
|
313
|
+
/**
|
|
314
|
+
* This function returns the cancellation refund for a given escrow address.
|
|
315
|
+
*
|
|
316
|
+
* > This uses Subgraph
|
|
317
|
+
*
|
|
318
|
+
* @param chainId - Network in which the escrow has been deployed
|
|
319
|
+
* @param escrowAddress - Address of the escrow
|
|
320
|
+
* @param options - Optional configuration for subgraph requests.
|
|
321
|
+
* @returns Cancellation refund data or null if not found.
|
|
322
|
+
* @throws ErrorUnsupportedChainID If the chain ID is not supported
|
|
323
|
+
* @throws ErrorInvalidEscrowAddressProvided If the escrow address is invalid
|
|
324
|
+
*
|
|
325
|
+
* @example
|
|
326
|
+
* ```ts
|
|
327
|
+
* import { ChainId } from '@human-protocol/sdk';
|
|
328
|
+
*
|
|
329
|
+
*
|
|
330
|
+
* const cancellationRefund = await EscrowUtils.getCancellationRefund(
|
|
331
|
+
* ChainId.POLYGON_AMOY,
|
|
332
|
+
* "0x1234567890123456789012345678901234567890"
|
|
333
|
+
* );
|
|
334
|
+
* if (cancellationRefund) {
|
|
335
|
+
* console.log('Refund amount:', cancellationRefund.amount);
|
|
336
|
+
* }
|
|
337
|
+
* ```
|
|
338
|
+
*/
|
|
339
|
+
static async getCancellationRefund(chainId, escrowAddress, options) {
|
|
340
|
+
const networkData = constants_1.NETWORKS[chainId];
|
|
341
|
+
if (!networkData)
|
|
342
|
+
throw error_1.ErrorUnsupportedChainID;
|
|
343
|
+
if (!ethers_1.ethers.isAddress(escrowAddress)) {
|
|
344
|
+
throw error_1.ErrorInvalidEscrowAddressProvided;
|
|
345
|
+
}
|
|
346
|
+
const { cancellationRefundEvents } = await (0, utils_1.customGqlFetch)((0, utils_1.getSubgraphUrl)(networkData), (0, graphql_1.GET_CANCELLATION_REFUND_BY_ADDRESS_QUERY)(), { escrowAddress: escrowAddress.toLowerCase() }, options);
|
|
347
|
+
if (!cancellationRefundEvents || cancellationRefundEvents.length === 0) {
|
|
348
|
+
return null;
|
|
349
|
+
}
|
|
350
|
+
return {
|
|
351
|
+
id: cancellationRefundEvents[0].id,
|
|
352
|
+
escrowAddress: cancellationRefundEvents[0].escrowAddress,
|
|
353
|
+
receiver: cancellationRefundEvents[0].receiver,
|
|
354
|
+
amount: BigInt(cancellationRefundEvents[0].amount),
|
|
355
|
+
block: Number(cancellationRefundEvents[0].block),
|
|
356
|
+
timestamp: Number(cancellationRefundEvents[0].timestamp) * 1000,
|
|
357
|
+
txHash: cancellationRefundEvents[0].txHash,
|
|
358
|
+
};
|
|
359
|
+
}
|
|
360
|
+
}
|
|
361
|
+
exports.EscrowUtils = EscrowUtils;
|
|
362
|
+
function mapEscrow(e, chainId) {
|
|
363
|
+
return {
|
|
364
|
+
id: e.id,
|
|
365
|
+
address: e.address,
|
|
366
|
+
amountPaid: BigInt(e.amountPaid),
|
|
367
|
+
balance: BigInt(e.balance),
|
|
368
|
+
count: Number(e.count),
|
|
369
|
+
factoryAddress: e.factoryAddress,
|
|
370
|
+
finalResultsUrl: e.finalResultsUrl,
|
|
371
|
+
finalResultsHash: e.finalResultsHash,
|
|
372
|
+
intermediateResultsUrl: e.intermediateResultsUrl,
|
|
373
|
+
intermediateResultsHash: e.intermediateResultsHash,
|
|
374
|
+
launcher: e.launcher,
|
|
375
|
+
jobRequesterId: e.jobRequesterId,
|
|
376
|
+
manifestHash: e.manifestHash,
|
|
377
|
+
manifest: e.manifest,
|
|
378
|
+
recordingOracle: e.recordingOracle,
|
|
379
|
+
reputationOracle: e.reputationOracle,
|
|
380
|
+
exchangeOracle: e.exchangeOracle,
|
|
381
|
+
recordingOracleFee: e.recordingOracleFee
|
|
382
|
+
? Number(e.recordingOracleFee)
|
|
383
|
+
: null,
|
|
384
|
+
reputationOracleFee: e.reputationOracleFee
|
|
385
|
+
? Number(e.reputationOracleFee)
|
|
386
|
+
: null,
|
|
387
|
+
exchangeOracleFee: e.exchangeOracleFee ? Number(e.exchangeOracleFee) : null,
|
|
388
|
+
status: e.status,
|
|
389
|
+
token: e.token,
|
|
390
|
+
totalFundedAmount: BigInt(e.totalFundedAmount),
|
|
391
|
+
createdAt: Number(e.createdAt) * 1000,
|
|
392
|
+
chainId: Number(chainId),
|
|
393
|
+
};
|
|
394
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/escrow/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.EscrowUtils = exports.EscrowClient = void 0;
|
|
4
|
+
var escrow_client_1 = require("./escrow_client");
|
|
5
|
+
Object.defineProperty(exports, "EscrowClient", { enumerable: true, get: function () { return escrow_client_1.EscrowClient; } });
|
|
6
|
+
var escrow_utils_1 = require("./escrow_utils");
|
|
7
|
+
Object.defineProperty(exports, "EscrowUtils", { enumerable: true, get: function () { return escrow_utils_1.EscrowUtils; } });
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ICancellationRefundFilter, IEscrowsFilter } from '../../interfaces';
|
|
2
2
|
export declare const GET_ESCROW_BY_ADDRESS_QUERY: () => import("graphql").DocumentNode;
|
|
3
3
|
export declare const GET_ESCROWS_QUERY: (filter: IEscrowsFilter) => import("graphql").DocumentNode;
|
|
4
|
-
export declare const GET_STATUS_UPDATES_QUERY: (from?: Date, to?: Date, launcher?: string) => import("graphql").DocumentNode;
|
|
4
|
+
export declare const GET_STATUS_UPDATES_QUERY: (from?: Date, to?: Date, launcher?: string, escrowAddress?: string) => import("graphql").DocumentNode;
|
|
5
5
|
export declare const GET_CANCELLATION_REFUNDS_QUERY: (filter: ICancellationRefundFilter) => import("graphql").DocumentNode;
|
|
6
6
|
export declare const GET_CANCELLATION_REFUND_BY_ADDRESS_QUERY: () => import("graphql").DocumentNode;
|
|
7
7
|
//# sourceMappingURL=escrow.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"escrow.d.ts","sourceRoot":"","sources":["../../../src/graphql/queries/escrow.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,yBAAyB,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AA2C7E,eAAO,MAAM,2BAA2B,sCAOvC,CAAC;AAEF,eAAO,MAAM,iBAAiB,GAAI,QAAQ,cAAc,mCAmDvD,CAAC;AAEF,eAAO,MAAM,wBAAwB,GACnC,OAAO,IAAI,EACX,KAAK,IAAI,EACT,WAAW,MAAM,
|
|
1
|
+
{"version":3,"file":"escrow.d.ts","sourceRoot":"","sources":["../../../src/graphql/queries/escrow.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,yBAAyB,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AA2C7E,eAAO,MAAM,2BAA2B,sCAOvC,CAAC;AAEF,eAAO,MAAM,iBAAiB,GAAI,QAAQ,cAAc,mCAmDvD,CAAC;AAEF,eAAO,MAAM,wBAAwB,GACnC,OAAO,IAAI,EACX,KAAK,IAAI,EACT,WAAW,MAAM,EACjB,gBAAgB,MAAM,mCAqCvB,CAAC;AAEF,eAAO,MAAM,8BAA8B,GACzC,QAAQ,yBAAyB,mCA2BlC,CAAC;AAEF,eAAO,MAAM,wCAAwC,sCAOpD,CAAC"}
|
|
@@ -95,13 +95,14 @@ const GET_ESCROWS_QUERY = (filter) => {
|
|
|
95
95
|
`;
|
|
96
96
|
};
|
|
97
97
|
exports.GET_ESCROWS_QUERY = GET_ESCROWS_QUERY;
|
|
98
|
-
const GET_STATUS_UPDATES_QUERY = (from, to, launcher) => {
|
|
98
|
+
const GET_STATUS_UPDATES_QUERY = (from, to, launcher, escrowAddress) => {
|
|
99
99
|
const WHERE_CLAUSE = `
|
|
100
100
|
where: {
|
|
101
101
|
status_in: $status
|
|
102
102
|
${from ? `timestamp_gte: $from` : ''}
|
|
103
103
|
${to ? `timestamp_lte: $to` : ''}
|
|
104
104
|
${launcher ? `launcher: $launcher` : ''}
|
|
105
|
+
${escrowAddress ? `escrowAddress: $escrowAddress` : ''}
|
|
105
106
|
}
|
|
106
107
|
`;
|
|
107
108
|
return (0, graphql_tag_1.default) `
|
|
@@ -110,6 +111,7 @@ const GET_STATUS_UPDATES_QUERY = (from, to, launcher) => {
|
|
|
110
111
|
$from: Int
|
|
111
112
|
$to: Int
|
|
112
113
|
$launcher: String
|
|
114
|
+
$escrowAddress: String
|
|
113
115
|
$orderDirection: String
|
|
114
116
|
$first: Int
|
|
115
117
|
$skip: Int
|
|
@@ -124,6 +126,8 @@ const GET_STATUS_UPDATES_QUERY = (from, to, launcher) => {
|
|
|
124
126
|
escrowAddress,
|
|
125
127
|
timestamp,
|
|
126
128
|
status,
|
|
129
|
+
block,
|
|
130
|
+
txHash,
|
|
127
131
|
}
|
|
128
132
|
}
|
|
129
133
|
`;
|
|
@@ -2,4 +2,5 @@ import { IStatisticsFilter } from '../../interfaces';
|
|
|
2
2
|
export declare const GET_HMTOKEN_STATISTICS_QUERY: import("graphql").DocumentNode;
|
|
3
3
|
export declare const GET_ESCROW_STATISTICS_QUERY: import("graphql").DocumentNode;
|
|
4
4
|
export declare const GET_EVENT_DAY_DATA_QUERY: (params: IStatisticsFilter) => import("graphql").DocumentNode;
|
|
5
|
+
export declare const GET_HMT_EVENT_DAY_DATA_QUERY: (params: IStatisticsFilter) => import("graphql").DocumentNode;
|
|
5
6
|
//# sourceMappingURL=statistics.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"statistics.d.ts","sourceRoot":"","sources":["../../../src/graphql/queries/statistics.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"statistics.d.ts","sourceRoot":"","sources":["../../../src/graphql/queries/statistics.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AA0DrD,eAAO,MAAM,4BAA4B,gCAOxC,CAAC;AAIF,eAAO,MAAM,2BAA2B,gCAOvC,CAAC;AAEF,eAAO,MAAM,wBAAwB,GAAI,QAAQ,iBAAiB,mCA6BjE,CAAC;AAEF,eAAO,MAAM,4BAA4B,GAAI,QAAQ,iBAAiB,mCA6BrE,CAAC"}
|