diff options
author | Florian Dold <florian.dold@gmail.com> | 2017-04-28 23:28:27 +0200 |
---|---|---|
committer | Florian Dold <florian.dold@gmail.com> | 2017-04-28 23:28:27 +0200 |
commit | d6bf24902a34f2094363121c8d9f4d54db6f7b6c (patch) | |
tree | 0794956ebdf91a2fbea16baa0e8aa559f45c5d06 /src/wxApi.ts | |
parent | ce97b1076b7e4a53b84d3fd34bf2047580ddeb22 (diff) |
implement new reserve creation dialog and auditor management
Diffstat (limited to 'src/wxApi.ts')
-rw-r--r-- | src/wxApi.ts | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/src/wxApi.ts b/src/wxApi.ts index de59914a1..bdc02af1b 100644 --- a/src/wxApi.ts +++ b/src/wxApi.ts @@ -48,9 +48,13 @@ export function getReserveCreationInfo(baseUrl: string, } export async function callBackend(type: string, detail?: any): Promise<any> { - return new Promise<ExchangeRecord[]>((resolve, reject) => { + return new Promise<any>((resolve, reject) => { chrome.runtime.sendMessage({ type, detail }, (resp) => { - resolve(resp); + if (resp.error) { + reject(resp); + } else { + resolve(resp); + } }); }); } @@ -63,6 +67,15 @@ export async function getCurrencies(): Promise<CurrencyRecord[]> { return await callBackend("get-currencies"); } + +export async function getCurrency(name: string): Promise<CurrencyRecord|null> { + return await callBackend("currency-info", {name}); +} + +export async function getExchangeInfo(baseUrl: string): Promise<ExchangeRecord> { + return await callBackend("exchange-info", {baseUrl}); +} + export async function updateCurrency(currencyRecord: CurrencyRecord): Promise<void> { return await callBackend("update-currency", { currencyRecord }); } |