diff options
author | Florian Dold <florian.dold@gmail.com> | 2020-07-09 18:56:18 +0530 |
---|---|---|
committer | Florian Dold <florian.dold@gmail.com> | 2020-07-09 18:56:18 +0530 |
commit | 63ebe1b2e296aabb79cb1756d5dfc82c1ba4fe02 (patch) | |
tree | 18d0a1f92b8b48abec3d66b10a56d23212d7d81b /src/wallet.ts | |
parent | 2efe743950ade93ef6cb981a6ac4a56ef3e71ec7 (diff) |
android APIs for withdrawal and exchange listing
Diffstat (limited to 'src/wallet.ts')
-rw-r--r-- | src/wallet.ts | 34 |
1 files changed, 33 insertions, 1 deletions
diff --git a/src/wallet.ts b/src/wallet.ts index 31f9af8c2..780f8eafd 100644 --- a/src/wallet.ts +++ b/src/wallet.ts @@ -69,6 +69,8 @@ import { PurchaseDetails, ExchangeWithdrawDetails, RefreshReason, + ExchangeListItem, + ExchangesListRespose, } from "./types/walletTypes"; import { Logger } from "./util/logging"; @@ -549,10 +551,40 @@ export class Wallet { return denoms; } - async getExchanges(): Promise<ExchangeRecord[]> { + /** + * Get all exchanges known to the exchange. + * + * @deprecated Use getExchanges instead + */ + async getExchangeRecords(): Promise<ExchangeRecord[]> { return await this.db.iter(Stores.exchanges).toArray(); } + async getExchanges(): Promise<ExchangesListRespose> { + const exchanges: (ExchangeListItem | undefined)[] = await this.db + .iter(Stores.exchanges) + .map((x) => { + const details = x.details; + if (!details) { + return undefined; + } + if (!x.addComplete) { + return undefined; + } + if (!x.wireInfo) { + return undefined; + } + return { + exchangeBaseUrl: x.baseUrl, + currency: details.currency, + paytoUris: x.wireInfo.accounts.map(x => x.payto_uri), + }; + }); + return { + exchanges: exchanges.filter((x) => !!x) as ExchangeListItem[], + }; + } + async getCurrencies(): Promise<CurrencyRecord[]> { return await this.db.iter(Stores.currencies).toArray(); } |