Skip to content

Bump web3py to 7.x #540

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

Merged
merged 1 commit into from
Apr 7, 2025
Merged

Bump web3py to 7.x #540

merged 1 commit into from
Apr 7, 2025

Conversation

ZigaMr
Copy link
Contributor

@ZigaMr ZigaMr commented Mar 13, 2025

This PR updates web3.py version in sapphirepy from 6.x to 7.x.
Changes:

  • sapphire.py Now uses 7.x class based middleware with changes to block_hash parsing (new hexbytes version).
  • test_e2e.py updated

TODO:

  • Add AsyncWeb3 middleware

In addition, this PR also updates the publish.yaml workflow with PyPI tag release.

Copy link

netlify bot commented Mar 13, 2025

Deploy Preview for oasisprotocol-sapphire-paratime ready!

Name Link
🔨 Latest commit 1ad5255
🔍 Latest deploy log https://app.netlify.com/sites/oasisprotocol-sapphire-paratime/deploys/67f3d76b8e8f7f0008689408
😎 Deploy Preview https://deploy-preview-540--oasisprotocol-sapphire-paratime.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@ZigaMr ZigaMr requested a review from matevz March 13, 2025 11:33
@ZigaMr ZigaMr force-pushed the ZigaMr/feat/bump-web3py-client branch 2 times, most recently from d7b10db to 0c7996f Compare March 17, 2025 14:15
Copy link
Member

@matevz matevz left a comment

Choose a reason for hiding this comment

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

Do we break compatibility with existing python apps when bumping the wrapper to web3 7.x? (e.g. could demo-starter-py remain exactly the same and just importing the new version of sapphirepy)

@ZigaMr
Copy link
Contributor Author

ZigaMr commented Mar 21, 2025

Do we break compatibility with existing python apps when bumping the wrapper to web3 7.x? (e.g. could demo-starter-py remain exactly the same and just importing the new version of sapphirepy)

From docs:

web3.py follows Semantic Versioning, which means that version 7 introduced backwards-incompatible changes.

However, we can add a couple of ```if```` conditions to check which web3 version is installed and align the client accordingly.

In case of demo-starter-py or any app that uses web3.py the change is also in migration to class-based middleware:
https://github.com/oasisprotocol/demo-starter-py/pull/6/files#diff-51246e53255db77c9edad496f074aa1bdbf8dbdc11f89a02040115c9ab4fa7f0R2
So some changes are necessary.

We could either add this as a sapphirepy PyPI pre-release version and wait for all apps to migrate or make it backwards compatible (6.x and 7.x) with a couple of version checks.

Copy link
Member

@matevz matevz left a comment

Choose a reason for hiding this comment

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

@ZigaMr ZigaMr force-pushed the ZigaMr/feat/bump-web3py-client branch from 10be7d4 to 148f6ef Compare April 2, 2025 16:17
@ZigaMr
Copy link
Contributor Author

ZigaMr commented Apr 2, 2025

Does the Usage section change in any way here https://github.com/oasisprotocol/sapphire-paratime/tree/ZigaMr/feat/bump-web3py-client/clients/py ?

Updated README with async/sync instructions.

@ZigaMr ZigaMr force-pushed the ZigaMr/feat/bump-web3py-client branch from 9a9aa96 to 5275e97 Compare April 4, 2025 16:56
fix: resolve mypy type checking and contract error assert

feat: Add async middleware and fix type errors

Fix RPC url to localhost and DEFAULT_GAS_LIMIT
@ZigaMr ZigaMr force-pushed the ZigaMr/feat/bump-web3py-client branch from 5275e97 to 1ad5255 Compare April 7, 2025 13:47
@ZigaMr ZigaMr merged commit c27a317 into main Apr 7, 2025
14 of 15 checks passed
@ZigaMr ZigaMr deleted the ZigaMr/feat/bump-web3py-client branch April 7, 2025 14:50
github-actions bot added a commit that referenced this pull request Apr 7, 2025
…l/ZigaMr/feat/bump-web3py-client

Bump web3py to 7.x c27a317
github-actions bot added a commit that referenced this pull request Apr 7, 2025
…gaMr/feat/bump-web3py-client

Bump web3py to 7.x c27a317
@matevz matevz linked an issue Apr 23, 2025 that may be closed by this pull request
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.

sapphire-py: Bump web3 to 7.x
2 participants