Setup and plumbing for auction module #1
41
x/auction/keeper/genesis.go
Normal file
41
x/auction/keeper/genesis.go
Normal file
@ -0,0 +1,41 @@
|
||||
package keeper
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"git.vdb.to/cerc-io/laconic2d/x/auction"
|
||||
)
|
||||
|
||||
// InitGenesis initializes the module state from a genesis state.
|
||||
func (k *Keeper) InitGenesis(ctx context.Context, data *auction.GenesisState) error {
|
||||
if err := k.Params.Set(ctx, data.Params); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// Save auctions in store.
|
||||
// for _, auction := range data.Auctions {
|
||||
// if err := k.Auctions.Set(ctx, auction.Id, *auction); err != nil {
|
||||
// return err
|
||||
// }
|
||||
// }
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// ExportGenesis exports the module state to a genesis state.
|
||||
func (k *Keeper) ExportGenesis(ctx context.Context) (*auction.GenesisState, error) {
|
||||
params, err := k.Params.Get(ctx)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// auctions, err := k.ListAuctions(ctx)
|
||||
// if err != nil {
|
||||
// return nil, err
|
||||
// }
|
||||
|
||||
return &auction.GenesisState{
|
||||
Params: params,
|
||||
// Auctions: auctions,
|
||||
}, nil
|
||||
}
|
60
x/auction/keeper/keeper.go
Normal file
60
x/auction/keeper/keeper.go
Normal file
@ -0,0 +1,60 @@
|
||||
package keeper
|
||||
|
||||
import (
|
||||
"cosmossdk.io/collections"
|
||||
storetypes "cosmossdk.io/core/store"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/codec"
|
||||
auth "github.com/cosmos/cosmos-sdk/x/auth/keeper"
|
||||
bank "github.com/cosmos/cosmos-sdk/x/bank/keeper"
|
||||
|
||||
auctiontypes "git.vdb.to/cerc-io/laconic2d/x/auction"
|
||||
)
|
||||
|
||||
type Keeper struct {
|
||||
// Codecs
|
||||
cdc codec.BinaryCodec
|
||||
|
||||
// External keepers
|
||||
accountKeeper auth.AccountKeeper
|
||||
bankKeeper bank.Keeper
|
||||
|
||||
// Track auction usage in other cosmos-sdk modules (more like a usage tracker).
|
||||
// usageKeepers []types.AuctionUsageKeeper
|
||||
|
||||
// state management
|
||||
Schema collections.Schema
|
||||
Params collections.Item[auctiontypes.Params]
|
||||
// TODO
|
||||
// Auctions ...
|
||||
}
|
||||
|
||||
// NewKeeper creates a new Keeper instance
|
||||
func NewKeeper(
|
||||
cdc codec.BinaryCodec,
|
||||
storeService storetypes.KVStoreService,
|
||||
accountKeeper auth.AccountKeeper,
|
||||
bankKeeper bank.Keeper,
|
||||
) Keeper {
|
||||
sb := collections.NewSchemaBuilder(storeService)
|
||||
k := Keeper{
|
||||
cdc: cdc,
|
||||
accountKeeper: accountKeeper,
|
||||
bankKeeper: bankKeeper,
|
||||
Params: collections.NewItem(sb, auctiontypes.ParamsKeyPrefix, "params", codec.CollValue[auctiontypes.Params](cdc)),
|
||||
// Auctions: ...
|
||||
}
|
||||
|
||||
schema, err := sb.Build()
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
k.Schema = schema
|
||||
|
||||
return k
|
||||
}
|
||||
|
||||
// func (k *Keeper) SetUsageKeepers(usageKeepers []types.AuctionUsageKeeper) {
|
||||
// k.usageKeepers = usageKeepers
|
||||
// }
|
14
x/auction/keeper/msg_server.go
Normal file
14
x/auction/keeper/msg_server.go
Normal file
@ -0,0 +1,14 @@
|
||||
package keeper
|
||||
|
||||
// TODO: Add required read methods
|
||||
|
||||
// var _ auctiontypes.MsgServer = msgServer{}
|
||||
|
||||
type msgServer struct {
|
||||
k Keeper
|
||||
}
|
||||
|
||||
// NewMsgServerImpl returns an implementation of the module MsgServer interface.
|
||||
// func NewMsgServerImpl(keeper Keeper) auctiontypes.MsgServer {
|
||||
// return &msgServer{k: keeper}
|
||||
// }
|
14
x/auction/keeper/query_server.go
Normal file
14
x/auction/keeper/query_server.go
Normal file
@ -0,0 +1,14 @@
|
||||
package keeper
|
||||
|
||||
// TODO: Add required read methods
|
||||
|
||||
// var _ auctiontypes.QueryServer = queryServer{}
|
||||
|
||||
type queryServer struct {
|
||||
k Keeper
|
||||
}
|
||||
|
||||
// NewQueryServerImpl returns an implementation of the module QueryServer.
|
||||
// func NewQueryServerImpl(k Keeper) auctiontypes.QueryServer {
|
||||
// return queryServer{k}
|
||||
// }
|
Loading…
Reference in New Issue
Block a user