From c05518e61c0e8cf401bbcd7ffbbe5eba8bd45969 Mon Sep 17 00:00:00 2001 From: kent-3 <100624004+kent-3@users.noreply.github.com> Date: Sun, 20 Oct 2024 09:36:33 -0400 Subject: [PATCH] cleaning --- src/lib.rs | 123 +++++------------- src/routes/nav.rs | 31 +---- src/routes/pool.rs | 7 +- src/routes/pool/add_liquidity.rs | 4 +- src/routes/pool/pool_creator.rs | 1 + src/routes/pool/pool_manager.rs | 215 ++++++++++--------------------- src/state.rs | 2 - src/types/basic.rs | 4 +- 8 files changed, 115 insertions(+), 272 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 0e3ceaf..5c0059f 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,6 +1,4 @@ #![allow(unused)] -#![allow(mixed_script_confusables)] -#![allow(confusable_idents)] // use codee::string::FromToStringCodec; // use leptos_use::storage::use_local_storage; @@ -10,14 +8,10 @@ use leptos::{ html::{Dialog, Input}, logging::log, prelude::*, - reactive::graph::ReactiveNode, }; use leptos_router::components::{ParentRoute, Route, Router, Routes, A}; use leptos_router_macro::path; -use rsecret::{ - query::{bank::BankQuerier, compute::ComputeQuerier}, - secret_client::CreateQuerierOptions, -}; +use rsecret::query::{bank::BankQuerier, compute::ComputeQuerier}; use secret_toolkit_snip20::{QueryMsg, TokenInfoResponse}; use secretrs::utils::EnigmaUtils; use send_wrapper::SendWrapper; @@ -41,7 +35,7 @@ use constants::{CHAIN_ID, GRPC_URL}; use error::Error; use keplr::{Keplr, Key}; use routes::{pool::*, trade::*}; -use state::{ChainId, Endpoint, KeplrSignals, ProviderConfig, TokenMap}; +use state::{ChainId, Endpoint, KeplrSignals, TokenMap}; use types::Coin; #[component] @@ -50,14 +44,11 @@ pub fn App() -> impl IntoView { // Global Contexts - // provide_context(RwSignal::new(ProviderConfig::new(GRPC_URL, CHAIN_ID))); provide_context(Endpoint::default()); provide_context(ChainId::default()); provide_context(KeplrSignals::new()); provide_context(TokenMap::new()); - // let provider = - // use_context::>().expect("provider config context missing!"); let endpoint = use_context::().expect("endpoint context missing!"); let chain_id = use_context::().expect("chain id context missing!"); let keplr = use_context::().expect("keplr signals context missing!"); @@ -65,13 +56,6 @@ pub fn App() -> impl IntoView { debug!("Loaded {} tokens", token_map.len()); - // Effect::new(move |_| { - // let provider = provider.get(); - // debug!( - // "Endpoint: {}\nChain ID: {}", - // provider.url, provider.chain_id - // ) - // }); Effect::new(move |_| { let enabled = keplr.enabled.get(); let key = keplr.key.get(); @@ -90,10 +74,10 @@ pub fn App() -> impl IntoView { keplr.enabled.set(true); }); - // let update_grpc_url = move |_| { - // debug!("updating client_options.grpc_url"); - // wasm_client.set(Client::new("https://foobar.com".to_string())) - // }; + on_cleanup(move || { + info!("cleaning up "); + keplr_keystorechange_handle.remove() + }); // Actions @@ -127,38 +111,19 @@ pub fn App() -> impl IntoView { // on:click handlers - let enable_keplr = move |_| { + let enable_keplr = move |_: MouseEvent| { enable_keplr_action.dispatch(()); }; - // let disable_keplr = move |_| { - // keplr_sys::disable(CHAIN_ID); - // keplr.enabled.set(false); - // keplr.key.set(None); - // }; + let disable_keplr = move |_: MouseEvent| { + Keplr::disable(CHAIN_ID); + keplr.enabled.set(false); + }; // Node references let options_dialog_ref = NodeRef::::new(); - // Effects - - // open the dialog whenever the "enable_keplr_action" is pending - // Effect::new(move |_| match dialog_ref.get() { - // Some(dialog) => match enable_keplr_action.pending().get() { - // true => { - // let _ = dialog.show_modal(); - // } - // false => dialog.close(), - // }, - // None => (), - // }); - - Owner::on_cleanup(move || { - info!("cleaning up "); - keplr_keystorechange_handle.remove() - }); - // HTML Elements let toggle_options_menu = move |_| match options_dialog_ref.get() { @@ -180,7 +145,6 @@ pub fn App() -> impl IntoView {
- // ρ
"Trader Crow 2"
-
- // "Loading..."

}> - // // you can `.await` resources to avoid dealing with the `None` state - //

- // "User ID: " - // {move || Suspend::new(async move { - // match resource.await { - // Ok(response) => response, - // Err(_) => "error".to_string(), - // } - // })} - //

- // or you can still use .get() to access resources in things like component props - // - // // ... - // - //
-
Pool Details
    @@ -479,7 +377,7 @@ pub fn PoolManager() -> impl IntoView {
- // This works to preserve the query params when navigating to nested routes. + // This preserves the query params when navigating to nested routes.