From 4fcca64cbd440ab30630638c69522666e08572f8 Mon Sep 17 00:00:00 2001 From: 6l20 Date: Wed, 25 Dec 2019 17:01:16 +0100 Subject: [PATCH] Add StateMutability ABI parameters to check if const or not --- accounts/abi/abi.go | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/accounts/abi/abi.go b/accounts/abi/abi.go index 603e956b9d..fdb4c48b39 100644 --- a/accounts/abi/abi.go +++ b/accounts/abi/abi.go @@ -108,12 +108,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 { return err @@ -134,10 +135,11 @@ 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, RawName: field.Name, - Const: field.Constant, + Const: isConst, Inputs: field.Inputs, Outputs: field.Outputs, }