-
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
base: epic-v0.6.x
Are you sure you want to change the base?
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.20%
==============================================
Files ? 73
Lines ? 6500
Branches ? 345
==============================================
Hits ? 5798
Misses ? 664
Partials ? 38 ☔ View full report in Codecov by Sentry. |
|
||
const BLOCK_HASH_REGEXP = new RegExp('^0x[a-fA-F0-9]{64}$'); | ||
const BlockNumber = z.number().int().nonnegative(); | ||
const BlockHash = z.string().regex(BLOCK_HASH_REGEXP); |
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.
const BlockHash = z.string().regex(BLOCK_HASH_REGEXP); | |
const BlockHash = z.string().regex(BLOCK_HASH_REGEXP, 'Invalid block hash'); |
@@ -109,7 +143,7 @@ describe('validation', () => { | |||
expect(result.data).toBeUndefined(); | |||
expect(result.error?.format()).toMatchObject({ | |||
parameters: { | |||
_errors: ['Array must contain at least 1 element(s)'], | |||
_errors: ['Array must contain at least 2 element(s)', 'Array must contain at least 1 element(s)'], |
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 did some digging around to see if there is a way to work around this - it's a little conflicting to have both i.e. at least 2 element(s)
and at least 1 element(s)
- but I couldn't find anything. Seems to be by design - colinhacks/zod#311 (comment).
Type of PR:
Required reviews:
What this does:
Issues fixed/closed:
Why it's needed:
Notes for reviewers: