-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'develop' into features/IOS-8424_receive_notification
- Loading branch information
Showing
111 changed files
with
2,537 additions
and
556 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
// | ||
// LoadingResult.swift | ||
// TangemApp | ||
// | ||
// Created by Sergey Balashov on 21.11.2024. | ||
// Copyright © 2024 Tangem AG. All rights reserved. | ||
// | ||
|
||
import Foundation | ||
|
||
/// LoadingResult to wrap the loading process | ||
/// Can be used in two ways | ||
/// - `LoadingResult<Value, Never>` with two possible option `loading` and `value` | ||
/// - `LoadingResult<Value, Error>` with three possible option `loading` / `value` / `error` | ||
public enum LoadingResult<Success, Failure: Error> { | ||
case success(Success) | ||
case failure(Failure) | ||
case loading | ||
} | ||
|
||
// MARK: - Initialization | ||
|
||
public extension LoadingResult { | ||
static func result(_ result: Result<Success, Failure>) -> LoadingResult { | ||
switch result { | ||
case .success(let value): .success(value) | ||
case .failure(let error): .failure(error) | ||
} | ||
} | ||
} | ||
|
||
// MARK: - Calculated | ||
|
||
public extension LoadingResult { | ||
var isLoading: Bool { | ||
switch self { | ||
case .loading: true | ||
case .success, .failure: false | ||
} | ||
} | ||
|
||
var value: Success? { | ||
switch self { | ||
case .success(let value): value | ||
case .loading, .failure: nil | ||
} | ||
} | ||
|
||
var error: Failure? { | ||
switch self { | ||
case .failure(let error): error | ||
case .loading, .success: nil | ||
} | ||
} | ||
|
||
func get() throws -> Success { | ||
switch self { | ||
case .success(let success): return success | ||
case .failure(let failure): throw failure | ||
case .loading: throw LoadingResultError.loadingInProcess | ||
} | ||
} | ||
} | ||
|
||
// MARK: - Equatable | ||
|
||
extension LoadingResult: Equatable where Success: Equatable, Failure: Equatable {} | ||
|
||
// MARK: - Hashable | ||
|
||
extension LoadingResult: Hashable where Success: Hashable, Failure: Hashable {} | ||
|
||
// MARK: - Mapping | ||
|
||
public extension LoadingResult { | ||
func mapValue<T>(_ transform: (Success) throws -> T) rethrows -> LoadingResult<T, Failure> { | ||
switch self { | ||
case .loading: .loading | ||
case .success(let value): .success(try transform(value)) | ||
case .failure(let error): .failure(error) | ||
} | ||
} | ||
} | ||
|
||
// MARK: - Error | ||
|
||
public enum LoadingResultError: LocalizedError { | ||
case loadingInProcess | ||
|
||
public var errorDescription: String? { | ||
switch self { | ||
case .loadingInProcess: "Loading in process" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
// | ||
// PendingOnrampTransaction.swift | ||
// TangemApp | ||
// | ||
// Created by Aleksei Muraveinik on 21.11.24. | ||
// Copyright © 2024 Tangem AG. All rights reserved. | ||
// | ||
|
||
import Foundation | ||
|
||
struct PendingOnrampTransaction: Equatable { | ||
let transactionRecord: OnrampPendingTransactionRecord | ||
let statuses: [PendingExpressTransactionStatus] | ||
} | ||
|
||
extension PendingOnrampTransaction: Identifiable { | ||
var id: String { | ||
transactionRecord.id | ||
} | ||
} | ||
|
||
extension PendingOnrampTransaction { | ||
var pendingTransaction: PendingTransaction { | ||
PendingTransaction( | ||
type: .onramp( | ||
sourceAmount: transactionRecord.fromAmount, | ||
sourceCurrencySymbol: transactionRecord.fromCurrencyCode, | ||
destination: transactionRecord.destinationTokenTxInfo | ||
), | ||
expressTransactionId: transactionRecord.expressTransactionId, | ||
externalTxId: transactionRecord.externalTxId, | ||
externalTxURL: transactionRecord.externalTxURL, | ||
provider: transactionRecord.provider, | ||
date: transactionRecord.date, | ||
transactionStatus: transactionRecord.transactionStatus, | ||
refundedTokenItem: nil, | ||
statuses: statuses | ||
) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
// | ||
// SentOnrampTransactionData.swift | ||
// Tangem | ||
// | ||
// Created by Aleksei Muraveinik on 20.11.24. | ||
// Copyright © 2024 Tangem AG. All rights reserved. | ||
// | ||
|
||
import TangemExpress | ||
|
||
struct SentOnrampTransactionData { | ||
let txId: String | ||
let provider: ExpressProvider | ||
let destinationTokenItem: TokenItem | ||
let date: Date | ||
let fromAmount: Decimal | ||
let fromCurrencyCode: String | ||
let externalTxId: String | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.