update latest block return

This commit is contained in:
boneyard93501 2021-03-04 01:55:21 -06:00
parent ae66e0e350
commit e2b1d73c94
3 changed files with 12 additions and 14 deletions

View File

@ -1,7 +1,13 @@
(xor
(seq
(call node_1 (service "get_latest_block") ["MC5H2NK6ZIPMR32U7D4W35AWNNVCQX1ENH"] hex_result)
(call %init_peer_id% (returnService "run") [hex_result])
(seq
(call relay ("op" "identity") [])
(call node_1 (service "get_latest_block") [api_key] hex_result)
)
(seq
(call relay ("op" "identity") [])
(call %init_peer_id% (returnService "run") [hex_result])
)
)
(seq
(call relay ("op" "identity") [])

View File

@ -33,17 +33,9 @@ pub fn get_latest_block(api_key: String) -> String {
let curl_cmd:Vec<String> = vec![header.into(), url.into()];
let response = unsafe { curl_request(curl_cmd) };
result_to_string(response)
/*
let raw_string = result_to_string(response);
let obj = serde_json::from_str(&raw_string);
let res = match obj {
Ok(x) => x["result"],
Err(_) => "",
};
String::from(res)
*/
let res = result_to_string(response);
let obj = serde_json::from_str::<serde_json::Value>(&res).unwrap();
serde_json::from_value(obj["result"].clone()).unwrap()
}
#[fce]

View File

@ -7,6 +7,6 @@ edition = "2018"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
fluence = { version = "=0.2.18", features = ["logger"]}
fluence = { version = "=0.3.3", features = ["logger"] }
log = "0.4.8"
serde_json = "1.0.64"