accounts/abi: handle the "constant" modifier for functions
This commit is contained in:
parent
2855a93ede
commit
270ea6eec3
|
@ -268,12 +268,12 @@ func set(dst, src reflect.Value, output Argument) error {
|
||||||
|
|
||||||
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
|
||||||
Const bool
|
Constant bool
|
||||||
Indexed bool
|
Indexed bool
|
||||||
Inputs []Argument
|
Inputs []Argument
|
||||||
Outputs []Argument
|
Outputs []Argument
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := json.Unmarshal(data, &fields); err != nil {
|
if err := json.Unmarshal(data, &fields); err != nil {
|
||||||
|
@ -288,7 +288,7 @@ func (abi *ABI) UnmarshalJSON(data []byte) error {
|
||||||
case "function", "":
|
case "function", "":
|
||||||
abi.Methods[field.Name] = Method{
|
abi.Methods[field.Name] = Method{
|
||||||
Name: field.Name,
|
Name: field.Name,
|
||||||
Const: field.Const,
|
Const: field.Constant,
|
||||||
Inputs: field.Inputs,
|
Inputs: field.Inputs,
|
||||||
Outputs: field.Outputs,
|
Outputs: field.Outputs,
|
||||||
}
|
}
|
||||||
|
|
|
@ -67,8 +67,11 @@ func (m Method) String() string {
|
||||||
}
|
}
|
||||||
outputs[i] += output.Type.String()
|
outputs[i] += output.Type.String()
|
||||||
}
|
}
|
||||||
|
constant := ""
|
||||||
return fmt.Sprintf("function %v(%v) returns(%v)", m.Name, strings.Join(inputs, ", "), strings.Join(outputs, ", "))
|
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 {
|
func (m Method) Id() []byte {
|
||||||
|
|
Loading…
Reference in New Issue