Skip to content

Commit 0defdc5

Browse files
emfriasxeroc
authored andcommitted
Add support for the new ticket_create_operation and ticket_update_operation
1 parent a664cd7 commit 0defdc5

3 files changed

Lines changed: 66 additions & 1 deletion

File tree

bitsharesbase/objecttypes.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,6 @@
1818
object_type["worker"] = 14
1919
object_type["balance"] = 15
2020
object_type["htlc"] = 16
21-
object_type["OBJECT_TYPE_COUNT"] = 16
21+
object_type["custom_authority"] = 17
22+
object_type["ticket"] = 18
23+
object_type["OBJECT_TYPE_COUNT"] = 18

bitsharesbase/operationids.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,11 @@
5555
"htlc_redeemed",
5656
"htlc_extend",
5757
"htlc_refund",
58+
"custom_authority_create_operation",
59+
"custom_authority_update_operation",
60+
"custom_authority_delete_operation",
61+
"ticket_create_operation",
62+
"ticket_update_operation",
5863
]
5964
operations = {o: ops.index(o) for o in ops}
6065

bitsharesbase/operations.py

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1042,5 +1042,63 @@ def __init__(self, *args, **kwargs):
10421042
)
10431043
)
10441044

1045+
ticket_type_strings = ['liquid', 'lock_180_days', 'lock_360_days', 'lock_720_days', 'lock_forever']
1046+
1047+
class Ticket_create_operation(GrapheneObject):
1048+
def __init__(self, *args, **kwargs):
1049+
if isArgsThisClass(self, args):
1050+
self.data = args[0].data
1051+
else:
1052+
if len(args) == 1 and len(kwargs) == 0:
1053+
kwargs = args[0]
1054+
1055+
if isinstance(kwargs["target_type"], int):
1056+
target_type = Varint32(kwargs["target_type"])
1057+
else:
1058+
target_type = Varint32(ticket_type_strings.index(kwargs["target_type"]))
1059+
1060+
super().__init__(
1061+
OrderedDict(
1062+
[
1063+
("fee", Asset(kwargs["fee"])),
1064+
("account", ObjectId(kwargs["account"], "account")),
1065+
("target_type", target_type),
1066+
("amount", Asset(kwargs["amount"])),
1067+
("extensions", Set([])),
1068+
]
1069+
)
1070+
)
1071+
1072+
class Ticket_update_operation(GrapheneObject):
1073+
def __init__(self, *args, **kwargs):
1074+
if isArgsThisClass(self, args):
1075+
self.data = args[0].data
1076+
else:
1077+
if len(args) == 1 and len(kwargs) == 0:
1078+
kwargs = args[0]
1079+
1080+
if isinstance(kwargs["target_type"], int):
1081+
target_type = Varint32(kwargs["target_type"])
1082+
else:
1083+
target_type = Varint32(ticket_type_strings.index(kwargs["target_type"]))
1084+
1085+
if kwargs.get("amount_for_new_target"):
1086+
amount_for_new_target = Optional(Asset(kwargs["amount_for_new_target"]))
1087+
else:
1088+
amount_for_new_target = Optional(None)
1089+
1090+
super().__init__(
1091+
OrderedDict(
1092+
[
1093+
("fee", Asset(kwargs["fee"])),
1094+
("ticket", ObjectId(kwargs["ticket"], "ticket")),
1095+
("account", ObjectId(kwargs["account"], "account")),
1096+
("target_type", target_type),
1097+
("amount_for_new_target", amount_for_new_target),
1098+
("extensions", Set([])),
1099+
]
1100+
)
1101+
)
1102+
10451103

10461104
fill_classmaps()

0 commit comments

Comments
 (0)