Merge pull request #15 from rodneywitcher/master

Resolves callback vs promise inconsistency
This commit is contained in:
Mitra Ardron 2019-03-21 11:36:13 -07:00 committed by GitHub
commit 0960047785
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -54,10 +54,13 @@ class TransportWOLK extends Transport {
.then( async () => { //TODO-WOLK check - I'm just not familiar with this construct - an async function inside a .then
if( this.wolk.ecdsaKey == undefined || this.wolk.ecdsaKey == null ) {
var wolkName = "user" + Math.floor((Math.random() * 1000) + 1);
debug("createAccount because ecsaKey null");
await this.wolk.createAccount(wolkName, (err, hash) => { //TODO-WOLK check - is this correct (it might be), async await, but has a callback?
if(err) { throw new Error("Error Creating Account: " + err); }
debug("Account Created: [%s] hash: %s KEY: %s", wolkName, ,this.wolk.ecdsaKey);
debug("WOLK: createAccount because ecdsaKey null")
return await this.wolk.createAccount(wolkName)
.then( hash => {
debug("[WOLK] Account Created: [" + wolkName + "] hash: " + hash + " KEY: " + this.wolk.ecdsaKey)
})
.catch( err => {
throw new Error("Error Creating Account: " + err);
})
}
});