Added option to label multisig addresses
This commit is contained in:
parent
edc9718ff7
commit
777c8280c8
@ -2212,12 +2212,16 @@ sm-chip .badge {
|
||||
.multisig-option {
|
||||
position: relative;
|
||||
padding: 1rem;
|
||||
border-radius: 0.5rem;
|
||||
font-size: 0.9rem;
|
||||
border-bottom: thin solid rgba(var(--text-color), 0.3);
|
||||
}
|
||||
.multisig-option .wrap-around {
|
||||
font-weight: 500;
|
||||
}
|
||||
.multisig-option__label {
|
||||
font-weight: 500;
|
||||
font-size: 1rem;
|
||||
}
|
||||
.multisig-option__balance {
|
||||
color: rgba(var(--text-color), 0.8);
|
||||
}
|
||||
|
||||
2
css/main.min.css
vendored
2
css/main.min.css
vendored
File diff suppressed because one or more lines are too long
@ -2282,11 +2282,15 @@ sm-chip {
|
||||
.multisig-option {
|
||||
position: relative;
|
||||
padding: 1rem;
|
||||
border-radius: 0.5rem;
|
||||
font-size: 0.9rem;
|
||||
border-bottom: thin solid rgba(var(--text-color), 0.3);
|
||||
.wrap-around {
|
||||
font-weight: 500;
|
||||
}
|
||||
&__label {
|
||||
font-weight: 500;
|
||||
font-size: 1rem;
|
||||
}
|
||||
&__balance {
|
||||
color: rgba(var(--text-color), 0.8);
|
||||
}
|
||||
|
||||
52
index.html
52
index.html
@ -31,7 +31,6 @@
|
||||
<script id="onLoadStartUp">
|
||||
function onLoadStartUp() {
|
||||
routeTo('loading')
|
||||
floDapps.setAppObjectStores({ userSettings: {} })
|
||||
document.body.classList.remove('hidden')
|
||||
|
||||
floDapps.setCustomPrivKeyInput(getSignedIn)
|
||||
@ -943,10 +942,14 @@
|
||||
</button>
|
||||
<p id="multisig_creation__warning" class="info info--warning"></p>
|
||||
<sm-form>
|
||||
<p>Enter minimum signatures required for approval of a transaction</p>
|
||||
<sm-input id="min_sign_required" placeholder="Min required" min="2" type="number"
|
||||
error-text="At least 2 members are required" animate required>
|
||||
</sm-input>
|
||||
<sm-input id="multisig_label" placeholder="Label" error-text="Please add a label" animated
|
||||
required></sm-input>
|
||||
<div class="grid gap-0-5">
|
||||
<p>Minimum signatures required for transaction approval</p>
|
||||
<sm-input id="min_sign_required" placeholder="Min required" min="2" type="number"
|
||||
error-text="At least 2 members are required" animate required>
|
||||
</sm-input>
|
||||
</div>
|
||||
<div class="multi-state-button">
|
||||
<button id="create_multisig_button" class="button button--primary" type="submit" disabled>
|
||||
Create
|
||||
@ -2646,7 +2649,7 @@
|
||||
</button>
|
||||
`
|
||||
},
|
||||
multisigOption(address) {
|
||||
multisigOption(address, label) {
|
||||
btcOperator.getBalance(address).then(balance => {
|
||||
const target = getRef('select_multisig_list').querySelector(`[data-address="${address}"]`);
|
||||
if (target)
|
||||
@ -2654,6 +2657,7 @@
|
||||
}).catch(err => notify(err, 'error'))
|
||||
return html`
|
||||
<li class="grid gap-0-5 align-center multisig-option" data-address=${address}>
|
||||
<text-field class="multisig-option__label" placeholder="Label" value=${label || 'Add a label'}></text-field>
|
||||
<sm-copy clip-text value=${address}></sm-copy>
|
||||
<div class="flex align-center space-between">
|
||||
<span class="multisig-option__balance flex align-center">Balance: <sm-spinner><sm-spinner></span>
|
||||
@ -2663,12 +2667,13 @@
|
||||
`
|
||||
},
|
||||
multisigAddresses() {
|
||||
messenger.multisig.listAddress().then(addresses => {
|
||||
const list = Object.keys(addresses).map(address => render.multisigOption(address))
|
||||
if (list.length) {
|
||||
renderElem(getRef('select_multisig_list'), html`${list}`)
|
||||
}
|
||||
}).catch(err => notify(err, 'error'))
|
||||
Promise.all([messenger.multisig.listAddress(), compactIDB.readAllData('multisigLabels')])
|
||||
.then(([addresses, labels]) => {
|
||||
const list = Object.keys(addresses).map(address => render.multisigOption(address, labels[address]))
|
||||
if (list.length) {
|
||||
renderElem(getRef('select_multisig_list'), html`${list}`)
|
||||
}
|
||||
}).catch(err => notify(err, 'error'))
|
||||
},
|
||||
notification(id, details) {
|
||||
let { floID, message, time, type } = details
|
||||
@ -3295,7 +3300,7 @@
|
||||
getRef('skip_members_button').addEventListener('click', e => {
|
||||
if (getRef('creation_popup').dataset.type === 'multisig') {
|
||||
showChildElement('creation_process', 2, { entry: slideInLeft, exit: slideOutLeft }).then(() => {
|
||||
getRef('min_sign_required').focusIn()
|
||||
getRef('multisig_label').focusIn()
|
||||
})
|
||||
} else {
|
||||
showChildElement('creation_process', 1, { entry: slideInLeft, exit: slideOutLeft }).then(() => {
|
||||
@ -3316,18 +3321,31 @@
|
||||
selectedMembers.add(floDapps.user.id)
|
||||
const selctedPubKeys = [...selectedMembers].map(id => floGlobals.pubKeys[id]);
|
||||
const minRequired = parseInt(getRef('min_sign_required').value.trim());
|
||||
const label = getRef('multisig_label').value.trim();
|
||||
buttonLoader('create_multisig_button', true)
|
||||
messenger.multisig.createAddress(selctedPubKeys, minRequired).then(multisigAddress => {
|
||||
notify('Created multisig address', 'success');
|
||||
closePopup();
|
||||
clearAllMembers();
|
||||
render.multisigAddresses();
|
||||
compactIDB.writeData('multisigLabels', label, multisigAddress).then(() => {
|
||||
notify('Created multisig address', 'success');
|
||||
closePopup();
|
||||
clearAllMembers();
|
||||
render.multisigAddresses();
|
||||
}).catch(error => notify(error, 'error'))
|
||||
}).catch(error => notify(error, 'error'))
|
||||
.finally(() => {
|
||||
buttonLoader('create_multisig_button', false)
|
||||
})
|
||||
})
|
||||
|
||||
getRef('select_multisig_list').addEventListener('change', e => {
|
||||
const multisigAddress = e.target.closest('.multisig-option').dataset.address;
|
||||
let label = e.target.value.trim();
|
||||
if (label === '')
|
||||
label = 'Unnamed'
|
||||
compactIDB.writeData('multisigLabels', label, multisigAddress).then(() => {
|
||||
notify('Updated label', 'success');
|
||||
}).catch(error => notify(error, 'error'))
|
||||
})
|
||||
|
||||
|
||||
document.getElementById('create_group_button').addEventListener('click', () => {
|
||||
const groupName = getRef('group_name_field').value.trim()
|
||||
|
||||
File diff suppressed because one or more lines are too long
@ -1,4 +1,4 @@
|
||||
(function(EXPORTS) { //floDapps v2.3.2d
|
||||
(function (EXPORTS) { //floDapps v2.3.2d
|
||||
/* General functions for FLO Dapps*/
|
||||
'use strict';
|
||||
const floDapps = EXPORTS;
|
||||
@ -454,7 +454,7 @@
|
||||
})
|
||||
});
|
||||
|
||||
floDapps.launchStartUp = function() {
|
||||
floDapps.launchStartUp = function () {
|
||||
return new Promise((resolve, reject) => {
|
||||
initIndexedDB().then(log => {
|
||||
console.log(log)
|
||||
@ -497,7 +497,7 @@
|
||||
|
||||
floDapps.setAppObjectStores = appObs => initIndexedDB.appObs = appObs;
|
||||
|
||||
floDapps.storeContact = function(floID, name) {
|
||||
floDapps.storeContact = function (floID, name) {
|
||||
return new Promise((resolve, reject) => {
|
||||
if (!floCrypto.validateAddr(floID))
|
||||
return reject("Invalid floID!")
|
||||
@ -508,7 +508,7 @@
|
||||
});
|
||||
}
|
||||
|
||||
floDapps.storePubKey = function(floID, pubKey) {
|
||||
floDapps.storePubKey = function (floID, pubKey) {
|
||||
return new Promise((resolve, reject) => {
|
||||
if (floID in user.pubKeys)
|
||||
return resolve("pubKey already stored")
|
||||
@ -523,7 +523,7 @@
|
||||
});
|
||||
}
|
||||
|
||||
floDapps.sendMessage = function(floID, message) {
|
||||
floDapps.sendMessage = function (floID, message) {
|
||||
return new Promise((resolve, reject) => {
|
||||
let options = {
|
||||
receiverID: floID,
|
||||
@ -538,7 +538,7 @@
|
||||
})
|
||||
}
|
||||
|
||||
floDapps.requestInbox = function(callback) {
|
||||
floDapps.requestInbox = function (callback) {
|
||||
return new Promise((resolve, reject) => {
|
||||
let lastVC = Object.keys(user.messages).sort().pop()
|
||||
let options = {
|
||||
@ -552,7 +552,7 @@
|
||||
try {
|
||||
if (d[v].message instanceof Object && "secret" in d[v].message)
|
||||
d[v].message = floCrypto.decryptData(d[v].message, privKey)
|
||||
} catch (error) {}
|
||||
} catch (error) { }
|
||||
compactIDB.writeData("messages", d[v], v, user.db_name)
|
||||
user.messages[v] = d[v]
|
||||
}
|
||||
@ -565,7 +565,7 @@
|
||||
})
|
||||
}
|
||||
|
||||
floDapps.manageAppConfig = function(adminPrivKey, addList, rmList, settings) {
|
||||
floDapps.manageAppConfig = function (adminPrivKey, addList, rmList, settings) {
|
||||
return new Promise((resolve, reject) => {
|
||||
if (!Array.isArray(addList) || !addList.length) addList = undefined;
|
||||
if (!Array.isArray(rmList) || !rmList.length) rmList = undefined;
|
||||
@ -584,12 +584,12 @@
|
||||
reject('Access Denied for Admin privilege')
|
||||
else
|
||||
floBlockchainAPI.writeData(floID, JSON.stringify(floData), adminPrivKey)
|
||||
.then(result => resolve(['Updated App Configuration', result]))
|
||||
.catch(error => reject(error))
|
||||
.then(result => resolve(['Updated App Configuration', result]))
|
||||
.catch(error => reject(error))
|
||||
})
|
||||
}
|
||||
|
||||
const clearCredentials = floDapps.clearCredentials = function() {
|
||||
const clearCredentials = floDapps.clearCredentials = function () {
|
||||
return new Promise((resolve, reject) => {
|
||||
compactIDB.clearData('credentials', DEFAULT.application).then(result => {
|
||||
localStorage.removeItem(`${DEFAULT.application}#privKey`);
|
||||
@ -599,7 +599,7 @@
|
||||
})
|
||||
}
|
||||
|
||||
floDapps.deleteUserData = function(credentials = false) {
|
||||
floDapps.deleteUserData = function (credentials = false) {
|
||||
return new Promise((resolve, reject) => {
|
||||
let p = []
|
||||
p.push(compactIDB.deleteDB(user.db_name))
|
||||
@ -611,7 +611,7 @@
|
||||
})
|
||||
}
|
||||
|
||||
floDapps.deleteAppData = function() {
|
||||
floDapps.deleteAppData = function () {
|
||||
return new Promise((resolve, reject) => {
|
||||
compactIDB.deleteDB(DEFAULT.application).then(result => {
|
||||
localStorage.removeItem(`${DEFAULT.application}#privKey`)
|
||||
@ -623,7 +623,7 @@
|
||||
})
|
||||
}
|
||||
|
||||
floDapps.securePrivKey = function(pwd) {
|
||||
floDapps.securePrivKey = function (pwd) {
|
||||
return new Promise(async (resolve, reject) => {
|
||||
let indexArr = localStorage.getItem(`${DEFAULT.application}#privKey`)
|
||||
if (!indexArr)
|
||||
@ -643,8 +643,8 @@
|
||||
})
|
||||
}
|
||||
|
||||
floDapps.verifyPin = function(pin = null) {
|
||||
const readSharesFromIDB = function(indexArr) {
|
||||
floDapps.verifyPin = function (pin = null) {
|
||||
const readSharesFromIDB = function (indexArr) {
|
||||
return new Promise((resolve, reject) => {
|
||||
var promises = []
|
||||
for (var i = 0; i < indexArr.length; i++)
|
||||
@ -687,7 +687,7 @@
|
||||
})
|
||||
}
|
||||
|
||||
const getNextGeneralData = floDapps.getNextGeneralData = function(type, vectorClock = null, options = {}) {
|
||||
const getNextGeneralData = floDapps.getNextGeneralData = function (type, vectorClock = null, options = {}) {
|
||||
var fk = floCloudAPI.util.filterKey(type, options)
|
||||
vectorClock = vectorClock || getNextGeneralData[fk] || '0';
|
||||
var filteredResult = {}
|
||||
@ -716,10 +716,10 @@
|
||||
let tmp = floCrypto.decryptData(data.message, key)
|
||||
data.message = JSON.parse(tmp)
|
||||
break;
|
||||
} catch (error) {}
|
||||
} catch (error) { }
|
||||
}
|
||||
}
|
||||
} catch (error) {}
|
||||
} catch (error) { }
|
||||
}
|
||||
}
|
||||
getNextGeneralData[fk] = Object.keys(filteredResult).sort().pop();
|
||||
|
||||
@ -153,7 +153,8 @@
|
||||
response_received: {},
|
||||
flodata: {},
|
||||
appendix: {},
|
||||
userSettings: {}
|
||||
userSettings: {},
|
||||
multisigLabels: {}
|
||||
}
|
||||
let user_db = `${floGlobals.application}_${floCrypto.toFloID(user.id)}`;
|
||||
compactIDB.initDB(user_db, obj).then(result => {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user