bug fix: floDapps
This commit is contained in:
parent
5a2b6250ca
commit
5e9926b87b
@ -2,7 +2,7 @@
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<title>FLO Operators</title>
|
||||
<title>FLO Standard Operators</title>
|
||||
|
||||
<script id="floGlobals">
|
||||
/* Constants for FLO blockchain operations !!Make sure to add this at begining!! */
|
||||
@ -26,7 +26,7 @@
|
||||
|
||||
//for cloud apps
|
||||
subAdmins: [],
|
||||
application: "Test_RIBC",
|
||||
application: "TEST_MODE",
|
||||
vectorClock: {},
|
||||
appObjects: {},
|
||||
generalData: {},
|
||||
@ -37,7 +37,8 @@
|
||||
</head>
|
||||
|
||||
<body onload="onLoadStartUp()">
|
||||
use console
|
||||
TEST_MODE
|
||||
(use console)
|
||||
|
||||
<script id="init_lib">
|
||||
//All util libraries required for Standard operations (DO NOT EDIT ANY)
|
||||
@ -7037,7 +7038,7 @@
|
||||
if(!(o in obj))
|
||||
obj[o] = this.appObs[o]
|
||||
compactIDB.initDB(floGlobals.application, obj).then(result => {
|
||||
resolve("Initiated supernode storage")
|
||||
resolve("IndexedDB App Storage Initated Successfully")
|
||||
}).catch(error => reject(error));
|
||||
})
|
||||
},
|
||||
@ -7139,7 +7140,7 @@
|
||||
|
||||
var getPrivateKeyCredentials = function(){
|
||||
return new Promise((resolve, reject) => {
|
||||
var indexArr = localStorage.getItem("privKey")
|
||||
var indexArr = localStorage.getItem(`${floGlobals.application}#privKey`)
|
||||
if(indexArr){
|
||||
readSharesFromIDB(JSON.parse(indexArr))
|
||||
.then(result => resolve(result))
|
||||
@ -7158,8 +7159,7 @@
|
||||
var threshold = floCrypto.randInt(10,20)
|
||||
writeSharesToIDB(floCrypto.createShamirsSecretShares(privKey, threshold, threshold)).then(resultIndexes =>{
|
||||
//store index keys in localStorage
|
||||
console.log(resultIndexes)
|
||||
localStorage.setItem("privKey", JSON.stringify(resultIndexes))
|
||||
localStorage.setItem(`${floGlobals.application}#privKey`, JSON.stringify(resultIndexes))
|
||||
//also add a dummy privatekey to the IDB
|
||||
var randomPrivKey = floCrypto.generateNewID().privKey
|
||||
var randomThreshold = floCrypto.randInt(10,20)
|
||||
@ -7186,13 +7186,12 @@
|
||||
callStartUpFunction: function(fname){
|
||||
return new Promise((resolve, reject) => {
|
||||
this.startUpFunctions[fname]().then(result => {
|
||||
console.log(result)
|
||||
this.callStartUpFunction.completed += 1
|
||||
console.log(`Completed ${this.callStartUpFunction.completed}/${this.callStartUpFunction.total} Startup functions`)
|
||||
console.log(`${result}\nCompleted ${this.callStartUpFunction.completed}/${this.callStartUpFunction.total} Startup functions`)
|
||||
resolve(true)
|
||||
}).catch(error => {
|
||||
console.error(error)
|
||||
console.log(`Failed ${this.callStartUpFunction.failed}/${this.callStartUpFunction.total} Startup functions`)
|
||||
this.callStartUpFunction.failed += 1
|
||||
console.error(`${error}\nFailed ${this.callStartUpFunction.failed}/${this.callStartUpFunction.total} Startup functions`)
|
||||
reject(false)
|
||||
})
|
||||
})
|
||||
@ -7213,7 +7212,7 @@
|
||||
this.util.callStartUpFunction.failed = 0
|
||||
var promises = []
|
||||
for(fn in this.util.startUpFunctions)
|
||||
promises.push(callStartUpFunction(fn))
|
||||
promises.push(this.util.callStartUpFunction(fn))
|
||||
Promise.all(promises)
|
||||
.then(results => resolve('App Startup finished successful'))
|
||||
.catch(errors => reject('App StartUp failed'))
|
||||
@ -7232,12 +7231,12 @@
|
||||
},
|
||||
|
||||
clearCredentials: function(){
|
||||
var indexArr = localStorage.getItem("privKey")
|
||||
var indexArr = localStorage.getItem(`${floGlobals.application}#privKey`)
|
||||
if(!indexArr)
|
||||
return `privKey credentials not found!`
|
||||
indexArr = JSON.parse(indexArr)
|
||||
indexArr.forEach(i => compactIDB.removeData('credentials', i))
|
||||
localStorage.removeItem("privKey")
|
||||
localStorage.removeItem(`${floGlobals.application}#privKey`)
|
||||
return `privKey credentials deleted!`
|
||||
},
|
||||
|
||||
@ -7270,7 +7269,7 @@
|
||||
floDapps.launchStartUp().then(result => {
|
||||
console.log(result)
|
||||
alert(`Welcome FLO_ID: ${myFloID}`)
|
||||
})
|
||||
}).catch(error => console.error(error))
|
||||
}
|
||||
</script>
|
||||
</body>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user