From 90b8a4505add6fdfddc5fea0639833daf68285c0 Mon Sep 17 00:00:00 2001 From: "jaeseung.bae" Date: Fri, 15 Mar 2024 17:21:29 +0900 Subject: [PATCH] chore: move validation logic to validate function --- x/collection/genesis.go | 7 +++++-- x/collection/keeper/genesis.go | 3 --- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/x/collection/genesis.go b/x/collection/genesis.go index ac08c34fe0..028101b3f7 100644 --- a/x/collection/genesis.go +++ b/x/collection/genesis.go @@ -64,8 +64,11 @@ func ValidateGenesis(data GenesisState) error { if len(contractNextTokenIDs.TokenIds) == 0 { return sdkerrors.ErrInvalidRequest.Wrap("next token ids cannot be empty") } - for _, nextTokenIDs := range contractNextTokenIDs.TokenIds { - if err := ValidateClassID(nextTokenIDs.ClassId); err != nil { + for _, nextTokenID := range contractNextTokenIDs.TokenIds { + if nextTokenID.Id.IsZero() { + return sdkerrors.ErrInvalidRequest.Wrap("nextTokenID.Id is not supposed to be zero") + } + if err := ValidateClassID(nextTokenID.ClassId); err != nil { return err } } diff --git a/x/collection/keeper/genesis.go b/x/collection/keeper/genesis.go index 0b786c78e6..01330383cc 100644 --- a/x/collection/keeper/genesis.go +++ b/x/collection/keeper/genesis.go @@ -97,9 +97,6 @@ func (k Keeper) InitGenesis(ctx sdk.Context, data *collection.GenesisState) { contractID := contractNextTokenIDs.ContractId for _, nextTokenID := range contractNextTokenIDs.TokenIds { - if nextTokenID.Id.IsZero() { - panic("nextTokenID.Id is not supposed to be zero") - } k.setNextTokenID(ctx, contractID, nextTokenID.ClassId, nextTokenID.Id) }