Skip to content

Commit

Permalink
Allow FeeCollectorAddress to be valid when setting Tokenfactory params
Browse files Browse the repository at this point in the history
This fixes the issue where MsgUpdateParams.Validate() only passes when
FeeCollectorAddress is set. It should be possible to set params with an empty FeeCollectorAddress
  • Loading branch information
jcompagni10 committed Jul 2, 2024
1 parent b5a30ef commit ff4b977
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 9 deletions.
18 changes: 15 additions & 3 deletions x/tokenfactory/keeper/msg_server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
},
}

Expand Down
6 changes: 0 additions & 6 deletions x/tokenfactory/types/tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}

0 comments on commit ff4b977

Please sign in to comment.