From 54103d4d3b6905975d520204812dd6c1d80ef513 Mon Sep 17 00:00:00 2001 From: Chris Li Date: Mon, 17 Apr 2023 10:10:00 +0800 Subject: [PATCH] fix: add `ErrInvalidApproval` errorcode for sp's approval invalid (#175) --- x/storage/keeper/keeper.go | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/x/storage/keeper/keeper.go b/x/storage/keeper/keeper.go index 57f784ec9..2e9e869ec 100644 --- a/x/storage/keeper/keeper.go +++ b/x/storage/keeper/keeper.go @@ -1209,14 +1209,11 @@ func (k Keeper) VerifySPAndSignature(ctx sdk.Context, spAcc sdk.AccAddress, sigD return sptypes.ErrStorageProviderNotInService } - approvalAccAddress, err := sdk.AccAddressFromHexUnsafe(sp.ApprovalAddress) - if err != nil { - return err - } + approvalAccAddress := sdk.MustAccAddressFromHex(sp.ApprovalAddress) - err = types.VerifySignature(approvalAccAddress, sdk.Keccak256(sigData), signature) + err := types.VerifySignature(approvalAccAddress, sdk.Keccak256(sigData), signature) if err != nil { - return err + return errors.Wrapf(types.ErrInvalidApproval, "verify signature error: %s", err) } return nil }