@@ -31,40 +31,40 @@ import (
3131
3232const jsondata = `
3333[
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" } ] }
3636]`
3737
3838const jsondata2 = `
3939[
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[][]" } ] }
5757]`
5858
5959func TestReader (t * testing.T ) {
6060 Uint256 , _ := NewType ("uint256" , "" , nil )
6161 exp := ABI {
6262 Methods : map [string ]Method {
6363 "balance" : {
64- "balance" , "balance" , true , nil , nil ,
64+ "balance" , "balance" , "view" , false , false , false , false , nil , nil ,
6565 },
6666 "send" : {
67- "send" , "send" , false , []Argument {
67+ "send" , "send" , "" , false , false , false , false , []Argument {
6868 {"amount" , Uint256 , false },
6969 }, nil ,
7070 },
@@ -173,7 +173,7 @@ func TestTestSlice(t *testing.T) {
173173
174174func TestMethodSignature (t * testing.T ) {
175175 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 }
177177 exp := "foo(string,string)"
178178 if m .Sig () != exp {
179179 t .Error ("signature mismatch" , exp , "!=" , m .Sig ())
@@ -185,7 +185,7 @@ func TestMethodSignature(t *testing.T) {
185185 }
186186
187187 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 }
189189 exp = "foo(uint256)"
190190 if m .Sig () != exp {
191191 t .Error ("signature mismatch" , exp , "!=" , m .Sig ())
@@ -204,7 +204,7 @@ func TestMethodSignature(t *testing.T) {
204204 {Name : "y" , Type : "int256" },
205205 }},
206206 })
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 }
208208 exp = "foo((int256,int256[],(int256,int256)[],(int256,int256)[2]),string)"
209209 if m .Sig () != exp {
210210 t .Error ("signature mismatch" , exp , "!=" , m .Sig ())
@@ -582,7 +582,7 @@ func TestInputFixedArrayAndVariableInputLength(t *testing.T) {
582582}
583583
584584func TestDefaultFunctionParsing (t * testing.T ) {
585- const definition = `[{ "name" : "balance" }]`
585+ const definition = `[{ "name" : "balance", "type" : "function" }]`
586586
587587 abi , err := JSON (strings .NewReader (definition ))
588588 if err != nil {
0 commit comments