From 2af0c711f7b3852046f4d436cd55a8a85dd89315 Mon Sep 17 00:00:00 2001 From: 6od9i <6od911@gmail.com> Date: Thu, 29 Jun 2023 11:01:07 +0400 Subject: [PATCH 01/15] Addresses generator (#1) - Generation amount of addresses added - Generation wallet with index > 9 fixed - Test generation addresses added --- .../KeystoreManager/BIP32Keystore.swift | 53 +++++++++++++++++- .../localTests/BIP32KeystoreTests.swift | 54 +++++++++++++++++++ 2 files changed, 105 insertions(+), 2 deletions(-) create mode 100644 Tests/web3swiftTests/localTests/BIP32KeystoreTests.swift diff --git a/Sources/Web3Core/KeystoreManager/BIP32Keystore.swift b/Sources/Web3Core/KeystoreManager/BIP32Keystore.swift index 4277cca61..003ba7fd5 100755 --- a/Sources/Web3Core/KeystoreManager/BIP32Keystore.swift +++ b/Sources/Web3Core/KeystoreManager/BIP32Keystore.swift @@ -177,7 +177,7 @@ public class BIP32Keystore: AbstractKeystore { if path.hasPrefix(prefixPath) { let upperIndex = (path.range(of: prefixPath)?.upperBound)! if upperIndex < path.endIndex { - pathAppendix = String(path[path.index(after: upperIndex)]) + pathAppendix = String(path[path.index(after: upperIndex).. [EthereumAddress] { + guard let decryptedRootNode = try? getPrefixNodeData(password) else { + return [] + } + guard let rootNode = HDNode(decryptedRootNode) else { + return [] + } + let prefixPath = self.rootPrefix + var pathAppendix: String? + + return [Int](0.. Date: Thu, 29 Jun 2023 13:30:27 +0400 Subject: [PATCH 02/15] - Grammar fixed - Removed prefix path from address generation --- Sources/Web3Core/KeystoreManager/BIP32Keystore.swift | 9 ++++----- Tests/web3swiftTests/localTests/BIP32KeystoreTests.swift | 1 - 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/Sources/Web3Core/KeystoreManager/BIP32Keystore.swift b/Sources/Web3Core/KeystoreManager/BIP32Keystore.swift index 003ba7fd5..1306f9ca9 100755 --- a/Sources/Web3Core/KeystoreManager/BIP32Keystore.swift +++ b/Sources/Web3Core/KeystoreManager/BIP32Keystore.swift @@ -217,13 +217,12 @@ public class BIP32Keystore: AbstractKeystore { } /// Fast generation addresses for current account - /// used for shows wich address user wiil get when changed number of his wallet + /// used for shows which address user will get when changed number of his wallet /// - Parameters: /// - password: password of seed storage - /// - preffixPath: preffix of Derivation Path without account number - /// - number: number of wallets adresses needed to generate from 0 to number-1 + /// - number: number of wallets addresses needed to generate from 0 to number-1 /// - Returns: Array of addresses generated from 0 to number bound, or empty array in case of error - public func getAddressForAccount(password: String, preffixPath: String, number: Int) -> [EthereumAddress] { + public func getAddressForAccount(password: String, number: Int) -> [EthereumAddress] { guard let decryptedRootNode = try? getPrefixNodeData(password) else { return [] } @@ -235,7 +234,7 @@ public class BIP32Keystore: AbstractKeystore { return [Int](0.. Date: Thu, 29 Jun 2023 15:37:24 +0400 Subject: [PATCH 03/15] - linter Trailing Whitespace Violation fixed --- Sources/Web3Core/KeystoreManager/BIP32Keystore.swift | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Sources/Web3Core/KeystoreManager/BIP32Keystore.swift b/Sources/Web3Core/KeystoreManager/BIP32Keystore.swift index 1306f9ca9..a6e9c57b9 100755 --- a/Sources/Web3Core/KeystoreManager/BIP32Keystore.swift +++ b/Sources/Web3Core/KeystoreManager/BIP32Keystore.swift @@ -215,7 +215,7 @@ public class BIP32Keystore: AbstractKeystore { guard let serializedRootNode = rootNode.serialize(serializePublic: false) else {throw AbstractKeystoreError.keyDerivationError} try encryptDataToStorage(password, data: serializedRootNode, aesMode: self.keystoreParams!.crypto.cipher) } - + /// Fast generation addresses for current account /// used for shows which address user will get when changed number of his wallet /// - Parameters: @@ -231,7 +231,7 @@ public class BIP32Keystore: AbstractKeystore { } let prefixPath = self.rootPrefix var pathAppendix: String? - + return [Int](0.. Date: Thu, 29 Jun 2023 20:55:02 +0400 Subject: [PATCH 04/15] - closure style updated - pathAppendix declaration place changed --- Sources/Web3Core/KeystoreManager/BIP32Keystore.swift | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/Sources/Web3Core/KeystoreManager/BIP32Keystore.swift b/Sources/Web3Core/KeystoreManager/BIP32Keystore.swift index a6e9c57b9..3b87641e3 100755 --- a/Sources/Web3Core/KeystoreManager/BIP32Keystore.swift +++ b/Sources/Web3Core/KeystoreManager/BIP32Keystore.swift @@ -230,10 +230,9 @@ public class BIP32Keystore: AbstractKeystore { return [] } let prefixPath = self.rootPrefix - var pathAppendix: String? - return [Int](0.. Date: Thu, 29 Jun 2023 22:03:08 +0400 Subject: [PATCH 05/15] - not used code removed - small refactoring --- .../KeystoreManager/BIP32Keystore.swift | 97 +++++++------------ .../localTests/BIP32KeystoreTests.swift | 8 +- 2 files changed, 41 insertions(+), 64 deletions(-) diff --git a/Sources/Web3Core/KeystoreManager/BIP32Keystore.swift b/Sources/Web3Core/KeystoreManager/BIP32Keystore.swift index 3b87641e3..7978494e3 100755 --- a/Sources/Web3Core/KeystoreManager/BIP32Keystore.swift +++ b/Sources/Web3Core/KeystoreManager/BIP32Keystore.swift @@ -149,14 +149,17 @@ public class BIP32Keystore: AbstractKeystore { } else { newIndex = UInt32.zero } + guard let newNode = parentNode.derive(index: newIndex, derivePrivateKey: true, hardened: false) else { throw AbstractKeystoreError.keyDerivationError } guard let newAddress = Utilities.publicToAddress(newNode.publicKey) else { throw AbstractKeystoreError.keyDerivationError } + let prefixPath = self.rootPrefix var newPath: String + if newNode.isHardened { newPath = prefixPath + "/" + String(newNode.index % HDNode.hardenedIndexPrefix) + "'" } else { @@ -166,101 +169,75 @@ public class BIP32Keystore: AbstractKeystore { } public func createNewCustomChildAccount(password: String, path: String) throws { - guard let decryptedRootNode = try getPrefixNodeData(password) else { + guard let decryptedRootNode = try getPrefixNodeData(password), + let keystoreParams = keystoreParams else { throw AbstractKeystoreError.encryptionError("Failed to decrypt a keystore") } guard let rootNode = HDNode(decryptedRootNode) else { throw AbstractKeystoreError.encryptionError("Failed to deserialize a root node") } + let prefixPath = self.rootPrefix var pathAppendix: String? + if path.hasPrefix(prefixPath) { - let upperIndex = (path.range(of: prefixPath)?.upperBound)! - if upperIndex < path.endIndex { + if let upperIndex = (path.range(of: prefixPath)?.upperBound), upperIndex < path.endIndex { pathAppendix = String(path[path.index(after: upperIndex).. [EthereumAddress] { - guard let decryptedRootNode = try? getPrefixNodeData(password) else { - return [] - } - guard let rootNode = HDNode(decryptedRootNode) else { - return [] + /// - number: number of wallets addresses needed to generate from `0` to `number-1` + /// - Returns: Array of addresses generated from `0` to number bound + public func getAddressForAccount(password: String, number: UInt) throws -> [EthereumAddress] { + guard let decryptedRootNode = try? getPrefixNodeData(password), + let rootNode = HDNode(decryptedRootNode) else { + throw AbstractKeystoreError.encryptionError("Failed to decrypt a keystore") } - let prefixPath = self.rootPrefix - return [Int](0.. Date: Fri, 30 Jun 2023 00:20:51 +0400 Subject: [PATCH 06/15] - Trailing Whitespace fixed in tests --- .../web3swiftTests/localTests/BIP32KeystoreTests.swift | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Tests/web3swiftTests/localTests/BIP32KeystoreTests.swift b/Tests/web3swiftTests/localTests/BIP32KeystoreTests.swift index bc0241bc3..e91d7e9b5 100644 --- a/Tests/web3swiftTests/localTests/BIP32KeystoreTests.swift +++ b/Tests/web3swiftTests/localTests/BIP32KeystoreTests.swift @@ -16,9 +16,9 @@ class BIP32KeystoreTests: XCTestCase { /// Seed randomly generated for this test let mnemonic = "resource beyond merit enemy foot piece reveal eagle nothing luggage goose spot" let password = "test_password" - + let addressesCount: UInt = 101 - + guard let keystore = try BIP32Keystore( mnemonics: mnemonic, password: password, @@ -28,12 +28,12 @@ class BIP32KeystoreTests: XCTestCase { XCTFail("Keystore has not generated") throw NSError(domain: "0", code: 0) } - + let addresses = try keystore.getAddressForAccount(password: password, number: addressesCount) XCTAssertEqual(UInt(addresses.count), addressesCount) XCTAssertNotEqual(addresses[11], addresses[1]) - + guard let sameKeystore = try BIP32Keystore( mnemonics: mnemonic, password: password, @@ -43,7 +43,7 @@ class BIP32KeystoreTests: XCTestCase { XCTFail("Keystore has not generated") throw NSError(domain: "0", code: 0) } - + let walletNumber = addressesCount - 1 try sameKeystore.createNewCustomChildAccount(password: password, path: HDNode.defaultPathMetamaskPrefix + "/\(walletNumber)") From d76e6ee726b3a92edbfb10afd24c079bc264aca3 Mon Sep 17 00:00:00 2001 From: Jenea Vranceanu Date: Fri, 30 Jun 2023 09:15:57 +0300 Subject: [PATCH 07/15] fix: createNewAccount always non-hardened derivation --- Sources/Web3Core/KeystoreManager/BIP32Keystore.swift | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/Sources/Web3Core/KeystoreManager/BIP32Keystore.swift b/Sources/Web3Core/KeystoreManager/BIP32Keystore.swift index a6e9c57b9..d3bc8122c 100755 --- a/Sources/Web3Core/KeystoreManager/BIP32Keystore.swift +++ b/Sources/Web3Core/KeystoreManager/BIP32Keystore.swift @@ -155,13 +155,7 @@ public class BIP32Keystore: AbstractKeystore { guard let newAddress = Utilities.publicToAddress(newNode.publicKey) else { throw AbstractKeystoreError.keyDerivationError } - let prefixPath = self.rootPrefix - var newPath: String - if newNode.isHardened { - newPath = prefixPath + "/" + String(newNode.index % HDNode.hardenedIndexPrefix) + "'" - } else { - newPath = prefixPath + "/" + String(newNode.index) - } + let newPath = rootPrefix + "/" + String(newNode.index) addressStorage.add(address: newAddress, for: newPath) } From 216f11b826890c4e975272c1705fc54d989afa05 Mon Sep 17 00:00:00 2001 From: 6od9i <6od911@gmail.com> Date: Fri, 30 Jun 2023 10:36:20 +0400 Subject: [PATCH 08/15] - bug with original pathAppendix fixed --- Sources/Web3Core/KeystoreManager/BIP32Keystore.swift | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Sources/Web3Core/KeystoreManager/BIP32Keystore.swift b/Sources/Web3Core/KeystoreManager/BIP32Keystore.swift index a86ea6c66..a59d95542 100755 --- a/Sources/Web3Core/KeystoreManager/BIP32Keystore.swift +++ b/Sources/Web3Core/KeystoreManager/BIP32Keystore.swift @@ -162,7 +162,7 @@ public class BIP32Keystore: AbstractKeystore { public func createNewCustomChildAccount(password: String, path: String) throws { guard let decryptedRootNode = try getPrefixNodeData(password), - let keystoreParams = keystoreParams else { + let keystoreParams else { throw AbstractKeystoreError.encryptionError("Failed to decrypt a keystore") } guard let rootNode = HDNode(decryptedRootNode) else { @@ -179,17 +179,17 @@ public class BIP32Keystore: AbstractKeystore { throw AbstractKeystoreError.encryptionError("out of bounds") } - guard var pathAppendix = pathAppendix else { + guard let modifiedAppendix = pathAppendix else { throw AbstractKeystoreError.encryptionError("Derivation depth mismatch") } - if pathAppendix.hasPrefix("/") { - pathAppendix = pathAppendix.trimmingCharacters(in: CharacterSet.init(charactersIn: "/")) + if modifiedAppendix.hasPrefix("/") { + pathAppendix = modifiedAppendix.trimmingCharacters(in: CharacterSet.init(charactersIn: "/")) } } else if path.hasPrefix("/") { pathAppendix = path.trimmingCharacters(in: CharacterSet.init(charactersIn: "/")) } - guard let pathAppendix = pathAppendix, + guard let pathAppendix, rootNode.depth == prefixPath.components(separatedBy: "/").count - 1 else { throw AbstractKeystoreError.encryptionError("Derivation depth mismatch") } From a64e38020b6571654b9ccbcf302de3e88ba8f437 Mon Sep 17 00:00:00 2001 From: Jenea Vranceanu Date: Fri, 30 Jun 2023 09:42:57 +0300 Subject: [PATCH 09/15] chore: refactoring of createNewCustomChildAccount --- .../KeystoreManager/BIP32Keystore.swift | 31 ++++++------------- 1 file changed, 10 insertions(+), 21 deletions(-) diff --git a/Sources/Web3Core/KeystoreManager/BIP32Keystore.swift b/Sources/Web3Core/KeystoreManager/BIP32Keystore.swift index d3bc8122c..7925fea5e 100755 --- a/Sources/Web3Core/KeystoreManager/BIP32Keystore.swift +++ b/Sources/Web3Core/KeystoreManager/BIP32Keystore.swift @@ -175,25 +175,12 @@ public class BIP32Keystore: AbstractKeystore { } else { throw AbstractKeystoreError.encryptionError("out of bounds") } - - guard pathAppendix != nil else { - throw AbstractKeystoreError.encryptionError("Derivation depth mismatch") - } - if pathAppendix!.hasPrefix("/") { - pathAppendix = pathAppendix?.trimmingCharacters(in: CharacterSet.init(charactersIn: "/")) - } - } else { - if path.hasPrefix("/") { - pathAppendix = path.trimmingCharacters(in: CharacterSet.init(charactersIn: "/")) - } } - guard pathAppendix != nil else { + pathAppendix = pathAppendix?.trimmingCharacters(in: .init(charactersIn: "/")) + guard let pathAppendix, rootNode.depth == prefixPath.components(separatedBy: "/").count - 1 else { throw AbstractKeystoreError.encryptionError("Derivation depth mismatch") } - guard rootNode.depth == prefixPath.components(separatedBy: "/").count - 1 else { - throw AbstractKeystoreError.encryptionError("Derivation depth mismatch") - } - guard let newNode = rootNode.derive(path: pathAppendix!, derivePrivateKey: true) else { + guard let newNode = rootNode.derive(path: pathAppendix, derivePrivateKey: true) else { throw AbstractKeystoreError.keyDerivationError } guard let newAddress = Utilities.publicToAddress(newNode.publicKey) else { @@ -201,12 +188,14 @@ public class BIP32Keystore: AbstractKeystore { } var newPath: String if newNode.isHardened { - newPath = prefixPath + "/" + pathAppendix!.trimmingCharacters(in: CharacterSet.init(charactersIn: "'")) + "'" + newPath = prefixPath + "/" + pathAppendix.trimmingCharacters(in: .init(charactersIn: "'")) + "'" } else { - newPath = prefixPath + "/" + pathAppendix! + newPath = prefixPath + "/" + pathAppendix } addressStorage.add(address: newAddress, for: newPath) - guard let serializedRootNode = rootNode.serialize(serializePublic: false) else {throw AbstractKeystoreError.keyDerivationError} + guard let serializedRootNode = rootNode.serialize(serializePublic: false) else { + throw AbstractKeystoreError.keyDerivationError + } try encryptDataToStorage(password, data: serializedRootNode, aesMode: self.keystoreParams!.crypto.cipher) } @@ -241,11 +230,11 @@ public class BIP32Keystore: AbstractKeystore { return nil } if pathAppendix!.hasPrefix("/") { - pathAppendix = pathAppendix?.trimmingCharacters(in: CharacterSet.init(charactersIn: "/")) + pathAppendix = pathAppendix?.trimmingCharacters(in: .init(charactersIn: "/")) } } else { if path.hasPrefix("/") { - pathAppendix = path.trimmingCharacters(in: CharacterSet.init(charactersIn: "/")) + pathAppendix = path.trimmingCharacters(in: .init(charactersIn: "/")) } } guard pathAppendix != nil, From 9c68d9b47f7ae2d88954328647850ab20c67b6fc Mon Sep 17 00:00:00 2001 From: 6od9i <6od911@gmail.com> Date: Fri, 30 Jun 2023 10:44:38 +0400 Subject: [PATCH 10/15] - Test testAddressGeneration modified with hardcoded addresses --- .../localTests/BIP32KeystoreTests.swift | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/Tests/web3swiftTests/localTests/BIP32KeystoreTests.swift b/Tests/web3swiftTests/localTests/BIP32KeystoreTests.swift index e91d7e9b5..19979ef8c 100644 --- a/Tests/web3swiftTests/localTests/BIP32KeystoreTests.swift +++ b/Tests/web3swiftTests/localTests/BIP32KeystoreTests.swift @@ -13,6 +13,7 @@ import Web3Core class BIP32KeystoreTests: XCTestCase { func testAddressGeneration() throws { + /// Arrange /// Seed randomly generated for this test let mnemonic = "resource beyond merit enemy foot piece reveal eagle nothing luggage goose spot" let password = "test_password" @@ -29,10 +30,9 @@ class BIP32KeystoreTests: XCTestCase { throw NSError(domain: "0", code: 0) } + /// Act let addresses = try keystore.getAddressForAccount(password: password, number: addressesCount) - XCTAssertEqual(UInt(addresses.count), addressesCount) - XCTAssertNotEqual(addresses[11], addresses[1]) guard let sameKeystore = try BIP32Keystore( mnemonics: mnemonic, @@ -48,6 +48,15 @@ class BIP32KeystoreTests: XCTestCase { try sameKeystore.createNewCustomChildAccount(password: password, path: HDNode.defaultPathMetamaskPrefix + "/\(walletNumber)") let address = sameKeystore.addresses?.last?.address + + /// Assert + XCTAssertEqual(UInt(addresses.count), addressesCount) + XCTAssertNotEqual(addresses[11], addresses[1]) XCTAssertEqual(addresses.last?.address, address) + XCTAssertEqual("0xEF22ebb8Bb5CDa4EaCc98b280c94Cbaa3828566F", addresses.last?.address) + XCTAssertEqual("0xdc69CBFE39c46B104875DF9602dFdCDB9b862a16", addresses.first?.address) + XCTAssertEqual("0xdc69CBFE39c46B104875DF9602dFdCDB9b862a16", sameKeystore.addresses?.first?.address) + XCTAssertEqual("0x971CF293b46162CD03DD9Cc39E89B592988DD6C4", addresses[Int(addressesCount / 2)].address) + XCTAssertEqual("0x3B565482a93CE4adA9dE0fD3c118bd41E24CC23C", addresses[10].address) } } From 91975f6f7030e50e977fb6c5f0b60502f776c16d Mon Sep 17 00:00:00 2001 From: Jenea Vranceanu Date: Fri, 30 Jun 2023 09:53:44 +0300 Subject: [PATCH 11/15] fix: trimming / only if it's present as a prefix; using let for 'newPath'; --- .../Web3Core/KeystoreManager/BIP32Keystore.swift | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/Sources/Web3Core/KeystoreManager/BIP32Keystore.swift b/Sources/Web3Core/KeystoreManager/BIP32Keystore.swift index 310a82389..4517eb993 100755 --- a/Sources/Web3Core/KeystoreManager/BIP32Keystore.swift +++ b/Sources/Web3Core/KeystoreManager/BIP32Keystore.swift @@ -162,15 +162,15 @@ public class BIP32Keystore: AbstractKeystore { public func createNewCustomChildAccount(password: String, path: String) throws { guard let decryptedRootNode = try getPrefixNodeData(password), - let keystoreParams else { + keystoreParams != nil else { throw AbstractKeystoreError.encryptionError("Failed to decrypt a keystore") } guard let rootNode = HDNode(decryptedRootNode) else { throw AbstractKeystoreError.encryptionError("Failed to deserialize a root node") } - let prefixPath = self.rootPrefix - var pathAppendix: String? + let prefixPath = rootPrefix + var pathAppendix = path if path.hasPrefix(prefixPath) { if let upperIndex = (path.range(of: prefixPath)?.upperBound), upperIndex < path.endIndex { @@ -179,8 +179,10 @@ public class BIP32Keystore: AbstractKeystore { throw AbstractKeystoreError.encryptionError("out of bounds") } } - pathAppendix = pathAppendix?.trimmingCharacters(in: .init(charactersIn: "/")) - guard let pathAppendix, rootNode.depth == prefixPath.components(separatedBy: "/").count - 1 else { + if pathAppendix.hasPrefix("/") { + pathAppendix = pathAppendix.trimmingCharacters(in: .init(charactersIn: "/")) + } + guard rootNode.depth == prefixPath.components(separatedBy: "/").count - 1 else { throw AbstractKeystoreError.encryptionError("Derivation depth mismatch") } guard let newNode = rootNode.derive(path: pathAppendix, derivePrivateKey: true) else { @@ -190,7 +192,7 @@ public class BIP32Keystore: AbstractKeystore { throw AbstractKeystoreError.keyDerivationError } - var newPath: String + let newPath: String if newNode.isHardened { newPath = prefixPath + "/" + pathAppendix.trimmingCharacters(in: .init(charactersIn: "'")) + "'" } else { From 97def7b106f43a8445289a5177ec8a9abeffb87c Mon Sep 17 00:00:00 2001 From: Jenea Vranceanu Date: Fri, 30 Jun 2023 18:29:26 +0300 Subject: [PATCH 12/15] fix: used short notation for null checking --- Sources/Web3Core/KeystoreManager/BIP32Keystore.swift | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Sources/Web3Core/KeystoreManager/BIP32Keystore.swift b/Sources/Web3Core/KeystoreManager/BIP32Keystore.swift index 4517eb993..fc11dc97c 100755 --- a/Sources/Web3Core/KeystoreManager/BIP32Keystore.swift +++ b/Sources/Web3Core/KeystoreManager/BIP32Keystore.swift @@ -162,7 +162,7 @@ public class BIP32Keystore: AbstractKeystore { public func createNewCustomChildAccount(password: String, path: String) throws { guard let decryptedRootNode = try getPrefixNodeData(password), - keystoreParams != nil else { + let keystoreParams else { throw AbstractKeystoreError.encryptionError("Failed to decrypt a keystore") } guard let rootNode = HDNode(decryptedRootNode) else { @@ -203,7 +203,7 @@ public class BIP32Keystore: AbstractKeystore { guard let serializedRootNode = rootNode.serialize(serializePublic: false) else { throw AbstractKeystoreError.keyDerivationError } - try encryptDataToStorage(password, data: serializedRootNode, aesMode: self.keystoreParams!.crypto.cipher) + try encryptDataToStorage(password, data: serializedRootNode, aesMode: keystoreParams.crypto.cipher) } /// Fast generation addresses for current account From 752171bdf56ded11f0bc3dde11fb192ac4be4bb6 Mon Sep 17 00:00:00 2001 From: Jenea Vranceanu <36865532+JeneaVranceanu@users.noreply.github.com> Date: Sat, 1 Jul 2023 21:53:34 +0300 Subject: [PATCH 13/15] chore: trailing closure style for compactMap --- Sources/Web3Core/KeystoreManager/BIP32Keystore.swift | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Sources/Web3Core/KeystoreManager/BIP32Keystore.swift b/Sources/Web3Core/KeystoreManager/BIP32Keystore.swift index fc11dc97c..dc7555dca 100755 --- a/Sources/Web3Core/KeystoreManager/BIP32Keystore.swift +++ b/Sources/Web3Core/KeystoreManager/BIP32Keystore.swift @@ -217,13 +217,13 @@ public class BIP32Keystore: AbstractKeystore { let rootNode = HDNode(decryptedRootNode) else { throw AbstractKeystoreError.encryptionError("Failed to decrypt a keystore") } - return try [UInt](0.. Date: Mon, 3 Jul 2023 09:13:44 +0400 Subject: [PATCH 14/15] - linter warning fixed --- Sources/Web3Core/KeystoreManager/BIP32Keystore.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sources/Web3Core/KeystoreManager/BIP32Keystore.swift b/Sources/Web3Core/KeystoreManager/BIP32Keystore.swift index dc7555dca..485a3ba48 100755 --- a/Sources/Web3Core/KeystoreManager/BIP32Keystore.swift +++ b/Sources/Web3Core/KeystoreManager/BIP32Keystore.swift @@ -217,7 +217,7 @@ public class BIP32Keystore: AbstractKeystore { let rootNode = HDNode(decryptedRootNode) else { throw AbstractKeystoreError.encryptionError("Failed to decrypt a keystore") } - return try [UInt](0.. Date: Wed, 5 Jul 2023 13:02:25 +0400 Subject: [PATCH 15/15] - isHardened check removed from createNewCustomChildAccount --- Sources/Web3Core/KeystoreManager/BIP32Keystore.swift | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/Sources/Web3Core/KeystoreManager/BIP32Keystore.swift b/Sources/Web3Core/KeystoreManager/BIP32Keystore.swift index 485a3ba48..22b305431 100755 --- a/Sources/Web3Core/KeystoreManager/BIP32Keystore.swift +++ b/Sources/Web3Core/KeystoreManager/BIP32Keystore.swift @@ -192,12 +192,7 @@ public class BIP32Keystore: AbstractKeystore { throw AbstractKeystoreError.keyDerivationError } - let newPath: String - if newNode.isHardened { - newPath = prefixPath + "/" + pathAppendix.trimmingCharacters(in: .init(charactersIn: "'")) + "'" - } else { - newPath = prefixPath + "/" + pathAppendix - } + let newPath = prefixPath + "/" + pathAppendix addressStorage.add(address: newAddress, for: newPath) guard let serializedRootNode = rootNode.serialize(serializePublic: false) else {