@stellar-expert/tx-meta-effects-parser 5.5.2 → 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.2",
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": {
@@ -64,15 +64,18 @@ class EventsAnalyzer {
64
64
  const {diagnosticEvents, processSystemEvents} = this.effectsAnalyzer
65
65
  if (!diagnosticEvents)
66
66
  return
67
+ const opContractId = this.effectsAnalyzer.retrieveOpContractId()
67
68
  //diagnostic events
68
69
  for (const evt of diagnosticEvents) {
69
70
  if (!processSystemEvents && !evt.inSuccessfulContractCall())
70
71
  continue //throw new UnexpectedTxMetaChangeError({type: 'diagnostic_event', action: 'failed'})
71
72
  //parse event
72
73
  const event = evt.event()
73
- const contractId = event.contractId() //contract id attached to the event itself
74
- || this.effectsAnalyzer.operation.func._value.contractAddress()._value //retrieve from the operation
75
- this.processDiagnosticEvent(event.body().value(), event.type().value, contractId ? StrKey.encodeContract(contractId) : null)
74
+ let contractId = event.contractId() || opContractId //contract id may be attached to the event itself, otherwise use contract from operation
75
+ if (contractId && typeof contractId !== 'string') {
76
+ contractId = StrKey.encodeContract(contractId)
77
+ }
78
+ this.processDiagnosticEvent(event.body().value(), event.type().value, contractId)
76
79
  }
77
80
  }
78
81
 
@@ -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
  /**