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
9 changes: 4 additions & 5 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ on:
workflow_dispatch:

env:
GO_VER: 1.23.1
GINKGO_VER: 2.19.1
GO_VER: 1.25.3
GINKGO_VER: 2.22.2

jobs:
check-cyrillic-comments:
Expand Down Expand Up @@ -54,10 +54,9 @@ jobs:
go-version: ${{ env.GO_VER }}
cache: false
- name: golangci-lint
uses: golangci/golangci-lint-action@v6
uses: golangci/golangci-lint-action@v8
with:
version: v1.60
args: --out-format=colored-line-number
version: v2.5.0
skip-cache: true
problem-matchers: true

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ on:
- 'v*'

env:
GO_VER: 1.23.1
GO_VER: 1.25.3
UBUNTU_VER: 22.04
APP_VER: ${{ github.ref_name }}
COMMIT: ${{ github.sha }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/vulnerability-scan.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ on:
- cron: "50 1 * * *"

env:
GO_VER: 1.23.1
GO_VER: 1.25.3

permissions:
contents: read
Expand Down
172 changes: 84 additions & 88 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -1,110 +1,106 @@
version: "2"
run:
# The default concurrency value is the number of available CPU.
go: '1.23'
concurrency: 4
timeout: 5m
go: "1.25"
tests: false
linters:
default: none
enable:
- errcheck
- gosimple
- govet
- ineffassign
- staticcheck
- typecheck
- unused
- asciicheck
- bodyclose
- contextcheck
- copyloopvar
- decorder
- dogsled
- dupword
- durationcheck
- errname
- errorlint
- copyloopvar
- misspell
- nestif
- noctx
- nolintlint
- prealloc
- stylecheck
- gci
- fatcontext
- forcetypeassert
- gocheckcompilerdirectives
- gocognit
- goconst
- gocritic
- gocyclo
- gofmt
- gofumpt
- goheader
- goimports
- gomodguard
- goprintffuncname
- gosec
- tparallel
- unconvert
- unparam
- whitespace
- revive
- usestdlibvars
- tenv
- promlinter
- nosprintfhostport
- nilnil
- loggercheck
- grouper
- errname
- decorder
- durationcheck
- iface
- interfacebloat
- intrange
- loggercheck
- misspell
- nestif
- nilerr
- forcetypeassert
- contextcheck
- reassign
- testableexamples
- dupword
- gocheckcompilerdirectives
- nilnil
- noctx
- nolintlint
- nosprintfhostport
- perfsprint
- testifylint
- sloglint
- prealloc
- promlinter
- protogetter
- fatcontext
- reassign
- recvcheck
- revive
- sloglint
- spancheck
- intrange
- copyloopvar
disable:
- godot
- wsl
- lll
- paralleltest
- godox
- testpackage
- nlreturn
- rowserrcheck
- sqlclosecheck
- ireturn
- wastedassign
- depguard
- tagliatelle
- gosmopolitan
- mirror
- tagalign
- zerologlint
- dupl
- funlen
- gomnd
- execinquery
- interfacebloat
linters-settings:
gosec:
excludes:
- 'G107'
- 'G402'
- 'G404'
- 'G115'
revive:
ignore-generated-header: true
rules:
- name: dot-imports
severity: warning
disabled: false
arguments:
- allowedPackages: ["github.com/onsi/gomega", "github.com/onsi/ginkgo/v2"]
stylecheck:
dot-import-whitelist:
- github.com/onsi/gomega
- github.com/onsi/ginkgo/v2
- staticcheck
- testableexamples
- testifylint
- tparallel
- unconvert
- unparam
- usestdlibvars
- whitespace
settings:
gosec:
excludes:
- G107
- G402
- G404
- G115
revive:
rules:
- name: dot-imports
arguments:
- allowedPackages:
- github.com/onsi/gomega
- github.com/onsi/ginkgo/v2
severity: warning
disabled: false
staticcheck:
dot-import-whitelist:
- github.com/onsi/gomega
- github.com/onsi/ginkgo/v2
exclusions:
generated: lax
presets:
- comments
- common-false-positives
- legacy
- std-error-handling
paths:
- third_party$
- builtin$
- examples$
formatters:
enable:
- gci
- gofmt
- gofumpt
- goimports
exclusions:
generated: lax
paths:
- third_party$
- builtin$
- examples$
output:
formats:
text:
path: stdout
colors: true
13 changes: 7 additions & 6 deletions cmd/addressCmd.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package cmd

import (
"crypto/ed25519"
"fmt"

"github.com/anoideaopen/foundation/proto"
"github.com/anoideaopen/testnet-cli/logger"
"github.com/anoideaopen/testnet-cli/utils"
"github.com/anoideaopen/testnet-cli/service"
"github.com/btcsuite/btcutil/base58"
"github.com/spf13/cobra"
"go.uber.org/zap"
Expand All @@ -22,20 +22,21 @@ var addressCmd = &cobra.Command{
}

_, _, err := base58.CheckDecode(secretKey)
var publicKey ed25519.PublicKey
var publicKey string
if err == nil {
var err error

_, publicKey, err = utils.GetPrivateKey(secretKey)
keyType := proto.KeyType(config.KeyType)
publicKey, err = service.GetPublicKey(secretKey, keyType)
if err != nil {
logger.Error("GetPrivateKey", zap.Error(err))
return
}
} else {
publicKey = base58.Decode(secretKey)
publicKey = secretKey
}

addr, err := utils.GetAddressByPublicKey(publicKey)
addr, err := service.GetAddressByPublicKey(publicKey)
if err != nil {
logger.Error("GetAddressByPublicKey", zap.Error(err))
return
Expand Down
2 changes: 1 addition & 1 deletion cmd/blockCmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (

"github.com/anoideaopen/testnet-cli/logger"
"github.com/golang/protobuf/proto" //nolint:staticcheck
cb "github.com/hyperledger/fabric-protos-go/common"
cb "github.com/hyperledger/fabric-protos-go-apiv2/common"
"github.com/spf13/cobra"
"go.uber.org/zap"
)
Expand Down
2 changes: 1 addition & 1 deletion cmd/convertCmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ var convertCmd = &cobra.Command{
} else if from == base58Str && to == "sum256base58Check" {
bytes := base58.Decode(convertedString)
if len(bytes) != ed25519.PublicKeySize {
fmt.Printf("incorrect publik key size %d but expected %d\n", len(bytes), ed25519.PublicKeySize)
fmt.Printf("incorrect public key size %d but expected %d\n", len(bytes), ed25519.PublicKeySize)
}
hash := sha3.Sum256(bytes)
result := base58.CheckEncode(hash[1:], hash[0])
Expand Down
4 changes: 2 additions & 2 deletions cmd/generateMessageCmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"strings"

"github.com/anoideaopen/testnet-cli/logger"
"github.com/anoideaopen/testnet-cli/utils"
"github.com/anoideaopen/testnet-cli/service"
"github.com/spf13/cobra"
)

Expand All @@ -32,7 +32,7 @@ var generateMessageCmd = &cobra.Command{ //nolint:unused

validatorPublicKeys := methodArgs[0]

message := utils.GenerateMessage(strings.Split(validatorPublicKeys, ","), channelID, config.ChaincodeName, methodName, methodArgs[1:])
message := service.GenerateMessage(strings.Split(validatorPublicKeys, ","), channelID, config.ChaincodeName, methodName, methodArgs[1:])
file, err := os.Create("message.txt")
if err != nil {
return
Expand Down
4 changes: 2 additions & 2 deletions cmd/getTxIDFromBlock.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"os"

"github.com/golang/protobuf/proto" //nolint:staticcheck
cb "github.com/hyperledger/fabric-protos-go/common"
cb "github.com/hyperledger/fabric-protos-go-apiv2/common"
"github.com/spf13/cobra"
)

Expand Down Expand Up @@ -47,7 +47,7 @@ var getTxIDFromBlockCmd = &cobra.Command{
}

fmt.Println(chdr.GetTxId())
fmt.Println(payload.GetData())
fmt.Println(payload.String())
}
},
}
21 changes: 12 additions & 9 deletions cmd/invokeAclCmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@ import (
"fmt"
"strings"

"github.com/anoideaopen/foundation/keys"
"github.com/anoideaopen/foundation/proto"
"github.com/anoideaopen/testnet-cli/logger"
"github.com/anoideaopen/testnet-cli/utils"
"github.com/anoideaopen/testnet-cli/service"
"github.com/spf13/cobra"
"go.uber.org/zap"
)
Expand Down Expand Up @@ -36,22 +38,23 @@ var invokeACLCmd = &cobra.Command{ //nolint:unused
fmt.Printf(" - '%v'\n", arg)
}

var validators []utils.SignerInfo
var validators []*keys.Keys
validatorsKey := strings.Split(config.SecretKey, ",")
keyType := proto.KeyType(config.KeyType)

for _, secretKey := range validatorsKey {
logger.Info("secretKey", zap.String("secretKey", secretKey))
privateKey, publicKey, err := utils.GetPrivateKey(secretKey)

k, err := service.GetKeys(secretKey, keyType)
if err != nil {
msg := "Failed to GetPrivateKeySK " + secretKey
msg := "Failed to GetPrivateKey " + secretKey
FatalError(msg, err)
}
signerInfo := utils.SignerInfo{}
signerInfo.PublicKey = publicKey
signerInfo.PrivateKey = privateKey
validators = append(validators, signerInfo)

validators = append(validators, k)
}

signedMessageArg, _, err := utils.SignACL(validators, methodName, address, reason, reasonID, newPkey)
signedMessageArg, _, err := service.SignACL(validators, methodName, address, reason, reasonID, newPkey)
logger.Debug("--- signedMessage")
for i, arg := range signedMessageArg {
fmt.Printf("%d\n", i)
Expand Down
Loading