mirror of
https://github.com/fluencelabs/examples
synced 2024-12-04 19:20:17 +00:00
update latest block return
This commit is contained in:
parent
ae66e0e350
commit
e2b1d73c94
@ -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") [])
|
||||
|
@ -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]
|
||||
|
@ -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"
|
||||
|
Loading…
Reference in New Issue
Block a user