from enum import IntEnum
from pathlib import Path

# Addresses came from starkware-libs/starknet-addresses repository: https://github.com/starkware-libs/starknet-addresses
ETH_FEE_CONTRACT_ADDRESS = (
    "0x049d36570d4e46f48e99674bd3fcc84644ddd6b96f7c741b1562b82f9e004dc7"
)

STRK_FEE_CONTRACT_ADDRESS = (
    "0x04718f5a0fc34cc1af16a1cdee98ffb20c31f5cd61d6ab07201858f4287c938d"
)

DEFAULT_DEPLOYER_ADDRESS = (
    "0x02ceed65a4bd731034c01113685c831b01c15d7d432f71afb1cf1634b53a2125"
)

API_VERSION = 0

RPC_CONTRACT_NOT_FOUND_ERROR = 20
RPC_INVALID_MESSAGE_SELECTOR_ERROR = 21
RPC_CLASS_HASH_NOT_FOUND_ERROR = 28
RPC_CONTRACT_ERROR = 40

DEFAULT_ENTRY_POINT_NAME = "__default__"
DEFAULT_L1_ENTRY_POINT_NAME = "__l1_default__"
DEFAULT_ENTRY_POINT_SELECTOR = 0
DEFAULT_DECLARE_SENDER_ADDRESS = 1

# MAX_STORAGE_ITEM_SIZE and ADDR_BOUND must be consistent with the corresponding constant in
# starkware/starknet/common/storage.cairo.
MAX_STORAGE_ITEM_SIZE = 256
ADDR_BOUND = 2**251 - MAX_STORAGE_ITEM_SIZE

FIELD_PRIME = 0x800000000000011000000000000000000000000000000000000000000000001
EC_ORDER = 0x800000000000010FFFFFFFFFFFFFFFFB781126DCAE7B2321E66A241ADC64D2F

# From cairo-lang
# int_from_bytes(b"STARKNET_CONTRACT_ADDRESS")
CONTRACT_ADDRESS_PREFIX = 523065374597054866729014270389667305596563390979550329787219
L2_ADDRESS_UPPER_BOUND = 2**251 - 256

QUERY_VERSION_BASE = 2**128

ROOT_PATH = Path(__file__).parent

# Result of `encode_shortstring("ANY_CALLER")`
ANY_CALLER = 0x414E595F43414C4C4552


# OUTSIDE EXECUTION INTERFACE_VERSION with ID
class OutsideExecutionInterfaceID(IntEnum):
    V1 = 0x68CFD18B92D1907B8BA3CC324900277F5A3622099431EA85DD8089255E4181
    V2 = 0x1D1144BB2138366FF28D8E9AB57456B1D332AC42196230C3A602003C89872


EXPECTED_RPC_VERSION = "0.10.0-rc.1"

ARGENT_V040_CLASS_HASH = (
    0x036078334509B514626504EDC9FB252328D1A240E4E948BEF8D0C08DFF45927F
)
