diff --git a/operate/ledger/__init__.py b/operate/ledger/__init__.py index 3e1c4327..ef821dcf 100644 --- a/operate/ledger/__init__.py +++ b/operate/ledger/__init__.py @@ -20,12 +20,8 @@ """Ledger helpers.""" import os -import typing as t -from operate.ledger.base import LedgerHelper -from operate.ledger.ethereum import Ethereum -from operate.ledger.solana import Solana -from operate.operate_types import Chain, LedgerType +from operate.operate_types import Chain ETHEREUM_PUBLIC_RPC = os.environ.get("ETHEREUM_RPC", "https://ethereum.publicnode.com") @@ -64,21 +60,6 @@ Chain.MODE: MODE_RPC, } -CHAIN_HELPERS: t.Dict[Chain, t.Type[LedgerHelper]] = { - Chain.ETHEREUM: Ethereum, - Chain.GNOSIS: Ethereum, - Chain.SOLANA: Solana, - Chain.BASE: Ethereum, - Chain.CELO: Ethereum, - Chain.OPTIMISTIC: Ethereum, - Chain.MODE: Ethereum, -} - -LEDGER_HELPERS: t.Dict[LedgerType, t.Type[LedgerHelper]] = { - LedgerType.ETHEREUM: Ethereum, - LedgerType.SOLANA: Solana, -} - # Base currency for each chain CURRENCY_DENOMS = { Chain.ETHEREUM: "ETH", @@ -107,16 +88,6 @@ def get_default_rpc(chain: Chain) -> str: return DEFAULT_RPCS.get(chain, ETHEREUM_RPC) -def get_ledger_helper_by_chain(rpc: str, chain: Chain) -> LedgerHelper: - """Get ledger helper by chain type.""" - return CHAIN_HELPERS.get(chain, Ethereum)(rpc=rpc) - - -def get_ledger_helper_by_ledger(rpc: str, ledger: LedgerHelper) -> LedgerHelper: - """Get ledger helper by ledger type.""" - return LEDGER_HELPERS.get(ledger, Ethereum)(rpc=rpc) # type: ignore - - def get_currency_denom(chain: Chain) -> str: """Get currency denom by chain type.""" return CURRENCY_DENOMS.get(chain, "ETH") diff --git a/operate/ledger/base.py b/operate/ledger/base.py deleted file mode 100644 index 0231b279..00000000 --- a/operate/ledger/base.py +++ /dev/null @@ -1,37 +0,0 @@ -# -*- coding: utf-8 -*- -# ------------------------------------------------------------------------------ -# -# Copyright 2023 Valory AG -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -# ------------------------------------------------------------------------------ - -"""Base class.""" - -import typing as t -from abc import ABC, abstractmethod - - -class LedgerHelper(ABC): # pylint: disable=too-few-public-methods - """Base ledger helper.""" - - api: t.Any - - def __init__(self, rpc: str) -> None: - """Initialize object.""" - self.rpc = rpc - - @abstractmethod - def create_key(self) -> t.Any: - """Create key.""" diff --git a/operate/ledger/ethereum.py b/operate/ledger/ethereum.py deleted file mode 100644 index ac169ead..00000000 --- a/operate/ledger/ethereum.py +++ /dev/null @@ -1,48 +0,0 @@ -# -*- coding: utf-8 -*- -# ------------------------------------------------------------------------------ -# -# Copyright 2023 Valory AG -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -# ------------------------------------------------------------------------------ - -"""Ethereum ledger helpers.""" - -import typing as t - -from aea_ledger_ethereum import EthereumApi, EthereumCrypto - -from operate.ledger.base import LedgerHelper -from operate.operate_types import LedgerType - - -class Ethereum(LedgerHelper): - """Ethereum ledger helper.""" - - api: EthereumApi - - def __init__(self, rpc: str) -> None: - """Initialize object.""" - super().__init__(rpc) - self.api = EthereumApi(address=self.rpc) - - def create_key(self) -> t.Dict: - """Create key.""" - account = EthereumCrypto() - return { - "address": account.address, - "private_key": account.private_key, - "encrypted": False, - "ledger": LedgerType.ETHEREUM, - } diff --git a/operate/ledger/profiles.py b/operate/ledger/profiles.py index f1d71413..2bd4afcd 100644 --- a/operate/ledger/profiles.py +++ b/operate/ledger/profiles.py @@ -164,10 +164,6 @@ Chain.MODE: "0xd988097fb8612cc24eeC14542bC03424c656005f", } -WXDAI = { - Chain.GNOSIS: "0xe91D153E0b41518A2Ce8Dd3D7944Fa863463a97d", -} - WRAPPED_NATIVE_ASSET = { Chain.GNOSIS: "0xe91D153E0b41518A2Ce8Dd3D7944Fa863463a97d", Chain.OPTIMISTIC: "0x4200000000000000000000000000000000000006", diff --git a/operate/ledger/solana.py b/operate/ledger/solana.py deleted file mode 100644 index 53e425b5..00000000 --- a/operate/ledger/solana.py +++ /dev/null @@ -1,38 +0,0 @@ -# -*- coding: utf-8 -*- -# ------------------------------------------------------------------------------ -# -# Copyright 2023 Valory AG -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -# ------------------------------------------------------------------------------ - -"""Solana ledger helpers.""" - -import typing as t - -from operate.ledger.base import LedgerHelper -from operate.operate_types import LedgerType - - -class Solana(LedgerHelper): - """Solana ledger helper.""" - - def create_key(self) -> t.Dict: - """Create key.""" - return { - "address": "", - "private_key": "", - "encrypted": False, - "ledger": LedgerType.SOLANA, - }