ecadlabs / taquito

A library for building dApps on the Tezos Blockchain - JavaScript / TypeScript
https://taquito.io
Apache License 2.0
298 stars 118 forks source link

Micheline types returned on the smart contract event payload is different from the expected one #2462

Closed zamrokk closed 1 year ago

zamrokk commented 1 year ago

Hi. I found something weird with eventsI receive from my smartcontract On the client side, with Taquito "16.1.2" I display what I receive and it should be an Array of addresses instead I get and Array of bytes.

If I look on an indexer, it is able to display the addresses as Array of string (https://ghostnet.tzkt.io/oo79S9vVsZeVNZeEKsF3byjurpqewF4kk8Z5giPmQxYMuGPNsAy/249015)

So where is the bug from ?

image

this how I emit the event in ligo

Tezos.emit("%orgMemberRequestsUpdated",[jor.membersToApprove,jor.membersToDecline,org.name])

Here is the type definition of each field

export type joinOrganizationResponse = {
    membersToApprove : set<address>,
    membersToDecline : set<address>, 
    orgName : string
};
dsawali commented 1 year ago

Hello there @zamrokk, thanks for taking the time to write up an issue.

Was this behaviour observed from using the event listener?

zamrokk commented 1 year ago

Yes. For other events returning a simple type, no problem but this is a tuple of 3 items o I receive a complex Micheline with pairs

dsawali commented 1 year ago

@zamrokk thanks, we'll look into this

zamrokk commented 1 year ago

The person who did the events is thinking that taquito did not unify the payload data with the type correctly He thinks nothing is wrong with the contract or the indexer-node pair

hui-an-yang commented 1 year ago

Hello @zamrokk,

Thanks for reporting this, we have looked into this and found that it's not a Taquito bug. Here with ctrl + F 'event' you can see what's being returned by the node is also array of bytes even the type definition is array of address. We have raised this question to Tezos core developer team waiting for reply, will get back to you when we have more information.

hui-an-yang commented 1 year ago

Hi @zamrokk

I've confirmed with a tezos core developer that they'll improve the event emitted to be readable form like tz1... in the future release. Here's their MR of the change.

zamrokk commented 1 year ago

Thank you for the support !!!