mirror of
https://github.com/lux-tel/session-ios.git
synced 2026-10-30 20:38:32 +00:00
• Added integration for new refund request • Wired up the refunding states based on the new data • Updated code to use strings from libSession instead of hardcoded values • Updated the code to trigger a pro state refresh when the `proAccessExpiryTimestampMs` on the config changes (ie. another device made a change to the pro configuration) • Updated logic to drive mocked pro states via the SessionProManager to make the code a bit cleaner • Updated the handling of pro proofs to sync both active and expired proofs (instead of just active) • Fixed a bunch of warnings
44 lines
1.9 KiB
Swift
44 lines
1.9 KiB
Swift
// Copyright © 2025 Rangeproof Pty Ltd. All rights reserved.
|
|
|
|
import Foundation
|
|
import SessionUtil
|
|
import SessionUtilitiesKit
|
|
|
|
public extension Network.SessionPro {
|
|
struct SetPaymentRefundRequestedRequest: Encodable, Equatable {
|
|
public let masterPublicKey: [UInt8]
|
|
public let masterSignature: Signature
|
|
public let timestampMs: UInt64
|
|
public let refundRequestedTimestampMs: UInt64
|
|
public let transaction: UserTransaction
|
|
|
|
// MARK: - Functions
|
|
|
|
func toLibSession() -> session_pro_backend_set_payment_refund_requested_request {
|
|
var result: session_pro_backend_set_payment_refund_requested_request = session_pro_backend_set_payment_refund_requested_request()
|
|
result.version = Network.SessionPro.apiVersion
|
|
result.set(\.master_pkey, to: masterPublicKey)
|
|
result.set(\.master_sig, to: masterSignature.signature)
|
|
result.unix_ts_ms = timestampMs
|
|
result.refund_requested_unix_ts_ms = refundRequestedTimestampMs
|
|
result.payment_tx = transaction.toLibSession()
|
|
|
|
return result
|
|
}
|
|
|
|
public func encode(to encoder: any Encoder) throws {
|
|
var cRequest: session_pro_backend_set_payment_refund_requested_request = toLibSession()
|
|
var cJson: session_pro_backend_to_json = session_pro_backend_set_payment_refund_requested_request_to_json(&cRequest);
|
|
defer { session_pro_backend_to_json_free(&cJson) }
|
|
|
|
guard cJson.success else { throw NetworkError.invalidPayload }
|
|
|
|
let jsonData: Data = Data(bytes: cJson.json.data, count: cJson.json.size)
|
|
let decoded: [String: AnyCodable] = try JSONDecoder().decode([String: AnyCodable].self, from: jsonData)
|
|
try decoded.encode(to: encoder)
|
|
}
|
|
}
|
|
}
|
|
|
|
extension session_pro_backend_set_payment_refund_requested_request: @retroactive CMutable {}
|