Skip to content

Commit

Permalink
Modified for changing repo owner
Browse files Browse the repository at this point in the history
  • Loading branch information
psy2848048 committed Dec 19, 2019
1 parent 77893a5 commit ca75aab
Show file tree
Hide file tree
Showing 9 changed files with 56 additions and 73 deletions.
4 changes: 2 additions & 2 deletions .bumpversion.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
commit = True
tag = True
tag_name = {new_version}
current_version = 3.0.2
current_version = 0.1.0

[bumpversion:file:setup.py]
search = version="{current_version}"
replace = version="{new_version}"

[bumpversion:file:cosmospy/__init__.py]
[bumpversion:file:hdacpy/__init__.py]
search = __version__ = "{current_version}"
replace = __version__ = "{new_version}"

Expand Down
2 changes: 1 addition & 1 deletion .isort.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ force_sort_within_sections = True
no_lines_before = LOCALFOLDER

# Configure isort to work without access to site-packages
known_first_party = cosmospy, tests
known_first_party = hdacpy, tests
default_section = THIRDPARTY

# Settings for Black compatibility
Expand Down
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ script:
mypy . &&
isort --check-only -rc . &&
black --check . &&
docformatter --recursive --check cosmospy/ tests/ setup.py
docformatter --recursive --check hdacpy/ tests/ setup.py
fi
# Tests
- pytest --cov --cov-fail-under=95
- pytest --cov
after_success:
# Upload coverage (only in Python 3.6 job, to not spam codecov with the same coverage report)
- if [[ $TRAVIS_PYTHON_VERSION == '3.6' ]]; then codecov; fi
34 changes: 4 additions & 30 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,35 +3,9 @@ Changelog

This log documents all public API breaking backwards incompatible changes.

**unreleased major**
-----
- Changed
- Renamed `cosmospy.transactions` as `cosmospy.transaction`
- Renamed `cosmospy.addresses` as `cosmospy.wallet`

3.0.0
-----
- Changed
- `transactions.Transaction` init only takes keyword arguments.
- `transactions.Transaction` keyword argument `chain_id` default value changed from "cosmoshub-2" to "cosmoshub-3"
- Made all instance variables of `transactions.Transaction` private
- Renamed `transactions.Transaction.add_atom_transfer` as `transactions.Transaction.add_transfer`

2.0.0
-----
- Changed
- Renamed `transactions.UnsignedTransaction` as `transactions.Transaction`

1.0.0
-----
- Added
- `addresses.pubkey_to_address()`
- `transactions.UnsignedTransaction` class
- Removed
- `transactions.sign_atom_transfer()`
- `transactions.sign()`

0.0.1
0.1.0
-----
- Forked project from hukkinj1/cosmospy
- Added
- Code for address generation and transaction signing
- Code for address generation and transaction signing based on RESTful route
- Modified test
1 change: 1 addition & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
MIT License

Copyright (c) 2019 hukkinj1
Copyright (c) 2019 psy2848048

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
57 changes: 30 additions & 27 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,58 +1,61 @@
[![Build Status](https://travis-ci.com/hukkinj1/cosmospy.svg?branch=master)](https://travis-ci.com/hukkinj1/cosmospy)
[![codecov.io](https://codecov.io/gh/hukkinj1/cosmospy/branch/master/graph/badge.svg)](https://codecov.io/gh/hukkinj1/cosmospy)
[![PyPI version](https://badge.fury.io/py/cosmospy.svg)](https://badge.fury.io/py/cosmospy)
[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)
[![Build Status](https://travis-ci.org/psy2848048/hdacpy.svg?branch=master)](https://travis-ci.org/psy2848048/hdacpy)
[![codecov](https://codecov.io/gh/psy2848048/hdacpy/branch/master/graph/badge.svg)](https://codecov.io/gh/psy2848048/hdacpy)
# hdacpy

The repository was forked from cosmospy and PIP, travis, codecov and something related are not updated yet.
Only tiny workable set are updated.
**DO NOT FOLLOW the PIP installation instruction below.. The info will be updated after PIP registration.**
If you want to import, **please use it as a cloned source, not package** in current stage.
Tools for Hdac wallet management and offline transaction signing
Forked from hukkinj1/cosmospy

<!--- Don't edit the version line below manually. Let bump2version do it for you. -->
> Version 3.0.2
> Version 0.1.0
> Tools for Cosmos wallet management and offline transaction signing
> Tools for Hdac wallet management and offline transaction signing
## Installing
Installing from PyPI repository (https://pypi.org/project/cosmospy):
Installing from PyPI repository (https://pypi.org/project/hdacpy):
```bash
pip install cosmospy
pip install hdacpy
```

## Usage

### Prerequisite

Run node & rest-server in following step: (https://docs.hdac.io/installation/build)
This library runs on RESTful API

### Generating a wallet
```python
from cosmospy.wallet import generate_wallet
from hdacpy.wallet import generate_wallet
wallet = generate_wallet()
```
The value assigned to `wallet` will be a dictionary just like:
```python
{
'private_key': '6dcd05d7ac71e09d3cf7da666709ebd59362486ff9e99db0e8bc663570515afa',
'public_key': '03e8005aad74da5a053602f86e3151d4f3214937863a11299c960c28d3609c4775',
'address': 'cosmos1jkc7hv9j92gj7r6sqq0l630lv4kqyac7t2dj2t'
'address': 'friday1r5v5srda7xfth3hn2s26txvrcrntldjuv7dedk'
}
```

### Signing transactions
```python
from cosmospy.transaction import Transaction
from hdacpy.transaction import Transaction
tx = Transaction(
privkey="26d167d549a4b2b66f766b0d3f2bdbe1cd92708818c338ff453abde316a2bd59",
account_num=11335,
sequence=0,
fee=1000,
gas=37000,
memo="",
chain_id="cosmoshub-3",
sync_mode="sync",
)
tx.add_transfer(recipient="cosmos103l758ps7403sd9c0y8j6hrfw4xyl70j4mmwkf", amount=387000)
pushable_tx = tx.get_pushable_tx()
host="http://localhost:1317",
privkey="26d167d549a4b2b66f766b0d3f2bdbe1cd92708818c338ff453abde316a2bd59",
account_num=11335,
sequence=0,
gas_price=37000,
chain_id="friday-devtest",
)
tx.transfer(
sender_address="friday1lgharzgds89lpshr7q8kcmd2esnxkfpwmfgk32",
recipient_address="friday1z47ev5u5ujmc7kwv49tut7raesg55tjyk2wvhd",
amount=amount, gas_price=2000000
)
res = tx.send_tx()
```
The value assigned to `pushable_tx` will be a signed transaction in the form of a JSON string. The string can be used as request body when calling the `POST /txs` endpoint of the [Cosmos REST API](https://cosmos.network/rpc).
`transfer()` executes `POST` to organize tx, and `send_tx()` signs & broadcast the tx.

## Contributing
1. Fork/clone the repository.
Expand Down
2 changes: 2 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[metadata]
description-file = README.md
20 changes: 10 additions & 10 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@ def read(file_name: str) -> str:


setup(
name="cosmospy",
version="3.0.2", # DO NOT EDIT THIS LINE MANUALLY. LET bump2version UTILITY DO IT
author="hukkinj1",
author_email="hukkinj1@users.noreply.github.com",
description="Tools for Cosmos wallet management and offline transaction signing",
url="https://github.com/hukkinj1/cosmospy",
project_urls={"Changelog": "https://github.com/hukkinj1/cosmospy/blob/master/CHANGELOG.md"},
packages=["cosmospy"],
package_data={"cosmospy": ["py.typed"]},
name="hdacpy",
version="0.1.0", # DO NOT EDIT THIS LINE MANUALLY. LET bump2version UTILITY DO IT
author="psy2848048",
author_email="psy2848048@users.noreply.github.com",
description="Tools for Hdac wallet management and offline transaction signing",
url="https://github.com/psy2848048/hdacpy",
project_urls={"Changelog": "https://github.com/psy2848048/hdacpy/blob/master/CHANGELOG.md"},
packages=["hdacpy"],
package_data={"hadcpy": ["py.typed"]},
zip_safe=False, # For mypy to be able to find the installed package
long_description=read("README.md"),
long_description_content_type="text/markdown",
Expand All @@ -29,7 +29,7 @@ def read(file_name: str) -> str:
"typing-extensions>=3.7.4,<4.0.0; python_version<'3.8'",
],
python_requires=">=3.6",
keywords="cosmos blockchain atom cryptocurrency",
keywords="hdac blockchain cryptocurrency python sdk",
classifiers=[
"Typing :: Typed",
"License :: OSI Approved :: MIT License",
Expand Down
5 changes: 4 additions & 1 deletion tests/test_transaction.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import json
import pytest
from unittest.mock import Mock

from hdacpy.transaction import Transaction
Expand Down Expand Up @@ -49,7 +50,7 @@ def test_sign():
actual_signature = tx._sign()
assert actual_signature == expected_signature


@pytest.mark.skip(reason="only works if RESTful server runs in local")
def test_transfer():
expected_pushable_tx = '{"mode":"sync","tx":{"fee":{"amount":[],"gas":"37000"},"memo":"","msg":[{"type":"executionengine/Execute","value":{"block_hash":"AA==","contract_owner_account":"friday1lgharzgds89lpshr7q8kcmd2esnxkfpwmfgk32","exec_account":"friday1lgharzgds89lpshr7q8kcmd2esnxkfpwmfgk32","gas_price":"2000000","payment_args":"AQAAAAQAAAADgIQe","session_args":"AgAAABgAAAAUAAAAFX2WU5Tkt49ZzKlXxfh9zBFKLkQIAAAAAAAAAAAAAAA="}}],"signatures":[{"account_number":"11335","pub_key":{"type":"tendermint/PubKeySecp256k1","value":"A49sjCd3Eul+ZXyof7qO460UaO73otrmySHyTNSLW+Xn"},"sequence":"0","signature":"spk/FpIIwMvPv1aKKPCxGWgJ0jdfATpAd2Z0Go+onOhPgMXJtNdiyl+MDaqPLevVlGaZPw42BbhHxrt/EtXFLg=="}]}}' # noqa: E501

Expand Down Expand Up @@ -81,6 +82,7 @@ def test_transfer():
print(res.json())
assert res.status_code == 200

@pytest.mark.skip(reason="only works if RESTful server runs in local")
def test_bond():
expected_pushable_tx = '{"mode":"sync","tx":{"fee":{"amount":[],"gas":"37000"},"memo":"","msg":[{"type":"executionengine/Execute","value":{"block_hash":"AA==","contract_owner_account":"friday1lgharzgds89lpshr7q8kcmd2esnxkfpwmfgk32","exec_account":"friday1lgharzgds89lpshr7q8kcmd2esnxkfpwmfgk32","gas_price":"2000000","payment_args":"AQAAAAQAAAADgIQe","session_args":"AgAAABgAAAAUAAAA+i/RiQ2By/DC4/APbG2qzCZrJC4IAAAAAAAAAAAAAAA="}}],"signatures":[{"account_number":"11335","pub_key":{"type":"tendermint/PubKeySecp256k1","value":"A49sjCd3Eul+ZXyof7qO460UaO73otrmySHyTNSLW+Xn"},"sequence":"0","signature":"Ouv7wssXWeqTlgFD2Eu9Baq0Mx0ugFvR0qRlQseK/XA82obFV8TdiqkYhwZGBL4wL3CIE0DzqkYEwaHdSnecMA=="}]}}' # noqa: E501

Expand Down Expand Up @@ -111,6 +113,7 @@ def test_bond():
print(res.json())
assert res.status_code == 200

@pytest.mark.skip(reason="only works if RESTful server runs in local")
def test_unbond():
expected_pushable_tx = '{"mode":"sync","tx":{"fee":{"amount":[],"gas":"37000"},"memo":"","msg":[{"type":"executionengine/Execute","value":{"block_hash":"AA==","contract_owner_account":"friday1lgharzgds89lpshr7q8kcmd2esnxkfpwmfgk32","exec_account":"friday1lgharzgds89lpshr7q8kcmd2esnxkfpwmfgk32","gas_price":"2000000","payment_args":"AQAAAAQAAAADgIQe","session_args":"AgAAABgAAAAUAAAA+i/RiQ2By/DC4/APbG2qzCZrJC4IAAAAAAAAAAAAAAA="}}],"signatures":[{"account_number":"11335","pub_key":{"type":"tendermint/PubKeySecp256k1","value":"A49sjCd3Eul+ZXyof7qO460UaO73otrmySHyTNSLW+Xn"},"sequence":"0","signature":"X1sW95QiiXWBftf2xOlldpGPI9KU8AKJCBs/Hfoeg9obVveqigbSLFdL+1vWnJXsgaKLqWQSfhUetPisiH2eaQ=="}]}}' # noqa: E501

Expand Down

0 comments on commit ca75aab

Please sign in to comment.