aboutsummaryrefslogtreecommitdiff
path: root/extension/lib
diff options
context:
space:
mode:
authorFlorian Dold <florian.dold@gmail.com>2016-02-19 01:30:02 +0100
committerFlorian Dold <florian.dold@gmail.com>2016-02-19 01:30:02 +0100
commit5a12edcd5d49029d85c47dc1169a5cc26cc6d10b (patch)
tree3083d2c3b2aa3e1fa6a3b7c8716548adbfa9e8fe /extension/lib
parent07f11151aa9015c46abfbc91e3e91dc7f8590824 (diff)
factor out RPC
Diffstat (limited to 'extension/lib')
-rw-r--r--extension/lib/wallet/wallet.ts35
1 files changed, 16 insertions, 19 deletions
diff --git a/extension/lib/wallet/wallet.ts b/extension/lib/wallet/wallet.ts
index 1504258a1..ed719211f 100644
--- a/extension/lib/wallet/wallet.ts
+++ b/extension/lib/wallet/wallet.ts
@@ -962,12 +962,12 @@ export class Wallet {
}
return mintInfo.mergeKeys(mintKeysJson, this)
- .then(() => {
- return Query(this.db)
- .put("mints", mintInfo)
- .finish()
- .then(() => mintInfo);
- });
+ .then(() => {
+ return Query(this.db)
+ .put("mints", mintInfo)
+ .finish()
+ .then(() => mintInfo);
+ });
});
});
@@ -1016,27 +1016,24 @@ export class Wallet {
return id;
}
-
- createPreCoin(denom: Denomination, reserve: Reserve): Promise<PreCoin> {
- return new Promise((resolve, reject) => {
+ private doRpc<T>(methodName: string, ...args): Promise<T> {
+ return new Promise<T>((resolve, reject) => {
let msg = {
- operation: "createPreCoin",
+ operation: methodName,
id: this.registerRpcId(resolve, reject),
- args: [denom, reserve]
+ args: args,
};
this.cryptoWorker.postMessage(msg);
});
}
+
+ createPreCoin(denom: Denomination, reserve: Reserve): Promise<PreCoin> {
+ return this.doRpc("createPreCoin", denom, reserve);
+ }
+
isValidDenom(denom: Denomination,
masterPub: string): Promise<boolean> {
- return new Promise((resolve, reject) => {
- let msg = {
- operation: "isValidDenom",
- id: this.registerRpcId(resolve, reject),
- args: [denom, masterPub]
- };
- this.cryptoWorker.postMessage(msg);
- });
+ return this.doRpc("isValidDenom", denom, masterPub);
}
} \ No newline at end of file