From ff4b9779a87849f1e7d449d55c5d078c86325ecc Mon Sep 17 00:00:00 2001 From: Julian Compagni Portis Date: Tue, 2 Jul 2024 12:33:44 -0400 Subject: [PATCH] Allow FeeCollectorAddress to be valid when setting Tokenfactory params This fixes the issue where MsgUpdateParams.Validate() only passes when FeeCollectorAddress is set. It should be possible to set params with an empty FeeCollectorAddress --- x/tokenfactory/keeper/msg_server_test.go | 18 +++++++++++++++--- x/tokenfactory/types/tx.go | 6 ------ 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/x/tokenfactory/keeper/msg_server_test.go b/x/tokenfactory/keeper/msg_server_test.go index 5130f266b..fd51c7a4f 100644 --- a/x/tokenfactory/keeper/msg_server_test.go +++ b/x/tokenfactory/keeper/msg_server_test.go @@ -869,24 +869,36 @@ func TestMsgUpdateParamsValidate(t *testing.T) { "authority is invalid", }, { - "empty fee_collector_address", + "empty fee_collector_address with denom_creation_fee", types.MsgUpdateParams{ Authority: testutil.TestOwnerAddress, Params: types.Params{ FeeCollectorAddress: "", + DenomCreationFee: sdktypes.NewCoins(sdktypes.NewCoin("untrn", math.OneInt())), }, }, - "fee_collector_address is invalid", + "DenomCreationFee and FeeCollectorAddr must be both set or both unset", + }, + { + "fee_collector_address empty denom_creation_fee", + types.MsgUpdateParams{ + Authority: testutil.TestOwnerAddress, + Params: types.Params{ + FeeCollectorAddress: testAddress, + }, + }, + "DenomCreationFee and FeeCollectorAddr must be both set or both unset", }, { "invalid fee_collector_address", types.MsgUpdateParams{ Authority: testutil.TestOwnerAddress, Params: types.Params{ + DenomCreationFee: sdktypes.NewCoins(sdktypes.NewCoin("untrn", math.OneInt())), FeeCollectorAddress: "invalid fee_collector_address", }, }, - "fee_collector_address is invalid", + "failed to validate FeeCollectorAddress", }, } diff --git a/x/tokenfactory/types/tx.go b/x/tokenfactory/types/tx.go index 8b908d852..3925b0b5a 100644 --- a/x/tokenfactory/types/tx.go +++ b/x/tokenfactory/types/tx.go @@ -32,11 +32,5 @@ func (msg *MsgUpdateParams) Validate() error { return errorsmod.Wrap(err, "authority is invalid") } - // TODO: This is inconsistent. Per Params.Validate() an empty creator address is valid as long as - // DenomCreationFee is nil. But This check fails if FeeCollectorAddress is unset. - if _, err := sdk.AccAddressFromBech32(msg.Params.FeeCollectorAddress); err != nil { - return errorsmod.Wrap(err, "fee_collector_address is invalid") - } - return msg.Params.Validate() }