-
Notifications
You must be signed in to change notification settings - Fork 28
/
auction.go
79 lines (65 loc) · 1.84 KB
/
auction.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
package types
import (
"time"
"github.com/OmniFlix/omniflixhub/v2/x/marketplace/exported"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/gogoproto/proto"
)
var (
_ proto.Message = &AuctionListing{}
_ exported.AuctionListingI = &AuctionListing{}
)
func NewAuctionListing(id uint64, nftId, denomId string, startTime time.Time, endTime *time.Time, startPrice sdk.Coin, incrementPercentage sdk.Dec,
owner sdk.AccAddress, whitelistAccounts []string, splitShares []WeightedAddress,
) AuctionListing {
return AuctionListing{
Id: id,
NftId: nftId,
DenomId: denomId,
StartTime: startTime,
EndTime: endTime,
StartPrice: startPrice,
IncrementPercentage: incrementPercentage,
Owner: owner.String(),
WhitelistAccounts: whitelistAccounts,
SplitShares: splitShares,
}
}
func (al AuctionListing) GetId() uint64 {
return al.Id
}
func (al AuctionListing) GetDenomId() string {
return al.DenomId
}
func (al AuctionListing) GetNftId() string {
return al.NftId
}
func (al AuctionListing) GetStartTime() time.Time {
return al.StartTime
}
func (al AuctionListing) GetStartPrice() sdk.Coin {
return al.StartPrice
}
func (al AuctionListing) GetIncrementPercentage() sdk.Dec {
return al.IncrementPercentage
}
func (al AuctionListing) GetOwner() sdk.AccAddress {
owner, _ := sdk.AccAddressFromBech32(al.Owner)
return owner
}
func (al AuctionListing) GetSplitShares() interface{} {
return al.SplitShares
}
func (al AuctionListing) GetStatus() string {
if al.StartTime.Before(time.Now()) {
return AUCTION_STATUS_ACTIVE.String()
}
return AUCTION_STATUS_INACTIVE.String()
}
func ValidAuctionStatus(status AuctionStatus) bool {
if status == AUCTION_STATUS_INACTIVE ||
status == AUCTION_STATUS_ACTIVE {
return true
}
return false
}