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")
|
||||
}
|
||||
|
||||
if len(output)%32 != 0 {
|
||||
return nil, fmt.Errorf("abi: improperly formatted output")
|
||||
}
|
||||
|
||||
// make sure the passed value is a pointer
|
||||
valueOf := reflect.ValueOf(v)
|
||||
if reflect.Ptr != valueOf.Kind() {
|
||||
|
|
|
|||
|
|
@ -98,10 +98,11 @@ func toGoSlice(i int, t Argument, output []byte) (interface{}, error) {
|
|||
case FixedBytesTy:
|
||||
inter = returnOutput
|
||||
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 {
|
||||
return nil, err
|
||||
}
|
||||
}*/
|
||||
default:
|
||||
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
|
||||
// argument in T.
|
||||
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
|
||||
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)
|
||||
|
|
@ -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)
|
||||
}
|
||||
|
||||
// this needs a near complete redo
|
||||
|
|
|
|||
Loading…
Reference in a new issue