-
Notifications
You must be signed in to change notification settings - Fork 17
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
Use BN for GenericScheme value #550
Conversation
@@ -18,7 +19,7 @@ export interface IUGenericScheme { | |||
|
|||
export interface IProposalCreateOptionsGS { | |||
callData?: string | |||
value?: number | |||
value?: BN | number | string |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this cannot be number
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
because value can be bigger than number
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
...in which case the calling application would already have crashed before getting into this code. This code can handle any number that an app is able to send to it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could you please add a test which send Number.MAX_SAFE_INTEGER +1 as the value ?
MAX_SAFE_INTEGER =. 2^53-1
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can tell you what will happen in your proposed case with the code as I've written it. The result will be that unexpected incorrect numbers will be sent to the contract (see the screenshot below).
There is nothing we can do to prevent the user from submitting numbers like this. We also can't prevent them from submitting totally invalid string representations. We could validate the values before submitting them to the contract, but note that we don't do that anywhere else where quantities are accepted, so why start here? We leave it up to the application to validate user input.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please submit your test. we should be able to support these kind of big values .
e.g sending 1 ether - 1000000000000000000 .
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I changed the existing test to use new BN('1000000000000000000')
.travis.yml
Outdated
sudo: required | ||
sudo: required |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why this ?
Resolves: #549