Skip to content

Commit

Permalink
chore: util linting
Browse files Browse the repository at this point in the history
  • Loading branch information
NotPeopling2day committed Dec 20, 2024
1 parent 9772d5b commit ddc851e
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 29 deletions.
13 changes: 10 additions & 3 deletions ape_alchemy/_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,26 @@
"mainnet",
],
"avalanche": [
"fuji",
"mainnet",
"fuji",
],
"base": [
"mainnet",
"sepolia",
],
"berachain": ["bartio"],
"berachain": [
"bartio",
],
"blast": [
"mainnet",
"sepolia",
],
"bsc": ["mainnet", "testnet", "opbnb", "opbnb-testnet"],
"bsc": [
"mainnet",
"testnet",
"opbnb",
"opbnb-testnet",
],
"crossfi": [
"mainnet",
"testnet",
Expand Down
52 changes: 26 additions & 26 deletions ape_alchemy/provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -260,32 +260,32 @@ def create_access_list(

return super().create_access_list(transaction, block_id=block_id)

def make_request(self, rpc: str, parameters: Optional[Iterable] = None) -> Any:
parameters = parameters or []
try:
result = self.web3.provider.make_request(RPCEndpoint(rpc), parameters)
except HTTPError as err:
response_data = err.response.json() if err.response else {}
if "error" not in response_data:
raise AlchemyProviderError(str(err)) from err

error_data = response_data["error"]
message = (
error_data.get("message", str(error_data))
if isinstance(error_data, dict)
else error_data
)
cls = (
AlchemyFeatureNotAvailable
if "is not available" in message
else AlchemyProviderError
)
raise cls(message) from err

if isinstance(result, dict) and (res := result.get("result")):
return res

return result
# def make_request(self, rpc: str, parameters: Optional[Iterable] = None) -> Any:
# parameters = parameters or []
# try:
# result = self.web3.provider.make_request(RPCEndpoint(rpc), parameters)
# except HTTPError as err:
# response_data = err.response.json() if err.response else {}
# if "error" not in response_data:
# raise AlchemyProviderError(str(err)) from err

# error_data = response_data["error"]
# message = (
# error_data.get("message", str(error_data))
# if isinstance(error_data, dict)
# else error_data
# )
# cls = (
# AlchemyFeatureNotAvailable
# if "is not available" in message
# else AlchemyProviderError
# )
# raise cls(message) from err

# if isinstance(result, dict) and (res := result.get("result")):
# return res

# return result

def send_private_transaction(self, txn: TransactionAPI, **kwargs) -> ReceiptAPI:
"""
Expand Down

0 comments on commit ddc851e

Please sign in to comment.