diff options
author | Florian Dold <florian@dold.me> | 2024-03-07 17:53:35 +0100 |
---|---|---|
committer | Florian Dold <florian@dold.me> | 2024-03-07 17:53:35 +0100 |
commit | 727c0f3d4d92e6fe2e3d1bdf4cb2e00dca01bd52 (patch) | |
tree | d7ca38aa86771e0eaa20dd73ff8f1ebe2cad2f57 /packages/taler-wallet-core/src | |
parent | c22b13eebe0577c2b948a99e42670580d49d60ce (diff) | |
download | wallet-core-727c0f3d4d92e6fe2e3d1bdf4cb2e00dca01bd52.tar.xz |
wallet-core: get rid of max_wire_fee
Diffstat (limited to 'packages/taler-wallet-core/src')
-rw-r--r-- | packages/taler-wallet-core/src/coinSelection.test.ts | 2 | ||||
-rw-r--r-- | packages/taler-wallet-core/src/coinSelection.ts | 20 | ||||
-rw-r--r-- | packages/taler-wallet-core/src/deposits.ts | 2 | ||||
-rw-r--r-- | packages/taler-wallet-core/src/pay-merchant.ts | 10 |
4 files changed, 2 insertions, 32 deletions
diff --git a/packages/taler-wallet-core/src/coinSelection.test.ts b/packages/taler-wallet-core/src/coinSelection.test.ts index 3d8e24b0c..67cd08652 100644 --- a/packages/taler-wallet-core/src/coinSelection.test.ts +++ b/packages/taler-wallet-core/src/coinSelection.test.ts @@ -140,7 +140,6 @@ test("pay: select one coin to pay with fee", (t) => { const zero = Amounts.zeroOfCurrency(payment.currency); const tally = { amountPayRemaining: payment, - amountWireFeeLimitRemaining: zero, amountDepositFeeLimitRemaining: zero, customerDepositFees: zero, customerWireFees: zero, @@ -176,7 +175,6 @@ test("pay: select one coin to pay with fee", (t) => { t.deepEqual(tally, { amountPayRemaining: Amounts.parseOrThrow("LOCAL:0"), - amountWireFeeLimitRemaining: zero, amountDepositFeeLimitRemaining: zero, customerDepositFees: Amounts.parse("LOCAL:0.1"), customerWireFees: Amounts.parse("LOCAL:0.1"), diff --git a/packages/taler-wallet-core/src/coinSelection.ts b/packages/taler-wallet-core/src/coinSelection.ts index 672d0ee79..7c22f63db 100644 --- a/packages/taler-wallet-core/src/coinSelection.ts +++ b/packages/taler-wallet-core/src/coinSelection.ts @@ -76,11 +76,6 @@ export interface CoinSelectionTally { amountPayRemaining: AmountJson; /** - * Allowance given by the merchant towards wire fees - */ - amountWireFeeLimitRemaining: AmountJson; - - /** * Allowance given by the merchant towards deposit fees * (and wire fees after wire fee limit is exhausted) */ @@ -110,17 +105,9 @@ function tallyFees( if (!tally.wireFeeCoveredForExchange.has(exchangeBaseUrl)) { const wf = wireFeesPerExchange[exchangeBaseUrl] ?? Amounts.zeroOfCurrency(currency); - const wfForgiven = Amounts.min(tally.amountWireFeeLimitRemaining, wf); - tally.amountWireFeeLimitRemaining = Amounts.sub( - tally.amountWireFeeLimitRemaining, - wfForgiven, - ).amount; // The remaining, amortized amount needs to be paid by the // wallet or covered by the deposit fee allowance. - let wfRemaining = Amounts.divide( - Amounts.sub(wf, wfForgiven).amount, - wireFeeAmortization, - ); + let wfRemaining = Amounts.divide(wf, wireFeeAmortization); // This is the amount forgiven via the deposit fee allowance. const wfDepositForgiven = Amounts.min( tally.amountDepositFeeLimitRemaining, @@ -183,7 +170,7 @@ export async function selectPayCoins( wex: WalletExecutionContext, req: SelectPayCoinRequestNg, ): Promise<SelectPayCoinsResult> { - const { contractTermsAmount, depositFeeLimit, wireFeeLimit } = req; + const { contractTermsAmount, depositFeeLimit } = req; if (logger.shouldLogTrace()) { logger.trace(`selecting coins for ${j2s(req)}`); @@ -218,7 +205,6 @@ export async function selectPayCoins( let tally: CoinSelectionTally = { amountPayRemaining: contractTermsAmount, - amountWireFeeLimitRemaining: wireFeeLimit, amountDepositFeeLimitRemaining: depositFeeLimit, customerDepositFees: Amounts.zeroOfCurrency(currency), customerWireFees: Amounts.zeroOfCurrency(currency), @@ -640,7 +626,6 @@ export interface SelectPayCoinRequestNg { restrictWireMethod: string; contractTermsAmount: AmountJson; depositFeeLimit: AmountJson; - wireFeeLimit: AmountJson; wireFeeAmortization: number; prevPayCoins?: PreviousPayCoins; requiredMinimumAge?: number; @@ -910,7 +895,6 @@ export function emptyTallyForPeerPayment( customerDepositFees: zero, lastDepositFee: zero, amountDepositFeeLimitRemaining: zero, - amountWireFeeLimitRemaining: zero, customerWireFees: zero, wireFeeCoveredForExchange: new Set(), }; diff --git a/packages/taler-wallet-core/src/deposits.ts b/packages/taler-wallet-core/src/deposits.ts index 2c7ee3596..2ee452de7 100644 --- a/packages/taler-wallet-core/src/deposits.ts +++ b/packages/taler-wallet-core/src/deposits.ts @@ -1228,7 +1228,6 @@ export async function prepareDepositGroup( contractTermsAmount: Amounts.parseOrThrow(contractData.amount), depositFeeLimit: Amounts.parseOrThrow(contractData.maxDepositFee), wireFeeAmortization: contractData.wireFeeAmortization ?? 1, - wireFeeLimit: Amounts.parseOrThrow(contractData.maxWireFee), prevPayCoins: [], }); @@ -1349,7 +1348,6 @@ export async function createDepositGroup( contractTermsAmount: Amounts.parseOrThrow(contractData.amount), depositFeeLimit: Amounts.parseOrThrow(contractData.maxDepositFee), wireFeeAmortization: contractData.wireFeeAmortization ?? 1, - wireFeeLimit: Amounts.parseOrThrow(contractData.maxWireFee), prevPayCoins: [], }); diff --git a/packages/taler-wallet-core/src/pay-merchant.ts b/packages/taler-wallet-core/src/pay-merchant.ts index a155d6298..4f9c20c9e 100644 --- a/packages/taler-wallet-core/src/pay-merchant.ts +++ b/packages/taler-wallet-core/src/pay-merchant.ts @@ -568,12 +568,6 @@ export function extractContractData( merchantSig: string, ): WalletContractData { const amount = Amounts.parseOrThrow(parsedContractTerms.amount); - let maxWireFee: AmountJson; - if (parsedContractTerms.max_wire_fee) { - maxWireFee = Amounts.parseOrThrow(parsedContractTerms.max_wire_fee); - } else { - maxWireFee = Amounts.zeroOfCurrency(amount.currency); - } return { amount: Amounts.stringify(amount), contractTermsHash: contractTermsHash, @@ -584,7 +578,6 @@ export function extractContractData( orderId: parsedContractTerms.order_id, summary: parsedContractTerms.summary, autoRefund: parsedContractTerms.auto_refund, - maxWireFee: Amounts.stringify(maxWireFee), payDeadline: parsedContractTerms.pay_deadline, refundDeadline: parsedContractTerms.refund_deadline, wireFeeAmortization: parsedContractTerms.wire_fee_amortization || 1, @@ -1157,7 +1150,6 @@ async function handleInsufficientFunds( contractTermsAmount: Amounts.parseOrThrow(contractData.amount), depositFeeLimit: Amounts.parseOrThrow(contractData.maxDepositFee), wireFeeAmortization: contractData.wireFeeAmortization ?? 1, - wireFeeLimit: Amounts.parseOrThrow(contractData.maxWireFee), prevPayCoins, requiredMinimumAge: contractData.minimumAge, }); @@ -1287,7 +1279,6 @@ async function checkPaymentByProposalId( contractTermsAmount: instructedAmount, depositFeeLimit: Amounts.parseOrThrow(contractData.maxDepositFee), wireFeeAmortization: contractData.wireFeeAmortization ?? 1, - wireFeeLimit: Amounts.parseOrThrow(contractData.maxWireFee), prevPayCoins: [], requiredMinimumAge: contractData.minimumAge, restrictWireMethod: contractData.wireMethod, @@ -1825,7 +1816,6 @@ export async function confirmPay( contractTermsAmount: Amounts.parseOrThrow(contractData.amount), depositFeeLimit: Amounts.parseOrThrow(contractData.maxDepositFee), wireFeeAmortization: contractData.wireFeeAmortization ?? 1, - wireFeeLimit: Amounts.parseOrThrow(contractData.maxWireFee), prevPayCoins: [], requiredMinimumAge: contractData.minimumAge, forcedSelection: forcedCoinSel, |