Merge pull request #2355 from karalabe/abi-constant-functions-2
accounts/abi: handle the "constant" modifier for functions
This commit is contained in:
commit
8b6ae6bf86
|
@ -270,7 +270,7 @@ func (abi *ABI) UnmarshalJSON(data []byte) error {
|
|||
var fields []struct {
|
||||
Type string
|
||||
Name string
|
||||
Const bool
|
||||
Constant bool
|
||||
Indexed bool
|
||||
Inputs []Argument
|
||||
Outputs []Argument
|
||||
|
@ -288,7 +288,7 @@ func (abi *ABI) UnmarshalJSON(data []byte) error {
|
|||
case "function", "":
|
||||
abi.Methods[field.Name] = Method{
|
||||
Name: field.Name,
|
||||
Const: field.Const,
|
||||
Const: field.Constant,
|
||||
Inputs: field.Inputs,
|
||||
Outputs: field.Outputs,
|
||||
}
|
||||
|
|
|
@ -67,8 +67,11 @@ func (m Method) String() string {
|
|||
}
|
||||
outputs[i] += output.Type.String()
|
||||
}
|
||||
|
||||
return fmt.Sprintf("function %v(%v) returns(%v)", m.Name, strings.Join(inputs, ", "), strings.Join(outputs, ", "))
|
||||
constant := ""
|
||||
if m.Const {
|
||||
constant = "constant "
|
||||
}
|
||||
return fmt.Sprintf("function %v(%v) %sreturns(%v)", m.Name, strings.Join(inputs, ", "), constant, strings.Join(outputs, ", "))
|
||||
}
|
||||
|
||||
func (m Method) Id() []byte {
|
||||
|
|
Loading…
Reference in New Issue