@sentio/sdk 1.19.4 → 1.19.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 +40 -0
- package/lib/aptos/aptos-processor.js +126 -0
- package/lib/aptos/aptos-processor.js.map +1 -0
- package/lib/aptos/bind-options.d.ts +11 -0
- package/lib/aptos/bind-options.js +17 -0
- package/lib/aptos/bind-options.js.map +1 -0
- package/lib/aptos/context.d.ts +12 -0
- package/lib/aptos/context.js +33 -0
- package/lib/aptos/context.js.map +1 -0
- package/lib/aptos/index.d.ts +5 -0
- package/lib/aptos/index.js +11 -0
- package/lib/aptos/index.js.map +1 -0
- package/lib/core/base-processor-template.js.map +1 -1
- package/lib/core/base-processor.d.ts +1 -1
- package/lib/core/base-processor.js.map +1 -1
- package/lib/core/bind-options.d.ts +0 -2
- package/lib/core/bind-options.js +1 -4
- package/lib/core/bind-options.js.map +1 -1
- package/lib/core/context.d.ts +10 -10
- package/lib/core/context.js +65 -11
- package/lib/core/context.js.map +1 -1
- package/lib/core/index.d.ts +1 -2
- package/lib/core/index.js +1 -4
- package/lib/core/index.js.map +1 -1
- package/lib/core/logger.d.ts +1 -1
- package/lib/core/logger.js +5 -5
- package/lib/core/logger.js.map +1 -1
- package/lib/core/metadata.d.ts +1 -1
- package/lib/core/metadata.js +3 -79
- package/lib/core/metadata.js.map +1 -1
- package/lib/core/meter.d.ts +1 -1
- package/lib/core/meter.js +2 -2
- package/lib/core/meter.js.map +1 -1
- package/lib/core/numberish.d.ts +1 -1
- package/lib/core/numberish.js +7 -7
- package/lib/core/numberish.js.map +1 -1
- package/lib/core/numberish.test.js.map +1 -1
- package/lib/core/solana-processor.d.ts +1 -1
- package/lib/core/solana-processor.js.map +1 -1
- package/lib/core/sui-processor.d.ts +1 -1
- package/lib/core/sui-processor.js.map +1 -1
- package/lib/gen/index.d.ts +1 -0
- package/lib/gen/index.js +18 -0
- package/lib/gen/index.js.map +1 -0
- package/lib/index.d.ts +2 -1
- package/lib/index.js +15 -2
- package/lib/index.js.map +1 -1
- package/lib/processor-state.d.ts +2 -1
- package/lib/processor-state.js.map +1 -1
- package/lib/service.d.ts +2 -2
- package/lib/service.js +41 -36
- package/lib/service.js.map +1 -1
- package/lib/testing/metric-utils.d.ts +1 -1
- package/lib/testing/metric-utils.js +2 -2
- package/lib/testing/metric-utils.js.map +1 -1
- package/lib/testing/test-processor-server.d.ts +2 -1
- package/lib/testing/test-processor-server.js +11 -11
- package/lib/testing/test-processor-server.js.map +1 -1
- package/lib/testing/test-provider.js +2 -2
- package/lib/testing/test-provider.js.map +1 -1
- package/lib/tests/aptos.test.js +44 -12
- package/lib/tests/aptos.test.js.map +1 -1
- package/lib/tests/souffl3.js +16 -4
- package/lib/tests/souffl3.js.map +1 -1
- package/lib/utils/chain.d.ts +1 -0
- package/lib/utils/chain.js +3 -1
- package/lib/utils/chain.js.map +1 -1
- package/package.json +3 -5
- package/src/aptos/aptos-processor.ts +156 -0
- package/src/aptos/bind-options.ts +15 -0
- package/src/aptos/context.ts +35 -0
- package/src/aptos/index.ts +8 -0
- package/src/core/base-processor-template.ts +1 -1
- package/src/core/base-processor.ts +1 -1
- package/src/core/bind-options.ts +0 -1
- package/src/core/context.ts +74 -15
- package/src/core/index.ts +2 -2
- package/src/core/logger.ts +1 -1
- package/src/core/metadata.ts +4 -76
- package/src/core/meter.ts +1 -1
- package/src/core/numberish.test.ts +1 -1
- package/src/core/numberish.ts +1 -1
- package/src/core/solana-processor.ts +1 -1
- package/src/core/sui-processor.ts +1 -1
- package/src/gen/index.ts +1 -0
- package/src/index.ts +4 -1
- package/src/processor-state.ts +3 -1
- package/src/service.ts +29 -29
- package/src/testing/metric-utils.ts +2 -2
- package/src/testing/test-processor-server.ts +5 -2
- package/src/testing/test-provider.ts +1 -1
- package/src/tests/aptos.test.ts +47 -11
- package/src/tests/souffl3.ts +30 -12
- package/src/utils/chain.ts +2 -0
- package/lib/core/aptos-processor.d.ts +0 -41
- package/lib/core/aptos-processor.js +0 -125
- package/lib/core/aptos-processor.js.map +0 -1
- package/src/core/aptos-processor.ts +0 -147
|
@@ -1,147 +0,0 @@
|
|
|
1
|
-
import { AptosBindOptions } from './bind-options'
|
|
2
|
-
import { AptosContext } from './context'
|
|
3
|
-
import { ProcessResult } from '..'
|
|
4
|
-
import Long from 'long'
|
|
5
|
-
|
|
6
|
-
type IndexConfigure = {
|
|
7
|
-
startSeqNumber: Long
|
|
8
|
-
endSeqNumber?: Long
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
export interface AptosEventFilter {
|
|
12
|
-
type: string
|
|
13
|
-
}
|
|
14
|
-
export interface AptosCallFilter {
|
|
15
|
-
function: string
|
|
16
|
-
typeArguments: string[] | undefined
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
export class AptosEventHandler {
|
|
20
|
-
filters: AptosEventFilter[]
|
|
21
|
-
handler: (event: any) => Promise<ProcessResult>
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
export class AptosCallHandler {
|
|
25
|
-
filters: AptosCallFilter[]
|
|
26
|
-
handler: (func: any) => Promise<ProcessResult>
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
export class AptosBaseProcessor {
|
|
30
|
-
public transactionHanlder: (transaction: any, ctx: AptosContext) => void
|
|
31
|
-
address: string
|
|
32
|
-
name: string
|
|
33
|
-
config: IndexConfigure = { startSeqNumber: new Long(0) }
|
|
34
|
-
eventHandlers: AptosEventHandler[] = []
|
|
35
|
-
callHandlers: AptosCallHandler[] = []
|
|
36
|
-
|
|
37
|
-
constructor(options: AptosBindOptions) {
|
|
38
|
-
if (options) {
|
|
39
|
-
this.bind(options)
|
|
40
|
-
}
|
|
41
|
-
global.PROCESSOR_STATE.aptosProcessors.push(this)
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
bind(options: AptosBindOptions) {
|
|
45
|
-
this.address = options.address
|
|
46
|
-
this.name = options.name || this.address
|
|
47
|
-
if (options.startBlock) {
|
|
48
|
-
this.startSlot(options.startBlock)
|
|
49
|
-
}
|
|
50
|
-
if (options.endBlock) {
|
|
51
|
-
this.endBlock(options.endBlock)
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
public onTransaction(handler: (transaction: any, ctx: AptosContext) => void) {
|
|
56
|
-
if (!this.isBind()) {
|
|
57
|
-
throw new Error("Processor doesn't bind to an address")
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
this.transactionHanlder = handler
|
|
61
|
-
|
|
62
|
-
return this
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
public onEvent(handler: (event: any, ctx: AptosContext) => void, filter: AptosEventFilter | AptosEventFilter[]) {
|
|
66
|
-
let _filters: AptosEventFilter[] = []
|
|
67
|
-
|
|
68
|
-
if (Array.isArray(filter)) {
|
|
69
|
-
_filters = filter
|
|
70
|
-
} else {
|
|
71
|
-
_filters.push(filter)
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
this.eventHandlers.push({
|
|
75
|
-
handler: async function (event) {
|
|
76
|
-
const ctx = new AptosContext(this.address, event.slot)
|
|
77
|
-
if (event) {
|
|
78
|
-
handler(event, ctx)
|
|
79
|
-
}
|
|
80
|
-
return {
|
|
81
|
-
gauges: ctx.gauges,
|
|
82
|
-
counters: ctx.counters,
|
|
83
|
-
logs: ctx.logs,
|
|
84
|
-
}
|
|
85
|
-
},
|
|
86
|
-
filters: _filters,
|
|
87
|
-
})
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
public onCall(handler: (func: any, ctx: AptosContext) => void, filter: AptosCallFilter | AptosCallFilter[]) {
|
|
91
|
-
let _filters: AptosCallFilter[] = []
|
|
92
|
-
|
|
93
|
-
if (Array.isArray(filter)) {
|
|
94
|
-
_filters = filter
|
|
95
|
-
} else {
|
|
96
|
-
_filters.push(filter)
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
this.callHandlers.push({
|
|
100
|
-
handler: async function (call) {
|
|
101
|
-
const ctx = new AptosContext(this.address, call.slot)
|
|
102
|
-
if (call) {
|
|
103
|
-
handler(call, ctx)
|
|
104
|
-
}
|
|
105
|
-
return {
|
|
106
|
-
gauges: ctx.gauges,
|
|
107
|
-
counters: ctx.counters,
|
|
108
|
-
logs: ctx.logs,
|
|
109
|
-
}
|
|
110
|
-
},
|
|
111
|
-
filters: _filters,
|
|
112
|
-
})
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
public handleTransaction(txn: any, slot: Long): ProcessResult | null {
|
|
116
|
-
const ctx = new AptosContext(this.address, slot)
|
|
117
|
-
|
|
118
|
-
if (txn) {
|
|
119
|
-
this.transactionHanlder(txn, ctx)
|
|
120
|
-
}
|
|
121
|
-
return {
|
|
122
|
-
gauges: ctx.gauges,
|
|
123
|
-
counters: ctx.counters,
|
|
124
|
-
logs: ctx.logs,
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
public isBind() {
|
|
129
|
-
return this.address !== null
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
public startSlot(startSlot: Long | number) {
|
|
133
|
-
if (typeof startSlot === 'number') {
|
|
134
|
-
startSlot = Long.fromNumber(startSlot)
|
|
135
|
-
}
|
|
136
|
-
this.config.startSeqNumber = startSlot
|
|
137
|
-
return this
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
public endBlock(endBlock: Long | number) {
|
|
141
|
-
if (typeof endBlock === 'number') {
|
|
142
|
-
endBlock = Long.fromNumber(endBlock)
|
|
143
|
-
}
|
|
144
|
-
this.config.endSeqNumber = endBlock
|
|
145
|
-
return this
|
|
146
|
-
}
|
|
147
|
-
}
|