-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: support for Sonic blockchain (#49)
- Loading branch information
1 parent
dc41eed
commit 7689af2
Showing
6 changed files
with
42 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,8 +6,6 @@ | |
.vscode/ | ||
build/ | ||
dist/ | ||
find.sh | ||
local/ | ||
/local/ | ||
.coverage | ||
requirements.txt | ||
tmp |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 10 additions & 7 deletions
17
pantos/common/blockchains/fantom.py → pantos/common/blockchains/sonic.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,34 @@ | ||
"""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 | ||
from pantos.common.blockchains.ethereum import EthereumUtilities | ||
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |