forked from iotaledger/iota.rs
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
15dbf1f
commit b073976
Showing
7 changed files
with
139 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,11 +8,12 @@ | |
|
||
1. Run your local Hornet | ||
- `$ git clone [email protected]:gohornet/hornet.git` | ||
- checkout `chrysalis-pt2` branch | ||
- Modify your `create_snapshot_alphanet.sh`, modify Line 14 to `go run ../main.go tool snapgen alphanet1 96f9de0989e77d0e150e850a5a600e83045fa57419eaf3b20225b763d4e23813 snapshots/alphanet1/full_export.bin` | ||
- `$ ./run_coo_bootstrap.sh ` | ||
- checkout `develop` branch | ||
- Modify your `create_snapshot_alphanet.sh`, modify Line 14 to `go run "..\main.go" tool snapgen alphanet1 96f9de0989e77d0e150e850a5a600e83045fa57419eaf3b20225b763d4e23813 1000000000 "snapshots\alphanet1\full_export.bin"` | ||
- Go to `hornet/alphanet` | ||
- `$ ./run_coo_bootstrap.sh` | ||
|
||
2. To build the iota_client python library by yourself, there are two ways. | ||
1. To build the iota_client python library by yourself, there are two ways. | ||
- By using the `cargo` | ||
- Go to `bindings/python/native` | ||
- `$ cargo build --release` | ||
|
@@ -29,7 +30,7 @@ | |
- The wheel file is now created in `bindings/python/native/target/wheels` | ||
- `$ pip3 install [THE_BUILT_WHEEL_FILE]` | ||
|
||
3. To use the pre-build libraries | ||
2. To use the pre-build libraries | ||
- To use the pre-built libraries for linux/macos/windows, please check the `Artifacts` files generated by the Github Action in the last commit. For example, there are the following 12 wheels in [this commit](https://github.com/iotaledger/iota.rs/actions/runs/596639195). Please download the one which matches your os and python version. | ||
- [linux-iota-client-py3.6-wheel](https://github.com/iotaledger/iota.rs/suites/2115209642/artifacts/43080898) | ||
- [linux-iota-client-py3.7-wheel](https://github.com/iotaledger/iota.rs/suites/2115209642/artifacts/43080899) | ||
|
@@ -46,6 +47,14 @@ | |
- **NOTE: Please download the wheel files generated in the commit version you want to use.** | ||
- `$ pip3 install [THE_DOWNLOADED_WHEEL_FILE]` | ||
|
||
## Testing | ||
- Install [tox](#https://pypi.org/project/tox/) | ||
- `$ pip install tox` | ||
- Build the library | ||
- `$ python setup.py install` | ||
- To test install tox globally and run | ||
- `$ tox -e py` | ||
|
||
## Python Example | ||
```python | ||
import iota_client | ||
|
@@ -176,8 +185,8 @@ Creates a new instance of the Client. | |
| --------------------- | -------------------------------------------- | ---------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------- | | ||
| [network] | <code>str</code> | <code>undefined</code> | The network | | ||
| [node] | <code>str</code> | <code>undefined</code> | A node URL | | ||
| [name] | <code>str</code> | <code>undefined</code> | The name for basic authentication | | ||
| [password] | <code>str</code> | <code>undefined</code> | The password for basic authentication | | ||
| [name] | <code>str</code> | <code>undefined</code> | The name for basic authentication | | ||
| [password] | <code>str</code> | <code>undefined</code> | The password for basic authentication | | ||
| [nodes] | <code>list[str]</code> | <code>undefined</code> | An array of node URLs | | ||
| [node_sync_interval] | <code>int</code> | <code>undefined</code> | The interval for the node syncing process | | ||
| [node_sync_disabled] | <code>bool</code> | <code>undefined</code> | Disables the node syncing process. Every node will be considered healthy and ready to use | | ||
|
@@ -469,7 +478,7 @@ Retries (promotes or reattaches) the message associated with the given id. | |
| ------------ | ---------------- | ---------------------- | ------------------------------------------------------ | | ||
| [message_id] | <code>str</code> | <code>undefined</code> | The message id | | ||
| interval | <code>int</code> | <code>5</code> | The interval in seconds in which we retry the message. | | ||
| max_attempts | <code>int</code> | <code>10</code> | The maximum of attempts we retry the message. | | ||
| max_attempts | <code>int</code> | <code>10</code> | The maximum of attempts we retry the message. | | ||
|
||
**Returns** the message ids and [Message](#message) of reattached messages. | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
include pyproject.toml Cargo.toml | ||
recursive-include src * |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
from .iota_client import * |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
pip>=19.1 | ||
pytest>=3.5.0 | ||
setuptools-rust>=0.10.2 | ||
psutil>=5.6 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
|
||
import sys | ||
import platform | ||
|
||
from setuptools import setup | ||
from setuptools_rust import RustExtension | ||
|
||
|
||
def get_py_version_cfgs(): | ||
# For now each Cfg Py_3_X flag is interpreted as "at least 3.X" | ||
version = sys.version_info[0:2] | ||
py3_min = 6 | ||
out_cfg = [] | ||
for minor in range(py3_min, version[1] + 1): | ||
out_cfg.append("--cfg=Py_3_%d" % minor) | ||
|
||
if platform.python_implementation() == "PyPy": | ||
out_cfg.append("--cfg=PyPy") | ||
|
||
return out_cfg | ||
|
||
|
||
setup( | ||
name="iota_client", | ||
version="0.1.0", | ||
classifiers=[ | ||
"License :: SPDX-License-Identifier :: Apache-2.0", | ||
"Development Status :: 0.1.0 - Alpha", | ||
"Intended Audience :: Developers", | ||
"Programming Language :: Python", | ||
"Programming Language :: Rust", | ||
"Operating System :: POSIX", | ||
"Operating System :: MacOS :: MacOS X", | ||
], | ||
packages=["iota_client"], | ||
rust_extensions=[ | ||
RustExtension( | ||
"iota_client.iota_client", | ||
rustc_flags=get_py_version_cfgs(), | ||
debug=False, | ||
), | ||
], | ||
include_package_data=True, | ||
zip_safe=False, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
# Copyright 2021 IOTA Stiftung | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
import iota_client | ||
import os | ||
|
||
TEST_NODE_URL = "https://api.lb-0.testnet.chrysalis2.com" | ||
|
||
# NOTE! Load the seed from your env path instead | ||
# NEVER assign the seed directly in your codes! | ||
# DO NOT USE THIS!!: | ||
# SEED = "256a818b2aac458941f7274985a410e57fb750f3a3a67969ece5bd9ae7eef5b2" | ||
|
||
# USE THIS INSTEAD | ||
SEED = os.getenv('NONSECURE_USE_OF_DEVELOPMENT_SEED_1') | ||
EMPTY_ADDRESS = "atoi1qzt0nhsf38nh6rs4p6zs5knqp6psgha9wsv74uajqgjmwc75ugupx3y7x0r" | ||
client = iota_client.Client(node=TEST_NODE_URL) | ||
|
||
def test_get_health(): | ||
health = client.get_health() | ||
|
||
def test_get_info(): | ||
node_info = client.get_info() | ||
|
||
def test_get_tips(): | ||
tips = client.get_tips() | ||
|
||
def test_get_addresses(): | ||
address_changed_list = client.get_addresses( | ||
seed=SEED, account_index=0, input_range_begin=0, input_range_end=10, get_all=True) | ||
|
||
# Get the (address, changed ) for the first found address | ||
address, changed = address_changed_list[0] | ||
balance = client.get_address_balance(address) | ||
|
||
def test_get_address_balance(): | ||
balance = client.get_address_balance(EMPTY_ADDRESS) | ||
|
||
def test_get_address_outputs(): | ||
outputs = client.get_address_outputs(EMPTY_ADDRESS) | ||
|
||
def test_indexation_with_int_list_data(): | ||
message_id_indexation = client.message( | ||
index="Hello", data=[84, 97, 110, 103, 108, 101]) | ||
|
||
def test_indexation_with_data_str(): | ||
message_id_indexation = client.message( | ||
index="Hi", data_str="Tangle") | ||
|
||
def test_get_message_index(): | ||
message_id_indexation_queried = client.get_message_index("Hello") | ||
|
||
def test_find_messages(): | ||
messages = client.find_messages(indexation_keys=["Hello"]) | ||
|
||
def test_get_unspent_address(): | ||
unspent_addresses = client.get_unspent_address(seed=SEED) | ||
|
||
def test_get_balance_in_seed(): | ||
balance = client.get_balance(seed=SEED) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
[tox] | ||
# can't install from sdist because local pyo3 repo can't be included in the sdist | ||
skipsdist = true | ||
|
||
[testenv] | ||
description = Run the unit tests under {basepython} | ||
deps = -rrequirements-dev.txt | ||
commands = | ||
python setup.py install | ||
pytest |