web3.js icon indicating copy to clipboard operation
web3.js copied to clipboard

[DRAFT] Allow smart contract methods to accept parameters when ABI was provided not `as const`

Open Muhammad-Altabba opened this issue 1 year ago • 4 comments
trafficstars

Description

Fixes #6275

If the developer provided an ABI from a file but without having as const, if he provided the ABI without saving it to a ts file first (with the as const), or if he provided an empty ABI, the user can call contract.methods.ANY_METHOD_NAM() but cannot pass any parameter to his called methods. Meaning he can call only methods that does not accept parameter or he need to do something like: (contract.methods.transfer as any)('0xe4beef667408b99053dc147ed19592ada0d77f59', 12) This MR will fix that.

Type of change

  • [ ] Bug fix (non-breaking change which fixes an issue)
  • [ ] New feature (non-breaking change which adds functionality)
  • [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected)

Checklist:

  • [ ] I have selected the correct base branch.
  • [ ] I have performed a self-review of my own code.
  • [ ] I have commented my code, particularly in hard-to-understand areas.
  • [ ] I have made corresponding changes to the documentation.
  • [ ] My changes generate no new warnings.
  • [ ] Any dependent changes have been merged and published in downstream modules.
  • [ ] I ran npm run lint with success and extended the tests and types if necessary.
  • [ ] I ran npm run test:unit with success.
  • [ ] I ran npm run test:coverage and my test cases cover all the lines and branches of the added code.
  • [ ] I ran npm run build and tested dist/web3.min.js in a browser.
  • [ ] I have tested my code on the live network.
  • [ ] I have checked the Deploy Preview and it looks correct.
  • [ ] I have updated the CHANGELOG.md file in the root folder.
  • [ ] I have linked Issue(s) with this PR in "Linked Issues" menu.

Muhammad-Altabba avatar Dec 03 '23 15:12 Muhammad-Altabba

Bundle Stats

Hey 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

Asset Old size New size Diff Diff %
Total 591 KB 591 KB 0 0.00%
View detailed bundle breakdown

Added

No assets were added

Removed

No assets were removed

Bigger

No assets were bigger

Smaller

No assets were smaller

Unchanged

Asset Old size New size Diff Diff %
web3.min.js 573 KB 573 KB 0 0.00%
../lib/commonjs/index.d.ts 8.63 KB 8.63 KB 0 0.00%
../lib/commonjs/accounts.d.ts 3.89 KB 3.89 KB 0 0.00%
../lib/commonjs/types.d.ts 2.45 KB 2.45 KB 0 0.00%
../lib/commonjs/web3.d.ts 1.14 KB 1.14 KB 0 0.00%
../lib/commonjs/abi.d.ts 999 bytes 999 bytes 0 0.00%
../lib/commonjs/eth.exports.d.ts 280 bytes 280 bytes 0 0.00%
../lib/commonjs/providers.exports.d.ts 148 bytes 148 bytes 0 0.00%
../lib/commonjs/version.d.ts 60 bytes 60 bytes 0 0.00%

github-actions[bot] avatar Dec 03 '23 15:12 github-actions[bot]

Codecov Report

Merging #6636 (21059cd) into 4.x (0c67cc6) will decrease coverage by 1.21%. Report is 49 commits behind head on 4.x. The diff coverage is 100.00%.

:exclamation: Current head 21059cd differs from pull request most recent head e37be00. Consider uploading reports for the commit e37be00 to get more accurate results

Additional details and impacted files
@@            Coverage Diff             @@
##              4.x    #6636      +/-   ##
==========================================
- Coverage   91.46%   90.25%   -1.21%     
==========================================
  Files         214      214              
  Lines        8155     8087      -68     
  Branches     2193     2162      -31     
==========================================
- Hits         7459     7299     -160     
- Misses        696      788      +92     
Flag Coverage Δ
UnitTests 90.25% <100.00%> (-1.21%) :arrow_down:

Flags with carried forward coverage won't be shown. Click here to find out more.

Components Coverage Δ
web3 ∅ <ø> (∅)
web3-core ∅ <ø> (∅)
web3-errors ∅ <ø> (∅)
web3-eth ∅ <ø> (∅)
web3-eth-abi ∅ <ø> (∅)
web3-eth-accounts ∅ <ø> (∅)
web3-eth-contract ∅ <ø> (∅)
web3-eth-ens ∅ <ø> (∅)
web3-eth-iban ∅ <ø> (∅)
web3-eth-personal ∅ <ø> (∅)
web3-net ∅ <ø> (∅)
web3-providers-http ∅ <ø> (∅)
web3-providers-ipc ∅ <ø> (∅)
web3-providers-ws ∅ <ø> (∅)
web3-rpc-methods ∅ <ø> (∅)
web3-utils ∅ <ø> (∅)
web3-validator ∅ <ø> (∅)

codecov[bot] avatar Dec 03 '23 15:12 codecov[bot]

Deploying with  Cloudflare Pages  Cloudflare Pages

Latest commit: e37be00
Status: ✅  Deploy successful!
Preview URL: https://4452029e.web3-js-docs.pages.dev
Branch Preview URL: https://6275-fix-web3ethcontractmeth.web3-js-docs.pages.dev

View logs

Benchmark

Benchmark suite Current: e37be00c20ad17db787025c1c4e9f114577248f6 Previous: 6c075dba3fefa27c833e5c71bf91319ac2466b0b Ratio
processingTx 9473 ops/sec (±3.68%) 9301 ops/sec (±4.81%) 0.98
processingContractDeploy 39709 ops/sec (±8.51%) 39129 ops/sec (±7.62%) 0.99
processingContractMethodSend 19106 ops/sec (±7.68%) 19443 ops/sec (±5.19%) 1.02
processingContractMethodCall 38407 ops/sec (±5.79%) 38971 ops/sec (±6.34%) 1.01
abiEncode 43900 ops/sec (±7.02%) 44252 ops/sec (±6.92%) 1.01
abiDecode 31601 ops/sec (±8.25%) 30419 ops/sec (±8.89%) 0.96
sign 1637 ops/sec (±3.04%) 1656 ops/sec (±4.08%) 1.01
verify 383 ops/sec (±0.51%) 373 ops/sec (±0.78%) 0.97

This comment was automatically generated by workflow using github-action-benchmark.

github-actions[bot] avatar Jan 04 '24 13:01 github-actions[bot]

This PR has been automatically marked as stale because it has not had recent activity. It will be closed in 7 days if no further activity occurs. Thank you for your contributions. If you believe this was a mistake, please comment.

github-actions[bot] avatar Mar 05 '24 00:03 github-actions[bot]