x/ibc: implement 09-localhost per specification (#5769)

Signed-off-by: Gregory Hill <gregorydhill@outlook.com>
This commit is contained in:
Greg Hill
2020-04-17 10:36:47 -04:00
committed by GitHub
parent 968fb1f040
commit de00a7fed1
12 changed files with 887 additions and 2 deletions
+1
View File
@@ -142,6 +142,7 @@ type ClientType byte
// available client types
const (
Tendermint ClientType = iota + 1 // 1
Localhost
)
// string representation of the client types
+3
View File
@@ -8,6 +8,7 @@ import (
"github.com/cosmos/cosmos-sdk/x/ibc/02-client/exported"
"github.com/cosmos/cosmos-sdk/x/ibc/02-client/types"
ibctmtypes "github.com/cosmos/cosmos-sdk/x/ibc/07-tendermint/types"
localhost "github.com/cosmos/cosmos-sdk/x/ibc/09-localhost"
)
// HandleMsgCreateClient defines the sdk.Handler for MsgCreateClient
@@ -27,6 +28,8 @@ func HandleMsgCreateClient(ctx sdk.Context, k Keeper, msg exported.MsgCreateClie
if err != nil {
return nil, err
}
case exported.Localhost:
clientState = localhost.NewClientState(ctx.MultiStore().GetKVStore(k.GetStoreKey()))
default:
return nil, sdkerrors.Wrap(ErrInvalidClientType, msg.GetClientType())
}
+4
View File
@@ -40,6 +40,10 @@ func (k Keeper) Logger(ctx sdk.Context) log.Logger {
return ctx.Logger().With("module", fmt.Sprintf("x/%s/%s", ibctypes.ModuleName, types.SubModuleName))
}
func (k Keeper) GetStoreKey() sdk.StoreKey {
return k.storeKey
}
// GetClientState gets a particular client from the store
func (k Keeper) GetClientState(ctx sdk.Context, clientID string) (exported.ClientState, bool) {
store := k.clientStore(ctx, clientID)