Skip to content

Commit

Permalink
fix golint error
Browse files Browse the repository at this point in the history
  • Loading branch information
sheldonleedev committed Jun 14, 2024
1 parent c9f2559 commit 7aeb700
Show file tree
Hide file tree
Showing 52 changed files with 82 additions and 130 deletions.
1 change: 0 additions & 1 deletion app/ante/btc_validation_decorator.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ func newBtcValidationDecorator(
}

func (bvd BtcValidationDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate bool, next sdk.AnteHandler) (newCtx sdk.Context, err error) {

// only do this validation when handling mempool addition. During DeliverTx they
// should be performed by btclightclient and btccheckpoint modules
if ctx.IsCheckTx() || ctx.IsReCheckTx() {
Expand Down
4 changes: 1 addition & 3 deletions app/ante/handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ func newEthAnteHandler(options HandlerOptions) sdk.AnteHandler {
return sdk.ChainAnteDecorators(
ethante.NewEthSetUpContextDecorator(options.EvmKeeper),

//FIXME: need to allow universal fees for Eth as well
// FIXME: need to allow universal fees for Eth as well
ethante.NewEthMempoolFeeDecorator(options.EvmKeeper), // Check eth effective gas price against minimal-gas-prices
ethante.NewEthMinGasPriceDecorator(options.FeeMarketKeeper, options.EvmKeeper), // Check eth effective gas price against the global MinGasPrice

Expand All @@ -33,7 +33,6 @@ func newEthAnteHandler(options HandlerOptions) sdk.AnteHandler {
// newLegacyCosmosAnteHandlerEip712 creates an AnteHandler to process legacy EIP-712
// transactions, as defined by the presence of an ExtensionOptionsWeb3Tx extension.
func newLegacyCosmosAnteHandlerEip712(options HandlerOptions) sdk.AnteHandler {

return sdk.ChainAnteDecorators(
NewRejectMessagesDecorator(), // reject MsgEthereumTxs and vesting messages
ethante.NewAuthzLimiterDecorator([]string{ // disable the Msg types that cannot be included on an authz.MsgExec msgs field
Expand Down Expand Up @@ -62,7 +61,6 @@ func newLegacyCosmosAnteHandlerEip712(options HandlerOptions) sdk.AnteHandler {
}

func newCosmosAnteHandler(options HandlerOptions) sdk.AnteHandler {

return sdk.ChainAnteDecorators(
NewRejectMessagesDecorator(), // reject MsgEthereumTxs and vesting msgs
ethante.NewAuthzLimiterDecorator([]string{ // disable the Msg types that cannot be included on an authz.MsgExec msgs field
Expand Down
4 changes: 2 additions & 2 deletions app/helpers/test_helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -200,9 +200,9 @@ func CreateTestAddrs(numAddrs int) []sdk.AccAddress {
// start at 100 so we can make up to 999 test addresses with valid test addresses
for i := 100; i < (numAddrs + 100); i++ {
numString := strconv.Itoa(i)
buffer.WriteString("A58856F0FD53BF058B4909A21AEC019107BA6") //base address string
buffer.WriteString("A58856F0FD53BF058B4909A21AEC019107BA6") // base address string

buffer.WriteString(numString) //adding on final two digits to make addresses unique
buffer.WriteString(numString) // adding on final two digits to make addresses unique
res, _ := sdk.AccAddressFromHexUnsafe(buffer.String())
bech := res.String()
addresses = append(addresses, testAddr(buffer.String(), bech))
Expand Down
8 changes: 4 additions & 4 deletions app/modules.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ func getGovProposalHandlers() []govclient.ProposalHandler {

govProposalHandlers = append(govProposalHandlers,
paramsclient.ProposalHandler,
//distrclient.ProposalHandler,
// distrclient.ProposalHandler,
upgradeclient.LegacyProposalHandler,
upgradeclient.LegacyCancelProposalHandler,
ibcclientclient.UpdateClientProposalHandler,
Expand Down Expand Up @@ -267,7 +267,7 @@ func orderBeginBlockers() []string {
paramstypes.ModuleName,
vestingtypes.ModuleName,

//self module
// self module
btclightclienttypes.ModuleName,
btcstakingtypes.ModuleName,
feetypes.ModuleName,
Expand Down Expand Up @@ -307,7 +307,7 @@ func orderEndBlockers() []string {
upgradetypes.ModuleName,
vestingtypes.ModuleName,

//self module
// self module
btclightclienttypes.ModuleName,
btcstakingtypes.ModuleName,
feetypes.ModuleName,
Expand Down Expand Up @@ -350,7 +350,7 @@ func orderInitBlockers() []string {
genutiltypes.ModuleName,
evidencetypes.ModuleName,

//self module
// self module

btclightclienttypes.ModuleName,
btcstakingtypes.ModuleName,
Expand Down
1 change: 0 additions & 1 deletion app/params/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ func RegisterDenoms() {
}

func SetAddressPrefixes() {

// Set config
config := sdk.GetConfig()
config.SetBech32PrefixForAccount(Bech32PrefixAccAddr, Bech32PrefixAccPub)
Expand Down
4 changes: 1 addition & 3 deletions app/upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@ import (
upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types"
)

var (
plans = []upgrades.Upgrade{}
)
var plans = []upgrades.Upgrade{}

// RegisterUpgradePlans register a handler of upgrade plan
func (app *LorenzoApp) RegisterUpgradePlans() {
Expand Down
1 change: 0 additions & 1 deletion cmd/lorenzod/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,6 @@ func initRootCmd(rootCmd *cobra.Command, encodingConfig appparams.EncodingConfig
txCommand(),
ethermintclient.KeyCommands(app.DefaultNodeHome),
)

}

// queryCommand returns the sub-command to send queries to the app
Expand Down
1 change: 0 additions & 1 deletion contracts/yieldaccruingtoken.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ var (
)

func init() {

// contract code
// https://github.com/Lorenzo-Protocol/builtin-contracts/blob/main/contracts/YieldAccruingToken.sol
err := json.Unmarshal(YieldAccruingTokenJSON, &YieldAccruingTokenContract)
Expand Down
1 change: 0 additions & 1 deletion types/btc_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ func getParams(opts servertypes.AppOptions) *chaincfg.Params {
}

network, err := cast.ToStringE(valueInterface)

if err != nil {
panic("Bitcoin network config should be valid string")
}
Expand Down
1 change: 0 additions & 1 deletion types/btc_header_bytes.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ func (m BTCHeaderBytes) MarshalJSON() ([]byte, error) {
func (m *BTCHeaderBytes) UnmarshalJSON(bz []byte) error {
var headerHexStr string
err := json.Unmarshal(bz, &headerHexStr)

if err != nil {
return err
}
Expand Down
1 change: 0 additions & 1 deletion types/btc_schnorr_pk.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,6 @@ func (pk BIP340PubKey) MarshalJSON() ([]byte, error) {
func (pk *BIP340PubKey) UnmarshalJSON(bz []byte) error {
var pkHexString string
err := json.Unmarshal(bz, &pkHexString)

if err != nil {
return err
}
Expand Down
1 change: 0 additions & 1 deletion types/btc_schnorr_sig.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ type BIP340Signature []byte
const BIP340SignatureLen = schnorr.SignatureSize

func NewBIP340Signature(data []byte) (*BIP340Signature, error) {

var sig BIP340Signature
err := sig.Unmarshal(data)

Expand Down
2 changes: 0 additions & 2 deletions types/btcutils.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ func ValidateBTCHeader(header *wire.BlockHeader, powLimit *big.Int) error {
// The upper limit for the power to be spent
// Use the one maintained by btcd
err := blockchain.CheckProofOfWork(block, powLimit)

if err != nil {
return err
}
Expand Down Expand Up @@ -69,7 +68,6 @@ func NewBTCTxFromHex(txHex string) (*wire.MsgTx, []byte, error) {
}

parsed, err := NewBTCTxFromBytes(txBytes)

if err != nil {
return nil, nil, err
}
Expand Down
2 changes: 1 addition & 1 deletion types/retry/retry.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ func Do(sleep time.Duration, maxSleepTime time.Duration, retryableFunc func() er
}

// Add some randomness to prevent thrashing
//TODO: lint
// TODO: lint
jitter := time.Duration(rand.Int63n(int64(sleep))) // nolint: gosec
sleep = sleep + jitter/2

Expand Down
8 changes: 4 additions & 4 deletions x/agent/client/cli/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,18 @@ import (

const (
// FlagName is the flag for the name of the agent
FlagName = "name"
FlagName = "name"
// FlagEthAddress is the flag for the eth address of the agent
FlagEthAddress = "eth-address"
FlagEthAddress = "eth-address"
// FlagDescription is the flag for the description of the agent
FlagDescription = "description"
// FlagURL is the flag for the url of the agent
FlagURL = "url"
FlagURL = "url"
)

var (
// FsAddAgent defines the flags for adding an agent
FsAddAgent = flag.NewFlagSet("", flag.ContinueOnError)
FsAddAgent = flag.NewFlagSet("", flag.ContinueOnError)
// FsEditAgent defines the flags for editing an agent
FsEditAgent = flag.NewFlagSet("", flag.ContinueOnError)
)
Expand Down
4 changes: 2 additions & 2 deletions x/agent/keeper/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ func (k Keeper) InitGenesis(ctx sdk.Context, genState types.GenesisState) {
// ExportGenesis returns the capability module's exported genesis.
func (k Keeper) ExportGenesis(ctx sdk.Context) *types.GenesisState {
return &types.GenesisState{
Admin: k.GetAdmin(ctx).String(),
Agents: k.getAgents(ctx),
Admin: k.GetAdmin(ctx).String(),
Agents: k.getAgents(ctx),
}
}
10 changes: 5 additions & 5 deletions x/agent/keeper/keeper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ import (
)

var (
testAdmin = helpers.CreateTestAddrs(1)[0]
agents = []types.Agent{
testAdmin = helpers.CreateTestAddrs(1)[0]
agents = []types.Agent{
{
Id: 1,
Name: "agent1",
Expand All @@ -43,8 +43,8 @@ func TestKeeperTestSuite(t *testing.T) {
func (suite *KeeperTestSuite) SetupTest() {
merge := func(cdc codec.Codec, state map[string]json.RawMessage) {
genesis := &types.GenesisState{
Agents: agents,
Admin: testAdmin.String(),
Agents: agents,
Admin: testAdmin.String(),
}
state[types.ModuleName] = cdc.MustMarshalJSON(genesis)
}
Expand Down Expand Up @@ -76,7 +76,7 @@ func (suite *KeeperTestSuite) TestGetNextNumber() {

func (suite *KeeperTestSuite) TestGetAdmin() {
suite.SetupTest()

admin := suite.keeper.GetAdmin(suite.ctx)
suite.Equal(admin, testAdmin)
}
6 changes: 3 additions & 3 deletions x/agent/keeper/msg_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ func (m msgServer) AddAgent(goctx context.Context, msg *types.MsgAddAgent) (*typ

agentID := m.k.addAgent(ctx, msg.Name, msg.BtcReceivingAddress, msg.EthAddr, msg.Description, msg.Url)

ctx.EventManager().EmitTypedEvent(&types.EventAddAgent{ //nolint:errcheck
ctx.EventManager().EmitTypedEvent(&types.EventAddAgent{ //nolint:errcheck,gosec
Id: agentID,
Name: msg.Name,
BtcReceivingAddress: msg.BtcReceivingAddress,
Expand Down Expand Up @@ -95,7 +95,7 @@ func (m msgServer) EditAgent(goctx context.Context, msg *types.MsgEditAgent) (*t
agent.Url = msg.Url
}
m.k.setAgent(ctx, agent)
ctx.EventManager().EmitTypedEvent(&types.EventEditAgent{ //nolint:errcheck
ctx.EventManager().EmitTypedEvent(&types.EventEditAgent{ //nolint:errcheck,gosec
Id: msg.Id,
Name: msg.Name,
Description: msg.Description,
Expand Down Expand Up @@ -126,7 +126,7 @@ func (m msgServer) RemoveAgent(goctx context.Context, msg *types.MsgRemoveAgent)
}

m.k.removeAgent(ctx, msg.Id)
ctx.EventManager().EmitTypedEvent(&types.EventRemoveAgent{ //nolint:errcheck
ctx.EventManager().EmitTypedEvent(&types.EventRemoveAgent{ //nolint:errcheck,gosec
Id: msg.Id,
Sender: msg.Sender,
})
Expand Down
4 changes: 0 additions & 4 deletions x/btclightclient/keeper/grpc_query.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ func (k Keeper) Hashes(ctx context.Context, req *types.QueryHashesRequest) (*typ
}
return true, nil
})

if err != nil {
return nil, err
}
Expand Down Expand Up @@ -189,21 +188,18 @@ func (k Keeper) BaseHeader(ctx context.Context, req *types.QueryBaseHeaderReques
}

func (k Keeper) HeaderDepth(ctx context.Context, req *types.QueryHeaderDepthRequest) (*types.QueryHeaderDepthResponse, error) {

if req == nil {
return nil, status.Error(codes.InvalidArgument, "invalid request")
}

haderHash, err := bbn.NewBTCHeaderHashBytesFromHex(req.Hash)

if err != nil {
return nil, status.Error(codes.InvalidArgument, "provided hash is not a valid hex string")
}

sdkCtx := sdk.UnwrapSDKContext(ctx)

depth, err := k.MainChainDepth(sdkCtx, &haderHash)

if err != nil {
return nil, err
}
Expand Down
7 changes: 1 addition & 6 deletions x/btclightclient/keeper/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,14 +63,12 @@ func (k Keeper) insertHeaders(
ctx sdk.Context,
headers []*wire.BlockHeader,
) error {

headerState := k.headersState(ctx)

result, err := k.bl.InsertHeaders(
headerState,
headers,
)

if err != nil {
return err
}
Expand Down Expand Up @@ -119,7 +117,6 @@ func (k Keeper) BlockHeight(ctx sdk.Context, headerHash *bbn.BTCHeaderHashBytes)
}

headerInfo, err := k.headersState(ctx).GetHeaderByHash(headerHash)

if err != nil {
return 0, err
}
Expand Down Expand Up @@ -157,7 +154,6 @@ func (k Keeper) GetTipInfo(ctx sdk.Context) *types.BTCHeaderInfo {
// GetHeaderByHash returns header with given hash, if it does not exists returns nil
func (k Keeper) GetHeaderByHash(ctx sdk.Context, hash *bbn.BTCHeaderHashBytes) *types.BTCHeaderInfo {
info, err := k.headersState(ctx).GetHeaderByHash(hash)

if err != nil {
return nil
}
Expand All @@ -168,7 +164,6 @@ func (k Keeper) GetHeaderByHash(ctx sdk.Context, hash *bbn.BTCHeaderHashBytes) *
// GetHeaderByHeight returns header with given height from main chain, returns nil if such header is not found
func (k Keeper) GetHeaderByHeight(ctx sdk.Context, height uint64) *types.BTCHeaderInfo {
header, err := k.headersState(ctx).GetHeaderByHeight(height)

if err != nil {
return nil
}
Expand All @@ -194,7 +189,7 @@ func (k Keeper) GetMainChainFrom(ctx sdk.Context, startHeight uint64) []*types.B
func (k Keeper) GetMainChainUpTo(ctx sdk.Context, depth uint64) []*types.BTCHeaderInfo {
headers := make([]*types.BTCHeaderInfo, 0)

var currentDepth = uint64(0)
currentDepth := uint64(0)
accHeaderFn := func(header *types.BTCHeaderInfo) bool {
// header header is at depth 0.
if currentDepth > depth {
Expand Down
2 changes: 0 additions & 2 deletions x/btclightclient/keeper/msg_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ func (m msgServer) InsertHeaders(ctx context.Context, msg *types.MsgInsertHeader
}

err := m.k.InsertHeaders(sdkCtx, msg.Headers)

if err != nil {
return nil, err
}
Expand All @@ -72,7 +71,6 @@ func (m msgServer) UpdateFeeRate(ctx context.Context, msg *types.MsgUpdateFeeRat
}

err := m.k.UpdateFeeRate(sdkCtx, msg.FeeRate)

if err != nil {
return nil, err
}
Expand Down
8 changes: 4 additions & 4 deletions x/btclightclient/keeper/triggers.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,26 +12,26 @@ func (k Keeper) triggerHeaderInserted(goCtx context.Context, headerInfo *types.B
k.AfterBTCHeaderInserted(goCtx, headerInfo)
// Emit HeaderInserted event
ctx := sdk.UnwrapSDKContext(goCtx)
ctx.EventManager().EmitTypedEvent(&types.EventBTCHeaderInserted{Header: headerInfo}) //nolint:errcheck
ctx.EventManager().EmitTypedEvent(&types.EventBTCHeaderInserted{Header: headerInfo}) //nolint:errcheck,gosec
}

func (k Keeper) triggerRollBack(goCtx context.Context, headerInfo *types.BTCHeaderInfo) {
// Trigger AfterBTCRollBack hook
k.AfterBTCRollBack(goCtx, headerInfo)
// Emit BTCRollBack event
ctx := sdk.UnwrapSDKContext(goCtx)
ctx.EventManager().EmitTypedEvent(&types.EventBTCRollBack{Header: headerInfo}) //nolint:errcheck
ctx.EventManager().EmitTypedEvent(&types.EventBTCRollBack{Header: headerInfo}) //nolint:errcheck,gosec
}

func (k Keeper) triggerRollForward(goCtx context.Context, headerInfo *types.BTCHeaderInfo) {
// Trigger AfterBTCRollForward hook
k.AfterBTCRollForward(goCtx, headerInfo)
// Emit BTCRollForward event
ctx := sdk.UnwrapSDKContext(goCtx)
ctx.EventManager().EmitTypedEvent(&types.EventBTCRollForward{Header: headerInfo}) //nolint:errcheck
ctx.EventManager().EmitTypedEvent(&types.EventBTCRollForward{Header: headerInfo}) //nolint:errcheck,gosec
}

func (k Keeper) triggerFeeRateUpdated(goCtx context.Context, feeRate uint64) {
ctx := sdk.UnwrapSDKContext(goCtx)
ctx.EventManager().EmitTypedEvent(&types.EventBTCFeeRateUpdated{FeeRate: feeRate})
ctx.EventManager().EmitTypedEvent(&types.EventBTCFeeRateUpdated{FeeRate: feeRate}) //nolint:errcheck,gosec
}
2 changes: 1 addition & 1 deletion x/btclightclient/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ func (AppModuleBasic) RegisterRESTRoutes(clientCtx client.Context, rtr *mux.Rout

// RegisterGRPCGatewayRoutes registers the gRPC Gateway routes for the module.
func (AppModuleBasic) RegisterGRPCGatewayRoutes(clientCtx client.Context, mux *runtime.ServeMux) {
types.RegisterQueryHandlerClient(context.Background(), mux, types.NewQueryClient(clientCtx)) //nolint:errcheck // generally we don't handle errors here
types.RegisterQueryHandlerClient(context.Background(), mux, types.NewQueryClient(clientCtx)) //nolint:errcheck,gosec // generally we don't handle errors here
}

// GetTxCmd returns the capability module's root tx command.
Expand Down
Loading

0 comments on commit 7aeb700

Please sign in to comment.