Skip to content

Commit

Permalink
Pass legacySignedPrivateKeyProto
Browse files Browse the repository at this point in the history
  • Loading branch information
nakajima committed Feb 2, 2024
1 parent d9fc466 commit 039687b
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 8 deletions.
12 changes: 5 additions & 7 deletions Sources/XMTPiOS/Client.swift
Original file line number Diff line number Diff line change
Expand Up @@ -112,16 +112,14 @@ public final class Client {
encryptionKey: nil,
accountAddress: account.address,
legacyIdentitySource: source,
legacySignedPrivateKeyProto: nil
legacySignedPrivateKeyProto: try privateKeyBundleV1.toV2().identityKey.serializedData()
)

guard let textToSign = v3Client.textToSign() else {
throw ClientError.creationError("no text to sign")
if let textToSign = v3Client.textToSign() {
let signature = try await account.sign(message: textToSign).rawData
try await v3Client.registerIdentity(recoverableWalletSignature: signature)
}

let signature = try await account.sign(message: textToSign).rawData
try await v3Client.registerIdentity(recoverableWalletSignature: signature)

let client = try Client(address: account.address, privateKeyBundleV1: privateKeyBundleV1, apiClient: apiClient, v3Client: v3Client)
try await client.ensureUserContactPublished()

Expand Down Expand Up @@ -203,7 +201,7 @@ public final class Client {
encryptionKey: nil,
accountAddress: address,
legacyIdentitySource: .static,
legacySignedPrivateKeyProto: try v1Bundle.identityKey.serializedData()
legacySignedPrivateKeyProto: try v1Bundle.toV2().identityKey.serializedData()
)

try await v3Client.registerIdentity(recoverableWalletSignature: nil)
Expand Down
13 changes: 12 additions & 1 deletion Sources/XMTPiOS/XMTPLogger.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,17 @@ class XMTPLogger: FfiLogger {
let logger = Logger()

func log(level: UInt32, levelLabel: String, message: String) {
logger.info("libxmtp[\(levelLabel)] - \(message)")
switch level {
case 1:
logger.error("libxmtp[\(levelLabel)] - \(message)")
case 2, 3:
logger.info("libxmtp[\(levelLabel)] - \(message)")
case 4:
logger.debug("libxmtp[\(levelLabel)] - \(message)")
case 5:
logger.trace("libxmtp[\(levelLabel)] - \(message)")
default:
print("libxmtp[\(levelLabel)] - \(message)")
}
}
}

0 comments on commit 039687b

Please sign in to comment.