fix fee discrepancy
The withdrawal call-to-action and withdrawal transaction details dialog showed different fees, as the "overhead" for unwithdrawable amounts in a reserve was not included in the withdrawal CTA. The withdrawal CTA now shows the same fees as the transaction details.
This commit is contained in:
parent
e89821a6c7
commit
2ba6692c6a
@ -1133,3 +1133,7 @@ export const codecForImportDbRequest = (): Codec<ImportDb> =>
|
|||||||
buildCodecForObject<ImportDb>()
|
buildCodecForObject<ImportDb>()
|
||||||
.property("dump", codecForAny())
|
.property("dump", codecForAny())
|
||||||
.build("ImportDbRequest");
|
.build("ImportDbRequest");
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -43,6 +43,7 @@ import {
|
|||||||
Duration,
|
Duration,
|
||||||
TalerProtocolTimestamp,
|
TalerProtocolTimestamp,
|
||||||
TransactionType,
|
TransactionType,
|
||||||
|
AmountString,
|
||||||
} from "@gnu-taler/taler-util";
|
} from "@gnu-taler/taler-util";
|
||||||
import {
|
import {
|
||||||
CoinRecord,
|
CoinRecord,
|
||||||
@ -103,6 +104,8 @@ interface DenominationSelectionInfo {
|
|||||||
export interface ExchangeWithdrawDetails {
|
export interface ExchangeWithdrawDetails {
|
||||||
/**
|
/**
|
||||||
* Exchange that the reserve will be created at.
|
* Exchange that the reserve will be created at.
|
||||||
|
*
|
||||||
|
* FIXME: Should be its own record.
|
||||||
*/
|
*/
|
||||||
exchangeInfo: ExchangeRecord;
|
exchangeInfo: ExchangeRecord;
|
||||||
|
|
||||||
@ -118,16 +121,6 @@ export interface ExchangeWithdrawDetails {
|
|||||||
*/
|
*/
|
||||||
selectedDenoms: DenominationSelectionInfo;
|
selectedDenoms: DenominationSelectionInfo;
|
||||||
|
|
||||||
/**
|
|
||||||
* Fees for withdraw.
|
|
||||||
*/
|
|
||||||
withdrawFee: AmountJson;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Remaining balance that is too small to be withdrawn.
|
|
||||||
*/
|
|
||||||
overhead: AmountJson;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Does the wallet know about an auditor for
|
* Does the wallet know about an auditor for
|
||||||
* the exchange that the reserve.
|
* the exchange that the reserve.
|
||||||
@ -177,6 +170,13 @@ export interface ExchangeWithdrawDetails {
|
|||||||
* Libtool-style version string for the wallet.
|
* Libtool-style version string for the wallet.
|
||||||
*/
|
*/
|
||||||
walletVersion: string;
|
walletVersion: string;
|
||||||
|
|
||||||
|
withdrawalAmountRaw: AmountString;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Amount that will actually be added to the wallet's balance.
|
||||||
|
*/
|
||||||
|
withdrawalAmountEffective: AmountString;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -976,13 +976,16 @@ async function processWithdrawGroupImpl(
|
|||||||
export async function getExchangeWithdrawalInfo(
|
export async function getExchangeWithdrawalInfo(
|
||||||
ws: InternalWalletState,
|
ws: InternalWalletState,
|
||||||
exchangeBaseUrl: string,
|
exchangeBaseUrl: string,
|
||||||
amount: AmountJson,
|
instructedAmount: AmountJson,
|
||||||
): Promise<ExchangeWithdrawDetails> {
|
): Promise<ExchangeWithdrawDetails> {
|
||||||
const { exchange, exchangeDetails } =
|
const { exchange, exchangeDetails } =
|
||||||
await ws.exchangeOps.updateExchangeFromUrl(ws, exchangeBaseUrl);
|
await ws.exchangeOps.updateExchangeFromUrl(ws, exchangeBaseUrl);
|
||||||
await updateWithdrawalDenoms(ws, exchangeBaseUrl);
|
await updateWithdrawalDenoms(ws, exchangeBaseUrl);
|
||||||
const denoms = await getCandidateWithdrawalDenoms(ws, exchangeBaseUrl);
|
const denoms = await getCandidateWithdrawalDenoms(ws, exchangeBaseUrl);
|
||||||
const selectedDenoms = selectWithdrawalDenominations(amount, denoms);
|
const selectedDenoms = selectWithdrawalDenominations(
|
||||||
|
instructedAmount,
|
||||||
|
denoms,
|
||||||
|
);
|
||||||
const exchangeWireAccounts: string[] = [];
|
const exchangeWireAccounts: string[] = [];
|
||||||
for (const account of exchangeDetails.wireInfo.accounts) {
|
for (const account of exchangeDetails.wireInfo.accounts) {
|
||||||
exchangeWireAccounts.push(account.payto_uri);
|
exchangeWireAccounts.push(account.payto_uri);
|
||||||
@ -1061,14 +1064,14 @@ export async function getExchangeWithdrawalInfo(
|
|||||||
isAudited,
|
isAudited,
|
||||||
isTrusted,
|
isTrusted,
|
||||||
numOfferedDenoms: possibleDenoms.length,
|
numOfferedDenoms: possibleDenoms.length,
|
||||||
overhead: Amounts.sub(amount, selectedDenoms.totalWithdrawCost).amount,
|
|
||||||
selectedDenoms,
|
selectedDenoms,
|
||||||
// FIXME: delete this field / replace by something we can display to the user
|
// FIXME: delete this field / replace by something we can display to the user
|
||||||
trustedAuditorPubs: [],
|
trustedAuditorPubs: [],
|
||||||
versionMatch,
|
versionMatch,
|
||||||
walletVersion: WALLET_EXCHANGE_PROTOCOL_VERSION,
|
walletVersion: WALLET_EXCHANGE_PROTOCOL_VERSION,
|
||||||
withdrawFee,
|
|
||||||
termsOfServiceAccepted: tosAccepted,
|
termsOfServiceAccepted: tosAccepted,
|
||||||
|
withdrawalAmountEffective: Amounts.stringify(selectedDenoms.totalCoinValue),
|
||||||
|
withdrawalAmountRaw: Amounts.stringify(instructedAmount),
|
||||||
};
|
};
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -318,12 +318,17 @@ export function WithdrawPageWithParsedURI({
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const withdrawalFee = Amounts.sub(
|
||||||
|
Amounts.parseOrThrow(details.info.withdrawalAmountRaw),
|
||||||
|
Amounts.parseOrThrow(details.info.withdrawalAmountEffective),
|
||||||
|
).amount;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<View
|
<View
|
||||||
onWithdraw={onWithdraw}
|
onWithdraw={onWithdraw}
|
||||||
amount={withdrawAmount}
|
amount={withdrawAmount}
|
||||||
exchangeBaseUrl={exchange}
|
exchangeBaseUrl={exchange}
|
||||||
withdrawalFee={details.info.withdrawFee} //FIXME
|
withdrawalFee={withdrawalFee}
|
||||||
terms={detailsHook.response.tos}
|
terms={detailsHook.response.tos}
|
||||||
onSwitchExchange={setCustomExchange}
|
onSwitchExchange={setCustomExchange}
|
||||||
knownExchanges={knownExchanges}
|
knownExchanges={knownExchanges}
|
||||||
|
Loading…
Reference in New Issue
Block a user