From a154039d1210bf189e58a5272debfb71ab436fcf Mon Sep 17 00:00:00 2001 From: necipsagiro Date: Wed, 31 Jan 2024 14:59:58 +0300 Subject: [PATCH] Add gas adjustment and output json flag to delegate and redelegate transactions --- src-tauri/src/main.rs | 9 +++++---- src/node-page.js | 4 +++- src/page-content/delegate-token.html | 5 +++++ 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/src-tauri/src/main.rs b/src-tauri/src/main.rs index 7f83d4c..d9bb511 100644 --- a/src-tauri/src/main.rs +++ b/src-tauri/src/main.rs @@ -667,6 +667,7 @@ fn delegate_token( fees: String, exception: String, ) -> Result { + println!("{}", exception); let my_boxed_session = unsafe { GLOBAL_STRUCT.as_ref() }.ok_or("There is no active session. Timed out.")?; let mut channel = my_boxed_session @@ -674,14 +675,14 @@ fn delegate_token( .channel_session() .map_err(|e| e.to_string())?; channel.exec(&format!( - "yes '{password}' | bash -c -l '$EXECUTE tx {operation} delegate {validator_valoper} {amount}$DENOM --from={wallet_name} --fees={fees}$DENOM --chain-id=$CHAIN_ID --gas=auto {extra}'", + "yes '{password}' | bash -c -l '$EXECUTE tx {operation} delegate {validator_valoper} {amount}$DENOM --from={wallet_name} --fees={fees}$DENOM --chain-id=$CHAIN_ID --gas=auto --output json {extra}'", password = my_boxed_session.walletpassword, operation = match exception.as_str() { "babylon" => "epoching", _ => "staking", }, extra = match exception.as_str() { - "babylon" => "--gas-adjustment 1.4", + "babylon" => "--gas-adjustment 1.4 -y", _ => "", } )).map_err(|e| e.to_string())?; @@ -707,14 +708,14 @@ fn redelegate_token( .channel_session() .map_err(|e| e.to_string())?; channel.exec(&*format!( - "yes '{password}' | bash -c -l '$EXECUTE tx {operation} redelegate {first_validator} {destination_validator} {amount}$DENOM --from={wallet_name} --fees={fees}$DENOM --chain-id=$CHAIN_ID --gas=auto {extra}'", + "yes '{password}' | bash -c -l '$EXECUTE tx {operation} redelegate {first_validator} {destination_validator} {amount}$DENOM --from={wallet_name} --fees={fees}$DENOM --chain-id=$CHAIN_ID --gas=auto --output json {extra}'", password = my_boxed_session.walletpassword, operation = match exception.as_str() { "babylon" => "epoching", _ => "staking", }, extra = match exception.as_str() { - "babylon" => "--gas-adjustment 1.4", + "babylon" => "--gas-adjustment 1.4 -y", _ => "", } )).map_err(|e| e.to_string())?; diff --git a/src/node-page.js b/src/node-page.js index b398695..45b8fd9 100644 --- a/src/node-page.js +++ b/src/node-page.js @@ -576,9 +576,11 @@ const delegateSetup = (valoper) => { await tauri.invoke("delegate_token", { walletName: document.querySelectorAll(".each-input-field")[0].value, validatorValoper: document.querySelectorAll(".each-input-field")[1].value, - amount: document.querySelectorAll(".each-input-field")[2].value, + fees: document.querySelectorAll(".each-input-field")[2].value, + amount: document.querySelectorAll(".each-input-field")[3].value, exception: exception }).then((res) => { + console.log(res); res = JSON.parse(res); if (res.raw_log.length == 2) { createMessage("Tx Hash", res.txhash); diff --git a/src/page-content/delegate-token.html b/src/page-content/delegate-token.html index 79316e3..821c8e2 100644 --- a/src/page-content/delegate-token.html +++ b/src/page-content/delegate-token.html @@ -19,6 +19,11 @@
+
+
Amount
+ +
+