Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions spel-cli/src/parse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,15 @@ fn parse_primitive(raw: &str, prim: &str) -> Result<ParsedValue, String> {
_ => Err(format!("Invalid bool '{}': expected true/false", raw)),
},
"string" | "String" => Ok(ParsedValue::Str(raw.to_string())),
// nssa AccountId is SerializeDisplay/DeserializeFromStr: a base58 string on the
// wire, not 32 raw bytes. Normalize any input (base58 / 0xhex / Public-prefixed)
// to canonical base58 and carry it as a string.
"account_id" => {
use base58::ToBase58 as _;
crate::hex::decode_bytes_32(raw)
.map(|b| ParsedValue::Str(b.to_base58()))
.map_err(|e| format!("Invalid account_id '{}': {}", raw, e))
}
other => Ok(ParsedValue::Raw(format!("{}({})", other, raw))),
}
}
Expand Down
2 changes: 2 additions & 0 deletions spel-cli/src/serialize.rs
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,8 @@ fn primitive_to_dynamic(prim: &str, val: &ParsedValue) -> Result<DynamicValue, S
("program_id", ParsedValue::U32Array(vals)) => Ok(DynamicValue::Tuple(
vals.iter().map(|v| DynamicValue::U32(*v)).collect(),
)),
// nssa AccountId serializes via Display (base58 string), not as raw bytes.
("account_id", ParsedValue::Str(s)) => Ok(DynamicValue::Str(s.clone())),
_ => Err(SerializeError::TypeMismatch {
expected: prim.to_string(),
got: format!("{:?}", val),
Expand Down