kyc/index.html
2023-08-24 06:06:45 +05:30

1908 lines
155 KiB
HTML

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>RanchiMall KYC</title>
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link
href="https://fonts.googleapis.com/css2?family=Roboto:ital,wght@0,400;0,500;0,700;1,400;1,500;1,700&display=swap"
rel="stylesheet">
<link rel="stylesheet" href="css/main.css">
<script id="floGlobals">
/* Constants for FLO blockchain operations !!Make sure to add this at beginning!! */
const floGlobals = {
blockchain: "FLO",
adminID: "FJ4KcVQ6HeHZ54DjrtE3rUYmYjV3FHhXSM",
application: "KYC_Docs",
SNStorageID: "FSF5igBd9xC7ZBB511DZG8PVB2eT93YE3M"
}
</script>
</head>
<body onload="onLoadStartUp()" class="hidden">
<sm-notifications id="notification_drawer"></sm-notifications>
<sm-popup id="confirmation_popup">
<h4 id="confirm_title"></h4>
<p id="confirm_message"></p>
<div class="flex align-center gap-0-5 margin-left-auto">
<button class="button cancel-button">Cancel</button>
<button class="button button--primary confirm-button">OK</button>
</div>
</sm-popup>
<sm-popup id="prompt_popup">
<h4 id="prompt_title"></h4>
<p id="prompt_message"></p>
<sm-form>
<sm-input id="prompt_input"></sm-input>
<div class="flex align-center gap-0-5 margin-left-auto">
<button class="button cancel-button">Cancel</button>
<button class="button confirm-button button--primary" type="submit">OK</button>
</div>
</sm-form>
</sm-popup>
<div id="app_body"></div>
<sm-popup id="user_popup">
<header slot="header" class="popup__header">
<button class="popup__header__close">
<svg class="icon" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24">
<path fill="none" d="M0 0h24v24H0z" />
<path
d="M12 10.586l4.95-4.95 1.414 1.414-4.95 4.95 4.95 4.95-1.414 1.414-4.95-4.95-4.95 4.95-1.414-1.414 4.95-4.95-4.95-4.95L7.05 5.636z" />
</svg>
</button>
<h3>Profile</h3>
</header>
<section class="grid gap-2">
<div id="agency_name_container" class="grid gap-0-5"> </div>
<div class="grid gap-0-5">
<h5>My FLO address</h5>
<sm-copy class="my-flo-address"></sm-copy>
</div>
<div class="grid gap-0-5">
<h5>My Bitcoin address</h5>
<sm-copy class="my-btc-address"></sm-copy>
</div>
<button class="button button--danger justify-self-start" onclick="signOut()">Sign out</button>
</section>
</sm-popup>
<sm-popup id="view_file_popup">
<header slot="header" class="popup__header">
<button class="popup__header__close">
<svg class="icon" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24">
<path fill="none" d="M0 0h24v24H0z" />
<path
d="M12 10.586l4.95-4.95 1.414 1.414-4.95 4.95 4.95 4.95-1.414 1.414-4.95-4.95-4.95 4.95-1.414-1.414 4.95-4.95-4.95-4.95L7.05 5.636z" />
</svg>
</button>
<h3>Process ID proof</h3>
</header>
<div id="view_file_popup__content" class="grid gap-1"></div>
</sm-popup>
<sm-popup id="commit_approvals_popup">
<header slot="header" class="popup__header">
<button class="popup__header__close">
<svg class="icon" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24">
<path fill="none" d="M0 0h24v24H0z" />
<path
d="M12 10.586l4.95-4.95 1.414 1.414-4.95 4.95 4.95 4.95-1.414 1.414-4.95-4.95-4.95 4.95-1.414-1.414 4.95-4.95-4.95-4.95L7.05 5.636z" />
</svg>
</button>
<h3>Commit to blockchain</h3>
</header>
<div id="commit_approvals_popup__content" class="grid gap-1"></div>
</sm-popup>
<sm-popup id="set_approver_name_popup">
<header slot="header" class="popup__header">
<button class="popup__header__close">
<svg class="icon" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24">
<path fill="none" d="M0 0h24v24H0z" />
<path
d="M12 10.586l4.95-4.95 1.414 1.414-4.95 4.95 4.95 4.95-1.414 1.414-4.95-4.95-4.95 4.95-1.414-1.414 4.95-4.95-4.95-4.95L7.05 5.636z" />
</svg>
</button>
<h3>Set your agency name</h3>
</header>
<sm-form>
<sm-input id="approver_name_input" placeholder="Enter your agency name" required></sm-input>
<div class="multi-state-button">
<button id="set_approver_name__button" class="button button--primary" type="submit"
onclick="setApproverName()">Set</button>
</div>
</sm-form>
</sm-popup>
<sm-popup id="approve_verifier_popup">
<header slot="header" class="popup__header">
<button class="popup__header__close">
<svg class="icon" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24">
<path fill="none" d="M0 0h24v24H0z" />
<path
d="M12 10.586l4.95-4.95 1.414 1.414-4.95 4.95 4.95 4.95-1.414 1.414-4.95-4.95-4.95 4.95-1.414-1.414 4.95-4.95-4.95-4.95L7.05 5.636z" />
</svg>
</button>
<h3>Approve verifiers</h3>
</header>
<sm-form>
<ul id="verifiers_container" class="grid gap-1">
<li class="flex align-center gap-1">
<sm-input class="w-100" placeholder="FLO/BTC address" error-text="Invalid address" data-address
required></sm-input>
</li>
</ul>
<button class="button button--colored button--small margin-right-auto" onclick="addVerifier()">Add
verifier</button>
<div class="multi-state-button">
<button id="approve_verifier_button" class="button button--primary" type="submit"
onclick="approveVerifiers()">Approve</button>
</div>
</sm-form>
</sm-popup>
<script src="https://unpkg.com/neverland"></script>
<script src="scripts/components.min.js"></script>
<script src="scripts/lib.js"></script>
<script src="scripts/floCrypto.js"></script>
<script src="scripts/btcOperator.js"></script>
<script src="scripts/floBlockchainAPI.js"></script>
<script src="scripts/compactIDB.js"></script>
<script src="scripts/floCloudAPI.js"></script>
<script src="scripts/floDapps.js"></script>
<!-- <script src="scripts/main.js"></script> -->
<script>
const { Component, useState, useEffect, html, render: renderElem } = neverland;
const uiGlobals = {
// Use to store global variables
}
//Checks for internet connection status
uiGlobals.connectionErrorNotification = []
if (!navigator.onLine)
uiGlobals.connectionErrorNotification.push(notify('There seems to be a problem connecting to the internet, Please check you internet connection.', 'error'))
window.addEventListener('offline', () => {
uiGlobals.connectionErrorNotification.push(notify('There seems to be a problem connecting to the internet, Please check you internet connection.', 'error'))
})
window.addEventListener('online', () => {
uiGlobals.connectionErrorNotification.forEach(notification => notification.remove())
notify('We are back online.', 'success')
location.reload()
uiGlobals.connectionErrorNotification = []
})
// Use instead of document.getElementById
function getRef(elementId) {
return document.getElementById(elementId)
}
//Function for displaying toast notifications. pass in error for mode param if you want to show an error.
function notify(message, mode, options = {}) {
let icon
switch (mode) {
case 'success':
icon = `<svg class="icon icon--success" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24"><path fill="none" d="M0 0h24v24H0z"/><path d="M10 15.172l9.192-9.193 1.415 1.414L10 18l-6.364-6.364 1.414-1.414z"/></svg>`
break;
case 'error':
icon = `<svg class="icon icon--error" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24"><path fill="none" d="M0 0h24v24H0z"/><path d="M12 22C6.477 22 2 17.523 2 12S6.477 2 12 2s10 4.477 10 10-4.477 10-10 10zm-1-7v2h2v-2h-2zm0-8v6h2V7h-2z"/></svg>`
options.pinned = true
break;
}
if (mode === 'error') {
console.error(message)
}
return getRef("notification_drawer").push(message, { icon, ...options });
}
let zIndex = 50
// function required for popups or modals to appear
function openPopup(popupId, pinned) {
zIndex++
getRef(popupId).setAttribute('style', `z-index: ${zIndex}`)
return getRef(popupId).show({ pinned })
}
// hides the popup or modal
function closePopup(options = {}) {
if (popupStack.peek() === undefined)
return;
popupStack.peek().popup.hide(options)
}
// displays a popup for asking permission. Use this instead of JS confirm
const getConfirmation = (title, options = {}) => {
return new Promise(resolve => {
const { message = '', cancelText = 'Cancel', confirmText = 'OK', danger = false } = options
getRef('confirm_title').innerText = title;
getRef('confirm_message').innerText = message;
const cancelButton = getRef('confirmation_popup').querySelector('.cancel-button');
const confirmButton = getRef('confirmation_popup').querySelector('.confirm-button')
confirmButton.textContent = confirmText
cancelButton.textContent = cancelText
if (danger)
confirmButton.classList.add('button--danger')
else
confirmButton.classList.remove('button--danger')
const { closed } = openPopup('confirmation_popup')
confirmButton.onclick = () => {
closePopup({ payload: true })
}
cancelButton.onclick = () => {
closePopup()
}
closed.then((payload) => {
confirmButton.onclick = null
cancelButton.onclick = null
if (payload)
resolve(true)
else
resolve(false)
})
})
}
function getFormattedTime(timestamp, format) {
try {
if (String(timestamp).length < 13)
timestamp *= 1000
let [day, month, date, year] = new Date(timestamp).toString().split(' '),
minutes = new Date(timestamp).getMinutes(),
hours = new Date(timestamp).getHours(),
currentTime = new Date().toString().split(' ')
minutes = minutes < 10 ? `0${minutes}` : minutes
let finalHours = ``;
if (hours > 12)
finalHours = `${hours - 12}:${minutes}`
else if (hours === 0)
finalHours = `12:${minutes}`
else
finalHours = `${hours}:${minutes}`
finalHours = hours >= 12 ? `${finalHours} PM` : `${finalHours} AM`
switch (format) {
case 'date-only':
return `${month} ${date}, ${year}`;
break;
case 'time-only':
return finalHours;
default:
return `${month} ${date}, ${year} at ${finalHours}`;
}
} catch (e) {
console.error(e);
return timestamp;
}
}
class Router {
constructor(options = {}) {
const { routes = {}, state = {}, routingStart, routingEnd } = options
this.routes = routes
this.state = state
this.routingStart = routingStart
this.routingEnd = routingEnd
this.lastPage = null
window.addEventListener('hashchange', e => this.routeTo(window.location.hash))
}
addRoute(route, callback) {
this.routes[route] = callback
}
async routeTo(path) {
try {
let page
let wildcards = []
let queryString
let params
[path, queryString] = path.split('?');
if (path.includes('#'))
path = path.split('#')[1];
if (path.includes('/'))
[, page, ...wildcards] = path.split('/')
else
page = path
this.state = { page, wildcards, lastPage: this.lastPage }
if (queryString) {
params = new URLSearchParams(queryString)
this.state.params = Object.fromEntries(params)
}
if (this.routingStart) {
this.routingStart(this.state)
}
if (this.routes[page]) {
await this.routes[page](this.state)
this.lastPage = page
} else {
if (this.routes['404']) {
this.routes['404'](this.state);
} else {
console.error(`No route found for '${page}' and no '404' route is defined.`);
}
}
if (this.routingEnd) {
this.routingEnd(this.state)
}
} catch (e) {
console.error(e)
}
}
}
function togglePrivateKeyVisibility(input) {
const target = input.closest('sm-input')
target.type = target.type === 'password' ? 'text' : 'password';
target.focusIn()
}
let privKeyResolver = null
function getSignedIn(passwordType) {
return new Promise((resolve, reject) => {
privKeyResolver = resolve
try {
console.log(floDapps.user.id)
getPromptInput('Enter password', '', {
isPassword: true,
}).then(password => {
if (password) {
resolve(password)
}
})
} catch (err) {
floGlobals.isPrivKeySecured = passwordType === 'PIN/Password';
if (!['#/landing', '#/sign_in', '#/sign_up', '#/kyc_status'].some(route => window.location.hash.includes(route))) {
history.replaceState(null, null, '#/kyc_status')
router.routeTo('#/kyc_status')
}
}
});
}
function setSecurePassword() {
if (!floGlobals.isPrivKeySecured) {
const password = getRef('secure_pwd_input').value.trim();
floDapps.securePrivKey(password).then(() => {
floGlobals.isPrivKeySecured = true;
notify('Password set successfully', 'success');
closePopup();
}).catch(err => {
notify(err, 'error');
})
}
}
function signOut() {
getConfirmation('Sign out?', { message: 'You are about to sign out of the app, continue?', confirmText: 'Leave', cancelText: 'Stay' })
.then(async (res) => {
if (res) {
await floDapps.clearCredentials();
location.reload();
}
});
}
// detect browser version
function detectBrowser() {
let ua = navigator.userAgent,
tem,
M = ua.match(/(opera|chrome|safari|firefox|msie|trident(?=\/))\/?\s*(\d+)/i) || [];
if (/trident/i.test(M[1])) {
tem = /\brv[ :]+(\d+)/g.exec(ua) || [];
return 'IE ' + (tem[1] || '');
}
if (M[1] === 'Chrome') {
tem = ua.match(/\b(OPR|Edge)\/(\d+)/);
if (tem != null) return tem.slice(1).join(' ').replace('OPR', 'Opera');
}
M = M[2] ? [M[1], M[2]] : [navigator.appName, navigator.appVersion, '-?'];
if ((tem = ua.match(/version\/(\d+)/i)) != null) M.splice(1, 1, tem[1]);
return M.join(' ');
}
function buttonLoader(id, show) {
const button = typeof id === 'string' ? document.getElementById(id) : id;
button.disabled = show;
const animOptions = {
duration: 200,
fill: 'forwards',
easing: 'ease'
}
if (show) {
button.parentNode.append(document.createElement('sm-spinner'))
button.animate([
{
clipPath: 'circle(100%)',
},
{
clipPath: 'circle(0)',
},
], animOptions)
} else {
button.animate([
{
clipPath: 'circle(0)',
},
{
clipPath: 'circle(100%)',
},
], animOptions).onfinish = () => {
const potentialTarget = button.parentNode.querySelector('sm-spinner')
if (potentialTarget) potentialTarget.remove();
}
}
}
function createRipple(event, target) {
const circle = document.createElement("span");
const diameter = Math.max(target.clientWidth, target.clientHeight);
const radius = diameter / 2;
const targetDimensions = target.getBoundingClientRect();
circle.style.width = circle.style.height = `${diameter}px`;
circle.style.left = `${event.clientX - (targetDimensions.left + radius)}px`;
circle.style.top = `${event.clientY - (targetDimensions.top + radius)}px`;
circle.classList.add("ripple");
const rippleAnimation = circle.animate(
[
{
opacity: 1,
transform: `scale(0)`
},
{
transform: "scale(4)",
opacity: 0,
},
],
{
duration: 600,
fill: "forwards",
easing: "ease-out",
}
);
target.append(circle);
rippleAnimation.onfinish = () => {
circle.remove();
};
}
</script>
<script>
// routing logic
const router = new Router({
routingStart(state) {
if ("scrollRestoration" in history) {
history.scrollRestoration = "manual";
}
window.scrollTo(0, 0);
},
routingEnd() {
document.querySelectorAll(".my-flo-address").forEach(elem => {
if (elem.tagName === 'SM-COPY') {
elem.value = floGlobals.myFloID
} else
elem.textContent = floGlobals.myFloID
})
document.querySelectorAll(".my-btc-address").forEach(elem => {
if (elem.tagName === 'SM-COPY') {
elem.value = floGlobals.myBtcID
} else
elem.textContent = floGlobals.myBtcID
})
document.querySelectorAll('sm-input[data-address]').forEach(input => input.customValidation = floCrypto.validateAddr)
}
})
router.addRoute('loading', (state) => {
renderElem(getRef('app_body'), html`
<article id="loading">
<sm-spinner></sm-spinner>
<div class="grid gap-1 justify-items-center">
<h4>Loading RanchiMall KYC</h4>
<button class="button button--colored" onclick=${clearCredentials}>Reset</button>
</div>
</article>
`);
})
function handleSignIn() {
privKeyResolver(getRef('private_key_field').value.trim());
router.routeTo('loading');
}
router.addRoute('sign_in', (state) => {
renderElem(getRef('app_body'), html`
<article id="sign_in">
<section>
<h1 style="font-size: 2rem;">Sign in</h1>
<p>Welcome back, glad to see you again</p>
<sm-form id="sign_in_form">
<sm-input id="private_key_field" class="password-field" type="password"
placeholder=${`${floGlobals.isPrivKeySecured ? 'Password' : 'FLO/BTC private key'}`} error-text="Private key is invalid" required>
<label slot="right" class="interact">
<input type="checkbox" class="hidden" autocomplete="off" readonly
onchange="togglePrivateKeyVisibility(this)">
<svg class="icon invisible" xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 0 24 24" width="24px" fill="#000000"> <title>Hide password</title> <path d="M0 0h24v24H0zm0 0h24v24H0zm0 0h24v24H0zm0 0h24v24H0z" fill="none" /> <path d="M12 7c2.76 0 5 2.24 5 5 0 .65-.13 1.26-.36 1.83l2.92 2.92c1.51-1.26 2.7-2.89 3.43-4.75-1.73-4.39-6-7.5-11-7.5-1.4 0-2.74.25-3.98.7l2.16 2.16C10.74 7.13 11.35 7 12 7zM2 4.27l2.28 2.28.46.46C3.08 8.3 1.78 10.02 1 12c1.73 4.39 6 7.5 11 7.5 1.55 0 3.03-.3 4.38-.84l.42.42L19.73 22 21 20.73 3.27 3 2 4.27zM7.53 9.8l1.55 1.55c-.05.21-.08.43-.08.65 0 1.66 1.34 3 3 3 .22 0 .44-.03.65-.08l1.55 1.55c-.67.33-1.41.53-2.2.53-2.76 0-5-2.24-5-5 0-.79.2-1.53.53-2.2zm4.31-.78l3.15 3.15.02-.16c0-1.66-1.34-3-3-3l-.17.01z" /> </svg>
<svg class="icon visible" xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 0 24 24" width="24px" fill="#000000"> <title>Show password</title> <path d="M0 0h24v24H0z" fill="none" /> <path d="M12 4.5C7 4.5 2.73 7.61 1 12c1.73 4.39 6 7.5 11 7.5s9.27-3.11 11-7.5c-1.73-4.39-6-7.5-11-7.5zM12 17c-2.76 0-5-2.24-5-5s2.24-5 5-5 5 2.24 5 5-2.24 5-5 5zm0-8c-1.66 0-3 1.34-3 3s1.34 3 3 3 3-1.34 3-3-1.34-3-3-3z" /> </svg>
</label>
</sm-input>
<button id="sign_in_button" onclick="handleSignIn()" class="button button--primary" type="submit" disabled>Sign in</button>
</sm-form>
<p>
New here? <a href="#/sign_up">get your FLO login credentials</a>
</p>
</section>
</article>
`);
if (!floGlobals.isPrivKeySecured)
getRef('private_key_field').customValidation = floCrypto.getPubKeyHex;
getRef('private_key_field').focusIn();
})
function handleSignUp() {
const privKey = getRef('generated_private_key').value.trim();
privKeyResolver(privKey);
router.routeTo('loading');
}
router.addRoute('sign_up', (state) => {
const { floID, privKey } = floCrypto.generateNewID()
renderElem(getRef('app_body'), html`
<article id="sign_up">
<section class="grid gap-1-5">
<div id="flo_id_warning" class="flex gap-1">
<svg class="icon" xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 0 24 24" width="24px" fill="#000000"> <path d="M0 0h24v24H0z" fill="none" /> <path d="M1 21h22L12 2 1 21zm12-3h-2v-2h2v2zm0-4h-2v-4h2v4z" /> </svg>
<div class="grid gap-0-5">
<strong>
<h3> Keep your keys safe! </h3>
</strong>
<p>Don't share with anyone. Once lost private key can't be recovered.</p>
</div>
</div>
<div class="grid gap-1-5 generated-keys-wrapper">
<div class="grid gap-0-5">
<h5>FLO address</h5>
<sm-copy id="generated_flo_address" value=${floID}></sm-copy>
</div>
<div class="grid gap-0-5">
<h5>Private key</h5>
<sm-copy id="generated_private_key" value=${privKey}></sm-copy>
</div>
</div>
<button id="sign_up_button" onclick="handleSignUp()" class="button button--primary w-100">Sign in with these credentials</button>
<p class="margin-top-1">You can use these FLO credentials with other RanchiMall apps too. </p>
</section>
</article>
`);
})
router.addRoute('kyc_status', (state) => {
renderElem(getRef('app_body'), html`
<article id="kyc_status">
<header id="main_header">
<div class="app-brand margin-right-auto">
<svg id="main_logo" class="icon" viewBox="0 0 27.25 32"> <title>RanchiMall</title> <path d="M27.14,30.86c-.74-2.48-3-4.36-8.25-6.94a20,20,0,0,1-4.2-2.49,6,6,0,0,1-1.25-1.67,4,4,0,0,1,0-2.26c.37-1.08.79-1.57,3.89-4.55a11.66,11.66,0,0,0,3.34-4.67,6.54,6.54,0,0,0,.05-2.82C20,3.6,18.58,2,16.16.49c-.89-.56-1.29-.64-1.3-.24a3,3,0,0,1-.3.72l-.3.55L13.42.94C13,.62,12.4.26,12.19.15c-.4-.2-.73-.18-.72.05a9.39,9.39,0,0,1-.61,1.33s-.14,0-.27-.13C8.76.09,8-.27,8,.23A11.73,11.73,0,0,1,6.76,2.6C4.81,5.87,2.83,7.49.77,7.49c-.89,0-.88,0-.61,1,.22.85.33.92,1.09.69A5.29,5.29,0,0,0,3,8.33c.23-.17.45-.29.49-.26a2,2,0,0,1,.22.63A1.31,1.31,0,0,0,4,9.34a5.62,5.62,0,0,0,2.27-.87L7,8l.13.55c.19.74.32.82,1,.65a7.06,7.06,0,0,0,3.46-2.47l.6-.71-.06.64c-.17,1.63-1.3,3.42-3.39,5.42L6.73,14c-3.21,3.06-3,5.59.6,8a46.77,46.77,0,0,0,4.6,2.41c.28.13,1,.52,1.59.87,3.31,2,4.95,3.92,4.95,5.93a2.49,2.49,0,0,0,.07.77h0c.09.09,0,.1.9-.14a2.61,2.61,0,0,0,.83-.32,3.69,3.69,0,0,0-.55-1.83A11.14,11.14,0,0,0,17,26.81a35.7,35.7,0,0,0-5.1-2.91C9.37,22.64,8.38,22,7.52,21.17a3.53,3.53,0,0,1-1.18-2.48c0-1.38.71-2.58,2.5-4.23,2.84-2.6,3.92-3.91,4.67-5.65a3.64,3.64,0,0,0,.42-2A3.37,3.37,0,0,0,13.61,5l-.32-.74.29-.48c.17-.27.37-.63.46-.8l.15-.3.44.64a5.92,5.92,0,0,1,1,2.81,5.86,5.86,0,0,1-.42,1.94c0,.12-.12.3-.15.4a9.49,9.49,0,0,1-.67,1.1,28,28,0,0,1-4,4.29C8.62,15.49,8.05,16.44,8,17.78a3.28,3.28,0,0,0,1.11,2.76c.95,1,2.07,1.74,5.25,3.32,3.64,1.82,5.22,2.9,6.41,4.38A4.78,4.78,0,0,1,21.94,31a3.21,3.21,0,0,0,.14.92,1.06,1.06,0,0,0,.43-.05l.83-.22.46-.12-.06-.46c-.21-1.53-1.62-3.25-3.94-4.8a37.57,37.57,0,0,0-5.22-2.82A13.36,13.36,0,0,1,11,21.19a3.36,3.36,0,0,1-.8-4.19c.41-.85.83-1.31,3.77-4.15,2.39-2.31,3.43-4.13,3.43-6a5.85,5.85,0,0,0-2.08-4.29c-.23-.21-.44-.43-.65-.65A2.5,2.5,0,0,1,15.27.69a10.6,10.6,0,0,1,2.91,2.78A4.16,4.16,0,0,1,19,6.16a4.91,4.91,0,0,1-.87,3c-.71,1.22-1.26,1.82-4.27,4.67a9.47,9.47,0,0,0-2.07,2.6,2.76,2.76,0,0,0-.33,1.54,2.76,2.76,0,0,0,.29,1.47c.57,1.21,2.23,2.55,4.65,3.73a32.41,32.41,0,0,1,5.82,3.24c2.16,1.6,3.2,3.16,3.2,4.8a1.94,1.94,0,0,0,.09.76,4.54,4.54,0,0,0,1.66-.4C27.29,31.42,27.29,31.37,27.14,30.86ZM6.1,7h0a3.77,3.77,0,0,1-1.46.45L4,7.51l.68-.83a25.09,25.09,0,0,0,3-4.82A12,12,0,0,1,8.28.76c.11-.12.77.32,1.53,1l.63.58-.57.84A10.34,10.34,0,0,1,6.1,7Zm5.71-1.78A9.77,9.77,0,0,1,9.24,7.18h0a5.25,5.25,0,0,1-1.17.28l-.58,0,.65-.78a21.29,21.29,0,0,0,2.1-3.12c.22-.41.42-.76.44-.79s.5.43.9,1.24L12,5ZM13.41,3a2.84,2.84,0,0,1-.45.64,11,11,0,0,1-.9-.91l-.84-.9.19-.45c.34-.79.39-.8,1-.31A9.4,9.4,0,0,1,13.8,2.33q-.18.34-.39.69Z" /> </svg>
<div class="app-name">
<div class="app-name__company">RanchiMall</div>
<h4 class="app-name__title">
KYC
</h4>
</div>
</div>
${!floGlobals.myFloID ? html`
<div class="flex align-center flex-wrap gap-0-5">
<a href="#/sign_up" class="button button--colored button--small">Sign up</a>
<a href="#/sign_in" class="button button--primary button--small">Sign in</a>
</div>
`: ''}
<theme-toggle id="theme_toggle"></theme-toggle>
</header>
<h1 class="text-center">KYC verification</h1>
<p class="text-center">Check your KYC status and submit your documents</p>
<svg id="search_illustration" xmlns="http://www.w3.org/2000/svg" data-name="Layer 1" width="578.0013" height="621.92557" viewBox="0 0 578.0013 621.92557" xmlns:xlink="http://www.w3.org/1999/xlink"> <def> <style> .accent-fill{ fill: var(--accent-color); } </style> </def> <path d="M677.64241,491.89724l-249.84894,64.339a33.03735,33.03735,0,0,1-40.18683-23.728L312.04574,239.081a33.03734,33.03734,0,0,1,23.728-40.18683l232.44363-59.85691L627.712,165.67105l73.65843,286.03936A33.03734,33.03734,0,0,1,677.64241,491.89724Z" transform="translate(-310.99935 -139.03722)" fill="#f2f2f2"/><path d="M338.14273,208.094a23.52653,23.52653,0,0,0-16.89723,28.61789l75.5609,293.42725a23.52654,23.52654,0,0,0,28.6179,16.89723l249.84894-64.339a23.52654,23.52654,0,0,0,16.89723-28.61789l-72.51713-281.6073-52.285-23.40643Z" transform="translate(-310.99935 -139.03722)" fill="#fff"/><path d="M627.07719,167.18472l-38.66749,9.95733a10.99077,10.99077,0,0,1-13.38436-7.9027L567.671,140.68008a.68692.68692,0,0,1,.944-.7991l58.56966,26.01073A.68692.68692,0,0,1,627.07719,167.18472Z" transform="translate(-310.99935 -139.03722)" fill="#f2f2f2"/><path d="M606.73438,417.76533,492.98165,447.058a5.49538,5.49538,0,0,1-2.74083-10.64353L603.99355,407.1218a5.49538,5.49538,0,1,1,2.74083,10.64353Z" transform="translate(-310.99935 -139.03722)" fill="#ccc"/><path d="M633.31182,430.07333l-135.705,34.9456A5.49538,5.49538,0,0,1,494.866,454.3754l135.705-34.94561a5.49539,5.49539,0,0,1,2.74084,10.64354Z" transform="translate(-310.99935 -139.03722)" fill="#ccc"/><circle id="a597741b-ffcf-4aba-98b0-6652ef5d57c9" data-name="Ellipse 44" cx="135.55495" cy="323.87767" r="19.42315" fill="#e6e6e6"/><path d="M594.63919,366.93361,443.56425,405.8227A17.01917,17.01917,0,0,1,422.863,393.59731l-31.6597-122.9905a17.01916,17.01916,0,0,1,12.22538-20.7012l151.075-38.88909a17.01916,17.01916,0,0,1,20.7012,12.22539l31.65971,122.9905A17.01917,17.01917,0,0,1,594.63919,366.93361Z" transform="translate(-310.99935 -139.03722)" fill="#fff"/><path d="M594.63919,366.93361,443.56425,405.8227A17.01917,17.01917,0,0,1,422.863,393.59731l-31.6597-122.9905a17.01916,17.01916,0,0,1,12.22538-20.7012l151.075-38.88909a17.01916,17.01916,0,0,1,20.7012,12.22539l31.65971,122.9905A17.01917,17.01917,0,0,1,594.63919,366.93361ZM403.9273,251.84246a15.017,15.017,0,0,0-10.7871,18.26578l31.6597,122.9905a15.017,15.017,0,0,0,18.26577,10.7871l151.075-38.88908a15.017,15.017,0,0,0,10.7871-18.26578L573.268,223.74048a15.017,15.017,0,0,0-18.26578-10.7871Z" transform="translate(-310.99935 -139.03722)" fill="#e6e6e6"/><path id="b056fd3f-f1a0-44f0-b006-deff0bee637d-532" data-name="Path 411" d="M546.83934,252.37075l-76.24555,19.62681a2.73087,2.73087,0,0,1-3.30848-1.71854,2.63064,2.63064,0,0,1,1.85283-3.33925l77.61329-19.97889c3.13521,1.58858,2.31023,4.83781.087,5.41011Z" transform="translate(-310.99935 -139.03722)" fill="#f2f2f2"/><path id="f1ea6668-a825-428d-96fe-a2c4e1b5a672-533" data-name="Path 412" d="M550.282,265.74474l-76.24555,19.62681A2.73089,2.73089,0,0,1,470.728,283.653a2.63065,2.63065,0,0,1,1.85284-3.33925l77.61329-19.97889c3.13521,1.58858,2.31022,4.83781.087,5.41011Z" transform="translate(-310.99935 -139.03722)" fill="#f2f2f2"/><path id="ee9aa382-a9c9-40d0-8ed3-22ec2dd616d6-534" data-name="Path 413" d="M459.51412,297.22917l-23.2694,5.98992a2.962,2.962,0,0,1-3.60325-2.12795l-7.06858-27.45979a2.962,2.962,0,0,1,2.12794-3.60325l23.2694-5.98991a2.963,2.963,0,0,1,3.60325,2.12795l7.06859,27.45982a2.962,2.962,0,0,1-2.12795,3.60324Z" transform="translate(-310.99935 -139.03722)" fill="#e6e6e6"/><path id="be954d2b-d8b8-4d26-80a0-a319e99a4b10-535" data-name="Path 414" d="M557.10914,293.18514,440.74446,323.13925a2.73087,2.73087,0,0,1-3.30847-1.71854,2.63062,2.63062,0,0,1,1.85284-3.33925L557.02218,287.775c3.13521,1.58859,2.31022,4.83781.087,5.41012Z" transform="translate(-310.99935 -139.03722)" fill="#f2f2f2"/><path id="baaae9e4-1b4d-40c2-8a9d-f2abb078b489-536" data-name="Path 415" d="M560.55283,306.563,444.18814,336.51715a2.73086,2.73086,0,0,1-3.30846-1.71854,2.63061,2.63061,0,0,1,1.85283-3.33926l117.73335-30.30643c3.13521,1.58858,2.31022,4.83781.087,5.41011Z" transform="translate(-310.99935 -139.03722)" fill="#f2f2f2"/><path id="a91bf4c9-37f6-4391-92ed-1882bd0ce21c-537" data-name="Path 416" d="M563.99426,319.93218,447.62957,349.8863a2.73086,2.73086,0,0,1-3.30846-1.71854,2.63061,2.63061,0,0,1,1.85283-3.33926l117.73335-30.30643c3.13521,1.58858,2.31023,4.83781.087,5.41011Z" transform="translate(-310.99935 -139.03722)" fill="#f2f2f2"/><path id="efb98e07-468b-4c85-9a64-ee4cc5493d6f-538" data-name="Path 417" d="M567.43768,333.30908,451.073,363.2632a2.73087,2.73087,0,0,1-3.30847-1.71854,2.63063,2.63063,0,0,1,1.85284-3.33926L567.35072,327.899c3.13521,1.58858,2.31022,4.83781.087,5.41011Z" transform="translate(-310.99935 -139.03722)" fill="#f2f2f2"/><path id="aeb1db98-32e5-40b8-ab89-fdad6a3263dc-539" data-name="Path 418" d="M570.87937,346.67924,454.51469,376.63336a2.73088,2.73088,0,0,1-3.30847-1.71855,2.63062,2.63062,0,0,1,1.85284-3.33925l117.73335-30.30643c3.13521,1.58858,2.31022,4.83781.087,5.41011Z" transform="translate(-310.99935 -139.03722)" fill="#f2f2f2"/><path id="be265de5-288f-49a7-867d-c42e7cdbf4db-540" data-name="Path 395" d="M447.98728,469.72335a2.01449,2.01449,0,0,1-1.27407-.08782l-.02505-.01034L441.3969,467.382a2.02852,2.02852,0,1,1,1.58747-3.73356l3.42865,1.45835,4.49293-10.56929a2.02766,2.02766,0,0,1,2.65942-1.07259l.00068.00028-.027.06912.02812-.06941a2.03011,2.03011,0,0,1,1.0723,2.66008l-5.28586,12.42716a2.02886,2.02886,0,0,1-1.36522,1.16845Z" transform="translate(-310.99935 -139.03722)" fill="#fff"/><path d="M773.47457,603.71475h-258a33.03734,33.03734,0,0,1-33-33v-303a33.03734,33.03734,0,0,1,33-33H755.50142l50.97315,40.62891V570.71475A33.03734,33.03734,0,0,1,773.47457,603.71475Z" transform="translate(-310.99935 -139.03722)" fill="#e6e6e6"/><path d="M515.47446,244.21475a23.52654,23.52654,0,0,0-23.5,23.5v303a23.52653,23.52653,0,0,0,23.5,23.5h258a23.52653,23.52653,0,0,0,23.5-23.5V279.92032l-44.79614-35.70557Z" transform="translate(-310.99935 -139.03722)" fill="#fff"/><path d="M723.29356,332.319H605.82977a5.49538,5.49538,0,0,1,0-10.99076H723.29356a5.49538,5.49538,0,1,1,0,10.99076Z" transform="translate(-310.99935 -139.03722)" class="accent-fill"/><path d="M745.962,350.86594H605.82977a5.49539,5.49539,0,0,1,0-10.99077H745.962a5.49539,5.49539,0,1,1,0,10.99077Z" transform="translate(-310.99935 -139.03722)" class="accent-fill"/><path d="M723.29425,404.44277h-117.46a5.495,5.495,0,1,0,0,10.99h117.46a5.495,5.495,0,0,0,0-10.99Z" transform="translate(-310.99935 -139.03722)" fill="#ccc"/><path d="M745.96417,422.99281H605.83429a5.495,5.495,0,1,0,0,10.99H745.96417a5.495,5.495,0,0,0,0-10.99Z" transform="translate(-310.99935 -139.03722)" fill="#ccc"/><path d="M723.29356,498.55433H605.82977a5.49538,5.49538,0,0,1,0-10.99076H723.29356a5.49538,5.49538,0,1,1,0,10.99076Z" transform="translate(-310.99935 -139.03722)" fill="#ccc"/><path d="M745.962,517.10125H605.82977a5.49539,5.49539,0,0,1,0-10.99077H745.962a5.49539,5.49539,0,1,1,0,10.99077Z" transform="translate(-310.99935 -139.03722)" fill="#ccc"/><circle id="abdb8e2f-a218-463c-85f4-c869fef49971" data-name="Ellipse 44" cx="245.91553" cy="197.05988" r="19.42315" class="accent-fill"/><path id="ba7dbbd6-0052-44b1-a552-47a8298b8d3e-541" data-name="Path 395" d="M554.99015,343.50645a2.0144,2.0144,0,0,1-1.21191-.40277l-.02168-.01626-4.5647-3.49185a2.02852,2.02852,0,1,1,2.46838-3.21972l2.95665,2.26729,6.98671-9.11494a2.02767,2.02767,0,0,1,2.84288-.3755l.00058.00044-.04336.06021.04454-.06021a2.03011,2.03011,0,0,1,.37507,2.84345l-8.2179,10.71637a2.02892,2.02892,0,0,1-1.61348.79109Z" transform="translate(-310.99935 -139.03722)" fill="#fff"/><path d="M578.33429,419.21278a19.42256,19.42256,0,0,1-19.41992,19.43,4.17626,4.17626,0,0,1-.5-.02,19.422,19.422,0,1,1,19.91992-19.41Z" transform="translate(-310.99935 -139.03722)" fill="#ccc"/><circle id="e4a71040-498e-4958-ad41-c2d79154b8f7" data-name="Ellipse 44" cx="245.91553" cy="363.29519" r="19.42315" fill="#ccc"/><path d="M805.48234,276.65121h-39.929a10.99077,10.99077,0,0,1-10.99076-10.99077v-29.491a.68692.68692,0,0,1,1.11347-.53844l50.23281,39.79483A.68692.68692,0,0,1,805.48234,276.65121Z" transform="translate(-310.99935 -139.03722)" fill="#ccc"/><path d="M578.33429,419.21278a19.42256,19.42256,0,0,1-19.41992,19.43,4.17626,4.17626,0,0,1-.5-.02,42.05076,42.05076,0,0,1,3.77-38.56A19.43323,19.43323,0,0,1,578.33429,419.21278Z" transform="translate(-310.99935 -139.03722)" class="accent-fill"/><path d="M600.33429,409.94277a5.50988,5.50988,0,0,1,5.5-5.5h29.27a41.57257,41.57257,0,0,1,3.60986,10.99H605.83429A5.50129,5.50129,0,0,1,600.33429,409.94277Z" transform="translate(-310.99935 -139.03722)" class="accent-fill"/><path d="M639.39435,422.99281a41.92449,41.92449,0,0,1-1.46,10.99h-32.1001a5.495,5.495,0,1,1,0-10.99Z" transform="translate(-310.99935 -139.03722)" class="accent-fill"/><path d="M711.816,490.77021a6.00013,6.00013,0,0,1-8.24672,1.9979l-70.0049-42.70029a6,6,0,0,1,6.24883-10.24462l70.00489,42.70029A6.00014,6.00014,0,0,1,711.816,490.77021Z" transform="translate(-310.99935 -139.03722)" fill="#3f3d56"/><path d="M641.8111,448.06992a48,48,0,1,1-15.98318-65.97376A48.05436,48.05436,0,0,1,641.8111,448.06992Zm-71.71233-43.74176a36,36,0,1,0,49.48033-11.98738A36.04071,36.04071,0,0,0,570.09877,404.32816Z" transform="translate(-310.99935 -139.03722)" fill="#3f3d56"/><circle cx="484.60301" cy="267.17256" r="24.56103" fill="#a0616a"/><path d="M794.015,543.90119a11.002,11.002,0,0,1,8.32251-14.15136,10.46752,10.46752,0,0,1,1.45923-.17969l25.87158-41.52344L806.036,465.57991a9.43208,9.43208,0,1,1,13.1206-13.55274L851.786,484.201l.06567.08008a8.54468,8.54468,0,0,1-.59448,10.18457l-36.25,42.873a10.301,10.301,0,0,1,.27,1.0459,11.0026,11.0026,0,0,1-9.875,13.11621q-.46839.041-.93213.041A11.0367,11.0367,0,0,1,794.015,543.90119Z" transform="translate(-310.99935 -139.03722)" fill="#a0616a"/><polygon points="444.151 609.001 431.891 609 426.059 561.712 444.153 561.713 444.151 609.001" fill="#a0616a"/><path d="M758.2767,759.92208l-39.53051-.00146v-.5a15.38605,15.38605,0,0,1,15.38647-15.38623h.001l24.1438.001Z" transform="translate(-310.99935 -139.03722)" fill="#2f2e41"/><polygon points="566.007 592.05 555.473 598.322 526.268 560.676 541.815 551.419 566.007 592.05" fill="#a0616a"/><path d="M885.77238,739.69878l-33.96586,20.2233-.25581-.4296a15.386,15.386,0,0,1,5.34836-21.09206l.00084-.0005,20.74515-12.35158Z" transform="translate(-310.99935 -139.03722)" fill="#2f2e41"/><path d="M735.512,727.21272c-8.21289-96.70606-13.09863-186.54492,16.92408-223.19336l.23217-.28418,50.52564,20.21094.08325.18066c.17041.37109,16.97388,37.333,13.0542,62.19434L828.794,643.64924l40.63574,68.041A4.50136,4.50136,0,0,1,867.379,718.118l-17.65918,7.76953a4.52142,4.52142,0,0,1-5.64844-1.76562l-44.2041-72.08008-24.96778-55.28613a1.50028,1.50028,0,0,0-2.85888.459L758.20052,727.31135a4.4918,4.4918,0,0,1-4.47461,4.02441H739.99764A4.53045,4.53045,0,0,1,735.512,727.21272Z" transform="translate(-310.99935 -139.03722)" fill="#2f2e41"/><path d="M752.60628,504.786l-.24072-.11523-.0376-.26465c-1.88745-13.21.34668-27.8877,6.63989-43.625a34.63634,34.63634,0,0,1,40.20191-20.74317h0a34.59441,34.59441,0,0,1,22.06055,16.96387,34.2209,34.2209,0,0,1,2.3728,27.4248c-7.93384,23.2002-18.22583,44.90723-18.32886,45.124l-.21558.45312Z" transform="translate(-310.99935 -139.03722)" class="accent-fill"/><path d="M697.48021,471.88251A11.002,11.002,0,0,1,713.65,474.72233a10.46856,10.46856,0,0,1,.67932,1.3039l47.95411,9.69217,12.7683-30.00357a9.43208,9.43208,0,1,1,17.28928,7.54372l-18.71,41.83025-.052.08956a8.54469,8.54469,0,0,1-9.74785,3.00972L710.97846,489.2473a10.30273,10.30273,0,0,1-.88511.61918,11.00261,11.00261,0,0,1-15.74382-4.6565q-.20244-.42436-.36484-.85874A11.0367,11.0367,0,0,1,697.48021,471.88251Z" transform="translate(-310.99935 -139.03722)" fill="#a0616a"/><path d="M884.33087,432.51247c-2.36572-4.19178-5.8125-8.03119-10.36914-9.58069-5.88476-2.001-12.25683.12964-18.30713,1.55218-4.66162,1.09595-9.53173,1.76679-14.23046.84192-4.69825-.92492-9.23047-3.65924-11.36817-7.94409-3.145-6.30359-.4956-13.82062-.687-20.86255a25.33438,25.33438,0,0,0-31.92334-23.81061c-5.79346-1.67193-11.03906-1.82659-14.62256,2.62714a17.0001,17.0001,0,0,0-17,17h16.25537a16.1496,16.1496,0,0,0,2.4541,11.93109c2.86963,4.21582,7.85938,7.2655,8.81983,12.274.93115,4.85351-2.36817,9.45868-5.8291,12.98669-3.46045,3.528-7.4751,7.02381-8.55567,11.84626a14.68871,14.68871,0,0,0,2.10352,10.56475,34.40329,34.40329,0,0,0,7.38623,8.13575,108.40184,108.40184,0,0,0,45.0376,23.04034c11.7041,2.81781,24.50586,3.54822,35.37109-1.6355a35.12563,35.12563,0,0,0,15.46484-48.96667Z" transform="translate(-310.99935 -139.03722)" fill="#2f2e41"/><path d="M888.00065,760.96278h-190a1,1,0,0,1,0-2h190a1,1,0,0,1,0,2Z" transform="translate(-310.99935 -139.03722)" fill="#ccc"/></svg>
<div class="grid gap-0-5 text-center justify-items-center">
<sm-form>
<div class="flex gap-0-5 align-items-start">
<sm-input placeholder="Bitcoin/FLO address to check" id="address_verify" class="flex-1"
error-text="Invalid address" required></sm-input>
<button id="verify" class="button button--primary icon-only" onclick=${initSearch} type="submit" title="search KYC status">
<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 d="M15.5 14h-.79l-.28-.27C15.41 12.59 16 11.11 16 9.5 16 5.91 13.09 3 9.5 3S3 5.91 3 9.5 5.91 16 9.5 16c1.61 0 3.09-.59 4.23-1.57l.27.28v.79l5 4.99L20.49 19l-4.99-5zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14z"/></svg>
</button>
</div>
</sm-form>
</div>
<output id="verification_result"></output>
</article>
`);
getRef('address_verify').customValidation = floCrypto.validateAddr;
if (state.params?.address)
verify(state.params?.address)
})
function initSearch() {
location.hash = `#/kyc_status?address=${getRef('address_verify').value.trim()}`;
}
function getUserKycRequests(address) {
const userKycRequests = floDapps.getNextGeneralData('userKycRequests', '0');
const filtered = {}
for (let key in userKycRequests) {
if (floCrypto.isSameAddr(userKycRequests[key].senderID, address || floDapps.user.id)) {
filtered[key] = userKycRequests[key]
}
}
return filtered
}
async function verify(address) {
if (address) {
if (getRef('address_verify').value.trim() !== address)
getRef('address_verify').value = address;
} else {
address = getRef('address_verify').value.trim();
}
getRef('verification_result').classList.remove('hidden');
if (address === '')
return renderElem(getRef('verification_result'), html``);
if (!floCrypto.validateAddr(address)) {
getRef('address_verify').isValid
return renderElem(getRef('verification_result'), html``);
}
if (address === '') return renderElem(getRef('verification_result'), html`Please enter an address`);
const floAddress = getFloAddress(address)
const btcAddress = getBtcAddress(floAddress)
renderElem(getRef('verification_result'), html`
<div class="grid gap-1 justify-items-center text-center">
<sm-spinner></sm-spinner>
<h4>Loading KYC status</h4>
</div>
`);
await floCloudAPI.requestGeneralData('userKycRequests', {
senderID: [floAddress, btcAddress]
})
const kycRequests = getUserKycRequests(floAddress);
const verifiedRequest = Object.values(kycRequests).find(request => {
const { senderID, tag_key, tag } = request;
const wasSentByAddress = senderID === floAddress || senderID === btcAddress
const isApproved = tag?.includes('approved')
const isApprovedByValidVerifier = floGlobals.subAdmins.some(subAdmin => floCrypto.isSameAddr(subAdmin, floCrypto.getFloID(tag_key)))
return wasSentByAddress && isApproved && isApprovedByValidVerifier
});
if (verifiedRequest) {
const { tag_key, tag_time } = verifiedRequest;
const issuedBy = floCrypto.getFloID(tag_key)
getRef('verification_result').dataset.status = 'valid';
renderElem(getRef('verification_result'), html`
<div class="grid justify-items-center text-center gap-0-5" style="margin: 2rem">
<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>
<h3>KYC successfully verified</h3>
</div>
<div class="info flex gap-0-5 flex-wrap">
<span>Issued by</span>
<div class="grid gap-1">
<h4>${floGlobals.appObjects.kycDocs.issuers[issuedBy]?.name || 'Unknown'}</h4>
<div class="grid">
<p>BTC address</p>
<sm-copy value=${getBtcAddress(issuedBy)} clip-text></sm-copy>
</div>
<div class="grid">
<p>FLO address</p>
<sm-copy value=${issuedBy} clip-text></sm-copy>
</div>
</div>
</div>
<div class="info flex align-center gap-0-5 flex-wrap">
<span>Issued on</span>
<span>${getFormattedTime(tag_time, 'date-only')}</span>
</div>
<div class="info flex align-center gap-0-5 flex-wrap">
<span>Verified on</span>
<span>${getFormattedTime(Date.now(), 'date-only')}</span>
</div>
`);
} else {
renderElem(getRef('verification_result'), html`
<div class="grid justify-items-center text-center gap-0-5" style="margin: 2rem">
<svg class="icon" xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 0 24 24" width="24px" fill="#000000"><path d="M0 0h24v24H0z" fill="none"/><path d="M12 2C6.47 2 2 6.47 2 12s4.47 10 10 10 10-4.47 10-10S17.53 2 12 2zm5 13.59L15.59 17 12 13.41 8.41 17 7 15.59 10.59 12 7 8.41 8.41 7 12 10.59 15.59 7 17 8.41 13.41 12 17 15.59z"/></svg>
<h4>KYC data not found</h4>
${myFloID ?
html`<a class="button button--primary" href="#/home">Start KYC process</a>` :
html`<a class="button button--primary" href="#/sign_in">Sign in to apply for KYC</a>`
}
</div>
`);
getRef('verification_result').dataset.status = 'invalid';
}
}
let isShowingFloID = false;
const docTypeNames = {
'aadhaar': 'Aadhaar Card',
'passport': 'Passport',
'driving_license': 'Driving License',
}
const btcAddresses = {}
const floAddresses = {}
function getBtcAddress(floAddress) {
if (!btcAddresses[floAddress])
btcAddresses[floAddress] = btcOperator.convert.legacy2bech(floAddress)
return btcAddresses[floAddress]
}
function getFloAddress(btcAddress) {
if (!floAddresses[btcAddress])
floAddresses[btcAddress] = floCrypto.toFloID(btcAddress)
return floAddresses[btcAddress]
}
const render = {
approvedAggregatorCard(address) {
const floID = getFloAddress(address)
const btcID = getBtcAddress(floID)
return html`
<li class="revoke-card">
<label class="flex align-center">
<input type="checkbox" value=${btcID}/>
<div class="grid gap-0-3">
<span class="wrap-around">BTC: ${btcID}</span>
<span class="wrap-around">FLO: ${floID}</span>
</div>
</label>
</li>
`
},
pendingKycRequest(request) {
const { message: { docType, docVectorClock }, vectorClock, senderID, time, } = request;
const floAddress = getFloAddress(senderID)
const btcAddress = getBtcAddress(floAddress)
return html`
<li class="kyc-request">
<time>${getFormattedTime(time)}</time>
<div class="grid">
<p>BTC Address</p>
<sm-copy value=${btcAddress}></sm-copy>
</div>
<div class="grid">
<p>FLO Address</p>
<sm-copy value=${floAddress}></sm-copy>
</div>
<div class="multi-state-button margin-right-auto">
<button class="button button--primary" .dataset=${{ requestVC: vectorClock, docVC: docVectorClock }} onclick=${viewFile}>
Check ${docTypeNames[docType]}
</button>
</div>
</li>`
},
approvedKycRequest(request) {
const { message: { docType, docVectorClock }, vectorClock, senderID, time, } = request;
const floAddress = getFloAddress(senderID)
const btcAddress = getBtcAddress(floAddress)
return html`
<li class="revoke-card">
<label class="flex align-center">
<input type="checkbox" value=${floAddress} .dataset=${{ requestVC: vectorClock, docVC: docVectorClock }}/>
<div class="grid gap-0-3">
<span class="wrap-around">BTC: ${btcAddress}</span>
<span class="wrap-around">FLO: ${floAddress}</span>
</div>
</label>
<div class="multi-state-button margin-right-auto">
<button class="button button--primary" .dataset=${{ requestVC: vectorClock, docVC: docVectorClock }} onclick=${viewFile}>
View ${docTypeNames[docType]}
</button>
</div>
</li>
`
},
rejectedKycRequest(request) {
const { message: { docType, docVectorClock }, vectorClock, senderID, time, } = request;
const floAddress = getFloAddress(senderID)
const btcAddress = getBtcAddress(floAddress)
return html`
<li class="kyc-request">
<div class="flex space-between gap-1 space-between">
<time>${getFormattedTime(time)}</time>
<div class="flex gap-0-3 align-center">
<svg class="icon"style="fill: var(--danger-color)" 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 d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zM4 12c0-4.42 3.58-8 8-8 1.85 0 3.55.63 4.9 1.69L5.69 16.9C4.63 15.55 4 13.85 4 12zm8 8c-1.85 0-3.55-.63-4.9-1.69L18.31 7.1C19.37 8.45 20 10.15 20 12c0 4.42-3.58 8-8 8z"/></svg>
<b>Rejected</b>
</div>
</div>
<div class="grid gap-1">
<div class="grid gap-0-3">
<p>FLO address</p>
<sm-copy value=${floAddress}></sm-copy>
</div>
<div class="grid gap-0-3">
<p>BTC address</p>
<sm-copy value=${btcAddress}></sm-copy>
</div>
</div>
</li>`
},
kycRequests(options = {}) {
const { status = 'pending', address } = options;
const kycRequests = floDapps.getNextGeneralData('userKycRequests', '0');
const filteredRequests = [];
const approvedRequests = new Set();
Object.values(kycRequests).forEach((request) => {
const { time, tag, note, senderID } = request;
const floAddress = getFloAddress(senderID)
if (status === 'pending') {
if (approvedRequests.has(floAddress))
return;
if (tag?.includes('approved'))
approvedRequests.add(floAddress)
}
if (status) {
switch (status) {
case 'approved':
if (!tag?.includes('approved') && !floGlobals.approvalsToBeCommitted.has(floAddress)) return;
break;
case 'rejected':
if (note !== 'rejected') return;
break;
case 'pending':
if (tag || note || floGlobals.approvalsToBeCommitted.has(floAddress)) return;
break;
}
}
if (address) {
const query = address.toLowerCase();
if (!floAddress.toLowerCase().includes(query) && !getBtcAddress(floAddress).toLowerCase().includes(query)) return;
}
switch (tag?.split('|')[0] || note) {
case 'approved':
return filteredRequests.push(render.approvedKycRequest(request));
case 'rejected':
return filteredRequests.push(render.rejectedKycRequest(request));
default:
return filteredRequests.push(render.pendingKycRequest(request));
}
})
return filteredRequests.reverse();
},
userRequests() {
let isVerified = false;
let concurrentRequests = 0;
const requests = getUserKycRequests();
const renderedRequests = Object.keys(requests).map((key) => {
const { time, tag, message: { docType }, note } = requests[key];
const txId = tag?.split('|')[1] || undefined;
if (!isVerified && tag?.includes('approved'))
isVerified = true;
if (!tag && !note) {
concurrentRequests++;
}
return html`
<li class="verification-item">
<time>${getFormattedTime(time)}</time>
<div class="flex flex-direction-column gap-0-5">
<h4>${docTypeNames[docType]}</h4>
${txId ? html`
<a href=${`https://blockbook.ranchimall.net/tx/${txId}`} target="_blank">
Check on blockchain
</a>
`: ''}
</div>
${isVerified ? html`
<div class="flex gap-0-3 align-center">
<svg class="icon"style="fill: var(--green)" 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>
<b>Verified</b>
</div>
`: html`
<p>Status: <b>${tag || note || 'Processing'}</b></p>
`}
</li>
`;
}).reverse();
return { renderedRequests, concurrentRequests, isVerified };
},
countrySpecificForm(country = 'el-salvador') {
const issuersList = floGlobals.subAdmins.map((issuer) => {
const { pubKey, name } = floGlobals.appObjects.kycDocs.issuers[issuer] || {};
if (!name || !pubKey) return html``;
return html`
<label class="interact">
<input type="radio" name="kyc_issuer" value=${pubKey}/>
<span>${name}</span>
</label>
`;
});
switch (country) {
case 'el-salvador': {
return Component(() => {
const maxFileSizeInMB = 2;
const [isHoldingImpPubOffice, setIsHoldingImpPubOffice] = useState(false);
const [isFamilyMemberHoldingImpPubOffice, setIsFamilyMemberHoldingImpPubOffice] = useState(false);
const [isAssociatedWithImpPubOffice, setIsAssociatedWithImpPubOffice] = useState(false);
const [selectedIdProof, setSelectedIdProof] = useState(null);
const [selectedVerifier, setSelectedVerifier] = useState(null);
const [selectedFile, setSelectedFile] = useState(null);
const [isUploading, setIsUploading] = useState(false);
useEffect(() => {
if (selectedIdProof) {
getRef('drag_drop_container').scrollIntoView({ behavior: 'smooth', block: 'center', inline: 'start' });
}
}, [selectedIdProof])
useEffect(() => {
if (selectedFile) {
const maxSizeInBytes = 1024 * 1024 * maxFileSizeInMB;
if (selectedFile.size > maxSizeInBytes) {
notify(`File size should be less than ${maxFileSizeInMB}MB`, 'error');
return;
}
getRef('file_upload_section').scrollIntoView({ behavior: 'smooth', block: 'center', inline: 'start' });
} else {
if (getRef('file_input')) getRef('file_input').value = ''
getRef('drag_drop_container')?.scrollIntoView({ behavior: 'smooth', block: 'center', inline: 'start' });
}
}, [selectedFile]);
function handleDragOver(e) {
e.preventDefault();
e.target.closest('#drag_drop_container').classList.add('drag-over');
}
function handleDragLeave(e) {
e.preventDefault();
e.target.closest('#drag_drop_container').classList.remove('drag-over');
}
function handleDrop(e) {
e.preventDefault();
e.target.closest('#drag_drop_container').classList.remove('drag-over');
setSelectedFile(e.dataTransfer.files[0]);
}
function handleFileChange(e) {
e.preventDefault();
setSelectedFile(e.target.files[0]);
}
async function uploadFile() {
if (!selectedIdProof) {
notify('Please select a ID proof', 'error');
return;
}
if (!selectedVerifier) {
notify('Please select a KYC verifier', 'error');
return;
}
const confirmation = await getConfirmation('Are you sure you want to upload this file?', {
confirmText: 'Upload',
});
if (!confirmation) return;
setIsUploading(true);
const finish = showProgress();
const reader = new FileReader();
reader.onload = async (e) => {
const fileDataAsArrayBuffer = e.target.result;
const fileAsBlob = new Blob([fileDataAsArrayBuffer], { type: selectedFile.type, });
try {
const { vectorClock } = await floCloudAPI.uploadFile(fileAsBlob, 'kycDoc', {
encrypt: selectedVerifier
})
const fileEntryResponse = await floCloudAPI.sendGeneralData({
docType: selectedIdProof,
docVectorClock: vectorClock,
}, 'userKycRequests')
fileEntryResponse.message = floCloudAPI.util.decodeMessage(fileEntryResponse.message)
// add file entry to general data
floGlobals.generalData[floCloudAPI.util.filterKey('userKycRequests')][fileEntryResponse.vectorClock] = fileEntryResponse
notify('File uploaded successfully', 'success');
await finish()
setSelectedFile(null);
renderHome();
} catch (err) {
console.error(err)
notify('Error uploading file. If the issue persists please reload the page and try again.', 'error');
} finally {
setIsUploading(false);
}
};
reader.readAsArrayBuffer(selectedFile);
}
return html`
<fieldset>
<legend>A. Personal information</legend>
<sm-input placeholder="Full name"></sm-input>
<sm-textarea placeholder="Full address" rows="3"></sm-textarea>
</fieldset>
<fieldset>
<legend>B. Politically exposed person form (PEP'S)</legend>
<div class="grid gap-3">
<div class="grid gap-1">
<p>Do you hold or have held any important public office? E.g. Minister, Mayor, Deputy, Other</p>
<div class="flex align-center gap-1" onchange=${(e) => { setIsHoldingImpPubOffice(e.target.value === 'yes') }}>
<label class="interact">
<input type="radio" name="person-pep" value="yes"/>
<span>Yes</span>
</label>
<label class="interact">
<input type="radio" name="person-pep" value="no" checked/>
<span>No</span>
</label>
</div>
${isHoldingImpPubOffice ? html`
<sm-input placeholder="Title"></sm-input>
<div class="flex align-center gap-0-5 flex-wrap">
<sm-input placeholder="Period" class="flex-1"></sm-input>
<input placeholder="Start" type="date" class="flex-1">
<input placeholder="End" type="date" class="flex-1">
</div>
`: ''}
</div>
<div class="grid gap-1">
<p>Does any family member (Husband, parents, siblings, in-laws, etc.) hold or have held any important public office?</p>
<div class="flex align-center gap-1" onchange=${(e) => { setIsFamilyMemberHoldingImpPubOffice(e.target.value === 'yes') }}>
<label class="interact">
<input type="radio" name="family-pep" value="yes"/>
<span>Yes</span>
</label>
<label class="interact">
<input type="radio" name="family-pep" value="no" checked/>
<span>No</span>
</label>
</div>
${isFamilyMemberHoldingImpPubOffice ? html`
<sm-input placeholder="Name"></sm-input>
<sm-input placeholder="Title"></sm-input>
<sm-input placeholder="Relative name"></sm-input>
<sm-input placeholder="Sibling"></sm-input>
`: ''}
</div>
<div class="grid gap-1">
<p>Does you have an associate holding a major public office?</p>
<div class="flex align-center gap-1" onchange=${(e) => { setIsAssociatedWithImpPubOffice(e.target.value === 'yes') }}>
<label class="interact">
<input type="radio" name="associate-pep" value="yes"/>
<span>Yes</span>
</label>
<label class="interact">
<input type="radio" name="associate-pep" value="no" checked/>
<span>No</span>
</label>
</div>
${isAssociatedWithImpPubOffice ? html`
<sm-input placeholder="Name"></sm-input>
<sm-input placeholder="Position held"></sm-input>
<div class="flex align-center gap-0-5 flex-wrap">
<sm-input placeholder="Period" class="flex-1"></sm-input>
<input placeholder="Start" type="date" class="flex-1">
<input placeholder="End" type="date" class="flex-1">
</div>
`: ''}
</div>
<p>
Politically Exposed Persons (PEP'S): Those natural persons identified at the beginning or during the course of the contractual relationship, nationals or foreigners, who perform or have performed public functions in our country or in their country of origin, as well as their relatives in the first and second degree of consanguinity or affinity, life partners or commercial or business associates.
</p>
</div>
</fieldset>
<fieldset>
<legend>C. Declaration of legal origin and accuracy of the information</legend>
<ol class="grid gap-1-5" type="a">
<li>
All the values that we (I) deliver will have an origin that in no way will be related to the cultivation, production, manufacture, storage or transport or illicit traffic of narcotic or psychotropic substances or any other related illegal activity, nor will we (I) admit that third parties make deposits in accounts in our (my) charge with funds coming from the above mentioned activities or those foreseen by the Anti-Money Laundering Law, allowing any investigation procedure by PROJECT B EL SALVADOR or the corresponding authorities.
</li>
<li>
The information provided in this instrument to PROJECT B EL SALVADOR is true and may be verified at any time.
</li>
<li>
We exempt PROJECT B from any liability arising from erroneous, false, or inaccurate information that we (I) have (would have) provided in this document or from the violation thereof.
</li>
</ol>
</fieldset>
<fieldset>
<legend>D. Provided documents</legend>
<fieldset id="file_doc_type_selector" onchange=${(e) => { setSelectedIdProof(e.target.value) }}>
<legend>Select ID proof</legend>
<label class="interact">
<input type="radio" name="file_type" value="driving_license"/>
<span>Driving license</span>
</label>
<label class="interact">
<input type="radio" name="file_type" value="passport"/>
<span>Passport</span>
</label>
</fieldset>
${selectedIdProof ? html`
<label class=${`drag-drop-container card grid gap-1 ${selectedFile ? 'hidden' : ''}`} id="drag_drop_container" ondragover=${handleDragOver} ondragleave=${handleDragLeave} ondrop=${handleDrop}>
<svg id="upload_icon" xmlns="http://www.w3.org/2000/svg" data-name="Layer 1" width="782.04441" height="701.88002" viewBox="0 0 782.04441 701.88002" xmlns:xlink="http://www.w3.org/1999/xlink"> <def> <style> .accented{ fill: var(--accent-color); } </style> </def> <path d="M609.48783,100.59015l-25.44631,6.56209L270.53735,187.9987,245.091,194.56079A48.17927,48.17927,0,0,0,210.508,253.17865L320.849,681.05606a48.17924,48.17924,0,0,0,58.61776,34.58317l.06572-.01695,364.26536-93.93675.06572-.01695a48.17923,48.17923,0,0,0,34.58309-58.6178l-110.341-427.87741A48.17928,48.17928,0,0,0,609.48783,100.59015Z" transform="translate(-208.9778 -99.05999)" fill="#f2f2f2"/> <path d="M612.94784,114.00532l-30.13945,7.77236L278.68955,200.20385l-30.139,7.77223a34.30949,34.30949,0,0,0-24.6275,41.74308l110.341,427.87741a34.30946,34.30946,0,0,0,41.7431,24.62736l.06572-.01695,364.26536-93.93674.06619-.01707a34.30935,34.30935,0,0,0,24.627-41.7429l-110.341-427.87741A34.30938,34.30938,0,0,0,612.94784,114.00532Z" transform="translate(-208.9778 -99.05999)" fill="#fff"/> <path d="M590.19,252.56327,405.917,300.08359a8.01411,8.01411,0,0,1-4.00241-15.52046l184.273-47.52033A8.01412,8.01412,0,0,1,590.19,252.56327Z" transform="translate(-208.9778 -99.05999)" fill="#f2f2f2"/><path d="M628.955,270.49906,412.671,326.27437a8.01411,8.01411,0,1,1-4.00241-15.52046l216.284-55.77531a8.01411,8.01411,0,0,1,4.00242,15.52046Z" transform="translate(-208.9778 -99.05999)" fill="#f2f2f2"/> <path d="M620.45825,369.93676l-184.273,47.52032a8.01411,8.01411,0,1,1-4.00242-15.52046l184.273-47.52032a8.01411,8.01411,0,1,1,4.00241,15.52046Z" transform="translate(-208.9778 -99.05999)" fill="#f2f2f2"/><path d="M659.22329,387.87255l-216.284,55.77531a8.01411,8.01411,0,1,1-4.00242-15.52046l216.284-55.77531a8.01411,8.01411,0,0,1,4.00242,15.52046Z" transform="translate(-208.9778 -99.05999)" fill="#f2f2f2"/> <path d="M650.72653,487.31025l-184.273,47.52033a8.01412,8.01412,0,0,1-4.00242-15.52047l184.273-47.52032a8.01411,8.01411,0,0,1,4.00242,15.52046Z" transform="translate(-208.9778 -99.05999)" fill="#f2f2f2"/><path d="M689.49156,505.246l-216.284,55.77532a8.01412,8.01412,0,1,1-4.00241-15.52047l216.284-55.77531a8.01411,8.01411,0,0,1,4.00242,15.52046Z" transform="translate(-208.9778 -99.05999)" fill="#f2f2f2"/> <path d="M374.45884,348.80871l-65.21246,16.817a3.847,3.847,0,0,1-4.68062-2.76146L289.5963,304.81607a3.847,3.847,0,0,1,2.76145-4.68061l65.21247-16.817a3.847,3.847,0,0,1,4.68061,2.76145l14.96947,58.04817A3.847,3.847,0,0,1,374.45884,348.80871Z" transform="translate(-208.9778 -99.05999)" fill="#e6e6e6"/> <path d="M404.72712,466.1822l-65.21247,16.817a3.847,3.847,0,0,1-4.68062-2.76146l-14.96946-58.04816A3.847,3.847,0,0,1,322.626,417.509l65.21246-16.817a3.847,3.847,0,0,1,4.68062,2.76145l14.96946,58.04817A3.847,3.847,0,0,1,404.72712,466.1822Z" transform="translate(-208.9778 -99.05999)" fill="#e6e6e6"/> <path d="M434.99539,583.55569l-65.21246,16.817a3.847,3.847,0,0,1-4.68062-2.76145l-14.96946-58.04817a3.847,3.847,0,0,1,2.76145-4.68062l65.21247-16.817a3.847,3.847,0,0,1,4.68061,2.76146l14.96947,58.04816A3.847,3.847,0,0,1,434.99539,583.55569Z" transform="translate(-208.9778 -99.05999)" fill="#e6e6e6"/> <path d="M863.63647,209.0517H487.31811a48.17928,48.17928,0,0,0-48.125,48.12512V699.05261a48.17924,48.17924,0,0,0,48.125,48.12507H863.63647a48.17924,48.17924,0,0,0,48.125-48.12507V257.17682A48.17928,48.17928,0,0,0,863.63647,209.0517Z" transform="translate(-208.9778 -99.05999)" fill="#e6e6e6"/> <path d="M863.637,222.90589H487.31811a34.30948,34.30948,0,0,0-34.271,34.27093V699.05261a34.30947,34.30947,0,0,0,34.271,34.27088H863.637a34.30936,34.30936,0,0,0,34.27051-34.27088V257.17682A34.30937,34.30937,0,0,0,863.637,222.90589Z" transform="translate(-208.9778 -99.05999)" fill="#fff"/> <circle class="accented" cx="694.19401" cy="614.02963" r="87.85039"/> <path d="M945.18722,701.63087H914.63056V671.07421a11.45875,11.45875,0,0,0-22.9175,0v30.55666H861.1564a11.45875,11.45875,0,0,0,0,22.9175h30.55666V755.105a11.45875,11.45875,0,1,0,22.9175,0V724.54837h30.55666a11.45875,11.45875,0,0,0,0-22.9175Z" transform="translate(-208.9778 -99.05999)" fill="#fff"/> <path d="M807.00068,465.71551H616.699a8.01412,8.01412,0,1,1,0-16.02823H807.00068a8.01412,8.01412,0,0,1,0,16.02823Z" transform="translate(-208.9778 -99.05999)" fill="#e6e6e6"/> <path d="M840.05889,492.76314H616.699a8.01412,8.01412,0,1,1,0-16.02823H840.05889a8.01411,8.01411,0,1,1,0,16.02823Z" transform="translate(-208.9778 -99.05999)" fill="#e6e6e6"/> <path d="M807.00068,586.929H616.699a8.01412,8.01412,0,1,1,0-16.02823H807.00068a8.01411,8.01411,0,0,1,0,16.02823Z" transform="translate(-208.9778 -99.05999)" fill="#e6e6e6"/> <path d="M840.05889,613.97661H616.699a8.01412,8.01412,0,1,1,0-16.02823H840.05889a8.01412,8.01412,0,1,1,0,16.02823Z" transform="translate(-208.9778 -99.05999)" fill="#e6e6e6"/> <path d="M574.07028,505.04162H506.72434a3.847,3.847,0,0,1-3.84278-3.84278V441.25158a3.847,3.847,0,0,1,3.84278-3.84278h67.34594a3.847,3.847,0,0,1,3.84278,3.84278v59.94726A3.847,3.847,0,0,1,574.07028,505.04162Z" transform="translate(-208.9778 -99.05999)" fill="#e6e6e6"/> <path d="M574.07028,626.25509H506.72434a3.847,3.847,0,0,1-3.84278-3.84278V562.46505a3.847,3.847,0,0,1,3.84278-3.84278h67.34594a3.847,3.847,0,0,1,3.84278,3.84278v59.94726A3.847,3.847,0,0,1,574.07028,626.25509Z" transform="translate(-208.9778 -99.05999)" fill="#e6e6e6"/> <path d="M807.21185,330.781H666.91017a8.01411,8.01411,0,0,1,0-16.02823H807.21185a8.01411,8.01411,0,0,1,0,16.02823Z" transform="translate(-208.9778 -99.05999)" fill="#ccc"/> <path d="M840.27007,357.82862H666.91017a8.01411,8.01411,0,1,1,0-16.02822h173.3599a8.01411,8.01411,0,0,1,0,16.02822Z" transform="translate(-208.9778 -99.05999)" fill="#ccc"/> <path class="accented" d="M635.85911,390.6071H506.51316a3.847,3.847,0,0,1-3.84277-3.84277V285.81706a3.847,3.847,0,0,1,3.84277-3.84277H635.85911a3.847,3.847,0,0,1,3.84277,3.84277V386.76433A3.847,3.847,0,0,1,635.85911,390.6071Z" transform="translate(-208.9778 -99.05999)"/> </svg>
<div class="grid gap-0-3">
<h4 class="drag-drop-text">
Drag & Drop ${docTypeNames[selectedIdProof]} here or click to browse
</h4>
<p>
Max file size: ${maxFileSizeInMB}MB. Allowed file types are <b>".png, .jpg, .pdf"</b>
</p>
</div>
<strong> Don't worry, your ${docTypeNames[selectedIdProof]} is end-to-end encrypted.</strong>
<input type="file" id="file_input" accept=".png,.jpg,.pdf" class="hidden" onchange=${handleFileChange}/>
</label>
`: ''}
${selectedFile ? html`
<div id="file_upload_section" class=${`grid gap-1 card`}>
${isUploading ? html`
<div id="upload_progress_section" class=${`grid gap-1`}>
<h4>Uploading file...</h4>
<div id="progress_bar" class="progress">
<div class="progress__bar"></div>
</div>
</div>
`: ''}
${!isUploading ? html`
<div id="upload_button_wrapper" class="flex flex align-center gap-1 flex-wrap">
<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 d="M14 2H6c-1.1 0-1.99.9-1.99 2L4 20c0 1.1.89 2 1.99 2H18c1.1 0 2-.9 2-2V8l-6-6zM6 20V4h7v5h5v11H6z" /> </svg>
<h4 id="selected_file_name">${selectedFile?.name}</h4>
<div class="flex align-center gap-0-5 flex-wrap w-100">
<button class="button" onclick=${() => { getRef('file_input').click() }} title="Change selected file">
Change
</button>
<button id="remove_file_button" class="button icon-only" onclick=${() => { setSelectedFile(null) }} title="Remove selected file">
<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 d="M16 9v10H8V9h8m-1.5-6h-5l-1 1H5v2h14V4h-3.5l-1-1zM18 7H6v12c0 1.1.9 2 2 2h8c1.1 0 2-.9 2-2V7z" /> </svg>
</button>
</div>
</div>
`: ''}
</div>
`: ''}
</fieldset>
${selectedFile ? html`
<fieldset onchange=${(e) => { setSelectedVerifier(e.target.value) }}>
<legend>Select KYC verifier</legend>
${issuersList}
</fieldset>
<div class="multi-state-button">
<button id="upload_file_button" class="button button--primary flex-1 gap-0-5" onclick=${uploadFile}>
<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="M18,15v3H6v-3H4v3c0,1.1,0.9,2,2,2h12c1.1,0,2-0.9,2-2v-3H18z M7,9l1.41,1.41L11,7.83V16h2V7.83l2.59,2.58L17,9l-5-5L7,9z"/></g></svg>
Upload
</button>
</div>
`: ''}
`
})()
}
default:
return html`<p>Country not supported</p>`
}
}
}
let userAddressTimeInterval;
function renderHome(appState) {
const { lastPage, page, params: { filter = 'pending', search } = {} } = appState || {};
const mainHeader = html`
<header id="main_header">
<div class="app-brand margin-right-auto hide-on-small">
<svg id="main_logo" class="icon" viewBox="0 0 27.25 32"> <title>RanchiMall</title> <path d="M27.14,30.86c-.74-2.48-3-4.36-8.25-6.94a20,20,0,0,1-4.2-2.49,6,6,0,0,1-1.25-1.67,4,4,0,0,1,0-2.26c.37-1.08.79-1.57,3.89-4.55a11.66,11.66,0,0,0,3.34-4.67,6.54,6.54,0,0,0,.05-2.82C20,3.6,18.58,2,16.16.49c-.89-.56-1.29-.64-1.3-.24a3,3,0,0,1-.3.72l-.3.55L13.42.94C13,.62,12.4.26,12.19.15c-.4-.2-.73-.18-.72.05a9.39,9.39,0,0,1-.61,1.33s-.14,0-.27-.13C8.76.09,8-.27,8,.23A11.73,11.73,0,0,1,6.76,2.6C4.81,5.87,2.83,7.49.77,7.49c-.89,0-.88,0-.61,1,.22.85.33.92,1.09.69A5.29,5.29,0,0,0,3,8.33c.23-.17.45-.29.49-.26a2,2,0,0,1,.22.63A1.31,1.31,0,0,0,4,9.34a5.62,5.62,0,0,0,2.27-.87L7,8l.13.55c.19.74.32.82,1,.65a7.06,7.06,0,0,0,3.46-2.47l.6-.71-.06.64c-.17,1.63-1.3,3.42-3.39,5.42L6.73,14c-3.21,3.06-3,5.59.6,8a46.77,46.77,0,0,0,4.6,2.41c.28.13,1,.52,1.59.87,3.31,2,4.95,3.92,4.95,5.93a2.49,2.49,0,0,0,.07.77h0c.09.09,0,.1.9-.14a2.61,2.61,0,0,0,.83-.32,3.69,3.69,0,0,0-.55-1.83A11.14,11.14,0,0,0,17,26.81a35.7,35.7,0,0,0-5.1-2.91C9.37,22.64,8.38,22,7.52,21.17a3.53,3.53,0,0,1-1.18-2.48c0-1.38.71-2.58,2.5-4.23,2.84-2.6,3.92-3.91,4.67-5.65a3.64,3.64,0,0,0,.42-2A3.37,3.37,0,0,0,13.61,5l-.32-.74.29-.48c.17-.27.37-.63.46-.8l.15-.3.44.64a5.92,5.92,0,0,1,1,2.81,5.86,5.86,0,0,1-.42,1.94c0,.12-.12.3-.15.4a9.49,9.49,0,0,1-.67,1.1,28,28,0,0,1-4,4.29C8.62,15.49,8.05,16.44,8,17.78a3.28,3.28,0,0,0,1.11,2.76c.95,1,2.07,1.74,5.25,3.32,3.64,1.82,5.22,2.9,6.41,4.38A4.78,4.78,0,0,1,21.94,31a3.21,3.21,0,0,0,.14.92,1.06,1.06,0,0,0,.43-.05l.83-.22.46-.12-.06-.46c-.21-1.53-1.62-3.25-3.94-4.8a37.57,37.57,0,0,0-5.22-2.82A13.36,13.36,0,0,1,11,21.19a3.36,3.36,0,0,1-.8-4.19c.41-.85.83-1.31,3.77-4.15,2.39-2.31,3.43-4.13,3.43-6a5.85,5.85,0,0,0-2.08-4.29c-.23-.21-.44-.43-.65-.65A2.5,2.5,0,0,1,15.27.69a10.6,10.6,0,0,1,2.91,2.78A4.16,4.16,0,0,1,19,6.16a4.91,4.91,0,0,1-.87,3c-.71,1.22-1.26,1.82-4.27,4.67a9.47,9.47,0,0,0-2.07,2.6,2.76,2.76,0,0,0-.33,1.54,2.76,2.76,0,0,0,.29,1.47c.57,1.21,2.23,2.55,4.65,3.73a32.41,32.41,0,0,1,5.82,3.24c2.16,1.6,3.2,3.16,3.2,4.8a1.94,1.94,0,0,0,.09.76,4.54,4.54,0,0,0,1.66-.4C27.29,31.42,27.29,31.37,27.14,30.86ZM6.1,7h0a3.77,3.77,0,0,1-1.46.45L4,7.51l.68-.83a25.09,25.09,0,0,0,3-4.82A12,12,0,0,1,8.28.76c.11-.12.77.32,1.53,1l.63.58-.57.84A10.34,10.34,0,0,1,6.1,7Zm5.71-1.78A9.77,9.77,0,0,1,9.24,7.18h0a5.25,5.25,0,0,1-1.17.28l-.58,0,.65-.78a21.29,21.29,0,0,0,2.1-3.12c.22-.41.42-.76.44-.79s.5.43.9,1.24L12,5ZM13.41,3a2.84,2.84,0,0,1-.45.64,11,11,0,0,1-.9-.91l-.84-.9.19-.45c.34-.79.39-.8,1-.31A9.4,9.4,0,0,1,13.8,2.33q-.18.34-.39.69Z" /> </svg>
<div class="app-name">
<div class="app-name__company">RanchiMall</div>
<h4 class="app-name__title">
KYC
</h4>
</div>
</div>
<theme-toggle id="theme_toggle"></theme-toggle>
<button id="user_popup_button" class="button--small" onclick="openPopup('user_popup')">
<svg class="icon margin-right-0-5" width="64" height="64" viewBox="0 0 64 64" fill="none" xmlns="http://www.w3.org/2000/svg"> <mask id="path-1-outside-1_16_6" maskUnits="userSpaceOnUse" x="3" y="3" width="58" height="58"> <rect fill="white" x="3" y="3" width="58" height="58" /> <path fill-rule="evenodd" clip-rule="evenodd" d="M31.946 43.6019C28.8545 47.1308 28.7789 51.9719 31.9811 55.1957C35.0078 52.2797 35.0105 46.8446 31.946 43.6019ZM31.9487 10.6835C24.6452 19.1291 24.9206 29.1137 31.9433 37.4108C39.0929 28.9436 39.1118 19.0076 31.9487 10.6808V10.6835ZM37.1111 35.051C43.1861 28.841 50.5976 27.4208 59 28.7654C56.2919 34.9754 52.4714 39.9353 45.7214 42.53C47.2118 41.3609 48.5699 40.4051 49.7984 39.3089C51.8504 37.481 53.303 35.267 54.0293 32.6075C54.2588 31.7678 53.9618 31.5302 53.1896 31.406C50.3627 30.9524 47.7086 31.5464 45.1733 32.702C40.9073 34.646 37.4324 37.6403 34.1735 40.8938C34.1168 40.9532 34.0925 41.0396 33.9899 41.2259C40.3754 41.4689 45.2381 44.0177 48.119 49.9064C44.3768 50.738 40.9532 50.5625 37.778 48.5213C40.1702 49.2557 42.557 49.7903 45.176 48.5483C44.852 48.0083 44.663 47.3765 44.231 47.0228C43.0511 46.0589 41.8415 45.0842 40.505 44.3498C38.4395 43.2212 36.131 42.692 33.5768 42.1682C37.0247 48.2081 36.1607 53.6918 31.946 59C29.9858 56.5295 28.6142 53.9456 28.2389 50.8946C27.8609 47.8328 28.7222 45.0518 30.1991 42.3896C26.9321 41.8658 19.8824 45.6485 18.7916 48.5645C21.3215 49.8443 23.7893 49.2611 26.33 48.3161C24.5048 50.1953 19.2425 50.9648 15.8108 49.8335C18.6593 44.0285 23.4977 41.4716 30.0263 41.2286C29.5457 40.7426 29.1893 40.3673 28.8167 40.0082C26.1005 37.3892 23.2142 34.9862 19.823 33.2366C17.0501 31.8056 14.1422 30.9092 10.9481 31.3871C10.5701 31.4438 10.1948 31.5356 9.6656 31.6436C10.6376 36.6386 13.9856 39.7355 18.1274 42.3464C13.775 41.8199 6.431 34.214 5 28.7546C13.397 27.3938 20.849 28.8842 26.897 35.2319C21.8939 24.089 24.5561 14.2259 31.946 5C39.2765 14.153 41.9657 23.9459 37.1111 35.051" /> </mask> <path fill-rule="evenodd" clip-rule="evenodd" d="M31.946 43.6019C28.8545 47.1308 28.7789 51.9719 31.9811 55.1957C35.0078 52.2797 35.0105 46.8446 31.946 43.6019ZM31.9487 10.6835C24.6452 19.1291 24.9206 29.1137 31.9433 37.4108C39.0929 28.9436 39.1118 19.0076 31.9487 10.6808V10.6835ZM37.1111 35.051C43.1861 28.841 50.5976 27.4208 59 28.7654C56.2919 34.9754 52.4714 39.9353 45.7214 42.53C47.2118 41.3609 48.5699 40.4051 49.7984 39.3089C51.8504 37.481 53.303 35.267 54.0293 32.6075C54.2588 31.7678 53.9618 31.5302 53.1896 31.406C50.3627 30.9524 47.7086 31.5464 45.1733 32.702C40.9073 34.646 37.4324 37.6403 34.1735 40.8938C34.1168 40.9532 34.0925 41.0396 33.9899 41.2259C40.3754 41.4689 45.2381 44.0177 48.119 49.9064C44.3768 50.738 40.9532 50.5625 37.778 48.5213C40.1702 49.2557 42.557 49.7903 45.176 48.5483C44.852 48.0083 44.663 47.3765 44.231 47.0228C43.0511 46.0589 41.8415 45.0842 40.505 44.3498C38.4395 43.2212 36.131 42.692 33.5768 42.1682C37.0247 48.2081 36.1607 53.6918 31.946 59C29.9858 56.5295 28.6142 53.9456 28.2389 50.8946C27.8609 47.8328 28.7222 45.0518 30.1991 42.3896C26.9321 41.8658 19.8824 45.6485 18.7916 48.5645C21.3215 49.8443 23.7893 49.2611 26.33 48.3161C24.5048 50.1953 19.2425 50.9648 15.8108 49.8335C18.6593 44.0285 23.4977 41.4716 30.0263 41.2286C29.5457 40.7426 29.1893 40.3673 28.8167 40.0082C26.1005 37.3892 23.2142 34.9862 19.823 33.2366C17.0501 31.8056 14.1422 30.9092 10.9481 31.3871C10.5701 31.4438 10.1948 31.5356 9.6656 31.6436C10.6376 36.6386 13.9856 39.7355 18.1274 42.3464C13.775 41.8199 6.431 34.214 5 28.7546C13.397 27.3938 20.849 28.8842 26.897 35.2319C21.8939 24.089 24.5561 14.2259 31.946 5C39.2765 14.153 41.9657 23.9459 37.1111 35.051" /> <path d="M31.946 43.6019L32.6728 42.915L31.918 42.1163L31.1938 42.943L31.946 43.6019ZM31.9811 55.1957L31.2716 55.9004L31.9657 56.5992L32.6749 55.9159L31.9811 55.1957ZM31.9487 10.6835L32.7051 11.3376L32.9487 11.0559V10.6835H31.9487ZM31.9433 37.4108L31.18 38.0569L31.9442 38.9597L32.7074 38.056L31.9433 37.4108ZM31.9487 10.6808L32.7068 10.0287L30.9487 7.98495V10.6808H31.9487ZM59 28.7654L59.9166 29.1651L60.4326 27.9819L59.158 27.778L59 28.7654ZM45.7214 42.53L45.1042 41.7432L46.0802 43.4634L45.7214 42.53ZM49.7984 39.3089L49.1332 38.5622L49.1326 38.5628L49.7984 39.3089ZM54.0293 32.6075L53.0647 32.3439L53.0646 32.3441L54.0293 32.6075ZM53.1896 31.406L53.3484 30.4187L53.348 30.4186L53.1896 31.406ZM45.1733 32.702L45.588 33.612L45.5881 33.6119L45.1733 32.702ZM34.1735 40.8938L33.467 40.1861L33.4585 40.1946L33.4501 40.2033L34.1735 40.8938ZM33.9899 41.2259L33.114 40.7435L32.3319 42.1635L33.9519 42.2252L33.9899 41.2259ZM48.119 49.9064L48.3359 50.8826L49.5751 50.6072L49.0173 49.4669L48.119 49.9064ZM37.778 48.5213L38.0715 47.5653L37.2372 49.3625L37.778 48.5213ZM45.176 48.5483L45.6045 49.4518L46.6008 48.9794L46.0335 48.0338L45.176 48.5483ZM44.231 47.0228L44.8645 46.2491L44.8637 46.2484L44.231 47.0228ZM40.505 44.3498L40.9866 43.4734L40.9845 43.4723L40.505 44.3498ZM33.5768 42.1682L33.7777 41.1886L31.6127 40.7446L32.7083 42.664L33.5768 42.1682ZM31.946 59L31.1626 59.6216L31.9457 60.6085L32.7292 59.6218L31.946 59ZM28.2389 50.8946L29.2314 50.7725L29.2314 50.7721L28.2389 50.8946ZM30.1991 42.3896L31.0736 42.8747L31.7652 41.6279L30.3574 41.4022L30.1991 42.3896ZM18.7916 48.5645L17.855 48.2141L17.5413 49.0527L18.3402 49.4568L18.7916 48.5645ZM26.33 48.3161L27.0473 49.0128L25.9814 47.3788L26.33 48.3161ZM15.8108 49.8335L14.9131 49.393L14.4073 50.4237L15.4977 50.7832L15.8108 49.8335ZM30.0263 41.2286L30.0635 42.2279L32.3372 42.1433L30.7373 40.5255L30.0263 41.2286ZM28.8167 40.0082L28.1226 40.7281L28.1228 40.7282L28.8167 40.0082ZM19.823 33.2366L19.3644 34.1252L19.3645 34.1253L19.823 33.2366ZM10.9481 31.3871L10.8001 30.3981L10.7998 30.3982L10.9481 31.3871ZM9.6656 31.6436L9.46564 30.6638L8.49474 30.8619L8.68401 31.8346L9.6656 31.6436ZM18.1274 42.3464L18.0073 43.3392L18.6607 41.5005L18.1274 42.3464ZM5 28.7546L4.84003 27.7675L3.75363 27.9435L4.03268 29.0082L5 28.7546ZM26.897 35.2319L26.173 35.9217L27.8093 34.8223L26.897 35.2319ZM31.946 5L32.7265 4.37488L31.9461 3.40036L31.1655 4.37483L31.946 5ZM31.1938 42.943C27.7974 46.8199 27.6566 52.261 31.2716 55.9004L32.6906 54.491C29.9012 51.6828 29.9116 47.4417 32.6982 44.2609L31.1938 42.943ZM32.6749 55.9159C36.1304 52.5867 36.081 46.5214 32.6728 42.915L31.2192 44.2888C33.94 47.1678 33.8852 51.9727 31.2873 54.4755L32.6749 55.9159ZM31.1923 10.0294C27.4048 14.4092 25.5379 19.2455 25.5737 24.1102C25.6095 28.971 27.5438 33.7608 31.18 38.0569L32.7066 36.7647C29.3201 32.7637 27.6054 28.4127 27.5736 24.0955C27.5419 19.7822 29.1891 15.4034 32.7051 11.3376L31.1923 10.0294ZM32.7074 38.056C36.4083 33.6729 38.31 28.8504 38.3133 23.9938C38.3165 19.1359 36.42 14.3451 32.7068 10.0287L31.1906 11.3329C34.6405 15.3433 36.3161 19.6839 36.3133 23.9925C36.3104 28.3024 34.6279 32.6815 31.1792 36.7656L32.7074 38.056ZM30.9487 10.6808V10.6835H32.9487V10.6808H30.9487ZM37.8259 35.7503C43.6131 29.8345 50.6632 28.444 58.842 29.7528L59.158 27.778C50.532 26.3976 42.7591 27.8475 36.3963 34.3517L37.8259 35.7503ZM58.0834 28.3657C55.4402 34.4268 51.7791 39.1301 45.3626 41.5966L46.0802 43.4634C53.1637 40.7405 57.1436 35.524 59.9166 29.1651L58.0834 28.3657ZM46.3386 43.3168C47.7733 42.1914 49.2057 41.178 50.4642 40.055L49.1326 38.5628C47.9341 39.6322 46.6503 40.5304 45.1042 41.7432L46.3386 43.3168ZM50.4636 40.0556C52.6466 38.111 54.2121 35.7338 54.994 32.871L53.0646 32.3441C52.3939 34.8002 51.0542 36.851 49.1332 38.5622L50.4636 40.0556ZM54.9939 32.8711C55.1262 32.3872 55.2248 31.6946 54.7698 31.1186C54.3643 30.6053 53.7257 30.4794 53.3484 30.4187L53.0308 32.3933C53.1086 32.4058 53.17 32.4181 53.2184 32.43C53.2671 32.442 53.2955 32.4518 53.3091 32.4572C53.3227 32.4626 53.3139 32.4606 53.2926 32.4461C53.2699 32.4307 53.2353 32.4025 53.2004 32.3583C53.1832 32.3366 53.1677 32.3132 53.1543 32.2886C53.1409 32.264 53.1307 32.2402 53.1231 32.2182C53.1079 32.1742 53.1053 32.144 53.1049 32.1366C53.1046 32.1302 53.1059 32.1427 53.1007 32.1797C53.0955 32.2165 53.0849 32.27 53.0647 32.3439L54.9939 32.8711ZM53.348 30.4186C50.274 29.9254 47.4176 30.5801 44.7585 31.7921L45.5881 33.6119C47.9996 32.5127 50.4514 31.9794 53.0312 32.3934L53.348 30.4186ZM44.7586 31.792C40.3293 33.8104 36.7535 36.9051 33.467 40.1861L34.88 41.6015C38.1113 38.3755 41.4853 35.4816 45.588 33.612L44.7586 31.792ZM33.4501 40.2033C33.3063 40.354 33.2291 40.5156 33.2033 40.5674C33.1672 40.64 33.1517 40.6749 33.114 40.7435L34.8658 41.7083C34.9307 41.5906 34.9786 41.4891 34.9945 41.4572C35.0049 41.4363 35.0004 41.4467 34.9882 41.4667C34.9731 41.4914 34.9435 41.5355 34.8969 41.5843L33.4501 40.2033ZM33.9519 42.2252C37.0233 42.3421 39.6629 43.0109 41.8597 44.3098C44.0485 45.6039 45.857 47.5582 47.2207 50.3459L49.0173 49.4669C47.5001 46.3659 45.4368 44.1014 42.8776 42.5882C40.3265 41.0798 37.342 40.3527 34.0279 40.2266L33.9519 42.2252ZM47.9021 48.9302C44.3241 49.7253 41.1983 49.5313 38.3188 47.6801L37.2372 49.3625C40.7081 51.5937 44.4295 51.7507 48.3359 50.8826L47.9021 48.9302ZM37.4845 49.4773C39.9089 50.2215 42.6205 50.8669 45.6045 49.4518L44.7475 47.6448C42.4935 48.7137 40.4315 48.2899 38.0715 47.5653L37.4845 49.4773ZM46.0335 48.0338C45.8849 47.7862 45.8212 47.6158 45.6292 47.2504C45.4736 46.9544 45.2423 46.5584 44.8645 46.2491L43.5975 47.7965C43.6517 47.8409 43.7309 47.9377 43.8588 48.181C43.9503 48.3549 44.1431 48.7704 44.3185 49.0628L46.0335 48.0338ZM44.8637 46.2484C43.6913 45.2906 42.4149 44.2582 40.9866 43.4734L40.0234 45.2262C41.2681 45.9102 42.4109 46.8272 43.5983 47.7972L44.8637 46.2484ZM40.9845 43.4723C38.7711 42.2628 36.3236 41.7107 33.7777 41.1886L33.3759 43.1478C35.9384 43.6733 38.1079 44.1796 40.0255 45.2273L40.9845 43.4723ZM32.7083 42.664C34.346 45.5328 34.9255 48.203 34.6411 50.7474C34.3555 53.3015 33.1882 55.8274 31.1628 58.3782L32.7292 59.6218C34.9185 56.8644 36.2905 53.9944 36.6287 50.9696C36.9679 47.9351 36.2555 44.8435 34.4453 41.6724L32.7083 42.664ZM32.7294 58.3784C30.8397 55.9968 29.577 53.5818 29.2314 50.7725L27.2464 51.0167C27.6514 54.3094 29.1319 57.0622 31.1626 59.6216L32.7294 58.3784ZM29.2314 50.7721C28.8877 47.9881 29.6602 45.4224 31.0736 42.8747L29.3247 41.9045C27.7842 44.6812 26.8341 47.6775 27.2464 51.0171L29.2314 50.7721ZM30.3574 41.4022C29.3303 41.2375 28.1125 41.4187 26.9159 41.7622C25.6987 42.1117 24.4105 42.6564 23.2045 43.307C21.999 43.9574 20.8488 44.728 19.9166 45.543C19.005 46.3399 18.2137 47.2553 17.855 48.2141L19.7282 48.9149C19.9149 48.4157 20.4139 47.7647 21.233 47.0487C22.0314 46.3507 23.0524 45.6616 24.1541 45.0672C25.2552 44.4732 26.4102 43.9882 27.4678 43.6846C28.5458 43.3751 29.4344 43.2798 30.0408 43.377L30.3574 41.4022ZM18.3402 49.4568C21.2702 50.939 24.0958 50.214 26.6786 49.2534L25.9814 47.3788C23.4828 48.3082 21.3728 48.7496 19.243 47.6722L18.3402 49.4568ZM25.6127 47.6194C24.9334 48.3187 23.4333 48.9382 21.5294 49.2141C19.6667 49.484 17.6562 49.3889 16.1239 48.8838L15.4977 50.7832C17.3971 51.4094 19.7336 51.4952 21.8162 51.1934C23.8578 50.8976 25.9014 50.1927 27.0473 49.0128L25.6127 47.6194ZM16.7085 50.274C18.0554 47.5292 19.8486 45.5942 22.044 44.3081C24.2482 43.0169 26.918 42.345 30.0635 42.2279L29.9891 40.2293C26.606 40.3552 23.5923 41.0832 21.0331 42.5824C18.4649 44.0869 16.4147 46.3328 14.9131 49.393L16.7085 50.274ZM30.7373 40.5255C30.2757 40.0586 29.8942 39.6578 29.5106 39.2882L28.1228 40.7282C28.4844 41.0768 28.8157 41.4266 29.3153 41.9317L30.7373 40.5255ZM29.5108 39.2883C26.7637 36.6396 23.7967 34.1615 20.2815 32.3479L19.3645 34.1253C22.6317 35.8109 25.4373 38.1388 28.1226 40.7281L29.5108 39.2883ZM20.2816 32.348C17.4111 30.8666 14.2829 29.877 10.8001 30.3981L11.0961 32.3761C14.0015 31.9414 16.6891 32.7446 19.3644 34.1252L20.2816 32.348ZM10.7998 30.3982C10.388 30.4599 9.94468 30.566 9.46564 30.6638L9.86556 32.6234C10.4449 32.5052 10.7522 32.4277 11.0964 32.376L10.7998 30.3982ZM8.68401 31.8346C9.73479 37.2345 13.3673 40.5279 17.5941 43.1923L18.6607 41.5005C14.6039 38.9431 11.5404 36.0427 10.6472 31.4526L8.68401 31.8346ZM18.2475 41.3536C17.3819 41.2489 16.2594 40.7693 14.9918 39.9335C13.742 39.1093 12.427 37.9891 11.1875 36.7057C8.68437 34.1137 6.62095 30.9947 5.96732 28.5011L4.03268 29.0082C4.81005 31.9739 7.13413 35.3875 9.74885 38.095C11.0683 39.4613 12.4947 40.6825 13.8908 41.6031C15.2691 42.512 16.6967 43.1806 18.0073 43.3392L18.2475 41.3536ZM5.15997 29.7417C13.3246 28.4186 20.4108 29.874 26.173 35.9217L27.621 34.5421C21.2872 27.8944 13.4694 26.369 4.84003 27.7675L5.15997 29.7417ZM27.8093 34.8223C25.3851 29.4232 24.8341 24.3801 25.7561 19.5859C26.6809 14.7778 29.1009 10.1516 32.7265 5.62517L31.1655 4.37483C27.4012 9.07433 24.7952 13.9927 23.7921 19.2082C22.7863 24.4378 23.4058 29.8977 25.9847 35.6415L27.8093 34.8223ZM31.1655 5.62512C34.7619 10.1157 37.1747 14.7077 38.1168 19.4869C39.0562 24.2523 38.5469 29.2701 36.1948 34.6504L38.0274 35.4515C40.5299 29.7268 41.1033 24.2956 40.0791 19.1001C39.0576 13.9183 36.4606 9.03731 32.7265 4.37488L31.1655 5.62512Z" mask="url(#path-1-outside-1_16_6)" /> </svg>
<div class="overflow-ellipsis">${floGlobals.myBtcID}</div>
</button>
</header>
`;
const renderedKycRequests = render.kycRequests({ status: filter, address: search });
if (floGlobals.isSubAdmin) {
renderElem(getRef('app_body'), html`
<article id="home_page">
${mainHeader}
<div id="verifier_wrapper" class="flex flex-wrap gap-1 align-items-start">
<section id="verifier_balance_container" class="grid gap-1"> </section>
<section class="grid gap-1">
<div id="kyc_requests_header" class="flex align-center space-between gap-1 flex-wrap">
<h3>KYC requests</h3>
<sm-chips id="kyc_request_filter" onchange=${handleRequestFilter}>
<sm-chip value="pending" selected=${filter === "pending"}>Pending</sm-chip>
<sm-chip value="approved" selected=${filter === "approved"}>Approved</sm-chip>
<sm-chip value="rejected" selected=${filter === "rejected"}>Rejected</sm-chip>
</sm-chips>
</div>
<sm-input id="search_approved" type="search" placeholder="Search address" oninput=${handleRequestSearch}>
<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" /> <path d="M15.5 14h-.79l-.28-.27C15.41 12.59 16 11.11 16 9.5 16 5.91 13.09 3 9.5 3S3 5.91 3 9.5 5.91 16 9.5 16c1.61 0 3.09-.59 4.23-1.57l.27.28v.79l5 4.99L20.49 19l-4.99-5zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14z" /> </svg>
</sm-input>
<div id="selected_wrapper" class="flex gap-0-5 align-center hidden">
<button class="button icon-only" title="Clear selection" onclick=${clearSelection}>
<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 d="M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12 19 6.41z" /> </svg>
</button>
<div id="selected_addresses"></div>
<div class="multi-state-button margin-left-auto">
<button id="revoke_kyc_button" class="button button--primary" onclick=${revokeKycs}>Revoke selected</button>
</div>
</div>
${filter === "approved" && renderedKycRequests?.length ? html`
<p>Select KYC verification to revoke</p>
`: ''}
<ul id="kyc_requests_list" class="flex flex-direction-column gap-0-5" onchange=${handleAddressSelection}>
${renderedKycRequests?.length ? renderedKycRequests : html`<li class="text-center" style="padding: 3rem;">No requests found</li>`}
</ul>
</section>
</div>
<button id="commit_approvals" class="fab button button--primary" data-count="0" onclick=${initApproval}>Commit approvals</button>
</article>
`);
if (lastPage !== page)
checkBalance();
} else if (floGlobals.isAdmin) {
const renderedSubAdmins = floGlobals.subAdmins.map(address => render.approvedAggregatorCard(address));
renderElem(getRef('app_body'), html`
<article id="home_page">
${mainHeader}
<section id="verifiers_section" class="grid gap-1">
<div class="flex align-center space-between gap-1 flex-wrap">
<h3>Approved KYC verifiers</h3>
<div class="multi-state-button">
<button id="revoke_verifier_button" class="hidden button button--colored button--small" onclick=${revokeVerifiers}>Revoke selected</button>
</div>
</div>
<ul id="approved_verifiers_list" onchange=${handleVerifierSelection}>
${renderedSubAdmins.length ? renderedSubAdmins : html`<li style="padding: 1rem 0;">No KYC verifiers found</li>`}
</ul>
<div class="multi-state-button margin-right-auto">
<button id="add_sub_admin_button" class="button button--small button--colored" onclick=${() => openPopup('approve_verifier_popup')}>
Approve KYC verifiers
</button>
</div>
</section>
</article>
`);
} else {
// user KYC home page
const selectedCountry = getRef('country_selector')?.value;
const { renderedRequests, concurrentRequests, isVerified } = render.userRequests()
const fileUploadSection = html`
<section class="flex flex-direction-column gap-1">
<h3 class="text-center" style="margin-bottom: 1rem">KYC verification</h3>
<div class="grid gap-1">
<div>Select country</div>
<sm-select id="country_selector" onchange=${() => renderHome()}>
<sm-option value="el-salvador">El Salvador</sm-option>
<sm-option value="india">India</sm-option>
</sm-select>
</div>
${render.countrySpecificForm(selectedCountry)}
</section>
`;
const kycCompleteSection = html`
<section class="flex flex-direction-column gap-1 card">
<div id="upload_icon" style="font-size: 3rem; margin: auto;">🎉</div>
<h2 class="text-center">Your KYC is verified!</h2>
</section>
`;
const tooManyRequestsSection = html`
<section class="flex flex-direction-column gap-1 card justify-items-center">
<h2 class="text-center">Your KYC request is being processed.</h2>
<p class="text-center">You can close this window and check back later.</p>
</section>
`;
renderElem(getRef('app_body'), html`
<article id="home_page">
${mainHeader}
${floGlobals.subAdmins.length ? html`
${isVerified ? html`${kycCompleteSection}` : html`${concurrentRequests < 1 ? fileUploadSection : tooManyRequestsSection}`}
${renderedRequests.length ? html`
<section class="grid gap-1">
<h4>KYC request</h4>
<ul id="verification_list" class="grid gap-0-5">${renderedRequests}</ul>
</section>
`: ''}
` : html`
<section class="flex flex-direction-column gap-1 card justify-items-center">
<h2 class="text-center">No KYC verifiers found</h2>
<p class="text-center">No KYC verifiers are available at the moment. Please try again later.</p>
</section>
`}
</article>
`);
}
if (userAddressTimeInterval) clearInterval(userAddressTimeInterval);
userAddressTimeInterval = setInterval(() => {
if (!isShowingFloID) {
renderElem(getRef('user_popup_button'), html`
<svg class="icon margin-right-0-5" width="64" height="64" viewBox="0 0 64 64" fill="none" xmlns="http://www.w3.org/2000/svg"> <mask id="path-1-outside-1_16_6" maskUnits="userSpaceOnUse" x="3" y="3" width="58" height="58"> <rect fill="white" x="3" y="3" width="58" height="58" /> <path fill-rule="evenodd" clip-rule="evenodd" d="M31.946 43.6019C28.8545 47.1308 28.7789 51.9719 31.9811 55.1957C35.0078 52.2797 35.0105 46.8446 31.946 43.6019ZM31.9487 10.6835C24.6452 19.1291 24.9206 29.1137 31.9433 37.4108C39.0929 28.9436 39.1118 19.0076 31.9487 10.6808V10.6835ZM37.1111 35.051C43.1861 28.841 50.5976 27.4208 59 28.7654C56.2919 34.9754 52.4714 39.9353 45.7214 42.53C47.2118 41.3609 48.5699 40.4051 49.7984 39.3089C51.8504 37.481 53.303 35.267 54.0293 32.6075C54.2588 31.7678 53.9618 31.5302 53.1896 31.406C50.3627 30.9524 47.7086 31.5464 45.1733 32.702C40.9073 34.646 37.4324 37.6403 34.1735 40.8938C34.1168 40.9532 34.0925 41.0396 33.9899 41.2259C40.3754 41.4689 45.2381 44.0177 48.119 49.9064C44.3768 50.738 40.9532 50.5625 37.778 48.5213C40.1702 49.2557 42.557 49.7903 45.176 48.5483C44.852 48.0083 44.663 47.3765 44.231 47.0228C43.0511 46.0589 41.8415 45.0842 40.505 44.3498C38.4395 43.2212 36.131 42.692 33.5768 42.1682C37.0247 48.2081 36.1607 53.6918 31.946 59C29.9858 56.5295 28.6142 53.9456 28.2389 50.8946C27.8609 47.8328 28.7222 45.0518 30.1991 42.3896C26.9321 41.8658 19.8824 45.6485 18.7916 48.5645C21.3215 49.8443 23.7893 49.2611 26.33 48.3161C24.5048 50.1953 19.2425 50.9648 15.8108 49.8335C18.6593 44.0285 23.4977 41.4716 30.0263 41.2286C29.5457 40.7426 29.1893 40.3673 28.8167 40.0082C26.1005 37.3892 23.2142 34.9862 19.823 33.2366C17.0501 31.8056 14.1422 30.9092 10.9481 31.3871C10.5701 31.4438 10.1948 31.5356 9.6656 31.6436C10.6376 36.6386 13.9856 39.7355 18.1274 42.3464C13.775 41.8199 6.431 34.214 5 28.7546C13.397 27.3938 20.849 28.8842 26.897 35.2319C21.8939 24.089 24.5561 14.2259 31.946 5C39.2765 14.153 41.9657 23.9459 37.1111 35.051" /> </mask> <path fill-rule="evenodd" clip-rule="evenodd" d="M31.946 43.6019C28.8545 47.1308 28.7789 51.9719 31.9811 55.1957C35.0078 52.2797 35.0105 46.8446 31.946 43.6019ZM31.9487 10.6835C24.6452 19.1291 24.9206 29.1137 31.9433 37.4108C39.0929 28.9436 39.1118 19.0076 31.9487 10.6808V10.6835ZM37.1111 35.051C43.1861 28.841 50.5976 27.4208 59 28.7654C56.2919 34.9754 52.4714 39.9353 45.7214 42.53C47.2118 41.3609 48.5699 40.4051 49.7984 39.3089C51.8504 37.481 53.303 35.267 54.0293 32.6075C54.2588 31.7678 53.9618 31.5302 53.1896 31.406C50.3627 30.9524 47.7086 31.5464 45.1733 32.702C40.9073 34.646 37.4324 37.6403 34.1735 40.8938C34.1168 40.9532 34.0925 41.0396 33.9899 41.2259C40.3754 41.4689 45.2381 44.0177 48.119 49.9064C44.3768 50.738 40.9532 50.5625 37.778 48.5213C40.1702 49.2557 42.557 49.7903 45.176 48.5483C44.852 48.0083 44.663 47.3765 44.231 47.0228C43.0511 46.0589 41.8415 45.0842 40.505 44.3498C38.4395 43.2212 36.131 42.692 33.5768 42.1682C37.0247 48.2081 36.1607 53.6918 31.946 59C29.9858 56.5295 28.6142 53.9456 28.2389 50.8946C27.8609 47.8328 28.7222 45.0518 30.1991 42.3896C26.9321 41.8658 19.8824 45.6485 18.7916 48.5645C21.3215 49.8443 23.7893 49.2611 26.33 48.3161C24.5048 50.1953 19.2425 50.9648 15.8108 49.8335C18.6593 44.0285 23.4977 41.4716 30.0263 41.2286C29.5457 40.7426 29.1893 40.3673 28.8167 40.0082C26.1005 37.3892 23.2142 34.9862 19.823 33.2366C17.0501 31.8056 14.1422 30.9092 10.9481 31.3871C10.5701 31.4438 10.1948 31.5356 9.6656 31.6436C10.6376 36.6386 13.9856 39.7355 18.1274 42.3464C13.775 41.8199 6.431 34.214 5 28.7546C13.397 27.3938 20.849 28.8842 26.897 35.2319C21.8939 24.089 24.5561 14.2259 31.946 5C39.2765 14.153 41.9657 23.9459 37.1111 35.051" /> <path d="M31.946 43.6019L32.6728 42.915L31.918 42.1163L31.1938 42.943L31.946 43.6019ZM31.9811 55.1957L31.2716 55.9004L31.9657 56.5992L32.6749 55.9159L31.9811 55.1957ZM31.9487 10.6835L32.7051 11.3376L32.9487 11.0559V10.6835H31.9487ZM31.9433 37.4108L31.18 38.0569L31.9442 38.9597L32.7074 38.056L31.9433 37.4108ZM31.9487 10.6808L32.7068 10.0287L30.9487 7.98495V10.6808H31.9487ZM59 28.7654L59.9166 29.1651L60.4326 27.9819L59.158 27.778L59 28.7654ZM45.7214 42.53L45.1042 41.7432L46.0802 43.4634L45.7214 42.53ZM49.7984 39.3089L49.1332 38.5622L49.1326 38.5628L49.7984 39.3089ZM54.0293 32.6075L53.0647 32.3439L53.0646 32.3441L54.0293 32.6075ZM53.1896 31.406L53.3484 30.4187L53.348 30.4186L53.1896 31.406ZM45.1733 32.702L45.588 33.612L45.5881 33.6119L45.1733 32.702ZM34.1735 40.8938L33.467 40.1861L33.4585 40.1946L33.4501 40.2033L34.1735 40.8938ZM33.9899 41.2259L33.114 40.7435L32.3319 42.1635L33.9519 42.2252L33.9899 41.2259ZM48.119 49.9064L48.3359 50.8826L49.5751 50.6072L49.0173 49.4669L48.119 49.9064ZM37.778 48.5213L38.0715 47.5653L37.2372 49.3625L37.778 48.5213ZM45.176 48.5483L45.6045 49.4518L46.6008 48.9794L46.0335 48.0338L45.176 48.5483ZM44.231 47.0228L44.8645 46.2491L44.8637 46.2484L44.231 47.0228ZM40.505 44.3498L40.9866 43.4734L40.9845 43.4723L40.505 44.3498ZM33.5768 42.1682L33.7777 41.1886L31.6127 40.7446L32.7083 42.664L33.5768 42.1682ZM31.946 59L31.1626 59.6216L31.9457 60.6085L32.7292 59.6218L31.946 59ZM28.2389 50.8946L29.2314 50.7725L29.2314 50.7721L28.2389 50.8946ZM30.1991 42.3896L31.0736 42.8747L31.7652 41.6279L30.3574 41.4022L30.1991 42.3896ZM18.7916 48.5645L17.855 48.2141L17.5413 49.0527L18.3402 49.4568L18.7916 48.5645ZM26.33 48.3161L27.0473 49.0128L25.9814 47.3788L26.33 48.3161ZM15.8108 49.8335L14.9131 49.393L14.4073 50.4237L15.4977 50.7832L15.8108 49.8335ZM30.0263 41.2286L30.0635 42.2279L32.3372 42.1433L30.7373 40.5255L30.0263 41.2286ZM28.8167 40.0082L28.1226 40.7281L28.1228 40.7282L28.8167 40.0082ZM19.823 33.2366L19.3644 34.1252L19.3645 34.1253L19.823 33.2366ZM10.9481 31.3871L10.8001 30.3981L10.7998 30.3982L10.9481 31.3871ZM9.6656 31.6436L9.46564 30.6638L8.49474 30.8619L8.68401 31.8346L9.6656 31.6436ZM18.1274 42.3464L18.0073 43.3392L18.6607 41.5005L18.1274 42.3464ZM5 28.7546L4.84003 27.7675L3.75363 27.9435L4.03268 29.0082L5 28.7546ZM26.897 35.2319L26.173 35.9217L27.8093 34.8223L26.897 35.2319ZM31.946 5L32.7265 4.37488L31.9461 3.40036L31.1655 4.37483L31.946 5ZM31.1938 42.943C27.7974 46.8199 27.6566 52.261 31.2716 55.9004L32.6906 54.491C29.9012 51.6828 29.9116 47.4417 32.6982 44.2609L31.1938 42.943ZM32.6749 55.9159C36.1304 52.5867 36.081 46.5214 32.6728 42.915L31.2192 44.2888C33.94 47.1678 33.8852 51.9727 31.2873 54.4755L32.6749 55.9159ZM31.1923 10.0294C27.4048 14.4092 25.5379 19.2455 25.5737 24.1102C25.6095 28.971 27.5438 33.7608 31.18 38.0569L32.7066 36.7647C29.3201 32.7637 27.6054 28.4127 27.5736 24.0955C27.5419 19.7822 29.1891 15.4034 32.7051 11.3376L31.1923 10.0294ZM32.7074 38.056C36.4083 33.6729 38.31 28.8504 38.3133 23.9938C38.3165 19.1359 36.42 14.3451 32.7068 10.0287L31.1906 11.3329C34.6405 15.3433 36.3161 19.6839 36.3133 23.9925C36.3104 28.3024 34.6279 32.6815 31.1792 36.7656L32.7074 38.056ZM30.9487 10.6808V10.6835H32.9487V10.6808H30.9487ZM37.8259 35.7503C43.6131 29.8345 50.6632 28.444 58.842 29.7528L59.158 27.778C50.532 26.3976 42.7591 27.8475 36.3963 34.3517L37.8259 35.7503ZM58.0834 28.3657C55.4402 34.4268 51.7791 39.1301 45.3626 41.5966L46.0802 43.4634C53.1637 40.7405 57.1436 35.524 59.9166 29.1651L58.0834 28.3657ZM46.3386 43.3168C47.7733 42.1914 49.2057 41.178 50.4642 40.055L49.1326 38.5628C47.9341 39.6322 46.6503 40.5304 45.1042 41.7432L46.3386 43.3168ZM50.4636 40.0556C52.6466 38.111 54.2121 35.7338 54.994 32.871L53.0646 32.3441C52.3939 34.8002 51.0542 36.851 49.1332 38.5622L50.4636 40.0556ZM54.9939 32.8711C55.1262 32.3872 55.2248 31.6946 54.7698 31.1186C54.3643 30.6053 53.7257 30.4794 53.3484 30.4187L53.0308 32.3933C53.1086 32.4058 53.17 32.4181 53.2184 32.43C53.2671 32.442 53.2955 32.4518 53.3091 32.4572C53.3227 32.4626 53.3139 32.4606 53.2926 32.4461C53.2699 32.4307 53.2353 32.4025 53.2004 32.3583C53.1832 32.3366 53.1677 32.3132 53.1543 32.2886C53.1409 32.264 53.1307 32.2402 53.1231 32.2182C53.1079 32.1742 53.1053 32.144 53.1049 32.1366C53.1046 32.1302 53.1059 32.1427 53.1007 32.1797C53.0955 32.2165 53.0849 32.27 53.0647 32.3439L54.9939 32.8711ZM53.348 30.4186C50.274 29.9254 47.4176 30.5801 44.7585 31.7921L45.5881 33.6119C47.9996 32.5127 50.4514 31.9794 53.0312 32.3934L53.348 30.4186ZM44.7586 31.792C40.3293 33.8104 36.7535 36.9051 33.467 40.1861L34.88 41.6015C38.1113 38.3755 41.4853 35.4816 45.588 33.612L44.7586 31.792ZM33.4501 40.2033C33.3063 40.354 33.2291 40.5156 33.2033 40.5674C33.1672 40.64 33.1517 40.6749 33.114 40.7435L34.8658 41.7083C34.9307 41.5906 34.9786 41.4891 34.9945 41.4572C35.0049 41.4363 35.0004 41.4467 34.9882 41.4667C34.9731 41.4914 34.9435 41.5355 34.8969 41.5843L33.4501 40.2033ZM33.9519 42.2252C37.0233 42.3421 39.6629 43.0109 41.8597 44.3098C44.0485 45.6039 45.857 47.5582 47.2207 50.3459L49.0173 49.4669C47.5001 46.3659 45.4368 44.1014 42.8776 42.5882C40.3265 41.0798 37.342 40.3527 34.0279 40.2266L33.9519 42.2252ZM47.9021 48.9302C44.3241 49.7253 41.1983 49.5313 38.3188 47.6801L37.2372 49.3625C40.7081 51.5937 44.4295 51.7507 48.3359 50.8826L47.9021 48.9302ZM37.4845 49.4773C39.9089 50.2215 42.6205 50.8669 45.6045 49.4518L44.7475 47.6448C42.4935 48.7137 40.4315 48.2899 38.0715 47.5653L37.4845 49.4773ZM46.0335 48.0338C45.8849 47.7862 45.8212 47.6158 45.6292 47.2504C45.4736 46.9544 45.2423 46.5584 44.8645 46.2491L43.5975 47.7965C43.6517 47.8409 43.7309 47.9377 43.8588 48.181C43.9503 48.3549 44.1431 48.7704 44.3185 49.0628L46.0335 48.0338ZM44.8637 46.2484C43.6913 45.2906 42.4149 44.2582 40.9866 43.4734L40.0234 45.2262C41.2681 45.9102 42.4109 46.8272 43.5983 47.7972L44.8637 46.2484ZM40.9845 43.4723C38.7711 42.2628 36.3236 41.7107 33.7777 41.1886L33.3759 43.1478C35.9384 43.6733 38.1079 44.1796 40.0255 45.2273L40.9845 43.4723ZM32.7083 42.664C34.346 45.5328 34.9255 48.203 34.6411 50.7474C34.3555 53.3015 33.1882 55.8274 31.1628 58.3782L32.7292 59.6218C34.9185 56.8644 36.2905 53.9944 36.6287 50.9696C36.9679 47.9351 36.2555 44.8435 34.4453 41.6724L32.7083 42.664ZM32.7294 58.3784C30.8397 55.9968 29.577 53.5818 29.2314 50.7725L27.2464 51.0167C27.6514 54.3094 29.1319 57.0622 31.1626 59.6216L32.7294 58.3784ZM29.2314 50.7721C28.8877 47.9881 29.6602 45.4224 31.0736 42.8747L29.3247 41.9045C27.7842 44.6812 26.8341 47.6775 27.2464 51.0171L29.2314 50.7721ZM30.3574 41.4022C29.3303 41.2375 28.1125 41.4187 26.9159 41.7622C25.6987 42.1117 24.4105 42.6564 23.2045 43.307C21.999 43.9574 20.8488 44.728 19.9166 45.543C19.005 46.3399 18.2137 47.2553 17.855 48.2141L19.7282 48.9149C19.9149 48.4157 20.4139 47.7647 21.233 47.0487C22.0314 46.3507 23.0524 45.6616 24.1541 45.0672C25.2552 44.4732 26.4102 43.9882 27.4678 43.6846C28.5458 43.3751 29.4344 43.2798 30.0408 43.377L30.3574 41.4022ZM18.3402 49.4568C21.2702 50.939 24.0958 50.214 26.6786 49.2534L25.9814 47.3788C23.4828 48.3082 21.3728 48.7496 19.243 47.6722L18.3402 49.4568ZM25.6127 47.6194C24.9334 48.3187 23.4333 48.9382 21.5294 49.2141C19.6667 49.484 17.6562 49.3889 16.1239 48.8838L15.4977 50.7832C17.3971 51.4094 19.7336 51.4952 21.8162 51.1934C23.8578 50.8976 25.9014 50.1927 27.0473 49.0128L25.6127 47.6194ZM16.7085 50.274C18.0554 47.5292 19.8486 45.5942 22.044 44.3081C24.2482 43.0169 26.918 42.345 30.0635 42.2279L29.9891 40.2293C26.606 40.3552 23.5923 41.0832 21.0331 42.5824C18.4649 44.0869 16.4147 46.3328 14.9131 49.393L16.7085 50.274ZM30.7373 40.5255C30.2757 40.0586 29.8942 39.6578 29.5106 39.2882L28.1228 40.7282C28.4844 41.0768 28.8157 41.4266 29.3153 41.9317L30.7373 40.5255ZM29.5108 39.2883C26.7637 36.6396 23.7967 34.1615 20.2815 32.3479L19.3645 34.1253C22.6317 35.8109 25.4373 38.1388 28.1226 40.7281L29.5108 39.2883ZM20.2816 32.348C17.4111 30.8666 14.2829 29.877 10.8001 30.3981L11.0961 32.3761C14.0015 31.9414 16.6891 32.7446 19.3644 34.1252L20.2816 32.348ZM10.7998 30.3982C10.388 30.4599 9.94468 30.566 9.46564 30.6638L9.86556 32.6234C10.4449 32.5052 10.7522 32.4277 11.0964 32.376L10.7998 30.3982ZM8.68401 31.8346C9.73479 37.2345 13.3673 40.5279 17.5941 43.1923L18.6607 41.5005C14.6039 38.9431 11.5404 36.0427 10.6472 31.4526L8.68401 31.8346ZM18.2475 41.3536C17.3819 41.2489 16.2594 40.7693 14.9918 39.9335C13.742 39.1093 12.427 37.9891 11.1875 36.7057C8.68437 34.1137 6.62095 30.9947 5.96732 28.5011L4.03268 29.0082C4.81005 31.9739 7.13413 35.3875 9.74885 38.095C11.0683 39.4613 12.4947 40.6825 13.8908 41.6031C15.2691 42.512 16.6967 43.1806 18.0073 43.3392L18.2475 41.3536ZM5.15997 29.7417C13.3246 28.4186 20.4108 29.874 26.173 35.9217L27.621 34.5421C21.2872 27.8944 13.4694 26.369 4.84003 27.7675L5.15997 29.7417ZM27.8093 34.8223C25.3851 29.4232 24.8341 24.3801 25.7561 19.5859C26.6809 14.7778 29.1009 10.1516 32.7265 5.62517L31.1655 4.37483C27.4012 9.07433 24.7952 13.9927 23.7921 19.2082C22.7863 24.4378 23.4058 29.8977 25.9847 35.6415L27.8093 34.8223ZM31.1655 5.62512C34.7619 10.1157 37.1747 14.7077 38.1168 19.4869C39.0562 24.2523 38.5469 29.2701 36.1948 34.6504L38.0274 35.4515C40.5299 29.7268 41.1033 24.2956 40.0791 19.1001C39.0576 13.9183 36.4606 9.03731 32.7265 4.37488L31.1655 5.62512Z" mask="url(#path-1-outside-1_16_6)" /> </svg>
<div class="overflow-ellipsis">${floGlobals.myFloID}</div>
`)
isShowingFloID = true
} else {
renderElem(getRef('user_popup_button'), html`
<svg class="icon margin-right-0-5" 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="M17.06,11.57C17.65,10.88,18,9.98,18,9c0-1.86-1.27-3.43-3-3.87L15,3h-2v2h-2V3H9v2H6v2h2v10H6v2h3v2h2v-2h2v2h2v-2 c2.21,0,4-1.79,4-4C19,13.55,18.22,12.27,17.06,11.57z M10,7h4c1.1,0,2,0.9,2,2s-0.9,2-2,2h-4V7z M15,17h-5v-4h5c1.1,0,2,0.9,2,2 S16.1,17,15,17z"/></g></svg>
<div class="overflow-ellipsis">${floGlobals.myBtcID}</div>
`)
isShowingFloID = false
}
}, 1000 * 60);
}
router.addRoute('', renderHome)
router.addRoute('home', renderHome)
router.addRoute('404', async () => {
renderElem(getRef('app_body'), html`
<article class="flex flex-direction-column align-center justify-center gap-1">
<h1>404</h1>
<h4>Page not found</h4>
</article>
`);
})
</script>
<script>
// subAdmin functions
function handleRequestFilter(e) {
const filter = e.target.value;
location.hash = `#/home?filter=${filter}`
}
function handleRequestSearch(e) {
const filter = getRef('kyc_request_filter').value;
const searchKey = e.target.value.toLowerCase()
router.routeTo(`#/home?filter=${filter}&search=${searchKey}`)
}
async function viewFile(e) {
const button = e.target;
const { requestVC, docVC } = button.dataset;
const { senderID, message: { docType }, tag } = floDapps.getNextGeneralData('userKycRequests', '0')[requestVC]
const floAddress = getFloAddress(senderID);
floGlobals.currentRequest = {
requestVC,
docVC,
senderID: floAddress,
docType,
};
try {
let objectURL
renderElem(getRef('view_file_popup__content'), html`
<div class="grid gap-1 justify-items-center text-center">
<sm-spinner></sm-spinner>
<h4>Loading ${senderID} ${docTypeNames[docType]}</h4>
</div>
`)
openPopup('view_file_popup').closed.then(() => {
URL.revokeObjectURL(objectURL);
renderElem(getRef('view_file_popup__content'), html``);
floGlobals.currentRequest = null;
})
const { file } = await floCloudAPI.downloadFile(docVC, {
decrypt: await floDapps.user.private,
});
const blob = new Blob([file], { type: file.type });
objectURL = URL.createObjectURL(blob);
const details = html`
<div class="flex gap-1 space-between flex-wrap align-center">
<h4>${senderID} (${docTypeNames[docType]})</h4>
${tag ? '' : html`
<div class="flex gap-0-5 margin-left-auto">
<div class="multi-state-button">
<button class="button button--danger" onclick=${rejectKyc}>Reject</button>
</div>
<div class="multi-state-button">
<button class="button button--primary" onclick=${approveKyc}>Approve</button>
</div>
</div>
`}
</div>
`
if (file.type.includes('image')) {
renderElem(getRef('view_file_popup__content'), html`
${details}
<img src=${objectURL} alt=${`${senderID} ${docTypeNames[docType]}`}>
`)
} else {
renderElem(getRef('view_file_popup__content'), html`
${details}
<object data=${objectURL} type="application/pdf" width="100%" height="600px">
<p>Sorry, your browser doesn't support PDF viewing. You can download the file <a href=${objectURL} download=${`${senderID}-${docType}`}>here</a>.</p>
</object>
`)
}
} catch (err) {
console.error(err)
notify('Error viewing file', 'error');
}
}
async function downloadFile(e) {
const button = e.target.closest('button'); button
const { requestVC, docVC } = button.closest('li').dataset;
const { senderID, message: { docType } } = floDapps.getNextGeneralData('userKycRequests', '0')[requestVC]
try {
buttonLoader(button, true)
const { file } = await floCloudAPI.downloadFile(docVC);
const blob = new Blob([file], { type: file.type });
const url = URL.createObjectURL(blob);
const a = document.createElement('a');
a.href = url;
a.download = `${senderID}-${docType}`;
a.click();
URL.revokeObjectURL(url);
} catch (err) {
console.error(err)
notify('Error downloading file', 'error');
} finally {
buttonLoader(button, false)
}
}
floGlobals.approvalsToBeCommitted = new Map();
async function approveKyc(e) {
const button = e.target.closest('button');
const { requestVC, docVC, senderID } = floGlobals.currentRequest;
floGlobals.approvalsToBeCommitted.set(senderID, {
requestVC,
docVC,
})
getRef('commit_approvals').dataset.count = floGlobals.approvalsToBeCommitted.size
closePopup()
floGlobals.currentRequest = null;
renderHome()
}
async function rejectKyc(e) {
const confirmation = await getConfirmation('Are you sure you want to reject this KYC?', {
confirmText: 'Reject',
});
if (!confirmation) return;
const button = e.target.closest('button');
buttonLoader(button, true)
const { requestVC, docVC } = floGlobals.currentRequest;
try {
await floCloudAPI.noteApplicationData(requestVC, 'rejected')
floGlobals.generalData[floCloudAPI.util.filterKey('userKycRequests')][requestVC].note = 'rejected'
notify('KYC rejected successfully', 'success');
closePopup()
renderHome()
} catch (err) {
console.error(err)
notify('Error rejecting KYC', 'error');
} finally {
buttonLoader(button, false)
}
}
const addressesToRevoke = new Map()
function handleAddressSelection(e) {
if (e.target.checked) {
addressesToRevoke.set(e.target.value, {
requestVC: e.target.dataset.requestVC,
docVC: e.target.dataset.docVC,
})
const floData = `KYC|REVOKE_KYC|${[...addressesToRevoke.keys()].join(',')}`
if (floData.length > 1040) {
return notify('Maximum limit reached for this batch. Revoke selected and continue the process.', 'error')
}
} else {
addressesToRevoke.delete(e.target.value)
}
if (addressesToRevoke.size) {
getRef('selected_addresses').textContent = `${addressesToRevoke.size} selected`
getRef('selected_wrapper').classList.remove('hidden')
getRef('kyc_requests_header').classList.add('hidden')
} else {
getRef('selected_addresses').textContent = ``
getRef('selected_wrapper').classList.add('hidden')
getRef('kyc_requests_header').classList.remove('hidden')
}
}
function clearSelection() {
addressesToRevoke.clear()
getRef('selected_addresses').textContent = ``
getRef('selected_wrapper').classList.add('hidden')
getRef('kyc_requests_list').querySelectorAll('input').forEach(input => input.checked = false)
}
function checkBalance() {
renderElem(getRef('verifier_balance_container'), html`
<h4>FLO balance</h4>
<div class="flex align-center gap-1">
<sm-spinner></sm-spinner>
<span>Checking balance...</span>
</div>
`)
floBlockchainAPI.getBalance(floGlobals.myFloID).then(balance => {
if (balance < 0.01) {
renderElem(getRef('verifier_balance_container'), html`
<div class="flex align-center space-between gap-1">
<h4>FLO balance</h4>
<button class="button button--colored button--small" onclick=${checkBalance}>Refresh</button>
</div>
<h2 style="color: var(--danger-color)">Insufficient balance</h2>
`)
} else {
renderElem(getRef('verifier_balance_container'), html`
<div class="flex align-center space-between gap-1">
<h4>FLO balance</h4>
<button class="button button--colored button--small" onclick=${checkBalance}>Refresh</button>
</div>
<h2>${balance} FLO</h2>
`)
}
}).catch(err => {
console.error(err)
renderElem(getRef('verifier_balance_container'), html`
<div class="flex align-center space-between gap-1">
<h4>FLO balance</h4>
<button class="button button--colored button--small" onclick=${checkBalance}>Refresh</button>
</div>
<h2 style="color: var(--danger-color)">Error fetching balance</h2>
`)
})
}
function initApproval() {
const approvedAddress = [...floGlobals.approvalsToBeCommitted.keys()].map(address => {
function removeKYC(e) {
floGlobals.approvalsToBeCommitted.delete(address)
getRef('commit_approvals').dataset.count = floGlobals.approvalsToBeCommitted.size
renderHome()
e.target.closest('li').remove()
if (floGlobals.approvalsToBeCommitted.size === 0) {
closePopup()
}
}
return html`
<li class="kyc-to-commit grid gap-1">
<div>
<p>BTC address</p>
<b class="wrap-around">${getBtcAddress(address)}</b>
</div>
<div>
<p>FLO address</p>
<b class="wrap-around">${address}</b>
</div>
<button class="button button--danger" onclick=${removeKYC}> Remove</button>
</li>
`
})
renderElem(getRef('commit_approvals_popup__content'), html`
<div class="flex gap-1 align-center space-between">
<h4>KYCs to commit</h4>
<div class="multi-state-button">
<button id="approve_kyc_button" class="button button--primary" onclick=${commitApprovals}>Commit</button>
</div>
</div>
<ul class="grid gap-1-5">
${approvedAddress}
</ul>
`)
openPopup('commit_approvals_popup').closed.then(() => {
renderElem(getRef('commit_approvals_popup__content'), html``)
})
}
async function commitApprovals() {
const approverPrivateKey = await floDapps.user.private
if (!floGlobals.isSubAdmin) {
return notify('You are not authorized to approve KYC', 'error')
}
if (floGlobals.approvalsToBeCommitted.size === 0) {
return notify('Enter at least one address to approve', 'error')
}
const confirmation = await getConfirmation('Approve all listed KYCs?', {
confirmText: 'Approve',
})
if (!confirmation) return
const addresses = [...floGlobals.approvalsToBeCommitted.keys()]
// create multiple txs if addresses exceed 1040 characters
const addressesPerTx = 30
const chunks = Math.ceil(addresses.length / addressesPerTx)
let txPromises = []
for (let i = 0; i < chunks; i++) {
const chunk = addresses.slice(i * addressesPerTx, (i + 1) * addressesPerTx)
const floData = `KYC|APPROVE_KYC|${chunk.join('+')}`
txPromises.push(floBlockchainAPI.writeData(floGlobals.myFloID, floData, approverPrivateKey, floGlobals.myFloID))
}
buttonLoader(getRef('approve_kyc_button'), true)
try {
const txIds = await Promise.all(txPromises)
const cloudPromises = [...floGlobals.approvalsToBeCommitted.values()].flatMap(({ requestVC, docVC }) => {
floGlobals.generalData[floCloudAPI.util.filterKey('userKycRequests')][requestVC].tag = `approved|${txIds.join('+')}`
return [
floCloudAPI.tagApplicationData(requestVC, `approved|${txIds.join('+')}`),
floCloudAPI.tagApplicationData(docVC, `approved|${txIds.join('+')}`)
]
})
await Promise.all(cloudPromises)
console.log(`Approval request submitted. TXIDs: ${txIds.join(', ')}`)
notify('Users approved successfully', 'success');
floGlobals.approvalsToBeCommitted.clear()
getRef('commit_approvals').dataset.count = floGlobals.approvalsToBeCommitted.size
renderHome()
closePopup()
} catch (err) {
console.error(err)
notify('Error approving users', 'error');
} finally {
buttonLoader(getRef('approve_kyc_button'), false)
setTimeout(() => {
checkBalance()
}, 1000)
}
}
async function revokeKycs() {
try {
const approverPrivateKey = await floDapps.user.private
if (!floGlobals.isSubAdmin) {
return notify('You are not authorized to revoke KYC', 'error')
}
if (addressesToRevoke.size === 0) {
return notify('Select at least one address to revoke', 'error')
}
let floData = `KYC|REVOKE_KYC|${[...addressesToRevoke.keys()].join('+')}`
console.log(floData)
if (floData.length > 1040) {
return notify('Too many addresses selected. Try removing one.', 'error')
}
const confirmation = await getConfirmation('Revoke selected addresses?', {
confirmText: 'Revoke',
})
if (!confirmation) return
buttonLoader(getRef('revoke_kyc_button'), true)
const txId = await floBlockchainAPI.writeData(floGlobals.myFloID, floData, approverPrivateKey, floGlobals.myFloID)
const cloudPromises = [...addressesToRevoke.values()].flatMap(({ requestVC, docVC }) => {
floGlobals.generalData[floCloudAPI.util.filterKey('userKycRequests')][requestVC].tag = null
floGlobals.generalData[floCloudAPI.util.filterKey('userKycRequests')][requestVC].note = 'revoked'
return [
floCloudAPI.tagApplicationData(requestVC, null),
floCloudAPI.noteApplicationData(requestVC, 'revoked'),
floCloudAPI.tagApplicationData(docVC, null)
]
})
const cloudResponses = await Promise.all(cloudPromises)
notify(`Revoke request submitted. TXID: ${txId}`, 'success');
addressesToRevoke.clear()
clearSelection()
} catch (e) {
notify('Error revoking users. If you have just approved or revoked KYCs wait for 5 mins.', 'error');
console.error(e)
} finally {
buttonLoader(getRef('revoke_kyc_button'), false)
setTimeout(() => {
checkBalance()
}, 1000)
getRef('selected_addresses').textContent = ``
getRef('selected_wrapper').classList.add('hidden')
getRef('kyc_requests_header').classList.remove('hidden')
renderHome()
}
}
function setApproverName() {
console.log('setApproverName')
const approverName = getRef('approver_name_input').value.trim()
if (approverName === '') {
notify('Please enter a name', 'error')
return
}
if (approverName.length > 48) {
notify('Keep the name shorter than 48 characters', 'error')
return
}
if (!floGlobals.appObjects.kycDocs.issuers[floGlobals.myFloID].name) {
floGlobals.appObjects.kycDocs.issuers[floGlobals.myFloID].name = approverName
buttonLoader(getRef('set_approver_name__button'), true)
floCloudAPI.updateObjectData('kycDocs').then(() => {
notify('Name updated successfully', 'success')
closePopup()
renderElem(getRef('agency_name_container'), html`
<h5>Agency name</h5>
<h3 id="agency_name">${approverName}</h3>
<button class="button button--colored justify-self-start button--small"
onclick=${() => openPopup('set_approver_name_popup')}>Change</button>
`)
}).catch(err => {
console.error(err)
notify('Error updating name', 'error')
}).finally(() => {
buttonLoader(getRef('set_approver_name__button'), false)
})
}
}
function showProgress() {
const duration = 1000 * 60; // Duration of the progress animation in milliseconds
const animation = getRef('progress_bar').children[0].animate([{
width: '0%'
}, {
width: '100%'
}], {
duration,
easing: 'ease-out',
fill: 'forwards'
})
return function () {
animation.updatePlaybackRate(100)
return new Promise(resolve => {
animation.onfinish = () => {
resolve()
}
})
}
}
// show warning when leaving the page with pending approvals
window.addEventListener('beforeunload', function (e) {
if (floGlobals.approvalsToBeCommitted.size === 0) return
// Cancel the event
e.preventDefault();
// Chrome requires returnValue to be set
e.returnValue = 'You need to commit the approvals before leaving the page.';
}, { capture: true });
async function clearCredentials() {
await floDapps.clearCredentials();
location.reload();
}
// admin functions
function addVerifier() {
getRef('verifiers_container').append(html.node`
<li class="flex align-center gap-1">
<sm-input class="w-100" placeholder="FLO/BTC address"
error-text="Invalid address" data-address></sm-input>
<button class="button icon-only" onclick=${(e) => { e.target.closest('li').remove() }}>
<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 d="M16 9v10H8V9h8m-1.5-6h-5l-1 1H5v2h14V4h-3.5l-1-1zM18 7H6v12c0 1.1.9 2 2 2h8c1.1 0 2-.9 2-2V7z"/></svg>
</button>
</li>
`)
getRef('verifiers_container').lastElementChild.querySelector('sm-input').customValidation = floCrypto.validateAddr
getRef('verifiers_container').lastElementChild.querySelector('sm-input').focusIn()
}
async function approveVerifiers() {
let addresses = [...getRef('verifiers_container')
.querySelectorAll('sm-input')]
.map(input => input.value.trim())
.filter(address => address !== '' && !floGlobals.subAdmins.includes(address));
addresses = [...new Set(addresses)]
const confirmation = await getConfirmation(`Approve ${addresses.join(', ')} as KYC verifiers?`, {
confirmText: 'Approve',
});
if (!confirmation) return;
buttonLoader(getRef('approve_verifier_button'), true)
try {
const adminPrivateKey = await floDapps.user.private
// const floData = `KYC|APPROVE_AGGREGATOR|${addresses.join('+')}`
// if (floData.length > 1040) {
// return notify('Too many addresses added. Try removing one.', 'error')
// }
// const [txId] = await Promise.all([
// floBlockchainAPI.writeData(floGlobals.myFloID, floData, adminPrivateKey, floGlobals.myFloID),
// floDapps.manageAppConfig(adminPrivateKey, addresses)
// ])
await floDapps.manageAppConfig(adminPrivateKey, addresses)
notify(`Verifiers approval request submitted. May take upto 30 mins to complete.`, 'success');
floGlobals.subAdmins = [...new Set([...floGlobals.subAdmins, ...addresses])]
closePopup()
renderHome()
} catch (err) {
console.error(err)
notify('Error approving verifiers', 'error');
} finally {
buttonLoader(getRef('approve_verifier_button'), false)
}
}
function handleVerifierSelection(e) {
const count = [...getRef('approved_verifiers_list').querySelectorAll('input')].reduce((acc, input) => {
if (input.checked) acc++
return acc
}, 0)
if (count) {
getRef('revoke_verifier_button').classList.remove('hidden')
getRef('revoke_verifier_button').dataset.count = count
} else {
getRef('revoke_verifier_button').classList.add('hidden')
}
}
async function revokeVerifiers() {
const confirmation = await getConfirmation(`Revoke selected verifiers?`, {
confirmText: 'Revoke',
});
if (!confirmation) return;
const addresses = [...getRef('approved_verifiers_list')
.querySelectorAll('input:checked')]
.map(input => input.value.trim())
buttonLoader(getRef('revoke_verifier_button'), true)
try {
const adminPrivateKey = await floDapps.user.private
const floData = `KYC|REVOKE_AGGREGATOR|${addresses.join('+')}`
if (floData.length > 1040) {
return notify('Too many addresses selected. Try removing one.', 'error')
}
const [txId] = await Promise.all([
floBlockchainAPI.writeData(floGlobals.myFloID, floData, adminPrivateKey, floGlobals.myFloID),
floDapps.manageAppConfig(adminPrivateKey, undefined, addresses)
])
notify(`Verifiers revoke request submitted. TXID: ${txId}`, 'success');
floGlobals.subAdmins = floGlobals.subAdmins.filter(address => !addresses.includes(address))
closePopup()
renderHome()
} catch (err) {
console.error(err)
notify('Error revoking verifiers', 'error');
} finally {
buttonLoader(getRef('revoke_verifier_button'), false)
}
}
</script>
<script id="onLoadStartUp">
router.routeTo('loading')
async function onLoadStartUp() {
if (window.quick) return;
floDapps.setMidStartup(() =>
new Promise((resolve, reject) => {
floCloudAPI.requestObjectData('kycDocs').then(() => {
if (['#/landing', '#/sign_in', '#/sign_up', '#/kyc_status'].some(route => window.location.hash.includes(route))) {
router.routeTo(window.location.hash);
}
resolve()
}).catch(err => {
console.error(err)
notify('Error loading KYC documents', 'error')
reject()
})
})
)
floDapps.setCustomPrivKeyInput(getSignedIn)
const [browserName, browserVersion] = detectBrowser().split(' ');
const supportedVersions = {
Chrome: 85,
Firefox: 75,
Safari: 13,
}
if (browserName in supportedVersions) {
if (parseInt(browserVersion) < supportedVersions[browserName]) {
notify(`${browserName} ${browserVersion} is not fully supported, some features may not work properly. Please update to ${supportedVersions[browserName]} or higher.`, 'error')
}
} else {
notify('Browser is not fully compatible, some features may not work. for best experience please use Chrome, Edge, Firefox or Safari', 'error')
}
document.body.classList.remove('hidden')
document.addEventListener('keyup', (e) => {
if (e.key === 'Escape') {
closePopup()
}
})
document.addEventListener('copy', () => {
notify('copied', 'success')
})
document.addEventListener("pointerdown", (e) => {
if (e.target.closest("button:not([disabled]), sm-button:not([disabled]), .interact")) {
createRipple(e, e.target.closest("button, sm-button, .interact"));
}
});
document.querySelectorAll('.popup__header__close, .close-popup-on-click').forEach(elem => {
elem.addEventListener('click', () => {
closePopup()
})
})
floDapps.launchStartUp().then(async result => {
console.log(result)
//App functions....
floGlobals.myFloID = getFloAddress(floDapps.user.id);
floGlobals.myBtcID = getBtcAddress(floGlobals.myFloID)
floGlobals.isSubAdmin = floGlobals.subAdmins.includes(floGlobals.myFloID)
floGlobals.isAdmin = floGlobals.myFloID === floGlobals.adminID
try {
if (floGlobals.isSubAdmin) {
const promises = []
// initialize kycDocs app data structure
if (!floGlobals.appObjects.kycDocs) {
console.log('kycDocs not found, resetting')
floGlobals.appObjects.kycDocs = {
issuers: {},
}
promises.push(floCloudAPI.resetObjectData('kycDocs'))
}
promises.push(floCloudAPI.requestGeneralData('userKycRequests'), {
receiverID: floGlobals.myFloID,
})
await Promise.all(promises)
// add subadmin public key to kycDocs if not present
if (!floGlobals.appObjects.kycDocs.issuers[floGlobals.myFloID]) {
floGlobals.appObjects.kycDocs.issuers[floGlobals.myFloID] = {
pubKey: floDapps.user.public,
}
floCloudAPI.updateObjectData('kycDocs').then(() => {
console.log('Added subadmin public key to kycDocs')
}).catch(err => {
console.error(err)
notify('Error adding subadmin public key to kycDocs', 'error')
})
}
if (!floGlobals.appObjects.kycDocs.issuers[floGlobals.myFloID].name) {
openPopup('set_approver_name_popup')
renderElem(getRef('agency_name_container'), html`
<h5>Agency name</h5>
<h3 id="agency_name">Name not set</h3>
<button class="button button--colored justify-self-start button--small"
onclick="openPopup('set_approver_name_popup')">Set</button>
`)
} else {
renderElem(getRef('agency_name_container'), html`
<h5>Agency name</h5>
<h3 id="agency_name">${floGlobals.appObjects.kycDocs.issuers[floGlobals.myFloID].name}</h3>
<button class="button button--colored justify-self-start button--small"
onclick=${() => openPopup('set_approver_name_popup')}>Change</button>
`)
}
} else if (floGlobals.isAdmin) {
} else[
// fetch user's kyc requests
await floCloudAPI.requestGeneralData('userKycRequests', {
senderID: [floGlobals.myFloID, floGlobals.myBtcID],
})
]
if (['#/landing', '#/sign_in', '#/sign_up'].includes(window.location.hash)) {
history.replaceState(null, null, '#/home')
router.routeTo('home')
} else {
router.routeTo(window.location.hash)
}
} catch (err) {
console.error(err)
notify('Error loading KYC documents', 'error')
}
}).catch(error => console.error(error))
}
</script>
</body>
</html>