From 82c18620c64c6127b9ed8472709dcbb3e9dd28bc Mon Sep 17 00:00:00 2001 From: dreamer Date: Mon, 15 Apr 2024 10:22:35 +0800 Subject: [PATCH] add Authority check --- modules/token/keeper/msg_server.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/modules/token/keeper/msg_server.go b/modules/token/keeper/msg_server.go index 767a107e..d054b2ab 100644 --- a/modules/token/keeper/msg_server.go +++ b/modules/token/keeper/msg_server.go @@ -272,8 +272,16 @@ func (m msgServer) UpdateParams( // DeployERC20 implements v1.MsgServer. func (m msgServer) DeployERC20(goCtx context.Context, msg *v1.MsgDeployERC20) (*v1.MsgDeployERC20Response, error) { - ctx := sdk.UnwrapSDKContext(goCtx) + if m.k.authority != msg.Authority { + return nil, errorsmod.Wrapf( + sdkerrors.ErrUnauthorized, + "invalid authority; expected %s, got %s", + m.k.authority, + msg.Authority, + ) + } + ctx := sdk.UnwrapSDKContext(goCtx) token, err := m.k.buildERC20Token(ctx, msg.Name, msg.Symbol, msg.MinUnit, msg.Scale) if err != nil { return nil, err