Skip to content

Commit d4053f4

Browse files
authored
Merge pull request #16 from Golem-Base/rvdp/dev
chore: remove old ABI events that do not exist anymore
2 parents f371706 + 7764dff commit d4053f4

3 files changed

Lines changed: 2 additions & 74 deletions

File tree

golem_base_sdk/__init__.py

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050
UpdateEntityReturnType,
5151
WatchLogsHandle,
5252
)
53-
from .utils import parse_legacy_btl_extended_log, rlp_encode_transaction
53+
from .utils import rlp_encode_transaction
5454

5555
__all__: Sequence[str] = [
5656
# Exports from .types
@@ -541,15 +541,6 @@ async def _process_golem_base_log_receipt(
541541
),
542542
)
543543
)
544-
# This is only here for backwards compatibility and can be removed
545-
# once we undeploy kaolin.
546-
case (
547-
"GolemBaseStorageEntityBTLExptended"
548-
| "GolemBaseStorageEntityTTLExptended"
549-
):
550-
extensions.append(parse_legacy_btl_extended_log(log_receipt))
551-
case other:
552-
raise ValueError(f"Unknown event type: {other}")
553544

554545
return GolemBaseTransactionReceipt(
555546
creates=creates,
@@ -695,13 +686,7 @@ def create_subscription(topic: HexStr) -> LogsSubscription:
695686
if delete_callback:
696687
event_names.append("GolemBaseStorageEntityDeleted")
697688
if extend_callback:
698-
event_names.extend(
699-
[
700-
"GolemBaseStorageEntityBTLExtended",
701-
"GolemBaseStorageEntityBTLExptended",
702-
"GolemBaseStorageEntityTTLExptended",
703-
]
704-
)
689+
event_names.append("GolemBaseStorageEntityBTLExtended")
705690

706691
events = list(
707692
map(

golem_base_sdk/constants.py

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -47,26 +47,4 @@
4747
"name": "GolemBaseStorageEntityBTLExtended",
4848
"type": "event",
4949
},
50-
# Old ABI event that has a typo in the name and a missing non-indexed argument.
51-
# This can be removed once we retire the kaolin network (the only one using
52-
# this event hash).
53-
{
54-
"anonymous": False,
55-
"inputs": [
56-
{"indexed": True, "name": "entityKey", "type": "uint256"},
57-
{"indexed": False, "name": "expirationBlock", "type": "uint256"},
58-
],
59-
"name": "GolemBaseStorageEntityBTLExptended",
60-
"type": "event",
61-
},
62-
# Old ABI before rename of TTL -> BTL
63-
{
64-
"anonymous": False,
65-
"inputs": [
66-
{"indexed": True, "name": "entityKey", "type": "uint256"},
67-
{"indexed": False, "name": "expirationBlock", "type": "uint256"},
68-
],
69-
"name": "GolemBaseStorageEntityTTLExptended",
70-
"type": "event",
71-
},
7250
]

golem_base_sdk/utils.py

Lines changed: 0 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,9 @@
33
import logging
44

55
import rlp
6-
from web3.types import LogReceipt
76

87
from .types import (
98
Annotation,
10-
EntityKey,
11-
ExtendEntityReturnType,
12-
GenericBytes,
139
GolemBaseTransaction,
1410
)
1511

@@ -73,34 +69,3 @@ def format_annotation[T](annotation: Annotation[T]) -> tuple[str, T]:
7369
encoded: bytes = rlp.encode(payload)
7470
logger.debug("Encoded payload: %s", encoded)
7571
return encoded
76-
77-
78-
def parse_legacy_btl_extended_log(log_receipt: LogReceipt) -> ExtendEntityReturnType:
79-
"""
80-
Parse legacy BTL extended logs.
81-
82-
For legacy extend ABI types, the type signature in the ABI does
83-
not correspond to the actual data returned, so we need
84-
to parse the data ourselves.
85-
"""
86-
# pylint: disable=line-too-long
87-
# Take the first 64 bytes by masking the rest
88-
# (shift 1 to the left 256 positions, then negate the number)
89-
# Example:
90-
# 0x 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 012f
91-
# 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0143
92-
# mask this with:
93-
# 0x 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000
94-
# 1111 1111 1111 1111 1111 1111 1111 1111 1111 1111 1111 1111 1111 1111 1111 1111
95-
# to obtain 0x143
96-
# and then shift the original number to the right
97-
# by 256 to obtain 0x12f
98-
data_parsed = int.from_bytes(log_receipt["data"], byteorder="big", signed=False)
99-
new_expiration_block = data_parsed & ((1 << 256) - 1)
100-
old_expiration_block = data_parsed >> 256
101-
102-
return ExtendEntityReturnType(
103-
old_expiration_block=old_expiration_block,
104-
new_expiration_block=new_expiration_block,
105-
entity_key=EntityKey(GenericBytes(log_receipt["topics"][1])),
106-
)

0 commit comments

Comments
 (0)