Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/develop' into feature/asyncio
Browse files Browse the repository at this point in the history
  • Loading branch information
bitphage committed Oct 22, 2019
2 parents d88e394 + 24d602b commit 2b8ed92
Show file tree
Hide file tree
Showing 33 changed files with 619 additions and 182 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"
}
]
6 changes: 6 additions & 0 deletions .changes/1.1.20.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[
{
"description": "updates from pyup",
"type": "patch"
}
]
6 changes: 6 additions & 0 deletions .changes/1.2.0.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[
{
"description": "Use the last irreversible block for tapos ref params",
"type": "minor"
}
]
10 changes: 5 additions & 5 deletions AUTHORS
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
685 Fabian Schuh <[email protected]>
735 Fabian Schuh <[email protected]>
154 Fabian Schuh <[email protected]>
76 Fabian Schuh <[email protected]>
24 pyup-bot <[email protected]>
90 Fabian Schuh <[email protected]>
48 pyup-bot <[email protected]>
20 gileadmcgee <[email protected]>
10 jhtitor <[email protected]>
10 user name <[email protected]>
9 jhtitor <[email protected]>
8 Maurits <[email protected]>
5 Vladimir Kamarzin <[email protected]>
4 bitcrab <[email protected]>
3 Boombastic <[email protected]>
3 Holger Nahrstaedt <[email protected]>
Expand All @@ -19,7 +20,6 @@
1 Best Buy #2 <[email protected]>
1 Holger Nahrstaedt <[email protected]>
1 Pavel Martynov <[email protected]>
1 Vladimir Kamarzin <[email protected]>
1 iHashFury <[email protected]>
1 jhtitor <[email protected]>
1 linouxis9 <[email protected]>
Expand Down
19 changes: 19 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Changelog
Note: version releases in the 0.x.y range may introduce breaking changes.

## 1.2.0

- minor: Use the last irreversible block for tapos ref params

## 1.1.20

- patch: updates from pyup

## 1.1.19

- patch: First release after semversioner

## 1.1.18

- patch: Starting version for semversioner

33 changes: 29 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,40 @@ 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
make -C docs clean html

docs_store:
git add docs
-git commit -m "Updating docs/"

authors:
git shortlog -e -s -n > AUTHORS

prerelease: test docs authors
release: clean check dist git
authors_store:
git add AUTHORS
-git commit -m "Updating 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 docs_store authors authors_store
release: prerelease semver clean build check dist upload git
4 changes: 2 additions & 2 deletions docs/modules.rst
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
python-graphenelib
==================
python-graphene
===============

.. toctree::
:maxdepth: 6
Expand Down
2 changes: 1 addition & 1 deletion docs/requirements.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
graphenelib==1.1.12
graphenelib==1.1.18
16 changes: 12 additions & 4 deletions grapheneapi/rpc.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,11 @@ def setup_proxy(self, options):
self.proxy_user = options.pop("proxy_user", None)
self.proxy_pass = options.pop("proxy_pass", None)
self.proxy_rdns = False
log.info(
"Using proxy %s:%d %s" % (self.proxy_host, self.proxy_port, self.proxy_type)
)
if self.proxy_host:
log.info(
"Using proxy %s:%d %s"
% (self.proxy_host, self.proxy_port, self.proxy_type)
)

def get_proxy_url(self): # pragma: no cover
if not self.proxy_host:
Expand Down Expand Up @@ -101,7 +103,13 @@ def parse_response(self, query):
if "detail" in ret["error"]:
raise RPCError(ret["error"]["detail"])
else:
raise RPCError(ret["error"]["message"])
if ret["error"]["message"] == "Execution error":
text = ret["error"]["data"]["stack"][0]["format"]
data = ret["error"]["data"]["stack"][0]["data"]
text = text.replace("${", "{")
raise RPCError(text.format(**data))
else:
raise RPCError(ret["error"]["message"])
else:
return ret["result"]

Expand Down
12 changes: 5 additions & 7 deletions graphenebase/transactions.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,15 @@
timeformat = "%Y-%m-%dT%H:%M:%S%Z"


def getBlockParams(ws):
def getBlockParams(ws, use_head_block=False):
""" Auxiliary method to obtain ``ref_block_num`` and
``ref_block_prefix``. Requires a websocket connection to a
witness node!
"""
dynBCParams = ws.get_dynamic_global_properties()
ref_block_num = dynBCParams["head_block_number"] & 0xFFFF
ref_block_prefix = struct.unpack_from(
"<I", unhexlify(dynBCParams["head_block_id"]), 4
)[0]
return ref_block_num, ref_block_prefix
raise DeprecationWarning(
"This method shouldn't be called anymore. It is part of "
"transactionbuilder now"
)


def formatTimeFromNow(secs=0):
Expand Down
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
21 changes: 7 additions & 14 deletions graphenecommon/chain.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# -*- coding: utf-8 -*-
import logging
from graphenestorage import SqliteConfigurationStore
from .instance import SharedInstance

log = logging.getLogger(__name__)

Expand Down Expand Up @@ -140,19 +139,13 @@ def unlock(self, *args, **kwargs):
def set_shared_instance(self):
""" This method allows to set the current instance as default
"""
SharedInstance.instance = self

def set_shared_config(self, config):
""" This allows to set a config that will be used when calling
``shared_blockchain_instance`` and allows to define the configuration
without requiring to actually create an instance
"""
assert isinstance(config, dict)
SharedInstance.config.update(config)
# if one is already set, delete
if SharedInstance.instance:
self.clear_cache()
SharedInstance.instance = None
# self._sharedInstance.instance = self
log.warning(
DeprecationWarning(
"set_shared_instance in chaininstance is no longer supported. "
"This interface no longer exists, please use .instance.set_shared_instance() instead."
)
)

# -------------------------------------------------------------------------
# General transaction/operation stuff
Expand Down
Loading

0 comments on commit 2b8ed92

Please sign in to comment.