diff options
author | Florian Dold <florian.dold@gmail.com> | 2016-10-12 02:55:53 +0200 |
---|---|---|
committer | Florian Dold <florian.dold@gmail.com> | 2016-10-12 02:55:53 +0200 |
commit | d4be3906e32ac7d9933c6030d6493f2f2152bdd9 (patch) | |
tree | 3341586381b6975a3c1fa99ca69c63fba5ac9c35 /lib/wallet/wxApi.ts | |
parent | dbcd85451edfc33f2e0a42c431f0cf3ab3b12876 (diff) | |
download | wallet-core-d4be3906e32ac7d9933c6030d6493f2f2152bdd9.tar.xz |
tree view of wallet db
Diffstat (limited to 'lib/wallet/wxApi.ts')
-rw-r--r-- | lib/wallet/wxApi.ts | 38 |
1 files changed, 34 insertions, 4 deletions
diff --git a/lib/wallet/wxApi.ts b/lib/wallet/wxApi.ts index 84235c6a9..549ce0a5a 100644 --- a/lib/wallet/wxApi.ts +++ b/lib/wallet/wxApi.ts @@ -14,8 +14,14 @@ TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> */ -import {AmountJson} from "./types"; -import {ReserveCreationInfo} from "./types"; +import { + AmountJson, + Coin, + PreCoin, + ReserveCreationInfo, + IExchangeInfo, + Reserve +} from "./types"; /** * Interface to the wallet through WebExtension messaging. @@ -24,8 +30,8 @@ import {ReserveCreationInfo} from "./types"; export function getReserveCreationInfo(baseUrl: string, - amount: AmountJson): Promise<ReserveCreationInfo> { - let m = {type: "reserve-creation-info", detail: {baseUrl, amount}}; + amount: AmountJson): Promise<ReserveCreationInfo> { + let m = { type: "reserve-creation-info", detail: { baseUrl, amount } }; return new Promise((resolve, reject) => { chrome.runtime.sendMessage(m, (resp) => { if (resp.error) { @@ -39,3 +45,27 @@ export function getReserveCreationInfo(baseUrl: string, }); }); } + +export async function callBackend(type: string, detail?: any): Promise<any> { + return new Promise<IExchangeInfo[]>((resolve, reject) => { + chrome.runtime.sendMessage({ type, detail }, (resp) => { + resolve(resp); + }); + }); +} + +export async function getExchanges(): Promise<IExchangeInfo[]> { + return await callBackend("get-exchanges"); +} + +export async function getReserves(exchangeBaseUrl: string): Promise<Reserve[]> { + return await callBackend("get-reserves", { exchangeBaseUrl }); +} + +export async function getCoins(exchangeBaseUrl: string): Promise<Coin[]> { + return await callBackend("get-coins", { exchangeBaseUrl }); +} + +export async function getPreCoins(exchangeBaseUrl: string): Promise<PreCoin[]> { + return await callBackend("get-precoins", { exchangeBaseUrl }); +}
\ No newline at end of file |