diff options
author | Florian Dold <florian.dold@gmail.com> | 2016-02-19 01:30:02 +0100 |
---|---|---|
committer | Florian Dold <florian.dold@gmail.com> | 2016-02-19 01:30:02 +0100 |
commit | 5a12edcd5d49029d85c47dc1169a5cc26cc6d10b (patch) | |
tree | 3083d2c3b2aa3e1fa6a3b7c8716548adbfa9e8fe | |
parent | 07f11151aa9015c46abfbc91e3e91dc7f8590824 (diff) | |
download | wallet-core-5a12edcd5d49029d85c47dc1169a5cc26cc6d10b.tar.xz |
factor out RPC
-rw-r--r-- | extension/lib/wallet/wallet.ts | 35 |
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 |