From 022d4ce59810b93c30e45c4048901cfb6ef68c4b Mon Sep 17 00:00:00 2001 From: fiatjaf Date: Mon, 14 Oct 2024 16:42:54 -0300 Subject: [PATCH] nip46: implement fmt.Stringer for request and response. --- nip46/nip46.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/nip46/nip46.go b/nip46/nip46.go index fd6f69e..766186f 100644 --- a/nip46/nip46.go +++ b/nip46/nip46.go @@ -19,12 +19,22 @@ type Request struct { Params []string `json:"params"` } +func (r Request) String() string { + j, _ := json.Marshal(r) + return string(j) +} + type Response struct { ID string `json:"id"` Error string `json:"error,omitempty"` Result string `json:"result,omitempty"` } +func (r Response) String() string { + j, _ := json.Marshal(r) + return string(j) +} + type Signer interface { GetSession(clientPubkey string) (Session, bool) HandleRequest(context.Context, *nostr.Event) (req Request, resp Response, eventResponse nostr.Event, err error)