Skip to content

Commit

Permalink
Fix entrypoint
Browse files Browse the repository at this point in the history
  • Loading branch information
Uxio0 committed Oct 13, 2023
1 parent ff2f7ae commit 466846b
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 4 deletions.
6 changes: 5 additions & 1 deletion safe_cli/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,11 @@ def build_safe_cli():
return SafeCli(args.safe_address, args.node_url, args.history)


if __name__ == "__main__":
def main(*args, **kwargs):
safe_cli = build_safe_cli()
safe_cli.print_startup_info()
safe_cli.loop()


if __name__ == "__main__":
main()
6 changes: 4 additions & 2 deletions safe_cli/safe_addresses.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,20 @@
https://github.com/gnosis/safe-deployments/tree/main/src/assets/v1.4.1
https://github.com/gnosis/safe-deployments/tree/main/src/assets/v1.3.0
"""
from typing import Sequence

from eth_typing import ChecksumAddress

from gnosis.eth import EthereumClient


def _get_valid_contract(
ethereum_client: EthereumClient, addresses: ChecksumAddress
ethereum_client: EthereumClient, addresses: Sequence[ChecksumAddress]
) -> ChecksumAddress:
"""
:param ethereum_client:
:param addresses:
:return: First valid contract found in blockchain
:return: First valid contract from the list of addresses provided found in blockchain
"""

for address in addresses:
Expand Down
3 changes: 2 additions & 1 deletion tests/test_entrypoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ def test_build_safe_cli(self, retrieve_all_info_mock: MagicMock):
)

safe_cli = self.build_test_safe_cli()
self.assertIsNone(safe_cli.print_startup_info())
with mock.patch.object(SafeOperator, "is_version_updated", return_value=True):
self.assertIsNone(safe_cli.print_startup_info())
self.assertIsInstance(safe_cli.get_prompt_text(), HTML)
self.assertIsInstance(safe_cli.get_bottom_toolbar(), HTML)

Expand Down
25 changes: 25 additions & 0 deletions tests/test_safe_addresses.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import unittest

from eth_account import Account

from safe_cli.safe_addresses import _get_valid_contract

from .safe_cli_test_case_mixin import SafeCliTestCaseMixin


class TestSafeAddresses(SafeCliTestCaseMixin, unittest.TestCase):
def test_get_valid_contract(self):
addresses = [
Account.create().address,
Account.create().address,
self.safe_contract_V1_4_1.address,
Account.create().address,
]
expected_address = self.safe_contract_V1_4_1.address
self.assertEqual(
_get_valid_contract(self.ethereum_client, addresses), expected_address
)


if __name__ == "__main__":
unittest.main()

0 comments on commit 466846b

Please sign in to comment.