Skip to content
Open
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion src/ape/api/address.py
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ def prepare_transaction(self, txn: "TransactionAPI", **kwargs) -> "TransactionAP
):
raise AccountsError(
f"Transfer value meets or exceeds account balance "
f"for account '{self.address}' on chain '{self.provider.chain_id}' "
f"for account '{self.address}' on chain '{self.chain_manager.chain_id}' "
f"using provider '{self.provider.name}'.\n"
"Are you using the correct account / chain / provider combination?\n"
f"(transfer_value={txn.total_transfer_value}, balance={self.balance})."
Expand Down
4 changes: 3 additions & 1 deletion src/ape/api/networks.py
Original file line number Diff line number Diff line change
Expand Up @@ -1042,7 +1042,9 @@ def explorer(self) -> Optional["ExplorerAPI"]:
Returns:
:class:`ape.api.explorers.ExplorerAPI`, optional
"""
chain_id = None if self.network_manager.active_provider is None else self.provider.chain_id
chain_id = (
None if self.network_manager.active_provider is None else self.chain_manager.chain_id
)
for plugin_name, plugin_tuple in self._plugin_explorers:
ecosystem_name, network_name, explorer_class = plugin_tuple

Expand Down
4 changes: 2 additions & 2 deletions src/ape/managers/_contractscache.py
Original file line number Diff line number Diff line change
Expand Up @@ -421,7 +421,7 @@ def _get_errors(
self, address: AddressType, chain_id: Optional[int] = None
) -> set[type[CustomError]]:
if chain_id is None and self.network_manager.active_provider is not None:
chain_id = self.provider.chain_id
chain_id = self.chain_manager.chain_id
elif chain_id is None:
return set()

Expand All @@ -438,7 +438,7 @@ def _cache_error(
self, address: AddressType, error: type[CustomError], chain_id: Optional[int] = None
):
if chain_id is None and self.network_manager.active_provider is not None:
chain_id = self.provider.chain_id
chain_id = self.chain_manager.chain_id
elif chain_id is None:
return

Expand Down
5 changes: 2 additions & 3 deletions src/ape/managers/chain.py
Original file line number Diff line number Diff line change
Expand Up @@ -605,7 +605,6 @@ def revert_to_block(self, block_number: int):
Args:
block_number (int): The block number to revert to.
"""

self._hash_to_receipt_map = {
h: r for h, r in self._hash_to_receipt_map.items() if r.block_number <= block_number
}
Expand Down Expand Up @@ -821,7 +820,7 @@ def snapshot(self) -> "SnapshotID":
Returns:
:class:`~ape.types.SnapshotID`: The snapshot ID.
"""
chain_id = self.provider.chain_id
chain_id = self.chain_manager.chain_id
snapshot_id = self.provider.snapshot()
if snapshot_id not in self._snapshots[chain_id]:
self._snapshots[chain_id].append(snapshot_id)
Expand All @@ -843,7 +842,7 @@ def restore(self, snapshot_id: Optional["SnapshotID"] = None):
snapshot_id (Optional[:class:`~ape.types.SnapshotID`]): The snapshot ID. Defaults
to the most recent snapshot ID.
"""
chain_id = self.provider.chain_id
chain_id = self.chain_manager.chain_id
if snapshot_id is None and not self._snapshots[chain_id]:
raise ChainError("There are no snapshots to revert to.")
elif snapshot_id is None:
Expand Down
2 changes: 1 addition & 1 deletion src/ape/pytest/fixtures.py
Original file line number Diff line number Diff line change
Expand Up @@ -648,7 +648,7 @@ def restore_snapshot(self, scope: Scope):
if snapshot_id is None:
return

elif snapshot_id not in self.chain_snapshots[self.provider.chain_id]:
elif snapshot_id not in self.chain_snapshots[self.chain_manager.chain_id]:
# Still clear out.
self.snapshots.clear_snapshot_id(scope)
return
Expand Down
6 changes: 3 additions & 3 deletions src/ape_accounts/accounts.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ def sign_authorization(
nonce: Optional[int] = None,
) -> Optional[MessageSignature]:
if chain_id is None:
chain_id = self.provider.chain_id
chain_id = self.chain_manager.chain_id

display_msg = f"Allow **full root access** to '{address}' on {chain_id or 'any chain'}?"
if not click.confirm(click.style(f"{display_msg}\n\nAcknowledge: ", fg="yellow")):
Expand Down Expand Up @@ -294,7 +294,7 @@ def set_delegate(self, contract: Union[BaseAddress, AddressType, str], **txn_kwa
sig = self.sign_authorization(contract_address, nonce=self.nonce + 1)
auth = Authorization.from_signature(
address=contract_address,
chain_id=self.provider.chain_id,
chain_id=self.chain_manager.chain_id,
# NOTE: `tx` uses `self.nonce`
nonce=self.nonce + 1,
signature=sig,
Expand All @@ -312,7 +312,7 @@ def set_delegate(self, contract: Union[BaseAddress, AddressType, str], **txn_kwa
def remove_delegate(self, **txn_kwargs):
sig = self.sign_authorization(ZERO_ADDRESS, nonce=self.nonce + 1)
auth = Authorization.from_signature(
chain_id=self.provider.chain_id,
chain_id=self.chain_manager.chain_id,
address=ZERO_ADDRESS,
# NOTE: `tx` uses `self.nonce`
nonce=self.nonce + 1,
Expand Down
2 changes: 1 addition & 1 deletion src/ape_ethereum/ecosystem.py
Original file line number Diff line number Diff line change
Expand Up @@ -963,7 +963,7 @@ def create_transaction(self, **kwargs) -> "TransactionAPI":
tx_data["chainId"] = int(chain_id, 16)

elif chain_id is None and self.network_manager.active_provider is not None:
tx_data["chainId"] = self.provider.chain_id
tx_data["chainId"] = self.chain_manager.chain_id

if "input" in tx_data:
tx_data["data"] = tx_data.pop("input")
Expand Down
9 changes: 6 additions & 3 deletions src/ape_ethereum/multicall/handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@ def use_multicall():
provider = cls.network_manager.provider
provider.set_code(MULTICALL3_ADDRESS, MULTICALL3_CODE)

if provider.chain_id not in SUPPORTED_CHAINS:
SUPPORTED_CHAINS.append(provider.chain_id)
if cls.chain_manager.chain_id not in SUPPORTED_CHAINS:
SUPPORTED_CHAINS.append(cls.chain_manager.chain_id)

return multicall

Expand All @@ -85,7 +85,10 @@ def contract(self) -> ContractInstance:
contract_type=ContractType.model_validate(MULTICALL3_CONTRACT_TYPE),
)

if self.provider.chain_id not in self.supported_chains and contract.code != MULTICALL3_CODE:
if (
self.chain_manager.chain_id not in self.supported_chains
and contract.code != MULTICALL3_CODE
):
# NOTE: 2nd condition allows for use in local test deployments and fork networks
raise UnsupportedChainError()

Expand Down
6 changes: 3 additions & 3 deletions src/ape_test/accounts.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ def sign_authorization(
nonce: Optional[int] = None,
) -> Optional[MessageSignature]:
if chain_id is None:
chain_id = self.provider.chain_id
chain_id = self.chain_manager.chain_id

try:
signed_authorization = EthAccount.sign_authorization(
Expand Down Expand Up @@ -222,7 +222,7 @@ def set_delegate(self, contract: Union[BaseAddress, AddressType, str], **txn_kwa
sig = self.sign_authorization(contract_address, nonce=self.nonce + 1)
auth = Authorization.from_signature(
address=contract_address,
chain_id=self.provider.chain_id,
chain_id=self.chain_manager.chain_id,
# NOTE: `tx` uses `self.nonce`
nonce=self.nonce + 1,
signature=sig,
Expand All @@ -240,7 +240,7 @@ def set_delegate(self, contract: Union[BaseAddress, AddressType, str], **txn_kwa
def remove_delegate(self, **txn_kwargs):
sig = self.sign_authorization(ZERO_ADDRESS, nonce=self.nonce + 1)
auth = Authorization.from_signature(
chain_id=self.provider.chain_id,
chain_id=self.chain_manager.chain_id,
address=ZERO_ADDRESS,
# NOTE: `tx` uses `self.nonce`
nonce=self.nonce + 1,
Expand Down
2 changes: 2 additions & 0 deletions tests/functional/test_trace.py
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,8 @@ def test_transaction_trace_provider_does_not_implement_client_version(
mock_weird_node = mocker.MagicMock()
mock_weird_node.client_version.side_effect = AttributeError
mock_weird_node.network = ethereum.local
mock_weird_node.chain_id = chain.chain_id
mock_weird_node.get_block.side_effect = chain.provider.get_block

class HackyTransactionTrace(TransactionTrace):
def _discover_calltrace_approach(self) -> CallTreeNode:
Expand Down
Loading