-
Notifications
You must be signed in to change notification settings - Fork 23
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
Improved schema validation for eth_getBalance #598
Conversation
* Allow any type of context variable for the eth address parameter * The non-empty array is not an acceptable schema for parameters. What we want is a one-element tuple
✅ Deploy Preview for taco-demo canceled.
|
✅ Deploy Preview for taco-nft-demo canceled.
|
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## epic-v0.6.x #598 +/- ##
==============================================
Coverage ? 89.19%
==============================================
Files ? 73
Lines ? 6498
Branches ? 345
==============================================
Hits ? 5796
Misses ? 664
Partials ? 38 ☔ View full report in Codecov by Sentry. |
@@ -6,7 +6,8 @@ import { plainStringSchema } from './common'; | |||
|
|||
export const contextParamSchema = z.string().regex(CONTEXT_PARAM_REGEXP); | |||
|
|||
const paramSchema = z.union([plainStringSchema, z.boolean(), z.number()]); | |||
// TODO: This is too broad, but it's a start | |||
const paramSchema = z.union([plainStringSchema, z.boolean(), z.number().int().nonnegative()]); |
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.
Is there ever a case for negative numbers?
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.
You're right, it is indeed acceptable (int256
type and friends). Fixed in b3902d4
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 was thinking about this some more. Perhaps we need to separate this schema into two parts.
- What is allowed for blockchain RPC / smart contract calls
- What is generally allowed
The original goal of the paraSchema
on L9 was 2), but we are now limiting it to 1).
Solidity doesn't have floating point numbers, so limiting it to z.number().int()
is fine. However, a JsonApiCondition
can require floating point numbers. For example, the paramOrContextParamSchema
is used for the value used for the returnValueTest () - and for a JSON API, checking a floating point number is perfectly fine, but now it won't be; typified by the fact that I saw you had to modify the floating point test.
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.
^ @cygnusv wdyt?
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.
yep, I was actually reverting my changes as we speak. Let's just put a pin on this so we can unblock the PR.
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.
Opened #600
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.
LGTM! 👌
Co-authored-by: Derek Pierre <derek.pierre@gmail.com>
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.
🎸
Type of PR:
Required reviews:
What this does:
Issues fixed/closed:
Why it's needed:
Notes for reviewers: