Skip to content

Commit c187d78

Browse files
Merge pull request #469 from Adamant-im/develop
Release 3.6.0
2 parents a6a4017 + 9e4d308 commit c187d78

File tree

154 files changed

+2752
-822
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

154 files changed

+2752
-822
lines changed

Diff for: Adamant.xcodeproj/project.pbxproj

+38-14
Large diffs are not rendered by default.

Diff for: Adamant/Adamant.xcdatamodeld/Adamant.xcdatamodel/contents

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
2-
<model type="com.apple.IDECoreDataModeler.DataModel" documentVersion="1.0" lastSavedToolsVersion="22225" systemVersion="23B74" minimumToolsVersion="Automatic" sourceLanguage="Swift" userDefinedModelVersionIdentifier="">
2+
<model type="com.apple.IDECoreDataModeler.DataModel" documentVersion="1.0" lastSavedToolsVersion="22225" systemVersion="23B81" minimumToolsVersion="Automatic" sourceLanguage="Swift" userDefinedModelVersionIdentifier="">
33
<entity name="BaseAccount" representedClassName="BaseAccount" isAbstract="YES" syncable="YES">
44
<attribute name="address" attributeType="String"/>
55
<attribute name="avatar" optional="YES" attributeType="String"/>
@@ -46,6 +46,7 @@
4646
<attribute name="height" attributeType="Integer 64" defaultValueString="0" usesScalarValueType="YES"/>
4747
<attribute name="isConfirmed" attributeType="Boolean" defaultValueString="NO" usesScalarValueType="YES"/>
4848
<attribute name="isOutgoing" attributeType="Boolean" defaultValueString="NO" usesScalarValueType="YES"/>
49+
<attribute name="nonceRaw" optional="YES" attributeType="String"/>
4950
<attribute name="recipientId" attributeType="String" defaultValueString=""/>
5051
<attribute name="senderId" attributeType="String" defaultValueString=""/>
5152
<attribute name="transactionId" attributeType="String" defaultValueString=""/>

Diff for: Adamant/App/DI/AppAssembly.swift

+5
Original file line numberDiff line numberDiff line change
@@ -322,6 +322,11 @@ struct AppAssembly: Assembly {
322322
AddressConverterFactory()
323323
}.inObjectScope(.container)
324324

325+
// MARK: Chat Preservation
326+
container.register(ChatPreservationProtocol.self) { _ in
327+
ChatPreservation()
328+
}.inObjectScope(.container)
329+
325330
// MARK: Wallet Service Compose
326331
container.register(WalletServiceCompose.self) { r in
327332
var wallets: [WalletCoreProtocol] = [

Diff for: Adamant/Helpers/ADM+JsonDecode.swift

+108
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
//
2+
// ADM+Decode.swift
3+
// Adamant
4+
//
5+
// Created by Stanislav Jelezoglo on 30.01.2024.
6+
// Copyright © 2024 Adamant. All rights reserved.
7+
//
8+
9+
import Foundation
10+
11+
struct JSONCodingKeys: CodingKey {
12+
var stringValue: String
13+
14+
init?(stringValue: String) {
15+
self.stringValue = stringValue
16+
}
17+
18+
var intValue: Int?
19+
20+
init?(intValue: Int) {
21+
self.init(stringValue: "\(intValue)")
22+
self.intValue = intValue
23+
}
24+
}
25+
26+
extension KeyedDecodingContainer {
27+
func decode(forKey key: K) throws -> Data {
28+
if let stringValue = try? decode(String.self, forKey: key) {
29+
return Data(stringValue.utf8)
30+
} else if (try? decode(Dictionary<String, Any>.self, forKey: key)) != nil {
31+
let container = try self.nestedContainer(keyedBy: JSONCodingKeys.self, forKey: key)
32+
let dictionary = try container.decode([String: Any].self)
33+
return try JSONSerialization.data(withJSONObject: dictionary, options: [])
34+
}
35+
36+
return Data()
37+
}
38+
39+
func decode(_ type: Dictionary<String, Any>.Type, forKey key: K) throws -> [String: Any] {
40+
let container = try self.nestedContainer(keyedBy: JSONCodingKeys.self, forKey: key)
41+
return try container.decode(type)
42+
}
43+
44+
func decodeIfPresent(_ type: Dictionary<String, Any>.Type, forKey key: K) throws -> [String: Any]? {
45+
guard contains(key) else {
46+
return nil
47+
}
48+
return try decode(type, forKey: key)
49+
}
50+
51+
func decode(_ type: Array<Any>.Type, forKey key: K) throws -> [Any] {
52+
var container = try self.nestedUnkeyedContainer(forKey: key)
53+
return try container.decode(type)
54+
}
55+
56+
func decodeIfPresent(_ type: Array<Any>.Type, forKey key: K) throws -> [Any]? {
57+
guard contains(key) else {
58+
return nil
59+
}
60+
return try decode(type, forKey: key)
61+
}
62+
63+
func decode(_ type: Dictionary<String, Any>.Type) throws -> [String: Any] {
64+
var dictionary: [String: Any] = [:]
65+
66+
for key in allKeys {
67+
if let boolValue = try? decode(Bool.self, forKey: key) {
68+
dictionary[key.stringValue] = boolValue
69+
} else if let stringValue = try? decode(String.self, forKey: key) {
70+
dictionary[key.stringValue] = stringValue
71+
} else if let intValue = try? decode(Int.self, forKey: key) {
72+
dictionary[key.stringValue] = intValue
73+
} else if let doubleValue = try? decode(Double.self, forKey: key) {
74+
dictionary[key.stringValue] = doubleValue
75+
} else if let nestedDictionary = try? decode(Dictionary<String, Any>.self, forKey: key) {
76+
dictionary[key.stringValue] = nestedDictionary
77+
} else if let nestedArray = try? decode(Array<Any>.self, forKey: key) {
78+
dictionary[key.stringValue] = nestedArray
79+
}
80+
}
81+
return dictionary
82+
}
83+
}
84+
85+
extension UnkeyedDecodingContainer {
86+
mutating func decode(_ type: Array<Any>.Type) throws -> [Any] {
87+
var array: [Any] = []
88+
while isAtEnd == false {
89+
if let value = try? decode(Bool.self) {
90+
array.append(value)
91+
} else if let value = try? decode(Double.self) {
92+
array.append(value)
93+
} else if let value = try? decode(String.self) {
94+
array.append(value)
95+
} else if let nestedDictionary = try? decode(Dictionary<String, Any>.self) {
96+
array.append(nestedDictionary)
97+
} else if let nestedArray = try? decode(Array<Any>.self) {
98+
array.append(nestedArray)
99+
}
100+
}
101+
return array
102+
}
103+
104+
mutating func decode(_ type: Dictionary<String, Any>.Type) throws -> [String: Any] {
105+
let nestedContainer = try self.nestedContainer(keyedBy: JSONCodingKeys.self)
106+
return try nestedContainer.decode(type)
107+
}
108+
}

Diff for: Adamant/Helpers/Node+UI.swift

+11-7
Original file line numberDiff line numberDiff line change
@@ -10,22 +10,22 @@ import CommonKit
1010
import UIKit
1111

1212
extension Node {
13-
func statusString(showVersion: Bool) -> String? {
13+
func statusString(showVersion: Bool, includeVersionTitle: Bool = true) -> String? {
1414
guard isEnabled else { return Strings.disabled }
1515

1616
switch connectionStatus {
1717
case .allowed:
1818
return [
1919
pingString,
20-
showVersion ? versionString : nil,
20+
showVersion ? versionString(includeVersionTitle: includeVersionTitle) : nil,
2121
heightString
2222
]
2323
.compactMap { $0 }
2424
.joined(separator: " ")
2525
case .synchronizing:
2626
return [
2727
Strings.synchronizing,
28-
showVersion ? versionString : nil,
28+
showVersion ? versionString(includeVersionTitle: includeVersionTitle) : nil,
2929
heightString
3030
]
3131
.compactMap { $0 }
@@ -121,10 +121,6 @@ private extension Node {
121121
}
122122
}
123123

124-
var versionString: String? {
125-
version.map { "(\(Strings.version): \($0))" }
126-
}
127-
128124
var pingString: String? {
129125
guard let ping = ping else { return nil }
130126
return "\(Strings.ping): \(Int(ping * 1000)) \(Strings.milliseconds)"
@@ -144,6 +140,14 @@ private extension Node {
144140
func getFormattedHeight(from height: Int) -> String {
145141
numberFormatter.string(from: Decimal(height)) ?? String(height)
146142
}
143+
144+
func versionString(includeVersionTitle: Bool) -> String? {
145+
guard includeVersionTitle else {
146+
return version.map { "(\($0))" }
147+
}
148+
149+
return version.map { "(v\($0))" }
150+
}
147151
}
148152

149153
extension Node {

Diff for: Adamant/Helpers/String+localized.swift

+2
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,8 @@ extension String.adamant {
6161
static var noInternetNotificationBoby: String {
6262
String.localized("Shared.NoInternet.Body", comment: "Shared alert notification: body message for no internet connection.")
6363
}
64+
static var noInternetTransferBody: String { String.localized("Shared.Transfer.NoInternet.Body", comment: "Shared alert notification: body message for no internet connection.")
65+
}
6466

6567
static var emailErrorMessageTitle: String {
6668
String.localized("Error.Mail.Title", comment: "Error messge title for support email")

Diff for: Adamant/Models/BaseBtcTransaction.swift

+4
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,10 @@ class BaseBtcTransaction: TransactionDetails {
2727

2828
var blockHeight: UInt64?
2929

30+
var nonceRaw: String? {
31+
nil
32+
}
33+
3034
required init(txId: String, dateValue: Date?, blockValue: String?, senderAddress: String, recipientAddress: String, amountValue: Decimal, feeValue: Decimal?, confirmationsValue: String?, isOutgoing: Bool, transactionStatus: TransactionStatus?) {
3135
self.txId = txId
3236
self.dateValue = dateValue

Diff for: Adamant/Models/CoreData/Chatroom+CoreDataClass.swift

+4-6
Original file line numberDiff line numberDiff line change
@@ -33,15 +33,13 @@ public class Chatroom: NSManagedObject {
3333
@MainActor func getName(addressBookService: AddressBookService) -> String? {
3434
guard let partner = partner else { return nil }
3535
let result: String?
36-
if let title = title {
36+
if let address = partner.address,
37+
let name = addressBookService.getName(for: address) {
38+
result = name
39+
} else if let title = title {
3740
result = title
3841
} else if let name = partner.name {
3942
result = name
40-
} else if
41-
let address = partner.address,
42-
let name = addressBookService.getName(for: address)
43-
{
44-
result = name
4543
} else {
4644
result = partner.address
4745
}

Diff for: Adamant/Models/CoreData/CoinTransaction+CoreDataProperties.swift

+1
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ extension CoinTransaction {
3030
@NSManaged public var isConfirmed: Bool
3131
@NSManaged public var blockchainType: String
3232
@NSManaged public var transactionStatusRaw: String
33+
@NSManaged public var nonceRaw: String?
3334
}
3435

3536
extension CoinTransaction : Identifiable {

Diff for: Adamant/Models/EthTransaction.swift

+8
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ struct EthTransaction {
5656
let blockNumber: String?
5757
let currencySymbol: String
5858

59+
var nonce: Int?
5960
var isOutgoing: Bool = false
6061
}
6162

@@ -161,6 +162,12 @@ extension EthTransaction: TransactionDetails {
161162
var blockHeight: UInt64? {
162163
return nil
163164
}
165+
166+
var nonceRaw: String? {
167+
guard let nonce = nonce else { return nil }
168+
169+
return String(nonce)
170+
}
164171
}
165172

166173
// MARK: - From EthereumTransaction
@@ -221,6 +228,7 @@ extension CodableTransaction {
221228
receiptStatus: receiptStatus,
222229
blockNumber: blockNumber,
223230
currencySymbol: token?.symbol ?? EthWalletService.currencySymbol,
231+
nonce: Int(nonce),
224232
isOutgoing: isOutgoing
225233
)
226234
}

Diff for: Adamant/Models/NodeWithGroup.swift

+9
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,13 @@ extension NodeGroup {
3333
return AdmWalletService.tokenNetworkSymbol
3434
}
3535
}
36+
37+
var includeVersionTitle: Bool {
38+
switch self {
39+
case .btc, .lskNode, .lskService, .doge, .adm:
40+
return true
41+
case .eth, .dash:
42+
return false
43+
}
44+
}
3645
}

Diff for: Adamant/Models/RPCResponseModel.swift

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
//
2+
// RPCResponseModel.swift
3+
// Adamant
4+
//
5+
// Created by Stanislav Jelezoglo on 29.01.2024.
6+
// Copyright © 2024 Adamant. All rights reserved.
7+
//
8+
9+
import Foundation
10+
11+
struct RPCResponseModel: Codable {
12+
let id: String
13+
let result: Data
14+
15+
private enum CodingKeys: String, CodingKey {
16+
case id
17+
case result
18+
}
19+
20+
init(from decoder: Decoder) throws {
21+
let container = try decoder.container(keyedBy: CodingKeys.self)
22+
id = try container.decode(String.self, forKey: .id)
23+
result = try container.decode(forKey: .result)
24+
}
25+
26+
func serialize<Response: Decodable>() -> Response? {
27+
try? JSONDecoder().decode(Response.self, from: result)
28+
}
29+
}

Diff for: Adamant/Models/RpcRequestModel.swift

+54
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
//
2+
// RpcRequestModel.swift
3+
// Adamant
4+
//
5+
// Created by Stanislav Jelezoglo on 31.01.2024.
6+
// Copyright © 2024 Adamant. All rights reserved.
7+
//
8+
9+
import Foundation
10+
11+
struct RpcRequest: Encodable {
12+
let method: String
13+
let id: String
14+
let params: [Parameter]
15+
let jsonrpc: String = "2.0"
16+
17+
init(method: String, id: String, params: [Parameter]) {
18+
self.method = method
19+
self.id = id
20+
self.params = params
21+
}
22+
23+
init(method: String, params: [Parameter]) {
24+
self.method = method
25+
self.id = method
26+
self.params = params
27+
}
28+
29+
init(method: String) {
30+
self.method = method
31+
self.id = method
32+
self.params = []
33+
}
34+
}
35+
36+
extension RpcRequest {
37+
enum Parameter {
38+
case string(String)
39+
case bool(Bool)
40+
}
41+
}
42+
43+
extension RpcRequest.Parameter: Encodable {
44+
func encode(to encoder: Encoder) throws {
45+
var container = encoder.singleValueContainer()
46+
47+
switch self {
48+
case let .string(value):
49+
try container.encode(value)
50+
case let .bool(value):
51+
try container.encode(value)
52+
}
53+
}
54+
}

Diff for: Adamant/Models/SimpleTransactionDetails.swift

+6-1
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ struct SimpleTransactionDetails: AdamantTransactionDetails, Hashable {
4040
var showToChat: Bool?
4141
var chatRoom: Chatroom?
4242

43+
var nonceRaw: String?
44+
4345
init(
4446
defaultCurrencySymbol: String? = nil,
4547
txId: String,
@@ -52,7 +54,8 @@ struct SimpleTransactionDetails: AdamantTransactionDetails, Hashable {
5254
blockValue: String? = nil,
5355
isOutgoing: Bool,
5456
transactionStatus: TransactionStatus? = nil,
55-
partnerName: String? = nil
57+
partnerName: String? = nil,
58+
nonceRaw: String?
5659
) {
5760
self.defaultCurrencySymbol = defaultCurrencySymbol
5861
self.txId = txId
@@ -66,6 +69,7 @@ struct SimpleTransactionDetails: AdamantTransactionDetails, Hashable {
6669
self.isOutgoing = isOutgoing
6770
self.transactionStatus = transactionStatus
6871
self.partnerName = partnerName
72+
self.nonceRaw = nonceRaw
6973
}
7074

7175
init(_ transaction: TransactionDetails) {
@@ -80,6 +84,7 @@ struct SimpleTransactionDetails: AdamantTransactionDetails, Hashable {
8084
self.blockValue = transaction.blockValue
8185
self.isOutgoing = transaction.isOutgoing
8286
self.transactionStatus = transaction.transactionStatus
87+
self.nonceRaw = transaction.nonceRaw
8388
}
8489

8590
init(_ transaction: TransferTransaction) {

0 commit comments

Comments
 (0)