aboutsummaryrefslogtreecommitdiffstats
path: root/accounts
diff options
context:
space:
mode:
authorPéter Szilágyi <peterke@gmail.com>2016-03-16 17:19:25 +0800
committerPéter Szilágyi <peterke@gmail.com>2016-03-16 17:24:16 +0800
commit270ea6eec330962d083fb66453cee563985114c2 (patch)
treeab961c903c234a8997e24defedd018f9b1157ede /accounts
parent2855a93ede6e9437d05a82c2397d48744621db9b (diff)
downloaddexon-270ea6eec330962d083fb66453cee563985114c2.tar.gz
dexon-270ea6eec330962d083fb66453cee563985114c2.tar.zst
dexon-270ea6eec330962d083fb66453cee563985114c2.zip
accounts/abi: handle the "constant" modifier for functions
Diffstat (limited to 'accounts')
-rw-r--r--accounts/abi/abi.go14
-rw-r--r--accounts/abi/method.go7
2 files changed, 12 insertions, 9 deletions
diff --git a/accounts/abi/abi.go b/accounts/abi/abi.go
index 324d3c76f..3704e6262 100644
--- a/accounts/abi/abi.go
+++ b/accounts/abi/abi.go
@@ -268,12 +268,12 @@ func set(dst, src reflect.Value, output Argument) error {
func (abi *ABI) UnmarshalJSON(data []byte) error {
var fields []struct {
- Type string
- Name string
- Const bool
- Indexed bool
- Inputs []Argument
- Outputs []Argument
+ Type string
+ Name string
+ Constant bool
+ Indexed bool
+ Inputs []Argument
+ Outputs []Argument
}
if err := json.Unmarshal(data, &fields); err != nil {
@@ -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,
}
diff --git a/accounts/abi/method.go b/accounts/abi/method.go
index e259c09aa..206c7d408 100644
--- a/accounts/abi/method.go
+++ b/accounts/abi/method.go
@@ -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 {