@@ -1722,3 +1722,45 @@ def voting_ticket_create(self, target_type, amount_to_lock, account=None, **kwar
17221722 }
17231723 )
17241724 return self .finalizeOp (op , account , "active" , ** kwargs )
1725+
1726+
1727+ def voting_ticket_update (self , ticket_id , new_target_type , amount_to_update ,
1728+ account = None , ** kwargs ):
1729+ """Update a voting ticket
1730+
1731+ :param str ticket_id: Id (e.g. "1.18.xxx") of the ticket to update.
1732+
1733+ :param int,str target_type: New lock period target. Should be a string
1734+ from operations.ticket_type_strings or the index of the
1735+ intended string.
1736+
1737+ :param Amount,None amount_to_update: Amount to move over to the new
1738+ lock-up target. (Optional - absence implies update whole
1739+ amount.)
1740+ """
1741+
1742+ if not account :
1743+ if "default_account" in self .config :
1744+ account = self .config ["default_account" ]
1745+ if not account :
1746+ raise ValueError ("You need to provide an account" )
1747+ account = Account (account , blockchain_instance = self )
1748+
1749+ if isinstance (amount_to_update , (Amount )):
1750+ amount_to_update = amount_to_update .json ()
1751+ elif amount_to_update is not None :
1752+ raise ValueError ("'amount_to_update' must be of type Amount or None" )
1753+ else :
1754+ pass # None is a valid value for optional field
1755+
1756+ op = operations .Ticket_update_operation (
1757+ ** {
1758+ "fee" : {"amount" : 0 , "asset_id" : "1.3.0" },
1759+ "ticket" : ticket_id ,
1760+ "account" : account ["id" ],
1761+ "target_type" : new_target_type ,
1762+ "amount_for_new_target" : amount_to_update ,
1763+ "extensions" : [],
1764+ }
1765+ )
1766+ return self .finalizeOp (op , account , "active" , ** kwargs )
0 commit comments