Skip to content

Commit

Permalink
[PAN-1924] Clean repo for OS (#6)
Browse files Browse the repository at this point in the history
* fix: prepare for OS
  • Loading branch information
juanmanuel-tirado authored May 27, 2024
1 parent 23e0775 commit 3c134ee
Show file tree
Hide file tree
Showing 55 changed files with 586 additions and 604 deletions.
1 change: 0 additions & 1 deletion .bandit

This file was deleted.

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
File renamed without changes.
12 changes: 12 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
name: CI

on:
push:
branches:
- main
pull_request:

jobs:
shared:
uses: pantos-io/ci-workflows/.github/workflows/python-ci.yml@8651148b739f73851ab50c671da422c94bc55095
secrets: inherit
10 changes: 10 additions & 0 deletions .github/workflows/sonar.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
name: Sonar

on:
workflow_run:
workflows: [CI]
types: [completed]

jobs:
shared:
uses: pantos-io/ci-workflows/.github/workflows/sonar.yml@v1
3 changes: 0 additions & 3 deletions .gitmodules

This file was deleted.

6 changes: 6 additions & 0 deletions .mypy.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[mypy]
namespace_packages = True
explicit_package_bases = True

[mypy-pantos.common.*]
ignore_missing_imports = True
1 change: 0 additions & 1 deletion .style.yapf

This file was deleted.

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
9 changes: 8 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
<img src="https://raw.githubusercontent.com/pantos-io/servicenode/img/pantos-logo-full.svg" alt="Pantos logo" align="right" width="120" />

[![CI](https://github.com/pantos-io/servicenode/actions/workflows/ci.yaml/badge.svg?branch=main)](https://github.com/pantos-io/servicenode/actions/workflows/ci.yaml)
[![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=pantos-io_servicenode&metric=alert_status)](https://sonarcloud.io/summary/new_code?id=pantos-io_servicenode)



# Pantos Service Node (reference implementation)

## 1. Introduction
Expand Down Expand Up @@ -159,4 +166,4 @@ sudo rabbitmqctl set_permissions -p pantos-service-node pantos-service-node ".*"

## 4. Contributing

At the moment, contributing to this project is not available.
For contributions take a look at our [code of conduct](CODE_OF_CONDUCT.md).
Empty file removed pantos/__init__.py
Empty file.
1 change: 0 additions & 1 deletion pantos/common

This file was deleted.

5 changes: 1 addition & 4 deletions pantos/servicenode/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,5 @@
ssl_context = (None if ssl_certificate is None or ssl_private_key is None
else (ssl_certificate, ssl_private_key))
debug = config['application']['debug']
application.run(host=host,
port=port,
ssl_context=ssl_context,
debug=debug,
application.run(host=host, port=port, ssl_context=ssl_context, debug=debug,
use_reloader=False)
1 change: 0 additions & 1 deletion pantos/servicenode/blockchains/avalanche.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ class AvalancheClient(EthereumClient):
"""Avalanche-specific blockchain client.
"""

@classmethod
def get_blockchain(cls) -> Blockchain:
# Docstring inherited
Expand Down
20 changes: 7 additions & 13 deletions pantos/servicenode/blockchains/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ class InsufficientBalanceError(BlockchainClientError):
insufficient balance.
"""

def __init__(self, **kwargs: typing.Any):
# Docstring inherited
super().__init__('insufficient balance', **kwargs)
Expand All @@ -49,7 +48,6 @@ class InvalidSignatureError(BlockchainClientError):
invalid signature.
"""

def __init__(self, **kwargs: typing.Any):
# Docstring inherited
super().__init__('invalid signature', **kwargs)
Expand All @@ -61,7 +59,6 @@ class UnresolvableTransferSubmissionError(BlockchainClientError):
submission.
"""

def __init__(self, **kwargs: typing.Any):
# Docstring inherited
super().__init__('unresolvable transfer/transferFrom submission error',
Expand All @@ -72,7 +69,6 @@ class BlockchainClient(BlockchainHandler, ErrorCreator[BlockchainClientError]):
"""Base class for all blockchain clients.
"""

def __init__(self):
"""Construct a blockchain client instance.
Expand All @@ -95,10 +91,8 @@ def __init__(self):
try:
initialize_blockchain_utilities(
self.get_blockchain(), [blockchain_node_url],
fallback_blockchain_nodes_urls,
average_block_time,
required_transaction_confirmations,
transaction_network_id,
fallback_blockchain_nodes_urls, average_block_time,
required_transaction_confirmations, transaction_network_id,
default_private_key=(private_key, private_key_password),
celery_tasks_enabled=True)
except BlockchainUtilitiesError:
Expand Down Expand Up @@ -417,9 +411,10 @@ def get_transfer_submission_status(
except BlockchainUtilitiesError:
raise self._create_unresolvable_transfer_submission_error(
internal_transaction_id=internal_transaction_id)
_logger.info('transfer/transferFrom transaction submission status',
extra=vars(status_response)
| {'internal_transaction_id': internal_transaction_id})
_logger.info(
'transfer/transferFrom transaction submission status',
extra=vars(status_response)
| {'internal_transaction_id': internal_transaction_id})
if not status_response.transaction_submission_completed:
return BlockchainClient.TransferSubmissionStatusResponse(False)
transaction_status = status_response.transaction_status
Expand All @@ -433,8 +428,7 @@ def get_transfer_submission_status(
self._read_on_chain_transfer_id(
transaction_id, destination_blockchain))
return BlockchainClient.TransferSubmissionStatusResponse(
True,
transaction_status=transaction_status,
True, transaction_status=transaction_status,
transaction_id=transaction_id,
on_chain_transfer_id=on_chain_transfer_id)

Expand Down
1 change: 0 additions & 1 deletion pantos/servicenode/blockchains/bnbchain.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ class BnbChainClient(EthereumClient):
"""BNB-Chain-specific blockchain client.
"""

@classmethod
def get_blockchain(cls) -> Blockchain:
# Docstring inherited
Expand Down
1 change: 0 additions & 1 deletion pantos/servicenode/blockchains/celo.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ class CeloClient(EthereumClient):
"""Celo-specific blockchain client.
"""

@classmethod
def get_blockchain(cls) -> Blockchain:
# Docstring inherited
Expand Down
1 change: 0 additions & 1 deletion pantos/servicenode/blockchains/cronos.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ class CronosClient(EthereumClient):
"""Cronos-specific blockchain client.
"""

@classmethod
def get_blockchain(cls) -> Blockchain:
# Docstring inherited
Expand Down
10 changes: 3 additions & 7 deletions pantos/servicenode/blockchains/ethereum.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ class EthereumClient(BlockchainClient):
"""Ethereum-specific blockchain client.
"""

def __init__(self):
# Docstring inherited
super().__init__()
Expand Down Expand Up @@ -159,8 +158,7 @@ def register_node(self, node_url: str, node_stake: int,
_logger.info('node registration submitted', extra=extra_info)
except Exception:
raise self._create_error('unable to register the service node',
node_url=node_url,
node_stake=node_stake)
node_url=node_url, node_stake=node_stake)

def start_transfer_submission(
self, request: BlockchainClient.TransferSubmissionStartRequest) \
Expand Down Expand Up @@ -318,8 +316,7 @@ def _read_on_chain_transfer_id(self, transaction_id: str,
assert (
transaction_receipt['transactionHash'].hex() == transaction_id)
_logger.info(
'transfer/transferFrom transaction receipt',
extra=json.loads(
'transfer/transferFrom transaction receipt', extra=json.loads(
web3.Web3.to_json(transaction_receipt))) # type: ignore
hub_contract = self._create_hub_contract(node_connections)
if self.get_blockchain() is destination_blockchain:
Expand All @@ -334,8 +331,7 @@ def _read_on_chain_transfer_id(self, transaction_id: str,
except Exception:
raise self._create_error(
'unable to read the Pantos transfer ID on the source '
'blockchain',
transaction_id=transaction_id,
'blockchain', transaction_id=transaction_id,
destination_blockchain=destination_blockchain)

def __create_node_connections(self) -> NodeConnections:
Expand Down
1 change: 0 additions & 1 deletion pantos/servicenode/blockchains/fantom.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ class FantomClient(EthereumClient):
"""Fantom-specific blockchain client.
"""

@classmethod
def get_blockchain(cls) -> Blockchain:
# Docstring inherited
Expand Down
1 change: 0 additions & 1 deletion pantos/servicenode/blockchains/polygon.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ class PolygonClient(EthereumClient):
"""Polygon-specific blockchain client.
"""

@classmethod
def get_blockchain(cls) -> Blockchain:
# Docstring inherited
Expand Down
1 change: 0 additions & 1 deletion pantos/servicenode/blockchains/solana.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ class SolanaClient(BlockchainClient):
"""Solana-specific blockchain client.
"""

def __init__(self):
# Docstring inherited
pass # pragma: no cover
Expand Down
1 change: 0 additions & 1 deletion pantos/servicenode/business/bids.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ class BidInteractor(Interactor):
"""Interactor for managing service node bids.
"""

@dataclasses.dataclass
class Bid:
"""Data for a transfer bid.
Expand Down
1 change: 0 additions & 1 deletion pantos/servicenode/business/node.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ class NodeInteractor(Interactor):
"""Interactor for managing the service node itself.
"""

def update_node_registrations(self) -> None:
"""Update the service node registrations on all supported
blockchains.
Expand Down
1 change: 0 additions & 1 deletion pantos/servicenode/business/plugins.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ class BidPluginInteractor(Interactor):
"""Interactor for handling the bid plugin operations.
"""

def replace_bids(self, source_blockchain: Blockchain) -> int:
"""Replace the old bids with new bids given by the bid plugin.
Additionally, the Validator fee is added to the bid fee.
Expand Down
Loading

0 comments on commit 3c134ee

Please sign in to comment.