Skip to content

Commit

Permalink
Merge pull request #159 from multiversx/fix-tx-event-data
Browse files Browse the repository at this point in the history
Changed data field to bytes
  • Loading branch information
popenta authored Nov 25, 2024
2 parents 17e9ddf + 7971254 commit 1755514
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion multiversx_sdk/converters/transactions_converter.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ def _event_on_network_to_event(self, event: TransactionEventOnNetwork) -> Transa
identifier = event.identifier
topics = [topic.raw for topic in event.topics]

legacy_data = event.data_payload.raw if event.data_payload else b'' or event.data.encode()
legacy_data = event.data_payload.raw if event.data_payload else b'' or event.data
data_items = [data.raw for data in event.additional_data] if event.additional_data else []

if len(data_items) == 0:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ def test_parse_deploy_outcome_with_error(self):
TxEventTopicOnNetwork(base64.b64encode(deployer.get_public_key()).decode()),
TxEventTopicOnNetwork(base64.b64encode(b"wrong number of arguments").decode()),
]
event.data = "@75736572206572726f72"
event.data = "@75736572206572726f72".encode()

logs = TxLogsOnNetwork()
logs.events = [event]
Expand Down
8 changes: 4 additions & 4 deletions multiversx_sdk/network_providers/transaction_events.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def __init__(self) -> None:
self.identifier: str = ''
self.topics: List[TransactionEventTopic] = []
self.data_payload: Optional[TransactionEventData] = None
self.data: str = ''
self.data: bytes = b''
self.additional_data: List[TransactionEventData] = []

@staticmethod
Expand All @@ -26,9 +26,9 @@ def from_http_response(response: Dict[str, Any]) -> 'TransactionEvent':
topics = response.get('topics') or []
result.topics = [TransactionEventTopic(item) for item in topics]

raw_data = base64.b64decode(response.get('responseData', b''))
raw_data = base64.b64decode(response.get('data', b'') or b'')
result.data_payload = TransactionEventData(raw_data)
result.data = raw_data.decode()
result.data = raw_data

additional_data: Any = response.get("additionalData") or []
if additional_data is None:
Expand All @@ -43,7 +43,7 @@ def to_dictionary(self) -> Dict[str, Any]:
"identifier": self.identifier,
"topics": [item.hex() for item in self.topics],
"data_payload": self.data_payload.hex() if self.data_payload else "",
"data": self.data,
"data": self.data.hex(),
"additional_data": [data.hex() for data in self.additional_data]
}

Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ allow-direct-references = true

[project]
name = "multiversx-sdk"
version = "0.17.0"
version = "0.18.0"
authors = [
{ name="MultiversX" },
]
Expand Down

0 comments on commit 1755514

Please sign in to comment.