mirror of
https://github.com/colinear-labs/chain.git
synced 2026-03-06 23:34:25 -08:00
cosmostest -> colinear in dir structure
This commit is contained in:
13
x/colinear-core/auctionconfig/config.go
Normal file
13
x/colinear-core/auctionconfig/config.go
Normal file
@@ -0,0 +1,13 @@
|
||||
package auctionconfig
|
||||
|
||||
const (
|
||||
// Times
|
||||
AuctionTime = 10 // 10 blocks = ~10-30 seconds
|
||||
|
||||
// Lease Period Requirements (seconds)
|
||||
MinLeasePeriod = 3_600 // 1 hour
|
||||
MaxLeasePeriod = 8_035_200 // 3 months
|
||||
|
||||
// Gas Fees
|
||||
AuctionGas = 10
|
||||
)
|
||||
36
x/colinear-core/client/cli/query.go
Normal file
36
x/colinear-core/client/cli/query.go
Normal file
@@ -0,0 +1,36 @@
|
||||
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"
|
||||
|
||||
"colinear/x/colinear-core/types"
|
||||
)
|
||||
|
||||
// GetQueryCmd returns the cli query commands for this module
|
||||
func GetQueryCmd(queryRoute string) *cobra.Command {
|
||||
// Group colinear 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())
|
||||
cmd.AddCommand(CmdShowNextAuction())
|
||||
cmd.AddCommand(CmdListAuction())
|
||||
cmd.AddCommand(CmdShowAuction())
|
||||
cmd.AddCommand(CmdAuctionBids())
|
||||
|
||||
// this line is used by starport scaffolding # 1
|
||||
|
||||
return cmd
|
||||
}
|
||||
74
x/colinear-core/client/cli/query_auction.go
Normal file
74
x/colinear-core/client/cli/query_auction.go
Normal file
@@ -0,0 +1,74 @@
|
||||
package cli
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"colinear/x/colinear-core/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
|
||||
}
|
||||
47
x/colinear-core/client/cli/query_auction_bids.go
Normal file
47
x/colinear-core/client/cli/query_auction_bids.go
Normal file
@@ -0,0 +1,47 @@
|
||||
package cli
|
||||
|
||||
import (
|
||||
"strconv"
|
||||
|
||||
"colinear/x/colinear-core/types"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/client"
|
||||
"github.com/cosmos/cosmos-sdk/client/flags"
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
var _ = strconv.Itoa(0)
|
||||
|
||||
func CmdAuctionBids() *cobra.Command {
|
||||
cmd := &cobra.Command{
|
||||
Use: "auction-bids [index]",
|
||||
Short: "Query auctionBids",
|
||||
Args: cobra.ExactArgs(1),
|
||||
RunE: func(cmd *cobra.Command, args []string) (err error) {
|
||||
reqIndex := args[0]
|
||||
|
||||
clientCtx, err := client.GetClientTxContext(cmd)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
queryClient := types.NewQueryClient(clientCtx)
|
||||
|
||||
params := &types.QueryAuctionBidsRequest{
|
||||
|
||||
Index: reqIndex,
|
||||
}
|
||||
|
||||
res, err := queryClient.AuctionBids(cmd.Context(), params)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return clientCtx.PrintProto(res)
|
||||
},
|
||||
}
|
||||
|
||||
flags.AddQueryFlagsToCmd(cmd)
|
||||
|
||||
return cmd
|
||||
}
|
||||
161
x/colinear-core/client/cli/query_auction_test.go
Normal file
161
x/colinear-core/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"
|
||||
|
||||
"colinear/testutil/network"
|
||||
"colinear/testutil/nullify"
|
||||
"colinear/x/colinear-core/client/cli"
|
||||
"colinear/x/colinear-core/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),
|
||||
)
|
||||
})
|
||||
}
|
||||
37
x/colinear-core/client/cli/query_next_auction.go
Normal file
37
x/colinear-core/client/cli/query_next_auction.go
Normal file
@@ -0,0 +1,37 @@
|
||||
package cli
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"colinear/x/colinear-core/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/colinear-core/client/cli/query_next_auction_test.go
Normal file
72
x/colinear-core/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"
|
||||
|
||||
"colinear/testutil/network"
|
||||
"colinear/testutil/nullify"
|
||||
"colinear/x/colinear-core/client/cli"
|
||||
"colinear/x/colinear-core/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),
|
||||
)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
35
x/colinear-core/client/cli/query_params.go
Normal file
35
x/colinear-core/client/cli/query_params.go
Normal file
@@ -0,0 +1,35 @@
|
||||
package cli
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"colinear/x/colinear-core/types"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/client"
|
||||
"github.com/cosmos/cosmos-sdk/client/flags"
|
||||
"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
|
||||
}
|
||||
38
x/colinear-core/client/cli/tx.go
Normal file
38
x/colinear-core/client/cli/tx.go
Normal file
@@ -0,0 +1,38 @@
|
||||
package cli
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/client"
|
||||
// "github.com/cosmos/cosmos-sdk/client/flags"
|
||||
"colinear/x/colinear-core/types"
|
||||
)
|
||||
|
||||
var (
|
||||
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,
|
||||
}
|
||||
|
||||
cmd.AddCommand(CmdNewAuction())
|
||||
cmd.AddCommand(CmdNewBid())
|
||||
// this line is used by starport scaffolding # 1
|
||||
|
||||
return cmd
|
||||
}
|
||||
57
x/colinear-core/client/cli/tx_new_auction.go
Normal file
57
x/colinear-core/client/cli/tx_new_auction.go
Normal file
@@ -0,0 +1,57 @@
|
||||
package cli
|
||||
|
||||
import (
|
||||
"strconv"
|
||||
|
||||
"colinear/x/colinear-core/types"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/client"
|
||||
"github.com/cosmos/cosmos-sdk/client/flags"
|
||||
"github.com/cosmos/cosmos-sdk/client/tx"
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
var _ = strconv.Itoa(0)
|
||||
|
||||
func CmdNewAuction() *cobra.Command {
|
||||
cmd := &cobra.Command{
|
||||
Use: "new-auction [name] [description] [ceiling] [denom] [end date]",
|
||||
Short: "Broadcast message newAuction",
|
||||
Args: cobra.ExactArgs(5),
|
||||
RunE: func(cmd *cobra.Command, args []string) (err error) {
|
||||
argName := args[0]
|
||||
argDescription := args[1]
|
||||
argCeiling := args[2]
|
||||
argDenom := args[3]
|
||||
argLeaseEnd := args[4]
|
||||
|
||||
clientCtx, err := client.GetClientTxContext(cmd)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
var le int
|
||||
le, err = strconv.Atoi(argLeaseEnd)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
msg := types.NewMsgNewAuction(
|
||||
clientCtx.GetFromAddress().String(),
|
||||
argName,
|
||||
argDescription,
|
||||
argCeiling,
|
||||
argDenom,
|
||||
uint64(le),
|
||||
)
|
||||
if err := msg.ValidateBasic(); err != nil {
|
||||
return err
|
||||
}
|
||||
return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg)
|
||||
},
|
||||
}
|
||||
|
||||
flags.AddTxFlagsToCmd(cmd)
|
||||
|
||||
return cmd
|
||||
}
|
||||
45
x/colinear-core/client/cli/tx_new_bid.go
Normal file
45
x/colinear-core/client/cli/tx_new_bid.go
Normal file
@@ -0,0 +1,45 @@
|
||||
package cli
|
||||
|
||||
import (
|
||||
"strconv"
|
||||
|
||||
"colinear/x/colinear-core/types"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/client"
|
||||
"github.com/cosmos/cosmos-sdk/client/flags"
|
||||
"github.com/cosmos/cosmos-sdk/client/tx"
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
var _ = strconv.Itoa(0)
|
||||
|
||||
func CmdNewBid() *cobra.Command {
|
||||
cmd := &cobra.Command{
|
||||
Use: "new-bid [auction-index] [amount]",
|
||||
Short: "Broadcast message newBid",
|
||||
Args: cobra.ExactArgs(2),
|
||||
RunE: func(cmd *cobra.Command, args []string) (err error) {
|
||||
argAuctionIndex := args[0]
|
||||
argAmount := args[1]
|
||||
|
||||
clientCtx, err := client.GetClientTxContext(cmd)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
msg := types.NewMsgNewBid(
|
||||
clientCtx.GetFromAddress().String(),
|
||||
argAuctionIndex,
|
||||
argAmount,
|
||||
)
|
||||
if err := msg.ValidateBasic(); err != nil {
|
||||
return err
|
||||
}
|
||||
return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg)
|
||||
},
|
||||
}
|
||||
|
||||
flags.AddTxFlagsToCmd(cmd)
|
||||
|
||||
return cmd
|
||||
}
|
||||
39
x/colinear-core/genesis.go
Normal file
39
x/colinear-core/genesis.go
Normal file
@@ -0,0 +1,39 @@
|
||||
package colinearcore
|
||||
|
||||
import (
|
||||
"colinear/x/colinear-core/keeper"
|
||||
"colinear/x/colinear-core/types"
|
||||
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
)
|
||||
|
||||
// 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)
|
||||
}
|
||||
|
||||
// ExportGenesis returns the capability module's exported genesis.
|
||||
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
|
||||
}
|
||||
43
x/colinear-core/genesis_test.go
Normal file
43
x/colinear-core/genesis_test.go
Normal file
@@ -0,0 +1,43 @@
|
||||
package colinearcore_test
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
keepertest "colinear/testutil/keeper"
|
||||
"colinear/testutil/nullify"
|
||||
colinear "colinear/x/colinear-core"
|
||||
"colinear/x/colinear-core/types"
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
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
|
||||
}
|
||||
|
||||
k, ctx := keepertest.ColinearcoreKeeper(t)
|
||||
colinear.InitGenesis(ctx, *k, genesisState)
|
||||
got := colinear.ExportGenesis(ctx, *k)
|
||||
require.NotNil(t, got)
|
||||
|
||||
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
|
||||
}
|
||||
33
x/colinear-core/handler.go
Normal file
33
x/colinear-core/handler.go
Normal file
@@ -0,0 +1,33 @@
|
||||
package colinearcore
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"colinear/x/colinear-core/keeper"
|
||||
"colinear/x/colinear-core/types"
|
||||
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
|
||||
)
|
||||
|
||||
// NewHandler ...
|
||||
func NewHandler(k keeper.Keeper) sdk.Handler {
|
||||
msgServer := keeper.NewMsgServerImpl(k)
|
||||
|
||||
return func(ctx sdk.Context, msg sdk.Msg) (*sdk.Result, error) {
|
||||
ctx = ctx.WithEventManager(sdk.NewEventManager())
|
||||
|
||||
switch msg := msg.(type) {
|
||||
case *types.MsgNewAuction:
|
||||
res, err := msgServer.NewAuction(sdk.WrapSDKContext(ctx), msg)
|
||||
return sdk.WrapServiceResult(ctx, res, err)
|
||||
case *types.MsgNewBid:
|
||||
res, err := msgServer.NewBid(sdk.WrapSDKContext(ctx), msg)
|
||||
return sdk.WrapServiceResult(ctx, res, err)
|
||||
// this line is used by starport scaffolding # 1
|
||||
default:
|
||||
errMsg := fmt.Sprintf("unrecognized %s message type: %T", types.ModuleName, msg)
|
||||
return nil, sdkerrors.Wrap(sdkerrors.ErrUnknownRequest, errMsg)
|
||||
}
|
||||
}
|
||||
}
|
||||
64
x/colinear-core/keeper/auction.go
Normal file
64
x/colinear-core/keeper/auction.go
Normal file
@@ -0,0 +1,64 @@
|
||||
package keeper
|
||||
|
||||
import (
|
||||
"colinear/x/colinear-core/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
|
||||
}
|
||||
113
x/colinear-core/keeper/auction_state.go
Normal file
113
x/colinear-core/keeper/auction_state.go
Normal file
@@ -0,0 +1,113 @@
|
||||
package keeper
|
||||
|
||||
import (
|
||||
"colinear/x/colinear-core/math"
|
||||
"colinear/x/colinear-core/memdb"
|
||||
"colinear/x/colinear-core/types"
|
||||
"log"
|
||||
"math/big"
|
||||
"time"
|
||||
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
func (k Keeper) AuctionIsExpired(ctx sdk.Context, auctionId string) (bool, error) {
|
||||
auction, found := k.GetAuction(ctx, auctionId)
|
||||
|
||||
// make sure the auction exists on-chain
|
||||
if !found {
|
||||
return true, errors.Errorf("auction %s not found", auctionId)
|
||||
}
|
||||
|
||||
return uint64(ctx.BlockHeight()) >= auction.Deadline, nil
|
||||
}
|
||||
|
||||
func (k Keeper) FinalizeExpiredAuctions(ctx sdk.Context) {
|
||||
memdb.BidDB.ForEachAuction(func(auctionId string) error {
|
||||
auction, found := k.GetAuction(ctx, auctionId)
|
||||
// make sure the auction exists on-chain
|
||||
if !found {
|
||||
return errors.Errorf("auction %s not found", auctionId)
|
||||
}
|
||||
|
||||
if uint64(ctx.BlockHeight()) >= auction.Deadline {
|
||||
var err error
|
||||
auction.Best, err = memdb.BidDB.GetLowestBid(auctionId)
|
||||
if err != nil {
|
||||
return errors.Errorf("could not get highest bid for auction %s: %s", auctionId, err)
|
||||
}
|
||||
|
||||
// Remaining Unpaid: Full bid amount
|
||||
auction.Remaining = auction.Best.Amount
|
||||
|
||||
// clear auction
|
||||
if err := memdb.BidDB.ClearAuction(auctionId); err != nil {
|
||||
return errors.Errorf("failed to clear auction from memcache: %s", err)
|
||||
}
|
||||
|
||||
// pay out unpaid remainder to auction creator
|
||||
ceiling := new(big.Int)
|
||||
ceiling.SetString(auction.Ceiling, 10)
|
||||
lowestBidAmt := new(big.Int)
|
||||
lowestBidAmt.SetString(auction.Best.Amount, 10)
|
||||
// only pay out if there is a difference
|
||||
if ceiling.Cmp(lowestBidAmt) == 1 {
|
||||
amtRemaining := new(big.Int)
|
||||
amtRemaining.Sub(ceiling, lowestBidAmt)
|
||||
coins := sdk.NewCoins(sdk.NewCoin(
|
||||
auction.Denom,
|
||||
sdk.NewIntFromBigInt(amtRemaining),
|
||||
))
|
||||
recipAddr, err := sdk.AccAddressFromBech32(auction.Owner)
|
||||
if err != nil {
|
||||
return errors.Errorf("failed to parse address %s", auction.Owner)
|
||||
}
|
||||
if err := k.bank.SendCoinsFromModuleToAccount(ctx, types.ModuleName, recipAddr, coins); err != nil {
|
||||
log.Printf("Failed to send coins from module: %s\n", err)
|
||||
// log.Fatalf("Failed to send coins from module: %s\n", err)
|
||||
}
|
||||
}
|
||||
|
||||
// lease period starts now
|
||||
auction.LeaseStart = uint64(ctx.BlockTime().Unix())
|
||||
|
||||
// end auction
|
||||
k.SetAuction(ctx, auction)
|
||||
}
|
||||
|
||||
return nil
|
||||
})
|
||||
}
|
||||
|
||||
func (k *Keeper) PayAuctionAmountDue(ctx sdk.Context, auctionId string) error {
|
||||
auction, found := k.GetAuction(ctx, auctionId)
|
||||
if !found {
|
||||
return errors.Errorf("auction %s not found", auctionId)
|
||||
}
|
||||
|
||||
blockTime := ctx.BlockTime()
|
||||
deadline := time.Unix(int64(auction.Deadline), 0)
|
||||
|
||||
if blockTime.After(deadline) {
|
||||
return nil
|
||||
} else {
|
||||
amtTotal := new(big.Int)
|
||||
amtTotal.SetString(auction.Best.Amount, 10)
|
||||
amtRemaining := new(big.Int)
|
||||
amtTotal.SetString(auction.Remaining, 10)
|
||||
amt, err := math.CalcAmountVestableLinear(
|
||||
amtTotal,
|
||||
amtRemaining,
|
||||
ctx.BlockTime(),
|
||||
time.Unix(int64(auction.LeaseStart), 0),
|
||||
time.Unix(int64(auction.LeaseEnd), 0),
|
||||
)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
coins := sdk.NewCoins(sdk.NewCoin(auction.Denom, sdk.NewIntFromBigInt(amt)))
|
||||
err = k.bank.SendCoinsFromModuleToAccount(ctx, "colinear", sdk.AccAddress(auction.Best.Owner), coins)
|
||||
return err
|
||||
}
|
||||
}
|
||||
64
x/colinear-core/keeper/auction_test.go
Normal file
64
x/colinear-core/keeper/auction_test.go
Normal file
@@ -0,0 +1,64 @@
|
||||
package keeper_test
|
||||
|
||||
import (
|
||||
"strconv"
|
||||
"testing"
|
||||
|
||||
keepertest "colinear/testutil/keeper"
|
||||
"colinear/testutil/nullify"
|
||||
"colinear/x/colinear-core/keeper"
|
||||
"colinear/x/colinear-core/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.ColinearcoreKeeper(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.ColinearcoreKeeper(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.ColinearcoreKeeper(t)
|
||||
items := createNAuction(keeper, ctx, 10)
|
||||
require.ElementsMatch(t,
|
||||
nullify.Fill(items),
|
||||
nullify.Fill(keeper.GetAllAuction(ctx)),
|
||||
)
|
||||
}
|
||||
7
x/colinear-core/keeper/grpc_query.go
Normal file
7
x/colinear-core/keeper/grpc_query.go
Normal file
@@ -0,0 +1,7 @@
|
||||
package keeper
|
||||
|
||||
import (
|
||||
"colinear/x/colinear-core/types"
|
||||
)
|
||||
|
||||
var _ types.QueryServer = Keeper{}
|
||||
58
x/colinear-core/keeper/grpc_query_auction.go
Normal file
58
x/colinear-core/keeper/grpc_query_auction.go
Normal file
@@ -0,0 +1,58 @@
|
||||
package keeper
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"colinear/x/colinear-core/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
|
||||
}
|
||||
37
x/colinear-core/keeper/grpc_query_auction_bids.go
Normal file
37
x/colinear-core/keeper/grpc_query_auction_bids.go
Normal file
@@ -0,0 +1,37 @@
|
||||
package keeper
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
|
||||
"colinear/x/colinear-core/memdb"
|
||||
"colinear/x/colinear-core/types"
|
||||
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"google.golang.org/grpc/codes"
|
||||
"google.golang.org/grpc/status"
|
||||
)
|
||||
|
||||
func (k Keeper) AuctionBids(goCtx context.Context, req *types.QueryAuctionBidsRequest) (*types.QueryAuctionBidsResponse, error) {
|
||||
if req == nil {
|
||||
return nil, status.Error(codes.InvalidArgument, "invalid request")
|
||||
}
|
||||
|
||||
ctx := sdk.UnwrapSDKContext(goCtx)
|
||||
|
||||
auction, found := k.GetAuction(ctx, req.Index)
|
||||
if !found {
|
||||
return nil, fmt.Errorf("auction %s not found", req.Index)
|
||||
}
|
||||
|
||||
if uint64(ctx.BlockHeight()) >= auction.Deadline {
|
||||
return nil, fmt.Errorf("auction %s is already finalized", req.Index)
|
||||
}
|
||||
|
||||
bids, err := memdb.BidDB.GetBids(auction.Index)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to get bids for auction %s: %s", auction.Index, err)
|
||||
}
|
||||
|
||||
return &types.QueryAuctionBidsResponse{Bids: bids}, nil
|
||||
}
|
||||
126
x/colinear-core/keeper/grpc_query_auction_test.go
Normal file
126
x/colinear-core/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 "colinear/testutil/keeper"
|
||||
"colinear/testutil/nullify"
|
||||
"colinear/x/colinear-core/types"
|
||||
)
|
||||
|
||||
// Prevent strconv unused error
|
||||
var _ = strconv.IntSize
|
||||
|
||||
func TestAuctionQuerySingle(t *testing.T) {
|
||||
keeper, ctx := keepertest.ColinearcoreKeeper(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.ColinearcoreKeeper(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"))
|
||||
})
|
||||
}
|
||||
25
x/colinear-core/keeper/grpc_query_next_auction.go
Normal file
25
x/colinear-core/keeper/grpc_query_next_auction.go
Normal file
@@ -0,0 +1,25 @@
|
||||
package keeper
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"colinear/x/colinear-core/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/colinear-core/keeper/grpc_query_next_auction_test.go
Normal file
49
x/colinear-core/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 "colinear/testutil/keeper"
|
||||
"colinear/testutil/nullify"
|
||||
"colinear/x/colinear-core/types"
|
||||
)
|
||||
|
||||
func TestNextAuctionQuery(t *testing.T) {
|
||||
keeper, ctx := keepertest.ColinearcoreKeeper(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),
|
||||
)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
20
x/colinear-core/keeper/grpc_query_params.go
Normal file
20
x/colinear-core/keeper/grpc_query_params.go
Normal file
@@ -0,0 +1,20 @@
|
||||
package keeper
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"colinear/x/colinear-core/types"
|
||||
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"google.golang.org/grpc/codes"
|
||||
"google.golang.org/grpc/status"
|
||||
)
|
||||
|
||||
func (k Keeper) Params(c context.Context, req *types.QueryParamsRequest) (*types.QueryParamsResponse, error) {
|
||||
if req == nil {
|
||||
return nil, status.Error(codes.InvalidArgument, "invalid request")
|
||||
}
|
||||
ctx := sdk.UnwrapSDKContext(c)
|
||||
|
||||
return &types.QueryParamsResponse{Params: k.GetParams(ctx)}, nil
|
||||
}
|
||||
22
x/colinear-core/keeper/grpc_query_params_test.go
Normal file
22
x/colinear-core/keeper/grpc_query_params_test.go
Normal file
@@ -0,0 +1,22 @@
|
||||
package keeper_test
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
testkeeper "colinear/testutil/keeper"
|
||||
"colinear/x/colinear-core/types"
|
||||
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
func TestParamsQuery(t *testing.T) {
|
||||
keeper, ctx := testkeeper.ColinearcoreKeeper(t)
|
||||
wctx := sdk.WrapSDKContext(ctx)
|
||||
params := types.DefaultParams()
|
||||
keeper.SetParams(ctx, params)
|
||||
|
||||
response, err := keeper.Params(wctx, &types.QueryParamsRequest{})
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, &types.QueryParamsResponse{Params: params}, response)
|
||||
}
|
||||
48
x/colinear-core/keeper/keeper.go
Normal file
48
x/colinear-core/keeper/keeper.go
Normal file
@@ -0,0 +1,48 @@
|
||||
package keeper
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/tendermint/tendermint/libs/log"
|
||||
|
||||
"colinear/x/colinear-core/types"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/codec"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
paramtypes "github.com/cosmos/cosmos-sdk/x/params/types"
|
||||
)
|
||||
|
||||
type (
|
||||
Keeper struct {
|
||||
cdc codec.BinaryCodec
|
||||
storeKey sdk.StoreKey
|
||||
memKey sdk.StoreKey
|
||||
paramstore paramtypes.Subspace
|
||||
bank types.BankKeeper
|
||||
}
|
||||
)
|
||||
|
||||
func NewKeeper(
|
||||
cdc codec.BinaryCodec,
|
||||
storeKey,
|
||||
memKey sdk.StoreKey,
|
||||
ps paramtypes.Subspace,
|
||||
bank types.BankKeeper,
|
||||
) *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,
|
||||
bank: bank,
|
||||
}
|
||||
}
|
||||
|
||||
func (k Keeper) Logger(ctx sdk.Context) log.Logger {
|
||||
return ctx.Logger().With("module", fmt.Sprintf("x/%s", types.ModuleName))
|
||||
}
|
||||
49
x/colinear-core/keeper/keeper_integration_test.go.bak
Normal file
49
x/colinear-core/keeper/keeper_integration_test.go.bak
Normal file
@@ -0,0 +1,49 @@
|
||||
// Reference file.
|
||||
|
||||
package keeper
|
||||
|
||||
import (
|
||||
"colinear/x/colinear-core"
|
||||
"colinear/x/colinear-core/types"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/baseapp"
|
||||
"github.com/cosmos/cosmos-sdk/codec"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
|
||||
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
|
||||
"github.com/stretchr/testify/suite"
|
||||
tendermintTypes "github.com/tendermint/tendermint/proto/tendermint/types"
|
||||
)
|
||||
|
||||
// Integration Tests Tutorial:
|
||||
// https://tutorials.cosmos.network/academy/3-my-own-chain/game-wager.html#integration-tests
|
||||
|
||||
// Example integration test suite:
|
||||
// https://github.com/cosmos/cosmos-sdk/blob/9e1ec7b/x/bank/keeper/keeper_test.go#L66-L110
|
||||
|
||||
type IntegrationTestSuite struct {
|
||||
suite.Suite
|
||||
|
||||
app colinear.AppModule
|
||||
msgServer types.MsgServer
|
||||
ctx sdk.Context
|
||||
queryClient types.QueryClient
|
||||
}
|
||||
|
||||
func (suite *IntegrationTestSuite) SetupTest() {
|
||||
suite.app = colinear.AppModule{
|
||||
Keeper: NewKeeper(cdc)
|
||||
}
|
||||
suite.ctx = suite.app.NewContext(false, tendermintTypes.Header{Time: time.Now()})
|
||||
suite.app.AccountKeeper.SetParams(suite.ctx, authtypes.DefaultParams())
|
||||
suite.app.BankKeeper.SetParams(suite.ctx, banktypes.DefaultParams())
|
||||
queryHelper := baseapp.NewQueryServerTestHelper(suite.ctx, suite.app.InterfaceRegistry())
|
||||
types.RegisterQueryServer(queryHelper)
|
||||
suite.queryClient = types.NewQueryClient(queryHelper)
|
||||
}
|
||||
|
||||
func TestKeeperTestSuite(t *testing.T) {
|
||||
suite.Run(t, new(IntegrationTestSuite))
|
||||
}
|
||||
17
x/colinear-core/keeper/msg_server.go
Normal file
17
x/colinear-core/keeper/msg_server.go
Normal file
@@ -0,0 +1,17 @@
|
||||
package keeper
|
||||
|
||||
import (
|
||||
"colinear/x/colinear-core/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{}
|
||||
91
x/colinear-core/keeper/msg_server_new_auction.go
Normal file
91
x/colinear-core/keeper/msg_server_new_auction.go
Normal file
@@ -0,0 +1,91 @@
|
||||
package keeper
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"math/big"
|
||||
"strconv"
|
||||
|
||||
"colinear/x/colinear-core/auctionconfig"
|
||||
"colinear/x/colinear-core/types"
|
||||
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
)
|
||||
|
||||
func (k msgServer) NewAuction(goCtx context.Context, msg *types.MsgNewAuction) (*types.MsgNewAuctionResponse, error) {
|
||||
ctx := sdk.UnwrapSDKContext(goCtx)
|
||||
|
||||
next, found := k.Keeper.GetNextAuction(ctx)
|
||||
if !found {
|
||||
return nil, errors.New("unable to get next auction index")
|
||||
}
|
||||
index := strconv.FormatUint(next.AuctionId, 10)
|
||||
|
||||
auctionLen := msg.LeaseEnd - uint64(ctx.BlockTime().Unix())
|
||||
|
||||
if auctionLen < auctionconfig.MinLeasePeriod {
|
||||
return nil, fmt.Errorf(
|
||||
"Auction length %d is below min lease period of %d",
|
||||
auctionLen,
|
||||
auctionconfig.MinLeasePeriod,
|
||||
)
|
||||
}
|
||||
|
||||
if auctionLen > auctionconfig.MaxLeasePeriod {
|
||||
return nil, fmt.Errorf(
|
||||
"Auction length %d is above max lease period of %d",
|
||||
auctionLen,
|
||||
auctionconfig.MaxLeasePeriod,
|
||||
)
|
||||
}
|
||||
|
||||
auction := types.Auction{
|
||||
Index: index,
|
||||
Name: msg.Name,
|
||||
Description: msg.Description,
|
||||
// best bid -> null
|
||||
// Best: new(types.Bid),
|
||||
Deadline: uint64(ctx.BlockHeight()) + auctionconfig.AuctionTime,
|
||||
Denom: msg.Denom,
|
||||
Owner: msg.Creator,
|
||||
Ceiling: msg.Ceiling,
|
||||
// lease start -> null
|
||||
// instead, initialize when auction is finalized
|
||||
// LeaseStart: uint64(ctx.BlockTime().Unix()),
|
||||
LeaseEnd: msg.LeaseEnd,
|
||||
// remaining payout -> null
|
||||
// Remaining: "0",
|
||||
}
|
||||
|
||||
senderAddr, err := sdk.AccAddressFromBech32(msg.Creator)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("sender address `%s` format invalid (bech32 required)", msg.Creator)
|
||||
}
|
||||
|
||||
spendable := k.bank.SpendableCoins(ctx, senderAddr)
|
||||
// if balance does not exceed or equal proposed auction ceiling...
|
||||
ceiling := new(big.Int)
|
||||
ceiling.SetString(auction.Ceiling, 10)
|
||||
if spendable.AmountOf(auction.Denom).BigInt().Cmp(ceiling) == -1 {
|
||||
return nil, fmt.Errorf("not enough balance to set ceiling %s%s", msg.Ceiling, auction.Denom)
|
||||
}
|
||||
|
||||
coins := sdk.NewCoins(sdk.Coin{
|
||||
Amount: sdk.NewIntFromBigInt(ceiling),
|
||||
Denom: auction.Denom,
|
||||
})
|
||||
|
||||
if err := k.Keeper.bank.SendCoinsFromAccountToModule(ctx, senderAddr, types.ModuleName, coins); err != nil {
|
||||
return nil, fmt.Errorf("failed to transfer %s%s", auction.Ceiling, auction.Denom)
|
||||
}
|
||||
|
||||
k.Keeper.SetAuction(ctx, auction)
|
||||
next.AuctionId++
|
||||
|
||||
k.Keeper.SetNextAuction(ctx, types.NextAuction{AuctionId: next.AuctionId})
|
||||
|
||||
return &types.MsgNewAuctionResponse{
|
||||
AuctionId: strconv.FormatUint(next.AuctionId, 10),
|
||||
}, nil
|
||||
}
|
||||
78
x/colinear-core/keeper/msg_server_new_bid.go
Normal file
78
x/colinear-core/keeper/msg_server_new_bid.go
Normal file
@@ -0,0 +1,78 @@
|
||||
package keeper
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"math/big"
|
||||
"reflect"
|
||||
|
||||
"colinear/x/colinear-core/memdb"
|
||||
"colinear/x/colinear-core/types"
|
||||
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
)
|
||||
|
||||
func (k msgServer) NewBid(goCtx context.Context, msg *types.MsgNewBid) (*types.MsgNewBidResponse, error) {
|
||||
ctx := sdk.UnwrapSDKContext(goCtx)
|
||||
|
||||
auction, found := k.Keeper.GetAuction(ctx, msg.AuctionIndex)
|
||||
if !found {
|
||||
return nil, fmt.Errorf("didn't find auction of index %s", msg.AuctionIndex)
|
||||
}
|
||||
|
||||
auctionExpired, err := k.Keeper.AuctionIsExpired(ctx, msg.AuctionIndex)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("error while checking auction %s expiry status: %s", msg.AuctionIndex, err)
|
||||
}
|
||||
if auctionExpired {
|
||||
return nil, fmt.Errorf("auction %s is expired", msg.AuctionIndex)
|
||||
}
|
||||
|
||||
ok := false
|
||||
amt := new(big.Int)
|
||||
amt, ok = amt.SetString(msg.Amount, 10)
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("failed to convert `%s` to a large integer", msg.Amount)
|
||||
}
|
||||
if amt.Sign() != 1 {
|
||||
return nil, fmt.Errorf("bid amount must be greater than 0")
|
||||
}
|
||||
|
||||
ceiling := new(big.Int)
|
||||
ceiling.SetString(auction.Ceiling, 10)
|
||||
if amt.Cmp(ceiling) == 1 {
|
||||
return nil, fmt.Errorf("bid amount cannot be greater than auction price ceiling (%s)", auction.Ceiling)
|
||||
}
|
||||
|
||||
lowestBid, err := memdb.BidDB.GetLowestBid(msg.AuctionIndex)
|
||||
// we manually handle KeyNotFound in GetHighestBid, so should return (nil, nil) if not found
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to get lowest bid: %s", reflect.TypeOf(err))
|
||||
}
|
||||
|
||||
if lowestBid != nil {
|
||||
amtPrev := new(big.Int)
|
||||
amtPrev, ok = amtPrev.SetString(lowestBid.Amount, 10)
|
||||
if !ok { // this should have been checked before, but whatever
|
||||
return nil, fmt.Errorf("failed to convert max bid (%s) to a large integer", msg.Amount)
|
||||
}
|
||||
|
||||
if amt.Cmp(amtPrev) != -1 {
|
||||
return nil, fmt.Errorf("bid amount must be less than current lowest bid (%s)", amtPrev)
|
||||
}
|
||||
}
|
||||
|
||||
bid := &types.Bid{
|
||||
Amount: msg.Amount,
|
||||
Owner: msg.Creator,
|
||||
}
|
||||
|
||||
if err := memdb.BidDB.AddBid(msg.AuctionIndex, bid); err != nil {
|
||||
return nil, fmt.Errorf("failed to add bid: %s", err)
|
||||
}
|
||||
|
||||
// auction.Bids = append(auction.Bids, bid)
|
||||
// k.Keeper.SetAuction(ctx, auction)
|
||||
|
||||
return &types.MsgNewBidResponse{}, nil
|
||||
}
|
||||
17
x/colinear-core/keeper/msg_server_test.go
Normal file
17
x/colinear-core/keeper/msg_server_test.go
Normal file
@@ -0,0 +1,17 @@
|
||||
package keeper_test
|
||||
|
||||
import (
|
||||
"context"
|
||||
"testing"
|
||||
|
||||
keepertest "colinear/testutil/keeper"
|
||||
"colinear/x/colinear-core/keeper"
|
||||
"colinear/x/colinear-core/types"
|
||||
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
)
|
||||
|
||||
func setupMsgServer(t testing.TB) (types.MsgServer, context.Context) {
|
||||
k, ctx := keepertest.ColinearcoreKeeper(t)
|
||||
return keeper.NewMsgServerImpl(*k), sdk.WrapSDKContext(ctx)
|
||||
}
|
||||
34
x/colinear-core/keeper/next_auction.go
Normal file
34
x/colinear-core/keeper/next_auction.go
Normal file
@@ -0,0 +1,34 @@
|
||||
package keeper
|
||||
|
||||
import (
|
||||
"colinear/x/colinear-core/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/colinear-core/keeper/next_auction_test.go
Normal file
38
x/colinear-core/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 "colinear/testutil/keeper"
|
||||
"colinear/testutil/nullify"
|
||||
"colinear/x/colinear-core/keeper"
|
||||
"colinear/x/colinear-core/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.ColinearcoreKeeper(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.ColinearcoreKeeper(t)
|
||||
createTestNextAuction(keeper, ctx)
|
||||
keeper.RemoveNextAuction(ctx)
|
||||
_, found := keeper.GetNextAuction(ctx)
|
||||
require.False(t, found)
|
||||
}
|
||||
17
x/colinear-core/keeper/params.go
Normal file
17
x/colinear-core/keeper/params.go
Normal file
@@ -0,0 +1,17 @@
|
||||
package keeper
|
||||
|
||||
import (
|
||||
"colinear/x/colinear-core/types"
|
||||
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
)
|
||||
|
||||
// GetParams get all parameters as types.Params
|
||||
func (k Keeper) GetParams(ctx 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)
|
||||
}
|
||||
19
x/colinear-core/keeper/params_test.go
Normal file
19
x/colinear-core/keeper/params_test.go
Normal file
@@ -0,0 +1,19 @@
|
||||
package keeper_test
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
testkeeper "colinear/testutil/keeper"
|
||||
"colinear/x/colinear-core/types"
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
func TestGetParams(t *testing.T) {
|
||||
k, ctx := testkeeper.ColinearcoreKeeper(t)
|
||||
params := types.DefaultParams()
|
||||
|
||||
k.SetParams(ctx, params)
|
||||
|
||||
require.EqualValues(t, params, k.GetParams(ctx))
|
||||
}
|
||||
47
x/colinear-core/math/vesting.go
Normal file
47
x/colinear-core/math/vesting.go
Normal file
@@ -0,0 +1,47 @@
|
||||
package math
|
||||
|
||||
import (
|
||||
"math/big"
|
||||
"time"
|
||||
)
|
||||
|
||||
// Calculate amount due to provider assuming linear payout schedule.
|
||||
//
|
||||
// Does NOT account for anything out-of-bounds. This must be checked beforehand.
|
||||
func CalcAmountVestableLinear(
|
||||
total *big.Int,
|
||||
remaining *big.Int,
|
||||
date time.Time,
|
||||
beginDate time.Time,
|
||||
endDate time.Time,
|
||||
) (*big.Int, error) {
|
||||
timePassed := big.NewInt(date.Unix() - beginDate.Unix())
|
||||
totalTime := big.NewInt(endDate.Unix() - beginDate.Unix())
|
||||
|
||||
taken := big.NewInt(0)
|
||||
taken.Sub(total, remaining)
|
||||
|
||||
out := big.NewInt(0)
|
||||
out.Mul(total, timePassed)
|
||||
out.Div(out, totalTime)
|
||||
out.Sub(out, taken)
|
||||
|
||||
return out, nil
|
||||
}
|
||||
|
||||
// No longer using exponential - use linear distribution schedule
|
||||
// because exponential rewards are a weak incentive for providers
|
||||
|
||||
// func CalcAmountVestableExponential(
|
||||
// ctx sdk.Context,
|
||||
// total big.Int,
|
||||
// remaining big.Int,
|
||||
// date time.Time,
|
||||
// beginDate time.Time,
|
||||
// endDate time.Time,
|
||||
// ) big.Int {
|
||||
// timescale := big.NewInt(endDate.Unix() - beginDate.Unix())
|
||||
// timePassed := big.NewInt(date.Unix() - beginDate.Unix())
|
||||
// expTerm := big.NewInt(1)
|
||||
// expTerm.Exp(big.NewInt(2), timePassed, big.NewInt(1))
|
||||
// }
|
||||
115
x/colinear-core/math/vesting_test.go
Normal file
115
x/colinear-core/math/vesting_test.go
Normal file
@@ -0,0 +1,115 @@
|
||||
package math
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"math/big"
|
||||
"testing"
|
||||
"time"
|
||||
)
|
||||
|
||||
func TestLinearVesting(t *testing.T) {
|
||||
|
||||
// Total: 1000 tokens
|
||||
// Time: halfway through
|
||||
// Claimed: 0
|
||||
// Expected: 500
|
||||
if res, err := CalcAmountVestableLinear(
|
||||
big.NewInt(1000),
|
||||
big.NewInt(1000),
|
||||
time.Now(),
|
||||
time.Unix(time.Now().Unix()-1000, 0),
|
||||
time.Unix(time.Now().Unix()+1000, 0),
|
||||
); err != nil {
|
||||
panic(err)
|
||||
} else {
|
||||
expectEq(res, 500)
|
||||
}
|
||||
|
||||
// Total: 1000 tokens
|
||||
// Time: beginning through
|
||||
// Claimed: 0
|
||||
// Expected: 0
|
||||
if res, err := CalcAmountVestableLinear(
|
||||
big.NewInt(1000),
|
||||
big.NewInt(1000),
|
||||
time.Now(),
|
||||
time.Now(),
|
||||
time.Unix(time.Now().Unix()+1000, 0),
|
||||
); err != nil {
|
||||
panic(err)
|
||||
} else {
|
||||
expectEq(res, 0)
|
||||
}
|
||||
|
||||
// Total: 1000 tokens
|
||||
// Time: end
|
||||
// Claimed: 0
|
||||
// Expected: 1000
|
||||
if res, err := CalcAmountVestableLinear(
|
||||
big.NewInt(1000),
|
||||
big.NewInt(1000),
|
||||
time.Now(),
|
||||
time.Unix(time.Now().Unix()-1000, 0),
|
||||
time.Now(),
|
||||
); err != nil {
|
||||
panic(err)
|
||||
} else {
|
||||
expectEq(res, 1000)
|
||||
}
|
||||
|
||||
// Total: 1000 tokens
|
||||
// Time: end
|
||||
// Claimed: 1000
|
||||
// Expected: 1000
|
||||
if res, err := CalcAmountVestableLinear(
|
||||
big.NewInt(1000),
|
||||
big.NewInt(0),
|
||||
time.Now(),
|
||||
time.Unix(time.Now().Unix()-1000, 0),
|
||||
time.Now(),
|
||||
); err != nil {
|
||||
panic(err)
|
||||
} else {
|
||||
expectEq(res, 0)
|
||||
}
|
||||
|
||||
// Total: 1000 tokens
|
||||
// Time: 33%
|
||||
// Claimed: 250 (25%)
|
||||
// Expected: 333-250 = 83
|
||||
if res, err := CalcAmountVestableLinear(
|
||||
big.NewInt(1000),
|
||||
big.NewInt(750),
|
||||
time.Now(),
|
||||
time.Unix(time.Now().Unix()-1000, 0),
|
||||
time.Unix(time.Now().Unix()+2000, 0),
|
||||
); err != nil {
|
||||
panic(err)
|
||||
} else {
|
||||
expectEq(res, 83)
|
||||
}
|
||||
|
||||
// Total: 1000 tokens
|
||||
// Time: 66%
|
||||
// Claimed: 250 (25%)
|
||||
// Expected: 666-250 = 416
|
||||
if res, err := CalcAmountVestableLinear(
|
||||
big.NewInt(1000),
|
||||
big.NewInt(750),
|
||||
time.Now(),
|
||||
time.Unix(time.Now().Unix()-2000, 0),
|
||||
time.Unix(time.Now().Unix()+1000, 0),
|
||||
); err != nil {
|
||||
panic(err)
|
||||
} else {
|
||||
expectEq(res, 416)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func expectEq(a *big.Int, b int) {
|
||||
a2 := int(a.Uint64())
|
||||
if a2 != b {
|
||||
panic(fmt.Sprintf("expected %d, got %d", b, a2))
|
||||
}
|
||||
}
|
||||
18
x/colinear-core/memdb/README.md
Normal file
18
x/colinear-core/memdb/README.md
Normal file
@@ -0,0 +1,18 @@
|
||||
# MemDB
|
||||
|
||||
## Bidding Flow
|
||||
|
||||
```mermaid
|
||||
flowchart
|
||||
|
||||
s[Submit Bid] --> rdb{{Read MemBids}} --> h{Is Highest Bid?}
|
||||
|
||||
h -- Yes --> m{{Add to MemBids}}
|
||||
h -- No --> re1[[Error]]
|
||||
|
||||
m -- Every Block --> ae{Auction expired?}
|
||||
ae -- Yes --> fh{{Find Highest Bid}}
|
||||
ae -- No --> ca{{Check again}} -- Next block --> ae
|
||||
|
||||
fh -- Settle --> scs[(Chain State)]
|
||||
```
|
||||
176
x/colinear-core/memdb/biddb.go
Normal file
176
x/colinear-core/memdb/biddb.go
Normal file
@@ -0,0 +1,176 @@
|
||||
package memdb
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"colinear/x/colinear-core/types"
|
||||
"encoding/gob"
|
||||
"errors"
|
||||
"log"
|
||||
"math/big"
|
||||
|
||||
badger "github.com/dgraph-io/badger/v3"
|
||||
)
|
||||
|
||||
type bidDB struct {
|
||||
db *badger.DB
|
||||
}
|
||||
|
||||
var BidDB bidDB
|
||||
|
||||
// Mount Db & initialize encoder/decoder
|
||||
func (b *bidDB) Mount() {
|
||||
db, err := badger.Open(badger.DefaultOptions("").WithInMemory(true))
|
||||
if err != nil {
|
||||
// must force crash here, since db is absolutely required
|
||||
log.Fatalf("Failed to mount in-memory db: %s", err)
|
||||
}
|
||||
b.db = db
|
||||
|
||||
// initialize encode/decode stuff
|
||||
gob.Register([]types.Bid{})
|
||||
}
|
||||
|
||||
// Add a bid to the bid list under specified auction key.
|
||||
func (b *bidDB) AddBid(auctionId string, bid *types.Bid) error {
|
||||
k := []byte(auctionId)
|
||||
|
||||
err := b.db.Update(func(txn *badger.Txn) error {
|
||||
var bids []*types.Bid
|
||||
bidsOld, err := txn.Get(k)
|
||||
if errors.Is(err, badger.ErrKeyNotFound) {
|
||||
// key not found -> just create a new Bid array
|
||||
bids = []*types.Bid{}
|
||||
} else {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
// key found -> decode contents to bids
|
||||
bidsOld.Value(func(val []byte) error {
|
||||
dec := gob.NewDecoder(bytes.NewReader(val))
|
||||
if err := dec.Decode(&bids); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
})
|
||||
}
|
||||
|
||||
// append bid
|
||||
bids = append(bids, bid)
|
||||
// encode new list
|
||||
buf := bytes.NewBuffer(nil)
|
||||
enc := gob.NewEncoder(buf)
|
||||
if err := enc.Encode(&bids); err != nil {
|
||||
return err
|
||||
}
|
||||
// set under auction key in db
|
||||
if err := txn.Set(k, buf.Bytes()); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
})
|
||||
|
||||
return err
|
||||
}
|
||||
|
||||
// Get the highest bid in the list under specified auction key.
|
||||
func (b *bidDB) GetLowestBid(auctionId string) (*types.Bid, error) {
|
||||
k := []byte(auctionId)
|
||||
|
||||
var bid *types.Bid
|
||||
|
||||
err := b.db.View(func(txn *badger.Txn) error {
|
||||
bidData, err := txn.Get(k)
|
||||
if err != nil {
|
||||
if !errors.Is(err, badger.ErrKeyNotFound) {
|
||||
return err
|
||||
} else {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
err = bidData.Value(func(val []byte) error {
|
||||
var bids []*types.Bid
|
||||
dec := gob.NewDecoder(bytes.NewReader(val))
|
||||
if err := dec.Decode(&bids); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if bids == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
minAmt := big.NewInt(0)
|
||||
refAmt := big.NewInt(0)
|
||||
for _, currBid := range bids {
|
||||
if bid == nil {
|
||||
bid = currBid
|
||||
minAmt.SetString(currBid.Amount, 10)
|
||||
} else {
|
||||
// set ref amt.
|
||||
refAmt.SetString(currBid.Amount, 10)
|
||||
// if ref amt is less, then we have a new min
|
||||
if refAmt.Cmp(minAmt) == -1 {
|
||||
bid = currBid
|
||||
}
|
||||
}
|
||||
}
|
||||
return nil
|
||||
})
|
||||
|
||||
return err
|
||||
})
|
||||
|
||||
return bid, err
|
||||
}
|
||||
|
||||
func (b *bidDB) GetBids(auctionId string) ([]*types.Bid, error) {
|
||||
k := []byte(auctionId)
|
||||
|
||||
var bids []*types.Bid
|
||||
err := b.db.View(func(txn *badger.Txn) error {
|
||||
res, err := txn.Get(k)
|
||||
if err != nil {
|
||||
return err
|
||||
} else {
|
||||
err := res.Value(func(val []byte) error {
|
||||
dec := gob.NewDecoder(bytes.NewReader(val))
|
||||
err := dec.Decode(&bids)
|
||||
return err
|
||||
})
|
||||
return err
|
||||
}
|
||||
})
|
||||
|
||||
return bids, err
|
||||
}
|
||||
|
||||
func (b *bidDB) ClearAuction(auctionId string) error {
|
||||
k := []byte(auctionId)
|
||||
|
||||
err := b.db.Update(func(txn *badger.Txn) error {
|
||||
return txn.Delete(k)
|
||||
})
|
||||
|
||||
return err
|
||||
}
|
||||
|
||||
// Iterate over all auction keys in memory. VIEW-ONLY.
|
||||
func (b *bidDB) ForEachAuction(viewFunc func(string) error) error {
|
||||
err := b.db.View(func(txn *badger.Txn) error {
|
||||
opts := badger.DefaultIteratorOptions
|
||||
// can customize options down here if we want
|
||||
iter := txn.NewIterator(opts)
|
||||
defer iter.Close()
|
||||
for iter.Rewind(); iter.Valid(); iter.Next() {
|
||||
item := iter.Item()
|
||||
key := string(item.Key())
|
||||
err := viewFunc(key)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
})
|
||||
return err
|
||||
}
|
||||
60
x/colinear-core/memdb/biddb_test.go
Normal file
60
x/colinear-core/memdb/biddb_test.go
Normal file
@@ -0,0 +1,60 @@
|
||||
package memdb
|
||||
|
||||
import (
|
||||
"colinear/x/colinear-core/types"
|
||||
"fmt"
|
||||
"testing"
|
||||
|
||||
"github.com/dgraph-io/badger/v3"
|
||||
)
|
||||
|
||||
func TestBasicFlow(t *testing.T) {
|
||||
// this should panic if there's a problem
|
||||
BidDB.Mount()
|
||||
|
||||
// add a bid
|
||||
if err := BidDB.AddBid("0", &types.Bid{Owner: "cosmos123", Amount: "100"}); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
// add a higher bid (db funcs won't check amount, though)
|
||||
if err := BidDB.AddBid("0", &types.Bid{Owner: "cosmos456", Amount: "200"}); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
// get all bids out
|
||||
if bids, err := BidDB.GetBids("0"); err != nil {
|
||||
panic(err)
|
||||
} else {
|
||||
if bids == nil {
|
||||
panic("GetBids(0) should should not return nil")
|
||||
}
|
||||
if len(bids) != 2 {
|
||||
panic(fmt.Sprintf("Length of GetBids(0) should be 2, instead got %d", len(bids)))
|
||||
}
|
||||
}
|
||||
|
||||
// check lowest bid
|
||||
if bid, err := BidDB.GetLowestBid("0"); err != nil {
|
||||
panic(err)
|
||||
} else {
|
||||
if bid.Owner != "cosmos123" || bid.Amount != "100" {
|
||||
panic(fmt.Sprintf("Lowest auction item not selected. Amount %s with owner %s was chosen.", bid.Amount, bid.Owner))
|
||||
}
|
||||
}
|
||||
|
||||
// clear auction under id 0
|
||||
if err := BidDB.ClearAuction("0"); err != nil {
|
||||
panic(err)
|
||||
} else {
|
||||
// expect auction key to be unknown
|
||||
if err := BidDB.db.View(func(txn *badger.Txn) error {
|
||||
_, err := txn.Get([]byte("0"))
|
||||
return err
|
||||
}); err != nil {
|
||||
if err != badger.ErrKeyNotFound {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
184
x/colinear-core/module.go
Normal file
184
x/colinear-core/module.go
Normal file
@@ -0,0 +1,184 @@
|
||||
package colinearcore
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
|
||||
"github.com/gorilla/mux"
|
||||
"github.com/grpc-ecosystem/grpc-gateway/runtime"
|
||||
"github.com/spf13/cobra"
|
||||
|
||||
abci "github.com/tendermint/tendermint/abci/types"
|
||||
|
||||
"colinear/x/colinear-core/client/cli"
|
||||
"colinear/x/colinear-core/keeper"
|
||||
"colinear/x/colinear-core/memdb"
|
||||
"colinear/x/colinear-core/types"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/client"
|
||||
"github.com/cosmos/cosmos-sdk/codec"
|
||||
cdctypes "github.com/cosmos/cosmos-sdk/codec/types"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/cosmos/cosmos-sdk/types/module"
|
||||
)
|
||||
|
||||
var (
|
||||
_ module.AppModule = AppModule{}
|
||||
_ module.AppModuleBasic = AppModuleBasic{}
|
||||
)
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// AppModuleBasic
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
// AppModuleBasic implements the AppModuleBasic interface for the capability module.
|
||||
type AppModuleBasic struct {
|
||||
cdc codec.BinaryCodec
|
||||
}
|
||||
|
||||
func NewAppModuleBasic(cdc codec.BinaryCodec) AppModuleBasic {
|
||||
return AppModuleBasic{cdc: cdc}
|
||||
}
|
||||
|
||||
// Name returns the capability module's name.
|
||||
func (AppModuleBasic) Name() string {
|
||||
return types.ModuleName
|
||||
}
|
||||
|
||||
func (AppModuleBasic) RegisterCodec(cdc *codec.LegacyAmino) {
|
||||
types.RegisterCodec(cdc)
|
||||
}
|
||||
|
||||
func (AppModuleBasic) RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) {
|
||||
types.RegisterCodec(cdc)
|
||||
}
|
||||
|
||||
// RegisterInterfaces registers the module's interface types
|
||||
func (a AppModuleBasic) RegisterInterfaces(reg cdctypes.InterfaceRegistry) {
|
||||
types.RegisterInterfaces(reg)
|
||||
}
|
||||
|
||||
// DefaultGenesis returns the capability module's default genesis state.
|
||||
func (AppModuleBasic) DefaultGenesis(cdc codec.JSONCodec) json.RawMessage {
|
||||
return cdc.MustMarshalJSON(types.DefaultGenesis())
|
||||
}
|
||||
|
||||
// ValidateGenesis performs genesis state validation for the capability module.
|
||||
func (AppModuleBasic) ValidateGenesis(cdc codec.JSONCodec, config client.TxEncodingConfig, bz json.RawMessage) error {
|
||||
var genState types.GenesisState
|
||||
if err := cdc.UnmarshalJSON(bz, &genState); err != nil {
|
||||
return fmt.Errorf("failed to unmarshal %s genesis state: %w", types.ModuleName, err)
|
||||
}
|
||||
return genState.Validate()
|
||||
}
|
||||
|
||||
// RegisterRESTRoutes registers the capability module's REST service handlers.
|
||||
func (AppModuleBasic) RegisterRESTRoutes(clientCtx client.Context, rtr *mux.Router) {
|
||||
}
|
||||
|
||||
// RegisterGRPCGatewayRoutes registers the gRPC Gateway routes for the module.
|
||||
func (AppModuleBasic) RegisterGRPCGatewayRoutes(clientCtx client.Context, mux *runtime.ServeMux) {
|
||||
types.RegisterQueryHandlerClient(context.Background(), mux, types.NewQueryClient(clientCtx))
|
||||
}
|
||||
|
||||
// GetTxCmd returns the capability module's root tx command.
|
||||
func (a AppModuleBasic) GetTxCmd() *cobra.Command {
|
||||
return cli.GetTxCmd()
|
||||
}
|
||||
|
||||
// GetQueryCmd returns the capability module's root query command.
|
||||
func (AppModuleBasic) GetQueryCmd() *cobra.Command {
|
||||
return cli.GetQueryCmd(types.StoreKey)
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// AppModule
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
// AppModule implements the AppModule interface for the capability module.
|
||||
type AppModule struct {
|
||||
AppModuleBasic
|
||||
|
||||
keeper keeper.Keeper
|
||||
accountKeeper types.AccountKeeper
|
||||
bankKeeper types.BankKeeper
|
||||
}
|
||||
|
||||
func NewAppModule(
|
||||
cdc codec.Codec,
|
||||
keeper keeper.Keeper,
|
||||
accountKeeper types.AccountKeeper,
|
||||
bankKeeper types.BankKeeper,
|
||||
) AppModule {
|
||||
|
||||
// initialize in-memory database
|
||||
memdb.BidDB.Mount()
|
||||
|
||||
return AppModule{
|
||||
AppModuleBasic: NewAppModuleBasic(cdc),
|
||||
keeper: keeper,
|
||||
accountKeeper: accountKeeper,
|
||||
bankKeeper: bankKeeper,
|
||||
}
|
||||
}
|
||||
|
||||
// Name returns the capability module's name.
|
||||
func (am AppModule) Name() string {
|
||||
return am.AppModuleBasic.Name()
|
||||
}
|
||||
|
||||
// Route returns the capability module's message routing key.
|
||||
func (am AppModule) Route() sdk.Route {
|
||||
return sdk.NewRoute(types.RouterKey, NewHandler(am.keeper))
|
||||
}
|
||||
|
||||
// QuerierRoute returns the capability module's query routing key.
|
||||
func (AppModule) QuerierRoute() string { return types.QuerierRoute }
|
||||
|
||||
// LegacyQuerierHandler returns the capability module's Querier.
|
||||
func (am AppModule) LegacyQuerierHandler(legacyQuerierCdc *codec.LegacyAmino) sdk.Querier {
|
||||
return nil
|
||||
}
|
||||
|
||||
// RegisterServices registers a GRPC query service to respond to the
|
||||
// module-specific GRPC queries.
|
||||
func (am AppModule) RegisterServices(cfg module.Configurator) {
|
||||
types.RegisterQueryServer(cfg.QueryServer(), am.keeper)
|
||||
}
|
||||
|
||||
// RegisterInvariants registers the capability module's invariants.
|
||||
func (am AppModule) RegisterInvariants(_ sdk.InvariantRegistry) {}
|
||||
|
||||
// InitGenesis performs the capability module's genesis initialization It returns
|
||||
// no validator updates.
|
||||
func (am AppModule) InitGenesis(ctx sdk.Context, cdc codec.JSONCodec, gs json.RawMessage) []abci.ValidatorUpdate {
|
||||
var genState types.GenesisState
|
||||
// Initialize global index to index in genesis state
|
||||
cdc.MustUnmarshalJSON(gs, &genState)
|
||||
|
||||
InitGenesis(ctx, am.keeper, genState)
|
||||
|
||||
return []abci.ValidatorUpdate{}
|
||||
}
|
||||
|
||||
// ExportGenesis returns the capability module's exported genesis state as raw JSON bytes.
|
||||
func (am AppModule) ExportGenesis(ctx sdk.Context, cdc codec.JSONCodec) json.RawMessage {
|
||||
genState := ExportGenesis(ctx, am.keeper)
|
||||
return cdc.MustMarshalJSON(genState)
|
||||
}
|
||||
|
||||
// ConsensusVersion implements ConsensusVersion.
|
||||
func (AppModule) ConsensusVersion() uint64 { return 2 }
|
||||
|
||||
// BeginBlock executes all ABCI BeginBlock logic respective to the capability module.
|
||||
func (am AppModule) BeginBlock(_ sdk.Context, _ abci.RequestBeginBlock) {}
|
||||
|
||||
// EndBlock executes all ABCI EndBlock logic respective to the capability module. It
|
||||
// returns no validator updates.
|
||||
func (am AppModule) EndBlock(ctx sdk.Context, _ abci.RequestEndBlock) []abci.ValidatorUpdate {
|
||||
|
||||
am.keeper.FinalizeExpiredAuctions(ctx)
|
||||
|
||||
return []abci.ValidatorUpdate{}
|
||||
}
|
||||
95
x/colinear-core/module_simulation.go
Normal file
95
x/colinear-core/module_simulation.go
Normal file
@@ -0,0 +1,95 @@
|
||||
package colinearcore
|
||||
|
||||
import (
|
||||
"math/rand"
|
||||
|
||||
"colinear/testutil/sample"
|
||||
colinearsimulation "colinear/x/colinear-core/simulation"
|
||||
"colinear/x/colinear-core/types"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/baseapp"
|
||||
simappparams "github.com/cosmos/cosmos-sdk/simapp/params"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/cosmos/cosmos-sdk/types/module"
|
||||
simtypes "github.com/cosmos/cosmos-sdk/types/simulation"
|
||||
"github.com/cosmos/cosmos-sdk/x/simulation"
|
||||
)
|
||||
|
||||
// avoid unused import issue
|
||||
var (
|
||||
_ = sample.AccAddress
|
||||
_ = colinearsimulation.FindAccount
|
||||
_ = simappparams.StakePerAccount
|
||||
_ = simulation.MsgEntryKind
|
||||
_ = baseapp.Paramspace
|
||||
)
|
||||
|
||||
const (
|
||||
opWeightMsgNewAuction = "op_weight_msg_new_auction"
|
||||
// TODO: Determine the simulation weight value
|
||||
defaultWeightMsgNewAuction int = 100
|
||||
|
||||
opWeightMsgNewBid = "op_weight_msg_new_bid"
|
||||
// TODO: Determine the simulation weight value
|
||||
defaultWeightMsgNewBid int = 100
|
||||
|
||||
// this line is used by starport scaffolding # simapp/module/const
|
||||
)
|
||||
|
||||
// GenerateGenesisState creates a randomized GenState of the module
|
||||
func (AppModule) GenerateGenesisState(simState *module.SimulationState) {
|
||||
accs := make([]string, len(simState.Accounts))
|
||||
for i, acc := range simState.Accounts {
|
||||
accs[i] = acc.Address.String()
|
||||
}
|
||||
colinearGenesis := types.GenesisState{
|
||||
Params: types.DefaultParams(),
|
||||
// this line is used by starport scaffolding # simapp/module/genesisState
|
||||
}
|
||||
simState.GenState[types.ModuleName] = simState.Cdc.MustMarshalJSON(&colinearGenesis)
|
||||
}
|
||||
|
||||
// ProposalContents doesn't return any content functions for governance proposals
|
||||
func (AppModule) ProposalContents(_ module.SimulationState) []simtypes.WeightedProposalContent {
|
||||
return nil
|
||||
}
|
||||
|
||||
// RandomizedParams creates randomized param changes for the simulator
|
||||
func (am AppModule) RandomizedParams(_ *rand.Rand) []simtypes.ParamChange {
|
||||
|
||||
return []simtypes.ParamChange{}
|
||||
}
|
||||
|
||||
// RegisterStoreDecoder registers a decoder
|
||||
func (am AppModule) RegisterStoreDecoder(_ sdk.StoreDecoderRegistry) {}
|
||||
|
||||
// WeightedOperations returns the all the gov module operations with their respective weights.
|
||||
func (am AppModule) WeightedOperations(simState module.SimulationState) []simtypes.WeightedOperation {
|
||||
operations := make([]simtypes.WeightedOperation, 0)
|
||||
|
||||
var weightMsgNewAuction int
|
||||
simState.AppParams.GetOrGenerate(simState.Cdc, opWeightMsgNewAuction, &weightMsgNewAuction, nil,
|
||||
func(_ *rand.Rand) {
|
||||
weightMsgNewAuction = defaultWeightMsgNewAuction
|
||||
},
|
||||
)
|
||||
operations = append(operations, simulation.NewWeightedOperation(
|
||||
weightMsgNewAuction,
|
||||
colinearsimulation.SimulateMsgNewAuction(am.accountKeeper, am.bankKeeper, am.keeper),
|
||||
))
|
||||
|
||||
var weightMsgNewBid int
|
||||
simState.AppParams.GetOrGenerate(simState.Cdc, opWeightMsgNewBid, &weightMsgNewBid, nil,
|
||||
func(_ *rand.Rand) {
|
||||
weightMsgNewBid = defaultWeightMsgNewBid
|
||||
},
|
||||
)
|
||||
operations = append(operations, simulation.NewWeightedOperation(
|
||||
weightMsgNewBid,
|
||||
colinearsimulation.SimulateMsgNewBid(am.accountKeeper, am.bankKeeper, am.keeper),
|
||||
))
|
||||
|
||||
// this line is used by starport scaffolding # simapp/module/operation
|
||||
|
||||
return operations
|
||||
}
|
||||
42
x/colinear-core/module_test.go.bak
Normal file
42
x/colinear-core/module_test.go.bak
Normal file
@@ -0,0 +1,42 @@
|
||||
package colinearcore
|
||||
|
||||
import (
|
||||
"colinear/x/colinear-core/types"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/baseapp"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
|
||||
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
|
||||
"github.com/stretchr/testify/suite"
|
||||
tendermintTypes "github.com/tendermint/tendermint/proto/tendermint/types"
|
||||
)
|
||||
|
||||
// Integration Tests Tutorial:
|
||||
// https://tutorials.cosmos.network/academy/3-my-own-chain/game-wager.html#integration-tests
|
||||
|
||||
// Example integration test suite:
|
||||
// https://github.com/cosmos/cosmos-sdk/blob/9e1ec7b/x/bank/keeper/keeper_test.go#L66-L110
|
||||
|
||||
type IntegrationTestSuite struct {
|
||||
suite.Suite
|
||||
|
||||
app *AppModule
|
||||
msgServer types.MsgServer
|
||||
ctx sdk.Context
|
||||
queryClient types.QueryClient
|
||||
}
|
||||
|
||||
func (suite *IntegrationTestSuite) SetupTest() {
|
||||
suite.ctx = suite.app.NewContext(false, tendermintTypes.Header{Time: time.Now()})
|
||||
suite.app.AccountKeeper.SetParams(suite.ctx, authtypes.DefaultParams())
|
||||
suite.app.BankKeeper.SetParams(suite.ctx, banktypes.DefaultParams())
|
||||
queryHelper := baseapp.NewQueryServerTestHelper(suite.ctx, suite.app.InterfaceRegistry())
|
||||
types.RegisterQueryServer(queryHelper)
|
||||
suite.queryClient = types.NewQueryClient(queryHelper)
|
||||
}
|
||||
|
||||
func TestKeeperTestSuite(t *testing.T) {
|
||||
suite.Run(t, new(IntegrationTestSuite))
|
||||
}
|
||||
30
x/colinear-core/simulation/new_auction.go
Normal file
30
x/colinear-core/simulation/new_auction.go
Normal file
@@ -0,0 +1,30 @@
|
||||
package simulation
|
||||
|
||||
import (
|
||||
"math/rand"
|
||||
|
||||
"colinear/x/colinear-core/keeper"
|
||||
"colinear/x/colinear-core/types"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/baseapp"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
simtypes "github.com/cosmos/cosmos-sdk/types/simulation"
|
||||
)
|
||||
|
||||
func SimulateMsgNewAuction(
|
||||
ak types.AccountKeeper,
|
||||
bk types.BankKeeper,
|
||||
k keeper.Keeper,
|
||||
) simtypes.Operation {
|
||||
return func(r *rand.Rand, app *baseapp.BaseApp, ctx sdk.Context, accs []simtypes.Account, chainID string,
|
||||
) (simtypes.OperationMsg, []simtypes.FutureOperation, error) {
|
||||
simAccount, _ := simtypes.RandomAcc(r, accs)
|
||||
msg := &types.MsgNewAuction{
|
||||
Creator: simAccount.Address.String(),
|
||||
}
|
||||
|
||||
// TODO: Handling the NewAuction simulation
|
||||
|
||||
return simtypes.NoOpMsg(types.ModuleName, msg.Type(), "NewAuction simulation not implemented"), nil, nil
|
||||
}
|
||||
}
|
||||
30
x/colinear-core/simulation/new_bid.go
Normal file
30
x/colinear-core/simulation/new_bid.go
Normal file
@@ -0,0 +1,30 @@
|
||||
package simulation
|
||||
|
||||
import (
|
||||
"math/rand"
|
||||
|
||||
"colinear/x/colinear-core/keeper"
|
||||
"colinear/x/colinear-core/types"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/baseapp"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
simtypes "github.com/cosmos/cosmos-sdk/types/simulation"
|
||||
)
|
||||
|
||||
func SimulateMsgNewBid(
|
||||
ak types.AccountKeeper,
|
||||
bk types.BankKeeper,
|
||||
k keeper.Keeper,
|
||||
) simtypes.Operation {
|
||||
return func(r *rand.Rand, app *baseapp.BaseApp, ctx sdk.Context, accs []simtypes.Account, chainID string,
|
||||
) (simtypes.OperationMsg, []simtypes.FutureOperation, error) {
|
||||
simAccount, _ := simtypes.RandomAcc(r, accs)
|
||||
msg := &types.MsgNewBid{
|
||||
Creator: simAccount.Address.String(),
|
||||
}
|
||||
|
||||
// TODO: Handling the NewBid simulation
|
||||
|
||||
return simtypes.NoOpMsg(types.ModuleName, msg.Type(), "NewBid simulation not implemented"), nil, nil
|
||||
}
|
||||
}
|
||||
15
x/colinear-core/simulation/simap.go
Normal file
15
x/colinear-core/simulation/simap.go
Normal file
@@ -0,0 +1,15 @@
|
||||
package simulation
|
||||
|
||||
import (
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
simtypes "github.com/cosmos/cosmos-sdk/types/simulation"
|
||||
)
|
||||
|
||||
// FindAccount find a specific address from an account list
|
||||
func FindAccount(accs []simtypes.Account, address string) (simtypes.Account, bool) {
|
||||
creator, err := sdk.AccAddressFromBech32(address)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return simtypes.FindAccount(accs, creator)
|
||||
}
|
||||
794
x/colinear-core/types/auction.pb.go
Normal file
794
x/colinear-core/types/auction.pb.go
Normal file
@@ -0,0 +1,794 @@
|
||||
// Code generated by protoc-gen-gogo. DO NOT EDIT.
|
||||
// source: colinear/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"`
|
||||
Best *Bid `protobuf:"bytes,4,opt,name=best,proto3" json:"best,omitempty"`
|
||||
Deadline uint64 `protobuf:"varint,5,opt,name=deadline,proto3" json:"deadline,omitempty"`
|
||||
Ceiling string `protobuf:"bytes,6,opt,name=ceiling,proto3" json:"ceiling,omitempty"`
|
||||
Denom string `protobuf:"bytes,7,opt,name=denom,proto3" json:"denom,omitempty"`
|
||||
Owner string `protobuf:"bytes,8,opt,name=owner,proto3" json:"owner,omitempty"`
|
||||
LeaseStart uint64 `protobuf:"varint,9,opt,name=leaseStart,proto3" json:"leaseStart,omitempty"`
|
||||
LeaseEnd uint64 `protobuf:"varint,10,opt,name=leaseEnd,proto3" json:"leaseEnd,omitempty"`
|
||||
Remaining string `protobuf:"bytes,11,opt,name=remaining,proto3" json:"remaining,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) GetBest() *Bid {
|
||||
if m != nil {
|
||||
return m.Best
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *Auction) GetDeadline() uint64 {
|
||||
if m != nil {
|
||||
return m.Deadline
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (m *Auction) GetCeiling() string {
|
||||
if m != nil {
|
||||
return m.Ceiling
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (m *Auction) GetDenom() string {
|
||||
if m != nil {
|
||||
return m.Denom
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (m *Auction) GetOwner() string {
|
||||
if m != nil {
|
||||
return m.Owner
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (m *Auction) GetLeaseStart() uint64 {
|
||||
if m != nil {
|
||||
return m.LeaseStart
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (m *Auction) GetLeaseEnd() uint64 {
|
||||
if m != nil {
|
||||
return m.LeaseEnd
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (m *Auction) GetRemaining() string {
|
||||
if m != nil {
|
||||
return m.Remaining
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func init() {
|
||||
proto.RegisterType((*Auction)(nil), "colinear.colinear.Auction")
|
||||
}
|
||||
|
||||
func init() { proto.RegisterFile("colinear/auction.proto", fileDescriptor_631f6f59914101d9) }
|
||||
|
||||
var fileDescriptor_631f6f59914101d9 = []byte{
|
||||
// 298 bytes of a gzipped FileDescriptorProto
|
||||
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x6c, 0x91, 0xbf, 0x4e, 0xc3, 0x30,
|
||||
0x10, 0xc6, 0xeb, 0x92, 0xfe, 0xbb, 0x6e, 0x56, 0x91, 0x4e, 0x15, 0xb2, 0x22, 0xa6, 0x2e, 0xa4,
|
||||
0x12, 0x2c, 0xac, 0x54, 0xe2, 0x05, 0xca, 0xc6, 0xe6, 0xc6, 0x27, 0x64, 0xa9, 0xb1, 0xab, 0xd8,
|
||||
0x88, 0xf2, 0x16, 0xbc, 0x12, 0x1b, 0x63, 0x47, 0x46, 0xd4, 0xbe, 0x08, 0xca, 0x59, 0x25, 0x19,
|
||||
0xd8, 0xee, 0xf7, 0xdd, 0x7d, 0xb9, 0x2f, 0x3e, 0xc0, 0xd2, 0x87, 0xca, 0x87, 0x48, 0x21, 0x2e,
|
||||
0xf5, 0x6b, 0x19, 0xad, 0x77, 0xc5, 0xae, 0xf6, 0xd1, 0xcb, 0xcb, 0xb6, 0x53, 0xb4, 0xe5, 0x7c,
|
||||
0xd6, 0x31, 0x6c, 0xac, 0x49, 0xc3, 0xd7, 0x9f, 0x7d, 0x18, 0x3d, 0x24, 0xbb, 0x9c, 0xc1, 0xc0,
|
||||
0x3a, 0x43, 0x7b, 0x14, 0xb9, 0x58, 0x4c, 0xd6, 0x09, 0xa4, 0x84, 0xcc, 0xe9, 0x8a, 0xb0, 0xcf,
|
||||
0x22, 0xd7, 0x32, 0x87, 0xa9, 0xa1, 0x50, 0xd6, 0x76, 0xd7, 0x18, 0xf1, 0x82, 0x5b, 0x5d, 0x49,
|
||||
0x16, 0x90, 0x6d, 0x28, 0x44, 0xcc, 0x72, 0xb1, 0x98, 0xde, 0xce, 0x8b, 0x7f, 0x33, 0x15, 0x2b,
|
||||
0x6b, 0xd6, 0x3c, 0x27, 0xe7, 0x30, 0x36, 0xa4, 0xcd, 0xd6, 0x3a, 0xc2, 0x41, 0x2e, 0x16, 0xd9,
|
||||
0xfa, 0x8f, 0x25, 0xc2, 0xa8, 0x24, 0xbb, 0xb5, 0xee, 0x05, 0x87, 0xbc, 0xe9, 0x8c, 0x4d, 0x62,
|
||||
0x43, 0xce, 0x57, 0x38, 0x4a, 0x89, 0x19, 0x1a, 0xd5, 0xbf, 0x39, 0xaa, 0x71, 0x9c, 0x54, 0x06,
|
||||
0xa9, 0x00, 0xb6, 0xa4, 0x03, 0x3d, 0x45, 0x5d, 0x47, 0x9c, 0xf0, 0x8e, 0x8e, 0xd2, 0x24, 0x60,
|
||||
0x7a, 0x74, 0x06, 0x21, 0x25, 0x38, 0xb3, 0xbc, 0x82, 0x49, 0x4d, 0x95, 0xb6, 0xae, 0xc9, 0x30,
|
||||
0xe5, 0xaf, 0xb6, 0xc2, 0xea, 0xfe, 0xeb, 0xa8, 0xc4, 0xe1, 0xa8, 0xc4, 0xcf, 0x51, 0x89, 0x8f,
|
||||
0x93, 0xea, 0x1d, 0x4e, 0xaa, 0xf7, 0x7d, 0x52, 0xbd, 0x67, 0x95, 0xfe, 0xf5, 0x86, 0x1f, 0x7d,
|
||||
0xbf, 0xec, 0x5c, 0x20, 0xbe, 0xef, 0x28, 0x6c, 0x86, 0x7c, 0x84, 0xbb, 0xdf, 0x00, 0x00, 0x00,
|
||||
0xff, 0xff, 0x99, 0xa2, 0x60, 0x3e, 0xcd, 0x01, 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.Remaining) > 0 {
|
||||
i -= len(m.Remaining)
|
||||
copy(dAtA[i:], m.Remaining)
|
||||
i = encodeVarintAuction(dAtA, i, uint64(len(m.Remaining)))
|
||||
i--
|
||||
dAtA[i] = 0x5a
|
||||
}
|
||||
if m.LeaseEnd != 0 {
|
||||
i = encodeVarintAuction(dAtA, i, uint64(m.LeaseEnd))
|
||||
i--
|
||||
dAtA[i] = 0x50
|
||||
}
|
||||
if m.LeaseStart != 0 {
|
||||
i = encodeVarintAuction(dAtA, i, uint64(m.LeaseStart))
|
||||
i--
|
||||
dAtA[i] = 0x48
|
||||
}
|
||||
if len(m.Owner) > 0 {
|
||||
i -= len(m.Owner)
|
||||
copy(dAtA[i:], m.Owner)
|
||||
i = encodeVarintAuction(dAtA, i, uint64(len(m.Owner)))
|
||||
i--
|
||||
dAtA[i] = 0x42
|
||||
}
|
||||
if len(m.Denom) > 0 {
|
||||
i -= len(m.Denom)
|
||||
copy(dAtA[i:], m.Denom)
|
||||
i = encodeVarintAuction(dAtA, i, uint64(len(m.Denom)))
|
||||
i--
|
||||
dAtA[i] = 0x3a
|
||||
}
|
||||
if len(m.Ceiling) > 0 {
|
||||
i -= len(m.Ceiling)
|
||||
copy(dAtA[i:], m.Ceiling)
|
||||
i = encodeVarintAuction(dAtA, i, uint64(len(m.Ceiling)))
|
||||
i--
|
||||
dAtA[i] = 0x32
|
||||
}
|
||||
if m.Deadline != 0 {
|
||||
i = encodeVarintAuction(dAtA, i, uint64(m.Deadline))
|
||||
i--
|
||||
dAtA[i] = 0x28
|
||||
}
|
||||
if m.Best != nil {
|
||||
{
|
||||
size, err := m.Best.MarshalToSizedBuffer(dAtA[:i])
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
i -= size
|
||||
i = encodeVarintAuction(dAtA, i, uint64(size))
|
||||
}
|
||||
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))
|
||||
}
|
||||
if m.Best != nil {
|
||||
l = m.Best.Size()
|
||||
n += 1 + l + sovAuction(uint64(l))
|
||||
}
|
||||
if m.Deadline != 0 {
|
||||
n += 1 + sovAuction(uint64(m.Deadline))
|
||||
}
|
||||
l = len(m.Ceiling)
|
||||
if l > 0 {
|
||||
n += 1 + l + sovAuction(uint64(l))
|
||||
}
|
||||
l = len(m.Denom)
|
||||
if l > 0 {
|
||||
n += 1 + l + sovAuction(uint64(l))
|
||||
}
|
||||
l = len(m.Owner)
|
||||
if l > 0 {
|
||||
n += 1 + l + sovAuction(uint64(l))
|
||||
}
|
||||
if m.LeaseStart != 0 {
|
||||
n += 1 + sovAuction(uint64(m.LeaseStart))
|
||||
}
|
||||
if m.LeaseEnd != 0 {
|
||||
n += 1 + sovAuction(uint64(m.LeaseEnd))
|
||||
}
|
||||
l = len(m.Remaining)
|
||||
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 Best", wireType)
|
||||
}
|
||||
var msglen int
|
||||
for shift := uint(0); ; shift += 7 {
|
||||
if shift >= 64 {
|
||||
return ErrIntOverflowAuction
|
||||
}
|
||||
if iNdEx >= l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
b := dAtA[iNdEx]
|
||||
iNdEx++
|
||||
msglen |= int(b&0x7F) << shift
|
||||
if b < 0x80 {
|
||||
break
|
||||
}
|
||||
}
|
||||
if msglen < 0 {
|
||||
return ErrInvalidLengthAuction
|
||||
}
|
||||
postIndex := iNdEx + msglen
|
||||
if postIndex < 0 {
|
||||
return ErrInvalidLengthAuction
|
||||
}
|
||||
if postIndex > l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
if m.Best == nil {
|
||||
m.Best = &Bid{}
|
||||
}
|
||||
if err := m.Best.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
|
||||
return err
|
||||
}
|
||||
iNdEx = postIndex
|
||||
case 5:
|
||||
if wireType != 0 {
|
||||
return fmt.Errorf("proto: wrong wireType = %d for field Deadline", wireType)
|
||||
}
|
||||
m.Deadline = 0
|
||||
for shift := uint(0); ; shift += 7 {
|
||||
if shift >= 64 {
|
||||
return ErrIntOverflowAuction
|
||||
}
|
||||
if iNdEx >= l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
b := dAtA[iNdEx]
|
||||
iNdEx++
|
||||
m.Deadline |= uint64(b&0x7F) << shift
|
||||
if b < 0x80 {
|
||||
break
|
||||
}
|
||||
}
|
||||
case 6:
|
||||
if wireType != 2 {
|
||||
return fmt.Errorf("proto: wrong wireType = %d for field Ceiling", 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.Ceiling = string(dAtA[iNdEx:postIndex])
|
||||
iNdEx = postIndex
|
||||
case 7:
|
||||
if wireType != 2 {
|
||||
return fmt.Errorf("proto: wrong wireType = %d for field Denom", 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.Denom = string(dAtA[iNdEx:postIndex])
|
||||
iNdEx = postIndex
|
||||
case 8:
|
||||
if wireType != 2 {
|
||||
return fmt.Errorf("proto: wrong wireType = %d for field Owner", 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.Owner = string(dAtA[iNdEx:postIndex])
|
||||
iNdEx = postIndex
|
||||
case 9:
|
||||
if wireType != 0 {
|
||||
return fmt.Errorf("proto: wrong wireType = %d for field LeaseStart", wireType)
|
||||
}
|
||||
m.LeaseStart = 0
|
||||
for shift := uint(0); ; shift += 7 {
|
||||
if shift >= 64 {
|
||||
return ErrIntOverflowAuction
|
||||
}
|
||||
if iNdEx >= l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
b := dAtA[iNdEx]
|
||||
iNdEx++
|
||||
m.LeaseStart |= uint64(b&0x7F) << shift
|
||||
if b < 0x80 {
|
||||
break
|
||||
}
|
||||
}
|
||||
case 10:
|
||||
if wireType != 0 {
|
||||
return fmt.Errorf("proto: wrong wireType = %d for field LeaseEnd", wireType)
|
||||
}
|
||||
m.LeaseEnd = 0
|
||||
for shift := uint(0); ; shift += 7 {
|
||||
if shift >= 64 {
|
||||
return ErrIntOverflowAuction
|
||||
}
|
||||
if iNdEx >= l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
b := dAtA[iNdEx]
|
||||
iNdEx++
|
||||
m.LeaseEnd |= uint64(b&0x7F) << shift
|
||||
if b < 0x80 {
|
||||
break
|
||||
}
|
||||
}
|
||||
case 11:
|
||||
if wireType != 2 {
|
||||
return fmt.Errorf("proto: wrong wireType = %d for field Remaining", 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.Remaining = 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")
|
||||
)
|
||||
364
x/colinear-core/types/bid.pb.go
Normal file
364
x/colinear-core/types/bid.pb.go
Normal file
@@ -0,0 +1,364 @@
|
||||
// Code generated by protoc-gen-gogo. DO NOT EDIT.
|
||||
// source: colinear/bid.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 Bid struct {
|
||||
Owner string `protobuf:"bytes,1,opt,name=owner,proto3" json:"owner,omitempty"`
|
||||
Amount string `protobuf:"bytes,2,opt,name=amount,proto3" json:"amount,omitempty"`
|
||||
}
|
||||
|
||||
func (m *Bid) Reset() { *m = Bid{} }
|
||||
func (m *Bid) String() string { return proto.CompactTextString(m) }
|
||||
func (*Bid) ProtoMessage() {}
|
||||
func (*Bid) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_74e391fc4965aac8, []int{0}
|
||||
}
|
||||
func (m *Bid) XXX_Unmarshal(b []byte) error {
|
||||
return m.Unmarshal(b)
|
||||
}
|
||||
func (m *Bid) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||
if deterministic {
|
||||
return xxx_messageInfo_Bid.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 *Bid) XXX_Merge(src proto.Message) {
|
||||
xxx_messageInfo_Bid.Merge(m, src)
|
||||
}
|
||||
func (m *Bid) XXX_Size() int {
|
||||
return m.Size()
|
||||
}
|
||||
func (m *Bid) XXX_DiscardUnknown() {
|
||||
xxx_messageInfo_Bid.DiscardUnknown(m)
|
||||
}
|
||||
|
||||
var xxx_messageInfo_Bid proto.InternalMessageInfo
|
||||
|
||||
func (m *Bid) GetOwner() string {
|
||||
if m != nil {
|
||||
return m.Owner
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (m *Bid) GetAmount() string {
|
||||
if m != nil {
|
||||
return m.Amount
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func init() {
|
||||
proto.RegisterType((*Bid)(nil), "colinear.colinear.Bid")
|
||||
}
|
||||
|
||||
func init() { proto.RegisterFile("colinear/bid.proto", fileDescriptor_74e391fc4965aac8) }
|
||||
|
||||
var fileDescriptor_74e391fc4965aac8 = []byte{
|
||||
// 142 bytes of a gzipped FileDescriptorProto
|
||||
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x12, 0x49, 0xce, 0x2f, 0xce,
|
||||
0xcd, 0x2f, 0x2e, 0x49, 0x2d, 0x2e, 0xd1, 0x4f, 0xca, 0x4c, 0xd1, 0x2b, 0x28, 0xca, 0x2f, 0xc9,
|
||||
0x17, 0x12, 0x45, 0x88, 0xea, 0x21, 0x98, 0x4a, 0xc6, 0x5c, 0xcc, 0x4e, 0x99, 0x29, 0x42, 0x22,
|
||||
0x5c, 0xac, 0xf9, 0xe5, 0x79, 0xa9, 0x45, 0x12, 0x8c, 0x0a, 0x8c, 0x1a, 0x9c, 0x41, 0x10, 0x8e,
|
||||
0x90, 0x18, 0x17, 0x5b, 0x62, 0x6e, 0x7e, 0x69, 0x5e, 0x89, 0x04, 0x13, 0x58, 0x18, 0xca, 0x73,
|
||||
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, 0xd1, 0xba,
|
||||
0x60, 0xcb, 0x2b, 0xf4, 0x91, 0x5c, 0x52, 0x52, 0x59, 0x90, 0x5a, 0x9c, 0xc4, 0x06, 0x76, 0x8c,
|
||||
0x31, 0x20, 0x00, 0x00, 0xff, 0xff, 0x20, 0x17, 0xe0, 0x92, 0xa4, 0x00, 0x00, 0x00,
|
||||
}
|
||||
|
||||
func (m *Bid) 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 *Bid) MarshalTo(dAtA []byte) (int, error) {
|
||||
size := m.Size()
|
||||
return m.MarshalToSizedBuffer(dAtA[:size])
|
||||
}
|
||||
|
||||
func (m *Bid) MarshalToSizedBuffer(dAtA []byte) (int, error) {
|
||||
i := len(dAtA)
|
||||
_ = i
|
||||
var l int
|
||||
_ = l
|
||||
if len(m.Amount) > 0 {
|
||||
i -= len(m.Amount)
|
||||
copy(dAtA[i:], m.Amount)
|
||||
i = encodeVarintBid(dAtA, i, uint64(len(m.Amount)))
|
||||
i--
|
||||
dAtA[i] = 0x12
|
||||
}
|
||||
if len(m.Owner) > 0 {
|
||||
i -= len(m.Owner)
|
||||
copy(dAtA[i:], m.Owner)
|
||||
i = encodeVarintBid(dAtA, i, uint64(len(m.Owner)))
|
||||
i--
|
||||
dAtA[i] = 0xa
|
||||
}
|
||||
return len(dAtA) - i, nil
|
||||
}
|
||||
|
||||
func encodeVarintBid(dAtA []byte, offset int, v uint64) int {
|
||||
offset -= sovBid(v)
|
||||
base := offset
|
||||
for v >= 1<<7 {
|
||||
dAtA[offset] = uint8(v&0x7f | 0x80)
|
||||
v >>= 7
|
||||
offset++
|
||||
}
|
||||
dAtA[offset] = uint8(v)
|
||||
return base
|
||||
}
|
||||
func (m *Bid) Size() (n int) {
|
||||
if m == nil {
|
||||
return 0
|
||||
}
|
||||
var l int
|
||||
_ = l
|
||||
l = len(m.Owner)
|
||||
if l > 0 {
|
||||
n += 1 + l + sovBid(uint64(l))
|
||||
}
|
||||
l = len(m.Amount)
|
||||
if l > 0 {
|
||||
n += 1 + l + sovBid(uint64(l))
|
||||
}
|
||||
return n
|
||||
}
|
||||
|
||||
func sovBid(x uint64) (n int) {
|
||||
return (math_bits.Len64(x|1) + 6) / 7
|
||||
}
|
||||
func sozBid(x uint64) (n int) {
|
||||
return sovBid(uint64((x << 1) ^ uint64((int64(x) >> 63))))
|
||||
}
|
||||
func (m *Bid) 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 ErrIntOverflowBid
|
||||
}
|
||||
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: Bid: wiretype end group for non-group")
|
||||
}
|
||||
if fieldNum <= 0 {
|
||||
return fmt.Errorf("proto: Bid: illegal tag %d (wire type %d)", fieldNum, wire)
|
||||
}
|
||||
switch fieldNum {
|
||||
case 1:
|
||||
if wireType != 2 {
|
||||
return fmt.Errorf("proto: wrong wireType = %d for field Owner", wireType)
|
||||
}
|
||||
var stringLen uint64
|
||||
for shift := uint(0); ; shift += 7 {
|
||||
if shift >= 64 {
|
||||
return ErrIntOverflowBid
|
||||
}
|
||||
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 ErrInvalidLengthBid
|
||||
}
|
||||
postIndex := iNdEx + intStringLen
|
||||
if postIndex < 0 {
|
||||
return ErrInvalidLengthBid
|
||||
}
|
||||
if postIndex > l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
m.Owner = string(dAtA[iNdEx:postIndex])
|
||||
iNdEx = postIndex
|
||||
case 2:
|
||||
if wireType != 2 {
|
||||
return fmt.Errorf("proto: wrong wireType = %d for field Amount", wireType)
|
||||
}
|
||||
var stringLen uint64
|
||||
for shift := uint(0); ; shift += 7 {
|
||||
if shift >= 64 {
|
||||
return ErrIntOverflowBid
|
||||
}
|
||||
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 ErrInvalidLengthBid
|
||||
}
|
||||
postIndex := iNdEx + intStringLen
|
||||
if postIndex < 0 {
|
||||
return ErrInvalidLengthBid
|
||||
}
|
||||
if postIndex > l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
m.Amount = string(dAtA[iNdEx:postIndex])
|
||||
iNdEx = postIndex
|
||||
default:
|
||||
iNdEx = preIndex
|
||||
skippy, err := skipBid(dAtA[iNdEx:])
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if (skippy < 0) || (iNdEx+skippy) < 0 {
|
||||
return ErrInvalidLengthBid
|
||||
}
|
||||
if (iNdEx + skippy) > l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
iNdEx += skippy
|
||||
}
|
||||
}
|
||||
|
||||
if iNdEx > l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
return nil
|
||||
}
|
||||
func skipBid(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, ErrIntOverflowBid
|
||||
}
|
||||
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, ErrIntOverflowBid
|
||||
}
|
||||
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, ErrIntOverflowBid
|
||||
}
|
||||
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, ErrInvalidLengthBid
|
||||
}
|
||||
iNdEx += length
|
||||
case 3:
|
||||
depth++
|
||||
case 4:
|
||||
if depth == 0 {
|
||||
return 0, ErrUnexpectedEndOfGroupBid
|
||||
}
|
||||
depth--
|
||||
case 5:
|
||||
iNdEx += 4
|
||||
default:
|
||||
return 0, fmt.Errorf("proto: illegal wireType %d", wireType)
|
||||
}
|
||||
if iNdEx < 0 {
|
||||
return 0, ErrInvalidLengthBid
|
||||
}
|
||||
if depth == 0 {
|
||||
return iNdEx, nil
|
||||
}
|
||||
}
|
||||
return 0, io.ErrUnexpectedEOF
|
||||
}
|
||||
|
||||
var (
|
||||
ErrInvalidLengthBid = fmt.Errorf("proto: negative length found during unmarshaling")
|
||||
ErrIntOverflowBid = fmt.Errorf("proto: integer overflow")
|
||||
ErrUnexpectedEndOfGroupBid = fmt.Errorf("proto: unexpected end of group")
|
||||
)
|
||||
31
x/colinear-core/types/codec.go
Normal file
31
x/colinear-core/types/codec.go
Normal file
@@ -0,0 +1,31 @@
|
||||
package types
|
||||
|
||||
import (
|
||||
"github.com/cosmos/cosmos-sdk/codec"
|
||||
cdctypes "github.com/cosmos/cosmos-sdk/codec/types"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/cosmos/cosmos-sdk/types/msgservice"
|
||||
)
|
||||
|
||||
func RegisterCodec(cdc *codec.LegacyAmino) {
|
||||
cdc.RegisterConcrete(&MsgNewAuction{}, "colinear/NewAuction", nil)
|
||||
cdc.RegisterConcrete(&MsgNewBid{}, "colinear/NewBid", nil)
|
||||
// this line is used by starport scaffolding # 2
|
||||
}
|
||||
|
||||
func RegisterInterfaces(registry cdctypes.InterfaceRegistry) {
|
||||
registry.RegisterImplementations((*sdk.Msg)(nil),
|
||||
&MsgNewAuction{},
|
||||
)
|
||||
registry.RegisterImplementations((*sdk.Msg)(nil),
|
||||
&MsgNewBid{},
|
||||
)
|
||||
// this line is used by starport scaffolding # 3
|
||||
|
||||
msgservice.RegisterMsgServiceDesc(registry, &_Msg_serviceDesc)
|
||||
}
|
||||
|
||||
var (
|
||||
Amino = codec.NewLegacyAmino()
|
||||
ModuleCdc = codec.NewProtoCodec(cdctypes.NewInterfaceRegistry())
|
||||
)
|
||||
12
x/colinear-core/types/errors.go
Normal file
12
x/colinear-core/types/errors.go
Normal file
@@ -0,0 +1,12 @@
|
||||
package types
|
||||
|
||||
// DONTCOVER
|
||||
|
||||
import (
|
||||
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
|
||||
)
|
||||
|
||||
// x/colinear-core module sentinel errors
|
||||
var (
|
||||
ErrSample = sdkerrors.Register(ModuleName, 1100, "sample error")
|
||||
)
|
||||
20
x/colinear-core/types/expected_keepers.go
Normal file
20
x/colinear-core/types/expected_keepers.go
Normal file
@@ -0,0 +1,20 @@
|
||||
package types
|
||||
|
||||
import (
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/cosmos/cosmos-sdk/x/auth/types"
|
||||
)
|
||||
|
||||
// AccountKeeper defines the expected account keeper used for simulations (noalias)
|
||||
type AccountKeeper interface {
|
||||
GetAccount(ctx sdk.Context, addr sdk.AccAddress) types.AccountI
|
||||
// Methods imported from account should be defined here
|
||||
}
|
||||
|
||||
// BankKeeper defines the expected interface needed to retrieve account balances.
|
||||
type BankKeeper interface {
|
||||
SpendableCoins(ctx sdk.Context, addr sdk.AccAddress) sdk.Coins
|
||||
SendCoinsFromModuleToAccount(ctx sdk.Context, senderModule string, recipientAddr sdk.AccAddress, amt sdk.Coins) error
|
||||
SendCoinsFromAccountToModule(ctx sdk.Context, senderAddr sdk.AccAddress, recipientModule string, amt sdk.Coins) error
|
||||
// Methods imported from bank should be defined here
|
||||
}
|
||||
36
x/colinear-core/types/genesis.go
Normal file
36
x/colinear-core/types/genesis.go
Normal file
@@ -0,0 +1,36 @@
|
||||
package types
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
)
|
||||
|
||||
// DefaultIndex is the default capability global index
|
||||
const DefaultIndex uint64 = 1
|
||||
|
||||
// DefaultGenesis returns the default Capability genesis state
|
||||
func DefaultGenesis() *GenesisState {
|
||||
return &GenesisState{
|
||||
NextAuction: &NextAuction{AuctionId: 0},
|
||||
AuctionList: []Auction{},
|
||||
// this line is used by starport scaffolding # genesis/types/default
|
||||
Params: DefaultParams(),
|
||||
}
|
||||
}
|
||||
|
||||
// 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()
|
||||
}
|
||||
446
x/colinear-core/types/genesis.pb.go
Normal file
446
x/colinear-core/types/genesis.pb.go
Normal file
@@ -0,0 +1,446 @@
|
||||
// Code generated by protoc-gen-gogo. DO NOT EDIT.
|
||||
// source: colinear/genesis.proto
|
||||
|
||||
package types
|
||||
|
||||
import (
|
||||
fmt "fmt"
|
||||
_ "github.com/gogo/protobuf/gogoproto"
|
||||
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
|
||||
|
||||
// GenesisState defines the colinear module's genesis state.
|
||||
type GenesisState struct {
|
||||
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{} }
|
||||
func (m *GenesisState) String() string { return proto.CompactTextString(m) }
|
||||
func (*GenesisState) ProtoMessage() {}
|
||||
func (*GenesisState) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_78c0d8c25fe3d9a9, []int{0}
|
||||
}
|
||||
func (m *GenesisState) XXX_Unmarshal(b []byte) error {
|
||||
return m.Unmarshal(b)
|
||||
}
|
||||
func (m *GenesisState) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||
if deterministic {
|
||||
return xxx_messageInfo_GenesisState.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 *GenesisState) XXX_Merge(src proto.Message) {
|
||||
xxx_messageInfo_GenesisState.Merge(m, src)
|
||||
}
|
||||
func (m *GenesisState) XXX_Size() int {
|
||||
return m.Size()
|
||||
}
|
||||
func (m *GenesisState) XXX_DiscardUnknown() {
|
||||
xxx_messageInfo_GenesisState.DiscardUnknown(m)
|
||||
}
|
||||
|
||||
var xxx_messageInfo_GenesisState proto.InternalMessageInfo
|
||||
|
||||
func (m *GenesisState) GetParams() Params {
|
||||
if m != nil {
|
||||
return m.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), "colinear.colinear.GenesisState")
|
||||
}
|
||||
|
||||
func init() { proto.RegisterFile("colinear/genesis.proto", fileDescriptor_78c0d8c25fe3d9a9) }
|
||||
|
||||
var fileDescriptor_78c0d8c25fe3d9a9 = []byte{
|
||||
// 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, 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) {
|
||||
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 *GenesisState) MarshalTo(dAtA []byte) (int, error) {
|
||||
size := m.Size()
|
||||
return m.MarshalToSizedBuffer(dAtA[:size])
|
||||
}
|
||||
|
||||
func (m *GenesisState) MarshalToSizedBuffer(dAtA []byte) (int, error) {
|
||||
i := len(dAtA)
|
||||
_ = 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 {
|
||||
return 0, err
|
||||
}
|
||||
i -= size
|
||||
i = encodeVarintGenesis(dAtA, i, uint64(size))
|
||||
}
|
||||
i--
|
||||
dAtA[i] = 0xa
|
||||
return len(dAtA) - i, nil
|
||||
}
|
||||
|
||||
func encodeVarintGenesis(dAtA []byte, offset int, v uint64) int {
|
||||
offset -= sovGenesis(v)
|
||||
base := offset
|
||||
for v >= 1<<7 {
|
||||
dAtA[offset] = uint8(v&0x7f | 0x80)
|
||||
v >>= 7
|
||||
offset++
|
||||
}
|
||||
dAtA[offset] = uint8(v)
|
||||
return base
|
||||
}
|
||||
func (m *GenesisState) Size() (n int) {
|
||||
if m == nil {
|
||||
return 0
|
||||
}
|
||||
var l 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
|
||||
}
|
||||
|
||||
func sovGenesis(x uint64) (n int) {
|
||||
return (math_bits.Len64(x|1) + 6) / 7
|
||||
}
|
||||
func sozGenesis(x uint64) (n int) {
|
||||
return sovGenesis(uint64((x << 1) ^ uint64((int64(x) >> 63))))
|
||||
}
|
||||
func (m *GenesisState) 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 ErrIntOverflowGenesis
|
||||
}
|
||||
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: GenesisState: wiretype end group for non-group")
|
||||
}
|
||||
if fieldNum <= 0 {
|
||||
return fmt.Errorf("proto: GenesisState: illegal tag %d (wire type %d)", fieldNum, wire)
|
||||
}
|
||||
switch fieldNum {
|
||||
case 1:
|
||||
if wireType != 2 {
|
||||
return fmt.Errorf("proto: wrong wireType = %d for field Params", 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 err := m.Params.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
|
||||
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:])
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if (skippy < 0) || (iNdEx+skippy) < 0 {
|
||||
return ErrInvalidLengthGenesis
|
||||
}
|
||||
if (iNdEx + skippy) > l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
iNdEx += skippy
|
||||
}
|
||||
}
|
||||
|
||||
if iNdEx > l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
return nil
|
||||
}
|
||||
func skipGenesis(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, ErrIntOverflowGenesis
|
||||
}
|
||||
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, ErrIntOverflowGenesis
|
||||
}
|
||||
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, ErrIntOverflowGenesis
|
||||
}
|
||||
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, ErrInvalidLengthGenesis
|
||||
}
|
||||
iNdEx += length
|
||||
case 3:
|
||||
depth++
|
||||
case 4:
|
||||
if depth == 0 {
|
||||
return 0, ErrUnexpectedEndOfGroupGenesis
|
||||
}
|
||||
depth--
|
||||
case 5:
|
||||
iNdEx += 4
|
||||
default:
|
||||
return 0, fmt.Errorf("proto: illegal wireType %d", wireType)
|
||||
}
|
||||
if iNdEx < 0 {
|
||||
return 0, ErrInvalidLengthGenesis
|
||||
}
|
||||
if depth == 0 {
|
||||
return iNdEx, nil
|
||||
}
|
||||
}
|
||||
return 0, io.ErrUnexpectedEOF
|
||||
}
|
||||
|
||||
var (
|
||||
ErrInvalidLengthGenesis = fmt.Errorf("proto: negative length found during unmarshaling")
|
||||
ErrIntOverflowGenesis = fmt.Errorf("proto: integer overflow")
|
||||
ErrUnexpectedEndOfGroupGenesis = fmt.Errorf("proto: unexpected end of group")
|
||||
)
|
||||
66
x/colinear-core/types/genesis_test.go
Normal file
66
x/colinear-core/types/genesis_test.go
Normal file
@@ -0,0 +1,66 @@
|
||||
package types_test
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"colinear/x/colinear-core/types"
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
func TestGenesisState_Validate(t *testing.T) {
|
||||
for _, tc := range []struct {
|
||||
desc string
|
||||
genState *types.GenesisState
|
||||
valid bool
|
||||
}{
|
||||
{
|
||||
desc: "default is valid",
|
||||
genState: types.DefaultGenesis(),
|
||||
valid: true,
|
||||
},
|
||||
{
|
||||
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) {
|
||||
err := tc.genState.Validate()
|
||||
if tc.valid {
|
||||
require.NoError(t, err)
|
||||
} else {
|
||||
require.Error(t, err)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
23
x/colinear-core/types/key_auction.go
Normal file
23
x/colinear-core/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
|
||||
}
|
||||
26
x/colinear-core/types/keys.go
Normal file
26
x/colinear-core/types/keys.go
Normal file
@@ -0,0 +1,26 @@
|
||||
package types
|
||||
|
||||
const (
|
||||
// ModuleName defines the module name
|
||||
ModuleName = "colinear"
|
||||
|
||||
// StoreKey defines the primary module store key
|
||||
StoreKey = ModuleName
|
||||
|
||||
// RouterKey is the message route for slashing
|
||||
RouterKey = ModuleName
|
||||
|
||||
// QuerierRoute defines the module's query routing key
|
||||
QuerierRoute = ModuleName
|
||||
|
||||
// MemStoreKey defines the in-memory store key
|
||||
MemStoreKey = "mem_colinear"
|
||||
)
|
||||
|
||||
func KeyPrefix(p string) []byte {
|
||||
return []byte(p)
|
||||
}
|
||||
|
||||
const (
|
||||
NextAuctionKey = "NextAuction-value-"
|
||||
)
|
||||
50
x/colinear-core/types/message_new_auction.go
Normal file
50
x/colinear-core/types/message_new_auction.go
Normal file
@@ -0,0 +1,50 @@
|
||||
package types
|
||||
|
||||
import (
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
|
||||
)
|
||||
|
||||
const TypeMsgNewAuction = "new_auction"
|
||||
|
||||
var _ sdk.Msg = &MsgNewAuction{}
|
||||
|
||||
func NewMsgNewAuction(creator string, name string, description string, ceiling string, denom string, leaseEnd uint64) *MsgNewAuction {
|
||||
return &MsgNewAuction{
|
||||
Creator: creator,
|
||||
Name: name,
|
||||
Description: description,
|
||||
Ceiling: ceiling,
|
||||
Denom: denom,
|
||||
LeaseEnd: leaseEnd,
|
||||
}
|
||||
}
|
||||
|
||||
func (msg *MsgNewAuction) Route() string {
|
||||
return RouterKey
|
||||
}
|
||||
|
||||
func (msg *MsgNewAuction) Type() string {
|
||||
return TypeMsgNewAuction
|
||||
}
|
||||
|
||||
func (msg *MsgNewAuction) GetSigners() []sdk.AccAddress {
|
||||
creator, err := sdk.AccAddressFromBech32(msg.Creator)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return []sdk.AccAddress{creator}
|
||||
}
|
||||
|
||||
func (msg *MsgNewAuction) GetSignBytes() []byte {
|
||||
bz := ModuleCdc.MustMarshalJSON(msg)
|
||||
return sdk.MustSortJSON(bz)
|
||||
}
|
||||
|
||||
func (msg *MsgNewAuction) ValidateBasic() error {
|
||||
_, err := sdk.AccAddressFromBech32(msg.Creator)
|
||||
if err != nil {
|
||||
return sdkerrors.Wrapf(sdkerrors.ErrInvalidAddress, "invalid creator address (%s)", err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
41
x/colinear-core/types/message_new_auction_test.go
Normal file
41
x/colinear-core/types/message_new_auction_test.go
Normal file
@@ -0,0 +1,41 @@
|
||||
package types
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"colinear/testutil/sample"
|
||||
|
||||
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
func TestMsgNewAuction_ValidateBasic(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
msg MsgNewAuction
|
||||
err error
|
||||
}{
|
||||
{
|
||||
name: "invalid address",
|
||||
msg: MsgNewAuction{
|
||||
Creator: "invalid_address",
|
||||
},
|
||||
err: sdkerrors.ErrInvalidAddress,
|
||||
}, {
|
||||
name: "valid address",
|
||||
msg: MsgNewAuction{
|
||||
Creator: sample.AccAddress(),
|
||||
},
|
||||
},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
err := tt.msg.ValidateBasic()
|
||||
if tt.err != nil {
|
||||
require.ErrorIs(t, err, tt.err)
|
||||
return
|
||||
}
|
||||
require.NoError(t, err)
|
||||
})
|
||||
}
|
||||
}
|
||||
47
x/colinear-core/types/message_new_bid.go
Normal file
47
x/colinear-core/types/message_new_bid.go
Normal file
@@ -0,0 +1,47 @@
|
||||
package types
|
||||
|
||||
import (
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
|
||||
)
|
||||
|
||||
const TypeMsgNewBid = "new_bid"
|
||||
|
||||
var _ sdk.Msg = &MsgNewBid{}
|
||||
|
||||
func NewMsgNewBid(creator string, auctionIndex string, amount string) *MsgNewBid {
|
||||
return &MsgNewBid{
|
||||
Creator: creator,
|
||||
AuctionIndex: auctionIndex,
|
||||
Amount: amount,
|
||||
}
|
||||
}
|
||||
|
||||
func (msg *MsgNewBid) Route() string {
|
||||
return RouterKey
|
||||
}
|
||||
|
||||
func (msg *MsgNewBid) Type() string {
|
||||
return TypeMsgNewBid
|
||||
}
|
||||
|
||||
func (msg *MsgNewBid) GetSigners() []sdk.AccAddress {
|
||||
creator, err := sdk.AccAddressFromBech32(msg.Creator)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return []sdk.AccAddress{creator}
|
||||
}
|
||||
|
||||
func (msg *MsgNewBid) GetSignBytes() []byte {
|
||||
bz := ModuleCdc.MustMarshalJSON(msg)
|
||||
return sdk.MustSortJSON(bz)
|
||||
}
|
||||
|
||||
func (msg *MsgNewBid) ValidateBasic() error {
|
||||
_, err := sdk.AccAddressFromBech32(msg.Creator)
|
||||
if err != nil {
|
||||
return sdkerrors.Wrapf(sdkerrors.ErrInvalidAddress, "invalid creator address (%s)", err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
41
x/colinear-core/types/message_new_bid_test.go
Normal file
41
x/colinear-core/types/message_new_bid_test.go
Normal file
@@ -0,0 +1,41 @@
|
||||
package types
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"colinear/testutil/sample"
|
||||
|
||||
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
func TestMsgNewBid_ValidateBasic(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
msg MsgNewBid
|
||||
err error
|
||||
}{
|
||||
{
|
||||
name: "invalid address",
|
||||
msg: MsgNewBid{
|
||||
Creator: "invalid_address",
|
||||
},
|
||||
err: sdkerrors.ErrInvalidAddress,
|
||||
}, {
|
||||
name: "valid address",
|
||||
msg: MsgNewBid{
|
||||
Creator: sample.AccAddress(),
|
||||
},
|
||||
},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
err := tt.msg.ValidateBasic()
|
||||
if tt.err != nil {
|
||||
require.ErrorIs(t, err, tt.err)
|
||||
return
|
||||
}
|
||||
require.NoError(t, err)
|
||||
})
|
||||
}
|
||||
}
|
||||
297
x/colinear-core/types/next_auction.pb.go
Normal file
297
x/colinear-core/types/next_auction.pb.go
Normal file
@@ -0,0 +1,297 @@
|
||||
// Code generated by protoc-gen-gogo. DO NOT EDIT.
|
||||
// source: colinear/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), "colinear.colinear.NextAuction")
|
||||
}
|
||||
|
||||
func init() { proto.RegisterFile("colinear/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")
|
||||
)
|
||||
39
x/colinear-core/types/params.go
Normal file
39
x/colinear-core/types/params.go
Normal file
@@ -0,0 +1,39 @@
|
||||
package types
|
||||
|
||||
import (
|
||||
paramtypes "github.com/cosmos/cosmos-sdk/x/params/types"
|
||||
"gopkg.in/yaml.v2"
|
||||
)
|
||||
|
||||
var _ paramtypes.ParamSet = (*Params)(nil)
|
||||
|
||||
// ParamKeyTable the param key table for launch module
|
||||
func ParamKeyTable() paramtypes.KeyTable {
|
||||
return paramtypes.NewKeyTable().RegisterParamSet(&Params{})
|
||||
}
|
||||
|
||||
// NewParams creates a new Params instance
|
||||
func NewParams() Params {
|
||||
return Params{}
|
||||
}
|
||||
|
||||
// DefaultParams returns a default set of parameters
|
||||
func DefaultParams() Params {
|
||||
return NewParams()
|
||||
}
|
||||
|
||||
// ParamSetPairs get the params.ParamSet
|
||||
func (p *Params) ParamSetPairs() paramtypes.ParamSetPairs {
|
||||
return paramtypes.ParamSetPairs{}
|
||||
}
|
||||
|
||||
// Validate validates the set of params
|
||||
func (p Params) Validate() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// String implements the Stringer interface.
|
||||
func (p Params) String() string {
|
||||
out, _ := yaml.Marshal(p)
|
||||
return string(out)
|
||||
}
|
||||
263
x/colinear-core/types/params.pb.go
Normal file
263
x/colinear-core/types/params.pb.go
Normal file
@@ -0,0 +1,263 @@
|
||||
// Code generated by protoc-gen-gogo. DO NOT EDIT.
|
||||
// source: colinear/params.proto
|
||||
|
||||
package types
|
||||
|
||||
import (
|
||||
fmt "fmt"
|
||||
_ "github.com/gogo/protobuf/gogoproto"
|
||||
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
|
||||
|
||||
// Params defines the parameters for the module.
|
||||
type Params struct {
|
||||
}
|
||||
|
||||
func (m *Params) Reset() { *m = Params{} }
|
||||
func (*Params) ProtoMessage() {}
|
||||
func (*Params) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_dec10d5375a626c5, []int{0}
|
||||
}
|
||||
func (m *Params) XXX_Unmarshal(b []byte) error {
|
||||
return m.Unmarshal(b)
|
||||
}
|
||||
func (m *Params) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||
if deterministic {
|
||||
return xxx_messageInfo_Params.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 *Params) XXX_Merge(src proto.Message) {
|
||||
xxx_messageInfo_Params.Merge(m, src)
|
||||
}
|
||||
func (m *Params) XXX_Size() int {
|
||||
return m.Size()
|
||||
}
|
||||
func (m *Params) XXX_DiscardUnknown() {
|
||||
xxx_messageInfo_Params.DiscardUnknown(m)
|
||||
}
|
||||
|
||||
var xxx_messageInfo_Params proto.InternalMessageInfo
|
||||
|
||||
func init() {
|
||||
proto.RegisterType((*Params)(nil), "colinear.colinear.Params")
|
||||
}
|
||||
|
||||
func init() { proto.RegisterFile("colinear/params.proto", fileDescriptor_dec10d5375a626c5) }
|
||||
|
||||
var fileDescriptor_dec10d5375a626c5 = []byte{
|
||||
// 131 bytes of a gzipped FileDescriptorProto
|
||||
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x12, 0x4f, 0xce, 0x2f, 0xce,
|
||||
0xcd, 0x2f, 0x2e, 0x49, 0x2d, 0x2e, 0xd1, 0x2f, 0x48, 0x2c, 0x4a, 0xcc, 0x2d, 0xd6, 0x2b, 0x28,
|
||||
0xca, 0x2f, 0xc9, 0x17, 0x12, 0x45, 0x48, 0xe8, 0x21, 0x98, 0x52, 0x22, 0xe9, 0xf9, 0xe9, 0xf9,
|
||||
0x60, 0x15, 0xfa, 0x20, 0x16, 0x44, 0xb1, 0x12, 0x1f, 0x17, 0x5b, 0x00, 0x58, 0xb3, 0x15, 0xcb,
|
||||
0x8c, 0x05, 0xf2, 0x0c, 0x4e, 0x16, 0x27, 0x1e, 0xc9, 0x31, 0x5e, 0x78, 0x24, 0xc7, 0xf8, 0xe0,
|
||||
0x91, 0x1c, 0xe3, 0x84, 0xc7, 0x72, 0x0c, 0x17, 0x1e, 0xcb, 0x31, 0xdc, 0x78, 0x2c, 0xc7, 0x10,
|
||||
0x25, 0x07, 0x31, 0x4b, 0x17, 0x6c, 0x61, 0x85, 0x3e, 0x92, 0xed, 0x25, 0x95, 0x05, 0xa9, 0xc5,
|
||||
0x49, 0x6c, 0x60, 0x03, 0x8d, 0x01, 0x01, 0x00, 0x00, 0xff, 0xff, 0xc4, 0x4e, 0x2a, 0x32, 0x98,
|
||||
0x00, 0x00, 0x00,
|
||||
}
|
||||
|
||||
func (m *Params) 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 *Params) MarshalTo(dAtA []byte) (int, error) {
|
||||
size := m.Size()
|
||||
return m.MarshalToSizedBuffer(dAtA[:size])
|
||||
}
|
||||
|
||||
func (m *Params) MarshalToSizedBuffer(dAtA []byte) (int, error) {
|
||||
i := len(dAtA)
|
||||
_ = i
|
||||
var l int
|
||||
_ = l
|
||||
return len(dAtA) - i, nil
|
||||
}
|
||||
|
||||
func encodeVarintParams(dAtA []byte, offset int, v uint64) int {
|
||||
offset -= sovParams(v)
|
||||
base := offset
|
||||
for v >= 1<<7 {
|
||||
dAtA[offset] = uint8(v&0x7f | 0x80)
|
||||
v >>= 7
|
||||
offset++
|
||||
}
|
||||
dAtA[offset] = uint8(v)
|
||||
return base
|
||||
}
|
||||
func (m *Params) Size() (n int) {
|
||||
if m == nil {
|
||||
return 0
|
||||
}
|
||||
var l int
|
||||
_ = l
|
||||
return n
|
||||
}
|
||||
|
||||
func sovParams(x uint64) (n int) {
|
||||
return (math_bits.Len64(x|1) + 6) / 7
|
||||
}
|
||||
func sozParams(x uint64) (n int) {
|
||||
return sovParams(uint64((x << 1) ^ uint64((int64(x) >> 63))))
|
||||
}
|
||||
func (m *Params) 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 ErrIntOverflowParams
|
||||
}
|
||||
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: Params: wiretype end group for non-group")
|
||||
}
|
||||
if fieldNum <= 0 {
|
||||
return fmt.Errorf("proto: Params: illegal tag %d (wire type %d)", fieldNum, wire)
|
||||
}
|
||||
switch fieldNum {
|
||||
default:
|
||||
iNdEx = preIndex
|
||||
skippy, err := skipParams(dAtA[iNdEx:])
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if (skippy < 0) || (iNdEx+skippy) < 0 {
|
||||
return ErrInvalidLengthParams
|
||||
}
|
||||
if (iNdEx + skippy) > l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
iNdEx += skippy
|
||||
}
|
||||
}
|
||||
|
||||
if iNdEx > l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
return nil
|
||||
}
|
||||
func skipParams(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, ErrIntOverflowParams
|
||||
}
|
||||
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, ErrIntOverflowParams
|
||||
}
|
||||
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, ErrIntOverflowParams
|
||||
}
|
||||
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, ErrInvalidLengthParams
|
||||
}
|
||||
iNdEx += length
|
||||
case 3:
|
||||
depth++
|
||||
case 4:
|
||||
if depth == 0 {
|
||||
return 0, ErrUnexpectedEndOfGroupParams
|
||||
}
|
||||
depth--
|
||||
case 5:
|
||||
iNdEx += 4
|
||||
default:
|
||||
return 0, fmt.Errorf("proto: illegal wireType %d", wireType)
|
||||
}
|
||||
if iNdEx < 0 {
|
||||
return 0, ErrInvalidLengthParams
|
||||
}
|
||||
if depth == 0 {
|
||||
return iNdEx, nil
|
||||
}
|
||||
}
|
||||
return 0, io.ErrUnexpectedEOF
|
||||
}
|
||||
|
||||
var (
|
||||
ErrInvalidLengthParams = fmt.Errorf("proto: negative length found during unmarshaling")
|
||||
ErrIntOverflowParams = fmt.Errorf("proto: integer overflow")
|
||||
ErrUnexpectedEndOfGroupParams = fmt.Errorf("proto: unexpected end of group")
|
||||
)
|
||||
2112
x/colinear-core/types/query.pb.go
Normal file
2112
x/colinear-core/types/query.pb.go
Normal file
File diff suppressed because it is too large
Load Diff
503
x/colinear-core/types/query.pb.gw.go
Normal file
503
x/colinear-core/types/query.pb.gw.go
Normal file
@@ -0,0 +1,503 @@
|
||||
// Code generated by protoc-gen-grpc-gateway. DO NOT EDIT.
|
||||
// source: colinear/query.proto
|
||||
|
||||
/*
|
||||
Package types is a reverse proxy.
|
||||
|
||||
It translates gRPC into RESTful JSON APIs.
|
||||
*/
|
||||
package types
|
||||
|
||||
import (
|
||||
"context"
|
||||
"io"
|
||||
"net/http"
|
||||
|
||||
"github.com/golang/protobuf/descriptor"
|
||||
"github.com/golang/protobuf/proto"
|
||||
"github.com/grpc-ecosystem/grpc-gateway/runtime"
|
||||
"github.com/grpc-ecosystem/grpc-gateway/utilities"
|
||||
"google.golang.org/grpc"
|
||||
"google.golang.org/grpc/codes"
|
||||
"google.golang.org/grpc/grpclog"
|
||||
"google.golang.org/grpc/metadata"
|
||||
"google.golang.org/grpc/status"
|
||||
)
|
||||
|
||||
// Suppress "imported and not used" errors
|
||||
var _ codes.Code
|
||||
var _ io.Reader
|
||||
var _ status.Status
|
||||
var _ = runtime.String
|
||||
var _ = utilities.NewDoubleArray
|
||||
var _ = descriptor.ForMessage
|
||||
var _ = metadata.Join
|
||||
|
||||
func request_Query_Params_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
||||
var protoReq QueryParamsRequest
|
||||
var metadata runtime.ServerMetadata
|
||||
|
||||
msg, err := client.Params(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
|
||||
return msg, metadata, err
|
||||
|
||||
}
|
||||
|
||||
func local_request_Query_Params_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
||||
var protoReq QueryParamsRequest
|
||||
var metadata runtime.ServerMetadata
|
||||
|
||||
msg, err := server.Params(ctx, &protoReq)
|
||||
return msg, metadata, err
|
||||
|
||||
}
|
||||
|
||||
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
|
||||
|
||||
}
|
||||
|
||||
func request_Query_AuctionBids_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
||||
var protoReq QueryAuctionBidsRequest
|
||||
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.AuctionBids(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
|
||||
return msg, metadata, err
|
||||
|
||||
}
|
||||
|
||||
func local_request_Query_AuctionBids_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
||||
var protoReq QueryAuctionBidsRequest
|
||||
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.AuctionBids(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.
|
||||
// Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterQueryHandlerFromEndpoint instead.
|
||||
func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, server QueryServer) error {
|
||||
|
||||
mux.Handle("GET", pattern_Query_Params_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_Params_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_Params_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
|
||||
|
||||
})
|
||||
|
||||
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()...)
|
||||
|
||||
})
|
||||
|
||||
mux.Handle("GET", pattern_Query_AuctionBids_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_AuctionBids_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_AuctionBids_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
|
||||
|
||||
})
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// RegisterQueryHandlerFromEndpoint is same as RegisterQueryHandler but
|
||||
// automatically dials to "endpoint" and closes the connection when "ctx" gets done.
|
||||
func RegisterQueryHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) {
|
||||
conn, err := grpc.Dial(endpoint, opts...)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer func() {
|
||||
if err != nil {
|
||||
if cerr := conn.Close(); cerr != nil {
|
||||
grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr)
|
||||
}
|
||||
return
|
||||
}
|
||||
go func() {
|
||||
<-ctx.Done()
|
||||
if cerr := conn.Close(); cerr != nil {
|
||||
grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr)
|
||||
}
|
||||
}()
|
||||
}()
|
||||
|
||||
return RegisterQueryHandler(ctx, mux, conn)
|
||||
}
|
||||
|
||||
// RegisterQueryHandler registers the http handlers for service Query to "mux".
|
||||
// The handlers forward requests to the grpc endpoint over "conn".
|
||||
func RegisterQueryHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error {
|
||||
return RegisterQueryHandlerClient(ctx, mux, NewQueryClient(conn))
|
||||
}
|
||||
|
||||
// RegisterQueryHandlerClient registers the http handlers for service Query
|
||||
// to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "QueryClient".
|
||||
// Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "QueryClient"
|
||||
// doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in
|
||||
// "QueryClient" to call the correct interceptors.
|
||||
func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, client QueryClient) error {
|
||||
|
||||
mux.Handle("GET", pattern_Query_Params_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_Params_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_Params_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
|
||||
|
||||
})
|
||||
|
||||
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()...)
|
||||
|
||||
})
|
||||
|
||||
mux.Handle("GET", pattern_Query_AuctionBids_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_AuctionBids_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_AuctionBids_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{"colinear", "colinear", "params"}, "", runtime.AssumeColonVerbOpt(true)))
|
||||
|
||||
pattern_Query_NextAuction_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"colinear", "colinear", "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{"colinear", "colinear", "auction", "index"}, "", runtime.AssumeColonVerbOpt(true)))
|
||||
|
||||
pattern_Query_AuctionAll_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"colinear", "colinear", "auction"}, "", runtime.AssumeColonVerbOpt(true)))
|
||||
|
||||
pattern_Query_AuctionBids_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 1, 5, 3}, []string{"colinear", "colinear", "auction_bids", "index"}, "", 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
|
||||
|
||||
forward_Query_AuctionBids_0 = runtime.ForwardResponseMessage
|
||||
)
|
||||
1247
x/colinear-core/types/tx.pb.go
Normal file
1247
x/colinear-core/types/tx.pb.go
Normal file
File diff suppressed because it is too large
Load Diff
1
x/colinear-core/types/types.go
Normal file
1
x/colinear-core/types/types.go
Normal file
@@ -0,0 +1 @@
|
||||
package types
|
||||
Reference in New Issue
Block a user