Skip to content

Commit

Permalink
feat: restrict to test accounts in local networks [APE-1377] (#21)
Browse files Browse the repository at this point in the history
* test: force test accounts

* chore: black

* fix: in fix

* chore: black again

* chore: mycry
  • Loading branch information
antazoey authored Sep 7, 2023
1 parent 7bef801 commit 78714f0
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions ape_safe/accounts.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit 78714f0

Please sign in to comment.