mirror of
https://github.com/planetmint/planetmint.git
synced 2025-03-30 15:08:31 +00:00
blackified
Signed-off-by: Lorenz Herzberger <lorenzherzberger@gmail.com>
This commit is contained in:
parent
3d47043090
commit
1c1df2e335
@ -14,20 +14,17 @@ class ConditionDetails:
|
||||
public_key: str = ""
|
||||
threshold: int = None
|
||||
sub_conditions: List[ConditionDetails] = field(default_factory=list)
|
||||
|
||||
|
||||
def to_dict(self) -> dict:
|
||||
if self.sub_conditions is None:
|
||||
return {
|
||||
"type": self.type,
|
||||
"public_key": self.public_key
|
||||
}
|
||||
return {"type": self.type, "public_key": self.public_key}
|
||||
else:
|
||||
return {
|
||||
"type": self.type,
|
||||
"threshold": self.threshold,
|
||||
"subconditions": [sub_condition.to_dict() for sub_condition in self.sub_conditions]
|
||||
"subconditions": [sub_condition.to_dict() for sub_condition in self.sub_conditions],
|
||||
}
|
||||
|
||||
|
||||
@staticmethod
|
||||
def from_dict(details: dict) -> ConditionDetails:
|
||||
sub_conditions = None
|
||||
@ -121,8 +118,7 @@ def output_with_public_key(output, transaction_id) -> Output:
|
||||
public_keys=output["public_keys"],
|
||||
amount=output["amount"],
|
||||
condition=Condition(
|
||||
uri=output["condition"]["uri"],
|
||||
details=ConditionDetails.from_dict(output["condition"]["details"])
|
||||
uri=output["condition"]["uri"], details=ConditionDetails.from_dict(output["condition"]["details"])
|
||||
),
|
||||
)
|
||||
|
||||
@ -133,7 +129,6 @@ def output_with_sub_conditions(output, transaction_id) -> Output:
|
||||
public_keys=output["public_keys"],
|
||||
amount=output["amount"],
|
||||
condition=Condition(
|
||||
uri=output["condition"]["uri"],
|
||||
details=ConditionDetails.from_dict(output["condition"]["details"])
|
||||
uri=output["condition"]["uri"], details=ConditionDetails.from_dict(output["condition"]["details"])
|
||||
),
|
||||
)
|
||||
|
@ -10,39 +10,31 @@ nested_threshold_output = {
|
||||
"condition": {
|
||||
"details": {
|
||||
"subconditions": [
|
||||
{
|
||||
"type": "ed25519-sha-256",
|
||||
"public_key": "7pT7eBEGJsmpUvRFhu7NUQSZVJVZDeF1xREuYKdVYUKK"
|
||||
},
|
||||
{
|
||||
"subconditions": [
|
||||
{"type": "ed25519-sha-256", "public_key": "7pT7eBEGJsmpUvRFhu7NUQSZVJVZDeF1xREuYKdVYUKK"},
|
||||
{
|
||||
"type": "ed25519-sha-256",
|
||||
"public_key": "746ZbyMgoCJykAdzZ2vZcHzwnndrVnAAh6pv6yLZDiH2"
|
||||
"subconditions": [
|
||||
{"type": "ed25519-sha-256", "public_key": "746ZbyMgoCJykAdzZ2vZcHzwnndrVnAAh6pv6yLZDiH2"},
|
||||
{"type": "ed25519-sha-256", "public_key": "EYb188vCQoaYDmW3Agen1u6Fh7xvDWCMnWJK8ueuCdbX"},
|
||||
],
|
||||
"threshold": 2,
|
||||
"type": "threshold-sha-256",
|
||||
},
|
||||
{
|
||||
"type": "ed25519-sha-256",
|
||||
"public_key": "EYb188vCQoaYDmW3Agen1u6Fh7xvDWCMnWJK8ueuCdbX"
|
||||
}
|
||||
],
|
||||
"threshold": 2,
|
||||
"type": "threshold-sha-256"
|
||||
}
|
||||
],
|
||||
"threshold": 1,
|
||||
"type": "threshold-sha-256"
|
||||
"type": "threshold-sha-256",
|
||||
},
|
||||
"uri": "ni:///sha-256;hhw6Rf9JgwKYkapwE9qu7oVaI0ArS0hj_dmzAkpIPdc?fpt=threshold-sha-256&cost=266240&subtypes=ed25519-sha-256"
|
||||
"uri": "ni:///sha-256;hhw6Rf9JgwKYkapwE9qu7oVaI0ArS0hj_dmzAkpIPdc?fpt=threshold-sha-256&cost=266240&subtypes=ed25519-sha-256",
|
||||
},
|
||||
"public_keys": [
|
||||
"7pT7eBEGJsmpUvRFhu7NUQSZVJVZDeF1xREuYKdVYUKK",
|
||||
"746ZbyMgoCJykAdzZ2vZcHzwnndrVnAAh6pv6yLZDiH2",
|
||||
"EYb188vCQoaYDmW3Agen1u6Fh7xvDWCMnWJK8ueuCdbX"
|
||||
]
|
||||
"EYb188vCQoaYDmW3Agen1u6Fh7xvDWCMnWJK8ueuCdbX",
|
||||
],
|
||||
}
|
||||
|
||||
|
||||
def test_output_nested_threshold_condition():
|
||||
output = Output.outputs_dict(nested_threshold_output)
|
||||
assert output
|
||||
output_dict = output.to_dict()
|
||||
assert nested_threshold_output == output_dict
|
||||
assert nested_threshold_output == output_dict
|
||||
|
Loading…
x
Reference in New Issue
Block a user