Skip to content
This repository has been archived by the owner on Nov 15, 2021. It is now read-only.

Commit

Permalink
Merge remote-tracking branch 'origin/development' into feature-events
Browse files Browse the repository at this point in the history
* origin/development:
  Update all the requirements (#87)
  Added Wallet.GetSyncedBalances
  • Loading branch information
metachris committed Nov 18, 2017
2 parents d807d77 + 1d0684b commit 863b408
Show file tree
Hide file tree
Showing 4 changed files with 67 additions and 42 deletions.
5 changes: 5 additions & 0 deletions neo/Prompt/Commands/tests/test_wallet_commands.py
Expand Up @@ -69,3 +69,8 @@ def test_3_import_token(self):
self.assertEqual(token.symbol, 'NEP5')
self.assertEqual(token.decimals, 8)
self.assertEqual(token.Address, 'AYhE3Svuqdfh1RtzvE8hUhNR7HSpaSDFQg')

def test_4_get_synced_balances(self):
wallet = self.GetWallet1()
synced_balances = wallet.GetSyncedBalances()
self.assertEqual(len(synced_balances), 2)
20 changes: 20 additions & 0 deletions neo/Wallets/Wallet.py
Expand Up @@ -31,6 +31,7 @@
from neo.Implementations.Blockchains.LevelDB.LevelDBBlockchain import LevelDBBlockchain
from neo.Fixed8 import Fixed8
from neo.UInt160 import UInt160
from neo.UInt256 import UInt256
from neo.Core.Helper import Helper


Expand Down Expand Up @@ -1154,6 +1155,25 @@ def Sign(self, context):

return success

def GetSyncedBalances(self):
"""
Returns a list of synced balances. The list looks like this:
[('NEO', 100.0), ('NEOGas', 100.0)]
Returns
list: [(asset_name, amount), ...]
"""
assets = self.GetCoinAssets()
balances = []
for asset in assets:
if type(asset) is UInt256:
bc_asset = Blockchain.Default().GetAssetState(asset.ToBytes())
total = self.GetBalance(asset).value / Fixed8.D
balances.append((bc_asset.GetName(), total))
elif type(asset) is NEP5Token:
balances.append((asset.symbol, self.GetBalance(asset)))
return balances

def ToJson(self, verbose=False):
# abstract
pass
42 changes: 21 additions & 21 deletions requirements.txt
@@ -1,45 +1,45 @@
asn1crypto==0.22.0
attrs==17.2.0
asn1crypto==0.23.0
attrs==17.3.0
Automat==0.6.0
autopep8==1.3.3
base58==0.2.5
bitcoin==1.1.42
blessings==1.6
bpython==0.16
byteplay3==3.5.0
certifi==2017.4.17
cffi==1.10.0
certifi==2017.11.5
cffi==1.11.2
chardet==3.0.4
colorlog==3.0.0
colorlog==3.1.0
constantly==15.1.0
coverage==4.4.1
coveralls==1.1
cryptography==2.0.3
coverage==4.4.2
coveralls==1.2.0
cryptography==2.1.3
curtsies==0.2.11
cycler==0.10.0
docopt==0.6.2
ecdsa==0.13
Events==0.3
gevent==1.2.2
greenlet==0.4.12
hyperlink==17.3.0
idna==2.5
hyperlink==17.3.1
idna==2.6
incremental==17.5.0
logzero==1.3.1
memory-profiler==0.47
mmh3==2.4
mmh3==2.5.1
mock==2.0.0
mpmath==0.19
mpmath==1.0.0
neo-boa==0.1.8
neo-python-rpc==0.1.6
numpy==1.13.1
numpy==1.13.3
pbr==3.1.1
peewee==2.10.1
peewee==2.10.2
pluggy==0.5.2
plyvel==0.9
prompt-toolkit==1.0.15
psutil==5.2.2
py==1.4.34
psutil==5.4.1
py==1.5.1
pycodestyle==2.3.1
pycparser==2.18
pycrypto==2.6.1
Expand All @@ -48,13 +48,13 @@ Pympler==0.5
pymitter==0.2.3
pyparsing==2.2.0
python-dateutil==2.6.1
pytz==2017.2
requests==2.18.1
pytz==2017.3
requests==2.18.4
scrypt==0.8.0
six==1.11.0
tqdm==4.19.4
Twisted==17.5.0
urllib3==1.21.1
Twisted==17.9.0
urllib3==1.22
virtualenv==15.1.0
wcwidth==0.1.7
zope.interface==4.4.2
zope.interface==4.4.3
42 changes: 21 additions & 21 deletions requirements_docs.txt
@@ -1,6 +1,6 @@
alabaster==0.7.10
asn1crypto==0.22.0
attrs==17.2.0
asn1crypto==0.23.0
attrs==17.3.0
Autologging==1.1.0
Automat==0.6.0
autopep8==1.3.3
Expand All @@ -10,14 +10,14 @@ bitcoin==1.1.42
blessings==1.6
bpython==0.16
byteplay3==3.5.0
certifi==2017.4.17
cffi==1.10.0
certifi==2017.11.5
cffi==1.11.2
chardet==3.0.4
colorlog==3.0.0
colorlog==3.1.0
constantly==15.1.0
coverage==4.4.1
coveralls==1.1
cryptography==2.0.3
coverage==4.4.2
coveralls==1.2.0
cryptography==2.1.3
curtsies==0.2.11
cycler==0.10.0
docopt==0.6.2
Expand All @@ -26,43 +26,43 @@ ecdsa==0.13
Events==0.3
gevent==1.2.2
greenlet==0.4.12
hyperlink==17.3.0
idna==2.5
hyperlink==17.3.1
idna==2.6
imagesize==0.7.1
incremental==17.5.0
Jinja2==2.10
MarkupSafe==1.0
memory-profiler==0.47
mmh3==2.4
mmh3==2.5.1
mock==2.0.0
mpmath==0.19
mpmath==1.0.0
neo-boa==0.1.8
neo-python-rpc==0.1.6
numpy==1.13.1
numpy==1.13.3
pbr==3.1.1
peewee==2.10.1
peewee==2.10.2
pluggy==0.5.2
prompt-toolkit==1.0.15
psutil==5.2.2
py==1.4.34
psutil==5.4.1
py==1.5.1
pycodestyle==2.3.1
pycparser==2.18
pycrypto==2.6.1
Pygments==2.2.0
Pympler==0.5
pyparsing==2.2.0
python-dateutil==2.6.1
pytz==2017.2
requests==2.18.1
pytz==2017.3
requests==2.18.4
scrypt==0.8.0
six==1.11.0
snowballstemmer==1.2.1
Sphinx==1.6.5
sphinx-rtd-theme==0.2.4
sphinxcontrib-websupport==1.0.1
tqdm==4.19.4
Twisted==17.5.0
urllib3==1.21.1
Twisted==17.9.0
urllib3==1.22
virtualenv==15.1.0
wcwidth==0.1.7
zope.interface==4.4.2
zope.interface==4.4.3

0 comments on commit 863b408

Please sign in to comment.