diff --git a/pragma-sdk/pragma_sdk/common/types/currency.py b/pragma-sdk/pragma_sdk/common/types/currency.py index b391c10b..920982b8 100644 --- a/pragma-sdk/pragma_sdk/common/types/currency.py +++ b/pragma-sdk/pragma_sdk/common/types/currency.py @@ -21,20 +21,21 @@ def __init__( ethereum_address: Optional[Address] = None, ): self.id = currency_id - self.decimals = decimals if isinstance(is_abstract_currency, int): is_abstract_currency = bool(is_abstract_currency) self.is_abstract_currency = is_abstract_currency - if starknet_address is None: - starknet_address = 0 - self.starknet_address = starknet_address + self.starknet_address = self._validate_address(starknet_address) + self.ethereum_address = self._validate_address(ethereum_address) - if ethereum_address is None: - ethereum_address = 0 - self.ethereum_address = ethereum_address + def _validate_address(self, address: Optional[Address]) -> int: + if address is None: + return 0 + if isinstance(address, str): + return int(address, 16) + return address @classmethod def from_asset_config(cls, config: AssetConfig) -> Self: diff --git a/pragma-sdk/pragma_sdk/common/types/types.py b/pragma-sdk/pragma_sdk/common/types/types.py index 40a95a27..9db42c61 100644 --- a/pragma-sdk/pragma_sdk/common/types/types.py +++ b/pragma-sdk/pragma_sdk/common/types/types.py @@ -1,7 +1,7 @@ from enum import StrEnum, unique from typing import Dict -Address = int | str +Address = int HexStr = str Decimals = int UnixTimestamp = int