Skip to content

Commit

Permalink
Fix lint
Browse files Browse the repository at this point in the history
  • Loading branch information
skosito committed Feb 21, 2024
1 parent 4099a2e commit b0c6b7b
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 19 deletions.
3 changes: 1 addition & 2 deletions x/crosschain/keeper/msg_server_vote_inbound_tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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())
}
Expand Down
4 changes: 2 additions & 2 deletions x/crosschain/keeper/msg_server_vote_inbound_tx_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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,
Expand Down
11 changes: 5 additions & 6 deletions x/fungible/keeper/gas_price.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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")
}
Expand All @@ -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")
}
Expand All @@ -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")
}
Expand Down
7 changes: 3 additions & 4 deletions x/observer/types/message_add_observer.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
}
9 changes: 4 additions & 5 deletions x/observer/types/message_update_observer.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand Down Expand Up @@ -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
}

0 comments on commit b0c6b7b

Please sign in to comment.