add deadline to auctions

master
michael 2022-09-01 19:13:17 +00:00
parent 5d71effb7f
commit 338b7d075a
8 changed files with 144 additions and 41 deletions

View File

@ -4,6 +4,7 @@ import (
"os"
"cosmos-test/app"
svrcmd "github.com/cosmos/cosmos-sdk/server/cmd"
"github.com/ignite/cli/ignite/pkg/cosmoscmd"
)

View File

@ -20159,6 +20159,9 @@ paths:
type: string
owner:
type: string
leaseEnd:
type: string
format: uint64
pagination:
type: object
properties:
@ -20251,6 +20254,16 @@ paths:
in: query
required: false
type: boolean
- name: pagination.reverse
description: >-
reverse is set to true if results are to be returned in the
descending order.
Since: cosmos-sdk 0.43
in: query
required: false
type: boolean
tags:
- Query
'/cosmos-test/cosmostest/auction/{index}':
@ -20288,6 +20301,9 @@ paths:
type: string
owner:
type: string
leaseEnd:
type: string
format: uint64
default:
description: An unexpected error response.
schema:
@ -47474,6 +47490,9 @@ definitions:
type: string
owner:
type: string
leaseEnd:
type: string
format: uint64
cosmostest.cosmostest.Bid:
type: object
properties:
@ -47527,6 +47546,9 @@ definitions:
type: string
owner:
type: string
leaseEnd:
type: string
format: uint64
pagination:
type: object
properties:
@ -47592,6 +47614,9 @@ definitions:
type: string
owner:
type: string
leaseEnd:
type: string
format: uint64
cosmostest.cosmostest.QueryGetNextAuctionResponse:
type: object
properties:

View File

@ -14,4 +14,5 @@ message Auction {
string ceiling = 6;
string denom = 7;
string owner = 8;
uint64 leaseEnd = 9;
}

View File

@ -18,6 +18,7 @@ message MsgNewAuction {
string description = 3;
string ceiling = 4;
string denom = 5;
uint64 leaseEnd = 6;
}
message MsgNewAuctionResponse {

View File

@ -20,7 +20,7 @@ func (k *Keeper) AuctionIsExpired(ctx types.Context, auctionId string) (bool, er
return uint64(ctx.BlockHeight()) >= auction.Deadline, nil
}
func (k *Keeper) EndExpiredAuctions(ctx types.Context) {
func (k *Keeper) FinalizeExpiredAuctions(ctx types.Context) {
memdb.BidDB.ForEachAuction(func(auctionId string) error {
auction, found := k.GetAuction(ctx, auctionId)
// make sure the auction exists on-chain
@ -61,3 +61,7 @@ func (k *Keeper) EndExpiredAuctions(ctx types.Context) {
return nil
})
}
func (k *Keeper) VestAuctionPayments(ctx types.Context) {
}

View File

@ -178,7 +178,7 @@ func (am AppModule) BeginBlock(_ sdk.Context, _ abci.RequestBeginBlock) {}
// returns no validator updates.
func (am AppModule) EndBlock(ctx sdk.Context, _ abci.RequestEndBlock) []abci.ValidatorUpdate {
am.keeper.EndExpiredAuctions(ctx)
am.keeper.FinalizeExpiredAuctions(ctx)
return []abci.ValidatorUpdate{}
}

View File

@ -31,6 +31,7 @@ type Auction struct {
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"`
LeaseEnd uint64 `protobuf:"varint,9,opt,name=leaseEnd,proto3" json:"leaseEnd,omitempty"`
}
func (m *Auction) Reset() { *m = Auction{} }
@ -122,6 +123,13 @@ func (m *Auction) GetOwner() string {
return ""
}
func (m *Auction) GetLeaseEnd() uint64 {
if m != nil {
return m.LeaseEnd
}
return 0
}
func init() {
proto.RegisterType((*Auction)(nil), "cosmostest.cosmostest.Auction")
}
@ -129,24 +137,24 @@ func init() {
func init() { proto.RegisterFile("cosmostest/auction.proto", fileDescriptor_631f6f59914101d9) }
var fileDescriptor_631f6f59914101d9 = []byte{
// 257 bytes of a gzipped FileDescriptorProto
// 271 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x6c, 0x90, 0xb1, 0x4e, 0xc3, 0x30,
0x10, 0x86, 0x6b, 0x48, 0x9b, 0xe2, 0x6e, 0x56, 0x91, 0x4e, 0x19, 0xac, 0x88, 0x29, 0x0b, 0xae,
0x04, 0x0b, 0x2b, 0x7d, 0x84, 0x8c, 0x6c, 0x49, 0x7c, 0x42, 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, 0x58, 0x66, 0x24, 0x8f, 0x8b,
0x3f, 0x66, 0x40, 0x93, 0x1a, 0x55, 0xa3, 0xf4, 0x0b, 0xac, 0xbc, 0xd3, 0x19, 0xa7, 0xc4, 0x12,
0xb5, 0x69, 0x21, 0x09, 0x89, 0x3d, 0x4c, 0xaa, 0x79, 0xd3, 0xd8, 0xc3, 0x3a, 0xa8, 0x1e, 0x26,
0x87, 0x06, 0x4b, 0x8b, 0x4f, 0x5a, 0xc2, 0x26, 0x38, 0x9c, 0xf9, 0xf0, 0xf0, 0x35, 0x70, 0x72,
0x1a, 0x38, 0xf9, 0x19, 0x38, 0xf9, 0x1c, 0x79, 0x74, 0x1a, 0x79, 0xf4, 0x3d, 0xf2, 0xe8, 0x99,
0x87, 0xb4, 0xb7, 0xbe, 0xb6, 0xe3, 0x7e, 0xd6, 0xa1, 0x7b, 0xef, 0xd0, 0x56, 0x2b, 0x5f, 0xe3,
0xfd, 0x6f, 0x00, 0x00, 0x00, 0xff, 0xff, 0x23, 0x2c, 0x20, 0x51, 0x8f, 0x01, 0x00, 0x00,
}
func (m *Auction) Marshal() (dAtA []byte, err error) {
@ -169,6 +177,11 @@ func (m *Auction) MarshalToSizedBuffer(dAtA []byte) (int, error) {
_ = i
var l int
_ = l
if m.LeaseEnd != 0 {
i = encodeVarintAuction(dAtA, i, uint64(m.LeaseEnd))
i--
dAtA[i] = 0x48
}
if len(m.Owner) > 0 {
i -= len(m.Owner)
copy(dAtA[i:], m.Owner)
@ -279,6 +292,9 @@ func (m *Auction) Size() (n int) {
if l > 0 {
n += 1 + l + sovAuction(uint64(l))
}
if m.LeaseEnd != 0 {
n += 1 + sovAuction(uint64(m.LeaseEnd))
}
return n
}
@ -564,6 +580,25 @@ func (m *Auction) Unmarshal(dAtA []byte) error {
}
m.Owner = string(dAtA[iNdEx:postIndex])
iNdEx = postIndex
case 9:
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
}
}
default:
iNdEx = preIndex
skippy, err := skipAuction(dAtA[iNdEx:])

View File

@ -33,6 +33,7 @@ type MsgNewAuction struct {
Description string `protobuf:"bytes,3,opt,name=description,proto3" json:"description,omitempty"`
Ceiling string `protobuf:"bytes,4,opt,name=ceiling,proto3" json:"ceiling,omitempty"`
Denom string `protobuf:"bytes,5,opt,name=denom,proto3" json:"denom,omitempty"`
LeaseEnd uint64 `protobuf:"varint,6,opt,name=leaseEnd,proto3" json:"leaseEnd,omitempty"`
}
func (m *MsgNewAuction) Reset() { *m = MsgNewAuction{} }
@ -103,6 +104,13 @@ func (m *MsgNewAuction) GetDenom() string {
return ""
}
func (m *MsgNewAuction) GetLeaseEnd() uint64 {
if m != nil {
return m.LeaseEnd
}
return 0
}
type MsgNewAuctionResponse struct {
AuctionId string `protobuf:"bytes,1,opt,name=auctionId,proto3" json:"auctionId,omitempty"`
}
@ -253,28 +261,29 @@ func init() {
func init() { proto.RegisterFile("cosmostest/tx.proto", fileDescriptor_2fcd5aa4ac15d93c) }
var fileDescriptor_2fcd5aa4ac15d93c = []byte{
// 321 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x92, 0x3f, 0x4f, 0xf3, 0x30,
0x10, 0xc6, 0xeb, 0xb7, 0x7f, 0x5e, 0xf5, 0x80, 0x01, 0x97, 0x22, 0xab, 0x42, 0x56, 0x15, 0x31,
0x74, 0x80, 0x54, 0x02, 0x21, 0xb1, 0xd2, 0x8d, 0xa1, 0x0c, 0x15, 0x13, 0x13, 0x21, 0xb6, 0x2a,
0x4b, 0xc4, 0x8e, 0x62, 0x57, 0x84, 0x4f, 0x01, 0x5f, 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 0x53, 0x7b, 0x57, 0x1f,
0x33, 0x4e, 0xa6, 0x33, 0x4e, 0xbe, 0x66, 0x9c, 0xbc, 0xce, 0x79, 0x65, 0x3a, 0xe7, 0x95, 0xcf,
0x39, 0xaf, 0x3c, 0xf0, 0xc2, 0x77, 0x66, 0x6f, 0x6c, 0xd2, 0x5d, 0x3d, 0xb8, 0x97, 0x0c, 0xf5,
0x93, 0x67, 0x8f, 0xee, 0xe2, 0x3b, 0x00, 0x00, 0xff, 0xff, 0x58, 0xb3, 0x7c, 0x83, 0x8b, 0x02,
0x00, 0x00,
}
// Reference imports to suppress errors if they are not otherwise used.
@ -413,6 +422,11 @@ func (m *MsgNewAuction) MarshalToSizedBuffer(dAtA []byte) (int, error) {
_ = i
var l int
_ = l
if m.LeaseEnd != 0 {
i = encodeVarintTx(dAtA, i, uint64(m.LeaseEnd))
i--
dAtA[i] = 0x30
}
if len(m.Denom) > 0 {
i -= len(m.Denom)
copy(dAtA[i:], m.Denom)
@ -585,6 +599,9 @@ func (m *MsgNewAuction) Size() (n int) {
if l > 0 {
n += 1 + l + sovTx(uint64(l))
}
if m.LeaseEnd != 0 {
n += 1 + sovTx(uint64(m.LeaseEnd))
}
return n
}
@ -826,6 +843,25 @@ func (m *MsgNewAuction) Unmarshal(dAtA []byte) error {
}
m.Denom = string(dAtA[iNdEx:postIndex])
iNdEx = postIndex
case 6:
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 ErrIntOverflowTx
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
m.LeaseEnd |= uint64(b&0x7F) << shift
if b < 0x80 {
break
}
}
default:
iNdEx = preIndex
skippy, err := skipTx(dAtA[iNdEx:])