-
Notifications
You must be signed in to change notification settings - Fork 0
/
account.py
44 lines (38 loc) · 1.09 KB
/
account.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
from stellar_base.address import Address
from stellar_base.utils import AccountNotExistError
class Details:
def __init__(self, address):
self.address = address
self.account = Address(address=self.address)
try:
self.account.get()
except AccountNotExistError:
self.account = None
@property
def check(self):
return True if self.account else False
@property
def get(self):
if self.account:
return self.account, self.address, self.balance, self.asset
else:
return None
@property
def balance(self):
balance = 0
try:
balance = self.account.balances[0]['balance']
except AttributeError:
balance = None
finally:
return balance
@property
def asset(self):
asset = None
try:
asset = self.account.balances[0]['asset_type']
asset = 'XLM' if asset == 'native' else asset
except AttributeError:
asset = None
finally:
return asset