From 6bde76e1535ae624a393ffe40a566b6548f3db5b Mon Sep 17 00:00:00 2001 From: Daniel Liu Date: Wed, 8 Jan 2025 21:20:34 +0800 Subject: [PATCH] accounts/abi: eplace strings.Replace with string.ReplaceAll (#24835) --- accounts/abi/bind/bind.go | 2 +- accounts/abi/bind/template.go | 2 +- accounts/abi/type.go | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/accounts/abi/bind/bind.go b/accounts/abi/bind/bind.go index c8ef5d0cfd96..21bbccc224ad 100644 --- a/accounts/abi/bind/bind.go +++ b/accounts/abi/bind/bind.go @@ -172,7 +172,7 @@ func Bind(types []string, abis []string, bytecodes []string, fsigs []map[string] contracts[types[i]] = &tmplContract{ Type: capitalise(types[i]), - InputABI: strings.Replace(strippedABI, "\"", "\\\"", -1), + InputABI: strings.ReplaceAll(strippedABI, "\"", "\\\""), InputBin: strings.TrimPrefix(strings.TrimSpace(bytecodes[i]), "0x"), Constructor: evmABI.Constructor, Calls: calls, diff --git a/accounts/abi/bind/template.go b/accounts/abi/bind/template.go index e3f031ade0e9..c1c041f2346f 100644 --- a/accounts/abi/bind/template.go +++ b/accounts/abi/bind/template.go @@ -160,7 +160,7 @@ var ( } {{range $pattern, $name := .Libraries}} {{decapitalise $name}}Addr, _, _, _ := Deploy{{capitalise $name}}(auth, backend) - {{$contract.Type}}Bin = strings.Replace({{$contract.Type}}Bin, "__${{$pattern}}$__", {{decapitalise $name}}Addr.String()[2:], -1) + {{$contract.Type}}Bin = strings.ReplaceAll({{$contract.Type}}Bin, "__${{$pattern}}$__", {{decapitalise $name}}Addr.String()[2:]) {{end}} address, tx, contract, err := bind.DeployContract(auth, *parsed, common.FromHex({{.Type}}Bin), backend {{range .Constructor.Inputs}}, {{.Name}}{{end}}) if err != nil { diff --git a/accounts/abi/type.go b/accounts/abi/type.go index 95b985f303cd..60a790cc2bc6 100644 --- a/accounts/abi/type.go +++ b/accounts/abi/type.go @@ -200,7 +200,7 @@ func NewType(t string, internalType string, components []ArgumentMarshaling) (ty if internalType != "" && strings.HasPrefix(internalType, structPrefix) { // Foo.Bar type definition is not allowed in golang, // convert the format to FooBar - typ.TupleRawName = strings.Replace(internalType[len(structPrefix):], ".", "", -1) + typ.TupleRawName = strings.ReplaceAll(internalType[len(structPrefix):], ".", "") } case "function":