Skip to content

Commit

Permalink
Bump safe-eth-py, web3, siwe and python versions (#60)
Browse files Browse the repository at this point in the history
  • Loading branch information
falvaradorodriguez authored Feb 21, 2025
1 parent bb9688c commit 2f4676a
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 19 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.12"]
python-version: ["3.13"]

steps:
- uses: actions/checkout@v4
Expand All @@ -30,7 +30,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.12"]
python-version: ["3.13"]
services:
redis:
image: redis
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[![Python CI](https://github.com/safe-global/safe-auth-service/actions/workflows/ci.yml/badge.svg)](https://github.com/safe-global/safe-auth-service/actions/workflows/ci.yml)
[![Coverage Status](https://coveralls.io/repos/github/safe-global/safe-auth-service/badge.svg?branch=main)](https://coveralls.io/github/safe-global/safe-auth-service?branch=main)
[![pre-commit](https://img.shields.io/badge/pre--commit-enabled-brightgreen?logo=pre-commit&logoColor=white)](https://github.com/pre-commit/pre-commit)
![Python 3.12](https://img.shields.io/badge/Python-3.12-blue.svg)
![Python 3.13](https://img.shields.io/badge/Python-3.13-blue.svg)
[![Docker Image Version (latest semver)](https://img.shields.io/docker/v/safeglobal/safe-auth-service?label=Docker&sort=semver)](https://hub.docker.com/r/safeglobal/safe-auth-service)


Expand Down
5 changes: 3 additions & 2 deletions app/tests/routers/test_auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from cryptography.hazmat.primitives.asymmetric import rsa
from eth_account import Account
from eth_account.messages import encode_defunct
from safe_eth.util.util import to_0x_hex_str

from ...main import app

Expand Down Expand Up @@ -75,10 +76,10 @@ def test_view_request_auth_token(self):
self.assertEqual(response.status_code, 200)
obtained_siwe_message = response.json().get("message")

private_key = account.key.hex()
private_key = to_0x_hex_str(account.key)
eip191_message = encode_defunct(text=obtained_siwe_message)
signed_message = Account.sign_message(eip191_message, private_key=private_key)
signature = signed_message.signature.hex()
signature = to_0x_hex_str(signed_message.signature)

jwt_private_key = rsa.generate_private_key(
public_exponent=65537,
Expand Down
20 changes: 11 additions & 9 deletions app/tests/services/test_message_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@

from eth_account import Account
from eth_account.messages import encode_defunct
from eth_typing import HexStr
from safe_eth.util.util import to_0x_hex_str
from siwe.siwe import ISO8601Datetime, SiweMessage, VersionEnum

from ...cache import get_redis
Expand Down Expand Up @@ -138,10 +140,10 @@ def test_verify_siwe_message(self, mock_redis_from_url: MagicMock):
)
message_str = siwe_message.prepare_message()

private_key = account.key.hex()
private_key = to_0x_hex_str(account.key)
eip191_message = encode_defunct(text=siwe_message.prepare_message())
signed_message = Account.sign_message(eip191_message, private_key=private_key)
signature = signed_message.signature.hex()
signature = to_0x_hex_str(signed_message.signature)

# Valid message
verify_siwe_message(message_str, signature)
Expand All @@ -152,10 +154,10 @@ def test_verify_siwe_message(self, mock_redis_from_url: MagicMock):
# Invalid message format
message_str = "Invalid SIWE message"

private_key = account.key.hex()
private_key = to_0x_hex_str(account.key)
eip191_message = encode_defunct(text=siwe_message.prepare_message())
signed_message = Account.sign_message(eip191_message, private_key=private_key)
signature = signed_message.signature.hex()
signature = to_0x_hex_str(signed_message.signature)

with self.assertRaises(InvalidMessageFormatError):
verify_siwe_message(message_str, signature)
Expand All @@ -175,10 +177,10 @@ def test_verify_siwe_message(self, mock_redis_from_url: MagicMock):
)
message_str = siwe_message.prepare_message()

private_key = account.key.hex()
private_key = to_0x_hex_str(account.key)
eip191_message = encode_defunct(text=siwe_message.prepare_message())
signed_message = Account.sign_message(eip191_message, private_key=private_key)
signature = signed_message.signature.hex()
signature = to_0x_hex_str(signed_message.signature)

with self.assertRaises(InvalidNonceError):
verify_siwe_message(message_str, signature)
Expand All @@ -198,10 +200,10 @@ def test_verify_siwe_message(self, mock_redis_from_url: MagicMock):
)
message_str = siwe_message.prepare_message()

private_key = account.key.hex()
private_key = to_0x_hex_str(account.key)
eip191_message = encode_defunct(text=siwe_message.prepare_message())
signed_message = Account.sign_message(eip191_message, private_key=private_key)
signature = signed_message.signature.hex()
signature = to_0x_hex_str(signed_message.signature)

with self.assertRaises(InvalidSignatureError):
verify_siwe_message(message_str, signature)
Expand All @@ -219,7 +221,7 @@ def test_verify_siwe_message(self, mock_redis_from_url: MagicMock):
expiration_time=expiration_time,
)
message_str = siwe_message.prepare_message()
signature = "0x455aaa"
signature = HexStr("0x455aaa")

with self.assertRaises(InvalidSignatureError):
verify_siwe_message(message_str, signature)
Expand Down
2 changes: 1 addition & 1 deletion docker/web/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM python:3.12-slim
FROM python:3.13-slim

EXPOSE 8888/tcp
ARG APP_HOME=/app
Expand Down
6 changes: 3 additions & 3 deletions requirements/prod.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ fastapi[all]==0.115.7
pydantic-settings==2.6.1
pyjwt[crypto]==2.10.0
redis[hiredis]==5.2.0
safe-eth-py==6.0.0b41
siwe==4.2.0
web3==6.20.2
safe-eth-py==7.1.1
siwe==4.4.0
web3==7.8.0
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ known_fastapi = fastapi,pydantic
sections = FUTURE,STDLIB,FASTAPI,THIRDPARTY,GNOSIS,FIRSTPARTY,LOCALFOLDER

[mypy]
python_version = 3.12
python_version = 3.13
check_untyped_defs = True
ignore_missing_imports = True
warn_unused_ignores = True
Expand Down

0 comments on commit 2f4676a

Please sign in to comment.