Skip to content

Commit

Permalink
move update() into ctor and rename to update_address
Browse files Browse the repository at this point in the history
  • Loading branch information
charles-cooper committed Nov 19, 2024
1 parent 9a04659 commit 49a9147
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
7 changes: 4 additions & 3 deletions boa/integrations/jupyter/browser.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,8 @@ def __init__(self, address=None, rpc=None):
self._given_address = address
self.address = address

self.update_address()

def send_transaction(self, tx_data: dict) -> dict:
"""
Implements the Account class' send_transaction method.
Expand All @@ -135,7 +137,7 @@ def sign_typed_data(self, full_message: dict[str, Any]) -> str:
TRANSACTION_TIMEOUT_MESSAGE,
)

def update(self):
def update_address(self):
address = getattr(self._given_address, "address", self._given_address)
accounts = self._rpc.fetch("eth_requestAccounts", [], ADDRESS_TIMEOUT_MESSAGE)

Expand All @@ -146,7 +148,6 @@ def update(self):
raise ValueError(f"Address {address} is not available in the browser")

self.address = Address(address)
return self.address


class BrowserEnv(NetworkEnv):
Expand All @@ -162,7 +163,7 @@ def __init__(self, address=None, **kwargs):
self._update_signer()

def _update_signer(self):
self.signer.update()
self.signer.update_address()
self.add_account(self.signer, force_eoa=True)

def execute_code(self, *args, **kwargs):
Expand Down
3 changes: 1 addition & 2 deletions tests/unitary/jupyter/test_browser.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,6 @@ def test_browser_signer_colab(colab_eval_mock, mocked_token, display_mock):
address = boa.env.generate_address()
colab_eval_mock.return_value = json.dumps({"data": [address]})
signer = BrowserSigner()
signer.update()
assert signer.address == address
colab_eval_mock.assert_called_once()
(js,), _ = colab_eval_mock.call_args
Expand Down Expand Up @@ -315,5 +314,5 @@ def test_browser_js_error(token, display_mock, mock_callback, account, mock_fork
"eth_requestAccounts", error={"message": "custom message", "stack": ""}
)
with pytest.raises(RPCError) as exc_info:
BrowserSigner().update()
BrowserSigner()
assert str(exc_info.value) == "-1: custom message"

0 comments on commit 49a9147

Please sign in to comment.