Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: restrict to test accounts in local networks [APE-1377] #21

Merged
merged 6 commits into from
Sep 7, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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