@sentio/sdk 1.21.0 → 1.21.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/aptos-processor.d.ts +6 -5
- package/lib/aptos/aptos-processor.js.map +1 -1
- package/lib/aptos/index.d.ts +1 -1
- package/lib/aptos/index.js.map +1 -1
- package/lib/aptos-codegen/codegen.js +4 -2
- package/lib/aptos-codegen/codegen.js.map +1 -1
- package/lib/aptos-codegen/typegen.js +3 -2
- package/lib/aptos-codegen/typegen.js.map +1 -1
- package/lib/builtin/aptos/0x1.d.ts +68 -68
- package/lib/builtin/aptos/0x1.js +136 -68
- package/lib/builtin/aptos/0x1.js.map +1 -1
- package/lib/builtin/aptos/0x3.d.ts +13 -13
- package/lib/builtin/aptos/0x3.js +26 -13
- package/lib/builtin/aptos/0x3.js.map +1 -1
- package/lib/gen/processor/protos/processor.d.ts +1 -0
- package/lib/gen/processor/protos/processor.js +18 -1
- package/lib/gen/processor/protos/processor.js.map +1 -1
- package/lib/service.js +2 -1
- package/lib/service.js.map +1 -1
- package/lib/tests/types/aptos/souffle.d.ts +16 -16
- package/lib/tests/types/aptos/souffle.js +32 -16
- package/lib/tests/types/aptos/souffle.js.map +1 -1
- package/package.json +1 -1
- package/src/aptos/aptos-processor.ts +9 -6
- package/src/aptos/index.ts +1 -1
- package/src/aptos-codegen/codegen.ts +6 -2
- package/src/aptos-codegen/typegen.test.ts +12 -0
- package/src/aptos-codegen/typegen.ts +3 -2
- package/src/builtin/aptos/0x1.ts +225 -68
- package/src/builtin/aptos/0x3.ts +39 -13
- package/src/gen/processor/protos/processor.ts +19 -1
- package/src/service.ts +2 -2
- package/src/tests/types/aptos/souffle.ts +48 -16
|
@@ -22,15 +22,18 @@ type IndexConfigure = {
|
|
|
22
22
|
// endSeqNumber?: Long
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
-
|
|
25
|
+
// TODO extends ArgumentsFilter
|
|
26
|
+
export interface EventFilter {
|
|
26
27
|
type: string
|
|
27
28
|
}
|
|
28
29
|
|
|
29
|
-
export interface
|
|
30
|
+
export interface FunctionNameAndCallFilter extends CallFilter {
|
|
30
31
|
function: string
|
|
31
32
|
}
|
|
32
33
|
|
|
33
|
-
|
|
34
|
+
// TODO extends ArgumentsFilter
|
|
35
|
+
export interface CallFilter {
|
|
36
|
+
includeFailed?: boolean
|
|
34
37
|
typeArguments?: string[]
|
|
35
38
|
}
|
|
36
39
|
|
|
@@ -44,7 +47,7 @@ class EventHandler {
|
|
|
44
47
|
}
|
|
45
48
|
|
|
46
49
|
class CallHandler {
|
|
47
|
-
filters:
|
|
50
|
+
filters: FunctionNameAndCallFilter[]
|
|
48
51
|
handler: (call: Transaction_UserTransaction) => Promise<ProcessResult>
|
|
49
52
|
}
|
|
50
53
|
|
|
@@ -124,9 +127,9 @@ export class AptosBaseProcessor {
|
|
|
124
127
|
|
|
125
128
|
public onEntryFunctionCall(
|
|
126
129
|
handler: (call: TransactionPayload_EntryFunctionPayload, ctx: AptosContext) => void,
|
|
127
|
-
filter:
|
|
130
|
+
filter: FunctionNameAndCallFilter | FunctionNameAndCallFilter[]
|
|
128
131
|
): AptosBaseProcessor {
|
|
129
|
-
let _filters:
|
|
132
|
+
let _filters: FunctionNameAndCallFilter[] = []
|
|
130
133
|
|
|
131
134
|
if (Array.isArray(filter)) {
|
|
132
135
|
_filters = filter
|
package/src/aptos/index.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export type { Transaction_UserTransaction, TransactionPayload_EntryFunctionPayload } from 'aptos/src/generated'
|
|
2
2
|
export type { EventInstance, TypedEventInstance, TypeRegistry, TypedEntryFunctionPayload } from './types'
|
|
3
|
-
export type {
|
|
3
|
+
export type { FunctionNameAndCallFilter, EventFilter, CallFilter, ArgumentsFilter } from './aptos-processor'
|
|
4
4
|
export { AptosBaseProcessor } from './aptos-processor'
|
|
5
5
|
export { AptosContext } from './context'
|
|
6
6
|
export { AptosBindOptions, AptosNetwork } from './bind-options'
|
|
@@ -285,8 +285,9 @@ function generateOnEntryFunctions(module: MoveModule, func: MoveFunction) {
|
|
|
285
285
|
|
|
286
286
|
const camelFuncName = capitalizeFirstChar(camelize(func.name))
|
|
287
287
|
const source = `
|
|
288
|
-
onEntry${camelFuncName}${genericString}(func: (call: ${module.name}.${camelFuncName}Payload${genericString}, ctx: aptos.AptosContext) => void): ${module.name} {
|
|
288
|
+
onEntry${camelFuncName}${genericString}(func: (call: ${module.name}.${camelFuncName}Payload${genericString}, ctx: aptos.AptosContext) => void, filter?: aptos.CallFilter): ${module.name} {
|
|
289
289
|
this.onEntryFunctionCall(func, {
|
|
290
|
+
...filter,
|
|
290
291
|
function: '${module.name}::${func.name}'
|
|
291
292
|
})
|
|
292
293
|
return this
|
|
@@ -304,8 +305,11 @@ function generateOnEvents(module: MoveModule, struct: MoveStruct): string {
|
|
|
304
305
|
if (!isEvent(struct)) {
|
|
305
306
|
return ''
|
|
306
307
|
}
|
|
308
|
+
|
|
309
|
+
const genericString = generateStructTypeParameters(struct)
|
|
310
|
+
|
|
307
311
|
const source = `
|
|
308
|
-
onEvent${struct.name}(func: (event: ${module.name}.${struct.name}Instance, ctx: aptos.AptosContext) => void): ${module.name} {
|
|
312
|
+
onEvent${struct.name}${genericString}(func: (event: ${module.name}.${struct.name}Instance${genericString}, ctx: aptos.AptosContext) => void): ${module.name} {
|
|
309
313
|
this.onEvent(func, {
|
|
310
314
|
type: '${module.name}::${struct.name}'
|
|
311
315
|
})
|
|
@@ -17,6 +17,18 @@ describe('type gen', () => {
|
|
|
17
17
|
assert(res.typeArgs.length === 0)
|
|
18
18
|
})
|
|
19
19
|
|
|
20
|
+
test('test depended types', async () => {
|
|
21
|
+
const res = parseMoveType(
|
|
22
|
+
'0x1::table_with_length::TableWithLength<T0, 0xd5f9f2b1c24faee8f07b790e570c75dfa1b7d8c1e9a60162fbd92ade03ea29e4::iterable_table::IterableValue<T0, T1>>'
|
|
23
|
+
)
|
|
24
|
+
|
|
25
|
+
const deps = res.dependedTypes()
|
|
26
|
+
assert(deps.length === 2)
|
|
27
|
+
assert(
|
|
28
|
+
deps[0] === '0xd5f9f2b1c24faee8f07b790e570c75dfa1b7d8c1e9a60162fbd92ade03ea29e4::iterable_table::IterableValue'
|
|
29
|
+
)
|
|
30
|
+
assert(deps[1] === '0x1::table_with_length::TableWithLength')
|
|
31
|
+
})
|
|
20
32
|
// test('type type gen', async () => {
|
|
21
33
|
//
|
|
22
34
|
// const res = parseGenericType('x<g1<a,g2<c,d>>,b,g3<a,b>,e>')
|
|
@@ -63,10 +63,11 @@ function generateSimpleType(type: string): string {
|
|
|
63
63
|
export function parseMoveType(type: string) {
|
|
64
64
|
// type = type.replace('&', '')
|
|
65
65
|
|
|
66
|
-
type = type.
|
|
66
|
+
type = type.replaceAll('&mut ', '&')
|
|
67
|
+
type = type.replaceAll('mut ', '')
|
|
67
68
|
|
|
68
69
|
// TODO replace ' ' is not exactly safe, need to double check this
|
|
69
|
-
type = type.
|
|
70
|
+
type = type.replaceAll(' ', '')
|
|
70
71
|
|
|
71
72
|
const stack: TypeDescriptor[] = [new TypeDescriptor('')]
|
|
72
73
|
let buffer = []
|