@sentio/sdk 1.34.0 → 1.34.1-rc.1
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/lib/gen/chainquery/protos/chainquery.d.ts +1 -1
- package/lib/gen/chainquery/protos/chainquery.js +108 -211
- package/lib/gen/chainquery/protos/chainquery.js.map +1 -1
- package/lib/gen/google/protobuf/empty.js.map +1 -1
- package/lib/gen/google/protobuf/timestamp.js +5 -9
- package/lib/gen/google/protobuf/timestamp.js.map +1 -1
- package/lib/gen/processor/protos/processor.d.ts +127 -27
- package/lib/gen/processor/protos/processor.js +789 -701
- package/lib/gen/processor/protos/processor.js.map +1 -1
- package/lib/gen/service/price/protos/price.d.ts +4 -4
- package/lib/gen/service/price/protos/price.js +15 -27
- package/lib/gen/service/price/protos/price.js.map +1 -1
- package/lib/release.config.js +2 -2
- package/lib/service.d.ts +6 -2
- package/lib/service.js +27 -19
- package/lib/service.js.map +1 -1
- package/lib/testing/test-processor-server.d.ts +6 -2
- package/lib/testing/test-processor-server.js +15 -5
- package/lib/testing/test-processor-server.js.map +1 -1
- package/lib/utils/token.d.ts +1 -1
- package/lib/utils/token.js.map +1 -1
- package/package.json +1 -1
- package/src/gen/chainquery/protos/chainquery.ts +171 -379
- package/src/gen/google/protobuf/empty.ts +7 -19
- package/src/gen/google/protobuf/timestamp.ts +11 -31
- package/src/gen/processor/protos/processor.ts +1064 -1286
- package/src/gen/service/price/protos/price.ts +38 -103
- package/src/service.ts +33 -22
- package/src/testing/test-processor-server.ts +18 -9
- package/src/utils/token.ts +1 -1
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
/* eslint-disable */
|
|
2
|
-
import { CallContext, CallOptions } from "nice-grpc-common";
|
|
3
|
-
import { Timestamp } from "../../../google/protobuf/timestamp";
|
|
4
2
|
import Long from "long";
|
|
3
|
+
import type { CallContext, CallOptions } from "nice-grpc-common";
|
|
5
4
|
import _m0 from "protobufjs/minimal";
|
|
5
|
+
import { Timestamp } from "../../../google/protobuf/timestamp";
|
|
6
6
|
|
|
7
7
|
export interface CoinID {
|
|
8
|
-
symbol
|
|
9
|
-
address
|
|
8
|
+
symbol?: string | undefined;
|
|
9
|
+
address?: CoinID_AddressIdentifier | undefined;
|
|
10
10
|
}
|
|
11
11
|
|
|
12
12
|
export interface CoinID_AddressIdentifier {
|
|
@@ -29,18 +29,12 @@ function createBaseCoinID(): CoinID {
|
|
|
29
29
|
}
|
|
30
30
|
|
|
31
31
|
export const CoinID = {
|
|
32
|
-
encode(
|
|
33
|
-
message: CoinID,
|
|
34
|
-
writer: _m0.Writer = _m0.Writer.create()
|
|
35
|
-
): _m0.Writer {
|
|
32
|
+
encode(message: CoinID, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
|
|
36
33
|
if (message.symbol !== undefined) {
|
|
37
34
|
writer.uint32(18).string(message.symbol);
|
|
38
35
|
}
|
|
39
36
|
if (message.address !== undefined) {
|
|
40
|
-
CoinID_AddressIdentifier.encode(
|
|
41
|
-
message.address,
|
|
42
|
-
writer.uint32(26).fork()
|
|
43
|
-
).ldelim();
|
|
37
|
+
CoinID_AddressIdentifier.encode(message.address, writer.uint32(26).fork()).ldelim();
|
|
44
38
|
}
|
|
45
39
|
return writer;
|
|
46
40
|
},
|
|
@@ -56,10 +50,7 @@ export const CoinID = {
|
|
|
56
50
|
message.symbol = reader.string();
|
|
57
51
|
break;
|
|
58
52
|
case 3:
|
|
59
|
-
message.address = CoinID_AddressIdentifier.decode(
|
|
60
|
-
reader,
|
|
61
|
-
reader.uint32()
|
|
62
|
-
);
|
|
53
|
+
message.address = CoinID_AddressIdentifier.decode(reader, reader.uint32());
|
|
63
54
|
break;
|
|
64
55
|
default:
|
|
65
56
|
reader.skipType(tag & 7);
|
|
@@ -72,9 +63,7 @@ export const CoinID = {
|
|
|
72
63
|
fromJSON(object: any): CoinID {
|
|
73
64
|
return {
|
|
74
65
|
symbol: isSet(object.symbol) ? String(object.symbol) : undefined,
|
|
75
|
-
address: isSet(object.address)
|
|
76
|
-
? CoinID_AddressIdentifier.fromJSON(object.address)
|
|
77
|
-
: undefined,
|
|
66
|
+
address: isSet(object.address) ? CoinID_AddressIdentifier.fromJSON(object.address) : undefined,
|
|
78
67
|
};
|
|
79
68
|
},
|
|
80
69
|
|
|
@@ -82,19 +71,16 @@ export const CoinID = {
|
|
|
82
71
|
const obj: any = {};
|
|
83
72
|
message.symbol !== undefined && (obj.symbol = message.symbol);
|
|
84
73
|
message.address !== undefined &&
|
|
85
|
-
(obj.address = message.address
|
|
86
|
-
? CoinID_AddressIdentifier.toJSON(message.address)
|
|
87
|
-
: undefined);
|
|
74
|
+
(obj.address = message.address ? CoinID_AddressIdentifier.toJSON(message.address) : undefined);
|
|
88
75
|
return obj;
|
|
89
76
|
},
|
|
90
77
|
|
|
91
78
|
fromPartial(object: DeepPartial<CoinID>): CoinID {
|
|
92
79
|
const message = createBaseCoinID();
|
|
93
80
|
message.symbol = object.symbol ?? undefined;
|
|
94
|
-
message.address =
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
: undefined;
|
|
81
|
+
message.address = (object.address !== undefined && object.address !== null)
|
|
82
|
+
? CoinID_AddressIdentifier.fromPartial(object.address)
|
|
83
|
+
: undefined;
|
|
98
84
|
return message;
|
|
99
85
|
},
|
|
100
86
|
};
|
|
@@ -104,10 +90,7 @@ function createBaseCoinID_AddressIdentifier(): CoinID_AddressIdentifier {
|
|
|
104
90
|
}
|
|
105
91
|
|
|
106
92
|
export const CoinID_AddressIdentifier = {
|
|
107
|
-
encode(
|
|
108
|
-
message: CoinID_AddressIdentifier,
|
|
109
|
-
writer: _m0.Writer = _m0.Writer.create()
|
|
110
|
-
): _m0.Writer {
|
|
93
|
+
encode(message: CoinID_AddressIdentifier, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
|
|
111
94
|
if (message.address !== "") {
|
|
112
95
|
writer.uint32(10).string(message.address);
|
|
113
96
|
}
|
|
@@ -117,10 +100,7 @@ export const CoinID_AddressIdentifier = {
|
|
|
117
100
|
return writer;
|
|
118
101
|
},
|
|
119
102
|
|
|
120
|
-
decode(
|
|
121
|
-
input: _m0.Reader | Uint8Array,
|
|
122
|
-
length?: number
|
|
123
|
-
): CoinID_AddressIdentifier {
|
|
103
|
+
decode(input: _m0.Reader | Uint8Array, length?: number): CoinID_AddressIdentifier {
|
|
124
104
|
const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
|
|
125
105
|
let end = length === undefined ? reader.len : reader.pos + length;
|
|
126
106
|
const message = createBaseCoinID_AddressIdentifier();
|
|
@@ -155,9 +135,7 @@ export const CoinID_AddressIdentifier = {
|
|
|
155
135
|
return obj;
|
|
156
136
|
},
|
|
157
137
|
|
|
158
|
-
fromPartial(
|
|
159
|
-
object: DeepPartial<CoinID_AddressIdentifier>
|
|
160
|
-
): CoinID_AddressIdentifier {
|
|
138
|
+
fromPartial(object: DeepPartial<CoinID_AddressIdentifier>): CoinID_AddressIdentifier {
|
|
161
139
|
const message = createBaseCoinID_AddressIdentifier();
|
|
162
140
|
message.address = object.address ?? "";
|
|
163
141
|
message.chain = object.chain ?? "";
|
|
@@ -170,15 +148,9 @@ function createBaseGetPriceRequest(): GetPriceRequest {
|
|
|
170
148
|
}
|
|
171
149
|
|
|
172
150
|
export const GetPriceRequest = {
|
|
173
|
-
encode(
|
|
174
|
-
message: GetPriceRequest,
|
|
175
|
-
writer: _m0.Writer = _m0.Writer.create()
|
|
176
|
-
): _m0.Writer {
|
|
151
|
+
encode(message: GetPriceRequest, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
|
|
177
152
|
if (message.timestamp !== undefined) {
|
|
178
|
-
Timestamp.encode(
|
|
179
|
-
toTimestamp(message.timestamp),
|
|
180
|
-
writer.uint32(10).fork()
|
|
181
|
-
).ldelim();
|
|
153
|
+
Timestamp.encode(toTimestamp(message.timestamp), writer.uint32(10).fork()).ldelim();
|
|
182
154
|
}
|
|
183
155
|
if (message.coinId !== undefined) {
|
|
184
156
|
CoinID.encode(message.coinId, writer.uint32(18).fork()).ldelim();
|
|
@@ -194,9 +166,7 @@ export const GetPriceRequest = {
|
|
|
194
166
|
const tag = reader.uint32();
|
|
195
167
|
switch (tag >>> 3) {
|
|
196
168
|
case 1:
|
|
197
|
-
message.timestamp = fromTimestamp(
|
|
198
|
-
Timestamp.decode(reader, reader.uint32())
|
|
199
|
-
);
|
|
169
|
+
message.timestamp = fromTimestamp(Timestamp.decode(reader, reader.uint32()));
|
|
200
170
|
break;
|
|
201
171
|
case 2:
|
|
202
172
|
message.coinId = CoinID.decode(reader, reader.uint32());
|
|
@@ -211,29 +181,24 @@ export const GetPriceRequest = {
|
|
|
211
181
|
|
|
212
182
|
fromJSON(object: any): GetPriceRequest {
|
|
213
183
|
return {
|
|
214
|
-
timestamp: isSet(object.timestamp)
|
|
215
|
-
? fromJsonTimestamp(object.timestamp)
|
|
216
|
-
: undefined,
|
|
184
|
+
timestamp: isSet(object.timestamp) ? fromJsonTimestamp(object.timestamp) : undefined,
|
|
217
185
|
coinId: isSet(object.coinId) ? CoinID.fromJSON(object.coinId) : undefined,
|
|
218
186
|
};
|
|
219
187
|
},
|
|
220
188
|
|
|
221
189
|
toJSON(message: GetPriceRequest): unknown {
|
|
222
190
|
const obj: any = {};
|
|
223
|
-
message.timestamp !== undefined &&
|
|
224
|
-
|
|
225
|
-
message.coinId !== undefined &&
|
|
226
|
-
(obj.coinId = message.coinId ? CoinID.toJSON(message.coinId) : undefined);
|
|
191
|
+
message.timestamp !== undefined && (obj.timestamp = message.timestamp.toISOString());
|
|
192
|
+
message.coinId !== undefined && (obj.coinId = message.coinId ? CoinID.toJSON(message.coinId) : undefined);
|
|
227
193
|
return obj;
|
|
228
194
|
},
|
|
229
195
|
|
|
230
196
|
fromPartial(object: DeepPartial<GetPriceRequest>): GetPriceRequest {
|
|
231
197
|
const message = createBaseGetPriceRequest();
|
|
232
198
|
message.timestamp = object.timestamp ?? undefined;
|
|
233
|
-
message.coinId =
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
: undefined;
|
|
199
|
+
message.coinId = (object.coinId !== undefined && object.coinId !== null)
|
|
200
|
+
? CoinID.fromPartial(object.coinId)
|
|
201
|
+
: undefined;
|
|
237
202
|
return message;
|
|
238
203
|
},
|
|
239
204
|
};
|
|
@@ -243,18 +208,12 @@ function createBaseGetPriceResponse(): GetPriceResponse {
|
|
|
243
208
|
}
|
|
244
209
|
|
|
245
210
|
export const GetPriceResponse = {
|
|
246
|
-
encode(
|
|
247
|
-
message: GetPriceResponse,
|
|
248
|
-
writer: _m0.Writer = _m0.Writer.create()
|
|
249
|
-
): _m0.Writer {
|
|
211
|
+
encode(message: GetPriceResponse, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
|
|
250
212
|
if (message.price !== 0) {
|
|
251
213
|
writer.uint32(9).double(message.price);
|
|
252
214
|
}
|
|
253
215
|
if (message.timestamp !== undefined) {
|
|
254
|
-
Timestamp.encode(
|
|
255
|
-
toTimestamp(message.timestamp),
|
|
256
|
-
writer.uint32(18).fork()
|
|
257
|
-
).ldelim();
|
|
216
|
+
Timestamp.encode(toTimestamp(message.timestamp), writer.uint32(18).fork()).ldelim();
|
|
258
217
|
}
|
|
259
218
|
return writer;
|
|
260
219
|
},
|
|
@@ -270,9 +229,7 @@ export const GetPriceResponse = {
|
|
|
270
229
|
message.price = reader.double();
|
|
271
230
|
break;
|
|
272
231
|
case 2:
|
|
273
|
-
message.timestamp = fromTimestamp(
|
|
274
|
-
Timestamp.decode(reader, reader.uint32())
|
|
275
|
-
);
|
|
232
|
+
message.timestamp = fromTimestamp(Timestamp.decode(reader, reader.uint32()));
|
|
276
233
|
break;
|
|
277
234
|
default:
|
|
278
235
|
reader.skipType(tag & 7);
|
|
@@ -285,17 +242,14 @@ export const GetPriceResponse = {
|
|
|
285
242
|
fromJSON(object: any): GetPriceResponse {
|
|
286
243
|
return {
|
|
287
244
|
price: isSet(object.price) ? Number(object.price) : 0,
|
|
288
|
-
timestamp: isSet(object.timestamp)
|
|
289
|
-
? fromJsonTimestamp(object.timestamp)
|
|
290
|
-
: undefined,
|
|
245
|
+
timestamp: isSet(object.timestamp) ? fromJsonTimestamp(object.timestamp) : undefined,
|
|
291
246
|
};
|
|
292
247
|
},
|
|
293
248
|
|
|
294
249
|
toJSON(message: GetPriceResponse): unknown {
|
|
295
250
|
const obj: any = {};
|
|
296
251
|
message.price !== undefined && (obj.price = message.price);
|
|
297
|
-
message.timestamp !== undefined &&
|
|
298
|
-
(obj.timestamp = message.timestamp.toISOString());
|
|
252
|
+
message.timestamp !== undefined && (obj.timestamp = message.timestamp.toISOString());
|
|
299
253
|
return obj;
|
|
300
254
|
},
|
|
301
255
|
|
|
@@ -323,39 +277,20 @@ export const PriceServiceDefinition = {
|
|
|
323
277
|
},
|
|
324
278
|
} as const;
|
|
325
279
|
|
|
326
|
-
export interface
|
|
327
|
-
getPrice(
|
|
328
|
-
request: GetPriceRequest,
|
|
329
|
-
context: CallContext & CallContextExt
|
|
330
|
-
): Promise<DeepPartial<GetPriceResponse>>;
|
|
280
|
+
export interface PriceServiceImplementation<CallContextExt = {}> {
|
|
281
|
+
getPrice(request: GetPriceRequest, context: CallContext & CallContextExt): Promise<DeepPartial<GetPriceResponse>>;
|
|
331
282
|
}
|
|
332
283
|
|
|
333
284
|
export interface PriceServiceClient<CallOptionsExt = {}> {
|
|
334
|
-
getPrice(
|
|
335
|
-
request: DeepPartial<GetPriceRequest>,
|
|
336
|
-
options?: CallOptions & CallOptionsExt
|
|
337
|
-
): Promise<GetPriceResponse>;
|
|
285
|
+
getPrice(request: DeepPartial<GetPriceRequest>, options?: CallOptions & CallOptionsExt): Promise<GetPriceResponse>;
|
|
338
286
|
}
|
|
339
287
|
|
|
340
|
-
type Builtin =
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
| boolean
|
|
347
|
-
| undefined;
|
|
348
|
-
|
|
349
|
-
type DeepPartial<T> = T extends Builtin
|
|
350
|
-
? T
|
|
351
|
-
: T extends Long
|
|
352
|
-
? string | number | Long
|
|
353
|
-
: T extends Array<infer U>
|
|
354
|
-
? Array<DeepPartial<U>>
|
|
355
|
-
: T extends ReadonlyArray<infer U>
|
|
356
|
-
? ReadonlyArray<DeepPartial<U>>
|
|
357
|
-
: T extends {}
|
|
358
|
-
? { [K in keyof T]?: DeepPartial<T[K]> }
|
|
288
|
+
type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined;
|
|
289
|
+
|
|
290
|
+
type DeepPartial<T> = T extends Builtin ? T
|
|
291
|
+
: T extends Long ? string | number | Long : T extends Array<infer U> ? Array<DeepPartial<U>>
|
|
292
|
+
: T extends ReadonlyArray<infer U> ? ReadonlyArray<DeepPartial<U>>
|
|
293
|
+
: T extends {} ? { [K in keyof T]?: DeepPartial<T[K]> }
|
|
359
294
|
: Partial<T>;
|
|
360
295
|
|
|
361
296
|
function toTimestamp(date: Date): Timestamp {
|
package/src/service.ts
CHANGED
|
@@ -7,11 +7,12 @@ import {
|
|
|
7
7
|
AptosCallHandlerConfig,
|
|
8
8
|
AptosEventHandlerConfig,
|
|
9
9
|
ContractConfig,
|
|
10
|
+
Data,
|
|
11
|
+
Data_SolInstruction,
|
|
10
12
|
DataBinding,
|
|
11
13
|
EventTrackingConfig,
|
|
12
14
|
ExportConfig,
|
|
13
15
|
HandlerType,
|
|
14
|
-
Instruction,
|
|
15
16
|
LogFilter,
|
|
16
17
|
LogHandlerConfig,
|
|
17
18
|
MetricConfig,
|
|
@@ -21,6 +22,7 @@ import {
|
|
|
21
22
|
ProcessConfigResponse,
|
|
22
23
|
ProcessorServiceImplementation,
|
|
23
24
|
ProcessResult,
|
|
25
|
+
ServerStreamingMethodResult,
|
|
24
26
|
StartRequest,
|
|
25
27
|
TemplateInstance,
|
|
26
28
|
} from './gen'
|
|
@@ -479,7 +481,7 @@ export class ProcessorServiceImpl implements ProcessorServiceImplementation {
|
|
|
479
481
|
case HandlerType.ETH_BLOCK:
|
|
480
482
|
return this.processBlock(request)
|
|
481
483
|
case HandlerType.SOL_INSTRUCTION:
|
|
482
|
-
return this.
|
|
484
|
+
return this.procecessSolInstructions(request)
|
|
483
485
|
// TODO migrate SUI cases
|
|
484
486
|
// case HandlerType.INSTRUCTION:
|
|
485
487
|
// return this.processInstruction(request)
|
|
@@ -493,6 +495,24 @@ export class ProcessorServiceImpl implements ProcessorServiceImplementation {
|
|
|
493
495
|
return result
|
|
494
496
|
}
|
|
495
497
|
|
|
498
|
+
async *processBindingsStream(requests: AsyncIterable<DataBinding>, context: CallContext) {
|
|
499
|
+
for await (const request of requests) {
|
|
500
|
+
const result = await this.processBinding(request)
|
|
501
|
+
let updated = false
|
|
502
|
+
if (
|
|
503
|
+
global.PROCESSOR_STATE.templatesInstances &&
|
|
504
|
+
this.templateInstances.length != global.PROCESSOR_STATE.templatesInstances.length
|
|
505
|
+
) {
|
|
506
|
+
await this.configure()
|
|
507
|
+
updated = true
|
|
508
|
+
}
|
|
509
|
+
yield {
|
|
510
|
+
result,
|
|
511
|
+
configUpdated: updated,
|
|
512
|
+
}
|
|
513
|
+
}
|
|
514
|
+
}
|
|
515
|
+
|
|
496
516
|
async processLogs(request: ProcessBindingsRequest, context: CallContext): Promise<ProcessBindingResponse> {
|
|
497
517
|
if (!this.started) {
|
|
498
518
|
throw new ServerError(Status.UNAVAILABLE, 'Service Not started.')
|
|
@@ -521,16 +541,16 @@ export class ProcessorServiceImpl implements ProcessorServiceImplementation {
|
|
|
521
541
|
}
|
|
522
542
|
}
|
|
523
543
|
|
|
524
|
-
async processLog(
|
|
525
|
-
if (!
|
|
544
|
+
async processLog(request: DataBinding): Promise<ProcessResult> {
|
|
545
|
+
if (!request.data) {
|
|
526
546
|
throw new ServerError(Status.INVALID_ARGUMENT, "Log can't be null")
|
|
527
547
|
}
|
|
528
548
|
|
|
529
549
|
const promises: Promise<ProcessResult>[] = []
|
|
530
|
-
const jsonString = Utf8ArrayToStr(
|
|
550
|
+
const jsonString = Utf8ArrayToStr(request.data.ethLog?.data || request.data.raw)
|
|
531
551
|
const log: Log = JSON.parse(jsonString)
|
|
532
552
|
|
|
533
|
-
for (const handlerId of
|
|
553
|
+
for (const handlerId of request.handlerIds) {
|
|
534
554
|
const handler = this.eventHandlers[handlerId]
|
|
535
555
|
promises.push(
|
|
536
556
|
handler(log).catch((e) => {
|
|
@@ -541,14 +561,12 @@ export class ProcessorServiceImpl implements ProcessorServiceImplementation {
|
|
|
541
561
|
return mergeProcessResults(await Promise.all(promises))
|
|
542
562
|
}
|
|
543
563
|
|
|
544
|
-
async
|
|
564
|
+
async procecessSolInstructions(request: DataBinding): Promise<ProcessResult> {
|
|
545
565
|
if (!request.data) {
|
|
546
566
|
throw new ServerError(Status.INVALID_ARGUMENT, 'instruction data cannot be empty')
|
|
547
567
|
}
|
|
548
568
|
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
const instruction: Instruction = Instruction.decode(request.data.raw) // JSON.parse(jsonString)
|
|
569
|
+
const instruction = request.data.solInstruction || Data_SolInstruction.decode(request.data.raw) // JSON.parse(jsonString)
|
|
552
570
|
const promises: Promise<ProcessResult>[] = []
|
|
553
571
|
|
|
554
572
|
// Only have instruction handlers for solana processors
|
|
@@ -556,13 +574,6 @@ export class ProcessorServiceImpl implements ProcessorServiceImplementation {
|
|
|
556
574
|
if (processor.address === instruction.programAccountId) {
|
|
557
575
|
let parsedInstruction: SolInstruction | null = null
|
|
558
576
|
if (instruction.parsed) {
|
|
559
|
-
// const decoded = new TextDecoder().decode(instruction.parsed)
|
|
560
|
-
if (!(instruction.parsed instanceof Uint8Array)) {
|
|
561
|
-
// const parsed = instruction.parsed as Uint8Array
|
|
562
|
-
const values = Object.entries(instruction.parsed).map(([key, value]) => value) as number[]
|
|
563
|
-
instruction.parsed = Uint8Array.from(values)
|
|
564
|
-
}
|
|
565
|
-
|
|
566
577
|
const a1 = JSON.parse(new TextDecoder().decode(instruction.parsed))
|
|
567
578
|
parsedInstruction = processor.getParsedInstruction(a1)
|
|
568
579
|
} else if (instruction.instructionData) {
|
|
@@ -593,7 +604,7 @@ export class ProcessorServiceImpl implements ProcessorServiceImplementation {
|
|
|
593
604
|
throw new ServerError(Status.INVALID_ARGUMENT, "Block can't be empty")
|
|
594
605
|
}
|
|
595
606
|
|
|
596
|
-
const jsonString = Utf8ArrayToStr(binding.data.raw)
|
|
607
|
+
const jsonString = Utf8ArrayToStr(binding.data.ethBlock?.data || binding.data.raw)
|
|
597
608
|
|
|
598
609
|
const block: Block = JSON.parse(jsonString)
|
|
599
610
|
|
|
@@ -627,7 +638,7 @@ export class ProcessorServiceImpl implements ProcessorServiceImplementation {
|
|
|
627
638
|
if (!binding.data) {
|
|
628
639
|
throw new ServerError(Status.INVALID_ARGUMENT, "Trace can't be empty")
|
|
629
640
|
}
|
|
630
|
-
const jsonString = Utf8ArrayToStr(binding.data.raw)
|
|
641
|
+
const jsonString = Utf8ArrayToStr(binding.data.ethTrace?.data || binding.data.raw)
|
|
631
642
|
const trace: Trace = JSON.parse(jsonString)
|
|
632
643
|
|
|
633
644
|
const promises: Promise<ProcessResult>[] = []
|
|
@@ -647,7 +658,7 @@ export class ProcessorServiceImpl implements ProcessorServiceImplementation {
|
|
|
647
658
|
throw new ServerError(Status.INVALID_ARGUMENT, "Event can't be empty")
|
|
648
659
|
}
|
|
649
660
|
const promises: Promise<ProcessResult>[] = []
|
|
650
|
-
const jsonString = Utf8ArrayToStr(binding.data.raw)
|
|
661
|
+
const jsonString = Utf8ArrayToStr(binding.data.aptEvent?.data || binding.data.raw)
|
|
651
662
|
const event = JSON.parse(jsonString)
|
|
652
663
|
|
|
653
664
|
for (const handlerId of binding.handlerIds) {
|
|
@@ -665,7 +676,7 @@ export class ProcessorServiceImpl implements ProcessorServiceImplementation {
|
|
|
665
676
|
if (!binding.data) {
|
|
666
677
|
throw new ServerError(Status.INVALID_ARGUMENT, "Event can't be empty")
|
|
667
678
|
}
|
|
668
|
-
const jsonString = Utf8ArrayToStr(binding.data.raw)
|
|
679
|
+
const jsonString = Utf8ArrayToStr(binding.data.aptResource?.data || binding.data.raw)
|
|
669
680
|
const json = JSON.parse(jsonString) as MoveResourcesWithVersionPayload
|
|
670
681
|
const promises: Promise<ProcessResult>[] = []
|
|
671
682
|
for (const handlerId of binding.handlerIds) {
|
|
@@ -682,7 +693,7 @@ export class ProcessorServiceImpl implements ProcessorServiceImplementation {
|
|
|
682
693
|
if (!binding.data) {
|
|
683
694
|
throw new ServerError(Status.INVALID_ARGUMENT, "Event can't be empty")
|
|
684
695
|
}
|
|
685
|
-
const jsonString = Utf8ArrayToStr(binding.data.raw)
|
|
696
|
+
const jsonString = Utf8ArrayToStr(binding.data.aptCall?.data || binding.data.raw)
|
|
686
697
|
const call = JSON.parse(jsonString)
|
|
687
698
|
|
|
688
699
|
const promises: Promise<ProcessResult>[] = []
|
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
ContractConfig,
|
|
4
4
|
DataBinding,
|
|
5
5
|
HandlerType,
|
|
6
|
-
|
|
6
|
+
Data_SolInstruction,
|
|
7
7
|
ProcessBindingResponse,
|
|
8
8
|
ProcessBindingsRequest,
|
|
9
9
|
ProcessConfigRequest,
|
|
@@ -23,8 +23,6 @@ import { ProcessorState } from '../state/processor-state'
|
|
|
23
23
|
import { ProcessorServiceImpl } from '../service'
|
|
24
24
|
import { Trace } from '../core/trace'
|
|
25
25
|
import { setProvider } from '../provider'
|
|
26
|
-
import { account } from '../builtin/aptos/0x1'
|
|
27
|
-
import { TextEncoder } from 'util'
|
|
28
26
|
|
|
29
27
|
export const TEST_CONTEXT: CallContext = <CallContext>{}
|
|
30
28
|
|
|
@@ -128,7 +126,8 @@ export class TestProcessorServer implements ProcessorServiceImplementation {
|
|
|
128
126
|
if (config.signature == signature) {
|
|
129
127
|
return {
|
|
130
128
|
data: {
|
|
131
|
-
raw:
|
|
129
|
+
raw: new Uint8Array(),
|
|
130
|
+
ethTrace: { data: toBytes(trace) },
|
|
132
131
|
},
|
|
133
132
|
handlerIds: [config.handlerId],
|
|
134
133
|
handlerType: HandlerType.ETH_TRACE,
|
|
@@ -189,7 +188,8 @@ export class TestProcessorServer implements ProcessorServiceImplementation {
|
|
|
189
188
|
if (match) {
|
|
190
189
|
return {
|
|
191
190
|
data: {
|
|
192
|
-
raw:
|
|
191
|
+
raw: new Uint8Array(),
|
|
192
|
+
ethLog: { data: toBytes(log) },
|
|
193
193
|
},
|
|
194
194
|
handlerIds: [config.handlerId],
|
|
195
195
|
handlerType: HandlerType.ETH_LOG,
|
|
@@ -250,7 +250,8 @@ export class TestProcessorServer implements ProcessorServiceImplementation {
|
|
|
250
250
|
if (match) {
|
|
251
251
|
return {
|
|
252
252
|
data: {
|
|
253
|
-
raw:
|
|
253
|
+
raw: new Uint8Array(),
|
|
254
|
+
ethLog: { data: toBytes(log) },
|
|
254
255
|
},
|
|
255
256
|
handlerIds: [config.handlerId],
|
|
256
257
|
handlerType: HandlerType.ETH_LOG,
|
|
@@ -283,7 +284,10 @@ export class TestProcessorServer implements ProcessorServiceImplementation {
|
|
|
283
284
|
buildBlockBinding(block: Partial<Block> & { number: number }, network: Networkish = 1): DataBinding {
|
|
284
285
|
const binding: DataBinding = {
|
|
285
286
|
data: {
|
|
286
|
-
raw:
|
|
287
|
+
raw: new Uint8Array(),
|
|
288
|
+
ethBlock: {
|
|
289
|
+
data: toBytes(block),
|
|
290
|
+
},
|
|
287
291
|
},
|
|
288
292
|
handlerType: HandlerType.ETH_BLOCK,
|
|
289
293
|
handlerIds: [],
|
|
@@ -307,12 +311,13 @@ export class TestProcessorServer implements ProcessorServiceImplementation {
|
|
|
307
311
|
return binding
|
|
308
312
|
}
|
|
309
313
|
|
|
310
|
-
testInstructions(instructions:
|
|
314
|
+
testInstructions(instructions: Data_SolInstruction[]): Promise<ProcessBindingResponse> {
|
|
311
315
|
return this.processBindings({
|
|
312
316
|
bindings: instructions.map((instruction) => {
|
|
313
317
|
return {
|
|
314
318
|
data: {
|
|
315
|
-
raw:
|
|
319
|
+
raw: new Uint8Array(),
|
|
320
|
+
solInstruction: instruction,
|
|
316
321
|
},
|
|
317
322
|
handlerIds: [],
|
|
318
323
|
handlerType: HandlerType.SOL_INSTRUCTION,
|
|
@@ -327,6 +332,10 @@ export class TestProcessorServer implements ProcessorServiceImplementation {
|
|
|
327
332
|
): Promise<ProcessBindingResponse> {
|
|
328
333
|
return this.service.processBindings(request, context)
|
|
329
334
|
}
|
|
335
|
+
|
|
336
|
+
processBindingsStream(request: AsyncIterable<DataBinding>, context: CallContext) {
|
|
337
|
+
return this.service.processBindingsStream(request, context)
|
|
338
|
+
}
|
|
330
339
|
}
|
|
331
340
|
|
|
332
341
|
function toBytes(obj: any): Uint8Array {
|
package/src/utils/token.ts
CHANGED
|
@@ -64,7 +64,7 @@ export async function getER20NormalizedAmount(
|
|
|
64
64
|
return scaleDown(amount, tokenInfo.decimal)
|
|
65
65
|
}
|
|
66
66
|
|
|
67
|
-
export function scaleDown(amount: BigNumber, decimal: number) {
|
|
67
|
+
export function scaleDown(amount: BigNumber | bigint, decimal: number) {
|
|
68
68
|
const divider = new BigDecimal(10).pow(decimal)
|
|
69
69
|
return toBigDecimal(amount).dividedBy(divider)
|
|
70
70
|
}
|