aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/android/index.ts2
-rw-r--r--src/headless/taler-wallet-cli.ts2
-rw-r--r--src/types/walletTypes.ts24
-rw-r--r--src/wallet.ts19
-rw-r--r--src/webex/messages.ts4
-rw-r--r--src/webex/wxApi.ts11
-rw-r--r--src/webex/wxBackend.ts7
7 files changed, 41 insertions, 28 deletions
diff --git a/src/android/index.ts b/src/android/index.ts
index e7a248476..3ed88e4ba 100644
--- a/src/android/index.ts
+++ b/src/android/index.ts
@@ -195,7 +195,7 @@ class AndroidWalletMessageHandler {
}
case "getWithdrawalDetailsForAmount": {
const wallet = await this.wp.promise;
- return await wallet.getWithdrawDetailsForAmount(args.exchangeBaseUrl, args.amount);
+ return await wallet.getWithdrawalDetailsForAmount(args.exchangeBaseUrl, args.amount);
}
case "withdrawTestkudos": {
const wallet = await this.wp.promise;
diff --git a/src/headless/taler-wallet-cli.ts b/src/headless/taler-wallet-cli.ts
index 23ae4da44..278489d26 100644
--- a/src/headless/taler-wallet-cli.ts
+++ b/src/headless/taler-wallet-cli.ts
@@ -386,7 +386,7 @@ advancedCli
.requiredArgument("amount", clk.STRING)
.action(async (args) => {
await withWallet(args, async (wallet) => {
- const details = await wallet.getWithdrawDetailsForAmount(
+ const details = await wallet.getWithdrawalDetailsForAmount(
args.manualWithdrawalDetails.exchange,
Amounts.parseOrThrow(args.manualWithdrawalDetails.amount),
);
diff --git a/src/types/walletTypes.ts b/src/types/walletTypes.ts
index 8bc4f97af..d61d04692 100644
--- a/src/types/walletTypes.ts
+++ b/src/types/walletTypes.ts
@@ -41,6 +41,7 @@ import {
makeCodecOptional,
Codec,
} from "../util/codec";
+import { AmountString } from "./talerTypes";
/**
* Response for the create reserve request to the wallet.
@@ -489,3 +490,26 @@ export interface ExchangeListItem {
currency: string;
paytoUris: string[];
}
+
+export interface ManualWithdrawalDetails {
+ /**
+ * Did the user accept the current version of the exchange's
+ * terms of service?
+ */
+ tosAccepted: boolean;
+
+ /**
+ * Amount that the user will transfer to the exchange.
+ */
+ rawAmount: AmountString;
+
+ /**
+ * Amount that will be added to the user's wallet balance.
+ */
+ effectiveAmount: AmountString;
+
+ /**
+ * Ways to pay the exchange.
+ */
+ paytoUris: string[];
+}
diff --git a/src/wallet.ts b/src/wallet.ts
index 780f8eafd..2b804ded7 100644
--- a/src/wallet.ts
+++ b/src/wallet.ts
@@ -67,10 +67,11 @@ import {
WithdrawDetails,
AcceptWithdrawalResponse,
PurchaseDetails,
- ExchangeWithdrawDetails,
+ ExchangeWithdrawDetails as ExchangeWithdrawalDetails,
RefreshReason,
ExchangeListItem,
ExchangesListRespose,
+ ManualWithdrawalDetails,
} from "./types/walletTypes";
import { Logger } from "./util/logging";
@@ -166,11 +167,21 @@ export class Wallet {
return getExchangePaytoUri(this.ws, exchangeBaseUrl, supportedTargetTypes);
}
- getWithdrawDetailsForAmount(
+ async getWithdrawalDetailsForAmount(
exchangeBaseUrl: string,
amount: AmountJson,
- ): Promise<ExchangeWithdrawDetails> {
- return getExchangeWithdrawalInfo(this.ws, exchangeBaseUrl, amount);
+ ): Promise<ManualWithdrawalDetails> {
+ const wi = await getExchangeWithdrawalInfo(this.ws, exchangeBaseUrl, amount);
+ const paytoUris = wi.exchangeInfo.wireInfo?.accounts.map((x) => x.payto_uri);
+ if (!paytoUris) {
+ throw Error("exchange is in invalid state");
+ }
+ return {
+ rawAmount: Amounts.stringify(amount),
+ effectiveAmount: Amounts.stringify(wi.selectedDenoms.totalCoinValue),
+ paytoUris,
+ tosAccepted: wi.termsOfServiceAccepted,
+ };
}
addNotificationListener(f: (n: WalletNotification) => void): void {
diff --git a/src/webex/messages.ts b/src/webex/messages.ts
index 932636f1a..8120d4f94 100644
--- a/src/webex/messages.ts
+++ b/src/webex/messages.ts
@@ -73,10 +73,6 @@ export interface MessageMap {
request: { baseUrl: string };
response: dbTypes.ExchangeRecord;
};
- "reserve-creation-info": {
- request: { baseUrl: string; amount: AmountJson };
- response: walletTypes.ExchangeWithdrawDetails;
- };
"get-history": {
request: {};
response: HistoryEvent[];
diff --git a/src/webex/wxApi.ts b/src/webex/wxApi.ts
index 1823f662c..0901005b5 100644
--- a/src/webex/wxApi.ts
+++ b/src/webex/wxApi.ts
@@ -104,17 +104,6 @@ async function callBackend<T extends MessageType>(
}
/**
- * Query the wallet for the coins that would be used to withdraw
- * from a given reserve.
- */
-export function getReserveCreationInfo(
- baseUrl: string,
- amount: AmountJson,
-): Promise<ExchangeWithdrawDetails> {
- return callBackend("reserve-creation-info", { baseUrl, amount });
-}
-
-/**
* Get all exchanges the wallet knows about.
*/
export function getExchanges(): Promise<ExchangeRecord[]> {
diff --git a/src/webex/wxBackend.ts b/src/webex/wxBackend.ts
index 5cf61a78a..540c79771 100644
--- a/src/webex/wxBackend.ts
+++ b/src/webex/wxBackend.ts
@@ -139,13 +139,6 @@ async function handleMessage(
}
return needsWallet().updateExchangeFromUrl(detail.baseUrl);
}
- case "reserve-creation-info": {
- if (!detail.baseUrl || typeof detail.baseUrl !== "string") {
- return Promise.resolve({ error: "bad url" });
- }
- const amount = codecForAmountJson().decode(detail.amount);
- return needsWallet().getWithdrawDetailsForAmount(detail.baseUrl, amount);
- }
case "get-history": {
// TODO: limit history length
return needsWallet().getHistory();