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

Amount schema value type is expected to be a number and not a string #1804

Open
bbenligiray opened this issue Jun 9, 2023 · 4 comments
Open

Comments

@bbenligiray
Copy link
Member

This is how amounts are represented

{
  "unit": "ether",
  "value": 1
}

Since value may still be a big number, it should be represented as a string and not a number type.
For reference, ethers.utils.parseUnits(1, 'ether') throws and ethers.utils.parseUnits('1', 'ether') succeeds.

@dcroote
Copy link
Contributor

dcroote commented Jun 9, 2023

I thought of that possibility when implementing this, hence the following check:

value: z.number().lte(9007199254740991), // 2**53 - 1

@bbenligiray
Copy link
Member Author

But why not make it a string instead? For example, I think it's very likely for someone to want to do this

{
  "value": "1000000000000000000",
  "unit": "wei"
}

@dcroote
Copy link
Contributor

dcroote commented Jun 9, 2023

It actually used to be a string (under various earlier variable names e.g. priorityFeeSchema), but no one had a strong preference, see here for the discussion in which you comment: #890 (comment)

@bbenligiray
Copy link
Member Author

Let's leave the issue open anyway in case it comes up again

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