Skip to content

Commit

Permalink
Fix AddTransaction looking for a class declaration on non-declare txns (
Browse files Browse the repository at this point in the history
  • Loading branch information
omerfirmak authored Nov 28, 2023
1 parent 9448c9f commit 89d6ba1
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions rpc/handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -1067,15 +1067,15 @@ 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)
if errIn != nil {
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.']}")
Expand Down

0 comments on commit 89d6ba1

Please sign in to comment.