@sentio/sdk 2.57.2-rc.3 → 2.57.2-rc.5
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/aptos/aptos-processor.d.ts +1 -1
- package/lib/aptos/aptos-processor.d.ts.map +1 -1
- package/lib/aptos/aptos-processor.js +3 -3
- package/lib/aptos/aptos-processor.js.map +1 -1
- package/lib/aptos/aptos-resource-processor-template.d.ts +1 -0
- package/lib/aptos/aptos-resource-processor-template.d.ts.map +1 -1
- package/lib/aptos/aptos-resource-processor-template.js +4 -2
- package/lib/aptos/aptos-resource-processor-template.js.map +1 -1
- package/lib/aptos/ext/coin.test.js.map +1 -1
- package/lib/aptos/ext/token.d.ts.map +1 -1
- package/lib/aptos/ext/token.js +8 -3
- package/lib/aptos/ext/token.js.map +1 -1
- package/lib/eth/base-processor-template.d.ts +3 -0
- package/lib/eth/base-processor-template.d.ts.map +1 -1
- package/lib/eth/base-processor-template.js +7 -4
- package/lib/eth/base-processor-template.js.map +1 -1
- package/lib/eth/base-processor.d.ts +3 -3
- package/lib/eth/base-processor.d.ts.map +1 -1
- package/lib/eth/base-processor.js +6 -6
- package/lib/eth/base-processor.js.map +1 -1
- package/lib/fuel/fuel-processor-template.d.ts +3 -0
- package/lib/fuel/fuel-processor-template.d.ts.map +1 -1
- package/lib/fuel/fuel-processor-template.js +7 -4
- package/lib/fuel/fuel-processor-template.js.map +1 -1
- package/lib/fuel/fuel-processor.d.ts +3 -3
- package/lib/fuel/fuel-processor.d.ts.map +1 -1
- package/lib/fuel/fuel-processor.js +6 -6
- package/lib/fuel/fuel-processor.js.map +1 -1
- package/lib/sui/sui-object-processor-template.d.ts +1 -0
- package/lib/sui/sui-object-processor-template.d.ts.map +1 -1
- package/lib/sui/sui-object-processor-template.js +4 -2
- package/lib/sui/sui-object-processor-template.js.map +1 -1
- package/lib/sui/sui-object-processor.d.ts +1 -1
- package/lib/sui/sui-object-processor.d.ts.map +1 -1
- package/lib/sui/sui-object-processor.js +2 -2
- package/lib/sui/sui-object-processor.js.map +1 -1
- package/lib/sui/sui-processor.js +2 -2
- package/lib/sui/sui-processor.js.map +1 -1
- package/lib/utils/metrics.d.ts.map +1 -1
- package/lib/utils/metrics.js +0 -3
- package/lib/utils/metrics.js.map +1 -1
- package/package.json +3 -3
- package/src/aptos/aptos-processor.ts +4 -3
- package/src/aptos/aptos-resource-processor-template.ts +11 -2
- package/src/aptos/ext/token.ts +7 -3
- package/src/eth/base-processor-template.ts +17 -4
- package/src/eth/base-processor.ts +9 -6
- package/src/fuel/fuel-processor-template.ts +10 -4
- package/src/fuel/fuel-processor.ts +9 -6
- package/src/sui/sui-object-processor-template.ts +11 -2
- package/src/sui/sui-object-processor.ts +3 -2
- package/src/sui/sui-processor.ts +2 -2
- package/src/utils/metrics.ts +0 -3
@@ -9,7 +9,7 @@ import { BlockParams } from 'ethers/providers'
|
|
9
9
|
import { DeferredTopicFilter } from 'ethers/contract'
|
10
10
|
import { TypedEvent, TypedCallTrace } from './eth.js'
|
11
11
|
import { TemplateInstanceState } from '../core/template.js'
|
12
|
-
import { proxyProcessor } from '../utils/metrics.js'
|
12
|
+
import { getHandlerName, proxyProcessor } from '../utils/metrics.js'
|
13
13
|
|
14
14
|
export class ProcessorTemplateProcessorState extends ListStateStorage<
|
15
15
|
BaseProcessorTemplate<BaseContract, BoundContractView<BaseContract, any>>
|
@@ -24,6 +24,7 @@ export abstract class BaseProcessorTemplate<
|
|
24
24
|
id: number
|
25
25
|
binds = new Set<string>()
|
26
26
|
blockHandlers: {
|
27
|
+
handlerName: string
|
27
28
|
handler: (block: BlockParams, ctx: ContractContext<TContract, TBoundContractView>) => PromiseOrVoid
|
28
29
|
preprocessHandler: (
|
29
30
|
block: BlockParams,
|
@@ -36,6 +37,7 @@ export abstract class BaseProcessorTemplate<
|
|
36
37
|
}[] = []
|
37
38
|
traceHandlers: {
|
38
39
|
signature: string
|
40
|
+
handlerName: string
|
39
41
|
handler: (trace: TypedCallTrace, ctx: ContractContext<TContract, TBoundContractView>) => PromiseOrVoid
|
40
42
|
preprocessHandler: (
|
41
43
|
trace: TypedCallTrace,
|
@@ -45,6 +47,7 @@ export abstract class BaseProcessorTemplate<
|
|
45
47
|
fetchConfig?: EthFetchConfig
|
46
48
|
}[] = []
|
47
49
|
eventHandlers: {
|
50
|
+
handlerName: string
|
48
51
|
handler: (event: TypedEvent, ctx: ContractContext<TContract, TBoundContractView>) => PromiseOrVoid
|
49
52
|
preprocessHandler: (
|
50
53
|
event: TypedEvent,
|
@@ -81,14 +84,21 @@ export abstract class BaseProcessorTemplate<
|
|
81
84
|
|
82
85
|
for (const eh of this.eventHandlers) {
|
83
86
|
// @ts-ignore friendly
|
84
|
-
processor.onEthEvent(eh.handler, eh.filter, eh.fetchConfig, eh.preprocessHandler)
|
87
|
+
processor.onEthEvent(eh.handler, eh.filter, eh.fetchConfig, eh.preprocessHandler, eh.handlerName)
|
85
88
|
}
|
86
89
|
for (const th of this.traceHandlers) {
|
87
90
|
// @ts-ignore friendly
|
88
|
-
processor.onEthTrace(th.signature, th.handler, th.fetchConfig, th.preprocessHandler)
|
91
|
+
processor.onEthTrace(th.signature, th.handler, th.fetchConfig, th.preprocessHandler, th.handlerName)
|
89
92
|
}
|
90
93
|
for (const bh of this.blockHandlers) {
|
91
|
-
processor.onInterval(
|
94
|
+
processor.onInterval(
|
95
|
+
bh.handler,
|
96
|
+
bh.timeIntervalInMinutes,
|
97
|
+
bh.blockInterval,
|
98
|
+
bh.fetchConfig,
|
99
|
+
bh.preprocessHandler,
|
100
|
+
bh.handlerName
|
101
|
+
)
|
92
102
|
}
|
93
103
|
|
94
104
|
const instance: TemplateInstance = {
|
@@ -124,6 +134,7 @@ export abstract class BaseProcessorTemplate<
|
|
124
134
|
) => Promise<PreprocessResult> = defaultPreprocessHandler
|
125
135
|
) {
|
126
136
|
this.eventHandlers.push({
|
137
|
+
handlerName: getHandlerName(),
|
127
138
|
handler: handler,
|
128
139
|
preprocessHandler,
|
129
140
|
filter: filter,
|
@@ -187,6 +198,7 @@ export abstract class BaseProcessorTemplate<
|
|
187
198
|
) => Promise<PreprocessResult> = defaultPreprocessHandler
|
188
199
|
) {
|
189
200
|
this.blockHandlers.push({
|
201
|
+
handlerName: getHandlerName(),
|
190
202
|
handler,
|
191
203
|
preprocessHandler,
|
192
204
|
timeIntervalInMinutes: timeInterval,
|
@@ -208,6 +220,7 @@ export abstract class BaseProcessorTemplate<
|
|
208
220
|
) {
|
209
221
|
this.traceHandlers.push({
|
210
222
|
signature,
|
223
|
+
handlerName: getHandlerName(),
|
211
224
|
handler,
|
212
225
|
preprocessHandler,
|
213
226
|
fetchConfig: EthFetchConfig.fromPartial(fetchConfig || {})
|
@@ -429,7 +429,8 @@ export abstract class BaseProcessor<
|
|
429
429
|
event: TypedEvent,
|
430
430
|
ctx: ContractContext<TContract, TBoundContractView>,
|
431
431
|
preprocessStore: { [k: string]: any }
|
432
|
-
) => Promise<PreprocessResult> = defaultPreprocessHandler
|
432
|
+
) => Promise<PreprocessResult> = defaultPreprocessHandler,
|
433
|
+
handlerName = getHandlerName()
|
433
434
|
): this {
|
434
435
|
const chainId = this.getChainId()
|
435
436
|
let _filters: DeferredTopicFilter[] = []
|
@@ -445,7 +446,7 @@ export abstract class BaseProcessor<
|
|
445
446
|
this.eventHandlers.push({
|
446
447
|
filters: _filters,
|
447
448
|
fetchConfig: EthFetchConfig.fromPartial(fetchConfig || {}),
|
448
|
-
handlerName
|
449
|
+
handlerName,
|
449
450
|
handler: async function (data: Data_EthLog, preparedData?: PreparedData) {
|
450
451
|
const { log, block, transaction, transactionReceipt } = formatEthData(data)
|
451
452
|
if (!log) {
|
@@ -605,14 +606,15 @@ export abstract class BaseProcessor<
|
|
605
606
|
block: RichBlock,
|
606
607
|
ctx: ContractContext<TContract, TBoundContractView>,
|
607
608
|
preprocessStore: { [k: string]: any }
|
608
|
-
) => Promise<PreprocessResult> = defaultPreprocessHandler
|
609
|
+
) => Promise<PreprocessResult> = defaultPreprocessHandler,
|
610
|
+
handlerName = getHandlerName()
|
609
611
|
): this {
|
610
612
|
const chainId = this.getChainId()
|
611
613
|
const processor = this
|
612
614
|
const contractName = this.config.name
|
613
615
|
|
614
616
|
this.blockHandlers.push({
|
615
|
-
handlerName
|
617
|
+
handlerName,
|
616
618
|
handler: async function (data: Data_EthBlock, preparedData?: PreparedData) {
|
617
619
|
const { block } = formatEthData(data)
|
618
620
|
|
@@ -676,7 +678,8 @@ export abstract class BaseProcessor<
|
|
676
678
|
trace: TypedCallTrace,
|
677
679
|
ctx: ContractContext<TContract, TBoundContractView>,
|
678
680
|
preprocessStore: { [k: string]: any }
|
679
|
-
) => Promise<PreprocessResult> = defaultPreprocessHandler
|
681
|
+
) => Promise<PreprocessResult> = defaultPreprocessHandler,
|
682
|
+
handlerName = getHandlerName()
|
680
683
|
): this {
|
681
684
|
const chainId = this.getChainId()
|
682
685
|
const contractName = this.config.name
|
@@ -688,7 +691,7 @@ export abstract class BaseProcessor<
|
|
688
691
|
this.traceHandlers.push({
|
689
692
|
signatures,
|
690
693
|
fetchConfig: EthFetchConfig.fromPartial(fetchConfig || {}),
|
691
|
-
handlerName
|
694
|
+
handlerName,
|
692
695
|
handler: async function (data: Data_EthTrace, preparedData?: PreparedData) {
|
693
696
|
const contractView = processor.CreateBoundContractView()
|
694
697
|
const contractInterface = contractView.rawContract.interface
|
@@ -7,7 +7,7 @@ import { Contract } from 'fuels'
|
|
7
7
|
import { FuelBlock, FuelLog, FuelTransaction } from './types.js'
|
8
8
|
import { DEFAULT_FUEL_FETCH_CONFIG, FuelFetchConfig } from './transaction.js'
|
9
9
|
import { FuelProcessor, FuelProcessorConfig, getOptionsSignature } from './fuel-processor.js'
|
10
|
-
import { proxyProcessor } from '../utils/metrics.js'
|
10
|
+
import { getHandlerName, proxyProcessor } from '../utils/metrics.js'
|
11
11
|
|
12
12
|
export class FuelProcessorTemplateProcessorState extends ListStateStorage<FuelBaseProcessorTemplate<Contract>> {
|
13
13
|
static INSTANCE = new FuelProcessorTemplateProcessorState()
|
@@ -17,6 +17,7 @@ export abstract class FuelBaseProcessorTemplate<TContract extends Contract> {
|
|
17
17
|
id: number
|
18
18
|
binds = new Set<string>()
|
19
19
|
blockHandlers: {
|
20
|
+
handlerName: string
|
20
21
|
handler: (block: FuelBlock, ctx: FuelContractContext<TContract>) => PromiseOrVoid
|
21
22
|
blockInterval?: HandleInterval
|
22
23
|
timeIntervalInMinutes?: HandleInterval
|
@@ -25,11 +26,13 @@ export abstract class FuelBaseProcessorTemplate<TContract extends Contract> {
|
|
25
26
|
|
26
27
|
logHandlers: {
|
27
28
|
logIdFilter: string | string[]
|
29
|
+
handlerName: string
|
28
30
|
handler: (logs: FuelLog<any>, ctx: FuelContractContext<TContract>) => PromiseOrVoid
|
29
31
|
// fetchConfig?: FuelFetchConfig
|
30
32
|
}[] = []
|
31
33
|
|
32
34
|
transactionHandlers: {
|
35
|
+
handlerName: string
|
33
36
|
handler: (transaction: FuelTransaction, ctx: FuelContractContext<TContract>) => PromiseOrVoid
|
34
37
|
fetchConfig: FuelFetchConfig
|
35
38
|
}[] = []
|
@@ -59,13 +62,13 @@ export abstract class FuelBaseProcessorTemplate<TContract extends Contract> {
|
|
59
62
|
const processor = this.bindInternal({ ...options, chainId: ctx.chainId })
|
60
63
|
|
61
64
|
for (const eh of this.logHandlers) {
|
62
|
-
processor.onLog(eh.logIdFilter, eh.handler)
|
65
|
+
processor.onLog(eh.logIdFilter, eh.handler, eh.handlerName)
|
63
66
|
}
|
64
67
|
for (const bh of this.blockHandlers) {
|
65
|
-
processor.onInterval(bh.handler, bh.timeIntervalInMinutes, bh.blockInterval)
|
68
|
+
processor.onInterval(bh.handler, bh.timeIntervalInMinutes, bh.blockInterval, bh.handlerName)
|
66
69
|
}
|
67
70
|
for (const th of this.transactionHandlers) {
|
68
|
-
processor.onTransaction(th.handler)
|
71
|
+
processor.onTransaction(th.handler, undefined, th.handlerName)
|
69
72
|
}
|
70
73
|
|
71
74
|
const instance: TemplateInstance = {
|
@@ -96,6 +99,7 @@ export abstract class FuelBaseProcessorTemplate<TContract extends Contract> {
|
|
96
99
|
) {
|
97
100
|
this.logHandlers.push({
|
98
101
|
logIdFilter,
|
102
|
+
handlerName: getHandlerName(),
|
99
103
|
handler
|
100
104
|
// fetchConfig: { ...fetchConfig}
|
101
105
|
})
|
@@ -140,6 +144,7 @@ export abstract class FuelBaseProcessorTemplate<TContract extends Contract> {
|
|
140
144
|
// fetchConfig?: FuelFetchConfig
|
141
145
|
) {
|
142
146
|
this.blockHandlers.push({
|
147
|
+
handlerName: getHandlerName(),
|
143
148
|
handler,
|
144
149
|
timeIntervalInMinutes: timeInterval,
|
145
150
|
blockInterval
|
@@ -153,6 +158,7 @@ export abstract class FuelBaseProcessorTemplate<TContract extends Contract> {
|
|
153
158
|
config: FuelFetchConfig = DEFAULT_FUEL_FETCH_CONFIG
|
154
159
|
) {
|
155
160
|
this.transactionHandlers.push({
|
161
|
+
handlerName: getHandlerName(),
|
156
162
|
handler,
|
157
163
|
fetchConfig: config
|
158
164
|
})
|
@@ -68,10 +68,11 @@ export class FuelProcessor<TContract extends Contract> implements FuelBaseProces
|
|
68
68
|
|
69
69
|
public onTransaction(
|
70
70
|
handler: (transaction: FuelTransaction, ctx: FuelContractContext<TContract>) => PromiseOrVoid,
|
71
|
-
config: FuelFetchConfig = DEFAULT_FUEL_FETCH_CONFIG
|
71
|
+
config: FuelFetchConfig = DEFAULT_FUEL_FETCH_CONFIG,
|
72
|
+
handlerName = getHandlerName()
|
72
73
|
) {
|
73
74
|
const callHandler = {
|
74
|
-
handlerName
|
75
|
+
handlerName,
|
75
76
|
handler: async (call: Data_FuelTransaction) => {
|
76
77
|
const abiMap = this.config.abi
|
77
78
|
? {
|
@@ -181,12 +182,13 @@ export class FuelProcessor<TContract extends Contract> implements FuelBaseProces
|
|
181
182
|
|
182
183
|
public onLog<T>(
|
183
184
|
logIdFilter: string | string[],
|
184
|
-
handler: (logs: FuelLog<T>, ctx: FuelContractContext<TContract>) => PromiseOrVoid
|
185
|
+
handler: (logs: FuelLog<T>, ctx: FuelContractContext<TContract>) => PromiseOrVoid,
|
186
|
+
handlerName = getHandlerName()
|
185
187
|
) {
|
186
188
|
const logIds = new Set(Array.isArray(logIdFilter) ? logIdFilter : [logIdFilter])
|
187
189
|
|
188
190
|
const logHandler = {
|
189
|
-
handlerName
|
191
|
+
handlerName,
|
190
192
|
handler: async ({ transaction, receiptIndex, timestamp }: Data_FuelReceipt) => {
|
191
193
|
try {
|
192
194
|
const tx = decodeFuelTransaction(transaction, this.provider)
|
@@ -272,7 +274,8 @@ export class FuelProcessor<TContract extends Contract> implements FuelBaseProces
|
|
272
274
|
public onInterval(
|
273
275
|
handler: (block: FuelBlock, ctx: FuelContractContext<TContract>) => PromiseOrVoid,
|
274
276
|
timeInterval: HandleInterval | undefined,
|
275
|
-
blockInterval: HandleInterval | undefined
|
277
|
+
blockInterval: HandleInterval | undefined,
|
278
|
+
handlerName = getHandlerName()
|
276
279
|
// fetchConfig: Partial<FuelFetchConfig> | undefined
|
277
280
|
): this {
|
278
281
|
if (timeInterval) {
|
@@ -286,7 +289,7 @@ export class FuelProcessor<TContract extends Contract> implements FuelBaseProces
|
|
286
289
|
this.blockHandlers.push({
|
287
290
|
blockInterval,
|
288
291
|
timeIntervalInMinutes: timeInterval,
|
289
|
-
handlerName
|
292
|
+
handlerName,
|
290
293
|
handler: async function (data: Data_FuelBlock) {
|
291
294
|
const header = data.block
|
292
295
|
if (!header) {
|
@@ -16,12 +16,13 @@ import { TemplateInstanceState } from '../core/template.js'
|
|
16
16
|
import { SuiBindOptions } from './sui-processor.js'
|
17
17
|
import { TransactionFilter, accountAddressString } from '../move/index.js'
|
18
18
|
import { ServerError, Status } from 'nice-grpc'
|
19
|
-
import { proxyProcessor } from '../utils/metrics.js'
|
19
|
+
import { getHandlerName, proxyProcessor } from '../utils/metrics.js'
|
20
20
|
|
21
21
|
class ObjectHandler<HandlerType> {
|
22
22
|
type?: string
|
23
23
|
checkpointInterval?: HandleInterval
|
24
24
|
timeIntervalInMinutes?: HandleInterval
|
25
|
+
handlerName: string
|
25
26
|
handler: HandlerType
|
26
27
|
fetchConfig: MoveAccountFetchConfig
|
27
28
|
}
|
@@ -68,7 +69,14 @@ export abstract class SuiObjectOrAddressProcessorTemplate<
|
|
68
69
|
|
69
70
|
const processor = this.createProcessor(options)
|
70
71
|
for (const h of this.objectHandlers) {
|
71
|
-
processor.onInterval(
|
72
|
+
processor.onInterval(
|
73
|
+
h.handler,
|
74
|
+
h.timeIntervalInMinutes,
|
75
|
+
h.checkpointInterval,
|
76
|
+
h.type,
|
77
|
+
h.fetchConfig,
|
78
|
+
h.handlerName
|
79
|
+
)
|
72
80
|
}
|
73
81
|
const config = processor.config
|
74
82
|
|
@@ -162,6 +170,7 @@ export abstract class SuiObjectOrAddressProcessorTemplate<
|
|
162
170
|
fetchConfig: Partial<MoveAccountFetchConfig> | undefined
|
163
171
|
): this {
|
164
172
|
this.objectHandlers.push({
|
173
|
+
handlerName: getHandlerName(),
|
165
174
|
handler: handler,
|
166
175
|
timeIntervalInMinutes: timeInterval,
|
167
176
|
checkpointInterval: checkpointInterval,
|
@@ -97,11 +97,12 @@ export abstract class SuiBaseObjectOrAddressProcessor<HandlerType> {
|
|
97
97
|
timeInterval: HandleInterval | undefined,
|
98
98
|
checkpointInterval: HandleInterval | undefined,
|
99
99
|
type: string | undefined,
|
100
|
-
fetchConfig: Partial<MoveAccountFetchConfig> | undefined
|
100
|
+
fetchConfig: Partial<MoveAccountFetchConfig> | undefined,
|
101
|
+
handlerName = getHandlerName()
|
101
102
|
): this {
|
102
103
|
const processor = this
|
103
104
|
this.objectHandlers.push({
|
104
|
-
handlerName
|
105
|
+
handlerName,
|
105
106
|
handler: async function (data) {
|
106
107
|
const ctx = new SuiObjectContext(
|
107
108
|
processor.config.network,
|
package/src/sui/sui-processor.ts
CHANGED
@@ -22,8 +22,8 @@ import { getHandlerName, proxyProcessor } from '../utils/metrics.js'
|
|
22
22
|
|
23
23
|
export const DEFAULT_FETCH_CONFIG: MoveFetchConfig = {
|
24
24
|
resourceChanges: false,
|
25
|
-
allEvents:
|
26
|
-
inputs:
|
25
|
+
allEvents: true,
|
26
|
+
inputs: true
|
27
27
|
}
|
28
28
|
|
29
29
|
export type IndexConfigure = Required<SuiBindOptions, 'startCheckpoint' | 'network'>
|
package/src/utils/metrics.ts
CHANGED
@@ -8,9 +8,6 @@ export function getHandlerName() {
|
|
8
8
|
export function proxyProcessor(cls: any) {
|
9
9
|
return new Proxy(cls, {
|
10
10
|
get: (target, prop, receiver) => {
|
11
|
-
if (prop.toString() == 'bind') {
|
12
|
-
return Reflect.get(target, prop, receiver)
|
13
|
-
}
|
14
11
|
return metricsStorage.run(metricsStorage.getStore() || `${cls.constructor.name}.${prop.toString()}`, () => {
|
15
12
|
const fn = (target as any)[prop]
|
16
13
|
if (typeof fn == 'function') {
|