Skip to content

Commit

Permalink
Remove relaying
Browse files Browse the repository at this point in the history
- Closes #273
  • Loading branch information
Uxio0 committed Oct 13, 2023
1 parent 688bc16 commit 2fadb42
Show file tree
Hide file tree
Showing 7 changed files with 9 additions and 216 deletions.
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,9 @@ Then you should be on the prompt and see information about the Safe, like the ow
Next step would be loading some owners for the Safe. At least `threshold` owners need to be loaded to do operations
on the Safe and at least one of them should have funds for sending transactions.

There're 3 operation modes:
There are 2 operation modes:
- **blockchain**: The default mode, transactions are sent to blockchain.
- **tx-service**: Use `tx-service` command to enable it. Transactions are sent to the Safe Transaction Service (if available on the network), so you will be able to see it on the Safe web interface/mobile apps. At least one signer is needed to send transactions to the service. Txs are **not executed**.
- **relay-service**: Use `relay-service [optional-gas-token]` to enable it. Sends transactions through the Safe Relay Service (if available on the network). If a optional gas token is set, it will be used to send transactions.

Loading owners is not needed if you just want to do `read-only` operations.

Expand Down
93 changes: 0 additions & 93 deletions safe_cli/api/relay_service_api.py

This file was deleted.

36 changes: 8 additions & 28 deletions safe_cli/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,9 @@
from prompt_toolkit.auto_suggest import AutoSuggestFromHistory
from prompt_toolkit.history import FileHistory
from prompt_toolkit.lexers import PygmentsLexer
from web3 import Web3

from safe_cli.operators import (
SafeOperator,
SafeRelayOperator,
SafeServiceNotAvailable,
SafeTxServiceOperator,
)
Expand Down Expand Up @@ -61,18 +59,13 @@ def print_startup_info(self):
self.safe_operator.print_info()

def get_prompt_text(self):
if isinstance(self.prompt_parser.safe_operator, SafeRelayOperator):
return HTML(
f"<bold><ansiblue>relay-service > {safe_address}</ansiblue><ansired> > </ansired></bold>"
)
elif isinstance(self.prompt_parser.safe_operator, SafeTxServiceOperator):
return HTML(
f"<bold><ansiblue>tx-service > {safe_address}</ansiblue><ansired> > </ansired></bold>"
)
elif isinstance(self.prompt_parser.safe_operator, SafeOperator):
return HTML(
f"<bold><ansiblue>blockchain > {safe_address}</ansiblue><ansired> > </ansired></bold>"
)
mode: Optional[str] = "blockchain"
if isinstance(self.prompt_parser.safe_operator, SafeTxServiceOperator):
mode = "tx-service"

return HTML(
f"<bold><ansiblue>blockchain > {safe_address}</ansiblue><ansired> > </ansired></bold>"
)

def get_bottom_toolbar(self):
return HTML(
Expand All @@ -82,7 +75,7 @@ def get_bottom_toolbar(self):

def parse_operator_mode(self, command: str) -> Optional[SafeOperator]:
"""
Parse operator mode to switch between blockchain (default), relay-service, and tx-service
Parse operator mode to switch between blockchain (default) and tx-service
:param command:
:return: SafeOperator if detected
"""
Expand All @@ -93,19 +86,6 @@ def parse_operator_mode(self, command: str) -> Optional[SafeOperator]:
HTML("<b><ansigreen>Sending txs to tx service</ansigreen></b>")
)
return SafeTxServiceOperator(safe_address, node_url)
elif split_command[0] == "relay-service":
if len(split_command) == 2 and Web3.is_checksum_address(
split_command[1]
):
gas_token = split_command[1]
else:
gas_token = None
print_formatted_text(
HTML(
f"<b><ansigreen>Sending txs trough relay service gas-token={gas_token}</ansigreen></b>"
)
)
return SafeRelayOperator(safe_address, node_url, gas_token=gas_token)
elif split_command[0] == "blockchain":
print_formatted_text(
HTML("<b><ansigreen>Sending txs to blockchain</ansigreen></b>")
Expand Down
1 change: 0 additions & 1 deletion safe_cli/operators/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# flake8: noqa F401
from .safe_operator import SafeOperator, SafeServiceNotAvailable
from .safe_relay_operator import SafeRelayOperator
from .safe_tx_service_operator import SafeTxServiceOperator
13 changes: 0 additions & 13 deletions safe_cli/operators/safe_operator.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
from gnosis.safe import InvalidInternalTx, Safe, SafeOperation, SafeTx
from gnosis.safe.multi_send import MultiSend, MultiSendOperation, MultiSendTx

from safe_cli.api.relay_service_api import RelayServiceApi
from safe_cli.api.transaction_service_api import TransactionServiceApi
from safe_cli.ethereum_hd_wallet import get_account_from_words
from safe_cli.safe_addresses import (
Expand Down Expand Up @@ -187,9 +186,6 @@ def __init__(self, address: str, node_url: str):
self.etherscan = EtherscanClient(self.network)
except EtherscanClientConfigurationProblem:
self.etherscan = None
self.safe_relay_service = RelayServiceApi.from_ethereum_client(
self.ethereum_client
)
self.safe_tx_service = TransactionServiceApi.from_ethereum_client(
self.ethereum_client
)
Expand Down Expand Up @@ -645,15 +641,6 @@ def print_info(self):
)
)

if self.safe_relay_service:
url = f"{self.safe_relay_service.base_url}/api/v1/safes/{self.address}/transactions/"
print_formatted_text(
HTML(
f"<b><ansigreen>Safe Relay Service</ansigreen></b>="
f"<ansiblue>{url}</ansiblue>"
)
)

if self.etherscan:
url = f"{self.etherscan.base_url}/address/{self.address}"
print_formatted_text(
Expand Down
73 changes: 0 additions & 73 deletions safe_cli/operators/safe_relay_operator.py

This file was deleted.

6 changes: 0 additions & 6 deletions safe_cli/safe_completer_constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@
"unload_cli_owners": "<address> [<address>...]",
"update": "",
"blockchain": "",
"relay-service": "[<token-address>]",
"tx-service": "",
"drain": "<address>",
}
Expand Down Expand Up @@ -187,11 +186,6 @@
"<b>blockchain</b> sets the default mode for tx service. Transactions will be "
"sent to blockchain"
),
"relay-service": HTML(
"<b>relay-service</b> enables relay-service integration. Transactions will be sent to the "
"relay-service so fees will be deducted from the Safe instead of from the sender. "
"A payment token can be provided to be used instead of Ether (stable coins, WETH and OWL"
),
"tx-service": HTML(
"<b>tx-service</b> enables tx-service integration. Transactions will be sent to the tx-service "
"instead of blockchain, so they will show up on the interface"
Expand Down

0 comments on commit 2fadb42

Please sign in to comment.