@stellar-expert/tx-meta-effects-parser 5.6.1 → 5.6.2
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
|
@@ -50,9 +50,9 @@ class AssetSupplyAnalyzer {
|
|
|
50
50
|
this.supplyChanges |= 1
|
|
51
51
|
}
|
|
52
52
|
}
|
|
53
|
-
if ((this.supplyChanges & 3) === 3) { //analyze possible collapsible mints only if both mint and burn effects recorded
|
|
53
|
+
/*if ((this.supplyChanges & 3) === 3) { //analyze possible collapsible mints only if both mint and burn effects recorded
|
|
54
54
|
new CollapsibleMintsAnalyzer(this.effectsAnalyzer).removeCollapsingMints()
|
|
55
|
-
}
|
|
55
|
+
}*/
|
|
56
56
|
}
|
|
57
57
|
|
|
58
58
|
/**
|
|
@@ -181,7 +181,7 @@ class CollapsibleMintsAnalyzer {
|
|
|
181
181
|
if (sum > 0n) { //asset minted
|
|
182
182
|
this.effectsAnalyzer.mint(asset, sum.toString(), true) //insert mint effect
|
|
183
183
|
} else if (sum < 0n) { //asset burned
|
|
184
|
-
this.effectsAnalyzer.burn(asset, sum.toString(), position) //insert burn effect at the position of the last removed effect
|
|
184
|
+
this.effectsAnalyzer.burn(asset, (-sum).toString(), position) //insert burn effect at the position of the last removed effect
|
|
185
185
|
}
|
|
186
186
|
//if sum=0 then both effects were annihilated and removed
|
|
187
187
|
}
|
|
@@ -158,13 +158,6 @@ class EventsAnalyzer {
|
|
|
158
158
|
if (classicAsset) {
|
|
159
159
|
if (classicAsset.includes(from)) { //SAC transfer by asset issuer
|
|
160
160
|
this.effectsAnalyzer.mint(classicAsset, amount)
|
|
161
|
-
this.effectsAnalyzer.credit(amount, classicAsset, to)
|
|
162
|
-
return
|
|
163
|
-
}
|
|
164
|
-
if (classicAsset.includes(to)) { //SAC transfer by asset issuer
|
|
165
|
-
this.effectsAnalyzer.debit(amount, classicAsset, from)
|
|
166
|
-
this.effectsAnalyzer.burn(classicAsset, amount)
|
|
167
|
-
return
|
|
168
161
|
}
|
|
169
162
|
if (isContractAddress(from)) {
|
|
170
163
|
this.effectsAnalyzer.debit(amount, classicAsset, from)
|
|
@@ -172,6 +165,9 @@ class EventsAnalyzer {
|
|
|
172
165
|
if (isContractAddress(to)) {
|
|
173
166
|
this.effectsAnalyzer.credit(amount, classicAsset, to)
|
|
174
167
|
}
|
|
168
|
+
if (classicAsset.includes(to)) { //SAC transfer by asset issuer
|
|
169
|
+
this.effectsAnalyzer.burn(classicAsset, amount)
|
|
170
|
+
}
|
|
175
171
|
} else { //other cases
|
|
176
172
|
this.effectsAnalyzer.debit(amount, this.effectsAnalyzer.resolveAsset(contract), from)
|
|
177
173
|
this.effectsAnalyzer.credit(amount, this.effectsAnalyzer.resolveAsset(contract), to)
|
package/src/effects-analyzer.js
CHANGED
|
@@ -132,7 +132,7 @@ class EffectsAnalyzer {
|
|
|
132
132
|
type: effectTypes.accountDebited,
|
|
133
133
|
source,
|
|
134
134
|
asset,
|
|
135
|
-
amount
|
|
135
|
+
amount: validateAmount(amount)
|
|
136
136
|
}
|
|
137
137
|
if (balance !== undefined) {
|
|
138
138
|
effect.balance = balance
|
|
@@ -147,7 +147,7 @@ class EffectsAnalyzer {
|
|
|
147
147
|
type: effectTypes.accountCredited,
|
|
148
148
|
source,
|
|
149
149
|
asset,
|
|
150
|
-
amount
|
|
150
|
+
amount: validateAmount(amount)
|
|
151
151
|
}
|
|
152
152
|
if (balance !== undefined) {
|
|
153
153
|
effect.balance = balance
|
|
@@ -162,7 +162,7 @@ class EffectsAnalyzer {
|
|
|
162
162
|
this.addEffect({
|
|
163
163
|
type: effectTypes.assetMinted,
|
|
164
164
|
asset,
|
|
165
|
-
amount
|
|
165
|
+
amount: validateAmount(amount)
|
|
166
166
|
}, position)
|
|
167
167
|
}
|
|
168
168
|
|
|
@@ -170,7 +170,7 @@ class EffectsAnalyzer {
|
|
|
170
170
|
this.addEffect({
|
|
171
171
|
type: effectTypes.assetBurned,
|
|
172
172
|
asset,
|
|
173
|
-
amount
|
|
173
|
+
amount: validateAmount(amount)
|
|
174
174
|
}, position)
|
|
175
175
|
}
|
|
176
176
|
|
|
@@ -998,6 +998,12 @@ function encodeSponsorshipEffectName(action, type) {
|
|
|
998
998
|
return effectTypes[`${type}Sponsorship${actionKey}`]
|
|
999
999
|
}
|
|
1000
1000
|
|
|
1001
|
+
function validateAmount(amount) {
|
|
1002
|
+
if (amount < 0)
|
|
1003
|
+
throw new TxMetaEffectParserError('Negative balance change amount: ' + amount.toString())
|
|
1004
|
+
return amount
|
|
1005
|
+
}
|
|
1006
|
+
|
|
1001
1007
|
function parseLargeInt(largeInt) {
|
|
1002
1008
|
return largeInt._value.toString()
|
|
1003
1009
|
}
|