diff --git a/index.html b/index.html index b76b519..ff336cb 100644 --- a/index.html +++ b/index.html @@ -149,17 +149,17 @@ style="enable-background:new 0 0 107.65 47.07;" xml:space="preserve">
@@ -1242,7 +1242,12 @@ getRef('smart_contract_creation_form').classList.remove('split-layout') renderElem(getRef('smart_contract_creation_form'), render.contractCreationForm(type, subtype)) getRef('smart_contract_creation_form').querySelectorAll('[data-flo-address]').forEach(input => { - input.customValidation = floCrypto.validateFloID + input.customValidation = (value) => { + return { + isValid: floCrypto.validateAddr(value), + errorText: `Invalid FLO address.
It usually starts with "F".` + } + } }) showChildElement('smartcontracts', 1, { entry: slideInLeft, exit: slideOutLeft }) break; @@ -1257,46 +1262,46 @@ const defaultExpiration = new Date(new Date().getTime() + (floGlobals.expirationDays * 24 * 60 * 60 * 1000)) .toISOString().slice(0, -8); renderElem(getRef('smart_contract_deposit_form'), html` -
- Select smart contract - - ${render.availableSmartContractOptions(filteredSmartContracts)} - -
-
-

Deposit ${sellingToken} to get ${acceptingToken}

-

Exchange rate: 1 ${sellingToken} = ${price} ${acceptingToken}

- -
-
- Amount (${sellingToken}) - -
-
- Expiration (Time after which unspent amount will be returned) - -
-
- FLO private key - - - -
-
- -
- `) +
+ Select smart contract + + ${render.availableSmartContractOptions(filteredSmartContracts)} + +
+
+

Deposit ${sellingToken} to get ${acceptingToken}

+

Exchange rate: 1 ${sellingToken} = ${price} ${acceptingToken}

+ +
+
+ Amount (${sellingToken}) + +
+
+ Expiration (Time after which unspent amount will be returned) + +
+
+ FLO private key + + + +
+
+ +
+ `) } else { renderElem(getRef('smart_contract_deposit_form'), html` -
- - No smart contracts found -
- `) +
+ + No smart contracts found +
+ `) } showChildElement('smartcontracts', 2, { entry: slideInLeft, exit: slideOutLeft }) break; @@ -1310,55 +1315,55 @@ const { price, contractName, contractAddress, acceptingToken, sellingToken, tokenIdentification, userChoices, contractSubType } = selectedSmartContract history.replaceState(null, null, `#/smartcontracts/participate?scName=${contractName}&scAddress=${contractAddress}`) renderElem(getRef('smart_contract_participate_form'), html` -
- Select smart contract - - ${render.availableSmartContractOptions(filteredSmartContracts, `${contractName}_${contractAddress}`)} - -
- ${userChoices ? html` -
- Choices -
- ${userChoices.map(choice => html` - - `)} -
- `: ''} - ${contractSubType === 'tokenswap' ? html` -
-

Swap ${acceptingToken} with ${sellingToken}

-

Exchange rate: 1 ${sellingToken} = ${price} ${acceptingToken}

+
+ Select smart contract + + ${render.availableSmartContractOptions(filteredSmartContracts, `${contractName}_${contractAddress}`)} +
- `: ''} -
- Participation amount (${acceptingToken || tokenIdentification}) - -
-
- FLO private key - - - -
-
- -
- `) + ${userChoices ? html` +
+ Choices +
+ ${userChoices.map(choice => html` + + `)} +
+ `: ''} + ${contractSubType === 'tokenswap' ? html` +
+

Swap ${acceptingToken} with ${sellingToken}

+

Exchange rate: 1 ${sellingToken} = ${price} ${acceptingToken}

+
+ `: ''} +
+ Participation amount (${acceptingToken || tokenIdentification}) + +
+
+ FLO private key + + + +
+
+ +
+ `) } else { renderElem(getRef('smart_contract_participate_form'), html` -
- - No smart contracts found -
- `) +
+ + No smart contracts found +
+ `) } showChildElement('smartcontracts', 3, { entry: slideInLeft, exit: slideOutLeft }) break; @@ -1372,45 +1377,45 @@ const { contractName, contractAddress, oracle_address, price, acceptingToken } = selectedSmartContract history.replaceState(null, null, `#/smartcontracts/participate?scName=${contractName}&scAddress=${contractAddress}`) renderElem(getRef('smart_contract_update_form'), html` -
- Oracle FLO Address - -
-
- Oracle FLO private key - - - -
-
- Select smart contract - - ${render.availableSmartContractOptions(filteredSmartContracts, `${contractName}_${contractAddress}`)} - -
-

- Current price: - ${price} ${acceptingToken} -

-
- Updated price (${acceptingToken}) - -
-
- -
- `) +
+ Oracle FLO Address + +
+
+ Oracle FLO private key + + + +
+
+ Select smart contract + + ${render.availableSmartContractOptions(filteredSmartContracts, `${contractName}_${contractAddress}`)} + +
+

+ Current price: + ${price} ${acceptingToken} +

+
+ Updated price (${acceptingToken}) + +
+
+ +
+ `) } else { renderElem(getRef('smart_contract_update_form'), html` -
- - No smart contracts found -
- `) +
+ + No smart contracts found +
+ `) } showChildElement('smartcontracts', 4, !firstLoad ? { entry: slideInLeft, exit: slideOutLeft } : {}) break; @@ -1424,44 +1429,44 @@ const { contractName, contractAddress, price, tokenIdentification, userChoices } = selectedSmartContract history.replaceState(null, null, `#/smartcontracts/trigger?scName=${contractName}&scAddress=${contractAddress}`) renderElem(getRef('smart_contract_trigger_form'), html` -
- Select smart contract - - ${render.availableSmartContractOptions(filteredSmartContracts, `${contractName}_${contractAddress}`)} - -
-
- Select outcome
- ${userChoices.map(choice => html` - - `)} + Select smart contract + + ${render.availableSmartContractOptions(filteredSmartContracts, `${contractName}_${contractAddress}`)} +
-
-
- Committee address FLO private key - - - -
-
- -
- `) +
+ Select outcome +
+ ${userChoices.map(choice => html` + + `)} +
+
+
+ Committee address FLO private key + + + +
+
+ +
+ `) } else { renderElem(getRef('smart_contract_trigger_form'), html` -
- - No smart contracts with external triggers found -
- `) +
+ + No smart contracts with external triggers found +
+ `) } showChildElement('smartcontracts', 5, { entry: slideInLeft, exit: slideOutLeft }) break; @@ -1599,8 +1604,18 @@ pagesData.lastPage = pageId } } - document.querySelectorAll('sm-input[data-flo-address]').forEach(input => input.customValidation = floCrypto.validateFloID) - document.querySelectorAll('sm-input[data-private-key]').forEach(input => input.customValidation = floCrypto.getPubKeyHex) + document.querySelectorAll('sm-input[data-flo-address]').forEach(input => input.customValidation = (value) => { + return { + isValid: floCrypto.validateAddr(value), + errorText: `Invalid FLO address.
It usually starts with "F"` + } + }) + document.querySelectorAll('sm-input[data-private-key]').forEach(input => input.customValidation = (value) => { + return { + isValid: floCrypto.getPubKeyHex(value), + errorText: `Invalid private key.
It's a long string of random characters usually starting with 'R'.` + } + }) } const indicatorObserver = new IntersectionObserver(entries => { @@ -1874,12 +1889,12 @@ className: 'saved-id grid interact', attributes: { 'tabindex': '0', 'data-flo-address': floID }, innerHTML: ` -
${name[0]}
-
-

${name}

-
${floID}
-
- ` +
${name[0]}
+
+

${name}

+
${floID}
+
+ ` }) }, transactionCard(details) { @@ -1951,16 +1966,16 @@ for (let i = 1; i <= paginationSegments; i++) { if (i === 1) { pagination.push(html` - - ${i} - - `) + + ${i} + + `) } else if (startingPage <= i && i <= showTill) { pagination.push(html` - - ${i} - - `) + + ${i} + + `) } else if (i === showTill + 1 && i < paginationSegments) { pagination.push(html`
...
`) } else if (i == paginationSegments) { @@ -1987,154 +2002,154 @@ availableSmartContractOptions(smartContracts = [], selected) { return smartContracts .map(({ contractName, contractAddress }) => html` - ${`${replaceDash(contractName)} (${contractAddress})`} - `) + ${`${replaceDash(contractName)} (${contractAddress})`} + `) }, contractCreationForm(type, subtype) { return html` - ${!type && !subtype ? html` -
-
- Type - - -
-
- Subtype - - - -
-
- ` : ''} -
-
- Contract name - -
- ${type === 'one-time-event' ? html` -
- Asset - - ${render.availableAssetOptions()} - + ${!type && !subtype ? html` +
+
+ Type + + +
+
+ Subtype + + + +
- ${subtype === 'time-trigger' ? html` + ` : ''} +
+
+ Contract name + +
+ ${type === 'one-time-event' ? html`
- Payee FLO addresses -
    -
  • - - -
  • -
- + Asset + + ${render.availableAssetOptions()} + +
+ ${subtype === 'time-trigger' ? html` +
+ Payee FLO addresses +
    +
  • + + +
  • +
+ +
+ ` : html` +
+ Participant choices +
+ + +
+ +
+ `} +
+ Expiration + +
+
+ Participation amount (optional) + +
+
+ Min. subscription amount (optional) + +
+
+ Max. subscription amount (optional) +
` : html` +
+ Price type + + +
- Participant choices -
- - -
- + Deposit token + + ${render.availableAssetOptions()} +
- `} +
+ Participation token + + ${render.availableAssetOptions()} + +
+
+ Price (1 deposit token = ? participation token) + +
+ `}
- Expiration - + FLO private key + + +
-
- Participation amount (optional) - -
-
- Min. subscription amount (optional) - -
-
- Max. subscription amount (optional) - -
- ` : html` -
- Price type - - -
-
- Deposit token - - ${render.availableAssetOptions()} - -
-
- Participation token - - ${render.availableAssetOptions()} - -
-
- Price (1 deposit token = ? participation token) - -
- `} -
- FLO private key - - - +
+ +
-
- -
-
- ` + ` } } let transactionsLazyLoader @@ -2208,15 +2223,15 @@ card = createElement('div', { className: 'generated-id-card', innerHTML: ` -
-
FLO Address
- -
-
-
Private Key
- -
- ` +
+
FLO Address
+ +
+
+
Private Key
+ +
+ ` }); getRef('created_flo_id').innerHTML = ''; getRef('created_flo_id').append(card); @@ -2323,30 +2338,30 @@ let ownedTokens = [] for (const token in floAddressBalances) { ownedTokens.push(html` - - `) + + `) } if (ownedTokens.length) { ownedTokens.push(html` - - `) + + `) renderElem(document.getElementById('sender_tokens_wrapper'), html.for(document.getElementById('sender_tokens_wrapper'), senderFloAddr)` -
-
Tokens
-

Select a token, if you want to send a token.

-
-
-
- ${ownedTokens} +
+
Tokens
+

Select a token, if you want to send a token.

-
- `) +
+
+ ${ownedTokens} +
+
+ `) document.getElementById('sender_tokens_wrapper').classList.remove('hidden') handleTokenSelection() } else { @@ -2366,12 +2381,12 @@ getRef('tx_flo_amount').classList.remove('hidden') renderElem(getRef('tx_receiver_wrapper'), html``) renderElem(getRef('tx_receiver_wrapper'), html` - - - - `) + + + + `) getRef('add_token_receiver').classList.add('hidden') floGlobals.sendType = 'flo' getRef('send_form').elementsChanged() @@ -2395,22 +2410,22 @@ const tokenName = selectedToken.value; const isFirst = getRef('tx_receiver_wrapper').children.length === 0 getRef('tx_receiver_wrapper').append(html.node` -
- - - - - - ${!isFirst ? html.node` - - ` : ''} -
- `) +
+ + + + + + ${!isFirst ? html.node` + + ` : ''} +
+ `) getRef('send_form').elementsChanged() } function removeTokenReceiver(elem) { @@ -2430,40 +2445,40 @@ console.log(options) getRef('tx_flo_amount').setAttribute('max', balance) renderElem(getRef('balance_card'), html` -
-
-
Balance
- +
+
+
Balance
+ +
+
+ ${showLoader ? html`` : balance} + FLO +
+
+ Sender FLO Address +

${address}

+
+ ${!showLoader && balance == 0 ? html` +

+ You don't have any FLO in your wallet. Please add some FLO to your wallet to send FLO. +

+ ` : ''}
-
- ${showLoader ? html`` : balance} - FLO -
-
- Sender FLO Address -

${address}

-
- ${!showLoader && balance == 0 ? html` -

- You don't have any FLO in your wallet. Please add some FLO to your wallet to send FLO. -

- ` : ''} -
- - `) + + `) } function resetBalance() { clearSelection() renderElem(getRef('balance_card'), html` -
-
Balance
-
-

- Sender balance will be shown once you enter it's private key -

- `) +
+
Balance
+
+

+ Sender balance will be shown once you enter it's private key +

+ `) } @@ -2524,9 +2539,9 @@ getRef('queried_flo_address').innerHTML = `

${allLabels[queriedFloId]}

`; } else { getRef('queried_flo_address').innerHTML = ` -

FLO Address

-

- `; +

FLO Address

+

+ `; } }) const queriedFloId = address || getRef('search_query_input').value.trim() @@ -2539,10 +2554,10 @@ let ownedTokens = [] for (const token in tokenBalances) { ownedTokens.push(html` -
  • - ${token}: ${parseFloat((tokenBalances[token].balance || 0).toFixed(8))} -
  • - `) +
  • + ${token}: ${parseFloat((tokenBalances[token].balance || 0).toFixed(8))} +
  • + `) } if (ownedTokens.length) { renderElem(getRef('token_list'), html`${ownedTokens}`) @@ -2582,11 +2597,11 @@ document.getElementById('load_more_transactions').classList.add('hidden') renderElem(getRef('pagination_wrapper'), html``) renderElem(getRef('queried_address_transactions'), html` -
    - - Loading transactions... -
    - `) +
    + + Loading transactions... +
    + `) const { items, totalPages } = await floWebWallet.listTransactions(address, { pageSize: txsPerPage, page }) floGlobals.query = { transactions: items, @@ -2670,8 +2685,8 @@ if (tokenReceivers.length) { const consent = await getConfirmation(`Confirm transaction`, { message: ` - Sending ${selectedToken.value} tokens to \n\n ${tokenReceivers.map(r => `${r}: ${bulkTokenReceivers[r]} ${selectedToken.value}`).join('\n')} - `, + Sending ${selectedToken.value} tokens to \n\n ${tokenReceivers.map(r => `${r}: ${bulkTokenReceivers[r]} ${selectedToken.value}`).join('\n')} + `, confirmText: 'Send', }) if (!consent) return; @@ -2682,16 +2697,16 @@ showTransactionResult(true, null, { title: `Multiple transactions have been initiated`, description: html` - - ` + + ` }); } else { const floData = `send ${bulkTokenReceivers[tokenReceivers[0]]} ${selectedToken.value}#` @@ -2723,24 +2738,24 @@ description = success ? 'This might take upto 30 mins to complete and reflect on blockchain.' : result renderElem(getRef('transaction_result'), html` - ${success ? html` - - ` : ''} - ${!success ? html` - - ` : ''} -

    ${title}

    -

    ${description}

    - ${success && result ? html` -
    - See transaction on blockchain -
    - Transaction ID - + ${success ? html` + + ` : ''} + ${!success ? html` + + ` : ''} +

    ${title}

    +

    ${description}

    + ${success && result ? html` +
    + See transaction on blockchain +
    + Transaction ID + +
    -
    - ` : ''} - `) + ` : ''} + `) openPopup('transaction_result_popup') } @@ -3096,11 +3111,11 @@ case 'dynamic': e.target.closest('sm-form').querySelector('.oracle-address-wrapper')?.remove() e.target.closest('fieldset').after(html.node` -
    - Oracle FLO address - -
    - `) +
    + Oracle FLO address + +
    + `) break; } } @@ -3226,7 +3241,7 @@ showTransactionResult(true, txid, { title: 'Smart contract creation initiated', description: html`Check details about your smart contract here. -
    It may take some time for the smart contract to be created.` +
    It may take some time for the smart contract to be created.` }) getRef('smart_contract_creation_form').reset() document.getElementById('create_contract_button').disabled = true @@ -3241,18 +3256,23 @@ function addPayeeAddress() { document.getElementById('payee_container').append(html.node` -
  • - - - -
  • - `) +
  • + + + +
  • + `) document.getElementById('payee_container').querySelectorAll('.payee-share').forEach((input) => { input.value = parseFloat((100 / document.getElementById('payee_container').querySelectorAll('.payee-share').length).toFixed(2)) }) - document.getElementById('payee_container').lastElementChild.querySelector('.payee-address').customValidation = floCrypto.validateFloID + document.getElementById('payee_container').lastElementChild.querySelector('.payee-address').customValidation = (value) => { + return { + isValid: floCrypto.validateAddr(value), + errorText: `Invalid FLO address.
    It usually starts with "F".` + } + } } function removePayee(e) { e.target.closest('li').remove() @@ -3264,13 +3284,13 @@ function addChoice(e) { const choiceNo = document.getElementById('choices_container').children.length + 1 document.getElementById('choices_container').append(html.node` -
    - - - - `) +
    + + + + `) } function removeChoice(e) { e.target.closest('.choice-wrapper').remove() @@ -3296,7 +3316,6 @@ function replaceDash(str) { return str.replace(/-/g, ' ') } -