@human-protocol/sdk 5.0.0-beta.1 → 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.
- package/dist/constants.js +3 -3
- package/dist/escrow.d.ts +55 -44
- package/dist/escrow.d.ts.map +1 -1
- package/dist/escrow.js +126 -53
- package/dist/graphql/queries/escrow.d.ts.map +1 -1
- package/dist/graphql/queries/escrow.js +5 -0
- package/dist/graphql/types.d.ts +101 -69
- package/dist/graphql/types.d.ts.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +11 -1
- package/dist/interfaces.d.ts +119 -72
- package/dist/interfaces.d.ts.map +1 -1
- package/dist/operator.d.ts +2 -2
- package/dist/operator.d.ts.map +1 -1
- package/dist/operator.js +14 -8
- package/dist/staking.d.ts.map +1 -1
- package/dist/staking.js +13 -2
- package/dist/statistics.d.ts +32 -33
- package/dist/statistics.d.ts.map +1 -1
- package/dist/statistics.js +38 -39
- package/dist/transaction.d.ts +28 -4
- package/dist/transaction.d.ts.map +1 -1
- package/dist/transaction.js +55 -5
- package/dist/types.d.ts +0 -75
- package/dist/types.d.ts.map +1 -1
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +7 -8
- package/dist/worker.d.ts +2 -2
- package/dist/worker.d.ts.map +1 -1
- package/dist/worker.js +15 -5
- package/package.json +3 -2
- package/src/constants.ts +3 -3
- package/src/escrow.ts +145 -76
- package/src/graphql/queries/escrow.ts +5 -0
- package/src/graphql/types.ts +108 -82
- package/src/index.ts +12 -0
- package/src/interfaces.ts +132 -73
- package/src/operator.ts +20 -16
- package/src/staking.ts +17 -4
- package/src/statistics.ts +58 -62
- package/src/transaction.ts +68 -10
- package/src/types.ts +0 -79
- package/src/utils.ts +8 -8
- package/src/worker.ts +19 -7
package/src/graphql/types.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { IReputationNetwork } from '../interfaces';
|
|
2
2
|
|
|
3
3
|
export type EscrowData = {
|
|
4
4
|
id: string;
|
|
@@ -7,19 +7,56 @@ export type EscrowData = {
|
|
|
7
7
|
balance: string;
|
|
8
8
|
count: string;
|
|
9
9
|
factoryAddress: string;
|
|
10
|
-
finalResultsUrl
|
|
11
|
-
|
|
10
|
+
finalResultsUrl: string | null;
|
|
11
|
+
finalResultsHash: string | null;
|
|
12
|
+
intermediateResultsUrl: string | null;
|
|
13
|
+
intermediateResultsHash: string | null;
|
|
12
14
|
launcher: string;
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
15
|
+
jobRequesterId: string | null;
|
|
16
|
+
manifestHash: string | null;
|
|
17
|
+
manifest: string | null;
|
|
18
|
+
recordingOracle: string | null;
|
|
19
|
+
reputationOracle: string | null;
|
|
20
|
+
exchangeOracle: string | null;
|
|
21
|
+
recordingOracleFee: string | null;
|
|
22
|
+
reputationOracleFee: string | null;
|
|
23
|
+
exchangeOracleFee: string | null;
|
|
18
24
|
status: string;
|
|
19
25
|
token: string;
|
|
20
26
|
totalFundedAmount: string;
|
|
21
27
|
createdAt: string;
|
|
22
|
-
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
export type WorkerData = {
|
|
31
|
+
id: string;
|
|
32
|
+
address: string;
|
|
33
|
+
totalHMTAmountReceived: string;
|
|
34
|
+
payoutCount: string;
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
export type InternalTransactionData = {
|
|
38
|
+
from: string;
|
|
39
|
+
to: string;
|
|
40
|
+
value: string;
|
|
41
|
+
method: string;
|
|
42
|
+
receiver: string | null;
|
|
43
|
+
escrow: string | null;
|
|
44
|
+
token: string | null;
|
|
45
|
+
id: string | null;
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
export type TransactionData = {
|
|
49
|
+
block: string;
|
|
50
|
+
txHash: string;
|
|
51
|
+
from: string;
|
|
52
|
+
to: string;
|
|
53
|
+
timestamp: string;
|
|
54
|
+
value: string;
|
|
55
|
+
method: string;
|
|
56
|
+
receiver: string | null;
|
|
57
|
+
escrow: string | null;
|
|
58
|
+
token: string | null;
|
|
59
|
+
internalTransactions: InternalTransactionData[];
|
|
23
60
|
};
|
|
24
61
|
|
|
25
62
|
export type HMTStatisticsData = {
|
|
@@ -72,86 +109,15 @@ export type RewardAddedEventData = {
|
|
|
72
109
|
amount: string;
|
|
73
110
|
};
|
|
74
111
|
|
|
75
|
-
export type DailyEscrowData = {
|
|
76
|
-
timestamp: Date;
|
|
77
|
-
escrowsTotal: number;
|
|
78
|
-
escrowsPending: number;
|
|
79
|
-
escrowsSolved: number;
|
|
80
|
-
escrowsPaid: number;
|
|
81
|
-
escrowsCancelled: number;
|
|
82
|
-
};
|
|
83
|
-
|
|
84
|
-
export type EscrowStatistics = {
|
|
85
|
-
totalEscrows: number;
|
|
86
|
-
dailyEscrowsData: DailyEscrowData[];
|
|
87
|
-
};
|
|
88
|
-
|
|
89
|
-
export type DailyWorkerData = {
|
|
90
|
-
timestamp: Date;
|
|
91
|
-
activeWorkers: number;
|
|
92
|
-
};
|
|
93
|
-
|
|
94
|
-
export type WorkerStatistics = {
|
|
95
|
-
dailyWorkersData: DailyWorkerData[];
|
|
96
|
-
};
|
|
97
|
-
|
|
98
|
-
export type DailyPaymentData = {
|
|
99
|
-
timestamp: Date;
|
|
100
|
-
totalAmountPaid: bigint;
|
|
101
|
-
totalCount: number;
|
|
102
|
-
averageAmountPerWorker: bigint;
|
|
103
|
-
};
|
|
104
|
-
|
|
105
|
-
export type PaymentStatistics = {
|
|
106
|
-
dailyPaymentsData: DailyPaymentData[];
|
|
107
|
-
};
|
|
108
|
-
|
|
109
112
|
export type HMTHolderData = {
|
|
110
113
|
address: string;
|
|
111
114
|
balance: string;
|
|
112
115
|
};
|
|
113
116
|
|
|
114
|
-
export type HMTHolder = {
|
|
115
|
-
address: string;
|
|
116
|
-
balance: bigint;
|
|
117
|
-
};
|
|
118
|
-
|
|
119
|
-
export type DailyHMTData = {
|
|
120
|
-
timestamp: Date;
|
|
121
|
-
totalTransactionAmount: bigint;
|
|
122
|
-
totalTransactionCount: number;
|
|
123
|
-
dailyUniqueSenders: number;
|
|
124
|
-
dailyUniqueReceivers: number;
|
|
125
|
-
};
|
|
126
|
-
|
|
127
|
-
export type HMTStatistics = {
|
|
128
|
-
totalTransferAmount: bigint;
|
|
129
|
-
totalTransferCount: number;
|
|
130
|
-
totalHolders: number;
|
|
131
|
-
};
|
|
132
|
-
|
|
133
|
-
export type IMDataEntity = {
|
|
134
|
-
served: number;
|
|
135
|
-
solved: number;
|
|
136
|
-
};
|
|
137
|
-
|
|
138
|
-
export type IMData = Record<string, IMDataEntity>;
|
|
139
|
-
|
|
140
|
-
export type DailyTaskData = {
|
|
141
|
-
timestamp: Date;
|
|
142
|
-
tasksTotal: number;
|
|
143
|
-
tasksSolved: number;
|
|
144
|
-
};
|
|
145
|
-
|
|
146
|
-
export type TaskStatistics = {
|
|
147
|
-
dailyTasksData: DailyTaskData[];
|
|
148
|
-
};
|
|
149
|
-
|
|
150
117
|
export type StatusEvent = {
|
|
151
|
-
timestamp:
|
|
118
|
+
timestamp: string;
|
|
152
119
|
escrowAddress: string;
|
|
153
120
|
status: string;
|
|
154
|
-
chainId: ChainId;
|
|
155
121
|
};
|
|
156
122
|
|
|
157
123
|
export type KVStoreData = {
|
|
@@ -160,5 +126,65 @@ export type KVStoreData = {
|
|
|
160
126
|
key: string;
|
|
161
127
|
value: string;
|
|
162
128
|
timestamp: Date;
|
|
163
|
-
block:
|
|
129
|
+
block: string;
|
|
130
|
+
};
|
|
131
|
+
|
|
132
|
+
export type StakerData = {
|
|
133
|
+
id: string;
|
|
134
|
+
address: string;
|
|
135
|
+
stakedAmount: string;
|
|
136
|
+
lockedAmount: string;
|
|
137
|
+
withdrawnAmount: string;
|
|
138
|
+
slashedAmount: string;
|
|
139
|
+
lockedUntilTimestamp: string;
|
|
140
|
+
lastDepositTimestamp: string;
|
|
141
|
+
};
|
|
142
|
+
|
|
143
|
+
export interface IOperatorSubgraph {
|
|
144
|
+
id: string;
|
|
145
|
+
address: string;
|
|
146
|
+
amountJobsProcessed: string;
|
|
147
|
+
role: string | null;
|
|
148
|
+
fee: string | null;
|
|
149
|
+
publicKey: string | null;
|
|
150
|
+
webhookUrl: string | null;
|
|
151
|
+
website: string | null;
|
|
152
|
+
url: string | null;
|
|
153
|
+
registrationNeeded: boolean | null;
|
|
154
|
+
registrationInstructions: string | null;
|
|
155
|
+
name: string | null;
|
|
156
|
+
category: string | null;
|
|
157
|
+
jobTypes: string | string[] | null;
|
|
158
|
+
reputationNetworks: { address: string }[];
|
|
159
|
+
staker: {
|
|
160
|
+
stakedAmount: string;
|
|
161
|
+
lockedAmount: string;
|
|
162
|
+
lockedUntilTimestamp: string;
|
|
163
|
+
withdrawnAmount: string;
|
|
164
|
+
slashedAmount: string;
|
|
165
|
+
lastDepositTimestamp: string;
|
|
166
|
+
} | null;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
export interface IReputationNetworkSubgraph
|
|
170
|
+
extends Omit<IReputationNetwork, 'operators'> {
|
|
171
|
+
operators: IOperatorSubgraph[];
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
export type PayoutData = {
|
|
175
|
+
id: string;
|
|
176
|
+
escrowAddress: string;
|
|
177
|
+
recipient: string;
|
|
178
|
+
amount: string;
|
|
179
|
+
createdAt: string;
|
|
180
|
+
};
|
|
181
|
+
|
|
182
|
+
export type CancellationRefundData = {
|
|
183
|
+
id: string;
|
|
184
|
+
escrowAddress: string;
|
|
185
|
+
receiver: string;
|
|
186
|
+
amount: string;
|
|
187
|
+
block: string;
|
|
188
|
+
timestamp: string;
|
|
189
|
+
txHash: string;
|
|
164
190
|
};
|
package/src/index.ts
CHANGED
|
@@ -13,6 +13,18 @@ export * from './types';
|
|
|
13
13
|
export * from './enums';
|
|
14
14
|
export * from './interfaces';
|
|
15
15
|
|
|
16
|
+
export {
|
|
17
|
+
EthereumError,
|
|
18
|
+
InvalidArgumentError,
|
|
19
|
+
ReplacementUnderpriced,
|
|
20
|
+
NumericFault,
|
|
21
|
+
NonceExpired,
|
|
22
|
+
TransactionReplaced,
|
|
23
|
+
ContractExecutionError,
|
|
24
|
+
InvalidEthereumAddressError,
|
|
25
|
+
InvalidKeyError,
|
|
26
|
+
} from './error';
|
|
27
|
+
|
|
16
28
|
export {
|
|
17
29
|
StakingClient,
|
|
18
30
|
StorageClient,
|
package/src/interfaces.ts
CHANGED
|
@@ -10,50 +10,24 @@ export interface IOperator {
|
|
|
10
10
|
id: string;
|
|
11
11
|
chainId: ChainId;
|
|
12
12
|
address: string;
|
|
13
|
-
stakedAmount: bigint;
|
|
14
|
-
lockedAmount: bigint;
|
|
15
|
-
lockedUntilTimestamp:
|
|
16
|
-
withdrawnAmount: bigint;
|
|
17
|
-
slashedAmount: bigint;
|
|
18
|
-
amountJobsProcessed: bigint;
|
|
19
|
-
role
|
|
20
|
-
fee
|
|
21
|
-
publicKey
|
|
22
|
-
webhookUrl
|
|
23
|
-
website
|
|
24
|
-
url
|
|
25
|
-
jobTypes
|
|
26
|
-
registrationNeeded
|
|
27
|
-
registrationInstructions
|
|
28
|
-
reputationNetworks
|
|
29
|
-
name
|
|
30
|
-
category
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
export interface IOperatorSubgraph {
|
|
34
|
-
id: string;
|
|
35
|
-
address: string;
|
|
36
|
-
amountJobsProcessed: bigint;
|
|
37
|
-
role?: string;
|
|
38
|
-
fee?: bigint;
|
|
39
|
-
publicKey?: string;
|
|
40
|
-
webhookUrl?: string;
|
|
41
|
-
website?: string;
|
|
42
|
-
url?: string;
|
|
43
|
-
registrationNeeded?: boolean;
|
|
44
|
-
registrationInstructions?: string;
|
|
45
|
-
name?: string;
|
|
46
|
-
category?: string;
|
|
47
|
-
jobTypes?: string | string[];
|
|
48
|
-
reputationNetworks?: { address: string }[];
|
|
49
|
-
staker?: {
|
|
50
|
-
stakedAmount: bigint;
|
|
51
|
-
lockedAmount: bigint;
|
|
52
|
-
lockedUntilTimestamp: bigint;
|
|
53
|
-
withdrawnAmount: bigint;
|
|
54
|
-
slashedAmount: bigint;
|
|
55
|
-
lastDepositTimestamp: bigint;
|
|
56
|
-
};
|
|
13
|
+
stakedAmount: bigint | null;
|
|
14
|
+
lockedAmount: bigint | null;
|
|
15
|
+
lockedUntilTimestamp: number | null;
|
|
16
|
+
withdrawnAmount: bigint | null;
|
|
17
|
+
slashedAmount: bigint | null;
|
|
18
|
+
amountJobsProcessed: bigint | null;
|
|
19
|
+
role: string | null;
|
|
20
|
+
fee: bigint | null;
|
|
21
|
+
publicKey: string | null;
|
|
22
|
+
webhookUrl: string | null;
|
|
23
|
+
website: string | null;
|
|
24
|
+
url: string | null;
|
|
25
|
+
jobTypes: string[] | null;
|
|
26
|
+
registrationNeeded: boolean | null;
|
|
27
|
+
registrationInstructions: string | null;
|
|
28
|
+
reputationNetworks: string[];
|
|
29
|
+
name: string | null;
|
|
30
|
+
category: string | null;
|
|
57
31
|
}
|
|
58
32
|
|
|
59
33
|
export interface IOperatorsFilter extends IPagination {
|
|
@@ -69,30 +43,31 @@ export interface IReputationNetwork {
|
|
|
69
43
|
operators: IOperator[];
|
|
70
44
|
}
|
|
71
45
|
|
|
72
|
-
export interface IReputationNetworkSubgraph
|
|
73
|
-
extends Omit<IReputationNetwork, 'operators'> {
|
|
74
|
-
operators: IOperatorSubgraph[];
|
|
75
|
-
}
|
|
76
|
-
|
|
77
46
|
export interface IEscrow {
|
|
78
47
|
id: string;
|
|
79
48
|
address: string;
|
|
80
|
-
amountPaid:
|
|
81
|
-
balance:
|
|
82
|
-
count:
|
|
49
|
+
amountPaid: bigint;
|
|
50
|
+
balance: bigint;
|
|
51
|
+
count: number;
|
|
83
52
|
factoryAddress: string;
|
|
84
|
-
finalResultsUrl
|
|
85
|
-
|
|
53
|
+
finalResultsUrl: string | null;
|
|
54
|
+
finalResultsHash: string | null;
|
|
55
|
+
intermediateResultsUrl: string | null;
|
|
56
|
+
intermediateResultsHash: string | null;
|
|
86
57
|
launcher: string;
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
58
|
+
jobRequesterId: string | null;
|
|
59
|
+
manifestHash: string | null;
|
|
60
|
+
manifest: string | null;
|
|
61
|
+
recordingOracle: string | null;
|
|
62
|
+
reputationOracle: string | null;
|
|
63
|
+
exchangeOracle: string | null;
|
|
64
|
+
recordingOracleFee: number | null;
|
|
65
|
+
reputationOracleFee: number | null;
|
|
66
|
+
exchangeOracleFee: number | null;
|
|
92
67
|
status: string;
|
|
93
68
|
token: string;
|
|
94
|
-
totalFundedAmount:
|
|
95
|
-
createdAt:
|
|
69
|
+
totalFundedAmount: bigint;
|
|
70
|
+
createdAt: number;
|
|
96
71
|
chainId: number;
|
|
97
72
|
}
|
|
98
73
|
|
|
@@ -151,11 +126,11 @@ export interface IKVStore {
|
|
|
151
126
|
export interface InternalTransaction {
|
|
152
127
|
from: string;
|
|
153
128
|
to: string;
|
|
154
|
-
value:
|
|
129
|
+
value: bigint;
|
|
155
130
|
method: string;
|
|
156
|
-
receiver
|
|
157
|
-
escrow
|
|
158
|
-
token
|
|
131
|
+
receiver: string | null;
|
|
132
|
+
escrow: string | null;
|
|
133
|
+
token: string | null;
|
|
159
134
|
}
|
|
160
135
|
|
|
161
136
|
export interface ITransaction {
|
|
@@ -163,12 +138,12 @@ export interface ITransaction {
|
|
|
163
138
|
txHash: string;
|
|
164
139
|
from: string;
|
|
165
140
|
to: string;
|
|
166
|
-
timestamp:
|
|
167
|
-
value:
|
|
141
|
+
timestamp: number;
|
|
142
|
+
value: bigint;
|
|
168
143
|
method: string;
|
|
169
|
-
receiver
|
|
170
|
-
escrow
|
|
171
|
-
token
|
|
144
|
+
receiver: string | null;
|
|
145
|
+
escrow: string | null;
|
|
146
|
+
token: string | null;
|
|
172
147
|
internalTransactions: InternalTransaction[];
|
|
173
148
|
}
|
|
174
149
|
|
|
@@ -209,7 +184,7 @@ export interface IStatusEventFilter extends IPagination {
|
|
|
209
184
|
export interface IWorker {
|
|
210
185
|
id: string;
|
|
211
186
|
address: string;
|
|
212
|
-
totalHMTAmountReceived:
|
|
187
|
+
totalHMTAmountReceived: bigint;
|
|
213
188
|
payoutCount: number;
|
|
214
189
|
}
|
|
215
190
|
|
|
@@ -223,10 +198,10 @@ export interface IStaker {
|
|
|
223
198
|
address: string;
|
|
224
199
|
stakedAmount: bigint;
|
|
225
200
|
lockedAmount: bigint;
|
|
226
|
-
lockedUntil: bigint;
|
|
227
201
|
withdrawableAmount: bigint;
|
|
228
202
|
slashedAmount: bigint;
|
|
229
|
-
|
|
203
|
+
lockedUntil: number;
|
|
204
|
+
lastDepositTimestamp: number;
|
|
230
205
|
}
|
|
231
206
|
|
|
232
207
|
export interface IStakersFilter extends IPagination {
|
|
@@ -253,3 +228,87 @@ export interface ICancellationRefundFilter extends IPagination {
|
|
|
253
228
|
from?: Date;
|
|
254
229
|
to?: Date;
|
|
255
230
|
}
|
|
231
|
+
|
|
232
|
+
export interface IDailyEscrow {
|
|
233
|
+
timestamp: number;
|
|
234
|
+
escrowsTotal: number;
|
|
235
|
+
escrowsPending: number;
|
|
236
|
+
escrowsSolved: number;
|
|
237
|
+
escrowsPaid: number;
|
|
238
|
+
escrowsCancelled: number;
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
export interface IEscrowStatistics {
|
|
242
|
+
totalEscrows: number;
|
|
243
|
+
dailyEscrowsData: IDailyEscrow[];
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
export interface IDailyWorker {
|
|
247
|
+
timestamp: number;
|
|
248
|
+
activeWorkers: number;
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
export interface IWorkerStatistics {
|
|
252
|
+
dailyWorkersData: IDailyWorker[];
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
export interface IDailyPayment {
|
|
256
|
+
timestamp: number;
|
|
257
|
+
totalAmountPaid: bigint;
|
|
258
|
+
totalCount: number;
|
|
259
|
+
averageAmountPerWorker: bigint;
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
export interface IPaymentStatistics {
|
|
263
|
+
dailyPaymentsData: IDailyPayment[];
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
export interface IHMTStatistics {
|
|
267
|
+
totalTransferAmount: bigint;
|
|
268
|
+
totalTransferCount: number;
|
|
269
|
+
totalHolders: number;
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
export interface IHMTHolder {
|
|
273
|
+
address: string;
|
|
274
|
+
balance: bigint;
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
export interface IDailyHMT {
|
|
278
|
+
timestamp: number;
|
|
279
|
+
totalTransactionAmount: bigint;
|
|
280
|
+
totalTransactionCount: number;
|
|
281
|
+
dailyUniqueSenders: number;
|
|
282
|
+
dailyUniqueReceivers: number;
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
export interface IStatusEvent {
|
|
286
|
+
timestamp: number;
|
|
287
|
+
escrowAddress: string;
|
|
288
|
+
status: EscrowStatus;
|
|
289
|
+
chainId: ChainId;
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
export interface ICancellationRefund {
|
|
293
|
+
id: string;
|
|
294
|
+
escrowAddress: string;
|
|
295
|
+
receiver: string;
|
|
296
|
+
amount: bigint;
|
|
297
|
+
block: number;
|
|
298
|
+
timestamp: number;
|
|
299
|
+
txHash: string;
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
export interface IPayout {
|
|
303
|
+
id: string;
|
|
304
|
+
escrowAddress: string;
|
|
305
|
+
recipient: string;
|
|
306
|
+
amount: bigint;
|
|
307
|
+
createdAt: number;
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
export interface IEscrowWithdraw {
|
|
311
|
+
txHash: string;
|
|
312
|
+
tokenAddress: string;
|
|
313
|
+
withdrawnAmount: bigint;
|
|
314
|
+
}
|
package/src/operator.ts
CHANGED
|
@@ -1,14 +1,12 @@
|
|
|
1
1
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
2
2
|
import gqlFetch from 'graphql-request';
|
|
3
|
+
import { IOperator, IOperatorsFilter, IReward } from './interfaces';
|
|
4
|
+
import { GET_REWARD_ADDED_EVENTS_QUERY } from './graphql/queries/reward';
|
|
3
5
|
import {
|
|
4
|
-
IOperator,
|
|
5
6
|
IOperatorSubgraph,
|
|
6
|
-
IOperatorsFilter,
|
|
7
7
|
IReputationNetworkSubgraph,
|
|
8
|
-
|
|
9
|
-
} from './
|
|
10
|
-
import { GET_REWARD_ADDED_EVENTS_QUERY } from './graphql/queries/reward';
|
|
11
|
-
import { RewardAddedEventData } from './graphql';
|
|
8
|
+
RewardAddedEventData,
|
|
9
|
+
} from './graphql';
|
|
12
10
|
import {
|
|
13
11
|
GET_LEADER_QUERY,
|
|
14
12
|
GET_LEADERS_QUERY,
|
|
@@ -30,7 +28,7 @@ export class OperatorUtils {
|
|
|
30
28
|
*
|
|
31
29
|
* @param {ChainId} chainId Network in which the operator is deployed
|
|
32
30
|
* @param {string} address Operator address.
|
|
33
|
-
* @returns {Promise<IOperator>} Returns the operator details.
|
|
31
|
+
* @returns {Promise<IOperator | null>} - Returns the operator details or null if not found.
|
|
34
32
|
*
|
|
35
33
|
* **Code example**
|
|
36
34
|
*
|
|
@@ -43,7 +41,7 @@ export class OperatorUtils {
|
|
|
43
41
|
public static async getOperator(
|
|
44
42
|
chainId: ChainId,
|
|
45
43
|
address: string
|
|
46
|
-
): Promise<IOperator> {
|
|
44
|
+
): Promise<IOperator | null> {
|
|
47
45
|
if (!ethers.isAddress(address)) {
|
|
48
46
|
throw ErrorInvalidStakerAddressProvided;
|
|
49
47
|
}
|
|
@@ -60,7 +58,7 @@ export class OperatorUtils {
|
|
|
60
58
|
});
|
|
61
59
|
|
|
62
60
|
if (!operator) {
|
|
63
|
-
return null
|
|
61
|
+
return null;
|
|
64
62
|
}
|
|
65
63
|
|
|
66
64
|
return mapOperator(operator, chainId);
|
|
@@ -236,14 +234,20 @@ function mapOperator(operator: IOperatorSubgraph, chainId: ChainId): IOperator {
|
|
|
236
234
|
id: operator.id,
|
|
237
235
|
chainId,
|
|
238
236
|
address: operator.address,
|
|
239
|
-
stakedAmount: BigInt(staker?.stakedAmount
|
|
240
|
-
lockedAmount: BigInt(staker?.lockedAmount
|
|
241
|
-
lockedUntilTimestamp:
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
237
|
+
stakedAmount: staker?.stakedAmount ? BigInt(staker?.stakedAmount) : null,
|
|
238
|
+
lockedAmount: staker?.lockedAmount ? BigInt(staker?.lockedAmount) : null,
|
|
239
|
+
lockedUntilTimestamp: staker?.lockedUntilTimestamp
|
|
240
|
+
? Number(staker.lockedUntilTimestamp) * 1000
|
|
241
|
+
: null,
|
|
242
|
+
withdrawnAmount: staker?.withdrawnAmount
|
|
243
|
+
? BigInt(staker?.withdrawnAmount)
|
|
244
|
+
: null,
|
|
245
|
+
slashedAmount: staker?.slashedAmount ? BigInt(staker?.slashedAmount) : null,
|
|
246
|
+
amountJobsProcessed: operator.amountJobsProcessed
|
|
247
|
+
? BigInt(operator.amountJobsProcessed)
|
|
248
|
+
: null,
|
|
245
249
|
role: operator.role,
|
|
246
|
-
fee: operator.fee ? BigInt(operator.fee) :
|
|
250
|
+
fee: operator.fee ? BigInt(operator.fee) : null,
|
|
247
251
|
publicKey: operator.publicKey,
|
|
248
252
|
webhookUrl: operator.webhookUrl,
|
|
249
253
|
website: operator.website,
|
package/src/staking.ts
CHANGED
|
@@ -24,6 +24,7 @@ import {
|
|
|
24
24
|
ErrorUnsupportedChainID,
|
|
25
25
|
} from './error';
|
|
26
26
|
import { IStaker, IStakersFilter, StakerInfo } from './interfaces';
|
|
27
|
+
import { StakerData } from './graphql';
|
|
27
28
|
import { NetworkData } from './types';
|
|
28
29
|
import { getSubgraphUrl, throwError } from './utils';
|
|
29
30
|
import {
|
|
@@ -509,7 +510,7 @@ export class StakingUtils {
|
|
|
509
510
|
throw ErrorUnsupportedChainID;
|
|
510
511
|
}
|
|
511
512
|
|
|
512
|
-
const { staker } = await gqlFetch<{ staker:
|
|
513
|
+
const { staker } = await gqlFetch<{ staker: StakerData }>(
|
|
513
514
|
getSubgraphUrl(networkData),
|
|
514
515
|
GET_STAKER_BY_ADDRESS_QUERY,
|
|
515
516
|
{ id: stakerAddress.toLowerCase() }
|
|
@@ -519,7 +520,7 @@ export class StakingUtils {
|
|
|
519
520
|
throw ErrorStakerNotFound;
|
|
520
521
|
}
|
|
521
522
|
|
|
522
|
-
return staker;
|
|
523
|
+
return mapStaker(staker);
|
|
523
524
|
}
|
|
524
525
|
|
|
525
526
|
/**
|
|
@@ -539,7 +540,7 @@ export class StakingUtils {
|
|
|
539
540
|
throw ErrorUnsupportedChainID;
|
|
540
541
|
}
|
|
541
542
|
|
|
542
|
-
const { stakers } = await gqlFetch<{ stakers:
|
|
543
|
+
const { stakers } = await gqlFetch<{ stakers: StakerData[] }>(
|
|
543
544
|
getSubgraphUrl(networkData),
|
|
544
545
|
GET_STAKERS_QUERY(filter),
|
|
545
546
|
{
|
|
@@ -577,6 +578,18 @@ export class StakingUtils {
|
|
|
577
578
|
return [];
|
|
578
579
|
}
|
|
579
580
|
|
|
580
|
-
return stakers;
|
|
581
|
+
return stakers.map((s) => mapStaker(s));
|
|
581
582
|
}
|
|
582
583
|
}
|
|
584
|
+
|
|
585
|
+
function mapStaker(s: StakerData): IStaker {
|
|
586
|
+
return {
|
|
587
|
+
address: s.address,
|
|
588
|
+
stakedAmount: BigInt(s.stakedAmount),
|
|
589
|
+
lockedAmount: BigInt(s.lockedAmount),
|
|
590
|
+
withdrawableAmount: BigInt(s.withdrawnAmount),
|
|
591
|
+
slashedAmount: BigInt(s.slashedAmount),
|
|
592
|
+
lockedUntil: Number(s.lockedUntilTimestamp) * 1000,
|
|
593
|
+
lastDepositTimestamp: Number(s.lastDepositTimestamp) * 1000,
|
|
594
|
+
};
|
|
595
|
+
}
|