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

feat: Add Arbitrum, Optimism and Polygon support #46

Merged
merged 10 commits into from
Sep 9, 2022

Conversation

eliseygusev
Copy link
Contributor

@eliseygusev eliseygusev commented Sep 3, 2022

What I did

Added support for Arbitrum and Optimism to Infura Provider so that it doesn't say NetworkError: 'infura' is not a valid provider for network 'mainnet' anymore

fixes: #44 and #45 and #24

How I did it

Similar to how it is done in ape-alchemy ApeWorX/ape-alchemy#17

How to verify it

I wrote test for it

Checklist

  • Passes all linting checks (pre-commit and CI jobs)
  • New test cases have been added and are passing
  • Documentation has been updated
  • PR title follows Conventional Commit standard (will be automatically included in the changelog)

@eliseygusev eliseygusev changed the title feat: Add Arbitrum and Optimism support feat: Add Arbitrum, Optimism and Polygon support Sep 3, 2022
Comment on lines 15 to 16
"rinkeby",
"goerli"
Copy link
Member

Choose a reason for hiding this comment

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

This is a bug with ape-arbitrum, but we only have support for rinkeby right now (but it's just called testnet which is the bug)

Suggested change
"rinkeby",
"goerli"
"testnet",

Copy link
Contributor Author

Choose a reason for hiding this comment

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

is it defined here? https://github.com/ApeWorX/ape-arbitrum/blob/main/ape_arbitrum/ecosystem.py#L9
may be I can just fix it there? or are there other dependencies using testnet instead of rinkeby and goerli?

Copy link
Member

Choose a reason for hiding this comment

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

ultimately, it would be best to update it there, however that is a larger breaking change because we will have to make people aware of the update in case they were using it, and also update other plugins too

Copy link
Contributor Author

@eliseygusev eliseygusev Sep 6, 2022

Choose a reason for hiding this comment

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

oh, I see
I think the best is to make it with "testnet" here at first.

And I guess, I would make separate requests to ape-arbitrum and ape-infura fixing the names (we can also add backward-compatilibity, should be easy to do). and leave those requests ready for announcements. does it sound good?

Copy link
Member

@fubuloubu fubuloubu Sep 6, 2022

Choose a reason for hiding this comment

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

exactly, make it work with arbitrum:testnet here for now, and we'll make the update when fixing ApeWorX/ape-arbitrum#3 at a later point in this plugin (and the others)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ok, got you. I've got one more question: as of now tests for all networks are failing because ape-arbitrum, ape-optimism and ape-polygon are not installed. how do you usually proceed with this? I guess, I shouldnt add arbitrum and optimism packages to requirements, but what can be done? Or the tests for those should just be ommited

Copy link
Member

Choose a reason for hiding this comment

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

I think it's good to add the tests, you can add installing those plugins under this extra and it will get installed during testing:
https://github.com/ApeWorX/ape-infura/blob/main/setup.py#L6

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ok, would follow
just wasnt sure whether you ok with tests being dependent on the other libraries
thanks for the help!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

should be good now. thanks a lot for reviewing!

ape_infura/providers.py Outdated Show resolved Hide resolved
ape_infura/providers.py Outdated Show resolved Hide resolved
tests/test_provider.py Outdated Show resolved Hide resolved
@fubuloubu fubuloubu enabled auto-merge (squash) September 6, 2022 21:24
auto-merge was automatically disabled September 6, 2022 21:28

Head branch was pushed to by a user without write access

@eliseygusev
Copy link
Contributor Author

flake failed because the comment was too long 😅 pushed a fix, sorry

@fubuloubu fubuloubu enabled auto-merge (squash) September 6, 2022 21:30
@eliseygusev
Copy link
Contributor Author

@fubuloubu do you know how to fix CI in that PR? would love it to get merged, but seems like I didnt touch anythin CI related, and the tests are failing.
Tests are requiring WEB3_INFURA_PROJECT_ID set. What is your usual approach to this? Seems like it always was the case for the CI in thar repo. I can add mocks, I guess, but it seems that you had a workaround before

@fubuloubu
Copy link
Member

Tests are requiring WEB3_INFURA_PROJECT_ID set. What is your usual approach to this?

No, basically because this is your first time contributing, you don't have access to the secret necessary to run the CI

Comment on lines 11 to 28
_ENVIRONMENT_VARIABLE_NAMES = ("WEB3_INFURA_PROJECT_ID", "WEB3_INFURA_API_KEY")
_ENVIRONMENT_VARIABLE_OPTIONS = {
"ethereum": (
"WEB3_INFURA_PROJECT_ID",
"WEB3_INFURA_API_KEY",
),
"arbitrum": (
"WEB3_ARBITRUM_INFURA_PROJECT_ID",
"WEB3_ARBITRUM_INFURA_API_KEY",
),
"optimism": (
"WEB3_OPTIMISM_INFURA_PROJECT_ID",
"WEB3_OPTIMISM_INFURA_API_KEY",
),
"polygon": (
"WEB3_POLYGON_INFURA_PROJECT_ID",
"WEB3_POLYGON_INFURA_API_KEY",
),
}
Copy link
Member

Choose a reason for hiding this comment

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

Just noticed this. You actually don't need this change because Infura uses just one project ID for all of it's RPC endpoints, unlike Alchemy which uses one per network

Copy link
Contributor Author

Choose a reason for hiding this comment

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

thanks for clarifying.
fixed the issue. tests work locally for me, so shall be good in CI as well

@fubuloubu
Copy link
Member

@eliseygusev fix that one issue, and I'll run the CI locally and merge this (since the CI isn't going to pass right now for you)

auto-merge was automatically disabled September 8, 2022 15:45

Head branch was pushed to by a user without write access

@fubuloubu fubuloubu merged commit 94843ba into ApeWorX:main Sep 9, 2022
@fubuloubu
Copy link
Member

Tested locally with my api key

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.

Support Arbitrum
2 participants