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