Hello!
I have a node app with the dependency: “@concordium/web-sdk”: “^8.1.0”
Some other part of the program is sending a minting process of a CIS2 token, and after it is sent to the blockchain, it waits for the transactionHash to be finalized using this code:
await concordiumNodeClient.getBlockItemStatus(transactionHash);
Once the tx is correctly finalized, it tries to deserialize the outcome of the transaction with the intention of finding out the token Ids that are minted.
This is an example of the events raised from the contract:
// Mint the token in the state.
let token_id = state.mint(¶ms.token, ¶ms.owner, builder);
// Event for minted token.
logger.log(&Cis2Event::Mint(MintEvent {
token_id,
amount: concordium_cis2::TokenAmountU64(1),
owner: params.owner,
}))?;
// Metadata URL for the token.
logger.log(&Cis2Event::TokenMetadata::<_, ContractTokenAmount>(
TokenMetadataEvent {
token_id,
metadata_url: params.token.metadata_url.first().unwrap().clone(),
},
))?;
As you can see, two events are raised everytime a token is minted… the MintEvent and the TokenMetadataEvent.
That is actually what i can see in the getBlockItemStatus method response:
{
...
"events":[
"fe011101001ccebf8fd2005ba1779c7568936901ae2d438be75711f45fcbc9104eb5c8ddc7",
"fb0111670068747470733a2f2f35746172732d637269636b65742d6173736574732e73332e616d617a6f6e6177732e636f6d2f637573746f6d2d6d657461646174612f37323235343735362d336466302d343465382d623131622d6666383435373035363663652e6a736f6e00"
],
...
}
But now I don’t seem to find a nice way to unmarshall those two events in a smart way… so I can get 2 JSONS like this:
[
{
token_id: 1,
amount: 1,
owner: "blablabla"
},
{
token_id: 1,
metadata_url: "https://metadata.json"
}
]
Any thoughts? Thanks in advance!!!