diff options
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 |