@sentio/sdk 2.45.0 → 2.45.1-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.
Files changed (33) hide show
  1. package/lib/aptos/aptos-resource-processor-template.d.ts.map +1 -1
  2. package/lib/aptos/aptos-resource-processor-template.js +2 -1
  3. package/lib/aptos/aptos-resource-processor-template.js.map +1 -1
  4. package/lib/aptos/ext/token-list.d.ts +20 -0
  5. package/lib/aptos/ext/token-list.d.ts.map +1 -0
  6. package/lib/aptos/ext/token-list.js +3099 -0
  7. package/lib/aptos/ext/token-list.js.map +1 -0
  8. package/lib/aptos/ext/token.d.ts +1 -1
  9. package/lib/aptos/ext/token.d.ts.map +1 -1
  10. package/lib/aptos/ext/token.js +1 -1
  11. package/lib/aptos/ext/token.js.map +1 -1
  12. package/lib/eth/base-processor-template.d.ts.map +1 -1
  13. package/lib/eth/base-processor-template.js +2 -1
  14. package/lib/eth/base-processor-template.js.map +1 -1
  15. package/lib/eth/base-processor.d.ts.map +1 -1
  16. package/lib/eth/base-processor.js +16 -0
  17. package/lib/eth/base-processor.js.map +1 -1
  18. package/lib/eth/base-processor.test.d.ts +2 -0
  19. package/lib/eth/base-processor.test.d.ts.map +1 -0
  20. package/lib/eth/base-processor.test.js.map +1 -0
  21. package/lib/utils/metrics.d.ts +4 -0
  22. package/lib/utils/metrics.d.ts.map +1 -0
  23. package/lib/utils/metrics.js +21 -0
  24. package/lib/utils/metrics.js.map +1 -0
  25. package/package.json +3 -3
  26. package/src/aptos/aptos-resource-processor-template.ts +2 -1
  27. package/src/aptos/ext/token-list.ts +3131 -0
  28. package/src/aptos/ext/token.ts +3 -22
  29. package/src/eth/base-processor-template.ts +2 -1
  30. package/src/eth/base-processor.ts +18 -0
  31. package/src/utils/metrics.ts +22 -0
  32. package/lib/aptos/ext/token-list.json +0 -3098
  33. package/src/aptos/ext/token-list.json +0 -3098
@@ -5,28 +5,9 @@ import { AptosNetwork, getClient } from '../network.js'
5
5
  import { coin } from '../builtin/0x1.js'
6
6
  import { MoveStructId } from '@aptos-labs/ts-sdk'
7
7
  import { AptosChainId } from '@sentio/chain'
8
- import DEFAULT_TOKEN_LIST from './token-list.json' assert { type: 'json' }
8
+ import { DEFAULT_TOKEN_LIST, InternalTokenInfo } from './token-list.js'
9
9
  import { BaseCoinInfo } from '../../move/ext/index.js'
10
10
 
11
- type InternalTokenInfo = {
12
- chainId: number
13
- tokenAddress: `0x${string}` | null
14
- faAddress: `0x${string}` | null
15
- name: string
16
- symbol: string
17
- decimals: number
18
- bridge: 'LayerZero' | 'Wormhole' | 'Celer' | null
19
- panoraSymbol: string
20
- logoUrl: string | null
21
- websiteUrl: string | null
22
- category: 'Native' | 'Bridged' | 'Meme'
23
- isInPanoraTokenList: boolean
24
- isBanned: boolean
25
- panoraOrderIndex: number | null
26
- coinGeckoId: string | null
27
- coinMarketCapId: number | null
28
- }
29
-
30
11
  export interface TokenInfo extends BaseCoinInfo {
31
12
  type: `0x${string}` // either tokenAddress or faAddress
32
13
  tokenAddress?: `0x${string}`
@@ -34,7 +15,7 @@ export interface TokenInfo extends BaseCoinInfo {
34
15
  name: string
35
16
  symbol: string
36
17
  decimals: number
37
- bridge: 'LayerZero' | 'Wormhole' | 'Celer' | 'Native'
18
+ bridge: 'LayerZero' | 'Wormhole' | 'Celer' | 'Echo' | 'Native'
38
19
  logoUrl?: string
39
20
  websiteUrl?: string
40
21
  category: 'Native' | 'Bridged' | 'Meme'
@@ -45,7 +26,7 @@ export interface TokenInfo extends BaseCoinInfo {
45
26
  const TOKEN_MAP = new Map<string, TokenInfo>()
46
27
 
47
28
  export async function initTokenList() {
48
- let list = DEFAULT_TOKEN_LIST as InternalTokenInfo[]
29
+ let list = DEFAULT_TOKEN_LIST
49
30
  try {
50
31
  const resp = await fetch(
51
32
  'https://raw.githubusercontent.com/PanoraExchange/Aptos-Tokens/refs/heads/main/token-list.json'
@@ -4,7 +4,7 @@ import { BaseProcessor, defaultPreprocessHandler } from './base-processor.js'
4
4
  import { BindOptions, getOptionsSignature } from './bind-options.js'
5
5
  import { EthFetchConfig, HandleInterval, TemplateInstance, PreprocessResult } from '@sentio/protos'
6
6
  import { PromiseOrVoid } from '../core/promises.js'
7
- import { ListStateStorage } from '@sentio/runtime'
7
+ import { ListStateStorage, processMetrics } from '@sentio/runtime'
8
8
  import { BlockParams } from 'ethers/providers'
9
9
  import { DeferredTopicFilter } from 'ethers/contract'
10
10
  import { TypedEvent, TypedCallTrace } from './eth.js'
@@ -57,6 +57,7 @@ export abstract class BaseProcessorTemplate<
57
57
  constructor() {
58
58
  this.id = ProcessorTemplateProcessorState.INSTANCE.getValues().length
59
59
  ProcessorTemplateProcessorState.INSTANCE.addValue(this)
60
+ processMetrics.process_template_count.add(1)
60
61
  }
61
62
 
62
63
  /**
@@ -1,3 +1,4 @@
1
+ import { AsyncLocalStorage } from 'node:async_hooks'
1
2
  import { BaseContract, DeferredTopicFilter, LogDescription, TransactionResponseParams } from 'ethers'
2
3
 
3
4
  import { BoundContractView, ContractContext, ContractView, GlobalContext } from './context.js'
@@ -20,6 +21,7 @@ import { fixEmptyKey, formatEthData, RichBlock, Trace, TypedCallTrace, TypedEven
20
21
  import sha3 from 'js-sha3'
21
22
  import { ListStateStorage } from '@sentio/runtime'
22
23
  import { EthChainId } from '@sentio/chain'
24
+ import { metricsStorage, handlersProxy } from '../utils/metrics.js'
23
25
 
24
26
  export interface AddressOrTypeEventFilter extends DeferredTopicFilter {
25
27
  addressType?: AddressType
@@ -379,6 +381,22 @@ export abstract class BaseProcessor<
379
381
  if (config.endBlock) {
380
382
  this.config.endBlock = BigInt(config.endBlock)
381
383
  }
384
+
385
+ this.blockHandlers = new Proxy(this.blockHandlers, handlersProxy())
386
+ this.eventHandlers = new Proxy(this.eventHandlers, handlersProxy())
387
+ this.traceHandlers = new Proxy(this.traceHandlers, handlersProxy())
388
+
389
+ return new Proxy(this, {
390
+ get: (target, prop, receiver) => {
391
+ return metricsStorage.run(metricsStorage.getStore() || prop.toString(), () => {
392
+ const fn = (target as any)[prop]
393
+ if (typeof fn == 'function') {
394
+ return AsyncLocalStorage.bind((...args: any) => fn.apply(receiver, args))
395
+ }
396
+ return Reflect.get(target, prop, receiver)
397
+ })
398
+ }
399
+ })
382
400
  }
383
401
 
384
402
  protected abstract CreateBoundContractView(): TBoundContractView
@@ -0,0 +1,22 @@
1
+ import { AsyncLocalStorage } from 'node:async_hooks'
2
+ import { processMetrics } from '@sentio/runtime'
3
+
4
+ export const metricsStorage = new AsyncLocalStorage<string>()
5
+
6
+ export function handlersProxy<T extends object>(): ProxyHandler<T> {
7
+ return {
8
+ set: (target, prop, value, receiver) => {
9
+ if (value.handler) {
10
+ const handlerName = metricsStorage.getStore()
11
+ const handler = value.handler
12
+ value.handler = async (...args: any) => {
13
+ const startTs = Date.now()
14
+ const res = await handler(...args)
15
+ processMetrics.process_handler_duration.record(Date.now() - startTs, { handler: handlerName })
16
+ return res
17
+ }
18
+ }
19
+ return Reflect.set(target, prop, value, receiver)
20
+ }
21
+ }
22
+ }