Skip to content

feat: switch to using JSON-RPC 2.0 by default #70

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

Merged
merged 7 commits into from
May 19, 2025
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
232 changes: 120 additions & 112 deletions .github/golangci.yaml
Original file line number Diff line number Diff line change
@@ -1,124 +1,132 @@
version: "2"
run:
concurrency: 8
timeout: 10m
issue-exit-code: 1
tests: true
skip-dirs-use-default: true
go: ""
modules-download-mode: readonly
tests: true
allow-parallel-runners: false
go: ""

output:
uniq-by-line: false
path-prefix: ""
sort-results: true

linters:
default: none
enable:
- asasalint
- asciicheck
- bidichk
- decorder
- dogsled
- dupl
- durationcheck
- errcheck
- errname
- errorlint
- gocheckcompilerdirectives
- gochecknoinits
- goconst
- gocritic
- godot
- gomoddirectives
- gosec
- govet
- importas
- ineffassign
- lll
- loggercheck
- makezero
- misspell
- nakedret
- nestif
- nilerr
- nilnil
- nlreturn
- nolintlint
- nonamedreturns
- prealloc
- predeclared
- promlinter
- reassign
- revive
- staticcheck
- tagliatelle
- testableexamples
- thelper
- tparallel
- unconvert
- unparam
- unused
- usestdlibvars
- wastedassign
- whitespace
- wsl
settings:
errcheck:
check-type-assertions: false
check-blank: true
exclude-functions:
- io/ioutil.ReadFile
- io.Copy(*bytes.Buffer)
- io.Copy(os.Stdout)
goconst:
min-len: 3
min-occurrences: 3
gocritic:
disabled-checks:
- hugeParam
- rangeExprCopy
- rangeValCopy
- importShadow
- unnamedResult
enabled-tags:
- diagnostic
- experimental
- opinionated
- performance
- style
godot:
scope: all
period: false
govet:
enable-all: true
nakedret:
max-func-lines: 1
tagliatelle:
case:
rules:
json: goCamel
yaml: goCamel
use-field-name: true
exclusions:
generated: lax
presets:
- comments
- common-false-positives
- legacy
- std-error-handling
rules:
- linters:
- gosec
- nilnil
path: (.+)_test.go
paths:
- third_party$
- builtin$
- examples$
issues:
max-issues-per-linter: 0
max-same-issues: 0
new: false
fix: false
exclude-rules:
- path: (.+)_test.go
linters:
- nilnil
- gosec

linters:
fast: false
disable-all: true
formatters:
enable:
- asasalint # Check for pass []any as any in variadic func(...any)
- asciicheck # Detects funky ASCII characters
- bidichk # Checks for dangerous unicode character sequences
- durationcheck # Check for two durations multiplied together
- errcheck # Forces to not skip error check
- exportloopref # Checks for pointers to enclosing loop variables
- gocritic # Bundles different linting checks
- godot # Checks for periods at the end of comments
- gomoddirectives # Allow or ban replace directives in go.mod
- gosimple # Code simplification
- govet # Official Go tool
- ineffassign # Detects when assignments to existing variables are not used
- nakedret # Finds naked/bare returns and requires change them
- nilerr # Requires explicit returns
- nilnil # Requires explicit returns
- promlinter # Lints Prometheus metrics names
- reassign # Checks that package variables are not reassigned
- revive # Drop-in replacement for golint
- tagliatelle # Checks struct tags
- tenv # Detects using os.Setenv instead of t.Setenv
- testableexamples # Checks if examples are testable (have expected output)
- unparam # Finds unused params
- usestdlibvars # Detects the possibility to use variables/constants from stdlib
- wastedassign # Finds wasted assignment statements
- loggercheck # Checks the odd number of key and value pairs for common logger libraries
- nestif # Finds deeply nested if statements
- nonamedreturns # Reports all named returns
- decorder # Check declaration order of types, consts, vars and funcs
- gocheckcompilerdirectives # Checks that compiler directive comments (//go:) are valid
- gochecknoinits # Checks for init methods
- whitespace # Tool for detection of leading and trailing whitespace
- wsl # Forces you to use empty lines
- unconvert # Unnecessary type conversions
- tparallel # Detects inappropriate usage of t.Parallel() method in your Go test codes
- thelper # Detects golang test helpers without t.Helper() call and checks the consistency of test helpers
- stylecheck # Stylecheck is a replacement for golint
- prealloc # Finds slice declarations that could potentially be pre-allocated
- predeclared # Finds code that shadows one of Go's predeclared identifiers
- nolintlint # Ill-formed or insufficient nolint directives
- nlreturn # Checks for a new line before return and branch statements to increase code clarity
- misspell # Misspelled English words in comments
- makezero # Finds slice declarations with non-zero initial length
- lll # Long lines
- importas # Enforces consistent import aliases
- gosec # Security problems
- gofmt # Whether the code was gofmt-ed
- gofumpt # Stricter gofmt
- goimports # Unused imports
- goconst # Repeated strings that could be replaced by a constant
- dogsled # Checks assignments with too many blank identifiers (e.g. x, , , _, := f())
- dupl # Code clone detection
- errname # Checks that sentinel errors are prefixed with the Err and error types are suffixed with the Error
- errorlint # errorlint is a linter for that can be used to find code that will cause problems with the error wrapping scheme introduced in Go 1.13
- unused # Checks Go code for unused constants, variables, functions and types

linters-settings:
gocritic:
enabled-tags:
- diagnostic
- experimental
- opinionated
- performance
- style
disabled-checks:
- hugeParam
- rangeExprCopy
- rangeValCopy
- importShadow
- unnamedResult
errcheck:
check-type-assertions: false
check-blank: true
exclude-functions:
- io/ioutil.ReadFile
- io.Copy(*bytes.Buffer)
- io.Copy(os.Stdout)
nakedret:
max-func-lines: 1
govet:
enable-all: true
gofmt:
simplify: true
goconst:
min-len: 3
min-occurrences: 3
godot:
scope: all
period: false
tagliatelle:
case:
use-field-name: true
rules:
json: goCamel
yaml: goCamel
- gofmt
- gofumpt
- goimports
settings:
gofmt:
simplify: true
exclusions:
generated: lax
paths:
- third_party$
- builtin$
- examples$
4 changes: 2 additions & 2 deletions .github/workflows/lint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ jobs:
- name: Install Go
uses: actions/setup-go@v5
with:
go-version: 1.22.x
go-version: 1.23.x

- name: Checkout code
uses: actions/checkout@v4

- name: Lint
uses: golangci/golangci-lint-action@v6
uses: golangci/golangci-lint-action@v8
with:
args:
--config=./.github/golangci.yaml
2 changes: 1 addition & 1 deletion .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:

- uses: actions/setup-go@v5
with:
go-version: 1.22
go-version: 1.23
cache: true

- uses: sigstore/cosign-installer@v3.7.0
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
- name: Install Go
uses: actions/setup-go@v5
with:
go-version: 1.22.x
go-version: 1.23.x

- name: Checkout code
uses: actions/checkout@v4
Expand All @@ -23,7 +23,7 @@ jobs:
- name: Install Go
uses: actions/setup-go@v5
with:
go-version: 1.22.x
go-version: 1.23.x

- name: Checkout code
uses: actions/checkout@v4
Expand Down
31 changes: 28 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,27 @@
`faucet` is a versatile command-line interface (CLI) tool and library designed to effortlessly deploy a faucet server
for Gno Tendermint 2 networks.

### Default endpoint (root)

The `faucet` adopts the [JSON-RPC 2.0 standard](https://www.jsonrpc.org/specification) for requests / responses.

By default, the `/` endpoint is the home of the `drip` method, to handle faucet drips. The first parameter is the
beneficiary address, and the second one is the string representation of the drip amount (`std.Coins`).

This can of course be overwritten with custom handling logic by the faucet creator (see below).

```json
{
"jsonrpc": "2.0",
"id": 0,
"method": "drip",
"params": [
"g1e6gxg5tvc55mwsn7t7dymmlasratv7mkv0rap2",
"1000ugnot"
]
}
```

## Key Features

### Customizability
Expand Down Expand Up @@ -46,6 +67,7 @@ make build
3. Run the faucet

To run the faucet, start the built binary:

```bash
./build/faucet --mnemonic "<faucet_account_mnemonic>"
```
Expand All @@ -54,16 +76,19 @@ The provided mnemonic will be used to derive accounts which will be used to serv
funds to users. Make sure that the accounts derived from it are well funded.

It should print something like the following. (Note the port number at the end.)

```
2024-01-11T12:47:27.826+0100 INFO cmd/logger.go:17 faucet started at [::]:8545
```

4. To send coins to a single account, in a new terminal enter the following (change to the correct recipient address):

```bash
curl --location --request POST 'http://localhost:8545' --header 'Content-Type: application/json' --data '{"To": "g1juz2yxmdsa6audkp6ep9vfv80c8p5u76e03vvh"}'
curl --location --request POST 'http://localhost:8545' --header 'Content-Type: application/json' --data '{ "jsonrpc": "2.0", "id": 0, "method": "drip", "params": [ "g1e6gxg5tvc55mwsn7t7dymmlasratv7mkv0rap2", "1000ugnot" ] }'
```

5. To ensure the faucet is listening to requests, you can ping the health endpoint:
5. To ensure the faucet is listening to requests, you can ping the health endpoint (returns a simple status 200):

```bash
curl --location --request GET 'http://localhost:8545/health'
```
Expand Down Expand Up @@ -94,7 +119,7 @@ func main() {
f, err := NewFaucet(
static.New(...), // gas estimator
http.NewClient(...), // remote address
)
)

// The faucet is controlled through a top-level context
ctx, cancelFn := context.WithCancel(context.Background())
Expand Down
Loading
Loading