Skip to content
This repository was archived by the owner on Oct 31, 2023. It is now read-only.

Commit

Permalink
Add withdraw method to cli (#2582)
Browse files Browse the repository at this point in the history
  • Loading branch information
Krigpl authored and mfranciszkiewicz committed Apr 6, 2018
1 parent a9bc17e commit 0487a48
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion golem/interface/client/account.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,21 @@
from typing import Dict, Any
import getpass

from decimal import Decimal
from ethereum.utils import denoms

from golem.core.deferred import sync_wait
from golem.interface.command import command, group
from golem.interface.command import Argument, command, group


@group(help="Manage account")
class Account:
client = None # type: 'golem.rpc.session.Client'

amount_arg = Argument('amount', help='Amount to withdraw, eg 1.45')
address_arg = Argument('destination', help='Address to send the funds to')
currency_arg = Argument('currency', help='ETH or GNT')

@command(help="Display account & financial info")
def info(self) -> Dict[str, Any]: # pylint: disable=no-self-use
client = Account.client
Expand Down Expand Up @@ -70,6 +75,17 @@ def unlock(self) -> str: # pylint: disable=no-self-use

return "Account unlock success"

@command(
arguments=(amount_arg, address_arg, currency_arg),
help="Withdraw GNT/ETH")
def withdraw( # pylint: disable=no-self-use
self,
amount,
destination,
currency) -> str:
amount = str(int(Decimal(amount) * denoms.ether))
return sync_wait(Account.client.withdraw(amount, destination, currency))


def _fmt(value: float, unit: str = "GNT") -> str:
return "{:.6f} {}".format(value / denoms.ether, unit)

0 comments on commit 0487a48

Please sign in to comment.