Setup hooks between laconic modules #9
@ -10,8 +10,6 @@ type AuctionUsageKeeper interface {
|
||||
ModuleName() string
|
||||
UsesAuction(ctx sdk.Context, auctionId string) bool
|
||||
|
||||
OnAuction(ctx sdk.Context, auctionId string)
|
||||
OnAuctionBid(ctx sdk.Context, auctionId string, bidderAddress string)
|
||||
OnAuctionWinnerSelected(ctx sdk.Context, auctionId string)
|
||||
}
|
||||
|
||||
|
@ -62,8 +62,6 @@ func newBidsIndexes(sb *collections.SchemaBuilder) BidsIndexes {
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: Add required methods
|
||||
|
||||
type Keeper struct {
|
||||
// Codecs
|
||||
cdc codec.BinaryCodec
|
||||
@ -120,16 +118,7 @@ func (k *Keeper) SetUsageKeepers(usageKeepers []auctiontypes.AuctionUsageKeeper)
|
||||
|
||||
// SaveAuction - saves a auction to the store.
|
||||
func (k Keeper) SaveAuction(ctx sdk.Context, auction *auctiontypes.Auction) error {
|
||||
if err := k.Auctions.Set(ctx, auction.Id, *auction); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// Notify interested parties.
|
||||
for _, keeper := range k.usageKeepers {
|
||||
keeper.OnAuction(ctx, auction.Id)
|
||||
}
|
||||
|
||||
return nil
|
||||
return k.Auctions.Set(ctx, auction.Id, *auction)
|
||||
}
|
||||
|
||||
// DeleteAuction - deletes the auction.
|
||||
@ -160,16 +149,7 @@ func (k Keeper) HasAuction(ctx sdk.Context, id string) (bool, error) {
|
||||
|
||||
func (k Keeper) SaveBid(ctx sdk.Context, bid *auctiontypes.Bid) error {
|
||||
key := collections.Join(bid.AuctionId, bid.BidderAddress)
|
||||
if err := k.Bids.Set(ctx, key, *bid); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// Notify interested parties.
|
||||
for _, keeper := range k.usageKeepers {
|
||||
keeper.OnAuctionBid(ctx, bid.AuctionId, bid.BidderAddress)
|
||||
}
|
||||
|
||||
return nil
|
||||
return k.Bids.Set(ctx, key, *bid)
|
||||
}
|
||||
|
||||
func (k Keeper) DeleteBid(ctx sdk.Context, bid auctiontypes.Bid) error {
|
||||
@ -201,7 +181,6 @@ func (k Keeper) GetBid(ctx sdk.Context, id string, bidder string) (auctiontypes.
|
||||
func (k Keeper) GetBids(ctx sdk.Context, id string) ([]*auctiontypes.Bid, error) {
|
||||
var bids []*auctiontypes.Bid
|
||||
|
||||
// TODO: Optimize using return by value?
|
||||
err := k.Bids.Walk(ctx, collections.NewPrefixedPairRange[string, string](id), func(key collections.Pair[string, string], value auctiontypes.Bid) (stop bool, err error) {
|
||||
bids = append(bids, &value)
|
||||
return false, nil
|
||||
|
@ -20,8 +20,6 @@ import (
|
||||
"git.vdb.to/cerc-io/laconic2d/x/auction/keeper"
|
||||
)
|
||||
|
||||
// TODO: Port remaining AppModule methods
|
||||
|
||||
var (
|
||||
_ module.AppModuleBasic = AppModule{}
|
||||
_ appmodule.AppModule = AppModule{}
|
||||
|
@ -18,8 +18,6 @@ import (
|
||||
"git.vdb.to/cerc-io/laconic2d/x/bond/keeper"
|
||||
)
|
||||
|
||||
// TODO: Port remaining AppModule methods
|
||||
|
||||
var (
|
||||
_ module.AppModuleBasic = AppModule{}
|
||||
_ appmodule.AppModule = AppModule{}
|
||||
|
@ -43,12 +43,6 @@ func (k *Keeper) InitGenesis(ctx sdk.Context, data *registry.GenesisState) error
|
||||
if err := k.insertAuthorityExpiryQueue(ctx, authority.Name, authority.Entry.ExpiryTime); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// TODO
|
||||
// Note: Bond genesis runs first, so bonds will already be present.
|
||||
// if authority.Entry.BondId != "" {
|
||||
// k.AddBondToAuthorityIndexEntry(ctx, authority.Entry.BondId, authority.Name)
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -29,8 +29,6 @@ import (
|
||||
"git.vdb.to/cerc-io/laconic2d/x/registry/helpers"
|
||||
)
|
||||
|
||||
// TODO: Add required methods
|
||||
|
||||
type RecordsIndexes struct {
|
||||
BondId *indexes.Multi[string, string, registrytypes.Record]
|
||||
}
|
||||
@ -51,7 +49,6 @@ func newRecordIndexes(sb *collections.SchemaBuilder) RecordsIndexes {
|
||||
}
|
||||
}
|
||||
|
||||
// TODO
|
||||
type AuthoritiesIndexes struct {
|
||||
AuctionId *indexes.Multi[string, string, registrytypes.NameAuthority]
|
||||
}
|
||||
@ -287,7 +284,7 @@ func (k Keeper) SetRecord(ctx sdk.Context, msg registrytypes.MsgSetRecord) (*reg
|
||||
|
||||
// Sort owners list.
|
||||
sort.Strings(record.Owners)
|
||||
sdkErr := k.processRecord(ctx, &record, false)
|
||||
sdkErr := k.processRecord(ctx, &record)
|
||||
if sdkErr != nil {
|
||||
return nil, sdkErr
|
||||
}
|
||||
@ -295,7 +292,7 @@ func (k Keeper) SetRecord(ctx sdk.Context, msg registrytypes.MsgSetRecord) (*reg
|
||||
return &record, nil
|
||||
}
|
||||
|
||||
func (k Keeper) processRecord(ctx sdk.Context, record *registrytypes.ReadableRecord, isRenewal bool) error {
|
||||
func (k Keeper) processRecord(ctx sdk.Context, record *registrytypes.ReadableRecord) error {
|
||||
params, err := k.GetParams(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
@ -433,7 +430,6 @@ func (k Keeper) GetModuleBalances(ctx sdk.Context) []*registrytypes.AccountBalan
|
||||
|
||||
// ProcessRecordExpiryQueue tries to renew expiring records (by collecting rent) else marks them as deleted.
|
||||
func (k Keeper) ProcessRecordExpiryQueue(ctx sdk.Context) error {
|
||||
// TODO: process expired records
|
||||
cids, err := k.getAllExpiredRecords(ctx, ctx.BlockHeader().Time)
|
||||
if err != nil {
|
||||
return err
|
||||
|
@ -132,7 +132,6 @@ func (k Keeper) SaveNameRecord(ctx sdk.Context, crn string, id string) error {
|
||||
Height: uint64(ctx.BlockHeight()),
|
||||
}
|
||||
|
||||
// TODO: Check if index gets updated on entry updates
|
||||
return k.NameRecords.Set(ctx, crn, nameRecord)
|
||||
}
|
||||
|
||||
@ -271,12 +270,9 @@ func (k Keeper) createAuthority(ctx sdk.Context, name string, owner string, isRo
|
||||
// If auctions are enabled, clear out owner fields. They will be set after a winner is picked.
|
||||
authority.OwnerAddress = ""
|
||||
authority.OwnerPublicKey = ""
|
||||
|
||||
// Reset bond ID if required.
|
||||
if authority.BondId != "" || len(authority.BondId) != 0 {
|
||||
// TODO
|
||||
// k.RemoveBondToAuthorityIndexEntry(ctx, authority.BondId, name)
|
||||
authority.BondId = ""
|
||||
}
|
||||
authority.BondId = ""
|
||||
|
||||
params := auctiontypes.Params{
|
||||
CommitsDuration: moduleParams.AuthorityAuctionCommitsDuration,
|
||||
@ -294,10 +290,6 @@ func (k Keeper) createAuthority(ctx sdk.Context, name string, owner string, isRo
|
||||
return sdkErr
|
||||
}
|
||||
|
||||
// TODO
|
||||
// Create auction ID -> authority name index.
|
||||
// k.AddAuctionToAuthorityMapping(ctx, auction.Id, name)
|
||||
|
||||
authority.Status = registrytypes.AuthorityUnderAuction
|
||||
authority.AuctionId = auction.Id
|
||||
authority.ExpiryTime = auction.RevealsEndTime.Add(moduleParams.AuthorityGracePeriod)
|
||||
@ -351,22 +343,12 @@ func (k Keeper) SetAuthorityBond(ctx sdk.Context, msg registrytypes.MsgSetAuthor
|
||||
return nil
|
||||
}
|
||||
|
||||
// TODO
|
||||
// Remove old bond ID mapping, if any.
|
||||
// if authority.BondId != "" {
|
||||
// k.RemoveBondToAuthorityIndexEntry(ctx, authority.BondId, name)
|
||||
// }
|
||||
|
||||
// Update bond id and save name authority in store.
|
||||
authority.BondId = bond.Id
|
||||
if err = k.SaveNameAuthority(ctx, name, &authority); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// TODO
|
||||
// Add new bond ID mapping.
|
||||
// k.AddBondToAuthorityIndexEntry(ctx, authority.BondId, name)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
|
@ -16,8 +16,6 @@ import (
|
||||
registrytypes "git.vdb.to/cerc-io/laconic2d/x/registry"
|
||||
)
|
||||
|
||||
// TODO: Add methods
|
||||
|
||||
// Record keeper implements the bond usage keeper interface.
|
||||
var (
|
||||
_ auctiontypes.AuctionUsageKeeper = RecordKeeper{}
|
||||
@ -54,14 +52,6 @@ func (rk RecordKeeper) UsesAuction(ctx sdk.Context, auctionId string) bool {
|
||||
return iter.Valid()
|
||||
}
|
||||
|
||||
func (rk RecordKeeper) OnAuction(ctx sdk.Context, auctionId string) {
|
||||
// no-op
|
||||
}
|
||||
|
||||
func (rk RecordKeeper) OnAuctionBid(ctx sdk.Context, auctionId string, bidderAddress string) {
|
||||
// no-op
|
||||
}
|
||||
|
||||
func (rk RecordKeeper) OnAuctionWinnerSelected(ctx sdk.Context, auctionId string) {
|
||||
// Update authority status based on auction status/winner.
|
||||
iter, err := rk.k.Authorities.Indexes.AuctionId.MatchExact(ctx, auctionId)
|
||||
@ -168,7 +158,7 @@ func (k Keeper) RenewRecord(ctx sdk.Context, msg registrytypes.MsgRenewRecord) e
|
||||
}
|
||||
|
||||
readableRecord := record.ToReadableRecord()
|
||||
return k.processRecord(ctx, &readableRecord, true)
|
||||
return k.processRecord(ctx, &readableRecord)
|
||||
}
|
||||
|
||||
// AssociateBond associates a record with a bond.
|
||||
|
Loading…
Reference in New Issue
Block a user