Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow configuration of internal parameters #947

Merged
merged 4 commits into from
May 7, 2024
Merged
Show file tree
Hide file tree
Changes from 3 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
5 changes: 4 additions & 1 deletion gnosis/eth/clients/ens_client.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import os
from typing import Any, Dict, List, Optional, Union

import requests
Expand All @@ -22,7 +23,9 @@ def __init__(self, network_id: int):
else: # Fallback to mainnet
url = "https://api.thegraph.com/subgraphs/name/ensdomains/ens/"
self.url = url
self.request_timeout = 5 # Seconds
self.request_timeout = int(
os.environ.get("ENS_CLIENT_REQUEST_TIMEOUT", 5)
) # Seconds
self.request_session = requests.Session()

def is_available(self) -> bool:
Expand Down
5 changes: 4 additions & 1 deletion gnosis/eth/clients/etherscan_client.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import json
import os
import time
from typing import Any, Dict, Optional
from urllib.parse import urljoin
Expand Down Expand Up @@ -115,7 +116,9 @@ def __init__(
self,
network: EthereumNetwork,
api_key: Optional[str] = None,
request_timeout: int = 10,
request_timeout: int = int(
os.environ.get("ETHERSCAN_CLIENT_REQUEST_TIMEOUT", 10)
),
):
self.network = network
self.api_key = api_key
Expand Down
5 changes: 4 additions & 1 deletion gnosis/eth/clients/sourcify_client.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import os
from typing import Any, Dict, List, Optional
from urllib.parse import urljoin

Expand Down Expand Up @@ -34,7 +35,9 @@ def __init__(
network: EthereumNetwork = EthereumNetwork.MAINNET,
base_url_api: str = "https://sourcify.dev",
base_url_repo: str = "https://repo.sourcify.dev/",
request_timeout: int = 10,
request_timeout: int = int(
os.environ.get("SOURCIFY_CLIENT_REQUEST_TIMEOUT", 10)
),
):
self.network = network
self.base_url_api = base_url_api
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import logging
import os
from typing import Any, Dict, List, Optional, Tuple, Union

from eth_account.signers.local import LocalAccount
from eth_typing import ChecksumAddress, HexStr
from hexbytes import HexBytes

from gnosis.eth import EthereumNetwork
from gnosis.eth import EthereumClient, EthereumNetwork
from gnosis.eth.utils import fast_keccak_text
from gnosis.safe import SafeTx

Expand Down Expand Up @@ -35,6 +36,17 @@ class TransactionServiceApi(SafeBaseAPI):
EthereumNetwork.ZKSYNC_MAINNET: "https://safe-transaction-zksync.safe.global",
}

def __init__(
self,
network: EthereumNetwork,
ethereum_client: Optional[EthereumClient] = None,
base_url: Optional[str] = None,
request_timeout: int = int(
os.environ.get("SAFE_TRANSACTION_SERVICE_REQUEST_TIMEOUT", 10)
),
):
super().__init__(network, ethereum_client, base_url, request_timeout)

@classmethod
def create_delegate_message_hash(cls, delegate_address: ChecksumAddress) -> str:
return fast_keccak_text(get_delegate_message(delegate_address))
Expand Down
Loading