@@ -89,6 +89,7 @@ public final class Client {
89
89
let apiClient : ApiClient
90
90
let v3Client : LibXMTP . FfiXmtpClient ?
91
91
public let libXMTPVersion : String = getVersionInfo ( )
92
+ let dbPath : String = " "
92
93
93
94
/// Access ``Conversations`` for this Client.
94
95
public lazy var conversations : Conversations = . init( client: self )
@@ -132,7 +133,7 @@ public final class Client {
132
133
) async throws -> FfiXmtpClient ? {
133
134
if options? . mlsAlpha == true , options? . api. env. supportsMLS == true {
134
135
let dbURL = options? . mlsDbPath ?? URL . documentsDirectory. appendingPathComponent ( " xmtp- \( options? . api. env. rawValue ?? " " ) - \( address) .db3 " ) . path
135
-
136
+
136
137
var encryptionKey = options? . mlsEncryptionKey
137
138
if ( encryptionKey == nil ) {
138
139
let preferences = UserDefaults . standard
@@ -146,7 +147,7 @@ public final class Client {
146
147
encryptionKey = preferences. data ( forKey: key)
147
148
}
148
149
}
149
-
150
+
150
151
let v3Client = try await LibXMTP . createClient (
151
152
logger: XMTPLogger ( ) ,
152
153
host: ( options? . api. env ?? . local) . url,
@@ -168,7 +169,7 @@ public final class Client {
168
169
} else {
169
170
try await v3Client. registerIdentity ( recoverableWalletSignature: nil )
170
171
}
171
-
172
+
172
173
print ( " LibXMTP \( getVersionInfo ( ) ) " )
173
174
174
175
return v3Client
@@ -250,16 +251,15 @@ public final class Client {
250
251
251
252
return try await v3Client. canMessage ( accountAddresses: [ address] ) == [ true ]
252
253
}
253
-
254
+
254
255
public func canMessageV3( addresses: [ String ] ) async throws -> Bool {
255
256
guard let v3Client else {
256
257
return false
257
258
}
258
-
259
+
259
260
return try await !v3Client. canMessage ( accountAddresses: addresses) . contains ( false )
260
261
}
261
262
262
-
263
263
public static func from( bundle: PrivateKeyBundle , options: ClientOptions ? = nil ) async throws -> Client {
264
264
return try await from ( v1Bundle: bundle. v1, options: options)
265
265
}
@@ -280,7 +280,7 @@ public final class Client {
280
280
privateKeyBundleV1: v1Bundle,
281
281
signingKey: nil
282
282
)
283
-
283
+
284
284
let client = try await LibXMTP . createV2Client ( host: options. api. env. url, isSecure: options. api. env. isSecure)
285
285
let apiClient = try GRPCApiClient (
286
286
environment: options. api. env,
@@ -451,6 +451,20 @@ public final class Client {
451
451
return subscribe ( topics: topics. map ( \. description) )
452
452
}
453
453
454
+ public func deleteLocalDatabase( ) {
455
+ let fm = FileManager . default
456
+ let url = URL ( string: dbPath)
457
+ if ( url != nil ) {
458
+ do {
459
+ // swiftlint: disable force_unwrapping
460
+ try fm. removeItem ( at: url!)
461
+ // swiftlint: enable force_unwrapping
462
+ } catch {
463
+ print ( " Error deleting file: \( dbPath) " )
464
+ }
465
+ }
466
+ }
467
+
454
468
func getUserContact( peerAddress: String ) async throws -> ContactBundle ? {
455
469
let peerAddress = EthereumAddress ( peerAddress) . toChecksumAddress ( )
456
470
return try await contacts. find ( peerAddress)
0 commit comments