Skip to content

Commit

Permalink
re-org files
Browse files Browse the repository at this point in the history
  • Loading branch information
Alex6323 committed Dec 11, 2023
1 parent 42a378a commit 5745b8c
Show file tree
Hide file tree
Showing 15 changed files with 102 additions and 102 deletions.
4 changes: 2 additions & 2 deletions bindings/python/examples/client/06_simple_block.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
TaggedDataPayload(
utf8_to_hex("tag"),
utf8_to_hex("data")))[0]
signed_block = secret_manager.sign_block(unsigned_block, chain)
block_id = client.post_block(signed_block)
block = secret_manager.sign_block(unsigned_block, chain)
block_id = client.post_block(block)

print(f'Empty block sent: {os.environ["EXPLORER_URL"]}/block/{block_id}')
6 changes: 3 additions & 3 deletions bindings/python/iota_sdk/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@
from .prefix_hex import *
from .types.address import *
from .types.balance import *
from .types.block.basic import *
from .types.block.block import *
from .types.block.body.basic import *
from .types.block.body.kind import *
from .types.block.body.validation import *
from .types.block.metadata import *
from .types.block.signed_block import *
from .types.block.validation import *
from .types.block_builder_options import *
from .types.block_issuer_key import *
from .types.burn import *
Expand Down
2 changes: 1 addition & 1 deletion bindings/python/iota_sdk/client/_high_level_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from typing import List, Optional
from dataclasses import dataclass
from abc import ABCMeta, abstractmethod
from iota_sdk.types.block.signed_block import Block
from iota_sdk.types.block.block import Block
from iota_sdk.types.common import CoinType, HexStr, json
from iota_sdk.types.output_metadata import OutputWithMetadata
from iota_sdk.types.output_id import OutputId
Expand Down
2 changes: 1 addition & 1 deletion bindings/python/iota_sdk/client/_node_core_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from abc import ABCMeta, abstractmethod
from dacite import from_dict

from iota_sdk.types.block.signed_block import Block
from iota_sdk.types.block.block import Block
from iota_sdk.types.block.metadata import BlockMetadata, BlockWithMetadata
from iota_sdk.types.common import HexStr
from iota_sdk.types.node_info import NodeInfo, NodeInfoWrapper
Expand Down
2 changes: 1 addition & 1 deletion bindings/python/iota_sdk/client/_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def _call_method(self, name, data=None):
"""

# pylint: disable=redefined-builtin
def hex_to_bech32(self, hex: HexStr, bech32_hrp: str) -> str:
def hex_to_bech32(self, hex_str: HexStr, bech32_hrp: str) -> str:
"""Transforms a hex encoded address to a bech32 encoded address.
"""
return self._call_method('hexToBech32', {
Expand Down
2 changes: 1 addition & 1 deletion bindings/python/iota_sdk/client/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from iota_sdk.client._node_indexer_api import NodeIndexerAPI
from iota_sdk.client._high_level_api import HighLevelAPI
from iota_sdk.client._utils import ClientUtils
from iota_sdk.types.block.signed_block import UnsignedBlock
from iota_sdk.types.block.block import UnsignedBlock
from iota_sdk.types.common import HexStr, Node
from iota_sdk.types.feature import Feature
from iota_sdk.types.network_info import NetworkInfo
Expand Down
2 changes: 1 addition & 1 deletion bindings/python/iota_sdk/secret_manager/secret_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import humps

from iota_sdk.external import create_secret_manager, call_secret_manager_method
from iota_sdk.types.block.signed_block import Block, UnsignedBlock
from iota_sdk.types.block.block import Block, UnsignedBlock
from iota_sdk.types.common import HexStr
from iota_sdk.types.signature import Ed25519Signature, Bip44
from iota_sdk.types.transaction_data import PreparedTransactionData
Expand Down
77 changes: 70 additions & 7 deletions bindings/python/iota_sdk/types/block/block.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,78 @@
# SPDX-License-Identifier: Apache-2.0

from __future__ import annotations
from enum import IntEnum
from dataclasses import dataclass, field
from typing import TypeAlias, Union
from dataclasses_json import config
from iota_sdk.utils import Utils
from iota_sdk.types.common import HexStr, json, SlotIndex
from iota_sdk.types.node_info import ProtocolParameters
from iota_sdk.types.signature import Signature
from iota_sdk.types.block.body.basic import BasicBlockBody
from iota_sdk.types.block.body.validation import ValidationBlockBody


class BlockBodyType(IntEnum):
"""Block types.
@json
@dataclass
class Block:
"""A signed block that can hold either a `BasicBlockBody` or a `ValidationBlockBody`.
Shared data is stored alongside such a block in the header fields.
Attributes:
Basic (0): A Basic Block Body.
Validation (1): A Validation Block Body.
protocol_version: Protocol version of the network to which this block belongs.
network_id: The identifier of the network to which this block belongs.
issuing_time: The time at which the block was issued. It is a Unix timestamp in nanoseconds.
slot_commitment_id: The identifier of the slot to which this block commits.
latest_finalized_slot: The slot index of the latest finalized slot.
issuer_id: The identifier of the account that issued this block.
body: Holds either a `BasicBlockBody` or a `ValidationBlockBody`.
signature: The Block signature.
"""
Basic = 0
Validation = 1
protocol_version: int
network_id: int = field(metadata=config(
encoder=str
))
issuing_time: int = field(metadata=config(
encoder=str
))
slot_commitment_id: HexStr
latest_finalized_slot: SlotIndex
issuer_id: HexStr
body: BlockBody
signature: Signature

def id(self, params: ProtocolParameters) -> HexStr:
"""Returns the block ID as a hexadecimal string.
"""
return Utils.block_id(self, params)


@json
@dataclass
class UnsignedBlock:
"""An unsigned block type that can hold either a `BasicBlock` or a `ValidationBlock`.
Shared data is stored alongside such a block in the header fields.
Attributes:
protocol_version: Protocol version of the network to which this block belongs.
network_id: The identifier of the network to which this block belongs.
issuing_time: The time at which the block was issued. It is a Unix timestamp in nanoseconds.
slot_commitment_id: The identifier of the slot to which this block commits.
latest_finalized_slot: The slot index of the latest finalized slot.
issuer_id: The identifier of the account that issued this block.
block: Holds either a `BasicBlock` or a `ValidationBlock`.
"""
protocol_version: int
network_id: int = field(metadata=config(
encoder=str
))
issuing_time: int = field(metadata=config(
encoder=str
))
slot_commitment_id: HexStr
latest_finalized_slot: SlotIndex
issuer_id: HexStr
body: BlockBody


BlockBody: TypeAlias = Union[BasicBlockBody, ValidationBlockBody]
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@
from dataclasses import dataclass, field
from typing import List, Optional
from dataclasses_json import config
from iota_sdk.types.block.block import BlockBodyType
from iota_sdk.types.block.body.kind import BlockBodyType
from iota_sdk.types.common import HexStr, json
from iota_sdk.types.payload import Payload


@json
@dataclass
class BasicBlockBody:
"""A `BasicBlockBody` is the most common type of block body used to issue various kinds of payloads such as transactions
"""A Basic Block Body is the most common type of block body used to issue various kinds of payloads such as transactions
at the cost of burning Mana.
Attributes:
Expand Down
16 changes: 16 additions & 0 deletions bindings/python/iota_sdk/types/block/body/kind.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Copyright 2023 IOTA Stiftung
# SPDX-License-Identifier: Apache-2.0

from __future__ import annotations
from enum import IntEnum


class BlockBodyType(IntEnum):
"""Block Body types.
Attributes:
Basic (0): A Basic Block Body.
Validation (1): A Validation Block Body.
"""
Basic = 0
Validation = 1
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from __future__ import annotations
from dataclasses import dataclass, field
from typing import List, Optional
from iota_sdk.types.block.block import BlockBodyType
from iota_sdk.types.block.body.kind import BlockBodyType
from iota_sdk.types.common import HexStr, json


Expand Down
2 changes: 1 addition & 1 deletion bindings/python/iota_sdk/types/block/metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from typing import Optional
from iota_sdk.types.common import HexStr, json
# TODO rename change to Block
from iota_sdk.types.block.signed_block import Block
from iota_sdk.types.block.block import Block


@json
Expand Down
79 changes: 0 additions & 79 deletions bindings/python/iota_sdk/types/block/signed_block.py

This file was deleted.

2 changes: 1 addition & 1 deletion bindings/python/iota_sdk/types/output_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from __future__ import annotations
from dataclasses import dataclass, field
from enum import Enum
from typing import List, Optional
from typing import Optional
from dataclasses_json import config
from iota_sdk.types.common import HexStr, json, opt_int_encoder
from iota_sdk.types.native_token import NativeToken
Expand Down
2 changes: 1 addition & 1 deletion bindings/python/iota_sdk/types/send_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

from __future__ import annotations
from dataclasses import dataclass, field
from typing import Optional, List
from typing import Optional
from dataclasses_json import config
from iota_sdk.types.common import hex_str_decoder, HexStr, json
from iota_sdk.types.native_token import NativeToken
Expand Down

0 comments on commit 5745b8c

Please sign in to comment.