account/abi: remove superfluous type checking (#21022)

* accounts/abi: added getType func to Type struct

* accounts/abi: fixed tuple unpack

* accounts/abi: removed type.Type

* accounts/abi: added comment

* accounts/abi: removed unused types

* accounts/abi: removed superfluous declarations

* accounts/abi: typo
This commit is contained in:
Marius van der Wijden
2020-05-05 16:30:43 +02:00
committed by GitHub
parent 44a3b8c04c
commit 933acf3389
7 changed files with 148 additions and 153 deletions

View File

@ -39,11 +39,11 @@ func formatSliceString(kind reflect.Kind, sliceSize int) string {
// type in t.
func sliceTypeCheck(t Type, val reflect.Value) error {
if val.Kind() != reflect.Slice && val.Kind() != reflect.Array {
return typeErr(formatSliceString(t.Type.Kind(), t.Size), val.Type())
return typeErr(formatSliceString(t.getType().Kind(), t.Size), val.Type())
}
if t.T == ArrayTy && val.Len() != t.Size {
return typeErr(formatSliceString(t.Elem.Type.Kind(), t.Size), formatSliceString(val.Type().Elem().Kind(), val.Len()))
return typeErr(formatSliceString(t.Elem.getType().Kind(), t.Size), formatSliceString(val.Type().Elem().Kind(), val.Len()))
}
if t.Elem.T == SliceTy || t.Elem.T == ArrayTy {
@ -52,8 +52,8 @@ func sliceTypeCheck(t Type, val reflect.Value) error {
}
}
if elemKind := val.Type().Elem().Kind(); elemKind != t.Elem.Type.Kind() {
return typeErr(formatSliceString(t.Elem.Type.Kind(), t.Size), val.Type())
if elemKind := val.Type().Elem().Kind(); elemKind != t.Elem.getType().Kind() {
return typeErr(formatSliceString(t.Elem.getType().Kind(), t.Size), val.Type())
}
return nil
}
@ -66,10 +66,10 @@ func typeCheck(t Type, value reflect.Value) error {
}
// Check base type validity. Element types will be checked later on.
if t.Type.Kind() != value.Kind() {
return typeErr(t.Type.Kind(), value.Kind())
if t.getType().Kind() != value.Kind() {
return typeErr(t.getType().Kind(), value.Kind())
} else if t.T == FixedBytesTy && t.Size != value.Len() {
return typeErr(t.Type, value.Type())
return typeErr(t.getType(), value.Type())
} else {
return nil
}