fix: rollback to tendermint v0.34.21 #38
@ -34,7 +34,7 @@ type queryResolver struct{ *Resolver }
|
||||
func (q queryResolver) LookupAuthorities(ctx context.Context, names []string) ([]*AuthorityRecord, error) {
|
||||
nsQueryClient := nstypes.NewQueryClient(q.ctx)
|
||||
auctionQueryClient := auctiontypes.NewQueryClient(q.ctx)
|
||||
var gqlResponse []*AuthorityRecord
|
||||
gqlResponse := []*AuthorityRecord{}
|
||||
|
||||
for _, name := range names {
|
||||
res, err := nsQueryClient.Whois(context.Background(), &nstypes.QueryWhoisRequest{Name: name})
|
||||
|
@ -3,6 +3,7 @@ package gql
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"reflect"
|
||||
"strconv"
|
||||
|
||||
@ -85,7 +86,7 @@ func getGQLRecord(ctx context.Context, resolver QueryResolver, record nstypes.Re
|
||||
|
||||
func getGQLNameRecord(record *nstypes.NameRecord) (*NameRecord, error) {
|
||||
if record == nil {
|
||||
return nil, nil
|
||||
return nil, fmt.Errorf("got nil record")
|
||||
}
|
||||
|
||||
records := make([]*NameRecordEntry, len(record.History))
|
||||
@ -166,6 +167,7 @@ func getReferences(ctx context.Context, resolver QueryResolver, r *nstypes.Recor
|
||||
var ids []string
|
||||
|
||||
for _, value := range r.Attributes {
|
||||
//nolint: all
|
||||
switch value.(type) {
|
||||
case interface{}:
|
||||
if obj, ok := value.(map[string]interface{}); ok {
|
||||
@ -186,7 +188,7 @@ func getAttributes(r *nstypes.RecordType) ([]*KeyValue, error) {
|
||||
}
|
||||
|
||||
func mapToKeyValuePairs(attrs map[string]interface{}) ([]*KeyValue, error) {
|
||||
var kvPairs []*KeyValue
|
||||
kvPairs := []*KeyValue{}
|
||||
|
||||
trueVal := true
|
||||
falseVal := false
|
||||
|
@ -134,7 +134,10 @@ func GetCmdCommitBid() *cobra.Command {
|
||||
}
|
||||
|
||||
// Save reveal file.
|
||||
ioutil.WriteFile(fmt.Sprintf("%s-%s.json", clientCtx.GetFromName(), commitHash), content, 0o600)
|
||||
err = ioutil.WriteFile(fmt.Sprintf("%s-%s.json", clientCtx.GetFromName(), commitHash), content, 0o600)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
msg := types.NewMsgCommitBid(auctionID, commitHash, clientCtx.GetFromAddress())
|
||||
err = msg.ValidateBasic()
|
||||
|
@ -32,7 +32,7 @@ func NewIntegrationTestSuite(cfg network.Config) *IntegrationTestSuite {
|
||||
return &IntegrationTestSuite{cfg: cfg}
|
||||
}
|
||||
|
||||
func (s *IntegrationTestSuite) SetupSuite() {
|
||||
func (s *IntegrationTestSuite) SetupSuite() { //nolint: all
|
||||
s.T().Log("setting up integration test suite")
|
||||
|
||||
var err error
|
||||
|
@ -274,7 +274,7 @@ func (suite *IntegrationTestSuite) TestGetCmdAuctionsByBidder() {
|
||||
}
|
||||
}
|
||||
|
||||
func (suite IntegrationTestSuite) createAuctionAndBid(createAuction, createBid bool) string {
|
||||
func (suite *IntegrationTestSuite) createAuctionAndBid(createAuction, createBid bool) string {
|
||||
val := suite.network.Validators[0]
|
||||
sr := suite.Require()
|
||||
auctionID := ""
|
||||
|
@ -27,7 +27,7 @@ func ExportGenesis(ctx sdk.Context, keeper keeper.Keeper) types.GenesisState {
|
||||
params := keeper.GetParams(ctx)
|
||||
auctions := keeper.ListAuctions(ctx)
|
||||
|
||||
var genesisAuctions []*types.Auction
|
||||
genesisAuctions := []*types.Auction{}
|
||||
for _, auction := range auctions {
|
||||
genesisAuctions = append(genesisAuctions, &auction)
|
||||
}
|
||||
|
@ -99,7 +99,7 @@ func GetBidIndexKey(auctionID string, bidder string) []byte {
|
||||
}
|
||||
|
||||
func GetAuctionBidsIndexPrefix(auctionID string) []byte {
|
||||
return append(append(PrefixAuctionBidsIndex, []byte(auctionID)...))
|
||||
return append(PrefixAuctionBidsIndex, []byte(auctionID)...)
|
||||
}
|
||||
|
||||
// SaveAuction - saves a auction to the store.
|
||||
@ -226,7 +226,7 @@ func (k Keeper) ListAuctions(ctx sdk.Context) []types.Auction {
|
||||
func (k Keeper) QueryAuctionsByOwner(ctx sdk.Context, ownerAddress string) []types.Auction {
|
||||
auctions := []types.Auction{}
|
||||
|
||||
ownerPrefix := append(prefixOwnerToAuctionsIndex, []byte(ownerAddress)...)
|
||||
ownerPrefix := append(prefixOwnerToAuctionsIndex, []byte(ownerAddress)...) //nolint: all
|
||||
store := ctx.KVStore(k.storeKey)
|
||||
itr := sdk.KVStorePrefixIterator(store, ownerPrefix)
|
||||
defer itr.Close()
|
||||
@ -247,9 +247,9 @@ func (k Keeper) QueryAuctionsByOwner(ctx sdk.Context, ownerAddress string) []typ
|
||||
func (k Keeper) QueryAuctionsByBidder(ctx sdk.Context, bidderAddress string) []types.Auction {
|
||||
auctions := []types.Auction{}
|
||||
|
||||
bidderPrefix := append(PrefixBidderToAuctionsIndex, []byte(bidderAddress)...)
|
||||
bidderPrefix := append(PrefixBidderToAuctionsIndex, []byte(bidderAddress)...) //nolint: all
|
||||
store := ctx.KVStore(k.storeKey)
|
||||
itr := sdk.KVStorePrefixIterator(store, []byte(bidderPrefix))
|
||||
itr := sdk.KVStorePrefixIterator(store, bidderPrefix)
|
||||
defer itr.Close()
|
||||
for ; itr.Valid(); itr.Next() {
|
||||
auctionID := itr.Key()[len(bidderPrefix):]
|
||||
@ -312,8 +312,8 @@ func (k Keeper) CreateAuction(ctx sdk.Context, msg types.MsgCreateAuction) (*typ
|
||||
|
||||
// Compute timestamps.
|
||||
now := ctx.BlockTime()
|
||||
commitsEndTime := now.Add(time.Duration(msg.CommitsDuration))
|
||||
revealsEndTime := now.Add(time.Duration(msg.CommitsDuration + msg.RevealsDuration))
|
||||
commitsEndTime := now.Add(msg.CommitsDuration)
|
||||
revealsEndTime := now.Add(msg.CommitsDuration + msg.RevealsDuration)
|
||||
|
||||
auction := types.Auction{
|
||||
Id: auctionID,
|
||||
@ -382,7 +382,7 @@ func (k Keeper) CommitBid(ctx sdk.Context, msg types.MsgCommitBid) (*types.Bid,
|
||||
return &bid, nil
|
||||
}
|
||||
|
||||
// RevealBid reeals a bid comitted earlier.
|
||||
// RevealBid reeals a bid committed earlier.
|
||||
func (k Keeper) RevealBid(ctx sdk.Context, msg types.MsgRevealBid) (*types.Auction, error) {
|
||||
if !k.HasAuction(ctx, msg.AuctionId) {
|
||||
return nil, sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "Auction not found.")
|
||||
@ -553,6 +553,7 @@ func (k Keeper) pickAuctionWinner(ctx sdk.Context, auction *types.Auction) {
|
||||
continue
|
||||
}
|
||||
|
||||
//nolint: all
|
||||
if highestBid.BidAmount.IsLT(bid.BidAmount) {
|
||||
ctx.Logger().Info(fmt.Sprintf("New highest bid %s %s", bid.BidderAddress, bid.BidAmount.String()))
|
||||
|
||||
@ -637,7 +638,7 @@ func (k Keeper) pickAuctionWinner(ctx sdk.Context, auction *types.Auction) {
|
||||
// Burn anything over the min. bid amount.
|
||||
amountToBurn := auction.WinningPrice.Sub(auction.MinimumBid)
|
||||
if amountToBurn.IsNegative() {
|
||||
ctx.Logger().Error(fmt.Sprintf("Auction coins to burn cannot be negative."))
|
||||
ctx.Logger().Error("Auction coins to burn cannot be negative.")
|
||||
panic("Auction coins to burn cannot be negative.")
|
||||
}
|
||||
|
||||
|
@ -56,7 +56,7 @@ func (b AppModuleBasic) ValidateGenesis(cdc codec.JSONCodec, config client.TxEnc
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to unmarshal %s genesis state: %w", types.ModuleName, err)
|
||||
}
|
||||
// Once json successfully marshalled, passes along to genesis.go
|
||||
// Once json successfully marshaled, passes along to genesis.go
|
||||
return ValidateGenesis(data)
|
||||
}
|
||||
|
||||
|
@ -50,7 +50,7 @@ func NewCreateBondCmd() *cobra.Command {
|
||||
},
|
||||
}
|
||||
|
||||
flags.AddTxFlags(cmd)
|
||||
cmd, _ = flags.AddTxFlags(cmd)
|
||||
return cmd
|
||||
}
|
||||
|
||||
@ -75,8 +75,8 @@ func RefillBondCmd() *cobra.Command {
|
||||
return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), &msg)
|
||||
},
|
||||
}
|
||||
flags.AddTxFlags(cmd)
|
||||
|
||||
cmd, _ = flags.AddTxFlags(cmd)
|
||||
return cmd
|
||||
}
|
||||
|
||||
@ -101,12 +101,12 @@ func WithdrawBondCmd() *cobra.Command {
|
||||
return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), &msg)
|
||||
},
|
||||
}
|
||||
flags.AddTxFlags(cmd)
|
||||
|
||||
cmd, _ = flags.AddTxFlags(cmd)
|
||||
return cmd
|
||||
}
|
||||
|
||||
// CancelBondCmd is the CLI command for cancelling a bond.
|
||||
// CancelBondCmd is the CLI command for canceling a bond.
|
||||
func CancelBondCmd() *cobra.Command {
|
||||
cmd := &cobra.Command{
|
||||
Use: "cancel [bond Id]",
|
||||
@ -122,6 +122,7 @@ func CancelBondCmd() *cobra.Command {
|
||||
return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), &msg)
|
||||
},
|
||||
}
|
||||
flags.AddTxFlags(cmd)
|
||||
|
||||
cmd, _ = flags.AddTxFlags(cmd)
|
||||
return cmd
|
||||
}
|
||||
|
@ -242,7 +242,7 @@ func (s *IntegrationTestSuite) TestTxCancelBond() {
|
||||
testCases := []struct {
|
||||
name string
|
||||
args []string
|
||||
getBondId bool
|
||||
getBondID bool
|
||||
err bool
|
||||
}{
|
||||
{
|
||||
@ -275,7 +275,7 @@ func (s *IntegrationTestSuite) TestTxCancelBond() {
|
||||
s.Run(fmt.Sprintf("Case %s", tc.name), func() {
|
||||
clientCtx := val.ClientCtx
|
||||
cmd := cli.CancelBondCmd()
|
||||
if tc.getBondId {
|
||||
if tc.getBondID {
|
||||
cmd := cli.GetQueryBondLists()
|
||||
|
||||
out, err := clitestutil.ExecTestCLICmd(clientCtx, cmd, []string{
|
||||
|
@ -119,10 +119,7 @@ func (k Keeper) CreateBond(ctx sdk.Context, ownerAddress sdk.AccAddress, coins s
|
||||
Sequence: account.GetSequence(),
|
||||
}.Generate()
|
||||
|
||||
maxBondAmount, err := k.getMaxBondAmount(ctx)
|
||||
if err != nil {
|
||||
return nil, sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "Invalid max bond amount.")
|
||||
}
|
||||
maxBondAmount := k.getMaxBondAmount(ctx)
|
||||
|
||||
bond := types.Bond{Id: bondID, Owner: ownerAddress.String(), Balance: coins}
|
||||
if bond.Balance.IsAnyGT(maxBondAmount) {
|
||||
@ -130,7 +127,7 @@ func (k Keeper) CreateBond(ctx sdk.Context, ownerAddress sdk.AccAddress, coins s
|
||||
}
|
||||
|
||||
// Move funds into the bond account module.
|
||||
err = k.bankKeeper.SendCoinsFromAccountToModule(ctx, ownerAddress, types.ModuleName, bond.Balance)
|
||||
err := k.bankKeeper.SendCoinsFromAccountToModule(ctx, ownerAddress, types.ModuleName, bond.Balance)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -198,7 +195,7 @@ func (k Keeper) ListBonds(ctx sdk.Context) []*types.Bond {
|
||||
func (k Keeper) QueryBondsByOwner(ctx sdk.Context, ownerAddress string) []types.Bond {
|
||||
var bonds []types.Bond
|
||||
|
||||
ownerPrefix := append(prefixOwnerToBondsIndex, []byte(ownerAddress)...)
|
||||
ownerPrefix := append(prefixOwnerToBondsIndex, []byte(ownerAddress)...) //nolint: all
|
||||
store := ctx.KVStore(k.storeKey)
|
||||
itr := sdk.KVStorePrefixIterator(store, ownerPrefix)
|
||||
defer itr.Close()
|
||||
@ -233,10 +230,7 @@ func (k Keeper) RefillBond(ctx sdk.Context, id string, ownerAddress sdk.AccAddre
|
||||
}
|
||||
}
|
||||
|
||||
maxBondAmount, err := k.getMaxBondAmount(ctx)
|
||||
if err != nil {
|
||||
return nil, sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "Invalid max bond amount.")
|
||||
}
|
||||
maxBondAmount := k.getMaxBondAmount(ctx)
|
||||
|
||||
updatedBalance := bond.Balance.Add(coins...)
|
||||
if updatedBalance.IsAnyGT(maxBondAmount) {
|
||||
@ -244,7 +238,7 @@ func (k Keeper) RefillBond(ctx sdk.Context, id string, ownerAddress sdk.AccAddre
|
||||
}
|
||||
|
||||
// Move funds into the bond account module.
|
||||
err = k.bankKeeper.SendCoinsFromAccountToModule(ctx, ownerAddress, types.ModuleName, coins)
|
||||
err := k.bankKeeper.SendCoinsFromAccountToModule(ctx, ownerAddress, types.ModuleName, coins)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -314,10 +308,10 @@ func (k Keeper) CancelBond(ctx sdk.Context, id string, ownerAddress sdk.AccAddre
|
||||
return &bond, nil
|
||||
}
|
||||
|
||||
func (k Keeper) getMaxBondAmount(ctx sdk.Context) (sdk.Coins, error) {
|
||||
func (k Keeper) getMaxBondAmount(ctx sdk.Context) sdk.Coins {
|
||||
params := k.GetParams(ctx)
|
||||
maxBondAmount := params.MaxBondAmount
|
||||
return sdk.NewCoins(maxBondAmount), nil
|
||||
return sdk.NewCoins(maxBondAmount)
|
||||
}
|
||||
|
||||
// GetBondModuleBalances gets the bond module account(s) balances.
|
||||
|
@ -75,7 +75,7 @@ $ %s tx %s set [payload file path] [bond-id]
|
||||
},
|
||||
}
|
||||
|
||||
flags.AddTxFlags(cmd)
|
||||
cmd, _ = flags.AddTxFlags(cmd)
|
||||
return cmd
|
||||
}
|
||||
|
||||
@ -107,7 +107,7 @@ $ %s tx %s renew-record [record-id]
|
||||
},
|
||||
}
|
||||
|
||||
flags.AddTxFlags(cmd)
|
||||
cmd, _ = flags.AddTxFlags(cmd)
|
||||
return cmd
|
||||
}
|
||||
|
||||
@ -139,7 +139,7 @@ $ %s tx %s associate-bond [record-id] [bond-id]
|
||||
},
|
||||
}
|
||||
|
||||
flags.AddTxFlags(cmd)
|
||||
cmd, _ = flags.AddTxFlags(cmd)
|
||||
return cmd
|
||||
}
|
||||
|
||||
@ -171,7 +171,7 @@ $ %s tx %s dissociate-bond [record-id]
|
||||
},
|
||||
}
|
||||
|
||||
flags.AddTxFlags(cmd)
|
||||
cmd, _ = flags.AddTxFlags(cmd)
|
||||
return cmd
|
||||
}
|
||||
|
||||
@ -203,7 +203,7 @@ $ %s tx %s dissociate-bond [record-id]
|
||||
},
|
||||
}
|
||||
|
||||
flags.AddTxFlags(cmd)
|
||||
cmd, _ = flags.AddTxFlags(cmd)
|
||||
return cmd
|
||||
}
|
||||
|
||||
@ -235,7 +235,7 @@ $ %s tx %s reassociate-records [old-bond-id] [new-bond-id]
|
||||
},
|
||||
}
|
||||
|
||||
flags.AddTxFlags(cmd)
|
||||
cmd, _ = flags.AddTxFlags(cmd)
|
||||
return cmd
|
||||
}
|
||||
|
||||
@ -268,7 +268,7 @@ $ %s tx %s set-name [crn] [cid]
|
||||
},
|
||||
}
|
||||
|
||||
flags.AddTxFlags(cmd)
|
||||
cmd, _ = flags.AddTxFlags(cmd)
|
||||
return cmd
|
||||
}
|
||||
|
||||
@ -312,7 +312,7 @@ $ %s tx %s reserve-name [name] --owner [ownerAddress]
|
||||
|
||||
cmd.Flags().String("owner", "", "Owner address, if creating a sub-authority.")
|
||||
|
||||
flags.AddTxFlags(cmd)
|
||||
cmd, _ = flags.AddTxFlags(cmd)
|
||||
return cmd
|
||||
}
|
||||
|
||||
@ -340,7 +340,7 @@ $ %s tx %s authority-bond [name] [bond-id]
|
||||
},
|
||||
}
|
||||
|
||||
flags.AddTxFlags(cmd)
|
||||
cmd, _ = flags.AddTxFlags(cmd)
|
||||
return cmd
|
||||
}
|
||||
|
||||
@ -367,7 +367,7 @@ $ %s tx %s delete-name [crn]
|
||||
},
|
||||
}
|
||||
|
||||
flags.AddTxFlags(cmd)
|
||||
cmd, _ = flags.AddTxFlags(cmd)
|
||||
return cmd
|
||||
}
|
||||
|
||||
|
@ -655,7 +655,7 @@ func (s *IntegrationTestSuite) TestGetCmdDissociateBond() {
|
||||
}
|
||||
|
||||
//
|
||||
//func (s *IntegrationTestSuite) TestGetCmdDissociateRecords() {
|
||||
// func (s *IntegrationTestSuite) TestGetCmdDissociateRecords() {
|
||||
// val := s.network.Validators[0]
|
||||
// sr := s.Require()
|
||||
// testCasesForDeletingName := []struct {
|
||||
@ -679,7 +679,7 @@ func (s *IntegrationTestSuite) TestGetCmdDissociateBond() {
|
||||
// return "", ""
|
||||
// },
|
||||
// func(recordId string, s *IntegrationTestSuite) {
|
||||
//
|
||||
|
||||
// },
|
||||
// },
|
||||
// {
|
||||
@ -700,7 +700,7 @@ func (s *IntegrationTestSuite) TestGetCmdDissociateBond() {
|
||||
// dir, err := os.Getwd()
|
||||
// sr.NoError(err)
|
||||
// payloadPath := dir + "/example1.yml"
|
||||
//
|
||||
|
||||
// args := []string{
|
||||
// payloadPath, bondId,
|
||||
// fmt.Sprintf("--%s=%s", flags.FlagFrom, accountName),
|
||||
@ -709,17 +709,17 @@ func (s *IntegrationTestSuite) TestGetCmdDissociateBond() {
|
||||
// fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock),
|
||||
// fmt.Sprintf("--%s=%s", flags.FlagFees, fmt.Sprintf("3%s", s.cfg.BondDenom)),
|
||||
// }
|
||||
//
|
||||
|
||||
// clientCtx := val.ClientCtx
|
||||
// cmd := cli.GetCmdSetRecord()
|
||||
//
|
||||
|
||||
// out, err := clitestutil.ExecTestCLICmd(clientCtx, cmd, args)
|
||||
// sr.NoError(err)
|
||||
// var d sdk.TxResponse
|
||||
// err = val.ClientCtx.Codec.UnmarshalJSON(out.Bytes(), &d)
|
||||
// sr.NoError(err)
|
||||
// sr.Zero(d.Code)
|
||||
//
|
||||
|
||||
// // retrieving the record-id
|
||||
// args = []string{fmt.Sprintf("--%s=json", tmcli.OutputFlag)}
|
||||
// cmd = cli.GetCmdList()
|
||||
@ -751,7 +751,7 @@ func (s *IntegrationTestSuite) TestGetCmdDissociateBond() {
|
||||
// },
|
||||
// },
|
||||
// }
|
||||
//
|
||||
|
||||
// for _, tc := range testCasesForDeletingName {
|
||||
// s.Run(fmt.Sprintf("Case %s", tc.name), func() {
|
||||
// var bondId string
|
||||
@ -762,7 +762,7 @@ func (s *IntegrationTestSuite) TestGetCmdDissociateBond() {
|
||||
// }
|
||||
// clientCtx := val.ClientCtx
|
||||
// cmd := cli.GetCmdDissociateRecords()
|
||||
//
|
||||
|
||||
// out, err := clitestutil.ExecTestCLICmd(clientCtx, cmd, tc.args)
|
||||
// if tc.err {
|
||||
// sr.Error(err)
|
||||
@ -777,7 +777,7 @@ func (s *IntegrationTestSuite) TestGetCmdDissociateBond() {
|
||||
// }
|
||||
// })
|
||||
// }
|
||||
//}
|
||||
// }
|
||||
|
||||
func (s *IntegrationTestSuite) TestGetCmdAssociateBond() {
|
||||
val := s.network.Validators[0]
|
||||
|
@ -59,7 +59,7 @@ func ExportGenesis(ctx sdk.Context, keeper keeper.Keeper) types.GenesisState {
|
||||
records := keeper.ListRecords(ctx)
|
||||
|
||||
authorities := keeper.ListNameAuthorityRecords(ctx)
|
||||
var authorityEntries []types.AuthorityEntry
|
||||
authorityEntries := []types.AuthorityEntry{}
|
||||
for name, record := range authorities {
|
||||
authorityEntries = append(authorityEntries, types.AuthorityEntry{
|
||||
Name: name,
|
||||
|
@ -43,7 +43,7 @@ func BytesArrToStringArr(val []byte) ([]string, error) {
|
||||
|
||||
func Int64ToBytes(num int64) []byte {
|
||||
buf := new(bytes.Buffer)
|
||||
binary.Write(buf, binary.BigEndian, num)
|
||||
_ = binary.Write(buf, binary.BigEndian, num)
|
||||
return buf.Bytes()
|
||||
}
|
||||
|
||||
|
@ -15,21 +15,21 @@ func RegisterInvariants(ir sdk.InvariantRegistry, k Keeper) {
|
||||
// (2) associated bond exists, if bondID is not null.
|
||||
func RecordInvariants(k Keeper) sdk.Invariant {
|
||||
return func(ctx sdk.Context) (string, bool) {
|
||||
//store := ctx.KVStore(k.storeKey)
|
||||
//itr := sdk.KVStorePrefixIterator(store, PrefixCIDToRecordIndex)
|
||||
//defer itr.Close()
|
||||
//for ; itr.Valid(); itr.Next() {
|
||||
// store := ctx.KVStore(k.storeKey)
|
||||
// itr := sdk.KVStorePrefixIterator(store, PrefixCIDToRecordIndex)
|
||||
// defer itr.Close()
|
||||
// for ; itr.Valid(); itr.Next() {
|
||||
// bz := store.Get(itr.Key())
|
||||
// if bz != nil {
|
||||
// var obj types.RecordObj
|
||||
// k.cdc.MustUnmarshalBinaryBare(bz, &obj)
|
||||
// record := obj.ToRecord()
|
||||
//
|
||||
|
||||
// if record.BondID != "" && !k.bondKeeper.HasBond(ctx, record.BondID) {
|
||||
// return sdk.FormatInvariant(types.ModuleName, "record-bond", fmt.Sprintf("Bond not found for record ID: '%s'.", record.ID)), true
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
// }
|
||||
|
||||
return "", false
|
||||
}
|
||||
|
@ -122,7 +122,7 @@ func (k Keeper) ListRecords(ctx sdk.Context) []types.Record {
|
||||
if bz != nil {
|
||||
var obj types.Record
|
||||
k.cdc.MustUnmarshal(bz, &obj)
|
||||
records = append(records, recordObjToRecord(store, k.cdc, obj))
|
||||
records = append(records, recordObjToRecord(store, obj))
|
||||
}
|
||||
}
|
||||
|
||||
@ -141,7 +141,7 @@ func (k Keeper) MatchRecords(ctx sdk.Context, matchFn func(*types.RecordType) bo
|
||||
if bz != nil {
|
||||
var obj types.Record
|
||||
k.cdc.MustUnmarshal(bz, &obj)
|
||||
obj = recordObjToRecord(store, k.cdc, obj)
|
||||
obj = recordObjToRecord(store, obj)
|
||||
record := obj.ToRecordType()
|
||||
if matchFn(&record) {
|
||||
records = append(records, obj)
|
||||
@ -419,7 +419,7 @@ func (k Keeper) GetModuleBalances(ctx sdk.Context) []*types.AccountBalance {
|
||||
return balances
|
||||
}
|
||||
|
||||
func recordObjToRecord(store sdk.KVStore, codec codec.BinaryCodec, record types.Record) types.Record {
|
||||
func recordObjToRecord(store sdk.KVStore, record types.Record) types.Record {
|
||||
reverseNameIndexKey := GetCIDToNamesIndexKey(record.Id)
|
||||
|
||||
if store.Has(reverseNameIndexKey) {
|
||||
|
@ -112,7 +112,7 @@ func (k RecordKeeper) GetAuctionToAuthorityMapping(ctx sdk.Context, auctionID st
|
||||
|
||||
// UsesBond returns true if the bond has associated records.
|
||||
func (k RecordKeeper) UsesBond(ctx sdk.Context, bondId string) bool {
|
||||
bondIDPrefix := append(PrefixBondIDToRecordsIndex, []byte(bondId)...)
|
||||
bondIDPrefix := append(PrefixBondIDToRecordsIndex, []byte(bondId)...) //nolint: all
|
||||
store := ctx.KVStore(k.storeKey)
|
||||
itr := sdk.KVStorePrefixIterator(store, bondIDPrefix)
|
||||
defer itr.Close()
|
||||
@ -138,7 +138,7 @@ func NewRecordKeeper(auctionKeeper auctionkeeper.Keeper, storeKey storetypes.Sto
|
||||
func (k RecordKeeper) QueryRecordsByBond(ctx sdk.Context, bondID string) []types.Record {
|
||||
var records []types.Record
|
||||
|
||||
bondIDPrefix := append(PrefixBondIDToRecordsIndex, []byte(bondID)...)
|
||||
bondIDPrefix := append(PrefixBondIDToRecordsIndex, []byte(bondID)...) //nolint: all
|
||||
store := ctx.KVStore(k.storeKey)
|
||||
itr := sdk.KVStorePrefixIterator(store, bondIDPrefix)
|
||||
defer itr.Close()
|
||||
@ -148,7 +148,7 @@ func (k RecordKeeper) QueryRecordsByBond(ctx sdk.Context, bondID string) []types
|
||||
if bz != nil {
|
||||
var obj types.Record
|
||||
k.cdc.MustUnmarshal(bz, &obj)
|
||||
records = append(records, recordObjToRecord(store, k.cdc, obj))
|
||||
records = append(records, recordObjToRecord(store, obj))
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user