diff --git a/Sources/KukaiCoreSwift/Extensions/String+extensions.swift b/Sources/KukaiCoreSwift/Extensions/String+extensions.swift index a450c29c..30a52012 100644 --- a/Sources/KukaiCoreSwift/Extensions/String+extensions.swift +++ b/Sources/KukaiCoreSwift/Extensions/String+extensions.swift @@ -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)) } } } diff --git a/Sources/KukaiCoreSwift/Services/TorusAuthService.swift b/Sources/KukaiCoreSwift/Services/TorusAuthService.swift index 282df906..1f33f065 100644 --- a/Sources/KukaiCoreSwift/Services/TorusAuthService.swift +++ b/Sources/KukaiCoreSwift/Services/TorusAuthService.swift @@ -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,