-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlib.rs
36 lines (32 loc) · 958 Bytes
/
lib.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
use anyhow::Result;
use serde_json;
use spin_sdk::{
http::{Request,Response},
http_component,
};
/// Send an HTTP request and return the response.
#[http_component]
fn send_outbound(_req: Request) -> Result<Response> {
let rpc_body = serde_json::json!({
"jsonrpc": "2.0",
"id": "sjriddle",
"method": "query",
"params": {
"request_type": "view_account",
"finality": "final",
"account_id": "peechz.near"
}
}).to_string();
let mut res = spin_sdk::outbound_http::send_request(
http::Request::builder()
.method("POST")
.uri("https://rpc.mainnet.near.org")
.header("Content-Type", "application/json")
.header("Accept", "*/*")
.body(Some(rpc_body.into()))?
)?;
res.headers_mut()
.insert("spin-component", "cadre-near-account".try_into()?);
println!("{:?}", res);
Ok(res)
}