@stellar-expert/tx-meta-effects-parser 8.2.0 → 8.3.0

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": "8.2.0",
3
+ "version": "8.3.0",
4
4
  "description": "Low-level effects parser for Stellar transaction results and meta XDR",
5
5
  "main": "src/index.js",
6
6
  "scripts": {
package/src/index.js CHANGED
@@ -120,7 +120,10 @@ function parseTxOperationsMeta({
120
120
  } catch (e) {
121
121
  throw new TxMetaEffectParserError('Invalid transaction metadata XDR. ' + e.message)
122
122
  }
123
-
123
+ let feeSource = feeEffect.source
124
+ if (feeSource.startsWith('M')) {
125
+ feeSource = xdrParserUtils.retrieveBaseMuxedAddress(feeSource)
126
+ }
124
127
  //add tx-level effects
125
128
  for (const {before, after} of parseTxMetaChanges(meta)) {
126
129
  if (before.entry !== 'account')
@@ -129,7 +132,7 @@ function parseTxOperationsMeta({
129
132
  effect.source = (before || after).address
130
133
  res.effects.push(effect)
131
134
  }
132
- if (feeEffect.source === after.address) {
135
+ if (feeSource === after.address) {
133
136
  feeEffect.balance = after.balance
134
137
  }
135
138
  if (isFeeBump && protocol === 20 && before.balance !== after.balance) { //bump fee calculation bug in protocol v20
@@ -65,6 +65,15 @@ function xdrParsePrice(price) {
65
65
  return price.n() / price.d()
66
66
  }
67
67
 
68
+ /**
69
+ * @param {string} address
70
+ * @return {string}
71
+ */
72
+ function retrieveBaseMuxedAddress(address) {
73
+ const rawBytes = StrKey.decodeMed25519PublicKey(address)
74
+ return StrKey.encodeEd25519PublicKey(rawBytes.subarray(0, 32))
75
+ }
76
+
68
77
  /**
69
78
  * Parse account signer key XDR
70
79
  * @param {xdr.SignerKey} signer
@@ -334,5 +343,6 @@ module.exports = {
334
343
  xdrParseSignerKey,
335
344
  xdrParsePrice,
336
345
  xdrParseScVal,
337
- xdrParseSacBalanceChange
346
+ xdrParseSacBalanceChange,
347
+ retrieveBaseMuxedAddress
338
348
  }