aboutsummaryrefslogtreecommitdiff
path: root/src/wxApi.ts
diff options
context:
space:
mode:
Diffstat (limited to 'src/wxApi.ts')
-rw-r--r--src/wxApi.ts17
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 });
}