Skip to content

Commit

Permalink
Inline fields in QueryCodeInfoResponse
Browse files Browse the repository at this point in the history
  • Loading branch information
pinosu committed Aug 5, 2024
1 parent 54d3ead commit 03777d7
Show file tree
Hide file tree
Showing 6 changed files with 258 additions and 131 deletions.
5 changes: 4 additions & 1 deletion docs/proto/proto-docs.md
Original file line number Diff line number Diff line change
Expand Up @@ -1091,7 +1091,10 @@ QueryCodeInfoResponse is the response type for the Query/Code RPC method

| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| `code_info` | [CodeInfoResponse](#cosmwasm.wasm.v1.CodeInfoResponse) | | |
| `code_id` | [uint64](#uint64) | | |
| `creator` | [string](#string) | | |
| `checksum` | [bytes](#bytes) | | |
| `instantiate_permission` | [AccessConfig](#cosmwasm.wasm.v1.AccessConfig) | | |



Expand Down
9 changes: 7 additions & 2 deletions proto/cosmwasm/wasm/v1/query.proto
Original file line number Diff line number Diff line change
Expand Up @@ -225,8 +225,13 @@ message QueryCodeInfoRequest {
// QueryCodeInfoResponse is the response type for the Query/Code RPC method
message QueryCodeInfoResponse {
option (gogoproto.equal) = true;
CodeInfoResponse code_info = 1
[ (gogoproto.embed) = true, (gogoproto.jsontag) = "" ];

uint64 code_id = 1 [ (gogoproto.customname) = "CodeID" ];
string creator = 2 [ (cosmos_proto.scalar) = "cosmos.AddressString" ];
bytes checksum = 3 [ (gogoproto.casttype) =
"github.com/cometbft/cometbft/libs/bytes.HexBytes" ];
AccessConfig instantiate_permission = 4
[ (gogoproto.nullable) = false, (amino.dont_omitempty) = true ];
}

// CodeInfoResponse contains code meta data from CodeInfo
Expand Down
5 changes: 1 addition & 4 deletions x/wasm/client/cli/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -261,11 +261,8 @@ func GetCmdQueryCodeInfo() *cobra.Command {
if err != nil {
return err
}
if res.CodeInfoResponse == nil {
return fmt.Errorf("code not found")
}

return clientCtx.PrintProto(res.CodeInfoResponse)
return clientCtx.PrintProto(res)

Check warning on line 265 in x/wasm/client/cli/query.go

View check run for this annotation

Codecov / codecov/patch

x/wasm/client/cli/query.go#L265

Added line #L265 was not covered by tests
},
SilenceUsage: true,
}
Expand Down
5 changes: 4 additions & 1 deletion x/wasm/keeper/querier.go
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,10 @@ func (q GrpcQuerier) CodeInfo(c context.Context, req *types.QueryCodeInfoRequest
return nil, types.ErrNoSuchCodeFn(req.CodeId).Wrapf("code id %d", req.CodeId)

Check warning on line 297 in x/wasm/keeper/querier.go

View check run for this annotation

Codecov / codecov/patch

x/wasm/keeper/querier.go#L297

Added line #L297 was not covered by tests
}
return &types.QueryCodeInfoResponse{
CodeInfoResponse: info,
CodeID: info.CodeID,
Creator: info.Creator,
Checksum: info.DataHash,
InstantiatePermission: info.InstantiatePermission,
}, nil
}

Expand Down
10 changes: 4 additions & 6 deletions x/wasm/keeper/querier_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -815,12 +815,10 @@ func TestQueryCodeInfo(t *testing.T) {
})
require.NoError(t, err)
expectedResponse := &types.QueryCodeInfoResponse{
CodeInfoResponse: &types.CodeInfoResponse{
CodeID: spec.codeID,
Creator: codeInfo.Creator,
DataHash: codeInfo.CodeHash,
InstantiatePermission: spec.accessConfig,
},
CodeID: spec.codeID,
Creator: codeInfo.Creator,
Checksum: codeInfo.CodeHash,
InstantiatePermission: spec.accessConfig,
}
require.NotNil(t, got)
require.EqualValues(t, expectedResponse, got)
Expand Down
Loading

0 comments on commit 03777d7

Please sign in to comment.