Skip to content

Commit

Permalink
Merge branch '2.0' into feat/python-transaction-refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
Alex Coats committed Nov 2, 2023
2 parents e920b99 + 8e8f61f commit d9a5d17
Show file tree
Hide file tree
Showing 8 changed files with 39 additions and 25 deletions.
10 changes: 8 additions & 2 deletions bindings/python/iota_sdk/types/balance.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,14 @@ class NativeTokensBalance:
metadata: Some metadata of the native token.
"""
token_id: HexStr
total: HexStr
available: HexStr
total: int = field(metadata=config(
encoder=hex,
decoder=lambda v: int(v, 16)
))
available: int = field(metadata=config(
encoder=hex,
decoder=lambda v: int(v, 16)
))
metadata: Optional[HexStr]


Expand Down
2 changes: 1 addition & 1 deletion bindings/python/iota_sdk/types/block/basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,5 @@ class BasicBlock:
))
payload: Optional[Payload] = None
type: int = field(
default_factory=lambda: BlockType.Basic,
default_factory=lambda: int(BlockType.Basic),
init=False)
2 changes: 1 addition & 1 deletion bindings/python/iota_sdk/types/block/validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,5 @@ class ValidationBlock:
highest_supported_version: int
protocol_parameters_hash: HexStr
type: int = field(
default_factory=lambda: BlockType.Validation,
default_factory=lambda: int(BlockType.Validation),
init=False)
8 changes: 6 additions & 2 deletions bindings/python/iota_sdk/types/native_token.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
# Copyright 2023 IOTA Stiftung
# SPDX-License-Identifier: Apache-2.0

from dataclasses import dataclass
from dataclasses import dataclass, field
from dataclasses_json import config

from iota_sdk.types.common import HexStr, json

Expand All @@ -16,4 +17,7 @@ class NativeToken():
amount: The amount of native tokens.
"""
id: HexStr
amount: HexStr
amount: int = field(metadata=config(
encoder=hex,
decoder=lambda v: int(v, 16)
))
6 changes: 4 additions & 2 deletions bindings/python/iota_sdk/types/send_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,12 @@ class CreateNativeTokenParams():
account_id: The ID of the corresponding account.
"""
circulating_supply: int = field(metadata=config(
encoder=str
encoder=hex,
decoder=lambda v: int(v, 16)
))
maximum_supply: int = field(metadata=config(
encoder=str
encoder=hex,
decoder=lambda v: int(v, 16)
))
foundry_metadata: Optional[str] = None
account_id: Optional[str] = None
Expand Down
2 changes: 1 addition & 1 deletion bindings/python/iota_sdk/types/signature.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class Ed25519Signature:
"""
public_key: HexStr
signature: HexStr
type: int = field(default_factory=lambda: 0, init=False)
type: int = field(default=0, init=False)


Signature: TypeAlias = Ed25519Signature
Expand Down
22 changes: 16 additions & 6 deletions bindings/python/iota_sdk/types/token_scheme.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
# Copyright 2023 IOTA Stiftung
# SPDX-License-Identifier: Apache-2.0

from dataclasses import dataclass, field
from typing import TypeAlias
from iota_sdk.types.common import HexStr, json
from dataclasses import dataclass, field
from dataclasses_json import config
from iota_sdk.types.common import json


@json
Expand All @@ -17,10 +18,19 @@ class SimpleTokenScheme:
maximum_supply: The maximum supply of the token.
type: The type code of the token scheme.
"""
minted_tokens: HexStr
melted_tokens: HexStr
maximum_supply: HexStr
type: int = field(default_factory=lambda: 0, init=False)
minted_tokens: int = field(metadata=config(
encoder=hex,
decoder=lambda v: int(v, 16)
))
melted_tokens: int = field(metadata=config(
encoder=hex,
decoder=lambda v: int(v, 16)
))
maximum_supply: int = field(metadata=config(
encoder=hex,
decoder=lambda v: int(v, 16)
))
type: int = field(default=0, init=False)


TokenScheme: TypeAlias = SimpleTokenScheme
12 changes: 2 additions & 10 deletions bindings/python/iota_sdk/types/unlock.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,7 @@ class UnlockType(IntEnum):

@json
@dataclass
class Unlock:
"""Unlock type.
"""
type: int


@json
@dataclass
class SignatureUnlock(Unlock):
class SignatureUnlock:
"""An unlock holding a signature unlocking one or more inputs.
"""
signature: Ed25519Signature
Expand All @@ -49,7 +41,7 @@ class SignatureUnlock(Unlock):

@json
@dataclass
class ReferenceUnlock(Unlock):
class ReferenceUnlock:
"""An unlock which must reference a previous unlock which unlocks also the input at the same index as this Reference Unlock.
"""
reference: int
Expand Down

0 comments on commit d9a5d17

Please sign in to comment.