Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions viz/memo.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,9 +105,11 @@ def decrypt(self, message: str) -> str:
keys = memo.involved_keys(message)
wif = None
for key in keys:
wif = self.blockchain.wallet.getPrivateKeyForPublicKey(str(key))
if wif:
try:
wif = self.blockchain.wallet.getPrivateKeyForPublicKey(str(key))
break
except:
continue
if not wif:
raise MissingKeyError("None of the required memo keys are installed!")

Expand Down
39 changes: 36 additions & 3 deletions viz/viz.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from typing import Any, DefaultDict, Dict, List, Optional, Union

from graphenecommon.chain import AbstractGrapheneChain
from graphenecommon.exceptions import KeyAlreadyInStoreException
from graphenecommon.exceptions import KeyAlreadyInStoreException,AccountDoesNotExistsException

from vizapi.noderpc import NodeRPC
from vizbase import operations
Expand Down Expand Up @@ -689,7 +689,7 @@ def update_account_profile(
:raises AccountDoesNotExistsException: if the account does not exist
"""

# check if account already exists
# check if the account does not exist
try:
Account(account_name, blockchain_instance=self)
except Exception:
Expand All @@ -704,6 +704,40 @@ def update_account_profile(
op = operations.Account_update(**op)

return self.finalizeOp(ops=op, account=account_name, permission="active")

def delegate_vesting_shares(
self,
delegator: str,
delegatee: str,
amount: float
) -> dict:
"""
Delegate vesting SHARES to account.

:param str delegator: account that delegates
:param str delegatee: account to which is delegated
:param float amount: number of SHARES to be delegated
"""

# check if the account does not exist
try:
Account(delegatee, blockchain_instance=self)
except Exception:
raise AccountDoesNotExistsException

op = {
"delegator": delegator,
"delegatee": delegatee,
"vesting_shares": "{:.{prec}f} {asset}".format(
float(amount),
prec=PRECISIONS.get(self.rpc.chain_params["shares_symbol"]),
asset=self.rpc.chain_params["shares_symbol"],
),
}

op = operations.Delegate_vesting_shares(**op)

return self.finalizeOp(op, delegator, "active")

def _store_keys(self, *args):
"""Store private keys to local storage."""
Expand All @@ -714,7 +748,6 @@ def _store_keys(self, *args):
pass

# TODO: Methods to implement:
# - delegate_vesting_shares
# - witness_update
# - chain_properties_update
# - allow / disallow
Expand Down