diff --git a/index.html b/index.html index f652d6c..184f16d 100644 --- a/index.html +++ b/index.html @@ -403,7 +403,7 @@ onclick="removeInvalid()">Fix
+ onclick="initTransaction()">Send
@@ -2470,7 +2470,7 @@ }) } - function sendMessage() { + function initTransaction() { const privKey = getRef('get_private_key_field').value.trim(); const sender = floCrypto.getFloID(privKey) const floAmount = parseFloat(getRef('tx_flo_amount').value.trim()); @@ -2500,7 +2500,13 @@ }) } - function showTransactionResult(success, result) { + function showTransactionResult(success, result, options = {}) { + let { title, description } = options + if (!title) + title = success ? 'Transaction request sent' : 'Transaction failed' + if (!description) + description = success ? 'This might take upto 30 mins to complete and reflect on blockchain.' : result + renderElem(getRef('transaction_result'), html` ${success ? html` @@ -2508,8 +2514,8 @@ ${!success ? html` ` : ''} -

${success ? 'Transaction request sent' : 'Transaction failed'}

-

${success ? 'This might take upto 30 mins to complete and reflect on blockchain.' : result}

+

${title}

+

${description}

${success ? html`
See transaction on blockchain @@ -2706,7 +2712,10 @@ }).then(res => { if (!res) return floBlockchainAPI.sendTx(depositorAddress, contractAddress, floGlobals.sendAmt, depositorPrivateKey, floData).then(txid => { - showTransactionResult(true, txid) + showTransactionResult(true, txid, { + title: `${sellingToken} tokens deposited`, + description: `If your tokens are not exchanged before the expiry time, you will get them back.` + }) getRef('smart_contract_deposit_form').reset() document.getElementById('deposit_button').disabled = true }).catch(error => { @@ -2732,18 +2741,21 @@ const participantPrivateKey = document.getElementById('participant_private_key').value.trim() const participantAddress = floCrypto.getFloID(participantPrivateKey) let floData + let title = 'Participation successful' switch (contractType) { case 'one-time-event': { // check min,max subscription and participation amount switch (contractSubType) { case 'time-trigger': floData = `send ${participationAmount} ${tokenIdentification}# to ${contractName}@` + description = `You have participated in the event. Check out details here` break case 'external-trigger': const userChoice = getRef('smart_contract_participate_form').querySelector('input[name="choice"]:checked').value if (!userChoice) return notify('Please select a choice', 'error') floData = `send ${participationAmount} ${tokenIdentification}# to ${contractName}@ to FLO address ${contractAddress} with the userchoice: ${userChoice}` + description = html`You have casted your vote. Check out details here` break } } @@ -2752,6 +2764,8 @@ switch (contractSubType) { case 'tokenswap': floData = `send ${participationAmount} ${acceptingToken}# to ${contractName}@` + title = 'Token swap initiated' + description = html`Check your transactions and token balance here` break; default: @@ -2773,7 +2787,10 @@ }).then(res => { if (!res) return floBlockchainAPI.sendTx(participantAddress, contractAddress, floGlobals.sendAmt, participantPrivateKey, floData).then(txid => { - showTransactionResult(true, txid) + showTransactionResult(true, txid, { + title, + description + }) getRef('smart_contract_participate_form').reset() document.getElementById('participate_button').disabled = true }).catch(error => { @@ -2809,7 +2826,9 @@ if (!res) return buttonLoader(e.target.closest('button'), true) floBlockchainAPI.writeData(oracleAddress, floData, oraclePrivateKey, contractAddress).then((txid) => { - showTransactionResult(true, txid) + showTransactionResult(true, txid, { + title: 'Price update initiated', + }) getRef('smart_contract_update_form').reset() document.getElementById('update_price_button').disabled = true }).catch((error) => {