Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update inx-app to 646f949dc816 #132

Merged
merged 2 commits into from
Mar 21, 2024
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
83 changes: 61 additions & 22 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,104 +6,144 @@ linters-settings:
simplify: true
goimports:
local-prefixes: github.com/iotaledger
golint:
min-confidence: 0.9
gocyclo:
min-complexity: 15
govet:
check-shadowing: false
disable:
- shadow
misspell:
locale: US
staticcheck:
checks: ["all"]
nlreturn:
block-size: 3
block-size: 2
stylecheck:
initialisms: ["ACL", "API", "ASCII", "CPU", "CSS", "DNS", "EOF", "GUID", "HTML", "HTTP", "HTTPS", "ID", "IP", "JSON", "QPS", "RAM", "RPC", "SLA", "SMTP", "SQL", "SSH", "TCP", "TLS", "TTL", "UDP", "UI", "GID", "UID", "UUID", "URI", "URL", "UTF8", "VM", "XML", "XMPP", "XSRF", "XSS", "SIP", "RTP", "AMQP", "DB", "TS"]
depguard:
rules:
main:
deny:
- pkg: "errors"
desc: Should be replaced with "github.com/iotaledger/hive.go/ierrors" package
- pkg: "golang.org/x/xerrors"
desc: Should be replaced with "github.com/iotaledger/hive.go/ierrors" package
- pkg: "github.com/pkg/errors"
desc: Should be replaced with "github.com/iotaledger/hive.go/ierrors" package

linters:
# Disable all linters.
disable-all: true
# Enable specific linter
enable:
- deadcode
- errcheck
- gosimple
- govet
- ineffassign
- staticcheck
- typecheck
- unused
- varcheck
- asasalint
- asciicheck
- bidichk
- bodyclose
- containedctx
- contextcheck
#- containedctx
#- contextcheck # this linter is buggy and renders all nolint rules useless
- copyloopvar
#- cyclop
- decorder
#- depguard
- depguard
- dogsled
- dupl
- dupword
- durationcheck
- errchkjson
- errname
- errorlint
- execinquery
- exhaustive
#- exhaustive
#- exhaustruct
- exportloopref
#- forbidigo
- forcetypeassert
#- funlen
#- gci
- ginkgolinter
- gocheckcompilerdirectives
#- gochecknoglobals
#- gochecknoinits
#- gochecksumtype
#- gocognit
- goconst
- gocritic
#- gocyclo
- godot
- godox
#- goerr113
- goerr113
- gofmt
#- gofumpt
- goheader
- goimports
- golint
#- gomnd
- gomoddirectives
#- gomoddirectives
- gomodguard
- goprintffuncname
- gosec
- gosmopolitan
- grouper
- ifshort
- importas
- interfacer
- inamedparam
#- interfacebloat
- intrange
#- ireturn
#- lll
- loggercheck
#- maintidx
- makezero
- maligned
- mirror
- misspell
- musttag
- nakedret
#- nestif
- nilerr
- nilnil
- nlreturn
- noctx
- nolintlint
- nonamedreturns
- nosnakecase
- nosprintfhostport
- paralleltest
#- perfsprint
- prealloc
- predeclared
- promlinter
- protogetter
- reassign
- revive
- rowserrcheck
- scopelint
- sloglint
- spancheck
- sqlclosecheck
- structcheck
- stylecheck
#- tagalign
- tagliatelle
- tenv
- testableexamples
- testifylint
- testpackage
#- thelper
- thelper
- tparallel
- unconvert
- unparam
- usestdlibvars
#- varnamelen
- wastedassign
- whitespace
#- wrapcheck
#- wsl
- zerologlint

issues:
exclude-files:
- ".*_test.go$"
# Maximum issues count per one linter.
# Set to 0 to disable.
# Default: 50
Expand Down Expand Up @@ -131,4 +171,3 @@ issues:
# - "blank-imports" # revive
# - "var-naming: don't use leading k in Go names;" #revive
# - 'shadow: declaration of "err"' # govet

16 changes: 6 additions & 10 deletions components/faucet/component.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ type dependencies struct {
}

func provide(c *dig.Container) error {

// we use a restricted address for the faucet, so we don't need to filter indexer requests.
// we only allow to receive mana, the rest is blocked.
faucetAddressRestricted, faucetSigner, err := getRestrictedFaucetAddressAndSigner()
Expand Down Expand Up @@ -97,7 +96,6 @@ func provide(c *dig.Container) error {
}

if err := c.Provide(func(deps faucetDeps) (*faucet.Faucet, error) {

fetchTransactionMetadata := func(transactionID iotago.TransactionID) (*api.TransactionMetadataResponse, error) {
ctx, cancel := context.WithTimeout(Component.Daemon().ContextStopped(), 5*time.Second)
defer cancel()
Expand Down Expand Up @@ -205,7 +203,7 @@ func provide(c *dig.Container) error {
continue
}

lastAcceptedBlockSlot := iotago.SlotIndex(deps.NodeBridge.NodeStatus().LastAcceptedBlockSlot)
lastAcceptedBlockSlot := iotago.SlotIndex(deps.NodeBridge.NodeStatus().GetLastAcceptedBlockSlot())
if output.UnlockConditionSet().HasTimelockUntil(lastAcceptedBlockSlot) {
// ignore timelocked outputs for balance calculation
continue
Expand Down Expand Up @@ -240,7 +238,7 @@ func provide(c *dig.Container) error {
}

getLatestSlot := func() iotago.SlotIndex {
return iotago.SlotIndex(deps.NodeBridge.NodeStatus().LastAcceptedBlockSlot)
return iotago.SlotIndex(deps.NodeBridge.NodeStatus().GetLastAcceptedBlockSlot())
}

submitTransactionPayload := func(ctx context.Context, builder *builder.TransactionBuilder, storedManaOutputIndex int, numPoWWorkers ...int) (iotago.ApplicationPayload, iotago.BlockID, error) {
Expand Down Expand Up @@ -269,7 +267,7 @@ func provide(c *dig.Container) error {
faucetAddressRestricted,
faucetSigner,
faucet.WithLogger(Component.Logger),
faucet.WithTokenName(deps.NodeBridge.NodeConfig().BaseToken.Name),
faucet.WithTokenName(deps.NodeBridge.NodeConfig().GetBaseToken().GetName()),
faucet.WithBaseTokenAmount(iotago.BaseToken(ParamsFaucet.BaseTokenAmount)),
faucet.WithBaseTokenAmountSmall(iotago.BaseToken(ParamsFaucet.BaseTokenAmountSmall)),
faucet.WithBaseTokenAmountMaxTarget(iotago.BaseToken(ParamsFaucet.BaseTokenAmountMaxTarget)),
Expand All @@ -291,7 +289,6 @@ func provide(c *dig.Container) error {
}

func run() error {

// create a background worker that handles the accepted transactions
if err := Component.Daemon().BackgroundWorker("Faucet[ListenToAcceptedTransactions]", func(ctx context.Context) {
if err := deps.NodeBridge.ListenToAcceptedTransactions(ctx, func(tx *nodebridge.AcceptedTransaction) error {
Expand Down Expand Up @@ -349,20 +346,19 @@ func run() error {
func loadEd25519PrivateKeysFromEnvironment(name string) ([]ed25519.PrivateKey, error) {
keys, exists := os.LookupEnv(name)
if !exists {
return nil, fmt.Errorf("environment variable '%s' not set", name)
return nil, ierrors.Errorf("environment variable '%s' not set", name)
}

if len(keys) == 0 {
return nil, fmt.Errorf("environment variable '%s' not set", name)
return nil, ierrors.Errorf("environment variable '%s' not set", name)
}

privateKeysSplitted := strings.Split(keys, ",")
privateKeys := make([]ed25519.PrivateKey, len(privateKeysSplitted))
for i, key := range privateKeysSplitted {
privateKey, err := crypto.ParseEd25519PrivateKeyFromString(key)
if err != nil {
return nil, fmt.Errorf("environment variable '%s' contains an invalid private key '%s'", name, key)

return nil, ierrors.Errorf("environment variable '%s' contains an invalid private key '%s'", name, key)
}
privateKeys[i] = privateKey
}
Expand Down
1 change: 0 additions & 1 deletion components/faucet/frontend.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import (
"github.com/labstack/echo/v4"
)

//nolint:typecheck // the linter can't find the files in the git submodule
//go:embed frontend/public
var distFiles embed.FS

Expand Down
1 change: 0 additions & 1 deletion components/faucet/routes.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ func addFaucetOutputToQueue(c echo.Context) (*faucet.EnqueueResponse, error) {
}

func setupRoutes(e *echo.Echo) {

e.Pre(enforceMaxOneDotPerURL)

e.Group("/*").Use(frontendMiddleware())
Expand Down
36 changes: 18 additions & 18 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,16 @@ module github.com/iotaledger/inx-faucet
go 1.22

require (
github.com/iotaledger/hive.go/app v0.0.0-20240305162344-4b8be588e1cf
github.com/iotaledger/hive.go/core v1.0.0-rc.3.0.20240305162344-4b8be588e1cf
github.com/iotaledger/hive.go/crypto v0.0.0-20240305162344-4b8be588e1cf
github.com/iotaledger/hive.go/ds v0.0.0-20240305162344-4b8be588e1cf
github.com/iotaledger/hive.go/ierrors v0.0.0-20240305162344-4b8be588e1cf
github.com/iotaledger/hive.go/lo v0.0.0-20240305162344-4b8be588e1cf
github.com/iotaledger/hive.go/log v0.0.0-20240305162344-4b8be588e1cf
github.com/iotaledger/hive.go/runtime v0.0.0-20240305162344-4b8be588e1cf
github.com/iotaledger/inx-app v1.0.0-rc.3.0.20240307101848-db58eb9353ec
github.com/iotaledger/iota.go/v4 v4.0.0-20240307091827-db3c503615a6
github.com/iotaledger/hive.go/app v0.0.0-20240320122938-13a946cf3c7a
github.com/iotaledger/hive.go/core v1.0.0-rc.3.0.20240320122938-13a946cf3c7a
github.com/iotaledger/hive.go/crypto v0.0.0-20240320122938-13a946cf3c7a
github.com/iotaledger/hive.go/ds v0.0.0-20240320122938-13a946cf3c7a
github.com/iotaledger/hive.go/ierrors v0.0.0-20240320122938-13a946cf3c7a
github.com/iotaledger/hive.go/lo v0.0.0-20240320122938-13a946cf3c7a
github.com/iotaledger/hive.go/log v0.0.0-20240320122938-13a946cf3c7a
github.com/iotaledger/hive.go/runtime v0.0.0-20240320122938-13a946cf3c7a
github.com/iotaledger/inx-app v1.0.0-rc.3.0.20240320125204-646f949dc816
github.com/iotaledger/iota.go/v4 v4.0.0-20240320124121-0b5258b05dbc
github.com/labstack/echo/v4 v4.11.4
go.uber.org/dig v1.17.1
golang.org/x/time v0.5.0
Expand All @@ -29,23 +29,23 @@ require (
github.com/eclipse/paho.mqtt.golang v1.4.3 // indirect
github.com/ethereum/go-ethereum v1.13.14 // indirect
github.com/fatih/structs v1.1.0 // indirect
github.com/felixge/fgprof v0.9.3 // indirect
github.com/felixge/fgprof v0.9.4 // indirect
github.com/fsnotify/fsnotify v1.7.0 // indirect
github.com/golang-jwt/jwt v3.2.2+incompatible // indirect
github.com/golang/protobuf v1.5.4 // indirect
github.com/google/go-github v17.0.0+incompatible // indirect
github.com/google/go-querystring v1.1.0 // indirect
github.com/google/pprof v0.0.0-20240207164012-fb44976bdcd5 // indirect
github.com/google/pprof v0.0.0-20240319011627-a57c5dfe54fd // indirect
github.com/gorilla/websocket v1.5.1 // indirect
github.com/grpc-ecosystem/go-grpc-middleware v1.4.0 // indirect
github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0 // indirect
github.com/hashicorp/go-version v1.6.0 // indirect
github.com/holiman/uint256 v1.2.4 // indirect
github.com/iancoleman/orderedmap v0.3.0 // indirect
github.com/iotaledger/hive.go/constraints v0.0.0-20240305162344-4b8be588e1cf // indirect
github.com/iotaledger/hive.go/serializer/v2 v2.0.0-rc.1.0.20240305162344-4b8be588e1cf // indirect
github.com/iotaledger/hive.go/stringify v0.0.0-20240305162344-4b8be588e1cf // indirect
github.com/iotaledger/inx/go v1.0.0-rc.2.0.20240307100839-48553e1d2022 // indirect
github.com/iotaledger/hive.go/constraints v0.0.0-20240320122938-13a946cf3c7a // indirect
github.com/iotaledger/hive.go/serializer/v2 v2.0.0-rc.1.0.20240320122938-13a946cf3c7a // indirect
github.com/iotaledger/hive.go/stringify v0.0.0-20240320122938-13a946cf3c7a // indirect
github.com/iotaledger/inx/go v1.0.0-rc.2.0.20240320124425-aef029f6d349 // indirect
github.com/knadh/koanf v1.5.0 // indirect
github.com/kr/text v0.2.0 // indirect
github.com/labstack/gommon v0.4.2 // indirect
Expand All @@ -56,7 +56,7 @@ require (
github.com/mitchellh/reflectwalk v1.0.2 // indirect
github.com/mr-tron/base58 v1.2.0 // indirect
github.com/pasztorpisti/qs v0.0.0-20171216220353-8d6c33ee906c // indirect
github.com/pelletier/go-toml/v2 v2.1.1 // indirect
github.com/pelletier/go-toml/v2 v2.2.0 // indirect
github.com/petermattis/goid v0.0.0-20231207134359-e60b3f734c67 // indirect
github.com/prometheus/client_golang v1.19.0 // indirect
github.com/prometheus/client_model v0.6.0 // indirect
Expand All @@ -73,7 +73,7 @@ require (
golang.org/x/sync v0.6.0 // indirect
golang.org/x/sys v0.18.0 // indirect
golang.org/x/text v0.14.0 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240304212257-790db918fca8 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240318140521-94a12d6c2237 // indirect
google.golang.org/protobuf v1.33.0 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
Expand Down
Loading