-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
24 changed files
with
3,108 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
syntax = "proto3"; | ||
package kira.ethereum; | ||
|
||
import "gogoproto/gogo.proto"; | ||
import "google/protobuf/any.proto"; | ||
|
||
option go_package = "github.com/KiraCore/sekai/x/ethereum/types"; | ||
|
||
message EVMTx { | ||
string From = 1; | ||
string To = 2; | ||
string Value = 3; | ||
string Gas = 4; | ||
string GasPrice = 5; | ||
string Nonce = 6; | ||
string Data = 7; | ||
int64 ChainId = 8; | ||
string V = 9; | ||
string R = 10; | ||
string S = 11; | ||
} |
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,8 @@ | ||
syntax = "proto3"; | ||
package kira.ethereum; | ||
|
||
import "kira/ethereum/ethereum.proto"; | ||
|
||
option go_package = "github.com/KiraCore/sekai/x/ethereum/types"; | ||
|
||
message GenesisState { } |
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,26 @@ | ||
syntax = "proto3"; | ||
package kira.ethereum; | ||
|
||
import "gogoproto/gogo.proto"; | ||
import "google/api/annotations.proto"; | ||
import "kira/ethereum/ethereum.proto"; | ||
import "kira/ethereum/tx.proto"; | ||
|
||
option go_package = "github.com/KiraCore/sekai/x/ethereum/types"; | ||
|
||
service Query { | ||
rpc RelayByAddress (RelayByAddressRequest) returns (RelayByAddressResponse) { | ||
option (google.api.http).get = "/kira/ethereum/relay/{addr}"; | ||
} | ||
} | ||
|
||
message RelayByAddressRequest { | ||
bytes addr = 1 [ | ||
(gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress", | ||
(gogoproto.moretags) = "yaml:\"addr\"" | ||
]; | ||
} | ||
|
||
message RelayByAddressResponse { | ||
MsgRelay msg_relay = 1; | ||
} |
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,31 @@ | ||
syntax = "proto3"; | ||
package kira.ethereum; | ||
|
||
import "gogoproto/gogo.proto"; | ||
import "cosmos/base/v1beta1/coin.proto"; | ||
import "cosmos/bank/v1beta1/bank.proto"; | ||
import "cosmos_proto/cosmos.proto"; | ||
import "cosmos/msg/v1/msg.proto"; | ||
import "amino/amino.proto"; | ||
import "kira/ethereum/ethereum.proto"; | ||
|
||
option go_package = "github.com/KiraCore/sekai/x/ethereum/types"; | ||
|
||
// Msg defines the ethereum Msg service. | ||
service Msg { | ||
rpc Relay(MsgRelay) returns (MsgRelayResponse); | ||
} | ||
|
||
message MsgRelay { | ||
option (gogoproto.equal) = false; | ||
option (gogoproto.goproto_getters) = false; | ||
|
||
bytes address = 1 [ | ||
(gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress", | ||
(gogoproto.moretags) = "yaml:\"address\"" | ||
]; | ||
|
||
string data = 2; | ||
} | ||
|
||
message MsgRelayResponse {} |
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,16 @@ | ||
package cli | ||
|
||
import ( | ||
"github.com/KiraCore/sekai/x/ethereum/types" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
// NewQueryCmd returns a root CLI command handler for all x/ethereum transaction commands. | ||
func NewQueryCmd() *cobra.Command { | ||
queryCmd := &cobra.Command{ | ||
Use: types.RouterKey, | ||
Short: "query commands for the ethereum module", | ||
} | ||
|
||
return queryCmd | ||
} |
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,50 @@ | ||
package cli | ||
|
||
import ( | ||
"github.com/KiraCore/sekai/x/ethereum/types" | ||
"github.com/cosmos/cosmos-sdk/client" | ||
"github.com/cosmos/cosmos-sdk/client/flags" | ||
"github.com/cosmos/cosmos-sdk/client/tx" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
// NewTxCmd returns a root CLI command handler for all x/ethereum transaction commands. | ||
func NewTxCmd() *cobra.Command { | ||
txCmd := &cobra.Command{ | ||
Use: types.ModuleName, | ||
Short: "ethereum sub commands", | ||
DisableFlagParsing: true, | ||
SuggestionsMinimumDistance: 2, | ||
RunE: client.ValidateCmd, | ||
} | ||
|
||
txCmd.AddCommand(GetTxRelay()) | ||
|
||
return txCmd | ||
} | ||
|
||
func GetTxRelay() *cobra.Command { | ||
cmd := &cobra.Command{ | ||
Use: "relay", | ||
Short: "New relay from ETHEREUM to COSMOS", | ||
Args: cobra.ExactArgs(1), | ||
RunE: func(cmd *cobra.Command, args []string) error { | ||
clientCtx, err := client.GetClientTxContext(cmd) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
msg := types.NewMsgRelay( | ||
clientCtx.FromAddress, | ||
args[0], | ||
) | ||
|
||
return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg) | ||
}, | ||
} | ||
|
||
flags.AddTxFlagsToCmd(cmd) | ||
cmd.MarkFlagRequired(flags.FlagFrom) | ||
|
||
return cmd | ||
} |
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,27 @@ | ||
package ethereum | ||
|
||
import ( | ||
"github.com/KiraCore/sekai/x/ethereum/keeper" | ||
"github.com/KiraCore/sekai/x/ethereum/types" | ||
sdk "github.com/cosmos/cosmos-sdk/types" | ||
"github.com/cosmos/cosmos-sdk/types/errors" | ||
) | ||
|
||
// NewHandler returns new instance of handler | ||
func NewHandler(ck keeper.Keeper, cgk types.CustomGovKeeper, bk types.BankKeeper) sdk.Handler { | ||
msgServer := keeper.NewMsgServerImpl(ck, cgk, bk) | ||
|
||
return func(ctx sdk.Context, msg sdk.Msg) (*sdk.Result, error) { | ||
ctx = ctx.WithEventManager(sdk.NewEventManager()) | ||
|
||
switch msg := msg.(type) { | ||
case *types.MsgRelay: | ||
{ | ||
res, err := msgServer.Relay(sdk.WrapSDKContext(ctx), msg) | ||
return sdk.WrapServiceResult(ctx, res, err) | ||
} | ||
default: | ||
return nil, errors.Wrapf(errors.ErrUnknownRequest, "unrecognized %s message type: %T", types.ModuleName, msg) | ||
} | ||
} | ||
} |
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,28 @@ | ||
package keeper | ||
|
||
import ( | ||
"github.com/KiraCore/sekai/x/ethereum/types" | ||
"github.com/cosmos/cosmos-sdk/store/prefix" | ||
sdk "github.com/cosmos/cosmos-sdk/types" | ||
) | ||
|
||
func (k Keeper) SetRelay(ctx sdk.Context, record *types.MsgRelay) { | ||
store := ctx.KVStore(k.storeKey) | ||
key := append([]byte(types.PrefixKeyRelay), record.Address...) | ||
|
||
store.Set(key, k.cdc.MustMarshal(record)) | ||
} | ||
|
||
func (k Keeper) GetRelayByAddress(ctx sdk.Context, address sdk.AccAddress) *types.MsgRelay { | ||
prefixStore := prefix.NewStore(ctx.KVStore(k.storeKey), []byte(types.PrefixKeyRelay)) | ||
bz := prefixStore.Get(address) | ||
|
||
if bz == nil { | ||
return nil | ||
} | ||
|
||
info := new(types.MsgRelay) | ||
k.cdc.MustUnmarshal(bz, info) | ||
|
||
return info | ||
} |
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,25 @@ | ||
package keeper | ||
|
||
import ( | ||
"context" | ||
"github.com/KiraCore/sekai/x/ethereum/types" | ||
sdk "github.com/cosmos/cosmos-sdk/types" | ||
) | ||
|
||
type Querier struct { | ||
keeper Keeper | ||
} | ||
|
||
func NewQuerier(keeper Keeper) types.QueryServer { | ||
return &Querier{keeper: keeper} | ||
} | ||
|
||
var _ types.QueryServer = Querier{} | ||
|
||
func (q Querier) RelayByAddress(goCtx context.Context, request *types.RelayByAddressRequest) (*types.RelayByAddressResponse, error) { | ||
ctx := sdk.UnwrapSDKContext(goCtx) | ||
|
||
return &types.RelayByAddressResponse{ | ||
MsgRelay: q.keeper.GetRelayByAddress(ctx, request.Addr), | ||
}, nil | ||
} |
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,37 @@ | ||
package keeper | ||
|
||
import ( | ||
appparams "github.com/KiraCore/sekai/app/params" | ||
"github.com/KiraCore/sekai/x/ethereum/types" | ||
"github.com/cometbft/cometbft/libs/log" | ||
"github.com/cosmos/cosmos-sdk/codec" | ||
storetypes "github.com/cosmos/cosmos-sdk/store/types" | ||
sdk "github.com/cosmos/cosmos-sdk/types" | ||
) | ||
|
||
// Keeper is for managing token module | ||
type Keeper struct { | ||
cdc codec.BinaryCodec | ||
storeKey storetypes.StoreKey | ||
gk types.CustomGovKeeper | ||
bk types.BankKeeper | ||
} | ||
|
||
// NewKeeper returns instance of a keeper | ||
func NewKeeper(storeKey storetypes.StoreKey, cdc codec.BinaryCodec, gk types.CustomGovKeeper, bk types.BankKeeper) Keeper { | ||
return Keeper{ | ||
cdc: cdc, | ||
storeKey: storeKey, | ||
gk: gk, | ||
bk: bk, | ||
} | ||
} | ||
|
||
// DefaultDenom returns the denom that is basically used for fee payment | ||
func (k Keeper) DefaultDenom(ctx sdk.Context) string { | ||
return appparams.DefaultDenom | ||
} | ||
|
||
func (k Keeper) Logger(ctx sdk.Context) log.Logger { | ||
return ctx.Logger().With("module", "x/"+types.ModuleName) | ||
} |
Oops, something went wrong.