Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix hydraw new tx cboHex decoding #1372

Merged
merged 1 commit into from
Mar 25, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions hydraw/static/bundle.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,13 @@ client.addEventListener("message", e => {
switch (msg.tag) {
case "TxValid":
// TODO: Should only draw pixels on SnapshotConfirmed
console.log("New transaction seen", msg.transaction.id);
if (msg.transaction.auxiliaryData != null) {
console.log("Transaction has auxiliary data", msg.transaction.auxiliaryData);
const aux = cbor.decodeFirstSync(msg.transaction.auxiliaryData).value;
const cborHex = msg.transaction.cborHex;
console.log("New transaction cborHex seen", cborHex);
const transaction = cbor.decodeFirstSync(cborHex);
const auxiliaryData = transaction[3]
if (auxiliaryData !== undefined && auxiliaryData !== null) {
console.log("Transaction has auxiliary data", auxiliaryData);
const aux = auxiliaryData.value;
const [x, y, r, g, b] = (aux.get(0) || aux.get(1)).get(metadataLabel);
n += delay;
setTimeout(() => drawPixel(x, y, [r, g, b]), n);
Expand Down Expand Up @@ -47,7 +50,6 @@ const drawPixel = (x, y, rgb) => {
ctx.fillRect(x, y, 1, 1);
}


canvas.addEventListener('click', function(e) {
console.log("event", e);
const canvasPosition = {
Expand Down