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

7203 - Alchemy rpc provider #7296

Open
wants to merge 12 commits into
base: 4.x
Choose a base branch
from
Open

Conversation

MRLab12
Copy link

@MRLab12 MRLab12 commented Oct 2, 2024

Description

I have opened this Draft PR to make sure I did the correct changes and get some feedback since this is my first contribution here.

This PR adds an Alchemy provider in web3-rpc-providers. I matched the design of the Quicknode provider.

For testing, I wasn't sure if a test for this provider should actually try to make a request. Should we consider mocking? I want to learn more about how testing is done in web3.js.

Fixes #7203

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.

let host = '';
let token = '';

switch (network) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@MRLab12 MRLab12 marked this pull request as ready for review October 16, 2024 12:59
[Network.POLYGON_AMOY]: 'polygon-amoy.g.alchemy.com',
[Network.OPTIMISM_MAINNET]: 'opt-mainnet.g.alchemy.com',
[Network.OPTIMISM_SEPOLIA]: 'opt-sepolia.g.alchemy.com',
};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be great to add all Alchemy platforms if they are compatible with web3js.

image

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this screenshot from web.js? Wondering if this is an accurate list of the chains to support with Alchemy.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@avkos Made some changes, not sure if all the chains I added are to be supported but lmk.

web3.provider?.disconnect();
}
});
it(`AlchemyProvider should work with ${transport} transport and ${network} network`, async () => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After adding all platforms it will be a different array of networks. so it will be better to have separate const networksAlchemy and separate test networksAlchemy.forEach

@MRLab12 MRLab12 force-pushed the alchemy-rpc-provider branch 2 times, most recently from 5103d29 to b17f49d Compare October 22, 2024 00:04
MRLab12 and others added 3 commits October 29, 2024 21:35
# Conflicts:
#	packages/web3-rpc-providers/src/types.ts
#	packages/web3/test/integration/web3RPCProviders.test.ts
Copy link
Contributor

@Muhammad-Altabba Muhammad-Altabba left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Many thanks @MRLab12 for your contribution,
It seems great now. I think, once other team members approve, we can merge this MR.

@MRLab12
Copy link
Author

MRLab12 commented Nov 12, 2024

I'm trying to run integration tests locally but having issues. Looking at the test errors here, most likely a missing Alchemy key is the issue. Can someone point me to how this should be set up?

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

Successfully merging this pull request may close these issues.

Add RPC provider: alchemy
4 participants