Rename NostrSignerType to NostrSignerCommand and introduce NostrSignerRequestType

This commit is contained in:
2025-01-30 22:37:41 -05:00
parent e8b7d56ffc
commit 5a13fb4f64
4 changed files with 22 additions and 9 deletions

View File

@@ -10,7 +10,8 @@ import SwiftData
@Model
final class SignerRequestModel {
var type: NostrSignerType
var command: NostrSignerCommand
var requestType: NostrSignerRequestType
var returnType: NostrSignerReturnType
var compressionType: NostrSignerCompressionType
var createdAt: Date
@@ -22,7 +23,8 @@ final class SignerRequestModel {
var decidedAt: Date?
init(
type: NostrSignerType,
command: NostrSignerCommand,
requestType: NostrSignerRequestType,
returnType: NostrSignerReturnType,
compressionType: NostrSignerCompressionType,
createdAt: Date,
@@ -33,7 +35,8 @@ final class SignerRequestModel {
approved: Bool? = nil,
decidedAt: Date? = nil
) {
self.type = type
self.command = command
self.requestType = requestType
self.returnType = returnType
self.compressionType = compressionType
self.createdAt = createdAt
@@ -46,7 +49,7 @@ final class SignerRequestModel {
}
}
enum NostrSignerType: String, Codable, CaseIterable {
enum NostrSignerCommand: String, Codable, CaseIterable {
case getPublicKey = "get_public_key"
case signEvent = "sign_event"
case nip04Encrypt = "nip04_encrypt"
@@ -57,6 +60,13 @@ enum NostrSignerType: String, Codable, CaseIterable {
case decryptZapEvent = "decrypt_zap_event"
}
enum NostrSignerRequestType: String, Codable {
case actionExtension
case nostrSignerUrlScheme
case nip07
case nip46
}
enum NostrSignerReturnType: String, Codable {
case signature
case event

View File

@@ -67,8 +67,8 @@ class SceneDelegate: NSObject, UIWindowSceneDelegate, ObservableObject {
compressionType = .none
}
guard let rawType = params[NostrSignerURLQueryItemName.type.rawValue],
let type = NostrSignerType(rawValue: rawType),
guard let rawCommand = params[NostrSignerURLQueryItemName.type.rawValue],
let command = NostrSignerCommand(rawValue: rawCommand),
let rawReturnType = params[NostrSignerURLQueryItemName.returnType.rawValue],
let returnType = NostrSignerReturnType(rawValue: rawReturnType)
else {
@@ -81,7 +81,8 @@ class SceneDelegate: NSObject, UIWindowSceneDelegate, ObservableObject {
let pubkey = params[NostrSignerURLQueryItemName.pubkey.rawValue]
let signerRequestModel = SignerRequestModel(
type: type,
command: command,
requestType: .nostrSignerUrlScheme,
returnType: returnType,
compressionType: compressionType,
createdAt: Date.now,

View File

@@ -16,7 +16,8 @@ struct HistoryView: View {
ForEach(signerRequestModels, id: \.self) { signerRequestModel in
Section {
VStack {
Text(signerRequestModel.type.rawValue)
Text(signerRequestModel.command.rawValue)
Text(signerRequestModel.requestType.rawValue)
Text(signerRequestModel.returnType.rawValue)
Text(signerRequestModel.compressionType.rawValue)
Text(signerRequestModel.createdAt.description)

View File

@@ -21,7 +21,8 @@ struct HomeView: View {
if let signerRequestModel = signerRequestModels.first {
Section {
VStack {
Text(signerRequestModel.type.rawValue)
Text(signerRequestModel.command.rawValue)
Text(signerRequestModel.requestType.rawValue)
Text(signerRequestModel.returnType.rawValue)
Text(signerRequestModel.compressionType.rawValue)
Text(signerRequestModel.createdAt.description)