1 Commits

Author SHA1 Message Date
Râu Cao
d59f31a3c6 Make code compatible with Ruby 2.7
Not including specs etc.
2024-01-15 12:34:53 +03:00
4 changed files with 11 additions and 7 deletions

View File

@@ -13,6 +13,8 @@ module Nostr
# #
# @param [String] key_kind The kind of key that is invalid (public or private) # @param [String] key_kind The kind of key that is invalid (public or private)
# #
def initialize(key_kind) = super("Invalid #{key_kind} key type") def initialize(key_kind)
super("Invalid #{key_kind} key type")
end
end end
end end

View File

@@ -79,7 +79,9 @@ module Nostr
# #
# @return [String] The bech32 string representation of the key # @return [String] The bech32 string representation of the key
# #
def to_bech32 = Bech32.encode(hrp: self.class.hrp, data: self) def to_bech32
Bech32.encode(hrp: self.class.hrp, data: self)
end
protected protected

View File

@@ -89,7 +89,7 @@ module Nostr
def get_key_pair_from_private_key(private_key) def get_key_pair_from_private_key(private_key)
validate_private_key(private_key) validate_private_key(private_key)
public_key = extract_public_key(private_key) public_key = extract_public_key(private_key)
KeyPair.new(private_key:, public_key:) KeyPair.new(private_key: private_key, public_key: public_key)
end end
private private

View File

@@ -62,10 +62,10 @@ module Nostr
) )
event = Event.new( event = Event.new(
pubkey: keypair.public_key, pubkey: keypair.public_key,
kind:, kind: kind,
content:, content: content,
created_at:, created_at: created_at,
tags: tags: tags
) )
event.sign(keypair.private_key) event.sign(keypair.private_key)
end end