From b0c6b7b5ddb490ea0a19181e8ff4e1c479122812 Mon Sep 17 00:00:00 2001 From: skosito Date: Wed, 21 Feb 2024 15:17:42 +0100 Subject: [PATCH] Fix lint --- x/crosschain/keeper/msg_server_vote_inbound_tx.go | 3 +-- .../keeper/msg_server_vote_inbound_tx_test.go | 4 ++-- x/fungible/keeper/gas_price.go | 11 +++++------ x/observer/types/message_add_observer.go | 7 +++---- x/observer/types/message_update_observer.go | 9 ++++----- 5 files changed, 15 insertions(+), 19 deletions(-) diff --git a/x/crosschain/keeper/msg_server_vote_inbound_tx.go b/x/crosschain/keeper/msg_server_vote_inbound_tx.go index 45af5ba0f6..930bbd8421 100644 --- a/x/crosschain/keeper/msg_server_vote_inbound_tx.go +++ b/x/crosschain/keeper/msg_server_vote_inbound_tx.go @@ -5,7 +5,6 @@ import ( "fmt" cosmoserrors "cosmossdk.io/errors" - errorsmod "cosmossdk.io/errors" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/zeta-chain/zetacore/common" "github.com/zeta-chain/zetacore/x/crosschain/types" @@ -93,7 +92,7 @@ func (k msgServer) VoteOnObservedInboundTx(goCtx context.Context, msg *types.Msg if isNew { // Check if the inbound has already been processed. if k.IsFinalizedInbound(ctx, msg.InTxHash, msg.SenderChainId, msg.EventIndex) { - return nil, errorsmod.Wrap(types.ErrObservedTxAlreadyFinalized, fmt.Sprintf("InTxHash:%s, SenderChainID:%d, EventIndex:%d", msg.InTxHash, msg.SenderChainId, msg.EventIndex)) + return nil, cosmoserrors.Wrap(types.ErrObservedTxAlreadyFinalized, fmt.Sprintf("InTxHash:%s, SenderChainID:%d, EventIndex:%d", msg.InTxHash, msg.SenderChainId, msg.EventIndex)) } observerKeeper.EmitEventBallotCreated(ctx, ballot, msg.InTxHash, observationChain.String()) } diff --git a/x/crosschain/keeper/msg_server_vote_inbound_tx_test.go b/x/crosschain/keeper/msg_server_vote_inbound_tx_test.go index 1a8c742c5b..1605a37e33 100644 --- a/x/crosschain/keeper/msg_server_vote_inbound_tx_test.go +++ b/x/crosschain/keeper/msg_server_vote_inbound_tx_test.go @@ -60,7 +60,7 @@ func TestKeeper_VoteOnObservedInboundTx(t *testing.T) { require.NoError(t, err) } ballot, _, _ := zk.ObserverKeeper.FindBallot(ctx, msg.Digest(), zk.ObserverKeeper.GetSupportedChainFromChainID(ctx, msg.SenderChainId), observerTypes.ObservationType_InBoundTx) - require.Equal(t, ballot.BallotStatus, observerTypes.BallotStatus_BallotFinalized_SuccessObservation) + require.Equal(t, ballot.BallotStatus, observertypes.BallotStatus_BallotFinalized_SuccessObservation) cctx, found := k.GetCrossChainTx(ctx, msg.Digest()) require.True(t, found) require.Equal(t, cctx.CctxStatus.Status, types.CctxStatus_OutboundMined) @@ -122,7 +122,7 @@ func TestNoDoubleEventProtections(t *testing.T) { // Check that the vote passed ballot, found := zk.ObserverKeeper.GetBallot(ctx, msg.Digest()) require.True(t, found) - require.Equal(t, ballot.BallotStatus, observerTypes.BallotStatus_BallotFinalized_SuccessObservation) + require.Equal(t, ballot.BallotStatus, observertypes.BallotStatus_BallotFinalized_SuccessObservation) //Perform the SAME event. Except, this time, we resubmit the event. msg2 := &types.MsgVoteOnObservedInboundTx{ Creator: validatorAddr, diff --git a/x/fungible/keeper/gas_price.go b/x/fungible/keeper/gas_price.go index 68acdc98b9..636cffeec9 100644 --- a/x/fungible/keeper/gas_price.go +++ b/x/fungible/keeper/gas_price.go @@ -5,7 +5,6 @@ import ( cosmoserrors "cosmossdk.io/errors" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/ethereum/go-ethereum/common" ethcommon "github.com/ethereum/go-ethereum/common" systemcontract "github.com/zeta-chain/protocol-contracts/pkg/contracts/zevm/systemcontract.sol" "github.com/zeta-chain/zetacore/x/fungible/types" @@ -20,7 +19,7 @@ func (k Keeper) SetGasPrice(ctx sdk.Context, chainid *big.Int, gasPrice *big.Int if !found { return 0, cosmoserrors.Wrapf(types.ErrContractNotFound, "system contract state variable not found") } - oracle := common.HexToAddress(system.SystemContract) + oracle := ethcommon.HexToAddress(system.SystemContract) if oracle == (ethcommon.Address{}) { return 0, cosmoserrors.Wrapf(types.ErrContractNotFound, "system contract invalid address") } @@ -39,12 +38,12 @@ func (k Keeper) SetGasPrice(ctx sdk.Context, chainid *big.Int, gasPrice *big.Int return res.GasUsed, nil } -func (k Keeper) SetGasCoin(ctx sdk.Context, chainid *big.Int, address common.Address) error { +func (k Keeper) SetGasCoin(ctx sdk.Context, chainid *big.Int, address ethcommon.Address) error { system, found := k.GetSystemContract(ctx) if !found { return cosmoserrors.Wrapf(types.ErrContractNotFound, "system contract state variable not found") } - oracle := common.HexToAddress(system.SystemContract) + oracle := ethcommon.HexToAddress(system.SystemContract) if oracle == (ethcommon.Address{}) { return cosmoserrors.Wrapf(types.ErrContractNotFound, "system contract invalid address") } @@ -63,12 +62,12 @@ func (k Keeper) SetGasCoin(ctx sdk.Context, chainid *big.Int, address common.Add return nil } -func (k Keeper) SetGasZetaPool(ctx sdk.Context, chainid *big.Int, pool common.Address) error { +func (k Keeper) SetGasZetaPool(ctx sdk.Context, chainid *big.Int, pool ethcommon.Address) error { system, found := k.GetSystemContract(ctx) if !found { return cosmoserrors.Wrapf(types.ErrContractNotFound, "system contract state variable not found") } - oracle := common.HexToAddress(system.SystemContract) + oracle := ethcommon.HexToAddress(system.SystemContract) if oracle == (ethcommon.Address{}) { return cosmoserrors.Wrapf(types.ErrContractNotFound, "system contract invalid address") } diff --git a/x/observer/types/message_add_observer.go b/x/observer/types/message_add_observer.go index a045154c4f..991bb0afa1 100644 --- a/x/observer/types/message_add_observer.go +++ b/x/observer/types/message_add_observer.go @@ -2,7 +2,6 @@ package types import ( cosmoserrors "cosmossdk.io/errors" - errorsmod "cosmossdk.io/errors" sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" "github.com/zeta-chain/zetacore/common" @@ -49,15 +48,15 @@ func (msg *MsgAddObserver) ValidateBasic() error { } _, err = sdk.AccAddressFromBech32(msg.ObserverAddress) if err != nil { - return errorsmod.Wrapf(sdkerrors.ErrInvalidAddress, "invalid observer address (%s)", err) + return cosmoserrors.Wrapf(sdkerrors.ErrInvalidAddress, "invalid observer address (%s)", err) } _, err = common.NewPubKey(msg.ZetaclientGranteePubkey) if err != nil { - return errorsmod.Wrapf(sdkerrors.ErrInvalidPubKey, "invalid zetaclient grantee pubkey (%s)", err) + return cosmoserrors.Wrapf(sdkerrors.ErrInvalidPubKey, "invalid zetaclient grantee pubkey (%s)", err) } _, err = common.GetAddressFromPubkeyString(msg.ZetaclientGranteePubkey) if err != nil { - return errorsmod.Wrapf(sdkerrors.ErrInvalidPubKey, "invalid zetaclient grantee pubkey (%s)", err) + return cosmoserrors.Wrapf(sdkerrors.ErrInvalidPubKey, "invalid zetaclient grantee pubkey (%s)", err) } return nil } diff --git a/x/observer/types/message_update_observer.go b/x/observer/types/message_update_observer.go index 4384099f2e..c6db5a1206 100644 --- a/x/observer/types/message_update_observer.go +++ b/x/observer/types/message_update_observer.go @@ -2,7 +2,6 @@ package types import ( cosmoserrors "cosmossdk.io/errors" - errorsmod "cosmossdk.io/errors" sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" ) @@ -48,17 +47,17 @@ func (msg *MsgUpdateObserver) ValidateBasic() error { } _, err = sdk.AccAddressFromBech32(msg.OldObserverAddress) if err != nil { - return errorsmod.Wrapf(sdkerrors.ErrInvalidAddress, "invalid old observer address (%s)", err) + return cosmoserrors.Wrapf(sdkerrors.ErrInvalidAddress, "invalid old observer address (%s)", err) } _, err = sdk.AccAddressFromBech32(msg.NewObserverAddress) if err != nil { - return errorsmod.Wrapf(sdkerrors.ErrInvalidAddress, "invalid new observer address (%s)", err) + return cosmoserrors.Wrapf(sdkerrors.ErrInvalidAddress, "invalid new observer address (%s)", err) } if msg.UpdateReason != ObserverUpdateReason_Tombstoned && msg.UpdateReason != ObserverUpdateReason_AdminUpdate { - return errorsmod.Wrapf(ErrUpdateObserver, "invalid update reason (%s)", msg.UpdateReason) + return cosmoserrors.Wrapf(ErrUpdateObserver, "invalid update reason (%s)", msg.UpdateReason) } if msg.UpdateReason == ObserverUpdateReason_Tombstoned && msg.OldObserverAddress != msg.Creator { - return errorsmod.Wrapf(ErrUpdateObserver, "invalid old observer address (%s)", msg.OldObserverAddress) + return cosmoserrors.Wrapf(ErrUpdateObserver, "invalid old observer address (%s)", msg.OldObserverAddress) } return nil }