@stellar-expert/tx-meta-effects-parser 5.0.0-beta11 → 5.0.0-beta12

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.
Files changed (2) hide show
  1. package/package.json +2 -2
  2. package/src/index.js +18 -5
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stellar-expert/tx-meta-effects-parser",
3
- "version": "5.0.0-beta11",
3
+ "version": "5.0.0-beta12",
4
4
  "description": "Low-level effects parser for Stellar transaction results and meta XDR",
5
5
  "main": "src/index.js",
6
6
  "scripts": {
@@ -9,7 +9,7 @@
9
9
  "author": "team@stellar.expert",
10
10
  "license": "MIT",
11
11
  "peerDependencies": {
12
- "@stellar/stellar-base": "^10.0.1"
12
+ "@stellar/stellar-base": "^11.0.0"
13
13
  },
14
14
  "devDependencies": {
15
15
  "@babel/core": "^7.22.9",
package/src/index.js CHANGED
@@ -79,7 +79,8 @@ function parseTxOperationsMeta({network, tx, result, meta}) {
79
79
  }
80
80
 
81
81
  //process fee charge
82
- res.effects = [processFeeChargedEffect(tx, tx.feeSource || parsedTx.source, result.feeCharged().toString(), isFeeBump)]
82
+ const feeEffect = processFeeChargedEffect(tx, tx.feeSource || parsedTx.source, result.feeCharged().toString(), isFeeBump)
83
+ res.effects = [feeEffect]
83
84
 
84
85
  //check execution result
85
86
  const {success, opResults} = parseTxResult(parsedResult)
@@ -95,7 +96,7 @@ function parseTxOperationsMeta({network, tx, result, meta}) {
95
96
  //retrieve operations result metadata
96
97
  try {
97
98
  meta = ensureXdrInputType(meta, xdr.TransactionMeta)
98
- } catch {
99
+ } catch (e) {
99
100
  throw new TxMetaEffectParserError('Invalid transaction metadata XDR. ' + e.message)
100
101
  }
101
102
 
@@ -107,6 +108,9 @@ function parseTxOperationsMeta({network, tx, result, meta}) {
107
108
  effect.source = (before || after).address
108
109
  res.effects.push(effect)
109
110
  }
111
+ if (before.balance !== after.balance) { //
112
+ feeEffect.charged = (BigInt(feeEffect.charged) - BigInt(after.balance) + BigInt(before.balance)).toString()
113
+ }
110
114
  }
111
115
  const metaValue = meta.value()
112
116
  const opMeta = metaValue.operations()
@@ -117,8 +121,8 @@ function parseTxOperationsMeta({network, tx, result, meta}) {
117
121
  if (success) {
118
122
  const params = {
119
123
  operation,
120
- meta:opMeta[i]?.changes(),
121
- result:opResults[i],network
124
+ meta: opMeta[i]?.changes(),
125
+ result: opResults[i], network
122
126
  }
123
127
  //only for Soroban contract invocation
124
128
  if (operation.type === 'invokeHostFunction') {
@@ -158,4 +162,13 @@ function ensureXdrInputType(value, xdrType) {
158
162
  * @property {{}[]} [effects]
159
163
  */
160
164
 
161
- module.exports = {parseTxOperationsMeta, parseTxResult, analyzeOperationEffects, parseLedgerEntryChanges, parseTxMetaChanges, effectTypes, xdrParserUtils, contractPreimageEncoder}
165
+ module.exports = {
166
+ parseTxOperationsMeta,
167
+ parseTxResult,
168
+ analyzeOperationEffects,
169
+ parseLedgerEntryChanges,
170
+ parseTxMetaChanges,
171
+ effectTypes,
172
+ xdrParserUtils,
173
+ contractPreimageEncoder
174
+ }