-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
fix: contract method types should allow any param if abi type not supplied #6688
Conversation
Previously type was [] (zero element tuple) instead of any[] which prevented passing parameters if contract aby type was not defined.
Bundle StatsHey there, this message comes from a github action that helps you and reviewers to understand how these changes affect the size of this project's bundle. As this PR is updated, I'll keep you updated on how the bundle size is impacted. Total
View detailed bundle breakdownAdded No assets were added Removed No assets were removed Bigger No assets were bigger Smaller No assets were smaller Unchanged
|
Deploying with Cloudflare Pages
|
@@ -316,7 +316,7 @@ export type ContractMethodInputParameters<Params extends ReadonlyArray<unknown> | |||
[MatchPrimitiveType<H['type'], H['components']>, ...ContractMethodInputParameters<R>] | |||
: ContractMethodInputParameters<R> | |||
: Params extends undefined | unknown | |||
? [] | |||
? any[] |
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.
Thanks @mpetrunic,
Do you think this is better than https://github.com/web3/web3.js/pull/6636/files#diff-7fa8f782e68ce845dbb6e8446b86041697fa427db5485b9c63bf689d0b32ed81R116?
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'm not 100% but yours doesn't cover constructor args?
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.
But this should be fixed regardless of your 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.
Thanks Marin for the fix and the clarification.
It would be also great if you could add a test. As you see my PR for the methods args types did not work, so I left it for when having time for it. As I worked on it in my free time 😄
By the way, the constructor args types were handled as part of: #6635. Where even if the ABI was not provided, the types are inferred as possible.
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.
It will be great to add a small test where typescript does not complain about the passed args.
And the Unit and integration tests are failing and needed to be checked, please.
Many thanks,
Signed-off-by: Marin Petrunic <marin.petrunic@gmail.com>
Signed-off-by: Marin Petrunic <marin.petrunic@gmail.com>
@Muhammad-Altabba Improved solution and added test^^ |
Benchmark
This comment was automatically generated by workflow using github-action-benchmark. |
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## 4.x #6688 +/- ##
==========================================
+ Coverage 91.46% 92.03% +0.56%
==========================================
Files 214 214
Lines 8155 8171 +16
Branches 2193 2200 +7
==========================================
+ Hits 7459 7520 +61
+ Misses 696 651 -45
Flags with carried forward coverage won't be shown. Click here to find out more.
|
Signed-off-by: Marin Petrunic <marin.petrunic@gmail.com>
Description
Previously type was [] (zero element tuple) instead of any[] which prevented passing parameters if contract aby type was not defined.
Type of change
Checklist:
npm run lint
with success and extended the tests and types if necessary.npm run test:unit
with success.npm run test:coverage
and my test cases cover all the lines and branches of the added code.npm run build
and testeddist/web3.min.js
in a browser.CHANGELOG.md
file in the root folder.