Skip to content

Instantly share code, notes, and snippets.

@GrafMine
Created March 7, 2024 03:33
Show Gist options
  • Save GrafMine/cc6ff262660f8143b9915607428c5df9 to your computer and use it in GitHub Desktop.
Save GrafMine/cc6ff262660f8143b9915607428c5df9 to your computer and use it in GitHub Desktop.
let get_provider = move || {
if let Some(win) = web_sys::window() {
if let Some(_phantom) = win.get("phantom") {
if let Some(phantom) = _phantom.dyn_ref::<js_sys::Object>() {
if let Ok(_solana) = js_sys::Reflect::get(phantom, &"solana".into()) {
if let Some(solana) = _solana.dyn_ref::<js_sys::Object>() {
if let Ok(is_phantom) = js_sys::Reflect::get(solana, &"isPhantom".into()) {
if is_phantom.as_bool() == Some(true) {
set_provider(Some(phantom.clone()));
}
}
}
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment