commit e06d4ead7e8ae287448755f54ba22a384b066af4
parent f61c3b14357a52d1d61e626daed370565d98ebe2
Author: Marc Stibane <marc@taler.net>
Date: Sat, 12 Oct 2024 18:45:06 +0200
scope
Diffstat:
3 files changed, 19 insertions(+), 19 deletions(-)
diff --git a/TalerWallet1/Model/Model+P2P.swift b/TalerWallet1/Model/Model+P2P.swift
@@ -26,9 +26,8 @@ fileprivate struct AmountResponse: Codable {
fileprivate struct GetMaxPeerPushDebitAmount: WalletBackendFormattedRequest {
typealias Response = AmountResponse
func operation() -> String { "getMaxPeerPushDebitAmount" }
- func args() -> Args { Args(currency: currency, restrictScope: scope) }
+ func args() -> Args { Args(currency: scope.currency, restrictScope: scope) }
- var currency: String
var scope: ScopeInfo
struct Args: Encodable {
var currency: String
@@ -37,9 +36,9 @@ fileprivate struct GetMaxPeerPushDebitAmount: WalletBackendFormattedRequest {
}
extension WalletModel {
@MainActor // M for MainActor
- func getMaxPeerPushDebitAmountM(_ currency: String, scope: ScopeInfo, viewHandles: Bool = false)
+ func getMaxPeerPushDebitAmountM(_ scope: ScopeInfo, viewHandles: Bool = false)
async throws -> Amount {
- let request = GetMaxPeerPushDebitAmount(currency: currency, scope: scope)
+ let request = GetMaxPeerPushDebitAmount(scope: scope)
let response = try await sendRequest(request, ASYNCDELAY, viewHandles: viewHandles)
return response.rawAmount
}
@@ -66,7 +65,9 @@ fileprivate struct CheckPeerPushDebit: WalletBackendFormattedRequest {
}
extension WalletModel {
@MainActor // M for MainActor
- func checkPeerPushDebitM(_ amount: Amount, scope: ScopeInfo, viewHandles: Bool = false)
+ func checkPeerPushDebitM(_ amount: Amount,
+ scope: ScopeInfo,
+ viewHandles: Bool = false)
async throws -> CheckPeerPushDebitResponse {
let request = CheckPeerPushDebit(amount: amount, scope: scope)
let response = try await sendRequest(request, ASYNCDELAY, viewHandles: viewHandles)
@@ -122,26 +123,26 @@ struct CheckPeerPullCreditResponse: Codable {
fileprivate struct CheckPeerPullCredit: WalletBackendFormattedRequest {
typealias Response = CheckPeerPullCreditResponse
func operation() -> String { "checkPeerPullCredit" }
- func args() -> Args { Args(exchangeBaseUrl: exchangeBaseUrl, scopeInfo: scopeInfo,
- amount: amount, clientCancellationId: "cancel") }
+ func args() -> Args { Args(amount: amount, scopeInfo: scope,
+ exchangeBaseUrl: scope?.url,
+ clientCancellationId: "cancel") }
- var exchangeBaseUrl: String?
- var scopeInfo: ScopeInfo?
var amount: Amount
+ var scope: ScopeInfo?
struct Args: Encodable {
- var exchangeBaseUrl: String?
- var scopeInfo: ScopeInfo?
var amount: Amount
+ var scopeInfo: ScopeInfo?
+ var exchangeBaseUrl: String?
var clientCancellationId: String?
}
}
extension WalletModel {
@MainActor // M for MainActor
- func checkPeerPullCreditM(_ exchangeBaseUrl: String?, amount: Amount,
- viewHandles: Bool = false)
+ func checkPeerPullCreditM(_ amount: Amount,
+ scope: ScopeInfo,
+ viewHandles: Bool = false)
async throws -> CheckPeerPullCreditResponse {
- let request = CheckPeerPullCredit(exchangeBaseUrl: exchangeBaseUrl,
- amount: amount)
+ let request = CheckPeerPullCredit(amount: amount, scope: scope)
let response = try await sendRequest(request, ASYNCDELAY, viewHandles: viewHandles)
return response
}
diff --git a/TalerWallet1/Views/Actions/Peer2peer/RequestPayment.swift b/TalerWallet1/Views/Actions/Peer2peer/RequestPayment.swift
@@ -74,7 +74,7 @@ struct RequestPayment: View {
}
do {
let baseURL = exchange?.exchangeBaseUrl
- let ppCheck = try await model.checkPeerPullCreditM(baseURL, amount: amount)
+ let ppCheck = try await model.checkPeerPullCreditM(amount, scope: scopeInfo, viewHandles: true)
let raw = ppCheck.amountRaw
let effective = ppCheck.amountEffective
if let fee = fee(raw: raw, effective: effective) {
diff --git a/TalerWallet1/Views/Actions/Peer2peer/SendAmountV.swift b/TalerWallet1/Views/Actions/Peer2peer/SendAmountV.swift
@@ -249,8 +249,7 @@ struct SendAmountContent: View {
.navigationTitle(navTitle)
.task {
do {
- let amount = try await model.getMaxPeerPushDebitAmountM(amountToTransfer.currencyStr,
- scope: scopeInfo, viewHandles: true)
+ let amount = try await model.getMaxPeerPushDebitAmountM(scopeInfo, viewHandles: true)
amountAvailable = amount
} catch {
amountAvailable = Amount.zero(currency: amountToTransfer.currencyStr)
@@ -273,7 +272,7 @@ struct SendAmountContent: View {
currencyName = currencyInfo.scope.currency
currencySymbol = currencyInfo.altUnitSymbol ?? currencyInfo.specs.name
do {
- amountAvailable = try await model.getMaxPeerPushDebitAmountM(currency, scope: scopeInfo)
+ amountAvailable = try await model.getMaxPeerPushDebitAmountM(scopeInfo)
} catch {
// TODO: Error
amountAvailable = balance.available