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

Set chain ID via BrowserSigner + #137 #131

Merged

Conversation

DanielSchiavini
Copy link
Collaborator

@DanielSchiavini DanielSchiavini commented Feb 5, 2024

Closes #125
Depends on #124
Includes #137

What I did

Set chain ID via BrowserSigner

How I did it

  • Added new property chain_id to BrowserSigner, with getter and setter
  • Added new test

How to verify it

In jupyterlab

!pip install git+https://github.com/DanielSchiavini/titanoboa.git@125/browser-chain-id
import boa
boa.set_browser_env()
boa.env.chain_id = "0x01"
boa.env.chain_id
> "0x01"

Description for the changelog

Allow retrieving and changing chain ID in JupyterLab/Colab via BrowserEnv

Cute Animal Picture

image

"rpc", "eth_chainId", timeout_message=RPC_TIMEOUT_MESSAGE
)

@chain_id.setter
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's call this set_chain_id()

@charles-cooper charles-cooper changed the base branch from 119/browser-rpc to master February 7, 2024 14:18
@DanielSchiavini DanielSchiavini changed the base branch from master to 119/browser-rpc February 7, 2024 14:20
@DanielSchiavini DanielSchiavini deleted the branch vyperlang:master February 7, 2024 15:26
Copy link
Member

@charles-cooper charles-cooper left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm besides one comment

boa/integrations/jupyter/browser.py Outdated Show resolved Hide resolved
@DanielSchiavini DanielSchiavini changed the base branch from 119/browser-rpc to master February 7, 2024 15:28
Copy link
Member

@charles-cooper charles-cooper left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i'm realizing we also need to patch the env whenever chainid is updated. so maybe this is a good time to introduce BrowserEnv

@DanielSchiavini DanielSchiavini changed the title Set chain ID via BrowserSigner Set chain ID via BrowserSigner + #137 Feb 8, 2024
@DanielSchiavini DanielSchiavini merged commit 2c5b4c3 into vyperlang:master Feb 9, 2024
3 of 4 checks passed
@DanielSchiavini DanielSchiavini deleted the 125/browser-chain-id branch February 9, 2024 11:01
"""

def __init__(self, address=None):
super().__init__(rpc=BrowserRPC())
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit -- BrowserRPC() could have side effects, i'd personally put it on its own line --

rpc = BrowserRPC()
super().__init__(rpc=rpc)

Copy link
Member

@charles-cooper charles-cooper left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Set chain_id via BrowserRPC
2 participants