From 78714f053bb82af4a187805d0f94a1d9024fcee1 Mon Sep 17 00:00:00 2001 From: antazoey Date: Thu, 7 Sep 2023 12:17:28 -0500 Subject: [PATCH] feat: restrict to test accounts in local networks [APE-1377] (#21) * test: force test accounts * chore: black * fix: in fix * chore: black again * chore: mycry --- ape_safe/accounts.py | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/ape_safe/accounts.py b/ape_safe/accounts.py index 4281e31..2fd7893 100644 --- a/ape_safe/accounts.py +++ b/ape_safe/accounts.py @@ -5,8 +5,10 @@ from ape.api import AccountAPI, AccountContainerAPI, ReceiptAPI, TransactionAPI from ape.api.address import BaseAddress +from ape.api.networks import LOCAL_NETWORK_NAME from ape.contracts import ContractInstance from ape.logging import logger +from ape.managers.accounts import AccountManager, TestAccountManager from ape.types import AddressType, HexBytes, MessageSignature, SignableMessage from ape.utils import ZERO_ADDRESS, cached_property from ape_ethereum.transactions import TransactionType @@ -176,11 +178,17 @@ def local_signers(self) -> List[AccountAPI]: # NOTE: Is not ordered by signing order # TODO: Skip per user config # TODO: Order per user config - return list( - self.account_manager[address] - for address in self.signers - if address in self.account_manager - ) + container: Union[AccountManager, TestAccountManager] + if ( + self.network_manager.active_provider + and self.provider.network.name == LOCAL_NETWORK_NAME + or self.provider.network.name.endswith("-fork") + ): + container = self.account_manager.test_accounts + else: + container = self.account_manager + + return list(container[address] for address in self.signers if address in container) def get_signatures( self,