multiversx / mx-sdk-js-core

MultiversX SDK for interacting with the MultiversX blockchain (in general) and Smart Contracts (in particular).
https://multiversx.github.io/mx-sdk-js-core/
Other
58 stars 37 forks source link

TokenOperationsOutcomeParser: error when a transaction has multiple events #397

Closed gfusee closed 3 months ago

gfusee commented 4 months ago

The implementation of the functions inside the class TokenOperationsOutcomeParser expect transactions to have only one event of interest: "issue", "ESDTNFTCreate", "ESDTLocalBurn", etc.

However this condition is not true, especially for indirect events in smart contract calls.

Here is a reproducible example:

import {ProxyNetworkProvider} from "@multiversx/sdk-network-providers/out"
import {TokenOperationsOutcomeParser} from "@multiversx/sdk-core/out"

async function main() {
    const provider = new ProxyNetworkProvider("https://gateway.multiversx.com")

    const tx = await provider.getTransaction("8c972e4756c553f11ba5dbdb74d9152c6bd0305761cd675b8b3945977d1d2a1a")

    const parser = new TokenOperationsOutcomeParser()
    const result = parser.parseNFTCreate(tx)

    console.log(result)
}

main()
andreibancioiu commented 4 months ago

Thanks for raising the issue :raised_hands:

We will brainstorm a bit the way to handle this limitation :pray:

popenta commented 4 months ago

We have adapted the specs and also made the changes in the upcoming release, js-core v13.

The implementation can be found here.

popenta commented 3 months ago

This has been introduced in the latest release (v13). Will close this issue.