@sentio/sdk 2.50.1 → 2.50.2-rc.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/aptos/builtin/0x1.js +1 -1
- package/lib/aptos/builtin/0x1.js.map +1 -1
- package/lib/aptos/builtin/0x3.js +1 -1
- package/lib/aptos/builtin/0x3.js.map +1 -1
- package/lib/aptos/builtin/0x4.js +1 -1
- package/lib/aptos/builtin/0x4.js.map +1 -1
- package/lib/aptos/codegen/codegen.js +2 -3
- package/lib/aptos/codegen/codegen.js.map +1 -1
- package/lib/aptos/network.d.ts +2 -2
- package/lib/aptos/network.d.ts.map +1 -1
- package/lib/aptos/network.js +4 -7
- package/lib/aptos/network.js.map +1 -1
- package/lib/core/event-logger.js +2 -1
- package/lib/core/event-logger.js.map +1 -1
- package/lib/core/event-tracker.d.ts.map +1 -1
- package/lib/core/event-tracker.js +3 -2
- package/lib/core/event-tracker.js.map +1 -1
- package/lib/eth/account-processor.d.ts.map +1 -1
- package/lib/eth/account-processor.js +3 -0
- package/lib/eth/account-processor.js.map +1 -1
- package/lib/eth/base-processor.d.ts +2 -0
- package/lib/eth/base-processor.d.ts.map +1 -1
- package/lib/eth/base-processor.js +8 -18
- package/lib/eth/base-processor.js.map +1 -1
- package/lib/eth/base-processor.test.js.map +1 -1
- package/lib/eth/eth-plugin.d.ts.map +1 -1
- package/lib/eth/eth-plugin.js +4 -0
- package/lib/eth/eth-plugin.js.map +1 -1
- package/lib/solana/builtin/types.d.ts +11 -11
- package/lib/tsup.config.ts +1 -0
- package/lib/utils/metrics.d.ts +2 -2
- package/lib/utils/metrics.d.ts.map +1 -1
- package/lib/utils/metrics.js +16 -19
- package/lib/utils/metrics.js.map +1 -1
- package/package.json +4 -4
- package/src/aptos/builtin/0x1.ts +1 -1
- package/src/aptos/builtin/0x3.ts +1 -1
- package/src/aptos/builtin/0x4.ts +1 -1
- package/src/aptos/codegen/codegen.ts +4 -5
- package/src/aptos/network.ts +6 -7
- package/src/core/event-logger.ts +2 -1
- package/src/core/event-tracker.ts +3 -2
- package/src/eth/account-processor.ts +4 -0
- package/src/eth/base-processor.ts +8 -19
- package/src/eth/eth-plugin.ts +4 -0
- package/src/tsup.config.ts +1 -0
- package/src/utils/metrics.ts +16 -19
@@ -1,4 +1,3 @@
|
|
1
|
-
import { AsyncLocalStorage } from 'node:async_hooks'
|
2
1
|
import { BaseContract, DeferredTopicFilter, LogDescription, TransactionResponseParams } from 'ethers'
|
3
2
|
|
4
3
|
import { BoundContractView, ContractContext, ContractView, GlobalContext } from './context.js'
|
@@ -19,9 +18,9 @@ import { PromiseOrVoid } from '../core/promises.js'
|
|
19
18
|
import { ServerError, Status } from 'nice-grpc'
|
20
19
|
import { fixEmptyKey, formatEthData, RichBlock, Trace, TypedCallTrace, TypedEvent } from './eth.js'
|
21
20
|
import sha3 from 'js-sha3'
|
22
|
-
import { ListStateStorage
|
21
|
+
import { ListStateStorage } from '@sentio/runtime'
|
23
22
|
import { EthChainId } from '@sentio/chain'
|
24
|
-
import {
|
23
|
+
import { getHandlerName, proxyProcessor } from '../utils/metrics.js'
|
25
24
|
import { ALL_ADDRESS } from '../core/index.js'
|
26
25
|
|
27
26
|
export interface AddressOrTypeEventFilter extends DeferredTopicFilter {
|
@@ -33,6 +32,7 @@ export const defaultPreprocessHandler = () => (<PreprocessResult>{ ethCallParams
|
|
33
32
|
|
34
33
|
export class EventsHandler {
|
35
34
|
filters: AddressOrTypeEventFilter[]
|
35
|
+
handlerName: string
|
36
36
|
handler: (event: Data_EthLog) => Promise<ProcessResult>
|
37
37
|
preprocessHandler?: (event: Data_EthLog, preprocessStore: { [k: string]: any }) => Promise<PreprocessResult>
|
38
38
|
fetchConfig: EthFetchConfig
|
@@ -40,6 +40,7 @@ export class EventsHandler {
|
|
40
40
|
|
41
41
|
export class TraceHandler {
|
42
42
|
signatures: string[]
|
43
|
+
handlerName: string
|
43
44
|
handler: (trace: Data_EthTrace) => Promise<ProcessResult>
|
44
45
|
preprocessHandler?: (event: Data_EthTrace, preprocessStore: { [k: string]: any }) => Promise<PreprocessResult>
|
45
46
|
fetchConfig: EthFetchConfig
|
@@ -314,6 +315,7 @@ export class GlobalProcessor {
|
|
314
315
|
this.traceHandlers.push({
|
315
316
|
signatures,
|
316
317
|
fetchConfig: EthFetchConfig.fromPartial(fetchConfig || {}),
|
318
|
+
handlerName: getHandlerName(),
|
317
319
|
handler: async function (data: Data_EthTrace) {
|
318
320
|
const { trace, block, transaction, transactionReceipt } = formatEthData(data)
|
319
321
|
|
@@ -383,22 +385,7 @@ export abstract class BaseProcessor<
|
|
383
385
|
this.config.endBlock = BigInt(config.endBlock)
|
384
386
|
}
|
385
387
|
|
386
|
-
|
387
|
-
this.blockHandlers = new Proxy(this.blockHandlers, handlersProxy({ chain_id, category: 'interval' }))
|
388
|
-
this.eventHandlers = new Proxy(this.eventHandlers, handlersProxy({ chain_id, category: 'event' }))
|
389
|
-
this.traceHandlers = new Proxy(this.traceHandlers, handlersProxy({ chain_id, category: 'call' }))
|
390
|
-
|
391
|
-
return new Proxy(this, {
|
392
|
-
get: (target, prop, receiver) => {
|
393
|
-
return metricsStorage.run(metricsStorage.getStore() || prop.toString(), () => {
|
394
|
-
const fn = (target as any)[prop]
|
395
|
-
if (typeof fn == 'function') {
|
396
|
-
return AsyncLocalStorage.bind((...args: any) => fn.apply(receiver, args))
|
397
|
-
}
|
398
|
-
return Reflect.get(target, prop, receiver)
|
399
|
-
})
|
400
|
-
}
|
401
|
-
})
|
388
|
+
return proxyProcessor(this)
|
402
389
|
}
|
403
390
|
|
404
391
|
protected abstract CreateBoundContractView(): TBoundContractView
|
@@ -452,6 +439,7 @@ export abstract class BaseProcessor<
|
|
452
439
|
this.eventHandlers.push({
|
453
440
|
filters: _filters,
|
454
441
|
fetchConfig: EthFetchConfig.fromPartial(fetchConfig || {}),
|
442
|
+
handlerName: getHandlerName(),
|
455
443
|
handler: async function (data: Data_EthLog, preparedData?: PreparedData) {
|
456
444
|
const { log, block, transaction, transactionReceipt } = formatEthData(data)
|
457
445
|
if (!log) {
|
@@ -693,6 +681,7 @@ export abstract class BaseProcessor<
|
|
693
681
|
this.traceHandlers.push({
|
694
682
|
signatures,
|
695
683
|
fetchConfig: EthFetchConfig.fromPartial(fetchConfig || {}),
|
684
|
+
handlerName: getHandlerName(),
|
696
685
|
handler: async function (data: Data_EthTrace, preparedData?: PreparedData) {
|
697
686
|
const contractView = processor.CreateBoundContractView()
|
698
687
|
const contractInterface = contractView.rawContract.interface
|
package/src/eth/eth-plugin.ts
CHANGED
@@ -115,6 +115,7 @@ export class EthPlugin extends Plugin {
|
|
115
115
|
contractConfig.traceConfigs.push({
|
116
116
|
signature: signature,
|
117
117
|
handlerId: handlerId,
|
118
|
+
handlerName: traceHandler.handlerName,
|
118
119
|
fetchConfig: traceHandler.fetchConfig
|
119
120
|
})
|
120
121
|
}
|
@@ -127,6 +128,7 @@ export class EthPlugin extends Plugin {
|
|
127
128
|
const handlerId = handlers.eventHandlers.push(eventsHandler.handler) - 1
|
128
129
|
const logConfig: LogHandlerConfig = {
|
129
130
|
handlerId: handlerId,
|
131
|
+
handlerName: eventsHandler.handlerName,
|
130
132
|
filters: [],
|
131
133
|
fetchConfig: eventsHandler.fetchConfig
|
132
134
|
}
|
@@ -205,6 +207,7 @@ export class EthPlugin extends Plugin {
|
|
205
207
|
contractConfig.traceConfigs.push({
|
206
208
|
signature: signature,
|
207
209
|
handlerId: handlerId,
|
210
|
+
handlerName: traceHandler.handlerName,
|
208
211
|
fetchConfig: traceHandler.fetchConfig
|
209
212
|
})
|
210
213
|
}
|
@@ -226,6 +229,7 @@ export class EthPlugin extends Plugin {
|
|
226
229
|
const handlerId = handlers.eventHandlers.push(eventsHandler.handler) - 1
|
227
230
|
const logConfig: LogHandlerConfig = {
|
228
231
|
handlerId: handlerId,
|
232
|
+
handlerName: eventsHandler.handlerName,
|
229
233
|
filters: [],
|
230
234
|
fetchConfig: eventsHandler.fetchConfig
|
231
235
|
}
|
package/src/tsup.config.ts
CHANGED
package/src/utils/metrics.ts
CHANGED
@@ -1,23 +1,20 @@
|
|
1
|
-
import {
|
2
|
-
import {
|
1
|
+
import { AsyncLocalStorage } from 'node:async_hooks'
|
2
|
+
import { metricsStorage } from '@sentio/runtime'
|
3
3
|
|
4
|
-
export function
|
5
|
-
return
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
handler: handlerName
|
16
|
-
})
|
17
|
-
return res
|
4
|
+
export function getHandlerName() {
|
5
|
+
return metricsStorage.getStore() || 'unknown'
|
6
|
+
}
|
7
|
+
|
8
|
+
export function proxyProcessor(cls: any) {
|
9
|
+
return new Proxy(cls, {
|
10
|
+
get: (target, prop, receiver) => {
|
11
|
+
return metricsStorage.run(metricsStorage.getStore() || `${cls.constructor.name}.${prop.toString()}`, () => {
|
12
|
+
const fn = (target as any)[prop]
|
13
|
+
if (typeof fn == 'function') {
|
14
|
+
return AsyncLocalStorage.bind((...args: any) => fn.apply(receiver, args))
|
18
15
|
}
|
19
|
-
|
20
|
-
|
16
|
+
return Reflect.get(target, prop, receiver)
|
17
|
+
})
|
21
18
|
}
|
22
|
-
}
|
19
|
+
})
|
23
20
|
}
|