mirror of
https://github.com/colinear-labs/chain.git
synced 2026-03-05 04:44:25 -08:00
scaffold base auction & nextAuction types
This commit is contained in:
@@ -25,6 +25,9 @@ func GetQueryCmd(queryRoute string) *cobra.Command {
|
||||
}
|
||||
|
||||
cmd.AddCommand(CmdQueryParams())
|
||||
cmd.AddCommand(CmdShowNextAuction())
|
||||
cmd.AddCommand(CmdListAuction())
|
||||
cmd.AddCommand(CmdShowAuction())
|
||||
// this line is used by starport scaffolding # 1
|
||||
|
||||
return cmd
|
||||
|
||||
73
x/cosmostest/client/cli/query_auction.go
Normal file
73
x/cosmostest/client/cli/query_auction.go
Normal file
@@ -0,0 +1,73 @@
|
||||
package cli
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"cosmos-test/x/cosmostest/types"
|
||||
"github.com/cosmos/cosmos-sdk/client"
|
||||
"github.com/cosmos/cosmos-sdk/client/flags"
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
func CmdListAuction() *cobra.Command {
|
||||
cmd := &cobra.Command{
|
||||
Use: "list-auction",
|
||||
Short: "list all auction",
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
clientCtx := client.GetClientContextFromCmd(cmd)
|
||||
|
||||
pageReq, err := client.ReadPageRequest(cmd.Flags())
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
queryClient := types.NewQueryClient(clientCtx)
|
||||
|
||||
params := &types.QueryAllAuctionRequest{
|
||||
Pagination: pageReq,
|
||||
}
|
||||
|
||||
res, err := queryClient.AuctionAll(context.Background(), params)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return clientCtx.PrintProto(res)
|
||||
},
|
||||
}
|
||||
|
||||
flags.AddPaginationFlagsToCmd(cmd, cmd.Use)
|
||||
flags.AddQueryFlagsToCmd(cmd)
|
||||
|
||||
return cmd
|
||||
}
|
||||
|
||||
func CmdShowAuction() *cobra.Command {
|
||||
cmd := &cobra.Command{
|
||||
Use: "show-auction [index]",
|
||||
Short: "shows a auction",
|
||||
Args: cobra.ExactArgs(1),
|
||||
RunE: func(cmd *cobra.Command, args []string) (err error) {
|
||||
clientCtx := client.GetClientContextFromCmd(cmd)
|
||||
|
||||
queryClient := types.NewQueryClient(clientCtx)
|
||||
|
||||
argIndex := args[0]
|
||||
|
||||
params := &types.QueryGetAuctionRequest{
|
||||
Index: argIndex,
|
||||
}
|
||||
|
||||
res, err := queryClient.Auction(context.Background(), params)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return clientCtx.PrintProto(res)
|
||||
},
|
||||
}
|
||||
|
||||
flags.AddQueryFlagsToCmd(cmd)
|
||||
|
||||
return cmd
|
||||
}
|
||||
161
x/cosmostest/client/cli/query_auction_test.go
Normal file
161
x/cosmostest/client/cli/query_auction_test.go
Normal file
@@ -0,0 +1,161 @@
|
||||
package cli_test
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strconv"
|
||||
"testing"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/client/flags"
|
||||
clitestutil "github.com/cosmos/cosmos-sdk/testutil/cli"
|
||||
"github.com/stretchr/testify/require"
|
||||
tmcli "github.com/tendermint/tendermint/libs/cli"
|
||||
"google.golang.org/grpc/codes"
|
||||
"google.golang.org/grpc/status"
|
||||
|
||||
"cosmos-test/testutil/network"
|
||||
"cosmos-test/testutil/nullify"
|
||||
"cosmos-test/x/cosmostest/client/cli"
|
||||
"cosmos-test/x/cosmostest/types"
|
||||
)
|
||||
|
||||
// Prevent strconv unused error
|
||||
var _ = strconv.IntSize
|
||||
|
||||
func networkWithAuctionObjects(t *testing.T, n int) (*network.Network, []types.Auction) {
|
||||
t.Helper()
|
||||
cfg := network.DefaultConfig()
|
||||
state := types.GenesisState{}
|
||||
require.NoError(t, cfg.Codec.UnmarshalJSON(cfg.GenesisState[types.ModuleName], &state))
|
||||
|
||||
for i := 0; i < n; i++ {
|
||||
auction := types.Auction{
|
||||
Index: strconv.Itoa(i),
|
||||
}
|
||||
nullify.Fill(&auction)
|
||||
state.AuctionList = append(state.AuctionList, auction)
|
||||
}
|
||||
buf, err := cfg.Codec.MarshalJSON(&state)
|
||||
require.NoError(t, err)
|
||||
cfg.GenesisState[types.ModuleName] = buf
|
||||
return network.New(t, cfg), state.AuctionList
|
||||
}
|
||||
|
||||
func TestShowAuction(t *testing.T) {
|
||||
net, objs := networkWithAuctionObjects(t, 2)
|
||||
|
||||
ctx := net.Validators[0].ClientCtx
|
||||
common := []string{
|
||||
fmt.Sprintf("--%s=json", tmcli.OutputFlag),
|
||||
}
|
||||
for _, tc := range []struct {
|
||||
desc string
|
||||
idIndex string
|
||||
|
||||
args []string
|
||||
err error
|
||||
obj types.Auction
|
||||
}{
|
||||
{
|
||||
desc: "found",
|
||||
idIndex: objs[0].Index,
|
||||
|
||||
args: common,
|
||||
obj: objs[0],
|
||||
},
|
||||
{
|
||||
desc: "not found",
|
||||
idIndex: strconv.Itoa(100000),
|
||||
|
||||
args: common,
|
||||
err: status.Error(codes.NotFound, "not found"),
|
||||
},
|
||||
} {
|
||||
t.Run(tc.desc, func(t *testing.T) {
|
||||
args := []string{
|
||||
tc.idIndex,
|
||||
}
|
||||
args = append(args, tc.args...)
|
||||
out, err := clitestutil.ExecTestCLICmd(ctx, cli.CmdShowAuction(), args)
|
||||
if tc.err != nil {
|
||||
stat, ok := status.FromError(tc.err)
|
||||
require.True(t, ok)
|
||||
require.ErrorIs(t, stat.Err(), tc.err)
|
||||
} else {
|
||||
require.NoError(t, err)
|
||||
var resp types.QueryGetAuctionResponse
|
||||
require.NoError(t, net.Config.Codec.UnmarshalJSON(out.Bytes(), &resp))
|
||||
require.NotNil(t, resp.Auction)
|
||||
require.Equal(t,
|
||||
nullify.Fill(&tc.obj),
|
||||
nullify.Fill(&resp.Auction),
|
||||
)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestListAuction(t *testing.T) {
|
||||
net, objs := networkWithAuctionObjects(t, 5)
|
||||
|
||||
ctx := net.Validators[0].ClientCtx
|
||||
request := func(next []byte, offset, limit uint64, total bool) []string {
|
||||
args := []string{
|
||||
fmt.Sprintf("--%s=json", tmcli.OutputFlag),
|
||||
}
|
||||
if next == nil {
|
||||
args = append(args, fmt.Sprintf("--%s=%d", flags.FlagOffset, offset))
|
||||
} else {
|
||||
args = append(args, fmt.Sprintf("--%s=%s", flags.FlagPageKey, next))
|
||||
}
|
||||
args = append(args, fmt.Sprintf("--%s=%d", flags.FlagLimit, limit))
|
||||
if total {
|
||||
args = append(args, fmt.Sprintf("--%s", flags.FlagCountTotal))
|
||||
}
|
||||
return args
|
||||
}
|
||||
t.Run("ByOffset", func(t *testing.T) {
|
||||
step := 2
|
||||
for i := 0; i < len(objs); i += step {
|
||||
args := request(nil, uint64(i), uint64(step), false)
|
||||
out, err := clitestutil.ExecTestCLICmd(ctx, cli.CmdListAuction(), args)
|
||||
require.NoError(t, err)
|
||||
var resp types.QueryAllAuctionResponse
|
||||
require.NoError(t, net.Config.Codec.UnmarshalJSON(out.Bytes(), &resp))
|
||||
require.LessOrEqual(t, len(resp.Auction), step)
|
||||
require.Subset(t,
|
||||
nullify.Fill(objs),
|
||||
nullify.Fill(resp.Auction),
|
||||
)
|
||||
}
|
||||
})
|
||||
t.Run("ByKey", func(t *testing.T) {
|
||||
step := 2
|
||||
var next []byte
|
||||
for i := 0; i < len(objs); i += step {
|
||||
args := request(next, 0, uint64(step), false)
|
||||
out, err := clitestutil.ExecTestCLICmd(ctx, cli.CmdListAuction(), args)
|
||||
require.NoError(t, err)
|
||||
var resp types.QueryAllAuctionResponse
|
||||
require.NoError(t, net.Config.Codec.UnmarshalJSON(out.Bytes(), &resp))
|
||||
require.LessOrEqual(t, len(resp.Auction), step)
|
||||
require.Subset(t,
|
||||
nullify.Fill(objs),
|
||||
nullify.Fill(resp.Auction),
|
||||
)
|
||||
next = resp.Pagination.NextKey
|
||||
}
|
||||
})
|
||||
t.Run("Total", func(t *testing.T) {
|
||||
args := request(nil, 0, uint64(len(objs)), true)
|
||||
out, err := clitestutil.ExecTestCLICmd(ctx, cli.CmdListAuction(), args)
|
||||
require.NoError(t, err)
|
||||
var resp types.QueryAllAuctionResponse
|
||||
require.NoError(t, net.Config.Codec.UnmarshalJSON(out.Bytes(), &resp))
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, len(objs), int(resp.Pagination.Total))
|
||||
require.ElementsMatch(t,
|
||||
nullify.Fill(objs),
|
||||
nullify.Fill(resp.Auction),
|
||||
)
|
||||
})
|
||||
}
|
||||
36
x/cosmostest/client/cli/query_next_auction.go
Normal file
36
x/cosmostest/client/cli/query_next_auction.go
Normal file
@@ -0,0 +1,36 @@
|
||||
package cli
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"cosmos-test/x/cosmostest/types"
|
||||
"github.com/cosmos/cosmos-sdk/client"
|
||||
"github.com/cosmos/cosmos-sdk/client/flags"
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
func CmdShowNextAuction() *cobra.Command {
|
||||
cmd := &cobra.Command{
|
||||
Use: "show-next-auction",
|
||||
Short: "shows nextAuction",
|
||||
Args: cobra.NoArgs,
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
clientCtx := client.GetClientContextFromCmd(cmd)
|
||||
|
||||
queryClient := types.NewQueryClient(clientCtx)
|
||||
|
||||
params := &types.QueryGetNextAuctionRequest{}
|
||||
|
||||
res, err := queryClient.NextAuction(context.Background(), params)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return clientCtx.PrintProto(res)
|
||||
},
|
||||
}
|
||||
|
||||
flags.AddQueryFlagsToCmd(cmd)
|
||||
|
||||
return cmd
|
||||
}
|
||||
72
x/cosmostest/client/cli/query_next_auction_test.go
Normal file
72
x/cosmostest/client/cli/query_next_auction_test.go
Normal file
@@ -0,0 +1,72 @@
|
||||
package cli_test
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"testing"
|
||||
|
||||
clitestutil "github.com/cosmos/cosmos-sdk/testutil/cli"
|
||||
"github.com/stretchr/testify/require"
|
||||
tmcli "github.com/tendermint/tendermint/libs/cli"
|
||||
"google.golang.org/grpc/status"
|
||||
|
||||
"cosmos-test/testutil/network"
|
||||
"cosmos-test/testutil/nullify"
|
||||
"cosmos-test/x/cosmostest/client/cli"
|
||||
"cosmos-test/x/cosmostest/types"
|
||||
)
|
||||
|
||||
func networkWithNextAuctionObjects(t *testing.T) (*network.Network, types.NextAuction) {
|
||||
t.Helper()
|
||||
cfg := network.DefaultConfig()
|
||||
state := types.GenesisState{}
|
||||
require.NoError(t, cfg.Codec.UnmarshalJSON(cfg.GenesisState[types.ModuleName], &state))
|
||||
|
||||
nextAuction := &types.NextAuction{}
|
||||
nullify.Fill(&nextAuction)
|
||||
state.NextAuction = nextAuction
|
||||
buf, err := cfg.Codec.MarshalJSON(&state)
|
||||
require.NoError(t, err)
|
||||
cfg.GenesisState[types.ModuleName] = buf
|
||||
return network.New(t, cfg), *state.NextAuction
|
||||
}
|
||||
|
||||
func TestShowNextAuction(t *testing.T) {
|
||||
net, obj := networkWithNextAuctionObjects(t)
|
||||
|
||||
ctx := net.Validators[0].ClientCtx
|
||||
common := []string{
|
||||
fmt.Sprintf("--%s=json", tmcli.OutputFlag),
|
||||
}
|
||||
for _, tc := range []struct {
|
||||
desc string
|
||||
args []string
|
||||
err error
|
||||
obj types.NextAuction
|
||||
}{
|
||||
{
|
||||
desc: "get",
|
||||
args: common,
|
||||
obj: obj,
|
||||
},
|
||||
} {
|
||||
t.Run(tc.desc, func(t *testing.T) {
|
||||
var args []string
|
||||
args = append(args, tc.args...)
|
||||
out, err := clitestutil.ExecTestCLICmd(ctx, cli.CmdShowNextAuction(), args)
|
||||
if tc.err != nil {
|
||||
stat, ok := status.FromError(tc.err)
|
||||
require.True(t, ok)
|
||||
require.ErrorIs(t, stat.Err(), tc.err)
|
||||
} else {
|
||||
require.NoError(t, err)
|
||||
var resp types.QueryGetNextAuctionResponse
|
||||
require.NoError(t, net.Config.Codec.UnmarshalJSON(out.Bytes(), &resp))
|
||||
require.NotNil(t, resp.NextAuction)
|
||||
require.Equal(t,
|
||||
nullify.Fill(&tc.obj),
|
||||
nullify.Fill(&resp.NextAuction),
|
||||
)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -9,6 +9,14 @@ import (
|
||||
// InitGenesis initializes the capability module's state from a provided genesis
|
||||
// state.
|
||||
func InitGenesis(ctx sdk.Context, k keeper.Keeper, genState types.GenesisState) {
|
||||
// Set if defined
|
||||
if genState.NextAuction != nil {
|
||||
k.SetNextAuction(ctx, *genState.NextAuction)
|
||||
}
|
||||
// Set all the auction
|
||||
for _, elem := range genState.AuctionList {
|
||||
k.SetAuction(ctx, elem)
|
||||
}
|
||||
// this line is used by starport scaffolding # genesis/module/init
|
||||
k.SetParams(ctx, genState.Params)
|
||||
}
|
||||
@@ -18,6 +26,12 @@ func ExportGenesis(ctx sdk.Context, k keeper.Keeper) *types.GenesisState {
|
||||
genesis := types.DefaultGenesis()
|
||||
genesis.Params = k.GetParams(ctx)
|
||||
|
||||
// Get all nextAuction
|
||||
nextAuction, found := k.GetNextAuction(ctx)
|
||||
if found {
|
||||
genesis.NextAuction = &nextAuction
|
||||
}
|
||||
genesis.AuctionList = k.GetAllAuction(ctx)
|
||||
// this line is used by starport scaffolding # genesis/module/export
|
||||
|
||||
return genesis
|
||||
|
||||
@@ -15,6 +15,17 @@ func TestGenesis(t *testing.T) {
|
||||
genesisState := types.GenesisState{
|
||||
Params: types.DefaultParams(),
|
||||
|
||||
NextAuction: &types.NextAuction{
|
||||
AuctionId: 43,
|
||||
},
|
||||
AuctionList: []types.Auction{
|
||||
{
|
||||
Index: "0",
|
||||
},
|
||||
{
|
||||
Index: "1",
|
||||
},
|
||||
},
|
||||
// this line is used by starport scaffolding # genesis/test/state
|
||||
}
|
||||
|
||||
@@ -26,5 +37,7 @@ func TestGenesis(t *testing.T) {
|
||||
nullify.Fill(&genesisState)
|
||||
nullify.Fill(got)
|
||||
|
||||
require.Equal(t, genesisState.NextAuction, got.NextAuction)
|
||||
require.ElementsMatch(t, genesisState.AuctionList, got.AuctionList)
|
||||
// this line is used by starport scaffolding # genesis/test/assert
|
||||
}
|
||||
|
||||
63
x/cosmostest/keeper/auction.go
Normal file
63
x/cosmostest/keeper/auction.go
Normal file
@@ -0,0 +1,63 @@
|
||||
package keeper
|
||||
|
||||
import (
|
||||
"cosmos-test/x/cosmostest/types"
|
||||
"github.com/cosmos/cosmos-sdk/store/prefix"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
)
|
||||
|
||||
// SetAuction set a specific auction in the store from its index
|
||||
func (k Keeper) SetAuction(ctx sdk.Context, auction types.Auction) {
|
||||
store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefix(types.AuctionKeyPrefix))
|
||||
b := k.cdc.MustMarshal(&auction)
|
||||
store.Set(types.AuctionKey(
|
||||
auction.Index,
|
||||
), b)
|
||||
}
|
||||
|
||||
// GetAuction returns a auction from its index
|
||||
func (k Keeper) GetAuction(
|
||||
ctx sdk.Context,
|
||||
index string,
|
||||
|
||||
) (val types.Auction, found bool) {
|
||||
store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefix(types.AuctionKeyPrefix))
|
||||
|
||||
b := store.Get(types.AuctionKey(
|
||||
index,
|
||||
))
|
||||
if b == nil {
|
||||
return val, false
|
||||
}
|
||||
|
||||
k.cdc.MustUnmarshal(b, &val)
|
||||
return val, true
|
||||
}
|
||||
|
||||
// RemoveAuction removes a auction from the store
|
||||
func (k Keeper) RemoveAuction(
|
||||
ctx sdk.Context,
|
||||
index string,
|
||||
|
||||
) {
|
||||
store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefix(types.AuctionKeyPrefix))
|
||||
store.Delete(types.AuctionKey(
|
||||
index,
|
||||
))
|
||||
}
|
||||
|
||||
// GetAllAuction returns all auction
|
||||
func (k Keeper) GetAllAuction(ctx sdk.Context) (list []types.Auction) {
|
||||
store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefix(types.AuctionKeyPrefix))
|
||||
iterator := sdk.KVStorePrefixIterator(store, []byte{})
|
||||
|
||||
defer iterator.Close()
|
||||
|
||||
for ; iterator.Valid(); iterator.Next() {
|
||||
var val types.Auction
|
||||
k.cdc.MustUnmarshal(iterator.Value(), &val)
|
||||
list = append(list, val)
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
63
x/cosmostest/keeper/auction_test.go
Normal file
63
x/cosmostest/keeper/auction_test.go
Normal file
@@ -0,0 +1,63 @@
|
||||
package keeper_test
|
||||
|
||||
import (
|
||||
"strconv"
|
||||
"testing"
|
||||
|
||||
keepertest "cosmos-test/testutil/keeper"
|
||||
"cosmos-test/testutil/nullify"
|
||||
"cosmos-test/x/cosmostest/keeper"
|
||||
"cosmos-test/x/cosmostest/types"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
// Prevent strconv unused error
|
||||
var _ = strconv.IntSize
|
||||
|
||||
func createNAuction(keeper *keeper.Keeper, ctx sdk.Context, n int) []types.Auction {
|
||||
items := make([]types.Auction, n)
|
||||
for i := range items {
|
||||
items[i].Index = strconv.Itoa(i)
|
||||
|
||||
keeper.SetAuction(ctx, items[i])
|
||||
}
|
||||
return items
|
||||
}
|
||||
|
||||
func TestAuctionGet(t *testing.T) {
|
||||
keeper, ctx := keepertest.CosmostestKeeper(t)
|
||||
items := createNAuction(keeper, ctx, 10)
|
||||
for _, item := range items {
|
||||
rst, found := keeper.GetAuction(ctx,
|
||||
item.Index,
|
||||
)
|
||||
require.True(t, found)
|
||||
require.Equal(t,
|
||||
nullify.Fill(&item),
|
||||
nullify.Fill(&rst),
|
||||
)
|
||||
}
|
||||
}
|
||||
func TestAuctionRemove(t *testing.T) {
|
||||
keeper, ctx := keepertest.CosmostestKeeper(t)
|
||||
items := createNAuction(keeper, ctx, 10)
|
||||
for _, item := range items {
|
||||
keeper.RemoveAuction(ctx,
|
||||
item.Index,
|
||||
)
|
||||
_, found := keeper.GetAuction(ctx,
|
||||
item.Index,
|
||||
)
|
||||
require.False(t, found)
|
||||
}
|
||||
}
|
||||
|
||||
func TestAuctionGetAll(t *testing.T) {
|
||||
keeper, ctx := keepertest.CosmostestKeeper(t)
|
||||
items := createNAuction(keeper, ctx, 10)
|
||||
require.ElementsMatch(t,
|
||||
nullify.Fill(items),
|
||||
nullify.Fill(keeper.GetAllAuction(ctx)),
|
||||
)
|
||||
}
|
||||
57
x/cosmostest/keeper/grpc_query_auction.go
Normal file
57
x/cosmostest/keeper/grpc_query_auction.go
Normal file
@@ -0,0 +1,57 @@
|
||||
package keeper
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"cosmos-test/x/cosmostest/types"
|
||||
"github.com/cosmos/cosmos-sdk/store/prefix"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/cosmos/cosmos-sdk/types/query"
|
||||
"google.golang.org/grpc/codes"
|
||||
"google.golang.org/grpc/status"
|
||||
)
|
||||
|
||||
func (k Keeper) AuctionAll(c context.Context, req *types.QueryAllAuctionRequest) (*types.QueryAllAuctionResponse, error) {
|
||||
if req == nil {
|
||||
return nil, status.Error(codes.InvalidArgument, "invalid request")
|
||||
}
|
||||
|
||||
var auctions []types.Auction
|
||||
ctx := sdk.UnwrapSDKContext(c)
|
||||
|
||||
store := ctx.KVStore(k.storeKey)
|
||||
auctionStore := prefix.NewStore(store, types.KeyPrefix(types.AuctionKeyPrefix))
|
||||
|
||||
pageRes, err := query.Paginate(auctionStore, req.Pagination, func(key []byte, value []byte) error {
|
||||
var auction types.Auction
|
||||
if err := k.cdc.Unmarshal(value, &auction); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
auctions = append(auctions, auction)
|
||||
return nil
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
return nil, status.Error(codes.Internal, err.Error())
|
||||
}
|
||||
|
||||
return &types.QueryAllAuctionResponse{Auction: auctions, Pagination: pageRes}, nil
|
||||
}
|
||||
|
||||
func (k Keeper) Auction(c context.Context, req *types.QueryGetAuctionRequest) (*types.QueryGetAuctionResponse, error) {
|
||||
if req == nil {
|
||||
return nil, status.Error(codes.InvalidArgument, "invalid request")
|
||||
}
|
||||
ctx := sdk.UnwrapSDKContext(c)
|
||||
|
||||
val, found := k.GetAuction(
|
||||
ctx,
|
||||
req.Index,
|
||||
)
|
||||
if !found {
|
||||
return nil, status.Error(codes.NotFound, "not found")
|
||||
}
|
||||
|
||||
return &types.QueryGetAuctionResponse{Auction: val}, nil
|
||||
}
|
||||
126
x/cosmostest/keeper/grpc_query_auction_test.go
Normal file
126
x/cosmostest/keeper/grpc_query_auction_test.go
Normal file
@@ -0,0 +1,126 @@
|
||||
package keeper_test
|
||||
|
||||
import (
|
||||
"strconv"
|
||||
"testing"
|
||||
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/cosmos/cosmos-sdk/types/query"
|
||||
"github.com/stretchr/testify/require"
|
||||
"google.golang.org/grpc/codes"
|
||||
"google.golang.org/grpc/status"
|
||||
|
||||
keepertest "cosmos-test/testutil/keeper"
|
||||
"cosmos-test/testutil/nullify"
|
||||
"cosmos-test/x/cosmostest/types"
|
||||
)
|
||||
|
||||
// Prevent strconv unused error
|
||||
var _ = strconv.IntSize
|
||||
|
||||
func TestAuctionQuerySingle(t *testing.T) {
|
||||
keeper, ctx := keepertest.CosmostestKeeper(t)
|
||||
wctx := sdk.WrapSDKContext(ctx)
|
||||
msgs := createNAuction(keeper, ctx, 2)
|
||||
for _, tc := range []struct {
|
||||
desc string
|
||||
request *types.QueryGetAuctionRequest
|
||||
response *types.QueryGetAuctionResponse
|
||||
err error
|
||||
}{
|
||||
{
|
||||
desc: "First",
|
||||
request: &types.QueryGetAuctionRequest{
|
||||
Index: msgs[0].Index,
|
||||
},
|
||||
response: &types.QueryGetAuctionResponse{Auction: msgs[0]},
|
||||
},
|
||||
{
|
||||
desc: "Second",
|
||||
request: &types.QueryGetAuctionRequest{
|
||||
Index: msgs[1].Index,
|
||||
},
|
||||
response: &types.QueryGetAuctionResponse{Auction: msgs[1]},
|
||||
},
|
||||
{
|
||||
desc: "KeyNotFound",
|
||||
request: &types.QueryGetAuctionRequest{
|
||||
Index: strconv.Itoa(100000),
|
||||
},
|
||||
err: status.Error(codes.NotFound, "not found"),
|
||||
},
|
||||
{
|
||||
desc: "InvalidRequest",
|
||||
err: status.Error(codes.InvalidArgument, "invalid request"),
|
||||
},
|
||||
} {
|
||||
t.Run(tc.desc, func(t *testing.T) {
|
||||
response, err := keeper.Auction(wctx, tc.request)
|
||||
if tc.err != nil {
|
||||
require.ErrorIs(t, err, tc.err)
|
||||
} else {
|
||||
require.NoError(t, err)
|
||||
require.Equal(t,
|
||||
nullify.Fill(tc.response),
|
||||
nullify.Fill(response),
|
||||
)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestAuctionQueryPaginated(t *testing.T) {
|
||||
keeper, ctx := keepertest.CosmostestKeeper(t)
|
||||
wctx := sdk.WrapSDKContext(ctx)
|
||||
msgs := createNAuction(keeper, ctx, 5)
|
||||
|
||||
request := func(next []byte, offset, limit uint64, total bool) *types.QueryAllAuctionRequest {
|
||||
return &types.QueryAllAuctionRequest{
|
||||
Pagination: &query.PageRequest{
|
||||
Key: next,
|
||||
Offset: offset,
|
||||
Limit: limit,
|
||||
CountTotal: total,
|
||||
},
|
||||
}
|
||||
}
|
||||
t.Run("ByOffset", func(t *testing.T) {
|
||||
step := 2
|
||||
for i := 0; i < len(msgs); i += step {
|
||||
resp, err := keeper.AuctionAll(wctx, request(nil, uint64(i), uint64(step), false))
|
||||
require.NoError(t, err)
|
||||
require.LessOrEqual(t, len(resp.Auction), step)
|
||||
require.Subset(t,
|
||||
nullify.Fill(msgs),
|
||||
nullify.Fill(resp.Auction),
|
||||
)
|
||||
}
|
||||
})
|
||||
t.Run("ByKey", func(t *testing.T) {
|
||||
step := 2
|
||||
var next []byte
|
||||
for i := 0; i < len(msgs); i += step {
|
||||
resp, err := keeper.AuctionAll(wctx, request(next, 0, uint64(step), false))
|
||||
require.NoError(t, err)
|
||||
require.LessOrEqual(t, len(resp.Auction), step)
|
||||
require.Subset(t,
|
||||
nullify.Fill(msgs),
|
||||
nullify.Fill(resp.Auction),
|
||||
)
|
||||
next = resp.Pagination.NextKey
|
||||
}
|
||||
})
|
||||
t.Run("Total", func(t *testing.T) {
|
||||
resp, err := keeper.AuctionAll(wctx, request(nil, 0, 0, true))
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, len(msgs), int(resp.Pagination.Total))
|
||||
require.ElementsMatch(t,
|
||||
nullify.Fill(msgs),
|
||||
nullify.Fill(resp.Auction),
|
||||
)
|
||||
})
|
||||
t.Run("InvalidRequest", func(t *testing.T) {
|
||||
_, err := keeper.AuctionAll(wctx, nil)
|
||||
require.ErrorIs(t, err, status.Error(codes.InvalidArgument, "invalid request"))
|
||||
})
|
||||
}
|
||||
24
x/cosmostest/keeper/grpc_query_next_auction.go
Normal file
24
x/cosmostest/keeper/grpc_query_next_auction.go
Normal file
@@ -0,0 +1,24 @@
|
||||
package keeper
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"cosmos-test/x/cosmostest/types"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"google.golang.org/grpc/codes"
|
||||
"google.golang.org/grpc/status"
|
||||
)
|
||||
|
||||
func (k Keeper) NextAuction(c context.Context, req *types.QueryGetNextAuctionRequest) (*types.QueryGetNextAuctionResponse, error) {
|
||||
if req == nil {
|
||||
return nil, status.Error(codes.InvalidArgument, "invalid request")
|
||||
}
|
||||
ctx := sdk.UnwrapSDKContext(c)
|
||||
|
||||
val, found := k.GetNextAuction(ctx)
|
||||
if !found {
|
||||
return nil, status.Error(codes.NotFound, "not found")
|
||||
}
|
||||
|
||||
return &types.QueryGetNextAuctionResponse{NextAuction: val}, nil
|
||||
}
|
||||
49
x/cosmostest/keeper/grpc_query_next_auction_test.go
Normal file
49
x/cosmostest/keeper/grpc_query_next_auction_test.go
Normal file
@@ -0,0 +1,49 @@
|
||||
package keeper_test
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/stretchr/testify/require"
|
||||
"google.golang.org/grpc/codes"
|
||||
"google.golang.org/grpc/status"
|
||||
|
||||
keepertest "cosmos-test/testutil/keeper"
|
||||
"cosmos-test/testutil/nullify"
|
||||
"cosmos-test/x/cosmostest/types"
|
||||
)
|
||||
|
||||
func TestNextAuctionQuery(t *testing.T) {
|
||||
keeper, ctx := keepertest.CosmostestKeeper(t)
|
||||
wctx := sdk.WrapSDKContext(ctx)
|
||||
item := createTestNextAuction(keeper, ctx)
|
||||
for _, tc := range []struct {
|
||||
desc string
|
||||
request *types.QueryGetNextAuctionRequest
|
||||
response *types.QueryGetNextAuctionResponse
|
||||
err error
|
||||
}{
|
||||
{
|
||||
desc: "First",
|
||||
request: &types.QueryGetNextAuctionRequest{},
|
||||
response: &types.QueryGetNextAuctionResponse{NextAuction: item},
|
||||
},
|
||||
{
|
||||
desc: "InvalidRequest",
|
||||
err: status.Error(codes.InvalidArgument, "invalid request"),
|
||||
},
|
||||
} {
|
||||
t.Run(tc.desc, func(t *testing.T) {
|
||||
response, err := keeper.NextAuction(wctx, tc.request)
|
||||
if tc.err != nil {
|
||||
require.ErrorIs(t, err, tc.err)
|
||||
} else {
|
||||
require.NoError(t, err)
|
||||
require.Equal(t,
|
||||
nullify.Fill(tc.response),
|
||||
nullify.Fill(response),
|
||||
)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
33
x/cosmostest/keeper/next_auction.go
Normal file
33
x/cosmostest/keeper/next_auction.go
Normal file
@@ -0,0 +1,33 @@
|
||||
package keeper
|
||||
|
||||
import (
|
||||
"cosmos-test/x/cosmostest/types"
|
||||
"github.com/cosmos/cosmos-sdk/store/prefix"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
)
|
||||
|
||||
// SetNextAuction set nextAuction in the store
|
||||
func (k Keeper) SetNextAuction(ctx sdk.Context, nextAuction types.NextAuction) {
|
||||
store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefix(types.NextAuctionKey))
|
||||
b := k.cdc.MustMarshal(&nextAuction)
|
||||
store.Set([]byte{0}, b)
|
||||
}
|
||||
|
||||
// GetNextAuction returns nextAuction
|
||||
func (k Keeper) GetNextAuction(ctx sdk.Context) (val types.NextAuction, found bool) {
|
||||
store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefix(types.NextAuctionKey))
|
||||
|
||||
b := store.Get([]byte{0})
|
||||
if b == nil {
|
||||
return val, false
|
||||
}
|
||||
|
||||
k.cdc.MustUnmarshal(b, &val)
|
||||
return val, true
|
||||
}
|
||||
|
||||
// RemoveNextAuction removes nextAuction from the store
|
||||
func (k Keeper) RemoveNextAuction(ctx sdk.Context) {
|
||||
store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefix(types.NextAuctionKey))
|
||||
store.Delete([]byte{0})
|
||||
}
|
||||
38
x/cosmostest/keeper/next_auction_test.go
Normal file
38
x/cosmostest/keeper/next_auction_test.go
Normal file
@@ -0,0 +1,38 @@
|
||||
package keeper_test
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
keepertest "cosmos-test/testutil/keeper"
|
||||
"cosmos-test/testutil/nullify"
|
||||
"cosmos-test/x/cosmostest/keeper"
|
||||
"cosmos-test/x/cosmostest/types"
|
||||
)
|
||||
|
||||
func createTestNextAuction(keeper *keeper.Keeper, ctx sdk.Context) types.NextAuction {
|
||||
item := types.NextAuction{}
|
||||
keeper.SetNextAuction(ctx, item)
|
||||
return item
|
||||
}
|
||||
|
||||
func TestNextAuctionGet(t *testing.T) {
|
||||
keeper, ctx := keepertest.CosmostestKeeper(t)
|
||||
item := createTestNextAuction(keeper, ctx)
|
||||
rst, found := keeper.GetNextAuction(ctx)
|
||||
require.True(t, found)
|
||||
require.Equal(t,
|
||||
nullify.Fill(&item),
|
||||
nullify.Fill(&rst),
|
||||
)
|
||||
}
|
||||
|
||||
func TestNextAuctionRemove(t *testing.T) {
|
||||
keeper, ctx := keepertest.CosmostestKeeper(t)
|
||||
createTestNextAuction(keeper, ctx)
|
||||
keeper.RemoveNextAuction(ctx)
|
||||
_, found := keeper.GetNextAuction(ctx)
|
||||
require.False(t, found)
|
||||
}
|
||||
@@ -1,9 +1,9 @@
|
||||
package cosmostest
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
// this line is used by starport scaffolding # 1
|
||||
|
||||
"github.com/gorilla/mux"
|
||||
"github.com/grpc-ecosystem/grpc-gateway/runtime"
|
||||
@@ -77,7 +77,7 @@ func (AppModuleBasic) RegisterRESTRoutes(clientCtx client.Context, rtr *mux.Rout
|
||||
|
||||
// RegisterGRPCGatewayRoutes registers the gRPC Gateway routes for the module.
|
||||
func (AppModuleBasic) RegisterGRPCGatewayRoutes(clientCtx client.Context, mux *runtime.ServeMux) {
|
||||
// this line is used by starport scaffolding # 2
|
||||
types.RegisterQueryHandlerClient(context.Background(), mux, types.NewQueryClient(clientCtx))
|
||||
}
|
||||
|
||||
// GetTxCmd returns the capability module's root tx command.
|
||||
|
||||
521
x/cosmostest/types/auction.pb.go
Normal file
521
x/cosmostest/types/auction.pb.go
Normal file
@@ -0,0 +1,521 @@
|
||||
// Code generated by protoc-gen-gogo. DO NOT EDIT.
|
||||
// source: cosmostest/auction.proto
|
||||
|
||||
package types
|
||||
|
||||
import (
|
||||
fmt "fmt"
|
||||
proto "github.com/gogo/protobuf/proto"
|
||||
io "io"
|
||||
math "math"
|
||||
math_bits "math/bits"
|
||||
)
|
||||
|
||||
// Reference imports to suppress errors if they are not otherwise used.
|
||||
var _ = proto.Marshal
|
||||
var _ = fmt.Errorf
|
||||
var _ = math.Inf
|
||||
|
||||
// This is a compile-time assertion to ensure that this generated file
|
||||
// is compatible with the proto package it is being compiled against.
|
||||
// A compilation error at this line likely means your copy of the
|
||||
// proto package needs to be updated.
|
||||
const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package
|
||||
|
||||
type Auction struct {
|
||||
Index string `protobuf:"bytes,1,opt,name=index,proto3" json:"index,omitempty"`
|
||||
Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"`
|
||||
Description string `protobuf:"bytes,3,opt,name=description,proto3" json:"description,omitempty"`
|
||||
Bids string `protobuf:"bytes,4,opt,name=bids,proto3" json:"bids,omitempty"`
|
||||
HighestBid string `protobuf:"bytes,5,opt,name=highestBid,proto3" json:"highestBid,omitempty"`
|
||||
}
|
||||
|
||||
func (m *Auction) Reset() { *m = Auction{} }
|
||||
func (m *Auction) String() string { return proto.CompactTextString(m) }
|
||||
func (*Auction) ProtoMessage() {}
|
||||
func (*Auction) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_631f6f59914101d9, []int{0}
|
||||
}
|
||||
func (m *Auction) XXX_Unmarshal(b []byte) error {
|
||||
return m.Unmarshal(b)
|
||||
}
|
||||
func (m *Auction) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||
if deterministic {
|
||||
return xxx_messageInfo_Auction.Marshal(b, m, deterministic)
|
||||
} else {
|
||||
b = b[:cap(b)]
|
||||
n, err := m.MarshalToSizedBuffer(b)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return b[:n], nil
|
||||
}
|
||||
}
|
||||
func (m *Auction) XXX_Merge(src proto.Message) {
|
||||
xxx_messageInfo_Auction.Merge(m, src)
|
||||
}
|
||||
func (m *Auction) XXX_Size() int {
|
||||
return m.Size()
|
||||
}
|
||||
func (m *Auction) XXX_DiscardUnknown() {
|
||||
xxx_messageInfo_Auction.DiscardUnknown(m)
|
||||
}
|
||||
|
||||
var xxx_messageInfo_Auction proto.InternalMessageInfo
|
||||
|
||||
func (m *Auction) GetIndex() string {
|
||||
if m != nil {
|
||||
return m.Index
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (m *Auction) GetName() string {
|
||||
if m != nil {
|
||||
return m.Name
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (m *Auction) GetDescription() string {
|
||||
if m != nil {
|
||||
return m.Description
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (m *Auction) GetBids() string {
|
||||
if m != nil {
|
||||
return m.Bids
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (m *Auction) GetHighestBid() string {
|
||||
if m != nil {
|
||||
return m.HighestBid
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func init() {
|
||||
proto.RegisterType((*Auction)(nil), "cosmostest.cosmostest.Auction")
|
||||
}
|
||||
|
||||
func init() { proto.RegisterFile("cosmostest/auction.proto", fileDescriptor_631f6f59914101d9) }
|
||||
|
||||
var fileDescriptor_631f6f59914101d9 = []byte{
|
||||
// 196 bytes of a gzipped FileDescriptorProto
|
||||
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0x48, 0xce, 0x2f, 0xce,
|
||||
0xcd, 0x2f, 0x2e, 0x49, 0x2d, 0x2e, 0xd1, 0x4f, 0x2c, 0x4d, 0x2e, 0xc9, 0xcc, 0xcf, 0xd3, 0x2b,
|
||||
0x28, 0xca, 0x2f, 0xc9, 0x17, 0x12, 0x45, 0xc8, 0xe8, 0x21, 0x98, 0x4a, 0x9d, 0x8c, 0x5c, 0xec,
|
||||
0x8e, 0x10, 0x85, 0x42, 0x22, 0x5c, 0xac, 0x99, 0x79, 0x29, 0xa9, 0x15, 0x12, 0x8c, 0x0a, 0x8c,
|
||||
0x1a, 0x9c, 0x41, 0x10, 0x8e, 0x90, 0x10, 0x17, 0x4b, 0x5e, 0x62, 0x6e, 0xaa, 0x04, 0x13, 0x58,
|
||||
0x10, 0xcc, 0x16, 0x52, 0xe0, 0xe2, 0x4e, 0x49, 0x2d, 0x4e, 0x2e, 0xca, 0x2c, 0x00, 0x69, 0x94,
|
||||
0x60, 0x06, 0x4b, 0x21, 0x0b, 0x81, 0x74, 0x25, 0x65, 0xa6, 0x14, 0x4b, 0xb0, 0x40, 0x74, 0x81,
|
||||
0xd8, 0x42, 0x72, 0x5c, 0x5c, 0x19, 0x99, 0xe9, 0x19, 0xa9, 0xc5, 0x25, 0x4e, 0x99, 0x29, 0x12,
|
||||
0xac, 0x60, 0x19, 0x24, 0x11, 0x27, 0x8b, 0x13, 0x8f, 0xe4, 0x18, 0x2f, 0x3c, 0x92, 0x63, 0x7c,
|
||||
0xf0, 0x48, 0x8e, 0x71, 0xc2, 0x63, 0x39, 0x86, 0x0b, 0x8f, 0xe5, 0x18, 0x6e, 0x3c, 0x96, 0x63,
|
||||
0x88, 0x92, 0x83, 0xb8, 0x58, 0x17, 0xec, 0xaf, 0x0a, 0x7d, 0x24, 0x4f, 0x96, 0x54, 0x16, 0xa4,
|
||||
0x16, 0x27, 0xb1, 0x81, 0xfd, 0x68, 0x0c, 0x08, 0x00, 0x00, 0xff, 0xff, 0xce, 0x1a, 0xcd, 0xf3,
|
||||
0xff, 0x00, 0x00, 0x00,
|
||||
}
|
||||
|
||||
func (m *Auction) Marshal() (dAtA []byte, err error) {
|
||||
size := m.Size()
|
||||
dAtA = make([]byte, size)
|
||||
n, err := m.MarshalToSizedBuffer(dAtA[:size])
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return dAtA[:n], nil
|
||||
}
|
||||
|
||||
func (m *Auction) MarshalTo(dAtA []byte) (int, error) {
|
||||
size := m.Size()
|
||||
return m.MarshalToSizedBuffer(dAtA[:size])
|
||||
}
|
||||
|
||||
func (m *Auction) MarshalToSizedBuffer(dAtA []byte) (int, error) {
|
||||
i := len(dAtA)
|
||||
_ = i
|
||||
var l int
|
||||
_ = l
|
||||
if len(m.HighestBid) > 0 {
|
||||
i -= len(m.HighestBid)
|
||||
copy(dAtA[i:], m.HighestBid)
|
||||
i = encodeVarintAuction(dAtA, i, uint64(len(m.HighestBid)))
|
||||
i--
|
||||
dAtA[i] = 0x2a
|
||||
}
|
||||
if len(m.Bids) > 0 {
|
||||
i -= len(m.Bids)
|
||||
copy(dAtA[i:], m.Bids)
|
||||
i = encodeVarintAuction(dAtA, i, uint64(len(m.Bids)))
|
||||
i--
|
||||
dAtA[i] = 0x22
|
||||
}
|
||||
if len(m.Description) > 0 {
|
||||
i -= len(m.Description)
|
||||
copy(dAtA[i:], m.Description)
|
||||
i = encodeVarintAuction(dAtA, i, uint64(len(m.Description)))
|
||||
i--
|
||||
dAtA[i] = 0x1a
|
||||
}
|
||||
if len(m.Name) > 0 {
|
||||
i -= len(m.Name)
|
||||
copy(dAtA[i:], m.Name)
|
||||
i = encodeVarintAuction(dAtA, i, uint64(len(m.Name)))
|
||||
i--
|
||||
dAtA[i] = 0x12
|
||||
}
|
||||
if len(m.Index) > 0 {
|
||||
i -= len(m.Index)
|
||||
copy(dAtA[i:], m.Index)
|
||||
i = encodeVarintAuction(dAtA, i, uint64(len(m.Index)))
|
||||
i--
|
||||
dAtA[i] = 0xa
|
||||
}
|
||||
return len(dAtA) - i, nil
|
||||
}
|
||||
|
||||
func encodeVarintAuction(dAtA []byte, offset int, v uint64) int {
|
||||
offset -= sovAuction(v)
|
||||
base := offset
|
||||
for v >= 1<<7 {
|
||||
dAtA[offset] = uint8(v&0x7f | 0x80)
|
||||
v >>= 7
|
||||
offset++
|
||||
}
|
||||
dAtA[offset] = uint8(v)
|
||||
return base
|
||||
}
|
||||
func (m *Auction) Size() (n int) {
|
||||
if m == nil {
|
||||
return 0
|
||||
}
|
||||
var l int
|
||||
_ = l
|
||||
l = len(m.Index)
|
||||
if l > 0 {
|
||||
n += 1 + l + sovAuction(uint64(l))
|
||||
}
|
||||
l = len(m.Name)
|
||||
if l > 0 {
|
||||
n += 1 + l + sovAuction(uint64(l))
|
||||
}
|
||||
l = len(m.Description)
|
||||
if l > 0 {
|
||||
n += 1 + l + sovAuction(uint64(l))
|
||||
}
|
||||
l = len(m.Bids)
|
||||
if l > 0 {
|
||||
n += 1 + l + sovAuction(uint64(l))
|
||||
}
|
||||
l = len(m.HighestBid)
|
||||
if l > 0 {
|
||||
n += 1 + l + sovAuction(uint64(l))
|
||||
}
|
||||
return n
|
||||
}
|
||||
|
||||
func sovAuction(x uint64) (n int) {
|
||||
return (math_bits.Len64(x|1) + 6) / 7
|
||||
}
|
||||
func sozAuction(x uint64) (n int) {
|
||||
return sovAuction(uint64((x << 1) ^ uint64((int64(x) >> 63))))
|
||||
}
|
||||
func (m *Auction) Unmarshal(dAtA []byte) error {
|
||||
l := len(dAtA)
|
||||
iNdEx := 0
|
||||
for iNdEx < l {
|
||||
preIndex := iNdEx
|
||||
var wire uint64
|
||||
for shift := uint(0); ; shift += 7 {
|
||||
if shift >= 64 {
|
||||
return ErrIntOverflowAuction
|
||||
}
|
||||
if iNdEx >= l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
b := dAtA[iNdEx]
|
||||
iNdEx++
|
||||
wire |= uint64(b&0x7F) << shift
|
||||
if b < 0x80 {
|
||||
break
|
||||
}
|
||||
}
|
||||
fieldNum := int32(wire >> 3)
|
||||
wireType := int(wire & 0x7)
|
||||
if wireType == 4 {
|
||||
return fmt.Errorf("proto: Auction: wiretype end group for non-group")
|
||||
}
|
||||
if fieldNum <= 0 {
|
||||
return fmt.Errorf("proto: Auction: illegal tag %d (wire type %d)", fieldNum, wire)
|
||||
}
|
||||
switch fieldNum {
|
||||
case 1:
|
||||
if wireType != 2 {
|
||||
return fmt.Errorf("proto: wrong wireType = %d for field Index", wireType)
|
||||
}
|
||||
var stringLen uint64
|
||||
for shift := uint(0); ; shift += 7 {
|
||||
if shift >= 64 {
|
||||
return ErrIntOverflowAuction
|
||||
}
|
||||
if iNdEx >= l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
b := dAtA[iNdEx]
|
||||
iNdEx++
|
||||
stringLen |= uint64(b&0x7F) << shift
|
||||
if b < 0x80 {
|
||||
break
|
||||
}
|
||||
}
|
||||
intStringLen := int(stringLen)
|
||||
if intStringLen < 0 {
|
||||
return ErrInvalidLengthAuction
|
||||
}
|
||||
postIndex := iNdEx + intStringLen
|
||||
if postIndex < 0 {
|
||||
return ErrInvalidLengthAuction
|
||||
}
|
||||
if postIndex > l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
m.Index = string(dAtA[iNdEx:postIndex])
|
||||
iNdEx = postIndex
|
||||
case 2:
|
||||
if wireType != 2 {
|
||||
return fmt.Errorf("proto: wrong wireType = %d for field Name", wireType)
|
||||
}
|
||||
var stringLen uint64
|
||||
for shift := uint(0); ; shift += 7 {
|
||||
if shift >= 64 {
|
||||
return ErrIntOverflowAuction
|
||||
}
|
||||
if iNdEx >= l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
b := dAtA[iNdEx]
|
||||
iNdEx++
|
||||
stringLen |= uint64(b&0x7F) << shift
|
||||
if b < 0x80 {
|
||||
break
|
||||
}
|
||||
}
|
||||
intStringLen := int(stringLen)
|
||||
if intStringLen < 0 {
|
||||
return ErrInvalidLengthAuction
|
||||
}
|
||||
postIndex := iNdEx + intStringLen
|
||||
if postIndex < 0 {
|
||||
return ErrInvalidLengthAuction
|
||||
}
|
||||
if postIndex > l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
m.Name = string(dAtA[iNdEx:postIndex])
|
||||
iNdEx = postIndex
|
||||
case 3:
|
||||
if wireType != 2 {
|
||||
return fmt.Errorf("proto: wrong wireType = %d for field Description", wireType)
|
||||
}
|
||||
var stringLen uint64
|
||||
for shift := uint(0); ; shift += 7 {
|
||||
if shift >= 64 {
|
||||
return ErrIntOverflowAuction
|
||||
}
|
||||
if iNdEx >= l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
b := dAtA[iNdEx]
|
||||
iNdEx++
|
||||
stringLen |= uint64(b&0x7F) << shift
|
||||
if b < 0x80 {
|
||||
break
|
||||
}
|
||||
}
|
||||
intStringLen := int(stringLen)
|
||||
if intStringLen < 0 {
|
||||
return ErrInvalidLengthAuction
|
||||
}
|
||||
postIndex := iNdEx + intStringLen
|
||||
if postIndex < 0 {
|
||||
return ErrInvalidLengthAuction
|
||||
}
|
||||
if postIndex > l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
m.Description = string(dAtA[iNdEx:postIndex])
|
||||
iNdEx = postIndex
|
||||
case 4:
|
||||
if wireType != 2 {
|
||||
return fmt.Errorf("proto: wrong wireType = %d for field Bids", wireType)
|
||||
}
|
||||
var stringLen uint64
|
||||
for shift := uint(0); ; shift += 7 {
|
||||
if shift >= 64 {
|
||||
return ErrIntOverflowAuction
|
||||
}
|
||||
if iNdEx >= l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
b := dAtA[iNdEx]
|
||||
iNdEx++
|
||||
stringLen |= uint64(b&0x7F) << shift
|
||||
if b < 0x80 {
|
||||
break
|
||||
}
|
||||
}
|
||||
intStringLen := int(stringLen)
|
||||
if intStringLen < 0 {
|
||||
return ErrInvalidLengthAuction
|
||||
}
|
||||
postIndex := iNdEx + intStringLen
|
||||
if postIndex < 0 {
|
||||
return ErrInvalidLengthAuction
|
||||
}
|
||||
if postIndex > l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
m.Bids = string(dAtA[iNdEx:postIndex])
|
||||
iNdEx = postIndex
|
||||
case 5:
|
||||
if wireType != 2 {
|
||||
return fmt.Errorf("proto: wrong wireType = %d for field HighestBid", wireType)
|
||||
}
|
||||
var stringLen uint64
|
||||
for shift := uint(0); ; shift += 7 {
|
||||
if shift >= 64 {
|
||||
return ErrIntOverflowAuction
|
||||
}
|
||||
if iNdEx >= l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
b := dAtA[iNdEx]
|
||||
iNdEx++
|
||||
stringLen |= uint64(b&0x7F) << shift
|
||||
if b < 0x80 {
|
||||
break
|
||||
}
|
||||
}
|
||||
intStringLen := int(stringLen)
|
||||
if intStringLen < 0 {
|
||||
return ErrInvalidLengthAuction
|
||||
}
|
||||
postIndex := iNdEx + intStringLen
|
||||
if postIndex < 0 {
|
||||
return ErrInvalidLengthAuction
|
||||
}
|
||||
if postIndex > l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
m.HighestBid = string(dAtA[iNdEx:postIndex])
|
||||
iNdEx = postIndex
|
||||
default:
|
||||
iNdEx = preIndex
|
||||
skippy, err := skipAuction(dAtA[iNdEx:])
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if (skippy < 0) || (iNdEx+skippy) < 0 {
|
||||
return ErrInvalidLengthAuction
|
||||
}
|
||||
if (iNdEx + skippy) > l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
iNdEx += skippy
|
||||
}
|
||||
}
|
||||
|
||||
if iNdEx > l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
return nil
|
||||
}
|
||||
func skipAuction(dAtA []byte) (n int, err error) {
|
||||
l := len(dAtA)
|
||||
iNdEx := 0
|
||||
depth := 0
|
||||
for iNdEx < l {
|
||||
var wire uint64
|
||||
for shift := uint(0); ; shift += 7 {
|
||||
if shift >= 64 {
|
||||
return 0, ErrIntOverflowAuction
|
||||
}
|
||||
if iNdEx >= l {
|
||||
return 0, io.ErrUnexpectedEOF
|
||||
}
|
||||
b := dAtA[iNdEx]
|
||||
iNdEx++
|
||||
wire |= (uint64(b) & 0x7F) << shift
|
||||
if b < 0x80 {
|
||||
break
|
||||
}
|
||||
}
|
||||
wireType := int(wire & 0x7)
|
||||
switch wireType {
|
||||
case 0:
|
||||
for shift := uint(0); ; shift += 7 {
|
||||
if shift >= 64 {
|
||||
return 0, ErrIntOverflowAuction
|
||||
}
|
||||
if iNdEx >= l {
|
||||
return 0, io.ErrUnexpectedEOF
|
||||
}
|
||||
iNdEx++
|
||||
if dAtA[iNdEx-1] < 0x80 {
|
||||
break
|
||||
}
|
||||
}
|
||||
case 1:
|
||||
iNdEx += 8
|
||||
case 2:
|
||||
var length int
|
||||
for shift := uint(0); ; shift += 7 {
|
||||
if shift >= 64 {
|
||||
return 0, ErrIntOverflowAuction
|
||||
}
|
||||
if iNdEx >= l {
|
||||
return 0, io.ErrUnexpectedEOF
|
||||
}
|
||||
b := dAtA[iNdEx]
|
||||
iNdEx++
|
||||
length |= (int(b) & 0x7F) << shift
|
||||
if b < 0x80 {
|
||||
break
|
||||
}
|
||||
}
|
||||
if length < 0 {
|
||||
return 0, ErrInvalidLengthAuction
|
||||
}
|
||||
iNdEx += length
|
||||
case 3:
|
||||
depth++
|
||||
case 4:
|
||||
if depth == 0 {
|
||||
return 0, ErrUnexpectedEndOfGroupAuction
|
||||
}
|
||||
depth--
|
||||
case 5:
|
||||
iNdEx += 4
|
||||
default:
|
||||
return 0, fmt.Errorf("proto: illegal wireType %d", wireType)
|
||||
}
|
||||
if iNdEx < 0 {
|
||||
return 0, ErrInvalidLengthAuction
|
||||
}
|
||||
if depth == 0 {
|
||||
return iNdEx, nil
|
||||
}
|
||||
}
|
||||
return 0, io.ErrUnexpectedEOF
|
||||
}
|
||||
|
||||
var (
|
||||
ErrInvalidLengthAuction = fmt.Errorf("proto: negative length found during unmarshaling")
|
||||
ErrIntOverflowAuction = fmt.Errorf("proto: integer overflow")
|
||||
ErrUnexpectedEndOfGroupAuction = fmt.Errorf("proto: unexpected end of group")
|
||||
)
|
||||
@@ -1,7 +1,7 @@
|
||||
package types
|
||||
|
||||
import (
|
||||
// this line is used by starport scaffolding # genesis/types/import
|
||||
"fmt"
|
||||
)
|
||||
|
||||
// DefaultIndex is the default capability global index
|
||||
@@ -10,6 +10,8 @@ const DefaultIndex uint64 = 1
|
||||
// DefaultGenesis returns the default Capability genesis state
|
||||
func DefaultGenesis() *GenesisState {
|
||||
return &GenesisState{
|
||||
NextAuction: nil,
|
||||
AuctionList: []Auction{},
|
||||
// this line is used by starport scaffolding # genesis/types/default
|
||||
Params: DefaultParams(),
|
||||
}
|
||||
@@ -18,6 +20,16 @@ func DefaultGenesis() *GenesisState {
|
||||
// Validate performs basic genesis state validation returning an error upon any
|
||||
// failure.
|
||||
func (gs GenesisState) Validate() error {
|
||||
// Check for duplicated index in auction
|
||||
auctionIndexMap := make(map[string]struct{})
|
||||
|
||||
for _, elem := range gs.AuctionList {
|
||||
index := string(AuctionKey(elem.Index))
|
||||
if _, ok := auctionIndexMap[index]; ok {
|
||||
return fmt.Errorf("duplicated index for auction")
|
||||
}
|
||||
auctionIndexMap[index] = struct{}{}
|
||||
}
|
||||
// this line is used by starport scaffolding # genesis/types/validate
|
||||
|
||||
return gs.Params.Validate()
|
||||
|
||||
@@ -25,7 +25,9 @@ const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package
|
||||
|
||||
// GenesisState defines the cosmostest module's genesis state.
|
||||
type GenesisState struct {
|
||||
Params Params `protobuf:"bytes,1,opt,name=params,proto3" json:"params"`
|
||||
Params Params `protobuf:"bytes,1,opt,name=params,proto3" json:"params"`
|
||||
NextAuction *NextAuction `protobuf:"bytes,2,opt,name=nextAuction,proto3" json:"nextAuction,omitempty"`
|
||||
AuctionList []Auction `protobuf:"bytes,3,rep,name=auctionList,proto3" json:"auctionList"`
|
||||
}
|
||||
|
||||
func (m *GenesisState) Reset() { *m = GenesisState{} }
|
||||
@@ -68,6 +70,20 @@ func (m *GenesisState) GetParams() Params {
|
||||
return Params{}
|
||||
}
|
||||
|
||||
func (m *GenesisState) GetNextAuction() *NextAuction {
|
||||
if m != nil {
|
||||
return m.NextAuction
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *GenesisState) GetAuctionList() []Auction {
|
||||
if m != nil {
|
||||
return m.AuctionList
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func init() {
|
||||
proto.RegisterType((*GenesisState)(nil), "cosmostest.cosmostest.GenesisState")
|
||||
}
|
||||
@@ -75,18 +91,23 @@ func init() {
|
||||
func init() { proto.RegisterFile("cosmostest/genesis.proto", fileDescriptor_78c0d8c25fe3d9a9) }
|
||||
|
||||
var fileDescriptor_78c0d8c25fe3d9a9 = []byte{
|
||||
// 173 bytes of a gzipped FileDescriptorProto
|
||||
// 247 bytes of a gzipped FileDescriptorProto
|
||||
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0x48, 0xce, 0x2f, 0xce,
|
||||
0xcd, 0x2f, 0x2e, 0x49, 0x2d, 0x2e, 0xd1, 0x4f, 0x4f, 0xcd, 0x4b, 0x2d, 0xce, 0x2c, 0xd6, 0x2b,
|
||||
0x28, 0xca, 0x2f, 0xc9, 0x17, 0x12, 0x45, 0xc8, 0xe8, 0x21, 0x98, 0x52, 0x22, 0xe9, 0xf9, 0xe9,
|
||||
0xf9, 0x60, 0x15, 0xfa, 0x20, 0x16, 0x44, 0xb1, 0x94, 0x38, 0x92, 0x31, 0x05, 0x89, 0x45, 0x89,
|
||||
0xb9, 0x50, 0x53, 0x94, 0xbc, 0xb9, 0x78, 0xdc, 0x21, 0xc6, 0x06, 0x97, 0x24, 0x96, 0xa4, 0x0a,
|
||||
0x59, 0x73, 0xb1, 0x41, 0xe4, 0x25, 0x18, 0x15, 0x18, 0x35, 0xb8, 0x8d, 0x64, 0xf5, 0xb0, 0x5a,
|
||||
0xa3, 0x17, 0x00, 0x56, 0xe4, 0xc4, 0x72, 0xe2, 0x9e, 0x3c, 0x43, 0x10, 0x54, 0x8b, 0x93, 0xc5,
|
||||
0x89, 0x47, 0x72, 0x8c, 0x17, 0x1e, 0xc9, 0x31, 0x3e, 0x78, 0x24, 0xc7, 0x38, 0xe1, 0xb1, 0x1c,
|
||||
0xc3, 0x85, 0xc7, 0x72, 0x0c, 0x37, 0x1e, 0xcb, 0x31, 0x44, 0xc9, 0x41, 0xb4, 0xea, 0x82, 0x1d,
|
||||
0x50, 0xa1, 0x8f, 0xe4, 0x9a, 0x92, 0xca, 0x82, 0xd4, 0xe2, 0x24, 0x36, 0xb0, 0x6b, 0x8c, 0x01,
|
||||
0x01, 0x00, 0x00, 0xff, 0xff, 0x74, 0xa7, 0xf1, 0xb2, 0xef, 0x00, 0x00, 0x00,
|
||||
0xb9, 0x50, 0x53, 0xa4, 0x64, 0x91, 0x24, 0xf2, 0x52, 0x2b, 0x4a, 0xe2, 0x13, 0x4b, 0x93, 0x4b,
|
||||
0x32, 0xf3, 0xf3, 0xa0, 0xd2, 0xc8, 0xd6, 0xa3, 0xc8, 0x28, 0xdd, 0x64, 0xe4, 0xe2, 0x71, 0x87,
|
||||
0x38, 0x28, 0xb8, 0x24, 0xb1, 0x24, 0x55, 0xc8, 0x9a, 0x8b, 0x0d, 0x62, 0xb2, 0x04, 0xa3, 0x02,
|
||||
0xa3, 0x06, 0xb7, 0x91, 0xac, 0x1e, 0x56, 0x07, 0xea, 0x05, 0x80, 0x15, 0x39, 0xb1, 0x9c, 0xb8,
|
||||
0x27, 0xcf, 0x10, 0x04, 0xd5, 0x22, 0xe4, 0xc2, 0xc5, 0x0d, 0xb2, 0xdd, 0x11, 0x62, 0x85, 0x04,
|
||||
0x13, 0xd8, 0x04, 0x25, 0x1c, 0x26, 0xf8, 0x21, 0x54, 0x06, 0x21, 0x6b, 0x13, 0x72, 0xe3, 0xe2,
|
||||
0x86, 0x3a, 0xd2, 0x27, 0xb3, 0xb8, 0x44, 0x82, 0x59, 0x81, 0x59, 0x83, 0xdb, 0x48, 0x0e, 0x87,
|
||||
0x29, 0x50, 0x4d, 0x50, 0x87, 0x20, 0x6b, 0x74, 0xb2, 0x38, 0xf1, 0x48, 0x8e, 0xf1, 0xc2, 0x23,
|
||||
0x39, 0xc6, 0x07, 0x8f, 0xe4, 0x18, 0x27, 0x3c, 0x96, 0x63, 0xb8, 0xf0, 0x58, 0x8e, 0xe1, 0xc6,
|
||||
0x63, 0x39, 0x86, 0x28, 0x39, 0x88, 0x01, 0xba, 0xe0, 0x00, 0xa9, 0xd0, 0x47, 0x0a, 0x9d, 0x92,
|
||||
0xca, 0x82, 0xd4, 0xe2, 0x24, 0x36, 0x70, 0xe0, 0x18, 0x03, 0x02, 0x00, 0x00, 0xff, 0xff, 0x3c,
|
||||
0x94, 0xf7, 0x48, 0xb7, 0x01, 0x00, 0x00,
|
||||
}
|
||||
|
||||
func (m *GenesisState) Marshal() (dAtA []byte, err error) {
|
||||
@@ -109,6 +130,32 @@ func (m *GenesisState) MarshalToSizedBuffer(dAtA []byte) (int, error) {
|
||||
_ = i
|
||||
var l int
|
||||
_ = l
|
||||
if len(m.AuctionList) > 0 {
|
||||
for iNdEx := len(m.AuctionList) - 1; iNdEx >= 0; iNdEx-- {
|
||||
{
|
||||
size, err := m.AuctionList[iNdEx].MarshalToSizedBuffer(dAtA[:i])
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
i -= size
|
||||
i = encodeVarintGenesis(dAtA, i, uint64(size))
|
||||
}
|
||||
i--
|
||||
dAtA[i] = 0x1a
|
||||
}
|
||||
}
|
||||
if m.NextAuction != nil {
|
||||
{
|
||||
size, err := m.NextAuction.MarshalToSizedBuffer(dAtA[:i])
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
i -= size
|
||||
i = encodeVarintGenesis(dAtA, i, uint64(size))
|
||||
}
|
||||
i--
|
||||
dAtA[i] = 0x12
|
||||
}
|
||||
{
|
||||
size, err := m.Params.MarshalToSizedBuffer(dAtA[:i])
|
||||
if err != nil {
|
||||
@@ -141,6 +188,16 @@ func (m *GenesisState) Size() (n int) {
|
||||
_ = l
|
||||
l = m.Params.Size()
|
||||
n += 1 + l + sovGenesis(uint64(l))
|
||||
if m.NextAuction != nil {
|
||||
l = m.NextAuction.Size()
|
||||
n += 1 + l + sovGenesis(uint64(l))
|
||||
}
|
||||
if len(m.AuctionList) > 0 {
|
||||
for _, e := range m.AuctionList {
|
||||
l = e.Size()
|
||||
n += 1 + l + sovGenesis(uint64(l))
|
||||
}
|
||||
}
|
||||
return n
|
||||
}
|
||||
|
||||
@@ -212,6 +269,76 @@ func (m *GenesisState) Unmarshal(dAtA []byte) error {
|
||||
return err
|
||||
}
|
||||
iNdEx = postIndex
|
||||
case 2:
|
||||
if wireType != 2 {
|
||||
return fmt.Errorf("proto: wrong wireType = %d for field NextAuction", wireType)
|
||||
}
|
||||
var msglen int
|
||||
for shift := uint(0); ; shift += 7 {
|
||||
if shift >= 64 {
|
||||
return ErrIntOverflowGenesis
|
||||
}
|
||||
if iNdEx >= l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
b := dAtA[iNdEx]
|
||||
iNdEx++
|
||||
msglen |= int(b&0x7F) << shift
|
||||
if b < 0x80 {
|
||||
break
|
||||
}
|
||||
}
|
||||
if msglen < 0 {
|
||||
return ErrInvalidLengthGenesis
|
||||
}
|
||||
postIndex := iNdEx + msglen
|
||||
if postIndex < 0 {
|
||||
return ErrInvalidLengthGenesis
|
||||
}
|
||||
if postIndex > l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
if m.NextAuction == nil {
|
||||
m.NextAuction = &NextAuction{}
|
||||
}
|
||||
if err := m.NextAuction.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
|
||||
return err
|
||||
}
|
||||
iNdEx = postIndex
|
||||
case 3:
|
||||
if wireType != 2 {
|
||||
return fmt.Errorf("proto: wrong wireType = %d for field AuctionList", wireType)
|
||||
}
|
||||
var msglen int
|
||||
for shift := uint(0); ; shift += 7 {
|
||||
if shift >= 64 {
|
||||
return ErrIntOverflowGenesis
|
||||
}
|
||||
if iNdEx >= l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
b := dAtA[iNdEx]
|
||||
iNdEx++
|
||||
msglen |= int(b&0x7F) << shift
|
||||
if b < 0x80 {
|
||||
break
|
||||
}
|
||||
}
|
||||
if msglen < 0 {
|
||||
return ErrInvalidLengthGenesis
|
||||
}
|
||||
postIndex := iNdEx + msglen
|
||||
if postIndex < 0 {
|
||||
return ErrInvalidLengthGenesis
|
||||
}
|
||||
if postIndex > l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
m.AuctionList = append(m.AuctionList, Auction{})
|
||||
if err := m.AuctionList[len(m.AuctionList)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
|
||||
return err
|
||||
}
|
||||
iNdEx = postIndex
|
||||
default:
|
||||
iNdEx = preIndex
|
||||
skippy, err := skipGenesis(dAtA[iNdEx:])
|
||||
|
||||
@@ -19,13 +19,38 @@ func TestGenesisState_Validate(t *testing.T) {
|
||||
valid: true,
|
||||
},
|
||||
{
|
||||
desc: "valid genesis state",
|
||||
desc: "valid genesis state",
|
||||
genState: &types.GenesisState{
|
||||
|
||||
NextAuction: &types.NextAuction{
|
||||
AuctionId: 54,
|
||||
},
|
||||
AuctionList: []types.Auction{
|
||||
{
|
||||
Index: "0",
|
||||
},
|
||||
{
|
||||
Index: "1",
|
||||
},
|
||||
},
|
||||
// this line is used by starport scaffolding # types/genesis/validField
|
||||
},
|
||||
valid: true,
|
||||
},
|
||||
{
|
||||
desc: "duplicated auction",
|
||||
genState: &types.GenesisState{
|
||||
AuctionList: []types.Auction{
|
||||
{
|
||||
Index: "0",
|
||||
},
|
||||
{
|
||||
Index: "0",
|
||||
},
|
||||
},
|
||||
},
|
||||
valid: false,
|
||||
},
|
||||
// this line is used by starport scaffolding # types/genesis/testcase
|
||||
} {
|
||||
t.Run(tc.desc, func(t *testing.T) {
|
||||
|
||||
23
x/cosmostest/types/key_auction.go
Normal file
23
x/cosmostest/types/key_auction.go
Normal file
@@ -0,0 +1,23 @@
|
||||
package types
|
||||
|
||||
import "encoding/binary"
|
||||
|
||||
var _ binary.ByteOrder
|
||||
|
||||
const (
|
||||
// AuctionKeyPrefix is the prefix to retrieve all Auction
|
||||
AuctionKeyPrefix = "Auction/value/"
|
||||
)
|
||||
|
||||
// AuctionKey returns the store key to retrieve a Auction from the index fields
|
||||
func AuctionKey(
|
||||
index string,
|
||||
) []byte {
|
||||
var key []byte
|
||||
|
||||
indexBytes := []byte(index)
|
||||
key = append(key, indexBytes...)
|
||||
key = append(key, []byte("/")...)
|
||||
|
||||
return key
|
||||
}
|
||||
@@ -20,3 +20,7 @@ const (
|
||||
func KeyPrefix(p string) []byte {
|
||||
return []byte(p)
|
||||
}
|
||||
|
||||
const (
|
||||
NextAuctionKey = "NextAuction-value-"
|
||||
)
|
||||
|
||||
297
x/cosmostest/types/next_auction.pb.go
Normal file
297
x/cosmostest/types/next_auction.pb.go
Normal file
@@ -0,0 +1,297 @@
|
||||
// Code generated by protoc-gen-gogo. DO NOT EDIT.
|
||||
// source: cosmostest/next_auction.proto
|
||||
|
||||
package types
|
||||
|
||||
import (
|
||||
fmt "fmt"
|
||||
proto "github.com/gogo/protobuf/proto"
|
||||
io "io"
|
||||
math "math"
|
||||
math_bits "math/bits"
|
||||
)
|
||||
|
||||
// Reference imports to suppress errors if they are not otherwise used.
|
||||
var _ = proto.Marshal
|
||||
var _ = fmt.Errorf
|
||||
var _ = math.Inf
|
||||
|
||||
// This is a compile-time assertion to ensure that this generated file
|
||||
// is compatible with the proto package it is being compiled against.
|
||||
// A compilation error at this line likely means your copy of the
|
||||
// proto package needs to be updated.
|
||||
const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package
|
||||
|
||||
type NextAuction struct {
|
||||
AuctionId uint64 `protobuf:"varint,1,opt,name=auctionId,proto3" json:"auctionId,omitempty"`
|
||||
}
|
||||
|
||||
func (m *NextAuction) Reset() { *m = NextAuction{} }
|
||||
func (m *NextAuction) String() string { return proto.CompactTextString(m) }
|
||||
func (*NextAuction) ProtoMessage() {}
|
||||
func (*NextAuction) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_403ab8ae798c785d, []int{0}
|
||||
}
|
||||
func (m *NextAuction) XXX_Unmarshal(b []byte) error {
|
||||
return m.Unmarshal(b)
|
||||
}
|
||||
func (m *NextAuction) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||
if deterministic {
|
||||
return xxx_messageInfo_NextAuction.Marshal(b, m, deterministic)
|
||||
} else {
|
||||
b = b[:cap(b)]
|
||||
n, err := m.MarshalToSizedBuffer(b)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return b[:n], nil
|
||||
}
|
||||
}
|
||||
func (m *NextAuction) XXX_Merge(src proto.Message) {
|
||||
xxx_messageInfo_NextAuction.Merge(m, src)
|
||||
}
|
||||
func (m *NextAuction) XXX_Size() int {
|
||||
return m.Size()
|
||||
}
|
||||
func (m *NextAuction) XXX_DiscardUnknown() {
|
||||
xxx_messageInfo_NextAuction.DiscardUnknown(m)
|
||||
}
|
||||
|
||||
var xxx_messageInfo_NextAuction proto.InternalMessageInfo
|
||||
|
||||
func (m *NextAuction) GetAuctionId() uint64 {
|
||||
if m != nil {
|
||||
return m.AuctionId
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func init() {
|
||||
proto.RegisterType((*NextAuction)(nil), "cosmostest.cosmostest.NextAuction")
|
||||
}
|
||||
|
||||
func init() { proto.RegisterFile("cosmostest/next_auction.proto", fileDescriptor_403ab8ae798c785d) }
|
||||
|
||||
var fileDescriptor_403ab8ae798c785d = []byte{
|
||||
// 139 bytes of a gzipped FileDescriptorProto
|
||||
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0x4d, 0xce, 0x2f, 0xce,
|
||||
0xcd, 0x2f, 0x2e, 0x49, 0x2d, 0x2e, 0xd1, 0xcf, 0x4b, 0xad, 0x28, 0x89, 0x4f, 0x2c, 0x4d, 0x2e,
|
||||
0xc9, 0xcc, 0xcf, 0xd3, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x12, 0x45, 0x48, 0xeb, 0x21, 0x98,
|
||||
0x4a, 0xda, 0x5c, 0xdc, 0x7e, 0xa9, 0x15, 0x25, 0x8e, 0x10, 0xb5, 0x42, 0x32, 0x5c, 0x9c, 0x50,
|
||||
0x6d, 0x9e, 0x29, 0x12, 0x8c, 0x0a, 0x8c, 0x1a, 0x2c, 0x41, 0x08, 0x01, 0x27, 0x8b, 0x13, 0x8f,
|
||||
0xe4, 0x18, 0x2f, 0x3c, 0x92, 0x63, 0x7c, 0xf0, 0x48, 0x8e, 0x71, 0xc2, 0x63, 0x39, 0x86, 0x0b,
|
||||
0x8f, 0xe5, 0x18, 0x6e, 0x3c, 0x96, 0x63, 0x88, 0x92, 0x83, 0x18, 0xa9, 0x0b, 0xb6, 0xbd, 0x42,
|
||||
0x1f, 0xc9, 0x29, 0x25, 0x95, 0x05, 0xa9, 0xc5, 0x49, 0x6c, 0x60, 0x47, 0x18, 0x03, 0x02, 0x00,
|
||||
0x00, 0xff, 0xff, 0xb1, 0x7c, 0xed, 0xa0, 0xa5, 0x00, 0x00, 0x00,
|
||||
}
|
||||
|
||||
func (m *NextAuction) Marshal() (dAtA []byte, err error) {
|
||||
size := m.Size()
|
||||
dAtA = make([]byte, size)
|
||||
n, err := m.MarshalToSizedBuffer(dAtA[:size])
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return dAtA[:n], nil
|
||||
}
|
||||
|
||||
func (m *NextAuction) MarshalTo(dAtA []byte) (int, error) {
|
||||
size := m.Size()
|
||||
return m.MarshalToSizedBuffer(dAtA[:size])
|
||||
}
|
||||
|
||||
func (m *NextAuction) MarshalToSizedBuffer(dAtA []byte) (int, error) {
|
||||
i := len(dAtA)
|
||||
_ = i
|
||||
var l int
|
||||
_ = l
|
||||
if m.AuctionId != 0 {
|
||||
i = encodeVarintNextAuction(dAtA, i, uint64(m.AuctionId))
|
||||
i--
|
||||
dAtA[i] = 0x8
|
||||
}
|
||||
return len(dAtA) - i, nil
|
||||
}
|
||||
|
||||
func encodeVarintNextAuction(dAtA []byte, offset int, v uint64) int {
|
||||
offset -= sovNextAuction(v)
|
||||
base := offset
|
||||
for v >= 1<<7 {
|
||||
dAtA[offset] = uint8(v&0x7f | 0x80)
|
||||
v >>= 7
|
||||
offset++
|
||||
}
|
||||
dAtA[offset] = uint8(v)
|
||||
return base
|
||||
}
|
||||
func (m *NextAuction) Size() (n int) {
|
||||
if m == nil {
|
||||
return 0
|
||||
}
|
||||
var l int
|
||||
_ = l
|
||||
if m.AuctionId != 0 {
|
||||
n += 1 + sovNextAuction(uint64(m.AuctionId))
|
||||
}
|
||||
return n
|
||||
}
|
||||
|
||||
func sovNextAuction(x uint64) (n int) {
|
||||
return (math_bits.Len64(x|1) + 6) / 7
|
||||
}
|
||||
func sozNextAuction(x uint64) (n int) {
|
||||
return sovNextAuction(uint64((x << 1) ^ uint64((int64(x) >> 63))))
|
||||
}
|
||||
func (m *NextAuction) Unmarshal(dAtA []byte) error {
|
||||
l := len(dAtA)
|
||||
iNdEx := 0
|
||||
for iNdEx < l {
|
||||
preIndex := iNdEx
|
||||
var wire uint64
|
||||
for shift := uint(0); ; shift += 7 {
|
||||
if shift >= 64 {
|
||||
return ErrIntOverflowNextAuction
|
||||
}
|
||||
if iNdEx >= l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
b := dAtA[iNdEx]
|
||||
iNdEx++
|
||||
wire |= uint64(b&0x7F) << shift
|
||||
if b < 0x80 {
|
||||
break
|
||||
}
|
||||
}
|
||||
fieldNum := int32(wire >> 3)
|
||||
wireType := int(wire & 0x7)
|
||||
if wireType == 4 {
|
||||
return fmt.Errorf("proto: NextAuction: wiretype end group for non-group")
|
||||
}
|
||||
if fieldNum <= 0 {
|
||||
return fmt.Errorf("proto: NextAuction: illegal tag %d (wire type %d)", fieldNum, wire)
|
||||
}
|
||||
switch fieldNum {
|
||||
case 1:
|
||||
if wireType != 0 {
|
||||
return fmt.Errorf("proto: wrong wireType = %d for field AuctionId", wireType)
|
||||
}
|
||||
m.AuctionId = 0
|
||||
for shift := uint(0); ; shift += 7 {
|
||||
if shift >= 64 {
|
||||
return ErrIntOverflowNextAuction
|
||||
}
|
||||
if iNdEx >= l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
b := dAtA[iNdEx]
|
||||
iNdEx++
|
||||
m.AuctionId |= uint64(b&0x7F) << shift
|
||||
if b < 0x80 {
|
||||
break
|
||||
}
|
||||
}
|
||||
default:
|
||||
iNdEx = preIndex
|
||||
skippy, err := skipNextAuction(dAtA[iNdEx:])
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if (skippy < 0) || (iNdEx+skippy) < 0 {
|
||||
return ErrInvalidLengthNextAuction
|
||||
}
|
||||
if (iNdEx + skippy) > l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
iNdEx += skippy
|
||||
}
|
||||
}
|
||||
|
||||
if iNdEx > l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
return nil
|
||||
}
|
||||
func skipNextAuction(dAtA []byte) (n int, err error) {
|
||||
l := len(dAtA)
|
||||
iNdEx := 0
|
||||
depth := 0
|
||||
for iNdEx < l {
|
||||
var wire uint64
|
||||
for shift := uint(0); ; shift += 7 {
|
||||
if shift >= 64 {
|
||||
return 0, ErrIntOverflowNextAuction
|
||||
}
|
||||
if iNdEx >= l {
|
||||
return 0, io.ErrUnexpectedEOF
|
||||
}
|
||||
b := dAtA[iNdEx]
|
||||
iNdEx++
|
||||
wire |= (uint64(b) & 0x7F) << shift
|
||||
if b < 0x80 {
|
||||
break
|
||||
}
|
||||
}
|
||||
wireType := int(wire & 0x7)
|
||||
switch wireType {
|
||||
case 0:
|
||||
for shift := uint(0); ; shift += 7 {
|
||||
if shift >= 64 {
|
||||
return 0, ErrIntOverflowNextAuction
|
||||
}
|
||||
if iNdEx >= l {
|
||||
return 0, io.ErrUnexpectedEOF
|
||||
}
|
||||
iNdEx++
|
||||
if dAtA[iNdEx-1] < 0x80 {
|
||||
break
|
||||
}
|
||||
}
|
||||
case 1:
|
||||
iNdEx += 8
|
||||
case 2:
|
||||
var length int
|
||||
for shift := uint(0); ; shift += 7 {
|
||||
if shift >= 64 {
|
||||
return 0, ErrIntOverflowNextAuction
|
||||
}
|
||||
if iNdEx >= l {
|
||||
return 0, io.ErrUnexpectedEOF
|
||||
}
|
||||
b := dAtA[iNdEx]
|
||||
iNdEx++
|
||||
length |= (int(b) & 0x7F) << shift
|
||||
if b < 0x80 {
|
||||
break
|
||||
}
|
||||
}
|
||||
if length < 0 {
|
||||
return 0, ErrInvalidLengthNextAuction
|
||||
}
|
||||
iNdEx += length
|
||||
case 3:
|
||||
depth++
|
||||
case 4:
|
||||
if depth == 0 {
|
||||
return 0, ErrUnexpectedEndOfGroupNextAuction
|
||||
}
|
||||
depth--
|
||||
case 5:
|
||||
iNdEx += 4
|
||||
default:
|
||||
return 0, fmt.Errorf("proto: illegal wireType %d", wireType)
|
||||
}
|
||||
if iNdEx < 0 {
|
||||
return 0, ErrInvalidLengthNextAuction
|
||||
}
|
||||
if depth == 0 {
|
||||
return iNdEx, nil
|
||||
}
|
||||
}
|
||||
return 0, io.ErrUnexpectedEOF
|
||||
}
|
||||
|
||||
var (
|
||||
ErrInvalidLengthNextAuction = fmt.Errorf("proto: negative length found during unmarshaling")
|
||||
ErrIntOverflowNextAuction = fmt.Errorf("proto: integer overflow")
|
||||
ErrUnexpectedEndOfGroupNextAuction = fmt.Errorf("proto: unexpected end of group")
|
||||
)
|
||||
File diff suppressed because it is too large
Load Diff
@@ -51,6 +51,114 @@ func local_request_Query_Params_0(ctx context.Context, marshaler runtime.Marshal
|
||||
|
||||
}
|
||||
|
||||
func request_Query_NextAuction_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
||||
var protoReq QueryGetNextAuctionRequest
|
||||
var metadata runtime.ServerMetadata
|
||||
|
||||
msg, err := client.NextAuction(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
|
||||
return msg, metadata, err
|
||||
|
||||
}
|
||||
|
||||
func local_request_Query_NextAuction_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
||||
var protoReq QueryGetNextAuctionRequest
|
||||
var metadata runtime.ServerMetadata
|
||||
|
||||
msg, err := server.NextAuction(ctx, &protoReq)
|
||||
return msg, metadata, err
|
||||
|
||||
}
|
||||
|
||||
func request_Query_Auction_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
||||
var protoReq QueryGetAuctionRequest
|
||||
var metadata runtime.ServerMetadata
|
||||
|
||||
var (
|
||||
val string
|
||||
ok bool
|
||||
err error
|
||||
_ = err
|
||||
)
|
||||
|
||||
val, ok = pathParams["index"]
|
||||
if !ok {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "index")
|
||||
}
|
||||
|
||||
protoReq.Index, err = runtime.String(val)
|
||||
|
||||
if err != nil {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "index", err)
|
||||
}
|
||||
|
||||
msg, err := client.Auction(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
|
||||
return msg, metadata, err
|
||||
|
||||
}
|
||||
|
||||
func local_request_Query_Auction_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
||||
var protoReq QueryGetAuctionRequest
|
||||
var metadata runtime.ServerMetadata
|
||||
|
||||
var (
|
||||
val string
|
||||
ok bool
|
||||
err error
|
||||
_ = err
|
||||
)
|
||||
|
||||
val, ok = pathParams["index"]
|
||||
if !ok {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "index")
|
||||
}
|
||||
|
||||
protoReq.Index, err = runtime.String(val)
|
||||
|
||||
if err != nil {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "index", err)
|
||||
}
|
||||
|
||||
msg, err := server.Auction(ctx, &protoReq)
|
||||
return msg, metadata, err
|
||||
|
||||
}
|
||||
|
||||
var (
|
||||
filter_Query_AuctionAll_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)}
|
||||
)
|
||||
|
||||
func request_Query_AuctionAll_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
||||
var protoReq QueryAllAuctionRequest
|
||||
var metadata runtime.ServerMetadata
|
||||
|
||||
if err := req.ParseForm(); err != nil {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
|
||||
}
|
||||
if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_AuctionAll_0); err != nil {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
|
||||
}
|
||||
|
||||
msg, err := client.AuctionAll(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
|
||||
return msg, metadata, err
|
||||
|
||||
}
|
||||
|
||||
func local_request_Query_AuctionAll_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
||||
var protoReq QueryAllAuctionRequest
|
||||
var metadata runtime.ServerMetadata
|
||||
|
||||
if err := req.ParseForm(); err != nil {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
|
||||
}
|
||||
if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_AuctionAll_0); err != nil {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
|
||||
}
|
||||
|
||||
msg, err := server.AuctionAll(ctx, &protoReq)
|
||||
return msg, metadata, err
|
||||
|
||||
}
|
||||
|
||||
// RegisterQueryHandlerServer registers the http handlers for service Query to "mux".
|
||||
// UnaryRPC :call QueryServer directly.
|
||||
// StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906.
|
||||
@@ -80,6 +188,75 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv
|
||||
|
||||
})
|
||||
|
||||
mux.Handle("GET", pattern_Query_NextAuction_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
|
||||
ctx, cancel := context.WithCancel(req.Context())
|
||||
defer cancel()
|
||||
var stream runtime.ServerTransportStream
|
||||
ctx = grpc.NewContextWithServerTransportStream(ctx, &stream)
|
||||
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
|
||||
rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req)
|
||||
if err != nil {
|
||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
}
|
||||
resp, md, err := local_request_Query_NextAuction_0(rctx, inboundMarshaler, server, req, pathParams)
|
||||
md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer())
|
||||
ctx = runtime.NewServerMetadataContext(ctx, md)
|
||||
if err != nil {
|
||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
}
|
||||
|
||||
forward_Query_NextAuction_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
|
||||
|
||||
})
|
||||
|
||||
mux.Handle("GET", pattern_Query_Auction_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
|
||||
ctx, cancel := context.WithCancel(req.Context())
|
||||
defer cancel()
|
||||
var stream runtime.ServerTransportStream
|
||||
ctx = grpc.NewContextWithServerTransportStream(ctx, &stream)
|
||||
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
|
||||
rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req)
|
||||
if err != nil {
|
||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
}
|
||||
resp, md, err := local_request_Query_Auction_0(rctx, inboundMarshaler, server, req, pathParams)
|
||||
md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer())
|
||||
ctx = runtime.NewServerMetadataContext(ctx, md)
|
||||
if err != nil {
|
||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
}
|
||||
|
||||
forward_Query_Auction_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
|
||||
|
||||
})
|
||||
|
||||
mux.Handle("GET", pattern_Query_AuctionAll_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
|
||||
ctx, cancel := context.WithCancel(req.Context())
|
||||
defer cancel()
|
||||
var stream runtime.ServerTransportStream
|
||||
ctx = grpc.NewContextWithServerTransportStream(ctx, &stream)
|
||||
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
|
||||
rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req)
|
||||
if err != nil {
|
||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
}
|
||||
resp, md, err := local_request_Query_AuctionAll_0(rctx, inboundMarshaler, server, req, pathParams)
|
||||
md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer())
|
||||
ctx = runtime.NewServerMetadataContext(ctx, md)
|
||||
if err != nil {
|
||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
}
|
||||
|
||||
forward_Query_AuctionAll_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
|
||||
|
||||
})
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -141,13 +318,85 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie
|
||||
|
||||
})
|
||||
|
||||
mux.Handle("GET", pattern_Query_NextAuction_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
|
||||
ctx, cancel := context.WithCancel(req.Context())
|
||||
defer cancel()
|
||||
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
|
||||
rctx, err := runtime.AnnotateContext(ctx, mux, req)
|
||||
if err != nil {
|
||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
}
|
||||
resp, md, err := request_Query_NextAuction_0(rctx, inboundMarshaler, client, req, pathParams)
|
||||
ctx = runtime.NewServerMetadataContext(ctx, md)
|
||||
if err != nil {
|
||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
}
|
||||
|
||||
forward_Query_NextAuction_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
|
||||
|
||||
})
|
||||
|
||||
mux.Handle("GET", pattern_Query_Auction_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
|
||||
ctx, cancel := context.WithCancel(req.Context())
|
||||
defer cancel()
|
||||
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
|
||||
rctx, err := runtime.AnnotateContext(ctx, mux, req)
|
||||
if err != nil {
|
||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
}
|
||||
resp, md, err := request_Query_Auction_0(rctx, inboundMarshaler, client, req, pathParams)
|
||||
ctx = runtime.NewServerMetadataContext(ctx, md)
|
||||
if err != nil {
|
||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
}
|
||||
|
||||
forward_Query_Auction_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
|
||||
|
||||
})
|
||||
|
||||
mux.Handle("GET", pattern_Query_AuctionAll_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
|
||||
ctx, cancel := context.WithCancel(req.Context())
|
||||
defer cancel()
|
||||
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
|
||||
rctx, err := runtime.AnnotateContext(ctx, mux, req)
|
||||
if err != nil {
|
||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
}
|
||||
resp, md, err := request_Query_AuctionAll_0(rctx, inboundMarshaler, client, req, pathParams)
|
||||
ctx = runtime.NewServerMetadataContext(ctx, md)
|
||||
if err != nil {
|
||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
}
|
||||
|
||||
forward_Query_AuctionAll_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
|
||||
|
||||
})
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
var (
|
||||
pattern_Query_Params_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"cosmos-test", "cosmostest", "params"}, "", runtime.AssumeColonVerbOpt(true)))
|
||||
|
||||
pattern_Query_NextAuction_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"cosmos-test", "cosmostest", "next_auction"}, "", runtime.AssumeColonVerbOpt(true)))
|
||||
|
||||
pattern_Query_Auction_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 1, 5, 3}, []string{"cosmos-test", "cosmostest", "auction", "index"}, "", runtime.AssumeColonVerbOpt(true)))
|
||||
|
||||
pattern_Query_AuctionAll_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"cosmos-test", "cosmostest", "auction"}, "", runtime.AssumeColonVerbOpt(true)))
|
||||
)
|
||||
|
||||
var (
|
||||
forward_Query_Params_0 = runtime.ForwardResponseMessage
|
||||
|
||||
forward_Query_NextAuction_0 = runtime.ForwardResponseMessage
|
||||
|
||||
forward_Query_Auction_0 = runtime.ForwardResponseMessage
|
||||
|
||||
forward_Query_AuctionAll_0 = runtime.ForwardResponseMessage
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user