factor out RPC
This commit is contained in:
parent
07f11151aa
commit
5a12edcd5d
@ -962,12 +962,12 @@ export class Wallet {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return mintInfo.mergeKeys(mintKeysJson, this)
|
return mintInfo.mergeKeys(mintKeysJson, this)
|
||||||
.then(() => {
|
.then(() => {
|
||||||
return Query(this.db)
|
return Query(this.db)
|
||||||
.put("mints", mintInfo)
|
.put("mints", mintInfo)
|
||||||
.finish()
|
.finish()
|
||||||
.then(() => mintInfo);
|
.then(() => mintInfo);
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -1016,27 +1016,24 @@ export class Wallet {
|
|||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private doRpc<T>(methodName: string, ...args): Promise<T> {
|
||||||
createPreCoin(denom: Denomination, reserve: Reserve): Promise<PreCoin> {
|
return new Promise<T>((resolve, reject) => {
|
||||||
return new Promise((resolve, reject) => {
|
|
||||||
let msg = {
|
let msg = {
|
||||||
operation: "createPreCoin",
|
operation: methodName,
|
||||||
id: this.registerRpcId(resolve, reject),
|
id: this.registerRpcId(resolve, reject),
|
||||||
args: [denom, reserve]
|
args: args,
|
||||||
};
|
};
|
||||||
this.cryptoWorker.postMessage(msg);
|
this.cryptoWorker.postMessage(msg);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
createPreCoin(denom: Denomination, reserve: Reserve): Promise<PreCoin> {
|
||||||
|
return this.doRpc("createPreCoin", denom, reserve);
|
||||||
|
}
|
||||||
|
|
||||||
isValidDenom(denom: Denomination,
|
isValidDenom(denom: Denomination,
|
||||||
masterPub: string): Promise<boolean> {
|
masterPub: string): Promise<boolean> {
|
||||||
return new Promise((resolve, reject) => {
|
return this.doRpc("isValidDenom", denom, masterPub);
|
||||||
let msg = {
|
|
||||||
operation: "isValidDenom",
|
|
||||||
id: this.registerRpcId(resolve, reject),
|
|
||||||
args: [denom, masterPub]
|
|
||||||
};
|
|
||||||
this.cryptoWorker.postMessage(msg);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user