diff --git a/x/aura/keeper/msg_server.go b/x/aura/keeper/msg_server.go index 1f0de1c..74cb375 100644 --- a/x/aura/keeper/msg_server.go +++ b/x/aura/keeper/msg_server.go @@ -100,12 +100,12 @@ func (k msgServer) Pause(ctx context.Context, msg *types.MsgPause) (*types.MsgPa } func (k msgServer) Unpause(ctx context.Context, msg *types.MsgUnpause) (*types.MsgUnpauseResponse, error) { - has, err := k.Pausers.Has(ctx, msg.Signer) + owner, err := k.Owner.Get(ctx) if err != nil { - return nil, sdkerrors.Wrapf(err, "unable to retrieve pauser from state") + return nil, sdkerrors.Wrapf(err, "unable to retrieve owner from state") } - if !has { - return nil, types.ErrInvalidPauser + if msg.Signer != owner { + return nil, sdkerrors.Wrapf(types.ErrInvalidOwner, "expected %s, got %s", owner, msg.Signer) } if paused, _ := k.Paused.Get(ctx); !paused { diff --git a/x/aura/keeper/msg_server_test.go b/x/aura/keeper/msg_server_test.go index 88e93aa..9f00041 100644 --- a/x/aura/keeper/msg_server_test.go +++ b/x/aura/keeper/msg_server_test.go @@ -150,22 +150,30 @@ func TestUnpause(t *testing.T) { // ARRANGE: Set paused state to true. require.NoError(t, k.Paused.Set(ctx, true)) - // ARRANGE: Set pauser in state. - pauser := utils.TestAccount() - require.NoError(t, k.Pausers.Set(ctx, pauser.Address)) + + // ACT: Attempt to unpause with no owner set. + _, err := server.Unpause(ctx, &types.MsgUnpause{}) + // ASSERT: The action should've failed due to no owner set. + require.ErrorContains(t, err, "unable to retrieve owner from state") + paused, _ := k.Paused.Get(ctx) + require.True(t, paused) + + // ARRANGE: Set owner in state. + owner := utils.TestAccount() + require.NoError(t, k.Owner.Set(ctx, owner.Address)) // ACT: Attempt to unpause with invalid signer. - _, err := server.Unpause(ctx, &types.MsgUnpause{ + _, err = server.Unpause(ctx, &types.MsgUnpause{ Signer: utils.TestAccount().Address, }) // ASSERT: The action should've failed due to invalid signer. - require.ErrorContains(t, err, types.ErrInvalidPauser.Error()) - paused, _ := k.Paused.Get(ctx) + require.ErrorContains(t, err, types.ErrInvalidOwner.Error()) + paused, _ = k.Paused.Get(ctx) require.True(t, paused) // ACT: Attempt to unpause. _, err = server.Unpause(ctx, &types.MsgUnpause{ - Signer: pauser.Address, + Signer: owner.Address, }) // ASSERT: The action should've succeeded. require.NoError(t, err) @@ -174,7 +182,7 @@ func TestUnpause(t *testing.T) { // ACT: Attempt to unpause again. _, err = server.Unpause(ctx, &types.MsgUnpause{ - Signer: pauser.Address, + Signer: owner.Address, }) // ASSERT: The action should've failed due to module being unpaused already. require.ErrorContains(t, err, "module is already unpaused") diff --git a/x/aura/types/errors.go b/x/aura/types/errors.go index f6fa680..6802371 100644 --- a/x/aura/types/errors.go +++ b/x/aura/types/errors.go @@ -3,7 +3,8 @@ package types import "cosmossdk.io/errors" var ( - ErrInvalidBurner = errors.Register(ModuleName, 1, "signer is not a burner") - ErrInvalidMinter = errors.Register(ModuleName, 2, "signer is not a minter") - ErrInvalidPauser = errors.Register(ModuleName, 3, "signer is not a pauser") + ErrInvalidOwner = errors.Register(ModuleName, 1, "signer is not owner") + ErrInvalidBurner = errors.Register(ModuleName, 2, "signer is not a burner") + ErrInvalidMinter = errors.Register(ModuleName, 3, "signer is not a minter") + ErrInvalidPauser = errors.Register(ModuleName, 4, "signer is not a pauser") )