From ddd01ccd8a491b9480cc5575416a6d544107f7a9 Mon Sep 17 00:00:00 2001 From: aleem1314 Date: Tue, 14 Mar 2023 11:29:38 +0530 Subject: [PATCH] wip: fix lint --- x/auction/keeper/keeper.go | 34 ++++++++++++++-------------- x/auction/types/msgs.go | 18 +++++++-------- x/bond/keeper/keeper.go | 26 ++++++++++----------- x/registry/keeper/grpc_query.go | 8 +++---- x/registry/keeper/naming_keeper.go | 36 +++++++++++++++--------------- x/registry/keeper/record_keeper.go | 30 ++++++++++++------------- x/registry/types/msg.go | 18 +++++++-------- x/registry/types/record_msg.go | 28 +++++++++++------------ 8 files changed, 99 insertions(+), 99 deletions(-) diff --git a/x/auction/keeper/keeper.go b/x/auction/keeper/keeper.go index 1ac41501..5bcbd704 100644 --- a/x/auction/keeper/keeper.go +++ b/x/auction/keeper/keeper.go @@ -307,7 +307,7 @@ func (k Keeper) CreateAuction(ctx sdk.Context, msg types.MsgCreateAuction) (*typ // Generate auction Id. account := k.accountKeeper.GetAccount(ctx, signerAddress) if account == nil { - return nil, errors.Wrap(sdkerrors.ErrInvalidAddress, "Account not found.") + return nil, errors.Wrap(sdkerrors.ErrInvalidAddress, "account not found") } auctionID := types.AuctionID{ @@ -346,7 +346,7 @@ func (k Keeper) CommitBid(ctx sdk.Context, msg types.MsgCommitBid) (*types.Bid, auction := k.GetAuction(ctx, msg.AuctionId) if auction.Status != types.AuctionStatusCommitPhase { - return nil, errors.Wrap(sdkerrors.ErrInvalidRequest, "Auction is not in commit phase.") + return nil, errors.Wrap(sdkerrors.ErrInvalidRequest, "auction is not in commit phase") } signerAddress, err := sdk.AccAddressFromBech32(msg.Signer) @@ -391,12 +391,12 @@ func (k Keeper) CommitBid(ctx sdk.Context, msg types.MsgCommitBid) (*types.Bid, // 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, errors.Wrap(sdkerrors.ErrInvalidRequest, "Auction not found.") + return nil, errors.Wrap(sdkerrors.ErrInvalidRequest, "auction not found") } auction := k.GetAuction(ctx, msg.AuctionId) if auction.Status != types.AuctionStatusRevealPhase { - return nil, errors.Wrap(sdkerrors.ErrInvalidRequest, "Auction is not in reveal phase.") + return nil, errors.Wrap(sdkerrors.ErrInvalidRequest, "auction is not in reveal phase") } signerAddress, err := sdk.AccAddressFromBech32(msg.Signer) @@ -405,65 +405,65 @@ func (k Keeper) RevealBid(ctx sdk.Context, msg types.MsgRevealBid) (*types.Aucti } if !k.HasBid(ctx, msg.AuctionId, signerAddress.String()) { - return nil, errors.Wrap(sdkerrors.ErrInvalidRequest, "Bid not found.") + return nil, errors.Wrap(sdkerrors.ErrInvalidRequest, "bid not found") } bid := k.GetBid(ctx, auction.Id, signerAddress.String()) if bid.Status != types.BidStatusCommitted { - return nil, errors.Wrap(sdkerrors.ErrInvalidRequest, "Bid not in committed state.") + return nil, errors.Wrap(sdkerrors.ErrInvalidRequest, "bid not in committed state") } revealBytes, err := hex.DecodeString(msg.Reveal) if err != nil { - return nil, errors.Wrap(sdkerrors.ErrInvalidRequest, "Invalid reveal string.") + return nil, errors.Wrap(sdkerrors.ErrInvalidRequest, "invalid reveal string") } cid, err := wnsUtils.CIDFromJSONBytes(revealBytes) if err != nil { - return nil, errors.Wrap(sdkerrors.ErrInvalidRequest, "Invalid reveal JSON.") + return nil, errors.Wrap(sdkerrors.ErrInvalidRequest, "invalid reveal JSON") } if bid.CommitHash != cid { - return nil, errors.Wrap(sdkerrors.ErrInvalidRequest, "Commit hash mismatch.") + return nil, errors.Wrap(sdkerrors.ErrInvalidRequest, "commit hash mismatch") } var reveal map[string]interface{} err = json.Unmarshal(revealBytes, &reveal) if err != nil { - return nil, errors.Wrap(sdkerrors.ErrInvalidRequest, "Reveal JSON unmarshal error.") + return nil, errors.Wrap(sdkerrors.ErrInvalidRequest, "reveal JSON unmarshal error") } chainID, err := wnsUtils.GetAttributeAsString(reveal, "chainId") if err != nil || chainID != ctx.ChainID() { - return nil, errors.Wrap(sdkerrors.ErrInvalidRequest, "Invalid reveal chainID.") + return nil, errors.Wrap(sdkerrors.ErrInvalidRequest, "invalid reveal chainID") } auctionID, err := wnsUtils.GetAttributeAsString(reveal, "auctionId") if err != nil || auctionID != msg.AuctionId { - return nil, errors.Wrap(sdkerrors.ErrInvalidRequest, "Invalid reveal auction Id.") + return nil, errors.Wrap(sdkerrors.ErrInvalidRequest, "invalid reveal auction Id") } bidderAddress, err := wnsUtils.GetAttributeAsString(reveal, "bidderAddress") if err != nil { - return nil, errors.Wrap(sdkerrors.ErrInvalidRequest, "Invalid reveal bid address.") + return nil, errors.Wrap(sdkerrors.ErrInvalidRequest, "invalid reveal bid address") } if bidderAddress != signerAddress.String() { - return nil, errors.Wrap(sdkerrors.ErrInvalidRequest, "Reveal bid address mismatch.") + return nil, errors.Wrap(sdkerrors.ErrInvalidRequest, "reveal bid address mismatch") } bidAmountStr, err := wnsUtils.GetAttributeAsString(reveal, "bidAmount") if err != nil { - return nil, errors.Wrap(sdkerrors.ErrInvalidRequest, "Invalid reveal bid amount.") + return nil, errors.Wrap(sdkerrors.ErrInvalidRequest, "invalid reveal bid amount") } bidAmount, err := sdk.ParseCoinNormalized(bidAmountStr) if err != nil { - return nil, errors.Wrap(sdkerrors.ErrInvalidRequest, "Invalid reveal bid amount.") + return nil, errors.Wrap(sdkerrors.ErrInvalidRequest, "invalid reveal bid amount") } if bidAmount.IsLT(auction.MinimumBid) { - return nil, errors.Wrap(sdkerrors.ErrInvalidRequest, "Bid is lower than minimum bid.") + return nil, errors.Wrap(sdkerrors.ErrInvalidRequest, "bid is lower than minimum bid") } // Lock bid amount. diff --git a/x/auction/types/msgs.go b/x/auction/types/msgs.go index 0b29e845..118e3e8f 100644 --- a/x/auction/types/msgs.go +++ b/x/auction/types/msgs.go @@ -37,15 +37,15 @@ func (msg MsgCreateAuction) ValidateBasic() error { } if msg.CommitsDuration <= 0 { - return errors.Wrap(sdkerrors.ErrInvalidRequest, "commit phase duration invalid.") + return errors.Wrap(sdkerrors.ErrInvalidRequest, "commit phase duration invalid") } if msg.RevealsDuration <= 0 { - return errors.Wrap(sdkerrors.ErrInvalidRequest, "reveal phase duration invalid.") + return errors.Wrap(sdkerrors.ErrInvalidRequest, "reveal phase duration invalid") } if !msg.MinimumBid.IsPositive() { - return errors.Wrap(sdkerrors.ErrInvalidRequest, "minimum bid should be greater than zero.") + return errors.Wrap(sdkerrors.ErrInvalidRequest, "minimum bid should be greater than zero") } return nil @@ -80,15 +80,15 @@ func (msg MsgCommitBid) Type() string { return "commit" } // ValidateBasic Implements Msg. func (msg MsgCommitBid) ValidateBasic() error { if msg.Signer == "" { - return errors.Wrap(sdkerrors.ErrInvalidAddress, "invalid signer address.") + return errors.Wrap(sdkerrors.ErrInvalidAddress, "invalid signer address") } if msg.AuctionId == "" { - return errors.Wrap(sdkerrors.ErrInvalidRequest, "invalid auction ID.") + return errors.Wrap(sdkerrors.ErrInvalidRequest, "invalid auction ID") } if msg.CommitHash == "" { - return errors.Wrap(sdkerrors.ErrInvalidRequest, "invalid commit hash.") + return errors.Wrap(sdkerrors.ErrInvalidRequest, "invalid commit hash") } return nil @@ -123,15 +123,15 @@ func (msg MsgRevealBid) Type() string { return "reveal" } // ValidateBasic Implements Msg. func (msg MsgRevealBid) ValidateBasic() error { if msg.Signer == "" { - return errors.Wrap(sdkerrors.ErrInvalidAddress, "invalid signer address.") + return errors.Wrap(sdkerrors.ErrInvalidAddress, "invalid signer address") } if msg.AuctionId == "" { - return errors.Wrap(sdkerrors.ErrInvalidRequest, "invalid auction ID.") + return errors.Wrap(sdkerrors.ErrInvalidRequest, "invalid auction ID") } if msg.Reveal == "" { - return errors.Wrap(sdkerrors.ErrInvalidRequest, "invalid reveal data.") + return errors.Wrap(sdkerrors.ErrInvalidRequest, "invalid reveal data") } return nil diff --git a/x/bond/keeper/keeper.go b/x/bond/keeper/keeper.go index 96be2037..0327678b 100644 --- a/x/bond/keeper/keeper.go +++ b/x/bond/keeper/keeper.go @@ -130,7 +130,7 @@ func (k Keeper) CreateBond(ctx sdk.Context, ownerAddress sdk.AccAddress, coins s bond := types.Bond{Id: bondID, Owner: ownerAddress.String(), Balance: coins} if bond.Balance.IsAnyGT(maxBondAmount) { - return nil, errors.Wrap(sdkerrors.ErrInvalidRequest, "Max bond amount exceeded.") + return nil, errors.Wrap(sdkerrors.ErrInvalidRequest, "Max bond amount exceeded") } // Move funds into the bond account module. @@ -222,18 +222,18 @@ func (k Keeper) QueryBondsByOwner(ctx sdk.Context, ownerAddress string) []types. // RefillBond refills an existing bond. func (k Keeper) RefillBond(ctx sdk.Context, id string, ownerAddress sdk.AccAddress, coins sdk.Coins) (*types.Bond, error) { if !k.HasBond(ctx, id) { - return nil, errors.Wrap(sdkerrors.ErrInvalidRequest, "Bond not found.") + return nil, errors.Wrap(sdkerrors.ErrInvalidRequest, "bond not found") } bond := k.GetBond(ctx, id) if bond.Owner != ownerAddress.String() { - return nil, errors.Wrap(sdkerrors.ErrUnauthorized, "Bond owner mismatch.") + return nil, errors.Wrap(sdkerrors.ErrUnauthorized, "bond owner mismatch") } // Check if account has funds. for _, coin := range coins { if !k.bankKeeper.HasBalance(ctx, ownerAddress, coin) { - return nil, errors.Wrap(sdkerrors.ErrInsufficientFunds, "Insufficient funds.") + return nil, errors.Wrap(sdkerrors.ErrInsufficientFunds, "insufficient funds") } } @@ -241,7 +241,7 @@ func (k Keeper) RefillBond(ctx sdk.Context, id string, ownerAddress sdk.AccAddre updatedBalance := bond.Balance.Add(coins...) if updatedBalance.IsAnyGT(maxBondAmount) { - return nil, errors.Wrap(sdkerrors.ErrInvalidRequest, "Max bond amount exceeded.") + return nil, errors.Wrap(sdkerrors.ErrInvalidRequest, "max bond amount exceeded") } // Move funds into the bond account module. @@ -260,17 +260,17 @@ func (k Keeper) RefillBond(ctx sdk.Context, id string, ownerAddress sdk.AccAddre // WithdrawBond withdraws funds from a bond. func (k Keeper) WithdrawBond(ctx sdk.Context, id string, ownerAddress sdk.AccAddress, coins sdk.Coins) (*types.Bond, error) { if !k.HasBond(ctx, id) { - return nil, errors.Wrap(sdkerrors.ErrInvalidRequest, "Bond not found.") + return nil, errors.Wrap(sdkerrors.ErrInvalidRequest, "bond not found") } bond := k.GetBond(ctx, id) if bond.Owner != ownerAddress.String() { - return nil, errors.Wrap(sdkerrors.ErrUnauthorized, "Bond owner mismatch.") + return nil, errors.Wrap(sdkerrors.ErrUnauthorized, "bond owner mismatch") } updatedBalance, isNeg := bond.Balance.SafeSub(coins...) if isNeg { - return nil, errors.Wrap(sdkerrors.ErrInsufficientFunds, "Insufficient bond balance.") + return nil, errors.Wrap(sdkerrors.ErrInsufficientFunds, "insufficient bond balance") } // Move funds from the bond into the account. @@ -289,18 +289,18 @@ func (k Keeper) WithdrawBond(ctx sdk.Context, id string, ownerAddress sdk.AccAdd // CancelBond cancels a bond, returning funds to the owner. func (k Keeper) CancelBond(ctx sdk.Context, id string, ownerAddress sdk.AccAddress) (*types.Bond, error) { if !k.HasBond(ctx, id) { - return nil, errors.Wrap(sdkerrors.ErrInvalidRequest, "Bond not found.") + return nil, errors.Wrap(sdkerrors.ErrInvalidRequest, "bond not found") } bond := k.GetBond(ctx, id) if bond.Owner != ownerAddress.String() { - return nil, errors.Wrap(sdkerrors.ErrUnauthorized, "Bond owner mismatch.") + return nil, errors.Wrap(sdkerrors.ErrUnauthorized, "bond owner mismatch") } // Check if bond is used in other modules. for _, usageKeeper := range k.usageKeepers { if usageKeeper.UsesBond(ctx, id) { - return nil, errors.Wrap(sdkerrors.ErrUnauthorized, fmt.Sprintf("Bond in use by the '%s' module.", usageKeeper.ModuleName())) + return nil, errors.Wrap(sdkerrors.ErrUnauthorized, fmt.Sprintf("bond in use by the '%s' module", usageKeeper.ModuleName())) } } @@ -341,13 +341,13 @@ func (k Keeper) TransferCoinsToModuleAccount(ctx sdk.Context, id, moduleAccount if isNeg { // Check if bond has sufficient funds. - return errors.Wrap(sdkerrors.ErrInsufficientFunds, "Insufficient funds.") + return errors.Wrap(sdkerrors.ErrInsufficientFunds, "insufficient funds") } // Move funds from bond module to record rent module. err := k.bankKeeper.SendCoinsFromModuleToModule(ctx, types.ModuleName, moduleAccount, coins) if err != nil { - return errors.Wrap(sdkerrors.ErrInvalidRequest, "Error transferring funds.") + return errors.Wrap(sdkerrors.ErrInvalidRequest, "error transferring funds") } // Update bond balance. diff --git a/x/registry/keeper/grpc_query.go b/x/registry/keeper/grpc_query.go index 9db6c8fd..690fe0ff 100644 --- a/x/registry/keeper/grpc_query.go +++ b/x/registry/keeper/grpc_query.go @@ -49,7 +49,7 @@ func (q Querier) GetRecord(c context.Context, req *types.QueryRecordByIDRequest) ctx := sdk.UnwrapSDKContext(c) id := req.GetId() if !q.Keeper.HasRecord(ctx, id) { - return nil, errors.Wrap(sdkerrors.ErrUnknownRequest, "Record not found.") + return nil, errors.Wrap(sdkerrors.ErrUnknownRequest, "record not found") } record := q.Keeper.GetRecord(ctx, id) return &types.QueryRecordByIDResponse{Record: record}, nil @@ -87,11 +87,11 @@ func (q Querier) LookupCrn(c context.Context, req *types.QueryLookupCrn) (*types ctx := sdk.UnwrapSDKContext(c) crn := req.GetCrn() if !q.Keeper.HasNameRecord(ctx, crn) { - return nil, errors.Wrap(sdkerrors.ErrUnknownRequest, "CRN not found.") + return nil, errors.Wrap(sdkerrors.ErrUnknownRequest, "crn not found") } nameRecord := q.Keeper.GetNameRecord(ctx, crn) if nameRecord == nil { - return nil, errors.Wrap(sdkerrors.ErrUnknownRequest, "name record not found.") + return nil, errors.Wrap(sdkerrors.ErrUnknownRequest, "name record not found") } return &types.QueryLookupCrnResponse{Name: nameRecord}, nil } @@ -101,7 +101,7 @@ func (q Querier) ResolveCrn(c context.Context, req *types.QueryResolveCrn) (*typ crn := req.GetCrn() record := q.Keeper.ResolveCRN(ctx, crn) if record == nil { - return nil, errors.Wrap(sdkerrors.ErrUnknownRequest, "record not found.") + return nil, errors.Wrap(sdkerrors.ErrUnknownRequest, "record not found") } return &types.QueryResolveCrnResponse{Record: record}, nil } diff --git a/x/registry/keeper/naming_keeper.go b/x/registry/keeper/naming_keeper.go index bab5ebf9..b0d227c3 100644 --- a/x/registry/keeper/naming_keeper.go +++ b/x/registry/keeper/naming_keeper.go @@ -113,12 +113,12 @@ func (k Keeper) updateBlockChangeSetForName(ctx sdk.Context, crn string) { func (k Keeper) getAuthority(ctx sdk.Context, crn string) (string, *url.URL, *types.NameAuthority, error) { parsedCRN, err := url.Parse(crn) if err != nil { - return "", nil, nil, errors.Wrap(sdkerrors.ErrInvalidRequest, "Invalid CRN.") + return "", nil, nil, errors.Wrap(sdkerrors.ErrInvalidRequest, "invalid CRN") } name := parsedCRN.Host if !k.HasNameAuthority(ctx, name) { - return name, nil, nil, errors.Wrap(sdkerrors.ErrInvalidRequest, "Name authority not found.") + return name, nil, nil, errors.Wrap(sdkerrors.ErrInvalidRequest, "name authority not found") } authority := k.GetNameAuthority(ctx, name) return name, parsedCRN, &authority, nil @@ -132,19 +132,19 @@ func (k Keeper) checkCRNAccess(ctx sdk.Context, signer sdk.AccAddress, crn strin formattedCRN := fmt.Sprintf("crn://%s%s", name, parsedCRN.RequestURI()) if formattedCRN != crn { - return errors.Wrap(sdkerrors.ErrInvalidRequest, "Invalid CRN.") + return errors.Wrap(sdkerrors.ErrInvalidRequest, "invalid CRN") } if authority.OwnerAddress != signer.String() { - return errors.Wrap(sdkerrors.ErrUnauthorized, "Access denied.") + return errors.Wrap(sdkerrors.ErrUnauthorized, "access denied") } if authority.Status != types.AuthorityActive { - return errors.Wrap(sdkerrors.ErrUnauthorized, "Authority is not active.") + return errors.Wrap(sdkerrors.ErrUnauthorized, "authority is not active") } if authority.BondId == "" || len(authority.BondId) == 0 { - return errors.Wrap(sdkerrors.ErrUnauthorized, "Authority bond not found.") + return errors.Wrap(sdkerrors.ErrUnauthorized, "authority bond not found") } if authority.OwnerPublicKey == "" { @@ -324,13 +324,13 @@ func (k Keeper) ProcessReserveSubAuthority(ctx sdk.Context, name string, msg typ // Check if parent authority exists. if !k.HasNameAuthority(ctx, parent) { - return errors.Wrap(sdkerrors.ErrInvalidRequest, "Parent authority not found.") + return errors.Wrap(sdkerrors.ErrInvalidRequest, "parent authority not found") } parentAuthority := k.GetNameAuthority(ctx, parent) // Sub-authority creator needs to be the owner of the parent authority. if parentAuthority.OwnerAddress != msg.Signer { - return errors.Wrap(sdkerrors.ErrUnauthorized, "Access denied.") + return errors.Wrap(sdkerrors.ErrUnauthorized, "access denied") } // Sub-authority owner defaults to parent authority owner. @@ -363,17 +363,17 @@ func (k Keeper) createAuthority(ctx sdk.Context, name string, owner string, isRo if k.HasNameAuthority(ctx, name) { authority := k.GetNameAuthority(ctx, name) if authority.Status != types.AuthorityExpired { - return errors.Wrap(sdkerrors.ErrInvalidRequest, "Name already reserved.") + return errors.Wrap(sdkerrors.ErrInvalidRequest, "name already reserved") } } ownerAddress, err := sdk.AccAddressFromBech32(owner) if err != nil { - return errors.Wrap(sdkerrors.ErrInvalidRequest, "Invalid owner address.") + return errors.Wrap(sdkerrors.ErrInvalidRequest, "invalid owner address") } ownerAccount := k.accountKeeper.GetAccount(ctx, ownerAddress) if ownerAccount == nil { - return errors.Wrap(sdkerrors.ErrUnknownAddress, "Account not found.") + return errors.Wrap(sdkerrors.ErrUnknownAddress, "account not found") } authority := types.NameAuthority{ @@ -431,11 +431,11 @@ func (k Keeper) ProcessReserveAuthority(ctx sdk.Context, msg types.MsgReserveAut crn := fmt.Sprintf("crn://%s", msg.GetName()) parsedCrn, err := url.Parse(crn) if err != nil { - return errors.Wrap(sdkerrors.ErrInvalidRequest, "Invalid name") + return errors.Wrap(sdkerrors.ErrInvalidRequest, "invalid name") } name := parsedCrn.Host if fmt.Sprintf("crn://%s", name) != crn { - return errors.Wrap(sdkerrors.ErrInvalidRequest, "Invalid name") + return errors.Wrap(sdkerrors.ErrInvalidRequest, "invalid name") } if strings.Contains(name, ".") { return k.ProcessReserveSubAuthority(ctx, name, msg) @@ -451,20 +451,20 @@ func (k Keeper) ProcessSetAuthorityBond(ctx sdk.Context, msg types.MsgSetAuthori name := msg.GetName() signer := msg.GetSigner() if !k.HasNameAuthority(ctx, name) { - return errors.Wrap(sdkerrors.ErrInvalidRequest, "Name authority not found.") + return errors.Wrap(sdkerrors.ErrInvalidRequest, "name authority not found") } authority := k.GetNameAuthority(ctx, name) if authority.OwnerAddress != signer { - return errors.Wrap(sdkerrors.ErrUnauthorized, "Access denied") + return errors.Wrap(sdkerrors.ErrUnauthorized, "access denied") } if !k.bondKeeper.HasBond(ctx, msg.BondId) { - return errors.Wrap(sdkerrors.ErrInvalidRequest, "Bond not found.") + return errors.Wrap(sdkerrors.ErrInvalidRequest, "bond not found") } // bond := k.bondKeeper.GetBond(ctx, msg.BondId) if bond.Owner != signer { - return errors.Wrap(sdkerrors.ErrUnauthorized, "Bond owner mismatch.") + return errors.Wrap(sdkerrors.ErrUnauthorized, "bond owner mismatch") } // No-op if bond hasn't changed. @@ -497,7 +497,7 @@ func (k Keeper) ProcessDeleteName(ctx sdk.Context, msg types.MsgDeleteNameAuthor } if !k.HasNameRecord(ctx, msg.Crn) { - return errors.Wrap(sdkerrors.ErrInvalidRequest, "Name not found.") + return errors.Wrap(sdkerrors.ErrInvalidRequest, "name not found") } // Set CID to empty string. diff --git a/x/registry/keeper/record_keeper.go b/x/registry/keeper/record_keeper.go index ea7e7e01..6eb6e21b 100644 --- a/x/registry/keeper/record_keeper.go +++ b/x/registry/keeper/record_keeper.go @@ -159,7 +159,7 @@ func (k RecordKeeper) QueryRecordsByBond(ctx sdk.Context, bondID string) []types // ProcessRenewRecord renews a record. func (k Keeper) ProcessRenewRecord(ctx sdk.Context, msg types.MsgRenewRecord) error { if !k.HasRecord(ctx, msg.RecordId) { - return errors.Wrap(sdkerrors.ErrInvalidRequest, "Record not found.") + return errors.Wrap(sdkerrors.ErrInvalidRequest, "record not found") } // Check if renewal is required (i.e. expired record marked as deleted). @@ -170,7 +170,7 @@ func (k Keeper) ProcessRenewRecord(ctx sdk.Context, msg types.MsgRenewRecord) er } if !record.Deleted || expiryTime.After(ctx.BlockTime()) { - return errors.Wrap(sdkerrors.ErrInvalidRequest, "Renewal not required.") + return errors.Wrap(sdkerrors.ErrInvalidRequest, "renewal not required") } recordType := record.ToRecordType() @@ -185,23 +185,23 @@ func (k Keeper) ProcessRenewRecord(ctx sdk.Context, msg types.MsgRenewRecord) er // ProcessAssociateBond associates a record with a bond. func (k Keeper) ProcessAssociateBond(ctx sdk.Context, msg types.MsgAssociateBond) error { if !k.HasRecord(ctx, msg.RecordId) { - return errors.Wrap(sdkerrors.ErrInvalidRequest, "Record not found.") + return errors.Wrap(sdkerrors.ErrInvalidRequest, "record not found") } if !k.bondKeeper.HasBond(ctx, msg.BondId) { - return errors.Wrap(sdkerrors.ErrInvalidRequest, "Bond not found.") + return errors.Wrap(sdkerrors.ErrInvalidRequest, "bond not found") } // Check if already associated with a bond. record := k.GetRecord(ctx, msg.RecordId) if record.BondId != "" || len(record.BondId) != 0 { - return errors.Wrap(sdkerrors.ErrUnauthorized, "Bond already exists.") + return errors.Wrap(sdkerrors.ErrUnauthorized, "bond already exists") } // Only the bond owner can associate a record with the bond. bond := k.bondKeeper.GetBond(ctx, msg.BondId) if msg.Signer != bond.Owner { - return errors.Wrap(sdkerrors.ErrUnauthorized, "Bond owner mismatch.") + return errors.Wrap(sdkerrors.ErrUnauthorized, "bond owner mismatch") } record.BondId = msg.BondId @@ -219,20 +219,20 @@ func (k Keeper) ProcessAssociateBond(ctx sdk.Context, msg types.MsgAssociateBond // ProcessDissociateBond dissociates a record from its bond. func (k Keeper) ProcessDissociateBond(ctx sdk.Context, msg types.MsgDissociateBond) error { if !k.HasRecord(ctx, msg.RecordId) { - return errors.Wrap(sdkerrors.ErrInvalidRequest, "Record not found.") + return errors.Wrap(sdkerrors.ErrInvalidRequest, "record not found") } // Check if associated with a bond. record := k.GetRecord(ctx, msg.RecordId) bondID := record.BondId if bondID == "" || len(bondID) == 0 { - return errors.Wrap(sdkerrors.ErrUnauthorized, "Bond not found.") + return errors.Wrap(sdkerrors.ErrUnauthorized, "bond not found") } // Only the bond owner can dissociate a record from the bond. bond := k.bondKeeper.GetBond(ctx, bondID) if msg.Signer != bond.Owner { - return errors.Wrap(sdkerrors.ErrUnauthorized, "Bond owner mismatch.") + return errors.Wrap(sdkerrors.ErrUnauthorized, "bond owner mismatch") } // Clear bond ID. @@ -246,13 +246,13 @@ func (k Keeper) ProcessDissociateBond(ctx sdk.Context, msg types.MsgDissociateBo // ProcessDissociateRecords dissociates all records associated with a given bond. func (k Keeper) ProcessDissociateRecords(ctx sdk.Context, msg types.MsgDissociateRecords) error { if !k.bondKeeper.HasBond(ctx, msg.BondId) { - return errors.Wrap(sdkerrors.ErrInvalidRequest, "Bond not found.") + return errors.Wrap(sdkerrors.ErrInvalidRequest, "bond not found") } // Only the bond owner can dissociate all records from the bond. bond := k.bondKeeper.GetBond(ctx, msg.BondId) if msg.Signer != bond.Owner { - return errors.Wrap(sdkerrors.ErrUnauthorized, "Bond owner mismatch.") + return errors.Wrap(sdkerrors.ErrUnauthorized, "bond owner mismatch") } // Dissociate all records from the bond. @@ -270,22 +270,22 @@ func (k Keeper) ProcessDissociateRecords(ctx sdk.Context, msg types.MsgDissociat // ProcessReAssociateRecords switches records from and old to new bond. func (k Keeper) ProcessReAssociateRecords(ctx sdk.Context, msg types.MsgReAssociateRecords) error { if !k.bondKeeper.HasBond(ctx, msg.OldBondId) { - return errors.Wrap(sdkerrors.ErrInvalidRequest, "Old bond not found.") + return errors.Wrap(sdkerrors.ErrInvalidRequest, "old bond not found") } if !k.bondKeeper.HasBond(ctx, msg.NewBondId) { - return errors.Wrap(sdkerrors.ErrInvalidRequest, "New bond not found.") + return errors.Wrap(sdkerrors.ErrInvalidRequest, "new bond not found") } // Only the bond owner can re-associate all records. oldBond := k.bondKeeper.GetBond(ctx, msg.OldBondId) if msg.Signer != oldBond.Owner { - return errors.Wrap(sdkerrors.ErrUnauthorized, "Old bond owner mismatch.") + return errors.Wrap(sdkerrors.ErrUnauthorized, "old bond owner mismatch") } newBond := k.bondKeeper.GetBond(ctx, msg.NewBondId) if msg.Signer != newBond.Owner { - return errors.Wrap(sdkerrors.ErrUnauthorized, "New bond owner mismatch.") + return errors.Wrap(sdkerrors.ErrUnauthorized, "new bond owner mismatch") } // Re-associate all records. diff --git a/x/registry/types/msg.go b/x/registry/types/msg.go index 2d8286e9..3ce3d728 100644 --- a/x/registry/types/msg.go +++ b/x/registry/types/msg.go @@ -33,11 +33,11 @@ func (msg MsgSetName) Type() string { return "set-name" } // ValidateBasic Implements Msg. func (msg MsgSetName) ValidateBasic() error { if msg.Crn == "" { - return errors.Wrap(sdkerrors.ErrInvalidRequest, "CRN is required.") + return errors.Wrap(sdkerrors.ErrInvalidRequest, "crn is required") } if msg.Cid == "" { - return errors.Wrap(sdkerrors.ErrInvalidRequest, "CID is required.") + return errors.Wrap(sdkerrors.ErrInvalidRequest, "cid is required") } if len(msg.Signer) == 0 { @@ -77,7 +77,7 @@ func (msg MsgReserveAuthority) Type() string { return "reserve-authority" } // ValidateBasic Implements Msg. func (msg MsgReserveAuthority) ValidateBasic() error { if len(msg.Name) == 0 { - return errors.Wrap(sdkerrors.ErrInvalidRequest, "name is required.") + return errors.Wrap(sdkerrors.ErrInvalidRequest, "name is required") } if len(msg.Signer) == 0 { @@ -117,15 +117,15 @@ func (msg MsgSetAuthorityBond) Type() string { return "authority-bond" } // ValidateBasic Implements Msg. func (msg MsgSetAuthorityBond) ValidateBasic() error { if len(msg.Name) == 0 { - return errors.Wrap(sdkerrors.ErrInvalidRequest, "name is required.") + return errors.Wrap(sdkerrors.ErrInvalidRequest, "name is required") } if len(msg.Signer) == 0 { - return errors.Wrap(sdkerrors.ErrInvalidAddress, "invalid signer.") + return errors.Wrap(sdkerrors.ErrInvalidAddress, "invalid signer") } if len(msg.BondId) == 0 { - return errors.Wrap(sdkerrors.ErrInvalidAddress, "bond id is required.") + return errors.Wrap(sdkerrors.ErrInvalidAddress, "bond id is required") } return nil @@ -160,16 +160,16 @@ func (msg MsgDeleteNameAuthority) Type() string { return "delete-name" } // ValidateBasic Implements Msg. func (msg MsgDeleteNameAuthority) ValidateBasic() error { if len(msg.Crn) == 0 { - return errors.Wrap(sdkerrors.ErrInvalidRequest, "crn is required.") + return errors.Wrap(sdkerrors.ErrInvalidRequest, "crn is required") } if len(msg.Signer) == 0 { - return errors.Wrap(sdkerrors.ErrInvalidAddress, "invalid signer.") + return errors.Wrap(sdkerrors.ErrInvalidAddress, "invalid signer") } _, err := url.Parse(msg.Crn) if err != nil { - return errors.Wrap(sdkerrors.ErrInvalidRequest, "invalid crn.") + return errors.Wrap(sdkerrors.ErrInvalidRequest, "invalid crn") } return nil diff --git a/x/registry/types/record_msg.go b/x/registry/types/record_msg.go index 2b7da76e..91f5e7da 100644 --- a/x/registry/types/record_msg.go +++ b/x/registry/types/record_msg.go @@ -40,12 +40,12 @@ func (msg MsgSetRecord) ValidateBasic() error { owners := msg.Payload.Record.Owners for _, owner := range owners { if owner == "" { - return errors.Wrap(sdkerrors.ErrInvalidRequest, "Record owner not set.") + return errors.Wrap(sdkerrors.ErrInvalidRequest, "record owner not set") } } if len(msg.BondId) == 0 { - return errors.Wrap(sdkerrors.ErrUnauthorized, "Bond ID is required.") + return errors.Wrap(sdkerrors.ErrUnauthorized, "bond ID is required") } return nil } @@ -84,11 +84,11 @@ func (msg MsgRenewRecord) Type() string { return "renew-record" } // ValidateBasic Implements Msg. func (msg MsgRenewRecord) ValidateBasic() error { if len(msg.RecordId) == 0 { - return errors.Wrap(sdkerrors.ErrInvalidRequest, "record id is required.") + return errors.Wrap(sdkerrors.ErrInvalidRequest, "record id is required") } if len(msg.Signer) == 0 { - return errors.Wrap(sdkerrors.ErrInvalidAddress, "invalid signer.") + return errors.Wrap(sdkerrors.ErrInvalidAddress, "invalid signer") } return nil @@ -124,13 +124,13 @@ func (msg MsgAssociateBond) Type() string { return "associate-bond" } // ValidateBasic Implements Msg. func (msg MsgAssociateBond) ValidateBasic() error { if len(msg.RecordId) == 0 { - return errors.Wrap(sdkerrors.ErrInvalidRequest, "record id is required.") + return errors.Wrap(sdkerrors.ErrInvalidRequest, "record id is required") } if len(msg.BondId) == 0 { - return errors.Wrap(sdkerrors.ErrInvalidRequest, "bond id is required.") + return errors.Wrap(sdkerrors.ErrInvalidRequest, "bond id is required") } if len(msg.Signer) == 0 { - return errors.Wrap(sdkerrors.ErrInvalidAddress, "invalid signer.") + return errors.Wrap(sdkerrors.ErrInvalidAddress, "invalid signer") } return nil @@ -165,10 +165,10 @@ func (msg MsgDissociateBond) Type() string { return "dissociate-bond" } // ValidateBasic Implements Msg. func (msg MsgDissociateBond) ValidateBasic() error { if len(msg.RecordId) == 0 { - return errors.Wrap(sdkerrors.ErrInvalidRequest, "record id is required.") + return errors.Wrap(sdkerrors.ErrInvalidRequest, "record id is required") } if len(msg.Signer) == 0 { - return errors.Wrap(sdkerrors.ErrInvalidAddress, "invalid signer.") + return errors.Wrap(sdkerrors.ErrInvalidAddress, "invalid signer") } return nil @@ -203,10 +203,10 @@ func (msg MsgDissociateRecords) Type() string { return "dissociate-records" } // ValidateBasic Implements Msg. func (msg MsgDissociateRecords) ValidateBasic() error { if len(msg.BondId) == 0 { - return errors.Wrap(sdkerrors.ErrInvalidRequest, "bond id is required.") + return errors.Wrap(sdkerrors.ErrInvalidRequest, "bond id is required") } if len(msg.Signer) == 0 { - return errors.Wrap(sdkerrors.ErrInvalidAddress, "invalid signer.") + return errors.Wrap(sdkerrors.ErrInvalidAddress, "invalid signer") } return nil @@ -242,13 +242,13 @@ func (msg MsgReAssociateRecords) Type() string { return "reassociate-records" } // ValidateBasic Implements Msg. func (msg MsgReAssociateRecords) ValidateBasic() error { if len(msg.OldBondId) == 0 { - return errors.Wrap(sdkerrors.ErrInvalidRequest, "old-bond-id is required.") + return errors.Wrap(sdkerrors.ErrInvalidRequest, "old-bond-id is required") } if len(msg.NewBondId) == 0 { - return errors.Wrap(sdkerrors.ErrInvalidRequest, "new-bond-id is required.") + return errors.Wrap(sdkerrors.ErrInvalidRequest, "new-bond-id is required") } if len(msg.Signer) == 0 { - return errors.Wrap(sdkerrors.ErrInvalidAddress, "invalid signer.") + return errors.Wrap(sdkerrors.ErrInvalidAddress, "invalid signer") } return nil