Skip to content
This repository has been archived by the owner on Nov 9, 2024. It is now read-only.

Commit

Permalink
Add create_bls_key command and button
Browse files Browse the repository at this point in the history
necipsagiro committed Feb 10, 2024
1 parent 868bd62 commit 91e3545
Showing 4 changed files with 78 additions and 0 deletions.
19 changes: 19 additions & 0 deletions src-tauri/src/main.rs
Original file line number Diff line number Diff line change
@@ -891,6 +891,24 @@ fn withdraw_rewards(valoper_address: String, wallet_name: String) -> Result<Stri
Ok(s)
}

#[tauri::command(async)]
fn create_bls_key(wallet_name: String) -> Result<String, String> {
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 create-bls-key $($EXECUTE keys show {wallet_name} -a) 2>&1'",
password = my_boxed_session.walletpassword,
)).map_err(|e| e.to_string())?;
let mut s = String::new();
channel.read_to_string(&mut s).map_err(|e| e.to_string())?;
channel.close().map_err(|e| e.to_string())?;
Ok(s)
}

fn main() {
tauri::Builder::default()
.setup(|app| {
@@ -938,6 +956,7 @@ fn main() {
stop_installation,
check_logs,
stop_check_logs,
create_bls_key,
])
.run(tauri::generate_context!())
.expect("error while running tauri application");
1 change: 1 addition & 0 deletions src/app.html
Original file line number Diff line number Diff line change
@@ -366,6 +366,7 @@
<button class="each-dropdown-subbutton" id="send-token-button">Send token</button><br>
<button class="each-dropdown-subbutton" id="wallets-button">Wallets</button><br>
<button class="each-dropdown-subbutton" id="logs-button">Logs</button><br>
<button class="each-dropdown-subbutton" id="create-bls-key-button">Create BLS Key</button><br>
</div>
<button class="each-dropdown-button" id="node-information-button">
<div>Node Information</div>
23 changes: 23 additions & 0 deletions src/node-page.js
Original file line number Diff line number Diff line change
@@ -126,6 +126,9 @@ const loadNodePage = async (start) => {
document.getElementById(button).nextElementSibling.style.display = currentIp.icon == "Celestia Light" ? "none" : "";
};

if (currentIp.icon != "Babylon")
document.getElementById("create-bls-key-button").style.display = "none";

if (start) {
await tauri.invoke("password_keyring_check", { exception: exception }).then((res) => {
sessionStorage.setItem("keyring", `{ "required": ${res[0]}, "exists": ${res[1]} }`);
@@ -678,6 +681,22 @@ const sendTokenSetup = () => {
});
window.scrollTo(0, 400);
};
const createBLSKeySetup = () => {
document.querySelector(".each-button").addEventListener("click", async () => {
showLoadingAnimation();
hideErrorMessage();
await tauri.invoke("create_bls_key", { walletName: document.querySelectorAll(".each-input-field")[0].value }).then((res) => {
console.log(res);
if (res.includes("Error")) {
showErrorMessage("Wrong wallet name!");
} else {
createMessage("Success", "BLS Key created successfully!");
};
}).catch(async (err) => { await handleTimeOut(err); showErrorMessage(err); });
hideLoadingAnimation();
});
window.scrollTo(0, 400);
};
const createKeyringSetup = (page_html, page_setup) => {
document.querySelector(".each-button").addEventListener("click", async () => {
if (document.querySelectorAll(".each-input-field")[0].value.length < 8) {
@@ -824,6 +843,7 @@ const setupNodePage = () => {
const unjailButton = document.getElementById("unjail-button");
const delegateTokenButton = document.getElementById("delegate-token-button");
const sendTokenButton = document.getElementById("send-token-button");
const createBLSKeyButton = document.getElementById("create-bls-key-button");
const redelegateTokenButton = document.getElementById("redelegate-token-button");
const voteButton = document.getElementById("vote-button");
const walletsButton = document.getElementById("wallets-button");
@@ -931,6 +951,9 @@ const setupNodePage = () => {
sendTokenButton.addEventListener("click", async function () {
await handleKeyringExistance("page-content/send-token.html", sendTokenSetup);
});
createBLSKeyButton.addEventListener("click", async function () {
await handleKeyringExistance("page-content/create-bls-key.html", createBLSKeySetup);
});
walletsButton.addEventListener("click", async function () {
await handleKeyringExistance("page-content/wallets.html", walletsSetup);
});
35 changes: 35 additions & 0 deletions src/page-content/create-bls-key.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<div class="each-row">
<div class="page-heading">Create BLS Key</div>
</div>
<div class="each-row">
<div class="each-input">
<div class="each-input-label">Wallet Name</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">
<div>Submit</div>
<svg class="each-button-svg" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 15 15">
<path
d="M9.5 13C10.0523 13 10.5 12.5523 10.5 12C10.5 11.4477 10.0523 11 9.5 11C8.94771 11 8.5 11.4477 8.5 12C8.5 12.5523 8.94771 13 9.5 13Z" />
<path
d="M9.5 3C10.0523 3 10.5 2.55229 10.5 2C10.5 1.44772 10.0523 1 9.5 1C8.94771 1 8.5 1.44772 8.5 2C8.5 2.55229 8.94771 3 9.5 3Z" />
<path
d="M1 8C1.55228 8 2 7.55229 2 7C2 6.44772 1.55228 6 1 6C0.447715 6 0 6.44772 0 7C0 7.55229 0.447715 8 1 8Z" />
<path
d="M13 5C12.5578 5.00134 12.1286 5.14933 11.7795 5.42077C11.4304 5.69221 11.1813 6.07178 11.071 6.5H8.92895C8.85816 6.218 8.72621 5.95501 8.54246 5.72968C8.3587 5.50435 8.12764 5.32219 7.86564 5.19611C7.60364 5.07003 7.31712 5.00312 7.02638 5.00011C6.73564 4.9971 6.4478 5.05807 6.18325 5.1787L4.595 3.1936C4.85633 2.85043 4.99853 2.43135 5 2C5 1.60444 4.8827 1.21776 4.66294 0.88886C4.44318 0.559962 4.13082 0.303617 3.76537 0.152242C3.39991 0.000866562 2.99778 -0.0387401 2.60982 0.0384303C2.22186 0.115601 1.86549 0.306082 1.58579 0.585787C1.30608 0.865492 1.1156 1.22186 1.03843 1.60982C0.961259 1.99778 1.00087 2.39992 1.15224 2.76537C1.30362 3.13082 1.55996 3.44318 1.88886 3.66294C2.21776 3.8827 2.60444 4 3 4C3.28192 3.99927 3.56043 3.93834 3.8169 3.8213L5.4049 5.8063C5.14235 6.14881 5.00005 6.56834 5.00005 6.9999C5.00005 7.43147 5.14235 7.85099 5.4049 8.1935L3.817 10.1785C3.56048 10.0615 3.28194 10.0007 3 10C2.60444 10 2.21776 10.1173 1.88886 10.3371C1.55996 10.5568 1.30362 10.8692 1.15224 11.2346C1.00087 11.6001 0.961259 12.0022 1.03843 12.3902C1.1156 12.7781 1.30608 13.1345 1.58579 13.4142C1.86549 13.6939 2.22186 13.8844 2.60982 13.9616C2.99778 14.0387 3.39991 13.9991 3.76537 13.8478C4.13082 13.6964 4.44318 13.44 4.66294 13.1111C4.8827 12.7822 5 12.3956 5 12C4.99854 11.5687 4.85634 11.1496 4.595 10.8064L6.1829 8.8214C6.44748 8.94207 6.73536 9.00306 7.02614 9.00007C7.31692 8.99707 7.60348 8.93016 7.86551 8.80406C8.12755 8.67797 8.35864 8.49579 8.54242 8.27043C8.7262 8.04507 8.85816 7.78205 8.92895 7.5H11.071C11.1652 7.86135 11.3587 8.18907 11.6298 8.44593C11.9008 8.7028 12.2384 8.87851 12.6043 8.95313C12.9702 9.02774 13.3496 8.99827 13.6996 8.86805C14.0496 8.73782 14.356 8.51208 14.5841 8.21644C14.8122 7.9208 14.9529 7.56713 14.99 7.19557C15.0272 6.82402 14.9595 6.44949 14.7945 6.1145C14.6295 5.77952 14.3739 5.49751 14.0567 5.3005C13.7395 5.1035 13.3734 4.99939 13 5ZM2 2C2 1.80222 2.05865 1.60888 2.16853 1.44443C2.27841 1.27998 2.43459 1.15181 2.61732 1.07612C2.80004 1.00043 3.00111 0.98063 3.19509 1.01922C3.38907 1.0578 3.56725 1.15304 3.70711 1.29289C3.84696 1.43275 3.9422 1.61093 3.98079 1.80491C4.01937 1.99889 3.99957 2.19996 3.92388 2.38268C3.84819 2.56541 3.72002 2.72159 3.55557 2.83147C3.39112 2.94135 3.19778 3 3 3C2.73488 2.9997 2.4807 2.89424 2.29323 2.70677C2.10576 2.5193 2.0003 2.26512 2 2ZM3 13C2.80222 13 2.60888 12.9414 2.44443 12.8315C2.27998 12.7216 2.15181 12.5654 2.07612 12.3827C2.00043 12.2 1.98063 11.9989 2.01921 11.8049C2.0578 11.6109 2.15304 11.4327 2.29289 11.2929C2.43275 11.153 2.61093 11.0578 2.80491 11.0192C2.99889 10.9806 3.19996 11.0004 3.38268 11.0761C3.56541 11.1518 3.72159 11.28 3.83147 11.4444C3.94135 11.6089 4 11.8022 4 12C3.9997 12.2651 3.89424 12.5193 3.70677 12.7068C3.5193 12.8942 3.26512 12.9997 3 13ZM7 8C6.80222 8 6.60888 7.94135 6.44443 7.83147C6.27998 7.72159 6.15181 7.56541 6.07612 7.38268C6.00043 7.19996 5.98063 6.99889 6.01921 6.80491C6.0578 6.61093 6.15304 6.43275 6.29289 6.29289C6.43275 6.15304 6.61093 6.0578 6.80491 6.01922C6.99889 5.98063 7.19996 6.00043 7.38268 6.07612C7.56541 6.15181 7.72159 6.27998 7.83147 6.44443C7.94135 6.60888 8 6.80222 8 7C7.9997 7.26512 7.89424 7.5193 7.70677 7.70677C7.5193 7.89424 7.26512 7.9997 7 8ZM13 8C12.8022 8 12.6089 7.94135 12.4444 7.83147C12.28 7.72159 12.1518 7.56541 12.0761 7.38268C12.0004 7.19996 11.9806 6.99889 12.0192 6.80491C12.0578 6.61093 12.153 6.43275 12.2929 6.29289C12.4327 6.15304 12.6109 6.0578 12.8049 6.01922C12.9989 5.98063 13.2 6.00043 13.3827 6.07612C13.5654 6.15181 13.7216 6.27998 13.8315 6.44443C13.9414 6.60888 14 6.80222 14 7C13.9997 7.26512 13.8942 7.5193 13.7068 7.70677C13.5193 7.89424 13.2651 7.9997 13 8Z" />
</svg>
</div>
</div>
<div class="each-row">
<div class="warning" id="inner-warning" style="display: none;">
<svg class="warning-svg" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg">
<path
d="M0.750968 15C0.193431 15 -0.169191 14.4499 0.0801473 13.9824L7.33015 0.388678C7.60654 -0.129559 8.3954 -0.129559 8.67179 0.388678L15.9218 13.9824C16.1711 14.4499 15.8085 15 15.251 15H0.750968ZM7.25097 5.625H8.75097V10.3125H7.25097V5.625ZM8.75097 11.9531C8.75097 12.3415 8.41518 12.6563 8.00097 12.6563C7.58675 12.6563 7.25097 12.3415 7.25097 11.9531C7.25097 11.5648 7.58675 11.25 8.00097 11.25C8.41518 11.25 8.75097 11.5648 8.75097 11.9531Z"
fill-rule="evenodd" />
</svg>
<div class="warning-text" id="inner-warning-text"></div>
</div>
</div>

0 comments on commit 91e3545

Please sign in to comment.