From cee7d06df9a501a56d9cf173eb38dc0438d94b68 Mon Sep 17 00:00:00 2001 From: lukema95 <867273263@qq.com> Date: Wed, 7 Feb 2024 09:41:30 +0800 Subject: [PATCH] refactor: remove codes that are not related to PR --- .../types/message_update_contract_bytecode.go | 4 ---- .../types/message_update_contract_bytecode_test.go | 10 ---------- x/fungible/types/message_update_system_contract.go | 8 ++------ .../types/message_update_zrc20_paused_status.go | 5 ----- .../message_update_zrc20_paused_status_test.go | 13 ------------- 5 files changed, 2 insertions(+), 38 deletions(-) diff --git a/x/fungible/types/message_update_contract_bytecode.go b/x/fungible/types/message_update_contract_bytecode.go index 581537957e..212526b558 100644 --- a/x/fungible/types/message_update_contract_bytecode.go +++ b/x/fungible/types/message_update_contract_bytecode.go @@ -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) diff --git a/x/fungible/types/message_update_contract_bytecode_test.go b/x/fungible/types/message_update_contract_bytecode_test.go index 772aff91a0..02e8b3cfdd 100644 --- a/x/fungible/types/message_update_contract_bytecode_test.go +++ b/x/fungible/types/message_update_contract_bytecode_test.go @@ -9,7 +9,6 @@ import ( ) func TestMsgUpdateContractBytecode_ValidateBasic(t *testing.T) { - sampleAddress := sample.EthAddress().String() tt := []struct { name string msg types.MsgUpdateContractBytecode @@ -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 { diff --git a/x/fungible/types/message_update_system_contract.go b/x/fungible/types/message_update_system_contract.go index e7eef7f261..b6879f2ff6 100644 --- a/x/fungible/types/message_update_system_contract.go +++ b/x/fungible/types/message_update_system_contract.go @@ -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" @@ -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 diff --git a/x/fungible/types/message_update_zrc20_paused_status.go b/x/fungible/types/message_update_zrc20_paused_status.go index fc74587e34..9eb1b77bd5 100644 --- a/x/fungible/types/message_update_zrc20_paused_status.go +++ b/x/fungible/types/message_update_zrc20_paused_status.go @@ -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 } diff --git a/x/fungible/types/message_update_zrc20_paused_status_test.go b/x/fungible/types/message_update_zrc20_paused_status_test.go index 66e873eeef..326af3fe96 100644 --- a/x/fungible/types/message_update_zrc20_paused_status_test.go +++ b/x/fungible/types/message_update_zrc20_paused_status_test.go @@ -9,7 +9,6 @@ import ( ) func TestMMsgUpdateZRC20PausedStatus_ValidateBasic(t *testing.T) { - sampleAddress := sample.EthAddress().String() tt := []struct { name string msg types.MsgUpdateZRC20PausedStatus @@ -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{