Skip to content

Commit

Permalink
Add gas adjustment and output json flag to delegate and redelegate tr…
Browse files Browse the repository at this point in the history
…ansactions
  • Loading branch information
necipsagiro committed Jan 31, 2024
1 parent 6556a8c commit a154039
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 5 deletions.
9 changes: 5 additions & 4 deletions src-tauri/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -667,21 +667,22 @@ fn delegate_token(
fees: String,
exception: String,
) -> Result<String, String> {
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
.open_session
.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())?;
Expand All @@ -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())?;
Expand Down
4 changes: 3 additions & 1 deletion src/node-page.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
5 changes: 5 additions & 0 deletions src/page-content/delegate-token.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@
<input class="each-input-field" placeholder=" "></input>
<div class="each-input-field-border"></div>
</div>
<div class="each-input">
<div class="each-input-label">Amount</div>
<input class="each-input-field" placeholder=" "></input>
<div class="each-input-field-border"></div>
</div>
</div>
<div class="each-row">
<div class="each-button" id="submit-button">
Expand Down

0 comments on commit a154039

Please sign in to comment.