Skip to content

Commit

Permalink
retiring(query_request): encode decode methods
Browse files Browse the repository at this point in the history
Signed-off-by: Deepanshu Tripathi <[email protected]>
  • Loading branch information
deepanshutr committed Sep 2, 2024
1 parent 06cfae9 commit ea6f6e9
Show file tree
Hide file tree
Showing 24 changed files with 1 addition and 265 deletions.
4 changes: 1 addition & 3 deletions helpers/query_request.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,7 @@ import (
)

type QueryRequest interface {
Request
GRPCRequest
FromCLI(CLICommand, client.Context) (QueryRequest, error)
FromHTTPRequest(*http.Request) (QueryRequest, error)
Encode() ([]byte, error)
Decode([]byte) (QueryRequest, error)
}
11 changes: 0 additions & 11 deletions x/assets/queries/asset/query_request.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import (
"github.com/cosmos/cosmos-sdk/client"

"github.com/AssetMantle/modules/helpers"
"github.com/AssetMantle/modules/helpers/base"
"github.com/AssetMantle/modules/helpers/constants"
"github.com/AssetMantle/modules/x/assets/key"
)
Expand Down Expand Up @@ -49,17 +48,7 @@ func (*QueryRequest) FromHTTPRequest(httpRequest *http.Request) (helpers.QueryRe
return newQueryRequest(assetID.(ids.AssetID)), nil
}
}
func (queryRequest *QueryRequest) Encode() ([]byte, error) {
return base.CodecPrototype().MarshalJSON(queryRequest)
}

func (queryRequest *QueryRequest) Decode(bytes []byte) (helpers.QueryRequest, error) {
if err := base.CodecPrototype().UnmarshalJSON(bytes, queryRequest); err != nil {
return nil, err
}

return queryRequest, nil
}
func requestPrototype() helpers.QueryRequest {
return &QueryRequest{}
}
Expand Down
11 changes: 0 additions & 11 deletions x/assets/queries/assets/query_request.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import (
"github.com/cosmos/cosmos-sdk/types/query"

"github.com/AssetMantle/modules/helpers"
"github.com/AssetMantle/modules/helpers/base"
"github.com/AssetMantle/modules/helpers/constants"
"github.com/AssetMantle/modules/x/assets/key"
)
Expand Down Expand Up @@ -68,17 +67,7 @@ func (*QueryRequest) FromHTTPRequest(httpRequest *http.Request) (helpers.QueryRe

return newQueryRequest(assetID.(ids.AssetID), int32(limit)), nil
}
func (queryRequest *QueryRequest) Encode() ([]byte, error) {
return base.CodecPrototype().MarshalJSON(queryRequest)
}

func (queryRequest *QueryRequest) Decode(bytes []byte) (helpers.QueryRequest, error) {
if err := base.CodecPrototype().UnmarshalJSON(bytes, queryRequest); err != nil {
return nil, err
}

return queryRequest, nil
}
func requestPrototype() helpers.QueryRequest {
return &QueryRequest{}
}
Expand Down
12 changes: 0 additions & 12 deletions x/assets/queries/parameters/query_request.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package parameters

import (
"github.com/AssetMantle/modules/helpers"
"github.com/AssetMantle/modules/helpers/base"
"github.com/cosmos/cosmos-sdk/client"
"net/http"
)
Expand All @@ -21,17 +20,6 @@ func (queryRequest *QueryRequest) FromHTTPRequest(_ *http.Request) (helpers.Quer
return requestPrototype(), nil
}

func (queryRequest *QueryRequest) Encode() ([]byte, error) {
return base.CodecPrototype().MarshalJSON(queryRequest)
}

func (queryRequest *QueryRequest) Decode(bytes []byte) (helpers.QueryRequest, error) {
if err := base.CodecPrototype().UnmarshalJSON(bytes, queryRequest); err != nil {
return nil, err
}

return queryRequest, nil
}
func requestPrototype() helpers.QueryRequest {
return &QueryRequest{}
}
11 changes: 0 additions & 11 deletions x/classifications/queries/classification/query_request.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import (
"github.com/cosmos/cosmos-sdk/client"

"github.com/AssetMantle/modules/helpers"
"github.com/AssetMantle/modules/helpers/base"
"github.com/AssetMantle/modules/helpers/constants"
"github.com/AssetMantle/modules/x/classifications/key"
)
Expand Down Expand Up @@ -49,16 +48,6 @@ func (*QueryRequest) FromHTTPRequest(httpRequest *http.Request) (helpers.QueryRe
return newQueryRequest(classificationID.(ids.ClassificationID)), nil
}
}
func (queryRequest *QueryRequest) Encode() ([]byte, error) {
return base.CodecPrototype().MarshalJSON(queryRequest)
}
func (queryRequest *QueryRequest) Decode(bytes []byte) (helpers.QueryRequest, error) {
if err := base.CodecPrototype().UnmarshalJSON(bytes, queryRequest); err != nil {
return nil, err
}

return queryRequest, nil
}
func requestPrototype() helpers.QueryRequest {
return &QueryRequest{}
}
Expand Down
11 changes: 0 additions & 11 deletions x/classifications/queries/classifications/query_request.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import (
"github.com/cosmos/cosmos-sdk/types/query"

"github.com/AssetMantle/modules/helpers"
"github.com/AssetMantle/modules/helpers/base"
"github.com/AssetMantle/modules/helpers/constants"
"github.com/AssetMantle/modules/x/classifications/key"
)
Expand Down Expand Up @@ -68,16 +67,6 @@ func (*QueryRequest) FromHTTPRequest(httpRequest *http.Request) (helpers.QueryRe

return newQueryRequest(classificationID.(ids.ClassificationID), int32(limit)), nil
}
func (queryRequest *QueryRequest) Encode() ([]byte, error) {
return base.CodecPrototype().MarshalJSON(queryRequest)
}
func (queryRequest *QueryRequest) Decode(bytes []byte) (helpers.QueryRequest, error) {
if err := base.CodecPrototype().UnmarshalJSON(bytes, queryRequest); err != nil {
return nil, err
}

return queryRequest, nil
}
func requestPrototype() helpers.QueryRequest {
return &QueryRequest{}
}
Expand Down
12 changes: 0 additions & 12 deletions x/classifications/queries/parameters/query_request.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package parameters

import (
"github.com/AssetMantle/modules/helpers"
"github.com/AssetMantle/modules/helpers/base"
"github.com/cosmos/cosmos-sdk/client"
"net/http"
)
Expand All @@ -21,17 +20,6 @@ func (queryRequest *QueryRequest) FromHTTPRequest(_ *http.Request) (helpers.Quer
return requestPrototype(), nil
}

func (queryRequest *QueryRequest) Encode() ([]byte, error) {
return base.CodecPrototype().MarshalJSON(queryRequest)
}

func (queryRequest *QueryRequest) Decode(bytes []byte) (helpers.QueryRequest, error) {
if err := base.CodecPrototype().UnmarshalJSON(bytes, queryRequest); err != nil {
return nil, err
}

return queryRequest, nil
}
func requestPrototype() helpers.QueryRequest {
return &QueryRequest{}
}
11 changes: 0 additions & 11 deletions x/identities/queries/identities/query_request.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import (
"github.com/cosmos/cosmos-sdk/types/query"

"github.com/AssetMantle/modules/helpers"
"github.com/AssetMantle/modules/helpers/base"
"github.com/AssetMantle/modules/helpers/constants"
"github.com/AssetMantle/modules/x/identities/key"
)
Expand Down Expand Up @@ -67,16 +66,6 @@ func (*QueryRequest) FromHTTPRequest(httpRequest *http.Request) (helpers.QueryRe
}
return newQueryRequest(identityID.(ids.IdentityID), int32(limit)), nil
}
func (queryRequest *QueryRequest) Encode() ([]byte, error) {
return base.CodecPrototype().MarshalJSON(queryRequest)
}
func (queryRequest *QueryRequest) Decode(bytes []byte) (helpers.QueryRequest, error) {
if err := base.CodecPrototype().UnmarshalJSON(bytes, queryRequest); err != nil {
return nil, err
}

return queryRequest, nil
}
func requestPrototype() helpers.QueryRequest {
return &QueryRequest{}
}
Expand Down
11 changes: 0 additions & 11 deletions x/identities/queries/identity/query_request.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import (
"github.com/cosmos/cosmos-sdk/client"

"github.com/AssetMantle/modules/helpers"
"github.com/AssetMantle/modules/helpers/base"
"github.com/AssetMantle/modules/helpers/constants"
"github.com/AssetMantle/modules/x/identities/key"
)
Expand Down Expand Up @@ -49,16 +48,6 @@ func (*QueryRequest) FromHTTPRequest(httpRequest *http.Request) (helpers.QueryRe
return newQueryRequest(identityID.(ids.IdentityID)), nil
}
}
func (queryRequest *QueryRequest) Encode() ([]byte, error) {
return base.CodecPrototype().MarshalJSON(queryRequest)
}
func (queryRequest *QueryRequest) Decode(bytes []byte) (helpers.QueryRequest, error) {
if err := base.CodecPrototype().UnmarshalJSON(bytes, queryRequest); err != nil {
return nil, err
}

return queryRequest, nil
}
func requestPrototype() helpers.QueryRequest {
return &QueryRequest{}
}
Expand Down
12 changes: 0 additions & 12 deletions x/identities/queries/parameters/query_request.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package parameters

import (
"github.com/AssetMantle/modules/helpers"
"github.com/AssetMantle/modules/helpers/base"
"github.com/cosmos/cosmos-sdk/client"
"net/http"
)
Expand All @@ -21,17 +20,6 @@ func (queryRequest *QueryRequest) FromHTTPRequest(_ *http.Request) (helpers.Quer
return requestPrototype(), nil
}

func (queryRequest *QueryRequest) Encode() ([]byte, error) {
return base.CodecPrototype().MarshalJSON(queryRequest)
}

func (queryRequest *QueryRequest) Decode(bytes []byte) (helpers.QueryRequest, error) {
if err := base.CodecPrototype().UnmarshalJSON(bytes, queryRequest); err != nil {
return nil, err
}

return queryRequest, nil
}
func requestPrototype() helpers.QueryRequest {
return &QueryRequest{}
}
12 changes: 0 additions & 12 deletions x/maintainers/queries/maintainer/query_request.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import (
"github.com/cosmos/cosmos-sdk/client"

"github.com/AssetMantle/modules/helpers"
"github.com/AssetMantle/modules/helpers/base"
"github.com/AssetMantle/modules/helpers/constants"
"github.com/AssetMantle/modules/x/maintainers/key"
)
Expand Down Expand Up @@ -52,17 +51,6 @@ func (*QueryRequest) FromHTTPRequest(httpRequest *http.Request) (helpers.QueryRe
}
}

func (queryRequest *QueryRequest) Encode() ([]byte, error) {
return base.CodecPrototype().MarshalJSON(queryRequest)
}

func (queryRequest *QueryRequest) Decode(bytes []byte) (helpers.QueryRequest, error) {
if err := base.CodecPrototype().UnmarshalJSON(bytes, queryRequest); err != nil {
return nil, err
}

return queryRequest, nil
}
func requestPrototype() helpers.QueryRequest {
return &QueryRequest{}
}
Expand Down
12 changes: 0 additions & 12 deletions x/maintainers/queries/maintainers/query_request.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import (
"github.com/cosmos/cosmos-sdk/types/query"

"github.com/AssetMantle/modules/helpers"
"github.com/AssetMantle/modules/helpers/base"
"github.com/AssetMantle/modules/helpers/constants"
"github.com/AssetMantle/modules/x/maintainers/key"
)
Expand Down Expand Up @@ -71,17 +70,6 @@ func (*QueryRequest) FromHTTPRequest(httpRequest *http.Request) (helpers.QueryRe
return newQueryRequest(maintainerID.(ids.MaintainerID), int32(limit)), nil
}

func (queryRequest *QueryRequest) Encode() ([]byte, error) {
return base.CodecPrototype().MarshalJSON(queryRequest)
}

func (queryRequest *QueryRequest) Decode(bytes []byte) (helpers.QueryRequest, error) {
if err := base.CodecPrototype().UnmarshalJSON(bytes, queryRequest); err != nil {
return nil, err
}

return queryRequest, nil
}
func requestPrototype() helpers.QueryRequest {
return &QueryRequest{}
}
Expand Down
12 changes: 0 additions & 12 deletions x/maintainers/queries/parameters/query_request.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package parameters

import (
"github.com/AssetMantle/modules/helpers"
"github.com/AssetMantle/modules/helpers/base"
"github.com/cosmos/cosmos-sdk/client"
"net/http"
)
Expand All @@ -21,17 +20,6 @@ func (queryRequest *QueryRequest) FromHTTPRequest(_ *http.Request) (helpers.Quer
return requestPrototype(), nil
}

func (queryRequest *QueryRequest) Encode() ([]byte, error) {
return base.CodecPrototype().MarshalJSON(queryRequest)
}

func (queryRequest *QueryRequest) Decode(bytes []byte) (helpers.QueryRequest, error) {
if err := base.CodecPrototype().UnmarshalJSON(bytes, queryRequest); err != nil {
return nil, err
}

return queryRequest, nil
}
func requestPrototype() helpers.QueryRequest {
return &QueryRequest{}
}
11 changes: 0 additions & 11 deletions x/metas/queries/meta/query_request.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import (
"github.com/cosmos/cosmos-sdk/client"

"github.com/AssetMantle/modules/helpers"
"github.com/AssetMantle/modules/helpers/base"
"github.com/AssetMantle/modules/helpers/constants"
"github.com/AssetMantle/modules/x/metas/key"
)
Expand Down Expand Up @@ -49,16 +48,6 @@ func (*QueryRequest) FromHTTPRequest(httpRequest *http.Request) (helpers.QueryRe
return newQueryRequest(dataID.(ids.DataID)), nil
}
}
func (queryRequest *QueryRequest) Encode() ([]byte, error) {
return base.CodecPrototype().MarshalJSON(queryRequest)
}
func (queryRequest *QueryRequest) Decode(bytes []byte) (helpers.QueryRequest, error) {
if err := base.CodecPrototype().UnmarshalJSON(bytes, queryRequest); err != nil {
return nil, err
}

return queryRequest, nil
}
func requestPrototype() helpers.QueryRequest {
return &QueryRequest{}
}
Expand Down
11 changes: 0 additions & 11 deletions x/metas/queries/metas/query_request.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import (
"github.com/cosmos/cosmos-sdk/types/query"

"github.com/AssetMantle/modules/helpers"
"github.com/AssetMantle/modules/helpers/base"
"github.com/AssetMantle/modules/helpers/constants"
"github.com/AssetMantle/modules/x/metas/key"
)
Expand Down Expand Up @@ -68,16 +67,6 @@ func (*QueryRequest) FromHTTPRequest(httpRequest *http.Request) (helpers.QueryRe

return newQueryRequest(dataID.(ids.DataID), int32(limit)), nil
}
func (queryRequest *QueryRequest) Encode() ([]byte, error) {
return base.CodecPrototype().MarshalJSON(queryRequest)
}
func (queryRequest *QueryRequest) Decode(bytes []byte) (helpers.QueryRequest, error) {
if err := base.CodecPrototype().UnmarshalJSON(bytes, queryRequest); err != nil {
return nil, err
}

return queryRequest, nil
}
func requestPrototype() helpers.QueryRequest {
return &QueryRequest{}
}
Expand Down
12 changes: 0 additions & 12 deletions x/metas/queries/parameters/query_request.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package parameters

import (
"github.com/AssetMantle/modules/helpers"
"github.com/AssetMantle/modules/helpers/base"
"github.com/cosmos/cosmos-sdk/client"
"net/http"
)
Expand All @@ -21,17 +20,6 @@ func (queryRequest *QueryRequest) FromHTTPRequest(_ *http.Request) (helpers.Quer
return requestPrototype(), nil
}

func (queryRequest *QueryRequest) Encode() ([]byte, error) {
return base.CodecPrototype().MarshalJSON(queryRequest)
}

func (queryRequest *QueryRequest) Decode(bytes []byte) (helpers.QueryRequest, error) {
if err := base.CodecPrototype().UnmarshalJSON(bytes, queryRequest); err != nil {
return nil, err
}

return queryRequest, nil
}
func requestPrototype() helpers.QueryRequest {
return &QueryRequest{}
}
Loading

0 comments on commit ea6f6e9

Please sign in to comment.