@stellar-expert/tx-meta-effects-parser 5.6.2 → 5.6.4
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
package/src/effects-analyzer.js
CHANGED
|
@@ -782,12 +782,21 @@ class EffectsAnalyzer {
|
|
|
782
782
|
processContractChanges({action, before, after}) {
|
|
783
783
|
if (action !== 'created' && action !== 'updated')
|
|
784
784
|
throw new UnexpectedTxMetaChangeError({type: 'contract', action})
|
|
785
|
-
const {kind, contract
|
|
785
|
+
const {kind, contract} = after
|
|
786
786
|
const effect = {
|
|
787
787
|
type: effectTypes.contractCreated,
|
|
788
788
|
contract,
|
|
789
|
-
kind
|
|
790
|
-
|
|
789
|
+
kind
|
|
790
|
+
}
|
|
791
|
+
switch (kind) {
|
|
792
|
+
case 'fromAsset':
|
|
793
|
+
effect.asset = after.asset
|
|
794
|
+
break
|
|
795
|
+
case 'wasm':
|
|
796
|
+
effect.wasmHash = after.hash
|
|
797
|
+
break
|
|
798
|
+
default:
|
|
799
|
+
throw new TxMetaEffectParserError('Unexpected contract type: ' + kind)
|
|
791
800
|
}
|
|
792
801
|
if (action === 'created') {
|
|
793
802
|
if (this.effects.some(e => e.contract === contract))
|
|
@@ -798,7 +807,7 @@ class EffectsAnalyzer {
|
|
|
798
807
|
if (before.storage?.length || after.storage?.length) {
|
|
799
808
|
this.processInstanceDataChanges(before, after)
|
|
800
809
|
}
|
|
801
|
-
if (before.hash === hash) //skip if hash unchanged
|
|
810
|
+
if (before.hash === after.hash) //skip if hash unchanged
|
|
802
811
|
return
|
|
803
812
|
}
|
|
804
813
|
this.addEffect(effect)
|
|
@@ -246,52 +246,20 @@ function parseContractData(value) {
|
|
|
246
246
|
entry: 'contract',
|
|
247
247
|
contract: owner
|
|
248
248
|
}
|
|
249
|
-
const
|
|
249
|
+
const instance = valueAttr.instance()._attributes
|
|
250
|
+
const type = instance.executable._switch.name
|
|
250
251
|
switch (type) {
|
|
251
252
|
case 'contractExecutableStellarAsset':
|
|
252
|
-
entry.
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
* storage: Array[3]
|
|
260
|
-
* [0]
|
|
261
|
-
* key: [scvSymbol]
|
|
262
|
-
* sym: METADATA
|
|
263
|
-
* val: [scvMap]
|
|
264
|
-
* map: Array[3]
|
|
265
|
-
* [0]
|
|
266
|
-
* key: [scvSymbol]
|
|
267
|
-
* sym: decimal
|
|
268
|
-
* val: [scvU32]
|
|
269
|
-
* u32: 7
|
|
270
|
-
* [1]
|
|
271
|
-
* key: [scvSymbol]
|
|
272
|
-
* sym: name
|
|
273
|
-
* val: [scvString]
|
|
274
|
-
* str: ICGVCWUQXIHO:GBD2ALDOSNTEW2QWQA6RGQXTZVWGFZYTT5DYZDCPPGNOYTXOAQ6RFUAC
|
|
275
|
-
* [2]
|
|
276
|
-
* key: [scvSymbol]
|
|
277
|
-
* sym: symbol
|
|
278
|
-
* val: [scvString]
|
|
279
|
-
* str: ICGVCWUQXIHO
|
|
280
|
-
* [1]
|
|
281
|
-
* key: [scvVec]
|
|
282
|
-
* vec: Array[1]
|
|
283
|
-
* [0]: [scvSymbol]
|
|
284
|
-
* sym: Admin
|
|
285
|
-
* val: [scvAddress]
|
|
286
|
-
* address: [scAddressTypeAccount]
|
|
287
|
-
* accountId: [publicKeyTypeEd25519]
|
|
288
|
-
* ed25519: GBD2ALDOSNTEW2QWQA6RGQXTZVWGFZYTT5DYZDCPPGNOYTXOAQ6RFUAC
|
|
289
|
-
*/
|
|
290
|
-
return undefined
|
|
253
|
+
entry.kind = 'fromAsset'
|
|
254
|
+
if (!instance.storage.length)
|
|
255
|
+
return undefined //likely the asset has been created "fromAddress" - no metadata in this case
|
|
256
|
+
const metaArgs = instance.storage[0]._attributes
|
|
257
|
+
if (metaArgs.key._value.toString() !== 'METADATA')
|
|
258
|
+
throw new TxMetaEffectParserError('Unexpected asset initialization metadata')
|
|
259
|
+
entry.asset = xdrParseAsset(metaArgs.val._value[1]._attributes.val._value.toString())
|
|
291
260
|
break
|
|
292
261
|
case 'contractExecutableWasm':
|
|
293
262
|
entry.kind = 'wasm'
|
|
294
|
-
const instance = valueAttr.instance()._attributes
|
|
295
263
|
entry.hash = instance.executable.wasmHash().toString('hex')
|
|
296
264
|
if (instance.storage?.length) {
|
|
297
265
|
entry.storage = instance.storage.map(entry => ({
|