diff --git a/neo/Prompt/Commands/tests/test_wallet_commands.py b/neo/Prompt/Commands/tests/test_wallet_commands.py index f623f6a65..8761da036 100644 --- a/neo/Prompt/Commands/tests/test_wallet_commands.py +++ b/neo/Prompt/Commands/tests/test_wallet_commands.py @@ -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) diff --git a/neo/Wallets/Wallet.py b/neo/Wallets/Wallet.py index 33b64d0fc..9da23646e 100755 --- a/neo/Wallets/Wallet.py +++ b/neo/Wallets/Wallet.py @@ -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 @@ -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 diff --git a/requirements.txt b/requirements.txt index f3d974306..d663d464b 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,5 +1,5 @@ -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 @@ -7,14 +7,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 @@ -22,24 +22,24 @@ 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 @@ -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 diff --git a/requirements_docs.txt b/requirements_docs.txt index 3bf35a170..8734cfc69 100644 --- a/requirements_docs.txt +++ b/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 @@ -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 @@ -26,25 +26,25 @@ 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 @@ -52,8 +52,8 @@ 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 @@ -61,8 +61,8 @@ 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