Skip to content

Commit ecf177f

Browse files
authored
Merge pull request #23 from Golem-Base/rvdp/update
Relax python version bound
2 parents ecb8fba + 86d6bd3 commit ecf177f

11 files changed

Lines changed: 1994 additions & 666 deletions

File tree

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ The `main` function demonstrates how to create, extend, and query entities:
7979

8080
- Subscribes to log events from the network (create, update, delete, extend).
8181

82-
- Creates an entity with data `"hello"`, TTL of `60`, and an annotation of `("foo", "bar")`.
82+
- Creates an entity with data `"hello"`, BTL of `60`, and an annotation of `("foo", "bar")`.
8383

8484
- Prints various metadata and state:
8585

example/nix/packages/golem-base-sdk-example.nix

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ let
2020

2121
pythonSet =
2222
(pkgs.callPackage inputs.pyproject-nix.build.packages {
23-
python = pkgs.python312;
23+
python = pkgs.python310;
2424
}).overrideScope
2525
(
2626
lib.composeManyExtensions [

example/pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ authors = [
99
]
1010
version = "0.0.1"
1111
license = "GPL-3.0-only"
12-
requires-python = ">=3.12"
12+
requires-python = ">=3.10"
1313
dynamic = ["description"]
1414
classifiers = ["Private :: Do Not Upload"]
1515

example/uv.lock

Lines changed: 915 additions & 274 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

flake.lock

Lines changed: 16 additions & 16 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

golem_base_sdk/__init__.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -740,10 +740,9 @@ async def _send_gb_transaction(
740740
await self.http_client().eth.call(txData)
741741
except Web3RPCError as e:
742742
if e.rpc_response:
743+
error = e.rpc_response["error"]["message"]
743744
raise Exception(
744-
f"Error while processing transaction: {
745-
e.rpc_response['error']['message']
746-
}"
745+
f"Error while processing transaction: {error}"
747746
) from e
748747
else:
749748
raise e

golem_base_sdk/types.py

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,9 @@
44
from dataclasses import dataclass
55
from typing import (
66
Any,
7+
Generic,
78
NewType,
8-
override,
9+
TypeVar,
910
)
1011

1112
from eth_typing import ChecksumAddress, HexStr
@@ -27,8 +28,9 @@ def as_address(self) -> ChecksumAddress:
2728
"""Convert this instance to a `eth_typing.ChecksumAddress`."""
2829
return AsyncWeb3.to_checksum_address(self.as_hex_string())
2930

30-
@override
31+
# @override
3132
def __repr__(self) -> str:
33+
"""Encode bytes as a string."""
3234
return f"{type(self).__name__}({self.as_hex_string()})"
3335

3436
@staticmethod
@@ -44,15 +46,20 @@ def from_hex_string(hexstr: str) -> "GenericBytes":
4446
Address = NewType("Address", GenericBytes)
4547

4648

49+
# TODO: use new generic syntax once we can bump to python 3.12 or higher
50+
V = TypeVar("V")
51+
52+
4753
@dataclass(frozen=True)
48-
class Annotation[V]:
54+
class Annotation(Generic[V]):
4955
"""Class to represent generic annotations."""
5056

5157
key: str
5258
value: V
5359

54-
@override
60+
# @override
5561
def __repr__(self) -> str:
62+
"""Encode annotation as a string."""
5663
return f"{type(self).__name__}({self.key} -> {self.value})"
5764

5865

@@ -61,7 +68,7 @@ class GolemBaseCreate:
6168
"""Class to represent a create operation in Golem Base."""
6269

6370
data: bytes
64-
ttl: int
71+
btl: int
6572
string_annotations: Sequence[Annotation[str]]
6673
numeric_annotations: Sequence[Annotation[int]]
6774

@@ -72,7 +79,7 @@ class GolemBaseUpdate:
7279

7380
entity_key: EntityKey
7481
data: bytes
75-
ttl: int
82+
btl: int
7683
string_annotations: Sequence[Annotation[str]]
7784
numeric_annotations: Sequence[Annotation[int]]
7885

golem_base_sdk/utils.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
"""Utility methods."""
22

33
import logging
4+
from typing import TypeVar
45

56
import rlp
67

@@ -15,8 +16,10 @@
1516

1617
def rlp_encode_transaction(tx: GolemBaseTransaction) -> bytes:
1718
"""Encode a Golem Base transaction in RLP."""
19+
# TODO: use new generic syntax once we can bump to python 3.12 or higher
20+
T = TypeVar("T")
1821

19-
def format_annotation[T](annotation: Annotation[T]) -> tuple[str, T]:
22+
def format_annotation(annotation: Annotation[T]) -> tuple[str, T]:
2023
return (annotation.key, annotation.value)
2124

2225
# Turn the transaction into a simple list of basic types that can be
@@ -26,7 +29,7 @@ def format_annotation[T](annotation: Annotation[T]) -> tuple[str, T]:
2629
list(
2730
map(
2831
lambda el: [
29-
el.ttl,
32+
el.btl,
3033
el.data,
3134
list(map(format_annotation, el.string_annotations)),
3235
list(map(format_annotation, el.numeric_annotations)),
@@ -39,7 +42,7 @@ def format_annotation[T](annotation: Annotation[T]) -> tuple[str, T]:
3942
map(
4043
lambda el: [
4144
el.entity_key.generic_bytes,
42-
el.ttl,
45+
el.btl,
4346
el.data,
4447
list(map(format_annotation, el.string_annotations)),
4548
list(map(format_annotation, el.numeric_annotations)),

0 commit comments

Comments
 (0)