@sentio/sdk 1.33.0 → 1.33.2
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/builtin/internal/eacaggregatorproxy_processor.d.ts +0 -23
- package/lib/builtin/internal/eacaggregatorproxy_processor.js +0 -69
- package/lib/builtin/internal/eacaggregatorproxy_processor.js.map +1 -1
- package/lib/builtin/internal/erc1155_processor.d.ts +0 -8
- package/lib/builtin/internal/erc1155_processor.js +0 -24
- package/lib/builtin/internal/erc1155_processor.js.map +1 -1
- package/lib/builtin/internal/erc20_processor.d.ts +0 -18
- package/lib/builtin/internal/erc20_processor.js +0 -54
- package/lib/builtin/internal/erc20_processor.js.map +1 -1
- package/lib/builtin/internal/erc20bytes_processor.d.ts +0 -9
- package/lib/builtin/internal/erc20bytes_processor.js +0 -27
- package/lib/builtin/internal/erc20bytes_processor.js.map +1 -1
- package/lib/builtin/internal/erc721_processor.d.ts +0 -14
- package/lib/builtin/internal/erc721_processor.js +0 -42
- package/lib/builtin/internal/erc721_processor.js.map +1 -1
- package/lib/builtin/internal/factories/EACAggregatorProxy__factory.js +1 -0
- package/lib/builtin/internal/factories/EACAggregatorProxy__factory.js.map +1 -1
- package/lib/builtin/internal/factories/ERC1155__factory.js +1 -0
- package/lib/builtin/internal/factories/ERC1155__factory.js.map +1 -1
- package/lib/builtin/internal/factories/ERC20Bytes__factory.js +1 -0
- package/lib/builtin/internal/factories/ERC20Bytes__factory.js.map +1 -1
- package/lib/builtin/internal/factories/ERC20__factory.js +1 -0
- package/lib/builtin/internal/factories/ERC20__factory.js.map +1 -1
- package/lib/builtin/internal/factories/ERC721__factory.js +1 -0
- package/lib/builtin/internal/factories/ERC721__factory.js.map +1 -1
- package/lib/builtin/internal/factories/WETH9__factory.js +1 -0
- package/lib/builtin/internal/factories/WETH9__factory.js.map +1 -1
- package/lib/builtin/internal/weth9_processor.d.ts +0 -11
- package/lib/builtin/internal/weth9_processor.js +0 -33
- package/lib/builtin/internal/weth9_processor.js.map +1 -1
- package/lib/core/meter.d.ts +2 -8
- package/lib/core/meter.js +15 -18
- package/lib/core/meter.js.map +1 -1
- package/lib/core/numberish.js +10 -2
- package/lib/core/numberish.js.map +1 -1
- package/lib/gen/chainquery/protos/chainquery.d.ts +25 -2
- package/lib/gen/chainquery/protos/chainquery.js +49 -9
- package/lib/gen/chainquery/protos/chainquery.js.map +1 -1
- package/lib/gen/processor/protos/processor.d.ts +10 -0
- package/lib/gen/processor/protos/processor.js +57 -2
- package/lib/gen/processor/protos/processor.js.map +1 -1
- package/lib/service.js +1 -1
- package/lib/service.js.map +1 -1
- package/lib/target-ethers-sentio/event-handler.d.ts +3 -0
- package/lib/target-ethers-sentio/event-handler.js +35 -0
- package/lib/target-ethers-sentio/event-handler.js.map +1 -0
- package/lib/target-ethers-sentio/{codegen.d.ts → file.d.ts} +0 -0
- package/lib/target-ethers-sentio/{codegen.js → file.js} +13 -110
- package/lib/target-ethers-sentio/file.js.map +1 -0
- package/lib/target-ethers-sentio/{functions.d.ts → functions-handler.d.ts} +1 -1
- package/lib/target-ethers-sentio/{functions.js → functions-handler.js} +9 -20
- package/lib/target-ethers-sentio/functions-handler.js.map +1 -0
- package/lib/target-ethers-sentio/index.d.ts +1 -0
- package/lib/target-ethers-sentio/index.js +13 -4
- package/lib/target-ethers-sentio/index.js.map +1 -1
- package/lib/target-ethers-sentio/types.d.ts +4 -0
- package/lib/target-ethers-sentio/types.js +46 -0
- package/lib/target-ethers-sentio/types.js.map +1 -0
- package/lib/target-ethers-sentio/view-function.d.ts +5 -0
- package/lib/target-ethers-sentio/view-function.js +74 -0
- package/lib/target-ethers-sentio/view-function.js.map +1 -0
- package/lib/utils/chain.js +1 -0
- package/lib/utils/chain.js.map +1 -1
- package/package.json +1 -1
- package/src/builtin/internal/eacaggregatorproxy_processor.ts +0 -189
- package/src/builtin/internal/erc1155_processor.ts +0 -46
- package/src/builtin/internal/erc20_processor.ts +0 -96
- package/src/builtin/internal/erc20bytes_processor.ts +0 -52
- package/src/builtin/internal/erc721_processor.ts +0 -82
- package/src/builtin/internal/factories/EACAggregatorProxy__factory.ts +1 -0
- package/src/builtin/internal/factories/ERC1155__factory.ts +1 -0
- package/src/builtin/internal/factories/ERC20Bytes__factory.ts +1 -0
- package/src/builtin/internal/factories/ERC20__factory.ts +1 -0
- package/src/builtin/internal/factories/ERC721__factory.ts +1 -0
- package/src/builtin/internal/factories/WETH9__factory.ts +1 -0
- package/src/builtin/internal/weth9_processor.ts +0 -58
- package/src/core/meter.ts +16 -18
- package/src/core/numberish.ts +11 -2
- package/src/gen/chainquery/protos/chainquery.ts +60 -11
- package/src/gen/processor/protos/processor.ts +56 -0
- package/src/service.ts +1 -2
- package/src/target-ethers-sentio/event-handler.ts +31 -0
- package/src/target-ethers-sentio/{codegen.ts → file.ts} +11 -117
- package/src/target-ethers-sentio/{functions.ts → functions-handler.ts} +5 -16
- package/src/target-ethers-sentio/index.ts +11 -1
- package/src/target-ethers-sentio/types.ts +42 -0
- package/src/target-ethers-sentio/view-function.ts +79 -0
- package/src/utils/chain.ts +1 -0
- package/lib/target-ethers-sentio/codegen.js.map +0 -1
- package/lib/target-ethers-sentio/functions.js.map +0 -1
|
@@ -518,88 +518,6 @@ export class ERC721ProcessorTemplate extends BaseProcessorTemplate<
|
|
|
518
518
|
}
|
|
519
519
|
return super.onEvent(handler, filter!);
|
|
520
520
|
}
|
|
521
|
-
|
|
522
|
-
onCallApprove(handler: (call: ApproveCallTrace, ctx: ERC721Context) => void) {
|
|
523
|
-
return super.onTrace("0x095ea7b3", handler);
|
|
524
|
-
}
|
|
525
|
-
|
|
526
|
-
onCallTotalSupply(
|
|
527
|
-
handler: (call: TotalSupplyCallTrace, ctx: ERC721Context) => void
|
|
528
|
-
) {
|
|
529
|
-
return super.onTrace("0x18160ddd", handler);
|
|
530
|
-
}
|
|
531
|
-
|
|
532
|
-
onCallBalanceOf(
|
|
533
|
-
handler: (call: BalanceOfCallTrace, ctx: ERC721Context) => void
|
|
534
|
-
) {
|
|
535
|
-
return super.onTrace("0x70a08231", handler);
|
|
536
|
-
}
|
|
537
|
-
|
|
538
|
-
onCallGetApproved(
|
|
539
|
-
handler: (call: GetApprovedCallTrace, ctx: ERC721Context) => void
|
|
540
|
-
) {
|
|
541
|
-
return super.onTrace("0x081812fc", handler);
|
|
542
|
-
}
|
|
543
|
-
|
|
544
|
-
onCallIsApprovedForAll(
|
|
545
|
-
handler: (call: IsApprovedForAllCallTrace, ctx: ERC721Context) => void
|
|
546
|
-
) {
|
|
547
|
-
return super.onTrace("0xe985e9c5", handler);
|
|
548
|
-
}
|
|
549
|
-
|
|
550
|
-
onCallName(handler: (call: NameCallTrace, ctx: ERC721Context) => void) {
|
|
551
|
-
return super.onTrace("0x06fdde03", handler);
|
|
552
|
-
}
|
|
553
|
-
|
|
554
|
-
onCallOwnerOf(handler: (call: OwnerOfCallTrace, ctx: ERC721Context) => void) {
|
|
555
|
-
return super.onTrace("0x6352211e", handler);
|
|
556
|
-
}
|
|
557
|
-
|
|
558
|
-
onCallSafeTransferFrom_address_address_uint256(
|
|
559
|
-
handler: (
|
|
560
|
-
call: SafeTransferFrom_address_address_uint256CallTrace,
|
|
561
|
-
ctx: ERC721Context
|
|
562
|
-
) => void
|
|
563
|
-
) {
|
|
564
|
-
return super.onTrace("0x42842e0e", handler);
|
|
565
|
-
}
|
|
566
|
-
|
|
567
|
-
onCallSafeTransferFrom_address_address_uint256_bytes(
|
|
568
|
-
handler: (
|
|
569
|
-
call: SafeTransferFrom_address_address_uint256_bytesCallTrace,
|
|
570
|
-
ctx: ERC721Context
|
|
571
|
-
) => void
|
|
572
|
-
) {
|
|
573
|
-
return super.onTrace("0xb88d4fde", handler);
|
|
574
|
-
}
|
|
575
|
-
|
|
576
|
-
onCallSetApprovalForAll(
|
|
577
|
-
handler: (call: SetApprovalForAllCallTrace, ctx: ERC721Context) => void
|
|
578
|
-
) {
|
|
579
|
-
return super.onTrace("0xa22cb465", handler);
|
|
580
|
-
}
|
|
581
|
-
|
|
582
|
-
onCallSupportsInterface(
|
|
583
|
-
handler: (call: SupportsInterfaceCallTrace, ctx: ERC721Context) => void
|
|
584
|
-
) {
|
|
585
|
-
return super.onTrace("0x01ffc9a7", handler);
|
|
586
|
-
}
|
|
587
|
-
|
|
588
|
-
onCallSymbol(handler: (call: SymbolCallTrace, ctx: ERC721Context) => void) {
|
|
589
|
-
return super.onTrace("0x95d89b41", handler);
|
|
590
|
-
}
|
|
591
|
-
|
|
592
|
-
onCallTokenURI(
|
|
593
|
-
handler: (call: TokenURICallTrace, ctx: ERC721Context) => void
|
|
594
|
-
) {
|
|
595
|
-
return super.onTrace("0xc87b56dd", handler);
|
|
596
|
-
}
|
|
597
|
-
|
|
598
|
-
onCallTransferFrom(
|
|
599
|
-
handler: (call: TransferFromCallTrace, ctx: ERC721Context) => void
|
|
600
|
-
) {
|
|
601
|
-
return super.onTrace("0x23b872dd", handler);
|
|
602
|
-
}
|
|
603
521
|
}
|
|
604
522
|
|
|
605
523
|
export class ERC721Processor extends BaseProcessor<
|
|
@@ -378,64 +378,6 @@ export class WETH9ProcessorTemplate extends BaseProcessorTemplate<
|
|
|
378
378
|
}
|
|
379
379
|
return super.onEvent(handler, filter!);
|
|
380
380
|
}
|
|
381
|
-
|
|
382
|
-
onCallName(handler: (call: NameCallTrace, ctx: WETH9Context) => void) {
|
|
383
|
-
return super.onTrace("0x06fdde03", handler);
|
|
384
|
-
}
|
|
385
|
-
|
|
386
|
-
onCallApprove(handler: (call: ApproveCallTrace, ctx: WETH9Context) => void) {
|
|
387
|
-
return super.onTrace("0x095ea7b3", handler);
|
|
388
|
-
}
|
|
389
|
-
|
|
390
|
-
onCallTotalSupply(
|
|
391
|
-
handler: (call: TotalSupplyCallTrace, ctx: WETH9Context) => void
|
|
392
|
-
) {
|
|
393
|
-
return super.onTrace("0x18160ddd", handler);
|
|
394
|
-
}
|
|
395
|
-
|
|
396
|
-
onCallTransferFrom(
|
|
397
|
-
handler: (call: TransferFromCallTrace, ctx: WETH9Context) => void
|
|
398
|
-
) {
|
|
399
|
-
return super.onTrace("0x23b872dd", handler);
|
|
400
|
-
}
|
|
401
|
-
|
|
402
|
-
onCallWithdraw(
|
|
403
|
-
handler: (call: WithdrawCallTrace, ctx: WETH9Context) => void
|
|
404
|
-
) {
|
|
405
|
-
return super.onTrace("0x2e1a7d4d", handler);
|
|
406
|
-
}
|
|
407
|
-
|
|
408
|
-
onCallDecimals(
|
|
409
|
-
handler: (call: DecimalsCallTrace, ctx: WETH9Context) => void
|
|
410
|
-
) {
|
|
411
|
-
return super.onTrace("0x313ce567", handler);
|
|
412
|
-
}
|
|
413
|
-
|
|
414
|
-
onCallBalanceOf(
|
|
415
|
-
handler: (call: BalanceOfCallTrace, ctx: WETH9Context) => void
|
|
416
|
-
) {
|
|
417
|
-
return super.onTrace("0x70a08231", handler);
|
|
418
|
-
}
|
|
419
|
-
|
|
420
|
-
onCallSymbol(handler: (call: SymbolCallTrace, ctx: WETH9Context) => void) {
|
|
421
|
-
return super.onTrace("0x95d89b41", handler);
|
|
422
|
-
}
|
|
423
|
-
|
|
424
|
-
onCallTransfer(
|
|
425
|
-
handler: (call: TransferCallTrace, ctx: WETH9Context) => void
|
|
426
|
-
) {
|
|
427
|
-
return super.onTrace("0xa9059cbb", handler);
|
|
428
|
-
}
|
|
429
|
-
|
|
430
|
-
onCallDeposit(handler: (call: DepositCallTrace, ctx: WETH9Context) => void) {
|
|
431
|
-
return super.onTrace("0xd0e30db0", handler);
|
|
432
|
-
}
|
|
433
|
-
|
|
434
|
-
onCallAllowance(
|
|
435
|
-
handler: (call: AllowanceCallTrace, ctx: WETH9Context) => void
|
|
436
|
-
) {
|
|
437
|
-
return super.onTrace("0xdd62ed3e", handler);
|
|
438
|
-
}
|
|
439
381
|
}
|
|
440
382
|
|
|
441
383
|
export class WETH9Processor extends BaseProcessor<
|
package/src/core/meter.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { BaseContext } from './base-context'
|
|
2
2
|
import { Numberish, toMetricValue } from './numberish'
|
|
3
3
|
import { Labels, NamedResultDescriptor } from './metadata'
|
|
4
|
-
import { AggregationConfig, AggregationType, MetricConfig } from '../gen'
|
|
4
|
+
import { AggregationConfig, AggregationType, MetricConfig, MetricType } from '../gen'
|
|
5
5
|
import { MapStateStorage } from '../state/state-storage'
|
|
6
6
|
|
|
7
7
|
export function normalizeName(name: string): string {
|
|
@@ -41,19 +41,17 @@ export class CounterOptions {
|
|
|
41
41
|
sparse?: boolean
|
|
42
42
|
}
|
|
43
43
|
|
|
44
|
-
enum MetricType {
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
}
|
|
44
|
+
// enum MetricType {
|
|
45
|
+
// Counter = 0,
|
|
46
|
+
// Gauge = 1,
|
|
47
|
+
// }
|
|
48
48
|
|
|
49
49
|
export class Metric extends NamedResultDescriptor {
|
|
50
|
-
|
|
51
|
-
descriptor: MetricConfig
|
|
50
|
+
config: MetricConfig
|
|
52
51
|
constructor(type: MetricType, name: string, option?: MetricOptions) {
|
|
53
52
|
super(name)
|
|
54
|
-
this.
|
|
55
|
-
|
|
56
|
-
const aggregationConfig = this.descriptor.aggregationConfig
|
|
53
|
+
this.config = MetricConfig.fromPartial({ name: this.name, type: type, ...option })
|
|
54
|
+
const aggregationConfig = this.config.aggregationConfig
|
|
57
55
|
if (aggregationConfig && aggregationConfig.intervalInMinutes.length) {
|
|
58
56
|
if (aggregationConfig.intervalInMinutes.length > 1) {
|
|
59
57
|
console.error('current only support one intervalInMinutes, only first interval will be used for', name)
|
|
@@ -71,12 +69,12 @@ export class MetricState extends MapStateStorage<Metric> {
|
|
|
71
69
|
getOrRegisterMetric(type: MetricType, name: string, option?: CounterOptions | MetricOptions): Metric {
|
|
72
70
|
const metricMap = this.getOrRegister()
|
|
73
71
|
let metric = metricMap.get(name)
|
|
74
|
-
if (metric && metric.type !== type) {
|
|
75
|
-
throw Error(`redefine ${name} of metric type ${type} that is previously ${metric.type}`)
|
|
72
|
+
if (metric && metric.config.type !== type) {
|
|
73
|
+
throw Error(`redefine ${name} of metric type ${type} that is previously ${metric.config.type}`)
|
|
76
74
|
}
|
|
77
75
|
|
|
78
76
|
if (!metric) {
|
|
79
|
-
if (type === MetricType.
|
|
77
|
+
if (type === MetricType.COUNTER) {
|
|
80
78
|
metric = new Counter(name, option)
|
|
81
79
|
} else {
|
|
82
80
|
metric = new Gauge(name, option)
|
|
@@ -89,11 +87,11 @@ export class MetricState extends MapStateStorage<Metric> {
|
|
|
89
87
|
|
|
90
88
|
export class Counter extends Metric {
|
|
91
89
|
static register(name: string, option?: CounterOptions): Counter {
|
|
92
|
-
return MetricState.INSTANCE.getOrRegisterMetric(MetricType.
|
|
90
|
+
return MetricState.INSTANCE.getOrRegisterMetric(MetricType.COUNTER, name, option) as Counter
|
|
93
91
|
}
|
|
94
92
|
|
|
95
93
|
constructor(name: string, option?: MetricOptions) {
|
|
96
|
-
super(MetricType.
|
|
94
|
+
super(MetricType.COUNTER, name, option)
|
|
97
95
|
}
|
|
98
96
|
|
|
99
97
|
add(ctx: BaseContext, value: Numberish, labels: Labels = {}) {
|
|
@@ -134,16 +132,16 @@ export class CounterBinding {
|
|
|
134
132
|
|
|
135
133
|
export class Gauge extends Metric {
|
|
136
134
|
static register(name: string, option?: MetricOptions): Gauge {
|
|
137
|
-
return MetricState.INSTANCE.getOrRegisterMetric(MetricType.
|
|
135
|
+
return MetricState.INSTANCE.getOrRegisterMetric(MetricType.GAUGE, name, option) as Gauge
|
|
138
136
|
}
|
|
139
137
|
|
|
140
138
|
constructor(name: string, option?: MetricOptions) {
|
|
141
|
-
super(MetricType.
|
|
139
|
+
super(MetricType.GAUGE, name, option)
|
|
142
140
|
}
|
|
143
141
|
|
|
144
142
|
record(ctx: BaseContext, value: Numberish, labels: Labels = {}) {
|
|
145
143
|
ctx.res.gauges.push({
|
|
146
|
-
metadata: ctx.getMetaData(this.
|
|
144
|
+
metadata: ctx.getMetaData(this.config.name, labels),
|
|
147
145
|
metricValue: toMetricValue(value),
|
|
148
146
|
runtimeInfo: undefined,
|
|
149
147
|
})
|
package/src/core/numberish.ts
CHANGED
|
@@ -19,11 +19,11 @@ export function toMetricValue(value: Numberish): MetricValue {
|
|
|
19
19
|
})
|
|
20
20
|
} else {
|
|
21
21
|
if (value.isNaN()) {
|
|
22
|
-
throw new Error('
|
|
22
|
+
throw new Error('Cannot record NaN value')
|
|
23
23
|
}
|
|
24
24
|
if (!value.isFinite()) {
|
|
25
25
|
// NaN also not finite
|
|
26
|
-
throw new Error('
|
|
26
|
+
throw new Error('Cannot record infinite value')
|
|
27
27
|
}
|
|
28
28
|
return MetricValue.fromPartial({
|
|
29
29
|
bigDecimal: value.toString(), // e.g. -7.350918e-428
|
|
@@ -41,6 +41,15 @@ export function toMetricValue(value: Numberish): MetricValue {
|
|
|
41
41
|
})
|
|
42
42
|
}
|
|
43
43
|
|
|
44
|
+
if (typeof value === 'number') {
|
|
45
|
+
if (Number.isNaN(value)) {
|
|
46
|
+
throw new Error('Cannot record NaN value')
|
|
47
|
+
}
|
|
48
|
+
if (!Number.isFinite(value)) {
|
|
49
|
+
throw new Error('Cannot record infinite value')
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
44
53
|
return MetricValue.fromPartial({
|
|
45
54
|
doubleValue: Number(value),
|
|
46
55
|
})
|
|
@@ -66,8 +66,9 @@ export interface EvmSQLQueryRequest {
|
|
|
66
66
|
|
|
67
67
|
export interface EvmGetHeaderRequest {
|
|
68
68
|
network: string;
|
|
69
|
-
fromBlock
|
|
70
|
-
toBlock
|
|
69
|
+
fromBlock?: Long | undefined;
|
|
70
|
+
toBlock?: Long | undefined;
|
|
71
|
+
blockNumbers: Long[];
|
|
71
72
|
}
|
|
72
73
|
|
|
73
74
|
export interface EvmQueryResponse {
|
|
@@ -1002,7 +1003,12 @@ export const EvmSQLQueryRequest = {
|
|
|
1002
1003
|
};
|
|
1003
1004
|
|
|
1004
1005
|
function createBaseEvmGetHeaderRequest(): EvmGetHeaderRequest {
|
|
1005
|
-
return {
|
|
1006
|
+
return {
|
|
1007
|
+
network: "",
|
|
1008
|
+
fromBlock: undefined,
|
|
1009
|
+
toBlock: undefined,
|
|
1010
|
+
blockNumbers: [],
|
|
1011
|
+
};
|
|
1006
1012
|
}
|
|
1007
1013
|
|
|
1008
1014
|
export const EvmGetHeaderRequest = {
|
|
@@ -1013,12 +1019,17 @@ export const EvmGetHeaderRequest = {
|
|
|
1013
1019
|
if (message.network !== "") {
|
|
1014
1020
|
writer.uint32(10).string(message.network);
|
|
1015
1021
|
}
|
|
1016
|
-
if (
|
|
1022
|
+
if (message.fromBlock !== undefined) {
|
|
1017
1023
|
writer.uint32(16).uint64(message.fromBlock);
|
|
1018
1024
|
}
|
|
1019
|
-
if (
|
|
1025
|
+
if (message.toBlock !== undefined) {
|
|
1020
1026
|
writer.uint32(24).uint64(message.toBlock);
|
|
1021
1027
|
}
|
|
1028
|
+
writer.uint32(34).fork();
|
|
1029
|
+
for (const v of message.blockNumbers) {
|
|
1030
|
+
writer.uint64(v);
|
|
1031
|
+
}
|
|
1032
|
+
writer.ldelim();
|
|
1022
1033
|
return writer;
|
|
1023
1034
|
},
|
|
1024
1035
|
|
|
@@ -1038,6 +1049,16 @@ export const EvmGetHeaderRequest = {
|
|
|
1038
1049
|
case 3:
|
|
1039
1050
|
message.toBlock = reader.uint64() as Long;
|
|
1040
1051
|
break;
|
|
1052
|
+
case 4:
|
|
1053
|
+
if ((tag & 7) === 2) {
|
|
1054
|
+
const end2 = reader.uint32() + reader.pos;
|
|
1055
|
+
while (reader.pos < end2) {
|
|
1056
|
+
message.blockNumbers.push(reader.uint64() as Long);
|
|
1057
|
+
}
|
|
1058
|
+
} else {
|
|
1059
|
+
message.blockNumbers.push(reader.uint64() as Long);
|
|
1060
|
+
}
|
|
1061
|
+
break;
|
|
1041
1062
|
default:
|
|
1042
1063
|
reader.skipType(tag & 7);
|
|
1043
1064
|
break;
|
|
@@ -1051,10 +1072,13 @@ export const EvmGetHeaderRequest = {
|
|
|
1051
1072
|
network: isSet(object.network) ? String(object.network) : "",
|
|
1052
1073
|
fromBlock: isSet(object.fromBlock)
|
|
1053
1074
|
? Long.fromValue(object.fromBlock)
|
|
1054
|
-
:
|
|
1075
|
+
: undefined,
|
|
1055
1076
|
toBlock: isSet(object.toBlock)
|
|
1056
1077
|
? Long.fromValue(object.toBlock)
|
|
1057
|
-
:
|
|
1078
|
+
: undefined,
|
|
1079
|
+
blockNumbers: Array.isArray(object?.blockNumbers)
|
|
1080
|
+
? object.blockNumbers.map((e: any) => Long.fromValue(e))
|
|
1081
|
+
: [],
|
|
1058
1082
|
};
|
|
1059
1083
|
},
|
|
1060
1084
|
|
|
@@ -1062,9 +1086,16 @@ export const EvmGetHeaderRequest = {
|
|
|
1062
1086
|
const obj: any = {};
|
|
1063
1087
|
message.network !== undefined && (obj.network = message.network);
|
|
1064
1088
|
message.fromBlock !== undefined &&
|
|
1065
|
-
(obj.fromBlock = (message.fromBlock ||
|
|
1089
|
+
(obj.fromBlock = (message.fromBlock || undefined).toString());
|
|
1066
1090
|
message.toBlock !== undefined &&
|
|
1067
|
-
(obj.toBlock = (message.toBlock ||
|
|
1091
|
+
(obj.toBlock = (message.toBlock || undefined).toString());
|
|
1092
|
+
if (message.blockNumbers) {
|
|
1093
|
+
obj.blockNumbers = message.blockNumbers.map((e) =>
|
|
1094
|
+
(e || Long.UZERO).toString()
|
|
1095
|
+
);
|
|
1096
|
+
} else {
|
|
1097
|
+
obj.blockNumbers = [];
|
|
1098
|
+
}
|
|
1068
1099
|
return obj;
|
|
1069
1100
|
},
|
|
1070
1101
|
|
|
@@ -1074,11 +1105,13 @@ export const EvmGetHeaderRequest = {
|
|
|
1074
1105
|
message.fromBlock =
|
|
1075
1106
|
object.fromBlock !== undefined && object.fromBlock !== null
|
|
1076
1107
|
? Long.fromValue(object.fromBlock)
|
|
1077
|
-
:
|
|
1108
|
+
: undefined;
|
|
1078
1109
|
message.toBlock =
|
|
1079
1110
|
object.toBlock !== undefined && object.toBlock !== null
|
|
1080
1111
|
? Long.fromValue(object.toBlock)
|
|
1081
|
-
:
|
|
1112
|
+
: undefined;
|
|
1113
|
+
message.blockNumbers =
|
|
1114
|
+
object.blockNumbers?.map((e) => Long.fromValue(e)) || [];
|
|
1082
1115
|
return message;
|
|
1083
1116
|
},
|
|
1084
1117
|
};
|
|
@@ -1311,6 +1344,14 @@ export const EvmQueryDefinition = {
|
|
|
1311
1344
|
responseStream: false,
|
|
1312
1345
|
options: {},
|
|
1313
1346
|
},
|
|
1347
|
+
evmHintHeaderCache: {
|
|
1348
|
+
name: "EvmHintHeaderCache",
|
|
1349
|
+
requestType: EvmGetHeaderRequest,
|
|
1350
|
+
requestStream: false,
|
|
1351
|
+
responseType: VoidResponse,
|
|
1352
|
+
responseStream: false,
|
|
1353
|
+
options: {},
|
|
1354
|
+
},
|
|
1314
1355
|
},
|
|
1315
1356
|
} as const;
|
|
1316
1357
|
|
|
@@ -1323,6 +1364,10 @@ export interface EvmQueryServiceImplementation<CallContextExt = {}> {
|
|
|
1323
1364
|
request: EvmGetHeaderRequest,
|
|
1324
1365
|
context: CallContext & CallContextExt
|
|
1325
1366
|
): Promise<DeepPartial<EvmQueryResponse>>;
|
|
1367
|
+
evmHintHeaderCache(
|
|
1368
|
+
request: EvmGetHeaderRequest,
|
|
1369
|
+
context: CallContext & CallContextExt
|
|
1370
|
+
): Promise<DeepPartial<VoidResponse>>;
|
|
1326
1371
|
}
|
|
1327
1372
|
|
|
1328
1373
|
export interface EvmQueryClient<CallOptionsExt = {}> {
|
|
@@ -1334,6 +1379,10 @@ export interface EvmQueryClient<CallOptionsExt = {}> {
|
|
|
1334
1379
|
request: DeepPartial<EvmGetHeaderRequest>,
|
|
1335
1380
|
options?: CallOptions & CallOptionsExt
|
|
1336
1381
|
): Promise<EvmQueryResponse>;
|
|
1382
|
+
evmHintHeaderCache(
|
|
1383
|
+
request: DeepPartial<EvmGetHeaderRequest>,
|
|
1384
|
+
options?: CallOptions & CallOptionsExt
|
|
1385
|
+
): Promise<VoidResponse>;
|
|
1337
1386
|
}
|
|
1338
1387
|
|
|
1339
1388
|
type Builtin =
|
|
@@ -4,6 +4,51 @@ import Long from "long";
|
|
|
4
4
|
import { Empty } from "../../google/protobuf/empty";
|
|
5
5
|
import _m0 from "protobufjs/minimal";
|
|
6
6
|
|
|
7
|
+
export enum MetricType {
|
|
8
|
+
UNKNOWN_TYPE = 0,
|
|
9
|
+
COUNTER = 1,
|
|
10
|
+
GAUGE = 2,
|
|
11
|
+
HISTOGRAM = 3,
|
|
12
|
+
UNRECOGNIZED = -1,
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export function metricTypeFromJSON(object: any): MetricType {
|
|
16
|
+
switch (object) {
|
|
17
|
+
case 0:
|
|
18
|
+
case "UNKNOWN_TYPE":
|
|
19
|
+
return MetricType.UNKNOWN_TYPE;
|
|
20
|
+
case 1:
|
|
21
|
+
case "COUNTER":
|
|
22
|
+
return MetricType.COUNTER;
|
|
23
|
+
case 2:
|
|
24
|
+
case "GAUGE":
|
|
25
|
+
return MetricType.GAUGE;
|
|
26
|
+
case 3:
|
|
27
|
+
case "HISTOGRAM":
|
|
28
|
+
return MetricType.HISTOGRAM;
|
|
29
|
+
case -1:
|
|
30
|
+
case "UNRECOGNIZED":
|
|
31
|
+
default:
|
|
32
|
+
return MetricType.UNRECOGNIZED;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export function metricTypeToJSON(object: MetricType): string {
|
|
37
|
+
switch (object) {
|
|
38
|
+
case MetricType.UNKNOWN_TYPE:
|
|
39
|
+
return "UNKNOWN_TYPE";
|
|
40
|
+
case MetricType.COUNTER:
|
|
41
|
+
return "COUNTER";
|
|
42
|
+
case MetricType.GAUGE:
|
|
43
|
+
return "GAUGE";
|
|
44
|
+
case MetricType.HISTOGRAM:
|
|
45
|
+
return "HISTOGRAM";
|
|
46
|
+
case MetricType.UNRECOGNIZED:
|
|
47
|
+
default:
|
|
48
|
+
return "UNRECOGNIZED";
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
7
52
|
export enum AggregationType {
|
|
8
53
|
COUNT = 0,
|
|
9
54
|
SUM = 1,
|
|
@@ -297,6 +342,7 @@ export interface MetricConfig {
|
|
|
297
342
|
unit: string;
|
|
298
343
|
sparse: boolean;
|
|
299
344
|
resolutionInSeconds: number;
|
|
345
|
+
type: MetricType;
|
|
300
346
|
aggregationConfig: AggregationConfig | undefined;
|
|
301
347
|
}
|
|
302
348
|
|
|
@@ -1443,6 +1489,7 @@ function createBaseMetricConfig(): MetricConfig {
|
|
|
1443
1489
|
unit: "",
|
|
1444
1490
|
sparse: false,
|
|
1445
1491
|
resolutionInSeconds: 0,
|
|
1492
|
+
type: 0,
|
|
1446
1493
|
aggregationConfig: undefined,
|
|
1447
1494
|
};
|
|
1448
1495
|
}
|
|
@@ -1467,6 +1514,9 @@ export const MetricConfig = {
|
|
|
1467
1514
|
if (message.resolutionInSeconds !== 0) {
|
|
1468
1515
|
writer.uint32(40).int32(message.resolutionInSeconds);
|
|
1469
1516
|
}
|
|
1517
|
+
if (message.type !== 0) {
|
|
1518
|
+
writer.uint32(56).int32(message.type);
|
|
1519
|
+
}
|
|
1470
1520
|
if (message.aggregationConfig !== undefined) {
|
|
1471
1521
|
AggregationConfig.encode(
|
|
1472
1522
|
message.aggregationConfig,
|
|
@@ -1498,6 +1548,9 @@ export const MetricConfig = {
|
|
|
1498
1548
|
case 5:
|
|
1499
1549
|
message.resolutionInSeconds = reader.int32();
|
|
1500
1550
|
break;
|
|
1551
|
+
case 7:
|
|
1552
|
+
message.type = reader.int32() as any;
|
|
1553
|
+
break;
|
|
1501
1554
|
case 6:
|
|
1502
1555
|
message.aggregationConfig = AggregationConfig.decode(
|
|
1503
1556
|
reader,
|
|
@@ -1521,6 +1574,7 @@ export const MetricConfig = {
|
|
|
1521
1574
|
resolutionInSeconds: isSet(object.resolutionInSeconds)
|
|
1522
1575
|
? Number(object.resolutionInSeconds)
|
|
1523
1576
|
: 0,
|
|
1577
|
+
type: isSet(object.type) ? metricTypeFromJSON(object.type) : 0,
|
|
1524
1578
|
aggregationConfig: isSet(object.aggregationConfig)
|
|
1525
1579
|
? AggregationConfig.fromJSON(object.aggregationConfig)
|
|
1526
1580
|
: undefined,
|
|
@@ -1536,6 +1590,7 @@ export const MetricConfig = {
|
|
|
1536
1590
|
message.sparse !== undefined && (obj.sparse = message.sparse);
|
|
1537
1591
|
message.resolutionInSeconds !== undefined &&
|
|
1538
1592
|
(obj.resolutionInSeconds = Math.round(message.resolutionInSeconds));
|
|
1593
|
+
message.type !== undefined && (obj.type = metricTypeToJSON(message.type));
|
|
1539
1594
|
message.aggregationConfig !== undefined &&
|
|
1540
1595
|
(obj.aggregationConfig = message.aggregationConfig
|
|
1541
1596
|
? AggregationConfig.toJSON(message.aggregationConfig)
|
|
@@ -1550,6 +1605,7 @@ export const MetricConfig = {
|
|
|
1550
1605
|
message.unit = object.unit ?? "";
|
|
1551
1606
|
message.sparse = object.sparse ?? false;
|
|
1552
1607
|
message.resolutionInSeconds = object.resolutionInSeconds ?? 0;
|
|
1608
|
+
message.type = object.type ?? 0;
|
|
1553
1609
|
message.aggregationConfig =
|
|
1554
1610
|
object.aggregationConfig !== undefined &&
|
|
1555
1611
|
object.aggregationConfig !== null
|
package/src/service.ts
CHANGED
|
@@ -46,7 +46,6 @@ import { AccountProcessorState } from './core/account-processor'
|
|
|
46
46
|
import { SuiProcessorState } from './core/sui-processor'
|
|
47
47
|
import { SolanaProcessorState } from './core/solana-processor'
|
|
48
48
|
import { ProcessorState } from './binds'
|
|
49
|
-
|
|
50
49
|
;(BigInt.prototype as any).toJSON = function () {
|
|
51
50
|
return this.toString()
|
|
52
51
|
}
|
|
@@ -118,7 +117,7 @@ export class ProcessorServiceImpl implements ProcessorServiceImplementation {
|
|
|
118
117
|
// part 0, prepare metrics and event tracking configs
|
|
119
118
|
for (const metric of MetricState.INSTANCE.getValues()) {
|
|
120
119
|
this.metricConfigs.push({
|
|
121
|
-
...metric.
|
|
120
|
+
...metric.config,
|
|
122
121
|
})
|
|
123
122
|
}
|
|
124
123
|
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { EventDeclaration, getFullSignatureAsSymbolForEvent } from 'typechain'
|
|
2
|
+
import { getFullSignatureForEventPatched } from './types'
|
|
3
|
+
|
|
4
|
+
export function generateEventHandler(event: EventDeclaration, contractName: string, includeArgTypes: boolean): string {
|
|
5
|
+
const eventName = includeArgTypes ? getFullSignatureAsSymbolForEvent(event) : event.name
|
|
6
|
+
const eventNamePrefix = includeArgTypes ? eventName + '_' : eventName
|
|
7
|
+
|
|
8
|
+
const filterName = getFullSignatureForEventPatched(event)
|
|
9
|
+
return `
|
|
10
|
+
onEvent${eventName}(
|
|
11
|
+
handler: (event: ${eventNamePrefix}Event, ctx: ${contractName}Context) => void,
|
|
12
|
+
filter?: ${eventNamePrefix}EventFilter | ${eventNamePrefix}EventFilter[]
|
|
13
|
+
) {
|
|
14
|
+
if (!filter) {
|
|
15
|
+
// @ts-ignore
|
|
16
|
+
filter = ${contractName}Processor.filters[
|
|
17
|
+
// @ts-ignore
|
|
18
|
+
'${filterName}'](${event.inputs.map(() => 'null').join(',')})
|
|
19
|
+
}
|
|
20
|
+
return super.onEvent(handler, filter!)
|
|
21
|
+
}
|
|
22
|
+
`
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export function generateEventHandlers(events: EventDeclaration[], contractName: string): string {
|
|
26
|
+
if (events.length === 1) {
|
|
27
|
+
return generateEventHandler(events[0], contractName, false)
|
|
28
|
+
} else {
|
|
29
|
+
return events.map((e) => generateEventHandler(e, contractName, true)).join('\n')
|
|
30
|
+
}
|
|
31
|
+
}
|