mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-27 15:16:43 +00:00
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:
parent
e4dce0b131
commit
886b51c976
4 changed files with 16 additions and 12 deletions
|
|
@ -17,13 +17,10 @@
|
||||||
package abi
|
package abi
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/binary"
|
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"math/big"
|
|
||||||
"reflect"
|
"reflect"
|
||||||
"strings"
|
|
||||||
|
|
||||||
"github.com/ethereum/go-ethereum/common"
|
"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 {
|
if method, ok := abi.Methods[name]; ok {
|
||||||
err = method.unpack(v, output)
|
err = method.unpack(v, output)
|
||||||
} else if event, ok := abi.Events[name]; ok {
|
} 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 {
|
} else {
|
||||||
err = fmt.Errorf("abi: could not find requested method or event %v", name)
|
err = fmt.Errorf("abi: could not find requested method or event %v", name)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,7 @@ import (
|
||||||
// separates byte slice into a slice of 32 byte slices.
|
// separates byte slice into a slice of 32 byte slices.
|
||||||
func chunkBytes(output []byte) (chunked [][32]byte) {
|
func chunkBytes(output []byte) (chunked [][32]byte) {
|
||||||
for i, j := 0, 0; i < len(output); i, j = i+32, j+1 {
|
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
|
return
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -29,6 +29,7 @@ const (
|
||||||
BoolTy
|
BoolTy
|
||||||
StringTy
|
StringTy
|
||||||
SliceTy
|
SliceTy
|
||||||
|
//StructTy
|
||||||
AddressTy
|
AddressTy
|
||||||
FixedBytesTy
|
FixedBytesTy
|
||||||
BytesTy
|
BytesTy
|
||||||
|
|
@ -39,15 +40,19 @@ const (
|
||||||
|
|
||||||
// Type is the reflection of the supported argument type
|
// Type is the reflection of the supported argument type
|
||||||
type Type struct {
|
type Type struct {
|
||||||
IsSlice, IsArray bool
|
// Slice descriptions
|
||||||
SliceSize int
|
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
|
Elem *Type
|
||||||
|
|
||||||
Kind reflect.Kind
|
Kind reflect.Kind // corresponding go Kind.
|
||||||
Type reflect.Type
|
Type reflect.Type // corresponding go Type.
|
||||||
Size int
|
Size int // type size (denotes uint256, uint248, etc.)
|
||||||
T byte // Our own type checking
|
T byte // Our own type checking
|
||||||
|
|
||||||
stringKind string // holds the unparsed string for deriving signatures
|
stringKind string // holds the unparsed string for deriving signatures
|
||||||
}
|
}
|
||||||
|
|
@ -65,7 +70,7 @@ var (
|
||||||
// string int uint fixed
|
// string int uint fixed
|
||||||
// string32 int8 uint8 uint[]
|
// string32 int8 uint8 uint[]
|
||||||
// address int256 uint256 fixed128x128[2]
|
// 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 parses the abi sub types
|
||||||
typeRegex = regexp.MustCompile("([a-zA-Z]+)(([0-9]+)(x([0-9]+))?)?")
|
typeRegex = regexp.MustCompile("([a-zA-Z]+)(([0-9]+)(x([0-9]+))?)?")
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@ package abi
|
||||||
import (
|
import (
|
||||||
"encoding/binary"
|
"encoding/binary"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"math/big"
|
||||||
"reflect"
|
"reflect"
|
||||||
|
|
||||||
"github.com/ethereum/go-ethereum/common"
|
"github.com/ethereum/go-ethereum/common"
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue