pub fn bt_state_string(state: &Value) -> StringExpand description
The string a Blocktrails state is hashed as when it is chained: a string
state is its own text, any other JSON value its JCS (jcs).
This is blocktrails/verify’s stateHash (043e7af): a string state hashes
as its UTF-8 text, never as JSON.stringify of it (which would quote it),
so a git-mark commit is its 40 lowercase hex characters; an object state,
such as an Mrc20State, hashes as its JCS. The MRC20 trails this crate
keeps already store each state’s JCS in state_strings, which is the same
string this function gives for the state as an object.
§Examples
use serde_json::json;
use solid_pod_rs::mrc20::bt_state_string;
let commit = "9adc596cfd1100333393a12f2f41b2d820f16d0b";
assert_eq!(bt_state_string(&json!(commit)), commit);
assert_eq!(bt_state_string(&json!({"b": 1, "a": [true, null]})), r#"{"a":[true,null],"b":1}"#);