Skip to content
This repository was archived by the owner on Jan 13, 2023. It is now read-only.

Commit 08230b0

Browse files
authored
Merge pull request #163 from iotaledger/release/2.0.5
Release/2.0.5
2 parents 540668b + a10903f commit 08230b0

File tree

13 files changed

+763
-471
lines changed

13 files changed

+763
-471
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ python:
66
- '3.6'
77
install:
88
- pip install .
9-
- pip install docutils # Used to check package metadata.
9+
- pip install docutils pygments # Used to check package metadata.
1010
script:
1111
- python setup.py check --strict --metadata --restructuredtext
1212
- nosetests

CONTRIBUTING.rst

Lines changed: 53 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@ We're pretty open about how people contribute to PyOTA, but there are a few thin
2828

2929
- Please do not post support requests here. Use the ``#iota-libs-pyota`` channel on `Slack`_ or post in the `forum`_ to ask for help.
3030
- Please do not propose new API methods here. There are multiple IOTA API libraries out there, and they must all have the same functionality.
31-
- That said, if you have an idea for a new API method, please share it on the ``#developers`` channel in `Slack`_ so that IOTA Foundation members can evaluate it!
31+
32+
- That said, if you have an idea for a new API method, please share it on the ``#developers`` channel in `Slack`_ so that IOTA Foundation members can evaluate it!
3233

3334

3435
Need Some Inspiration?
@@ -54,29 +55,43 @@ Found a bug in the PyOTA code? Great! We can't fix bugs we don't know about; y
5455
Instructions
5556
------------
5657
1. Make sure it really is a PyOTA bug.
57-
- Check the traceback, and see if you can narrow down the cause of the bug.
58-
- If the error is not directly caused by PyOTA, or if you are unable to figure out what is causing the problem, we're still here for for you! Post in the ``#iota-libs-pyota`` channel in `Slack`_ for assistance.
58+
59+
- Check the traceback, and see if you can narrow down the cause of the bug.
60+
- If the error is not directly caused by PyOTA, or if you are unable to figure out what is causing the problem, we're still here for for you! Post in the ``#iota-libs-pyota`` channel in `Slack`_ for assistance.
61+
5962
2. Is it safe to publish details about this bug publicly?
60-
- If the bug is security-related (e.g., could compromise a user's seed if exploited), or if it requires sensitive information in order to reproduce (e.g., the private key for an address), please do not post in in the PyOTA Bug Tracker!
61-
- To report security-related bugs, please contact ``@phx`` directly in `Slack`_.
63+
64+
- If the bug is security-related (e.g., could compromise a user's seed if exploited), or if it requires sensitive information in order to reproduce (e.g., the private key for an address), please do not post in in the PyOTA Bug Tracker!
65+
- To report security-related bugs, please contact ``@phx`` directly in `Slack`_.
66+
6267
3. Is this a known issue?
63-
- Before posting a bug report, check the `PyOTA Bug Tracker`_ to see if there is an existing issue for this bug.
68+
69+
- Before posting a bug report, check the `PyOTA Bug Tracker`_ to see if there is an existing issue for this bug.
70+
6471
4. Create a new issue in the `PyOTA Bug Tracker`_.
65-
- Be sure to include the following information:
66-
- Which version of PyOTA you are using.
67-
- Which version of Python you are using.
68-
- Which operating system you are using.
69-
- Instructions to reproduce the bug.
70-
- The expected behavior, if applicable.
71-
- The full exception traceback, if available.
72-
- If the exception also has a context object, please include it.
72+
73+
- Be sure to include the following information:
74+
75+
- Which version of PyOTA you are using.
76+
- Which version of Python you are using.
77+
- Which operating system you are using.
78+
- Instructions to reproduce the bug.
79+
- The expected behavior, if applicable.
80+
- The full exception traceback, if available.
81+
- If the exception also has a context object, please include it.
82+
7383
5. Please be nice!
74-
- It's frustrating when things don't work the way you expect them to. We promise we didn't put that bug in there on purpose; we're all human, and we all make mistakes sometimes.
84+
85+
- It's frustrating when things don't work the way you expect them to. We promise we didn't put that bug in there on purpose; we're all human, and we all make mistakes sometimes.
86+
7587
6. Please be patient!
76-
- We're committed to making to making PyOTA better, but we've also got jobs and other commitments. We'll respond as soon as we can, but it might be a few days.
88+
89+
- We're committed to making to making PyOTA better, but we've also got jobs and other commitments. We'll respond as soon as we can, but it might be a few days.
90+
7791
7. Please be responsive if follow-up is needed.
78-
- We may request additional information to help us identify/fix the bug. The faster you respond to follow-up comments in your bug report, the sooner we can squash that bug!
79-
- If someone adds a comment to your bug report, it will appear in the `Notifications`_ page in GitHub. You can also configure GitHub to `email you`_ when a new comment is posted.
92+
93+
- We may request additional information to help us identify/fix the bug. The faster you respond to follow-up comments in your bug report, the sooner we can squash that bug!
94+
- If someone adds a comment to your bug report, it will appear in the `Notifications`_ page in GitHub. You can also configure GitHub to `email you`_ when a new comment is posted.
8095

8196
What You Can Expect
8297
-------------------
@@ -93,10 +108,14 @@ If you would like to contribute code to the PyOTA project, this section is for y
93108
Instructions
94109
------------
95110
1. Find an issue in the `PyOTA Bug Tracker`_ to work on.
96-
- If you want to work on a bug or feature that doesn't have a GitHub issue yet, create a new one before starting to work on it. That will give other developers an opportunity to provide feedback and/or suggest changes that will make it integrate better with the rest of the code.
111+
112+
- If you want to work on a bug or feature that doesn't have a GitHub issue yet, create a new one before starting to work on it. That will give other developers an opportunity to provide feedback and/or suggest changes that will make it integrate better with the rest of the code.
113+
97114
2. Create a fork of the PyOTA repository.
98115
3. Create a new branch just for the bug/feature you are working on.
99-
- If you want to work on multiple bugs/features, you can use branches to keep them separate, so that you can submit a separate Pull Request for each one.
116+
117+
- If you want to work on multiple bugs/features, you can use branches to keep them separate, so that you can submit a separate Pull Request for each one.
118+
100119
4. Once you have completed your work, create a Pull Request, ensuring that it meets the requirements listed below.
101120

102121
Requirements for Pull Requests
@@ -110,16 +129,24 @@ If you have any questions, please feel free to post in the ``#iota-libs-pyota``
110129
- Please create Pull Requests against the ``develop`` branch.
111130
- Please limit each Pull Request to a single bugfix/enhancement.
112131
- Please limit the scope of each Pull Request to just the changes needed for that bugfix/enhancement.
113-
- If you would like to refactor existing code, please create separate Pull Request(s) just for the refactoring.
132+
133+
- If you would like to refactor existing code, please create separate Pull Request(s) just for the refactoring.
134+
114135
- Please ensure your code works in all supported versions of Python (this includes versions of Python 2 and Python 3).
115-
- See ``README.rst`` for the list of supported Python versions.
136+
137+
- See ``README.rst`` for the list of supported Python versions.
138+
116139
- Please ensure that your Pull Request includes full test coverage.
117140
- Please do not introduce new dependencies unless absolutely necessary.
118141
- When introducing new classes/functions, please write comprehensive and meaningful docstrings. It should be clear to anyone reading your code what your new class/function does and why it exists.
119-
- Similarly, please be liberal about adding comments to your code. If you have any knowledge and/or had to do any research that would make your code easier to understand, add it as comment. Future developers will be very grateful for the extra context!
120-
- Please ensure that your comments and docstrings use proper English grammar and spelling.
142+
- Similarly, please be liberal about adding comments to your code. If you have any knowledge and/or had to do any research that would make your code easier to understand, add it as comment. Future developers will be very grateful for the extra context!
143+
144+
- Please ensure that your comments and docstrings use proper English grammar and spelling.
145+
121146
- Please ensure that your code conforms to `PEP-8`_.
122-
- You may deviate from PEP-8 if you feel that your changes improve readability, but be aware that you may be asked to justify your decision.
147+
148+
- Much of the existing code is not currently formatted for PEP-8; where practical, you may prefer PEP-8 over being consistent with the existing code.
149+
- We are currently converting the codebase over to PEP-8; `come on over and help us out!`_
123150

124151
What You Can Expect
125152
-------------------
@@ -129,6 +156,7 @@ When you submit a Pull Request, here is what you can expect from the individual
129156
- If any changes are needed, or if we cannot accept your submission, we will provide a respectful and constructive explanation.
130157

131158

159+
.. _come on over and help us out!: https://github.com/iotaledger/iota.lib.py/issues/145
132160
.. _email you: https://help.github.com/articles/managing-notification-delivery-methods/
133161
.. _forum: https://forum.iota.org
134162
.. _help wanted: https://github.com/iotaledger/iota.lib.py/issues?q=is%3Aissue+is%3Aopen+label%3A%22help+wanted%22

README.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ can also build the documentation locally:
9898
make html
9999

100100
.. _Create virtualenv: https://realpython.com/blog/python/python-virtual-environments-a-primer/
101-
.. _Discord: https://discordapp.com/invite/yxve4wu
101+
.. _Discord: https://discord.gg/7Gu2mG5
102102
.. _PyOTA Bug Tracker: https://github.com/iotaledger/iota.lib.py/issues
103103
.. _ReadTheDocs: https://pyota.readthedocs.io/
104104
.. _dedicated forum: https://forum.iota.org/

iota/api.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -417,6 +417,22 @@ def store_transactions(self, trytes):
417417
"""
418418
return core.StoreTransactionsCommand(self.adapter)(trytes=trytes)
419419

420+
def were_addresses_spent_from(self, addresses):
421+
# type: (Iterable[Address]) -> dict
422+
"""
423+
Check if a list of addresses was ever spent from, in the current
424+
epoch, or in previous epochs.
425+
426+
:param addresses:
427+
List of addresses to check.
428+
429+
References:
430+
- https://iota.readme.io/docs/wereaddressesspentfrom
431+
"""
432+
return core.WereAddressesSpentFromCommand(self.adapter)(
433+
addresses = addresses,
434+
)
435+
420436

421437
class Iota(StrictIota):
422438
"""

iota/bin/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
from getpass import getpass as secure_input
99
from io import StringIO
1010
from sys import exit
11-
from typing import Optional, Text
11+
from typing import Any, Optional, Text
1212

1313
from six import text_type, with_metaclass
1414

@@ -39,7 +39,7 @@ def __init__(self, stdout=sys.stdout, stderr=sys.stderr, stdin=sys.stdin):
3939

4040
@abstract_method
4141
def execute(self, api, **arguments):
42-
# type: (Iota, ...) -> Optional[int]
42+
# type: (Iota, **Any) -> Optional[int]
4343
"""
4444
Executes the command and (optionally) returns an exit code (used by
4545
the shell to determine if the application exited cleanly).

iota/bin/repl.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -89,24 +89,26 @@ def _start_repl(api):
8989
"""
9090
Starts the REPL.
9191
"""
92-
_banner = (
92+
banner = (
9393
'IOTA API client for {uri} ({testnet}) initialized as variable `api`.\n'
9494
'Type `help(api)` for list of API commands.'.format(
9595
testnet = 'testnet' if api.testnet else 'mainnet',
9696
uri = api.adapter.get_uri(),
9797
)
9898
)
9999

100+
scope_vars = {'api': api}
101+
100102
try:
101103
# noinspection PyUnresolvedReferences
102104
import IPython
103105
except ImportError:
104106
# IPython not available; use regular Python REPL.
105107
from code import InteractiveConsole
106-
InteractiveConsole(locals={'api': api}).interact(_banner)
108+
InteractiveConsole(locals=scope_vars).interact(banner, '')
107109
else:
108-
# Launch IPython REPL.
109-
IPython.embed(header=_banner)
110+
print(banner)
111+
IPython.start_ipython(argv=[], user_ns=scope_vars)
110112

111113

112114
def main():

iota/commands/core/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,4 @@
2525
from .interrupt_attaching_to_tangle import *
2626
from .remove_neighbors import *
2727
from .store_transactions import *
28+
from .were_addresses_spent_from import *
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# coding=utf-8
2+
from __future__ import absolute_import, division, print_function, \
3+
unicode_literals
4+
5+
import filters as f
6+
7+
from iota.commands import FilterCommand, RequestFilter
8+
from iota.filters import AddressNoChecksum
9+
10+
__all__ = [
11+
'WereAddressesSpentFromCommand',
12+
]
13+
14+
15+
class WereAddressesSpentFromCommand(FilterCommand):
16+
"""
17+
Executes `wereAddressesSpentFrom` command.
18+
19+
See :py:meth:`iota.api.StrictIota.were_addresses_spent_from`.
20+
"""
21+
command = 'wereAddressesSpentFrom'
22+
23+
def get_request_filter(self):
24+
return WereAddressesSpentFromRequestFilter()
25+
26+
def get_response_filter(self):
27+
pass
28+
29+
30+
class WereAddressesSpentFromRequestFilter(RequestFilter):
31+
def __init__(self):
32+
super(WereAddressesSpentFromRequestFilter, self).__init__(
33+
{
34+
'addresses': (
35+
f.Required
36+
| f.Array
37+
| f.FilterRepeater(
38+
f.Required
39+
| AddressNoChecksum()
40+
| f.Unicode(encoding='ascii', normalize=False)
41+
)
42+
),
43+
}
44+
)

iota/crypto/types.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -189,10 +189,10 @@ def get_digest(self):
189189
sponge.absorb(key_fragment)
190190
sponge.squeeze(hash_trits)
191191

192-
fragment_start = i * FRAGMENT_LENGTH
193-
fragment_end = fragment_start + FRAGMENT_LENGTH
192+
fragment_hash_start = i * HASH_LENGTH
193+
fragment_hash_end = fragment_hash_start + HASH_LENGTH
194194

195-
digest[fragment_start:fragment_end] = hash_trits
195+
digest[fragment_hash_start:fragment_hash_end] = hash_trits
196196

197197
return Digest(TryteString.from_trits(digest), self.key_index)
198198

0 commit comments

Comments
 (0)