Skip to content
This repository was archived by the owner on Sep 6, 2022. It is now read-only.

Commit 19302e2

Browse files
committed
new version has weird changes so nvm
1 parent 1b71494 commit 19302e2

File tree

262 files changed

+4561
-4975
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

262 files changed

+4561
-4975
lines changed

.golangci.yml

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -28,16 +28,15 @@ linters:
2828
- durationcheck
2929
- exportloopref
3030
- gosec
31-
- whitespace
3231

33-
# - structcheck # lots of false positives
34-
# - errcheck #lot of false positives
35-
# - contextcheck
36-
# - errchkjson # lots of false positives
37-
# - errorlint # this check crashes
38-
# - exhaustive # silly check
39-
# - makezero # false positives
40-
# - nilerr # several intentional
32+
#- structcheck # lots of false positives
33+
#- errcheck #lot of false positives
34+
# - contextcheck
35+
# - errchkjson # lots of false positives
36+
# - errorlint # this check crashes
37+
# - exhaustive # silly check
38+
# - makezero # false positives
39+
# - nilerr # several intentional
4140

4241
linters-settings:
4342
gofmt:
@@ -47,9 +46,9 @@ linters-settings:
4746
min-occurrences: 6 # minimum number of occurrences
4847
gosec:
4948
excludes:
50-
- G404 # Use of weak random number generator - lots of FP
51-
- G107 # Potential http request -- those are intentional
52-
- G306 # G306: Expect WriteFile permissions to be 0600 or less
49+
- G404 # Use of weak random number generator - lots of FP
50+
- G107 # Potential http request -- those are intentional
51+
- G306 # G306: Expect WriteFile permissions to be 0600 or less
5352

5453
issues:
5554
exclude-rules:
@@ -68,6 +67,5 @@ issues:
6867
exclude:
6968
- 'SA1019: event.TypeMux is deprecated: use Feed'
7069
- 'SA1019: strings.Title is deprecated'
71-
- 'SA1019: strings.Title has been deprecated since Go 1.18 and an alternative has been available since Go 1.0: The rule Title uses for word boundaries does not handle Unicode punctuation properly. Use golang.org/x/text/cases instead.'
7270
- 'SA1029: should not use built-in type string as key for value'
73-
- 'G306: Expect WriteFile permissions to be 0600 or less'
71+
- 'G306: Expect WriteFile permissions to be 0600 or less'

accounts/abi/argument.go

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ package abi
1818

1919
import (
2020
"encoding/json"
21-
"errors"
2221
"fmt"
2322
"reflect"
2423
"strings"
@@ -80,7 +79,7 @@ func (arguments Arguments) isTuple() bool {
8079
func (arguments Arguments) Unpack(data []byte) ([]interface{}, error) {
8180
if len(data) == 0 {
8281
if len(arguments.NonIndexed()) != 0 {
83-
return nil, errors.New("abi: attempting to unmarshall an empty string while arguments are expected")
82+
return nil, fmt.Errorf("abi: attempting to unmarshall an empty string while arguments are expected")
8483
}
8584
return make([]interface{}, 0), nil
8685
}
@@ -91,11 +90,11 @@ func (arguments Arguments) Unpack(data []byte) ([]interface{}, error) {
9190
func (arguments Arguments) UnpackIntoMap(v map[string]interface{}, data []byte) error {
9291
// Make sure map is not nil
9392
if v == nil {
94-
return errors.New("abi: cannot unpack into a nil map")
93+
return fmt.Errorf("abi: cannot unpack into a nil map")
9594
}
9695
if len(data) == 0 {
9796
if len(arguments.NonIndexed()) != 0 {
98-
return errors.New("abi: attempting to unmarshall an empty string while arguments are expected")
97+
return fmt.Errorf("abi: attempting to unmarshall an empty string while arguments are expected")
9998
}
10099
return nil // Nothing to unmarshal, return
101100
}
@@ -117,7 +116,7 @@ func (arguments Arguments) Copy(v interface{}, values []interface{}) error {
117116
}
118117
if len(values) == 0 {
119118
if len(arguments.NonIndexed()) != 0 {
120-
return errors.New("abi: attempting to copy no values while arguments are expected")
119+
return fmt.Errorf("abi: attempting to copy no values while arguments are expected")
121120
}
122121
return nil // Nothing to copy, return
123122
}

accounts/abi/bind/backends/simulated.go

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -106,20 +106,16 @@ func (b *SimulatedBackend) Close() error {
106106

107107
// Commit imports all the pending transactions as a single block and starts a
108108
// fresh new state.
109-
func (b *SimulatedBackend) Commit() common.Hash {
109+
func (b *SimulatedBackend) Commit() {
110110
b.mu.Lock()
111111
defer b.mu.Unlock()
112112

113113
if _, err := b.blockchain.InsertChain([]*types.Block{b.pendingBlock}); err != nil {
114114
panic(err) // This cannot happen unless the simulator is wrong, fail in that case
115115
}
116-
blockHash := b.pendingBlock.Hash()
117-
118116
// Using the last inserted block here makes it possible to build on a side
119117
// chain after a fork.
120118
b.rollback(b.pendingBlock)
121-
122-
return blockHash
123119
}
124120

125121
// Rollback aborts all pending transactions, reverting to the last committed state.

accounts/abi/bind/backends/simulated_test.go

Lines changed: 0 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1335,42 +1335,3 @@ func TestForkResendTx(t *testing.T) {
13351335
t.Errorf("TX included in wrong block: %d", h)
13361336
}
13371337
}
1338-
1339-
func TestCommitReturnValue(t *testing.T) {
1340-
testAddr := crypto.PubkeyToAddress(testKey.PublicKey)
1341-
sim := simTestBackend(testAddr)
1342-
defer sim.Close()
1343-
1344-
startBlockHeight := sim.blockchain.CurrentBlock().NumberU64()
1345-
1346-
// Test if Commit returns the correct block hash
1347-
h1 := sim.Commit()
1348-
if h1 != sim.blockchain.CurrentBlock().Hash() {
1349-
t.Error("Commit did not return the hash of the last block.")
1350-
}
1351-
1352-
// Create a block in the original chain (containing a transaction to force different block hashes)
1353-
head, _ := sim.HeaderByNumber(context.Background(), nil) // Should be child's, good enough
1354-
gasPrice := new(big.Int).Add(head.BaseFee, big.NewInt(1))
1355-
_tx := types.NewTransaction(0, testAddr, big.NewInt(1000), params.TxGas, gasPrice, nil)
1356-
tx, _ := types.SignTx(_tx, types.HomesteadSigner{}, testKey)
1357-
sim.SendTransaction(context.Background(), tx)
1358-
h2 := sim.Commit()
1359-
1360-
// Create another block in the original chain
1361-
sim.Commit()
1362-
1363-
// Fork at the first bock
1364-
if err := sim.Fork(context.Background(), h1); err != nil {
1365-
t.Errorf("forking: %v", err)
1366-
}
1367-
1368-
// Test if Commit returns the correct block hash after the reorg
1369-
h2fork := sim.Commit()
1370-
if h2 == h2fork {
1371-
t.Error("The block in the fork and the original block are the same block!")
1372-
}
1373-
if sim.blockchain.GetHeader(h2fork, startBlockHeight+2) == nil {
1374-
t.Error("Could not retrieve the just created block (side-chain)")
1375-
}
1376-
}

accounts/abi/bind/base_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ func (mc *mockPendingCaller) PendingCallContract(ctx context.Context, call ether
115115
}
116116

117117
func TestPassingBlockNumber(t *testing.T) {
118+
118119
mc := &mockPendingCaller{
119120
mockCaller: &mockCaller{
120121
codeAtBytes: []byte{1, 2, 3},

accounts/abi/bind/bind.go

Lines changed: 2 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -43,43 +43,6 @@ const (
4343
LangObjC
4444
)
4545

46-
func isKeyWord(arg string) bool {
47-
switch arg {
48-
case "break":
49-
case "case":
50-
case "chan":
51-
case "const":
52-
case "continue":
53-
case "default":
54-
case "defer":
55-
case "else":
56-
case "fallthrough":
57-
case "for":
58-
case "func":
59-
case "go":
60-
case "goto":
61-
case "if":
62-
case "import":
63-
case "interface":
64-
case "iota":
65-
case "map":
66-
case "make":
67-
case "new":
68-
case "package":
69-
case "range":
70-
case "return":
71-
case "select":
72-
case "struct":
73-
case "switch":
74-
case "type":
75-
case "var":
76-
default:
77-
return false
78-
}
79-
80-
return true
81-
}
82-
8346
// Bind generates a Go wrapper around a contract ABI. This wrapper isn't meant
8447
// to be used as is in client code, but rather as an intermediate struct which
8548
// enforces compile time type safety and naming convention opposed to having to
@@ -151,7 +114,7 @@ func Bind(types []string, abis []string, bytecodes []string, fsigs []map[string]
151114
normalized.Inputs = make([]abi.Argument, len(original.Inputs))
152115
copy(normalized.Inputs, original.Inputs)
153116
for j, input := range normalized.Inputs {
154-
if input.Name == "" || isKeyWord(input.Name) {
117+
if input.Name == "" {
155118
normalized.Inputs[j].Name = fmt.Sprintf("arg%d", j)
156119
}
157120
if hasStruct(input.Type) {
@@ -195,7 +158,7 @@ func Bind(types []string, abis []string, bytecodes []string, fsigs []map[string]
195158
normalized.Inputs = make([]abi.Argument, len(original.Inputs))
196159
copy(normalized.Inputs, original.Inputs)
197160
for j, input := range normalized.Inputs {
198-
if input.Name == "" || isKeyWord(input.Name) {
161+
if input.Name == "" {
199162
normalized.Inputs[j].Name = fmt.Sprintf("arg%d", j)
200163
}
201164
// Event is a bit special, we need to define event struct in binding,

accounts/abi/bind/bind_test.go

Lines changed: 1 addition & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1971,7 +1971,7 @@ var bindTests = []struct {
19711971
}
19721972
}
19731973
`,
1974-
bytecode: []string{"0x608060405234801561001057600080fd5b5061042b806100206000396000f3fe608060405234801561001057600080fd5b50600436106100365760003560e01c8063c2bb515f1461003b578063cce7b04814610059575b600080fd5b610043610075565b60405161005091906101af565b60405180910390f35b610073600480360381019061006e91906103ac565b6100b5565b005b61007d6100b8565b604051806040016040528060405180602001604052806000815250815260200160405180602001604052806000815250815250905090565b50565b604051806040016040528060608152602001606081525090565b600081519050919050565b600082825260208201905092915050565b60005b8381101561010c5780820151818401526020810190506100f1565b8381111561011b576000848401525b50505050565b6000601f19601f8301169050919050565b600061013d826100d2565b61014781856100dd565b93506101578185602086016100ee565b61016081610121565b840191505092915050565b600060408301600083015184820360008601526101888282610132565b915050602083015184820360208601526101a28282610132565b9150508091505092915050565b600060208201905081810360008301526101c9818461016b565b905092915050565b6000604051905090565b600080fd5b600080fd5b600080fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b61022282610121565b810181811067ffffffffffffffff82111715610241576102406101ea565b5b80604052505050565b60006102546101d1565b90506102608282610219565b919050565b600080fd5b600080fd5b600080fd5b600067ffffffffffffffff82111561028f5761028e6101ea565b5b61029882610121565b9050602081019050919050565b82818337600083830152505050565b60006102c76102c284610274565b61024a565b9050828152602081018484840111156102e3576102e261026f565b5b6102ee8482856102a5565b509392505050565b600082601f83011261030b5761030a61026a565b5b813561031b8482602086016102b4565b91505092915050565b60006040828403121561033a576103396101e5565b5b610344604061024a565b9050600082013567ffffffffffffffff81111561036457610363610265565b5b610370848285016102f6565b600083015250602082013567ffffffffffffffff81111561039457610393610265565b5b6103a0848285016102f6565b60208301525092915050565b6000602082840312156103c2576103c16101db565b5b600082013567ffffffffffffffff8111156103e0576103df6101e0565b5b6103ec84828501610324565b9150509291505056fea264697066735822122033bca1606af9b6aeba1673f98c52003cec19338539fb44b86690ce82c51483b564736f6c634300080e0033"},
1974+
bytecode: []string{`0x608060405234801561001057600080fd5b5061042b806100206000396000f3fe608060405234801561001057600080fd5b50600436106100365760003560e01c8063c2bb515f1461003b578063cce7b04814610059575b600080fd5b610043610075565b60405161005091906101af565b60405180910390f35b610073600480360381019061006e91906103ac565b6100b5565b005b61007d6100b8565b604051806040016040528060405180602001604052806000815250815260200160405180602001604052806000815250815250905090565b50565b604051806040016040528060608152602001606081525090565b600081519050919050565b600082825260208201905092915050565b60005b8381101561010c5780820151818401526020810190506100f1565b8381111561011b576000848401525b50505050565b6000601f19601f8301169050919050565b600061013d826100d2565b61014781856100dd565b93506101578185602086016100ee565b61016081610121565b840191505092915050565b600060408301600083015184820360008601526101888282610132565b915050602083015184820360208601526101a28282610132565b9150508091505092915050565b600060208201905081810360008301526101c9818461016b565b905092915050565b6000604051905090565b600080fd5b600080fd5b600080fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b61022282610121565b810181811067ffffffffffffffff82111715610241576102406101ea565b5b80604052505050565b60006102546101d1565b90506102608282610219565b919050565b600080fd5b600080fd5b600080fd5b600067ffffffffffffffff82111561028f5761028e6101ea565b5b61029882610121565b9050602081019050919050565b82818337600083830152505050565b60006102c76102c284610274565b61024a565b9050828152602081018484840111156102e3576102e261026f565b5b6102ee8482856102a5565b509392505050565b600082601f83011261030b5761030a61026a565b5b813561031b8482602086016102b4565b91505092915050565b60006040828403121561033a576103396101e5565b5b610344604061024a565b9050600082013567ffffffffffffffff81111561036457610363610265565b5b610370848285016102f6565b600083015250602082013567ffffffffffffffff81111561039457610393610265565b5b6103a0848285016102f6565b60208301525092915050565b6000602082840312156103c2576103c16101db565b5b600082013567ffffffffffffffff8111156103e0576103df6101e0565b5b6103ec84828501610324565b9150509291505056fea264697066735822122033bca1606af9b6aeba1673f98c52003cec19338539fb44b86690ce82c51483b564736f6c634300080e0033`},
19751975
abi: []string{`[ { "anonymous": false, "inputs": [ { "indexed": false, "internalType": "int256", "name": "msg", "type": "int256" }, { "indexed": false, "internalType": "int256", "name": "_msg", "type": "int256" } ], "name": "log", "type": "event" }, { "inputs": [ { "components": [ { "internalType": "bytes", "name": "data", "type": "bytes" }, { "internalType": "bytes", "name": "_data", "type": "bytes" } ], "internalType": "struct oracle.request", "name": "req", "type": "tuple" } ], "name": "addRequest", "outputs": [], "stateMutability": "pure", "type": "function" }, { "inputs": [], "name": "getRequest", "outputs": [ { "components": [ { "internalType": "bytes", "name": "data", "type": "bytes" }, { "internalType": "bytes", "name": "_data", "type": "bytes" } ], "internalType": "struct oracle.request", "name": "", "type": "tuple" } ], "stateMutability": "pure", "type": "function" } ]`},
19761976
imports: `
19771977
"math/big"
@@ -2002,43 +2002,6 @@ var bindTests = []struct {
20022002
}
20032003
`,
20042004
},
2005-
{
2006-
name: "RangeKeyword",
2007-
contract: `
2008-
// SPDX-License-Identifier: GPL-3.0
2009-
pragma solidity >=0.4.22 <0.9.0;
2010-
contract keywordcontract {
2011-
function functionWithKeywordParameter(range uint256) public pure {}
2012-
}
2013-
`,
2014-
bytecode: []string{"0x608060405234801561001057600080fd5b5060dc8061001f6000396000f3fe6080604052348015600f57600080fd5b506004361060285760003560e01c8063527a119f14602d575b600080fd5b60436004803603810190603f9190605b565b6045565b005b50565b6000813590506055816092565b92915050565b600060208284031215606e57606d608d565b5b6000607a848285016048565b91505092915050565b6000819050919050565b600080fd5b6099816083565b811460a357600080fd5b5056fea2646970667358221220d4f4525e2615516394055d369fb17df41c359e5e962734f27fd683ea81fd9db164736f6c63430008070033"},
2015-
abi: []string{`[{"inputs":[{"internalType":"uint256","name":"range","type":"uint256"}],"name":"functionWithKeywordParameter","outputs":[],"stateMutability":"pure","type":"function"}]`},
2016-
imports: `
2017-
"math/big"
2018-
2019-
"github.com/ethereum/go-ethereum/accounts/abi/bind"
2020-
"github.com/ethereum/go-ethereum/accounts/abi/bind/backends"
2021-
"github.com/ethereum/go-ethereum/core"
2022-
"github.com/ethereum/go-ethereum/crypto"
2023-
"github.com/ethereum/go-ethereum/eth/ethconfig"
2024-
`,
2025-
tester: `
2026-
var (
2027-
key, _ = crypto.GenerateKey()
2028-
user, _ = bind.NewKeyedTransactorWithChainID(key, big.NewInt(1337))
2029-
sim = backends.NewSimulatedBackend(core.GenesisAlloc{user.From: {Balance: big.NewInt(1000000000000000000)}}, ethconfig.Defaults.Miner.GasCeil)
2030-
)
2031-
_, tx, _, err := DeployRangeKeyword(user, sim)
2032-
if err != nil {
2033-
t.Fatalf("error deploying contract: %v", err)
2034-
}
2035-
sim.Commit()
2036-
2037-
if _, err = bind.WaitDeployed(nil, sim, tx); err != nil {
2038-
t.Errorf("error deploying the contract: %v", err)
2039-
}
2040-
`,
2041-
},
20422005
}
20432006

20442007
// Tests that packages generated by the binder can be successfully compiled and

accounts/abi/error_handling.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ func typeCheck(t Type, value reflect.Value) error {
7373
} else {
7474
return nil
7575
}
76+
7677
}
7778

7879
// typeErr returns a formatted type casting error.

accounts/abi/event_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,7 @@ func TestEventMultiValueWithArrayUnpack(t *testing.T) {
161161
}
162162

163163
func TestEventTupleUnpack(t *testing.T) {
164+
164165
type EventTransfer struct {
165166
Value *big.Int
166167
}

accounts/abi/reflect.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,7 @@ func mapArgNamesToStructFields(argNames []string, value reflect.Value) (map[stri
220220

221221
// second round ~~~
222222
for _, argName := range argNames {
223+
223224
structFieldName := ToCamelCase(argName)
224225

225226
if structFieldName == "" {

0 commit comments

Comments
 (0)