widget: don't panic on bad GET, bump alloy deps

This commit is contained in:
dr-frmr 2024-07-01 13:54:53 +02:00
parent da90cc49c7
commit 19d5ffc9bd
No known key found for this signature in database
3 changed files with 20 additions and 17 deletions

View File

@ -41,9 +41,9 @@ alloy = { version = "0.1.3", features = [
"signers",
"signer-local",
] }
alloy-primitives = "0.7.5"
alloy-sol-macro = "0.7.5"
alloy-sol-types = "0.7.5"
alloy-primitives = "0.7.6"
alloy-sol-macro = "0.7.6"
alloy-sol-types = "0.7.6"
anyhow = "1.0.71"
async-trait = "0.1.71"
base64 = "0.22.0"

View File

@ -151,7 +151,10 @@ fn fetch_most_recent_blog_posts(n: usize) -> Vec<KinodeBlogPost> {
) {
Ok(response) => serde_json::from_slice::<Vec<KinodeBlogPost>>(response.body())
.expect("Invalid UTF-8 from kinode.org"),
Err(e) => panic!("Failed to fetch blog posts: {:?}", e),
Err(e) => {
println!("Failed to fetch blog posts: {e:?}");
vec![]
}
};
blog_posts.into_iter().rev().take(n as usize).collect()

View File

@ -258,7 +258,6 @@ pub async fn register(
}
pub async fn connect_to_provider(maybe_rpc: Option<String>) -> RootProvider<PubSubFrontend> {
// This ETH provider uses public rpc endpoints to verify registration signatures.
let url = if let Some(rpc_url) = maybe_rpc {
rpc_url
} else {
@ -268,19 +267,20 @@ pub async fn connect_to_provider(maybe_rpc: Option<String>) -> RootProvider<PubS
"Connecting to Optimism RPC at {url}\n\
Specify a different RPC URL with the --rpc flag."
);
let ws = WsConnect::new(url);
// this fails occasionally in certain networking environments. i'm not sure why.
// frustratingly, the exact same call does not fail in the eth module. more investigation needed.
let Ok(client) = ProviderBuilder::new().on_ws(ws).await else {
panic!(
"Error: runtime could not connect to ETH RPC.\n\
This is necessary in order to verify node identity onchain.\n\
Please make sure you are using a valid WebSockets URL if using \
the --rpc flag, and you are connected to the internet."
);
};
println!("Connected to Optimism RPC");
let client = match ProviderBuilder::new().on_ws(WsConnect::new(url)).await {
Ok(client) => client,
Err(e) => {
panic!(
"Error: runtime could not connect to ETH RPC: {e}\n\
This is necessary in order to verify node identity onchain.\n\
Please make sure you are using a valid WebSockets URL if using \
the --rpc flag, and you are connected to the internet."
);
}
};
println!("Connected to Optimism RPC");
client
}