Skip to content

Commit ae7c969

Browse files
committed
Merge branch 'release/0.1.20'
2 parents 886806e + bb5ba9d commit ae7c969

14 files changed

+155
-34
lines changed

.travis.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
dist: trusty
12
language: python
23
sudo: false
34
python:
@@ -14,5 +15,13 @@ install:
1415
- pip install tox-travis codecov
1516
script:
1617
- tox
18+
- sed -i 's/filename="/filename=".\//g' coverage.xml
19+
- sonar-scanner
1720
after_success:
1821
- codecov
22+
23+
addons:
24+
sonarcloud:
25+
organization: bitshares
26+
token:
27+
secure: "dSFPBeC5Gr9oiU0weJY3rJXfc68uo2zvfRMcYRSQdqruAtrNqqmJCew0rANDtJPLkKxfIzbJSkokKCvt3f1SXbIOnbuAv/MN2TKDZkqZyve3AdMgYifepHwzK14KWO79ga7gaBKa6CxayZbOkX0BWciOO+5QFlBtmYdov3JpxboymZH9jJKdRs2C3mrIfGQG48u1qaFNaFFRKCvlCY0pXM7MbxFf1C+EADJC1CeR5yHQ2Zd3K6dIh+JpiZ9b1DbxjwWeRC7fOQ9KFV6I8I+GPPjKsS50/96m7SPlnriogYKx4DXRD85by2HfRUUv2bsDXzz4kLo2KR3c358lyhhh3qZBmJS/fJEq+s9Tmqcxb4ssMmht6tpQKnc6NWN4Z/wK0+nyBqFZryZnzO863HRu6GM1d6Mp7q976z1u5UWgPi2D5Y2ulZNfan4T+NVZViTM/XD8Mj9tOpml1A1LbDt3lgHulV9vUD1Hd/TzWh546ydN3hCnGbeuSDY2N5GKNptOAG48sXWPgGc8y8X0yBY+0c3oo0JaMIP1e7IIXEcmq2LI/gF8C0feTKMbBFQSG8kAHHJhOLrV5o9aUFyWK1YT4AADRZrUKXlRaL6rnA0tXDxuGpwYkaB6zbA/c2l2pxsysO5REpbIgn1o6emo5XJ9flXMszwmDqvoio0XaB4JcJY="

CONTRIBUTING.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,9 +105,9 @@ everyone is a beginner at first
105105

106106
Your patch should follow the same conventions & pass the same code
107107
quality checks as the rest of the project.
108-
[Codeclimate](https://codeclimate.com/github/xeroc/python-bitshares)
108+
[Codeclimate](https://codeclimate.com/github/bitshares/python-bitshares)
109109
will give you feedback in this regard. You can check & fix codeclimate's
110-
feedback by running it locally using [Codeclimate's CLI](https://codeclimate.com/github/xeroc/python-bitshares), via
110+
feedback by running it locally using [Codeclimate's CLI](https://codeclimate.com/github/bitshares/python-bitshares), via
111111
`codeclimate analyze`.
112112

113113
### 7. Make a Pull Request

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ clean-pyc:
1414
find . -name '*~' -exec rm -f {} +
1515

1616
lint:
17-
flake8 --ignore=E501,F401 bitsharesapi bitsharesbase examples
17+
flake8 bitsharesapi bitsharesbase examples
1818

1919
test:
2020
python3 setup.py test

README.md

Lines changed: 15 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,23 @@
11
# Python Library for BitShares
22

33
![](https://img.shields.io/pypi/v/bitshares.svg?style=for-the-badge)
4-
![](https://img.shields.io/github/release/xeroc/python-bitshares.svg?style=for-the-badge)
5-
![](https://img.shields.io/github/downloads/xeroc/python-bitshares/total.svg?style=for-the-badge)
4+
![](https://img.shields.io/github/release/bitshares/python-bitshares.svg?style=for-the-badge)
5+
![](https://img.shields.io/github/downloads/bitshares/python-bitshares/total.svg?style=for-the-badge)
66
![](https://img.shields.io/pypi/pyversions/bitshares.svg?style=for-the-badge)
77
![](https://img.shields.io/pypi/l/bitshares.svg?style=for-the-badge)
88
![](https://cla-assistant.io/readme/badge/bitshares/python-bitshares)
99

1010
**Stable**
1111

1212
[![docs master](https://readthedocs.org/projects/python-bitshares/badge/?version=latest)](http://python-bitshares.readthedocs.io/en/latest/)
13-
[![Travis master](https://travis-ci.org/xeroc/python-bitshares.png?branch=master)](https://travis-ci.org/xeroc/python-bitshares)
14-
[![codecov](https://codecov.io/gh/xeroc/python-bitshares/branch/master/graph/badge.svg)](https://codecov.io/gh/xeroc/python-bitshares)
13+
[![Travis master](https://travis-ci.org/bitshares/python-bitshares.png?branch=master)](https://travis-ci.org/bitshares/python-bitshares)
14+
[![codecov](https://codecov.io/gh/bitshares/python-bitshares/branch/master/graph/badge.svg)](https://codecov.io/gh/bitshares/python-bitshares)
1515

1616
**Develop**
1717

1818
[![docs develop](https://readthedocs.org/projects/python-bitshares/badge/?version=develop)](http://python-bitshares.readthedocs.io/en/develop/)
19-
[![Travis develop](https://travis-ci.org/xeroc/python-bitshares.png?branch=develop)](https://travis-ci.org/xeroc/python-bitshares)
20-
[![codecov develop](https://codecov.io/gh/xeroc/python-bitshares/branch/develop/graph/badge.svg)](https://codecov.io/gh/xeroc/python-bitshares)
19+
[![Travis develop](https://travis-ci.org/bitshares/python-bitshares.png?branch=develop)](https://travis-ci.org/bitshares/python-bitshares)
20+
[![codecov develop](https://codecov.io/gh/bitshares/python-bitshares/branch/develop/graph/badge.svg)](https://codecov.io/gh/bitshares/python-bitshares)
2121

2222
---
2323

@@ -28,22 +28,19 @@ Visit the [pybitshares website](http://docs.pybitshares.com/en/latest/) for in d
2828
## Installation
2929

3030
### Install with pip3:
31-
```
32-
$ sudo apt-get install libffi-dev libssl-dev python-dev python3-dev python3-pip
33-
$ pip3 install bitshares
34-
```
31+
32+
$ sudo apt-get install libffi-dev libssl-dev python-dev python3-dev python3-pip
33+
$ pip3 install bitshares
3534

3635
### Manual installation:
37-
```
38-
$ git clone https://github.com/xeroc/python-bitshares/
39-
$ cd python-bitshares
40-
$ python3 setup.py install --user
41-
```
36+
37+
$ git clone https://github.com/bitshares/python-bitshares/
38+
$ cd python-bitshares
39+
$ python3 setup.py install --user
4240

4341
### Upgrade
44-
```
45-
$ pip3 install --user --upgrade
46-
```
42+
43+
$ pip3 install --user --upgrade bitshares
4744

4845
## Contributing
4946

bitshares/bitshares.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
from bitsharesapi.bitsharesnoderpc import BitSharesNodeRPC
55
from bitsharesbase.account import PublicKey
66
from bitsharesbase import operations
7+
from .instance import set_shared_blockchain_instance, shared_blockchain_instance
78
from .asset import Asset
89
from .account import Account
910
from .amount import Amount
@@ -327,6 +328,20 @@ def unlock(self, *args, **kwargs):
327328
"""
328329
return self.wallet.unlock(*args, **kwargs)
329330

331+
# -------------------------------------------------------------------------
332+
# Shared instance interface
333+
# -------------------------------------------------------------------------
334+
def set_shared_instance(self):
335+
""" This method allows to set the current instance as default
336+
"""
337+
set_shared_blockchain_instance(self)
338+
339+
@classmethod
340+
def get_shared_instance(cls, self):
341+
""" This interface allows to obtain the default instance
342+
"""
343+
return shared_blockchain_instance()
344+
330345
# -------------------------------------------------------------------------
331346
# Transaction Buffers
332347
# -------------------------------------------------------------------------

bitshares/blockchainobject.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,6 @@ def __init__(
6868
self,
6969
data,
7070
klass=None,
71-
space_id=1,
72-
object_id=None,
7371
lazy=False,
7472
use_cache=True,
7573
*args,
@@ -182,3 +180,13 @@ def __contains__(self, key):
182180
def __repr__(self):
183181
return "<%s %s>" % (
184182
self.__class__.__name__, str(self.identifier))
183+
184+
185+
class Object(BlockchainObject):
186+
187+
def refresh(self):
188+
dict.__init__(
189+
self,
190+
self.blockchain.rpc.get_object(self.identifier),
191+
blockchain_instance=self.blockchain
192+
)

bitshares/storage.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -357,6 +357,14 @@ def delete(self, key):
357357
cursor.execute(*query)
358358
connection.commit()
359359

360+
def wipe(self):
361+
""" Delete all configuration from the configuration store
362+
"""
363+
query = ("DELETE FROM %s " % (self.__tablename__) +
364+
"WHERE key<>?",
365+
(MasterPassword.config_key,))
366+
self.sql_execute(query)
367+
360368
def __iter__(self):
361369
return iter(self.items())
362370

bitshares/transactionbuilder.py

Lines changed: 30 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
from .account import Account
2+
from .asset import Asset
23
from bitsharesbase.objects import Operation
34
from bitsharesbase.account import PrivateKey, PublicKey
45
from bitsharesbase.signedtransactions import Signed_Transaction
@@ -216,24 +217,46 @@ def appendSigner(self, account, permission):
216217

217218
# Let's define a helper function for recursion
218219
def fetchkeys(account, perm, level=0, required_treshold=1):
220+
221+
# Do not travel recursion more than 2 levels
219222
if level > 2:
220223
return []
224+
221225
r = []
226+
# Let's go through all *keys* of the account
222227
for authority in account[perm]["key_auths"]:
223228
try:
229+
# Try obtain the private key from wallet
224230
wif = self.blockchain.wallet.getPrivateKeyForPublicKey(
225231
authority[0])
226-
r.append([wif, authority[1]])
232+
if wif:
233+
r.append([wif, authority[1]])
234+
# If we found a key for account, we add it
235+
# to signing_accounts to be sure we do not resign
236+
# another operation with the same account/wif
237+
self.signing_accounts.append(account)
227238
except Exception:
228239
pass
229240

241+
# Test if we reached threshold already
242+
if sum([x[1] for x in r]) >= required_treshold:
243+
break
244+
245+
# Let's see if we still need to go through accounts
230246
if sum([x[1] for x in r]) < required_treshold:
231247
# go one level deeper
232248
for authority in account[perm]["account_auths"]:
249+
# Let's see if we can find keys for an account in
250+
# account_auths
251+
# This is recursive with a limit at level 2 (see above)
233252
auth_account = Account(
234253
authority[0], blockchain_instance=self.blockchain)
235254
r.extend(fetchkeys(auth_account, perm, level + 1, required_treshold))
236255

256+
# Test if we reached threshold already and break
257+
if sum([x[1] for x in r]) >= required_treshold:
258+
break
259+
237260
return r
238261

239262
# Now let's actually deal with the accounts
@@ -247,13 +270,13 @@ def fetchkeys(account, perm, level=0, required_treshold=1):
247270
)
248271
# ... or should we rather obtain the keys from an account name
249272
else:
250-
account = Account(account, blockchain_instance=self.blockchain)
251-
required_treshold = account[permission]["weight_threshold"]
252-
keys = fetchkeys(account, permission, required_treshold=required_treshold)
273+
accountObj = Account(account, blockchain_instance=self.blockchain)
274+
required_treshold = accountObj[permission]["weight_threshold"]
275+
keys = fetchkeys(accountObj, permission, required_treshold=required_treshold)
253276
# If we couldn't find an active key, let's try overwrite it
254277
# with an owner key
255278
if not keys and permission != "owner":
256-
keys.extend(fetchkeys(account, "owner", required_treshold=required_treshold))
279+
keys.extend(fetchkeys(accountObj, "owner", required_treshold=required_treshold))
257280
for x in keys:
258281
self.wifs.add(x[0])
259282

@@ -275,6 +298,8 @@ def set_fee_asset(self, fee_asset):
275298
from .amount import Amount
276299
if isinstance(fee_asset, Amount):
277300
self.fee_asset_id = fee_asset["id"]
301+
elif isinstance(fee_asset, Asset):
302+
self.fee_asset_id = fee_asset["id"]
278303
elif fee_asset:
279304
self.fee_asset_id = fee_asset
280305
else:

bitshares/worker.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ def post_format(self):
2323
if isinstance(self["work_end_date"], str):
2424
self["work_end_date"] = formatTimeString(self["work_end_date"])
2525
self["work_begin_date"] = formatTimeString(self["work_begin_date"])
26+
self["daily_pay"] = int(self["daily_pay"])
2627

2728
def refresh(self):
2829
worker = self.blockchain.rpc.get_object(self.identifier)

bitsharesapi/exceptions.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import re
2-
from grapheneapi.graphenewsrpc import RPCError
2+
from grapheneapi.exceptions import RPCError
33

44

55
def decodeRPCErrorMsg(e):

setup.cfg

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ description-file = README.md
55
test=pytest
66

77
[coverage:run]
8-
#source=bitshares*
8+
source=bitsharesbase,bitsharesapi,bitshares
9+
branch=True
910
omit=
1011
tests/*
1112
.tox/*
@@ -15,6 +16,16 @@ omit=
1516
include=bitshares*
1617
ignore_errors=True
1718
show_missing=True
19+
exclude_lines =
20+
pragma: no cover
21+
def __repr__
22+
if self.debug:
23+
if settings.DEBUG
24+
raise AssertionError
25+
raise NotImplementedError
26+
if 0:
27+
if __name__ == .__main__.:
28+
if sys.version > '3':
1829

1930
[flake8]
2031
ignore = E501,F401
@@ -26,3 +37,12 @@ exclude =
2637
# The conf file is mostly autogenerated, ignore it
2738
docs/conf.py,
2839
max-complexity = 15
40+
41+
# [nosetests]
42+
# with-coverage=1
43+
# with-xunit=1
44+
# #cover-branches=1
45+
# cover-xml=1
46+
# cover-inclusive=1
47+
# detailed-errors=1
48+
# cover-package=graphenebase,grapheneapi,graphenestorage,graphene

setup.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,19 +11,19 @@
1111
ascii = codecs.lookup('ascii')
1212
codecs.register(lambda name, enc=ascii: {True: enc}.get(name == 'mbcs'))
1313

14-
VERSION = '0.1.19'
14+
VERSION = '0.1.20'
1515

1616
setup(
1717
name='bitshares',
1818
version=VERSION,
1919
description='Python library for bitshares',
2020
long_description=open('README.md').read(),
21-
download_url='https://github.com/xeroc/python-bitshares/tarball/' + VERSION,
21+
download_url='https://github.com/bitshares/python-bitshares/tarball/' + VERSION,
2222
author='Fabian Schuh',
2323
author_email='[email protected]',
2424
maintainer='Fabian Schuh',
2525
maintainer_email='[email protected]',
26-
url='http://www.github.com/xeroc/python-bitshares',
26+
url='http://www.github.com/bitshares/python-bitshares',
2727
keywords=['bitshares', 'library', 'api', 'rpc'],
2828
packages=[
2929
"bitshares",

sonar-project.properties

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# Metadata
2+
sonar.projectKey=python-bitshares
3+
sonar.projectName=Python BitShares Library
4+
sonar.projectVersion=1.0
5+
sonar.organization=bitshares
6+
7+
# Upload to sonar cloud
8+
sonar.host.url=https://sonarcloud.io
9+
10+
# Language
11+
sonar.language=py
12+
13+
# Sources
14+
sonar.sources=bitshares,bitsharesapi,bitsharesbase
15+
16+
# Unit tests
17+
sonar.tests=./tests/
18+
19+
# Linter
20+
#sonar.python.pylint=/usr/local/bin/pylint
21+
#sonar.python.pylint_config=.pylintrc
22+
#sonar.python.pylint.reportPath=pylint-report.txt
23+
24+
sonar.links.homepage=https://bitshares.org
25+
sonar.links.ci=https://travis-ci.org/bitshares/python-bitshares/
26+
sonar.links.issue=https://github.com/bitshares/python-bitshares/issues
27+
sonar.links.scm=https://github.com/bitshares/python-bitshares/tree/master
28+
29+
sonar.exclusions=htmlcov/*,docs/*,build/*,dist/*,*.py,tests/*,graphene*/*
30+
31+
# coverage
32+
# sonar.python.xunit.reportPath=test-reports/*.xml
33+
#sonar.python.coverage.reportPath=coverage.xml
34+
35+
sonar.python.xunit.reportPath=nosetests.xml
36+
sonar.python.coverage.reportPath=coverage.xml
37+
#sonar.python.coveragePlugin=cobertura

tox.ini

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,10 @@ skip_missing_interpreters = true
55
[testenv]
66
deps=-rrequirements-test.txt
77
commands=
8-
coverage run -a setup.py test
8+
coverage run setup.py test
99
coverage report
1010
coverage html
11+
coverage xml -i
1112

1213
[testenv:lint]
1314
deps=

0 commit comments

Comments
 (0)