Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Notify] Subscriptions index by app #1259

Merged
merged 2 commits into from
Dec 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ public struct NotifyClientFactory {
let keyserverURL = URL(string: "https://keys.walletconnect.com")!
let keychainStorage = KeychainStorage(serviceIdentifier: "com.walletconnect.sdk", accessGroup: groupIdentifier)
let groupKeychainService = GroupKeychainStorage(serviceIdentifier: groupIdentifier)
let databasePath = databasePath(appGroup: groupIdentifier, database: "notify.db")
let databasePath = databasePath(appGroup: groupIdentifier, database: "notify_v\(version).db")
let sqlite = DiskSqlite(path: databasePath)

return NotifyClientFactory.create(
Expand Down Expand Up @@ -102,4 +102,8 @@ public struct NotifyClientFactory {

return path.absoluteString
}

static var version: String {
return "1"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -110,14 +110,15 @@ private extension NotifyDatabase {

try sqlite.execute(sql: """
CREATE TABLE IF NOT EXISTS \(Table.subscriptions) (
topic TEXT PRIMARY KEY,
topic TEXT NOT NULL,
account TEXT NOT NULL,
relay TEXT NOT NULL,
metadata TEXT NOT NULL,
scope TEXT NOT NULL,
expiry TEXT NOT NULL,
symKey TEXT NOT NULL,
appAuthenticationKey TEXT NOT NULL
appAuthenticationKey TEXT NOT NULL,
id TEXT PRIMARY KEY
);
""")

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import Foundation
import Database

public struct NotifySubscription: DatabaseObject, SqliteRow {
public struct NotifySubscription: Codable, Equatable, SqliteRow {
public let topic: String
public let account: Account
public let relay: RelayProtocolOptions
Expand All @@ -11,8 +11,8 @@ public struct NotifySubscription: DatabaseObject, SqliteRow {
public let symKey: String
public let appAuthenticationKey: String

public var databaseId: String {
return topic
private var id: String {
return "\(account.absoluteString)-\(metadata.url)"
}

public init(decoder: SqliteRowDecoder) throws {
Expand All @@ -36,6 +36,7 @@ public struct NotifySubscription: DatabaseObject, SqliteRow {
encoder.encodeDate(expiry, for: "expiry")
encoder.encodeString(symKey, for: "symKey")
encoder.encodeString(appAuthenticationKey, for: "appAuthenticationKey")
encoder.encodeString(id, for: "id")
return encoder
}

Expand Down
Loading