Skip to content

Commit

Permalink
- change leftPadding name to avoid conflicts
Browse files Browse the repository at this point in the history
- bug fix setup
  • Loading branch information
simonmcl committed Jan 23, 2024
1 parent 73d48c4 commit 30b765a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 13 deletions.
6 changes: 3 additions & 3 deletions Sources/KukaiCoreSwift/Extensions/String+extensions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,12 @@ public extension String {
}

/// Pad the left side of a string with characters
func leftPadding(toLength: Int, withPad character: Character) -> String {
let stringLength = count
func padLeft(toLength: Int, withPad character: Character) -> String {
let stringLength = self.count
if stringLength < toLength {
return String(repeatElement(character, count: toLength - stringLength)) + self
} else {
return String(suffix(toLength))
return String(self.suffix(toLength))
}
}
}
12 changes: 2 additions & 10 deletions Sources/KukaiCoreSwift/Services/TorusAuthService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -331,16 +331,8 @@ public class TorusAuthService: NSObject {
}

let data = try await self.torusUtils.getPublicAddress(endpoints: nd.getTorusNodeEndpoints(), torusNodePubs: nd.getTorusNodePub(), verifier: verifierName, verifierId: socialUserId, isExtended: true)
var pubX = data.x
var pubY = data.y

if let x = pubX, x.count > 0 && x.count < 64 {
pubX = pubX?.leftPadding(toLength: (64 - x.count), withPad: "0")
}

if let y = pubY, y.count > 0 && y.count < 64 {
pubY = pubY?.leftPadding(toLength: (64 - y.count), withPad: "0")
}
var pubX = data.x?.padLeft(toLength: 64, withPad: "0")
var pubY = data.y?.padLeft(toLength: 64, withPad: "0")

guard let x = pubX,
let y = pubY,
Expand Down

0 comments on commit 30b765a

Please sign in to comment.