@sentio/sdk 2.54.0-rc.1 → 2.54.0-rc.11
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.map +1 -1
- package/lib/aptos/aptos-plugin.js +6 -2
- package/lib/aptos/aptos-plugin.js.map +1 -1
- package/lib/aptos/aptos-processor.d.ts.map +1 -1
- package/lib/aptos/aptos-processor.js +7 -0
- package/lib/aptos/aptos-processor.js.map +1 -1
- package/lib/aptos/builtin/0x1.d.ts +840 -815
- package/lib/aptos/builtin/0x1.d.ts.map +1 -1
- package/lib/aptos/builtin/0x1.js +1200 -1137
- package/lib/aptos/builtin/0x1.js.map +1 -1
- package/lib/aptos/builtin/0x3.d.ts +67 -52
- package/lib/aptos/builtin/0x3.d.ts.map +1 -1
- package/lib/aptos/builtin/0x3.js +66 -53
- package/lib/aptos/builtin/0x3.js.map +1 -1
- package/lib/aptos/builtin/0x4.d.ts +113 -113
- package/lib/aptos/builtin/0x4.d.ts.map +1 -1
- package/lib/aptos/builtin/0x4.js +149 -149
- package/lib/aptos/builtin/0x4.js.map +1 -1
- package/lib/btc/btc-plugin.d.ts.map +1 -1
- package/lib/btc/btc-plugin.js +5 -2
- package/lib/btc/btc-plugin.js.map +1 -1
- package/lib/btc/btc-processor.d.ts +1 -0
- package/lib/btc/btc-processor.d.ts.map +1 -1
- package/lib/btc/btc-processor.js +1 -0
- package/lib/btc/btc-processor.js.map +1 -1
- package/lib/cosmos/cosmos-plugin.d.ts.map +1 -1
- package/lib/cosmos/cosmos-plugin.js +1 -0
- package/lib/cosmos/cosmos-plugin.js.map +1 -1
- package/lib/cosmos/cosmos-processor.d.ts.map +1 -1
- package/lib/cosmos/cosmos-processor.js +3 -0
- 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.map +1 -1
- package/lib/eth/base-processor.js +1 -0
- package/lib/eth/base-processor.js.map +1 -1
- package/lib/fuel/asset-processor.d.ts.map +1 -1
- package/lib/fuel/asset-processor.js +3 -0
- package/lib/fuel/asset-processor.js.map +1 -1
- package/lib/fuel/base-processor.d.ts.map +1 -1
- package/lib/fuel/base-processor.js +2 -0
- package/lib/fuel/base-processor.js.map +1 -1
- package/lib/fuel/fuel-plugin.d.ts +4 -2
- package/lib/fuel/fuel-plugin.d.ts.map +1 -1
- package/lib/fuel/fuel-plugin.js +58 -25
- package/lib/fuel/fuel-plugin.js.map +1 -1
- package/lib/fuel/fuel-processor.d.ts +3 -2
- package/lib/fuel/fuel-processor.d.ts.map +1 -1
- package/lib/fuel/fuel-processor.js +22 -24
- package/lib/fuel/fuel-processor.js.map +1 -1
- package/lib/fuel/global-processor.d.ts.map +1 -1
- package/lib/fuel/global-processor.js +3 -0
- package/lib/fuel/global-processor.js.map +1 -1
- package/lib/fuel/transaction.d.ts +5 -1
- package/lib/fuel/transaction.d.ts.map +1 -1
- package/lib/fuel/transaction.js +17 -10
- package/lib/fuel/transaction.js.map +1 -1
- package/lib/fuel/types.d.ts +7 -1
- package/lib/fuel/types.d.ts.map +1 -1
- package/lib/fuel/types.js.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/stark/starknet-plugin.d.ts.map +1 -1
- package/lib/stark/starknet-plugin.js +2 -1
- package/lib/stark/starknet-plugin.js.map +1 -1
- package/lib/stark/starknet-processor.d.ts +1 -0
- package/lib/stark/starknet-processor.d.ts.map +1 -1
- package/lib/stark/starknet-processor.js +4 -0
- package/lib/stark/starknet-processor.js.map +1 -1
- package/lib/sui/builtin/0x1.d.ts +83 -0
- package/lib/sui/builtin/0x1.d.ts.map +1 -1
- package/lib/sui/builtin/0x1.js +345 -1
- package/lib/sui/builtin/0x1.js.map +1 -1
- package/lib/sui/context.d.ts +1 -0
- package/lib/sui/context.d.ts.map +1 -1
- package/lib/sui/context.js +2 -0
- package/lib/sui/context.js.map +1 -1
- package/lib/sui/sui-object-processor.d.ts.map +1 -1
- package/lib/sui/sui-object-processor.js +2 -0
- package/lib/sui/sui-object-processor.js.map +1 -1
- package/lib/sui/sui-plugin.d.ts.map +1 -1
- package/lib/sui/sui-plugin.js +10 -5
- package/lib/sui/sui-plugin.js.map +1 -1
- package/lib/sui/sui-processor.d.ts.map +1 -1
- package/lib/sui/sui-processor.js +6 -0
- package/lib/sui/sui-processor.js.map +1 -1
- package/lib/testing/fuel-facet.d.ts.map +1 -1
- package/lib/testing/fuel-facet.js +8 -7
- package/lib/testing/fuel-facet.js.map +1 -1
- package/package.json +8 -8
- package/src/aptos/abis/0x1.json +3816 -3657
- package/src/aptos/abis/0x3.json +247 -219
- package/src/aptos/abis/0x4.json +576 -576
- package/src/aptos/aptos-plugin.ts +6 -2
- package/src/aptos/aptos-processor.ts +8 -0
- package/src/aptos/builtin/0x1.ts +2374 -2235
- package/src/aptos/builtin/0x3.ts +154 -113
- package/src/aptos/builtin/0x4.ts +280 -282
- package/src/btc/btc-plugin.ts +5 -2
- package/src/btc/btc-processor.ts +2 -0
- package/src/cosmos/cosmos-plugin.ts +1 -0
- package/src/cosmos/cosmos-processor.ts +5 -1
- package/src/cosmos/types.ts +1 -0
- package/src/eth/base-processor.ts +2 -0
- package/src/fuel/asset-processor.ts +5 -1
- package/src/fuel/base-processor.ts +2 -0
- package/src/fuel/fuel-plugin.ts +66 -24
- package/src/fuel/fuel-processor.ts +38 -31
- package/src/fuel/global-processor.ts +5 -1
- package/src/fuel/transaction.ts +18 -9
- package/src/fuel/types.ts +8 -0
- package/src/move/filter.ts +4 -0
- package/src/stark/starknet-plugin.ts +2 -1
- package/src/stark/starknet-processor.ts +7 -1
- package/src/sui/abis/0x1.json +391 -0
- package/src/sui/builtin/0x1.ts +510 -1
- package/src/sui/context.ts +2 -0
- package/src/sui/sui-object-processor.ts +2 -0
- package/src/sui/sui-plugin.ts +10 -5
- package/src/sui/sui-processor.ts +7 -0
- package/src/testing/fuel-facet.ts +8 -7
package/src/btc/btc-plugin.ts
CHANGED
@@ -47,11 +47,13 @@ export class BTCPlugin extends Plugin {
|
|
47
47
|
})
|
48
48
|
for (const callHandler of processor.callHandlers) {
|
49
49
|
const handlerId = handlers.txHandlers.push(callHandler.handler) - 1
|
50
|
+
const handlerName = callHandler.handlerName
|
50
51
|
|
51
52
|
if (callHandler.filter) {
|
52
53
|
contractConfig.btcTransactionConfigs.push({
|
53
54
|
filters: filters2Proto(callHandler.filter),
|
54
|
-
handlerId
|
55
|
+
handlerId,
|
56
|
+
handlerName
|
55
57
|
})
|
56
58
|
} else if (contractConfig.contract?.address != '*') {
|
57
59
|
contractConfig.btcTransactionConfigs.push({
|
@@ -60,7 +62,8 @@ export class BTCPlugin extends Plugin {
|
|
60
62
|
script_address: processor.config.address
|
61
63
|
}
|
62
64
|
} as TransactionFilter),
|
63
|
-
handlerId
|
65
|
+
handlerId,
|
66
|
+
handlerName
|
64
67
|
})
|
65
68
|
}
|
66
69
|
}
|
package/src/btc/btc-processor.ts
CHANGED
@@ -29,6 +29,7 @@ export class BTCProcessor {
|
|
29
29
|
filter?: TransactionFilters
|
30
30
|
) {
|
31
31
|
const callHandler = {
|
32
|
+
handlerName: getHandlerName(),
|
32
33
|
handler: async (call: Data_BTCTransaction) => {
|
33
34
|
const tx = call.transaction as Transaction
|
34
35
|
|
@@ -133,6 +134,7 @@ interface BTCProcessorConfig {
|
|
133
134
|
}
|
134
135
|
|
135
136
|
export type CallHandler<T> = {
|
137
|
+
handlerName: string
|
136
138
|
handler: (call: T) => Promise<ProcessResult>
|
137
139
|
filter?: TransactionFilters
|
138
140
|
}
|
@@ -2,11 +2,14 @@ import { CallHandler, CosmosProcessorConfig, CosmosProcessorState } from './type
|
|
2
2
|
import { Data_CosmosCall } from '@sentio/protos'
|
3
3
|
import { CosmosContext } from './context.js'
|
4
4
|
import { CosmosEvent, CosmosTransaction, CosmosTxLog } from './transaction.js'
|
5
|
+
import { getHandlerName, proxyProcessor } from '../utils/metrics.js'
|
5
6
|
|
6
7
|
export class CosmosProcessor {
|
7
8
|
callHandlers: CallHandler<Data_CosmosCall>[] = []
|
8
9
|
|
9
|
-
constructor(readonly config: CosmosProcessorConfig) {
|
10
|
+
constructor(readonly config: CosmosProcessorConfig) {
|
11
|
+
return proxyProcessor(this)
|
12
|
+
}
|
10
13
|
|
11
14
|
static bind(config: CosmosProcessorConfig): CosmosProcessor {
|
12
15
|
const processor = new CosmosProcessor(config)
|
@@ -20,6 +23,7 @@ export class CosmosProcessor {
|
|
20
23
|
) {
|
21
24
|
const filter = Array.isArray(logFilters) ? logFilters : [logFilters]
|
22
25
|
const callHandler = {
|
26
|
+
handlerName: getHandlerName(),
|
23
27
|
handler: async (call: Data_CosmosCall) => {
|
24
28
|
const transaction = call.transaction as CosmosTransaction
|
25
29
|
|
package/src/cosmos/types.ts
CHANGED
@@ -5,6 +5,7 @@ import { FuelContext } from './context.js'
|
|
5
5
|
import { decodeFuelTransaction } from './transaction.js'
|
6
6
|
import { Provider, InputType, OutputType } from 'fuels'
|
7
7
|
import { getOptionsSignature } from './fuel-processor.js'
|
8
|
+
import { getHandlerName, proxyProcessor } from '../utils/metrics.js'
|
8
9
|
|
9
10
|
export class FuelAssetProcessor implements FuelBaseProcessor<FuelAssetProcessorConfig> {
|
10
11
|
callHandlers: CallHandler<Data_FuelCall>[] = []
|
@@ -23,7 +24,9 @@ export class FuelAssetProcessor implements FuelBaseProcessor<FuelAssetProcessorC
|
|
23
24
|
return processor
|
24
25
|
}
|
25
26
|
|
26
|
-
constructor(readonly config: FuelAssetProcessorConfig) {
|
27
|
+
constructor(readonly config: FuelAssetProcessorConfig) {
|
28
|
+
return proxyProcessor(this)
|
29
|
+
}
|
27
30
|
|
28
31
|
async configure(): Promise<void> {
|
29
32
|
this.provider = await getProvider(this.config.chainId)
|
@@ -49,6 +52,7 @@ export class FuelAssetProcessor implements FuelBaseProcessor<FuelAssetProcessorC
|
|
49
52
|
}
|
50
53
|
|
51
54
|
const callHandler = {
|
55
|
+
handlerName: getHandlerName(),
|
52
56
|
handler: async (call: Data_FuelCall) => {
|
53
57
|
const gqlTransaction = call.transaction
|
54
58
|
const tx = decodeFuelTransaction(gqlTransaction, this.provider)
|
@@ -3,6 +3,7 @@ import { Contract, JsonAbi } from 'fuels'
|
|
3
3
|
// import { FuelCall } from './context.js'
|
4
4
|
import { FuelChainId } from '@sentio/chain'
|
5
5
|
import { FuelLog } from './types.js'
|
6
|
+
import { proxyProcessor } from '../utils/metrics.js'
|
6
7
|
|
7
8
|
export abstract class FuelAbstractProcessor<TContract extends Contract> extends FuelProcessor<TContract> {
|
8
9
|
protected constructor(abi: JsonAbi, config?: Omit<FuelProcessorConfig, 'abi'>) {
|
@@ -17,6 +18,7 @@ export abstract class FuelAbstractProcessor<TContract extends Contract> extends
|
|
17
18
|
abi
|
18
19
|
})
|
19
20
|
addFuelProcessor(config, this)
|
21
|
+
return proxyProcessor(this)
|
20
22
|
}
|
21
23
|
}
|
22
24
|
|
package/src/fuel/fuel-plugin.ts
CHANGED
@@ -3,6 +3,7 @@ import {
|
|
3
3
|
ContractConfig,
|
4
4
|
Data_FuelBlock,
|
5
5
|
Data_FuelCall,
|
6
|
+
Data_FuelReceipt,
|
6
7
|
DataBinding,
|
7
8
|
HandlerType,
|
8
9
|
ProcessConfigResponse,
|
@@ -18,21 +19,24 @@ import { FuelProcessor } from './fuel-processor.js'
|
|
18
19
|
import { FuelGlobalProcessor } from './global-processor.js'
|
19
20
|
|
20
21
|
interface Handlers {
|
21
|
-
|
22
|
+
transactionHandlers: ((trace: Data_FuelCall) => Promise<ProcessResult>)[]
|
22
23
|
blockHandlers: ((block: Data_FuelBlock) => Promise<ProcessResult>)[]
|
24
|
+
logHandlers: ((log: Data_FuelReceipt) => Promise<ProcessResult>)[]
|
23
25
|
}
|
24
26
|
|
25
27
|
export class FuelPlugin extends Plugin {
|
26
28
|
name: string = 'FuelPlugin'
|
27
29
|
handlers: Handlers = {
|
28
|
-
|
29
|
-
blockHandlers: []
|
30
|
+
transactionHandlers: [],
|
31
|
+
blockHandlers: [],
|
32
|
+
logHandlers: []
|
30
33
|
}
|
31
34
|
|
32
35
|
async configure(config: ProcessConfigResponse) {
|
33
36
|
const handlers: Handlers = {
|
34
|
-
|
35
|
-
blockHandlers: []
|
37
|
+
transactionHandlers: [],
|
38
|
+
blockHandlers: [],
|
39
|
+
logHandlers: []
|
36
40
|
}
|
37
41
|
|
38
42
|
for (const processor of FuelProcessorState.INSTANCE.getValues()) {
|
@@ -48,29 +52,27 @@ export class FuelPlugin extends Plugin {
|
|
48
52
|
endBlock: processor.config.endBlock
|
49
53
|
})
|
50
54
|
for (const callHandler of processor.callHandlers) {
|
51
|
-
const handlerId = handlers.
|
55
|
+
const handlerId = handlers.transactionHandlers.push(callHandler.handler) - 1
|
56
|
+
const handlerName = callHandler.handlerName
|
52
57
|
if (processor instanceof FuelProcessor) {
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
} else {
|
59
|
-
const fetchConfig = {
|
60
|
-
handlerId,
|
61
|
-
filters: callHandler.fetchConfig?.filters || []
|
62
|
-
}
|
63
|
-
contractConfig.fuelCallConfigs.push(fetchConfig)
|
58
|
+
// on transaction
|
59
|
+
const fetchConfig = {
|
60
|
+
handlerId,
|
61
|
+
handlerName,
|
62
|
+
filters: callHandler.fetchConfig?.filters || []
|
64
63
|
}
|
64
|
+
contractConfig.fuelCallConfigs.push(fetchConfig)
|
65
65
|
} else if (processor instanceof FuelAssetProcessor) {
|
66
66
|
const assetConfig = callHandler.assetConfig
|
67
67
|
contractConfig.assetConfigs.push({
|
68
68
|
filters: assetConfig?.filters || [],
|
69
|
-
handlerId
|
69
|
+
handlerId,
|
70
|
+
handlerName
|
70
71
|
})
|
71
72
|
} else if (processor instanceof FuelGlobalProcessor) {
|
72
73
|
const fetchConfig = {
|
73
74
|
handlerId,
|
75
|
+
handlerName,
|
74
76
|
filters: []
|
75
77
|
}
|
76
78
|
contractConfig.fuelCallConfigs.push(fetchConfig)
|
@@ -78,6 +80,18 @@ export class FuelPlugin extends Plugin {
|
|
78
80
|
}
|
79
81
|
}
|
80
82
|
|
83
|
+
for (const logHandler of processor.logHandlers ?? []) {
|
84
|
+
const handlerId = handlers.logHandlers.push(logHandler.handler) - 1
|
85
|
+
const handlerName = logHandler.handlerName
|
86
|
+
if (processor instanceof FuelProcessor) {
|
87
|
+
contractConfig.fuelLogConfigs.push({
|
88
|
+
logIds: logHandler.logConfig?.logIds || [],
|
89
|
+
handlerId,
|
90
|
+
handlerName
|
91
|
+
})
|
92
|
+
}
|
93
|
+
}
|
94
|
+
|
81
95
|
for (const blockHandler of processor.blockHandlers) {
|
82
96
|
const handlerId = handlers.blockHandlers.push(blockHandler.handler) - 1
|
83
97
|
contractConfig.intervalConfigs.push({
|
@@ -92,19 +106,25 @@ export class FuelPlugin extends Plugin {
|
|
92
106
|
})
|
93
107
|
}
|
94
108
|
|
95
|
-
// Finish up a contract
|
96
109
|
config.contractConfigs.push(contractConfig)
|
97
110
|
}
|
98
111
|
|
99
112
|
this.handlers = handlers
|
100
113
|
}
|
101
114
|
|
102
|
-
supportedHandlers = [
|
115
|
+
supportedHandlers = [
|
116
|
+
HandlerType.FUEL_TRANSACTION,
|
117
|
+
HandlerType.FUEL_RECEIPT,
|
118
|
+
HandlerType.FUEL_CALL,
|
119
|
+
HandlerType.FUEL_BLOCK
|
120
|
+
]
|
103
121
|
|
104
122
|
processBinding(request: DataBinding): Promise<ProcessResult> {
|
105
123
|
switch (request.handlerType) {
|
106
|
-
case HandlerType.
|
124
|
+
case HandlerType.FUEL_TRANSACTION:
|
107
125
|
return this.processTransaction(request)
|
126
|
+
case HandlerType.FUEL_RECEIPT:
|
127
|
+
return this.processLog(request)
|
108
128
|
case HandlerType.FUEL_BLOCK:
|
109
129
|
return this.processBlock(request)
|
110
130
|
default:
|
@@ -126,16 +146,38 @@ export class FuelPlugin extends Plugin {
|
|
126
146
|
return TemplateInstanceState.INSTANCE.getValues().length !== config.templateInstances.length
|
127
147
|
}
|
128
148
|
|
149
|
+
async processLog(binding: DataBinding): Promise<ProcessResult> {
|
150
|
+
if (!binding.data?.fuelLog?.transaction) {
|
151
|
+
throw new ServerError(Status.INVALID_ARGUMENT, "transaction can't be null")
|
152
|
+
}
|
153
|
+
const log = binding.data.fuelLog
|
154
|
+
|
155
|
+
const promises: Promise<ProcessResult>[] = []
|
156
|
+
|
157
|
+
for (const handlerId of binding.handlerIds) {
|
158
|
+
const promise = this.handlers.logHandlers[handlerId](log).catch((e) => {
|
159
|
+
throw new ServerError(
|
160
|
+
Status.INTERNAL,
|
161
|
+
'error processing transaction: ' + JSON.stringify(log) + '\n' + errorString(e)
|
162
|
+
)
|
163
|
+
})
|
164
|
+
if (GLOBAL_CONFIG.execution.sequential) {
|
165
|
+
await promise
|
166
|
+
}
|
167
|
+
promises.push(promise)
|
168
|
+
}
|
169
|
+
return mergeProcessResults(await Promise.all(promises))
|
170
|
+
}
|
129
171
|
async processTransaction(binding: DataBinding): Promise<ProcessResult> {
|
130
|
-
if (!binding.data?.
|
172
|
+
if (!binding.data?.fuelTransaction?.transaction) {
|
131
173
|
throw new ServerError(Status.INVALID_ARGUMENT, "transaction can't be null")
|
132
174
|
}
|
133
|
-
const fuelTransaction = binding.data.
|
175
|
+
const fuelTransaction = binding.data.fuelTransaction
|
134
176
|
|
135
177
|
const promises: Promise<ProcessResult>[] = []
|
136
178
|
|
137
179
|
for (const handlerId of binding.handlerIds) {
|
138
|
-
const promise = this.handlers.
|
180
|
+
const promise = this.handlers.transactionHandlers[handlerId](fuelTransaction).catch((e) => {
|
139
181
|
throw new ServerError(
|
140
182
|
Status.INTERNAL,
|
141
183
|
'error processing transaction: ' + JSON.stringify(fuelTransaction.transaction) + '\n' + errorString(e)
|
@@ -1,8 +1,21 @@
|
|
1
|
-
import {
|
1
|
+
import {
|
2
|
+
Data_FuelBlock,
|
3
|
+
Data_FuelCall,
|
4
|
+
Data_FuelReceipt,
|
5
|
+
FuelCallFilter,
|
6
|
+
HandleInterval,
|
7
|
+
ProcessResult
|
8
|
+
} from '@sentio/protos'
|
2
9
|
import { FuelCall, FuelContext, FuelContractContext } from './context.js'
|
3
10
|
import { bn, Contract, Interface, JsonAbi, Provider } from 'fuels'
|
4
11
|
import { FuelNetwork, getProvider } from './network.js'
|
5
|
-
import {
|
12
|
+
import {
|
13
|
+
decodeFuelTransaction,
|
14
|
+
decodeFuelTransactionWithAbi,
|
15
|
+
decodeLog,
|
16
|
+
DEFAULT_FUEL_FETCH_CONFIG,
|
17
|
+
FuelFetchConfig
|
18
|
+
} from './transaction.js'
|
6
19
|
import {
|
7
20
|
BlockHandler,
|
8
21
|
CallHandler,
|
@@ -10,9 +23,9 @@ import {
|
|
10
23
|
FuelBlock,
|
11
24
|
FuelLog,
|
12
25
|
FuelProcessorState,
|
13
|
-
FuelTransaction
|
26
|
+
FuelTransaction,
|
27
|
+
LogHandler
|
14
28
|
} from './types.js'
|
15
|
-
import { mergeProcessResults } from '@sentio/runtime'
|
16
29
|
import { PromiseOrVoid } from '../core/index.js'
|
17
30
|
import { ServerError, Status } from 'nice-grpc'
|
18
31
|
import { getHandlerName, proxyProcessor } from '../utils/metrics.js'
|
@@ -20,6 +33,7 @@ import { getHandlerName, proxyProcessor } from '../utils/metrics.js'
|
|
20
33
|
export class FuelProcessor<TContract extends Contract> implements FuelBaseProcessor<FuelProcessorConfig> {
|
21
34
|
callHandlers: CallHandler<Data_FuelCall>[] = []
|
22
35
|
blockHandlers: BlockHandler[] = []
|
36
|
+
logHandlers: LogHandler<Data_FuelReceipt>[] = []
|
23
37
|
|
24
38
|
private provider: Provider
|
25
39
|
private contract: TContract
|
@@ -35,6 +49,7 @@ export class FuelProcessor<TContract extends Contract> implements FuelBaseProces
|
|
35
49
|
}
|
36
50
|
|
37
51
|
latestGasPrice: string | undefined
|
52
|
+
|
38
53
|
async configure() {
|
39
54
|
this.provider = await getProvider(this.config.chainId)
|
40
55
|
this.provider.getLatestGasPrice = async () => {
|
@@ -55,6 +70,7 @@ export class FuelProcessor<TContract extends Contract> implements FuelBaseProces
|
|
55
70
|
config: FuelFetchConfig = DEFAULT_FUEL_FETCH_CONFIG
|
56
71
|
) {
|
57
72
|
const callHandler = {
|
73
|
+
handlerName: getHandlerName(),
|
58
74
|
handler: async (call: Data_FuelCall) => {
|
59
75
|
const abiMap = this.config.abi
|
60
76
|
? {
|
@@ -113,6 +129,7 @@ export class FuelProcessor<TContract extends Contract> implements FuelBaseProces
|
|
113
129
|
}
|
114
130
|
|
115
131
|
const callHandler = {
|
132
|
+
handlerName: getHandlerName(),
|
116
133
|
handler: async (call: Data_FuelCall) => {
|
117
134
|
try {
|
118
135
|
// const contract = new Contract(this.config.address, abi, this.provider)
|
@@ -167,51 +184,41 @@ export class FuelProcessor<TContract extends Contract> implements FuelBaseProces
|
|
167
184
|
) {
|
168
185
|
const logIds = new Set(Array.isArray(logIdFilter) ? logIdFilter : [logIdFilter])
|
169
186
|
|
170
|
-
const
|
171
|
-
|
187
|
+
const logHandler = {
|
188
|
+
handlerName: getHandlerName(),
|
189
|
+
handler: async ({ transaction, receiptIndex, timestamp }: Data_FuelReceipt) => {
|
172
190
|
try {
|
173
|
-
const
|
174
|
-
const
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
)
|
179
|
-
|
180
|
-
const results: ProcessResult[] = []
|
181
|
-
const logs = (tx.logs || []).filter((log) => logIds.has(log.logId))
|
182
|
-
for (const log of logs) {
|
191
|
+
const tx = decodeFuelTransaction(transaction, this.provider)
|
192
|
+
const index = Number(receiptIndex)
|
193
|
+
const receipt = tx.receipts[index]
|
194
|
+
const log = decodeLog(receipt, this.config.abi)
|
195
|
+
if (log) {
|
183
196
|
const ctx = new FuelContractContext(
|
184
197
|
this.config.chainId,
|
185
198
|
this.contract,
|
186
199
|
this.config.address,
|
187
200
|
this.config.name ?? this.config.address,
|
188
|
-
|
201
|
+
timestamp || new Date(0),
|
189
202
|
tx,
|
190
203
|
null
|
191
204
|
)
|
192
|
-
ctx.setLogIndex(
|
193
|
-
await handler(log, ctx)
|
194
|
-
|
205
|
+
ctx.setLogIndex(index)
|
206
|
+
await handler({ receiptIndex: index, ...log }, ctx)
|
207
|
+
return ctx.stopAndGetResult()
|
208
|
+
} else {
|
209
|
+
console.error(`Log with receipt index ${receiptIndex} not found in tx`)
|
195
210
|
}
|
196
|
-
return mergeProcessResults(results)
|
197
211
|
} catch (e) {
|
198
212
|
console.error(e)
|
199
|
-
return {
|
200
|
-
gauges: [],
|
201
|
-
counters: [],
|
202
|
-
events: [],
|
203
|
-
exports: [],
|
204
|
-
states: {
|
205
|
-
configUpdated: false
|
206
|
-
}
|
207
|
-
}
|
208
213
|
}
|
214
|
+
|
215
|
+
return ProcessResult.fromPartial({})
|
209
216
|
},
|
210
217
|
logConfig: {
|
211
218
|
logIds: Array.from(logIds)
|
212
219
|
}
|
213
220
|
}
|
214
|
-
this.
|
221
|
+
this.logHandlers.push(logHandler)
|
215
222
|
return this
|
216
223
|
}
|
217
224
|
|
@@ -7,6 +7,7 @@ import { FuelContext } from './context.js'
|
|
7
7
|
import { FuelProcessorConfig, getOptionsSignature } from './fuel-processor.js'
|
8
8
|
import { mergeProcessResults } from '@sentio/runtime'
|
9
9
|
import { ALL_ADDRESS } from '../core/index.js'
|
10
|
+
import { getHandlerName, proxyProcessor } from '../utils/metrics.js'
|
10
11
|
|
11
12
|
type GlobalFuelProcessorConfig = Omit<FuelProcessorConfig, 'address' | 'abi'>
|
12
13
|
|
@@ -28,7 +29,9 @@ export class FuelGlobalProcessor implements FuelBaseProcessor<GlobalFuelProcesso
|
|
28
29
|
return processor
|
29
30
|
}
|
30
31
|
|
31
|
-
constructor(readonly config: GlobalFuelProcessorConfig) {
|
32
|
+
constructor(readonly config: GlobalFuelProcessorConfig) {
|
33
|
+
return proxyProcessor(this)
|
34
|
+
}
|
32
35
|
|
33
36
|
async configure() {
|
34
37
|
this.provider = await getProvider(this.config.chainId)
|
@@ -39,6 +42,7 @@ export class FuelGlobalProcessor implements FuelBaseProcessor<GlobalFuelProcesso
|
|
39
42
|
config: FuelFetchConfig = DEFAULT_FUEL_FETCH_CONFIG
|
40
43
|
) {
|
41
44
|
const callHandler = {
|
45
|
+
handlerName: getHandlerName(),
|
42
46
|
handler: async (call: Data_FuelCall) => {
|
43
47
|
let tx: FuelTransaction
|
44
48
|
try {
|
package/src/fuel/transaction.ts
CHANGED
@@ -7,6 +7,7 @@ import {
|
|
7
7
|
Input,
|
8
8
|
InputType,
|
9
9
|
Interface,
|
10
|
+
JsonAbi,
|
10
11
|
processGqlReceipt,
|
11
12
|
Provider,
|
12
13
|
ReceiptType,
|
@@ -65,6 +66,17 @@ export function decodeFuelTransaction(gqlTransaction: any, provider: Provider):
|
|
65
66
|
}
|
66
67
|
}
|
67
68
|
|
69
|
+
export function decodeLog(receipt: any | undefined, abi: JsonAbi) {
|
70
|
+
if (receipt && (receipt.type === ReceiptType.LogData || receipt.type === ReceiptType.Log)) {
|
71
|
+
const interfaceToUse = new Interface(abi)
|
72
|
+
const data = receipt.type === ReceiptType.Log ? new BigNumberCoder('u64').encode(receipt.val0) : receipt.data
|
73
|
+
const logId: string = receipt.val1.toString()
|
74
|
+
const [decodedLog] = interfaceToUse.decodeLog(data, logId)
|
75
|
+
return { logId, data: decodedLog }
|
76
|
+
}
|
77
|
+
return null
|
78
|
+
}
|
79
|
+
|
68
80
|
export async function decodeFuelTransactionWithAbi(
|
69
81
|
gqlTransaction: any,
|
70
82
|
abiMap: AbiMap,
|
@@ -92,16 +104,13 @@ export async function decodeFuelTransactionWithAbi(
|
|
92
104
|
const abi = Object.values(abiMap)[0]
|
93
105
|
const logs = [] as FuelLog<any>[]
|
94
106
|
;(receipts as any[]).forEach((receipt, idx) => {
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
const logId = receipt.val1.toString()
|
100
|
-
const [decodedLog] = interfaceToUse.decodeLog(data, logId)
|
101
|
-
logs.push({ logId, data: decodedLog, receiptIndex: idx })
|
102
|
-
} catch (e) {
|
103
|
-
console.warn('Failed to decode log', e)
|
107
|
+
try {
|
108
|
+
const log = decodeLog(receipt, abi)
|
109
|
+
if (log) {
|
110
|
+
logs.push({ ...log, receiptIndex: idx })
|
104
111
|
}
|
112
|
+
} catch (e) {
|
113
|
+
console.warn('Failed to decode log', e)
|
105
114
|
}
|
106
115
|
})
|
107
116
|
|
package/src/fuel/types.ts
CHANGED
@@ -2,6 +2,7 @@ import { MapStateStorage } from '@sentio/runtime'
|
|
2
2
|
import {
|
3
3
|
Data_FuelBlock,
|
4
4
|
Data_FuelCall,
|
5
|
+
Data_FuelReceipt,
|
5
6
|
FuelAssetHandlerConfig,
|
6
7
|
FuelCallHandlerConfig,
|
7
8
|
HandleInterval,
|
@@ -15,6 +16,7 @@ export interface FuelBaseProcessor<T> {
|
|
15
16
|
config: T
|
16
17
|
callHandlers: CallHandler<Data_FuelCall>[]
|
17
18
|
blockHandlers: BlockHandler[]
|
19
|
+
logHandlers?: LogHandler<Data_FuelReceipt>[]
|
18
20
|
}
|
19
21
|
|
20
22
|
export class FuelProcessorState extends MapStateStorage<FuelBaseProcessor<any>> {
|
@@ -22,9 +24,15 @@ export class FuelProcessorState extends MapStateStorage<FuelBaseProcessor<any>>
|
|
22
24
|
}
|
23
25
|
|
24
26
|
export type CallHandler<T> = {
|
27
|
+
handlerName: string
|
25
28
|
handler: (call: T) => Promise<ProcessResult>
|
26
29
|
fetchConfig?: Partial<FuelCallHandlerConfig>
|
27
30
|
assetConfig?: Partial<FuelAssetHandlerConfig>
|
31
|
+
}
|
32
|
+
|
33
|
+
export type LogHandler<T> = {
|
34
|
+
handlerName: string
|
35
|
+
handler: (call: T) => Promise<ProcessResult>
|
28
36
|
logConfig?: {
|
29
37
|
logIds: string[]
|
30
38
|
}
|
package/src/move/filter.ts
CHANGED
@@ -34,22 +34,26 @@ export interface ArgumentsFilter {
|
|
34
34
|
|
35
35
|
export class EventHandler<T> {
|
36
36
|
filters: EventFilter[]
|
37
|
+
handlerName: string
|
37
38
|
handler: (event: T) => Promise<ProcessResult>
|
38
39
|
fetchConfig: MoveFetchConfig
|
39
40
|
}
|
40
41
|
|
41
42
|
export class CallHandler<T> {
|
42
43
|
filters: FunctionNameAndCallFilter[]
|
44
|
+
handlerName: string
|
43
45
|
handler: (call: T) => Promise<ProcessResult>
|
44
46
|
fetchConfig: MoveFetchConfig
|
45
47
|
}
|
46
48
|
|
47
49
|
export class ObjectChangeHandler<T> {
|
50
|
+
handlerName: string
|
48
51
|
handler: (call: T) => Promise<ProcessResult>
|
49
52
|
type: string
|
50
53
|
}
|
51
54
|
|
52
55
|
export class ResourceChangeHandler<T> {
|
56
|
+
handlerName: string
|
53
57
|
handler: (call: T) => Promise<ProcessResult>
|
54
58
|
type: string
|
55
59
|
}
|
@@ -6,6 +6,7 @@ import { StarknetEvent } from './event.js'
|
|
6
6
|
import { ListStateStorage, mergeProcessResults } from '@sentio/runtime'
|
7
7
|
import { StarknetProcessorConfig } from './types.js'
|
8
8
|
import { StarknetContractView } from './contract.js'
|
9
|
+
import { getHandlerName, proxyProcessor } from '../utils/metrics.js'
|
9
10
|
|
10
11
|
export class StarknetProcessor {
|
11
12
|
callHandlers: CallHandler<Data_StarknetEvent>[] = []
|
@@ -20,7 +21,9 @@ export class StarknetProcessor {
|
|
20
21
|
|
21
22
|
classHash: string
|
22
23
|
|
23
|
-
constructor(readonly config: StarknetProcessorConfig) {
|
24
|
+
constructor(readonly config: StarknetProcessorConfig) {
|
25
|
+
return proxyProcessor(this)
|
26
|
+
}
|
24
27
|
|
25
28
|
async configure() {
|
26
29
|
this.provider = new RpcProvider({
|
@@ -47,6 +50,7 @@ export class StarknetProcessor {
|
|
47
50
|
}
|
48
51
|
const abi = this.config.abi
|
49
52
|
const callHandler = {
|
53
|
+
handlerName: getHandlerName(),
|
50
54
|
handler: async (call: Data_StarknetEvent) => {
|
51
55
|
try {
|
52
56
|
const eventData = [call.result] as any[]
|
@@ -98,6 +102,7 @@ export class StarknetProcessor {
|
|
98
102
|
}
|
99
103
|
|
100
104
|
export type CallHandler<T> = {
|
105
|
+
handlerName: string
|
101
106
|
handler: (call: T) => Promise<ProcessResult>
|
102
107
|
eventFilter?: string[]
|
103
108
|
}
|
@@ -123,6 +128,7 @@ export abstract class AbstractStarknetProcessor {
|
|
123
128
|
) {
|
124
129
|
this.processor = new StarknetProcessor(config)
|
125
130
|
StarknetProcessorState.INSTANCE.addValue(this.processor)
|
131
|
+
return proxyProcessor(this)
|
126
132
|
}
|
127
133
|
|
128
134
|
onEvent<T, C>(
|