commit 26f887970f78a0afd07fd8f5a2da505284ca4034
parent ba2a1c6ad3f9531900bce28ae409cb9384828acd
Author: lash <dev@holbrook.no>
Date: Thu, 2 Mar 2023 14:58:00 +0000
Add token image
Diffstat:
2 files changed, 16 insertions(+), 0 deletions(-)
diff --git a/js/qrread.html b/js/qrread.html
@@ -172,6 +172,8 @@ window.addEventListener('load', () => {
<dd id="scanTokenMetaName">(unavailable)</dd>
<dt>Token Description</dt>
<dd id="scanTokenMetaDescription">(unavailable)</dd>
+ <dt>Token Image</dt>
+ <dd id="scanTokenMetaImage">(unavailable)</dd>
<dt>Batch</dt>
<dd id="scanTokenBatch"></dd>
<dt>NFT units</dt>
diff --git a/js/qrread.js b/js/qrread.js
@@ -463,6 +463,13 @@ async function scanTokenMetadata(tokenId) {
} else if (tokenId.substring(0, 2) == '0x') {
tokenId = tokenId.substring(2);
}
+
+ const imgWrap = document.getElementById('scanTokenMetaImage');
+ let img = imgWrap.lastChild;
+ if (img !== null) {
+ imgWrap.removeChild(img);
+ }
+
let r = undefined;
try {
r = await settings.metaInterface.get(tokenId);
@@ -470,13 +477,20 @@ async function scanTokenMetadata(tokenId) {
setStatus('metadata lookup failed', STATUS_ERROR);
document.getElementById('scanTokenMetaName').innerHTML = '(unavailable)';
document.getElementById('scanTokenMetaDescription').innerHTML = '(unavailable)';
+ document.getElementById('scanTokenMetaImage').innerHTML = '(unavailable)';
return;
}
+
const o = JSON.parse(r);
setStatus('found token metadata', STATUS_OK);
console.debug('metadata token', tokenId, o);
document.getElementById('scanTokenMetaName').innerHTML = o['name'];
document.getElementById('scanTokenMetaDescription').innerHTML = o['description'];
+
+ img = document.createElement('img');
+ img.src = o['image'];
+ img.style.height = '200px';
+ imgWrap.appendChild(img);
}
async function manualConfirmHandler(addr) {