Skip to content

Commit 524ba5f

Browse files
committed
examples: fix linter issues
Signed-off-by: Anna Shaleva <[email protected]>
1 parent 949ed4f commit 524ba5f

File tree

13 files changed

+39
-42
lines changed

13 files changed

+39
-42
lines changed

examples/engine/engine.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,25 +4,25 @@ import (
44
"github.com/nspcc-dev/neo-go/pkg/interop/runtime"
55
)
66

7-
// NotifyScriptContainer sends runtime notification with script container hash
7+
// NotifyScriptContainer sends runtime notification with script container hash.
88
func NotifyScriptContainer() {
99
tx := runtime.GetScriptContainer()
1010
runtime.Notify("Tx", tx.Hash)
1111
}
1212

13-
// NotifyCallingScriptHash sends runtime notification with calling script hash
13+
// NotifyCallingScriptHash sends runtime notification with calling script hash.
1414
func NotifyCallingScriptHash() {
1515
callingScriptHash := runtime.GetCallingScriptHash()
1616
runtime.Notify("Calling", callingScriptHash)
1717
}
1818

19-
// NotifyExecutingScriptHash sends runtime notification about executing script hash
19+
// NotifyExecutingScriptHash sends runtime notification about executing script hash.
2020
func NotifyExecutingScriptHash() {
2121
execScriptHash := runtime.GetExecutingScriptHash()
2222
runtime.Notify("Executing", execScriptHash)
2323
}
2424

25-
// NotifyEntryScriptHash sends notification about entry script hash
25+
// NotifyEntryScriptHash sends notification about entry script hash.
2626
func NotifyEntryScriptHash() {
2727
entryScriptHash := runtime.GetEntryScriptHash()
2828
runtime.Notify("Entry", entryScriptHash)

examples/iterator/iterator.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import (
77
)
88

99
// _deploy primes contract's storage with some data to be used later.
10-
func _deploy(_ any, _ bool) {
10+
func _deploy(_ any, _ bool) { // nolint: unused
1111
ctx := storage.GetContext() // RW context.
1212
storage.Put(ctx, "foo1", "1")
1313
storage.Put(ctx, "foo2", "2")

examples/nft-nd-nns/nns.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ const (
6060
// Other constants.
6161
const (
6262
// defaultRegisterPrice is the default price for new domain registration.
63-
defaultRegisterPrice = 10_0000_0000
63+
defaultRegisterPrice = 10_0000_0000 // nolint: unused
6464
// millisecondsInYear is amount of milliseconds per year.
6565
millisecondsInYear = 365 * 24 * 3600 * 1000
6666
)
@@ -79,7 +79,7 @@ func Update(nef []byte, manifest string) {
7979
}
8080

8181
// _deploy initializes defaults (total supply and registration price) on contract deploy.
82-
func _deploy(data any, isUpdate bool) {
82+
func _deploy(data any, isUpdate bool) { // nolint: unused
8383
if isUpdate {
8484
return
8585
}
@@ -491,7 +491,7 @@ func getRecordKey(tokenId []byte, name string, typ RecordType) []byte {
491491

492492
// isValid returns true if the provided address is a valid Uint160.
493493
func isValid(address interop.Hash160) bool {
494-
return address != nil && len(address) == 20
494+
return address != nil && len(address) == 20 // nolint: gosimple
495495
}
496496

497497
// checkCommittee panics if the script container is not signed by the committee.
@@ -555,7 +555,7 @@ func splitAndCheck(name string, allowMultipleFragments bool) []string {
555555
if l > 2 && !allowMultipleFragments {
556556
return nil
557557
}
558-
for i := 0; i < l; i++ {
558+
for i := range fragments {
559559
if !checkFragment(fragments[i], i == l-1) {
560560
return nil
561561
}

examples/nft-nd-nns/nns_test.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -418,11 +418,9 @@ func testTokensOf(t *testing.T, c *neotest.ContractInvoker, result [][]byte, arg
418418
}
419419
require.NoError(t, err)
420420
iter := s.Pop().Interop().Value().(*storage.Iterator)
421-
arr := make([]stackitem.Item, 0, len(result))
422421
for i := range result {
423422
require.True(t, iter.Next())
424423
require.Equal(t, result[i], iter.Value().Value())
425-
arr = append(arr, stackitem.Make(result[i]))
426424
}
427425
require.False(t, iter.Next())
428426
}

examples/nft-nd/nft.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ const (
2626
totalSupplyPrefix = "s"
2727
// balancePrefix contains map from addresses to balances.
2828
balancePrefix = "b"
29-
// accountPrefix contains map from address + token id to tokens
29+
// accountPrefix contains map from address + token id to tokens.
3030
accountPrefix = "a"
3131
// tokenPrefix contains map from token id to it's owner.
3232
tokenPrefix = "t"

examples/runtime/runtime.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import (
77
)
88

99
var (
10-
// Check if the invoker of the contract is the specified owner
10+
// Check if the invoker of the contract is the specified owner.
1111
owner = address.ToHash160("NbrUYaZgyhSkNoRo9ugRyEMdUZxrhkNaWB")
1212
)
1313

@@ -22,7 +22,7 @@ func init() {
2222

2323
// _deploy is called after contract deployment or update, it'll be called
2424
// in deployment transaction and if call update method of this contract.
25-
func _deploy(_ any, isUpdate bool) {
25+
func _deploy(_ any, isUpdate bool) { // nolint: unused
2626
if isUpdate {
2727
Log("_deploy method called after contract update")
2828
return

examples/storage/storage.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@ import (
55
"github.com/nspcc-dev/neo-go/pkg/interop/storage"
66
)
77

8-
// ctx holds storage context for contract methods
8+
// ctx holds storage context for contract methods.
99
var ctx storage.Context
1010

1111
// defaultKey represents the default key.
1212
var defaultKey = []byte("default")
1313

14-
// init inits storage context before any other contract method is called
14+
// init inits storage context before any other contract method is called.
1515
func init() {
1616
ctx = storage.GetContext()
1717
}

examples/timer/timer.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,23 +9,23 @@ import (
99
"github.com/nspcc-dev/neo-go/pkg/interop/storage"
1010
)
1111

12-
const defaultTicks = 3
12+
const defaultTicks = 3 // nolint: unused
1313
const mgmtKey = "mgmt"
1414

1515
var (
16-
// ctx holds storage context for contract methods
16+
// ctx holds storage context for contract methods.
1717
ctx storage.Context
18-
// Check if the invoker of the contract is the specified owner
18+
// Check if the invoker of the contract is the specified owner.
1919
owner = address.ToHash160("NbrUYaZgyhSkNoRo9ugRyEMdUZxrhkNaWB")
20-
// ticksKey is a storage key for ticks counter
20+
// ticksKey is a storage key for ticks counter.
2121
ticksKey = []byte("ticks")
2222
)
2323

2424
func init() {
2525
ctx = storage.GetContext()
2626
}
2727

28-
func _deploy(_ any, isUpdate bool) {
28+
func _deploy(_ any, isUpdate bool) { // nolint: unused
2929
if isUpdate {
3030
ticksLeft := storage.Get(ctx, ticksKey).(int) + 1
3131
storage.Put(ctx, ticksKey, ticksLeft)

examples/token/nep17/nep17.go

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import (
88
"github.com/nspcc-dev/neo-go/pkg/interop/storage"
99
)
1010

11-
// Token holds all token info
11+
// Token holds all token info.
1212
type Token struct {
1313
// Token name
1414
Name string
@@ -35,17 +35,17 @@ func getIntFromDB(ctx storage.Context, key []byte) int {
3535
return res
3636
}
3737

38-
// GetSupply gets the token totalSupply value from VM storage
38+
// GetSupply gets the token totalSupply value from VM storage.
3939
func (t Token) GetSupply(ctx storage.Context) int {
4040
return getIntFromDB(ctx, []byte(t.CirculationKey))
4141
}
4242

43-
// BalanceOf gets the token balance of a specific address
43+
// BalanceOf gets the token balance of a specific address.
4444
func (t Token) BalanceOf(ctx storage.Context, holder []byte) int {
4545
return getIntFromDB(ctx, holder)
4646
}
4747

48-
// Transfer token from one user to another
48+
// Transfer token from one user to another.
4949
func (t Token) Transfer(ctx storage.Context, from, to interop.Hash160, amount int, data any) bool {
5050
amountFrom := t.CanTransfer(ctx, from, to, amount)
5151
if amountFrom == -1 {
@@ -74,7 +74,7 @@ func (t Token) Transfer(ctx storage.Context, from, to interop.Hash160, amount in
7474
return true
7575
}
7676

77-
// CanTransfer returns the amount it can transfer
77+
// CanTransfer returns the amount it can transfer.
7878
func (t Token) CanTransfer(ctx storage.Context, from []byte, to []byte, amount int) int {
7979
if len(to) != 20 || !IsUsableAddress(from) {
8080
return -1
@@ -94,10 +94,9 @@ func (t Token) CanTransfer(ctx storage.Context, from []byte, to []byte, amount i
9494
return amountFrom
9595
}
9696

97-
// IsUsableAddress checks if the sender is either the correct Neo address or SC address
97+
// IsUsableAddress checks if the sender is either the correct Neo address or SC address.
9898
func IsUsableAddress(addr []byte) bool {
9999
if len(addr) == 20 {
100-
101100
if runtime.CheckWitness(addr) {
102101
return true
103102
}
@@ -112,13 +111,13 @@ func IsUsableAddress(addr []byte) bool {
112111
return false
113112
}
114113

115-
// Mint initial supply of tokens
114+
// Mint initial supply of tokens.
116115
func (t Token) Mint(ctx storage.Context, to interop.Hash160) bool {
117116
if !IsUsableAddress(t.Owner) {
118117
return false
119118
}
120119
minted := storage.Get(ctx, []byte("minted"))
121-
if minted != nil && minted.(bool) == true {
120+
if minted != nil && minted.(bool) {
122121
return false
123122
}
124123

examples/token/token.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ var (
1919
)
2020

2121
// init initializes Token Interface and storage context for the Smart
22-
// Contract to operate with
22+
// Contract to operate with.
2323
func init() {
2424
token = nep17.Token{
2525
Name: "Awesome NEO Token",
@@ -32,32 +32,32 @@ func init() {
3232
ctx = storage.GetContext()
3333
}
3434

35-
// Symbol returns the token symbol
35+
// Symbol returns the token symbol.
3636
func Symbol() string {
3737
return token.Symbol
3838
}
3939

40-
// Decimals returns the token decimals
40+
// Decimals returns the token decimals.
4141
func Decimals() int {
4242
return token.Decimals
4343
}
4444

45-
// TotalSupply returns the token total supply value
45+
// TotalSupply returns the token total supply value.
4646
func TotalSupply() int {
4747
return token.GetSupply(ctx)
4848
}
4949

50-
// BalanceOf returns the amount of token on the specified address
50+
// BalanceOf returns the amount of token on the specified address.
5151
func BalanceOf(holder interop.Hash160) int {
5252
return token.BalanceOf(ctx, holder)
5353
}
5454

55-
// Transfer token from one user to another
55+
// Transfer token from one user to another.
5656
func Transfer(from interop.Hash160, to interop.Hash160, amount int, data any) bool {
5757
return token.Transfer(ctx, from, to, amount, data)
5858
}
5959

60-
// Mint initial supply of tokens
60+
// Mint initial supply of tokens.
6161
func Mint(to interop.Hash160) bool {
6262
return token.Mint(ctx, to)
6363
}

examples/zkp/cubic_circuit/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ func (circuit *CubicCircuit) Define(api frontend.API) error {
5151

5252
// main demonstrates how to build the proof and verify it with the help of gnark
5353
// library. Error handling omitted intentionally to simplify the example.
54-
func main() {
54+
func main() { // nolint: unused
5555
var (
5656
circuit CubicCircuit
5757
assignment = CubicCircuit{X: 3, Y: 35}

examples/zkp/cubic_circuit/main_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,7 @@ func setup(t *testing.T, ccs constraint.ConstraintSystem, phase1ResponsePath str
315315
// receive a []byte, deserialize it, add his contribution and send back to
316316
// coordinator, like it is done in https://github.com/bnb-chain/zkbnb-setup
317317
// for BN254 elliptic curve.
318-
for i := range nContributionsPhase2 {
318+
for range nContributionsPhase2 {
319319
srs2.Contribute()
320320
}
321321

examples/zkp/xor_compat/verify.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ var (
4343
// proving system and is taken from the
4444
// https://github.com/neo-project/neo/issues/2647#issuecomment-1002893109 without
4545
// changes. The verification process checks the following equality:
46-
// A * B = alpha * beta + sum(pub_input[i] * (beta * u_i(x) + alpha * v_i(x) + w_i(x)) / gamma) * gamma + C * delta
46+
// A * B = alpha * beta + sum(pub_input[i] * (beta * u_i(x) + alpha * v_i(x) + w_i(x)) / gamma) * gamma + C * delta.
4747
func VerifyProof(a []byte, b []byte, c []byte, publicInput [][]byte) bool {
4848
alphaPoint := crypto.Bls12381Deserialize(alpha)
4949
betaPoint := crypto.Bls12381Deserialize(beta)
@@ -68,11 +68,11 @@ func VerifyProof(a []byte, b []byte, c []byte, publicInput [][]byte) bool {
6868
panic("error: inputlen or iclen")
6969
}
7070
icPoints := make([]crypto.Bls12381Point, iclen)
71-
for i := 0; i < iclen; i++ {
71+
for i := range icPoints {
7272
icPoints[i] = crypto.Bls12381Deserialize(ic[i])
7373
}
7474
acc := icPoints[0]
75-
for i := 0; i < inputlen; i++ {
75+
for i := range publicInput {
7676
scalar := publicInput[i] // 32-bytes LE field element.
7777
temp := crypto.Bls12381Mul(icPoints[i+1], scalar, false)
7878
acc = crypto.Bls12381Add(acc, temp)

0 commit comments

Comments
 (0)