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

python: block types and wrapper #1346

Merged
merged 31 commits into from
Oct 4, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
2e3a55e
block types and wrapper
Alex6323 Sep 28, 2023
ac62da5
format
Alex6323 Sep 28, 2023
b1869e7
fix examples
Alex6323 Sep 28, 2023
4d6f7e8
nit
Alex6323 Sep 28, 2023
5b160f8
review 1
Alex6323 Sep 28, 2023
d0cc109
review 2
Alex6323 Sep 29, 2023
c2aeaad
review 3
Alex6323 Sep 29, 2023
ebc15e8
Merge branch '2.0' into python/block-changes
Alex6323 Sep 29, 2023
0d04825
fix wrapper deserialization, temp. disable some tests
Alex6323 Sep 29, 2023
501d60f
Merge branch '2.0' into python/block-changes
Alex6323 Sep 29, 2023
3fc8393
update BlockMetadata type
Alex6323 Sep 29, 2023
8a4fc2d
fix some tests
Alex6323 Sep 29, 2023
0220d4e
test nits
Alex6323 Sep 29, 2023
b0ccc9f
remove union for sig
Alex6323 Sep 29, 2023
20aa2f0
doc fix
Alex6323 Sep 29, 2023
a044634
lint sdk
Alex6323 Sep 29, 2023
29d9f6d
full circle
Alex6323 Sep 29, 2023
0f2b64a
review 4
Alex6323 Sep 29, 2023
15f7168
review 5
Alex6323 Sep 29, 2023
7afa497
review 6
Alex6323 Sep 29, 2023
9c76bb4
Merge branch '2.0' into python/block-changes
Alex6323 Oct 2, 2023
e3c6cf0
review 7
Alex6323 Oct 2, 2023
573eae9
did I mess up?
Alex6323 Oct 2, 2023
0cb5955
not ignore some tests
Alex6323 Oct 3, 2023
3dffaa6
Merge branch '2.0' into python/block-changes
Alex6323 Oct 3, 2023
177f07c
remove import
Alex6323 Oct 3, 2023
fc249b7
fix block tests
Alex6323 Oct 3, 2023
9a9f7fe
refer to issue in ignored tests
Alex6323 Oct 3, 2023
5e543cd
fix ci
Alex6323 Oct 4, 2023
55ce115
re-enable python tests in CI
Alex6323 Oct 4, 2023
09cfa59
long live the union (type alias)
Alex6323 Oct 4, 2023
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
7 changes: 3 additions & 4 deletions bindings/python/iota_sdk/types/block/basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@

from __future__ import annotations
from dataclasses import dataclass, field
from typing import List, Optional, Union
from typing import List, Optional
from iota_sdk.types.block.block import Block, BlockType
from iota_sdk.types.common import HexStr, json
from iota_sdk.types.payload import TaggedDataPayload, TransactionPayload
from iota_sdk.types.payload import PayloadUnion


@json
Expand All @@ -26,8 +26,7 @@ class BasicBlock(Block):
weak_parents: List[HexStr]
shallow_like_parents: List[HexStr]
max_burned_mana: str
payload: Optional[Union[TaggedDataPayload,
TransactionPayload]] = None
payload: Optional[PayloadUnion] = None
type: int = field(
default_factory=lambda: BlockType.Basic,
init=False)
10 changes: 6 additions & 4 deletions bindings/python/iota_sdk/types/block/wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,16 @@

from __future__ import annotations
from dataclasses import dataclass
from typing import Union
from typing import TypeAlias, Union
from iota_sdk.types.block.basic import BasicBlock
from iota_sdk.types.block.validation import ValidationBlock
from iota_sdk.types.common import HexStr, json, SlotIndex
from iota_sdk.types.node_info import ProtocolParameters
from iota_sdk.types.signature import Ed25519Signature
from iota_sdk.types.signature import SignatureUnion
from iota_sdk.utils import Utils

BlockUnion: TypeAlias = Union[BasicBlock, ValidationBlock]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fine for now I guess but this should definitely not be here



@json
@dataclass
Expand All @@ -34,8 +36,8 @@ class BlockWrapper:
slot_commitment_id: HexStr
latest_finalized_slot: SlotIndex
issuer_id: HexStr
block: Union[BasicBlock, ValidationBlock]
signature: Union[Ed25519Signature]
block: BlockUnion
signature: SignatureUnion

def id(self, params: ProtocolParameters) -> HexStr:
"""Returns the block ID as a hexadecimal string.
Expand Down
4 changes: 4 additions & 0 deletions bindings/python/iota_sdk/types/signature.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Copyright 2023 IOTA Stiftung
# SPDX-License-Identifier: Apache-2.0

from typing import TypeAlias, Union
from dataclasses import dataclass, field
from iota_sdk.types.common import HexStr, CoinType, json

Expand Down Expand Up @@ -28,6 +29,9 @@ class Ed25519Signature(Signature):
type: int = field(default_factory=lambda: 0, init=False)


SignatureUnion: TypeAlias = Union[Ed25519Signature]


@json
@dataclass
class Bip44():
Expand Down
Loading