@stellar-expert/tx-meta-effects-parser 5.0.1 → 5.0.3

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.0.1",
3
+ "version": "5.0.3",
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
@@ -31,17 +31,18 @@ function parseTxOperationsMeta({network, tx, result, meta}) {
31
31
  } catch (e) {
32
32
  throw new TxMetaEffectParserError('Invalid transaction envelope XDR. ' + e.message)
33
33
  }
34
- try {
35
- result = ensureXdrInputType(result, xdr.TransactionResult)
36
- } catch (e) {
34
+ if (!isEphemeral) {
37
35
  try {
38
- const pair = ensureXdrInputType(result, xdr.TransactionResultPair)
39
- result = pair.result()
40
- } catch {
41
- throw new TxMetaEffectParserError('Invalid transaction result XDR. ' + e.message)
36
+ result = ensureXdrInputType(result, xdr.TransactionResult)
37
+ } catch (e) {
38
+ try {
39
+ const pair = ensureXdrInputType(result, xdr.TransactionResultPair)
40
+ result = pair.result()
41
+ } catch {
42
+ throw new TxMetaEffectParserError('Invalid transaction result XDR. ' + e.message)
43
+ }
42
44
  }
43
45
  }
44
-
45
46
  tx = TransactionBuilder.fromXDR(tx, network)
46
47
 
47
48
  let parsedTx = tx
@@ -78,9 +79,14 @@ function parseTxOperationsMeta({network, tx, result, meta}) {
78
79
  }
79
80
  }
80
81
 
82
+ res.effects = []
83
+
84
+ if (isEphemeral)
85
+ return res //do not parse meta for unsubmitted/rejected transactions
86
+
81
87
  //process fee charge
82
88
  const feeEffect = processFeeChargedEffect(tx, tx.feeSource || parsedTx.source, result.feeCharged().toString(), isFeeBump)
83
- res.effects = [feeEffect]
89
+ res.effects.push(feeEffect)
84
90
 
85
91
  //check execution result
86
92
  const {success, opResults} = parseTxResult(parsedResult)
@@ -89,10 +95,6 @@ function parseTxOperationsMeta({network, tx, result, meta}) {
89
95
  return res
90
96
  }
91
97
 
92
- //do not parse meta for unsubmitted/rejected transactions
93
- if (isEphemeral)
94
- return res
95
-
96
98
  //retrieve operations result metadata
97
99
  try {
98
100
  meta = ensureXdrInputType(meta, xdr.TransactionMeta)
@@ -47,7 +47,7 @@ function xdrParseAccountAddress(accountId, muxedAccountsSupported = false) {
47
47
  throw new TxMetaEffectParserError(`Unsupported account type: ${accountId.arm()}`)
48
48
  }
49
49
  }
50
- if (accountId instanceof Buffer) {
50
+ if (accountId instanceof Uint8Array) {
51
51
  return StrKey.encodeEd25519PublicKey(accountId)
52
52
  }
53
53
  throw new TypeError(`Failed to identify and parse account address: ${accountId}`)