diff --git a/rpc/subscriptions.go b/rpc/subscriptions.go index 40586400db..cfa6e8dfba 100644 --- a/rpc/subscriptions.go +++ b/rpc/subscriptions.go @@ -13,6 +13,12 @@ import ( const subscribeEventsChunkSize = 1024 +type SubscriptionResponse struct { + Version string `json:"jsonrpc"` + Method string `json:"method"` + Params any `json:"params"` +} + func (h *Handler) SubscribeEvents(ctx context.Context, fromAddr *felt.Felt, keys [][]felt.Felt, blockID *BlockID, ) (*SubscriptionID, *jsonrpc.Error) { @@ -158,7 +164,7 @@ func sendEvents(ctx context.Context, w jsonrpc.Conn, events []*blockchain.Filter }, } - resp, err := json.Marshal(jsonrpc.Request{ + resp, err := json.Marshal(SubscriptionResponse{ Version: "2.0", Method: "starknet_subscriptionEvents", Params: map[string]any{ diff --git a/rpc/subscriptions_test.go b/rpc/subscriptions_test.go index 9271b01ace..bc3bb89ed2 100644 --- a/rpc/subscriptions_test.go +++ b/rpc/subscriptions_test.go @@ -327,7 +327,7 @@ func TestSubscribeEvents(t *testing.T) { } func marshalSubscriptionResponse(e *EmittedEvent, id uint64) ([]byte, error) { - return json.Marshal(jsonrpc.Request{ + return json.Marshal(SubscriptionResponse{ Version: "2.0", Method: "starknet_subscriptionEvents", Params: map[string]any{