craft-nft

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

commit 6ebb4ac9001f94ec87ed71177b7d8a436c938348
parent 4952e097a7bfee77f1c97c597b35bec92311d381
Author: lash <dev@holbrook.no>
Date:   Tue, 28 Feb 2023 11:24:40 +0000

Define voucher instead of NFT amount

Diffstat:
Mjs/qrread.html | 20+++++++++++---------
Mjs/qrread.js | 8++++++--
Mjs/qrread_ui.js | 2++
3 files changed, 19 insertions(+), 11 deletions(-)

diff --git a/js/qrread.html b/js/qrread.html @@ -13,14 +13,14 @@ const MAX_MINT = 4; const BATCH_UNIT_VALUE = 500; window.addEventListener('load', () => { - settings.batchUnitValue = BATCH_UNIT_VALUE; +// settings.batchUnitValue = BATCH_UNIT_VALUE; actLoad(); - for (let i = 1; i <= MAX_MINT; i<<=1) { - const opt = document.createElement('option'); - opt.setAttribute('value', i); - opt.innerHTML = i.toString(); - document.getElementById('requestAmount').appendChild(opt); - } +// for (let i = 1; i <= MAX_MINT; i<<=1) { +// const opt = document.createElement('option'); +// opt.setAttribute('value', i); +// opt.innerHTML = i.toString(); +// document.getElementById('requestAmount').appendChild(opt); +// } document.getElementById('keyFileSubmit').addEventListener("click", (o) => { const keyFile = document.getElementById("keyFile").value; const keyFilePassword = document.getElementById("keyFilePassword").value; @@ -147,7 +147,7 @@ window.addEventListener('load', () => { <label for="requestTokenChooser">Choose NFT token</label> <div id="tokenChooser"></div> <label for="requestAmount">Choose mint amount</label> - <select id="requestAmount"></select> + <input type="text" id="requestAmount"></input> <button id="requestSubmit">create request</button> </div> <div class="pane" id="read"> @@ -161,8 +161,10 @@ window.addEventListener('load', () => { <dd id="scanTokenMetaDescription">(unavailable)</dd> <dt>Batch</dt> <dd id="scanTokenBatch"></dd> - <dt>Amount</dt> + <dt>NFT units</dt> <dd id="scanTokenAmount"></dd> + <dt>Voucher amount</dt> + <dd id="scanVoucherAmount"></dd> </dl> <div class="out"> <canvas id="qr-canvas" width="400" height="400"></canvas> diff --git a/js/qrread.js b/js/qrread.js @@ -35,6 +35,7 @@ var settings = { voucherSymbol: undefined, voucherDecimals: undefined, voucherExpire: undefined, + voucherTransferAmount: 0, }; const txBase = { @@ -181,7 +182,7 @@ async function signAndSend() { nonce++; } - const value = (settings.mintAmount * settings.batchUnitValue) * (10 ** settings.voucherDecimals); + const value = settings.voucherTransferAmount; setStatus('signing and sending fungible token transaction of value ' + value + '...', STATUS_BUSY); let txVoucher = txBaseERC20; txVoucher.to = settings.voucherAddress; @@ -478,7 +479,10 @@ async function requestHandler(tokenBatch, amount) { settings.dataPost = tokenId + batchNumberHex; settings.tokenId = tokenId; settings.batchNumber = v[1]; - settings.mintAmount = amount; + //settings.mintAmount = amount; + settings.mintAmount = 1; + //settings.voucherTransferAmount = (settings.mintAmount * settings.batchUnitValue) * (10 ** settings.voucherDecimals); + settings.voucherTransferAmount = amount * (10 ** settings.voucherDecimals); const e = new CustomEvent('uistate', { detail: { delta: STATE.MINT, diff --git a/js/qrread_ui.js b/js/qrread_ui.js @@ -67,6 +67,8 @@ 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("requestAmount").value = null; document.getElementById("product").style.display = "none"; document.getElementById("read").style.display = "block"; document.getElementById("scanConfirm").style.display = "none";