@stellar-expert/tx-meta-effects-parser 8.2.0 → 8.3.1
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 +1 -1
- package/src/effects-analyzer.js +2 -0
- package/src/index.js +5 -2
- package/src/parser/tx-xdr-parser-utils.js +11 -1
package/package.json
CHANGED
package/src/effects-analyzer.js
CHANGED
|
@@ -889,6 +889,8 @@ class EffectsAnalyzer {
|
|
|
889
889
|
const balanceEffects = this.effects.filter(e => e.source === tokenBalance.address &&
|
|
890
890
|
(e.type === effectTypes.accountCredited || e.type === effectTypes.accountDebited) &&
|
|
891
891
|
(e.asset === effect.owner || e.asset === this.sacMap?.get(effect.owner)))
|
|
892
|
+
if (!balanceEffects.length)
|
|
893
|
+
return
|
|
892
894
|
balanceEffects[balanceEffects.length - 1].balance = tokenBalance.balance //set latest transfer effect balance
|
|
893
895
|
}
|
|
894
896
|
}
|
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 (
|
|
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
|
}
|