Closed taoeffect closed 3 months ago
@taoeffect
I implemented numberRange()
in this previous PR.
So things left to do here is to add this to various places you mentioned.
Q. I remember you telling us a few weeks ago to refrain from making updates to contracts files and this one does involve changes in contract files. Is this safe to work on now?
Yes, it is safe to work on the contract files. Please see the pinned comments on Slack for details about where caution should be exercised.
Problem
Some numbers should be appropriately limited in the app but aren't. Right now there is no simple way in contract validation functions to limit a number's range.
Also, I noticed separate missing
stringMax
validators for:Solution
Similar to
stringMax()
, implementnumberRange()
that looks like this:No need to add the name of the parameter there. Just make sure that any error messages thrown include the range itself, and that should be sufficient to identity which parameter failed.
Then add this to:
mincomeAmount
: make it go from1
to1000000000
distributionPeriodLength
: from1
to365
amount
(ingroup/payment)
): from0
to1000000000
exchangeRate
: from0
to1000000000
expires_date_ms
: from0
toNumber.MAX_SAFE_INTEGER
For the
stringMax
validators:vote
should be aunionOf
the 4literalOf
s fromrules.js
proposalIds
should bearrayOf
MAX_HASH_LEN
stringsmemberID
should beMAX_HASH_LEN
reason
should be some value that's also enforced in the UI (double check that it is), and probably same asGROUP_DESCRIPTION_MAX_CHAR
name
should beGROUP_NAME_MAX_CHAR
memberID
is anotherMAX_HASH_LEN