@sentio/sdk 2.59.0-rc.22 → 2.59.0-rc.24
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-plugin.d.ts +5 -2
- package/lib/aptos/aptos-plugin.d.ts.map +1 -1
- package/lib/aptos/aptos-plugin.js +41 -2
- package/lib/aptos/aptos-plugin.js.map +1 -1
- package/lib/aptos/aptos-processor.d.ts +6 -5
- package/lib/aptos/aptos-processor.d.ts.map +1 -1
- package/lib/aptos/aptos-processor.js +18 -12
- package/lib/aptos/aptos-processor.js.map +1 -1
- package/lib/aptos/builtin/0x1.d.ts +159 -159
- package/lib/aptos/builtin/0x1.d.ts.map +1 -1
- package/lib/aptos/builtin/0x1.js +316 -316
- package/lib/aptos/builtin/0x1.js.map +1 -1
- package/lib/aptos/builtin/0x3.d.ts +52 -52
- package/lib/aptos/builtin/0x3.d.ts.map +1 -1
- package/lib/aptos/builtin/0x3.js +102 -102
- package/lib/aptos/builtin/0x3.js.map +1 -1
- package/lib/aptos/builtin/0x4.d.ts +12 -12
- package/lib/aptos/builtin/0x4.d.ts.map +1 -1
- package/lib/aptos/builtin/0x4.js +22 -22
- package/lib/aptos/builtin/0x4.js.map +1 -1
- package/lib/aptos/codegen/codegen.js +10 -0
- package/lib/aptos/codegen/codegen.js.map +1 -1
- package/lib/aptos/data.d.ts +20 -0
- package/lib/aptos/data.d.ts.map +1 -0
- package/lib/aptos/data.js +38 -0
- package/lib/aptos/data.js.map +1 -0
- package/lib/aptos/index.d.ts +1 -0
- package/lib/aptos/index.d.ts.map +1 -1
- package/lib/aptos/index.js.map +1 -1
- package/lib/aptos/models.d.ts +5 -0
- package/lib/aptos/models.d.ts.map +1 -1
- package/lib/eth/base-processor.d.ts +6 -2
- package/lib/eth/base-processor.d.ts.map +1 -1
- package/lib/eth/base-processor.js +5 -1
- package/lib/eth/base-processor.js.map +1 -1
- package/lib/move/filter.d.ts +1 -0
- package/lib/move/filter.d.ts.map +1 -1
- package/lib/move/filter.js +1 -0
- package/lib/move/filter.js.map +1 -1
- package/lib/move/shared-network-codegen.d.ts.map +1 -1
- package/lib/move/shared-network-codegen.js +1 -0
- package/lib/move/shared-network-codegen.js.map +1 -1
- package/lib/sui/builtin/0x1.d.ts.map +1 -1
- package/lib/sui/builtin/0x1.js.map +1 -1
- package/lib/sui/builtin/0x2.d.ts.map +1 -1
- package/lib/sui/builtin/0x2.js.map +1 -1
- package/lib/sui/builtin/0x3.d.ts.map +1 -1
- package/lib/sui/builtin/0x3.js.map +1 -1
- package/lib/sui/models.d.ts +5 -0
- package/lib/sui/models.d.ts.map +1 -1
- package/package.json +3 -3
- package/src/aptos/aptos-plugin.ts +50 -3
- package/src/aptos/aptos-processor.ts +22 -24
- package/src/aptos/builtin/0x1.ts +317 -316
- package/src/aptos/builtin/0x3.ts +103 -102
- package/src/aptos/builtin/0x4.ts +23 -22
- package/src/aptos/codegen/codegen.ts +13 -1
- package/src/aptos/data.ts +48 -0
- package/src/aptos/index.ts +2 -0
- package/src/aptos/models.ts +7 -0
- package/src/eth/base-processor.ts +7 -2
- package/src/move/filter.ts +1 -0
- package/src/move/shared-network-codegen.ts +1 -0
- package/src/sui/builtin/0x1.ts +1 -0
- package/src/sui/builtin/0x2.ts +1 -0
- package/src/sui/builtin/0x3.ts +1 -0
- package/src/sui/models.ts +7 -0
package/lib/sui/models.d.ts
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
import type { SuiEvent, MoveCallSuiTransaction, SuiMoveObject } from '@mysten/sui/client';
|
2
2
|
import { DecodedStruct } from '@typemove/move';
|
3
|
+
import { MoveFetchConfig } from '@sentio/protos';
|
3
4
|
export type TypedEventInstance<T> = DecodedStruct<SuiEvent, T>;
|
4
5
|
export type TypedSuiMoveObject<T> = DecodedStruct<SuiMoveObject, T>;
|
5
6
|
export type TypedFunctionPayload<T extends Array<any>> = MoveCallSuiTransaction & {
|
@@ -8,4 +9,8 @@ export type TypedFunctionPayload<T extends Array<any>> = MoveCallSuiTransaction
|
|
8
9
|
*/
|
9
10
|
arguments_decoded: T;
|
10
11
|
};
|
12
|
+
export type PartitionHandler<D> = (data: D) => string | Promise<string>;
|
13
|
+
export type HandlerOptions<D> = Partial<MoveFetchConfig> & {
|
14
|
+
partitionKey?: string | PartitionHandler<D>;
|
15
|
+
};
|
11
16
|
//# sourceMappingURL=models.d.ts.map
|
package/lib/sui/models.d.ts.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"models.d.ts","sourceRoot":"","sources":["../../src/sui/models.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,sBAAsB,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AACzF,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAA;
|
1
|
+
{"version":3,"file":"models.d.ts","sourceRoot":"","sources":["../../src/sui/models.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,sBAAsB,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AACzF,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAA;AAC9C,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAA;AAEhD,MAAM,MAAM,kBAAkB,CAAC,CAAC,IAAI,aAAa,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAA;AAC9D,MAAM,MAAM,kBAAkB,CAAC,CAAC,IAAI,aAAa,CAAC,aAAa,EAAE,CAAC,CAAC,CAAA;AAEnE,MAAM,MAAM,oBAAoB,CAAC,CAAC,SAAS,KAAK,CAAC,GAAG,CAAC,IAAI,sBAAsB,GAAG;IAChF;;OAEG;IACH,iBAAiB,EAAE,CAAC,CAAA;CACrB,CAAA;AAED,MAAM,MAAM,gBAAgB,CAAC,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,KAAK,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAA;AAEvE,MAAM,MAAM,cAAc,CAAC,CAAC,IAAI,OAAO,CAAC,eAAe,CAAC,GAAG;IACzD,YAAY,CAAC,EAAE,MAAM,GAAG,gBAAgB,CAAC,CAAC,CAAC,CAAA;CAC5C,CAAA"}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@sentio/sdk",
|
3
|
-
"version": "2.59.0-rc.
|
3
|
+
"version": "2.59.0-rc.24",
|
4
4
|
"license": "Apache-2.0",
|
5
5
|
"type": "module",
|
6
6
|
"exports": {
|
@@ -88,8 +88,8 @@
|
|
88
88
|
"typechain": "^8.3.2",
|
89
89
|
"utility-types": "^3.11.0",
|
90
90
|
"yaml": "^2.3.4",
|
91
|
-
"@sentio/protos": "2.59.0-rc.
|
92
|
-
"@sentio/runtime": "^2.59.0-rc.
|
91
|
+
"@sentio/protos": "2.59.0-rc.24",
|
92
|
+
"@sentio/runtime": "^2.59.0-rc.24"
|
93
93
|
},
|
94
94
|
"peerDependencies": {
|
95
95
|
"@sentio/tsup": "^8.3.5-rc.1"
|
@@ -3,7 +3,6 @@ import {
|
|
3
3
|
AccountConfig,
|
4
4
|
ContractConfig,
|
5
5
|
Data_AptCall,
|
6
|
-
Data_AptEvent,
|
7
6
|
Data_AptResource,
|
8
7
|
DataBinding,
|
9
8
|
HandlerType,
|
@@ -12,6 +11,9 @@ import {
|
|
12
11
|
MoveOwnerType,
|
13
12
|
ProcessConfigResponse,
|
14
13
|
ProcessResult,
|
14
|
+
ProcessStreamResponse_Partitions,
|
15
|
+
ProcessStreamResponse_Partitions_Partition,
|
16
|
+
ProcessStreamResponse_Partitions_Partition_SysValue,
|
15
17
|
StartRequest
|
16
18
|
} from '@sentio/protos'
|
17
19
|
|
@@ -27,13 +29,15 @@ import {
|
|
27
29
|
AptosResourceProcessorTemplateState
|
28
30
|
} from './aptos-resource-processor-template.js'
|
29
31
|
import { AptosNetwork } from './network.js'
|
32
|
+
import { AptEvent } from './data.js'
|
30
33
|
|
31
34
|
interface Handlers {
|
32
|
-
aptosEventHandlers: ((event:
|
35
|
+
aptosEventHandlers: ((event: AptEvent) => Promise<ProcessResult>)[]
|
33
36
|
aptosCallHandlers: ((func: Data_AptCall) => Promise<ProcessResult>)[]
|
34
37
|
aptosResourceHandlers: ((resourceWithVersion: Data_AptResource) => Promise<ProcessResult>)[]
|
35
38
|
aptosTransactionIntervalHandlers: ((txn: Data_AptCall) => Promise<ProcessResult>)[]
|
36
39
|
}
|
40
|
+
|
37
41
|
export class AptosPlugin extends Plugin {
|
38
42
|
name: string = 'AptosPlugin'
|
39
43
|
handlers: Handlers = {
|
@@ -43,6 +47,8 @@ export class AptosPlugin extends Plugin {
|
|
43
47
|
aptosTransactionIntervalHandlers: []
|
44
48
|
}
|
45
49
|
|
50
|
+
partitionHandlers: Record<number, (request: AptEvent) => Promise<string | undefined>> = {}
|
51
|
+
|
46
52
|
async start(request: StartRequest) {
|
47
53
|
await initTokenList()
|
48
54
|
|
@@ -90,6 +96,9 @@ export class AptosPlugin extends Plugin {
|
|
90
96
|
// 1. Prepare event handlers
|
91
97
|
for (const handler of aptosProcessor.eventHandlers) {
|
92
98
|
const handlerId = handlers.aptosEventHandlers.push(handler.handler) - 1
|
99
|
+
if (handler.partitionHandler) {
|
100
|
+
this.partitionHandlers[handlerId] = handler.partitionHandler
|
101
|
+
}
|
93
102
|
const eventHandlerConfig: MoveEventHandlerConfig = {
|
94
103
|
filters: handler.filters.map((f) => {
|
95
104
|
return {
|
@@ -225,12 +234,50 @@ export class AptosPlugin extends Plugin {
|
|
225
234
|
}
|
226
235
|
}
|
227
236
|
|
237
|
+
async partition(request: DataBinding): Promise<ProcessStreamResponse_Partitions> {
|
238
|
+
switch (request.handlerType) {
|
239
|
+
case HandlerType.APT_EVENT:
|
240
|
+
const result: Record<number, ProcessStreamResponse_Partitions_Partition> = {}
|
241
|
+
for (const handlerId of request.handlerIds) {
|
242
|
+
const partitionHandler = this.partitionHandlers[handlerId]
|
243
|
+
if (partitionHandler && request.data?.aptEvent) {
|
244
|
+
const partitionValue = await partitionHandler(new AptEvent(request.data.aptEvent))
|
245
|
+
result[handlerId] = {
|
246
|
+
userValue: partitionValue
|
247
|
+
}
|
248
|
+
} else {
|
249
|
+
result[handlerId] = {
|
250
|
+
sysValue: ProcessStreamResponse_Partitions_Partition_SysValue.UNRECOGNIZED
|
251
|
+
}
|
252
|
+
}
|
253
|
+
}
|
254
|
+
return {
|
255
|
+
partitions: result
|
256
|
+
}
|
257
|
+
|
258
|
+
case HandlerType.APT_RESOURCE:
|
259
|
+
case HandlerType.APT_CALL:
|
260
|
+
throw new ServerError(Status.INTERNAL, 'not implemented')
|
261
|
+
}
|
262
|
+
return {
|
263
|
+
partitions: request.handlerIds.reduce(
|
264
|
+
(acc, id) => ({
|
265
|
+
...acc,
|
266
|
+
[id]: {
|
267
|
+
sysValue: ProcessStreamResponse_Partitions_Partition_SysValue.UNRECOGNIZED
|
268
|
+
}
|
269
|
+
}),
|
270
|
+
{}
|
271
|
+
)
|
272
|
+
}
|
273
|
+
}
|
274
|
+
|
228
275
|
async processAptosEvent(binding: DataBinding): Promise<ProcessResult> {
|
229
276
|
if (!binding.data?.aptEvent) {
|
230
277
|
throw new ServerError(Status.INVALID_ARGUMENT, "Event can't be empty")
|
231
278
|
}
|
232
279
|
const promises: Promise<ProcessResult>[] = []
|
233
|
-
const event = binding.data.aptEvent
|
280
|
+
const event = new AptEvent(binding.data.aptEvent)
|
234
281
|
|
235
282
|
for (const handlerId of binding.handlerIds) {
|
236
283
|
const promise = this.handlers.aptosEventHandlers[handlerId](event).catch((e) => {
|
@@ -12,14 +12,7 @@ import {
|
|
12
12
|
import { AptosBindOptions, AptosNetwork } from './network.js'
|
13
13
|
import { AptosContext, AptosResourcesContext, AptosTransactionContext } from './context.js'
|
14
14
|
import { ListStateStorage } from '@sentio/runtime'
|
15
|
-
import {
|
16
|
-
MoveFetchConfig,
|
17
|
-
Data_AptResource,
|
18
|
-
HandleInterval,
|
19
|
-
Data_AptEvent,
|
20
|
-
Data_AptCall,
|
21
|
-
MoveAccountFetchConfig
|
22
|
-
} from '@sentio/protos'
|
15
|
+
import { MoveFetchConfig, Data_AptResource, HandleInterval, Data_AptCall, MoveAccountFetchConfig } from '@sentio/protos'
|
23
16
|
import { ServerError, Status } from 'nice-grpc'
|
24
17
|
import {
|
25
18
|
accountTypeString,
|
@@ -35,8 +28,9 @@ import {
|
|
35
28
|
import { ALL_ADDRESS, Labels, PromiseOrVoid } from '../core/index.js'
|
36
29
|
import { TypeDescriptor, matchType, NestedDecodedStruct } from '@typemove/move'
|
37
30
|
import { decodeResourceChange, ResourceChange } from '@typemove/aptos'
|
38
|
-
import { GeneralTransactionResponse } from './models.js'
|
31
|
+
import { GeneralTransactionResponse, HandlerOptions } from './models.js'
|
39
32
|
import { getHandlerName, proxyProcessor } from '../utils/metrics.js'
|
33
|
+
import { AptEvent } from './data.js'
|
40
34
|
|
41
35
|
const DEFAULT_FETCH_CONFIG: MoveFetchConfig = {
|
42
36
|
resourceChanges: false,
|
@@ -66,7 +60,7 @@ export class AptosProcessorState extends ListStateStorage<AptosTransactionProces
|
|
66
60
|
export class AptosTransactionProcessor<T extends GeneralTransactionResponse, CT extends AptosTransactionContext<T>> {
|
67
61
|
readonly moduleName: string
|
68
62
|
config: IndexConfigure
|
69
|
-
eventHandlers: EventHandler<
|
63
|
+
eventHandlers: EventHandler<AptEvent>[] = []
|
70
64
|
callHandlers: CallHandler<Data_AptCall>[] = []
|
71
65
|
resourceChangeHandlers: ResourceChangeHandler<Data_AptResource>[] = []
|
72
66
|
transactionIntervalHandlers: TransactionIntervalHandler[] = []
|
@@ -85,10 +79,10 @@ export class AptosTransactionProcessor<T extends GeneralTransactionResponse, CT
|
|
85
79
|
protected onMoveEvent(
|
86
80
|
handler: (event: Event, ctx: AptosContext) => PromiseOrVoid,
|
87
81
|
filter: EventFilter | EventFilter[],
|
88
|
-
|
82
|
+
handlerOptions?: HandlerOptions<Event>
|
89
83
|
): this {
|
90
84
|
let _filters: EventFilter[] = []
|
91
|
-
const _fetchConfig = MoveFetchConfig.fromPartial({ ...DEFAULT_FETCH_CONFIG, ...
|
85
|
+
const _fetchConfig = MoveFetchConfig.fromPartial({ ...DEFAULT_FETCH_CONFIG, ...handlerOptions })
|
92
86
|
|
93
87
|
if (Array.isArray(filter)) {
|
94
88
|
_filters = filter
|
@@ -106,12 +100,7 @@ export class AptosTransactionProcessor<T extends GeneralTransactionResponse, CT
|
|
106
100
|
if (!data.rawTransaction) {
|
107
101
|
throw new ServerError(Status.INVALID_ARGUMENT, 'event is null')
|
108
102
|
}
|
109
|
-
const txn =
|
110
|
-
if (txn.events == null) {
|
111
|
-
txn.events = []
|
112
|
-
}
|
113
|
-
|
114
|
-
const evt = JSON.parse(data.rawEvent)
|
103
|
+
const txn = data.transaction
|
115
104
|
|
116
105
|
const ctx = new AptosContext(
|
117
106
|
processor.moduleName,
|
@@ -123,13 +112,21 @@ export class AptosTransactionProcessor<T extends GeneralTransactionResponse, CT
|
|
123
112
|
processor.config.baseLabels
|
124
113
|
)
|
125
114
|
|
126
|
-
const decoded = await processor.coder
|
127
|
-
await handler(decoded ||
|
128
|
-
|
115
|
+
const decoded = await data.decodeEvent(processor.coder)
|
116
|
+
await handler(decoded || data.event, ctx)
|
129
117
|
return ctx.stopAndGetResult()
|
130
118
|
},
|
131
119
|
filters: _filters,
|
132
|
-
fetchConfig: _fetchConfig
|
120
|
+
fetchConfig: _fetchConfig,
|
121
|
+
partitionHandler: async (data: AptEvent): Promise<string | undefined> => {
|
122
|
+
const p = handlerOptions?.partitionKey
|
123
|
+
if (!p) return undefined
|
124
|
+
if (typeof p === 'function') {
|
125
|
+
const decoded = await data.decodeEvent(processor.coder)
|
126
|
+
return p(decoded || data.event)
|
127
|
+
}
|
128
|
+
return p
|
129
|
+
}
|
133
130
|
})
|
134
131
|
return this
|
135
132
|
}
|
@@ -233,8 +230,8 @@ export class AptosTransactionProcessor<T extends GeneralTransactionResponse, CT
|
|
233
230
|
return this
|
234
231
|
}
|
235
232
|
|
236
|
-
public onEvent(handler: (event: Event, ctx: AptosContext) => void,
|
237
|
-
this.onMoveEvent(handler, { type: '' },
|
233
|
+
public onEvent(handler: (event: Event, ctx: AptosContext) => void, handlerOptions?: HandlerOptions<Event>): this {
|
234
|
+
this.onMoveEvent(handler, { type: '' }, handlerOptions)
|
238
235
|
return this
|
239
236
|
}
|
240
237
|
|
@@ -377,6 +374,7 @@ export class AptosModulesProcessor extends AptosTransactionProcessor<
|
|
377
374
|
|
378
375
|
export class AptosGlobalProcessor {
|
379
376
|
private baseProcessor
|
377
|
+
|
380
378
|
private constructor(options: AptosBindOptions) {
|
381
379
|
this.baseProcessor = new AptosTransactionProcessor('*', options)
|
382
380
|
return proxyProcessor(this)
|