Skip to content

Commit

Permalink
Ultra prune
Browse files Browse the repository at this point in the history
  • Loading branch information
gades committed Mar 18, 2024
1 parent 3fff1b6 commit 1c6597b
Show file tree
Hide file tree
Showing 48 changed files with 53,708 additions and 47,979 deletions.
12 changes: 6 additions & 6 deletions UnstoppableWallet/TonKitKmm.xcframework/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -10,33 +10,33 @@
<key>DebugSymbolsPath</key>
<string>dSYMs</string>
<key>LibraryIdentifier</key>
<string>ios-arm64</string>
<string>ios-x86_64-simulator</string>
<key>LibraryPath</key>
<string>TonKitKmm.framework</string>
<key>SupportedArchitectures</key>
<array>
<string>arm64</string>
<string>x86_64</string>
</array>
<key>SupportedPlatform</key>
<string>ios</string>
<key>SupportedPlatformVariant</key>
<string>simulator</string>
</dict>
<dict>
<key>BinaryPath</key>
<string>TonKitKmm.framework/TonKitKmm</string>
<key>DebugSymbolsPath</key>
<string>dSYMs</string>
<key>LibraryIdentifier</key>
<string>ios-x86_64-simulator</string>
<string>ios-arm64</string>
<key>LibraryPath</key>
<string>TonKitKmm.framework</string>
<key>SupportedArchitectures</key>
<array>
<string>x86_64</string>
<string>arm64</string>
</array>
<key>SupportedPlatform</key>
<string>ios</string>
<key>SupportedPlatformVariant</key>
<string>simulator</string>
</dict>
</array>
<key>CFBundlePackageType</key>
Expand Down

Large diffs are not rendered by default.

Binary file not shown.
Binary file not shown.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Binary file not shown.
Binary file not shown.

Large diffs are not rendered by default.

216 changes: 116 additions & 100 deletions UnstoppableWallet/UnstoppableWallet.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -316,8 +316,8 @@ extension TonAdapter: ISendTonAdapter {
return Self.amount(kitAmount: kitAmount)
}

func send(recipient: String, amount: Decimal) async throws {
func send(recipient: String, amount: Decimal, memo: String?) async throws {
let rawAmount = amount * Self.coinRate
try await tonKit.send(recipient: recipient, amount: rawAmount.description)
try await tonKit.send(recipient: recipient, amount: rawAmount.description, memo: memo)
}
}
2 changes: 1 addition & 1 deletion UnstoppableWallet/UnstoppableWallet/Core/Protocols.swift
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ protocol ISendTonAdapter {
var availableBalance: Decimal { get }
func validate(address: String) throws
func estimateFee() async throws -> Decimal
func send(recipient: String, amount: Decimal) async throws
func send(recipient: String, amount: Decimal, memo: String?) async throws
}

protocol IErc20Adapter {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -467,4 +467,9 @@ extension [Contact] {
guard let blockchainUid else { return self }
return filter { $0.address(blockchainUid: blockchainUid) != nil }
}

func by(address: String, blockchainUid: String) -> Self.Element? {
filter { $0.address(blockchainUid: blockchainUid)?.address.lowercased() == address.lowercased() }
.first
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@ import TonKitKmm

class TonTransactionRecord: TransactionRecord {
let fee: TransactionValue?
let memo: String?

init(source: TransactionSource, transaction: TonTransaction, feeToken: Token) {
fee = transaction.fee.map { .coinValue(token: feeToken, value: TonAdapter.amount(kitAmount: $0)) }
memo = transaction.memo

super.init(
source: source,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,19 @@ struct AlertViewItem {
let selected: Bool
let disabled: Bool

init(text: String, description: String? = nil, selected: Bool, disabled: Bool = false) {
init(text: String, description: String? = nil, selected: Bool = false, disabled: Bool = false) {
self.text = text
self.description = description
self.selected = selected
self.disabled = disabled
}
}

extension AlertViewItem: Hashable {
public func hash(into hasher: inout Hasher) {
hasher.combine(text)
hasher.combine(description)
hasher.combine(selected)
hasher.combine(disabled)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -289,8 +289,7 @@ class ChartUiView: UIView {
if !chartView.isPressed {
chartView.setCurve(colorType: viewItem.chartTrend.chartColorType)
}
chartView.set(chartData: viewItem.chartData, indicators: viewItem.indicators, showIndicators: showIndicators, animated: true)
chartView.set(highLimitText: viewItem.maxValue, lowLimitText: viewItem.minValue)
chartView.set(chartData: viewItem.chartData, indicators: viewItem.indicators, showIndicators: showIndicators, limitFormatter: viewItem.limitFormatter, animated: true)
} else {
currentValueWrapper.isHidden = true
chartView.isHidden = true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@ enum ChartModule {
let chartTrend: MovementTrend
let chartDiff: Decimal?

let minValue: String?
let maxValue: String?
let limitFormatter: ((Decimal) -> String?)?
}

struct SelectedPointViewItem {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,8 @@ class CoinChartService {
rateDiff24h: coinPrice.diff,
timestamp: coinPrice.timestamp,
chartPointsItem: chartPointsItem,
indicators: indicatorRepository.indicators
indicators: indicatorRepository.indicators,
showIndicators: indicatorsShown
)

state = .completed(item)
Expand Down Expand Up @@ -221,6 +222,7 @@ extension CoinChartService {
let timestamp: TimeInterval
let chartPointsItem: ChartPointsItem
let indicators: [ChartIndicator]
let showIndicators: Bool
}

struct ChartPointsItem {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,22 +50,16 @@ class CoinChartFactory {
return item
}

let values = points.map(\.value)

let chartData = ChartData(items: items, startWindow: firstPoint.timestamp, endWindow: lastPoint.timestamp)
return ChartModule.ViewItem(
value: ValueFormatter.instance.formatFull(currencyValue: CurrencyValue(currency: currency, value: item.rate)),
valueDescription: nil,
rightSideMode: .none,
chartData: ChartData(items: items, startWindow: firstPoint.timestamp, endWindow: lastPoint.timestamp),
chartData: chartData,
indicators: item.indicators,
chartTrend: lastPoint.value > firstPoint.value ? .up : .down,
chartDiff: (lastPoint.value - firstPoint.value) / firstPoint.value * 100,
minValue: values.min().flatMap {
ValueFormatter.instance.formatFull(currency: currency, value: $0)
},
maxValue: values.max().flatMap {
ValueFormatter.instance.formatFull(currency: currency, value: $0)
}
limitFormatter: { value in ValueFormatter.instance.formatFull(currency: currency, value: value) }
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,16 @@ extension ContactBookContactModule {
case add(ContactAddress)
}
}

struct ContactBookContactView: UIViewControllerRepresentable {
typealias UIViewControllerType = UIViewController

let mode: ContactBookContactModule.Mode
let onUpdateContact: (() -> Void)?

func makeUIViewController(context: Context) -> UIViewControllerType {
ContactBookContactModule.viewController(mode: mode, onUpdateContact: onUpdateContact) ?? UIViewController()
}

func updateUIViewController(_: UIViewControllerType, context _: Context) {}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,20 @@ protocol ContactBookSelectorDelegate: AnyObject {
}

enum ContactBookModule {
private static func showAddContact(mode: ContactBookModule.AddContactMode, contactAddress: ContactAddress, parentViewController: UIViewController?) {
private static func showAddContact(mode: ContactBookModule.AddContactMode, contactAddress: ContactAddress) -> UIViewController? {
switch mode {
case .new:
guard let module = ContactBookContactModule.viewController(mode: .add(contactAddress)) else {
return
return nil
}

parentViewController?.present(module, animated: true)
return module
case .exist:
guard let module = ContactBookModule.viewController(mode: .addToContact(contactAddress), presented: true) else {
return
return nil
}

parentViewController?.present(module, animated: true)
return module
}
}

Expand Down Expand Up @@ -61,14 +61,17 @@ extension ContactBookModule {

static func showAddition(contactAddress: ContactAddress, parentViewController: UIViewController?) {
// if all contacts has address for blockchain just show add-new controller
if App.shared.contactManager.all?.isEmpty ?? true {
showAddContact(mode: .new, contactAddress: contactAddress, parentViewController: parentViewController)
if App.shared.contactManager.all?.isEmpty ?? true, let controller = showAddContact(mode: .new, contactAddress: contactAddress) {
parentViewController?.present(controller, animated: true)
return
}

// show alert and choose make new contact or add to existed
let alertController = ContactBookModule.chooseAddContactMode(resultAfterClose: true) { [weak parentViewController] mode in
showAddContact(mode: mode, contactAddress: contactAddress, parentViewController: parentViewController)
guard let controller = showAddContact(mode: mode, contactAddress: contactAddress) else {
return
}
parentViewController?.present(controller, animated: true)
}

parentViewController?.present(alertController, animated: true)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ extension MarketListMarketPairDecorator: IMarketListDecorator {
let currency = service.currency

let volume = item.volume.flatMap { ValueFormatter.instance.formatShort(currency: currency, value: $0) } ?? "n/a".localized
let price = item.price.flatMap { ValueFormatter.instance.formatShort(currency: currency, value: $0) } ?? "n/a".localized
let price = item.price.flatMap { ValueFormatter.instance.formatShort(value: $0, decimalCount: 8, symbol: item.target) } ?? "n/a".localized

return MarketModule.ListViewItem(
uid: item.uid,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class MetricChartFactory {
dateFormatter.locale = currentLocale
}

private func format(value: Decimal?, valueType: MetricChartModule.ValueType, exactlyValue: Bool = false) -> String? {
private static func format(value: Decimal?, valueType: MetricChartModule.ValueType, exactlyValue: Bool = false) -> String? {
guard let value else {
return nil
}
Expand Down Expand Up @@ -78,15 +78,15 @@ extension MetricChartFactory {

switch itemData.type {
case .regular:
value = format(value: lastItem.value, valueType: valueType)
value = Self.format(value: lastItem.value, valueType: valueType)
chartTrend = (lastItem.value - firstItem.value).isSignMinus ? .down : .up
valueDiff = (lastItem.value - firstItem.value) / firstItem.value * 100

if let first = itemData.indicators[MarketGlobalModule.dominance]?.first, let last = itemData.indicators[MarketGlobalModule.dominance]?.last {
rightSideMode = .dominance(value: last, diff: (last - first) / first * 100)
}
case let .aggregated(aggregatedValue):
value = format(value: aggregatedValue, valueType: valueType)
value = Self.format(value: aggregatedValue, valueType: valueType)
chartTrend = .neutral
}

Expand Down Expand Up @@ -120,8 +120,7 @@ extension MetricChartFactory {
indicators: indicators,
chartTrend: chartTrend,
chartDiff: valueDiff,
minValue: format(value: min, valueType: valueType),
maxValue: format(value: max, valueType: valueType)
limitFormatter: { value in Self.format(value: value, valueType: valueType) }
)
}

Expand All @@ -132,14 +131,14 @@ extension MetricChartFactory {

let date = Date(timeIntervalSince1970: chartItem.timestamp)
let formattedDate = DateHelper.instance.formatFullTime(from: date)
let formattedValue = format(value: value, valueType: valueType)
let formattedValue = Self.format(value: value, valueType: valueType)

var rightSideMode: ChartModule.RightSideMode = .none

if let dominance = chartItem.indicators[ChartIndicator.LineConfiguration.dominanceId] {
rightSideMode = .dominance(value: dominance, diff: nil)
} else if let volume = chartItem.indicators[ChartData.volume] {
rightSideMode = .volume(value: format(value: volume, valueType: valueType))
rightSideMode = .volume(value: Self.format(value: volume, valueType: valueType))
}

return ChartModule.SelectedPointViewItem(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class FeeSettingsViewHelper {
return (l2Value, l1Value, .value(primary: evmFeeData.gasLimit.description, secondary: nil))
}

@ViewBuilder func row(title: String, feeValue: FeeSettings.FeeValue, description: AlertView.InfoDescription) -> some View {
@ViewBuilder func row(title: String, feeValue: FeeSettings.FeeValue, description: ActionSheetView.InfoDescription) -> some View {
HStack(spacing: .margin8) {
Text(title)
.textSubhead2()
Expand All @@ -57,7 +57,7 @@ class FeeSettingsViewHelper {
.frame(height: .heightCell56)
}

@ViewBuilder func headerRow(title: String, description: AlertView.InfoDescription) -> some View {
@ViewBuilder func headerRow(title: String, description: ActionSheetView.InfoDescription) -> some View {
Text(title)
.textSubhead1()
.frame(maxWidth: .infinity, alignment: .leading)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
struct MultiSwapMainField: Identifiable {
let title: String
let description: AlertView.InfoDescription?
let description: ActionSheetView.InfoDescription?
let value: String
let valueLevel: ValueLevel
let settingId: String?
let modified: Bool

init(title: String, description: AlertView.InfoDescription? = nil, value: String, valueLevel: ValueLevel = .regular, settingId: String? = nil, modified: Bool = false) {
init(title: String, description: ActionSheetView.InfoDescription? = nil, value: String, valueLevel: ValueLevel = .regular, settingId: String? = nil, modified: Bool = false) {
self.title = title
self.description = description
self.value = value
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,12 @@ class BaseUniswapMultiSwapProvider: BaseEvmMultiSwapProvider {
var evmFeeData: EvmFeeData?
var transactionError: Error?

if let evmKit = evmBlockchainManager.evmKitManager(blockchainType: blockchainType).evmKitWrapper?.evmKit, let gasPrice {
if let evmKitWrapper = evmBlockchainManager.evmKitManager(blockchainType: blockchainType).evmKitWrapper, let gasPrice {
do {
let evmKit = evmKitWrapper.evmKit
let transactionData = try transactionData(receiveAddress: evmKit.receiveAddress, chain: evmKit.chain, trade: quote.trade, tradeOptions: quote.tradeOptions)
txData = transactionData
evmFeeData = try await evmFeeEstimator.estimateFee(blockchainType: blockchainType, evmKit: evmKit, transactionData: transactionData, gasPrice: gasPrice)
evmFeeData = try await evmFeeEstimator.estimateFee(evmKitWrapper: evmKitWrapper, transactionData: transactionData, gasPrice: gasPrice)
} catch {
transactionError = error
}
Expand Down Expand Up @@ -63,7 +64,7 @@ class BaseUniswapMultiSwapProvider: BaseEvmMultiSwapProvider {
throw SwapError.noGasPrice
}

guard let gasLimit = quote.evmFeeData?.gasLimit else {
guard let gasLimit = quote.evmFeeData?.surchargedGasLimit else {
throw SwapError.noGasLimit
}

Expand Down Expand Up @@ -327,7 +328,8 @@ extension BaseUniswapMultiSwapProvider {
fields.append(
.address(
title: "swap.recipient".localized,
value: recipient.title
value: recipient.title,
blockchainType: tokenOut.blockchainType
)
)
}
Expand Down
Loading

0 comments on commit 1c6597b

Please sign in to comment.