Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 5cf13de

Browse files
Merge pull request #896 from kodelab-aden/feature/rawspan-update
fix: Update usages of Data.bytes for compatibility with Swift 6.2
2 parents 133b891 + eecf264 commit 5cf13de

File tree

3 files changed

+10
-10
lines changed

3 files changed

+10
-10
lines changed

‎Sources/Web3Core/KeystoreManager/BIP32HDNode.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ public class HDNode {
8484
}
8585
depth = data[4..<5].bytes[0]
8686
parentFingerprint = data[5..<9]
87-
childNumber = data[9..<13].bytes.withUnsafeBytes { 0ドル.load(as: UInt32.self) }
87+
childNumber = Array(data.dropFirst(9).prefix(4)).withUnsafeBytes { 0ドル.load(as: UInt32.self) }
8888
chaincode = data[13..<45]
8989
if serializePrivate {
9090
privateKey = data[46..<78]

‎Sources/Web3Core/Utility/Utilities.swift

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -239,8 +239,8 @@ public struct Utilities {
239239
/// Takes a hash of some message. What message is hashed should be checked by user separately.
240240
public static func hashECRecover(hash: Data, signature: Data) -> EthereumAddress? {
241241
if signature.count != 65 { return nil }
242-
let rData=signature[0..<32].bytes
243-
let sData=signature[32..<64].bytes
242+
let rData:[UInt8]=Array(signature.prefix(32))
243+
let sData:[UInt8]=Array(signature.dropFirst(32).prefix(32))
244244
var vData = signature[64]
245245
if vData >= 27 && vData <= 30 {
246246
vData -= 27
@@ -274,11 +274,11 @@ public struct Utilities {
274274

275275
/// Unmarshals a 65 byte recoverable EC signature into internal structure.
276276
static func unmarshalSignature(signatureData: Data) -> SECP256K1.UnmarshaledSignature? {
277-
if signatureData.count != 65 { return nil }
278-
let bytes = signatureData.bytes
279-
let r = Array(bytes[0..<32])
280-
let s = Array(bytes[32..<64])
281-
return SECP256K1.UnmarshaledSignature(v: bytes[64], r: Data(r), s: Data(s))
277+
guard signatureData.count == 65else { return nil }
278+
let rSlice = signatureData.prefix(32)
279+
let sSlice = signatureData.dropFirst(32).prefix(32)
280+
let v = signatureData[64]
281+
return SECP256K1.UnmarshaledSignature(v: v, r: Data(rSlice), s: Data(sSlice))
282282
}
283283

284284
/// Marshals the V, R and S signature parameters into a 65 byte recoverable EC signature.

‎Sources/web3swift/HookedFunctions/Web3+BrowserFunctions.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,8 @@ extension Web3.BrowserFunctions {
5353

5454
public func personalECRecover(_ personalMessage: Data, signature: Data) -> String? {
5555
if signature.count != 65 { return nil }
56-
let rData = signature[0..<32].bytes
57-
let sData = signature[32..<64].bytes
56+
let rData = Array(signature.prefix(32))
57+
let sData = Array(signature.dropFirst(32).prefix(32))
5858
var vData = signature[64]
5959
if vData >= 27 && vData <= 30 {
6060
vData -= 27

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /