Skip to content

Commit

Permalink
Merge branch '2.0' into feat/btree-sets
Browse files Browse the repository at this point in the history
  • Loading branch information
Alex Coats committed Oct 5, 2023
2 parents 416bf62 + 60efd78 commit edbb25e
Show file tree
Hide file tree
Showing 62 changed files with 468 additions and 312 deletions.
7 changes: 4 additions & 3 deletions bindings/core/src/method_handler/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#[cfg(feature = "mqtt")]
use iota_sdk::client::mqtt::{MqttPayload, Topic};
use iota_sdk::{
client::{request_funds_from_faucet, Client},
client::{request_funds_from_faucet, secret::SecretManager, Client},
types::{
api::core::response::OutputWithMetadataResponse,
block::{
Expand Down Expand Up @@ -173,15 +173,16 @@ pub(crate) async fn call_client_method_internal(client: &Client, method: ClientM
ClientMethod::GetProtocolParameters => Response::ProtocolParameters(client.get_protocol_parameters().await?),
ClientMethod::PostBlockPayload { payload } => {
let block = client
.finish_basic_block_builder(
.build_basic_block::<SecretManager>(
todo!("issuer id"),
todo!("block signature"),
todo!("issuing time"),
None,
Some(Payload::try_from_dto_with_params(
payload,
&client.get_protocol_parameters().await?,
)?),
todo!("secret manager"),
todo!("chain"),
)
.await?;

Expand Down
20 changes: 6 additions & 14 deletions bindings/python/iota_sdk/types/address.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,7 @@ class AddressType(IntEnum):

@json
@dataclass
class Address():
"""Base class for addresses.
"""
type: int


@json
@dataclass
class Ed25519Address(Address):
class Ed25519Address:
"""Represents an Ed25519 address.
Attributes:
pub_key_hash: The hex encoded Ed25519 public key hash.
Expand All @@ -44,7 +36,7 @@ class Ed25519Address(Address):

@json
@dataclass
class AccountAddress(Address):
class AccountAddress:
"""Represents an Account address.
Attributes:
account_id: The hex encoded account id.
Expand All @@ -58,7 +50,7 @@ class AccountAddress(Address):

@json
@dataclass
class NFTAddress(Address):
class NFTAddress:
"""Represents an NFT address.
Attributes:
nft_id: The hex encoded NFT id.
Expand All @@ -78,10 +70,10 @@ class AddressWithUnspentOutputs():
output_ids: bool


AddressUnion: TypeAlias = Union[Ed25519Address, AccountAddress, NFTAddress]
Address: TypeAlias = Union[Ed25519Address, AccountAddress, NFTAddress]


def deserialize_address(d: Dict[str, Any]) -> AddressUnion:
def deserialize_address(d: Dict[str, Any]) -> Address:
"""
Takes a dictionary as input and returns an instance of a specific class based on the value of the 'type' key in the dictionary.
Expand All @@ -99,7 +91,7 @@ def deserialize_address(d: Dict[str, Any]) -> AddressUnion:


def deserialize_addresses(
dicts: List[Dict[str, Any]]) -> List[AddressUnion]:
dicts: List[Dict[str, Any]]) -> List[Address]:
"""
Takes a list of dictionaries as input and returns a list with specific instances of a classes based on the value of the 'type' key in the dictionary.
Expand Down
8 changes: 4 additions & 4 deletions bindings/python/iota_sdk/types/block/basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@
from __future__ import annotations
from dataclasses import dataclass, field
from typing import List, Optional
from iota_sdk.types.block.block import Block, BlockType
from iota_sdk.types.block.block import BlockType
from iota_sdk.types.common import HexStr, json
from iota_sdk.types.payload import PayloadUnion
from iota_sdk.types.payload import Payload


@json
@dataclass
class BasicBlock(Block):
class BasicBlock:
"""A `BasicBlock` is the most common type of block used to issue various kinds of payloads such as transactions
at the cost of burning Mana.
Expand All @@ -26,7 +26,7 @@ class BasicBlock(Block):
weak_parents: List[HexStr]
shallow_like_parents: List[HexStr]
max_burned_mana: str
payload: Optional[PayloadUnion] = None
payload: Optional[Payload] = None
type: int = field(
default_factory=lambda: BlockType.Basic,
init=False)
10 changes: 0 additions & 10 deletions bindings/python/iota_sdk/types/block/block.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@

from __future__ import annotations
from enum import IntEnum
from dataclasses import dataclass
from iota_sdk.types.common import json


class BlockType(IntEnum):
Expand All @@ -16,11 +14,3 @@ class BlockType(IntEnum):
"""
Basic = 0
Validation = 1


@json
@dataclass
class Block:
"""Base class for blocks.
"""
type: int
4 changes: 2 additions & 2 deletions bindings/python/iota_sdk/types/block/validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
from __future__ import annotations
from dataclasses import dataclass, field
from typing import List
from iota_sdk.types.block.block import Block, BlockType
from iota_sdk.types.block.block import BlockType
from iota_sdk.types.common import HexStr, json


@json
@dataclass
class ValidationBlock(Block):
class ValidationBlock:
"""A Validation Block is a special type of block used by validators to secure the network. It is recognized by the
Congestion Control of the IOTA 2.0 protocol and can be issued without burning Mana within the constraints of the
allowed validator throughput. It is allowed to reference more parent blocks than a normal Basic Block.
Expand Down
17 changes: 9 additions & 8 deletions bindings/python/iota_sdk/types/block/wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,12 @@
from __future__ import annotations
from dataclasses import dataclass
from typing import TypeAlias, Union
from iota_sdk.types.block.basic import BasicBlock
from iota_sdk.types.block.validation import ValidationBlock
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 SignatureUnion
from iota_sdk.utils import Utils

BlockUnion: TypeAlias = Union[BasicBlock, ValidationBlock]
from iota_sdk.types.signature import Signature
from iota_sdk.types.block.basic import BasicBlock
from iota_sdk.types.block.validation import ValidationBlock


@json
Expand All @@ -36,10 +34,13 @@ class BlockWrapper:
slot_commitment_id: HexStr
latest_finalized_slot: SlotIndex
issuer_id: HexStr
block: BlockUnion
signature: SignatureUnion
block: Block
signature: Signature

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


Block: TypeAlias = Union[BasicBlock, ValidationBlock]
22 changes: 7 additions & 15 deletions bindings/python/iota_sdk/types/context_input.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,7 @@ class ContextInputType(IntEnum):

@json
@dataclass
class ContextInput():
"""Base class for context inputs.
"""
type: int


@json
@dataclass
class CommitmentContextInput(ContextInput):
class CommitmentContextInput:
"""A Commitment Context Input allows referencing a commitment to a certain slot.
Attributes:
Expand All @@ -42,7 +34,7 @@ class CommitmentContextInput(ContextInput):

@json
@dataclass
class BlockIssuanceCreditContextInput(ContextInput):
class BlockIssuanceCreditContextInput:
"""A Block Issuance Credit (BIC) Context Input provides the VM with context for the value of
the BIC vector of a specific slot.
Expand All @@ -59,7 +51,7 @@ class BlockIssuanceCreditContextInput(ContextInput):

@json
@dataclass
class RewardContextInput(ContextInput):
class RewardContextInput:
"""A Reward Context Input indicates which transaction Input is claiming Mana rewards.
Attributes:
Expand All @@ -73,11 +65,11 @@ class RewardContextInput(ContextInput):
init=False)


ContextInputUnion: TypeAlias = Union[CommitmentContextInput,
BlockIssuanceCreditContextInput, RewardContextInput]
ContextInput: TypeAlias = Union[CommitmentContextInput,
BlockIssuanceCreditContextInput, RewardContextInput]


def deserialize_context_input(d: Dict[str, Any]) -> ContextInputUnion:
def deserialize_context_input(d: Dict[str, Any]) -> ContextInput:
"""
Takes a dictionary as input and returns an instance of a specific class based on the value of the 'type' key in the dictionary.
Expand All @@ -95,7 +87,7 @@ def deserialize_context_input(d: Dict[str, Any]) -> ContextInputUnion:


def deserialize_context_inputs(
dicts: List[Dict[str, Any]]) -> List[ContextInputUnion]:
dicts: List[Dict[str, Any]]) -> List[ContextInput]:
"""
Takes a list of dictionaries as input and returns a list with specific instances of a classes based on the value of the 'type' key in the dictionary.
Expand Down
23 changes: 9 additions & 14 deletions bindings/python/iota_sdk/types/essence.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@

from __future__ import annotations
from enum import IntEnum
from typing import TYPE_CHECKING, Optional, List
from typing import TYPE_CHECKING, Optional, List, TypeAlias

from dataclasses import dataclass, field

from iota_sdk.types.common import HexStr, json, SlotIndex
from iota_sdk.types.mana import ManaAllotment
from iota_sdk.types.input import UtxoInput
from iota_sdk.types.context_input import ContextInputUnion
from iota_sdk.types.output import OutputUnion
from iota_sdk.types.context_input import ContextInput
from iota_sdk.types.output import Output

# Required to prevent circular import
if TYPE_CHECKING:
Expand All @@ -29,15 +29,7 @@ class EssenceType(IntEnum):

@json
@dataclass
class TransactionEssence:
"""Base class of Transaction essence
"""
type: int


@json
@dataclass
class RegularTransactionEssence(TransactionEssence):
class RegularTransactionEssence:
"""Describes the essence data making up a transaction by defining its inputs, outputs, and an optional payload.
Attributes:
Expand All @@ -55,10 +47,13 @@ class RegularTransactionEssence(TransactionEssence):
creation_slot: SlotIndex
inputs: List[UtxoInput]
inputs_commitment: HexStr
outputs: List[OutputUnion]
context_inputs: Optional[List[ContextInputUnion]] = None
outputs: List[Output]
context_inputs: Optional[List[ContextInput]] = None
allotments: Optional[List[ManaAllotment]] = None
payload: Optional[Payload] = None
type: int = field(
default_factory=lambda: EssenceType.RegularTransactionEssence,
init=False)


TransactionEssence: TypeAlias = RegularTransactionEssence
Loading

0 comments on commit edbb25e

Please sign in to comment.