@sentio/sdk 2.59.0-rc.24 → 2.59.0-rc.26
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 +6 -5
- package/lib/aptos/aptos-plugin.d.ts.map +1 -1
- package/lib/aptos/aptos-plugin.js +31 -33
- package/lib/aptos/aptos-plugin.js.map +1 -1
- package/lib/aptos/aptos-processor.d.ts +18 -18
- package/lib/aptos/aptos-processor.d.ts.map +1 -1
- package/lib/aptos/aptos-processor.js +83 -38
- package/lib/aptos/aptos-processor.js.map +1 -1
- package/lib/aptos/aptos-resource-processor-template.d.ts +5 -4
- package/lib/aptos/aptos-resource-processor-template.d.ts.map +1 -1
- package/lib/aptos/aptos-resource-processor-template.js +8 -8
- package/lib/aptos/aptos-resource-processor-template.js.map +1 -1
- package/lib/aptos/builtin/0x1.d.ts +334 -333
- package/lib/aptos/builtin/0x1.d.ts.map +1 -1
- package/lib/aptos/builtin/0x1.js +348 -348
- package/lib/aptos/builtin/0x1.js.map +1 -1
- package/lib/aptos/builtin/0x3.d.ts +67 -66
- package/lib/aptos/builtin/0x3.d.ts.map +1 -1
- package/lib/aptos/builtin/0x3.js +28 -28
- package/lib/aptos/builtin/0x3.js.map +1 -1
- package/lib/aptos/builtin/0x4.d.ts +30 -29
- package/lib/aptos/builtin/0x4.d.ts.map +1 -1
- package/lib/aptos/builtin/0x4.js +34 -34
- package/lib/aptos/builtin/0x4.js.map +1 -1
- package/lib/aptos/codegen/codegen.js +19 -2
- package/lib/aptos/codegen/codegen.js.map +1 -1
- package/lib/aptos/data.d.ts +28 -3
- package/lib/aptos/data.d.ts.map +1 -1
- package/lib/aptos/data.js +61 -0
- package/lib/aptos/data.js.map +1 -1
- package/lib/aptos/models.d.ts +1 -5
- package/lib/aptos/models.d.ts.map +1 -1
- package/lib/btc/btc-plugin.d.ts +4 -1
- package/lib/btc/btc-plugin.d.ts.map +1 -1
- package/lib/btc/btc-plugin.js +27 -0
- package/lib/btc/btc-plugin.js.map +1 -1
- package/lib/btc/btc-processor.d.ts +6 -5
- package/lib/btc/btc-processor.d.ts.map +1 -1
- package/lib/btc/btc-processor.js +35 -9
- package/lib/btc/btc-processor.js.map +1 -1
- package/lib/btc/types.d.ts +2 -1
- package/lib/btc/types.d.ts.map +1 -1
- package/lib/core/handler-options.d.ts +25 -0
- package/lib/core/handler-options.d.ts.map +1 -0
- package/lib/core/handler-options.js +21 -0
- package/lib/core/handler-options.js.map +1 -0
- package/lib/core/index.d.ts +2 -0
- package/lib/core/index.d.ts.map +1 -1
- package/lib/core/index.js +2 -0
- package/lib/core/index.js.map +1 -1
- package/lib/core/partition-handler-manager.d.ts +44 -0
- package/lib/core/partition-handler-manager.d.ts.map +1 -0
- package/lib/core/partition-handler-manager.js +76 -0
- package/lib/core/partition-handler-manager.js.map +1 -0
- package/lib/cosmos/cosmos-processor.d.ts +3 -2
- package/lib/cosmos/cosmos-processor.d.ts.map +1 -1
- package/lib/cosmos/cosmos-processor.js +11 -1
- package/lib/cosmos/cosmos-processor.js.map +1 -1
- package/lib/cosmos/types.d.ts +1 -0
- package/lib/cosmos/types.d.ts.map +1 -1
- package/lib/eth/base-processor.d.ts +18 -17
- package/lib/eth/base-processor.d.ts.map +1 -1
- package/lib/eth/base-processor.js +147 -26
- package/lib/eth/base-processor.js.map +1 -1
- package/lib/eth/builtin/internal/eacaggregatorproxy-processor.d.ts +32 -31
- package/lib/eth/builtin/internal/eacaggregatorproxy-processor.d.ts.map +1 -1
- package/lib/eth/builtin/internal/eacaggregatorproxy-processor.js +62 -62
- package/lib/eth/builtin/internal/eacaggregatorproxy-processor.js.map +1 -1
- package/lib/eth/builtin/internal/erc1155-processor.d.ts +17 -16
- package/lib/eth/builtin/internal/erc1155-processor.d.ts.map +1 -1
- package/lib/eth/builtin/internal/erc1155-processor.js +32 -32
- package/lib/eth/builtin/internal/erc1155-processor.js.map +1 -1
- package/lib/eth/builtin/internal/erc20-processor.d.ts +25 -24
- package/lib/eth/builtin/internal/erc20-processor.d.ts.map +1 -1
- package/lib/eth/builtin/internal/erc20-processor.js +48 -48
- package/lib/eth/builtin/internal/erc20-processor.js.map +1 -1
- package/lib/eth/builtin/internal/erc20bytes-processor.d.ts +14 -13
- package/lib/eth/builtin/internal/erc20bytes-processor.d.ts.map +1 -1
- package/lib/eth/builtin/internal/erc20bytes-processor.js +26 -26
- package/lib/eth/builtin/internal/erc20bytes-processor.js.map +1 -1
- package/lib/eth/builtin/internal/erc721-processor.d.ts +21 -20
- package/lib/eth/builtin/internal/erc721-processor.d.ts.map +1 -1
- package/lib/eth/builtin/internal/erc721-processor.js +40 -40
- package/lib/eth/builtin/internal/erc721-processor.js.map +1 -1
- package/lib/eth/builtin/internal/weth9-processor.d.ts +20 -19
- package/lib/eth/builtin/internal/weth9-processor.d.ts.map +1 -1
- package/lib/eth/builtin/internal/weth9-processor.js +38 -38
- package/lib/eth/builtin/internal/weth9-processor.js.map +1 -1
- package/lib/eth/codegen/event-handler.js +2 -2
- package/lib/eth/codegen/event-handler.js.map +1 -1
- package/lib/eth/codegen/file.d.ts.map +1 -1
- package/lib/eth/codegen/file.js +1 -0
- package/lib/eth/codegen/file.js.map +1 -1
- package/lib/eth/codegen/functions-handler.js +2 -2
- package/lib/eth/codegen/functions-handler.js.map +1 -1
- package/lib/eth/eth-plugin.d.ts +4 -1
- package/lib/eth/eth-plugin.d.ts.map +1 -1
- package/lib/eth/eth-plugin.js +42 -1
- package/lib/eth/eth-plugin.js.map +1 -1
- package/lib/eth/eth.d.ts +2 -7
- package/lib/eth/eth.d.ts.map +1 -1
- package/lib/eth/eth.js +8 -1
- package/lib/eth/eth.js.map +1 -1
- package/lib/fuel/codegen/codegen.js +5 -5
- package/lib/fuel/codegen/codegen.js.map +1 -1
- package/lib/fuel/fuel-plugin.d.ts +4 -1
- package/lib/fuel/fuel-plugin.d.ts.map +1 -1
- package/lib/fuel/fuel-plugin.js +41 -0
- package/lib/fuel/fuel-plugin.js.map +1 -1
- package/lib/fuel/fuel-processor-template.d.ts +7 -4
- package/lib/fuel/fuel-processor-template.d.ts.map +1 -1
- package/lib/fuel/fuel-processor-template.js +11 -9
- package/lib/fuel/fuel-processor-template.js.map +1 -1
- package/lib/fuel/fuel-processor.d.ts +7 -7
- package/lib/fuel/fuel-processor.d.ts.map +1 -1
- package/lib/fuel/fuel-processor.js +90 -19
- package/lib/fuel/fuel-processor.js.map +1 -1
- package/lib/fuel/types.d.ts +3 -0
- package/lib/fuel/types.d.ts.map +1 -1
- package/lib/move/filter.d.ts +4 -0
- package/lib/move/filter.d.ts.map +1 -1
- package/lib/move/filter.js +4 -0
- package/lib/move/filter.js.map +1 -1
- package/lib/move/shared-network-codegen.js +5 -5
- package/lib/move/shared-network-codegen.js.map +1 -1
- package/lib/solana/solana-processor.d.ts +10 -4
- package/lib/solana/solana-processor.d.ts.map +1 -1
- package/lib/solana/solana-processor.js +13 -4
- package/lib/solana/solana-processor.js.map +1 -1
- package/lib/stark/starknet-processor.d.ts +3 -1
- package/lib/stark/starknet-processor.d.ts.map +1 -1
- package/lib/stark/starknet-processor.js +27 -2
- package/lib/stark/starknet-processor.js.map +1 -1
- package/lib/sui/builtin/0x1.d.ts +7 -6
- package/lib/sui/builtin/0x1.d.ts.map +1 -1
- package/lib/sui/builtin/0x1.js +12 -12
- package/lib/sui/builtin/0x1.js.map +1 -1
- package/lib/sui/builtin/0x2.d.ts +61 -60
- package/lib/sui/builtin/0x2.d.ts.map +1 -1
- package/lib/sui/builtin/0x2.js +120 -120
- package/lib/sui/builtin/0x2.js.map +1 -1
- package/lib/sui/builtin/0x3.d.ts +49 -48
- package/lib/sui/builtin/0x3.d.ts.map +1 -1
- package/lib/sui/builtin/0x3.js +96 -96
- package/lib/sui/builtin/0x3.js.map +1 -1
- package/lib/sui/models.d.ts +1 -5
- package/lib/sui/models.d.ts.map +1 -1
- package/lib/sui/sui-plugin.d.ts +6 -3
- package/lib/sui/sui-plugin.d.ts.map +1 -1
- package/lib/sui/sui-plugin.js +59 -20
- package/lib/sui/sui-plugin.js.map +1 -1
- package/lib/sui/sui-processor.d.ts +5 -4
- package/lib/sui/sui-processor.d.ts.map +1 -1
- package/lib/sui/sui-processor.js +47 -11
- package/lib/sui/sui-processor.js.map +1 -1
- package/package.json +3 -3
- package/src/aptos/aptos-plugin.ts +35 -39
- package/src/aptos/aptos-processor.ts +94 -54
- package/src/aptos/aptos-resource-processor-template.ts +9 -8
- package/src/aptos/builtin/0x1.ts +1407 -507
- package/src/aptos/builtin/0x3.ts +251 -80
- package/src/aptos/builtin/0x4.ts +112 -46
- package/src/aptos/codegen/codegen.ts +23 -2
- package/src/aptos/data.ts +78 -3
- package/src/aptos/models.ts +1 -6
- package/src/btc/btc-plugin.ts +38 -0
- package/src/btc/btc-processor.ts +35 -10
- package/src/btc/types.ts +2 -1
- package/src/core/handler-options.ts +40 -0
- package/src/core/index.ts +5 -0
- package/src/core/partition-handler-manager.ts +94 -0
- package/src/cosmos/cosmos-processor.ts +12 -1
- package/src/cosmos/types.ts +1 -0
- package/src/eth/base-processor.ts +139 -33
- package/src/eth/builtin/internal/eacaggregatorproxy-processor.ts +118 -62
- package/src/eth/builtin/internal/erc1155-processor.ts +76 -32
- package/src/eth/builtin/internal/erc20-processor.ts +79 -48
- package/src/eth/builtin/internal/erc20bytes-processor.ts +47 -26
- package/src/eth/builtin/internal/erc721-processor.ts +77 -40
- package/src/eth/builtin/internal/weth9-processor.ts +79 -38
- package/src/eth/codegen/event-handler.ts +2 -2
- package/src/eth/codegen/file.ts +1 -0
- package/src/eth/codegen/functions-handler.ts +2 -2
- package/src/eth/eth-plugin.ts +55 -3
- package/src/eth/eth.ts +12 -1
- package/src/fuel/codegen/codegen.ts +5 -5
- package/src/fuel/fuel-plugin.ts +56 -0
- package/src/fuel/fuel-processor-template.ts +17 -10
- package/src/fuel/fuel-processor.ts +89 -13
- package/src/fuel/types.ts +3 -0
- package/src/move/filter.ts +4 -0
- package/src/move/shared-network-codegen.ts +5 -5
- package/src/solana/solana-processor.ts +28 -6
- package/src/stark/starknet-processor.ts +28 -2
- package/src/sui/builtin/0x1.ts +22 -13
- package/src/sui/builtin/0x2.ts +220 -121
- package/src/sui/builtin/0x3.ts +241 -97
- package/src/sui/models.ts +1 -6
- package/src/sui/sui-plugin.ts +68 -22
- package/src/sui/sui-processor.ts +48 -11
@@ -1,18 +1,17 @@
|
|
1
1
|
import { defaultMoveCoder, MoveCoder } from './index.js'
|
2
2
|
|
3
3
|
import {
|
4
|
+
EntryFunctionPayloadResponse,
|
4
5
|
Event,
|
5
6
|
MoveResource,
|
6
7
|
UserTransactionResponse,
|
7
|
-
EntryFunctionPayloadResponse,
|
8
|
-
MultisigPayloadResponse,
|
9
8
|
WriteSetChangeWriteResource
|
10
9
|
} from '@aptos-labs/ts-sdk'
|
11
10
|
|
12
11
|
import { AptosBindOptions, AptosNetwork } from './network.js'
|
13
12
|
import { AptosContext, AptosResourcesContext, AptosTransactionContext } from './context.js'
|
14
13
|
import { ListStateStorage } from '@sentio/runtime'
|
15
|
-
import {
|
14
|
+
import { Data_AptResource, HandleInterval, MoveAccountFetchConfig, MoveFetchConfig } from '@sentio/protos'
|
16
15
|
import { ServerError, Status } from 'nice-grpc'
|
17
16
|
import {
|
18
17
|
accountTypeString,
|
@@ -26,11 +25,11 @@ import {
|
|
26
25
|
TransactionIntervalHandler
|
27
26
|
} from '../move/index.js'
|
28
27
|
import { ALL_ADDRESS, Labels, PromiseOrVoid } from '../core/index.js'
|
29
|
-
import {
|
30
|
-
import {
|
28
|
+
import { matchType, NestedDecodedStruct, TypeDescriptor } from '@typemove/move'
|
29
|
+
import { ResourceChange } from '@typemove/aptos'
|
31
30
|
import { GeneralTransactionResponse, HandlerOptions } from './models.js'
|
32
31
|
import { getHandlerName, proxyProcessor } from '../utils/metrics.js'
|
33
|
-
import { AptEvent } from './data.js'
|
32
|
+
import { AptCall, AptEvent, AptResource } from './data.js'
|
34
33
|
|
35
34
|
const DEFAULT_FETCH_CONFIG: MoveFetchConfig = {
|
36
35
|
resourceChanges: false,
|
@@ -61,8 +60,8 @@ export class AptosTransactionProcessor<T extends GeneralTransactionResponse, CT
|
|
61
60
|
readonly moduleName: string
|
62
61
|
config: IndexConfigure
|
63
62
|
eventHandlers: EventHandler<AptEvent>[] = []
|
64
|
-
callHandlers: CallHandler<
|
65
|
-
resourceChangeHandlers: ResourceChangeHandler<
|
63
|
+
callHandlers: CallHandler<AptCall>[] = []
|
64
|
+
resourceChangeHandlers: ResourceChangeHandler<AptResource>[] = []
|
66
65
|
transactionIntervalHandlers: TransactionIntervalHandler[] = []
|
67
66
|
coder: MoveCoder
|
68
67
|
|
@@ -79,7 +78,7 @@ export class AptosTransactionProcessor<T extends GeneralTransactionResponse, CT
|
|
79
78
|
protected onMoveEvent(
|
80
79
|
handler: (event: Event, ctx: AptosContext) => PromiseOrVoid,
|
81
80
|
filter: EventFilter | EventFilter[],
|
82
|
-
handlerOptions?: HandlerOptions<Event>
|
81
|
+
handlerOptions?: HandlerOptions<MoveFetchConfig, Event>
|
83
82
|
): this {
|
84
83
|
let _filters: EventFilter[] = []
|
85
84
|
const _fetchConfig = MoveFetchConfig.fromPartial({ ...DEFAULT_FETCH_CONFIG, ...handlerOptions })
|
@@ -134,10 +133,10 @@ export class AptosTransactionProcessor<T extends GeneralTransactionResponse, CT
|
|
134
133
|
protected onEntryFunctionCall(
|
135
134
|
handler: (call: EntryFunctionPayloadResponse, ctx: AptosContext) => PromiseOrVoid,
|
136
135
|
filter: FunctionNameAndCallFilter | FunctionNameAndCallFilter[],
|
137
|
-
|
136
|
+
handlerOptions?: HandlerOptions<MoveFetchConfig, EntryFunctionPayloadResponse>
|
138
137
|
): this {
|
139
138
|
let _filters: FunctionNameAndCallFilter[] = []
|
140
|
-
const _fetchConfig = MoveFetchConfig.fromPartial({ ...DEFAULT_FETCH_CONFIG, ...
|
139
|
+
const _fetchConfig = MoveFetchConfig.fromPartial({ ...DEFAULT_FETCH_CONFIG, ...handlerOptions })
|
141
140
|
|
142
141
|
if (Array.isArray(filter)) {
|
143
142
|
_filters = filter
|
@@ -155,7 +154,7 @@ export class AptosTransactionProcessor<T extends GeneralTransactionResponse, CT
|
|
155
154
|
if (!data.rawTransaction) {
|
156
155
|
throw new ServerError(Status.INVALID_ARGUMENT, 'call is null')
|
157
156
|
}
|
158
|
-
const tx =
|
157
|
+
const tx = data.transaction
|
159
158
|
|
160
159
|
const ctx = new AptosContext(
|
161
160
|
processor.moduleName,
|
@@ -167,18 +166,22 @@ export class AptosTransactionProcessor<T extends GeneralTransactionResponse, CT
|
|
167
166
|
processor.config.baseLabels
|
168
167
|
)
|
169
168
|
if (tx) {
|
170
|
-
|
171
|
-
if (payload.type === 'multisig_payload') {
|
172
|
-
payload = (payload as MultisigPayloadResponse).transaction_payload ?? payload
|
173
|
-
}
|
174
|
-
|
175
|
-
const decoded = await processor.coder.decodeFunctionPayload(payload as EntryFunctionPayloadResponse)
|
169
|
+
const decoded = await data.decodeCall(processor.coder)
|
176
170
|
await handler(decoded, ctx)
|
177
171
|
}
|
178
172
|
return ctx.stopAndGetResult()
|
179
173
|
},
|
180
174
|
filters: _filters,
|
181
|
-
fetchConfig: _fetchConfig
|
175
|
+
fetchConfig: _fetchConfig,
|
176
|
+
partitionHandler: async (data: AptCall): Promise<string | undefined> => {
|
177
|
+
const p = handlerOptions?.partitionKey
|
178
|
+
if (!p) return undefined
|
179
|
+
if (typeof p === 'function') {
|
180
|
+
const decoded = await data.decodeCall(processor.coder)
|
181
|
+
return p(decoded)
|
182
|
+
}
|
183
|
+
return p
|
184
|
+
}
|
182
185
|
})
|
183
186
|
return this
|
184
187
|
}
|
@@ -189,9 +192,9 @@ export class AptosTransactionProcessor<T extends GeneralTransactionResponse, CT
|
|
189
192
|
includeFailed?: boolean
|
190
193
|
sender?: string
|
191
194
|
},
|
192
|
-
|
195
|
+
handleOptions?: HandlerOptions<MoveFetchConfig, UserTransactionResponse>
|
193
196
|
): this {
|
194
|
-
const _fetchConfig = MoveFetchConfig.fromPartial({ ...DEFAULT_FETCH_CONFIG, ...
|
197
|
+
const _fetchConfig = MoveFetchConfig.fromPartial({ ...DEFAULT_FETCH_CONFIG, ...handleOptions })
|
195
198
|
|
196
199
|
const processor = this
|
197
200
|
const filter: FunctionNameAndCallFilter = { function: '', includeFailed: transactionFilter?.includeFailed }
|
@@ -208,10 +211,7 @@ export class AptosTransactionProcessor<T extends GeneralTransactionResponse, CT
|
|
208
211
|
if (!data.rawTransaction) {
|
209
212
|
throw new ServerError(Status.INVALID_ARGUMENT, 'call is null')
|
210
213
|
}
|
211
|
-
const call =
|
212
|
-
if (call.events == null) {
|
213
|
-
call.events = []
|
214
|
-
}
|
214
|
+
const call = data.transaction
|
215
215
|
const ctx = new AptosContext(
|
216
216
|
processor.moduleName,
|
217
217
|
processor.config.network,
|
@@ -225,19 +225,31 @@ export class AptosTransactionProcessor<T extends GeneralTransactionResponse, CT
|
|
225
225
|
return ctx.stopAndGetResult()
|
226
226
|
},
|
227
227
|
filters: [filter],
|
228
|
-
fetchConfig: _fetchConfig
|
228
|
+
fetchConfig: _fetchConfig,
|
229
|
+
partitionHandler: async (data: AptCall): Promise<string | undefined> => {
|
230
|
+
const p = handleOptions?.partitionKey
|
231
|
+
if (!p) return undefined
|
232
|
+
if (typeof p === 'function') {
|
233
|
+
return p(data.transaction)
|
234
|
+
}
|
235
|
+
return p
|
236
|
+
}
|
229
237
|
})
|
230
238
|
return this
|
231
239
|
}
|
232
240
|
|
233
|
-
public onEvent(
|
241
|
+
public onEvent(
|
242
|
+
handler: (event: Event, ctx: AptosContext) => void,
|
243
|
+
handlerOptions?: HandlerOptions<MoveFetchConfig, Event>
|
244
|
+
): this {
|
234
245
|
this.onMoveEvent(handler, { type: '' }, handlerOptions)
|
235
246
|
return this
|
236
247
|
}
|
237
248
|
|
238
249
|
public onResourceChange<T>(
|
239
250
|
handler: (changes: ResourceChange<T>[], ctx: AptosResourcesContext) => PromiseOrVoid,
|
240
|
-
typeDesc: TypeDescriptor<T> | string
|
251
|
+
typeDesc: TypeDescriptor<T> | string,
|
252
|
+
handlerOptions?: HandlerOptions<object, ResourceChange<T>[]>
|
241
253
|
): this {
|
242
254
|
if (typeof typeDesc === 'string') {
|
243
255
|
typeDesc = parseMoveType(typeDesc)
|
@@ -252,6 +264,7 @@ export class AptosTransactionProcessor<T extends GeneralTransactionResponse, CT
|
|
252
264
|
if (!data.rawResources || !data.version) {
|
253
265
|
throw new ServerError(Status.INVALID_ARGUMENT, 'resource is null')
|
254
266
|
}
|
267
|
+
const aptResource = new AptResource(data)
|
255
268
|
const timestamp = Number(data.timestampMicros)
|
256
269
|
const ctx = new AptosResourcesContext(
|
257
270
|
processor.config.network,
|
@@ -260,10 +273,7 @@ export class AptosTransactionProcessor<T extends GeneralTransactionResponse, CT
|
|
260
273
|
timestamp,
|
261
274
|
processor.config.baseLabels
|
262
275
|
)
|
263
|
-
let resources = await
|
264
|
-
data.rawResources.map((r) => JSON.parse(r)),
|
265
|
-
ctx.coder
|
266
|
-
)
|
276
|
+
let resources = await aptResource.decodeResources<T>(processor.coder)
|
267
277
|
|
268
278
|
if (hasAny) {
|
269
279
|
resources = resources.filter((r) => {
|
@@ -277,7 +287,16 @@ export class AptosTransactionProcessor<T extends GeneralTransactionResponse, CT
|
|
277
287
|
}
|
278
288
|
return ctx.stopAndGetResult()
|
279
289
|
},
|
280
|
-
type: hasAny ? typeDesc.qname : typeDesc.getNormalizedSignature()
|
290
|
+
type: hasAny ? typeDesc.qname : typeDesc.getNormalizedSignature(),
|
291
|
+
partitionHandler: async (data): Promise<string | undefined> => {
|
292
|
+
const p = handlerOptions?.partitionKey
|
293
|
+
if (!p) return undefined
|
294
|
+
if (typeof p === 'function') {
|
295
|
+
const resources = await data.decodeResources<T>(processor.coder)
|
296
|
+
return p(resources)
|
297
|
+
}
|
298
|
+
return p
|
299
|
+
}
|
281
300
|
})
|
282
301
|
return this
|
283
302
|
}
|
@@ -286,7 +305,7 @@ export class AptosTransactionProcessor<T extends GeneralTransactionResponse, CT
|
|
286
305
|
handler: (transaction: T, ctx: CT) => PromiseOrVoid,
|
287
306
|
timeInterval: HandleInterval | undefined,
|
288
307
|
versionInterval: HandleInterval | undefined,
|
289
|
-
|
308
|
+
handlerOptions?: HandlerOptions<MoveFetchConfig, T>
|
290
309
|
): this {
|
291
310
|
const processor = this
|
292
311
|
this.transactionIntervalHandlers.push({
|
@@ -315,7 +334,16 @@ export class AptosTransactionProcessor<T extends GeneralTransactionResponse, CT
|
|
315
334
|
},
|
316
335
|
timeIntervalInMinutes: timeInterval,
|
317
336
|
versionInterval: versionInterval,
|
318
|
-
fetchConfig: { ...DEFAULT_FETCH_CONFIG, ...
|
337
|
+
fetchConfig: { ...DEFAULT_FETCH_CONFIG, ...handlerOptions },
|
338
|
+
partitionHandler: async (data): Promise<string | undefined> => {
|
339
|
+
const p = handlerOptions?.partitionKey
|
340
|
+
if (!p) return undefined
|
341
|
+
if (typeof p === 'function') {
|
342
|
+
const transaction = JSON.parse(data.rawTransaction) as T
|
343
|
+
return p(transaction)
|
344
|
+
}
|
345
|
+
return p
|
346
|
+
}
|
319
347
|
})
|
320
348
|
return this
|
321
349
|
}
|
@@ -324,7 +352,7 @@ export class AptosTransactionProcessor<T extends GeneralTransactionResponse, CT
|
|
324
352
|
handler: (transaction: T, ctx: CT) => PromiseOrVoid,
|
325
353
|
timeIntervalInMinutes = 60,
|
326
354
|
backfillTimeIntervalInMinutes = 240,
|
327
|
-
|
355
|
+
handlerOptions?: HandlerOptions<MoveFetchConfig, T>
|
328
356
|
): this {
|
329
357
|
return this.onInterval(
|
330
358
|
handler,
|
@@ -333,7 +361,7 @@ export class AptosTransactionProcessor<T extends GeneralTransactionResponse, CT
|
|
333
361
|
backfillInterval: backfillTimeIntervalInMinutes
|
334
362
|
},
|
335
363
|
undefined,
|
336
|
-
|
364
|
+
handlerOptions
|
337
365
|
)
|
338
366
|
}
|
339
367
|
|
@@ -341,13 +369,13 @@ export class AptosTransactionProcessor<T extends GeneralTransactionResponse, CT
|
|
341
369
|
handler: (transaction: T, context: CT) => PromiseOrVoid,
|
342
370
|
versionInterval = 100000,
|
343
371
|
backfillVersionInterval = 400000,
|
344
|
-
|
372
|
+
handlerOptions?: HandlerOptions<MoveFetchConfig, T>
|
345
373
|
): this {
|
346
374
|
return this.onInterval(
|
347
375
|
handler,
|
348
376
|
undefined,
|
349
377
|
{ recentInterval: versionInterval, backfillInterval: backfillVersionInterval },
|
350
|
-
|
378
|
+
handlerOptions
|
351
379
|
)
|
352
380
|
}
|
353
381
|
|
@@ -403,9 +431,9 @@ export class AptosGlobalProcessor {
|
|
403
431
|
) => PromiseOrVoid,
|
404
432
|
timeIntervalInMinutes = 60,
|
405
433
|
backfillTimeIntervalInMinutes = 240,
|
406
|
-
|
434
|
+
handlerOptions?: HandlerOptions<MoveFetchConfig, GeneralTransactionResponse>
|
407
435
|
): this {
|
408
|
-
this.baseProcessor.onTimeInterval(handler, timeIntervalInMinutes, backfillTimeIntervalInMinutes,
|
436
|
+
this.baseProcessor.onTimeInterval(handler, timeIntervalInMinutes, backfillTimeIntervalInMinutes, handlerOptions)
|
409
437
|
return this
|
410
438
|
}
|
411
439
|
|
@@ -416,9 +444,9 @@ export class AptosGlobalProcessor {
|
|
416
444
|
) => PromiseOrVoid,
|
417
445
|
versionInterval = 100000,
|
418
446
|
backfillVersionInterval = 400000,
|
419
|
-
|
447
|
+
handlerOptions?: HandlerOptions<MoveFetchConfig, GeneralTransactionResponse>
|
420
448
|
): this {
|
421
|
-
this.baseProcessor.onVersionInterval(handler, versionInterval, backfillVersionInterval,
|
449
|
+
this.baseProcessor.onVersionInterval(handler, versionInterval, backfillVersionInterval, handlerOptions)
|
422
450
|
return this
|
423
451
|
}
|
424
452
|
}
|
@@ -452,7 +480,7 @@ export class AptosResourcesProcessor {
|
|
452
480
|
timeInterval: HandleInterval | undefined,
|
453
481
|
versionInterval: HandleInterval | undefined,
|
454
482
|
type: string | undefined,
|
455
|
-
|
483
|
+
handlerOptions?: HandlerOptions<MoveAccountFetchConfig, MoveResource[]>,
|
456
484
|
handlerName = getHandlerName()
|
457
485
|
): this {
|
458
486
|
const processor = this
|
@@ -462,6 +490,7 @@ export class AptosResourcesProcessor {
|
|
462
490
|
if (data.timestampMicros > Number.MAX_SAFE_INTEGER) {
|
463
491
|
throw new ServerError(Status.INVALID_ARGUMENT, 'timestamp is too large')
|
464
492
|
}
|
493
|
+
const aptResource = new AptResource(data)
|
465
494
|
const timestamp = Number(data.timestampMicros)
|
466
495
|
|
467
496
|
const ctx = new AptosResourcesContext(
|
@@ -471,13 +500,22 @@ export class AptosResourcesProcessor {
|
|
471
500
|
timestamp,
|
472
501
|
processor.config.baseLabels
|
473
502
|
)
|
474
|
-
await handler(
|
503
|
+
await handler(aptResource.resources, ctx)
|
475
504
|
return ctx.stopAndGetResult()
|
476
505
|
},
|
477
506
|
timeIntervalInMinutes: timeInterval,
|
478
507
|
versionInterval: versionInterval,
|
479
508
|
type: type,
|
480
|
-
fetchConfig: { ...DEFAULT_RESOURCE_FETCH_CONFIG, ...
|
509
|
+
fetchConfig: { ...DEFAULT_RESOURCE_FETCH_CONFIG, ...handlerOptions },
|
510
|
+
partitionHandler: async (data: Data_AptResource): Promise<string | undefined> => {
|
511
|
+
const p = handlerOptions?.partitionKey
|
512
|
+
if (!p) return undefined
|
513
|
+
if (typeof p === 'function') {
|
514
|
+
const aptResource = new AptResource(data)
|
515
|
+
return p(aptResource.resources)
|
516
|
+
}
|
517
|
+
return p
|
518
|
+
}
|
481
519
|
})
|
482
520
|
return this
|
483
521
|
}
|
@@ -487,7 +525,7 @@ export class AptosResourcesProcessor {
|
|
487
525
|
timeIntervalInMinutes = 60,
|
488
526
|
backfillTimeIntervalInMinutes = 240,
|
489
527
|
type?: string,
|
490
|
-
|
528
|
+
handlerOptions?: HandlerOptions<MoveAccountFetchConfig, MoveResource[]>
|
491
529
|
): this {
|
492
530
|
return this.onInterval(
|
493
531
|
handler,
|
@@ -497,7 +535,7 @@ export class AptosResourcesProcessor {
|
|
497
535
|
},
|
498
536
|
undefined,
|
499
537
|
type,
|
500
|
-
|
538
|
+
handlerOptions
|
501
539
|
)
|
502
540
|
}
|
503
541
|
|
@@ -506,14 +544,14 @@ export class AptosResourcesProcessor {
|
|
506
544
|
versionInterval = 100000,
|
507
545
|
backfillVersionInterval = 400000,
|
508
546
|
typePrefix?: string,
|
509
|
-
|
547
|
+
handlerOptions?: HandlerOptions<MoveAccountFetchConfig, MoveResource[]>
|
510
548
|
): this {
|
511
549
|
return this.onInterval(
|
512
550
|
handler,
|
513
551
|
undefined,
|
514
552
|
{ recentInterval: versionInterval, backfillInterval: backfillVersionInterval },
|
515
553
|
typePrefix,
|
516
|
-
|
554
|
+
handlerOptions
|
517
555
|
)
|
518
556
|
}
|
519
557
|
|
@@ -537,6 +575,7 @@ export class AptosResourcesProcessor {
|
|
537
575
|
if (!data.rawResources || !data.version) {
|
538
576
|
throw new ServerError(Status.INVALID_ARGUMENT, 'resource is null')
|
539
577
|
}
|
578
|
+
const aptResource = new AptResource(data)
|
540
579
|
const ctx = new AptosResourcesContext(
|
541
580
|
processor.config.network,
|
542
581
|
processor.config.address,
|
@@ -545,10 +584,11 @@ export class AptosResourcesProcessor {
|
|
545
584
|
processor.config.baseLabels
|
546
585
|
)
|
547
586
|
|
548
|
-
let resources = (await
|
549
|
-
|
550
|
-
|
551
|
-
|
587
|
+
let resources = (await aptResource.decodeResources<T>(ctx.coder)) as NestedDecodedStruct<
|
588
|
+
MoveResource,
|
589
|
+
WriteSetChangeWriteResource,
|
590
|
+
T
|
591
|
+
>[]
|
552
592
|
|
553
593
|
if (hasAny) {
|
554
594
|
resources = resources.filter((r) => {
|
@@ -7,6 +7,7 @@ import { HandleInterval, MoveAccountFetchConfig } from '@sentio/protos'
|
|
7
7
|
import { MoveResource } from '@aptos-labs/ts-sdk'
|
8
8
|
import { PromiseOrVoid } from '../core/index.js'
|
9
9
|
import { getHandlerName, proxyProcessor } from '../utils/metrics.js'
|
10
|
+
import { HandlerOptions } from './models.js'
|
10
11
|
|
11
12
|
export class AptosResourceProcessorTemplateState extends ListStateStorage<AptosResourceProcessorTemplate> {
|
12
13
|
static INSTANCE = new AptosResourceProcessorTemplateState()
|
@@ -18,7 +19,7 @@ class Handler {
|
|
18
19
|
timeIntervalInMinutes?: HandleInterval
|
19
20
|
handlerName: string
|
20
21
|
handler: (resources: MoveResource[], ctx: AptosResourcesContext) => PromiseOrVoid
|
21
|
-
|
22
|
+
handlerOptions: HandlerOptions<MoveAccountFetchConfig, MoveResource[]>
|
22
23
|
}
|
23
24
|
|
24
25
|
export class AptosResourceProcessorTemplate {
|
@@ -55,7 +56,7 @@ export class AptosResourceProcessorTemplate {
|
|
55
56
|
h.timeIntervalInMinutes,
|
56
57
|
h.checkpointInterval,
|
57
58
|
h.type,
|
58
|
-
h.
|
59
|
+
h.handlerOptions,
|
59
60
|
h.handlerName
|
60
61
|
)
|
61
62
|
}
|
@@ -90,7 +91,7 @@ export class AptosResourceProcessorTemplate {
|
|
90
91
|
timeInterval: HandleInterval | undefined,
|
91
92
|
checkpointInterval: HandleInterval | undefined,
|
92
93
|
type: string | undefined,
|
93
|
-
|
94
|
+
handlerOptions?: HandlerOptions<MoveAccountFetchConfig, MoveResource[]>
|
94
95
|
): this {
|
95
96
|
this.handlers.push({
|
96
97
|
handlerName: getHandlerName(),
|
@@ -98,7 +99,7 @@ export class AptosResourceProcessorTemplate {
|
|
98
99
|
timeIntervalInMinutes: timeInterval,
|
99
100
|
checkpointInterval: checkpointInterval,
|
100
101
|
type,
|
101
|
-
|
102
|
+
handlerOptions: { ...DEFAULT_RESOURCE_FETCH_CONFIG, ...handlerOptions }
|
102
103
|
})
|
103
104
|
return this
|
104
105
|
}
|
@@ -108,7 +109,7 @@ export class AptosResourceProcessorTemplate {
|
|
108
109
|
timeIntervalInMinutes = 60,
|
109
110
|
backfillTimeIntervalInMinutes = 240,
|
110
111
|
type?: string,
|
111
|
-
|
112
|
+
handlerOptions?: HandlerOptions<MoveAccountFetchConfig, MoveResource[]>
|
112
113
|
): this {
|
113
114
|
return this.onInterval(
|
114
115
|
handler,
|
@@ -118,7 +119,7 @@ export class AptosResourceProcessorTemplate {
|
|
118
119
|
},
|
119
120
|
undefined,
|
120
121
|
type,
|
121
|
-
|
122
|
+
handlerOptions
|
122
123
|
)
|
123
124
|
}
|
124
125
|
|
@@ -127,14 +128,14 @@ export class AptosResourceProcessorTemplate {
|
|
127
128
|
checkpointInterval = 100000,
|
128
129
|
backfillCheckpointInterval = 400000,
|
129
130
|
type?: string,
|
130
|
-
|
131
|
+
handlerOptions?: HandlerOptions<MoveAccountFetchConfig, MoveResource[]>
|
131
132
|
): this {
|
132
133
|
return this.onInterval(
|
133
134
|
handler,
|
134
135
|
undefined,
|
135
136
|
{ recentInterval: checkpointInterval, backfillInterval: backfillCheckpointInterval },
|
136
137
|
type,
|
137
|
-
|
138
|
+
handlerOptions
|
138
139
|
)
|
139
140
|
}
|
140
141
|
}
|