@@ -31,40 +31,40 @@ import (
31
31
32
32
const jsondata = `
33
33
[
34
- { "type" : "function", "name" : "balance", "constant " : true },
35
- { "type" : "function", "name" : "send", "constant" : false, " inputs" : [ { "name" : "amount", "type" : "uint256" } ] }
34
+ { "type" : "function", "name" : "balance", "stateMutability " : "view" },
35
+ { "type" : "function", "name" : "send", "inputs" : [ { "name" : "amount", "type" : "uint256" } ] }
36
36
]`
37
37
38
38
const jsondata2 = `
39
39
[
40
- { "type" : "function", "name" : "balance", "constant " : true },
41
- { "type" : "function", "name" : "send", "constant" : false, " inputs" : [ { "name" : "amount", "type" : "uint256" } ] },
42
- { "type" : "function", "name" : "test", "constant" : false, " inputs" : [ { "name" : "number", "type" : "uint32" } ] },
43
- { "type" : "function", "name" : "string", "constant" : false, " inputs" : [ { "name" : "inputs", "type" : "string" } ] },
44
- { "type" : "function", "name" : "bool", "constant" : false, " inputs" : [ { "name" : "inputs", "type" : "bool" } ] },
45
- { "type" : "function", "name" : "address", "constant" : false, " inputs" : [ { "name" : "inputs", "type" : "address" } ] },
46
- { "type" : "function", "name" : "uint64[2]", "constant" : false, " inputs" : [ { "name" : "inputs", "type" : "uint64[2]" } ] },
47
- { "type" : "function", "name" : "uint64[]", "constant" : false, " inputs" : [ { "name" : "inputs", "type" : "uint64[]" } ] },
48
- { "type" : "function", "name" : "foo", "constant" : false, " inputs" : [ { "name" : "inputs", "type" : "uint32" } ] },
49
- { "type" : "function", "name" : "bar", "constant" : false, " inputs" : [ { "name" : "inputs", "type" : "uint32" }, { "name" : "string", "type" : "uint16" } ] },
50
- { "type" : "function", "name" : "slice", "constant" : false, " inputs" : [ { "name" : "inputs", "type" : "uint32[2]" } ] },
51
- { "type" : "function", "name" : "slice256", "constant" : false, " inputs" : [ { "name" : "inputs", "type" : "uint256[2]" } ] },
52
- { "type" : "function", "name" : "sliceAddress", "constant" : false, " inputs" : [ { "name" : "inputs", "type" : "address[]" } ] },
53
- { "type" : "function", "name" : "sliceMultiAddress", "constant" : false, " inputs" : [ { "name" : "a", "type" : "address[]" }, { "name" : "b", "type" : "address[]" } ] },
54
- { "type" : "function", "name" : "nestedArray", "constant" : false, " inputs" : [ { "name" : "a", "type" : "uint256[2][2]" }, { "name" : "b", "type" : "address[]" } ] },
55
- { "type" : "function", "name" : "nestedArray2", "constant" : false, " inputs" : [ { "name" : "a", "type" : "uint8[][2]" } ] },
56
- { "type" : "function", "name" : "nestedSlice", "constant" : false, " inputs" : [ { "name" : "a", "type" : "uint8[][]" } ] }
40
+ { "type" : "function", "name" : "balance", "stateMutability " : "view" },
41
+ { "type" : "function", "name" : "send", "inputs" : [ { "name" : "amount", "type" : "uint256" } ] },
42
+ { "type" : "function", "name" : "test", "inputs" : [ { "name" : "number", "type" : "uint32" } ] },
43
+ { "type" : "function", "name" : "string", "inputs" : [ { "name" : "inputs", "type" : "string" } ] },
44
+ { "type" : "function", "name" : "bool", "inputs" : [ { "name" : "inputs", "type" : "bool" } ] },
45
+ { "type" : "function", "name" : "address", "inputs" : [ { "name" : "inputs", "type" : "address" } ] },
46
+ { "type" : "function", "name" : "uint64[2]", "inputs" : [ { "name" : "inputs", "type" : "uint64[2]" } ] },
47
+ { "type" : "function", "name" : "uint64[]", "inputs" : [ { "name" : "inputs", "type" : "uint64[]" } ] },
48
+ { "type" : "function", "name" : "foo", "inputs" : [ { "name" : "inputs", "type" : "uint32" } ] },
49
+ { "type" : "function", "name" : "bar", "inputs" : [ { "name" : "inputs", "type" : "uint32" }, { "name" : "string", "type" : "uint16" } ] },
50
+ { "type" : "function", "name" : "slice", "inputs" : [ { "name" : "inputs", "type" : "uint32[2]" } ] },
51
+ { "type" : "function", "name" : "slice256", "inputs" : [ { "name" : "inputs", "type" : "uint256[2]" } ] },
52
+ { "type" : "function", "name" : "sliceAddress", "inputs" : [ { "name" : "inputs", "type" : "address[]" } ] },
53
+ { "type" : "function", "name" : "sliceMultiAddress", "inputs" : [ { "name" : "a", "type" : "address[]" }, { "name" : "b", "type" : "address[]" } ] },
54
+ { "type" : "function", "name" : "nestedArray", "inputs" : [ { "name" : "a", "type" : "uint256[2][2]" }, { "name" : "b", "type" : "address[]" } ] },
55
+ { "type" : "function", "name" : "nestedArray2", "inputs" : [ { "name" : "a", "type" : "uint8[][2]" } ] },
56
+ { "type" : "function", "name" : "nestedSlice", "inputs" : [ { "name" : "a", "type" : "uint8[][]" } ] }
57
57
]`
58
58
59
59
func TestReader (t * testing.T ) {
60
60
Uint256 , _ := NewType ("uint256" , "" , nil )
61
61
exp := ABI {
62
62
Methods : map [string ]Method {
63
63
"balance" : {
64
- "balance" , "balance" , true , nil , nil ,
64
+ "balance" , "balance" , "view" , false , false , false , false , nil , nil ,
65
65
},
66
66
"send" : {
67
- "send" , "send" , false , []Argument {
67
+ "send" , "send" , "" , false , false , false , false , []Argument {
68
68
{"amount" , Uint256 , false },
69
69
}, nil ,
70
70
},
@@ -173,7 +173,7 @@ func TestTestSlice(t *testing.T) {
173
173
174
174
func TestMethodSignature (t * testing.T ) {
175
175
String , _ := NewType ("string" , "" , nil )
176
- m := Method {"foo" , "foo" , false , []Argument {{"bar" , String , false }, {"baz" , String , false }}, nil }
176
+ m := Method {"foo" , "foo" , "" , false , false , false , false , []Argument {{"bar" , String , false }, {"baz" , String , false }}, nil }
177
177
exp := "foo(string,string)"
178
178
if m .Sig () != exp {
179
179
t .Error ("signature mismatch" , exp , "!=" , m .Sig ())
@@ -185,7 +185,7 @@ func TestMethodSignature(t *testing.T) {
185
185
}
186
186
187
187
uintt , _ := NewType ("uint256" , "" , nil )
188
- m = Method {"foo" , "foo" , false , []Argument {{"bar" , uintt , false }}, nil }
188
+ m = Method {"foo" , "foo" , "" , false , false , false , false , []Argument {{"bar" , uintt , false }}, nil }
189
189
exp = "foo(uint256)"
190
190
if m .Sig () != exp {
191
191
t .Error ("signature mismatch" , exp , "!=" , m .Sig ())
@@ -204,7 +204,7 @@ func TestMethodSignature(t *testing.T) {
204
204
{Name : "y" , Type : "int256" },
205
205
}},
206
206
})
207
- m = Method {"foo" , "foo" , false , []Argument {{"s" , s , false }, {"bar" , String , false }}, nil }
207
+ m = Method {"foo" , "foo" , "" , false , false , false , false , []Argument {{"s" , s , false }, {"bar" , String , false }}, nil }
208
208
exp = "foo((int256,int256[],(int256,int256)[],(int256,int256)[2]),string)"
209
209
if m .Sig () != exp {
210
210
t .Error ("signature mismatch" , exp , "!=" , m .Sig ())
@@ -582,7 +582,7 @@ func TestInputFixedArrayAndVariableInputLength(t *testing.T) {
582
582
}
583
583
584
584
func TestDefaultFunctionParsing (t * testing.T ) {
585
- const definition = `[{ "name" : "balance" }]`
585
+ const definition = `[{ "name" : "balance", "type" : "function" }]`
586
586
587
587
abi , err := JSON (strings .NewReader (definition ))
588
588
if err != nil {
0 commit comments