Skip to content
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

Hardhat tasks can be refactored more... #8

Open
balajipachai opened this issue Jan 17, 2024 · 2 comments
Open

Hardhat tasks can be refactored more... #8

balajipachai opened this issue Jan 17, 2024 · 2 comments

Comments

@balajipachai
Copy link
Contributor

I have gone through all the hardhat tasks and have observed there are a few lines in each task that can be refactored.
Those few lines are:

const privateKey = getPrivateKey();
const rpcProviderUrl = getProviderRpcUrl(blockchain);
const provider = new providers.JsonRpcProvider(rpcProviderUrl);
const wallet = new Wallet(privateKey);
const signer = wallet.connect(provider);

In some tasks the rpcProviderUrl is named as sourceRpcProviderUrl and provider is named as sourceProvider.

It is a matter of naming convention we can decide upon using only rpcProviderUrl and provider and refactor the above code into a function.

The function can either be called setup or accountAndNetworkSetup in a file namely setup.ts.

This file then can be imported in almost all hardhat tasks and the function will be invoked instead of using the redundant 5 lines.

What this will do?

  • Improve code readability, thus making it easier to understand.
  • Remove redundant lines, thus making the code concise and compact.

Please do let me know what you think about, if this sounds good, I can open a PR for the same.
@andrejrakic @zeuslawyer

@andrejrakic
Copy link
Collaborator

Hey @balajipachai absolutely, go for it! Great suggestion, we'll be happy to assist if needed

@balajipachai
Copy link
Contributor Author

Perfect , will make the changes and submit a PR!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants