Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[PAN-1808] upgrade python to 3.12 and switch to poetry #3

Closed
wants to merge 12 commits into from
Closed
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 20 additions & 10 deletions .github/actions/install-deps/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,27 @@ description: 'Install all required dependencies'
runs:
using: composite
steps:
- name: Setup Python
uses: actions/setup-python@v4
- name: Set up python
id: setup-python
uses: actions/setup-python@v5
with:
python-version: '3.10'
python-version: '3.12.2'

- name: Install dependencies
shell: bash
run: python3 -m pip install -r requirements.txt
- name: Install Poetry
uses: snok/install-poetry@v1
with:
virtualenvs-create: true
virtualenvs-in-project: true
installer-parallel: true

- uses: actions/cache@v3
- name: Load cached venv
id: cached-poetry-dependencies
uses: actions/cache@v3
with:
# with this we are going to cache the virtual environment
path: ${{ env.pythonLocation }}
key: ${{ env.pythonLocation }}-${{ hashFiles('setup.py') }}-${{ hashFiles('dev-requirements.txt') }}
path: .venv
key: venv-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('**/poetry.lock') }}

- name: Install dependencies
shell: bash
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
run: poetry install --no-interaction --no-root
75 changes: 0 additions & 75 deletions .github/workflows/ci-cd.yaml

This file was deleted.

19 changes: 2 additions & 17 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,27 +15,12 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
submodules: recursive

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: 3.10
cache: 'pip'

- name: Install dependencies
run: |
python -m venv .venv
source .venv/bin/activate
python -m pip install -r requirements.txt
- uses: ./.github/actions/install-deps

- name: Build package
run: |
source .venv/bin/activate
pip install build
python -m build
make wheel
env:
PANTOS_COMMON_VERSION: ${{ github.event.release.tag_name }}

Expand Down
9 changes: 1 addition & 8 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,18 +1,11 @@
repos:
- repo: local
hooks:
- id: validate-commit-msg
name: Commit message is prefixed by Jira ticket number
entry: ^(?!PAN-\d*:.+)
language: pygrep
stages: [ commit-msg ]
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
hooks:
- id: no-commit-to-branch
name: Check that branch name follows our standard
description: Checks that a branch has a proper name
args: ['--branch', 'main','--pattern', '^(?!(feature|bugfix)\/PAN-[0-9]+-[a-z0-9._-]+).*']
args: ['--branch', 'main','--pattern', '^(PAN-[0-9]+-[a-z0-9._-]+).*']
stages: [ commit-msg ]
- repo: https://github.com/PyCQA/flake8
rev: 6.0.0
Expand Down
26 changes: 15 additions & 11 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,48 +1,52 @@
PYTHON_FILES := pantos/common scripts tests ./*.py
PYTHON_FILES := pantos/common scripts tests

.PHONY: code
code: check format lint sort bandit test

.PHONY: check
check:
mypy $(PYTHON_FILES)
poetry run mypy $(PYTHON_FILES)

.PHONY: test
test:
python3 -m pytest tests
poetry run python3 -m pytest tests

.PHONY: coverage
coverage:
rm -rf .coverage
python3 -m pytest --cov-report term-missing --cov=pantos tests
poetry run python3 -m pytest --cov-report term-missing --cov=pantos tests

.PHONY: lint
lint:
flake8 $(PYTHON_FILES)
poetry run flake8 $(PYTHON_FILES)

.PHONY: sort
sort:
isort --force-single-line-imports $(PYTHON_FILES)
poetry run isort --force-single-line-imports $(PYTHON_FILES)

.PHONY: sort-check
sort-check:
isort --force-single-line-imports $(PYTHON_FILES) --check-only
poetry run isort --force-single-line-imports $(PYTHON_FILES) --check-only

.PHONY: bandit
bandit:
bandit -r $(PYTHON_FILES) --quiet --configfile=.bandit
poetry run bandit -r $(PYTHON_FILES) --quiet --configfile=.bandit

.PHONY: bandit-check
bandit-check:
bandit -r $(PYTHON_FILES) --configfile=.bandit
poetry run bandit -r $(PYTHON_FILES) --configfile=.bandit

.PHONY: format
format:
yapf --in-place --recursive $(PYTHON_FILES)
poetry run yapf --in-place --recursive $(PYTHON_FILES)

.PHONY: format-check
format-check:
yapf --diff --recursive $(PYTHON_FILES)
poetry run yapf --diff --recursive $(PYTHON_FILES)

.PHONY: wheel
wheel:
poetry build -f wheel

.PHONY: clean
clean:
Expand Down
31 changes: 15 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,31 +31,34 @@ Please make sure that your environment meets the following requirements:

#### Python Version

The Pantos Client CLI requires **Python 3.10**. Ensure that you have the correct Python version installed before the installation steps. You can download the latest version of Python from the official [Python website](https://www.python.org/downloads/).
Pantos Common requires **Python 3.12**. Ensure that you have the correct Python version installed before the installation steps. You can download the latest version of Python from the official [Python website](https://www.python.org/downloads/).
markuslevonyak marked this conversation as resolved.
Show resolved Hide resolved

#### Library Versions

The Pantos Common project has been tested with the library versions in **requirements.txt**.
The Pantos Common project has been tested with the library versions specified in **poetry.lock**.

### 2.2 Installation Steps
#### Poetry

#### Virtual environment
Poetry is our tool of choice for dependency management and packaging.

Create a virtual environment from the repository's root directory:
Installing:
https://python-poetry.org/docs/#installing-with-the-official-installer
or
https://python-poetry.org/docs/#installing-with-pipx

By default poetry creates the venv directory under under ```{cache-dir}/virtualenvs```. If you opt for creating the virtualenv inside the project’s root directory, execute the following command:
```bash
$ python -m venv .venv
poetry config virtualenvs.in-project true
```

Activate the virtual environment:
### 2.2 Installation Steps

```bash
$ source .venv/bin/activate
```
#### Libraries

Create the virtual environment and install the dependencies:

Install the required packages:
```bash
$ python -m pip install -r requirements.txt
$ poetry install --no-root
```

## 3. Usage
Expand All @@ -65,7 +68,3 @@ The Pantos Common project should be used as a utility library, for example as a
### 3.1 Examples

https://github.com/pantos-io/client-library/blob/main/pantos/client/library/blockchains/base.py

## 4. Contributing

At the moment, contributing to this project is not available.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[{"type":"function","name":"getMinimumValidatorNodeSignatures","inputs":[],"outputs":[{"name":"","type":"uint256","internalType":"uint256"}],"stateMutability":"view"},{"type":"function","name":"getPantosHub","inputs":[],"outputs":[{"name":"","type":"address","internalType":"address"}],"stateMutability":"view"},{"type":"function","name":"getPantosToken","inputs":[],"outputs":[{"name":"","type":"address","internalType":"address"}],"stateMutability":"view"},{"type":"function","name":"getValidatorNodes","inputs":[],"outputs":[{"name":"","type":"address[]","internalType":"address[]"}],"stateMutability":"view"},{"type":"function","name":"isValidSenderNonce","inputs":[{"name":"sender","type":"address","internalType":"address"},{"name":"nonce","type":"uint256","internalType":"uint256"}],"outputs":[{"name":"","type":"bool","internalType":"bool"}],"stateMutability":"view"},{"type":"function","name":"isValidValidatorNodeNonce","inputs":[{"name":"nonce","type":"uint256","internalType":"uint256"}],"outputs":[{"name":"","type":"bool","internalType":"bool"}],"stateMutability":"view"},{"type":"function","name":"verifyAndForwardTransfer","inputs":[{"name":"request","type":"tuple","internalType":"struct PantosTypes.TransferRequest","components":[{"name":"sender","type":"address","internalType":"address"},{"name":"recipient","type":"address","internalType":"address"},{"name":"token","type":"address","internalType":"address"},{"name":"amount","type":"uint256","internalType":"uint256"},{"name":"serviceNode","type":"address","internalType":"address"},{"name":"fee","type":"uint256","internalType":"uint256"},{"name":"nonce","type":"uint256","internalType":"uint256"},{"name":"validUntil","type":"uint256","internalType":"uint256"}]},{"name":"signature","type":"bytes","internalType":"bytes"}],"outputs":[],"stateMutability":"nonpayable"},{"type":"function","name":"verifyAndForwardTransferFrom","inputs":[{"name":"sourceBlockchainFactor","type":"uint256","internalType":"uint256"},{"name":"destinationBlockchainFactor","type":"uint256","internalType":"uint256"},{"name":"request","type":"tuple","internalType":"struct PantosTypes.TransferFromRequest","components":[{"name":"destinationBlockchainId","type":"uint256","internalType":"uint256"},{"name":"sender","type":"address","internalType":"address"},{"name":"recipient","type":"string","internalType":"string"},{"name":"sourceToken","type":"address","internalType":"address"},{"name":"destinationToken","type":"string","internalType":"string"},{"name":"amount","type":"uint256","internalType":"uint256"},{"name":"serviceNode","type":"address","internalType":"address"},{"name":"fee","type":"uint256","internalType":"uint256"},{"name":"nonce","type":"uint256","internalType":"uint256"},{"name":"validUntil","type":"uint256","internalType":"uint256"}]},{"name":"signature","type":"bytes","internalType":"bytes"}],"outputs":[],"stateMutability":"nonpayable"},{"type":"function","name":"verifyAndForwardTransferTo","inputs":[{"name":"request","type":"tuple","internalType":"struct PantosTypes.TransferToRequest","components":[{"name":"sourceBlockchainId","type":"uint256","internalType":"uint256"},{"name":"sourceTransferId","type":"uint256","internalType":"uint256"},{"name":"sourceTransactionId","type":"string","internalType":"string"},{"name":"sender","type":"string","internalType":"string"},{"name":"recipient","type":"address","internalType":"address"},{"name":"sourceToken","type":"string","internalType":"string"},{"name":"destinationToken","type":"address","internalType":"address"},{"name":"amount","type":"uint256","internalType":"uint256"},{"name":"nonce","type":"uint256","internalType":"uint256"}]},{"name":"signerAddresses","type":"address[]","internalType":"address[]"},{"name":"signatures","type":"bytes[]","internalType":"bytes[]"}],"outputs":[],"stateMutability":"nonpayable"},{"type":"function","name":"verifyTransfer","inputs":[{"name":"request","type":"tuple","internalType":"struct PantosTypes.TransferRequest","components":[{"name":"sender","type":"address","internalType":"address"},{"name":"recipient","type":"address","internalType":"address"},{"name":"token","type":"address","internalType":"address"},{"name":"amount","type":"uint256","internalType":"uint256"},{"name":"serviceNode","type":"address","internalType":"address"},{"name":"fee","type":"uint256","internalType":"uint256"},{"name":"nonce","type":"uint256","internalType":"uint256"},{"name":"validUntil","type":"uint256","internalType":"uint256"}]},{"name":"signature","type":"bytes","internalType":"bytes"}],"outputs":[],"stateMutability":"view"},{"type":"function","name":"verifyTransferFrom","inputs":[{"name":"request","type":"tuple","internalType":"struct PantosTypes.TransferFromRequest","components":[{"name":"destinationBlockchainId","type":"uint256","internalType":"uint256"},{"name":"sender","type":"address","internalType":"address"},{"name":"recipient","type":"string","internalType":"string"},{"name":"sourceToken","type":"address","internalType":"address"},{"name":"destinationToken","type":"string","internalType":"string"},{"name":"amount","type":"uint256","internalType":"uint256"},{"name":"serviceNode","type":"address","internalType":"address"},{"name":"fee","type":"uint256","internalType":"uint256"},{"name":"nonce","type":"uint256","internalType":"uint256"},{"name":"validUntil","type":"uint256","internalType":"uint256"}]},{"name":"signature","type":"bytes","internalType":"bytes"}],"outputs":[],"stateMutability":"view"},{"type":"function","name":"verifyTransferTo","inputs":[{"name":"request","type":"tuple","internalType":"struct PantosTypes.TransferToRequest","components":[{"name":"sourceBlockchainId","type":"uint256","internalType":"uint256"},{"name":"sourceTransferId","type":"uint256","internalType":"uint256"},{"name":"sourceTransactionId","type":"string","internalType":"string"},{"name":"sender","type":"string","internalType":"string"},{"name":"recipient","type":"address","internalType":"address"},{"name":"sourceToken","type":"string","internalType":"string"},{"name":"destinationToken","type":"address","internalType":"address"},{"name":"amount","type":"uint256","internalType":"uint256"},{"name":"nonce","type":"uint256","internalType":"uint256"}]},{"name":"signerAddresses","type":"address[]","internalType":"address[]"},{"name":"signatures","type":"bytes[]","internalType":"bytes[]"}],"outputs":[],"stateMutability":"view"},{"type":"event","name":"MinimumValidatorNodeSignaturesUpdated","inputs":[{"name":"minimumValidatorNodeSignatures","type":"uint256","indexed":false,"internalType":"uint256"}],"anonymous":false},{"type":"event","name":"PantosHubSet","inputs":[{"name":"pantosHub","type":"address","indexed":false,"internalType":"address"}],"anonymous":false},{"type":"event","name":"PantosTokenSet","inputs":[{"name":"pantosToken","type":"address","indexed":false,"internalType":"address"}],"anonymous":false},{"type":"event","name":"ValidatorNodeAdded","inputs":[{"name":"validatorNodeAddress","type":"address","indexed":false,"internalType":"address"}],"anonymous":false},{"type":"event","name":"ValidatorNodeRemoved","inputs":[{"name":"validatorNodeAddress","type":"address","indexed":false,"internalType":"address"}],"anonymous":false}]

This file was deleted.

Large diffs are not rendered by default.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[{"anonymous": false, "inputs": [{"indexed": true, "internalType": "address", "name": "owner", "type": "address"}, {"indexed": true, "internalType": "address", "name": "spender", "type": "address"}, {"indexed": false, "internalType": "uint256", "name": "value", "type": "uint256"}], "name": "Approval", "type": "event"}, {"anonymous": false, "inputs": [{"indexed": false, "internalType": "address", "name": "pantosForwarder", "type": "address"}], "name": "PantosForwarderSet", "type": "event"}, {"anonymous": false, "inputs": [], "name": "PantosForwarderUnset", "type": "event"}, {"anonymous": false, "inputs": [{"indexed": true, "internalType": "address", "name": "from", "type": "address"}, {"indexed": true, "internalType": "address", "name": "to", "type": "address"}, {"indexed": false, "internalType": "uint256", "name": "value", "type": "uint256"}], "name": "Transfer", "type": "event"}, {"inputs": [{"internalType": "address", "name": "owner", "type": "address"}, {"internalType": "address", "name": "spender", "type": "address"}], "name": "allowance", "outputs": [{"internalType": "uint256", "name": "", "type": "uint256"}], "stateMutability": "view", "type": "function"}, {"inputs": [{"internalType": "address", "name": "spender", "type": "address"}, {"internalType": "uint256", "name": "amount", "type": "uint256"}], "name": "approve", "outputs": [{"internalType": "bool", "name": "", "type": "bool"}], "stateMutability": "nonpayable", "type": "function"}, {"inputs": [{"internalType": "address", "name": "account", "type": "address"}], "name": "balanceOf", "outputs": [{"internalType": "uint256", "name": "", "type": "uint256"}], "stateMutability": "view", "type": "function"}, {"inputs": [], "name": "decimals", "outputs": [{"internalType": "uint8", "name": "", "type": "uint8"}], "stateMutability": "view", "type": "function"}, {"inputs": [], "name": "getOwner", "outputs": [{"internalType": "address", "name": "", "type": "address"}], "stateMutability": "view", "type": "function"}, {"inputs": [], "name": "getPantosForwarder", "outputs": [{"internalType": "address", "name": "", "type": "address"}], "stateMutability": "view", "type": "function"}, {"inputs": [], "name": "name", "outputs": [{"internalType": "string", "name": "", "type": "string"}], "stateMutability": "view", "type": "function"}, {"inputs": [{"internalType": "address", "name": "sender", "type": "address"}, {"internalType": "address", "name": "recipient", "type": "address"}, {"internalType": "uint256", "name": "amount", "type": "uint256"}], "name": "pantosTransfer", "outputs": [], "stateMutability": "nonpayable", "type": "function"}, {"inputs": [{"internalType": "address", "name": "sender", "type": "address"}, {"internalType": "uint256", "name": "amount", "type": "uint256"}], "name": "pantosTransferFrom", "outputs": [], "stateMutability": "nonpayable", "type": "function"}, {"inputs": [{"internalType": "address", "name": "recipient", "type": "address"}, {"internalType": "uint256", "name": "amount", "type": "uint256"}], "name": "pantosTransferTo", "outputs": [], "stateMutability": "nonpayable", "type": "function"}, {"inputs": [], "name": "symbol", "outputs": [{"internalType": "string", "name": "", "type": "string"}], "stateMutability": "view", "type": "function"}, {"inputs": [], "name": "totalSupply", "outputs": [{"internalType": "uint256", "name": "", "type": "uint256"}], "stateMutability": "view", "type": "function"}, {"inputs": [{"internalType": "address", "name": "recipient", "type": "address"}, {"internalType": "uint256", "name": "amount", "type": "uint256"}], "name": "transfer", "outputs": [{"internalType": "bool", "name": "", "type": "bool"}], "stateMutability": "nonpayable", "type": "function"}, {"inputs": [{"internalType": "address", "name": "sender", "type": "address"}, {"internalType": "address", "name": "recipient", "type": "address"}, {"internalType": "uint256", "name": "amount", "type": "uint256"}], "name": "transferFrom", "outputs": [{"internalType": "bool", "name": "", "type": "bool"}], "stateMutability": "nonpayable", "type": "function"}]

This file was deleted.

Loading
Loading