Skip to content

Commit

Permalink
feat/python: unlock slotindex (#1393)
Browse files Browse the repository at this point in the history
* rename

* this 2 line nonsense is weird

* expiration fix

* spaced out

* test

* .

* ..

* Update bindings/python/iota_sdk/types/unlock_condition.py

Co-authored-by: DaughterOfMars <[email protected]>

* als oin ts

* Update bindings/nodejs/lib/types/block/output/unlock-condition.ts

Co-authored-by: DaughterOfMars <[email protected]>

* Update bindings/python/iota_sdk/types/unlock_condition.py

Co-authored-by: DaughterOfMars <[email protected]>

---------

Co-authored-by: DaughterOfMars <[email protected]>
Co-authored-by: Thoralf-M <[email protected]>
  • Loading branch information
3 people authored Oct 10, 2023
1 parent 9fb7b8c commit 560026b
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 16 deletions.
7 changes: 3 additions & 4 deletions bindings/nodejs/lib/types/block/output/unlock-condition.ts
Original file line number Diff line number Diff line change
Expand Up @@ -156,8 +156,8 @@ class TimelockUnlockCondition extends UnlockCondition {
}

/**
* Defines an expiration slot index. Before the slot index is reached, only the Address defined in the Address
* Unlock Condition is allowed to unlock the output. Afterward, only the Return Address can unlock it.
* Defines a slot index until which only the Address defined in the Address Unlock Condition is allowed to unlock the output.
* After the slot index is reached/passed, only the Return Address can unlock it.
*/
class ExpirationUnlockCondition extends UnlockCondition {
/**
Expand All @@ -168,8 +168,7 @@ class ExpirationUnlockCondition extends UnlockCondition {
})
readonly returnAddress: Address;
/**
* Before this slot index, the condition is allowed to unlock the output,
* after that only the address defined in return address.
* Before this slot index, the Address Unlock Condition is allowed to unlock the output, after that only the address defined in Return Address can.
*/
readonly slotIndex: SlotIndex;

Expand Down
2 changes: 1 addition & 1 deletion bindings/python/examples/client/build_basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
address_unlock_condition,
ExpirationUnlockCondition(
return_address=Ed25519Address(hex_address),
unix_time=1
slot_index=1
)
],
amount=1000000,
Expand Down
15 changes: 8 additions & 7 deletions bindings/python/iota_sdk/types/unlock_condition.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from typing import Dict, List, TypeAlias, Union, Any
from dataclasses_json import config
from iota_sdk.types.address import Address, AccountAddress
from iota_sdk.types.common import json
from iota_sdk.types.common import json, SlotIndex
from iota_sdk.types.address import deserialize_address


Expand Down Expand Up @@ -71,11 +71,11 @@ class StorageDepositReturnUnlockCondition:
@json
@dataclass
class TimelockUnlockCondition:
"""A timelock unlock condition.
"""Defines a slot index until which the output can not be unlocked.
Args:
unix_time: The Unix timestamp marking the end of the timelock.
slot_index: Slot index that defines when the output can be consumed.
"""
unix_time: int
slot_index: SlotIndex
type: int = field(
default_factory=lambda: int(
UnlockConditionType.Timelock),
Expand All @@ -85,12 +85,13 @@ class TimelockUnlockCondition:
@json
@dataclass
class ExpirationUnlockCondition:
"""An expiration unlock condition.
"""Defines a slot index until which only the Address defined in the Address Unlock Condition is allowed to unlock the output. After the slot index is reached/passed, only the Return Address can unlock it.
Args:
unix_time: Unix timestamp marking the expiration of the claim.
slot_index: Before this slot index, Address Unlock Condition is allowed to unlock the output,
after that only the address defined in Return Address.
return_address: The return address if the output was not claimed in time.
"""
unix_time: int
slot_index: SlotIndex
return_address: Address = field(
metadata=config(
decoder=deserialize_address
Expand Down
4 changes: 2 additions & 2 deletions bindings/python/tests/test_block.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,12 +174,12 @@ def test_basic_block_with_tx_payload_all_output_types():
"type": 0, "address": {
"type": 0, "pubKeyHash": "0x7ffec9e1233204d9c6dce6812b1539ee96af691ca2e4d9065daa85907d33e5d3"}}, {
"type": 3, "returnAddress": {
"type": 0, "pubKeyHash": "0x7ffec9e1233204d9c6dce6812b1539ee96af691ca2e4d9065daa85907d33e5d3"}, "unixTime": 1}]}, {
"type": 0, "pubKeyHash": "0x7ffec9e1233204d9c6dce6812b1539ee96af691ca2e4d9065daa85907d33e5d3"}, "slotIndex": 1}]}, {
"type": 3, "amount": "1000000", "unlockConditions": [
{
"type": 0, "address": {
"type": 0, "pubKeyHash": "0x7ffec9e1233204d9c6dce6812b1539ee96af691ca2e4d9065daa85907d33e5d3"}}, {
"type": 2, "unixTime": 1}]}, {
"type": 2, "slotIndex": 1}]}, {
"type": 3, "amount": "5578452198", "nativeTokens": [
{
"id": "0x080021bcfa2252a500348f73c939722d65c0354eab33b753ab09bc80a7f592c9a40100000000", "amount": "0x41"}, {
Expand Down
4 changes: 2 additions & 2 deletions bindings/python/tests/test_output.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ def test_output():
"type": 0,
"pubKeyHash": "0x8f463f0c57b86cf52cc69542fb43a2ec87f83b9c47493cce04c1a4616716bed0"
},
"unixTime": 1659119101
"slotIndex": 1659119101
}
]
}
Expand All @@ -101,7 +101,7 @@ def test_output():
},
{
"type": 2,
"unixTime": 1661850262
"slotIndex": 1661850262
}
]
}
Expand Down

0 comments on commit 560026b

Please sign in to comment.