diff --git a/pkg/appgateserver/config/errors.go b/pkg/appgateserver/config/errors.go index 3d4d6831f..bad78c42c 100644 --- a/pkg/appgateserver/config/errors.go +++ b/pkg/appgateserver/config/errors.go @@ -1,6 +1,8 @@ package config -import sdkerrors "cosmossdk.io/errors" +import ( + sdkerrors "cosmossdk.io/errors" +) var ( codespace = "appgate_config" diff --git a/pkg/appgateserver/errors.go b/pkg/appgateserver/errors.go index 17f5456d6..fb2ecf002 100644 --- a/pkg/appgateserver/errors.go +++ b/pkg/appgateserver/errors.go @@ -1,6 +1,8 @@ package appgateserver -import sdkerrors "cosmossdk.io/errors" +import ( + sdkerrors "cosmossdk.io/errors" +) var ( codespace = "appgateserver" diff --git a/pkg/client/keyring/errors.go b/pkg/client/keyring/errors.go index 7be8a677a..c078a54ed 100644 --- a/pkg/client/keyring/errors.go +++ b/pkg/client/keyring/errors.go @@ -1,6 +1,8 @@ package keyring -import "cosmossdk.io/errors" +import ( + "cosmossdk.io/errors" +) var ( // ErrEmptySigningKeyName represents an error which indicates that the diff --git a/pkg/client/tx/errors.go b/pkg/client/tx/errors.go index 328d7a51d..142618399 100644 --- a/pkg/client/tx/errors.go +++ b/pkg/client/tx/errors.go @@ -1,6 +1,8 @@ package tx -import errorsmod "cosmossdk.io/errors" +import ( + errorsmod "cosmossdk.io/errors" +) var ( // ErrInvalidMsg signifies that there was an issue in validating the diff --git a/pkg/observable/errors.go b/pkg/observable/errors.go index c34f2f7d6..47d39d088 100644 --- a/pkg/observable/errors.go +++ b/pkg/observable/errors.go @@ -1,6 +1,8 @@ package observable -import errorsmod "cosmossdk.io/errors" +import ( + errorsmod "cosmossdk.io/errors" +) var ( ErrObserverClosed = errorsmod.Register(codespace, 1, "observer is closed") diff --git a/pkg/observable/interface.go b/pkg/observable/interface.go index d86da414f..aa0becd6e 100644 --- a/pkg/observable/interface.go +++ b/pkg/observable/interface.go @@ -1,6 +1,8 @@ package observable -import "context" +import ( + "context" +) // NOTE: We explicitly decided to write a small and custom notifications package // to keep logic simple and minimal. If the needs & requirements of this library ever diff --git a/pkg/polylog/context.go b/pkg/polylog/context.go index 0e6904b64..a346bf19c 100644 --- a/pkg/polylog/context.go +++ b/pkg/polylog/context.go @@ -1,6 +1,8 @@ package polylog -import "context" +import ( + "context" +) // CtxKey is the key used to store the polylog.Logger in a context.Context. This // is **independant** of any logger-implementation-specific context key that may diff --git a/pkg/relayer/config/errors.go b/pkg/relayer/config/errors.go index cabd22e76..fed389db5 100644 --- a/pkg/relayer/config/errors.go +++ b/pkg/relayer/config/errors.go @@ -1,6 +1,8 @@ package config -import sdkerrors "cosmossdk.io/errors" +import ( + sdkerrors "cosmossdk.io/errors" +) var ( codespace = "relayminer_config" diff --git a/pkg/relayer/miner/gen/template.go b/pkg/relayer/miner/gen/template.go index c75e761a4..aaa768813 100644 --- a/pkg/relayer/miner/gen/template.go +++ b/pkg/relayer/miner/gen/template.go @@ -1,6 +1,8 @@ package main -import "text/template" +import ( + "text/template" +) var ( relayFixtureLineFmt = "\t\t\"%x\"," diff --git a/pkg/relayer/protocol/errors.go b/pkg/relayer/protocol/errors.go index f578bf8e0..36807f59c 100644 --- a/pkg/relayer/protocol/errors.go +++ b/pkg/relayer/protocol/errors.go @@ -1,6 +1,8 @@ package protocol -import errorsmod "cosmossdk.io/errors" +import ( + errorsmod "cosmossdk.io/errors" +) var ( ErrDifficulty = errorsmod.New(codespace, 1, "difficulty error") diff --git a/pkg/relayer/session/errors.go b/pkg/relayer/session/errors.go index 520c85bc1..db8b2bfea 100644 --- a/pkg/relayer/session/errors.go +++ b/pkg/relayer/session/errors.go @@ -1,6 +1,8 @@ package session -import sdkerrors "cosmossdk.io/errors" +import ( + sdkerrors "cosmossdk.io/errors" +) var ( codespace = "relayer_session" diff --git a/pkg/sdk/errors.go b/pkg/sdk/errors.go index c7d1c4cc7..d7222ffd6 100644 --- a/pkg/sdk/errors.go +++ b/pkg/sdk/errors.go @@ -1,6 +1,8 @@ package sdk -import sdkerrors "cosmossdk.io/errors" +import ( + sdkerrors "cosmossdk.io/errors" +) var ( codespace = "poktrollsdk" diff --git a/pkg/sdk/urls.go b/pkg/sdk/urls.go index de182f150..0cf6d0572 100644 --- a/pkg/sdk/urls.go +++ b/pkg/sdk/urls.go @@ -1,6 +1,8 @@ package sdk -import "fmt" +import ( + "fmt" +) // HostToWebsocketURL converts the provided host into a websocket URL that can // be used to subscribe to onchain events and query the chain via a client diff --git a/pkg/signer/simple_signer.go b/pkg/signer/simple_signer.go index 432c1c8a3..753a59144 100644 --- a/pkg/signer/simple_signer.go +++ b/pkg/signer/simple_signer.go @@ -1,6 +1,8 @@ package signer -import "github.com/cosmos/cosmos-sdk/crypto/keyring" +import ( + "github.com/cosmos/cosmos-sdk/crypto/keyring" +) var _ Signer = (*SimpleSigner)(nil) diff --git a/testutil/testerrors/require.go b/testutil/testerrors/require.go index 624cdaf6e..d6a34366f 100644 --- a/testutil/testerrors/require.go +++ b/testutil/testerrors/require.go @@ -1,6 +1,8 @@ package testerrors -import errorsmod "cosmossdk.io/errors" +import ( + errorsmod "cosmossdk.io/errors" +) var ( // ErrAsync is returned when a test assertion fails in a goroutine other than diff --git a/testutil/testkeyring/gen_accounts/template.go b/testutil/testkeyring/gen_accounts/template.go index e7dfb5b57..108fbc697 100644 --- a/testutil/testkeyring/gen_accounts/template.go +++ b/testutil/testkeyring/gen_accounts/template.go @@ -2,7 +2,9 @@ package main -import "text/template" +import ( + "text/template" +) var ( preGeneratedAccountLineFmt = "\t\tmustParsePreGeneratedAccount(%q)," diff --git a/testutil/yaml/yaml.go b/testutil/yaml/yaml.go index 56a29cc89..875800a13 100644 --- a/testutil/yaml/yaml.go +++ b/testutil/yaml/yaml.go @@ -1,6 +1,8 @@ package yaml -import "strings" +import ( + "strings" +) // YAML is indentation sensitive, so we need to remove the extra indentation from the test cases and make sure // it is space-indented instead of tab-indented, otherwise the YAML parser will fail diff --git a/tools/scripts/goimports-revisor.sh b/tools/scripts/goimports-revisor.sh new file mode 100755 index 000000000..568c26874 --- /dev/null +++ b/tools/scripts/goimports-revisor.sh @@ -0,0 +1,34 @@ +#!/usr/bin/env bash + +FLAGS=( + -rm-unused + -use-cache + -imports-order "std,general,company,project,blanked,dotted" + -project-name "github.com/pokt-network/poktrolld" +) + +# Define a function to check for the exclusion comment and run goimports-reviser +process_file() { + local file=$1 + if ! grep -q "//go:build ignore" "$file"; then + echo "Processing $file" + goimports-reviser "${FLAGS[@]}" "$file" + fi +} + +export -f process_file + +# Find all .go files, excluding specified patterns, and process them +find . -type f -name '*.go' \ + ! -path "./vendors/*" \ + ! -path "./ts-client/*" \ + ! -path "./.git/*" \ + ! -path "./.github/*" \ + ! -path "./bin/*" \ + ! -path "./docs/*" \ + ! -path "./localnet/*" \ + ! -path "./proto/*" \ + ! -path "./tools/*" \ + ! -name "*mock.go" \ + ! -name "*pb.go" \ + -exec bash -c 'process_file "$0"' {} \; diff --git a/tools/scripts/restore-scaffold-lines.sh b/tools/scripts/restore-scaffold-lines.sh new file mode 100755 index 000000000..250c80714 --- /dev/null +++ b/tools/scripts/restore-scaffold-lines.sh @@ -0,0 +1,39 @@ +#!/usr/bin/env bash + +# The line to be restored +RESTORE_LINE="// this line is used by starport scaffolding # root/moduleImport" + +# The pattern after which the line should be restored (modify this as needed) +PATTERN="import (" + +# Function to restore the line in a file +restore_line() { + local file=$1 + local temp_file=$(mktemp) + + # Flag to indicate if the line has been restored + local restored=0 + + # Read the file line by line + while IFS= read -r line; do + echo "$line" >> "$temp_file" + # Check if the line matches the pattern + if [[ $line == *"$PATTERN"* ]]; then + # Add the RESTORE_LINE after the pattern + echo "$RESTORE_LINE" >> "$temp_file" + restored=1 + fi + done < "$file" + + # Replace the original file with the temp file + mv "$temp_file" "$file" +} + +# Process each file changed in the git diff +git diff --name-only | while IFS= read -r file; do + # Check if the file is a .go file and the specific line was deleted + if [[ $file == *.go ]] && git diff "$file" | grep -q "^\-.*$RESTORE_LINE"; then + echo "Restoring line in $file" + restore_line "$file" + fi +done diff --git a/x/application/client/config/errors.go b/x/application/client/config/errors.go index fea38af57..a97fd7adb 100644 --- a/x/application/client/config/errors.go +++ b/x/application/client/config/errors.go @@ -1,6 +1,8 @@ package config -import sdkerrors "cosmossdk.io/errors" +import ( + sdkerrors "cosmossdk.io/errors" +) var ( codespace = "applicationconfig" diff --git a/x/application/types/key_application.go b/x/application/types/key_application.go index 02cbefc4e..8e6d382fd 100644 --- a/x/application/types/key_application.go +++ b/x/application/types/key_application.go @@ -1,6 +1,8 @@ package types -import "encoding/binary" +import ( + "encoding/binary" +) var _ binary.ByteOrder diff --git a/x/gateway/types/key_gateway.go b/x/gateway/types/key_gateway.go index 8fe1e65f7..3a41d8ef6 100644 --- a/x/gateway/types/key_gateway.go +++ b/x/gateway/types/key_gateway.go @@ -1,6 +1,8 @@ package types -import "encoding/binary" +import ( + "encoding/binary" +) var _ binary.ByteOrder diff --git a/x/service/types/relay.go b/x/service/types/relay.go index 7815fc1ab..f54e4a696 100644 --- a/x/service/types/relay.go +++ b/x/service/types/relay.go @@ -1,6 +1,8 @@ package types -import "crypto/sha256" +import ( + "crypto/sha256" +) // getSignableBytes returns the bytes resulting from marshaling the relay request // A value receiver is used to avoid overwriting any pre-existing signature diff --git a/x/supplier/client/config/errors.go b/x/supplier/client/config/errors.go index 0739daf93..f72b07d2e 100644 --- a/x/supplier/client/config/errors.go +++ b/x/supplier/client/config/errors.go @@ -1,6 +1,8 @@ package config -import sdkerrors "cosmossdk.io/errors" +import ( + sdkerrors "cosmossdk.io/errors" +) var ( codespace = "supplierconfig" diff --git a/x/supplier/types/key_proof.go b/x/supplier/types/key_proof.go index 6307f4ccb..3d97c1fd9 100644 --- a/x/supplier/types/key_proof.go +++ b/x/supplier/types/key_proof.go @@ -1,6 +1,8 @@ package types -import "encoding/binary" +import ( + "encoding/binary" +) var _ binary.ByteOrder diff --git a/x/supplier/types/key_supplier.go b/x/supplier/types/key_supplier.go index 20f28a5c1..ebd8a50bc 100644 --- a/x/supplier/types/key_supplier.go +++ b/x/supplier/types/key_supplier.go @@ -1,6 +1,8 @@ package types -import "encoding/binary" +import ( + "encoding/binary" +) var _ binary.ByteOrder