Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Events :: Return typed decoded event data #1325

Open
Valazan opened this issue Sep 20, 2024 · 1 comment
Open

Events :: Return typed decoded event data #1325

Valazan opened this issue Sep 20, 2024 · 1 comment
Assignees

Comments

@Valazan
Copy link
Contributor

Valazan commented Sep 20, 2024

Currently, the Software Development Kit (SDK) is returning data as a generic Result object provided by the Ethers.js library. While this Result object contains the necessary decoded data from smart contract interactions, it lacks a structured format that aligns with the smart contract's Application Binary Interface (ABI).

The ABI defines the methods and variables available in a smart contract, essentially acting as a blueprint for how data should be organized and accessed. When the SDK returns data as an unstructured Result, developers may face challenges in interpreting and utilizing this data effectively. They might need to manually parse the Result object to extract the relevant information, which can be error-prone and time-consuming.

To enhance usability and developer experience, the SDK should return the decoded data structured according to the ABI specifications. This means organizing the data into objects or formats that directly reflect the expected inputs and outputs defined in the smart contract's ABI. By doing so, developers can interact with the data more intuitively, reducing the overhead of manual data manipulation and minimizing the risk of errors.

In summary, modifying the SDK to output data structured per the ABI will streamline the development process by providing clear, well-organized data that aligns with the smart contract's defined interface

@freemanzMrojo
Copy link
Member

Hey @Valazan just FYI in this period of time we have replaced ethers by viem for the case you describe above, so an object is returned when decoding an event. We have also introduced a method to return the decoded values in an "ethers format" (as array). So currently you have both.

Some additional work might need to be done for "custom" types (maybe that could be the scope of this ticket) but the new methods return objects, just FYI.

Have a look at:

  • ABIEvent#parseLog for events decoding
  • ABIFunction#decodeResult for functions decoding

Reach out to me if you have any questions ofc, or if we need to work on something else to improve it.

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants