From 556bca33e1aa1c6d821c5c080c5cd8f33db0fafb Mon Sep 17 00:00:00 2001 From: Uxio Fuentefria <6909403+Uxio0@users.noreply.github.com> Date: Fri, 3 May 2024 11:33:26 +0200 Subject: [PATCH] Remove relay --- gnosis/safe/api/__init__.py | 4 - gnosis/safe/api/relay_service_api.py | 89 ------------------- .../transaction_service_messages.py | 3 + 3 files changed, 3 insertions(+), 93 deletions(-) delete mode 100644 gnosis/safe/api/relay_service_api.py diff --git a/gnosis/safe/api/__init__.py b/gnosis/safe/api/__init__.py index 82e5967bf..b3e310234 100644 --- a/gnosis/safe/api/__init__.py +++ b/gnosis/safe/api/__init__.py @@ -1,12 +1,8 @@ # flake8: noqa F401 from .base_api import SafeAPIException -from .relay_service_api import RelayEstimation, RelaySentTransaction, RelayServiceApi from .transaction_service_api import TransactionServiceApi __all__ = [ "SafeAPIException", - "RelayServiceApi", - "RelayEstimation", - "RelaySentTransaction", "TransactionServiceApi", ] diff --git a/gnosis/safe/api/relay_service_api.py b/gnosis/safe/api/relay_service_api.py deleted file mode 100644 index 9bbce6867..000000000 --- a/gnosis/safe/api/relay_service_api.py +++ /dev/null @@ -1,89 +0,0 @@ -from typing import TypedDict -from urllib.parse import urljoin - -import requests -from eth_typing import ChecksumAddress, HexStr - -from .. import SafeTx -from ..signatures import signature_split -from .base_api import SafeAPIException, SafeBaseAPI - - -class RelayEstimation(TypedDict): - safeTxGas: int - baseGas: int - gasPrice: int - lastUsedNonce: int - gasToken: ChecksumAddress - refundReceiver: ChecksumAddress - - -class RelaySentTransaction(TypedDict): - safeTxHash: HexStr - txHash: HexStr - - -class RelayServiceApi(SafeBaseAPI): - URL_BY_NETWORK = { - # Currently there's no official relayer operated - } - - def send_transaction( - self, safe_address: str, safe_tx: SafeTx - ) -> RelaySentTransaction: - url = urljoin(self.base_url, f"/api/v1/safes/{safe_address}/transactions/") - signatures = [] - for i in range(len(safe_tx.signatures) // 65): - v, r, s = signature_split(safe_tx.signatures, i) - signatures.append( - { - "v": v, - "r": r, - "s": s, - } - ) - - data = { - "to": safe_tx.to, - "value": safe_tx.value, - "data": safe_tx.data.hex() if safe_tx.data else None, - "operation": safe_tx.operation, - "gasToken": safe_tx.gas_token, - "safeTxGas": safe_tx.safe_tx_gas, - "dataGas": safe_tx.base_gas, - "gasPrice": safe_tx.gas_price, - "refundReceiver": safe_tx.refund_receiver, - "nonce": safe_tx.safe_nonce, - "signatures": signatures, - } - response = requests.post(url, json=data, timeout=self.request_timeout) - if not response.ok: - raise SafeAPIException(f"Error posting transaction: {response.content}") - else: - return RelaySentTransaction(response.json()) - - def get_estimation(self, safe_address: str, safe_tx: SafeTx) -> RelayEstimation: - """ - :param safe_address: - :param safe_tx: - :return: RelayEstimation - """ - url = urljoin( - self.base_url, f"/api/v2/safes/{safe_address}/transactions/estimate/" - ) - data = { - "to": safe_tx.to, - "value": safe_tx.value, - "data": safe_tx.data.hex() if safe_tx.data else None, - "operation": safe_tx.operation, - "gasToken": safe_tx.gas_token, - } - response = requests.post(url, json=data, timeout=self.request_timeout) - if not response.ok: - raise SafeAPIException(f"Error posting transaction: {response.content}") - else: - response_json = response.json() - # Convert values to int - for key in ("safeTxGas", "baseGas", "gasPrice"): - response_json[key] = int(response_json[key]) - return RelayEstimation(response_json) diff --git a/gnosis/safe/api/transaction_service_api/transaction_service_messages.py b/gnosis/safe/api/transaction_service_api/transaction_service_messages.py index e24c78050..e213936bd 100644 --- a/gnosis/safe/api/transaction_service_api/transaction_service_messages.py +++ b/gnosis/safe/api/transaction_service_api/transaction_service_messages.py @@ -1,3 +1,6 @@ +""" +Utilities to build EIP712 messages for Safe +""" import time from typing import Dict