From d204639aaf7b8f22c0aeecf16702422b1ac6a6a6 Mon Sep 17 00:00:00 2001 From: linfeng-crypto Date: Tue, 17 May 2022 17:59:27 +0800 Subject: [PATCH] update change log for v2.2.0 (fix #48) --- .github/workflows/test.yml | 13 +++++++++---- .pre-commit-config.yaml | 2 +- CHANGELOG.md | 2 +- chainlibpy/cro_coin.py | 8 ++++---- tests/test_coin.py | 6 +++--- tox.ini | 6 +++++- 6 files changed, 23 insertions(+), 14 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 564473f..ea6b3b5 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -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 diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index a343263..a8f0dcd 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -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/ diff --git a/CHANGELOG.md b/CHANGELOG.md index fb3712c..42b24ea 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/chainlibpy/cro_coin.py b/chainlibpy/cro_coin.py index 44881e1..88e5f33 100644 --- a/chainlibpy/cro_coin.py +++ b/chainlibpy/cro_coin.py @@ -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}" @@ -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: @@ -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 diff --git a/tests/test_coin.py b/tests/test_coin.py index e80755c..d22258e 100644 --- a/tests/test_coin.py +++ b/tests/test_coin.py @@ -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", ), diff --git a/tox.ini b/tox.ini index 3e5f99a..57a2733 100644 --- a/tox.ini +++ b/tox.ini @@ -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 @@ -27,4 +31,4 @@ deps = exclude = .tox,*.egg,build,*.yaml,*.yml commands = poetry run pre-commit run --all-files - poetry run pytest tests \ No newline at end of file + poetry run pytest tests