-
Notifications
You must be signed in to change notification settings - Fork 5.1k
Web3 Eth Personal #4781
Web3 Eth Personal #4781
Conversation
… detectTransactionType
…/web3.js into wyatt/4.x/4652-eth-tx-refactor
288d883 to
5f3a2b2
Compare
|
This pull request introduces 3 alerts when merging 5f3a2b2 into 96026ec - view on LGTM.com new alerts:
|
|
|
||
| export class EthPersonal extends Web3Context<EthPersonalAPI> { | ||
| public async getAccounts() { | ||
| const result = await this.requestManager.send({ |
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 think web3.js shouldn't block these functions using await and it should return promise , and let user wait for promise resolution . so user code is able to leverage async based on his requirements. Same suggestion for all following functions.
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.
User of the library will be interacting with getAccounts function that will be returning the promise in any case. So either we return Promise chain with then block to process result or use await both have exactly same user experience.
Use will be able to leverage async behavior, no matter we use await in the function or not, because the function user is interacting with is returning the Promise. That's the fundamental of adoption of async/await pattern.
Co-authored-by: Junaid <86780488+jdevcs@users.noreply.github.com>
spacesailor24
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.
Regarding packages/web3-eth-personal/src/index.ts, while I understand the efficiencies of a single file that includes the validation and formatting of parameters and the sending of the JSON RPC payload, this goes against the pattern that was established for the eth_ RPC methods
I still think a more versatile approach would be splitting the methods into the separate files:
rpc_methods.ts: Bare minimum RPC methods that don't include any validation or formattingrpc_method_wrappers.ts: For methods that make use of validation and/or formattingindex.ts: imports and minimally wraps methods from above two files
….js into nh/4720-web3-eth-personal
jdevcs is currently unavailable to dismiss stale review
Description
Add
web3-eth-personalpackage with it's implementation.Fixes #4720
Type of change
Checklist:
npm run dtslintwith success and extended the tests and types if necessary.npm run test:unitwith success.npm run test:covand my test cases cover all the lines and branches of the added code.npm run buildand testeddist/web3.min.jsin a browser.CHANGELOG.mdfile in the root folder.