-
Notifications
You must be signed in to change notification settings - Fork 5.1k
5427 contracts unit tests #5465
Conversation
| }; | ||
| expect(contract.defaultCommon).toBeUndefined(); | ||
| contract.defaultCommon = defaultCommon; | ||
| // expect(contract.defaultHardfork).toStrictEqual(defaultCommon); // TODO check if is being fixed in 5419 |
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.
| // expect(contract.defaultHardfork).toStrictEqual(defaultCommon); // TODO check if is being fixed in 5419 | |
| // expect(contract.defaultCommon).toStrictEqual(defaultCommon); // TODO check if is being fixed in 5419 |
Did u mean defaultCommon instead of defaultHardFork?
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.
yes. it was commented earlier, as this should not pass:
in earlier line I set HF diff as compared to contract.defaultCommon.hardfork
it should throw error when contract.defaultHardfork != contract.defaultCommon.hardfork we discussed in #5419 ?
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.
https://github.com/web3/web3.js/blob/4.x/packages/web3-eth/src/validation.ts#L161 It will error when theres a validation check against when common, chain and hardfork are all defined
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, so validation is done at validateTransactionForSigning level.
I think we should have additional feature of doing validation during setting defaults as well, this will help users to identify errors at earlier stage.
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.
sounds good, that can be a different feature. pr looks good to me
Muhammad-Altabba
left a comment
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.
Looks great.
However, I have just 2 questions.
Muhammad-Altabba
left a comment
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.
Looks great!
However, there are fixable issues in the pipeline I think.
* fix typing compatibility when linking a contract to a context * replace any with unknown at a suggested code for Web3Context * Web3 net system tests (#5457) * Add tests * Update geth script * Fix geth script * Reset to initial chainId * Remove uneeded space * Ganace chainId * more fixes and sample calls for the plugin draft * tiny code revert for unused variable * add comments and replace some `any`s with `unknown`s for plugin related code * 5427 contracts unit tests (#5465) * sample abi of a contract * unit tests contract * contract events test * unit test data * additional tests for more coverage * default common check * test contract source and updated abi * common type fix * Merge with 5091 Co-authored-by: Nikos Iliakis <[email protected]> Co-authored-by: Junaid <[email protected]> Co-authored-by: Wyatt Barnes <[email protected]>
* Init abstract Web3PluginBase class. Init registerPlugin method * Update web3.ts to have a named export instead of using default * Init web3-plugin-example package * Update CHANGELOG and README * Update packages/web3-plugin-example/test/unit/plugin.test.ts * Remove unneeded npm scripts * Remove webpack config * Init ExistingPluginNamespaceError * registerPluging - throw error is namespace not undefined * Update Web3 to use default and named exports * Add peerDependencies * Default API generic to Web3APISpec for Web3PluginBase * Remove use of ChainlinkPluginAPI. Define return type for getPrice * Remove no longer needed generic values * Override link method for plugin * Remove no longer used import * Remove ChainlinkPlugin code * Init custom_rpc_methods plugin example * Init contract_method_wrappers plugin example * Update web3 import to remove import ts error * Fix typing compatibility when linking a contract to a context (#5416) * fix typing compatibility when linking a contract to a context * replace any with unknown at a suggested code for Web3Context * Web3 net system tests (#5457) * Add tests * Update geth script * Fix geth script * Reset to initial chainId * Remove uneeded space * Ganace chainId * more fixes and sample calls for the plugin draft * tiny code revert for unused variable * add comments and replace some `any`s with `unknown`s for plugin related code * 5427 contracts unit tests (#5465) * sample abi of a contract * unit tests contract * contract events test * unit test data * additional tests for more coverage * default common check * test contract source and updated abi * common type fix * Merge with 5091 Co-authored-by: Nikos Iliakis <[email protected]> Co-authored-by: Junaid <[email protected]> Co-authored-by: Wyatt Barnes <[email protected]> * Fix lint error * Move web3-plugin-example to tools/. Remove @ts-expect-errors. Move Web3 module redeclarations to test files * Update CHANGELOGs * Fix tsc and linter errors * Update packages/web3-types/CHANGELOG.md * Add CHANGELOG changes to root CHANGELOG * Update packages/web3-types/CHANGELOG.md * Update CHANGELOG.md Co-authored-by: Muhammad Altabba <[email protected]> * Update CHANGELOG.md * Add web3-plugin-example CHANGELOG * Remove unnecessary web3 imports * Revert change to Web3 export * Init web3_export_helper.ts * Update packages/web3/CHANGELOG.md Co-authored-by: Muhammad Altabba <[email protected]> * Update CHANGELOG.md Co-authored-by: Muhammad Altabba <[email protected]> * Update comments for mocking in contract_method_wrappers.test.ts Co-authored-by: Junaid <[email protected]> Co-authored-by: Muhammad Altabba <[email protected]> Co-authored-by: Nikos Iliakis <[email protected]>
* fix typing compatibility when linking a contract to a context * replace any with unknown at a suggested code for Web3Context * Web3 net system tests (#5457) * Add tests * Update geth script * Fix geth script * Reset to initial chainId * Remove uneeded space * Ganace chainId * more fixes and sample calls for the plugin draft * tiny code revert for unused variable * add comments and replace some `any`s with `unknown`s for plugin related code * 5427 contracts unit tests (#5465) * sample abi of a contract * unit tests contract * contract events test * unit test data * additional tests for more coverage * default common check * test contract source and updated abi * common type fix * Merge with 5091 Co-authored-by: Nikos Iliakis <[email protected]> Co-authored-by: Junaid <[email protected]> Co-authored-by: Wyatt Barnes <[email protected]>
* Update web3.ts to have a named export instead of using default * Init web3-plugin-example package * Update CHANGELOG and README * Update packages/web3-plugin-example/test/unit/plugin.test.ts * Remove unneeded npm scripts * Remove webpack config * Update Web3 to use default and named exports * Add peerDependencies * Remove use of ChainlinkPluginAPI. Define return type for getPrice * Override link method for plugin * Remove ChainlinkPlugin code * Init custom_rpc_methods plugin example * Init contract_method_wrappers plugin example * Update web3 import to remove import ts error * Fix typing compatibility when linking a contract to a context (#5416) * fix typing compatibility when linking a contract to a context * replace any with unknown at a suggested code for Web3Context * Web3 net system tests (#5457) * Add tests * Update geth script * Fix geth script * Reset to initial chainId * Remove uneeded space * Ganace chainId * more fixes and sample calls for the plugin draft * tiny code revert for unused variable * add comments and replace some `any`s with `unknown`s for plugin related code * 5427 contracts unit tests (#5465) * sample abi of a contract * unit tests contract * contract events test * unit test data * additional tests for more coverage * default common check * test contract source and updated abi * common type fix * Merge with 5091 Co-authored-by: Nikos Iliakis <[email protected]> Co-authored-by: Junaid <[email protected]> Co-authored-by: Wyatt Barnes <[email protected]> * Move web3-plugin-example to tools/. Remove @ts-expect-errors. Move Web3 module redeclarations to test files * Update CHANGELOGs * Update packages/web3-types/CHANGELOG.md * Update CHANGELOG.md Co-authored-by: Muhammad Altabba <[email protected]> * Revert change to Web3 export * WIP plugin docs * Update plugin_authors doc * Update plugin_users doc * Rewording * Update packages/web3/CHANGELOG.md * Update CHANGELOG.md * Update docs/docs/guides/web3_plugin_guide/plugin_authors.md Co-authored-by: Junaid <[email protected]> * Update docs/docs/guides/web3_plugin_guide/plugin_users.md Co-authored-by: Junaid <[email protected]> * Update docs/docs/guides/web3_plugin_guide/plugin_users.md Co-authored-by: Junaid <[email protected]> * Apply suggestions from code review Co-authored-by: Junaid <[email protected]> * Update tree shaking guide to sidebar position 2 * Update plugin authors sidebar position to 0 * Update docs/docs/guides/web3_plugin_guide/plugin_users.md Co-authored-by: Alex <[email protected]> Co-authored-by: Muhammad Altabba <[email protected]> Co-authored-by: Nikos Iliakis <[email protected]> Co-authored-by: Junaid <[email protected]> Co-authored-by: Alex <[email protected]>
Description
#5427
Type of change
Checklist for 1.x:
npm run dtslintwith success and extended the tests and types if necessary.npm run test:covand my test cases cover all the lines and branches of the added code.npm run buildwith success.dist/web3.min.jsin a browser.CHANGELOG.mdfile in the root folder.Checklist for 4.x:
yarnsuccessfullyyarn lintsuccessfullyyarn build:websuccessfullyyarn test:unitsuccessfullyyarn test:integrationsuccessfullycompile:contractssuccessfullyCHANGELOG.mdfile in the packages I have edited.