Update index.html

This commit is contained in:
SaketAnand 2024-08-15 02:55:59 +05:30
parent 86154f268b
commit 8cbd06aadb

View File

@ -1,3 +1,4 @@
<!DOCTYPE html>
<html lang="en">
<head>
@ -254,8 +255,8 @@
<div class="grid gap-0-5">
<h4>Did you forget your Binance Address?</h4>
<p>
If you have your BSC/BTC/FLO Private Key, enter it here and recover your
Binance Address.
If you have your BSC/BTC/FLO Private Key, enter it here and recover
your Binance Address.
</p>
</div>
<sm-form>
@ -1120,6 +1121,7 @@
if (/^[0-9a-fA-F]{64}$/.test(keyToConvert)) {
keyToConvert = coinjs.privkey2wif(keyToConvert);
}
console.log("lkkkk", keyToConvert);
const ethPrivateKey = coinjs.wif2privkey(keyToConvert).privkey;
BSCAddress = floEthereum.ethAddressFromPrivateKey(ethPrivateKey);
floAddress = keyToConvert.startsWith("R")
@ -1222,6 +1224,9 @@
buttonLoader("check_balance_button", false);
});
}
function handleInvalidSearch() {
if (document.startViewTransition)
document.startViewTransition(() => {
@ -1269,74 +1274,81 @@
Check balance
</button>
</div>
<sm-input
id="private_key_input"
placeholder="Sender's FLO/BTC/BSC private key"
oninput=${handleSenderInput}
data-private-key
class="password-field"
type="password"
animate
required
>
<svg
class="icon"
slot="icon"
xmlns="http://www.w3.org/2000/svg"
enable-background="new 0 0 24 24"
height="24px"
viewBox="0 0 24 24"
width="24px"
fill="#000000"
>
<g><rect fill="none" height="24" width="24"></rect></g>
<g>
<path
d="M21,10h-8.35C11.83,7.67,9.61,6,7,6c-3.31,0-6,2.69-6,6s2.69,6,6,6c2.61,0,4.83-1.67,5.65-4H13l2,2l2-2l2,2l4-4.04L21,10z M7,15c-1.65,0-3-1.35-3-3c0-1.65,1.35-3,3-3s3,1.35,3,3C10,13.65,8.65,15,7,15z"
></path>
</g>
</svg>
<label slot="right" class="interact">
<input
type="checkbox"
class="hidden"
autocomplete="off"
readonly
onchange="togglePrivateKeyVisibility(this)"
/>
<svg
class="icon invisible"
xmlns="http://www.w3.org/2000/svg"
height="24px"
viewBox="0 0 24 24"
width="24px"
fill="#000000"
>
<title>Hide password</title>
<path
d="M0 0h24v24H0zm0 0h24v24H0zm0 0h24v24H0zm0 0h24v24H0z"
fill="none"
></path>
<path
d="M12 7c2.76 0 5 2.24 5 5 0 .65-.13 1.26-.36 1.83l2.92 2.92c1.51-1.26 2.7-2.89 3.43-4.75-1.73-4.39-6-7.5-11-7.5-1.4 0-2.74.25-3.98.7l2.16 2.16C10.74 7.13 11.35 7 12 7zM2 4.27l2.28 2.28.46.46C3.08 8.3 1.78 10.02 1 12c1.73 4.39 6 7.5 11 7.5 1.55 0 3.03-.3 4.38-.84l.42.42L19.73 22 21 20.73 3.27 3 2 4.27zM7.53 9.8l1.55 1.55c-.05.21-.08.43-.08.65 0 1.66 1.34 3 3 3 .22 0 .44-.03.65-.08l1.55 1.55c-.67.33-1.41.53-2.2.53-2.76 0-5-2.24-5-5 0-.79.2-1.53.53-2.2zm4.31-.78l3.15 3.15.02-.16c0-1.66-1.34-3-3-3l-.17.01z"
></path>
</svg>
<svg
class="icon visible"
xmlns="http://www.w3.org/2000/svg"
height="24px"
viewBox="0 0 24 24"
width="24px"
fill="#000000"
>
<title>Show password</title>
<path d="M0 0h24v24H0z" fill="none"></path>
<path
d="M12 4.5C7 4.5 2.73 7.61 1 12c1.73 4.39 6 7.5 11 7.5s9.27-3.11 11-7.5c-1.73-4.39-6-7.5-11-7.5zM12 17c-2.76 0-5-2.24-5-5s2.24-5 5-5 5 2.24 5 5-2.24 5-5 5zm0-8c-1.66 0-3 1.34-3 3s1.34 3 3 3 3-1.34 3-3-1.34-3-3-3z"
></path>
</svg>
</label>
</sm-input>
<sm-input
id="private_key_input"
placeholder="Sender's FLO/BTC/BSC private key"
oninput=${handleSenderInput}
data-private-key
class="password-field"
type="password"
animate
required
>
<svg
class="icon"
slot="icon"
xmlns="http://www.w3.org/2000/svg"
enable-background="new 0 0 24 24"
height="24px"
viewBox="0 0 24 24"
width="24px"
fill="#000000"
>
<g><rect fill="none" height="24" width="24"></rect></g>
<g>
<path
d="M21,10h-8.35C11.83,7.67,9.61,6,7,6c-3.31,0-6,2.69-6,6s2.69,6,6,6c2.61,0,4.83-1.67,5.65-4H13l2,2l2-2l2,2l4-4.04L21,10z M7,15c-1.65,0-3-1.35-3-3c0-1.65,1.35-3,3-3s3,1.35,3,3C10,13.65,8.65,15,7,15z"
></path>
</g>
</svg>
<label slot="right" class="interact">
<input
type="checkbox"
class="hidden"
autocomplete="off"
readonly
onchange="togglePrivateKeyVisibility(this)"
/>
<svg
class="icon invisible"
xmlns="http://www.w3.org/2000/svg"
height="24px"
viewBox="0 0 24 24"
width="24px"
fill="#000000"
>
<title>Hide password</title>
<path
d="M0 0h24v24H0zm0 0h24v24H0zm0 0h24v24H0zm0 0h24v24H0z"
fill="none"
></path>
<path
d="M12 7c2.76 0 5 2.24 5 5 0 .65-.13 1.26-.36 1.83l2.92 2.92c1.51-1.26 2.7-2.89 3.43-4.75-1.73-4.39-6-7.5-11-7.5-1.4 0-2.74.25-3.98.7l2.16 2.16C10.74 7.13 11.35 7 12 7zM2 4.27l2.28 2.28.46.46C3.08 8.3 1.78 10.02 1 12c1.73 4.39 6 7.5 11 7.5 1.55 0 3.03-.3 4.38-.84l.42.42L19.73 22 21 20.73 3.27 3 2 4.27zM7.53 9.8l1.55 1.55c-.05.21-.08.43-.08.65 0 1.66 1.34 3 3 3 .22 0 .44-.03.65-.08l1.55 1.55c-.67.33-1.41.53-2.2.53-2.76 0-5-2.24-5-5 0-.79.2-1.53.53-2.2zm4.31-.78l3.15 3.15.02-.16c0-1.66-1.34-3-3-3l-.17.01z"
></path>
</svg>
<svg
class="icon visible"
xmlns="http://www.w3.org/2000/svg"
height="24px"
viewBox="0 0 24 24"
width="24px"
fill="#000000"
>
<title>Show password</title>
<path d="M0 0h24v24H0z" fill="none"></path>
<path
d="M12 4.5C7 4.5 2.73 7.61 1 12c1.73 4.39 6 7.5 11 7.5s9.27-3.11 11-7.5c-1.73-4.39-6-7.5-11-7.5zM12 17c-2.76 0-5-2.24-5-5s2.24-5 5-5 5 2.24 5 5-2.24 5-5 5zm0-8c-1.66 0-3 1.34-3 3s1.34 3 3 3 3-1.34 3-3-1.34-3-3-3z"
></path>
</svg>
</label>
</sm-input>
<div
id="sender_balance_container"
class="flex align-center gap-0-3 hidden"
@ -1468,11 +1480,84 @@
renderError("Please switch MetaMask to Binance Mainnet");
}
});
// function togglePrivateKeyVisibility(input) {
// const target = input.closest("sm-input") ;
// target.type = target.type === "password" ? "text" : "password";
// target.focusIn();
// }
function togglePrivateKeyVisibility(input) {
const target = input.closest("sm-input");
target.type = target.type === "password" ? "text" : "password";
target.focusIn();
}
console.log(input)
const target = input.closest("sm-input");
// const checkBalanceButton = document.querySelector("#check_balance_button");
console.log(target)
target.type = target.type === "password" ? "text" : "password";
// target.focus();
// checkBalanceButton.disabled = false;
}
// const toggleButton = document.querySelector('#toggleButton');
// const privateKeyInput = document.querySelector('#private_key_input');
// toggleButton.addEventListener('click', () => {
// togglePrivateKeyVisibility(privateKeyInput);
// });
function checkSenderBalance() {
let address;
const privateKey = getRef("private_key_input").value.trim();
@ -1533,9 +1618,10 @@
});
}
function handleSenderInput(e) {
getRef("check_balance_button").disabled = !e.target.isValid;
console.log(e.target.isValid)
getRef("check_balance_button").disabled = false;
if (!e.target.isValid) {
getRef("sender_balance_container").classList.add("hidden");
// getRef("sender_balance_container").classList.add("hidden");
}
}
function handleAssetChange(e) {
@ -1599,12 +1685,12 @@
}
}
getRef("send_tx_form").reset();
getRef("sender_balance_container").classList.add("hidden");
// getRef("sender_balance_container").classList.add("hidden");
} catch (e) {
console.error(e.message);
showTransactionResult("failed", {
description: `Insufficient ${asset.toUpperCase()} balance`,
});
description: `Insufficient ${asset.toUpperCase()} balance`,
});
const regex = /\(error=({.*?}),/;
const match = e.message.match(regex);
if (match && match[1]) {
@ -1621,107 +1707,219 @@
buttonLoader("send_tx_button", false);
}
}
function showTransactionResult(status, { txHash, description = "" }) {
switch (status) {
case "pending":
renderElem(
getRef("transaction_result_popup__content"),
html`
<ul>
<li class="transaction__phase">
<svg
class="icon confirmed"
xmlns="http://www.w3.org/2000/svg"
height="24px"
viewBox="0 0 24 24"
width="24px"
fill="#000000"
>
<path d="M0 0h24v24H0V0z" fill="none" />
<path
d="M9 16.2L4.8 12l-1.4 1.4L9 19 21 7l-1.4-1.4L9 16.2z"
/>
</svg>
<h4>Transaction sent</h4>
</li>
<li class="transaction__phase">
<sm-spinner></sm-spinner>
<p>Waiting for transaction to be confirmed</p>
</li>
</ul>
<div class="grid">
<span class="label">Transaction ID</span>
<sm-copy value=${txHash}></sm-copy>
</div>
<a
class="button button--primary"
target="_blank"
href=${`https://bscscan.com/tx/${txHash}`}
>Check transaction status</a
>
`
);
break;
case "confirmed":
renderElem(
getRef("transaction_result_popup__content"),
html`
<svg
class="icon user-action-result__icon confirmed"
xmlns="http://www.w3.org/2000/svg"
height="24px"
viewBox="0 0 24 24"
width="24px"
fill="#000000"
>
<path d="M0 0h24v24H0V0z" fill="none" />
<path
d="M9 16.2L4.8 12l-1.4 1.4L9 19 21 7l-1.4-1.4L9 16.2z"
/>
</svg>
<div class="grid gap-0-5 justify-center text-center">
<h4>Transaction confirmed</h4>
<p>Transaction has been confirmed on the blockchain.</p>
</div>
<div class="grid">
<span class="label">Transaction ID</span>
<sm-copy value=${txHash}></sm-copy>
</div>
<a
class="button button--primary"
target="_blank"
href=${`https://bscscan.com/tx/${txHash}`}
>Check transaction status</a
>
`
);
break;
case "failed":
renderElem(
getRef("transaction_result_popup__content"),
html`
<svg
class="icon user-action-result__icon failed"
xmlns="http://www.w3.org/2000/svg"
height="24px"
viewBox="0 0 24 24"
width="24px"
fill="#000000"
>
<path
d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm1 15h-2v-2h2v2zm0-4h-2V7h2v6z"
/>
</svg>
<div class="grid gap-0-5 justify-center text-center">
<h4>Transaction failed</h4>
<p>${description}</p>
</div>
`
);
break;
}
openPopup("transaction_result_popup");
}
// function showTransactionResult(status, { txHash, description = "" }) {
// switch (status) {
// case "pending":
// renderElem(
// getRef("transaction_result_popup__content"),
// html`
// <ul>
// <li class="transaction__phase">
// <svg
// class="icon confirmed"
// xmlns="http://www.w3.org/2000/svg"
// height="24px"
// viewBox="0 0 24 24"
// width="24px"
// fill="#000000"
// >
// <path d="M0 0h24v24H0V0z" fill="none" />
// <path
// d="M9 16.2L4.8 12l-1.4 1.4L9 19 21 7l-1.4-1.4L9 16.2z"
// />
// </svg>
// <h4>Transaction sent</h4>
// </li>
// <li class="transaction__phase">
// <sm-spinner></sm-spinner>
// <p>Waiting for transaction to be confirmed</p>
// </li>
// </ul>
// <div class="grid">
// <span class="label">Transaction ID</span>
// <sm-copy value=${txHash}></sm-copy>
// </div>
// <a
// class="button button--primary"
// target="_blank"
// href=${`https://bscscan.com/tx/${txHash}`}
// >Check transaction status</a
// >
// `
// );
// break;
// case "confirmed":
// renderElem(
// getRef("transaction_result_popup__content"),
// html`
// <svg
// class="icon user-action-result__icon confirmed"
// xmlns="http://www.w3.org/2000/svg"
// height="24px"
// viewBox="0 0 24 24"
// width="24px"
// fill="#000000"
// >
// <path d="M0 0h24v24H0V0z" fill="none" />
// <path
// d="M9 16.2L4.8 12l-1.4 1.4L9 19 21 7l-1.4-1.4L9 16.2z"
// />
// </svg>
// <div class="grid gap-0-5 justify-center text-center">
// <h4>Transaction confirmed</h4>
// <p>Transaction has been confirmed on the blockchain.</p>
// </div>
// <div class="grid">
// <span class="label">Transaction ID</span>
// <sm-copy value=${txHash}></sm-copy>
// </div>
// <a
// class="button button--primary"
// target="_blank"
// href=${`https://bscscan.com/tx/${txHash}`}
// >Check transaction status</a
// >
// `
// );
// break;
// case "failed":
// renderElem(
// getRef("transaction_result_popup__content"),
// html`
// <svg
// class="icon user-action-result__icon failed"
// xmlns="http://www.w3.org/2000/svg"
// height="24px"
// viewBox="0 0 24 24"
// width="24px"
// fill="#000000"
// >
// <path
// d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm1 15h-2v-2h2v2zm0-4h-2V7h2v6z"
// />
// </svg>
// <div class="grid gap-0-5 justify-center text-center">
// <h4>Transaction failed</h4>
// <p>${description}</p>
// </div>
// `
// );
// break;
// }
// openPopup("transaction_result_popup");
// }
// *************************************************************************
// ***************************************************************************
// function showTransactionResult(status, { txHash, description = "Insufficient BSC balance" })
// { switch (status)
// { case "pending": renderElem( getRef("transaction_result_popup__content"),
// html` <ul> <li class="transaction__phase"> <svg class="icon confirmed" xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 0 24 24" width="24px" fill="#000000" > <path d="M0 0h24v24H0V0z" fill="none" /> <path d="M9 16.2L4.8 12l-1.4 1.4L9 19 21 7l-1.4-1.4L9 16.2z" /> </svg> <h4>Transaction sent</h4> </li> <li class="transaction__phase"> <sm-spinner></sm-spinner> <p>Waiting for transaction to be confirmed</p> </li> </ul>
// <div class="grid"> <span class="label">Transaction ID</span>
// <sm-copy value=${txHash}></sm-copy> </div>
// <a class="button button--primary" target="_blank" href=${`https://bscscan.com/tx/${txHash}`} >Check transaction status</a > ` );
// break;
// case "confirmed":
// renderElem( getRef("transaction_result_popup__content"),
// html` <svg class="icon user-action-result__icon confirmed" xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 0 24 24" width="24px" fill="#000000" > <path d="M0 0h24v24H0V0z" fill="none" /> <path d="M9 16.2L4.8 12l-1.4 1.4L9 19 21 7l-1.4-1.4L9 16.2z" /> </svg>
// <div class="grid gap-0-5 justify-center text-center">
// <h4>Transaction confirmed</h4>
// <p>Transaction has been confirmed on the blockchain.</p> </div>
// <div class="grid"> <span class="label">Transaction ID</span>
// <sm-copy value=${txHash}></sm-copy> </div>
// <a class="button button--primary" target="_blank" href=${`https://bscscan.com/tx/${txHash}`} >Check transaction status</a > ` );
// break;
// case "failed": renderElem( getRef("transaction_result_popup__content"),
// html` <svg class="icon user-action-result__icon failed" xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 0 24 24" width="24px" fill="#000000" > <path d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm1 15h-2v-2h2v2zm0-4h-2V7h2v6z" /> </svg> <div class="grid gap-0-5 justify-center text-center">
// <h4>Transaction failed</h4>
// <p>"Insufficient BSC balance"</p> </div> ` );
// break;
// } openPopup("transaction_result_popup"); }
// showTransactionResult("failed", { txHash: "your-tx-hash-here", description: "Insufficient BSC balance" });
function showTransactionResult(status, { txHash, usdtBalance, bscBalance }) {
let description = "Insufficient BSC balance";
if (usdtBalance <= 0) {
description = "Insufficient USDT balance";
} else if (bscBalance <= 0) {
description = "Insufficient BSC balance";
}
switch (status) {
case "pending":
renderElem(
getRef("transaction_result_popup__content"),
html`
<ul>
<li class="transaction__phase">
<svg class="icon confirmed" xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 0 24 24" width="24px" fill="#000000">
<path d="M0 0h24v24H0V0z" fill="none" />
<path d="M9 16.2L4.8 12l-1.4 1.4L9 19 21 7l-1.4-1.4L9 16.2z" />
</svg>
<h4>Transaction sent</h4>
</li>
<li class="transaction__phase">
<sm-spinner></sm-spinner>
<p>Waiting for transaction to be confirmed</p>
</li>
</ul>
<div class="grid">
<span class="label">Transaction ID</span>
<sm-copy value=${txHash}></sm-copy>
</div>
<a class="button button--primary" target="_blank" href=${`https://bscscan.com/tx/${txHash}`}>
Check transaction status
</a>
`
);
break;
case "confirmed":
renderElem(
getRef("transaction_result_popup__content"),
html`
<svg class="icon user-action-result__icon confirmed" xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 0 24 24" width="24px" fill="#000000">
<path d="M0 0h24v24H0V0z" fill="none" />
<path d="M9 16.2L4.8 12l-1.4 1.4L9 19 21 7l-1.4-1.4L9 16.2z" />
</svg>
<div class="grid gap-0-5 justify-center text-center">
<h4>Transaction confirmed</h4>
<p>Transaction has been confirmed on the blockchain.</p>
</div>
<div class="grid">
<span class="label">Transaction ID</span>
<sm-copy value=${txHash}></sm-copy>
</div>
<a class="button button--primary" target="_blank" href=${`https://bscscan.com/tx/${txHash}`}>
Check transaction status
</a>
`
);
break;
case "failed":
renderElem(
getRef("transaction_result_popup__content"),
html`
<svg class="icon user-action-result__icon failed" xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 0 24 24" width="24px" fill="#000000">
<path d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm1 15h-2v-2h2v2zm0-4h-2V7h2v6z" />
</svg>
<div class="grid gap-0-5 justify-center text-center">
<h4>Transaction failed</h4>
<p>${description}</p>
</div>
`
);
break;
}
openPopup("transaction_result_popup");
}
router.addRoute("create", (state) => {
getRef("page_container").dataset.page = "create";
renderElem(
@ -1830,9 +2028,9 @@
let bscPrivateKey = getRef("retrieve_btc_addr_field").value.trim();
getRef("recovered_btc_addr_wrapper").classList.remove("hidden");
getRef("recovered_btc_addr").value =
bscPrivateKey.startsWith("R") ||
bscPrivateKey.startsWith("L") ||
bscPrivateKey.startsWith("K")
bscPrivateKey.startsWith("R") ||
bscPrivateKey.startsWith("L") ||
bscPrivateKey.startsWith("K")
? floEthereum.ethAddressFromPrivateKey(
coinjs.wif2privkey(bscPrivateKey).privkey
)
@ -1847,3 +2045,4 @@
</script>
</body>
</html>
<!-- function showTransactionResult(status, { txHash, description = "Insufficient BSC balance" }) { switch (status) { case "pending": renderElem( getRef("transaction_result_popup__content"), html` <ul> <li class="transaction__phase"> <svg class="icon confirmed" xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 0 24 24" width="24px" fill="#000000" > <path d="M0 0h24v24H0V0z" fill="none" /> <path d="M9 16.2L4.8 12l-1.4 1.4L9 19 21 7l-1.4-1.4L9 16.2z" /> </svg> <h4>Transaction sent</h4> </li> <li class="transaction__phase"> <sm-spinner></sm-spinner> <p>Waiting for transaction to be confirmed</p> </li> </ul> <div class="grid"> <span class="label">Transaction ID</span> <sm-copy value=${txHash}></sm-copy> </div> <a class="button button--primary" target="_blank" href=${`https://bscscan.com/tx/${txHash}`} >Check transaction status</a > ` ); break; case "confirmed": renderElem( getRef("transaction_result_popup__content"), html` <svg class="icon user-action-result__icon confirmed" xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 0 24 24" width="24px" fill="#000000" > <path d="M0 0h24v24H0V0z" fill="none" /> <path d="M9 16.2L4.8 12l-1.4 1.4L9 19 21 7l-1.4-1.4L9 16.2z" /> </svg> <div class="grid gap-0-5 justify-center text-center"> <h4>Transaction confirmed</h4> <p>Transaction has been confirmed on the blockchain.</p> </div> <div class="grid"> <span class="label">Transaction ID</span> <sm-copy value=${txHash}></sm-copy> </div> <a class="button button--primary" target="_blank" href=${`https://bscscan.com/tx/${txHash}`} >Check transaction status</a > ` ); break; case "failed": renderElem( getRef("transaction_result_popup__content"), html` <svg class="icon user-action-result__icon failed" xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 0 24 24" width="24px" fill="#000000" > <path d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm1 15h-2v-2h2v2zm0-4h-2V7h2v6z" /> </svg> <div class="grid gap-0-5 justify-center text-center"> <h4>Transaction failed</h4> <p>"Insufficient BSC balance"</p> </div> ` ); break; } openPopup("transaction_result_popup"); } showTransactionResult("failed", { txHash: "your-tx-hash-here", description: "Insufficient BSC balance" }); -->