Skip to content

Commit

Permalink
more linting
Browse files Browse the repository at this point in the history
  • Loading branch information
akremstudy committed May 30, 2024
1 parent 2f58ade commit 12ef1bd
Show file tree
Hide file tree
Showing 13 changed files with 65 additions and 49 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ release/
.idea/
.vscode/
.DS_Store
layerd
/layerd
.hypothesis
evm/artifacts
evm/cache
Expand Down
1 change: 1 addition & 0 deletions app/default_overrides.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ func (bankModule) DefaultGenesis(cdc codec.JSONCodec) json.RawMessage {
Exponent: 0,
},
{
Denom: DisplayDenom, // ie Ether
Exponent: 6,
},
},
Expand Down
5 changes: 4 additions & 1 deletion app/export.go
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,10 @@ func (app *App) prepForZeroHeightGenesis(ctx sdk.Context, jailAllowedAddrs []str
ctx,
func(addr sdk.ConsAddress, info slashingtypes.ValidatorSigningInfo) (stop bool) {
info.StartHeight = 0
app.SlashingKeeper.SetValidatorSigningInfo(ctx, addr, info)
err = app.SlashingKeeper.SetValidatorSigningInfo(ctx, addr, info)
if err != nil {
panic(err)
}
return false
},
)
Expand Down
5 changes: 4 additions & 1 deletion cmd/layerd/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,10 @@ func overwriteFlagDefaults(c *cobra.Command, defaults map[string]string) {
set := func(s *pflag.FlagSet, key, val string) {
if f := s.Lookup(key); f != nil {
f.DefValue = val
f.Value.Set(val)
err := f.Value.Set(val)
if err != nil {
panic(err)
}
}
}
for key, val := range defaults {
Expand Down
2 changes: 1 addition & 1 deletion daemons/configs/default_market_param_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ func WriteDefaultMarketParamsToml(homeDir string) {
configFilePath := getMarketParamsConfigFilePath(homeDir)
if !tmos.FileExists(configFilePath) {
buffer := GenerateDefaultMarketParamsTomlString()
tmos.MustWriteFile(configFilePath, buffer.Bytes(), 0644)
tmos.MustWriteFile(configFilePath, buffer.Bytes(), 0o644)
}
}

Expand Down
2 changes: 1 addition & 1 deletion daemons/configs/default_pricefeed_exchange_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ func WriteDefaultPricefeedExchangeToml(homeDir string) {
configFilePath := getConfigFilePath(homeDir)
if !tmos.FileExists(configFilePath) {
buffer := GenerateDefaultExchangeTomlString()
tmos.MustWriteFile(configFilePath, buffer.Bytes(), 0644)
tmos.MustWriteFile(configFilePath, buffer.Bytes(), 0o644)
}
}

Expand Down
2 changes: 2 additions & 0 deletions daemons/pricefeed/client/sources/util_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//nolint:stylecheck // ignore stylecheck for this file
package sources

import (
Expand All @@ -17,6 +18,7 @@ const (
deltaPrecision = 0.000000001
)

//lint:ignore ST1005 This is a test error
var errpositiveTagValidation = errors.New(
"Key: 'TestPositiveValidation.PositiveFloatString' Error:Field validation for 'PositiveFloatString' " +
"failed on the 'positive-float-string' tag",
Expand Down
2 changes: 1 addition & 1 deletion daemons/reporter/client/median.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ func (c *Client) median(querydata []byte) (string, error) {
mv := c.MarketToExchange.GetValidMedianPrices([]types.MarketParam{mp}, time.Now())
val, found := mv[mp.Id]
if !found {
return "", fmt.Errorf("no median values found for query data: %s", querydata)
return "", fmt.Errorf("no median values found for query data: %s", key)
}

value, err := prices.EncodePrice(float64(val), mp.Exponent)
Expand Down
9 changes: 7 additions & 2 deletions daemons/token_bridge_feed/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"io"
"math/big"
"net/http"
"net/url"
"sync"
"time"

Expand Down Expand Up @@ -107,8 +108,12 @@ type DepositReport struct {
Value string
}

func (c *Client) QueryAPI(url string) ([]byte, error) {
resp, err := http.Get(url)
func (c *Client) QueryAPI(urlStr string) ([]byte, error) {
parsedUrl, err := url.ParseRequestURI(urlStr)
if err != nil {
return nil, err
}
resp, err := http.Get(parsedUrl.String())
if err != nil {
return nil, fmt.Errorf("failed to make API request: %w", err)
}
Expand Down
3 changes: 1 addition & 2 deletions daemons/types/grpc_client.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//nolint:staticcheck // SA1019: grpc.DialContext is deprecated, use NewClient instead.
package types

import (
Expand Down Expand Up @@ -33,7 +34,6 @@ func (g *GrpcClientImpl) NewGrpcConnection(
socketAddress,
grpc.WithTransportCredentials(insecure.NewCredentials()),
// https://github.com/grpc/grpc-go/blob/master/dialoptions.go#L264
grpc.WithBlock(),
grpc.WithContextDialer(func(ctx context.Context, addr string) (net.Conn, error) {
// Create a custom `net.Dialer` in order to specify `unix` as the desired network.
var dialer net.Dialer
Expand All @@ -51,7 +51,6 @@ func (g *GrpcClientImpl) NewTcpConnection(
ctx,
endpoint,
grpc.WithTransportCredentials(insecure.NewCredentials()),
grpc.WithBlock(),
)
}

Expand Down
5 changes: 4 additions & 1 deletion docs/docs.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,15 @@ func handler(title string) http.HandlerFunc {
t, _ := httptemplate.ParseFS(template, indexFile)

return func(w http.ResponseWriter, req *http.Request) {
t.Execute(w, struct {
err := t.Execute(w, struct {
Title string
URL string
}{
title,
apiFile,
})
if err != nil {
panic(err)
}
}
}
75 changes: 38 additions & 37 deletions evm/setup/test_setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"io"
"log"
"net/http"
"net/url"
"os"
"strconv"
)
Expand All @@ -31,19 +32,46 @@ import (
// validators: http://localhost:1317/layer/bridge/blockvalidators?height=555
// header: http://localhost:1317/layer/bridge/blockheadermerkleevm?height=1763

func main() {
// *** get latest block number ***
url := "http://localhost:1317/cosmos/base/tendermint/v1beta1/blocks/latest"

resp, err := http.Get(url)
func request(urlStr string) ([]byte, error) {
// Parse and validate the URL
parsedUrl, err := url.ParseRequestURI(urlStr)
if err != nil {
return nil, err
}
resp, err := http.Get(parsedUrl.String())
if err != nil {
log.Fatalf("Failed to send request to Cosmos API: %v", err)
}
defer resp.Body.Close()

body, err := io.ReadAll(resp.Body)
if err != nil {
log.Fatalf("failed to read response body: %v", err)
return nil, err
}
return body, nil
}

func createfile(filePath string, body []byte) error {
file, err := os.Create(filePath)
if err != nil {
return err
}
defer file.Close()

_, err = file.Write(body)
if err != nil {
return err
}

return nil
}

func main() {
// *** get latest block number ***
url := "http://localhost:1317/cosmos/base/tendermint/v1beta1/blocks/latest"
body, err := request(url)
if err != nil {
log.Fatalf("Failed to read response body: %v", err)
}

var result map[string]interface{}
Expand All @@ -61,14 +89,7 @@ func main() {

// *** query block validators ***
url = "http://localhost:1317/layer/bridge/blockvalidators?height=" + height

resp, err = http.Get(url)
if err != nil {
log.Fatalf("Failed to send request to Cosmos API: %v", err)
}
defer resp.Body.Close()

body, err = io.ReadAll(resp.Body)
body, err = request(url)
if err != nil {
log.Fatalf("Failed to read response body: %v", err)
}
Expand All @@ -94,16 +115,10 @@ func main() {
// Replace with your desired file path
filePath := "setup/data/validators.json"

file, err := os.Create(filePath)
err = createfile(filePath, body)
if err != nil {
log.Fatalf("Failed to create file: %v", err)
}
defer file.Close()

_, err = file.Write(body)
if err != nil {
log.Fatalf("Failed to write to file: %v", err)
}

log.Printf("Response data written to %s", filePath)

Expand Down Expand Up @@ -134,15 +149,7 @@ func main() {
// }

url = "http://localhost:1317/layer/bridge/blockheadermerkleevm?height=" + height

resp, err = http.Get(url)
if err != nil {
log.Fatalf("Failed to send request to Cosmos API: %v", err)
}

defer resp.Body.Close()

body, err = io.ReadAll(resp.Body)
body, err = request(url)
if err != nil {
log.Fatalf("Failed to read response body: %v", err)
}
Expand Down Expand Up @@ -177,16 +184,10 @@ func main() {
// Replace with your desired file path
filePath = "setup/data/blockheadermerkleparts.json"

file, err = os.Create(filePath)
err = createfile(filePath, body)
if err != nil {
log.Fatalf("Failed to create file: %v", err)
}
defer file.Close()

_, err = file.Write(body)
if err != nil {
log.Fatalf("Failed to write to file: %v", err)
}

log.Printf("Response data written to %s", filePath)
}
1 change: 0 additions & 1 deletion lib/metrics/metric_keys.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// nolint:lll
package metrics

// Metrics Keys Guidelines
Expand Down

0 comments on commit 12ef1bd

Please sign in to comment.