@sentio/sdk 2.60.0-rc.1 → 2.60.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-processor.d.ts +1 -0
- package/lib/aptos/aptos-processor.d.ts.map +1 -1
- package/lib/aptos/aptos-processor.js +11 -3
- package/lib/aptos/aptos-processor.js.map +1 -1
- package/lib/aptos/builtin/0x1.d.ts +211 -0
- package/lib/aptos/builtin/0x1.d.ts.map +1 -1
- package/lib/aptos/builtin/0x1.js +328 -1
- package/lib/aptos/builtin/0x1.js.map +1 -1
- package/lib/aptos/builtin/0x3.js +1 -1
- package/lib/aptos/builtin/0x3.js.map +1 -1
- package/lib/aptos/builtin/0x4.js +1 -1
- package/lib/aptos/builtin/0x4.js.map +1 -1
- package/lib/core/core-plugin.d.ts +1 -0
- package/lib/core/core-plugin.d.ts.map +1 -1
- package/lib/core/core-plugin.js +6 -2
- package/lib/core/core-plugin.js.map +1 -1
- package/lib/core/handler-options.d.ts +6 -0
- package/lib/core/handler-options.d.ts.map +1 -1
- package/lib/core/handler-options.js.map +1 -1
- package/lib/eth/base-processor.d.ts +3 -1
- package/lib/eth/base-processor.d.ts.map +1 -1
- package/lib/eth/base-processor.js +26 -0
- package/lib/eth/base-processor.js.map +1 -1
- package/lib/eth/eth-plugin.d.ts.map +1 -1
- package/lib/eth/eth-plugin.js +45 -3
- package/lib/eth/eth-plugin.js.map +1 -1
- package/lib/eth/eth.d.ts.map +1 -1
- package/lib/eth/eth.js +30 -24
- package/lib/eth/eth.js.map +1 -1
- package/lib/iota/builtin/0x1.d.ts +817 -0
- package/lib/iota/builtin/0x1.d.ts.map +1 -0
- package/lib/iota/builtin/0x1.js +4385 -0
- package/lib/iota/builtin/0x1.js.map +1 -0
- package/lib/iota/builtin/0x2.d.ts +4529 -0
- package/lib/iota/builtin/0x2.d.ts.map +1 -0
- package/lib/iota/builtin/0x2.js +17109 -0
- package/lib/iota/builtin/0x2.js.map +1 -0
- package/lib/iota/builtin/0x3.d.ts +2293 -0
- package/lib/iota/builtin/0x3.d.ts.map +1 -0
- package/lib/iota/builtin/0x3.js +6522 -0
- package/lib/iota/builtin/0x3.js.map +1 -0
- package/lib/iota/builtin/index.d.ts +4 -0
- package/lib/iota/builtin/index.d.ts.map +1 -0
- package/lib/iota/builtin/index.js +7 -0
- package/lib/iota/builtin/index.js.map +1 -0
- package/lib/iota/codegen/codegen.d.ts +2 -0
- package/lib/iota/codegen/codegen.d.ts.map +1 -0
- package/lib/iota/codegen/codegen.js +94 -0
- package/lib/iota/codegen/codegen.js.map +1 -0
- package/lib/iota/codegen/index.d.ts +2 -0
- package/lib/iota/codegen/index.d.ts.map +1 -0
- package/lib/iota/codegen/index.js +2 -0
- package/lib/iota/codegen/index.js.map +1 -0
- package/lib/iota/codegen/run.d.ts +2 -0
- package/lib/iota/codegen/run.d.ts.map +1 -0
- package/lib/iota/codegen/run.js +12 -0
- package/lib/iota/codegen/run.js.map +1 -0
- package/lib/iota/context.d.ts +50 -0
- package/lib/iota/context.d.ts.map +1 -0
- package/lib/iota/context.js +134 -0
- package/lib/iota/context.js.map +1 -0
- package/lib/iota/ext/coin.d.ts +17 -0
- package/lib/iota/ext/coin.d.ts.map +1 -0
- package/lib/iota/ext/coin.js +532 -0
- package/lib/iota/ext/coin.js.map +1 -0
- package/lib/iota/ext/index.d.ts +3 -0
- package/lib/iota/ext/index.d.ts.map +1 -0
- package/lib/iota/ext/index.js +3 -0
- package/lib/iota/ext/index.js.map +1 -0
- package/lib/iota/ext/move-dex.d.ts +19 -0
- package/lib/iota/ext/move-dex.d.ts.map +1 -0
- package/lib/iota/ext/move-dex.js +24 -0
- package/lib/iota/ext/move-dex.js.map +1 -0
- package/lib/iota/index.d.ts +11 -0
- package/lib/iota/index.d.ts.map +1 -0
- package/lib/iota/index.js +12 -0
- package/lib/iota/index.js.map +1 -0
- package/lib/iota/iota-object-processor-template.d.ts +44 -0
- package/lib/iota/iota-object-processor-template.d.ts.map +1 -0
- package/lib/iota/iota-object-processor-template.js +171 -0
- package/lib/iota/iota-object-processor-template.js.map +1 -0
- package/lib/iota/iota-object-processor.d.ts +83 -0
- package/lib/iota/iota-object-processor.d.ts.map +1 -0
- package/lib/iota/iota-object-processor.js +193 -0
- package/lib/iota/iota-object-processor.js.map +1 -0
- package/lib/iota/iota-plugin-part.d.ts +12 -0
- package/lib/iota/iota-plugin-part.d.ts.map +1 -0
- package/lib/iota/iota-plugin-part.js +178 -0
- package/lib/iota/iota-plugin-part.js.map +1 -0
- package/lib/iota/iota-plugin.d.ts +3 -0
- package/lib/iota/iota-plugin.d.ts.map +1 -0
- package/lib/iota/iota-plugin.js +4 -0
- package/lib/iota/iota-plugin.js.map +1 -0
- package/lib/iota/iota-processor.d.ts +47 -0
- package/lib/iota/iota-processor.d.ts.map +1 -0
- package/lib/iota/iota-processor.js +223 -0
- package/lib/iota/iota-processor.js.map +1 -0
- package/lib/iota/models.d.ts +12 -0
- package/lib/iota/models.d.ts.map +1 -0
- package/lib/iota/models.js +2 -0
- package/lib/iota/models.js.map +1 -0
- package/lib/iota/move-coder.d.ts +4 -0
- package/lib/iota/move-coder.d.ts.map +1 -0
- package/lib/iota/move-coder.js +12 -0
- package/lib/iota/move-coder.js.map +1 -0
- package/lib/iota/network.d.ts +10 -0
- package/lib/iota/network.d.ts.map +1 -0
- package/lib/iota/network.js +24 -0
- package/lib/iota/network.js.map +1 -0
- package/lib/iota/utils.d.ts +3 -0
- package/lib/iota/utils.d.ts.map +1 -0
- package/lib/iota/utils.js +41 -0
- package/lib/iota/utils.js.map +1 -0
- package/lib/store/schema.d.ts.map +1 -1
- package/lib/store/schema.js +1 -0
- package/lib/store/schema.js.map +1 -1
- package/lib/sui/builtin/0x2.d.ts +73 -0
- package/lib/sui/builtin/0x2.d.ts.map +1 -1
- package/lib/sui/builtin/0x2.js +237 -1
- package/lib/sui/builtin/0x2.js.map +1 -1
- package/lib/sui/builtin/0x3.d.ts +2 -0
- package/lib/sui/builtin/0x3.d.ts.map +1 -1
- package/lib/sui/builtin/0x3.js +21 -1
- package/lib/sui/builtin/0x3.js.map +1 -1
- package/lib/sui/network.d.ts.map +1 -1
- package/lib/sui/network.js +0 -3
- package/lib/sui/network.js.map +1 -1
- package/lib/sui/sui-plugin-part.d.ts +12 -0
- package/lib/sui/sui-plugin-part.d.ts.map +1 -0
- package/lib/sui/sui-plugin-part.js +178 -0
- package/lib/sui/sui-plugin-part.js.map +1 -0
- package/lib/sui/sui-plugin.d.ts +4 -0
- package/lib/sui/sui-plugin.d.ts.map +1 -1
- package/lib/sui/sui-plugin.js +12 -159
- package/lib/sui/sui-plugin.js.map +1 -1
- package/lib/testing/iota-facet.d.ts +14 -0
- package/lib/testing/iota-facet.d.ts.map +1 -0
- package/lib/testing/iota-facet.js +124 -0
- package/lib/testing/iota-facet.js.map +1 -0
- package/lib/testing/test-processor-server.d.ts +2 -0
- package/lib/testing/test-processor-server.d.ts.map +1 -1
- package/lib/testing/test-processor-server.js +3 -0
- package/lib/testing/test-processor-server.js.map +1 -1
- package/package.json +21 -9
- package/src/aptos/abis/0x1.json +1040 -45
- package/src/aptos/abis/0x3.json +2 -2
- package/src/aptos/abis/0x4.json +17 -17
- package/src/aptos/aptos-processor.ts +15 -3
- package/src/aptos/builtin/0x1.ts +615 -1
- package/src/aptos/builtin/0x3.ts +1 -1
- package/src/aptos/builtin/0x4.ts +1 -1
- package/src/core/core-plugin.ts +8 -3
- package/src/core/handler-options.ts +7 -0
- package/src/eth/base-processor.ts +43 -1
- package/src/eth/eth-plugin.ts +49 -3
- package/src/eth/eth.ts +31 -26
- package/src/iota/abis/0x1.json +4213 -0
- package/src/iota/abis/0x2.json +26692 -0
- package/src/iota/abis/0x3.json +10598 -0
- package/src/iota/builtin/0x1.ts +6292 -0
- package/src/iota/builtin/0x2.ts +26198 -0
- package/src/iota/builtin/0x3.ts +11144 -0
- package/src/iota/builtin/index.ts +6 -0
- package/src/iota/codegen/codegen.ts +118 -0
- package/src/iota/codegen/index.ts +1 -0
- package/src/iota/codegen/run.ts +13 -0
- package/src/iota/context.ts +200 -0
- package/src/iota/ext/coin.ts +565 -0
- package/src/iota/ext/index.ts +2 -0
- package/src/iota/ext/move-dex.ts +52 -0
- package/src/iota/index.ts +29 -0
- package/src/iota/iota-object-processor-template.ts +277 -0
- package/src/iota/iota-object-processor.ts +386 -0
- package/src/iota/iota-plugin-part.ts +211 -0
- package/src/iota/iota-plugin.ts +2 -0
- package/src/iota/iota-processor.ts +339 -0
- package/src/iota/models.ts +14 -0
- package/src/iota/move-coder.ts +15 -0
- package/src/iota/network.ts +27 -0
- package/src/iota/utils.ts +52 -0
- package/src/store/schema.ts +1 -0
- package/src/sui/abis/0x2.json +269 -0
- package/src/sui/abis/0x3.json +29 -0
- package/src/sui/builtin/0x2.ts +367 -1
- package/src/sui/builtin/0x3.ts +29 -1
- package/src/sui/network.ts +0 -3
- package/src/sui/sui-plugin-part.ts +211 -0
- package/src/sui/sui-plugin.ts +12 -178
- package/src/testing/iota-facet.ts +143 -0
- package/src/testing/test-processor-server.ts +3 -0
@@ -1,4 +1,4 @@
|
|
1
|
-
import { BaseContract, DeferredTopicFilter, LogDescription, TransactionResponseParams } from 'ethers'
|
1
|
+
import { BaseContract, DeferredTopicFilter, LogDescription, LogParams, TransactionResponseParams } from 'ethers'
|
2
2
|
|
3
3
|
import { BoundContractView, ContractContext, ContractView, GlobalContext } from './context.js'
|
4
4
|
import {
|
@@ -93,6 +93,7 @@ export class GlobalProcessor {
|
|
93
93
|
blockHandlers: BlockHandler[] = proxyHandlers([])
|
94
94
|
transactionHandler: TransactionHandler[] = proxyHandlers([])
|
95
95
|
traceHandlers: TraceHandler[] = proxyHandlers([])
|
96
|
+
eventHandlers: EventsHandler[] = []
|
96
97
|
|
97
98
|
static bind(config: Omit<BindOptions, 'address'>): GlobalProcessor {
|
98
99
|
const processor = new GlobalProcessor(config)
|
@@ -333,6 +334,47 @@ export class GlobalProcessor {
|
|
333
334
|
return this
|
334
335
|
}
|
335
336
|
|
337
|
+
public onEvent(
|
338
|
+
handler: (rawLog: LogParams, ctx: GlobalContext) => PromiseOrVoid,
|
339
|
+
filter?: AddressOrTypeEventFilter | AddressOrTypeEventFilter[],
|
340
|
+
handlerOptions?: HandlerOptions<EthFetchConfig, TypedEvent>
|
341
|
+
): this {
|
342
|
+
let _filters: AddressOrTypeEventFilter[] = []
|
343
|
+
|
344
|
+
if (Array.isArray(filter)) {
|
345
|
+
_filters = filter
|
346
|
+
} else if (filter) {
|
347
|
+
_filters.push(filter)
|
348
|
+
}
|
349
|
+
const chainId = this.getChainId()
|
350
|
+
|
351
|
+
this.eventHandlers.push({
|
352
|
+
filters: _filters,
|
353
|
+
fetchConfig: EthFetchConfig.fromPartial(handlerOptions || {}),
|
354
|
+
handlerName: getHandlerName(),
|
355
|
+
handler: async function (data) {
|
356
|
+
const { log, block, transaction, transactionReceipt } = formatEthData(data)
|
357
|
+
if (!log) {
|
358
|
+
throw new ServerError(Status.INVALID_ARGUMENT, 'Log is empty')
|
359
|
+
}
|
360
|
+
const ctx = new GlobalContext(
|
361
|
+
chainId,
|
362
|
+
transaction?.to || '*',
|
363
|
+
data.timestamp,
|
364
|
+
block,
|
365
|
+
log,
|
366
|
+
undefined,
|
367
|
+
transaction,
|
368
|
+
transactionReceipt
|
369
|
+
)
|
370
|
+
|
371
|
+
await handler(log, ctx)
|
372
|
+
return ctx.stopAndGetResult()
|
373
|
+
}
|
374
|
+
})
|
375
|
+
return this
|
376
|
+
}
|
377
|
+
|
336
378
|
public onTrace(
|
337
379
|
signatures: string | string[],
|
338
380
|
handler: (trace: Trace, ctx: GlobalContext) => PromiseOrVoid,
|
package/src/eth/eth-plugin.ts
CHANGED
@@ -212,6 +212,53 @@ export class EthPlugin extends Plugin {
|
|
212
212
|
})
|
213
213
|
}
|
214
214
|
}
|
215
|
+
|
216
|
+
for (const eventsHandler of processor.eventHandlers) {
|
217
|
+
// associate id with filter
|
218
|
+
const handlerId = this.handlerRegister.register(eventsHandler.handler, processor.getChainId())
|
219
|
+
const logConfig: LogHandlerConfig = {
|
220
|
+
handlerId: handlerId,
|
221
|
+
handlerName: eventsHandler.handlerName,
|
222
|
+
filters: [],
|
223
|
+
fetchConfig: eventsHandler.fetchConfig
|
224
|
+
}
|
225
|
+
|
226
|
+
if (!eventsHandler.filters || eventsHandler.filters.length === 0) {
|
227
|
+
// if no filter, then we assume all logs
|
228
|
+
logConfig.filters.push({
|
229
|
+
topics: []
|
230
|
+
})
|
231
|
+
} else {
|
232
|
+
for (const filter of eventsHandler.filters) {
|
233
|
+
const topics = await filter.getTopicFilter()
|
234
|
+
// if (!filter.topics) {
|
235
|
+
// throw new ServerError(Status.INVALID_ARGUMENT, 'Topic should not be null')
|
236
|
+
// }
|
237
|
+
let address = undefined
|
238
|
+
if (filter.address) {
|
239
|
+
address = filter.address.toString()
|
240
|
+
}
|
241
|
+
const logFilter: LogFilter = {
|
242
|
+
addressType: filter.addressType,
|
243
|
+
address: address && validateAndNormalizeAddress(address),
|
244
|
+
topics: []
|
245
|
+
}
|
246
|
+
|
247
|
+
for (const ts of topics) {
|
248
|
+
let hashes: string[] = []
|
249
|
+
if (Array.isArray(ts)) {
|
250
|
+
hashes = hashes.concat(ts)
|
251
|
+
} else if (ts) {
|
252
|
+
hashes.push(ts)
|
253
|
+
}
|
254
|
+
logFilter.topics.push({ hashes: hashes })
|
255
|
+
}
|
256
|
+
logConfig.filters.push(logFilter)
|
257
|
+
}
|
258
|
+
}
|
259
|
+
contractConfig.logConfigs.push(logConfig)
|
260
|
+
}
|
261
|
+
|
215
262
|
config.contractConfigs.push(contractConfig)
|
216
263
|
}
|
217
264
|
|
@@ -238,9 +285,7 @@ export class EthPlugin extends Plugin {
|
|
238
285
|
|
239
286
|
for (const filter of eventsHandler.filters) {
|
240
287
|
const topics = await filter.getTopicFilter()
|
241
|
-
|
242
|
-
// throw new ServerError(Status.INVALID_ARGUMENT, 'Topic should not be null')
|
243
|
-
// }
|
288
|
+
|
244
289
|
let address = undefined
|
245
290
|
if (filter.address) {
|
246
291
|
address = filter.address.toString()
|
@@ -262,6 +307,7 @@ export class EthPlugin extends Plugin {
|
|
262
307
|
}
|
263
308
|
logConfig.filters.push(logFilter)
|
264
309
|
}
|
310
|
+
|
265
311
|
accountConfig.logConfigs.push(logConfig)
|
266
312
|
}
|
267
313
|
|
package/src/eth/eth.ts
CHANGED
@@ -150,34 +150,39 @@ export function formatEthData(data: {
|
|
150
150
|
return data.__formattedEthData
|
151
151
|
}
|
152
152
|
|
153
|
-
|
154
|
-
|
155
|
-
data.block.transactions
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
if (
|
162
|
-
data.transaction.v
|
163
|
-
|
164
|
-
|
153
|
+
try {
|
154
|
+
const log = data.log ? formatLog(data.log) : undefined
|
155
|
+
if (data.block && !data.block.transactions) {
|
156
|
+
data.block.transactions = []
|
157
|
+
}
|
158
|
+
const block = data.block ? formatRichBlock(data.block) : undefined
|
159
|
+
const trace = data.trace ? (data.trace as Trace) : undefined
|
160
|
+
let transaction = undefined
|
161
|
+
if (data.transaction) {
|
162
|
+
if (!data.transaction.v) {
|
163
|
+
data.transaction.v = '0x1c'
|
164
|
+
data.transaction.r = '0x88ff6cf0fefd94db46111149ae4bfc179e9b94721fffd821d38d16464b3f71d0'
|
165
|
+
data.transaction.s = '0x45e0aff800961cfce805daef7016b9b675c137a6a41a548f7b60a3484c06a33a'
|
166
|
+
}
|
167
|
+
transaction = formatTransactionResponse(data.transaction)
|
168
|
+
}
|
169
|
+
const transactionReceipt = data.transactionReceipt ? formatTransactionReceipt(data.transactionReceipt) : undefined
|
170
|
+
|
171
|
+
const result = {
|
172
|
+
log,
|
173
|
+
block,
|
174
|
+
trace,
|
175
|
+
transaction,
|
176
|
+
transactionReceipt
|
165
177
|
}
|
166
|
-
transaction = formatTransactionResponse(data.transaction)
|
167
|
-
}
|
168
|
-
const transactionReceipt = data.transactionReceipt ? formatTransactionReceipt(data.transactionReceipt) : undefined
|
169
|
-
|
170
|
-
const result = {
|
171
|
-
log,
|
172
|
-
block,
|
173
|
-
trace,
|
174
|
-
transaction,
|
175
|
-
transactionReceipt
|
176
|
-
}
|
177
178
|
|
178
|
-
|
179
|
-
|
180
|
-
|
179
|
+
// Cache the result on the input data object
|
180
|
+
data.__formattedEthData = result
|
181
|
+
return result
|
182
|
+
} catch (e) {
|
183
|
+
console.error('Error formatting eth data', e)
|
184
|
+
return data
|
185
|
+
}
|
181
186
|
}
|
182
187
|
|
183
188
|
export function formatRichBlock(block: RichBlock): RichBlock {
|