@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 +1 -1
- package/src/index.js +15 -13
- package/src/tx-xdr-parser-utils.js +1 -1
package/package.json
CHANGED
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
|
-
|
|
35
|
-
result = ensureXdrInputType(result, xdr.TransactionResult)
|
|
36
|
-
} catch (e) {
|
|
34
|
+
if (!isEphemeral) {
|
|
37
35
|
try {
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
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
|
|
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
|
|
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}`)
|