Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 10 additions & 6 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
name: Linters
name: Lint codebase
on:
push:
branches:
- main
pull_request:

permissions:
contents: read

jobs:
golangci:
name: lint
Expand All @@ -10,10 +16,8 @@ jobs:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: '1.22'
cache: false
go-version: stable
- name: golangci-lint
uses: golangci/golangci-lint-action@v3
uses: golangci/golangci-lint-action@v8
with:
# Require: The version of golangci-lint to use.
version: latest
version: v2.1
35 changes: 10 additions & 25 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -1,31 +1,16 @@
run:
tests: true
timeout: 5m
concurrency: 4
modules-download-mode: readonly

version: "2"
linters:
enable-all: true
default: all
disable:
# unwanted linters
- depguard # would have loved to add but doesn't seem to work correctly
- depguard
- err113
- exhaustruct
- exhaustruct # requires every field to be instantiated in e.g. struct creation
- gochecknoglobals
- gochecknoinits
- gomnd
- gomoddirectives
- mnd

linters-settings:
dogsled:
max-blank-identifiers: 1
misspell:
locale: US
nolintlint:
allow-unused: false
require-explanation: true
require-specific: true
varnamelen:
ignore-names:
- tc
- varnamelen
formatters:
enable:
- gofumpt
run:
go: "1.23"
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ install:

# ----------------------------------
# Linting
LINT_IMAGE=golangci/golangci-lint:v2.1.6
lint:
@echo "Running golangci-lint..." && \
golangci-lint run && \
echo " > Done."
docker run -t --rm -v $(CURDIR):/app -w /app $(LINT_IMAGE) golangci-lint run

# ----------------------------------
# Tests
Expand Down
11 changes: 11 additions & 0 deletions cmd/root.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// Package cmd contains the required logic to run the individual subcommands
// for the evmos-utils.
package cmd

import (
Expand Down Expand Up @@ -25,6 +27,8 @@ It can be used to test upgrades, deposit or vote for specific or the latest prop
chainID string
// denom of the chain's fee token.
denom string
// feeAmount is the amount of fees to send with a default transaction.
feeAmount int
// home is the home directory of the binary.
home string
// keyringBackend is the keyring to use.
Expand Down Expand Up @@ -71,6 +75,12 @@ func init() {
"http://localhost:26657",
"Node to post queries and transactions to",
)
rootCmd.PersistentFlags().IntVar(
&feeAmount,
"fees",
utils.GetDefaultFees(),
"Amount of fees to send with a default transaction",
)

rootCmd.AddCommand(upgradeCmd)
rootCmd.AddCommand(depositCmd)
Expand All @@ -84,6 +94,7 @@ func collectConfig() utils.BinaryConfig {
Appd: appd,
ChainID: chainID,
Denom: denom,
FeeAmount: feeAmount,
Home: home,
KeyringBackend: keyringBackend,
Node: node,
Expand Down
6 changes: 4 additions & 2 deletions gov/deposit.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// Package gov contains all logic related to governance queries and transactions
// like voting and checking minimum deposits, etc.
package gov

import (
Expand Down Expand Up @@ -61,8 +63,8 @@ func GetMinDeposit(bin *utils.Binary) (sdk.Coins, error) {
// ParseMinDepositFromResponse parses the minimum deposit from the given output of the governance
// parameters query.
//
// FIXME: It wasn't possible to unmarshal the JSON output of the query because of a missing unit in the max_deposit_period
// parameter. This should rather be done using GRPC.
// NOTE: It wasn't possible to unmarshal the JSON output of the query because of a missing unit in the
// max_deposit_period parameter. This could instead be done using GRPC.
func ParseMinDepositFromResponse(out string) (sdk.Coins, error) {
depositPatternRaw := `min_deposit":\[{"denom":"(\w+)","amount":"(\d+)`
depositPattern := regexp.MustCompile(depositPatternRaw)
Expand Down
1 change: 1 addition & 0 deletions gov/proposal.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ func QueryLatestProposalID(bin *utils.Binary) (int, error) {
return 0, errors.New("no proposals found")
}

//#nosec G115 // proposal id won't exceed int32
return int(res.Proposals[len(res.Proposals)-1].Id), nil
}

Expand Down
1 change: 1 addition & 0 deletions main.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// Package main orchestrates the execution of the evmos-utils.
package main

import (
Expand Down
4 changes: 4 additions & 0 deletions utils/binary.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// Package utils contains different helper types and functions
// to make handling of the gRPC responses easier and handle different binaries, etc..
package utils

import (
Expand Down Expand Up @@ -38,6 +40,8 @@ type BinaryConfig struct {
ChainID string
// Denom for the fee payments on transactions
Denom string
// FeeAmount is the amount of fees send with a default transaction.
FeeAmount int
// Home is the home directory of the binary.
Home string
// KeyringBackend defines which keyring to use
Expand Down
5 changes: 5 additions & 0 deletions utils/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,8 @@ const (
// DeltaHeight is the amount of blocks in the future that the upgrade will be scheduled.
DeltaHeight = 20
)

// GetDefaultFees returns the value for the default amount of fees being sent with transactions.
func GetDefaultFees() int {
return defaultFees
}
6 changes: 4 additions & 2 deletions utils/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ type QueryArgs struct {
Quiet bool
}

// ExecuteQueryCmd executes a query command.
// ExecuteQuery executes a query command against a given binary.
func ExecuteQuery(bin *Binary, args QueryArgs) (string, error) {
queryCommand := args.Subcommand
queryCommand = append(queryCommand, "--node", bin.Config.Node)
Expand All @@ -45,12 +45,14 @@ func ExecuteTx(bin *Binary, args TxArgs) (string, error) {
"--from", args.From,
"--keyring-backend", bin.Config.KeyringBackend,
"--gas", "auto",
"--fees", fmt.Sprintf("%d%s", defaultFees, bin.Config.Denom),
"--fees", fmt.Sprintf("%d%s", bin.Config.FeeAmount, bin.Config.Denom),
"--gas-adjustment", "1.3",
"-b", "sync",
"-y",
)

bin.Logger.Info().Msgf("executing transaction with command: %s", strings.Join(txCommand, " "))

return ExecuteBinaryCmd(bin, BinaryCmdArgs{
Subcommand: txCommand,
Quiet: args.Quiet,
Expand Down
Loading