Skip to content

Commit 47c83ee

Browse files
committed
fix last 4 warnings
1 parent 75c7e77 commit 47c83ee

File tree

3 files changed

+6
-8
lines changed

3 files changed

+6
-8
lines changed

Sources/web3swift/Convenience/Data+Extension.swift

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,9 @@ import Foundation
99
public extension Data {
1010

1111
init<T>(fromArray values: [T]) {
12-
var values = values
13-
self.init(buffer: UnsafeBufferPointer(start: &values, count: values.count))
12+
let values = values
13+
let ptrUB = values.withUnsafeBufferPointer { (ptr: UnsafeBufferPointer) in return ptr }
14+
self.init(buffer: ptrUB)
1415
}
1516

1617
func toArray<T>(type: T.Type) throws -> [T] {

Sources/web3swift/Convenience/SECP256k1.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ extension SECP256K1 {
116116
let result = privateKey.withUnsafeBytes { (pkRawBufferPointer: UnsafeRawBufferPointer) -> Int32? in
117117
if let pkRawPointer = pkRawBufferPointer.baseAddress, pkRawBufferPointer.count > 0 {
118118
let privateKeyPointer = pkRawPointer.assumingMemoryBound(to: UInt8.self)
119-
let res = secp256k1_ec_pubkey_create(context!, UnsafeMutablePointer<secp256k1_pubkey>(&publicKey), privateKeyPointer)
119+
let res = secp256k1_ec_pubkey_create(context!, &publicKey, privateKeyPointer)
120120
return res
121121
} else {
122122
return nil
@@ -163,7 +163,7 @@ extension SECP256K1 {
163163
let result = serializedKey.withUnsafeBytes { (serializedKeyRawBufferPointer: UnsafeRawBufferPointer) -> Int32? in
164164
if let serializedKeyRawPointer = serializedKeyRawBufferPointer.baseAddress, serializedKeyRawBufferPointer.count > 0 {
165165
let serializedKeyPointer = serializedKeyRawPointer.assumingMemoryBound(to: UInt8.self)
166-
let res = secp256k1_ec_pubkey_parse(context!, UnsafeMutablePointer<secp256k1_pubkey>(&publicKey), serializedKeyPointer, keyLen)
166+
let res = secp256k1_ec_pubkey_parse(context!, &publicKey, serializedKeyPointer, keyLen)
167167
return res
168168
} else {
169169
return nil

Sources/web3swift/KeystoreManager/BIP32HDNode.swift

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -79,10 +79,7 @@ public class HDNode {
7979
}
8080
depth = data[4..<5].bytes[0]
8181
parentFingerprint = data[5..<9]
82-
let cNum = data[9..<13].bytes
83-
childNumber = UnsafePointer(cNum).withMemoryRebound(to: UInt32.self, capacity: 1) {
84-
$0.pointee
85-
}
82+
childNumber = data[9..<13].bytes.withUnsafeBytes { $0.load(as: UInt32.self) }
8683
chaincode = data[13..<45]
8784
if serializePrivate {
8885
privateKey = data[46..<78]

0 commit comments

Comments
 (0)