Skip to content

Commit fbce1af

Browse files
committed
chore: resolve merge conflicts
2 parents 8e13858 + 5b36700 commit fbce1af

File tree

6 files changed

+37
-22
lines changed

6 files changed

+37
-22
lines changed

README.md

+1-2
Original file line numberDiff line numberDiff line change
@@ -107,8 +107,7 @@ docker run \
107107
apeworx/ape compile
108108
```
109109

110-
**Docker Uninstall Process:** You will need to remove files generated by
111-
docker
110+
**Docker Uninstall Process:** You will need to remove files generated by docker
112111

113112
```bash
114113
sudo rm -rf **\~/.solcx**

src/ape/api/providers.py

+17-10
Original file line numberDiff line numberDiff line change
@@ -616,10 +616,11 @@ def update_settings(self, new_settings: dict):
616616
self.provider_settings.update(new_settings)
617617
self.connect()
618618

619-
def estimate_gas_cost(self, txn: TransactionAPI) -> int:
619+
def estimate_gas_cost(self, txn: TransactionAPI, **kwargs) -> int:
620620
txn_dict = txn.dict()
621621
try:
622-
return self._web3.eth.estimate_gas(txn_dict) # type: ignore
622+
block_id = kwargs.pop("block_identifier", None)
623+
return self.web3.eth.estimate_gas(txn_dict, block_identifier=block_id) # type: ignore
623624
except ValueError as err:
624625
tx_error = self.get_virtual_machine_error(err)
625626

@@ -657,27 +658,33 @@ def get_block(self, block_id: BlockID) -> BlockAPI:
657658
block_data = dict(self.web3.eth.get_block(block_id))
658659
return self.network.ecosystem.decode_block(block_data)
659660

660-
def get_nonce(self, address: str) -> int:
661-
return self.web3.eth.get_transaction_count(address) # type: ignore
661+
def get_nonce(self, address: str, **kwargs) -> int:
662+
block_id = kwargs.pop("block_identifier", None)
663+
return self.web3.eth.get_transaction_count(address, block_identifier=block_id)
662664

663665
def get_balance(self, address: str) -> int:
664-
return self.web3.eth.get_balance(address) # type: ignore
666+
return self.web3.eth.get_balance(address)
665667

666668
def get_code(self, address: str) -> bytes:
667-
return self.web3.eth.get_code(address) # type: ignore
669+
return self.web3.eth.get_code(address)
668670

669-
def get_storage_at(self, address: str, slot: int) -> bytes:
671+
def get_storage_at(self, address: str, slot: int, **kwargs) -> bytes:
672+
block_id = kwargs.pop("block_identifier", None)
670673
try:
671-
return self.web3.eth.get_storage_at(address, slot) # type: ignore
674+
return self.web3.eth.get_storage_at(
675+
address, slot, block_identifier=block_id
676+
) # type: ignore
672677
except ValueError as err:
673678
if "RPC Endpoint has not been implemented" in str(err):
674679
raise APINotImplementedError(str(err)) from err
675680

676681
raise # Raise original error
677682

678-
def send_call(self, txn: TransactionAPI) -> bytes:
683+
def send_call(self, txn: TransactionAPI, **kwargs) -> bytes:
679684
try:
680-
return self.web3.eth.call(txn.dict())
685+
block_id = kwargs.pop("block_identifier", None)
686+
state = kwargs.pop("state_override", None)
687+
return self.web3.eth.call(txn.dict(), block_identifier=block_id, state_override=state)
681688
except ValueError as err:
682689
raise self.get_virtual_machine_error(err) from err
683690

src/ape/contracts/base.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,7 @@ def serialize_transaction(self, *args, **kwargs) -> TransactionAPI:
7979
def __call__(self, *args, **kwargs) -> Any:
8080
txn = self.serialize_transaction(*args, **kwargs)
8181
txn.chain_id = self.provider.network.chain_id
82-
83-
raw_output = self.provider.send_call(txn)
82+
raw_output = self.provider.send_call(txn, **kwargs)
8483
output = self.provider.network.ecosystem.decode_returndata(
8584
self.abi,
8685
raw_output,

src/ape_ethereum/transactions.py

-3
Original file line numberDiff line numberDiff line change
@@ -51,15 +51,12 @@ class AccessList(BaseModel):
5151

5252
class BaseTransaction(TransactionAPI):
5353
def serialize_transaction(self) -> bytes:
54-
5554
if not self.signature:
5655
raise SignatureError("The transaction is not signed.")
5756

5857
txn_data = self.dict(exclude={"sender"})
59-
6058
unsigned_txn = serializable_unsigned_transaction_from_dict(txn_data)
6159
signature = (self.signature.v, to_int(self.signature.r), to_int(self.signature.s))
62-
6360
signed_txn = encode_transaction(unsigned_txn, signature)
6461

6562
if self.sender and EthAccount.recover_transaction(signed_txn) != self.sender:

src/ape_test/providers.py

+7-5
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,10 @@ def disconnect(self):
3333
def update_settings(self, new_settings: dict):
3434
pass
3535

36-
def estimate_gas_cost(self, txn: TransactionAPI) -> int:
36+
def estimate_gas_cost(self, txn: TransactionAPI, **kwargs) -> int:
3737
try:
38-
result = self.web3.eth.estimate_gas(txn.dict()) # type: ignore
39-
return result
38+
block_id = kwargs.pop("block_identifier", None)
39+
return self.web3.eth.estimate_gas(txn.dict(), block_identifier=block_id) # type: ignore
4040
except ValidationError as err:
4141
message = gas_estimation_error_message(err)
4242
raise TransactionError(base_err=err, message=message) from err
@@ -65,13 +65,15 @@ def priority_fee(self) -> int:
6565
"""Returns 0 because test chains do not care about priority fees."""
6666
return 0
6767

68-
def send_call(self, txn: TransactionAPI) -> bytes:
68+
def send_call(self, txn: TransactionAPI, **kwargs) -> bytes:
6969
data = txn.dict(exclude_none=True)
7070
if "gas" not in data or data["gas"] == 0:
7171
data["gas"] = int(1e12)
7272

7373
try:
74-
return self.web3.eth.call(data)
74+
block_id = kwargs.pop("block_identifier", None)
75+
state = kwargs.pop("state_override", None)
76+
return self.web3.eth.call(data, block_identifier=block_id, state_override=state)
7577
except ValidationError as err:
7678
raise VirtualMachineError(base_err=err) from err
7779
except TransactionFailed as err:

tests/functional/test_contract_instance.py

+11
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,17 @@ def test_init_specify_contract_type(
2929
assert contract.myNumber() == 2
3030

3131

32+
def test_call_using_block_identifier(
33+
vyper_contract_instance, owner, chain, networks_connected_to_tester
34+
):
35+
contract = vyper_contract_instance
36+
contract.setNumber(1, sender=owner)
37+
height = chain.blocks.height
38+
contract.setNumber(33, sender=owner)
39+
actual = contract.myNumber(block_identifier=height)
40+
assert actual == 1
41+
42+
3243
def test_repr(contract_instance):
3344
assert re.match(
3445
rf"<TestContract((Sol)|(Vy)) {contract_instance.address}>", repr(contract_instance)

0 commit comments

Comments
 (0)