-
Notifications
You must be signed in to change notification settings - Fork 0
/
service.py
54 lines (41 loc) · 1.19 KB
/
service.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
"""
Provide implementation of the account.
"""
import asyncio
from accessify import implements
from cli.account.interfaces import AccountInterface
loop = asyncio.get_event_loop()
@implements(AccountInterface)
class Account:
"""
Implements account.
"""
def __init__(self, service):
"""
Constructor.
Arguments:
service: object to interact with Remme core API.
"""
self.service = service
def get_balance(self, address):
"""
Get balance of the account by its address.
"""
try:
balance = loop.run_until_complete(self.service.token.get_balance(address=address))
except Exception as error:
return None, str(error)
return {
'balance': balance,
}, None
def transfer_tokens(self, address_to, amount):
"""
Transfer tokens to address.
"""
try:
transaction = loop.run_until_complete(self.service.token.transfer(address_to=address_to, amount=amount))
except Exception as error:
return None, str(error)
return {
'batch_identifier': transaction.batch_id,
}, None