accounts/abi: Fix method overwritten by same name methods.

This commit is contained in:
sf 2018-06-28 20:51:29 +08:00 committed by Guillaume Ballet
parent f7cdea2bdc
commit 52a6ec8d40

View file

@ -21,6 +21,7 @@ import (
"encoding/json"
"fmt"
"io"
"strconv"
"github.com/ethereum/go-ethereum/common"
)
@ -128,6 +129,7 @@ func (abi *ABI) UnmarshalJSON(data []byte) error {
abi.Methods = make(map[string]Method)
abi.Events = make(map[string]Event)
functionCnt, eventCnt := 0, 0
for _, field := range fields {
switch field.Type {
case "constructor":
@ -142,12 +144,16 @@ func (abi *ABI) UnmarshalJSON(data []byte) error {
Inputs: field.Inputs,
Outputs: field.Outputs,
}
abi.Methods[field.Name+strconv.Itoa(functionCnt)] = abi.Methods[field.Name]
functionCnt++
case "event":
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++
}
}