code.vegaprotocol.io/vega@v0.79.0/core/blockchain/response.go (about) 1 // Copyright (C) 2023 Gobalsky Labs Limited 2 // 3 // This program is free software: you can redistribute it and/or modify 4 // it under the terms of the GNU Affero General Public License as 5 // published by the Free Software Foundation, either version 3 of the 6 // License, or (at your option) any later version. 7 // 8 // This program is distributed in the hope that it will be useful, 9 // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 // GNU Affero General Public License for more details. 12 // 13 // You should have received a copy of the GNU Affero General Public License 14 // along with this program. If not, see <http://www.gnu.org/licenses/>. 15 16 package blockchain 17 18 import "github.com/cometbft/cometbft/abci/types" 19 20 const ( 21 // AbciTxnValidationFailure ... 22 AbciTxnValidationFailure uint32 = 51 23 24 // AbciTxnDecodingFailure code is returned when CheckTx or DeliverTx fail to decode the Txn. 25 AbciTxnDecodingFailure uint32 = 60 26 27 // AbciTxnInternalError code is returned when CheckTx or DeliverTx fail to process the Txn. 28 AbciTxnInternalError uint32 = 70 29 30 // AbciTxnPartialProcessingError code is return when a batch instruction partially fail. 31 AbciTxnPartialProcessingError uint32 = 71 32 33 // AbciUnknownCommandError code is returned when the app doesn't know how to handle a given command. 34 AbciUnknownCommandError uint32 = 80 35 36 // AbciSpamError code is returned when CheckTx or DeliverTx fail spam protection tests. 37 AbciSpamError uint32 = 89 38 ) 39 40 func NewResponseCheckTx(code uint32, info string) *types.ResponseCheckTx { 41 return &types.ResponseCheckTx{ 42 Code: code, 43 Info: info, 44 } 45 } 46 47 func NewResponseCheckTxError(code uint32, err error) *types.ResponseCheckTx { 48 return &types.ResponseCheckTx{ 49 Code: code, 50 Info: err.Error(), 51 Data: []byte(err.Error()), 52 } 53 } 54 55 func NewResponseDeliverTx(code uint32, info string) *types.ExecTxResult { 56 return &types.ExecTxResult{ 57 Code: code, 58 Info: info, 59 } 60 } 61 62 func NewResponseDeliverTxError(code uint32, err error) *types.ExecTxResult { 63 return &types.ExecTxResult{ 64 Code: code, 65 Info: err.Error(), 66 Data: []byte(err.Error()), 67 } 68 }