Skip to content

Commit

Permalink
refactor: remove codes that are not related to PR
Browse files Browse the repository at this point in the history
  • Loading branch information
lukema95 committed Feb 7, 2024
1 parent e5ee939 commit cee7d06
Show file tree
Hide file tree
Showing 5 changed files with 2 additions and 38 deletions.
4 changes: 0 additions & 4 deletions x/fungible/types/message_update_contract_bytecode.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,6 @@ func (msg *MsgUpdateContractBytecode) ValidateBasic() error {
return cosmoserror.Wrapf(sdkerrors.ErrInvalidAddress, "invalid creator address (%s)", err)
}

if msg.ContractAddress == msg.NewCodeHash {
return cosmoserror.Wrapf(sdkerrors.ErrInvalidRequest, "contract address and new bytecode address cannot be the same")
}

// check if the contract address is valid
if !ethcommon.IsHexAddress(msg.ContractAddress) {
return cosmoserror.Wrapf(sdkerrors.ErrInvalidAddress, "invalid contract address (%s)", msg.ContractAddress)
Expand Down
10 changes: 0 additions & 10 deletions x/fungible/types/message_update_contract_bytecode_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import (
)

func TestMsgUpdateContractBytecode_ValidateBasic(t *testing.T) {
sampleAddress := sample.EthAddress().String()
tt := []struct {
name string
msg types.MsgUpdateContractBytecode
Expand Down Expand Up @@ -51,15 +50,6 @@ func TestMsgUpdateContractBytecode_ValidateBasic(t *testing.T) {
},
wantError: true,
},
{
name: "same old contract and new bytecode address",
msg: types.MsgUpdateContractBytecode{
Creator: sample.AccAddress(),
ContractAddress: sampleAddress,
NewCodeHash: sampleAddress,
},
wantError: true,
},
}

for _, tc := range tt {
Expand Down
8 changes: 2 additions & 6 deletions x/fungible/types/message_update_system_contract.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package types

import (
cosmoserrors "cosmossdk.io/errors"
sdk "github.com/cosmos/cosmos-sdk/types"
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
ethcommon "github.com/ethereum/go-ethereum/common"
Expand Down Expand Up @@ -42,14 +41,11 @@ func (msg *MsgUpdateSystemContract) GetSignBytes() []byte {
func (msg *MsgUpdateSystemContract) ValidateBasic() error {
_, err := sdk.AccAddressFromBech32(msg.Creator)
if err != nil {
return cosmoserrors.Wrapf(sdkerrors.ErrInvalidAddress, "invalid creator address (%s)", err)
return sdkerrors.Wrapf(sdkerrors.ErrInvalidAddress, "invalid creator address (%s)", err)
}
// check if the system contract address is valid
if ethcommon.HexToAddress(msg.NewSystemContractAddress) == (ethcommon.Address{}) {
return cosmoserrors.Wrapf(sdkerrors.ErrInvalidAddress, "invalid system contract address (%s)", msg.NewSystemContractAddress)
}
if !ethcommon.IsHexAddress(msg.NewSystemContractAddress) {
return cosmoserrors.Wrapf(sdkerrors.ErrInvalidAddress, "invalid system contract address (%s)", msg.NewSystemContractAddress)
return sdkerrors.Wrapf(sdkerrors.ErrInvalidAddress, "invalid system contract address (%s)", msg.NewSystemContractAddress)
}

return nil
Expand Down
5 changes: 0 additions & 5 deletions x/fungible/types/message_update_zrc20_paused_status.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,15 +55,10 @@ func (msg *MsgUpdateZRC20PausedStatus) ValidateBasic() error {
}

// check if all zrc20 addresses are valid
found := make(map[string]bool)
for _, zrc20 := range msg.Zrc20Addresses {
if !ethcommon.IsHexAddress(zrc20) {
return cosmoserrors.Wrapf(sdkerrors.ErrInvalidAddress, "invalid zrc20 contract address (%s)", zrc20)
}
if found[zrc20] {
return cosmoserrors.Wrapf(sdkerrors.ErrInvalidRequest, "duplicate zrc20 contract address (%s)", zrc20)
}
found[zrc20] = true
}
return nil
}
13 changes: 0 additions & 13 deletions x/fungible/types/message_update_zrc20_paused_status_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import (
)

func TestMMsgUpdateZRC20PausedStatus_ValidateBasic(t *testing.T) {
sampleAddress := sample.EthAddress().String()
tt := []struct {
name string
msg types.MsgUpdateZRC20PausedStatus
Expand Down Expand Up @@ -76,18 +75,6 @@ func TestMMsgUpdateZRC20PausedStatus_ValidateBasic(t *testing.T) {
},
wantErr: true,
},
{
name: "duplicate zrc20 address",
msg: types.MsgUpdateZRC20PausedStatus{
Creator: sample.AccAddress(),
Zrc20Addresses: []string{
sampleAddress,
sampleAddress,
},
Action: types.UpdatePausedStatusAction_PAUSE,
},
wantErr: true,
},
{
name: "invalid action",
msg: types.MsgUpdateZRC20PausedStatus{
Expand Down

0 comments on commit cee7d06

Please sign in to comment.