From aaad19f2a4e0273788085d6619bb9a6ecb524be9 Mon Sep 17 00:00:00 2001 From: sf Date: Thu, 28 Jun 2018 22:23:20 +0800 Subject: [PATCH] accounts/abi: Fix method overwritten by same name methods. --- accounts/abi/abi.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/accounts/abi/abi.go b/accounts/abi/abi.go index 93c44a7ce3..bfa402f84a 100644 --- a/accounts/abi/abi.go +++ b/accounts/abi/abi.go @@ -138,21 +138,27 @@ func (abi *ABI) UnmarshalJSON(data []byte) error { } // empty defaults to function according to the abi spec case "function", "": + _, ok := abi.Methods[field.Name] + if ok { + abi.Methods[field.Name+strconv.Itoa(functionCnt)] = abi.Methods[field.Name] + } abi.Methods[field.Name] = Method{ Name: field.Name, Const: field.Constant, Inputs: field.Inputs, Outputs: field.Outputs, } - abi.Methods[field.Name+strconv.Itoa(functionCnt)] = abi.Methods[field.Name] functionCnt++ case "event": + _, ok := abi.Events[field.Name] + if ok { + abi.Events[field.Name+strconv.Itoa(eventCnt)] = abi.Events[field.Name] + } abi.Events[field.Name] = Event{ Name: field.Name, Anonymous: field.Anonymous, Inputs: field.Inputs, } - abi.Events[field.Name+strconv.Itoa(eventCnt)] = abi.Events[field.Name] eventCnt++ } }