forked from evmos/ethermint
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into init-bitcoincommiter-module
- Loading branch information
Showing
35 changed files
with
2,212 additions
and
7 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,13 @@ | ||
syntax = "proto3"; | ||
package ethermint.bitcoinindexer.v1; | ||
|
||
import "ethermint/bitcoinindexer/v1/params.proto"; | ||
import "gogoproto/gogo.proto"; | ||
|
||
option go_package = "github.com/evmos/ethermint/x/bitcoinindexer/types"; | ||
|
||
// GenesisState defines the bitcoinindexer module's genesis state. | ||
message GenesisState { | ||
// params holds all the parameters of this module. | ||
Params params = 1 [(gogoproto.nullable) = false]; | ||
} |
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,12 @@ | ||
syntax = "proto3"; | ||
package ethermint.bitcoinindexer.v1; | ||
|
||
import "gogoproto/gogo.proto"; | ||
|
||
option go_package = "github.com/evmos/ethermint/x/bitcoinindexer/types"; | ||
|
||
// Params defines the parameters for the module. | ||
message Params { | ||
option (gogoproto.goproto_stringer) = false; | ||
|
||
} |
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 ethermint.bitcoinindexer.v1; | ||
|
||
import "ethermint/bitcoinindexer/v1/params.proto"; | ||
import "gogoproto/gogo.proto"; | ||
import "google/api/annotations.proto"; | ||
// import "cosmos/base/query/v1beta1/pagination.proto"; | ||
|
||
option go_package = "github.com/evmos/ethermint/x/bitcoinindexer/types"; | ||
|
||
// Query defines the gRPC querier service. | ||
service Query { | ||
// Params Parameters queries the parameters of the module. | ||
rpc Params(QueryParamsRequest) returns (QueryParamsResponse) { | ||
option (google.api.http).get = "/ethermint/bitcoinindexer/v1/params"; | ||
} | ||
} | ||
|
||
// QueryParamsRequest is request type for the Query/Params RPC method. | ||
message QueryParamsRequest {} | ||
|
||
// QueryParamsResponse is response type for the Query/Params RPC method. | ||
message QueryParamsResponse { | ||
// params holds all the parameters of this module. | ||
Params params = 1 [(gogoproto.nullable) = false]; | ||
} |
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,7 @@ | ||
syntax = "proto3"; | ||
package ethermint.bitcoinindexer.v1; | ||
|
||
option go_package = "github.com/evmos/ethermint/x/bitcoinindexer/types"; | ||
|
||
// Msg defines the Msg service. | ||
service 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,52 @@ | ||
package keeper | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/cosmos/cosmos-sdk/codec" | ||
codectypes "github.com/cosmos/cosmos-sdk/codec/types" | ||
"github.com/cosmos/cosmos-sdk/store" | ||
storetypes "github.com/cosmos/cosmos-sdk/store/types" | ||
sdk "github.com/cosmos/cosmos-sdk/types" | ||
typesparams "github.com/cosmos/cosmos-sdk/x/params/types" | ||
"github.com/evmos/ethermint/x/bitcoinindexer/keeper" | ||
"github.com/evmos/ethermint/x/bitcoinindexer/types" | ||
"github.com/stretchr/testify/require" | ||
"github.com/tendermint/tendermint/libs/log" | ||
tmproto "github.com/tendermint/tendermint/proto/tendermint/types" | ||
tmdb "github.com/tendermint/tm-db" | ||
) | ||
|
||
func BitcoinindexerKeeper(t testing.TB) (*keeper.Keeper, sdk.Context) { | ||
storeKey := sdk.NewKVStoreKey(types.StoreKey) | ||
memStoreKey := storetypes.NewMemoryStoreKey(types.MemStoreKey) | ||
|
||
db := tmdb.NewMemDB() | ||
stateStore := store.NewCommitMultiStore(db) | ||
stateStore.MountStoreWithDB(storeKey, storetypes.StoreTypeIAVL, db) | ||
stateStore.MountStoreWithDB(memStoreKey, storetypes.StoreTypeMemory, nil) | ||
require.NoError(t, stateStore.LoadLatestVersion()) | ||
|
||
registry := codectypes.NewInterfaceRegistry() | ||
cdc := codec.NewProtoCodec(registry) | ||
|
||
paramsSubspace := typesparams.NewSubspace(cdc, | ||
types.Amino, | ||
storeKey, | ||
memStoreKey, | ||
"BitcoinindexerParams", | ||
) | ||
k := keeper.NewKeeper( | ||
cdc, | ||
storeKey, | ||
memStoreKey, | ||
paramsSubspace, | ||
) | ||
|
||
ctx := sdk.NewContext(stateStore, tmproto.Header{}, false, log.NewNopLogger()) | ||
|
||
// Initialize params | ||
k.SetParams(ctx, types.DefaultParams()) | ||
|
||
return k, ctx | ||
} |
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 @@ | ||
package cli | ||
|
||
import ( | ||
"fmt" | ||
// "strings" | ||
|
||
"github.com/spf13/cobra" | ||
|
||
"github.com/cosmos/cosmos-sdk/client" | ||
// "github.com/cosmos/cosmos-sdk/client/flags" | ||
// sdk "github.com/cosmos/cosmos-sdk/types" | ||
|
||
"github.com/evmos/ethermint/x/bitcoinindexer/types" | ||
) | ||
|
||
// GetQueryCmd returns the cli query commands for this module | ||
func GetQueryCmd(_ string) *cobra.Command { | ||
// Group bitcoinindexer queries under a subcommand | ||
cmd := &cobra.Command{ | ||
Use: types.ModuleName, | ||
Short: fmt.Sprintf("Querying commands for the %s module", types.ModuleName), | ||
DisableFlagParsing: true, | ||
SuggestionsMinimumDistance: 2, | ||
RunE: client.ValidateCmd, | ||
} | ||
|
||
cmd.AddCommand(CmdQueryParams()) | ||
// this line is used by starport scaffolding # 1 | ||
|
||
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,34 @@ | ||
package cli | ||
|
||
import ( | ||
"context" | ||
|
||
"github.com/cosmos/cosmos-sdk/client" | ||
"github.com/cosmos/cosmos-sdk/client/flags" | ||
"github.com/evmos/ethermint/x/bitcoinindexer/types" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
func CmdQueryParams() *cobra.Command { | ||
cmd := &cobra.Command{ | ||
Use: "params", | ||
Short: "shows the parameters of the module", | ||
Args: cobra.NoArgs, | ||
RunE: func(cmd *cobra.Command, args []string) error { | ||
clientCtx := client.GetClientContextFromCmd(cmd) | ||
|
||
queryClient := types.NewQueryClient(clientCtx) | ||
|
||
res, err := queryClient.Params(context.Background(), &types.QueryParamsRequest{}) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
return clientCtx.PrintProto(res) | ||
}, | ||
} | ||
|
||
flags.AddQueryFlagsToCmd(cmd) | ||
|
||
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,36 @@ | ||
package cli | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/spf13/cobra" | ||
|
||
"github.com/cosmos/cosmos-sdk/client" | ||
// "github.com/cosmos/cosmos-sdk/client/flags" | ||
"github.com/evmos/ethermint/x/bitcoinindexer/types" | ||
) | ||
|
||
var ( | ||
// NOTE: unused | ||
// DefaultRelativePacketTimeoutTimestamp = uint64((time.Duration(10) * time.Minute).Nanoseconds()) | ||
) | ||
|
||
const ( | ||
// flagPacketTimeoutTimestamp = "packet-timeout-timestamp" | ||
// listSeparator = "," | ||
) | ||
|
||
// GetTxCmd returns the transaction commands for this module | ||
func GetTxCmd() *cobra.Command { | ||
cmd := &cobra.Command{ | ||
Use: types.ModuleName, | ||
Short: fmt.Sprintf("%s transactions subcommands", types.ModuleName), | ||
DisableFlagParsing: true, | ||
SuggestionsMinimumDistance: 2, | ||
RunE: client.ValidateCmd, | ||
} | ||
|
||
// this line is used by starport scaffolding # 1 | ||
|
||
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,23 @@ | ||
package bitcoinindexer | ||
|
||
import ( | ||
sdk "github.com/cosmos/cosmos-sdk/types" | ||
"github.com/evmos/ethermint/x/bitcoinindexer/keeper" | ||
"github.com/evmos/ethermint/x/bitcoinindexer/types" | ||
) | ||
|
||
// InitGenesis initializes the module's state from a provided genesis state. | ||
func InitGenesis(ctx sdk.Context, k keeper.Keeper, genState types.GenesisState) { | ||
// this line is used by starport scaffolding # genesis/module/init | ||
k.SetParams(ctx, genState.Params) | ||
} | ||
|
||
// ExportGenesis returns the module's exported genesis | ||
func ExportGenesis(ctx sdk.Context, k keeper.Keeper) *types.GenesisState { | ||
genesis := types.DefaultGenesis() | ||
genesis.Params = k.GetParams(ctx) | ||
|
||
// this line is used by starport scaffolding # genesis/module/export | ||
|
||
return genesis | ||
} |
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,29 @@ | ||
package bitcoinindexer_test | ||
|
||
import ( | ||
"testing" | ||
|
||
keepertest "github.com/evmos/ethermint/testutil/keeper" | ||
// "github.com/evmos/ethermint/testutil/nullify" | ||
"github.com/evmos/ethermint/x/bitcoinindexer" | ||
"github.com/evmos/ethermint/x/bitcoinindexer/types" | ||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
func TestGenesis(t *testing.T) { | ||
genesisState := types.GenesisState{ | ||
Params: types.DefaultParams(), | ||
|
||
// this line is used by starport scaffolding # genesis/test/state | ||
} | ||
|
||
k, ctx := keepertest.BitcoinindexerKeeper(t) | ||
bitcoinindexer.InitGenesis(ctx, *k, genesisState) | ||
got := bitcoinindexer.ExportGenesis(ctx, *k) | ||
require.NotNil(t, got) | ||
|
||
// nullify.Fill(&genesisState) | ||
// nullify.Fill(got) | ||
|
||
// this line is used by starport scaffolding # genesis/test/assert | ||
} |
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,45 @@ | ||
package keeper | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/cosmos/cosmos-sdk/codec" | ||
storetypes "github.com/cosmos/cosmos-sdk/store/types" | ||
sdk "github.com/cosmos/cosmos-sdk/types" | ||
paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" | ||
"github.com/tendermint/tendermint/libs/log" | ||
|
||
"github.com/evmos/ethermint/x/bitcoinindexer/types" | ||
) | ||
|
||
type ( | ||
Keeper struct { | ||
cdc codec.BinaryCodec | ||
storeKey storetypes.StoreKey | ||
memKey storetypes.StoreKey | ||
paramstore paramtypes.Subspace | ||
} | ||
) | ||
|
||
func NewKeeper( | ||
cdc codec.BinaryCodec, | ||
storeKey, | ||
memKey storetypes.StoreKey, | ||
ps paramtypes.Subspace, | ||
) *Keeper { | ||
// set KeyTable if it has not already been set | ||
if !ps.HasKeyTable() { | ||
ps = ps.WithKeyTable(types.ParamKeyTable()) | ||
} | ||
|
||
return &Keeper{ | ||
cdc: cdc, | ||
storeKey: storeKey, | ||
memKey: memKey, | ||
paramstore: ps, | ||
} | ||
} | ||
|
||
func (k Keeper) Logger(ctx sdk.Context) log.Logger { | ||
return ctx.Logger().With("module", fmt.Sprintf("x/%s", types.ModuleName)) | ||
} |
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,17 @@ | ||
package keeper | ||
|
||
import ( | ||
"github.com/evmos/ethermint/x/bitcoinindexer/types" | ||
) | ||
|
||
type msgServer struct { | ||
Keeper | ||
} | ||
|
||
// NewMsgServerImpl returns an implementation of the MsgServer interface | ||
// for the provided Keeper. | ||
func NewMsgServerImpl(keeper Keeper) types.MsgServer { | ||
return &msgServer{Keeper: keeper} | ||
} | ||
|
||
var _ types.MsgServer = msgServer{} |
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 keeper_test | ||
|
||
import ( | ||
"context" | ||
"testing" | ||
|
||
sdk "github.com/cosmos/cosmos-sdk/types" | ||
keepertest "github.com/evmos/ethermint/testutil/keeper" | ||
"github.com/evmos/ethermint/x/bitcoinindexer/keeper" | ||
"github.com/evmos/ethermint/x/bitcoinindexer/types" | ||
) | ||
|
||
func setupMsgServer(t testing.TB) (types.MsgServer, context.Context) { | ||
k, ctx := keepertest.BitcoinindexerKeeper(t) | ||
return keeper.NewMsgServerImpl(*k), sdk.WrapSDKContext(ctx) | ||
} |
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 keeper | ||
|
||
import ( | ||
sdk "github.com/cosmos/cosmos-sdk/types" | ||
"github.com/evmos/ethermint/x/bitcoinindexer/types" | ||
) | ||
|
||
// GetParams get all parameters as types.Params | ||
func (k Keeper) GetParams(_ sdk.Context) types.Params { | ||
return types.NewParams() | ||
} | ||
|
||
// SetParams set the params | ||
func (k Keeper) SetParams(ctx sdk.Context, params types.Params) { | ||
k.paramstore.SetParamSet(ctx, ¶ms) | ||
} |
Oops, something went wrong.