Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
![Python 3.10](https://img.shields.io/badge/Python-3.10-blue.svg)
![Python 3.11](https://img.shields.io/badge/Python-3.11-blue.svg)
![Python 3.12](https://img.shields.io/badge/Python-3.12-blue.svg)
![Python 3.13](https://img.shields.io/badge/Python-3.13-blue.svg)
[![Docker Image Version (latest semver)](https://img.shields.io/docker/v/safeglobal/safe-cli?label=Docker&sort=semver)](https://hub.docker.com/r/safeglobal/safe-cli)

# Safe CLI
Expand All @@ -29,7 +30,7 @@ docker run -it safeglobal/safe-cli safe-cli <checksummed_safe_address> <ethereum

## Using Python PIP

**Prerequisite:** [Python](https://www.python.org/downloads/) >= 3.10 (Python 3.12 is recommended).
**Prerequisite:** [Python](https://www.python.org/downloads/) >= 3.10 (Python 3.13 is recommended).

Once Python is installed on your system, run the following command to install Safe CLI:
```bash
Expand Down
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ dynamic = ["version"]
description = "Command Line Interface for Safe"
readme = "README.md"
license = "MIT"
requires-python = ">=3.8"
requires-python = ">=3.10"
authors = [{ name = "Uxío Fuentefría", email = "uxio@safe.global" }]
classifiers = [
"License :: OSI Approved :: MIT License",
Expand All @@ -26,7 +26,7 @@ dependencies = [
"prompt_toolkit>=3",
"pygments>=2",
"requests>=2",
"safe-eth-py>=7",
"safe-eth-py==7.17.0",
"tabulate>=0.8",
"typer>=0.14.0",
]
Expand Down
4 changes: 2 additions & 2 deletions requirements-test.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
-r requirements.txt
coverage==7.10.6
coverage==7.12.0
flake8==7.3.0
pytest==8.4.2
pytest==9.0.1
pytest-sugar==1.1.1
6 changes: 3 additions & 3 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ packaging>=24.2
prompt_toolkit==3.0.52
pygments==2.19.2
requests==2.32.5
safe-eth-py==7.6.1
safe-eth-py==7.17.0
tabulate==0.9.0
trezor==0.13.10
typer==0.16.0
web3==7.12.0
typer==0.20.0
web3==7.14.0
20 changes: 10 additions & 10 deletions src/safe_cli/operators/safe_operator.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
EthereumNetworkNotSupported,
TxSpeed,
)
from safe_eth.eth.clients import EtherscanClient, EtherscanClientConfigurationProblem
from safe_eth.eth.clients import EtherscanClientV2
from safe_eth.eth.constants import NULL_ADDRESS, SENTINEL_ADDRESS
from safe_eth.eth.contracts import (
get_erc20_contract,
Expand Down Expand Up @@ -112,7 +112,7 @@ def decorated(self, *args, **kwargs):
)
)
if self.etherscan:
url = f"{self.etherscan.base_url}/address/{self.address}"
url = f"{self.etherscan.get_base_url()}address/{self.address}"
print_formatted_text(HTML(f"<b>Try Etherscan instead</b> {url}"))
else:
return f(self, *args, **kwargs)
Expand Down Expand Up @@ -141,7 +141,6 @@ class SafeOperator:
ethereum_client: EthereumClient
ens: ENS
network: EthereumNetwork
etherscan: Optional[EtherscanClient]
safe_tx_service: Optional[TransactionServiceApi]
safe: Safe
safe_contract: Contract
Expand All @@ -161,11 +160,6 @@ def __init__(
self.ethereum_client = EthereumClient(self.node_url)
self.ens = ENS.from_web3(self.ethereum_client.w3)
self.network: EthereumNetwork = self.ethereum_client.get_network()
try:
self.etherscan = EtherscanClient(self.network)
except EtherscanClientConfigurationProblem:
self.etherscan = None

try:
self.safe_tx_service = TransactionServiceApi.from_ethereum_client(
self.ethereum_client
Expand Down Expand Up @@ -196,6 +190,12 @@ def __init__(
self.hw_wallet_manager = get_hw_wallet_manager()
self.interactive = interactive # Disable prompt dialogs

@cached_property
def etherscan(self) -> Optional[EtherscanClientV2]:
if EtherscanClientV2.is_supported_network(self.network):
return EtherscanClientV2(self.network)
return None

@cached_property
def last_default_fallback_handler_address(self) -> ChecksumAddress:
"""
Expand Down Expand Up @@ -843,7 +843,7 @@ def print_info(self):
)

if self.etherscan:
url = f"{self.etherscan.base_url}/address/{self.address}"
url = f"{self.etherscan.get_base_url()}/address/{self.address}"
print_formatted_text(
HTML(
f"<b><ansigreen>Etherscan</ansigreen></b>="
Expand Down Expand Up @@ -903,7 +903,7 @@ def get_safe_cli_info(self) -> SafeCliInfo:
safe_info.master_copy,
safe_info.modules,
safe_info.fallback_handler,
safe_info.guard,
safe_info.transaction_guard,
balance_ether,
safe_info.version,
)
Expand Down
4 changes: 4 additions & 0 deletions tests/test_safe_cli_entry_point.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
from safe_eth.safe.safe import SafeInfo
from safe_eth.util.util import to_0x_hex_str
from typer.testing import CliRunner
from web3.constants import CHECKSUM_ADDRESSS_ZERO

from safe_cli import VERSION
from safe_cli.main import app
Expand Down Expand Up @@ -330,6 +331,7 @@ def test_build_safe_cli(self, retrieve_all_info_mock: MagicMock):
[safe_owner],
1,
"1.4.1",
CHECKSUM_ADDRESSS_ZERO,
)
result = runner.invoke(
app,
Expand Down Expand Up @@ -362,6 +364,7 @@ def test_build_safe_cli_for_owner(
[safe_owner],
1,
"1.4.1",
CHECKSUM_ADDRESSS_ZERO,
)
get_safes_for_owner_mock.return_value = []

Expand Down Expand Up @@ -396,6 +399,7 @@ def test_parse_operator_mode(
[safe_owner],
1,
"1.4.1",
CHECKSUM_ADDRESSS_ZERO,
)
get_command_mock.side_effect = ["tx-service", "exit"]

Expand Down
6 changes: 3 additions & 3 deletions tests/test_safe_operator.py
Original file line number Diff line number Diff line change
Expand Up @@ -278,18 +278,18 @@ def test_change_guard(self):

safe_operator = self.setup_operator(version="1.4.1")
safe = Safe(safe_operator.address, self.ethereum_client)
current_guard = safe.retrieve_guard()
current_guard = safe.retrieve_transaction_guard()
with self.assertRaises(SameGuardException):
safe_operator.change_guard(current_guard)

not_valid_guard = Account.create().address
with self.assertRaises(InvalidGuardException): # Contract does not exist
self.assertTrue(safe_operator.change_guard(not_valid_guard))

new_guard = self.deploy_example_guard()
new_guard = self.deploy_example_transaction_guard()
self.assertTrue(safe_operator.change_guard(new_guard))
self.assertEqual(safe_operator.safe_cli_info.guard, new_guard)
self.assertEqual(safe.retrieve_guard(), new_guard)
self.assertEqual(safe.retrieve_transaction_guard(), new_guard)

def test_change_master_copy(self):
safe_operator = self.setup_operator(version="1.3.0")
Expand Down