From 63b79e1d2300045c4dc9868903e83bea1ddbc948 Mon Sep 17 00:00:00 2001 From: Naomi Plasterer Date: Tue, 8 Oct 2024 19:52:44 -0700 Subject: [PATCH] make block number optional --- Sources/XMTPiOS/Client.swift | 6 +++++- Sources/XMTPiOS/SigningKey.swift | 10 +++++----- XMTP.podspec | 2 +- 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/Sources/XMTPiOS/Client.swift b/Sources/XMTPiOS/Client.swift index 1aadce17..83febe9c 100644 --- a/Sources/XMTPiOS/Client.swift +++ b/Sources/XMTPiOS/Client.swift @@ -248,7 +248,11 @@ public final class Client { do { let signedData = try await signingKey.sign(message: signatureRequest.signatureText()) if signingKey.isSmartContractWallet { - try await signatureRequest.addScwSignature(signatureBytes: signedData.rawData, address: signingKey.address, chainId: signingKey.chainId, blockNumber: signingKey.blockNumber) + try await signatureRequest.addScwSignature(signatureBytes: signedData.rawData, + address: signingKey.address, + chainId: UInt64(signingKey.chainId), + blockNumber: signingKey.blockNumber.flatMap { $0 >= 0 ? UInt64($0) : nil }) + } else { try await signatureRequest.addEcdsaSignature(signatureBytes: signedData.rawData) } diff --git a/Sources/XMTPiOS/SigningKey.swift b/Sources/XMTPiOS/SigningKey.swift index 8e40cace..72ebb0f4 100644 --- a/Sources/XMTPiOS/SigningKey.swift +++ b/Sources/XMTPiOS/SigningKey.swift @@ -24,10 +24,10 @@ public protocol SigningKey { var isSmartContractWallet: Bool { get } /// The name of the chainId for example "1" - var chainId: UInt64 { get } + var chainId: Int64 { get } /// The blockNumber of the chain for example "1" - var blockNumber: UInt64 { get } + var blockNumber: Int64? { get } /// Sign the data and return a secp256k1 compact recoverable signature. func sign(_ data: Data) async throws -> Signature @@ -42,12 +42,12 @@ extension SigningKey { return false } - public var chainId: UInt64 { + public var chainId: Int64 { return 1 } - public var blockNumber: UInt64 { - return 1 + public var blockNumber: Int64? { + return nil } func createIdentity(_ identity: PrivateKey, preCreateIdentityCallback: PreEventCallback? = nil) async throws -> AuthorizedIdentity { diff --git a/XMTP.podspec b/XMTP.podspec index 76198185..ef7c81a7 100644 --- a/XMTP.podspec +++ b/XMTP.podspec @@ -16,7 +16,7 @@ Pod::Spec.new do |spec| # spec.name = "XMTP" - spec.version = "0.15.1" + spec.version = "0.15.1-alpha0" spec.summary = "XMTP SDK Cocoapod" # This description is used to generate tags and improve search results.