Skip to content

Commit

Permalink
transactionPage updates
Browse files Browse the repository at this point in the history
  • Loading branch information
madvas committed Feb 13, 2024
1 parent be9ec32 commit d050953
Showing 1 changed file with 36 additions and 11 deletions.
47 changes: 36 additions & 11 deletions transactionPage/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -108,9 +108,15 @@
return c.charCodeAt(0);
});
var binaryData = new Uint8Array(bytes);
var decompressed = pako.inflate(binaryData, {
to: 'string'
});
try {
var decompressed = pako.inflate(binaryData, {
to: 'string'
});
} catch (e) {
contentEl.textContent = "Sorry, there is a problem decoding the transaction data. Please try again.";
console.error(e);
}

return decompressed;
}

Expand All @@ -123,7 +129,7 @@
}

async function sendTransaction() {

console.log("Sending transaction");
if (typeof BigInt === "undefined") {
contentEl.textContent = "BigInt is not supported in this browser";
console.log("BigInt is not supported in this browser");
Expand All @@ -144,6 +150,11 @@

const txKey = getURLParameter("tx_key");

if (txKey == "" || txKey === null || txKey === undefined) {
contentEl.textContent = "Your transaction has been successfully sent, you can close this tab now.";
return;
}

fetch(getHostURL(), {
method: 'POST',
body: JSON.stringify({
Expand Down Expand Up @@ -206,6 +217,8 @@
return;
}

contentEl.textContent = "Your transaction has been successfully signed, you can close this tab now.";

const txKey = getURLParameter("tx_key");
const txResult = response.result;

Expand All @@ -220,15 +233,27 @@
}
}).then(response => {
if (response.ok) {
contentEl.textContent = "Your data was successfully signed and sent to the Discord. You can close this tab now.";

} else if (response.status === 409) {
contentEl.textContent = "This transaction has already been processed by our servers.";
contentEl.textContent = "This transaction has already been processed by the server.";
} else if (response.status === 400) {
contentEl.textContent = "There was an issue with the request: ";
response.json().then(data => {
if (data.errors && data.errors.length > 0) {
// Append each error message to the content element
data.errors.forEach((error, index) => {
contentEl.textContent += (index > 0 ? ', ' : '') + error;
});
} else {
contentEl.textContent += "An unknown error occurred.";
}
});
} else {
contentEl.textContent = "Your data was signed, but we failed to reach our Discord.";
contentEl.textContent = "Your data was signed, but we failed to reach the server.";
console.log(response);
}
}).catch(error => {
contentEl.textContent = "Your data was signed, but we failed to reach our Discord.";
contentEl.textContent = "Your data was signed, but we failed to reach the server.";
console.log(error);
});

Expand Down Expand Up @@ -259,15 +284,15 @@
}
}).then(response => {
if (response.ok) {
contentEl.textContent = "Your signature was successfully sent to the Discord. You can close this tab now.";
contentEl.textContent = "Your signature was successfully sent to the server. You can close this tab now.";
} else if (response.status === 409) {
contentEl.textContent = "This transaction has already been processed by our servers.";
} else {
contentEl.textContent = "Your signature is correct, but we failed to reach our Discord.";
contentEl.textContent = "Your signature is correct, but we failed to reach the server.";
console.log(response);
}
}).catch(error => {
contentEl.textContent = "Your signature is correct, but we failed to reach our Discord.";
contentEl.textContent = "Your signature is correct, but we failed to reach the server.";
console.log(error);
});
})
Expand Down

0 comments on commit d050953

Please sign in to comment.