Skip to content

Commit

Permalink
Merge branch 'release/1.1.19'
Browse files Browse the repository at this point in the history
  • Loading branch information
xeroc committed Aug 20, 2019
2 parents ba3702a + fdf7755 commit 6c537a3
Show file tree
Hide file tree
Showing 15 changed files with 96 additions and 33 deletions.
6 changes: 6 additions & 0 deletions .changes/1.1.18.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[
{
"description": "Starting version for semversioner",
"type": "patch"
}
]
6 changes: 6 additions & 0 deletions .changes/1.1.19.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[
{
"description": "First release after semversioner",
"type": "patch"
}
]
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -65,3 +65,5 @@ target/
.ropeproject/
.pytest_cache/
.scannerwork/

.changes/next-release
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Changelog
Note: version releases in the 0.x.y range may introduce breaking changes.

## 1.1.19

- patch: First release after semversioner

## 1.1.18

- patch: Starting version for semversioner

23 changes: 20 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,11 @@ check:
python3 setup.py check

dist:
python3 setup.py sdist upload -r pypi
python3 setup.py bdist_wheel upload
python3 setup.py sdist bdist_wheel
python3 setup.py bdist_wheel

upload:
twine upload --repository-url https://upload.pypi.org/legacy/ dist/*

docs:
sphinx-apidoc -d 6 -e -f -o docs . *.py tests
Expand All @@ -46,5 +49,19 @@ docs:
authors:
git shortlog -e -s -n > AUTHORS

semver: semver-release semver-updates

semver-release:
semversioner release

semver-updates:
semversioner changelog > CHANGELOG.md
$(eval CURRENT_VERSION = $(shell semversioner current-version))
sed -i "s/^__version__.*/__version__ = \"$(CURRENT_VERSION)\"/" setup.py
git add .changes setup.py CHANGELOG.md
git commit -m "semverioner release updates" --no-verify
git flow release start $(CURRENT_VERSION)
git flow release finish $(CURRENT_VERSION)

prerelease: test docs authors
release: clean check dist git
release: semver clean check dist upload git
2 changes: 1 addition & 1 deletion docs/requirements.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
graphenelib==1.1.17
graphenelib==1.1.18
24 changes: 12 additions & 12 deletions graphenecommon/amount.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ def __neg__(self):
def __add__(self, other):
a = self.copy()
if isinstance(other, Amount):
assert other["asset"] == self["asset"]
assert other["asset"]["id"] == self["asset"]["id"]
a["amount"] += other["amount"]
else:
a["amount"] += float(other)
Expand All @@ -196,7 +196,7 @@ def __add__(self, other):
def __sub__(self, other):
a = self.copy()
if isinstance(other, Amount):
assert other["asset"] == self["asset"]
assert other["asset"]["id"] == self["asset"]["id"]
a["amount"] -= other["amount"]
else:
a["amount"] -= float(other)
Expand All @@ -205,7 +205,7 @@ def __sub__(self, other):
def __mul__(self, other):
a = self.copy()
if isinstance(other, Amount):
assert other["asset"] == self["asset"]
assert other["asset"]["id"] == self["asset"]["id"]
a["amount"] *= other["amount"]
else:
a["amount"] *= other
Expand Down Expand Up @@ -253,23 +253,23 @@ def __iadd__(self, other):

def __isub__(self, other):
if isinstance(other, Amount):
assert other["asset"] == self["asset"]
assert other["asset"]["id"] == self["asset"]["id"]
self["amount"] -= other["amount"]
else:
self["amount"] -= other
return self

def __imul__(self, other):
if isinstance(other, Amount):
assert other["asset"] == self["asset"]
assert other["asset"]["id"] == self["asset"]["id"]
self["amount"] *= other["amount"]
else:
self["amount"] *= other
return self

def __idiv__(self, other):
if isinstance(other, Amount):
assert other["asset"] == self["asset"]
assert other["asset"]["id"] == self["asset"]["id"]
return self["amount"] / other["amount"]
else:
self["amount"] /= other
Expand All @@ -295,42 +295,42 @@ def __ipow__(self, other):

def __lt__(self, other):
if isinstance(other, Amount):
assert other["asset"] == self["asset"]
assert other["asset"]["id"] == self["asset"]["id"]
return self["amount"] < other["amount"]
else:
return self["amount"] < float(other or 0)

def __le__(self, other):
if isinstance(other, Amount):
assert other["asset"] == self["asset"]
assert other["asset"]["id"] == self["asset"]["id"]
return self["amount"] <= other["amount"]
else:
return self["amount"] <= float(other or 0)

def __eq__(self, other):
if isinstance(other, Amount):
assert other["asset"] == self["asset"]
assert other["asset"]["id"] == self["asset"]["id"]
return self["amount"] == other["amount"]
else:
return self["amount"] == float(other or 0)

def __ne__(self, other):
if isinstance(other, Amount):
assert other["asset"] == self["asset"]
assert other["asset"]["id"] == self["asset"]["id"]
return self["amount"] != other["amount"]
else:
return self["amount"] != float(other or 0)

def __ge__(self, other):
if isinstance(other, Amount):
assert other["asset"] == self["asset"]
assert other["asset"]["id"] == self["asset"]["id"]
return self["amount"] >= other["amount"]
else:
return self["amount"] >= float(other or 0)

def __gt__(self, other):
if isinstance(other, Amount):
assert other["asset"] == self["asset"]
assert other["asset"]["id"] == self["asset"]["id"]
return self["amount"] > other["amount"]
else:
return self["amount"] > float(other or 0)
Expand Down
4 changes: 4 additions & 0 deletions graphenecommon/blockchain.py
Original file line number Diff line number Diff line change
Expand Up @@ -291,3 +291,7 @@ def get_all_accounts(self, start="", stop="", steps=1e3, **kwargs):
lastname = ret[-1][0]
if len(ret) < steps:
raise StopIteration

@property
def participation_rate(self):
return bin(int(self.info()["recent_slots_filled"])).count("1") / 128
8 changes: 8 additions & 0 deletions graphenecommon/blockchainobject.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,14 @@ def cache(self, key):
"""
self.store(self, key)

def __getitem__(self, key):
""" Since we've overwriten __getitem__ in cache and inherit from there,
we need to make sure we use `list` here instead of `dict`.
"""
if not self._fetched:
self.refresh()
return list.__getitem__(self, key)


class BlockchainObject(Caching, dict):
""" This class deals with objects from graphene-based blockchains.
Expand Down
4 changes: 3 additions & 1 deletion graphenecommon/price.py
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,9 @@ def invert(self):
self["base"] = tmp
if "for_sale" in self and self["for_sale"]:
self["for_sale"] = self.amount_class(
self["for_sale"]["amount"] * self["price"], self["base"]["symbol"]
self["for_sale"]["amount"] * self["price"],
self["base"]["symbol"],
blockchain_instance=self.blockchain,
)
return self

Expand Down
14 changes: 8 additions & 6 deletions graphenecommon/transactionbuilder.py
Original file line number Diff line number Diff line change
Expand Up @@ -265,13 +265,15 @@ def _fetchkeys(self, account, perm, level=0, required_treshold=1):
auth_account = self.account_class(
authority[0], blockchain_instance=self.blockchain
)
r.extend(
self._fetchkeys(auth_account, perm, level + 1, required_treshold)
)
required_treshold = auth_account[perm]["weight_threshold"]
keys = self._fetchkeys(auth_account, perm, level + 1, required_treshold)

for key in keys:
r.append(key)

# Test if we reached threshold already and break
if sum([x[1] for x in r]) >= required_treshold:
break
# Test if we reached threshold already and break
if sum([x[1] for x in r]) >= required_treshold:
break

return r

Expand Down
5 changes: 5 additions & 0 deletions graphenecommon/vesting.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,17 @@ def claimable(self):
/ float(p["vesting_seconds"])
)
if float(p["vesting_seconds"]) > 0.0
and float(self["balance"]["amount"])
else 1
)
return (
self.amount_class(self["balance"], blockchain_instance=self.blockchain)
* ratio
)
elif self["policy"][0] == 2:
return self.amount_class(
self["balance"], blockchain_instance=self.blockchain
)
else:
raise NotImplementedError("This policy isn't implemented yet")

Expand Down
10 changes: 5 additions & 5 deletions requirements-test.txt
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
pyyaml==5.1
pyyaml==5.1.1
dateutils==0.6.6

# Unit testing
pytest==4.4.1
pytest==4.6.3
pytest-mock==1.10.4
pytest-benchmark==3.2.2
coverage==4.5.3
mock==2.0.0
mock==3.0.5

# Code style
flake8==3.7.7
# black
isort==4.3.17
pre-commit==1.15.2
isort==4.3.20
pre-commit==1.17.0

# For advanced unittesting
secp256k1
4 changes: 2 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
ecdsa==0.13.2
requests==2.21.0
requests==2.22.0
websocket-client==0.56.0
pylibscrypt==1.8.0
pycryptodome==3.8.1
pycryptodome==3.8.2
appdirs==1.4.3
scrypt==0.8.13
# secp256k1==0.13.2
6 changes: 3 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@

from setuptools import setup

VERSION = "1.1.18"
__version__ = "1.1.19"
URL = "https://github.com/xeroc/python-graphenelib"

setup(
name="graphenelib",
version=VERSION,
version=__version__,
description="Python library for graphene-based blockchains",
long_description=open("README.md").read(),
download_url="{}/tarball/{}".format(URL, VERSION),
download_url="{}/tarball/{}".format(URL, __version__),
author="Fabian Schuh",
author_email="[email protected]",
maintainer="Fabian Schuh",
Expand Down

0 comments on commit 6c537a3

Please sign in to comment.