Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
kent-3 committed Aug 19, 2024
1 parent 13910e1 commit a7bc4af
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 41 deletions.
10 changes: 5 additions & 5 deletions dist/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0" />


<script type="module" nonce="mY8Yb/pms7oi6Cs+Er587g==">
import init, * as bindings from 'https://kent-3.github.io/secret-leptos/secret-leptos-1cce32ade9d28a25.js';
const wasm = await init('https://kent-3.github.io/secret-leptos/secret-leptos-1cce32ade9d28a25_bg.wasm');
<script type="module" nonce="IcqZPCxFuWaH/SN5llOz+Q==">
import init, * as bindings from 'https://kent-3.github.io/secret-leptos/secret-leptos-37da47e175517847.js';
const wasm = await init('https://kent-3.github.io/secret-leptos/secret-leptos-37da47e175517847_bg.wasm');


window.wasmBindings = bindings;
Expand Down Expand Up @@ -39,8 +39,8 @@
});
</script>

<link rel="modulepreload" href="https://kent-3.github.io/secret-leptos/secret-leptos-1cce32ade9d28a25.js" crossorigin=anonymous integrity="sha384-GXM0tQw/lzpbcp+ia4iAWuzoUTO3GLyt00CDnfhvN7dhHmkdmYZJqpbKZa/HQU8n">
<link rel="preload" href="https://kent-3.github.io/secret-leptos/secret-leptos-1cce32ade9d28a25_bg.wasm" crossorigin=anonymous integrity="sha384-UR999BpHxsj2kA+4azjCGWHggx3PxoGAhc7Qu5YKvWf0jRuN9N49XV0mRI4PPqm4" as="fetch" type="application/wasm"></head>
<link rel="modulepreload" href="https://kent-3.github.io/secret-leptos/secret-leptos-37da47e175517847.js" crossorigin=anonymous integrity="sha384-kGIelXqVMUY0OXdaUWdWZSd2Z9Zm9B2vL5A8kaMcpJJv1apHsj+r3i8Te19bUiPr">
<link rel="preload" href="https://kent-3.github.io/secret-leptos/secret-leptos-37da47e175517847_bg.wasm" crossorigin=anonymous integrity="sha384-QXwJq77Evl8ec2j8kK5Ewm7zZB6TYVynYFsSazILeEPw4wBX2M0nyrV57f7b6LQx" as="fetch" type="application/wasm"></head>

<style>
.spinner {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -476,13 +476,6 @@ function __wbg_get_imports() {
imports.wbg.__wbg_log_b103404cc5920657 = function(arg0) {
console.log(getObject(arg0));
};
imports.wbg.__wbg_open_e1cebf2dfae8bdba = function(arg0) {
const ret = getObject(arg0).open;
return ret;
};
imports.wbg.__wbg_close_1a7c6f85879ea3c4 = function(arg0) {
getObject(arg0).close();
};
imports.wbg.__wbg_preventDefault_c55d86c27b2dfa6e = function(arg0) {
getObject(arg0).preventDefault();
};
Expand All @@ -493,6 +486,13 @@ function __wbg_get_imports() {
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
};
imports.wbg.__wbg_open_e1cebf2dfae8bdba = function(arg0) {
const ret = getObject(arg0).open;
return ret;
};
imports.wbg.__wbg_close_1a7c6f85879ea3c4 = function(arg0) {
getObject(arg0).close();
};
imports.wbg.__wbg_body_b3bb488e8e54bf4b = function(arg0) {
const ret = getObject(arg0).body;
return isLikeNone(ret) ? 0 : addHeapObject(ret);
Expand Down Expand Up @@ -858,16 +858,6 @@ function __wbg_get_imports() {
const ret = getObject(arg0) in getObject(arg1);
return ret;
};
imports.wbg.__wbg_ping_cb8b34dd389cde4c = function() { return handleError(function () {
const ret = window.keplr.ping();
return addHeapObject(ret);
}, arguments) };
imports.wbg.__wbg_enable_70f888566a8088b5 = function() { return handleError(function (arg0, arg1) {
var v0 = getArrayJsValueFromWasm0(arg0, arg1).slice();
wasm.__wbindgen_export_5(arg0, arg1 * 4, 4);
const ret = window.keplr.enable(v0);
return addHeapObject(ret);
}, arguments) };
imports.wbg.__wbg_new_525245e2b9901204 = function() {
const ret = new Object();
return addHeapObject(ret);
Expand All @@ -876,6 +866,12 @@ function __wbg_get_imports() {
const ret = arg0;
return addHeapObject(ret);
};
imports.wbg.__wbg_enable_70f888566a8088b5 = function() { return handleError(function (arg0, arg1) {
var v0 = getArrayJsValueFromWasm0(arg0, arg1).slice();
wasm.__wbindgen_export_5(arg0, arg1 * 4, 4);
const ret = window.keplr.enable(v0);
return addHeapObject(ret);
}, arguments) };
imports.wbg.__wbg_set_f975102236d3c502 = function(arg0, arg1, arg2) {
getObject(arg0)[takeObject(arg1)] = takeObject(arg2);
};
Expand Down Expand Up @@ -906,6 +902,10 @@ function __wbg_get_imports() {
const ret = Array.from(getObject(arg0));
return addHeapObject(ret);
};
imports.wbg.__wbindgen_is_null = function(arg0) {
const ret = getObject(arg0) === null;
return ret;
};
imports.wbg.__wbg_warn_2b3adb99ce26c314 = function(arg0) {
console.warn(getObject(arg0));
};
Expand Down Expand Up @@ -977,10 +977,6 @@ function __wbg_get_imports() {
const ret = getObject(arg0).host;
return addHeapObject(ret);
};
imports.wbg.__wbindgen_is_null = function(arg0) {
const ret = getObject(arg0) === null;
return ret;
};
imports.wbg.__wbg_createTextNode_8bce33cf33bf8f6e = function(arg0, arg1, arg2) {
const ret = getObject(arg0).createTextNode(getStringFromWasm0(arg1, arg2));
return addHeapObject(ret);
Expand Down Expand Up @@ -1263,15 +1259,15 @@ function __wbg_get_imports() {
imports.wbg.__wbg_alert_c1d5ffe256491b29 = function() { return handleError(function (arg0, arg1, arg2) {
getObject(arg0).alert(getStringFromWasm0(arg1, arg2));
}, arguments) };
imports.wbg.__wbindgen_closure_wrapper2627 = function(arg0, arg1, arg2) {
imports.wbg.__wbindgen_closure_wrapper2626 = function(arg0, arg1, arg2) {
const ret = makeClosure(arg0, arg1, 170, __wbg_adapter_46);
return addHeapObject(ret);
};
imports.wbg.__wbindgen_closure_wrapper2633 = function(arg0, arg1, arg2) {
imports.wbg.__wbindgen_closure_wrapper2632 = function(arg0, arg1, arg2) {
const ret = makeMutClosure(arg0, arg1, 386, __wbg_adapter_49);
return addHeapObject(ret);
};
imports.wbg.__wbindgen_closure_wrapper4244 = function(arg0, arg1, arg2) {
imports.wbg.__wbindgen_closure_wrapper4243 = function(arg0, arg1, arg2) {
const ret = makeMutClosure(arg0, arg1, 415, __wbg_adapter_49);
return addHeapObject(ret);
};
Expand Down
Binary file not shown.
15 changes: 11 additions & 4 deletions src/keplr/error.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
#[derive(thiserror::Error, serde::Serialize, serde::Deserialize, Debug, Clone, PartialEq)]
pub enum Error {
#[error("An error occurred in JavaScript: {0}")]
JsError(String),
// #[error("Serialization Error: {0}")]
// SerializationError(#[from] serde_wasm_bindgen::Error),
Js(String),

#[error("Serialization Error: {0}")]
Serialization(String),
}

impl From<js_sys::wasm_bindgen::JsValue> for Error {
Expand All @@ -12,6 +13,12 @@ impl From<js_sys::wasm_bindgen::JsValue> for Error {
.message()
.as_string()
.unwrap_or("unknown JS error".to_string());
Error::JsError(message)
Error::Js(message)
}
}
impl From<serde_wasm_bindgen::Error> for Error {
fn from(error: serde_wasm_bindgen::Error) -> Self {
let message = error.to_string();
Error::Serialization(message)
}
}
12 changes: 4 additions & 8 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,13 +94,6 @@ pub enum QueryAnswer {
pub fn App() -> impl IntoView {
info!("rendering <App/>");

spawn_local(async {
match Keplr::ping().await {
Ok(_) => debug!("Keplr is available!"),
Err(_) => debug!("Keplr is not available!"),
}
});

// Global Context

let keplr = KeplrSignals::new();
Expand Down Expand Up @@ -132,7 +125,10 @@ pub fn App() -> impl IntoView {

let enable_keplr_action: Action<(), bool, SyncStorage> =
Action::new_unsync_with_value(Some(false), move |_: &()| async move {
if Keplr::ping().await.is_err() {
let keplr_extension = js_sys::Reflect::get(&window(), &JsValue::from_str("keplr"))
.expect("unable to check for `keplr` property");

if keplr_extension.is_undefined() || keplr_extension.is_null() {
window()
.alert_with_message("keplr not found")
.expect("alert failed");
Expand Down

0 comments on commit a7bc4af

Please sign in to comment.