-
Notifications
You must be signed in to change notification settings - Fork 803
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
Add chain properties to chain-spec-builder #7368
base: master
Are you sure you want to change the base?
Add chain properties to chain-spec-builder #7368
Conversation
/// Chain properties in comma-separated KEY=VALUE format. | ||
/// Example: `--properties tokenSymbol=UNIT,tokenDecimals=12,ss58Format=42,isEthereum=false` | ||
#[arg(long)] | ||
pub properties: Option<String>, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pub properties: Option<String>, | |
pub properties: Vec<String>, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed in 1b8e84a.
/// Chain properties in comma-separated KEY=VALUE format. | ||
/// Example: `--properties tokenSymbol=UNIT,tokenDecimals=12,ss58Format=42,isEthereum=false` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/// Chain properties in comma-separated KEY=VALUE format. | |
/// Example: `--properties tokenSymbol=UNIT,tokenDecimals=12,ss58Format=42,isEthereum=false` | |
/// Chain properties in `KEY=VALUE` format. | |
/// | |
/// Multiple `KEY=VALUE` entries can be specified and separated by a comma. | |
/// | |
/// Example: `--properties tokenSymbol=UNIT,tokenDecimals=12,ss58Format=42,isEthereum=false` | |
/// Or: `--properties tokenSymbol=UNIT --properties tokenDecimals=12 --properties ss58Format=42 --properties=isEthereum=false` | |
/// | |
/// The first uses comma as separation and the second passes the argument multiple times. Both | |
/// styles can also be mixed. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added in 1b8e84a.
let key = iter.next().unwrap_or("").trim().to_owned(); | ||
let value_str = iter.next().unwrap_or("").trim(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If they don't exist, it should be an error.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in 1b8e84a.
fn parse_properties(raw: &String, props: &mut sc_chain_spec::Properties) -> Result<(), String> { | ||
for pair in raw.split(',') { | ||
let mut iter = pair.splitn(2, '='); | ||
let key = iter.next().ok_or("Invalid chain property key")?.trim().to_owned(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let key = iter.next().ok_or("Invalid chain property key")?.trim().to_owned(); | |
let key = iter.next().ok_or_else(|| format!("Invalid chain property key: {pair}"))?.trim().to_owned(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Addressed in d9b1292.
Head branch was pushed to by a user without write access
This PR adds support for chain properties to
chain-spec-builder
. Now properties can be specified as such:$ chain-spec-builder create -r $RUNTIME_PATH --properties tokenSymbol=DUMMY,tokenDecimals=6,isEthereum=false