Skip to content

Commit

Permalink
good improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
kent-3 committed Aug 19, 2024
1 parent 3180e0a commit 13910e1
Show file tree
Hide file tree
Showing 16 changed files with 386 additions and 107 deletions.
16 changes: 2 additions & 14 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ tonic = { version = "0.11.0", default-features = false }
# Web support
console_error_panic_hook = "0.1.7"
js-sys = "0.3"
web-sys = "0.3"
# gloo-net = "0.6"
# gloo-storage = "0.3"

Expand All @@ -82,6 +83,6 @@ tracing-subscriber = "0.3"
tracing-subscriber-wasm = "0.1"

# Local
keplr = { path = "../keplr/keplr" }
keplr-sys = { path = "../keplr/keplr-sys" }
rsecret = { path = "../secret-clients/rsecret" }
secretrs = { version = "0.1" }
12 changes: 6 additions & 6 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="7FMyFJtSxiUhB+GeBXVGzA==">
import init, * as bindings from 'https://kent-3.github.io/secret-leptos/secret-leptos-a6c6fd9b4d31a18d.js';
const wasm = await init('https://kent-3.github.io/secret-leptos/secret-leptos-a6c6fd9b4d31a18d_bg.wasm');
<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');


window.wasmBindings = bindings;
Expand All @@ -18,7 +18,7 @@

</script>
<link rel="icon" href="https://kent-3.github.io/secret-leptos/favicon-e9cbd8f50cc65bf2.ico" integrity="sha384&#x2D;YobgLXwtz0GhXVUTHml49p32guapVFlEG8UpQdDVN3kekOqkQi&#x2B;qSXEpwp&#x2B;yM4BW"/>
<link rel="stylesheet" href="https://kent-3.github.io/secret-leptos/input-1e281e73305a75dd.css" integrity="sha384&#x2D;oetCHYGBfUNM84kyFcBMXGp8djsTF4YBWZK4mg1yjqBxJgfjTVf&#x2B;aqfZN7&#x2B;6Tzkf"/>
<link rel="stylesheet" href="https://kent-3.github.io/secret-leptos/input-19d3d6031e6224f1.css" integrity="sha384&#x2D;Llf&#x2F;1z3pS30ykImra&#x2F;t6OnhoWltBvHrJog4vWANEoBZhLszMWX24fL&#x2B;f9mlg3zE3"/>

<script>
function checkResourcesLoaded() {
Expand All @@ -39,8 +39,8 @@
});
</script>

<link rel="modulepreload" href="https://kent-3.github.io/secret-leptos/secret-leptos-a6c6fd9b4d31a18d.js" crossorigin=anonymous integrity="sha384-jRERt5wpq7c3IgcgCviHwLicEDT33Y7dITe70HpmbZjptSQga3w3ljCc7NwcysZ8">
<link rel="preload" href="https://kent-3.github.io/secret-leptos/secret-leptos-a6c6fd9b4d31a18d_bg.wasm" crossorigin=anonymous integrity="sha384-W9KQIgECqP6qPQ4tWbUwSgCJKU12mU9U1I3L9GZgne6q6kTpzTtEHGiooHi1V754" as="fetch" type="application/wasm"></head>
<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>

<style>
.spinner {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,11 @@
line-height: 1.75rem;
}

.text-sm {
font-size: 0.875rem;
line-height: 1.25rem;
}

.font-bold {
font-weight: 700;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -469,16 +469,6 @@ function __wbg_get_imports() {
imports.wbg.__wbg_remove_81fdfdc9088ee033 = function(arg0) {
getObject(arg0).remove();
};
imports.wbg.__wbg_preventDefault_c55d86c27b2dfa6e = function(arg0) {
getObject(arg0).preventDefault();
};
imports.wbg.__wbg_value_d4a95e7a0d390578 = function(arg0, arg1) {
const ret = getObject(arg1).value;
const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
const len1 = WASM_VECTOR_LEN;
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
};
imports.wbg.__wbg_getEnigmaUtils_43f42e9235e0913c = function(arg0, arg1) {
const ret = window.keplr.getEnigmaUtils(getStringFromWasm0(arg0, arg1));
return addHeapObject(ret);
Expand All @@ -493,6 +483,16 @@ function __wbg_get_imports() {
imports.wbg.__wbg_close_1a7c6f85879ea3c4 = function(arg0) {
getObject(arg0).close();
};
imports.wbg.__wbg_preventDefault_c55d86c27b2dfa6e = function(arg0) {
getObject(arg0).preventDefault();
};
imports.wbg.__wbg_value_d4a95e7a0d390578 = function(arg0, arg1) {
const ret = getObject(arg1).value;
const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
const len1 = WASM_VECTOR_LEN;
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
};
imports.wbg.__wbg_body_b3bb488e8e54bf4b = function(arg0) {
const ret = getObject(arg0).body;
return isLikeNone(ret) ? 0 : addHeapObject(ret);
Expand Down Expand Up @@ -675,10 +675,6 @@ function __wbg_get_imports() {
const ret = getObject(arg0).length;
return ret;
};
imports.wbg.__wbg_message_e18bae0a0e2c097a = function(arg0) {
const ret = getObject(arg0).message;
return addHeapObject(ret);
};
imports.wbg.__wbg_disable_ed6a167e9fc723b1 = function(arg0, arg1) {
window.keplr.disable(getStringFromWasm0(arg0, arg1));
};
Expand Down Expand Up @@ -838,6 +834,10 @@ function __wbg_get_imports() {
const ret = window.keplr.getSecret20ViewingKey(getStringFromWasm0(arg0, arg1), getStringFromWasm0(arg2, arg3));
return addHeapObject(ret);
}, arguments) };
imports.wbg.__wbg_message_e18bae0a0e2c097a = function(arg0) {
const ret = getObject(arg0).message;
return addHeapObject(ret);
};
imports.wbg.__wbg_getKey_8255541c6425d853 = function() { return handleError(function (arg0, arg1) {
const ret = window.keplr.getKey(getStringFromWasm0(arg0, arg1));
return addHeapObject(ret);
Expand All @@ -858,6 +858,16 @@ 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 @@ -866,10 +876,6 @@ function __wbg_get_imports() {
const ret = arg0;
return addHeapObject(ret);
};
imports.wbg.__wbg_enable_70f888566a8088b5 = function() { return handleError(function (arg0, arg1) {
const ret = window.keplr.enable(getStringFromWasm0(arg0, arg1));
return addHeapObject(ret);
}, arguments) };
imports.wbg.__wbg_set_f975102236d3c502 = function(arg0, arg1, arg2) {
getObject(arg0)[takeObject(arg1)] = takeObject(arg2);
};
Expand All @@ -884,8 +890,8 @@ function __wbg_get_imports() {
const ret = window.keplr.experimentalSuggestChain(takeObject(arg0));
return addHeapObject(ret);
}, arguments) };
imports.wbg.__wbg_suggestToken_843c76cab321fd73 = function() { return handleError(function (arg0, arg1, arg2, arg3) {
const ret = window.keplr.suggestToken(getStringFromWasm0(arg0, arg1), getStringFromWasm0(arg2, arg3));
imports.wbg.__wbg_suggestToken_843c76cab321fd73 = function() { return handleError(function (arg0, arg1, arg2, arg3, arg4, arg5) {
const ret = window.keplr.suggestToken(getStringFromWasm0(arg0, arg1), getStringFromWasm0(arg2, arg3), arg4 === 0 ? undefined : getStringFromWasm0(arg4, arg5));
return addHeapObject(ret);
}, arguments) };
imports.wbg.__wbg_getOfflineSignerOnlyAmino_ebb2efe1afcd60b6 = function(arg0, arg1) {
Expand All @@ -900,10 +906,6 @@ 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 @@ -975,6 +977,10 @@ 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 @@ -1257,15 +1263,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_wrapper2632 = function(arg0, arg1, arg2) {
const ret = makeClosure(arg0, arg1, 173, __wbg_adapter_46);
imports.wbg.__wbindgen_closure_wrapper2627 = function(arg0, arg1, arg2) {
const ret = makeClosure(arg0, arg1, 170, __wbg_adapter_46);
return addHeapObject(ret);
};
imports.wbg.__wbindgen_closure_wrapper2638 = function(arg0, arg1, arg2) {
imports.wbg.__wbindgen_closure_wrapper2633 = function(arg0, arg1, arg2) {
const ret = makeMutClosure(arg0, arg1, 386, __wbg_adapter_49);
return addHeapObject(ret);
};
imports.wbg.__wbindgen_closure_wrapper4250 = function(arg0, arg1, arg2) {
imports.wbg.__wbindgen_closure_wrapper4244 = function(arg0, arg1, arg2) {
const ret = makeMutClosure(arg0, arg1, 415, __wbg_adapter_49);
return addHeapObject(ret);
};
Expand Down
Binary file added dist/secret-leptos-1cce32ade9d28a25_bg.wasm
Binary file not shown.
Binary file removed dist/secret-leptos-a6c6fd9b4d31a18d_bg.wasm
Binary file not shown.
16 changes: 9 additions & 7 deletions src/error.rs
Original file line number Diff line number Diff line change
@@ -1,27 +1,29 @@
// The Serialize and Deserialize traits are derived to ensure that Errors can be
// transmitted to or from a server, which is necessary for them to function as Resources.
#[derive(thiserror::Error, serde::Serialize, serde::Deserialize, Debug, Clone, PartialEq)]
pub enum Error {
#[error("An error occurred: {0}")]
GenericError(String),
Generic(String),

#[error("A Secret error occurred: {0}")]
SecretError(String),
#[error("An error related to Secret occurred: {0}")]
Secret(String),

#[error(transparent)]
KeplrError(#[from] ::keplr::Error),
#[error("An error related to Keplr occurred: {0}")]
Keplr(#[from] crate::keplr::Error),

#[error("Keplr is not enabled!")]
KeplrDisabled,
}

impl From<rsecret::Error> for Error {
fn from(error: rsecret::Error) -> Self {
Error::SecretError(error.to_string())
Error::Secret(error.to_string())
}
}

impl Error {
pub fn generic(message: impl ToString) -> Self {
let message = message.to_string();
Error::GenericError(message)
Error::Generic(message)
}
}
17 changes: 17 additions & 0 deletions src/keplr/error.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#[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),
}

impl From<js_sys::wasm_bindgen::JsValue> for Error {
fn from(error: js_sys::wasm_bindgen::JsValue) -> Self {
let message = js_sys::Error::from(error)
.message()
.as_string()
.unwrap_or("unknown JS error".to_string());
Error::JsError(message)
}
}
Loading

0 comments on commit 13910e1

Please sign in to comment.