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

Refactor out common non-NIP-01 tags out of NostrEvent file into separ… #197

Merged
merged 1 commit into from
Nov 3, 2024

Conversation

tyiu
Copy link
Contributor

@tyiu tyiu commented Nov 3, 2024

…ate protocols for better code separation

@tyiu tyiu force-pushed the tyiu/refactor-non-nip-01-tags branch from 5a25155 to c76c110 Compare November 3, 2024 17:04
@@ -10,7 +10,7 @@ import Foundation
/// A structure that describes a Nostr event.
///
/// > Note: [NIP-01 Specification](https://github.com/nostr-protocol/nips/blob/master/01.md#events-and-signatures)
public class NostrEvent: Codable, Equatable, Hashable, ContentWarningTagInterpreting, LabelTagInterpreting {
public class NostrEvent: Codable, Equatable, Hashable, AlternativeSummaryTagInterpreting, ContentWarningTagInterpreting, ExpirationTagInterpreting, LabelTagInterpreting {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Making this change allows us to keep the base NostrEvent class clean for only the NIP-01 implementation. Any other NIPs that apply to all event kinds can be introduced as a separate protocol/extension that NostrEvent extends from. It'll let us maintain the code much easier.

@@ -318,7 +291,7 @@ public protocol NostrEventBuilding {

public extension NostrEvent {
/// Builder of a ``NostrEvent`` of type `T`.
class Builder<T: NostrEvent>: NostrEventBuilding, ContentWarningTagBuilding, LabelBuilding {
class Builder<T: NostrEvent>: NostrEventBuilding, AlternativeSummaryTagBuilding, ContentWarningTagBuilding, ExpirationTagBuilding, LabelTagBuilding {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here.

@tyiu tyiu merged commit 7dcc12d into main Nov 3, 2024
5 checks passed
@tyiu tyiu deleted the tyiu/refactor-non-nip-01-tags branch November 3, 2024 17:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant