Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IBC Router Middleware #373

Closed
wants to merge 7 commits into from
Closed
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
107 changes: 107 additions & 0 deletions docs/ibc/proto-docs.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,16 @@

## Table of Contents

- [ibc/applications/router/v1/genesis.proto](#ibc/applications/router/v1/genesis.proto)
- [GenesisState](#ibc.applications.router.v1.GenesisState)
- [Params](#ibc.applications.router.v1.Params)

- [ibc/applications/router/v1/query.proto](#ibc/applications/router/v1/query.proto)
- [QueryParamsRequest](#ibc.applications.router.v1.QueryParamsRequest)
- [QueryParamsResponse](#ibc.applications.router.v1.QueryParamsResponse)

- [Query](#ibc.applications.router.v1.Query)

- [ibc/applications/transfer/v1/transfer.proto](#ibc/applications/transfer/v1/transfer.proto)
- [DenomTrace](#ibc.applications.transfer.v1.DenomTrace)
- [FungibleTokenPacketData](#ibc.applications.transfer.v1.FungibleTokenPacketData)
Expand Down Expand Up @@ -246,6 +256,103 @@



<a name="ibc/applications/router/v1/genesis.proto"></a>
<p align="right"><a href="#top">Top</a></p>

## ibc/applications/router/v1/genesis.proto



<a name="ibc.applications.router.v1.GenesisState"></a>

### GenesisState
GenesisState defines the router genesis state


| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| `params` | [Params](#ibc.applications.router.v1.Params) | | |






<a name="ibc.applications.router.v1.Params"></a>

### Params
Params defines the set of IBC router parameters.


| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| `fee_percentage` | [string](#string) | | |





<!-- end messages -->

<!-- end enums -->

<!-- end HasExtensions -->

<!-- end services -->



<a name="ibc/applications/router/v1/query.proto"></a>
<p align="right"><a href="#top">Top</a></p>

## ibc/applications/router/v1/query.proto



<a name="ibc.applications.router.v1.QueryParamsRequest"></a>

### QueryParamsRequest
QueryParamsRequest is the request type for the Query/Params RPC method.






<a name="ibc.applications.router.v1.QueryParamsResponse"></a>

### QueryParamsResponse
QueryParamsResponse is the response type for the Query/Params RPC method.


| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| `params` | [Params](#ibc.applications.router.v1.Params) | | params defines the parameters of the module. |





<!-- end messages -->

<!-- end enums -->

<!-- end HasExtensions -->


<a name="ibc.applications.router.v1.Query"></a>

### Query
Query provides defines the gRPC querier service.

| Method Name | Request Type | Response Type | Description | HTTP Verb | Endpoint |
| ----------- | ------------ | ------------- | ------------| ------- | -------- |
| `Params` | [QueryParamsRequest](#ibc.applications.router.v1.QueryParamsRequest) | [QueryParamsResponse](#ibc.applications.router.v1.QueryParamsResponse) | Params queries all parameters of the router module. | GET|/ibc/apps/router/v1/params|

<!-- end services -->



<a name="ibc/applications/transfer/v1/transfer.proto"></a>
<p align="right"><a href="#top">Top</a></p>

Expand Down
59 changes: 59 additions & 0 deletions modules/apps/router/client/cli/cli.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
package cli

import (
"fmt"

"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/client/flags"
"github.com/cosmos/cosmos-sdk/version"
"github.com/cosmos/ibc-go/modules/apps/router/types"
"github.com/spf13/cobra"
)

// GetQueryCmd returns the query commands for router
func GetQueryCmd() *cobra.Command {
queryCmd := &cobra.Command{
Use: "ibc-router",
DisableFlagParsing: true,
SuggestionsMinimumDistance: 2,
}

queryCmd.AddCommand(
GetCmdParams(),
)

return queryCmd
}

// GetCmdParams returns the command handler for ibc-router parameter querying.
func GetCmdParams() *cobra.Command {
cmd := &cobra.Command{
Use: "params",
Short: "Query the current ibc-router parameters",
Long: "Query the current ibc-router parameters",
Args: cobra.NoArgs,
Example: fmt.Sprintf("%s query ibc-router params", version.AppName),
RunE: func(cmd *cobra.Command, _ []string) error {
clientCtx, err := client.GetClientQueryContext(cmd)
if err != nil {
return err
}
queryClient := types.NewQueryClient(clientCtx)

res, err := queryClient.Params(cmd.Context(), &types.QueryParamsRequest{})
if err != nil {
return err
}
return clientCtx.PrintProto(res.Params)
},
}

flags.AddQueryFlagsToCmd(cmd)

return cmd
}

// NewTxCmd returns the transaction commands for router
func NewTxCmd() *cobra.Command {
return nil
}
16 changes: 16 additions & 0 deletions modules/apps/router/keeper/genesis.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package keeper

import (
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/ibc-go/modules/apps/router/types"
)

// InitGenesis
func (k Keeper) InitGenesis(ctx sdk.Context, state types.GenesisState) {
k.SetParams(ctx, state.Params)
}

// ExportGenesis
func (k Keeper) ExportGenesis(ctx sdk.Context) *types.GenesisState {
return &types.GenesisState{Params: k.GetParams(ctx)}
}
21 changes: 21 additions & 0 deletions modules/apps/router/keeper/grpc_query.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package keeper

import (
"context"

sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/ibc-go/modules/apps/router/types"
)

// TODO

var _ types.QueryServer = Keeper{}

func (k Keeper) Params(c context.Context, _ *types.QueryParamsRequest) (*types.QueryParamsResponse, error) {
ctx := sdk.UnwrapSDKContext(c)
params := k.GetParams(ctx)

return &types.QueryParamsResponse{
Params: &params,
}, nil
}
Loading