mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-27 23:26:44 +00:00
accounts/abi: begin redo
Signed-off-by: RJ Catalano <rj@monax.io>
This commit is contained in:
parent
a0083e913a
commit
59b55e0652
2 changed files with 9 additions and 5 deletions
|
|
@ -93,6 +93,10 @@ func (abi ABI) Unpack(v interface{}, name string, output []byte) error {
|
||||||
return fmt.Errorf("abi: unmarshalling empty output")
|
return fmt.Errorf("abi: unmarshalling empty output")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if len(output)%32 != 0 {
|
||||||
|
return nil, fmt.Errorf("abi: improperly formatted output")
|
||||||
|
}
|
||||||
|
|
||||||
// make sure the passed value is a pointer
|
// make sure the passed value is a pointer
|
||||||
valueOf := reflect.ValueOf(v)
|
valueOf := reflect.ValueOf(v)
|
||||||
if reflect.Ptr != valueOf.Kind() {
|
if reflect.Ptr != valueOf.Kind() {
|
||||||
|
|
|
||||||
|
|
@ -98,10 +98,11 @@ func toGoSlice(i int, t Argument, output []byte) (interface{}, error) {
|
||||||
case FixedBytesTy:
|
case FixedBytesTy:
|
||||||
inter = returnOutput
|
inter = returnOutput
|
||||||
case SliceTy, ArrayTy:
|
case SliceTy, ArrayTy:
|
||||||
inter, err = toGoSlice(i+index/32, t, output)
|
fmt.Println("Index: ", i+index/32)
|
||||||
|
/*inter, err = toGoSlice(i+index/32, t, output)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}*/
|
||||||
default:
|
default:
|
||||||
return nil, fmt.Errorf("abi: unsupported slice type passed in")
|
return nil, fmt.Errorf("abi: unsupported slice type passed in")
|
||||||
}
|
}
|
||||||
|
|
@ -163,9 +164,6 @@ func readBool(word []byte) (bool, error) {
|
||||||
// toGoType parses the input and casts it to the proper type defined by the ABI
|
// toGoType parses the input and casts it to the proper type defined by the ABI
|
||||||
// argument in T.
|
// argument in T.
|
||||||
func toGoType(i int, t Argument, output []byte) (interface{}, error) {
|
func toGoType(i int, t Argument, output []byte) (interface{}, error) {
|
||||||
if len(output)%32 != 0 {
|
|
||||||
return nil, fmt.Errorf("abi: improperly formatted output")
|
|
||||||
}
|
|
||||||
// we need to treat slices differently
|
// we need to treat slices differently
|
||||||
if (t.Type.IsSlice || t.Type.IsArray) && t.Type.T != BytesTy && t.Type.T != StringTy && t.Type.T != FixedBytesTy && t.Type.T != FunctionTy {
|
if (t.Type.IsSlice || t.Type.IsArray) && t.Type.T != BytesTy && t.Type.T != StringTy && t.Type.T != FixedBytesTy && t.Type.T != FunctionTy {
|
||||||
return toGoSlice(i, t, output)
|
return toGoSlice(i, t, output)
|
||||||
|
|
@ -215,3 +213,5 @@ func toGoType(i int, t Argument, output []byte) (interface{}, error) {
|
||||||
}
|
}
|
||||||
return nil, fmt.Errorf("abi: unknown type %v", t.Type.T)
|
return nil, fmt.Errorf("abi: unknown type %v", t.Type.T)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// this needs a near complete redo
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue