Skip to content

Commit

Permalink
adjust fee cap setting
Browse files Browse the repository at this point in the history
  • Loading branch information
miralandlabs committed Aug 10, 2024
1 parent d7d4f80 commit 719d619
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 12 deletions.
8 changes: 4 additions & 4 deletions src/components/settings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ pub fn Settings() -> Element {

// MI
let mut priority_fee_cap = use_priority_fee_cap();
let mut priority_fee_cap_input = use_signal(|| priority_fee_cap.read().0.clone());
let mut priority_fee_cap_input = use_signal(|| priority_fee_cap.read().0);
let mut priority_fee_cap_error = use_signal::<Option<u64>>(|| None);
let is_priority_fee_cap_edited = priority_fee_cap.read().0.ne(&*priority_fee_cap_input.read());

Expand Down Expand Up @@ -315,9 +315,9 @@ pub fn Settings() -> Element {
}
}
div {
class: "w-full flex flex-auto flex-col gap-2 justify-end",
class: "w-full flex flex-auto flex-col gap-2 justify-between",
div {
class: "flex flex-row flex-shrink h-min gap-1 shrink mb-auto",
class: "w-full flex flex-row justify-end flex-shrink h-min gap-1 shrink mb-auto",
input {
class: "bg-transparent dark:text-white text-right px-1 mb-auto rounded font-semibold hover:bg-green-600 transition-colors",
dir: "rtl",
Expand Down Expand Up @@ -362,7 +362,7 @@ pub fn Settings() -> Element {
button {
class: "bg-green-500 hover:bg-green-600 active:bg-green-700 text-white rounded shrink ml-auto transition-colors px-2 py-1",
onclick: move |_| {
priority_fee_cap.set(PriorityFeeCap(priority_fee_cap_input.read().clone()));
priority_fee_cap.set(PriorityFeeCap(*priority_fee_cap_input.read()));
},
"Save"
}
Expand Down
4 changes: 2 additions & 2 deletions src/hooks/use_fee_url.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@ pub fn use_fee_url() -> Signal<FeeUrl> {
}

pub fn use_fee_url_provider() {
let fee_url = use_persistent(KEY, || FeeUrl(FEE_URL.to_string()));
use_context_provider(|| Signal::new(fee_url.get()));
let fee_url = use_persistent(KEY, || FeeUrl(FEE_URL.to_string())).get();
use_context_provider(|| Signal::new(fee_url));
}
8 changes: 4 additions & 4 deletions src/hooks/use_priority_fee_cap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,17 @@ use crate::{gateway::PRIORITY_FEE_CAP, hooks::use_persistent::use_persistent};

const KEY: &str = "priority_fee_cap";

#[derive(Clone, Debug, Default, Deserialize, Serialize, PartialEq)]
#[derive(Clone, Copy, Debug, Default, Deserialize, Serialize, PartialEq)]
pub struct PriorityFeeCap(pub u64);

pub fn use_priority_fee_cap() -> Signal<PriorityFeeCap> {
let priority_fee_cap = use_context::<Signal<PriorityFeeCap>>();
let mut priority_fee_cap_persistent = use_persistent(KEY, || PriorityFeeCap(PRIORITY_FEE_CAP));
use_effect(move || priority_fee_cap_persistent.set(priority_fee_cap.read().clone()));
use_effect(move || priority_fee_cap_persistent.set(*priority_fee_cap.read()));
priority_fee_cap
}

pub fn use_priority_fee_cap_provider() {
let priority_fee_cap = use_persistent(KEY, || PriorityFeeCap(PRIORITY_FEE_CAP));
use_context_provider(|| Signal::new(priority_fee_cap.get()));
let priority_fee_cap = use_persistent(KEY, || PriorityFeeCap(PRIORITY_FEE_CAP)).get();
use_context_provider(|| Signal::new(priority_fee_cap));
}
4 changes: 2 additions & 2 deletions src/hooks/use_rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@ pub fn use_rpc_url() -> Signal<RpcUrl> {
}

pub fn use_rpc_url_provider() {
let rpc = use_persistent(KEY, || RpcUrl(RPC_URL.to_string()));
use_context_provider(|| Signal::new(rpc.get()));
let rpc = use_persistent(KEY, || RpcUrl(RPC_URL.to_string())).get();
use_context_provider(|| Signal::new(rpc));
}

0 comments on commit 719d619

Please sign in to comment.