diff --git a/.gitignore b/.gitignore index 136bb07..bd1e0d5 100644 --- a/.gitignore +++ b/.gitignore @@ -6,8 +6,6 @@ .vscode/ build/ dist/ -find.sh -local/ +/local/ .coverage -requirements.txt tmp diff --git a/pantos/common/blockchains/enums.py b/pantos/common/blockchains/enums.py index ef62617..2c8a29e 100644 --- a/pantos/common/blockchains/enums.py +++ b/pantos/common/blockchains/enums.py @@ -15,7 +15,9 @@ class Blockchain(enum.IntEnum): SOLANA = 4 POLYGON = 5 CRONOS = 6 - FANTOM = 7 + # Renamed from "FANTOM" to "SONIC" on 2024-10-17 due to + # network renaming + SONIC = 7 CELO = 8 # Decomissioned: AURORA = 9 diff --git a/pantos/common/blockchains/fantom.py b/pantos/common/blockchains/sonic.py similarity index 58% rename from pantos/common/blockchains/fantom.py rename to pantos/common/blockchains/sonic.py index e5fbfc5..6f1c578 100644 --- a/pantos/common/blockchains/fantom.py +++ b/pantos/common/blockchains/sonic.py @@ -1,7 +1,10 @@ -"""Module for Fantom-specific utilities and errors. Since Fantom is +"""Module for Sonic-specific utilities and errors. Since Sonic is Ethereum-compatible, the utilities implementation inherits from the pantos.common.blockchains.ethereum module. +Note that Pantos used to support Sonic's predecessor Fantom. This module +was renamed accordingly on 2024-10-17. + """ from pantos.common.blockchains.base import BlockchainUtilitiesError from pantos.common.blockchains.enums import Blockchain @@ -9,23 +12,23 @@ from pantos.common.blockchains.ethereum import EthereumUtilitiesError -class FantomUtilitiesError(EthereumUtilitiesError): - """Exception class for all Fantom utilities errors. +class SonicUtilitiesError(EthereumUtilitiesError): + """Exception class for all Sonic utilities errors. """ pass -class FantomUtilities(EthereumUtilities): - """Class for Fantom-specific utilities. +class SonicUtilities(EthereumUtilities): + """Class for Sonic-specific utilities. """ @classmethod def get_blockchain(cls) -> Blockchain: # Docstring inherited - return Blockchain.FANTOM + return Blockchain.SONIC @classmethod def get_error_class(cls) -> type[BlockchainUtilitiesError]: # Docstring inherited - return FantomUtilitiesError + return SonicUtilitiesError diff --git a/tests/blockchains/test_factory.py b/tests/blockchains/test_factory.py index f01b48e..601eb5f 100644 --- a/tests/blockchains/test_factory.py +++ b/tests/blockchains/test_factory.py @@ -12,9 +12,9 @@ from pantos.common.blockchains.factory import _blockchain_utilities from pantos.common.blockchains.factory import get_blockchain_utilities from pantos.common.blockchains.factory import initialize_blockchain_utilities -from pantos.common.blockchains.fantom import FantomUtilities from pantos.common.blockchains.polygon import PolygonUtilities from pantos.common.blockchains.solana import SolanaUtilities +from pantos.common.blockchains.sonic import SonicUtilities from pantos.common.exceptions import NotInitializedError @@ -60,8 +60,8 @@ def _get_blockchain_utilities_class(blockchain): return CronosUtilities if blockchain is Blockchain.ETHEREUM: return EthereumUtilities - if blockchain is Blockchain.FANTOM: - return FantomUtilities + if blockchain is Blockchain.SONIC: + return SonicUtilities if blockchain is Blockchain.POLYGON: return PolygonUtilities if blockchain is Blockchain.SOLANA: diff --git a/tests/blockchains/test_fantom.py b/tests/blockchains/test_fantom.py deleted file mode 100644 index 1fb7bc7..0000000 --- a/tests/blockchains/test_fantom.py +++ /dev/null @@ -1,25 +0,0 @@ -import pytest - -from pantos.common.blockchains.enums import Blockchain -from pantos.common.blockchains.fantom import FantomUtilities -from pantos.common.blockchains.fantom import FantomUtilitiesError - - -@pytest.fixture(scope='module') -def fantom_utilities(blockchain_node_urls, fallback_blockchain_node_urls, - average_block_time, required_transaction_confirmations, - transaction_network_id): - return FantomUtilities(blockchain_node_urls, fallback_blockchain_node_urls, - average_block_time, - required_transaction_confirmations, - transaction_network_id) - - -def test_get_blockchain_correct(fantom_utilities): - assert fantom_utilities.get_blockchain() is Blockchain.FANTOM - assert FantomUtilities.get_blockchain() is Blockchain.FANTOM - - -def test_get_error_class_correct(fantom_utilities): - assert fantom_utilities.get_error_class() is FantomUtilitiesError - assert FantomUtilities.get_error_class() is FantomUtilitiesError diff --git a/tests/blockchains/test_sonic.py b/tests/blockchains/test_sonic.py new file mode 100644 index 0000000..f92c8b6 --- /dev/null +++ b/tests/blockchains/test_sonic.py @@ -0,0 +1,25 @@ +import pytest + +from pantos.common.blockchains.enums import Blockchain +from pantos.common.blockchains.sonic import SonicUtilities +from pantos.common.blockchains.sonic import SonicUtilitiesError + + +@pytest.fixture(scope='module') +def sonic_utilities(blockchain_node_urls, fallback_blockchain_node_urls, + average_block_time, required_transaction_confirmations, + transaction_network_id): + return SonicUtilities(blockchain_node_urls, fallback_blockchain_node_urls, + average_block_time, + required_transaction_confirmations, + transaction_network_id) + + +def test_get_blockchain_correct(sonic_utilities): + assert sonic_utilities.get_blockchain() is Blockchain.SONIC + assert SonicUtilities.get_blockchain() is Blockchain.SONIC + + +def test_get_error_class_correct(sonic_utilities): + assert sonic_utilities.get_error_class() is SonicUtilitiesError + assert SonicUtilities.get_error_class() is SonicUtilitiesError