From 2ae125ab3d3a26025cba4e3d3ae487608cf9e86d Mon Sep 17 00:00:00 2001 From: Eliascm17 Date: Wed, 3 May 2023 11:38:12 -0500 Subject: [PATCH] remove app from monorepo (#249) --- Cargo.toml | 2 - app/.gitignore | 13 - app/Cargo.toml | 49 -- app/README.md | 6 - app/build.sh | 26 - app/favicon.ico | Bin 15406 -> 0 bytes app/img/CLOCKWORK.svg | 11 - app/index.html | 34 -- app/src/components/account_info_table.rs | 65 --- app/src/components/backpack.rs | 26 - app/src/components/blocks_table.rs | 70 --- app/src/components/chat.rs | 174 ------- app/src/components/clock.rs | 37 -- app/src/components/connect_button.rs | 197 ------- app/src/components/markets_table.rs | 88 ---- app/src/components/mod.rs | 33 -- app/src/components/navbar.rs | 30 -- app/src/components/page_control.rs | 43 -- app/src/components/phantom_connect.rs | 67 --- app/src/components/search_bar.rs | 224 -------- app/src/components/sidebar.rs | 159 ------ app/src/components/thread_info_table.rs | 99 ---- app/src/components/thread_sim_logs.rs | 181 ------- app/src/components/threads_table.rs | 489 ------------------ .../components/transaction_history_table.rs | 131 ----- app/src/components/transaction_info.rs | 83 --- app/src/context/client.rs | 400 -------------- app/src/context/mod.rs | 5 - app/src/context/user.rs | 9 - app/src/hooks/mod.rs | 3 - app/src/hooks/use_pagination.rs | 98 ---- app/src/hot_keys.rs | 95 ---- app/src/main.rs | 77 --- app/src/pages/account.rs | 63 --- app/src/pages/accounts.rs | 17 - app/src/pages/files.rs | 14 - app/src/pages/home.rs | 10 - app/src/pages/keys.rs | 131 ----- app/src/pages/market.rs | 14 - app/src/pages/mod.rs | 25 - app/src/pages/new_key.rs | 112 ---- app/src/pages/not_found.rs | 7 - app/src/pages/page.rs | 21 - app/src/pages/programs.rs | 17 - app/src/pages/thread.rs | 66 --- app/src/pages/transaction.rs | 53 -- app/src/pyth.rs | 148 ------ app/src/routes.rs | 35 -- app/src/utils.rs | 19 - app/vercel.json | 26 - 50 files changed, 3802 deletions(-) delete mode 100644 app/.gitignore delete mode 100644 app/Cargo.toml delete mode 100644 app/README.md delete mode 100755 app/build.sh delete mode 100644 app/favicon.ico delete mode 100644 app/img/CLOCKWORK.svg delete mode 100644 app/index.html delete mode 100644 app/src/components/account_info_table.rs delete mode 100644 app/src/components/backpack.rs delete mode 100644 app/src/components/blocks_table.rs delete mode 100644 app/src/components/chat.rs delete mode 100644 app/src/components/clock.rs delete mode 100644 app/src/components/connect_button.rs delete mode 100644 app/src/components/markets_table.rs delete mode 100644 app/src/components/mod.rs delete mode 100644 app/src/components/navbar.rs delete mode 100644 app/src/components/page_control.rs delete mode 100644 app/src/components/phantom_connect.rs delete mode 100644 app/src/components/search_bar.rs delete mode 100644 app/src/components/sidebar.rs delete mode 100644 app/src/components/thread_info_table.rs delete mode 100644 app/src/components/thread_sim_logs.rs delete mode 100644 app/src/components/threads_table.rs delete mode 100644 app/src/components/transaction_history_table.rs delete mode 100644 app/src/components/transaction_info.rs delete mode 100644 app/src/context/client.rs delete mode 100644 app/src/context/mod.rs delete mode 100644 app/src/context/user.rs delete mode 100644 app/src/hooks/mod.rs delete mode 100644 app/src/hooks/use_pagination.rs delete mode 100644 app/src/hot_keys.rs delete mode 100644 app/src/main.rs delete mode 100644 app/src/pages/account.rs delete mode 100644 app/src/pages/accounts.rs delete mode 100644 app/src/pages/files.rs delete mode 100644 app/src/pages/home.rs delete mode 100644 app/src/pages/keys.rs delete mode 100644 app/src/pages/market.rs delete mode 100644 app/src/pages/mod.rs delete mode 100644 app/src/pages/new_key.rs delete mode 100644 app/src/pages/not_found.rs delete mode 100644 app/src/pages/page.rs delete mode 100644 app/src/pages/programs.rs delete mode 100644 app/src/pages/thread.rs delete mode 100644 app/src/pages/transaction.rs delete mode 100644 app/src/pyth.rs delete mode 100644 app/src/routes.rs delete mode 100644 app/src/utils.rs delete mode 100644 app/vercel.json diff --git a/Cargo.toml b/Cargo.toml index 41de481e..7ed0b969 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -9,8 +9,6 @@ members = [ "utils" ] -exclude = [ "app" ] - [patch.crates-io] anchor-lang = { git = "https://github.com/coral-xyz/anchor", branch = "master" } anchor-spl = { git = "https://github.com/coral-xyz/anchor", branch = "master", features = ["mint", "token"] } diff --git a/app/.gitignore b/app/.gitignore deleted file mode 100644 index 746f774a..00000000 --- a/app/.gitignore +++ /dev/null @@ -1,13 +0,0 @@ -# Generated by Cargo -# will have compiled files and executables -/target/ -/dist/ -# Remove Cargo.lock from gitignore if creating an executable, leave it for libraries -# More information here https://doc.rust-lang.org/cargo/guide/cargo-toml-vs-cargo-lock.html -Cargo.lock - -# These are backup files generated by rustfmt -**/*.rs.bk - -**/.DS_Store - diff --git a/app/Cargo.toml b/app/Cargo.toml deleted file mode 100644 index e6f70746..00000000 --- a/app/Cargo.toml +++ /dev/null @@ -1,49 +0,0 @@ -[package] -name = "clockwork-app" -version = "2.0.15" -edition = "2021" -description = "The Clockwork Dashboard" -license = "AGPL-3.0-or-later" -homepage = "https://clockwork.xyz" -repository = "https://github.com/clockwork-xyz/app" -documentation = "https://docs.clockwork.xyz" -readme = "./README.md" -keywords = ["solana"] -publish = false - -[dependencies] -anchor-lang = "0.27.0" -bincode = "1.3.3" -bytemuck = "1.13.0" -chrono = "0.4.23" -clockwork-thread-program-v1 = { package = "clockwork-thread-program-v1", path = "../programs/thread/v1", version = "1.4.4", features = ["no-entrypoint"] } -clockwork-thread-program-v2 = { package = "clockwork-thread-program", path = "../programs/thread", version = "=2.0.15", features = ["no-entrypoint"] } -clockwork-network-program = { package = "clockwork-network-program", path = "../programs/network", version = "=2.0.15", features = ["no-entrypoint"] } -clockwork-relayer-api = { path = "../relayer/api", version = "=2.0.15" } -clockwork-cron = { path = "../cron", version = "=2.0.15" } -clockwork-utils = { path = "../utils", version = "=2.0.15" } -dioxus = "0.3.1" -dioxus-router = { version = "0.3.0", features = ["web"] } -dioxus-web = "0.3.0" -gloo-events = "0.1.2" -gloo-storage = "0.2.2" -gloo-timers = "0.2.6" -gloo-utils = "0.1.4" -js-sys = "0.3.61" -log = "0.4" -pyth-sdk-solana = "0.7.1" -reqwest = { version = "0.11.16", features = ["blocking", "json"] } -serde = { version = "1", features = ["derive"] } -serde_json = "1.0" -solana-client-wasm = { git = "https://github.com/clockwork-xyz/solana-playground", rev = "83e485fbb8f8f09a6411d65ffe63823080847cda" } -solana-extra-wasm = { git = "https://github.com/clockwork-xyz/solana-playground", rev = "83e485fbb8f8f09a6411d65ffe63823080847cda" } -uuid = { version = "1.3.0", features = ["v4"] } -wasm-bindgen = "0.2.84" -wasm-bindgen-futures = "0.4.29" -wasm-logger = "0.2" -web-sys = { version = "0.3.61", features = ["Element"] } - -[patch.crates-io] -dioxus = { git = "https://github.com/DioxusLabs/dioxus", branch = "master" } -dioxus-router = { git = "https://github.com/DioxusLabs/dioxus", branch = "master", features = ["web"] } -dioxus-web = { git = "https://github.com/DioxusLabs/dioxus", branch = "master" } diff --git a/app/README.md b/app/README.md deleted file mode 100644 index 4e364200..00000000 --- a/app/README.md +++ /dev/null @@ -1,6 +0,0 @@ -## Get started -- Run `cargo install trunk` -- Run `trunk serve` -- Visit `localhost:8080` - - diff --git a/app/build.sh b/app/build.sh deleted file mode 100755 index ad68cc01..00000000 --- a/app/build.sh +++ /dev/null @@ -1,26 +0,0 @@ -#!/bin/sh -set -e - -# Set the Cargo and Rustup home directories -export HOME="/root" -export CARGO_HOME="$HOME/.cargo" -export RUSTUP_HOME="$HOME/.rustup" - -# Install Rust -curl https://sh.rustup.rs -sSf | sh -s -- -y --default-toolchain stable -export PATH="$CARGO_HOME/bin:$PATH" - -# Set rustc to stable -rustup override set stable - -# Install trunk -cargo install trunk - -# Update wasm target -rustup target add wasm32-unknown-unknown - -# Build the project -trunk build --release - -# Move favicon into /dist folder. -cp favicon.ico dist/favicon.ico diff --git a/app/favicon.ico b/app/favicon.ico deleted file mode 100644 index 1ac151f1dbee3eee694603315f7a84cc2b51c9e0..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 15406 zcmeHOcUV+c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J3IPLm-;ndMQknOaW5Z?HH0BaSkq4UAt4|RzEqFIiOHZz83nXxkZvMfFNWaYN# z$jhJZ@jo{*a{TEx{-x$vs A7XSbN diff --git a/app/img/CLOCKWORK.svg b/app/img/CLOCKWORK.svg deleted file mode 100644 index 5e6b5b5f..00000000 --- a/app/img/CLOCKWORK.svg +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - - - - - - diff --git a/app/index.html b/app/index.html deleted file mode 100644 index f1715ea5..00000000 --- a/app/index.html +++ /dev/null @@ -1,34 +0,0 @@ - - - - - - - - - - - - - - Clockwork - - - - - -
- - - \ No newline at end of file diff --git a/app/src/components/account_info_table.rs b/app/src/components/account_info_table.rs deleted file mode 100644 index e1d80169..00000000 --- a/app/src/components/account_info_table.rs +++ /dev/null @@ -1,65 +0,0 @@ -use anchor_lang::prelude::Pubkey; -use dioxus::prelude::*; -use solana_client_wasm::solana_sdk::account::Account; - -use crate::utils::format_balance; - -#[derive(PartialEq, Props)] -pub struct AccountInfoTableProps { - account: Account, - address: Pubkey, -} - -pub fn AccountInfoTable(cx: Scope) -> Element { - let account = &cx.props.account; - let address = &cx.props.address; - let balance = format_balance(account.lamports, false); - let executable = account.executable; - let owner = account.owner; - cx.render(rsx! { - table { - class: "w-full divide-y divide-slate-800", - tbody { - Row { - label: "Address".to_string(), - value: address.to_string() - } - Row { - label: "Balance".to_string(), - value: balance, - } - Row { - label: "Executable".to_string(), - value: executable.to_string(), - } - Row { - label: "Owner".to_string(), - value: owner.to_string(), - } - } - } - }) -} - -#[derive(PartialEq, Props)] -struct RowProps { - label: String, - value: String, -} - -fn Row(cx: Scope) -> Element { - cx.render(rsx! { - div { - class: "flex justify-between", - id: cx.props.label.as_str(), - div { - class: "table-cell whitespace-nowrap px-2 py-2 text-sm text-slate-500", - "{cx.props.label}" - } - div { - class: "table-cell whitespace-nowrap px-2 py-2 text-sm font-mono text-slate-100", - "{cx.props.value}" - } - } - }) -} diff --git a/app/src/components/backpack.rs b/app/src/components/backpack.rs deleted file mode 100644 index 17a5aa53..00000000 --- a/app/src/components/backpack.rs +++ /dev/null @@ -1,26 +0,0 @@ -#![allow(non_upper_case_globals)] - -use wasm_bindgen::prelude::*; - -#[wasm_bindgen] -extern "C" { - pub type Backpack; - pub static backpack: Backpack; - #[wasm_bindgen(method, getter=isConnected)] - pub fn is_connected(this: &Backpack) -> bool; - #[wasm_bindgen(method)] - pub async fn connect(this: &Backpack) -> JsValue; - #[wasm_bindgen(method)] - pub async fn disconnect(this: &Backpack); - #[wasm_bindgen(method, getter=publicKey)] - pub fn pubkey(this: &Backpack) -> N; - #[wasm_bindgen(method, js_name=signMessage)] - pub async fn sign_message(this: &Backpack, message: Vec, pubkey: Option) -> JsValue; -} - -#[wasm_bindgen] -extern "C" { - pub type N; - #[wasm_bindgen(method, js_name = toString)] - pub fn to_string(this: &N) -> String; -} diff --git a/app/src/components/blocks_table.rs b/app/src/components/blocks_table.rs deleted file mode 100644 index 9e03f82c..00000000 --- a/app/src/components/blocks_table.rs +++ /dev/null @@ -1,70 +0,0 @@ -use dioxus::prelude::*; -use solana_extra_wasm::transaction_status::UiConfirmedBlock; - -use crate::context::Client; - -pub fn BlocksTable(cx: Scope) -> Element { - let block = use_state::>(&cx, || None); - let client_context = use_shared_state::(cx).unwrap(); - - use_future(&cx, (), |_| { - let block = block.clone(); - let client_context = client_context.clone(); - async move { - loop { - if let Some(recent_block) = client_context.read().get_block().await { - block.set(Some(recent_block)); - } - gloo_timers::future::TimeoutFuture::new(1000).await; - } - } - }); - - cx.render(rsx! { - div { - h1 { - class: "text-2xl font-semibold mb-6", - "Blocks" - } - table { - class: "w-full divide-y divide-slate-800", - Header {} - if let Some(block) = block.get() { - rsx! { - tr { - class: "px-3 text-base hover:bg-slate-100 hover:text-slate-900 hover:cursor-pointer focus:bg-slate-900", - td { - class: "whitespace-nowrap px-3 py-4", - "{block.blockhash}" - } - td { - class: "whitespace-nowrap px-3 py-4", - "{block.signatures.as_ref().unwrap_or(&vec![]).len()}" - } - } - } - } - } - } - }) -} - -fn Header(cx: Scope) -> Element { - cx.render(rsx! { - thead { - tr { - class: "text-left text-sm text-slate-500", - th { - class: "py-3 px-3 font-medium", - scope: "col", - "Blockhash" - } - th { - class: "py-3 px-3 font-medium", - scope: "col", - "Transactions" - } - } - } - }) -} diff --git a/app/src/components/chat.rs b/app/src/components/chat.rs deleted file mode 100644 index 0b0cc8cc..00000000 --- a/app/src/components/chat.rs +++ /dev/null @@ -1,174 +0,0 @@ -use dioxus::{html::input_data::keyboard_types::Key, prelude::*}; -use reqwest::header::CONTENT_TYPE; -use serde::{Serialize, Deserialize}; -use wasm_bindgen::JsCast; -use web_sys::HtmlElement; - -pub fn Chat(cx: Scope) -> Element { - let chat_state = use_state::(cx, || ChatState::default()); - - cx.render(rsx! { - div { - class: "absolute inset-x-0 bottom-0 flex flex-col-reverse max-h-[300px] px-3 pb-2 bg-slate-800 rounded-xl", - ChatBar { - chat_state: chat_state.clone() - } - ChatResults { - chat_state:chat_state.clone() - } - } - }) -} - -#[inline_props] -pub fn ChatBar(cx: Scope, chat_state: UseState) -> Element { - let query = &chat_state.get().query.clone(); - - // Move the focus to the chat bar. - // autofocus property on input is having issues: https://github.com/DioxusLabs/dioxus/issues/725 - use_effect(&cx, (), |_| async move { - gloo_timers::future::TimeoutFuture::new(50).await; - let document = gloo_utils::document(); - if let Some(element) = document.get_element_by_id("chat-bar") { - element.unchecked_into::().focus().ok(); - } - }); - - - use_future!(cx, |(chat_state,)| { - async move { - if chat_state.busy && chat_state.query.len() > 0 { - let payload = ChatRequest { - message: chat_state.query.clone() - }; - - let res = reqwest::Client::new() - .post("http://127.0.0.1:5000/chat") - .header(CONTENT_TYPE, "application/json") - .json(&payload) - .send() - .await - .unwrap() - .text() - .await - .unwrap(); - - - let split_text: Vec = res.split('\n').map(|s| s.to_string()).collect(); - - chat_state.modify(|cs| - { - let mut results = cs.results.clone(); - results.push(format!("You: {}", chat_state.query.clone())); - for text in split_text.iter() { - if text.ne(&"Thought: Do I need to use a tool? No".to_string()) { - results.push(text.clone()); - } - } - ChatState { busy: false, query:"".to_string(), results } - } - ); - } - } - }); - - cx.render(rsx! { - div { - class: "relative flex flex-row mt-2 rounded-xl gap-x-4 self-stretch lg:gap-x-6 shadow-sm", - input { - class: "w-full h-12 bg-slate-700 rounded-xl border-0 px-4 py-1.5 text-gray-100 shadow-sm ring-0.5 placeholder:text-gray-400 focus:ring-0 focus:outline-0 sm:text-lg sm:leading-6", - id: "chat-bar", - r#type: "text", - placeholder: "Send a message to ClockworkGPT...", - value: "{query}", - oninput: move |e| { - let query_str = e.value.clone().as_str().to_string(); - chat_state.modify(|cs| ChatState {query: query_str, results: cs.results.clone(), ..*cs}); - }, - onclick: move |e| e.stop_propagation(), - onkeydown: move |e| { - if e.key() == Key::Enter { - chat_state.modify(|cs| ChatState { query: cs.query.clone(), results: cs.results.clone(), busy: true}); - } - } - } - button { - onclick: move |_| { - chat_state.modify(|cs| ChatState { query: cs.query.clone(), results: cs.results.clone(), busy: true}); - - }, - class: "absolute inset-y-0 right-4 px-2 my-1 text-slate-100 hover:bg-slate-600 active:bg-slate-400 active:text-slate-900 active:ring-0 active:focus-0 transition text-sm font-medium rounded", - svg { - xmlns: "http://www.w3.org/2000/svg", - fill: "none", - view_box: "0 0 24 24", - stroke_width: "1.5", - stroke: "currentColor", - class: "w-5 h-5", - path { - stroke_linecap: "round", - stroke_linejoin: "round", - d: "M6 12L3.269 3.126A59.768 59.768 0 0121.485 12 59.77 59.77 0 013.27 20.876L5.999 12zm0 0h7.5" - } - } - } - } - }) -} - -#[inline_props] -pub fn ChatResults(cx: Scope, chat_state: UseState) -> Element { - let results = chat_state.results.clone(); - - if !results.is_empty() { - cx.render(rsx! { - div { - id: "results", - class: "flex flex-col w-full mt-2 space-y-4 mx-auto px-4 overflow-y-auto", - for result in results.iter() { - rsx! { - ChatResultRow { - chat_result: result.to_string(), - } - } - } - } - }) - } else { - None - } -} - - -#[derive(PartialEq, Clone, Props)] -pub struct ChatResultRowProps { - pub chat_result: String -} - -pub fn ChatResultRow(cx: Scope) -> Element { - use_effect(&cx, (), |_| async move { - let document = gloo_utils::document(); - if let Some(element) = document.get_element_by_id("results") { - element.unchecked_into::().set_scroll_top(10000); - } - }); - - cx.render(rsx! { - p { - class: "text-md text-slate-400", - "{cx.props.chat_result}" - } - }) -} - -#[derive(Debug, Serialize, Deserialize)] -pub struct ChatRequest { - message: String -} - -#[derive(Debug, Default)] -pub struct ChatState { - pub busy: bool, - pub query: String, - pub results: Vec, -} \ No newline at end of file diff --git a/app/src/components/clock.rs b/app/src/components/clock.rs deleted file mode 100644 index 827d2d9a..00000000 --- a/app/src/components/clock.rs +++ /dev/null @@ -1,37 +0,0 @@ -use chrono::Utc; -use dioxus::prelude::*; -use dioxus_router::Link; -use solana_client_wasm::WasmClient; - -pub fn Clock(cx: Scope) -> Element { - let blockhash = use_state(&cx, || String::new()); - let slot = use_state(&cx, || 0); - let time = use_state(&cx, || Utc::now()); - - use_future(&cx, (), |_| { - let blockhash = blockhash.clone(); - let slot = slot.clone(); - let time = time.clone(); - let client = WasmClient::new("http://74.118.139.244:8899"); - async move { - loop { - blockhash.set(client.get_latest_blockhash().await.unwrap().to_string()); - time.set(Utc::now()); - slot.set(client.get_slot().await.unwrap()); - gloo_timers::future::TimeoutFuture::new(1000).await; - } - } - }); - - cx.render(rsx! { - div { - class: "fixed bottom-0 right-0 p-4", - Link { - to: "https://explorer.solana.com/block/{slot}", - class: "hover:underline", - new_tab: true, - format!("Block: {} {}", slot, time.to_rfc3339()) - } - } - }) -} diff --git a/app/src/components/connect_button.rs b/app/src/components/connect_button.rs deleted file mode 100644 index 5595183f..00000000 --- a/app/src/components/connect_button.rs +++ /dev/null @@ -1,197 +0,0 @@ -use clockwork_utils::pubkey::Abbreviated; -use dioxus::prelude::*; -use gloo_events::EventListener; -use gloo_storage::{LocalStorage, Storage}; -use solana_client_wasm::solana_sdk::pubkey::Pubkey; -use std::str::FromStr; - -use super::backpack::backpack; -use crate::{ - context::{Client, Cluster, User}, - utils::format_balance, -}; - -pub fn ConnectButton(cx: Scope) -> Element { - let user_context = use_shared_state::(cx).unwrap(); - let client_context = use_shared_state::(cx).unwrap(); - let show_popover = use_state(&cx, || false); - let show_cluster_dropdown = use_state(&cx, || false); - - use_effect(cx, (), |_| { - let user_context = user_context.clone(); - let client_context = client_context.clone(); - async move { - // load user from local storage - match LocalStorage::get::("user_context") { - Ok(u) => { - let mut uc_write = user_context.write(); - uc_write.account = u.account; - uc_write.pubkey = u.pubkey; - } - Err(_err) => log::info!("user is not logged in"), - } - // load cluster from local storage - match LocalStorage::get::("cluster") { - Ok(cluster) => *client_context.write() = Client::new_with_config(cluster), - Err(_err) => log::info!("cached cluster not found"), - } - } - }); - - let handle_click = move |_| { - cx.spawn({ - let user_context = user_context.clone(); - let client_context = client_context.clone(); - let show_popover = show_popover.clone(); - let client_context = client_context.clone(); - async move { - let user_context_read = user_context.read(); - let client_context = client_context.read(); - match user_context_read.account.is_some() { - true => { - show_popover.set(!*show_popover.get()); - } - _ => { - // Check if the provider is not connected before connecting - if !backpack.is_connected() { - backpack.connect().await; - } - log::info!("connected: {:?}", backpack.is_connected()); - if backpack.is_connected() { - let pubkey = - Pubkey::from_str(backpack.pubkey().to_string().as_str()).unwrap(); - let account = client_context.client.get_account(&pubkey).await; - match account { - Ok(acc) => { - drop(user_context_read); - user_context.write().account = Some(acc.clone()); - user_context.write().pubkey = Some(pubkey); - LocalStorage::set( - "user_context", - User { - pubkey: user_context.read().pubkey, - account: user_context.read().account.clone(), - }, - ) - .unwrap(); - LocalStorage::set("cluster", client_context.cluster.clone()) - .unwrap(); - } - - Err(err) => log::info!("Failed to get user account: {:?}", err), - } - } - } - } - } - }); - }; - - use_future(&cx, (), |_| { - let client_context = client_context.clone(); - let show_cluster_dropdown = show_cluster_dropdown.clone(); - async move { - let document = gloo_utils::document(); - Some(EventListener::new(&document, "click", move |_| { - let document = gloo_utils::document(); - if let Some(element) = document.active_element() { - let element_id = element.id(); - let e_id = element_id.as_str(); - match e_id { - "Mainnet" | "Devnet" => { - let cluster = Cluster::from_str(e_id).unwrap(); - *client_context.write() = Client::new_with_config(cluster); - LocalStorage::set("cluster", client_context.write().cluster.clone()) - .unwrap(); - let _ = web_sys::window().unwrap().location().reload(); - show_cluster_dropdown.set(false); - } - _ => {} - } - } - })) - } - }); - - let connect_text = if let Some(pubkey) = user_context.read().pubkey { - pubkey.abbreviated() - } else { - String::from("Connect") - }; - - cx.render(rsx! { - button { - class: "px-6 py-3 border rounded-full transition text-slate-100 hover:bg-slate-800 active:bg-slate-100 active:text-slate-900 font-semibold", - onclick: handle_click, - connect_text.as_str() - } - if *show_popover.get() { - rsx! { - div { - class: "absolute top-[60px] right-[34px] transform overflow-hidden h-60 flex flex-col rounded-lg bg-slate-800 px-4 pt-5 items-center pb-4 space-y-4 shadow-xl transition-all sm:my-8 sm:w-full sm:max-w-sm sm:p-6", - div { - class: "w-full flex flex-row justify-between", - p { - class: "text-slate-100 font-semibold", - "{connect_text.as_str()}" - } - Balance {} - } - button { - class: "inline-flex w-full justify-center gap-x-1.5 rounded-md bg-white px-3 py-2 text-sm font-semibold text-gray-900 shadow-sm ring-1 ring-inset ring-gray-300 hover:bg-gray-50", - onclick: move |_| { show_cluster_dropdown.set(true) }, - "{client_context.read().cluster.to_string()}" - svg { - class: "-mr-1 h-5 w-5 text-slate-800", - view_box: "0 0 20 20", - fill: "currentColor", - path { - fill_rule: "evenodd", - d: "M5.23 7.21a.75.75 0 011.06.02L10 11.168l3.71-3.938a.75.75 0 111.08 1.04l-4.25 4.5a.75.75 0 01-1.08 0l-4.25-4.5a.75.75 0 01.02-1.06z", - } - } - } - if *show_cluster_dropdown.get() { - rsx! { - div { - id: "div1", - class: "absolute top-[90px] right-[25px] z-0 mt-2 w-[335px] origin-top-right rounded-md bg-white shadow-lg ring-1 ring-black ring-opacity-5 focus:outline-none", - div { - id: "div2", - class: "py-1", - button { - class: "text-slate-800 block px-4 py-2 text-sm", - id: "Mainnet", - "Mainnet" - } - button { - class: "text-slate-800 block px-4 py-2 text-sm", - id: "Devnet", - "Devnet" - } - } - } - } - } - } - } - } - }) -} - -fn Balance(cx: Scope) -> Element { - let user_context = use_shared_state::(cx).unwrap(); - - let user_balance = if let Some(account) = &user_context.read().account { - format_balance(account.lamports, true) - } else { - String::from("") - }; - - cx.render(rsx! { - div { - class: "text-lg", - user_balance - } - }) -} diff --git a/app/src/components/markets_table.rs b/app/src/components/markets_table.rs deleted file mode 100644 index 3b9f82ff..00000000 --- a/app/src/components/markets_table.rs +++ /dev/null @@ -1,88 +0,0 @@ -use dioxus::prelude::*; -use dioxus_router::Link; - -use crate::pyth::{get_price_feeds, PythFeedPrice, Quotable}; - -pub fn MarketsTable(cx: Scope) -> Element { - let market_data = use_state(&cx, || vec![]); - - use_future(&cx, (), |_| { - let market_data = market_data.clone(); - async move { - loop { - market_data.set(get_price_feeds().await); - gloo_timers::future::TimeoutFuture::new(1000).await; - } - } - }); - - cx.render(rsx! { - div { - class: "max-w-lg", - h1 { - class: "text-2xl font-semibold mb-6", - "Markets" - } - table { - class: "w-full", - Header {} - for (i, feed) in market_data.get().iter().enumerate() { - Row { - elem_id: format!("list-item-{}", i), - price: feed.clone(), - } - } - } - } - }) -} - -fn Header(cx: Scope) -> Element { - cx.render(rsx! { - thead { - tr { - class: "text-left text-sm text-slate-500", - th { - class: "py-3 px-3 font-medium", - scope: "col", - "Ticker" - } - th { - class: "py-3 px-3 font-medium", - scope: "col", - "Price" - } - } - } - }) -} - -#[derive(PartialEq, Props)] -struct RowProps<'a> { - elem_id: String, - price: PythFeedPrice<'a>, -} - -fn Row<'a>(cx: Scope<'a, RowProps<'a>>) -> Element { - let address = cx.props.price.pubkey; - let quote = cx.props.price.price.quote(); - let cell_class = "table-cell whitespace-nowrap first:pl-3 first:rounded-tl first:rounded-bl last:rounded-tr last:rounded-br py-2"; - cx.render(rsx! { - Link { - // class: "px-3 text-base hover:bg-slate-100 hover:text-slate-900 hover:cursor-pointer focus:bg-slate-900", - to: "/accounts/markets/{address}", - class: "table-row font-mono text-sm transition hover:cursor-pointer hover:bg-slate-800 active:bg-slate-100 active:text-slate-900", - id: cx.props.elem_id.as_str(), - div { - // class: "whitespace-nowrap px-3 py-4", - class: cell_class, - "{cx.props.price.ticker}" - } - div { - // class: "whitespace-nowrap px-3 py-4", - class: cell_class, - "{quote}" - } - } - }) -} diff --git a/app/src/components/mod.rs b/app/src/components/mod.rs deleted file mode 100644 index 2db35376..00000000 --- a/app/src/components/mod.rs +++ /dev/null @@ -1,33 +0,0 @@ -pub mod account_info_table; -pub mod backpack; -pub mod blocks_table; -pub mod chat; -pub mod clock; -pub mod connect_button; -pub mod markets_table; -pub mod navbar; -pub mod page_control; -pub mod search_bar; -pub mod sidebar; -pub mod thread_info_table; -pub mod thread_sim_logs; -pub mod threads_table; -pub mod transaction_history_table; -pub mod transaction_info; - -pub use account_info_table::*; -pub use backpack::*; -pub use blocks_table::*; -pub use chat::*; -pub use clock::*; -pub use connect_button::*; -pub use markets_table::*; -pub use navbar::*; -pub use page_control::*; -pub use search_bar::*; -pub use sidebar::*; -pub use thread_info_table::*; -pub use thread_sim_logs::*; -pub use threads_table::*; -pub use transaction_history_table::*; -pub use transaction_info::*; \ No newline at end of file diff --git a/app/src/components/navbar.rs b/app/src/components/navbar.rs deleted file mode 100644 index 175eeee1..00000000 --- a/app/src/components/navbar.rs +++ /dev/null @@ -1,30 +0,0 @@ -use dioxus::prelude::*; -use dioxus_router::Link; - -use crate::components::{ConnectButton, SearchButton}; - -pub fn Navbar(cx: Scope) -> Element { - cx.render(rsx! { - div { - class: "flex flex-row justify-between w-screen p-8", - Logo {} - div { - class: "flex items-center space-x-4", - SearchButton {} - ConnectButton {} - } - } - }) -} - -pub fn Logo(cx: Scope) -> Element { - cx.render(rsx! { - Link { - to: "/", - class: "flex items-center w-40", - img { - src: "/img/CLOCKWORK.svg", - } - } - }) -} diff --git a/app/src/components/page_control.rs b/app/src/components/page_control.rs deleted file mode 100644 index fa6d7e9c..00000000 --- a/app/src/components/page_control.rs +++ /dev/null @@ -1,43 +0,0 @@ -use dioxus::prelude::*; - -use crate::hooks::UsePagination; - -#[inline_props] -pub fn PageControl(cx: Scope, paginated_data: UsePagination) -> Element { - let button_class = "py-2 px-6 text-slate-100 hover:bg-slate-800 active:bg-slate-100 active:text-slate-900 transition text-sm font-medium rounded"; - let hidden_button_class = "py-2 px-6 text-slate-100 hover:bg-slate-800 active:bg-slate-100 active:text-slate-900 transition text-sm font-medium rounded invisible"; - let back_button_class = if paginated_data.current_page().gt(&1) { - button_class - } else { - hidden_button_class - }; - - let forward_button_class = if paginated_data - .current_page() - .eq(&paginated_data.total_pages()) - { - hidden_button_class - } else { - button_class - }; - - cx.render(rsx! { - div { - class: "flex items-center justify-center space-x-4 mt-2", - button { - class: back_button_class, - onclick: move |_| { paginated_data.prev_page() }, - "←" - } - div { - class: "text-sm text-slate-100", - "{paginated_data.current_page()} of {paginated_data.total_pages()}" - } - button { - class: forward_button_class, - onclick: move |_| { paginated_data.next_page() }, - "→" - } - } - }) -} diff --git a/app/src/components/phantom_connect.rs b/app/src/components/phantom_connect.rs deleted file mode 100644 index df8682ff..00000000 --- a/app/src/components/phantom_connect.rs +++ /dev/null @@ -1,67 +0,0 @@ -use super::phantom::{solana, ConnectResponse}; -use wasm_bindgen_futures::spawn_local; -use yew::{function_component, html, Callback, Html, MouseEvent, Properties, use_state}; -use std::ops::Deref; -use log; - -use super::button::Button; - -#[derive(Properties, PartialEq)] -pub struct Props { - #[prop_or_default] - pub onclick: Callback, -} - -#[function_component] -pub fn PhantomConnect(_: &Props) -> Html { - let account_handle = use_state(|| "".to_string()); - let account = account_handle.deref().clone(); - let has_account = account.trim().is_empty(); - - let handle_click = Callback::from(move |_: MouseEvent| { - let account_handle = account_handle.clone(); - let account = account_handle.deref().clone(); - - spawn_local(async move { - match account != "".to_string() { - true => { - let response = solana.disconnect().await; - log::info!("disconnected: {:?}", response); - account_handle.set("".to_string()); - - } - _ => { - let response = solana.connect().await; - log::info!("connected: {:?}", solana.is_connected()); - if solana.is_connected() { - let response: ConnectResponse = response.into_serde().unwrap(); - log::info!("disconnected: {:?}", response.public_key); - account_handle.set(response.public_key) - } - } - }; - }); - }); - - let connect_hint_text = match has_account { - true => "Connect to Phantom Wallet".to_owned(), - false => format!("Connected to {:?}", account) - }; - - let connect_text = match has_account { - true => "Login Phantom", - false => "Logout Phantom" - }; - - html! { - <> -

- { connect_hint_text } -

-