Skip to content

Commit

Permalink
fix: use accAddress to compare in validatebasic function in collectio…
Browse files Browse the repository at this point in the history
…n & token modules

Signed-off-by: 170210 <[email protected]>
  • Loading branch information
170210 committed Mar 19, 2024
1 parent 3e087f8 commit 2870e3f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
9 changes: 6 additions & 3 deletions x/collection/msgs.go
Original file line number Diff line number Diff line change
Expand Up @@ -428,14 +428,17 @@ func (m MsgAuthorizeOperator) ValidateBasic() error {
return err
}

if _, err := sdk.AccAddressFromBech32(m.Holder); err != nil {
holderAcc, err := sdk.AccAddressFromBech32(m.Holder)
if err != nil {
return sdkerrors.ErrInvalidAddress.Wrapf("invalid holder address: %s", m.Holder)
}
if _, err := sdk.AccAddressFromBech32(m.Operator); err != nil {

operatorAcc, err := sdk.AccAddressFromBech32(m.Operator)
if err != nil {
return sdkerrors.ErrInvalidAddress.Wrapf("invalid operator address: %s", m.Operator)
}

if m.Operator == m.Holder {
if holderAcc.Equals(operatorAcc) {
return ErrApproverProxySame
}

Expand Down
9 changes: 6 additions & 3 deletions x/token/msgs.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,14 +146,17 @@ func (m MsgAuthorizeOperator) ValidateBasic() error {
return err
}

if _, err := sdk.AccAddressFromBech32(m.Holder); err != nil {
holderAcc, err := sdk.AccAddressFromBech32(m.Holder)
if err != nil {
return sdkerrors.ErrInvalidAddress.Wrapf("invalid holder address: %s", m.Holder)
}
if _, err := sdk.AccAddressFromBech32(m.Operator); err != nil {

operatorAcc, err := sdk.AccAddressFromBech32(m.Operator)
if err != nil {
return sdkerrors.ErrInvalidAddress.Wrapf("invalid operator address: %s", m.Operator)
}

if m.Operator == m.Holder {
if holderAcc.Equals(operatorAcc) {
return ErrApproverProxySame
}

Expand Down

0 comments on commit 2870e3f

Please sign in to comment.