Feature update
-- added UI for aggregator approval/removal -- added link to access management page
This commit is contained in:
parent
826cb771e4
commit
4426493304
@ -48,7 +48,7 @@ strong {
|
||||
|
||||
a {
|
||||
text-decoration: none;
|
||||
color: var(--accent-color);
|
||||
color: inherit;
|
||||
}
|
||||
a:focus-visible {
|
||||
box-shadow: 0 0 0 0.1rem rgba(var(--text-color), 1) inset;
|
||||
|
||||
2
css/main.min.css
vendored
2
css/main.min.css
vendored
File diff suppressed because one or more lines are too long
@ -48,7 +48,7 @@ strong {
|
||||
|
||||
a {
|
||||
text-decoration: none;
|
||||
color: var(--accent-color);
|
||||
color: inherit;
|
||||
|
||||
&:focus-visible {
|
||||
box-shadow: 0 0 0 0.1rem rgba(var(--text-color), 1) inset;
|
||||
|
||||
36
index.html
36
index.html
@ -19,7 +19,7 @@
|
||||
<h4>Loading RanchiMall KYC blockchain verification</h4>
|
||||
</div>
|
||||
<article>
|
||||
<header class="flex space-between">
|
||||
<header class="flex gap-1 align-center">
|
||||
<h1 class="flex align-items-center" style="font-size: 1rem;">
|
||||
<svg class="icon" style="margin-right:0.3rem" viewBox="0 0 96 108" xml:space="preserve">
|
||||
<path d="M90.2,102.5c-2.4-8.2-9.9-14.5-27.4-23.1c-7.1-3.5-11.8-6.2-14-8.3c-1.7-1.6-3.5-4-4.2-5.5c-0.7-1.7-0.7-5.5,0-7.5
|
||||
@ -47,6 +47,7 @@
|
||||
</svg>
|
||||
RanchiMall
|
||||
</h1>
|
||||
<a href="/chainkyc/manage.html" class="button button--colored margin-left-auto">For officials</a>
|
||||
<theme-toggle></theme-toggle>
|
||||
</header>
|
||||
<section id="verification_section" class="grid gap-1-5">
|
||||
@ -102,7 +103,7 @@
|
||||
if (address === '') return renderElem(getRef('verification_result'), html`Please enter an address`);
|
||||
getRef('verification_result').classList.remove('hidden');
|
||||
if (floGlobals.approvedKyc[address]) {
|
||||
const { validFrom, validTo, verifiedBy, revokedBy } = floGlobals.approvedKyc[address];
|
||||
const { validFrom, validTo, issuedBy, revokedBy } = floGlobals.approvedKyc[address];
|
||||
const validFromFormatted = getFormattedTime(validFrom, 'date-only');
|
||||
const validToFormatted = getFormattedTime(validTo, 'date-only');
|
||||
if (validFrom <= Date.now() && Date.now() <= validTo) {
|
||||
@ -112,17 +113,20 @@
|
||||
<svg class='icon' xmlns="http://www.w3.org/2000/svg" enable-background="new 0 0 24 24" height="24px" viewBox="0 0 24 24" width="24px" fill="#000000"><g><rect fill="none" height="24" width="24"/></g><g><path d="M23,12l-2.44-2.79l0.34-3.69l-3.61-0.82L15.4,1.5L12,2.96L8.6,1.5L6.71,4.69L3.1,5.5L3.44,9.2L1,12l2.44,2.79l-0.34,3.7 l3.61,0.82L8.6,22.5l3.4-1.47l3.4,1.46l1.89-3.19l3.61-0.82l-0.34-3.69L23,12z M10.09,16.72l-3.8-3.81l1.48-1.48l2.32,2.33 l5.85-5.87l1.48,1.48L10.09,16.72z"/></g></svg>
|
||||
<h4>Verified KYC</h4>
|
||||
</div>
|
||||
<div class="info flex align-center gap-0-5 flex-wrap">
|
||||
<span>Verified on</span>
|
||||
<span>${getFormattedTime(Date.now(), 'date-only')}</span>
|
||||
<div class="info flex gap-0-5 flex-wrap">
|
||||
<span>Issued by</span>
|
||||
<div class="grid">
|
||||
<h4>${floGlobals.approvedKycAggregators[issuedBy]}</h4>
|
||||
<sm-copy value=${issuedBy} clip-text></sm-copy>
|
||||
</div>
|
||||
</div>
|
||||
<div class="info flex align-center gap-0-5 flex-wrap">
|
||||
<span>Issued on</span>
|
||||
<span>${validFromFormatted}</span>
|
||||
</div>
|
||||
<div class="info flex align-center gap-0-5 flex-wrap">
|
||||
<span>Issued by</span>
|
||||
<sm-copy value=${verifiedBy} clip-text></sm-copy>
|
||||
<span>Verified on</span>
|
||||
<span>${getFormattedTime(Date.now(), 'date-only')}</span>
|
||||
</div>
|
||||
`);
|
||||
} else {
|
||||
@ -131,21 +135,27 @@
|
||||
<svg class="icon" xmlns="http://www.w3.org/2000/svg" enable-background="new 0 0 24 24" height="24px" viewBox="0 0 24 24" width="24px" fill="#000000"><g><path d="M0,0h24v24H0V0z" fill="none"/></g><g><path d="M12,2L4,5v6.09c0,5.05,3.41,9.76,8,10.91c4.59-1.15,8-5.86,8-10.91V5L12,2z M15.5,14.09l-1.41,1.41L12,13.42L9.91,15.5 L8.5,14.09L10.59,12L8.5,9.91L9.91,8.5L12,10.59l2.09-2.09l1.41,1.41L13.42,12L15.5,14.09z"/></g></svg>
|
||||
<h4>KYC verification expired</h4>
|
||||
</div>
|
||||
<div class="info flex gap-0-5 flex-wrap">
|
||||
<span>Issued by</span>
|
||||
<div class="grid">
|
||||
<h4>${floGlobals.approvedKycAggregators[issuedBy]}</h4>
|
||||
<sm-copy value=${issuedBy} clip-text></sm-copy>
|
||||
</div>
|
||||
</div>
|
||||
<div class="info flex align-center gap-0-5 flex-wrap">
|
||||
<span>Issued on</span>
|
||||
<span>${validFromFormatted}</span>
|
||||
</div>
|
||||
<div class="info flex align-center gap-0-5 flex-wrap">
|
||||
<span>Issued by</span>
|
||||
<sm-copy value=${verifiedBy} clip-text></sm-copy>
|
||||
</div>
|
||||
<div class="info flex align-center gap-0-5 flex-wrap">
|
||||
<span>Expired on</span>
|
||||
<span>${validToFormatted}</span>
|
||||
</div>
|
||||
<div class="info flex align-center gap-0-5 flex-wrap">
|
||||
<div class="info flex gap-0-5 flex-wrap">
|
||||
<span>Revoked by</span>
|
||||
<sm-copy value=${revokedBy} clip-text></sm-copy>
|
||||
<div class="grid">
|
||||
<h4>${floGlobals.approvedKycAggregators[revokedBy]}</h4>
|
||||
<sm-copy value=${revokedBy} clip-text></sm-copy>
|
||||
</div>
|
||||
</div>
|
||||
`);
|
||||
getRef('verification_result').dataset.status = 'invalid';
|
||||
|
||||
306
manage.html
306
manage.html
@ -29,60 +29,69 @@
|
||||
</div>
|
||||
<article>
|
||||
<header class="flex space-between">
|
||||
<h1 class="flex align-items-center" style="font-size: 1rem;">
|
||||
<svg class="icon" style="margin-right:0.3rem" viewBox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.3,23.3L20.3,23.3c-2,1-3.3,1.4-4.8,1.5L13.3,25l2.3-2.8c3.7-4.5,6.4-8.9,10-16
|
||||
c0.9-1.8,1.8-3.5,2-3.6c0.4-0.4,2.6,1.1,5.1,3.4l2.1,1.9l-1.9,2.8C28.2,17.5,24.5,21.2,20.3,23.3z M39.3,17.4
|
||||
c-1.2,1.7-6.5,5.7-8.6,6.5v0c-1.1,0.4-2.8,0.8-3.9,0.9L24.9,25l2.1-2.6c2.5-3.1,5.1-7,7-10.4c0.7-1.4,1.4-2.5,1.5-2.6
|
||||
c0.3-0.4,1.7,1.4,3,4.1l1.5,3L39.3,17.4z M44.6,10c-0.7,1.2-1.4,2.1-1.5,2.1c-0.1,0-1.5-1.4-3-3l-2.8-3l0.6-1.5
|
||||
c1.1-2.6,1.3-2.7,3.4-1c1.9,1.5,4.5,3.8,4.5,4.1C45.8,7.8,45.3,8.9,44.6,10z"></path>
|
||||
</svg>
|
||||
RanchiMall
|
||||
</h1>
|
||||
<a href="/chainkyc">
|
||||
<h1 class="flex align-items-center" style="font-size: 1rem;">
|
||||
<svg class="icon" style="margin-right:0.3rem" viewBox="0 0 96 108" xml:space="preserve">
|
||||
<path d="M90.2,102.5c-2.4-8.2-9.9-14.5-27.4-23.1c-7.1-3.5-11.8-6.2-14-8.3c-1.7-1.6-3.5-4-4.2-5.5c-0.7-1.7-0.7-5.5,0-7.5
|
||||
c1.3-3.6,2.6-5.2,12.9-15.1c6.2-5.9,9.3-10.3,11.1-15.5c0.7-2.1,0.8-7.6,0.2-9.4C66.5,12,61.7,6.7,53.7,1.6c-3-1.9-4.3-2.1-4.3-0.8
|
||||
c0,0.3-0.5,1.4-1,2.4l-1,1.8l-2.8-1.9c-1.5-1.1-3.4-2.2-4.1-2.6c-1.3-0.7-2.4-0.6-2.4,0.2c0,0.3-1.4,3.4-2,4.4
|
||||
c0,0.1-0.4-0.1-0.9-0.4c-6.1-4.4-8.7-5.5-8.7-3.9c0,0.7-1.8,4.2-4,7.9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8,4.5,4.1C45.8,7.8,45.3,8.9,44.6,10z"></path>
|
||||
</svg>
|
||||
RanchiMall
|
||||
</h1>
|
||||
</a>
|
||||
<theme-toggle></theme-toggle>
|
||||
</header>
|
||||
<div class="flex justify-center">
|
||||
<sm-chips id="manage_type" class="margin-bottom-1"
|
||||
style="padding: 0.5rem; background-color: rgba(var(--foreground-color),1); border-radius: 0.8rem;">
|
||||
<sm-chip value="aggregator" selected>Aggregator</sm-chip>
|
||||
<sm-chip value="admin">Admin</sm-chip>
|
||||
</sm-chips>
|
||||
</div>
|
||||
<section id="kyc_section" class="grid gap-1-5">
|
||||
<div class="flex flex-wrap align-center space-between gap-1">
|
||||
<h2>
|
||||
KYC Management
|
||||
<h2 id="manage_title">
|
||||
Manage KYC
|
||||
</h2>
|
||||
<sm-chips id="kyc_type">
|
||||
<sm-chip value="approve" selected>Approve</sm-chip>
|
||||
<sm-chip value="revoke">Revoke</sm-chip>
|
||||
</sm-chips>
|
||||
</div>
|
||||
<div class="grid gap-0-5">
|
||||
<h4>Aggregator credentials</h4>
|
||||
<sm-input id="aggregator_private_key" placeholder="Private key" error-text="Invalid private key"
|
||||
<div class="grid gap-1">
|
||||
<h4 id="credential_title">Aggregator credentials</h4>
|
||||
<sm-input id="approver_private_key" placeholder="Private key" error-text="Invalid private key"
|
||||
type="password" required animate></sm-input>
|
||||
<p id="aggregator_balance" class="hidden"></p>
|
||||
</div>
|
||||
<div id="kyc_mode_wrapper">
|
||||
<sm-form>
|
||||
<div class="grid gap-0-5">
|
||||
<h4>KYCs to be approved</h4>
|
||||
<p class="margin-bottom-1">
|
||||
<h4 id="approval_title">KYCs to be approved</h4>
|
||||
<p id="approval_description" class="margin-bottom-1">
|
||||
Enter the addresses of the KYCs you want to approve. You can add multiple addresses by
|
||||
clicking the "Add address" button.
|
||||
</p>
|
||||
<ul id="kyc_addresses_container" class="grid gap-0-3"></ul>
|
||||
<ul id="kyc_addresses_container" class="grid gap-1"></ul>
|
||||
<button id="add_address" class="button margin-right-auto" onclick="addAddressInput()">Add
|
||||
address</button>
|
||||
</div>
|
||||
@ -93,14 +102,14 @@
|
||||
</sm-form>
|
||||
<div class="grid gap-1 hidden">
|
||||
<div class="grid gap-0-5">
|
||||
<h4>Approved KYC addresses</h4>
|
||||
<p>
|
||||
<h4 id="revoke_title">Approved KYC addresses</h4>
|
||||
<p id="revoke_description">
|
||||
To revoke a KYC, select one or multiple KYCs and click on the 'Revoke selected' button.
|
||||
</p>
|
||||
</div>
|
||||
<div class="grid gap-0-5"
|
||||
style="position: sticky; top: 0; z-index: 2; background-color: rgba(var(--foreground-color),1);">
|
||||
<sm-input id="search_approved" type="search" placeholder="Search address">
|
||||
<sm-input id="search_approved" type="search" placeholder="Search">
|
||||
<svg class="icon" slot="icon" xmlns="http://www.w3.org/2000/svg" height="24px"
|
||||
viewBox="0 0 24 24" width="24px" fill="#000000">
|
||||
<path d="M0 0h24v24H0V0z" fill="none" />
|
||||
@ -124,7 +133,7 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<ul id="approved_kyc_addresses" class="grid gap-0-3"></ul>
|
||||
<ul id="approved_addresses" class="grid gap-0-3"></ul>
|
||||
<p id="no_results" class="hidden">
|
||||
No addresses found.
|
||||
</p>
|
||||
@ -132,19 +141,21 @@
|
||||
</div>
|
||||
</section>
|
||||
</article>
|
||||
<template id="key_address_template">
|
||||
<template id="kyc_address_template">
|
||||
<li class="address-input flex align-center gap-0-5">
|
||||
<sm-input class="kyc-address" placeholder="FLO/BTC address" error-text="Invalid address" required
|
||||
animate></sm-input>
|
||||
<button class="remove-address button--small" onclick="removeAddressInput(this)">
|
||||
<svg class="icon margin-right-0-3" xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 0 24 24"
|
||||
width="24px" fill="#000000">
|
||||
<div class="grid gap-0-3 flex-1">
|
||||
<sm-input class="kyc-address" placeholder="FLO/BTC address" error-text="Invalid address" required
|
||||
animate></sm-input>
|
||||
<sm-input class="aggregator-label" placeholder="Label" required animate></sm-input>
|
||||
</div>
|
||||
<button class="remove-address button icon-only" onclick="removeAddressInput(this)">
|
||||
<svg class="icon" xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 0 24 24" width="24px"
|
||||
fill="#000000">
|
||||
<path d="M0 0h24v24H0V0z" fill="none"></path>
|
||||
<path
|
||||
d="M7 11v2h10v-2H7zm5-9C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm0 18c-4.41 0-8-3.59-8-8s3.59-8 8-8 8 3.59 8 8-3.59 8-8 8z">
|
||||
</path>
|
||||
</svg>
|
||||
Remove
|
||||
</button>
|
||||
</li>
|
||||
</template>
|
||||
@ -254,25 +265,83 @@
|
||||
</li>
|
||||
`
|
||||
},
|
||||
approvedKycs() {
|
||||
const approvedKycs = Object.keys(floGlobals.approvedKyc)
|
||||
approvedKycAddresses() {
|
||||
const approvedKycAddresses = Object.keys(floGlobals.approvedKyc)
|
||||
.filter(address => !floGlobals.approvedKyc[address].revokedBy)
|
||||
.map(address => render.approvedKycAddressCard(address))
|
||||
renderElem(getRef('approved_kyc_addresses'), html`${approvedKycs}`)
|
||||
renderElem(getRef('approved_addresses'), html`${approvedKycAddresses}`)
|
||||
},
|
||||
approvedAggregatorCard(address) {
|
||||
const floID = floCrypto.toFloID(address)
|
||||
const btcID = btcOperator.convert.legacy2bech(floID)
|
||||
return html`
|
||||
<li class="revoke-card" data-address=${btcID} data-search-key=${`${floGlobals.approvedKycAggregators[address]}-${btcID}-${floID}`}>
|
||||
<label class="flex align-center">
|
||||
<input type="checkbox" value=${btcID}/>
|
||||
<div class="grid gap-0-5">
|
||||
<h4>${floGlobals.approvedKycAggregators[address]}</h4>
|
||||
<div class="grid gap-0-3">
|
||||
<span class="wrap-around">BTC: ${btcID}</span>
|
||||
<span class="wrap-around">FLO: ${floID}</span>
|
||||
</div>
|
||||
</div>
|
||||
</label>
|
||||
</li>
|
||||
`
|
||||
},
|
||||
approvedAggregators() {
|
||||
const approvedAggregators = Object.keys(floGlobals.approvedKycAggregators)
|
||||
.map(address => render.approvedAggregatorCard(address))
|
||||
renderElem(getRef('approved_addresses'), html`${approvedAggregators}`)
|
||||
},
|
||||
ui() {
|
||||
const manageType = getRef('manage_type').value
|
||||
const actionType = getRef('kyc_type').value
|
||||
if (manageType === 'aggregator') {
|
||||
getRef('manage_title').textContent = 'Manage KYC'
|
||||
getRef('credential_title').textContent = 'Aggregator credentials'
|
||||
getRef('approval_title').textContent = 'KYCs to be approved'
|
||||
getRef('approval_description').textContent = `
|
||||
Enter the addresses of the KYCs you want to approve. You can add multiple addresses by clicking the "Add address" button.
|
||||
`
|
||||
getRef('revoke_title').textContent = 'Approved KYC addresses'
|
||||
getRef('revoke_description').textContent = `
|
||||
To revoke a KYC, select one or multiple KYCs and click on the 'Revoke selected' button.
|
||||
`
|
||||
render.approvedKycAddresses()
|
||||
getRef('search_approved').placeholder = 'Search addresses'
|
||||
} else {
|
||||
getRef('manage_title').textContent = 'Manage aggregators'
|
||||
getRef('credential_title').textContent = 'Admin credentials'
|
||||
getRef('approval_title').textContent = 'Aggregators to be approved'
|
||||
getRef('approval_description').textContent = `
|
||||
Enter the addresses of the aggregators you want to approve. You can add multiple addresses by clicking the "Add address" button.
|
||||
`
|
||||
getRef('revoke_title').textContent = 'Approved aggregator addresses'
|
||||
getRef('revoke_description').textContent = `
|
||||
To revoke an aggregator, select one or multiple aggregators and click on the 'Revoke selected' button.
|
||||
`
|
||||
render.approvedAggregators()
|
||||
getRef('search_approved').placeholder = 'Search names or addresses'
|
||||
}
|
||||
if (actionType === 'approve') {
|
||||
showChildElement('kyc_mode_wrapper', 0)
|
||||
} else {
|
||||
showChildElement('kyc_mode_wrapper', 1)
|
||||
}
|
||||
getRef('kyc_addresses_container').innerHTML = '';
|
||||
clearSelection()
|
||||
addAddressInput()
|
||||
}
|
||||
}
|
||||
|
||||
getRef('manage_type').addEventListener('change', render.ui)
|
||||
|
||||
const addressesToRevoke = new Set()
|
||||
getRef('kyc_type').addEventListener('change', e => {
|
||||
if (e.target.value === 'approve') {
|
||||
showChildElement('kyc_mode_wrapper', 0)
|
||||
} else {
|
||||
showChildElement('kyc_mode_wrapper', 1)
|
||||
render.approvedKycs()
|
||||
}
|
||||
})
|
||||
getRef('kyc_type').addEventListener('change', render.ui)
|
||||
getRef('search_approved').addEventListener('input', e => {
|
||||
const searchKey = e.target.value.toLowerCase()
|
||||
getRef('approved_kyc_addresses').querySelectorAll('li').forEach(li => {
|
||||
getRef('approved_addresses').querySelectorAll('li').forEach(li => {
|
||||
if (li.dataset.searchKey.toLowerCase().includes(searchKey)) {
|
||||
li.classList.remove('hidden')
|
||||
} else {
|
||||
@ -280,13 +349,13 @@
|
||||
}
|
||||
})
|
||||
// show message if no results
|
||||
if (getRef('approved_kyc_addresses').querySelectorAll('li:not(.hidden)').length === 0) {
|
||||
if (getRef('approved_addresses').querySelectorAll('li:not(.hidden)').length === 0) {
|
||||
getRef('no_results').classList.remove('hidden')
|
||||
} else {
|
||||
getRef('no_results').classList.add('hidden')
|
||||
}
|
||||
})
|
||||
getRef('approved_kyc_addresses').addEventListener('change', e => {
|
||||
getRef('approved_addresses').addEventListener('change', e => {
|
||||
if (e.target.checked) {
|
||||
const addresses = processAddresses([...addressesToRevoke])
|
||||
const floData = `KYC|REVOKE_KYC|${addresses.join(',')}`
|
||||
@ -310,15 +379,15 @@
|
||||
addressesToRevoke.clear()
|
||||
getRef('selected_addresses').textContent = ``
|
||||
getRef('selected_wrapper').classList.add('hidden')
|
||||
getRef('approved_kyc_addresses').querySelectorAll('input').forEach(input => input.checked = false)
|
||||
getRef('approved_addresses').querySelectorAll('input').forEach(input => input.checked = false)
|
||||
}
|
||||
getRef('aggregator_private_key').addEventListener('input', e => {
|
||||
checkBalance(floCrypto.getAddress(e.target.value.trim()))
|
||||
getRef('approver_private_key').addEventListener('input', e => {
|
||||
checkBalance(floCrypto.getFloID(e.target.value.trim()))
|
||||
})
|
||||
function checkBalance(address) {
|
||||
if (!address)
|
||||
address = floCrypto.getAddress(getRef('aggregator_private_key').value.trim())
|
||||
if (getRef('aggregator_private_key').isValid) {
|
||||
address = floCrypto.getFloID(getRef('approver_private_key').value.trim())
|
||||
if (getRef('approver_private_key').isValid) {
|
||||
floBlockchainAPI.getBalance(address).then(balance => {
|
||||
if (balance < 0.01) {
|
||||
renderElem(getRef('aggregator_balance'), html`Balance: ${balance} FLO. You don't have enough FLO.`);
|
||||
@ -338,10 +407,13 @@
|
||||
}
|
||||
}
|
||||
function addAddressInput() {
|
||||
const addressInput = getRef('key_address_template').content.cloneNode(true)
|
||||
const manageType = getRef('manage_type').value
|
||||
const addressInput = getRef('kyc_address_template').content.cloneNode(true)
|
||||
if (!getRef('kyc_addresses_container').firstElementChild) {
|
||||
addressInput.querySelector('.remove-address').remove()
|
||||
}
|
||||
if (manageType === 'aggregator')
|
||||
addressInput.querySelector('.aggregator-label').remove()
|
||||
getRef('kyc_addresses_container').appendChild(addressInput)
|
||||
}
|
||||
function removeAddressInput(button) {
|
||||
@ -356,10 +428,9 @@
|
||||
const removeButton = mutation.target.firstElementChild.querySelector('.remove-address')
|
||||
if (!removeButton) {
|
||||
const newRemoveButton = html.node`
|
||||
<button class="remove-address button--small" onclick="removeAddressInput(this)">
|
||||
<svg class="icon margin-right-0-3" xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 0 24 24" width="24px" fill="#000000"> <path d="M0 0h24v24H0V0z" fill="none"></path> <path d="M7 11v2h10v-2H7zm5-9C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm0 18c-4.41 0-8-3.59-8-8s3.59-8 8-8 8 3.59 8 8-3.59 8-8 8z"></path> </svg>
|
||||
Remove
|
||||
</button>
|
||||
<button class="remove-address button icon-only" onclick="removeAddressInput(this)">
|
||||
<svg class="icon" xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 0 24 24" width="24px" fill="#000000"> <path d="M0 0h24v24H0V0z" fill="none"></path> <path d="M7 11v2h10v-2H7zm5-9C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm0 18c-4.41 0-8-3.59-8-8s3.59-8 8-8 8 3.59 8 8-3.59 8-8 8z"> </path> </svg>
|
||||
</button>
|
||||
`
|
||||
mutation.target.firstElementChild.appendChild(newRemoveButton)
|
||||
}
|
||||
@ -380,28 +451,53 @@
|
||||
const uniqueAddresses = new Set()
|
||||
addresses.forEach(address => {
|
||||
let equivalentBtcAddress = address
|
||||
if (floCrypto.validateFloID(address))
|
||||
if (getRef('manage_type').value === 'aggregator' && floCrypto.validateFloID(address))
|
||||
equivalentBtcAddress = btcOperator.convert.legacy2bech(address)
|
||||
else
|
||||
equivalentBtcAddress = floCrypto.toFloID(address)
|
||||
uniqueAddresses.add(equivalentBtcAddress)
|
||||
})
|
||||
return [...uniqueAddresses]
|
||||
}
|
||||
function approveAddresses() {
|
||||
const aggregatorPrivateKey = getRef('aggregator_private_key').value.trim()
|
||||
if (!aggregatorPrivateKey) {
|
||||
return notify('Enter aggregator private key', 'error')
|
||||
const manageType = getRef('manage_type').value
|
||||
const approverPrivateKey = getRef('approver_private_key').value.trim()
|
||||
if (!approverPrivateKey) {
|
||||
return notify(`Enter ${manageType} private key`, 'error')
|
||||
}
|
||||
const aggregatorAddress = floCrypto.getAddress(aggregatorPrivateKey)
|
||||
if (!floGlobals.approvedKycAggregators.hasOwnProperty(aggregatorAddress)) {
|
||||
return notify('KYC aggregator address is not approved', 'error')
|
||||
const approverAddress = floCrypto.getFloID(approverPrivateKey)
|
||||
if (manageType === 'aggregator') {
|
||||
if (!floGlobals.approvedKycAggregators.hasOwnProperty(approverAddress)) {
|
||||
return notify('KYC aggregator address is not approved', 'error')
|
||||
}
|
||||
} else {
|
||||
if (floGlobals.masterAddress !== approverAddress) {
|
||||
return notify(`Private key doesn't match admin`, 'error')
|
||||
}
|
||||
}
|
||||
const addressInputs = [...document.querySelectorAll('.kyc-address')]
|
||||
.filter(input => input.value.trim() !== '')
|
||||
.map(input => input.value.trim())
|
||||
let addressLabels = []
|
||||
if (manageType === 'admin') {
|
||||
addressLabels = [...document.querySelectorAll('.aggregator-label')]
|
||||
.filter(input => input.value.trim() !== '')
|
||||
.map(input => input.value.trim())
|
||||
}
|
||||
const addresses = processAddresses(addressInputs)
|
||||
if (addresses.length === 0) {
|
||||
return notify('Enter at least one address to approve', 'error')
|
||||
}
|
||||
const floData = `KYC|APPROVE_KYC|${addresses.join(',')}`
|
||||
let floData
|
||||
if (manageType === 'aggregator')
|
||||
floData = `KYC|APPROVE_KYC|${addresses.join(',')}`
|
||||
else {
|
||||
const addressWithLabels = addresses.map((address, index) => {
|
||||
return `${address}:${addressLabels[index]}`
|
||||
})
|
||||
floData = `KYC|APPROVE_AGGREGATOR|${addressWithLabels.join(',')}`
|
||||
}
|
||||
console.log(floData)
|
||||
if (floData.length > 1040) {
|
||||
return notify('Too many addresses. Try removing one and resubmitting.', 'error')
|
||||
}
|
||||
@ -410,10 +506,10 @@
|
||||
}).then((res) => {
|
||||
if (!res) return
|
||||
buttonLoader(getRef('submit_kyc'), true)
|
||||
floBlockchainAPI.writeData(aggregatorAddress, floData, aggregatorPrivateKey, aggregatorAddress).then(txId => {
|
||||
floBlockchainAPI.writeData(approverAddress, floData, approverPrivateKey, approverAddress).then(txId => {
|
||||
notify(`Approval request submitted. TXID: ${txId}`, 'success')
|
||||
getRef('kyc_addresses_container').innerHTML = '';
|
||||
getRef('aggregator_private_key').value = ''
|
||||
getRef('approver_private_key').value = ''
|
||||
addAddressInput()
|
||||
}).catch(e => {
|
||||
notify(e, 'error')
|
||||
@ -426,34 +522,54 @@
|
||||
})
|
||||
}
|
||||
function revokeAddresses() {
|
||||
const aggregatorPrivateKey = getRef('aggregator_private_key').value.trim()
|
||||
if (aggregatorPrivateKey === '') {
|
||||
const manageType = getRef('manage_type').value
|
||||
const approverPrivateKey = getRef('approver_private_key').value.trim()
|
||||
if (approverPrivateKey === '') {
|
||||
return notify('Please enter KYC aggregator private key', 'error')
|
||||
}
|
||||
const aggregatorAddress = floCrypto.getAddress(aggregatorPrivateKey)
|
||||
if (!floGlobals.approvedKycAggregators.hasOwnProperty(aggregatorAddress)) {
|
||||
return notify('KYC aggregator address is not approved', 'error')
|
||||
const approverAddress = floCrypto.getFloID(approverPrivateKey)
|
||||
if (manageType === 'aggregator') {
|
||||
if (!floGlobals.approvedKycAggregators.hasOwnProperty(approverAddress)) {
|
||||
return notify('KYC aggregator address is not approved', 'error')
|
||||
}
|
||||
} else {
|
||||
if (floGlobals.masterAddress !== approverAddress) {
|
||||
return notify(`Private key doesn't match admin`, 'error')
|
||||
}
|
||||
}
|
||||
const addresses = processAddresses([...addressesToRevoke])
|
||||
if (addresses.length === 0) {
|
||||
return notify('Select at least one address to revoke', 'error')
|
||||
}
|
||||
let floData
|
||||
if (manageType === 'aggregator')
|
||||
floData = `KYC|REVOKE_KYC|${addresses.join(',')}`
|
||||
else
|
||||
floData = `KYC|REVOKE_AGGREGATOR|${addresses.join(',')}`
|
||||
console.log(floData)
|
||||
getConfirmation('Revoke selected addresses?', {
|
||||
confirmText: 'Revoke',
|
||||
}).then((res) => {
|
||||
if (!res) return
|
||||
const floData = `KYC|REVOKE_KYC|${addresses.join(',')}`
|
||||
buttonLoader(getRef('revoke_kyc_button'), true)
|
||||
floBlockchainAPI.writeData(aggregatorAddress, floData, aggregatorPrivateKey, aggregatorAddress).then(txId => {
|
||||
floBlockchainAPI.writeData(approverAddress, floData, approverPrivateKey, approverAddress).then(txId => {
|
||||
notify(`Revoke request submitted. TXID: ${txId}`, 'success')
|
||||
getRef('aggregator_private_key').value = ''
|
||||
addressesToRevoke.forEach(address => {
|
||||
if (!floGlobals.approvedKyc.hasOwnProperty(address)) return
|
||||
floGlobals.approvedKyc[address].revokedBy = aggregatorAddress
|
||||
floGlobals.approvedKyc[address].validTo = Date.now()
|
||||
})
|
||||
getRef('approver_private_key').value = ''
|
||||
if (manageType === 'aggregator') {
|
||||
addressesToRevoke.forEach(address => {
|
||||
if (!floGlobals.approvedKyc.hasOwnProperty(address)) return
|
||||
floGlobals.approvedKyc[address].revokedBy = approverAddress
|
||||
floGlobals.approvedKyc[address].validTo = Date.now()
|
||||
})
|
||||
render.approvedKycAddresses()
|
||||
} else {
|
||||
addressesToRevoke.forEach(address => {
|
||||
if (!floGlobals.approvedKycAggregators.hasOwnProperty(address)) return
|
||||
delete floGlobals.approvedKycAggregators[address]
|
||||
})
|
||||
render.approvedAggregators()
|
||||
}
|
||||
addressesToRevoke.clear()
|
||||
render.approvedKycs()
|
||||
clearSelection()
|
||||
}).catch(e => {
|
||||
notify(e, 'error')
|
||||
@ -470,7 +586,7 @@
|
||||
await getApprovedAggregators()
|
||||
await getApprovedKycs()
|
||||
router.routeTo(window.location.hash)
|
||||
getRef('aggregator_private_key').customValidation = floCrypto.getPubKeyHex
|
||||
getRef('approver_private_key').customValidation = floCrypto.getPubKeyHex
|
||||
addAddressInput()
|
||||
} catch (e) {
|
||||
notify(e, 'error')
|
||||
|
||||
@ -173,15 +173,14 @@ function getApprovedAggregators() {
|
||||
switch (operationType) {
|
||||
case 'APPROVE_AGGREGATOR':
|
||||
operationData.split(',').forEach(aggregator => {
|
||||
floGlobals.approvedKycAggregators[floCrypto.toFloID(aggregator)] = {
|
||||
validFrom: time * 1000,
|
||||
validTo: validity || Date.now() + 10000000
|
||||
};
|
||||
const [address, label = ''] = aggregator.split(':');
|
||||
floGlobals.approvedKycAggregators[floCrypto.toFloID(address)] = label;
|
||||
});
|
||||
break;
|
||||
case 'REVOKE_AGGREGATOR':
|
||||
operationData.split(',').forEach(aggregator => {
|
||||
delete floGlobals.approvedKycAggregators[floCrypto.toFloID(aggregator)]
|
||||
const [address, label = ''] = aggregator.split(':');
|
||||
delete floGlobals.approvedKycAggregators[floCrypto.toFloID(address)]
|
||||
});
|
||||
break;
|
||||
default:
|
||||
@ -215,7 +214,7 @@ function getApprovedKycs() {
|
||||
floGlobals.approvedKyc[address] = {
|
||||
validFrom: time * 1000,
|
||||
validTo: validity || Date.now() + 10000000,
|
||||
verifiedBy: vin[0].addr
|
||||
issuedBy: vin[0].addr
|
||||
};
|
||||
});
|
||||
break;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user