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

fix: proper view method result parsing #1320

Merged
merged 5 commits into from
Oct 12, 2022

Conversation

dOrgJelli
Copy link
Contributor

objects.push(element.toString());
return prepared;
} else if (
typeof value === "object" &&
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What are some examples where this is useful?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is necessary because ethers.js utilizes the BigNumber object to represent numbers larger than JS' number range (ex: uint256). When you simply JSON.stringify(...) a BigNumber the result is not desirable and just shows the internals of the object. This is because BigNumber does not implement a toJSON() method. So instead, we leverage object's toString() method if it's available.

nerfZael
nerfZael previously approved these changes Oct 12, 2022
@dOrgJelli dOrgJelli merged commit 0e51185 into origin-dev Oct 12, 2022
@dOrgJelli dOrgJelli deleted the ethereum-return-value-parsing branch April 10, 2023 17:02
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

Successfully merging this pull request may close these issues.

2 participants