4
4
from typing import Any , DefaultDict , Dict , List , Optional , Union
5
5
6
6
from graphenecommon .chain import AbstractGrapheneChain
7
- from graphenecommon .exceptions import KeyAlreadyInStoreException
7
+ from graphenecommon .exceptions import KeyAlreadyInStoreException , AccountDoesNotExistsException
8
8
9
9
from vizapi .noderpc import NodeRPC
10
10
from vizbase import operations
@@ -689,7 +689,7 @@ def update_account_profile(
689
689
:raises AccountDoesNotExistsException: if the account does not exist
690
690
"""
691
691
692
- # check if account already exists
692
+ # check if the account does not exist
693
693
try :
694
694
Account (account_name , blockchain_instance = self )
695
695
except Exception :
@@ -704,6 +704,40 @@ def update_account_profile(
704
704
op = operations .Account_update (** op )
705
705
706
706
return self .finalizeOp (ops = op , account = account_name , permission = "active" )
707
+
708
+ def delegate_vesting_shares (
709
+ self ,
710
+ delegator : str ,
711
+ delegatee : str ,
712
+ amount : float
713
+ ) -> dict :
714
+ """
715
+ Delegate vesting SHARES to account.
716
+
717
+ :param str delegator: account that delegates
718
+ :param str delegatee: account to which is delegated
719
+ :param float amount: number of SHARES to be delegated
720
+ """
721
+
722
+ # check if the account does not exist
723
+ try :
724
+ Account (delegatee , blockchain_instance = self )
725
+ except Exception :
726
+ raise AccountDoesNotExistsException
727
+
728
+ op = {
729
+ "delegator" : delegator ,
730
+ "delegatee" : delegatee ,
731
+ "vesting_shares" : "{:.{prec}f} {asset}" .format (
732
+ float (amount ),
733
+ prec = PRECISIONS .get (self .rpc .chain_params ["shares_symbol" ]),
734
+ asset = self .rpc .chain_params ["shares_symbol" ],
735
+ ),
736
+ }
737
+
738
+ op = operations .Delegate_vesting_shares (** op )
739
+
740
+ return self .finalizeOp (op , delegator , "active" )
707
741
708
742
def _store_keys (self , * args ):
709
743
"""Store private keys to local storage."""
@@ -714,7 +748,6 @@ def _store_keys(self, *args):
714
748
pass
715
749
716
750
# TODO: Methods to implement:
717
- # - delegate_vesting_shares
718
751
# - witness_update
719
752
# - chain_properties_update
720
753
# - allow / disallow
0 commit comments