Skip to content

Commit

Permalink
Revert "add cli to get denom hash from trace path and base denom (bac…
Browse files Browse the repository at this point in the history
…kport #679) (#710)" (#827)

This reverts commit 6f6af9b.
  • Loading branch information
colin-axner authored Feb 3, 2022
1 parent ead42ed commit 12b96bc
Show file tree
Hide file tree
Showing 11 changed files with 35 additions and 775 deletions.
3 changes: 0 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,3 @@ dependency-graph.png
*.aux
*.out
*.synctex.gz

*.history

4 changes: 0 additions & 4 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,6 @@ Ref: https://keepachangelog.com/en/1.0.0/

* (channel) [\#692](https://github.com/cosmos/ibc-go/pull/692) Minimize channel logging by only emitting the packet sequence, source port/channel, destination port/channel upon packet receives, acknowledgements and timeouts.

### Features

* [\#679](https://github.com/cosmos/ibc-go/pull/679) New CLI command `query ibc-transfer denom-hash <denom trace>` to get the denom hash for a denom trace; this might be useful for debug

## [v2.0.2](https://github.com/cosmos/ibc-go/releases/tag/v2.0.2) - 2021-12-15

### Dependencies
Expand Down
66 changes: 0 additions & 66 deletions docs/client/swagger-ui/swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,54 +4,6 @@ info:
description: A REST interface for state queries
version: 1.0.0
paths:
'/ibc/apps/transfer/v1/denom_hashes/{trace}':
get:
summary: DenomHash queries a denomination hash information.
operationId: DenomHash
responses:
'200':
description: A successful response.
schema:
type: object
properties:
hash:
type: string
description: hash (in hex format) of the denomination trace information.
description: >-
QueryDenomHashResponse is the response type for the
Query/DenomHash RPC
method.
default:
description: An unexpected error response
schema:
type: object
properties:
error:
type: string
code:
type: integer
format: int32
message:
type: string
details:
type: array
items:
type: object
properties:
type_url:
type: string
value:
type: string
format: byte
parameters:
- name: trace
description: 'The denomination trace ([port_id]/[channel_id])+/[denom]'
in: path
required: true
type: string
tags:
- Query
/ibc/apps/transfer/v1/denom_traces:
get:
summary: DenomTraces queries all denomination traces.
Expand Down Expand Up @@ -7374,15 +7326,6 @@ paths:
required: false
type: boolean
format: boolean
- name: packet_commitment_sequences
description: list of packet sequences.
in: query
required: false
type: array
items:
type: string
format: uint64
collectionFormat: multi
tags:
- Query
'/ibc/core/channel/v1/channels/{channel_id}/ports/{port_id}/packet_acks/{sequence}':
Expand Down Expand Up @@ -9896,15 +9839,6 @@ definitions:
SendEnabled
parameter for the denomination to false.
ibc.applications.transfer.v1.QueryDenomHashResponse:
type: object
properties:
hash:
type: string
description: hash (in hex format) of the denomination trace information.
description: |-
QueryDenomHashResponse is the response type for the Query/DenomHash RPC
method.
ibc.applications.transfer.v1.QueryDenomTraceResponse:
type: object
properties:
Expand Down
35 changes: 0 additions & 35 deletions docs/ibc/proto-docs.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@
- [GenesisState](#ibc.applications.transfer.v1.GenesisState)

- [ibc/applications/transfer/v1/query.proto](#ibc/applications/transfer/v1/query.proto)
- [QueryDenomHashRequest](#ibc.applications.transfer.v1.QueryDenomHashRequest)
- [QueryDenomHashResponse](#ibc.applications.transfer.v1.QueryDenomHashResponse)
- [QueryDenomTraceRequest](#ibc.applications.transfer.v1.QueryDenomTraceRequest)
- [QueryDenomTraceResponse](#ibc.applications.transfer.v1.QueryDenomTraceResponse)
- [QueryDenomTracesRequest](#ibc.applications.transfer.v1.QueryDenomTracesRequest)
Expand Down Expand Up @@ -348,38 +346,6 @@ GenesisState defines the ibc-transfer genesis state



<a name="ibc.applications.transfer.v1.QueryDenomHashRequest"></a>

### QueryDenomHashRequest
QueryDenomHashRequest is the request type for the Query/DenomHash RPC
method


| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| `trace` | [string](#string) | | The denomination trace ([port_id]/[channel_id])+/[denom] |






<a name="ibc.applications.transfer.v1.QueryDenomHashResponse"></a>

### QueryDenomHashResponse
QueryDenomHashResponse is the response type for the Query/DenomHash RPC
method.


| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| `hash` | [string](#string) | | hash (in hex format) of the denomination trace information. |






<a name="ibc.applications.transfer.v1.QueryDenomTraceRequest"></a>

### QueryDenomTraceRequest
Expand Down Expand Up @@ -486,7 +452,6 @@ Query provides defines the gRPC querier service.
| `DenomTrace` | [QueryDenomTraceRequest](#ibc.applications.transfer.v1.QueryDenomTraceRequest) | [QueryDenomTraceResponse](#ibc.applications.transfer.v1.QueryDenomTraceResponse) | DenomTrace queries a denomination trace information. | GET|/ibc/apps/transfer/v1/denom_traces/{hash}|
| `DenomTraces` | [QueryDenomTracesRequest](#ibc.applications.transfer.v1.QueryDenomTracesRequest) | [QueryDenomTracesResponse](#ibc.applications.transfer.v1.QueryDenomTracesResponse) | DenomTraces queries all denomination traces. | GET|/ibc/apps/transfer/v1/denom_traces|
| `Params` | [QueryParamsRequest](#ibc.applications.transfer.v1.QueryParamsRequest) | [QueryParamsResponse](#ibc.applications.transfer.v1.QueryParamsResponse) | Params queries all parameters of the ibc-transfer module. | GET|/ibc/apps/transfer/v1/params|
| `DenomHash` | [QueryDenomHashRequest](#ibc.applications.transfer.v1.QueryDenomHashRequest) | [QueryDenomHashResponse](#ibc.applications.transfer.v1.QueryDenomHashResponse) | DenomHash queries a denomination hash information. | GET|/ibc/apps/transfer/v1/denom_hashes/{trace}|

<!-- end services -->

Expand Down
1 change: 0 additions & 1 deletion modules/apps/transfer/client/cli/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ func GetQueryCmd() *cobra.Command {
GetCmdQueryDenomTraces(),
GetCmdParams(),
GetCmdQueryEscrowAddress(),
GetCmdQueryDenomHash(),
)

return queryCmd
Expand Down
32 changes: 0 additions & 32 deletions modules/apps/transfer/client/cli/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,35 +131,3 @@ func GetCmdQueryEscrowAddress() *cobra.Command {

return cmd
}

// GetCmdQueryDenomHash defines the command to query a denomination hash from a given trace.
func GetCmdQueryDenomHash() *cobra.Command {
cmd := &cobra.Command{
Use: "denom-hash [trace]",
Short: "Query the denom hash info from a given denom trace",
Long: "Query the denom hash info from a given denom trace",
Example: fmt.Sprintf("%s query ibc-transfer denom-hash [denom_trace]", version.AppName),
Args: cobra.ExactArgs(1),
RunE: func(cmd *cobra.Command, args []string) error {
clientCtx, err := client.GetClientQueryContext(cmd)
if err != nil {
return err
}
queryClient := types.NewQueryClient(clientCtx)

req := &types.QueryDenomHashRequest{
Trace: args[0],
}

res, err := queryClient.DenomHash(cmd.Context(), req)
if err != nil {
return err
}

return clientCtx.PrintProto(res)
},
}

flags.AddQueryFlagsToCmd(cmd)
return cmd
}
27 changes: 0 additions & 27 deletions modules/apps/transfer/keeper/grpc_query.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,30 +81,3 @@ func (q Keeper) Params(c context.Context, _ *types.QueryParamsRequest) (*types.Q
Params: &params,
}, nil
}

// DenomHash implements the Query/DenomHash gRPC method
func (q Keeper) DenomHash(c context.Context, req *types.QueryDenomHashRequest) (*types.QueryDenomHashResponse, error) {
if req == nil {
return nil, status.Error(codes.InvalidArgument, "empty request")
}

// Convert given request trace path to DenomTrace struct to confirm the path in a valid denom trace format
denomTrace := types.ParseDenomTrace(req.Trace)
if err := denomTrace.Validate(); err != nil {
return nil, status.Error(codes.InvalidArgument, err.Error())
}

ctx := sdk.UnwrapSDKContext(c)
denomHash := denomTrace.Hash()
found := q.HasDenomTrace(ctx, denomHash)
if !found {
return nil, status.Error(
codes.NotFound,
sdkerrors.Wrap(types.ErrTraceNotFound, req.Trace).Error(),
)
}

return &types.QueryDenomHashResponse{
Hash: denomHash.String(),
}, nil
}
67 changes: 0 additions & 67 deletions modules/apps/transfer/keeper/grpc_query_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,70 +140,3 @@ func (suite *KeeperTestSuite) TestQueryParams() {
res, _ := suite.queryClient.Params(ctx, &types.QueryParamsRequest{})
suite.Require().Equal(&expParams, res.Params)
}

func (suite *KeeperTestSuite) TestQueryDenomHash() {

reqTrace := types.DenomTrace{
Path: "transfer/channelToA/transfer/channelToB",
BaseDenom: "uatom",
}

var (
req *types.QueryDenomHashRequest
expHash = reqTrace.Hash().String()
)

testCases := []struct {
msg string
malleate func()
expPass bool
}{
{
"invalid trace",
func() {
req = &types.QueryDenomHashRequest{
Trace: "transfer/channelToA/transfer/",
}
},
false,
},
{
"not found denom trace",
func() {
req = &types.QueryDenomHashRequest{
Trace: "transfer/channelToC/uatom",
}
},
false,
},
{
"success",
func() {},
true,
},
}

for _, tc := range testCases {
suite.Run(fmt.Sprintf("Case %s", tc.msg), func() {
suite.SetupTest() // reset

req = &types.QueryDenomHashRequest{
Trace: reqTrace.GetFullDenomPath(),
}
suite.chainA.GetSimApp().TransferKeeper.SetDenomTrace(suite.chainA.GetContext(), reqTrace)

tc.malleate()
ctx := sdk.WrapSDKContext(suite.chainA.GetContext())

res, err := suite.queryClient.DenomHash(ctx, req)

if tc.expPass {
suite.Require().NoError(err)
suite.Require().NotNil(res)
suite.Require().Equal(expHash, res.Hash)
} else {
suite.Require().Error(err)
}
})
}
}
Loading

0 comments on commit 12b96bc

Please sign in to comment.