accounts/abi: various fixes throughout the package on the path to compilation.

Signed-off-by: RJ Catalano <rj@monax.io>
This commit is contained in:
RJ Catalano 2017-06-11 14:49:44 -05:00
parent e4dce0b131
commit 886b51c976
No known key found for this signature in database
GPG key ID: D4AB109D9B5D6386
4 changed files with 16 additions and 12 deletions

View file

@ -17,13 +17,10 @@
package abi
import (
"encoding/binary"
"encoding/json"
"fmt"
"io"
"math/big"
"reflect"
"strings"
"github.com/ethereum/go-ethereum/common"
)
@ -101,7 +98,8 @@ func (abi ABI) Unpack(v interface{}, name string, output []byte) (err error) {
if method, ok := abi.Methods[name]; ok {
err = method.unpack(v, output)
} else if event, ok := abi.Events[name]; ok {
err = event.unpackLog(v, output)
//err = event.unpackLog(v, output) // to create
err = fmt.Errorf("abi: could not find requested method or event %v", name)
} else {
err = fmt.Errorf("abi: could not find requested method or event %v", name)
}

View file

@ -24,7 +24,7 @@ import (
// separates byte slice into a slice of 32 byte slices.
func chunkBytes(output []byte) (chunked [][32]byte) {
for i, j := 0, 0; i < len(output); i, j = i+32, j+1 {
chunked[j] = output[i : i+32]
copy(chunked[j][:], output[i:i+32])
}
return
}

View file

@ -29,6 +29,7 @@ const (
BoolTy
StringTy
SliceTy
//StructTy
AddressTy
FixedBytesTy
BytesTy
@ -39,15 +40,19 @@ const (
// Type is the reflection of the supported argument type
type Type struct {
IsSlice, IsArray bool
SliceSize int
// Slice descriptions
IsArray bool //todo: change to IsStatic
IsSlice bool //todo: change to IsDynamic
IsDoublySliced bool //todo: find a better name
SliceSize int
// If applicable (struct, slice), the underlying type
Elem *Type
Kind reflect.Kind
Type reflect.Type
Size int
T byte // Our own type checking
Kind reflect.Kind // corresponding go Kind.
Type reflect.Type // corresponding go Type.
Size int // type size (denotes uint256, uint248, etc.)
T byte // Our own type checking
stringKind string // holds the unparsed string for deriving signatures
}
@ -65,7 +70,7 @@ var (
// string int uint fixed
// string32 int8 uint8 uint[]
// address int256 uint256 fixed128x128[2]
fullTypeRegex = regexp.MustCompile(`([a-zA-Z0-9]+)(\[([0-9]*)\])?`)
fullTypeRegex = regexp.MustCompile(`([a-zA-Z0-9]+)(\[([0-9]*)\])?(\[([0-9]*)\])?`)
// typeRegex parses the abi sub types
typeRegex = regexp.MustCompile("([a-zA-Z]+)(([0-9]+)(x([0-9]+))?)?")
)

View file

@ -3,6 +3,7 @@ package abi
import (
"encoding/binary"
"fmt"
"math/big"
"reflect"
"github.com/ethereum/go-ethereum/common"