-
Notifications
You must be signed in to change notification settings - Fork 161
Rh instance #161
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
Merged
Merged
Rh instance #161
Changes from 6 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
82175b2
rh-profiles
mihaimarcu2004 66d2b77
fixes
mihaimarcu2004 ca18c7e
fix
mihaimarcu2004 e4ff6c3
correct chain_id
mihaimarcu2004 79d52c5
correct chain_id
mihaimarcu2004 0ea8fea
chain_id logic updated
mihaimarcu2004 ff598de
fix
mihaimarcu2004 d12c0ea
rh_testnet
mihaimarcu2004 bea3c37
construct_profile
mihaimarcu2004 08b317d
naming
mihaimarcu2004 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,61 @@ | ||
| # lighter/endpoint_profiles.py | ||
|
|
||
| from dataclasses import dataclass | ||
|
|
||
|
|
||
| def normalize_base_url(url: str) -> str: | ||
| return url.rstrip("/") | ||
|
|
||
|
|
||
| def join_url(base_url: str, path: str) -> str: | ||
| return f"{base_url.rstrip('/')}/{path.lstrip('/')}" | ||
|
|
||
|
|
||
| @dataclass(frozen=True) | ||
| class EndpointProfile: | ||
| name: str | ||
| api_url: str | ||
| ws_url: str | ||
| chain_id: int | ||
|
|
||
| def __post_init__(self): | ||
| object.__setattr__(self, "api_url", normalize_base_url(self.api_url)) | ||
| object.__setattr__(self, "ws_url", normalize_base_url(self.ws_url)) | ||
|
|
||
|
|
||
| MAINNET = EndpointProfile( | ||
| name="mainnet", | ||
| api_url="https://mainnet.zklighter.elliot.ai", | ||
| ws_url="wss://mainnet.zklighter.elliot.ai/stream", | ||
| chain_id=304, | ||
| ) | ||
|
|
||
| ROBINHOOD = EndpointProfile( | ||
| name="robinhood", | ||
| api_url="https://api.rh.lighter.xyz", | ||
| ws_url="wss://api.rh.lighter.xyz/stream", | ||
| chain_id=466324, | ||
| ) | ||
|
|
||
|
|
||
| TESTNET = EndpointProfile( | ||
| name="testnet", | ||
| api_url="https://testnet.zklighter.elliot.ai", | ||
| ws_url="wss://testnet.zklighter.elliot.ai/stream", | ||
| chain_id=300, | ||
| ) | ||
|
|
||
| DEFAULT_ENDPOINT_PROFILE = MAINNET | ||
|
|
||
| ENDPOINT_PROFILES = { | ||
| MAINNET.name: MAINNET, | ||
| ROBINHOOD.name: ROBINHOOD, | ||
| TESTNET.name: TESTNET, | ||
| } | ||
|
|
||
|
|
||
| def get_endpoint_profile(name: str) -> EndpointProfile: | ||
| try: | ||
| return ENDPOINT_PROFILES[name] | ||
| except KeyError as exc: | ||
| raise ValueError(f"Unknown endpoint profile: {name}") from exc |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.