Skip to content

Commit

Permalink
fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
dreamer-zq committed Apr 22, 2024
1 parent d5cc5fe commit 50833ca
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions modules/token/types/v1/msgs.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ var (
_ sdk.Msg = &MsgDeployERC20{}
_ sdk.Msg = &MsgSwapFromERC20{}
_ sdk.Msg = &MsgSwapToERC20{}
_ sdk.Msg = &MsgUpgradeERC20{}

regexpERC20Fmt = fmt.Sprintf("^[a-z][a-z0-9/]{%d,%d}$", tokentypes.MinimumSymbolLen-1, tokentypes.MaximumSymbolLen-1)
regexpERC20 = regexp.MustCompile(regexpERC20Fmt).MatchString
Expand Down Expand Up @@ -441,6 +442,24 @@ func (m *MsgSwapToERC20) GetSigners() []sdk.AccAddress {
return []sdk.AccAddress{addr}
}

// ValidateBasic implements Msg
func (m *MsgUpgradeERC20) ValidateBasic() error {
if _, err := sdk.AccAddressFromBech32(m.Authority); err != nil {
return errorsmod.Wrapf(sdkerrors.ErrInvalidAddress, "invalid authority address (%s)", err)
}

if !common.IsHexAddress(m.Implementation) {
return errorsmod.Wrapf(sdkerrors.ErrInvalidAddress, "expecting a hex address, got %s", m.Implementation)
}
return nil
}

// GetSigners returns the expected signers for a MsgUpgradeERC20 message
func (m *MsgUpgradeERC20) GetSigners() []sdk.AccAddress {
addr, _ := sdk.AccAddressFromBech32(m.Authority)
return []sdk.AccAddress{addr}
}

// ValidateERC20 validates ERC20 symbol or name
func ValidateERC20(params string) error {
if !regexpERC20(params) {
Expand Down

0 comments on commit 50833ca

Please sign in to comment.