mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-20 10:52:25 +00:00
Add StateMutability ABI parameters to check if const or not
This commit is contained in:
parent
3bb6815fc1
commit
4fcca64cbd
1 changed files with 9 additions and 7 deletions
|
|
@ -108,12 +108,13 @@ func (abi ABI) UnpackIntoMap(v map[string]interface{}, name string, data []byte)
|
||||||
// UnmarshalJSON implements json.Unmarshaler interface
|
// UnmarshalJSON implements json.Unmarshaler interface
|
||||||
func (abi *ABI) UnmarshalJSON(data []byte) error {
|
func (abi *ABI) UnmarshalJSON(data []byte) error {
|
||||||
var fields []struct {
|
var fields []struct {
|
||||||
Type string
|
Type string
|
||||||
Name string
|
Name string
|
||||||
Constant bool
|
Constant bool
|
||||||
Anonymous bool
|
StateMutability string
|
||||||
Inputs []Argument
|
Anonymous bool
|
||||||
Outputs []Argument
|
Inputs []Argument
|
||||||
|
Outputs []Argument
|
||||||
}
|
}
|
||||||
if err := json.Unmarshal(data, &fields); err != nil {
|
if err := json.Unmarshal(data, &fields); err != nil {
|
||||||
return err
|
return err
|
||||||
|
|
@ -134,10 +135,11 @@ func (abi *ABI) UnmarshalJSON(data []byte) error {
|
||||||
name = fmt.Sprintf("%s%d", field.Name, idx)
|
name = fmt.Sprintf("%s%d", field.Name, idx)
|
||||||
_, ok = abi.Methods[name]
|
_, ok = abi.Methods[name]
|
||||||
}
|
}
|
||||||
|
isConst := field.Constant || field.StateMutability == "pure" || field.StateMutability == "view"
|
||||||
abi.Methods[name] = Method{
|
abi.Methods[name] = Method{
|
||||||
Name: name,
|
Name: name,
|
||||||
RawName: field.Name,
|
RawName: field.Name,
|
||||||
Const: field.Constant,
|
Const: isConst,
|
||||||
Inputs: field.Inputs,
|
Inputs: field.Inputs,
|
||||||
Outputs: field.Outputs,
|
Outputs: field.Outputs,
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue