@sentio/sdk 2.54.0-rc.5 → 2.54.0-rc.7
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/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/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/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 +3 -3
- package/src/aptos/aptos-plugin.ts +6 -2
- package/src/aptos/aptos-processor.ts +8 -0
- 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/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/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
@@ -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>(
|
@@ -196,6 +196,7 @@ export class SuiAddressProcessor extends SuiBaseObjectOrAddressProcessorInternal
|
|
196
196
|
const processor = this
|
197
197
|
|
198
198
|
this.callHandlers.push({
|
199
|
+
handlerName: getHandlerName(),
|
199
200
|
handler: async function (data) {
|
200
201
|
if (!data.transaction) {
|
201
202
|
throw new ServerError(Status.INVALID_ARGUMENT, 'transaction is null')
|
@@ -290,6 +291,7 @@ export class SuiObjectTypeProcessor<T> extends SuiBaseObjectOrAddressProcessor<
|
|
290
291
|
}
|
291
292
|
const processor = this
|
292
293
|
this.objectChangeHandlers.push({
|
294
|
+
handlerName: getHandlerName(),
|
293
295
|
handler: async function (data: Data_SuiObjectChange) {
|
294
296
|
const ctx = new SuiObjectChangeContext(
|
295
297
|
processor.config.network,
|
package/src/sui/sui-plugin.ts
CHANGED
@@ -100,7 +100,8 @@ export class SuiPlugin extends Plugin {
|
|
100
100
|
}
|
101
101
|
}),
|
102
102
|
fetchConfig: handler.fetchConfig,
|
103
|
-
handlerId
|
103
|
+
handlerId,
|
104
|
+
handlerName: handler.handlerName
|
104
105
|
}
|
105
106
|
contractConfig.moveEventConfigs.push(eventHandlerConfig)
|
106
107
|
}
|
@@ -118,7 +119,8 @@ export class SuiPlugin extends Plugin {
|
|
118
119
|
}
|
119
120
|
}),
|
120
121
|
fetchConfig: handler.fetchConfig,
|
121
|
-
handlerId
|
122
|
+
handlerId,
|
123
|
+
handlerName: handler.handlerName
|
122
124
|
}
|
123
125
|
contractConfig.moveCallConfigs.push(functionHandlerConfig)
|
124
126
|
}
|
@@ -127,7 +129,8 @@ export class SuiPlugin extends Plugin {
|
|
127
129
|
const handlerId = handlers.suiObjectChangeHandlers.push(handler.handler) - 1
|
128
130
|
const objectChangeHandler: MoveResourceChangeConfig = {
|
129
131
|
type: handler.type,
|
130
|
-
handlerId
|
132
|
+
handlerId,
|
133
|
+
handlerName: handler.handlerName
|
131
134
|
}
|
132
135
|
contractConfig.moveResourceChangeConfigs.push(objectChangeHandler)
|
133
136
|
}
|
@@ -145,7 +148,8 @@ export class SuiPlugin extends Plugin {
|
|
145
148
|
const handlerId = handlers.suiObjectChangeHandlers.push(handler.handler) - 1
|
146
149
|
const objectChangeHandler: MoveResourceChangeConfig = {
|
147
150
|
type: handler.type,
|
148
|
-
handlerId
|
151
|
+
handlerId,
|
152
|
+
handlerName: handler.handlerName
|
149
153
|
}
|
150
154
|
accountConfig.moveResourceChangeConfigs.push(objectChangeHandler)
|
151
155
|
}
|
@@ -185,7 +189,8 @@ export class SuiPlugin extends Plugin {
|
|
185
189
|
}
|
186
190
|
}),
|
187
191
|
fetchConfig: handler.fetchConfig,
|
188
|
-
handlerId
|
192
|
+
handlerId,
|
193
|
+
handlerName: handler.handlerName
|
189
194
|
}
|
190
195
|
accountConfig.moveCallConfigs.push(functionHandlerConfig)
|
191
196
|
}
|
package/src/sui/sui-processor.ts
CHANGED
@@ -19,6 +19,7 @@ import { getMoveCalls } from './utils.js'
|
|
19
19
|
import { defaultMoveCoder, MoveCoder } from './index.js'
|
20
20
|
import { ALL_ADDRESS, Labels } from '../core/index.js'
|
21
21
|
import { Required } from 'utility-types'
|
22
|
+
import { getHandlerName, proxyProcessor } from '../utils/metrics.js'
|
22
23
|
|
23
24
|
export const DEFAULT_FETCH_CONFIG: MoveFetchConfig = {
|
24
25
|
resourceChanges: false,
|
@@ -63,6 +64,8 @@ export class SuiBaseProcessor {
|
|
63
64
|
this.config = configure(options)
|
64
65
|
SuiProcessorState.INSTANCE.addValue(this)
|
65
66
|
this.coder = defaultMoveCoder(this.config.network)
|
67
|
+
|
68
|
+
return proxyProcessor(this)
|
66
69
|
}
|
67
70
|
|
68
71
|
getChainId(): string {
|
@@ -90,6 +93,7 @@ export class SuiBaseProcessor {
|
|
90
93
|
const allEventType = new Set(_filters.map((f) => f.type))
|
91
94
|
|
92
95
|
this.eventHandlers.push({
|
96
|
+
handlerName: getHandlerName(),
|
93
97
|
handler: async function (data) {
|
94
98
|
if (!data.transaction) {
|
95
99
|
throw new ServerError(Status.INVALID_ARGUMENT, 'event is null')
|
@@ -153,6 +157,7 @@ export class SuiBaseProcessor {
|
|
153
157
|
const allFunctionType = new Set(_filters.map((f) => f.function))
|
154
158
|
|
155
159
|
this.callHandlers.push({
|
160
|
+
handlerName: getHandlerName(),
|
156
161
|
handler: async function (data) {
|
157
162
|
if (!data.transaction) {
|
158
163
|
throw new ServerError(Status.INVALID_ARGUMENT, 'call is null')
|
@@ -214,6 +219,7 @@ export class SuiBaseProcessor {
|
|
214
219
|
const processor = this
|
215
220
|
|
216
221
|
this.callHandlers.push({
|
222
|
+
handlerName: getHandlerName(),
|
217
223
|
handler: async function (data) {
|
218
224
|
if (!data.transaction) {
|
219
225
|
throw new ServerError(Status.INVALID_ARGUMENT, 'transaction is null')
|
@@ -250,6 +256,7 @@ export class SuiBaseProcessor {
|
|
250
256
|
}
|
251
257
|
const processor = this
|
252
258
|
this.objectChangeHandlers.push({
|
259
|
+
handlerName: getHandlerName(),
|
253
260
|
handler: async function (data: Data_SuiObjectChange) {
|
254
261
|
const ctx = new SuiObjectChangeContext(
|
255
262
|
processor.config.network,
|