Skip to content

Commit

Permalink
refactor core.constants
Browse files Browse the repository at this point in the history
  • Loading branch information
ribeirojose committed Feb 20, 2024
1 parent 6af0426 commit e3dd4e7
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 16 deletions.
37 changes: 22 additions & 15 deletions cow_py/core/constants.py
Original file line number Diff line number Diff line change
@@ -1,34 +1,41 @@
from enum import Enum
from typing import Dict
from .chains import Chain

"""
This module contains constants and functions related to the CoW Protocol. It provides mappings of
the main CoW contract addresses to CoW's supported networks.
"""

BUY_ETH_ADDRESS = "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE"

VAULT_RELAYER = "0xC92E8bdf79f0507f65a392b0ab4667716BFE0110"
COMPOSABLE_COW = "0xfdaFc9d1902f4e0b84f65F49f244b32b31013b74"
SETTLEMENT_CONTRACT = "0x9008D19f58AAbD9eD0D60971565AA8510560ab41"
EXTENSIBLE_FALLBACK_HANDLER = "0x2f55e8b20D0B9FEFA187AA7d00B6Cbe563605bF5"

class CowContractAddress(Enum):
VAULT_RELAYER = "0xC92E8bdf79f0507f65a392b0ab4667716BFE0110"
COMPOSABLE_COW = "0xfdaFc9d1902f4e0b84f65F49f244b32b31013b74"
SETTLEMENT_CONTRACT = "0x9008D19f58AAbD9eD0D60971565AA8510560ab41"
EXTENSIBLE_FALLBACK_HANDLER = "0x2f55e8b20D0B9FEFA187AA7d00B6Cbe563605bF5"


def map_address_to_supported_networks(address: str) -> Dict[Chain, str]:
"""
Maps a given address to all supported networks.
:param address: The address to be mapped.
:return: A dictionary mapping the address to each supported chain.
"""
return {chain_id: address for chain_id in Chain}


""" An object containing the addresses of the CoW Protocol settlement contracts for each supported chain. """
COW_PROTOCOL_SETTLEMENT_CONTRACT_CHAIN_ADDRESS_MAP = map_address_to_supported_networks(
SETTLEMENT_CONTRACT
CowContractAddress.SETTLEMENT_CONTRACT
)

""" An object containing the addresses of the CoW Protocol Vault relayer contracts for each supported chain. """
COW_PROTOCOL_VAULT_RELAYER_CHAIN_ADDRESS_MAP = map_address_to_supported_networks(
VAULT_RELAYER
CowContractAddress.VAULT_RELAYER
)

""" An object containing the addresses of the `ExtensibleFallbackHandler` contracts for each supported chain. """
EXTENSIBLE_FALLBACK_HANDLER_CONTRACT_CHAIN_ADDRESS_MAP = (
map_address_to_supported_networks(EXTENSIBLE_FALLBACK_HANDLER)
map_address_to_supported_networks(CowContractAddress.EXTENSIBLE_FALLBACK_HANDLER)
)

""" An object containing the addresses of the `ComposableCow` contracts for each supported chain. """
COMPOSABLE_COW_CONTRACT_CHAIN_ADDRESS_MAP = map_address_to_supported_networks(
COMPOSABLE_COW
CowContractAddress.COMPOSABLE_COW
)
1 change: 1 addition & 0 deletions cow_py/subgraphs/base/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

import httpx


class GraphQLError(Exception):
pass

Expand Down
1 change: 0 additions & 1 deletion tests/core/test_cow_error.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import pytest
from cow_py.core.cow_error import (
CowError,
) # Adjust the import path according to your project structure
Expand Down

0 comments on commit e3dd4e7

Please sign in to comment.