Skip to content
This repository has been archived by the owner on Apr 17, 2019. It is now read-only.

Update tx-example.py and blocks-query.py #1844

Merged
merged 8 commits into from
Nov 15, 2018

Conversation

igor-egorov
Copy link
Contributor

Signed-off-by: Igor Egorov igor@soramitsu.co.jp

Description of the Change

New Iroha lib in Python gets able to query blocks stream.
Examples tx-example.py and blocks-query.py are updated.

Benefits

Up to date examples.

Possible Drawbacks

None ?

Usage Examples or Tests

Run:
1. Iroha
2. blocks-query.py
3. tx-example.py

Igor Egorov added 3 commits November 12, 2018 16:56
Signed-off-by: Igor Egorov <igor@soramitsu.co.jp>
Signed-off-by: Igor Egorov <igor@soramitsu.co.jp>
Signed-off-by: Igor Egorov <igor@soramitsu.co.jp>
@igor-egorov igor-egorov added needs-review pr awaits review from maintainers SDK Anything related to the client bindings labels Nov 12, 2018
@igor-egorov igor-egorov requested review from nickaleks, lebdron and luckychess and removed request for nickaleks November 12, 2018 13:59
Igor Egorov added 2 commits November 12, 2018 17:25
No need to have separate method for signing blocks queries

Signed-off-by: Igor Egorov <igor@soramitsu.co.jp>
Signed-off-by: Igor Egorov <igor@soramitsu.co.jp>
@@ -211,6 +217,28 @@ def query(self, name, counter=1, creator_account=None, created_time=None, **kwar
internal_query.CopyFrom(message)
return query_wrapper

def blocks_query(self, counter=1, creator_account=None, created_time=None):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

May be just creator_account=self.creator_account, created_time=self.now()? Lines 228-231 could be removed after that.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately, that won't work, since self is not defined at the moment of evaluation.

>>> class A(object):
...     def __init__(self):
...             self.a = 'abc'
...     def x(self, param=self.a):
...             print(param)
...
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "<stdin>", line 4, in A
NameError: name 'self' is not defined

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Python was definitely overrated by me.

example/python/tx-example.py Outdated Show resolved Hide resolved
Signed-off-by: Igor Egorov <igor@soramitsu.co.jp>
Copy link
Contributor

@nickaleks nickaleks left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please fix minor issues

.createdTime(current_time()) \
.transferAsset("admin@test", "userone@domain", "coin#domain", "Some message", "2.00").build()
tx = iroha.transaction([
iroha.command('TransferAsset', src_account_id='admin@test', dest_account_id='userone@domain',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe add formatting?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Applied autopep8

Igor Egorov added 2 commits November 15, 2018 12:20
Signed-off-by: Igor Egorov <igor@soramitsu.co.jp>
Signed-off-by: Igor Egorov <igor@soramitsu.co.jp>
@igor-egorov
Copy link
Contributor Author

Since those files (tx-example.py and blocks-query.py) are not tested in CI, the branch will be merged without waiting for CI.

@igor-egorov igor-egorov merged commit 4841926 into trunk/python_bindings Nov 15, 2018
@igor-egorov igor-egorov deleted the feature/new-tx-example branch November 15, 2018 10:17
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
needs-review pr awaits review from maintainers SDK Anything related to the client bindings
Development

Successfully merging this pull request may close these issues.

None yet

3 participants