From 216e65cb2042cbf985ba5906942dfcefd1ffc5b8 Mon Sep 17 00:00:00 2001 From: Krzysztof Tomecki <152964795+chris-4chain@users.noreply.github.com> Date: Tue, 9 Jul 2024 15:16:26 +0200 Subject: [PATCH] feat(SPV-848): adjust to the review --- examples/list_transactions/list_transactions.go | 4 +--- http.go | 4 ++-- notifications/registerer.go | 9 +-------- 3 files changed, 4 insertions(+), 13 deletions(-) diff --git a/examples/list_transactions/list_transactions.go b/examples/list_transactions/list_transactions.go index b83e190..d1d0c6f 100644 --- a/examples/list_transactions/list_transactions.go +++ b/examples/list_transactions/list_transactions.go @@ -23,9 +23,7 @@ func main() { client := walletclient.NewWithXPriv(server, examples.ExampleXPriv) ctx := context.Background() - metadata := map[string]any{ - "note": "user-id-123", - } + metadata := map[string]any{} conditions := filter.TransactionFilter{} queryParams := filter.QueryParams{} diff --git a/http.go b/http.go index a66add4..9b95d6f 100644 --- a/http.go +++ b/http.go @@ -1144,7 +1144,7 @@ func (wc *WalletClient) AdminSubscribeWebhook(ctx context.Context, webhookURL, t if err != nil { return WrapError(err) } - err = wc.doHTTPRequest(ctx, http.MethodPost, "/admin/webhooks/subscribe", rawJSON, wc.adminXPriv, true, nil) + err = wc.doHTTPRequest(ctx, http.MethodPost, "/admin/webhooks/subscribtion", rawJSON, wc.adminXPriv, true, nil) return WrapError(err) } @@ -1157,6 +1157,6 @@ func (wc *WalletClient) AdminUnsubscribeWebhook(ctx context.Context, webhookURL if err != nil { return WrapError(err) } - err = wc.doHTTPRequest(ctx, http.MethodPost, "/admin/webhooks/unsubscribe", rawJSON, wc.adminXPriv, true, nil) + err = wc.doHTTPRequest(ctx, http.MethodDelete, "/admin/webhooks/subscribtion", rawJSON, wc.adminXPriv, true, nil) return err } diff --git a/notifications/registerer.go b/notifications/registerer.go index eb6bc31..edaf2e9 100644 --- a/notifications/registerer.go +++ b/notifications/registerer.go @@ -1,7 +1,6 @@ package notifications import ( - "errors" "reflect" "github.com/bitcoin-sv/spv-wallet/models" @@ -15,14 +14,8 @@ type eventHandler struct { // RegisterHandler - registers a handler for a specific event type func RegisterHandler[EventType models.Events](nd *Webhook, handlerFunction func(event *EventType)) error { handlerValue := reflect.ValueOf(handlerFunction) - if handlerValue.Kind() != reflect.Func { - return errors.New("handlerFunction must be a function") - } - modelType := handlerValue.Type().In(0) - if modelType.Kind() == reflect.Ptr { - modelType = modelType.Elem() - } + modelType := handlerValue.Type().In(0).Elem() name := modelType.Name() nd.handlers.store(name, &eventHandler{