From 90d4085b497d25839a5268ee36d406e5f09f846e Mon Sep 17 00:00:00 2001 From: sampocs Date: Tue, 27 Aug 2024 10:00:52 -0500 Subject: [PATCH] addressed riley pr comments --- x/icacallbacks/migrations/v2/convert.go | 12 ++++++------ x/icaoracle/types/genesis.go | 10 +++++----- x/interchainquery/keeper/keeper.go | 6 +++--- x/stakeibc/keeper/claim.go | 3 +-- x/stakeibc/keeper/epoch_tracker.go | 2 +- x/stakeibc/keeper/icacallbacks_redemption.go | 2 +- 6 files changed, 17 insertions(+), 18 deletions(-) diff --git a/x/icacallbacks/migrations/v2/convert.go b/x/icacallbacks/migrations/v2/convert.go index e5ded88d93..24c7c34daa 100644 --- a/x/icacallbacks/migrations/v2/convert.go +++ b/x/icacallbacks/migrations/v2/convert.go @@ -74,14 +74,14 @@ func convertCallbackData(oldCallbackData icacallbacktypes.CallbackData) (icacall // Deserialize the callback args with the old DelegateCallback type oldDelegateCallback := oldstakeibctypes.DelegateCallback{} if err := proto.Unmarshal(oldCallbackData.CallbackArgs, &oldDelegateCallback); err != nil { - return icacallbacktypes.CallbackData{}, errorsmod.Wrapf(err, "failed to unmarshal") + return icacallbacktypes.CallbackData{}, errorsmod.Wrap(err, "failed to unmarshal") } // Convert and serialize with the new DelegateCallback type newDelegateCallback := convertDelegateCallback(oldDelegateCallback) newDelegateCallbackBz, err := proto.Marshal(&newDelegateCallback) if err != nil { - return icacallbacktypes.CallbackData{}, errorsmod.Wrapf(err, "failed to marshal") + return icacallbacktypes.CallbackData{}, errorsmod.Wrap(err, "failed to marshal") } // Update the CallbackData with the new args @@ -91,14 +91,14 @@ func convertCallbackData(oldCallbackData icacallbacktypes.CallbackData) (icacall // Deserialize the callback args with the old UndelegateCallback type oldUndelegateCallback := oldstakeibctypes.UndelegateCallback{} if err := proto.Unmarshal(oldCallbackData.CallbackArgs, &oldUndelegateCallback); err != nil { - return icacallbacktypes.CallbackData{}, errorsmod.Wrapf(err, "failed to unmarshal") + return icacallbacktypes.CallbackData{}, errorsmod.Wrap(err, "failed to unmarshal") } // Convert and serialize with the new UndelegateCallback type newUndelegateCallback := convertUndelegateCallback(oldUndelegateCallback) newUndelegateCallbackBz, err := proto.Marshal(&newUndelegateCallback) if err != nil { - return icacallbacktypes.CallbackData{}, errorsmod.Wrapf(err, "failed to marshal") + return icacallbacktypes.CallbackData{}, errorsmod.Wrap(err, "failed to marshal") } // Update the CallbackData with the new args @@ -108,14 +108,14 @@ func convertCallbackData(oldCallbackData icacallbacktypes.CallbackData) (icacall // Deserialize the callback args with the old RebalanceCallback type oldRebalanceCallback := oldstakeibctypes.RebalanceCallback{} if err := proto.Unmarshal(oldCallbackData.CallbackArgs, &oldRebalanceCallback); err != nil { - return icacallbacktypes.CallbackData{}, errorsmod.Wrapf(err, "failed to unmarshal") + return icacallbacktypes.CallbackData{}, errorsmod.Wrap(err, "failed to unmarshal") } // Convert and serialize with the new RebalanceCallback type newRebalanceCallback := convertRebalanceCallback(oldRebalanceCallback) newRebalanceCallbackBz, err := proto.Marshal(&newRebalanceCallback) if err != nil { - return icacallbacktypes.CallbackData{}, errorsmod.Wrapf(err, "failed to marshal") + return icacallbacktypes.CallbackData{}, errorsmod.Wrap(err, "failed to marshal") } // Update the CallbackData with the new args diff --git a/x/icaoracle/types/genesis.go b/x/icaoracle/types/genesis.go index 7357824a3e..96f753776d 100644 --- a/x/icaoracle/types/genesis.go +++ b/x/icaoracle/types/genesis.go @@ -17,22 +17,22 @@ func DefaultGenesis() *GenesisState { // failure. func (gs GenesisState) Validate() error { if err := gs.Params.Validate(); err != nil { - return errorsmod.Wrapf(err, "invalid genesis state") + return errorsmod.Wrap(err, "invalid genesis state") } for _, oracle := range gs.Oracles { if oracle.ChainId == "" { - return errorsmod.Wrapf(ErrInvalidGenesisState, "oracle has empty chain ID") + return errorsmod.Wrap(ErrInvalidGenesisState, "oracle has empty chain ID") } } for _, metric := range gs.Metrics { if metric.Key == "" { - return errorsmod.Wrapf(ErrInvalidGenesisState, "metric has missing key") + return errorsmod.Wrap(ErrInvalidGenesisState, "metric has missing key") } if metric.UpdateTime == 0 { - return errorsmod.Wrapf(ErrInvalidGenesisState, "metric has missing time") + return errorsmod.Wrap(ErrInvalidGenesisState, "metric has missing time") } if metric.DestinationOracle == "" { - return errorsmod.Wrapf(ErrInvalidGenesisState, "metric has missing destination oracle chain ID") + return errorsmod.Wrap(ErrInvalidGenesisState, "metric has missing destination oracle chain ID") } } diff --git a/x/interchainquery/keeper/keeper.go b/x/interchainquery/keeper/keeper.go index 9f269f05fe..f441d2b5c2 100644 --- a/x/interchainquery/keeper/keeper.go +++ b/x/interchainquery/keeper/keeper.go @@ -70,11 +70,11 @@ func (k *Keeper) SubmitICQRequest(ctx sdk.Context, query types.Query, forceUniqu // In the query response, this will be used to verify that the query wasn't historical connection, found := k.IBCKeeper.ConnectionKeeper.GetConnection(ctx, query.ConnectionId) if !found { - return errorsmod.Wrapf(connectiontypes.ErrConnectionNotFound, "%s", query.ConnectionId) + return errorsmod.Wrap(connectiontypes.ErrConnectionNotFound, query.ConnectionId) } clientState, found := k.IBCKeeper.ClientKeeper.GetClientState(ctx, connection.ClientId) if !found { - return errorsmod.Wrapf(clienttypes.ErrClientNotFound, "%s", connection.ClientId) + return errorsmod.Wrap(clienttypes.ErrClientNotFound, connection.ClientId) } query.SubmissionHeight = clientState.GetLatestHeight().GetRevisionHeight() @@ -96,7 +96,7 @@ func (k *Keeper) RetryICQRequest(ctx sdk.Context, query types.Query) error { // Submit a new query (with a new ID) if err := k.SubmitICQRequest(ctx, query, true); err != nil { - return errorsmod.Wrapf(err, "failed to retry query") + return errorsmod.Wrap(err, types.ErrFailedToRetryQuery.Error()) } return nil diff --git a/x/stakeibc/keeper/claim.go b/x/stakeibc/keeper/claim.go index f78d75d844..c824760136 100644 --- a/x/stakeibc/keeper/claim.go +++ b/x/stakeibc/keeper/claim.go @@ -31,8 +31,7 @@ func (k msgServer) ClaimUndelegatedTokens(goCtx context.Context, msg *types.MsgC } // Confirm host zone is not halted - _, err = k.GetActiveHostZone(ctx, msg.HostZoneId) - if err != nil { + if _, err = k.GetActiveHostZone(ctx, msg.HostZoneId); err != nil { return nil, err } diff --git a/x/stakeibc/keeper/epoch_tracker.go b/x/stakeibc/keeper/epoch_tracker.go index 5692998d47..d9a875946c 100644 --- a/x/stakeibc/keeper/epoch_tracker.go +++ b/x/stakeibc/keeper/epoch_tracker.go @@ -110,7 +110,7 @@ func (k Keeper) GetStrideEpochElapsedShare(ctx sdk.Context) (sdk.Dec, error) { } epochEndTime, err := cast.ToInt64E(epochTracker.NextEpochStartTime) if err != nil { - return sdk.ZeroDec(), errorsmod.Wrapf(err, "unable to convert next epoch start time to int64") + return sdk.ZeroDec(), errorsmod.Wrap(err, "unable to convert next epoch start time to int64") } epochStartTime := epochEndTime - epochDuration diff --git a/x/stakeibc/keeper/icacallbacks_redemption.go b/x/stakeibc/keeper/icacallbacks_redemption.go index 30fbcc8a74..66300a7fc7 100644 --- a/x/stakeibc/keeper/icacallbacks_redemption.go +++ b/x/stakeibc/keeper/icacallbacks_redemption.go @@ -63,7 +63,7 @@ func (k Keeper) RedemptionCallback(ctx sdk.Context, packet channeltypes.Packet, icacallbackstypes.AckResponseStatus_FAILURE, packet)) // Reset unbondings record status - err := k.RecordsKeeper.SetHostZoneUnbondingStatus(ctx, chainId, redemptionCallback.EpochUnbondingRecordIds, recordstypes.HostZoneUnbonding_EXIT_TRANSFER_QUEUE) + err = k.RecordsKeeper.SetHostZoneUnbondingStatus(ctx, chainId, redemptionCallback.EpochUnbondingRecordIds, recordstypes.HostZoneUnbonding_EXIT_TRANSFER_QUEUE) if err != nil { return err }