forked from cosmos/relayer
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: replaces query canonical client with sending a tx to try to set…
… it (#57)
- Loading branch information
Showing
15 changed files
with
566 additions
and
85 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
syntax = "proto3"; | ||
package dymensionxyz.dymension.lightclient; | ||
|
||
import "cosmos/msg/v1/msg.proto"; | ||
import "gogoproto/gogo.proto"; | ||
|
||
option go_package = "github.com/cosmos/relayer/relayer/chains/cosmos/dym/lightclient/types"; | ||
|
||
|
||
// verify a client state and its consensus states against the rollapp | ||
// if it matches, set the client as the canonical client for the rollapp | ||
message MsgSetCanonicalClient { | ||
option (cosmos.msg.v1.signer) = "signer"; | ||
string signer = 1; | ||
// id of ibc client state | ||
string client_id = 2; | ||
} | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package types | ||
|
||
import ( | ||
"github.com/cosmos/cosmos-sdk/codec" | ||
codectypes "github.com/cosmos/cosmos-sdk/codec/types" | ||
sdk "github.com/cosmos/cosmos-sdk/types" | ||
) | ||
|
||
var ModuleName = "lightclient" | ||
|
||
var ( | ||
amino = codec.NewLegacyAmino() | ||
ModuleCdc = codec.NewAminoCodec(amino) | ||
) | ||
|
||
func RegisterInterfaces(registry codectypes.InterfaceRegistry) { | ||
registry.RegisterImplementations((*sdk.Msg)(nil), | ||
&MsgSetCanonicalClient{}, | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
package types | ||
|
||
import ( | ||
errorsmod "cosmossdk.io/errors" | ||
sdk "github.com/cosmos/cosmos-sdk/types" | ||
"github.com/cosmos/cosmos-sdk/x/auth/migrations/legacytx" | ||
"github.com/dymensionxyz/gerr-cosmos/gerrc" | ||
) | ||
|
||
const ( | ||
TypeMsgSetCanonicalClient = "set_canonical_client" | ||
) | ||
|
||
var ( | ||
_ sdk.Msg = &MsgSetCanonicalClient{} | ||
_ legacytx.LegacyMsg = &MsgSetCanonicalClient{} | ||
) | ||
|
||
func (msg *MsgSetCanonicalClient) Route() string { | ||
return ModuleName | ||
} | ||
|
||
func (msg *MsgSetCanonicalClient) Type() string { | ||
return TypeMsgSetCanonicalClient | ||
} | ||
|
||
func (msg *MsgSetCanonicalClient) GetSigners() []sdk.AccAddress { | ||
creator, err := sdk.AccAddressFromBech32(msg.Signer) | ||
if err != nil { | ||
panic(err) | ||
} | ||
return []sdk.AccAddress{creator} | ||
} | ||
|
||
func (msg *MsgSetCanonicalClient) GetSignBytes() []byte { | ||
bz := ModuleCdc.MustMarshalJSON(msg) | ||
return sdk.MustSortJSON(bz) | ||
} | ||
|
||
func (msg *MsgSetCanonicalClient) ValidateBasic() error { | ||
_, err := sdk.AccAddressFromBech32(msg.Signer) | ||
if err != nil { | ||
return errorsmod.Wrapf(gerrc.ErrInvalidArgument, "invalid creator address (%s)", err) | ||
} | ||
if msg.ClientId == "" { | ||
return gerrc.ErrInvalidArgument.Wrap("empty client id") | ||
} | ||
return nil | ||
} |
Oops, something went wrong.