From d233e5ea66746f0e204bc119349f1ba5e72d0047 Mon Sep 17 00:00:00 2001 From: Alexandru Popenta Date: Mon, 25 Nov 2024 14:49:10 +0200 Subject: [PATCH 1/2] change data field to bytes --- multiversx_sdk/converters/transactions_converter.py | 2 +- multiversx_sdk/network_providers/transaction_events.py | 8 ++++---- pyproject.toml | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/multiversx_sdk/converters/transactions_converter.py b/multiversx_sdk/converters/transactions_converter.py index 4a60ce84..554851bb 100644 --- a/multiversx_sdk/converters/transactions_converter.py +++ b/multiversx_sdk/converters/transactions_converter.py @@ -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: diff --git a/multiversx_sdk/network_providers/transaction_events.py b/multiversx_sdk/network_providers/transaction_events.py index cd3d833d..08dd9d08 100644 --- a/multiversx_sdk/network_providers/transaction_events.py +++ b/multiversx_sdk/network_providers/transaction_events.py @@ -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 @@ -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: @@ -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] } diff --git a/pyproject.toml b/pyproject.toml index 2eae3b17..ed92d33a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -7,7 +7,7 @@ allow-direct-references = true [project] name = "multiversx-sdk" -version = "0.17.0" +version = "0.18.0" authors = [ { name="MultiversX" }, ] From 7971254300165475be51d4650774a86ece6a5bbf Mon Sep 17 00:00:00 2001 From: Alexandru Popenta Date: Mon, 25 Nov 2024 14:53:17 +0200 Subject: [PATCH 2/2] linter fix --- .../smart_contract_transactions_outcome_parser_test.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/multiversx_sdk/core/transactions_outcome_parsers/smart_contract_transactions_outcome_parser_test.py b/multiversx_sdk/core/transactions_outcome_parsers/smart_contract_transactions_outcome_parser_test.py index 5e35ce8b..567a39ae 100644 --- a/multiversx_sdk/core/transactions_outcome_parsers/smart_contract_transactions_outcome_parser_test.py +++ b/multiversx_sdk/core/transactions_outcome_parsers/smart_contract_transactions_outcome_parser_test.py @@ -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]