@stellar-expert/tx-meta-effects-parser 5.5.3 → 5.5.4

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": "5.5.3",
3
+ "version": "5.5.4",
4
4
  "description": "Low-level effects parser for Stellar transaction results and meta XDR",
5
5
  "main": "src/index.js",
6
6
  "scripts": {
@@ -1,7 +1,6 @@
1
1
  const {StrKey} = require('@stellar/stellar-base')
2
2
  const effectTypes = require('../effect-types')
3
3
  const {xdrParseScVal, xdrParseAsset, isContractAddress} = require('../parser/tx-xdr-parser-utils')
4
- const {contractIdFromPreimage} = require('../parser/contract-preimage-encoder')
5
4
  const {mapSacContract} = require('./sac-contract-mapper')
6
5
 
7
6
  const EVENT_TYPES = {
@@ -65,7 +64,7 @@ class EventsAnalyzer {
65
64
  const {diagnosticEvents, processSystemEvents} = this.effectsAnalyzer
66
65
  if (!diagnosticEvents)
67
66
  return
68
- const opContractId = retrieveOpContractId(this.effectsAnalyzer.operation, this.effectsAnalyzer.network)
67
+ const opContractId = this.effectsAnalyzer.retrieveOpContractId()
69
68
  //diagnostic events
70
69
  for (const evt of diagnosticEvents) {
71
70
  if (!processSystemEvents && !evt.inSuccessfulContractCall())
@@ -305,18 +304,4 @@ function processEventBodyValue(value) {
305
304
  return xdrParseScVal(value) //other scValue
306
305
  }
307
306
 
308
- function retrieveOpContractId(operation, network) {
309
- const funcValue = operation.func._value._attributes
310
- if (!funcValue)
311
- return null //WASM upload
312
- let address = funcValue.contractAddress?._value
313
- if (!address) {
314
- const preimage = funcValue.contractIdPreimage
315
- if (preimage) {
316
- address = contractIdFromPreimage(preimage, network)
317
- }
318
- }
319
- return address
320
- }
321
-
322
307
  module.exports = EventsAnalyzer
@@ -194,8 +194,7 @@ class EffectsAnalyzer {
194
194
  refundable: parseLargeInt(attrs.totalRefundableResourceFeeCharged),
195
195
  rent: parseLargeInt(attrs.rentFeeCharged)
196
196
  }
197
- const contract = StrKey.encodeContract(this.operation.func._value.contractAddress()._value)
198
- this.addMetric(contract, 'fee', fee)
197
+ this.addMetric(this.retrieveOpContractId(), 'fee', fee)
199
198
  }
200
199
  }
201
200
 
@@ -911,6 +910,18 @@ class EffectsAnalyzer {
911
910
  throw new UnexpectedTxMetaChangeError(change)
912
911
  }
913
912
  }
913
+
914
+ retrieveOpContractId() {
915
+ const funcValue = this.operation.func._value._attributes
916
+ if (funcValue) {
917
+ if (funcValue.contractAddress)
918
+ return StrKey.encodeContract(funcValue.contractAddress._value)
919
+ const preimage = funcValue.contractIdPreimage
920
+ if (preimage)
921
+ return contractIdFromPreimage(preimage, this.network)
922
+ }
923
+ return null
924
+ }
914
925
  }
915
926
 
916
927
  /**