Skip to content

Commit

Permalink
Merge branch '2.0' into chore/features
Browse files Browse the repository at this point in the history
  • Loading branch information
DaughterOfMars committed Sep 20, 2023
2 parents d221715 + 0b9d534 commit 9f8f6fc
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 20 deletions.
2 changes: 1 addition & 1 deletion bindings/python/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ python3 example/[example file]
- Where `[example file]` is the file name from the example folder. For example:
```bash
python3 examples/client/00_get_info.py
python3 examples/how_tos/client/get_info.py
```
## API Reference
Expand Down
57 changes: 57 additions & 0 deletions bindings/python/iota_sdk/types/essence.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# Copyright 2023 IOTA Stiftung
# SPDX-License-Identifier: Apache-2.0

from __future__ import annotations
from enum import IntEnum
from typing import Optional, List, Union

from dataclasses import dataclass, field

from iota_sdk.types.common import HexStr, json
from iota_sdk.types.output import BasicOutput, AccountOutput, FoundryOutput, NftOutput
from iota_sdk.types.input import UtxoInput
from iota_sdk.types.payload import TaggedDataPayload
from iota_sdk.types.unlock import SignatureUnlock, ReferenceUnlock


class EssenceType(IntEnum):
"""Block payload types.
Attributes:
RegularTransactionEssence (2): A Regular Transaction Essence.
"""
RegularTransactionEssence = 5


@json
@dataclass
class TransactionEssence:
type: int


@json
@dataclass
class RegularTransactionEssence(TransactionEssence):
"""Describes the essence data making up a transaction by defining its inputs, outputs, and an optional payload.
Attributes:
network_id: The unique value denoting whether the block was meant for mainnet, shimmer, testnet, or a private network.
It consists of the first 8 bytes of the BLAKE2b-256 hash of the network name.
creation_slot: The slot index in which the transaction was created.
context_inputs: The inputs that provide additional contextual information for the execution of a transaction.
inputs: The inputs to consume in order to fund the outputs of the Transaction Payload.
inputs_commitment: BLAKE2b-256 hash serving as a commitment to the serialized outputs referenced by Inputs.
outputs: The outputs that are created by the Transaction Payload
allotments: The allotments of Mana which which will be added upon commitment of the slot.
payload: An optional tagged data payload
"""
network_id: str
# TODO: Replace with a proper SlotIndex type
creation_slot: HexStr
context_inputs: Optional[List[Union[CommitmentInput, BlockIssuanceCreditInput, RewardInput]]] = None
inputs: List[UtxoInput]
inputs_commitment: HexStr
outputs: List[Union[BasicOutput, AccountOutput, FoundryOutput, NftOutput, DelegationOutput]]
allotments: Optional[List[Allotment]] = None
payload: Optional[TaggedDataPayload] = None
type: int = field(default_factory=lambda: EssenceType.RegularTransactionEssence, init=False)
18 changes: 0 additions & 18 deletions bindings/python/iota_sdk/types/payload.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,24 +25,6 @@ class PayloadType(IntEnum):
Transaction = 6


@json
@dataclass
class TransactionEssence:
type: int


@json
@dataclass
class RegularTransactionEssence(TransactionEssence):
network_id: str
inputs_commitment: HexStr
inputs: List[UtxoInput]
outputs: List[Union[AccountOutput, FoundryOutput, NftOutput, BasicOutput]]
allotments: List[ManaAllotment]
payload: Optional[TaggedDataPayload] = None
type: int = field(default_factory=lambda: 1, init=False)


@json
@dataclass
class Payload():
Expand Down
3 changes: 2 additions & 1 deletion bindings/python/iota_sdk/types/transaction_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
from typing import Optional, List, Union
from iota_sdk.types.address import Ed25519Address, AccountAddress, NFTAddress
from iota_sdk.types.output import BasicOutput, AccountOutput, FoundryOutput, NftOutput, OutputMetadata
from iota_sdk.types.payload import RegularTransactionEssence, TransactionPayload
from iota_sdk.types.essence import RegularTransactionEssence
from iota_sdk.types.payload import TransactionPayload
from iota_sdk.types.signature import Bip44
from iota_sdk.types.common import json

Expand Down

0 comments on commit 9f8f6fc

Please sign in to comment.