Skip to content

Commit

Permalink
fix(tokenfactory): remove denom validation upon change admin (#675)
Browse files Browse the repository at this point in the history
validate basic doesn't validate denom

(cherry picked from commit 848d94f)
  • Loading branch information
mtsitrin authored and omritoptix committed Jan 19, 2025
1 parent 1107877 commit 7c46ed9
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 14 deletions.
2 changes: 1 addition & 1 deletion x/tokenfactory/bindings/message_plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ func GetFullDenom(contract string, subDenom string) (string, error) {
if _, err := parseAddress(contract); err != nil {
return "", err
}
fullDenom, err := tokenfactorytypes.GetTokenDenom(contract, subDenom)
fullDenom, err := tokenfactorytypes.ConstructFactoryDenom(contract, subDenom)
if err != nil {
return "", sdkerrors.Wrap(err, "validate sub-denom")
}
Expand Down
2 changes: 1 addition & 1 deletion x/tokenfactory/keeper/createdenom.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ func (k Keeper) validateCreateDenom(ctx sdk.Context, creatorAddr string, subdeno
"can't create subdenoms that are the same as a native denom")
}

denom, err := types.GetTokenDenom(creatorAddr, subdenom)
denom, err := types.ConstructFactoryDenom(creatorAddr, subdenom)
if err != nil {
return "", err
}
Expand Down
4 changes: 2 additions & 2 deletions x/tokenfactory/types/denoms.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ const (
MaxCreatorLength = 59 + MaxHrpLength
)

// GetTokenDenom constructs a denom string for tokens created by tokenfactory
// ConstructFactoryDenom constructs a denom string for tokens created by tokenfactory
// based on an input creator address and a subdenom
// The denom constructed is factory/{creator}/{subdenom}
func GetTokenDenom(creator, subdenom string) (string, error) {
func ConstructFactoryDenom(creator, subdenom string) (string, error) {
if len(subdenom) > MaxSubdenomLength {
return "", ErrSubdenomTooLong
}
Expand Down
2 changes: 1 addition & 1 deletion x/tokenfactory/types/denoms_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ func TestGetTokenDenom(t *testing.T) {
},
} {
t.Run(tc.desc, func(t *testing.T) {
_, err := types.GetTokenDenom(tc.creator, tc.subdenom)
_, err := types.ConstructFactoryDenom(tc.creator, tc.subdenom)
if tc.valid {
require.NoError(t, err)
} else {
Expand Down
12 changes: 3 additions & 9 deletions x/tokenfactory/types/msgs.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ func (m MsgCreateDenom) ValidateBasic() error {
return sdkerrors.Wrapf(sdkerrors.ErrInvalidAddress, "Invalid sender address (%s)", err)
}

_, err = GetTokenDenom(m.Sender, m.Subdenom)
_, err = ConstructFactoryDenom(m.Sender, m.Subdenom)
if err != nil {
return sdkerrors.Wrap(ErrInvalidDenom, err.Error())
}
Expand Down Expand Up @@ -188,9 +188,8 @@ func (m MsgChangeAdmin) ValidateBasic() error {
return sdkerrors.Wrapf(sdkerrors.ErrInvalidAddress, "Invalid address (%s)", err)
}

_, _, err = DeconstructDenom(m.Denom)
if err != nil {
return err
if m.Denom == "" {
return sdkerrors.Wrapf(sdkerrors.ErrInvalidRequest, "Denom cannot be empty")
}

return nil
Expand Down Expand Up @@ -228,11 +227,6 @@ func (m MsgSetDenomMetadata) ValidateBasic() error {
return err
}

_, _, err = DeconstructDenom(m.Metadata.Base)
if err != nil {
return err
}

return nil
}

Expand Down

0 comments on commit 7c46ed9

Please sign in to comment.