From 89d6ba1eb0a03deba682f23088c515c5932fa9d5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=96mer=20Faruk=20Irmak?= Date: Tue, 28 Nov 2023 15:28:31 +0300 Subject: [PATCH] Fix AddTransaction looking for a class declaration on non-declare txns (#1478) --- rpc/handlers.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/rpc/handlers.go b/rpc/handlers.go index 7c7153e5f7..6370fbb197 100644 --- a/rpc/handlers.go +++ b/rpc/handlers.go @@ -1067,7 +1067,7 @@ func (h *Handler) AddTransaction(txnJSON json.RawMessage) (*AddTxResponse, *json return nil, jsonrpc.Err(jsonrpc.InvalidJSON, err.Error()) } - if txnType, typeFound := request["type"]; typeFound && txnType == TxnInvoke.String() { + if txnType := request["type"]; txnType == TxnInvoke.String() { request["type"] = starknet.TxnInvoke.String() updatedReq, errIn := json.Marshal(request) @@ -1075,7 +1075,7 @@ func (h *Handler) AddTransaction(txnJSON json.RawMessage) (*AddTxResponse, *json return nil, jsonrpc.Err(jsonrpc.InternalError, errIn.Error()) } txnJSON = updatedReq - } else if version, ok := request["version"]; ok && (version == "0x2" || version == "0x3") { + } else if version := request["version"]; txnType == TxnDeclare.String() && (version == "0x2" || version == "0x3") { contractClass, ok := request["contract_class"].(map[string]interface{}) if !ok { return nil, jsonrpc.Err(jsonrpc.InvalidParams, "{'contract_class': ['Missing data for required field.']}")