Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: make TaggedData data field optional #1983

Merged
merged 9 commits into from
May 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions bindings/python/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Security -->

## 1.1.4 - 2024-05-03

### Fixed

- Made `TaggedDataPayload::{tag, data}` optional;

## 1.1.3 - 2024-02-14

### Added
Expand Down
2 changes: 1 addition & 1 deletion bindings/python/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "iota-sdk-python"
version = "1.1.3"
version = "1.1.4"
authors = ["IOTA Stiftung"]
edition = "2021"
description = "Python bindings for the IOTA SDK library"
Expand Down
4 changes: 2 additions & 2 deletions bindings/python/iota_sdk/types/block.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ class Block:
protocolVersion: int
parents: List[HexStr]
nonce: str
payload: Optional[Union[TaggedDataPayload,
TransactionPayload, MilestonePayload]] = None
payload: Optional[Union[TransactionPayload,
MilestonePayload, TaggedDataPayload]] = None

@classmethod
def from_dict(cls, block_dict: Dict) -> Block:
Expand Down
4 changes: 2 additions & 2 deletions bindings/python/iota_sdk/types/payload.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,8 +143,8 @@ class TaggedDataPayload(Payload):
tag: The tag part of the tagged data payload.
data: The data part of the tagged data payload.
"""
tag: HexStr
data: HexStr
tag: Optional[HexStr] = None
data: Optional[HexStr] = None
type: int = field(
default_factory=lambda: int(
PayloadType.TaggedData),
Expand Down
2 changes: 1 addition & 1 deletion bindings/python/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def get_py_version_cfgs():

setup(
name="iota_sdk",
version="1.1.3",
version="1.1.4",
classifiers=[
"License :: SPDX-License-Identifier :: Apache-2.0",
"Intended Audience :: Developers",
Expand Down
8 changes: 8 additions & 0 deletions bindings/python/tests/test_block.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,11 @@ def test_block():
assert block.as_dict() == block_dict
assert isinstance(block.payload, Payload)
assert block.payload.type == PayloadType.Milestone

# with tx payload and tagged data payload where the data is optional
block_dict = {"protocolVersion": 2, "parents": ["0x0882f56f6aa18a473c1104aaa6df5260ccf0b4b7a013763c44f231ebdd23a3c7", "0x1b26789153a9f1d5e139498f18e4cb2b7e31b67f6ddbec1053f49ce5034cdac4", "0x25ac8b75c5b14f13875dafb4de92b5256dd9c7fd73576eacc99740bd90413f62", "0xd36066423f2b225c9b9566794ea2ed25331afee340ea045271a1dd1d28f87b92"], "payload": {"type": 6, "essence": {"type": 1, "networkId": "7784367046153662236", "inputs": [{"type": 0, "transactionId": "0x9649d1ce9177435ee8fd3234267d7f1c82a858d3d36994379c495be864fdb223", "transactionOutputIndex": 0}], "inputsCommitment": "0xbeb2d535e60610e4284dd8de2046b695ed820519b8d7bea1b4e87859e01a4613", "outputs": [{"type": 3, "amount": "1000000000", "unlockConditions": [
{"type": 0, "address": {"type": 0, "pubKeyHash": "0x7258772f96283ebcc91997805a0b4acc98c83d3d0bb1bc919e31974bb6cea9a2"}}]}, {"type": 3, "amount": "288098760415811743", "unlockConditions": [{"type": 0, "address": {"type": 0, "pubKeyHash": "0x77c2f4cdd686cc9e7667ff66977fc9e7687866a3a97745917cf786ba13a4124c"}}]}], "payload": {"type": 5}}, "unlocks": [{"type": 0, "signature": {"type": 0, "publicKey": "0xbae586465c574fcc9339ee0baae32bbabede7fab87b94f150c6bd38afd76abbe", "signature": "0x1c208a3afe0a5cb1045c0a4d2a5ae003ea56c9bed06128c60bde7e07266314ecd8bbfba22ecbba04e4f2e436d50d699b402537aef65a586149e6ae4d8be1fe0a"}}]}, "nonce": "1673315"}
block = Block.from_dict(block_dict)
assert block.as_dict() == block_dict
assert isinstance(block.payload, Payload)
assert block.payload.type == PayloadType.Transaction
Loading