@lukso/transaction-decoder 1.3.7-dev.caea45e → 1.3.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.
@@ -1,71 +0,0 @@
1
- import type { Hex } from 'viem'
2
- import { decodeKeyValueRaw } from '../decoder/plugins'
3
- import { pluginRegistry } from '../decoder/registry'
4
- import type { DecodeEventResult, DecoderOptions } from '../decoder/types'
5
- import type { ServerDecoderCaches } from './caches'
6
- import type { ServerDecoderOptions } from './types'
7
-
8
- /**
9
- * Decode an array of raw log events using the registered decoder plugins.
10
- *
11
- * Uses the same plugin iteration pattern as transaction.ts:
12
- * try each plugin's `decodeEvent`, first match wins, raw log kept as fallback.
13
- *
14
- * For DataChanged events, also decodes the ERC725Y key-value pair using
15
- * the schema plugin system (same as setData transaction decoding).
16
- */
17
- export async function decodeEventLogs(
18
- logs: DecodeEventResult[],
19
- options: ServerDecoderOptions,
20
- _caches: ServerDecoderCaches
21
- ): Promise<DecodeEventResult[]> {
22
- const { chain } = options
23
- const plugins = await pluginRegistry.getAll({ syncOnly: true })
24
- const schemaPlugins = pluginRegistry.getAllSchema()
25
-
26
- const decoderOptions: DecoderOptions = {
27
- chain,
28
- plugins,
29
- schemaPlugins,
30
- wrappers: [],
31
- async: false,
32
- }
33
-
34
- const results: DecodeEventResult[] = []
35
-
36
- for (const log of logs) {
37
- let decoded: DecodeEventResult
38
- for (const plugin of plugins) {
39
- decoded = await plugin.decodeEvent(log, decoderOptions)
40
- if (decoded) break
41
- }
42
- const result = decoded ?? log
43
-
44
- // For DataChanged events, decode the ERC725Y key-value pair
45
- if (result?.eventName === 'DataChanged' && result.args) {
46
- try {
47
- const dataKey = result.args.find((a) => a.name === 'dataKey')?.value as
48
- | Hex
49
- | undefined
50
- const dataValue = result.args.find((a) => a.name === 'dataValue')
51
- ?.value as Hex | undefined
52
- if (dataKey) {
53
- const info = await decodeKeyValueRaw(
54
- dataKey,
55
- dataValue ?? '0x',
56
- decoderOptions
57
- )
58
- if (info) {
59
- ;(result as Record<string, unknown>).info = info
60
- }
61
- }
62
- } catch {
63
- // Schema decoding failed — keep event without info
64
- }
65
- }
66
-
67
- results.push(result)
68
- }
69
-
70
- return results
71
- }