Skip to content

Commit

Permalink
Pushing a snapshot for 1.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Pantos Snapshoter committed Apr 25, 2024
0 parents commit d36735a
Show file tree
Hide file tree
Showing 76 changed files with 8,816 additions and 0 deletions.
18 changes: 18 additions & 0 deletions .bandit
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
tests:
- B103
- B108
- B306
- B307
- B313
- B314
- B315
- B316
- B317
- B318
- B319
- B320
- B601
- B602
- B604
- B608
- B609
9 changes: 9 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
**/__pycache__/
*.egg-info/
*.swp
.DS_store
.venv/
.vscode/
build/
dist/
find.sh
46 changes: 46 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
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._-]+).*']
stages: [ commit-msg ]
- repo: https://github.com/PyCQA/flake8
rev: 6.0.0
hooks:
- id: flake8
files: ^pantos/common
stages: [ commit ]
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.0.1
hooks:
- id: mypy
files: ^pantos/common
additional_dependencies: ['types-requests', 'types-PyYAML']
stages: [ commit ]
- repo: https://github.com/PyCQA/isort
rev: 5.12.0
hooks:
- id: isort
alias: format
args: ['--force-single-line-imports' ]
stages: [ commit ]
- repo: https://github.com/PyCQA/bandit
rev: 1.7.5
hooks:
- id: bandit
alias: lint
args:
- --quiet
- --format=custom
- --configfile=.bandit
stages: [ commit ]
9 changes: 9 additions & 0 deletions .style.yapf
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[style]
based_on_style = pep8
spaces_before_comment = 2
split_before_logical_operator = true
column_limit = 79
allow_split_before_dict_value = false
blank_lines_between_top_level_imports_and_variables = 1
blank_line_before_nested_class_or_def = false
split_before_named_assigns = false
674 changes: 674 additions & 0 deletions LICENSE.md

Large diffs are not rendered by default.

37 changes: 37 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
.PHONY: code
code: check format lint sort bandit test

.PHONY: check
check:
mypy pantos/common

.PHONY: test
test:
python3 -m pytest tests

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

.PHONY: lint
lint:
flake8 pantos/common tests

.PHONY: sort
sort:
isort --force-single-line-imports pantos/common tests

.PHONY: bandit
bandit:
bandit -r pantos/common tests --quiet --configfile=.bandit

.PHONY: format
format:
yapf --in-place --recursive pantos/common tests

.PHONY: clean
clean:
rm -r -f build/
rm -r -f dist/
rm -r -f pantos_common.egg-info/
71 changes: 71 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
# Common code for Pantos off-chain components

## 1. Introduction

### 1.1 Overview

Welcome to the documentation for Pantos Common. This repository is a centralized hub for storing shared code components used across multiple projects within our organization.

The primary purpose of the Common Repository is to promote code reusability, streamline collaboration, and maintain consistency across various projects. Centralizing shared code aims to enhance efficiency and reduce redundancy in our development processes.

### 1.2 Features

The Pantos Common project currently offers the following functionalities:

#### Signing module
The **signer.py** module is used for signing and verifying signatures. The private key must be on the curve Ed25519 or Ed448 and encrypted in a PEM file.

#### Service nodes module
The **servicenodes.py** module is used for communicating with Pantos service nodes. It can be used for querying the bids, sending transfers, and requesting the transfer status.

#### Blockchain utility modules
The blockchain utility modules extract common blockchain functionalities used across projects. Such functionalities include sending transactions or calling the blockchain nodes for read-only data.

The blockchain utility modules can be found in the **blockchains** package. There is a Python module for each Pantos-supported blockchain.

## 2. Installation

### 2.1 Prerequisites

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/).

#### Library Versions

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

### 2.2 Installation Steps

#### Virtual environment

Create a virtual environment from the repository's root directory:

```bash
$ python -m venv .venv
```

Activate the virtual environment:

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

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

## 3. Usage

The Pantos Common project should be used as a utility library, for example as a submodule in an upstream project. After those steps, the modules can be imported directly from the Common library.

### 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.
Empty file added pantos/__init__.py
Empty file.
Empty file added pantos/common/__init__.py
Empty file.
3 changes: 3 additions & 0 deletions pantos/common/blockchains/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
"""Package for all blockchain-specific utilities.
"""
31 changes: 31 additions & 0 deletions pantos/common/blockchains/avalanche.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
"""Module for Avalanche-specific utilities and errors. Since the
Avalanche C-Chain is Ethereum-compatible, the utilities implementation
inherits from the pantos.common.blockchains.ethereum module.
"""
from pantos.common.blockchains.base import BlockchainUtilitiesError
from pantos.common.blockchains.enums import Blockchain
from pantos.common.blockchains.ethereum import EthereumUtilities
from pantos.common.blockchains.ethereum import EthereumUtilitiesError


class AvalancheUtilitiesError(EthereumUtilitiesError):
"""Exception class for all Avalanche utilities errors.
"""
pass


class AvalancheUtilities(EthereumUtilities):
"""Class for Avalanche-specific utilities.
"""
@classmethod
def get_blockchain(cls) -> Blockchain:
# Docstring inherited
return Blockchain.AVALANCHE

@classmethod
def get_error_class(cls) -> type[BlockchainUtilitiesError]:
# Docstring inherited
return AvalancheUtilitiesError
Loading

0 comments on commit d36735a

Please sign in to comment.