Skip to content

Commit

Permalink
Move L2 contract to contracts package
Browse files Browse the repository at this point in the history
  • Loading branch information
Uxio0 committed Nov 6, 2023
1 parent 99f3aaa commit cbdc25e
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 69 deletions.
2 changes: 2 additions & 0 deletions safe_cli/contracts/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# flake8: noqa F401
from .safe_to_l2_migration import safe_to_l2_migration
File renamed without changes.
18 changes: 14 additions & 4 deletions safe_cli/operators/safe_operator.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
get_erc721_contract,
get_safe_V1_1_1_contract,
)
from gnosis.eth.utils import get_empty_tx_params
from gnosis.safe import InvalidInternalTx, Safe, SafeOperation, SafeTx
from gnosis.safe.api import TransactionServiceApi
from gnosis.safe.multi_send import MultiSend, MultiSendOperation, MultiSendTx
Expand Down Expand Up @@ -63,7 +64,7 @@
)
from safe_cli.utils import choose_option_question, get_erc_20_list, yes_or_no_question

from .utils.l2_migration import get_l2_migration_v111_data, get_l2_migration_v130_data
from ..contracts import safe_to_l2_migration


@dataclasses.dataclass
Expand Down Expand Up @@ -610,20 +611,29 @@ def update_version_to_l2(
if self.safe.retrieve_nonce() > 0:
raise InvalidNonceException("Nonce must be 0 for non L2 to L2 migration")

l2_migration_contract = self.ethereum_client.w3.eth.contract(
NULL_ADDRESS, abi=safe_to_l2_migration["abi"]
)
if safe_version == "1.1.1":
safe_l2_singleton = safe_deployments["1.3.0"]["GnosisSafeL2"][str(chain_id)]
fallback_handler = safe_deployments["1.3.0"][
"CompatibilityFallbackHandler"
][str(chain_id)]
data = get_l2_migration_v111_data(
self.safe, safe_l2_singleton, fallback_handler
data = HexBytes(
l2_migration_contract.functions.migrateFromV111(
safe_l2_singleton, fallback_handler
).build_transaction(get_empty_tx_params())["data"]
)
elif safe_version in ("1.3.0", "1.4.1"):
safe_l2_singleton = safe_deployments[safe_version]["GnosisSafeL2"][
str(chain_id)
]
fallback_handler = self.safe_cli_info.fallback_handler
data = get_l2_migration_v130_data(self.safe, safe_l2_singleton)
data = HexBytes(
l2_migration_contract.functions.migrateToL2(
safe_l2_singleton
).build_transaction(get_empty_tx_params())["data"]
)
else:
raise InvalidMasterCopyException(
"Current version is not supported to migrate to L2"
Expand Down
Empty file.
64 changes: 0 additions & 64 deletions safe_cli/operators/utils/l2_migration.py

This file was deleted.

2 changes: 1 addition & 1 deletion tests/test_safe_operator.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
from gnosis.safe import Safe
from gnosis.safe.multi_send import MultiSend

from safe_cli.contracts import safe_to_l2_migration
from safe_cli.operators.exceptions import (
AccountNotLoadedException,
ExistingOwnerException,
Expand All @@ -30,7 +31,6 @@
SenderRequiredException,
)
from safe_cli.operators.safe_operator import SafeOperator
from safe_cli.operators.utils.safe_to_l2_migration import safe_to_l2_migration
from safe_cli.utils import get_erc_20_list
from tests.utils import generate_transfers_erc20

Expand Down

0 comments on commit cbdc25e

Please sign in to comment.