@stellar-expert/tx-meta-effects-parser 7.0.0-rc.1 → 7.0.0-rc.3

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stellar-expert/tx-meta-effects-parser",
3
- "version": "7.0.0-rc.1",
3
+ "version": "7.0.0-rc.3",
4
4
  "description": "Low-level effects parser for Stellar transaction results and meta XDR",
5
5
  "main": "src/index.js",
6
6
  "scripts": {
@@ -304,7 +304,7 @@ function processEventBodyValue(value) {
304
304
  /*if (innerValue instanceof Array) //handle simple JS arrays
305
305
  return innerValue.map(xdrParseScVal)*/
306
306
  if (!innerValue) //scVoid
307
- return undefined
307
+ return null
308
308
  return xdrParseScVal(value) //other scValue
309
309
  }
310
310
 
package/src/index.js CHANGED
@@ -9,6 +9,7 @@ const {analyzeSignerChanges} = require('./aggregation/signer-changes-analyzer')
9
9
  const contractPreimageEncoder = require('./parser/contract-preimage-encoder')
10
10
  const xdrParserUtils = require('./parser/tx-xdr-parser-utils')
11
11
  const effectTypes = require('./effect-types')
12
+ const events = require('node:events')
12
13
 
13
14
  /**
14
15
  * Retrieve effects from transaction execution result metadata
@@ -139,6 +140,8 @@ function parseTxOperationsMeta({
139
140
  }
140
141
  const metaValue = meta.value()
141
142
  const opMeta = metaValue.operations()
143
+ const isV4Meta = meta.arm() === 'v4'
144
+ let txEvents = isV4Meta ? metaValue.events() : undefined
142
145
 
143
146
  //analyze operation effects for each operation
144
147
  for (let i = 0; i < parsedTx.operations.length; i++) {
@@ -155,12 +158,20 @@ function parseTxOperationsMeta({
155
158
  const isSorobanInvocation = operation.type === 'invokeHostFunction'
156
159
  //only for Soroban contract invocation
157
160
  if (isSorobanInvocation) {
158
- const sorobanMeta = metaValue._attributes.sorobanMeta
161
+ const {sorobanMeta} = metaValue._attributes
159
162
  if (sorobanMeta) {
160
- params.events = sorobanMeta.events()
161
- params.diagnosticEvents = sorobanMeta.diagnosticEvents()
163
+ if (sorobanMeta.events) {
164
+ params.events = sorobanMeta.events()
165
+ }
166
+ if (sorobanMeta.diagnosticEvents) {
167
+ params.diagnosticEvents = sorobanMeta.diagnosticEvents()
168
+ }
162
169
  params.processSystemEvents = processSystemEvents
163
170
  }
171
+ if (isV4Meta) {
172
+ params.diagnosticEvents = metaValue.diagnosticEvents()
173
+ params.events = metaValue.operations()[0].events()
174
+ }
164
175
  params.mapSac = mapSac
165
176
  }
166
177
  const analyzer = new EffectsAnalyzer(params)
@@ -16,6 +16,7 @@ function parseTxMetaChanges(meta) {
16
16
  break
17
17
  case 'v2':
18
18
  case 'v3':
19
+ case 'v4':
19
20
  retrieveTopLevelChanges(transactionMeta.txChangesBefore(), txMetaChanges)
20
21
  retrieveTopLevelChanges(transactionMeta.txChangesAfter(), txMetaChanges)
21
22
  break