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

Improved schema validation for eth_getBalance #598

Draft
wants to merge 5 commits into
base: epic-v0.6.x
Choose a base branch
from

Conversation

cygnusv
Copy link
Member

@cygnusv cygnusv commented Oct 18, 2024

Type of PR:

  • Bugfix
  • Feature
  • Documentation
  • Other

Required reviews:

  • 1
  • 2
  • 3

What this does:

High-level idea of the changes introduced in this PR. List relevant API
changes (if any), as well as related PRs and issues.

Issues fixed/closed:

  • Fixes #...

Why it's needed:

Explain how this PR fits in the greater context of the NuCypher Network. E.g.,
if this PR address a nucypher/productdev issue, let reviewers know!

Notes for reviewers:

What should reviewers focus on? Is there a particular commit/function/section
of your PR that requires more attention from reviewers?

* 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
@cygnusv cygnusv changed the base branch from main to epic-v0.6.x October 18, 2024 15:33
Copy link

netlify bot commented Oct 18, 2024

Deploy Preview for taco-demo canceled.

Name Link
🔨 Latest commit 0d750e4
🔍 Latest deploy log https://app.netlify.com/sites/taco-demo/deploys/67127fd7eaba4200083e5056

Copy link

netlify bot commented Oct 18, 2024

Deploy Preview for taco-nft-demo canceled.

Name Link
🔨 Latest commit 0d750e4
🔍 Latest deploy log https://app.netlify.com/sites/taco-nft-demo/deploys/67127fd7cb6ea10008709f5d

@codecov-commenter
Copy link

Codecov Report

All modified and coverable lines are covered by tests ✅

Please upload report for BASE (epic-v0.6.x@fcdb1da). Learn more about missing BASE report.

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.
📢 Have feedback on the report? Share it here.


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);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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)'],
Copy link
Member

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.

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

Successfully merging this pull request may close these issues.

3 participants