diff --git a/x/fungible/keeper/msg_server_deploy_fungible_coin_zrc20.go b/x/fungible/keeper/msg_server_deploy_fungible_coin_zrc20.go index 24ab3f5f87..76bfbba39e 100644 --- a/x/fungible/keeper/msg_server_deploy_fungible_coin_zrc20.go +++ b/x/fungible/keeper/msg_server_deploy_fungible_coin_zrc20.go @@ -37,12 +37,14 @@ func (k msgServer) DeployFungibleCoinZRC20(goCtx context.Context, msg *types.Msg var address common.Address var err error + if err = msg.ValidateBasic(); err != nil { + return nil, err + } + if msg.Creator != k.observerKeeper.GetParams(ctx).GetAdminPolicyAccount(zetaObserverTypes.Policy_Type_group2) { return nil, sdkerrors.Wrap(sdkerrors.ErrUnauthorized, "Deploy can only be executed by the correct policy account") } - if msg.Decimals > 255 { - return nil, sdkerrors.Wrapf(sdkerrors.ErrInvalidRequest, "decimals must be less than 256") - } + if msg.CoinType == zetacommon.CoinType_Gas { // #nosec G701 always in range address, err = k.SetupChainGasCoinAndPool(ctx, msg.ForeignChainId, msg.Name, msg.Symbol, uint8(msg.Decimals), big.NewInt(msg.GasLimit)) diff --git a/x/fungible/keeper/msg_server_deploy_fungible_coin_zrc20_test.go b/x/fungible/keeper/msg_server_deploy_fungible_coin_zrc20_test.go index 788feba0fb..95426c9437 100644 --- a/x/fungible/keeper/msg_server_deploy_fungible_coin_zrc20_test.go +++ b/x/fungible/keeper/msg_server_deploy_fungible_coin_zrc20_test.go @@ -122,7 +122,7 @@ func TestMsgServer_DeployFungibleCoinZRC20(t *testing.T) { admin, sample.EthAddress().Hex(), chainID, - 256, + 78, "foo", "foo", common.CoinType_Gas, diff --git a/x/fungible/types/message_deploy_fungible_coin_zrc20.go b/x/fungible/types/message_deploy_fungible_coin_zrc20.go index 14d6681b3f..6b23365001 100644 --- a/x/fungible/types/message_deploy_fungible_coin_zrc20.go +++ b/x/fungible/types/message_deploy_fungible_coin_zrc20.go @@ -50,7 +50,11 @@ func (msg *MsgDeployFungibleCoinZRC20) ValidateBasic() error { return sdkerrors.Wrapf(sdkerrors.ErrInvalidAddress, "invalid creator address (%s)", err) } if msg.GasLimit < 0 { - return sdkerrors.Wrapf(sdkerrors.ErrInvalidGasLimit, "invalid gas limit (%s)", err) + return sdkerrors.Wrapf(sdkerrors.ErrInvalidGasLimit, "invalid gas limit") + } + + if msg.Decimals > 77 { + return sdkerrors.Wrapf(sdkerrors.ErrInvalidRequest, "decimals must be less than 78") } return nil } diff --git a/x/fungible/types/message_deploy_fungible_coin_zrc20_test.go b/x/fungible/types/message_deploy_fungible_coin_zrc20_test.go index 75f50bc290..e107af7781 100644 --- a/x/fungible/types/message_deploy_fungible_coin_zrc20_test.go +++ b/x/fungible/types/message_deploy_fungible_coin_zrc20_test.go @@ -30,6 +30,14 @@ func TestMsgDeployFungibleCoinZRC4_ValidateBasic(t *testing.T) { }, err: sdkerrors.ErrInvalidGasLimit, }, + { + name: "invalid decimals", + msg: types.MsgDeployFungibleCoinZRC20{ + Creator: sample.AccAddress(), + Decimals: 78, + }, + err: sdkerrors.Wrapf(sdkerrors.ErrInvalidRequest, "decimals must be less than 78"), + }, { name: "valid message", msg: types.MsgDeployFungibleCoinZRC20{