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

Commit 569b052

Browse files
authored
Merge pull request #22 from iotaledger/release/1.1.0
1.1.0
2 parents adb1c27 + cd51ca4 commit 569b052

File tree

19 files changed

+1198
-404
lines changed

19 files changed

+1198
-404
lines changed

examples/sandbox.py

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
# coding=utf-8
2+
from __future__ import absolute_import, division, print_function, \
3+
unicode_literals
4+
5+
from iota import *
6+
from iota.adapter.sandbox import SandboxAdapter
7+
8+
9+
# Create the API object.
10+
iota =\
11+
Iota(
12+
# To use sandbox mode, inject a ``SandboxAdapter``.
13+
adapter = SandboxAdapter(
14+
# URI of the sandbox node.
15+
uri = 'https://sandbox.iotatoken.com/api/v1/',
16+
17+
# Access token used to authenticate requests.
18+
# Contact the node maintainer to get an access token.
19+
auth_token = 'auth token goes here',
20+
),
21+
22+
# Seed used for cryptographic functions.
23+
# If null, a random seed will be generated.
24+
seed = b'SEED9GOES9HERE',
25+
)
26+
27+
# Example of sending a transfer using the sandbox.
28+
# For more information, see :py:meth:`Iota.send_transfer`.
29+
# noinspection SpellCheckingInspection
30+
iota.send_transfer(
31+
depth = 100,
32+
33+
# One or more :py:class:`ProposedTransaction` objects to add to the
34+
# bundle.
35+
transfers = [
36+
ProposedTransaction(
37+
# Recipient of the transfer.
38+
address =
39+
Address(
40+
b'TESTVALUE9DONTUSEINPRODUCTION99999FBFFTG'
41+
b'QFWEHEL9KCAFXBJBXGE9HID9XCOHFIDABHDG9AHDR'
42+
),
43+
44+
# Amount of IOTA to transfer.
45+
# This value may be zero.
46+
value = 42,
47+
48+
# Optional tag to attach to the transfer.
49+
tag = Tag(b'EXAMPLE'),
50+
51+
# Optional message to include with the transfer.
52+
message = TryteString.from_string('Hello, Tangle!'),
53+
),
54+
],
55+
)

examples/shell.py

Lines changed: 14 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
from argparse import ArgumentParser
99
from getpass import getpass as secure_input
10-
from logging import INFO, basicConfig, getLogger
10+
from logging import DEBUG, basicConfig, getLogger
1111
from sys import argv, stderr
1212

1313
from six import text_type
@@ -18,10 +18,10 @@
1818

1919
from iota import __version__
2020
from iota.adapter import resolve_adapter
21-
from iota.adapter.wrappers import LogWrapper, RoutingWrapper
21+
from iota.adapter.wrappers import RoutingWrapper
2222

2323

24-
basicConfig(level=INFO, stream=stderr)
24+
basicConfig(level=DEBUG, stream=stderr)
2525

2626

2727
def main(uri, testnet, pow_uri, debug_requests):
@@ -34,16 +34,23 @@ def main(uri, testnet, pow_uri, debug_requests):
3434
if isinstance(seed, text_type):
3535
seed = seed.encode('ascii')
3636

37+
adapter_ = resolve_adapter(uri)
38+
3739
# If ``pow_uri`` is specified, route POW requests to a separate node.
38-
adapter_ = create_adapter(uri, debug_requests)
3940
if pow_uri:
40-
pow_adapter = create_adapter(pow_uri, debug_requests)
41+
pow_adapter = resolve_adapter(pow_uri)
4142

4243
adapter_ =\
4344
RoutingWrapper(adapter_)\
4445
.add_route('attachToTangle', pow_adapter)\
4546
.add_route('interruptAttachingToTangle', pow_adapter)
4647

48+
# If ``debug_requests`` is specified, log HTTP requests/responses.
49+
if debug_requests:
50+
logger = getLogger(__name__)
51+
logger.setLevel(DEBUG)
52+
adapter_.set_logger(logger)
53+
4754
iota = Iota(adapter_, seed=seed, testnet=testnet)
4855

4956
_banner = (
@@ -57,26 +64,6 @@ def main(uri, testnet, pow_uri, debug_requests):
5764
start_shell(iota, _banner)
5865

5966

60-
def create_adapter(uri, debug):
61-
# type: (Text, bool) -> BaseAdapter
62-
"""
63-
Creates an adapter with the specified settings.
64-
65-
:param uri:
66-
Node URI.
67-
68-
:param debug:
69-
Whether to attach a LogWrapper to the adapter.
70-
"""
71-
adapter_ = resolve_adapter(uri)
72-
73-
return (
74-
LogWrapper(adapter_, getLogger(__name__), INFO)
75-
if debug
76-
else adapter_
77-
)
78-
79-
8067
def start_shell(iota, _banner):
8168
"""
8269
Starts the shell with limited scope.
@@ -102,11 +89,11 @@ def start_shell(iota, _banner):
10289
parser.add_argument(
10390
'--uri',
10491
type = text_type,
105-
default = 'udp://localhost:14265/',
92+
default = 'http://localhost:14265/',
10693

10794
help =
10895
'URI of the node to connect to '
109-
'(defaults to udp://localhost:14265/).',
96+
'(defaults to http://localhost:14265/).',
11097
)
11198

11299
parser.add_argument(

setup.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
name = 'PyOTA',
2929
description = 'IOTA API library for Python',
3030
url = 'https://github.com/iotaledger/iota.lib.py',
31-
version = '1.0.0',
31+
version = '1.1.0',
3232

3333
packages = find_packages('src'),
3434
include_package_data = True,
@@ -37,7 +37,7 @@
3737

3838
install_requires = [
3939
'filters',
40-
'requests',
40+
'requests[security]',
4141
'six',
4242
'typing',
4343
],

0 commit comments

Comments
 (0)