Skip to content

Commit

Permalink
transaction page improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
madvas committed Jun 21, 2023
1 parent b27f9e1 commit 7989bde
Showing 1 changed file with 7 additions and 14 deletions.
21 changes: 7 additions & 14 deletions transactionPage/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,7 @@
async function sendTransaction() {

if (typeof BigInt === "undefined") {
let body = document.body;
body.textContent = "BigInt is not supported in this browser";
contentEl.textContent = "BigInt is not supported in this browser";
console.log("BigInt is not supported in this browser");
}

Expand All @@ -137,8 +136,6 @@
data: decompressFromUrl(getURLParameter("data"))
};

console.log(txParams);

try {
const txResult = await ethereum.request({
method: 'eth_sendTransaction',
Expand Down Expand Up @@ -204,9 +201,8 @@
params: [getURLParameter("from"), msgParams],
from: getURLParameter("from")
}, function (err, response) {
let body = document.body;
if (err) {
body.textContent = "Apologies, but there was an issue with signing the data.";
contentEl.textContent = "Apologies, but there was an issue with signing the data.";
return;
}

Expand All @@ -224,15 +220,15 @@
}
}).then(response => {
if (response.ok) {
body.textContent = "Your data was successfully signed and sent to the Discord. You can close this tab now.";
contentEl.textContent = "Your data was successfully signed and sent to the Discord. You can close this tab now.";
} else if (response.status === 409) {
body.textContent = "This transaction has already been processed by our servers.";
contentEl.textContent = "This transaction has already been processed by our servers.";
} else {
body.textContent = "Your data was signed, but we failed to reach our Discord.";
contentEl.textContent = "Your data was signed, but we failed to reach our Discord.";
console.log(response);
}
}).catch(error => {
body.textContent = "Your data was signed, but we failed to reach our Discord.";
contentEl.textContent = "Your data was signed, but we failed to reach our Discord.";
console.log(error);
});

Expand All @@ -243,7 +239,6 @@
let message = signSpec.messageTemplate(data);
const encodedMessage = new TextEncoder().encode(message);
message = '0x' + Array.from(encodedMessage).map(byte => byte.toString(16).padStart(2, '0')).join('');
let body = document.body;
window.ethereum
.request({
method: 'personal_sign',
Expand Down Expand Up @@ -287,7 +282,6 @@
accounts = await ethereum.request({
method: 'eth_requestAccounts'
});
let body = document.body;
from = getURLParameter("from")
if (from && from.toLowerCase() !== accounts[0].toLowerCase()) {
correctAccount = false;
Expand Down Expand Up @@ -329,8 +323,7 @@
const host = getURLParameter("host");

if (!allowedHostnames.test(host)) {
let body = document.body;
body.textContent = "Passed host is not allowed";
contentEl.textContent = "Passed host is not allowed";
throw new Error("Passed host is not allowed");
}
}
Expand Down

0 comments on commit 7989bde

Please sign in to comment.