@sentio/sdk 1.31.2 → 1.31.4

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/src/service.ts CHANGED
@@ -42,6 +42,10 @@ import {
42
42
  MoveResourcesWithVersionPayload,
43
43
  } from './aptos/aptos-processor'
44
44
  import { AccountProcessorState } from './core/account-processor'
45
+ import { SuiProcessorState } from './core/sui-processor'
46
+ import { SolanaProcessorState } from './core/solana-processor'
47
+ import { ProcessorState } from './binds'
48
+
45
49
  ;(BigInt.prototype as any).toJSON = function () {
46
50
  return this.toString()
47
51
  }
@@ -133,7 +137,7 @@ export class ProcessorServiceImpl implements ProcessorServiceImplementation {
133
137
  }
134
138
 
135
139
  // Part 1.a, prepare EVM processors
136
- for (const processor of global.PROCESSOR_STATE.processors) {
140
+ for (const processor of ProcessorState.INSTANCE.getValues()) {
137
141
  // If server favor incremental update this need to change
138
142
  // Start basic config for contract
139
143
  const chainId = processor.getChainId()
@@ -266,7 +270,7 @@ export class ProcessorServiceImpl implements ProcessorServiceImplementation {
266
270
  }
267
271
 
268
272
  // Part 2, prepare solana constractors
269
- for (const solanaProcessor of global.PROCESSOR_STATE.solanaProcessors) {
273
+ for (const solanaProcessor of SolanaProcessorState.INSTANCE.getValues()) {
270
274
  const contractConfig: ContractConfig = {
271
275
  processorType: USER_PROCESSOR,
272
276
  contract: {
@@ -293,7 +297,7 @@ export class ProcessorServiceImpl implements ProcessorServiceImplementation {
293
297
  }
294
298
 
295
299
  // Part 3, prepare sui constractors
296
- for (const suiProcessor of global.PROCESSOR_STATE.suiProcessors) {
300
+ for (const suiProcessor of SuiProcessorState.INSTANCE.getValues()) {
297
301
  const contractConfig: ContractConfig = {
298
302
  processorType: USER_PROCESSOR,
299
303
  contract: {
@@ -530,12 +534,12 @@ export class ProcessorServiceImpl implements ProcessorServiceImplementation {
530
534
 
531
535
  const result = ProcessResult.fromPartial({})
532
536
 
533
- if (request.chainId.toLowerCase().startsWith('sui') && global.PROCESSOR_STATE.suiProcessors) {
537
+ if (request.chainId.toLowerCase().startsWith('sui') && SuiProcessorState.INSTANCE.getValues()) {
534
538
  const processorPromises: Promise<void>[] = []
535
539
  for (const txn of request.transactions) {
536
540
  processorPromises.push(
537
541
  new Promise((resolve, _) => {
538
- for (const processor of global.PROCESSOR_STATE.suiProcessors) {
542
+ for (const processor of SuiProcessorState.INSTANCE.getValues()) {
539
543
  const res = processor.handleTransaction(
540
544
  JSON.parse(new TextDecoder().decode(txn.raw)),
541
545
  txn.slot ?? Long.fromNumber(0)
@@ -571,7 +575,7 @@ export class ProcessorServiceImpl implements ProcessorServiceImplementation {
571
575
  const result = ProcessResult.fromPartial({})
572
576
 
573
577
  // Only have instruction handlers for solana processors
574
- if (global.PROCESSOR_STATE.solanaProcessors) {
578
+ if (SolanaProcessorState.INSTANCE.getValues()) {
575
579
  const processorPromises: Promise<void>[] = []
576
580
  for (const instruction of request.instructions) {
577
581
  if (!instruction) {
@@ -580,7 +584,7 @@ export class ProcessorServiceImpl implements ProcessorServiceImplementation {
580
584
 
581
585
  processorPromises.push(
582
586
  new Promise((resolve, _) => {
583
- for (const processor of global.PROCESSOR_STATE.solanaProcessors) {
587
+ for (const processor of SolanaProcessorState.INSTANCE.getValues()) {
584
588
  if (processor.address === instruction.programAccountId) {
585
589
  let parsedInstruction: Instruction | null = null
586
590
  if (instruction.parsed) {
@@ -1,32 +1,14 @@
1
- import {
2
- BaseProcessor,
3
- BoundContractView,
4
- ContractView,
5
- BaseProcessorTemplate,
6
- SolanaBaseProcessor,
7
- SuiBaseProcessor,
8
- } from '../core'
1
+ import { BoundContractView, BaseProcessorTemplate } from '../core'
9
2
 
10
3
  import { BaseContract } from 'ethers'
11
4
  import { TemplateInstance } from '../gen'
12
5
 
13
6
  export class ProcessorState {
14
- // from abiName_address_chainId => contract wrapper
15
- contracts = new Map<string, ContractView<BaseContract>>()
16
7
  // all evm processors
17
- processors: BaseProcessor<BaseContract, BoundContractView<BaseContract, any>>[] = []
18
- // from abiName_options to contracts
19
- processorMap = new Map<string, BaseProcessor<any, any>>()
20
- // evm processor templates
21
8
  templates: BaseProcessorTemplate<BaseContract, BoundContractView<BaseContract, any>>[] = []
22
9
  // evm processor template instances spec
23
10
  templatesInstances: TemplateInstance[] = []
24
11
 
25
- solanaProcessors: SolanaBaseProcessor[] = []
26
-
27
- suiProcessors: SuiBaseProcessor[] = []
28
-
29
12
  // TODO move above to state map
30
-
31
13
  stateMap = new Map<string, any>()
32
14
  }