Removed aggregator address field

This commit is contained in:
sairaj mote 2023-03-28 23:25:49 +05:30
parent fb92bf3449
commit 1a1a3f1b8e

View File

@ -60,14 +60,12 @@
<sm-chip value="revoke">Revoke</sm-chip> <sm-chip value="revoke">Revoke</sm-chip>
</sm-chips> </sm-chips>
</div> </div>
<sm-form> <sm-form id="kyc_form">
<div class="grid gap-0-5"> <div class="grid gap-0-5">
<h4>Aggregator credentials</h4> <h4>Aggregator credentials</h4>
<sm-input id="aggregator_address" placeholder="FLO/BTC address" error-text="Invalid address"
required animate></sm-input>
<p id="aggregator_balance" class="hidden margin-bottom-0-5"></p>
<sm-input id="aggregator_private_key" placeholder="Private key" error-text="Invalid private key" <sm-input id="aggregator_private_key" placeholder="Private key" error-text="Invalid private key"
type="password" required animate></sm-input> type="password" required animate></sm-input>
<p id="aggregator_balance" class="hidden"></p>
</div> </div>
<div class="grid gap-0-5"> <div class="grid gap-0-5">
<h4 id="address_manage_title">KYCs to be approved</h4> <h4 id="address_manage_title">KYCs to be approved</h4>
@ -169,13 +167,13 @@
getRef('submit_kyc').textContent = 'Revoke' getRef('submit_kyc').textContent = 'Revoke'
} }
}) })
getRef('aggregator_address').addEventListener('input', e => { getRef('aggregator_private_key').addEventListener('input', e => {
checkBalance(floCrypto.toFloID(e.target.value.trim())) checkBalance(floCrypto.getAddress(e.target.value.trim()))
}) })
function checkBalance(address) { function checkBalance(address) {
if (!address) if (!address)
address = floCrypto.toFloID(getRef('aggregator_address').value.trim()) address = floCrypto.getAddress(getRef('aggregator_private_key').value.trim())
if (getRef('aggregator_address').isValid) { if (getRef('aggregator_private_key').isValid) {
floBlockchainAPI.getBalance(address).then(balance => { floBlockchainAPI.getBalance(address).then(balance => {
if (balance < 0.01) { if (balance < 0.01) {
renderElem(getRef('aggregator_balance'), html`Balance: ${balance}FLO. You don't have enough FLO.`); renderElem(getRef('aggregator_balance'), html`Balance: ${balance}FLO. You don't have enough FLO.`);
@ -248,8 +246,8 @@
return [...addresses] return [...addresses]
} }
function submitAddresses() { function submitAddresses() {
const aggregatorAddress = getRef('aggregator_address').value.trim()
const aggregatorPrivateKey = getRef('aggregator_private_key').value.trim() const aggregatorPrivateKey = getRef('aggregator_private_key').value.trim()
const aggregatorAddress = floCrypto.getAddress(aggregatorPrivateKey)
if (!floGlobals.approvedKycAggregators.hasOwnProperty(aggregatorAddress)) { if (!floGlobals.approvedKycAggregators.hasOwnProperty(aggregatorAddress)) {
notify('KYC aggregator address is not approved', 'error') notify('KYC aggregator address is not approved', 'error')
return return
@ -265,11 +263,11 @@
notify('Too many addresses. Try removing one and resubmitting.', 'error') notify('Too many addresses. Try removing one and resubmitting.', 'error')
return return
} }
console.log(floData)
buttonLoader(getRef('submit_kyc'), true) buttonLoader(getRef('submit_kyc'), true)
floBlockchainAPI.writeData(aggregatorAddress, floData, aggregatorPrivateKey, aggregatorAddress).then(txId => { floBlockchainAPI.writeData(aggregatorAddress, floData, aggregatorPrivateKey, aggregatorAddress).then(txId => {
notify(`${kycType === 'approve' ? 'Approval' : 'Revoke'} request submitted. TXID: ${txId}`, 'success') notify(`${kycType === 'approve' ? 'Approval' : 'Revoke'} request submitted. TXID: ${txId}`, 'success')
getRef('kyc_addresses_container').innerHTML = ''; getRef('kyc_addresses_container').innerHTML = '';
getRef('kyc_form').reset()
addAddressInput() addAddressInput()
}).catch(e => { }).catch(e => {
notify(e, 'error') notify(e, 'error')
@ -284,7 +282,6 @@
try { try {
await getApprovedAggregators() await getApprovedAggregators()
router.routeTo(window.location.hash) router.routeTo(window.location.hash)
getRef('aggregator_address').customValidation = floCrypto.validateAddr
getRef('aggregator_private_key').customValidation = floCrypto.getPubKeyHex getRef('aggregator_private_key').customValidation = floCrypto.getPubKeyHex
addAddressInput() addAddressInput()
} catch (e) { } catch (e) {