Skip to content
This repository was archived by the owner on Mar 5, 2025. It is now read-only.

Conversation

@nazarhussain
Copy link
Contributor

Description

Add web3-eth-personal package with it's implementation.

Fixes #4720

Type of change

  • New feature (non-breaking change which adds functionality)

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 dtslint with success and extended the tests and types if necessary.
  • I ran npm run test:unit with success.
  • I ran npm run test:cov 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.

…/web3.js into wyatt/4.x/4652-eth-tx-refactor
@nazarhussain nazarhussain changed the base branch from 4.x to wyatt/4.x/4789-transaction-rpc-methods February 28, 2022 12:25
@nazarhussain nazarhussain force-pushed the nh/4720-web3-eth-personal branch from 288d883 to 5f3a2b2 Compare February 28, 2022 12:25
@lgtm-com
Copy link

lgtm-com bot commented Feb 28, 2022

This pull request introduces 3 alerts when merging 5f3a2b2 into 96026ec - view on LGTM.com

new alerts:

  • 3 for Unused variable, import, function or class

@nazarhussain nazarhussain changed the title [WIP] Web3 Eth Personal Web3 Eth Personal Feb 28, 2022
@nazarhussain nazarhussain marked this pull request as ready for review February 28, 2022 13:23
jdevcs
jdevcs previously requested changes Feb 28, 2022

export class EthPersonal extends Web3Context<EthPersonalAPI> {
public async getAccounts() {
const result = await this.requestManager.send({
Copy link
Contributor

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.

Copy link
Contributor Author

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>
Copy link
Contributor

@spacesailor24 spacesailor24 left a 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 formatting
  • rpc_method_wrappers.ts: For methods that make use of validation and/or formatting
  • index.ts: imports and minimally wraps methods from above two files

Base automatically changed from wyatt/4.x/4789-transaction-rpc-methods to 4.x March 3, 2022 19:03
@spacesailor24 spacesailor24 dismissed jdevcs’s stale review March 4, 2022 09:28

jdevcs is currently unavailable to dismiss stale review

@spacesailor24 spacesailor24 merged commit 39f8fd5 into 4.x Mar 4, 2022
@spacesailor24 spacesailor24 deleted the nh/4720-web3-eth-personal branch March 4, 2022 09:29
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

4.x 4.0 related

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Web3 Eth Personal

5 participants