@sentio/sdk 1.36.0-rc.3 → 1.36.0-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 +2 -2
- package/lib/aptos/aptos-processor.js +1 -1
- package/lib/aptos/aptos-processor.js.map +1 -1
- package/lib/aptos/context.d.ts +2 -2
- package/lib/aptos/context.js.map +1 -1
- package/lib/core/numberish.d.ts +2 -0
- package/lib/core/numberish.js +5 -1
- package/lib/core/numberish.js.map +1 -1
- package/lib/core/solana-processor.d.ts +0 -1
- package/lib/core/solana-processor.js +0 -4
- package/lib/core/solana-processor.js.map +1 -1
- package/lib/gen/google/protobuf/struct.d.ts +73 -0
- package/lib/gen/google/protobuf/struct.js +371 -0
- package/lib/gen/google/protobuf/struct.js.map +1 -0
- package/lib/gen/processor/protos/processor.d.ts +13 -5
- package/lib/gen/processor/protos/processor.js +43 -39
- package/lib/gen/processor/protos/processor.js.map +1 -1
- package/lib/service.js +38 -13
- package/lib/service.js.map +1 -1
- package/package.json +3 -1
- package/src/aptos/aptos-processor.ts +4 -4
- package/src/aptos/context.ts +2 -2
- package/src/core/numberish.ts +5 -0
- package/src/core/solana-processor.ts +0 -5
- package/src/gen/google/protobuf/struct.ts +422 -0
- package/src/gen/processor/protos/processor.ts +47 -44
- package/src/service.ts +48 -13
package/src/service.ts
CHANGED
|
@@ -27,7 +27,6 @@ import {
|
|
|
27
27
|
|
|
28
28
|
import { Empty } from './gen/google/protobuf/empty'
|
|
29
29
|
import Long from 'long'
|
|
30
|
-
import { TextDecoder } from 'util'
|
|
31
30
|
import { Trace } from './core'
|
|
32
31
|
import { Instruction as SolInstruction } from '@project-serum/anchor'
|
|
33
32
|
import { MetricState } from './core/meter'
|
|
@@ -43,6 +42,12 @@ import { SuiProcessorState } from './core/sui-processor'
|
|
|
43
42
|
import { SolanaProcessorState } from './core/solana-processor'
|
|
44
43
|
import { ProcessorState } from './binds'
|
|
45
44
|
import { ProcessorTemplateProcessorState, TemplateInstanceState } from './core/base-processor-template'
|
|
45
|
+
import { toBigInt } from './core/numberish'
|
|
46
|
+
import { MoveResource, Transaction_UserTransaction } from 'aptos-sdk/src/generated'
|
|
47
|
+
|
|
48
|
+
// (Long.prototype as any).toBigInt = function() {
|
|
49
|
+
// return BigInt(this.toString())
|
|
50
|
+
// };
|
|
46
51
|
;(BigInt.prototype as any).toJSON = function () {
|
|
47
52
|
return this.toString()
|
|
48
53
|
}
|
|
@@ -541,8 +546,7 @@ export class ProcessorServiceImpl implements ProcessorServiceImplementation {
|
|
|
541
546
|
if (processor.address === instruction.programAccountId) {
|
|
542
547
|
let parsedInstruction: SolInstruction | null = null
|
|
543
548
|
if (instruction.parsed) {
|
|
544
|
-
|
|
545
|
-
parsedInstruction = processor.getParsedInstruction(a1)
|
|
549
|
+
parsedInstruction = processor.getParsedInstruction(instruction.parsed as { type: string; info: any })
|
|
546
550
|
} else if (instruction.instructionData) {
|
|
547
551
|
parsedInstruction = processor.getParsedInstruction(instruction.instructionData)
|
|
548
552
|
}
|
|
@@ -610,14 +614,22 @@ export class ProcessorServiceImpl implements ProcessorServiceImplementation {
|
|
|
610
614
|
throw new ServerError(Status.INVALID_ARGUMENT, "Event can't be empty")
|
|
611
615
|
}
|
|
612
616
|
const promises: Promise<ProcessResult>[] = []
|
|
613
|
-
|
|
614
|
-
|
|
617
|
+
let event: Transaction_UserTransaction
|
|
618
|
+
if (binding.data.aptEvent) {
|
|
619
|
+
event = binding.data.aptEvent?.event as Transaction_UserTransaction
|
|
620
|
+
} else {
|
|
621
|
+
const jsonString = Utf8ArrayToStr(binding.data.raw)
|
|
622
|
+
event = JSON.parse(jsonString)
|
|
623
|
+
}
|
|
615
624
|
|
|
616
625
|
for (const handlerId of binding.handlerIds) {
|
|
617
626
|
// only support aptos event for now
|
|
618
627
|
promises.push(
|
|
619
628
|
this.aptosEventHandlers[handlerId](event).catch((e) => {
|
|
620
|
-
throw new ServerError(
|
|
629
|
+
throw new ServerError(
|
|
630
|
+
Status.INTERNAL,
|
|
631
|
+
'error processing event: ' + JSON.stringify(event) + '\n' + errorString(e)
|
|
632
|
+
)
|
|
621
633
|
})
|
|
622
634
|
)
|
|
623
635
|
}
|
|
@@ -628,13 +640,31 @@ export class ProcessorServiceImpl implements ProcessorServiceImplementation {
|
|
|
628
640
|
if (!binding.data) {
|
|
629
641
|
throw new ServerError(Status.INVALID_ARGUMENT, "Event can't be empty")
|
|
630
642
|
}
|
|
631
|
-
|
|
632
|
-
const
|
|
643
|
+
|
|
644
|
+
const resource: MoveResourcesWithVersionPayload = {
|
|
645
|
+
resources: [],
|
|
646
|
+
version: 0n,
|
|
647
|
+
timestamp: 0n,
|
|
648
|
+
}
|
|
649
|
+
if (binding.data.aptResource?.resources) {
|
|
650
|
+
resource.timestamp = toBigInt(binding.data.aptResource.timestampMicros)
|
|
651
|
+
resource.version = toBigInt(binding.data.aptResource.version)
|
|
652
|
+
resource.resources = binding.data.aptResource.resources as MoveResource[]
|
|
653
|
+
} else {
|
|
654
|
+
const jsonString = Utf8ArrayToStr(binding.data.raw)
|
|
655
|
+
const json = JSON.parse(jsonString)
|
|
656
|
+
resource.timestamp = toBigInt(json.timestamp)
|
|
657
|
+
resource.version = toBigInt(json.version)
|
|
658
|
+
}
|
|
659
|
+
|
|
633
660
|
const promises: Promise<ProcessResult>[] = []
|
|
634
661
|
for (const handlerId of binding.handlerIds) {
|
|
635
662
|
promises.push(
|
|
636
|
-
this.aptosResourceHandlers[handlerId](
|
|
637
|
-
throw new ServerError(
|
|
663
|
+
this.aptosResourceHandlers[handlerId](resource).catch((e) => {
|
|
664
|
+
throw new ServerError(
|
|
665
|
+
Status.INTERNAL,
|
|
666
|
+
'error processing event: ' + JSON.stringify(resource) + '\n' + errorString(e)
|
|
667
|
+
)
|
|
638
668
|
})
|
|
639
669
|
)
|
|
640
670
|
}
|
|
@@ -645,14 +675,19 @@ export class ProcessorServiceImpl implements ProcessorServiceImplementation {
|
|
|
645
675
|
if (!binding.data) {
|
|
646
676
|
throw new ServerError(Status.INVALID_ARGUMENT, "Event can't be empty")
|
|
647
677
|
}
|
|
648
|
-
|
|
649
|
-
|
|
678
|
+
let call: Transaction_UserTransaction
|
|
679
|
+
if (binding.data.aptCall?.call) {
|
|
680
|
+
call = binding.data.aptCall?.call as Transaction_UserTransaction
|
|
681
|
+
} else {
|
|
682
|
+
const jsonString = Utf8ArrayToStr(binding.data.raw)
|
|
683
|
+
call = JSON.parse(jsonString)
|
|
684
|
+
}
|
|
650
685
|
|
|
651
686
|
const promises: Promise<ProcessResult>[] = []
|
|
652
687
|
for (const handlerId of binding.handlerIds) {
|
|
653
688
|
// only support aptos call for now
|
|
654
689
|
const promise = this.aptosCallHandlers[handlerId](call).catch((e) => {
|
|
655
|
-
throw new ServerError(Status.INTERNAL, 'error processing call: ' +
|
|
690
|
+
throw new ServerError(Status.INTERNAL, 'error processing call: ' + JSON.stringify(call) + '\n' + errorString(e))
|
|
656
691
|
})
|
|
657
692
|
promises.push(promise)
|
|
658
693
|
}
|