From c92be0c8d458a50b6a86e73f156f3685da2840a9 Mon Sep 17 00:00:00 2001 From: Trinity Date: Thu, 31 Oct 2024 10:37:24 +0700 Subject: [PATCH] nit --- x/asset/keeper/msg_server_authorize_address.go | 2 +- x/asset/keeper/msg_server_un_authorize_address.go | 2 +- x/asset/keeper/msg_server_update_token.go | 8 +------- x/bridge/abci.go | 4 +++- x/bridge/types/ratelimit.go | 4 ---- 5 files changed, 6 insertions(+), 14 deletions(-) diff --git a/x/asset/keeper/msg_server_authorize_address.go b/x/asset/keeper/msg_server_authorize_address.go index e0b1c1a1..4550e5af 100644 --- a/x/asset/keeper/msg_server_authorize_address.go +++ b/x/asset/keeper/msg_server_authorize_address.go @@ -28,7 +28,7 @@ func (ms msgServer) AuthorizeAddress(goCtx context.Context, msg *types.MsgAuthor } // assert that the manager account is the only signer of the message - if sdk.AccAddress(signers[0]).String() != token.Manager { + if msg.Manager != token.Manager { return nil, errorsmod.Wrap(sdkerrors.ErrUnauthorized, "caller not authorized") } diff --git a/x/asset/keeper/msg_server_un_authorize_address.go b/x/asset/keeper/msg_server_un_authorize_address.go index bfbc5d24..bd11a9fa 100644 --- a/x/asset/keeper/msg_server_un_authorize_address.go +++ b/x/asset/keeper/msg_server_un_authorize_address.go @@ -29,7 +29,7 @@ func (ms msgServer) UnAuthorizeAddress(goCtx context.Context, msg *types.MsgUnAu } // assert that the manager account is the only signer of the message - if sdk.AccAddress(signers[0]).String() != token.Manager { + if msg.Manager != token.Manager { return nil, errorsmod.Wrap(sdkerrors.ErrUnauthorized, "caller not authorized") } diff --git a/x/asset/keeper/msg_server_update_token.go b/x/asset/keeper/msg_server_update_token.go index c47db2bd..4d9c85b4 100644 --- a/x/asset/keeper/msg_server_update_token.go +++ b/x/asset/keeper/msg_server_update_token.go @@ -18,14 +18,8 @@ func (ms msgServer) UpdateToken(goCtx context.Context, msg *types.MsgUpdateToken return nil, errorsmod.Wrapf(sdkerrors.ErrKeyNotFound, "symbol %s does not exists: %s", msg.Symbol, err.Error()) } - // Checks if the token manager signed - signers, _, err := ms.cdc.GetMsgV1Signers(msg) - if err != nil { - return nil, err - } - // assert that the manager account is the only signer of the message - if sdk.AccAddress(signers[0]).String() != existing.Manager { + if msg.Manager != existing.Manager { return nil, errorsmod.Wrap(sdkerrors.ErrUnauthorized, "caller not authorized") } diff --git a/x/bridge/abci.go b/x/bridge/abci.go index 5d799f9d..3174c194 100644 --- a/x/bridge/abci.go +++ b/x/bridge/abci.go @@ -5,6 +5,7 @@ import ( "fmt" errorsmod "cosmossdk.io/errors" + "cosmossdk.io/math" "github.com/cosmos/cosmos-sdk/telemetry" sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" @@ -45,7 +46,8 @@ func BeginBlocker(goCtx context.Context, k keeper.Keeper) error { epochInfo.CurrentEpochStartTime = epochInfo.CurrentEpochStartTime.Add(epochInfo.Duration) err = k.RegisteredCoins.Walk(goCtx, nil, func(denom string, ratelimit types.RateLimit) (stop bool, err error) { - ratelimit.ResetInflow() + // Reset Inflow + ratelimit.CurrentInflow = math.ZeroInt() err = k.RegisteredCoins.Set(goCtx, denom, ratelimit) if err != nil { k.Logger(goCtx).Error(fmt.Sprintf("Error reset ratelimit with denom %s at height %d", denom, epochInfo.CurrentEpochStartHeight)) diff --git a/x/bridge/types/ratelimit.go b/x/bridge/types/ratelimit.go index 1075aa56..8f5fe018 100644 --- a/x/bridge/types/ratelimit.go +++ b/x/bridge/types/ratelimit.go @@ -42,7 +42,3 @@ func (r *RateLimit) CheckAddInflowThreshold(amount math.Int) error { r.CurrentInflow = netInflow return nil } - -func (r *RateLimit) ResetInflow() { - r.CurrentInflow = math.ZeroInt() -}