diff --git a/daemon/algod/api/server/v2/generated/model/model_types.yml b/daemon/algod/api/server/v2/generated/model/model_types.yml index ecb10ba22e..ad39740b12 100644 --- a/daemon/algod/api/server/v2/generated/model/model_types.yml +++ b/daemon/algod/api/server/v2/generated/model/model_types.yml @@ -6,3 +6,5 @@ output-options: integer: uint64 skip-prune: true output: ./server/v2/generated/model/types.go +compatibility: + always-prefix-enum-values: true diff --git a/daemon/algod/api/server/v2/generated/model/types.go b/daemon/algod/api/server/v2/generated/model/types.go index e9e07b3592..e3fd2d22ff 100644 --- a/daemon/algod/api/server/v2/generated/model/types.go +++ b/daemon/algod/api/server/v2/generated/model/types.go @@ -23,9 +23,9 @@ const ( // Defines values for AddressRole. const ( - FreezeTarget AddressRole = "freeze-target" - Receiver AddressRole = "receiver" - Sender AddressRole = "sender" + AddressRoleFreezeTarget AddressRole = "freeze-target" + AddressRoleReceiver AddressRole = "receiver" + AddressRoleSender AddressRole = "sender" ) // Defines values for Format. @@ -43,13 +43,13 @@ const ( // Defines values for TxType. const ( - Acfg TxType = "acfg" - Afrz TxType = "afrz" - Appl TxType = "appl" - Axfer TxType = "axfer" - Keyreg TxType = "keyreg" - Pay TxType = "pay" - Stpf TxType = "stpf" + TxTypeAcfg TxType = "acfg" + TxTypeAfrz TxType = "afrz" + TxTypeAppl TxType = "appl" + TxTypeAxfer TxType = "axfer" + TxTypeKeyreg TxType = "keyreg" + TxTypePay TxType = "pay" + TxTypeStpf TxType = "stpf" ) // Defines values for TransactionProofResponseHashtype. @@ -66,8 +66,8 @@ const ( // Defines values for AccountInformationParamsExclude. const ( - All AccountInformationParamsExclude = "all" - None AccountInformationParamsExclude = "none" + AccountInformationParamsExcludeAll AccountInformationParamsExclude = "all" + AccountInformationParamsExcludeNone AccountInformationParamsExclude = "none" ) // Defines values for AccountApplicationInformationParamsFormat. @@ -114,8 +114,8 @@ const ( // Defines values for PendingTransactionInformationParamsFormat. const ( - Json PendingTransactionInformationParamsFormat = "json" - Msgpack PendingTransactionInformationParamsFormat = "msgpack" + PendingTransactionInformationParamsFormatJson PendingTransactionInformationParamsFormat = "json" + PendingTransactionInformationParamsFormatMsgpack PendingTransactionInformationParamsFormat = "msgpack" ) // Account Account information at a given round. diff --git a/daemon/algod/api/server/v2/handlers.go b/daemon/algod/api/server/v2/handlers.go index 264d4f1445..378425c9f9 100644 --- a/daemon/algod/api/server/v2/handlers.go +++ b/daemon/algod/api/server/v2/handlers.go @@ -341,7 +341,7 @@ func (v2 *Handlers) ShutdownNode(ctx echo.Context, params model.ShutdownNodePara // AccountInformation gets account information for a given account. // (GET /v2/accounts/{address}) func (v2 *Handlers) AccountInformation(ctx echo.Context, address string, params model.AccountInformationParams) error { - handle, contentType, err := getCodecHandle((*model.Format)(params.Format)) + handle, contentType, err := getCodecHandle((*string)(params.Format)) if err != nil { return badRequest(ctx, err, errFailedParsingFormatOption, v2.Log) } @@ -488,7 +488,7 @@ func (v2 *Handlers) basicAccountInformation(ctx echo.Context, addr basics.Addres // AccountAssetInformation gets account information about a given asset. // (GET /v2/accounts/{address}/assets/{asset-id}) func (v2 *Handlers) AccountAssetInformation(ctx echo.Context, address string, assetID uint64, params model.AccountAssetInformationParams) error { - handle, contentType, err := getCodecHandle((*model.Format)(params.Format)) + handle, contentType, err := getCodecHandle((*string)(params.Format)) if err != nil { return badRequest(ctx, err, errFailedParsingFormatOption, v2.Log) } @@ -541,7 +541,7 @@ func (v2 *Handlers) AccountAssetInformation(ctx echo.Context, address string, as // AccountApplicationInformation gets account information about a given app. // (GET /v2/accounts/{address}/applications/{application-id}) func (v2 *Handlers) AccountApplicationInformation(ctx echo.Context, address string, applicationID uint64, params model.AccountApplicationInformationParams) error { - handle, contentType, err := getCodecHandle((*model.Format)(params.Format)) + handle, contentType, err := getCodecHandle((*string)(params.Format)) if err != nil { return badRequest(ctx, err, errFailedParsingFormatOption, v2.Log) } @@ -598,7 +598,7 @@ func (v2 *Handlers) AccountApplicationInformation(ctx echo.Context, address stri // GetBlock gets the block for the given round. // (GET /v2/blocks/{round}) func (v2 *Handlers) GetBlock(ctx echo.Context, round uint64, params model.GetBlockParams) error { - handle, contentType, err := getCodecHandle((*model.Format)(params.Format)) + handle, contentType, err := getCodecHandle((*string)(params.Format)) if err != nil { return badRequest(ctx, err, errFailedParsingFormatOption, v2.Log) } @@ -1187,7 +1187,7 @@ func (v2 *Handlers) PendingTransactionInformation(ctx echo.Context, txid string, response.Inners = convertInners(&txn) } - handle, contentType, err := getCodecHandle((*model.Format)(params.Format)) + handle, contentType, err := getCodecHandle((*string)(params.Format)) if err != nil { return badRequest(ctx, err, errFailedParsingFormatOption, v2.Log) } @@ -1221,7 +1221,7 @@ func (v2 *Handlers) getPendingTransactions(ctx echo.Context, max *uint64, format addrPtr = &addr } - handle, contentType, err := getCodecHandle((*model.Format)(format)) + handle, contentType, err := getCodecHandle(format) if err != nil { return badRequest(ctx, err, errFailedParsingFormatOption, v2.Log) } diff --git a/daemon/algod/api/server/v2/utils.go b/daemon/algod/api/server/v2/utils.go index 52690cb8e3..32f18ea7d4 100644 --- a/daemon/algod/api/server/v2/utils.go +++ b/daemon/algod/api/server/v2/utils.go @@ -206,16 +206,16 @@ func computeAppIndexFromTxn(tx node.TxnWithStatus, l LedgerForAPI) *uint64 { } // getCodecHandle converts a format string into the encoder + content type -func getCodecHandle(formatPtr *model.Format) (codec.Handle, string, error) { - format := model.Json +func getCodecHandle(formatPtr *string) (codec.Handle, string, error) { + format := "json" if formatPtr != nil { - format = model.PendingTransactionInformationParamsFormat(strings.ToLower(string(*formatPtr))) + format = strings.ToLower(*formatPtr) } switch format { - case model.Json: + case "json": return protocol.JSONStrictHandle, "application/json", nil - case model.Msgpack: + case "msgpack": fallthrough case "msgp": return protocol.CodecHandle, "application/msgpack", nil