@sentio/sdk 2.59.0-rc.4 → 2.59.0-rc.40
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/api.d.ts +1 -0
- package/lib/aptos/api.d.ts.map +1 -1
- package/lib/aptos/api.js +13 -1
- package/lib/aptos/api.js.map +1 -1
- package/lib/aptos/aptos-plugin.d.ts +8 -4
- package/lib/aptos/aptos-plugin.d.ts.map +1 -1
- package/lib/aptos/aptos-plugin.js +51 -8
- package/lib/aptos/aptos-plugin.js.map +1 -1
- package/lib/aptos/aptos-processor.d.ts +21 -19
- package/lib/aptos/aptos-processor.d.ts.map +1 -1
- package/lib/aptos/aptos-processor.js +102 -50
- 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 +333 -332
- package/lib/aptos/builtin/0x1.d.ts.map +1 -1
- package/lib/aptos/builtin/0x1.js +664 -664
- package/lib/aptos/builtin/0x1.js.map +1 -1
- package/lib/aptos/builtin/0x3.d.ts +66 -65
- package/lib/aptos/builtin/0x3.d.ts.map +1 -1
- package/lib/aptos/builtin/0x3.js +130 -130
- package/lib/aptos/builtin/0x3.js.map +1 -1
- package/lib/aptos/builtin/0x4.d.ts +29 -28
- package/lib/aptos/builtin/0x4.d.ts.map +1 -1
- package/lib/aptos/builtin/0x4.js +56 -56
- package/lib/aptos/builtin/0x4.js.map +1 -1
- package/lib/aptos/codegen/codegen.js +31 -4
- package/lib/aptos/codegen/codegen.js.map +1 -1
- package/lib/aptos/data.d.ts +45 -0
- package/lib/aptos/data.d.ts.map +1 -0
- package/lib/aptos/data.js +99 -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 +1 -0
- package/lib/aptos/models.d.ts.map +1 -1
- package/lib/aptos/move-coder.d.ts +8 -2
- package/lib/aptos/move-coder.d.ts.map +1 -1
- package/lib/aptos/move-coder.js +84 -1
- package/lib/aptos/move-coder.js.map +1 -1
- package/lib/aptos/network.d.ts +1 -0
- package/lib/aptos/network.d.ts.map +1 -1
- package/lib/aptos/network.js +1 -0
- package/lib/aptos/network.js.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/base-context.d.ts +4 -2
- package/lib/core/base-context.d.ts.map +1 -1
- package/lib/core/base-context.js +10 -5
- package/lib/core/base-context.js.map +1 -1
- package/lib/core/event-logger.d.ts +5 -0
- package/lib/core/event-logger.d.ts.map +1 -1
- package/lib/core/event-logger.js +36 -1
- package/lib/core/event-logger.js.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 +3 -1
- package/lib/core/index.d.ts.map +1 -1
- package/lib/core/index.js +3 -1
- package/lib/core/index.js.map +1 -1
- package/lib/core/meter.d.ts +45 -2
- package/lib/core/meter.d.ts.map +1 -1
- package/lib/core/meter.js +124 -2
- package/lib/core/meter.js.map +1 -1
- package/lib/core/numberish.d.ts +2 -1
- package/lib/core/numberish.d.ts.map +1 -1
- package/lib/core/numberish.js +35 -1
- package/lib/core/numberish.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 +23 -17
- package/lib/eth/base-processor.d.ts.map +1 -1
- package/lib/eth/base-processor.js +173 -34
- package/lib/eth/base-processor.js.map +1 -1
- package/lib/eth/bind-options.d.ts +6 -0
- package/lib/eth/bind-options.d.ts.map +1 -1
- package/lib/eth/bind-options.js +2 -0
- package/lib/eth/bind-options.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 +5 -1
- package/lib/eth/eth-plugin.d.ts.map +1 -1
- package/lib/eth/eth-plugin.js +53 -5
- 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 +91 -28
- 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 +5 -0
- package/lib/move/filter.d.ts.map +1 -1
- package/lib/move/filter.js +5 -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 +5 -4
- 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 +32 -14
- package/lib/stark/starknet-processor.js.map +1 -1
- package/lib/store/codegen.d.ts.map +1 -1
- package/lib/store/codegen.js +36 -2
- package/lib/store/codegen.js.map +1 -1
- package/lib/store/schema.d.ts.map +1 -1
- package/lib/store/schema.js +3 -1
- package/lib/store/schema.js.map +1 -1
- package/lib/store/store.d.ts +4 -3
- package/lib/store/store.d.ts.map +1 -1
- package/lib/store/store.js +41 -1
- package/lib/store/store.js.map +1 -1
- package/lib/store/types.d.ts +20 -1
- package/lib/store/types.d.ts.map +1 -1
- package/lib/store/types.js +22 -0
- package/lib/store/types.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 -0
- package/lib/sui/models.d.ts.map +1 -1
- package/lib/sui/sui-object-processor-template.js +1 -1
- package/lib/sui/sui-object-processor-template.js.map +1 -1
- package/lib/sui/sui-object-processor.d.ts +2 -0
- package/lib/sui/sui-object-processor.d.ts.map +1 -1
- package/lib/sui/sui-object-processor.js +4 -0
- package/lib/sui/sui-object-processor.js.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 +68 -24
- package/lib/sui/sui-plugin.js.map +1 -1
- package/lib/sui/sui-processor.d.ts +6 -4
- package/lib/sui/sui-processor.d.ts.map +1 -1
- package/lib/sui/sui-processor.js +48 -11
- package/lib/sui/sui-processor.js.map +1 -1
- package/lib/testing/eth-facet.d.ts +2 -1
- package/lib/testing/eth-facet.d.ts.map +1 -1
- package/lib/testing/eth-facet.js.map +1 -1
- package/lib/utils/block.d.ts +2 -0
- package/lib/utils/block.d.ts.map +1 -1
- package/lib/utils/block.js +13 -0
- package/lib/utils/block.js.map +1 -1
- package/package.json +7 -6
- package/src/aptos/api.ts +13 -1
- package/src/aptos/aptos-plugin.ts +62 -13
- package/src/aptos/aptos-processor.ts +114 -74
- package/src/aptos/aptos-resource-processor-template.ts +9 -8
- package/src/aptos/builtin/0x1.ts +1566 -664
- package/src/aptos/builtin/0x3.ts +303 -130
- package/src/aptos/builtin/0x4.ts +124 -56
- package/src/aptos/codegen/codegen.ts +40 -5
- package/src/aptos/data.ts +123 -0
- package/src/aptos/index.ts +2 -0
- package/src/aptos/models.ts +2 -0
- package/src/aptos/move-coder.ts +96 -3
- package/src/aptos/network.ts +1 -0
- 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/base-context.ts +10 -5
- package/src/core/event-logger.ts +45 -1
- package/src/core/handler-options.ts +40 -0
- package/src/core/index.ts +17 -1
- package/src/core/meter.ts +159 -4
- package/src/core/numberish.ts +34 -1
- 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 +163 -41
- package/src/eth/bind-options.ts +7 -0
- 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 +76 -10
- 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 +90 -22
- package/src/fuel/types.ts +3 -0
- package/src/move/filter.ts +5 -0
- package/src/move/shared-network-codegen.ts +5 -4
- package/src/solana/solana-processor.ts +28 -6
- package/src/stark/starknet-processor.ts +31 -13
- package/src/store/codegen.ts +50 -2
- package/src/store/schema.ts +3 -1
- package/src/store/store.ts +57 -4
- package/src/store/types.ts +30 -1
- package/src/sui/builtin/0x1.ts +22 -12
- package/src/sui/builtin/0x2.ts +220 -120
- package/src/sui/builtin/0x3.ts +241 -96
- package/src/sui/models.ts +2 -0
- package/src/sui/sui-object-processor-template.ts +1 -1
- package/src/sui/sui-object-processor.ts +6 -0
- package/src/sui/sui-plugin.ts +77 -26
- package/src/sui/sui-processor.ts +50 -11
- package/src/testing/eth-facet.ts +2 -1
- package/src/utils/block.ts +15 -0
@@ -0,0 +1,123 @@
|
|
1
|
+
import { Data_AptEvent, Data_AptCall, Data_AptResource } from '@sentio/protos'
|
2
|
+
import { UserTransactionResponse, MoveResource } from '@aptos-labs/ts-sdk'
|
3
|
+
import { MoveCoder, decodeResourceChange, ResourceChange } from '@typemove/aptos'
|
4
|
+
|
5
|
+
type Data_AptEvent_Ext = Data_AptEvent & {
|
6
|
+
_tx?: UserTransactionResponse
|
7
|
+
_event?: any
|
8
|
+
_decodedEvent?: any
|
9
|
+
}
|
10
|
+
|
11
|
+
type Data_AptCall_Ext = Data_AptCall & {
|
12
|
+
_tx?: UserTransactionResponse
|
13
|
+
_decodedCall?: any
|
14
|
+
}
|
15
|
+
|
16
|
+
type Data_AptResource_Ext = Data_AptResource & {
|
17
|
+
_resources?: MoveResource[]
|
18
|
+
_decodedResources?: ResourceChange<any>[]
|
19
|
+
}
|
20
|
+
|
21
|
+
export class AptEvent implements Data_AptEvent {
|
22
|
+
constructor(readonly data: Data_AptEvent_Ext) {}
|
23
|
+
|
24
|
+
get rawEvent(): string {
|
25
|
+
return this.data.rawEvent
|
26
|
+
}
|
27
|
+
get eventIndex(): number {
|
28
|
+
return this.data.eventIndex
|
29
|
+
}
|
30
|
+
get rawTransaction(): string {
|
31
|
+
return this.data.rawTransaction
|
32
|
+
}
|
33
|
+
|
34
|
+
get transaction() {
|
35
|
+
if (!this.data._tx) {
|
36
|
+
this.data._tx = JSON.parse(this.data.rawTransaction) as UserTransactionResponse
|
37
|
+
if (this.data._tx.events == null) {
|
38
|
+
this.data._tx.events = []
|
39
|
+
}
|
40
|
+
}
|
41
|
+
return this.data._tx
|
42
|
+
}
|
43
|
+
|
44
|
+
get event() {
|
45
|
+
if (!this.data._event) {
|
46
|
+
this.data._event = JSON.parse(this.data.rawEvent)
|
47
|
+
}
|
48
|
+
return this.data._event
|
49
|
+
}
|
50
|
+
|
51
|
+
async decodeEvent(coder: MoveCoder) {
|
52
|
+
if (!this.data._decodedEvent) {
|
53
|
+
this.data._decodedEvent = await coder.decodeEvent<any>(this.event)
|
54
|
+
return this.data._decodedEvent
|
55
|
+
}
|
56
|
+
return this.data._decodedEvent
|
57
|
+
}
|
58
|
+
}
|
59
|
+
|
60
|
+
export class AptCall implements Data_AptCall {
|
61
|
+
constructor(readonly data: Data_AptCall_Ext) {}
|
62
|
+
|
63
|
+
get rawTransaction(): string {
|
64
|
+
return this.data.rawTransaction
|
65
|
+
}
|
66
|
+
|
67
|
+
get transaction() {
|
68
|
+
if (!this.data._tx) {
|
69
|
+
this.data._tx = JSON.parse(this.data.rawTransaction) as UserTransactionResponse
|
70
|
+
if (this.data._tx.events == null) {
|
71
|
+
this.data._tx.events = []
|
72
|
+
}
|
73
|
+
}
|
74
|
+
return this.data._tx
|
75
|
+
}
|
76
|
+
|
77
|
+
async decodeCall(coder: MoveCoder) {
|
78
|
+
if (!this.data._decodedCall) {
|
79
|
+
const tx = this.transaction
|
80
|
+
let payload = tx.payload
|
81
|
+
if (payload.type === 'multisig_payload') {
|
82
|
+
payload = (payload as any).transaction_payload ?? payload
|
83
|
+
}
|
84
|
+
this.data._decodedCall = await coder.decodeFunctionPayload(payload as any)
|
85
|
+
return this.data._decodedCall
|
86
|
+
}
|
87
|
+
return this.data._decodedCall
|
88
|
+
}
|
89
|
+
}
|
90
|
+
|
91
|
+
export class AptResource implements Data_AptResource {
|
92
|
+
constructor(readonly data: Data_AptResource_Ext) {}
|
93
|
+
|
94
|
+
get version(): bigint {
|
95
|
+
return this.data.version
|
96
|
+
}
|
97
|
+
|
98
|
+
get timestampMicros(): bigint {
|
99
|
+
return this.data.timestampMicros
|
100
|
+
}
|
101
|
+
|
102
|
+
get rawResources(): string[] {
|
103
|
+
return this.data.rawResources
|
104
|
+
}
|
105
|
+
|
106
|
+
get resources(): MoveResource[] {
|
107
|
+
if (!this.data._resources) {
|
108
|
+
this.data._resources = this.data.rawResources.map((r) => JSON.parse(r) as MoveResource)
|
109
|
+
}
|
110
|
+
return this.data._resources
|
111
|
+
}
|
112
|
+
|
113
|
+
get timestamp(): Date {
|
114
|
+
return new Date(Number(this.data.timestampMicros) / 1000)
|
115
|
+
}
|
116
|
+
|
117
|
+
async decodeResources<T>(coder: MoveCoder): Promise<ResourceChange<T>[]> {
|
118
|
+
if (!this.data._decodedResources) {
|
119
|
+
this.data._decodedResources = await decodeResourceChange<T>(this.resources, coder)
|
120
|
+
}
|
121
|
+
return this.data._decodedResources as ResourceChange<T>[]
|
122
|
+
}
|
123
|
+
}
|
package/src/aptos/index.ts
CHANGED
package/src/aptos/models.ts
CHANGED
package/src/aptos/move-coder.ts
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
import { AptosNetwork, getClient } from './network.js'
|
2
|
-
import { MoveCoder } from '@typemove/aptos'
|
3
|
-
import { Aptos } from '@aptos-labs/ts-sdk'
|
2
|
+
import { MoveCoder, TypedFunctionPayload } from '@typemove/aptos'
|
3
|
+
import { Aptos, EntryFunctionPayloadResponse } from '@aptos-labs/ts-sdk'
|
4
|
+
import { TypeDescriptor, VECTOR_STR } from '@typemove/move'
|
4
5
|
|
5
6
|
const CODERS = new Map<AptosNetwork, MoveCoder>()
|
6
7
|
const URL_CODERS = new Map<string, MoveCoder>()
|
@@ -9,7 +10,8 @@ export function defaultMoveCoder(network: AptosNetwork = AptosNetwork.MAIN_NET):
|
|
9
10
|
let coder = CODERS.get(network)
|
10
11
|
if (!coder) {
|
11
12
|
const client = getClient(network)
|
12
|
-
|
13
|
+
|
14
|
+
coder = network == AptosNetwork.INITIA_ECHELON ? new InitiaMoveCoder(client) : new MoveCoder(client)
|
13
15
|
CODERS.set(network, coder)
|
14
16
|
URL_CODERS.set(client.config.fullnode || '', coder)
|
15
17
|
}
|
@@ -29,3 +31,94 @@ export function defaultMoveCoderForClient(client: Aptos): MoveCoder {
|
|
29
31
|
}
|
30
32
|
return coder
|
31
33
|
}
|
34
|
+
|
35
|
+
export class InitiaMoveCoder extends MoveCoder {
|
36
|
+
constructor(client: Aptos) {
|
37
|
+
super(client, true)
|
38
|
+
}
|
39
|
+
|
40
|
+
async decodeFunctionPayload<T extends Array<any>>(
|
41
|
+
payload: EntryFunctionPayloadResponse
|
42
|
+
): Promise<TypedFunctionPayload<T>> {
|
43
|
+
const func = await this.getMoveFunction(payload.function)
|
44
|
+
const paramsTypes = this.adapter.getMeaningfulFunctionParams(func.params)
|
45
|
+
const argumentsDecoded = []
|
46
|
+
|
47
|
+
for (let i = 0; i < paramsTypes.length; i++) {
|
48
|
+
const arg = payload.arguments[i]
|
49
|
+
const paramType = paramsTypes[i]
|
50
|
+
if (arg == null) {
|
51
|
+
argumentsDecoded.push(null)
|
52
|
+
} else {
|
53
|
+
argumentsDecoded.push(await this.decodeBase64(Buffer.from(arg, 'base64'), paramType))
|
54
|
+
}
|
55
|
+
}
|
56
|
+
|
57
|
+
return {
|
58
|
+
...payload,
|
59
|
+
arguments_decoded: argumentsDecoded
|
60
|
+
} as TypedFunctionPayload<T>
|
61
|
+
}
|
62
|
+
|
63
|
+
protected async decodeBase64(b: Buffer, type: TypeDescriptor): Promise<any> {
|
64
|
+
switch (type.qname.toLowerCase()) {
|
65
|
+
case 'signer': // TODO check this, aptos only
|
66
|
+
case 'address':
|
67
|
+
case '0x1::string::String':
|
68
|
+
return b.toString()
|
69
|
+
case 'bool':
|
70
|
+
return b.readUInt8() !== 0 // Convert first byte to boolean
|
71
|
+
case 'u8':
|
72
|
+
return b.readUInt8()
|
73
|
+
case 'u16':
|
74
|
+
return b.readUInt16LE()
|
75
|
+
case 'u32':
|
76
|
+
return b.readUInt32LE()
|
77
|
+
case 'u64':
|
78
|
+
return b.readBigUInt64LE()
|
79
|
+
case 'u128':
|
80
|
+
case 'u256':
|
81
|
+
const hex = b.toString('hex')
|
82
|
+
const reversedHex = hex.match(/.{2}/g)?.reverse().join('') || ''
|
83
|
+
return BigInt('0x' + reversedHex)
|
84
|
+
case '0x1::object::object':
|
85
|
+
return b.toString('hex')
|
86
|
+
case VECTOR_STR:
|
87
|
+
// vector<u8> as hex string
|
88
|
+
if (type.typeArgs[0].qname === 'u8' || type.typeArgs[0].qname === 'U8') {
|
89
|
+
return b.toString('hex')
|
90
|
+
}
|
91
|
+
|
92
|
+
console.warn(`can't decode vector type: ${type.qname}, data: ${b.toString('base64')}`)
|
93
|
+
return b.toString('base64')
|
94
|
+
default:
|
95
|
+
// try enum type first
|
96
|
+
const enumType = await this.maybeGetMoveEnum(type.qname)
|
97
|
+
if (enumType) {
|
98
|
+
return b.toString('utf-8')
|
99
|
+
}
|
100
|
+
|
101
|
+
// Process complex type
|
102
|
+
/*const struct = await this.getMoveStruct(type.qname)
|
103
|
+
|
104
|
+
const typeCtx = new Map<string, TypeDescriptor>()
|
105
|
+
for (const [idx, typeArg] of type.typeArgs.entries()) {
|
106
|
+
typeCtx.set('T' + idx, typeArg)
|
107
|
+
}
|
108
|
+
|
109
|
+
const typedData: any = {}
|
110
|
+
|
111
|
+
for (const field of struct.fields) {
|
112
|
+
let filedType = field.type
|
113
|
+
filedType = filedType.applyTypeArgs(typeCtx)
|
114
|
+
const fieldValue = this.adapter.getData(data)[field.name]
|
115
|
+
const value = await this.decode(fieldValue, filedType)
|
116
|
+
typedData[field.name] = value
|
117
|
+
}*/
|
118
|
+
|
119
|
+
// todo: how to decode complex type?
|
120
|
+
console.warn(`can't decode type:${type.qname}, data: ${b.toString('base64')}`)
|
121
|
+
return b.toString('hex')
|
122
|
+
}
|
123
|
+
}
|
124
|
+
}
|
package/src/aptos/network.ts
CHANGED
package/src/btc/btc-plugin.ts
CHANGED
@@ -7,10 +7,12 @@ import {
|
|
7
7
|
HandlerType,
|
8
8
|
ProcessConfigResponse,
|
9
9
|
ProcessResult,
|
10
|
+
ProcessStreamResponse_Partitions,
|
10
11
|
StartRequest
|
11
12
|
} from '@sentio/protos'
|
12
13
|
|
13
14
|
import { ServerError, Status } from 'nice-grpc'
|
15
|
+
import { PartitionHandlerManager } from '../core/index.js'
|
14
16
|
import { TemplateInstanceState } from '../core/template.js'
|
15
17
|
import { BTCProcessorState } from './btc-processor.js'
|
16
18
|
import { filters2Proto, TransactionFilter } from './filter.js'
|
@@ -27,6 +29,8 @@ export class BTCPlugin extends Plugin {
|
|
27
29
|
blockHandlers: []
|
28
30
|
}
|
29
31
|
|
32
|
+
partitionManager = new PartitionHandlerManager()
|
33
|
+
|
30
34
|
async configure(config: ProcessConfigResponse) {
|
31
35
|
const handlers: Handlers = {
|
32
36
|
txHandlers: [],
|
@@ -47,6 +51,11 @@ export class BTCPlugin extends Plugin {
|
|
47
51
|
})
|
48
52
|
for (const callHandler of processor.callHandlers) {
|
49
53
|
const handlerId = handlers.txHandlers.push(callHandler.handler) - 1
|
54
|
+
this.partitionManager.registerPartitionHandler(
|
55
|
+
HandlerType.BTC_TRANSACTION,
|
56
|
+
handlerId,
|
57
|
+
callHandler.partitionHandler
|
58
|
+
)
|
50
59
|
const handlerName = callHandler.handlerName
|
51
60
|
|
52
61
|
if (callHandler.filter) {
|
@@ -70,6 +79,7 @@ export class BTCPlugin extends Plugin {
|
|
70
79
|
|
71
80
|
for (const blockHandler of processor.blockHandlers) {
|
72
81
|
const handlerId = handlers.blockHandlers.push(blockHandler.handler) - 1
|
82
|
+
this.partitionManager.registerPartitionHandler(HandlerType.BTC_BLOCK, handlerId, blockHandler.partitionHandler)
|
73
83
|
contractConfig.intervalConfigs.push({
|
74
84
|
slot: 0,
|
75
85
|
slotInterval: blockHandler.blockInterval,
|
@@ -107,6 +117,34 @@ export class BTCPlugin extends Plugin {
|
|
107
117
|
}
|
108
118
|
}
|
109
119
|
|
120
|
+
async partition(request: DataBinding): Promise<ProcessStreamResponse_Partitions> {
|
121
|
+
let data: any
|
122
|
+
switch (request.handlerType) {
|
123
|
+
case HandlerType.BTC_TRANSACTION:
|
124
|
+
if (!request.data?.btcTransaction) {
|
125
|
+
throw new ServerError(Status.INVALID_ARGUMENT, "btcTransaction can't be empty")
|
126
|
+
}
|
127
|
+
data = request.data.btcTransaction
|
128
|
+
break
|
129
|
+
case HandlerType.BTC_BLOCK:
|
130
|
+
if (!request.data?.btcBlock) {
|
131
|
+
throw new ServerError(Status.INVALID_ARGUMENT, "btcBlock can't be empty")
|
132
|
+
}
|
133
|
+
data = request.data.btcBlock
|
134
|
+
break
|
135
|
+
default:
|
136
|
+
throw new ServerError(Status.INVALID_ARGUMENT, 'No handle type registered ' + request.handlerType)
|
137
|
+
}
|
138
|
+
const partitions = await this.partitionManager.processPartitionForHandlerType(
|
139
|
+
request.handlerType,
|
140
|
+
request.handlerIds,
|
141
|
+
data
|
142
|
+
)
|
143
|
+
return {
|
144
|
+
partitions
|
145
|
+
}
|
146
|
+
}
|
147
|
+
|
110
148
|
async start(request: StartRequest) {}
|
111
149
|
|
112
150
|
stateDiff(config: ProcessConfigResponse): boolean {
|
package/src/btc/btc-processor.ts
CHANGED
@@ -2,7 +2,7 @@ import { ListStateStorage } from '@sentio/runtime'
|
|
2
2
|
import { BlockHandler, BTCBlock, BTCBlockContext, BTCContext, BTCOnIntervalFetchConfig, Transaction } from './types.js'
|
3
3
|
import { Data_BTCBlock, Data_BTCTransaction, HandleInterval, ProcessResult } from '@sentio/protos'
|
4
4
|
import { TransactionFilters } from './filter.js'
|
5
|
-
import { PromiseOrVoid } from '../core/index.js'
|
5
|
+
import { HandlerOptions, PromiseOrVoid } from '../core/index.js'
|
6
6
|
import { ServerError, Status } from 'nice-grpc'
|
7
7
|
import { getHandlerName, proxyProcessor } from '../utils/metrics.js'
|
8
8
|
|
@@ -26,7 +26,8 @@ export class BTCProcessor {
|
|
26
26
|
|
27
27
|
public onTransaction(
|
28
28
|
handler: (transaction: Transaction, ctx: BTCContext) => void | Promise<void>,
|
29
|
-
filter?: TransactionFilters
|
29
|
+
filter?: TransactionFilters,
|
30
|
+
handlerOptions?: HandlerOptions<object, Transaction>
|
30
31
|
) {
|
31
32
|
const callHandler = {
|
32
33
|
handlerName: getHandlerName(),
|
@@ -42,7 +43,16 @@ export class BTCProcessor {
|
|
42
43
|
await handler(tx, ctx)
|
43
44
|
return ctx.stopAndGetResult()
|
44
45
|
},
|
45
|
-
filter
|
46
|
+
filter,
|
47
|
+
partitionHandler: async (call: Data_BTCTransaction): Promise<string | undefined> => {
|
48
|
+
const p = handlerOptions?.partitionKey
|
49
|
+
if (!p) return undefined
|
50
|
+
if (typeof p === 'function') {
|
51
|
+
const tx = call.transaction as Transaction
|
52
|
+
return p(tx)
|
53
|
+
}
|
54
|
+
return p
|
55
|
+
}
|
46
56
|
}
|
47
57
|
this.callHandlers.push(callHandler)
|
48
58
|
return this
|
@@ -52,7 +62,7 @@ export class BTCProcessor {
|
|
52
62
|
handler: (block: BTCBlock, ctx: BTCBlockContext) => PromiseOrVoid,
|
53
63
|
timeInterval: HandleInterval | undefined,
|
54
64
|
blockInterval: HandleInterval | undefined,
|
55
|
-
|
65
|
+
handlerOptions?: HandlerOptions<BTCOnIntervalFetchConfig, BTCBlock>
|
56
66
|
): this {
|
57
67
|
if (timeInterval) {
|
58
68
|
if (timeInterval.backfillInterval < timeInterval.recentInterval) {
|
@@ -75,7 +85,7 @@ export class BTCProcessor {
|
|
75
85
|
const block = {
|
76
86
|
...header
|
77
87
|
} as BTCBlock
|
78
|
-
if (
|
88
|
+
if (handlerOptions?.getTransactions) {
|
79
89
|
block.tx = header.rawtx?.map((tx: any) => tx as Transaction)
|
80
90
|
}
|
81
91
|
|
@@ -88,7 +98,21 @@ export class BTCProcessor {
|
|
88
98
|
await handler(block, ctx)
|
89
99
|
return ctx.stopAndGetResult()
|
90
100
|
},
|
91
|
-
fetchConfig
|
101
|
+
fetchConfig: handlerOptions,
|
102
|
+
partitionHandler: async (data: Data_BTCBlock): Promise<string | undefined> => {
|
103
|
+
const p = handlerOptions?.partitionKey
|
104
|
+
if (!p) return undefined
|
105
|
+
if (typeof p === 'function') {
|
106
|
+
const header = data.block
|
107
|
+
if (!header) return undefined
|
108
|
+
const block = { ...header } as BTCBlock
|
109
|
+
if (handlerOptions?.getTransactions) {
|
110
|
+
block.tx = header.rawtx?.map((tx: any) => tx as Transaction)
|
111
|
+
}
|
112
|
+
return p(block)
|
113
|
+
}
|
114
|
+
return p
|
115
|
+
}
|
92
116
|
})
|
93
117
|
return this
|
94
118
|
}
|
@@ -97,7 +121,7 @@ export class BTCProcessor {
|
|
97
121
|
handler: (block: BTCBlock, ctx: BTCBlockContext) => PromiseOrVoid,
|
98
122
|
blockInterval = 250,
|
99
123
|
backfillBlockInterval = 1000,
|
100
|
-
|
124
|
+
handlerOptions?: HandlerOptions<BTCOnIntervalFetchConfig, BTCBlock>
|
101
125
|
): this {
|
102
126
|
return this.onInterval(
|
103
127
|
handler,
|
@@ -106,7 +130,7 @@ export class BTCProcessor {
|
|
106
130
|
recentInterval: blockInterval,
|
107
131
|
backfillInterval: backfillBlockInterval
|
108
132
|
},
|
109
|
-
|
133
|
+
handlerOptions
|
110
134
|
)
|
111
135
|
}
|
112
136
|
|
@@ -114,13 +138,13 @@ export class BTCProcessor {
|
|
114
138
|
handler: (block: BTCBlock, ctx: BTCBlockContext) => PromiseOrVoid,
|
115
139
|
timeIntervalInMinutes = 60,
|
116
140
|
backfillTimeIntervalInMinutes = 240,
|
117
|
-
|
141
|
+
handlerOptions?: HandlerOptions<BTCOnIntervalFetchConfig, BTCBlock>
|
118
142
|
): this {
|
119
143
|
return this.onInterval(
|
120
144
|
handler,
|
121
145
|
{ recentInterval: timeIntervalInMinutes, backfillInterval: backfillTimeIntervalInMinutes },
|
122
146
|
undefined,
|
123
|
-
|
147
|
+
handlerOptions
|
124
148
|
)
|
125
149
|
}
|
126
150
|
}
|
@@ -137,4 +161,5 @@ export type CallHandler<T> = {
|
|
137
161
|
handlerName: string
|
138
162
|
handler: (call: T) => Promise<ProcessResult>
|
139
163
|
filter?: TransactionFilters
|
164
|
+
partitionHandler?: (call: T) => Promise<string | undefined>
|
140
165
|
}
|
package/src/btc/types.ts
CHANGED
@@ -126,8 +126,9 @@ export type BlockHandler = {
|
|
126
126
|
handler: (block: Data_BTCBlock) => Promise<ProcessResult>
|
127
127
|
handlerName: string
|
128
128
|
fetchConfig?: BTCOnIntervalFetchConfig
|
129
|
+
partitionHandler?: (block: Data_BTCBlock) => Promise<string | undefined>
|
129
130
|
}
|
130
131
|
|
131
132
|
export type BTCOnIntervalFetchConfig = {
|
132
|
-
getTransactions
|
133
|
+
getTransactions?: boolean
|
133
134
|
}
|
package/src/core/base-context.ts
CHANGED
@@ -1,15 +1,17 @@
|
|
1
1
|
import { ProcessResult, RecordMetaData } from '@sentio/protos'
|
2
|
-
import { EventLoggerBinding } from './event-logger.js'
|
3
|
-
import { Meter, Labels } from './meter.js'
|
2
|
+
import { EventLoggerBinding, EventLoggerBindingNew } from './event-logger.js'
|
3
|
+
import { Meter, Labels, MeterNew } from './meter.js'
|
4
4
|
import { ChainId } from '@sentio/chain'
|
5
|
-
import {
|
5
|
+
import { mergeProcessResultsInPlace, PluginManager } from '@sentio/runtime'
|
6
6
|
import { Required } from 'utility-types'
|
7
7
|
import { ServerError, Status } from 'nice-grpc'
|
8
8
|
import { Store } from '../store/store.js'
|
9
9
|
|
10
10
|
export abstract class BaseContext {
|
11
11
|
meter: Meter
|
12
|
+
meterNew: MeterNew
|
12
13
|
eventLogger: EventLoggerBinding
|
14
|
+
eventLoggerNew: EventLoggerBindingNew
|
13
15
|
private _store: Store
|
14
16
|
baseLabels: Labels
|
15
17
|
private active: boolean
|
@@ -21,12 +23,13 @@ export abstract class BaseContext {
|
|
21
23
|
gauges: [],
|
22
24
|
states: {
|
23
25
|
configUpdated: false
|
24
|
-
}
|
26
|
+
},
|
27
|
+
timeseriesResult: []
|
25
28
|
}
|
26
29
|
|
27
30
|
public update(res: Partial<ProcessResult>) {
|
28
31
|
if (this.active) {
|
29
|
-
|
32
|
+
mergeProcessResultsInPlace(this._res, [ProcessResult.fromPartial(res)])
|
30
33
|
} else {
|
31
34
|
throw new ServerError(Status.INTERNAL, 'context not active, possible async function invoke without await')
|
32
35
|
}
|
@@ -34,7 +37,9 @@ export abstract class BaseContext {
|
|
34
37
|
|
35
38
|
protected constructor(baseLabels: Labels | undefined) {
|
36
39
|
this.meter = new Meter(this)
|
40
|
+
this.meterNew = new MeterNew(this)
|
37
41
|
this.eventLogger = new EventLoggerBinding(this)
|
42
|
+
this.eventLoggerNew = new EventLoggerBindingNew(this)
|
38
43
|
this.baseLabels = baseLabels || {}
|
39
44
|
this.active = true
|
40
45
|
this.initStore()
|
package/src/core/event-logger.ts
CHANGED
@@ -6,7 +6,10 @@ import {
|
|
6
6
|
EventLogConfig_Field,
|
7
7
|
EventLogConfig_StructFieldType,
|
8
8
|
EventTrackingResult,
|
9
|
-
LogLevel
|
9
|
+
LogLevel,
|
10
|
+
RichStruct,
|
11
|
+
TimeseriesResult,
|
12
|
+
TimeseriesResult_TimeseriesType
|
10
13
|
} from '@sentio/protos'
|
11
14
|
import { normalizeAttribute, normalizeLabels, normalizeToRichStruct } from './normalization.js'
|
12
15
|
import { MapStateStorage, processMetrics } from '@sentio/runtime'
|
@@ -141,3 +144,44 @@ function checkEventName(eventName: string) {
|
|
141
144
|
throw new Error(`Event name ${eventName} is already used in the database schema`)
|
142
145
|
}
|
143
146
|
}
|
147
|
+
|
148
|
+
function emitNew<T>(ctx: BaseContext, eventName: string, event: Event<T>) {
|
149
|
+
const { distinctId, severity, message, ...payload } = event
|
150
|
+
|
151
|
+
const data: RichStruct = {
|
152
|
+
fields: {
|
153
|
+
severity: {
|
154
|
+
stringValue: (severity || LogLevel.INFO).toString()
|
155
|
+
},
|
156
|
+
message: {
|
157
|
+
stringValue: message || ''
|
158
|
+
},
|
159
|
+
distinctEntityId: {
|
160
|
+
stringValue: distinctId || ''
|
161
|
+
},
|
162
|
+
...normalizeToRichStruct(ctx.baseLabels, payload).fields
|
163
|
+
}
|
164
|
+
}
|
165
|
+
const res: TimeseriesResult = {
|
166
|
+
metadata: ctx.getMetaData(eventName, {}),
|
167
|
+
type: TimeseriesResult_TimeseriesType.EVENT,
|
168
|
+
data,
|
169
|
+
runtimeInfo: undefined
|
170
|
+
}
|
171
|
+
|
172
|
+
processMetrics.process_eventemit_count.add(1)
|
173
|
+
ctx.update({ timeseriesResult: [res] })
|
174
|
+
}
|
175
|
+
|
176
|
+
export class EventLoggerBindingNew {
|
177
|
+
private readonly ctx: BaseContext
|
178
|
+
|
179
|
+
constructor(ctx: BaseContext) {
|
180
|
+
this.ctx = ctx
|
181
|
+
}
|
182
|
+
|
183
|
+
emit<T>(eventName: string, event: Event<T>) {
|
184
|
+
checkEventName(eventName)
|
185
|
+
emitNew(this.ctx, eventName, event)
|
186
|
+
}
|
187
|
+
}
|
@@ -0,0 +1,40 @@
|
|
1
|
+
/**
|
2
|
+
* Function type that extracts a partition key from data.
|
3
|
+
* @template D The data type to process
|
4
|
+
*/
|
5
|
+
export type PartitionHandler<D> = (data: D) => string | Promise<string>
|
6
|
+
|
7
|
+
/**
|
8
|
+
* Handler options that extend fetch configuration with optional partitioning support.
|
9
|
+
* @template F The fetch configuration type (e.g., EthFetchConfig, MoveFetchConfig)
|
10
|
+
* @template D The data type that will be processed (e.g., Event, Transaction, Block)
|
11
|
+
*/
|
12
|
+
export type HandlerOptions<F, D> = Partial<F> & {
|
13
|
+
/**
|
14
|
+
* Optional partition key for data partitioning.
|
15
|
+
* Can be a static string or a function that computes the key from the data.
|
16
|
+
*/
|
17
|
+
partitionKey?: string | PartitionHandler<D>
|
18
|
+
}
|
19
|
+
|
20
|
+
/**
|
21
|
+
* Merge two handler options, with the second options taking precedence over the first.
|
22
|
+
* @param options1 First handler options
|
23
|
+
* @param options2 Second handler options (takes precedence)
|
24
|
+
* @returns Merged handler options
|
25
|
+
*/
|
26
|
+
export function mergeHandlerOptions<F, D>(
|
27
|
+
options1?: HandlerOptions<F, D>,
|
28
|
+
options2?: HandlerOptions<F, D>
|
29
|
+
): HandlerOptions<F, D> | undefined {
|
30
|
+
if (!options1 && !options2) return undefined
|
31
|
+
if (!options1) return options2
|
32
|
+
if (!options2) return options1
|
33
|
+
|
34
|
+
return {
|
35
|
+
...options1,
|
36
|
+
...options2,
|
37
|
+
// For partitionKey, the second option takes precedence
|
38
|
+
partitionKey: options2.partitionKey ?? options1.partitionKey
|
39
|
+
}
|
40
|
+
}
|
package/src/core/index.ts
CHANGED
@@ -3,7 +3,18 @@ export type { PromiseOrValue, PromiseOrVoid } from './promises.js'
|
|
3
3
|
export type { PartiallyOptional } from './partial-optional.js'
|
4
4
|
export { BaseContext } from './base-context.js'
|
5
5
|
export { normalizeLabels } from './normalization.js'
|
6
|
-
export {
|
6
|
+
export {
|
7
|
+
CounterBinding,
|
8
|
+
Meter,
|
9
|
+
type Labels,
|
10
|
+
GaugeBinding,
|
11
|
+
Counter,
|
12
|
+
Gauge,
|
13
|
+
MetricOptions,
|
14
|
+
CounterNew,
|
15
|
+
GaugeNew,
|
16
|
+
MeterNew
|
17
|
+
} from './meter.js'
|
7
18
|
export { Exporter } from './exporter.js'
|
8
19
|
export * from './event-logger.js'
|
9
20
|
export { type Numberish, toBigInteger, toMetricValue } from './numberish.js'
|
@@ -11,3 +22,8 @@ export { type Numberish, toBigInteger, toMetricValue } from './numberish.js'
|
|
11
22
|
export { CorePlugin } from './core-plugin.js'
|
12
23
|
export { DatabaseSchema } from './database-schema.js'
|
13
24
|
export * from './constants.js'
|
25
|
+
export { type HandlerOptions, type PartitionHandler, mergeHandlerOptions } from './handler-options.js'
|
26
|
+
export {
|
27
|
+
PartitionHandlerManager,
|
28
|
+
type PartitionHandler as PartitionHandlerFunction
|
29
|
+
} from './partition-handler-manager.js'
|