Skip to content

Commit

Permalink
Merge pull request ethereum#31 from maticnetwork/abi-fix
Browse files Browse the repository at this point in the history
fix abigen to create pure/view methods
  • Loading branch information
jdkanani authored Mar 19, 2020
2 parents 4748248 + 4e6427d commit 9e2f108
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions accounts/abi/abi.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,12 +114,13 @@ func (abi ABI) UnpackIntoMap(v map[string]interface{}, name string, data []byte)
// UnmarshalJSON implements json.Unmarshaler interface
func (abi *ABI) UnmarshalJSON(data []byte) error {
var fields []struct {
Type string
Name string
Constant bool
Anonymous bool
Inputs []Argument
Outputs []Argument
Type string
Name string
Constant bool
StateMutability string
Anonymous bool
Inputs []Argument
Outputs []Argument
}

if err := json.Unmarshal(data, &fields); err != nil {
Expand All @@ -142,9 +143,10 @@ func (abi *ABI) UnmarshalJSON(data []byte) error {
name = fmt.Sprintf("%s%d", field.Name, idx)
_, ok = abi.Methods[name]
}
isConst := field.Constant || field.StateMutability == "pure" || field.StateMutability == "view"
abi.Methods[name] = Method{
Name: name,
Const: field.Constant,
Const: isConst,
Inputs: field.Inputs,
Outputs: field.Outputs,
}
Expand Down

0 comments on commit 9e2f108

Please sign in to comment.