Add get chain-id command - #4605
Open
snickerdoodle2 wants to merge 6 commits into
Open
snickerdoodle2 wants to merge 6 commits into
snickerdoodle2 wants to merge 6 commits into
Conversation
snickerdoodle2
force-pushed
the
feat/4597-get-chain-id
branch
from
September 25, 2026 12:53
60758f4 to
18e7724
Compare
ddoktorski
reviewed
Sep 29, 2026
Comment on lines
+34
to
+37
| let chain_id = provider | ||
| .chain_id() | ||
| .await | ||
| .map_err(|err| StarknetCommandError::ProviderError(err.into()))?; |
| * [balance](./sncast/get/balance.md) | ||
| * [block](./sncast/get/block.md) | ||
| * [class-hash-at](./sncast/get/class_hash_at.md) | ||
| * [chain-id](./sncast/get/chain_id.md) |
Contributor
There was a problem hiding this comment.
nit: Put it above class-hash-at for alphabetical order
Contributor
There was a problem hiding this comment.
nit: It can be renamed to chain-id.md
Comment on lines
+21
to
+25
| let builder = if let Some(name) = &self.chain_name { | ||
| builder.field("Chain Name", name) | ||
| } else { | ||
| builder | ||
| }; |
Contributor
There was a problem hiding this comment.
It can be replaced by OutputBuilder.if_some() call
Contributor
There was a problem hiding this comment.
Let's add a test for result 0x0
Comment on lines
+27
to
+28
| let stdout = output.get_output().stdout.clone(); | ||
| let json: serde_json::Value = serde_json::from_slice(&stdout).unwrap(); |
Contributor
There was a problem hiding this comment.
nit:
Suggested change
| let stdout = output.get_output().stdout.clone(); | |
| let json: serde_json::Value = serde_json::from_slice(&stdout).unwrap(); | |
| let json: serde_json::Value = serde_json::from_slice(&output.get_output().stdout).unwrap(); |
This branch has not been deployed
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Closes #4597
Introduced changes
Added command to display chain's ID.
Plain output
JSON output
{ "chain_id": "0x534e5f5345504f4c4941", "chain_name": "SN_SEPOLIA", "command": "get chain-id", "type": "response" }Checklist
CHANGELOG.md