Skip to content
This repository has been archived by the owner on Mar 6, 2023. It is now read-only.

Commit

Permalink
Merge pull request #50 from linfeng-crypto/issue-48
Browse files Browse the repository at this point in the history
update change log for v2.2.0 (fix #48)
  • Loading branch information
macong-cdc authored May 18, 2022
2 parents 267ee78 + d204639 commit 8f91869
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 14 deletions.
13 changes: 9 additions & 4 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,13 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Run Tox tests
id: test
uses: fedora-python/tox-github-action@master
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
tox_env: ${{ matrix.tox_env }}
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install tox tox-gh-actions
- name: Test with tox
run: tox
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ repos:
- id: isort

- repo: https://github.com/psf/black
rev: 21.12b0
rev: 22.3.0
hooks:
- id: black
exclude: ^chainlibpy/generated/
Expand Down
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

This log documents all public API breaking backwards incompatible changes.

## 2.2.0 - to be released
## 2.2.0 - 17/May/2022

[#26](https://github.com/crypto-org-chain/chainlibpy/issues/26) [#27](https://github.com/crypto-org-chain/chainlibpy/issues/27) [#28](https://github.com/crypto-org-chain/chainlibpy/issues/28) Refactor protobuf message to class to add more functionalities and hide protobuf complexity

Expand Down
8 changes: 4 additions & 4 deletions chainlibpy/cro_coin.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def amount_base(self, amount: Union[int, float, str, "decimal.Decimal"]) -> None

if "." in temp_base_amount:
raise ValueError(f"Amount is less than 1{self._base_denom}")
if int(temp_base_amount) > MAX_CRO_SUPPLY * 10 ** self._exponent:
if int(temp_base_amount) > MAX_CRO_SUPPLY * 10**self._exponent:
raise ValueError(
"Input is more than maximum cro supply"
f" {MAX_CRO_SUPPLY * 10 ** self._exponent}{self._base_denom}"
Expand Down Expand Up @@ -124,7 +124,7 @@ def _cast_to_Decimal_obj(
def _get_conversion_rate_to_base_unit(self, unit: str) -> decimal.Decimal:
"""Takes a unit and gets its conversion rate to the base unit."""
if unit == self._denom:
return decimal.Decimal(value=10 ** self._exponent)
return decimal.Decimal(value=10**self._exponent)
elif unit == self._base_denom:
return decimal.Decimal(1)
else:
Expand Down Expand Up @@ -164,8 +164,8 @@ def _to_number_in_base(
with decimal.localcontext() as ctx:
multiplier = len(s_number) - s_number.index(".") - 1
ctx.prec = multiplier
d_number = decimal.Decimal(value=number, context=ctx) * 10 ** multiplier
unit_conversion /= 10 ** multiplier
d_number = decimal.Decimal(value=number, context=ctx) * 10**multiplier
unit_conversion /= 10**multiplier

with decimal.localcontext() as ctx:
ctx.prec = 999
Expand Down
6 changes: 3 additions & 3 deletions tests/test_coin.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,10 +173,10 @@ def test_crocoin_with_wrong_unit_should_raise_exception(
(decimal.Decimal(value=str(MAX_CRO_SUPPLY + 1)), CRO_DENOM, "3000000000100000000"),
("30000000000.00000001", CRO_DENOM, "3000000000000000001"),
(decimal.Decimal(value="30000000000.00000001"), CRO_DENOM, "3000000000000000001"),
(MAX_CRO_SUPPLY * 10 ** 8 + 1, BASECRO_DENOM, "3000000000000000001"),
(str(MAX_CRO_SUPPLY * 10 ** 8 + 1), BASECRO_DENOM, "3000000000000000001"),
(MAX_CRO_SUPPLY * 10**8 + 1, BASECRO_DENOM, "3000000000000000001"),
(str(MAX_CRO_SUPPLY * 10**8 + 1), BASECRO_DENOM, "3000000000000000001"),
(
decimal.Decimal(value=str(MAX_CRO_SUPPLY * 10 ** 8 + 1)),
decimal.Decimal(value=str(MAX_CRO_SUPPLY * 10**8 + 1)),
BASECRO_DENOM,
"3000000000000000001",
),
Expand Down
6 changes: 5 additions & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ minversion = 3.3.0
# arguments use the pyproject.toml file as specified in PEP-517 and PEP-518.
isolated_build = true

[gh-actions]
python =
3.8: py38
3.9: py39

[testenv]
whitelist_externals = poetry
Expand All @@ -27,4 +31,4 @@ deps =
exclude = .tox,*.egg,build,*.yaml,*.yml
commands =
poetry run pre-commit run --all-files
poetry run pytest tests
poetry run pytest tests

0 comments on commit 8f91869

Please sign in to comment.