commit 85076129a39de72b2d0a0f163f744283318162a3
parent e921612d95dea72594ffcf5c97b4737f0b3940ea
Author: Marc Stibane <marc@taler.net>
Date: Tue, 24 Sep 2024 09:30:29 +0200
getMaxDepositAmount, getMaxPeerPushDebitAmount
Diffstat:
2 files changed, 40 insertions(+), 10 deletions(-)
diff --git a/TalerWallet1/Model/Model+Deposit.swift b/TalerWallet1/Model/Model+Deposit.swift
@@ -65,6 +65,34 @@ extension WalletModel {
return response.wireTypes
}
}
+// MARK: - max Deposit amount
+/// Check if initiating a deposit is possible, check fees
+fileprivate struct AmountResponse: Codable {
+ let effectiveAmount: Amount?
+ let rawAmount: Amount
+}
+fileprivate struct GetMaxDepositAmount: WalletBackendFormattedRequest {
+ typealias Response = AmountResponse
+ func operation() -> String { "getMaxDepositAmount" }
+ func args() -> Args { Args(currency: currency, restrictScope: scope) }
+
+ var currency: String
+ var scope: ScopeInfo
+ struct Args: Encodable {
+ var currency: String
+ var restrictScope: ScopeInfo
+// var depositPaytoUri: String
+ }
+}
+extension WalletModel {
+ @MainActor // M for MainActor
+ func getMaxDepositAmountM(_ currency: String, scope: ScopeInfo, viewHandles: Bool = false)
+ async throws -> Amount {
+ let request = GetMaxDepositAmount(currency: currency, scope: scope)
+ let response = try await sendRequest(request, ASYNCDELAY, viewHandles: viewHandles)
+ return response.rawAmount
+ }
+} // getMaxDepositAmountM
// MARK: - Deposit
struct DepositFees: Codable {
let coin: Amount
diff --git a/TalerWallet1/Model/Model+P2P.swift b/TalerWallet1/Model/Model+P2P.swift
@@ -19,27 +19,29 @@ struct PeerContractTerms: Codable {
}
// MARK: - PeerPushDebit
/// Check if initiating a peer push payment is possible, check fees
-struct AmountResponse: Codable {
- let effectiveAmount: Amount
+fileprivate struct AmountResponse: Codable {
+ let effectiveAmount: Amount?
let rawAmount: Amount
}
-fileprivate struct GetMaxPeerPushAmount: WalletBackendFormattedRequest {
+fileprivate struct GetMaxPeerPushDebitAmount: WalletBackendFormattedRequest {
typealias Response = AmountResponse
- func operation() -> String { "GetMaxPeerPushAmount" }
- func args() -> Args { Args(currency: currency) }
+ func operation() -> String { "getMaxPeerPushDebitAmount" }
+ func args() -> Args { Args(currency: currency, restrictScope: scope) }
var currency: String
+ var scope: ScopeInfo
struct Args: Encodable {
var currency: String
+ var restrictScope: ScopeInfo
}
}
extension WalletModel {
- @MainActor // M for MainActor
- func getMaxPeerPushAmountM(_ currency: String, viewHandles: Bool = false)
- async throws -> AmountResponse {
- let request = GetMaxPeerPushAmount(currency: currency)
+ @MainActor // M for MainActor
+ func getMaxPeerPushDebitAmountM(_ currency: String, scope: ScopeInfo, viewHandles: Bool = false)
+ async throws -> Amount {
+ let request = GetMaxPeerPushDebitAmount(currency: currency, scope: scope)
let response = try await sendRequest(request, ASYNCDELAY, viewHandles: viewHandles)
- return response
+ return response.rawAmount
}
} // getMaxPeerPushAmountM
// - - - - - -