Skip to content

Commit bd57f69

Browse files
committed
build: go1.19 fmt ./...
1 parent c721ca0 commit bd57f69

File tree

170 files changed

+873
-783
lines changed

Some content is hidden

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

170 files changed

+873
-783
lines changed

accounts/abi/abi_test.go

+20-14
Original file line numberDiff line numberDiff line change
@@ -165,8 +165,9 @@ func TestInvalidABI(t *testing.T) {
165165

166166
// TestConstructor tests a constructor function.
167167
// The test is based on the following contract:
168-
// contract TestConstructor {
169-
// constructor(uint256 a, uint256 b) public{}
168+
//
169+
// contract TestConstructor {
170+
// constructor(uint256 a, uint256 b) public{}
170171
// }
171172
func TestConstructor(t *testing.T) {
172173
json := `[{ "inputs": [{"internalType": "uint256","name": "a","type": "uint256" },{ "internalType": "uint256","name": "b","type": "uint256"}],"stateMutability": "nonpayable","type": "constructor"}]`
@@ -710,16 +711,19 @@ func TestBareEvents(t *testing.T) {
710711
}
711712

712713
// TestUnpackEvent is based on this contract:
713-
// contract T {
714-
// event received(address sender, uint amount, bytes memo);
715-
// event receivedAddr(address sender);
716-
// function receive(bytes memo) external payable {
717-
// received(msg.sender, msg.value, memo);
718-
// receivedAddr(msg.sender);
719-
// }
720-
// }
714+
//
715+
// contract T {
716+
// event received(address sender, uint amount, bytes memo);
717+
// event receivedAddr(address sender);
718+
// function receive(bytes memo) external payable {
719+
// received(msg.sender, msg.value, memo);
720+
// receivedAddr(msg.sender);
721+
// }
722+
// }
723+
//
721724
// When receive("X") is called with sender 0x00... and value 1, it produces this tx receipt:
722-
// receipt{status=1 cgas=23949 bloom=00000000004000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000040200000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 logs=[log: b6818c8064f645cd82d99b59a1a267d6d61117ef [75fd880d39c1daf53b6547ab6cb59451fc6452d27caa90e5b6649dd8293b9eed] 000000000000000000000000376c47978271565f56deb45495afa69e59c16ab200000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000060000000000000000000000000000000000000000000000000000000000000000158 9ae378b6d4409eada347a5dc0c180f186cb62dc68fcc0f043425eb917335aa28 0 95d429d309bb9d753954195fe2d69bd140b4ae731b9b5b605c34323de162cf00 0]}
725+
//
726+
// receipt{status=1 cgas=23949 bloom=00000000004000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000040200000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 logs=[log: b6818c8064f645cd82d99b59a1a267d6d61117ef [75fd880d39c1daf53b6547ab6cb59451fc6452d27caa90e5b6649dd8293b9eed] 000000000000000000000000376c47978271565f56deb45495afa69e59c16ab200000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000060000000000000000000000000000000000000000000000000000000000000000158 9ae378b6d4409eada347a5dc0c180f186cb62dc68fcc0f043425eb917335aa28 0 95d429d309bb9d753954195fe2d69bd140b4ae731b9b5b605c34323de162cf00 0]}
723727
func TestUnpackEvent(t *testing.T) {
724728
const abiJSON = `[{"constant":false,"inputs":[{"name":"memo","type":"bytes"}],"name":"receive","outputs":[],"payable":true,"stateMutability":"payable","type":"function"},{"anonymous":false,"inputs":[{"indexed":false,"name":"sender","type":"address"},{"indexed":false,"name":"amount","type":"uint256"},{"indexed":false,"name":"memo","type":"bytes"}],"name":"received","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"name":"sender","type":"address"}],"name":"receivedAddr","type":"event"}]`
725729
abi, err := JSON(strings.NewReader(abiJSON))
@@ -1066,8 +1070,9 @@ func TestDoubleDuplicateMethodNames(t *testing.T) {
10661070
// TestDoubleDuplicateEventNames checks that if send0 already exists, there won't be a name
10671071
// conflict and that the second send event will be renamed send1.
10681072
// The test runs the abi of the following contract.
1069-
// contract DuplicateEvent {
1070-
// event send(uint256 a);
1073+
//
1074+
// contract DuplicateEvent {
1075+
// event send(uint256 a);
10711076
// event send0();
10721077
// event send();
10731078
// }
@@ -1094,7 +1099,8 @@ func TestDoubleDuplicateEventNames(t *testing.T) {
10941099
// TestUnnamedEventParam checks that an event with unnamed parameters is
10951100
// correctly handled.
10961101
// The test runs the abi of the following contract.
1097-
// contract TestEvent {
1102+
//
1103+
// contract TestEvent {
10981104
// event send(uint256, uint256);
10991105
// }
11001106
func TestUnnamedEventParam(t *testing.T) {

accounts/abi/bind/backends/simulated_test.go

+12-11
Original file line numberDiff line numberDiff line change
@@ -89,17 +89,17 @@ func TestSimulatedBackend(t *testing.T) {
8989

9090
var testKey, _ = crypto.HexToECDSA("b71c71a67e1177ad4e901695e1b4b9ee17ae16c6668d313eac2f96dbcda3f291")
9191

92-
// the following is based on this contract:
93-
// contract T {
94-
// event received(address sender, uint amount, bytes memo);
95-
// event receivedAddr(address sender);
92+
// the following is based on this contract:
93+
// contract T {
94+
// event received(address sender, uint amount, bytes memo);
95+
// event receivedAddr(address sender);
9696
//
97-
// function receive(bytes calldata memo) external payable returns (string memory res) {
98-
// emit received(msg.sender, msg.value, memo);
99-
// emit receivedAddr(msg.sender);
100-
// return "hello world";
101-
// }
102-
// }
97+
// function receive(bytes calldata memo) external payable returns (string memory res) {
98+
// emit received(msg.sender, msg.value, memo);
99+
// emit receivedAddr(msg.sender);
100+
// return "hello world";
101+
// }
102+
// }
103103
const abiJSON = `[ { "constant": false, "inputs": [ { "name": "memo", "type": "bytes" } ], "name": "receive", "outputs": [ { "name": "res", "type": "string" } ], "payable": true, "stateMutability": "payable", "type": "function" }, { "anonymous": false, "inputs": [ { "indexed": false, "name": "sender", "type": "address" }, { "indexed": false, "name": "amount", "type": "uint256" }, { "indexed": false, "name": "memo", "type": "bytes" } ], "name": "received", "type": "event" }, { "anonymous": false, "inputs": [ { "indexed": false, "name": "sender", "type": "address" } ], "name": "receivedAddr", "type": "event" } ]`
104104
const abiBin = `0x608060405234801561001057600080fd5b506102a0806100206000396000f3fe60806040526004361061003b576000357c010000000000000000000000000000000000000000000000000000000090048063a69b6ed014610040575b600080fd5b6100b76004803603602081101561005657600080fd5b810190808035906020019064010000000081111561007357600080fd5b82018360208201111561008557600080fd5b803590602001918460018302840111640100000000831117156100a757600080fd5b9091929391929390505050610132565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156100f75780820151818401526020810190506100dc565b50505050905090810190601f1680156101245780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b60607f75fd880d39c1daf53b6547ab6cb59451fc6452d27caa90e5b6649dd8293b9eed33348585604051808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001848152602001806020018281038252848482818152602001925080828437600081840152601f19601f8201169050808301925050509550505050505060405180910390a17f46923992397eac56cf13058aced2a1871933622717e27b24eabc13bf9dd329c833604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390a16040805190810160405280600b81526020017f68656c6c6f20776f726c6400000000000000000000000000000000000000000081525090509291505056fea165627a7a72305820ff0c57dad254cfeda48c9cfb47f1353a558bccb4d1bc31da1dae69315772d29e0029`
105105
const deployedCode = `60806040526004361061003b576000357c010000000000000000000000000000000000000000000000000000000090048063a69b6ed014610040575b600080fd5b6100b76004803603602081101561005657600080fd5b810190808035906020019064010000000081111561007357600080fd5b82018360208201111561008557600080fd5b803590602001918460018302840111640100000000831117156100a757600080fd5b9091929391929390505050610132565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156100f75780820151818401526020810190506100dc565b50505050905090810190601f1680156101245780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b60607f75fd880d39c1daf53b6547ab6cb59451fc6452d27caa90e5b6649dd8293b9eed33348585604051808573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001848152602001806020018281038252848482818152602001925080828437600081840152601f19601f8201169050808301925050509550505050505060405180910390a17f46923992397eac56cf13058aced2a1871933622717e27b24eabc13bf9dd329c833604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390a16040805190810160405280600b81526020017f68656c6c6f20776f726c6400000000000000000000000000000000000000000081525090509291505056fea165627a7a72305820ff0c57dad254cfeda48c9cfb47f1353a558bccb4d1bc31da1dae69315772d29e0029`
@@ -951,7 +951,8 @@ func TestSimulatedBackend_CodeAt(t *testing.T) {
951951
}
952952

953953
// When receive("X") is called with sender 0x00... and value 1, it produces this tx receipt:
954-
// receipt{status=1 cgas=23949 bloom=00000000004000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000040200000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 logs=[log: b6818c8064f645cd82d99b59a1a267d6d61117ef [75fd880d39c1daf53b6547ab6cb59451fc6452d27caa90e5b6649dd8293b9eed] 000000000000000000000000376c47978271565f56deb45495afa69e59c16ab200000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000060000000000000000000000000000000000000000000000000000000000000000158 9ae378b6d4409eada347a5dc0c180f186cb62dc68fcc0f043425eb917335aa28 0 95d429d309bb9d753954195fe2d69bd140b4ae731b9b5b605c34323de162cf00 0]}
954+
//
955+
// receipt{status=1 cgas=23949 bloom=00000000004000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000040200000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 logs=[log: b6818c8064f645cd82d99b59a1a267d6d61117ef [75fd880d39c1daf53b6547ab6cb59451fc6452d27caa90e5b6649dd8293b9eed] 000000000000000000000000376c47978271565f56deb45495afa69e59c16ab200000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000060000000000000000000000000000000000000000000000000000000000000000158 9ae378b6d4409eada347a5dc0c180f186cb62dc68fcc0f043425eb917335aa28 0 95d429d309bb9d753954195fe2d69bd140b4ae731b9b5b605c34323de162cf00 0]}
955956
func TestSimulatedBackend_PendingAndCallContract(t *testing.T) {
956957
testAddr := crypto.PubkeyToAddress(testKey.PublicKey)
957958
sim := simTestBackend(testAddr)

accounts/abi/reflect.go

+14-8
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,13 @@ import (
2828
// given type
2929
// e.g. turn
3030
// var fields []reflect.StructField
31-
// fields = append(fields, reflect.StructField{
32-
// Name: "X",
33-
// Type: reflect.TypeOf(new(big.Int)),
34-
// Tag: reflect.StructTag("json:\"" + "x" + "\""),
35-
// }
31+
//
32+
// fields = append(fields, reflect.StructField{
33+
// Name: "X",
34+
// Type: reflect.TypeOf(new(big.Int)),
35+
// Tag: reflect.StructTag("json:\"" + "x" + "\""),
36+
// }
37+
//
3638
// into
3739
// type TupleT struct { X *big.Int }
3840
func ConvertType(in interface{}, proto interface{}) interface{} {
@@ -178,10 +180,14 @@ func setStruct(dst, src reflect.Value) error {
178180

179181
// mapArgNamesToStructFields maps a slice of argument names to struct fields.
180182
// first round: for each Exportable field that contains a `abi:""` tag
181-
// and this field name exists in the given argument name list, pair them together.
183+
//
184+
// and this field name exists in the given argument name list, pair them together.
185+
//
182186
// second round: for each argument name that has not been already linked,
183-
// find what variable is expected to be mapped into, if it exists and has not been
184-
// used, pair them.
187+
//
188+
// find what variable is expected to be mapped into, if it exists and has not been
189+
// used, pair them.
190+
//
185191
// Note this function assumes the given value is a struct value.
186192
func mapArgNamesToStructFields(argNames []string, value reflect.Value) (map[string]string, error) {
187193
typ := value.Type()

accounts/accounts.go

+4-2
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,8 @@ type Backend interface {
177177
// safely used to calculate a signature from.
178178
//
179179
// The hash is calulcated as
180-
// keccak256("\x19Ethereum Signed Message:\n"${message length}${message}).
180+
//
181+
// keccak256("\x19Ethereum Signed Message:\n"${message length}${message}).
181182
//
182183
// This gives context to the signed message and prevents signing of transactions.
183184
func TextHash(data []byte) []byte {
@@ -189,7 +190,8 @@ func TextHash(data []byte) []byte {
189190
// safely used to calculate a signature from.
190191
//
191192
// The hash is calulcated as
192-
// keccak256("\x19Ethereum Signed Message:\n"${message length}${message}).
193+
//
194+
// keccak256("\x19Ethereum Signed Message:\n"${message length}${message}).
193195
//
194196
// This gives context to the signed message and prevents signing of transactions.
195197
func TextAndHash(data []byte) ([]byte, string) {

accounts/hd.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ var LegacyLedgerBaseDerivationPath = DerivationPath{0x80000000 + 44, 0x80000000
4646
// The BIP-32 spec https://github.com/bitcoin/bips/blob/master/bip-0032.mediawiki
4747
// defines derivation paths to be of the form:
4848
//
49-
// m / purpose' / coin_type' / account' / change / address_index
49+
// m / purpose' / coin_type' / account' / change / address_index
5050
//
5151
// The BIP-44 spec https://github.com/bitcoin/bips/blob/master/bip-0044.mediawiki
5252
// defines that the `purpose` be 44' (or 0x8000002C) for crypto currencies, and

accounts/keystore/watch.go

+1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
// You should have received a copy of the GNU Lesser General Public License
1515
// along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.
1616

17+
//go:build (darwin && !ios && cgo) || freebsd || (linux && !arm64) || netbsd || solaris
1718
// +build darwin,!ios,cgo freebsd linux,!arm64 netbsd solaris
1819

1920
package keystore

accounts/keystore/watch_fallback.go

+1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
// You should have received a copy of the GNU Lesser General Public License
1515
// along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.
1616

17+
//go:build (darwin && !cgo) || ios || (linux && arm64) || windows || (!darwin && !freebsd && !linux && !netbsd && !solaris)
1718
// +build darwin,!cgo ios linux,arm64 windows !darwin,!freebsd,!linux,!netbsd,!solaris
1819

1920
// This is the fallback implementation of directory watching.

accounts/scwallet/wallet.go

+3
Original file line numberDiff line numberDiff line change
@@ -879,6 +879,7 @@ func (s *Session) walletStatus() (*walletStatus, error) {
879879
}
880880

881881
// derivationPath fetches the wallet's current derivation path from the card.
882+
//
882883
//lint:ignore U1000 needs to be added to the console interface
883884
func (s *Session) derivationPath() (accounts.DerivationPath, error) {
884885
response, err := s.Channel.transmitEncrypted(claSCWallet, insStatus, statusP1Path, 0, nil)
@@ -994,13 +995,15 @@ func (s *Session) derive(path accounts.DerivationPath) (accounts.Account, error)
994995
}
995996

996997
// keyExport contains information on an exported keypair.
998+
//
997999
//lint:ignore U1000 needs to be added to the console interface
9981000
type keyExport struct {
9991001
PublicKey []byte `asn1:"tag:0"`
10001002
PrivateKey []byte `asn1:"tag:1,optional"`
10011003
}
10021004

10031005
// publicKey returns the public key for the current derivation path.
1006+
//
10041007
//lint:ignore U1000 needs to be added to the console interface
10051008
func (s *Session) publicKey() ([]byte, error) {
10061009
response, err := s.Channel.transmitEncrypted(claSCWallet, insExportKey, exportP1Any, exportP2Pubkey, nil)

accounts/url.go

+3-4
Original file line numberDiff line numberDiff line change
@@ -92,10 +92,9 @@ func (u *URL) UnmarshalJSON(input []byte) error {
9292

9393
// Cmp compares x and y and returns:
9494
//
95-
// -1 if x < y
96-
// 0 if x == y
97-
// +1 if x > y
98-
//
95+
// -1 if x < y
96+
// 0 if x == y
97+
// +1 if x > y
9998
func (u URL) Cmp(url URL) int {
10099
if u.Scheme == url.Scheme {
101100
return strings.Compare(u.Path, url.Path)

0 commit comments

Comments
 (0)