craft-nft

A standalone NFT implementation for real-world arts and crafts assets
Log | Files | Refs | README

commit fb2dea044f73e4e2934c692fca2340350eb17421
parent 9a8bcf7f747740faa1be7de0dab988b954cb6b40
Author: lash <dev@holbrook.no>
Date:   Thu,  2 Mar 2023 11:51:51 +0000

Use whole token values in scan qr app

Diffstat:
Mjs/qrread.js | 7++++---
Mjs/qrread_ui.js | 2+-
2 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/js/qrread.js b/js/qrread.js @@ -182,7 +182,7 @@ async function signAndSend() { } const value = settings.voucherTransferAmount; - setStatus('signing and sending fungible token transaction of value ' + value + '...', STATUS_BUSY); + setStatus('signing and sending fungible token transaction of value ' + (value / (10 ** settings.voucherDecimals)) + '...', STATUS_BUSY); let txVoucher = txBaseERC20; txVoucher.to = settings.voucherAddress; if (txVoucher.to.substring(0, 2) != '0x') { @@ -303,7 +303,8 @@ async function scanContract(contractAddress, voucherAddress) { settings.tokenSymbol = await contract.symbol(); settings.voucherName = await voucher.name(); settings.voucherSymbol = await voucher.symbol(); - settings.voucherDecimals = await voucher.decimals(); + const decimals = await voucher.decimals(); + settings.voucherDecimals = decimals.toNumber(); setStatus('scanning contract for tokens...', STATUS_BUSY); setTimeout(scanContractTokens, 0, contractAddress, voucherAddress); } @@ -394,7 +395,7 @@ async function checkVoucherBalance(addr, unitCount) { console.warn('insufficient funds to cover all batch token units. need ' + target + ', have ' + balance); setStatus('watch out; insufficient fungible token coverage for batch token units.', STATUS_ERROR); } else { - setStatus('fungible token balance ' + balance, STATUS_OK); + setStatus('fungible token balance ' + (balance / (10 ** settings.voucherDecimals)) , STATUS_OK); } settings.voucherAddress = addr; diff --git a/js/qrread_ui.js b/js/qrread_ui.js @@ -75,7 +75,7 @@ window.addEventListener('uistate', (e) => { document.getElementById("scanTokenId").innerHTML = settings.tokenId; document.getElementById("scanTokenBatch").innerHTML = settings.batchNumber; document.getElementById("scanTokenAmount").innerHTML = settings.mintAmount; - document.getElementById("scanVoucherAmount").innerHTML = settings.voucherTransferAmount; + document.getElementById("scanVoucherAmount").innerHTML = settings.voucherTransferAmount / (10 ** settings.voucherDecimals); document.getElementById("requestAmount").value = null; document.getElementById("product").style.display = "none"; document.getElementById("read").style.display = "block";