good morning!!!!
Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
B
bor
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Harbor Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
open
bor
Commits
89043cba
Unverified
Commit
89043cba
authored
4 years ago
by
Natsu Kagami
Committed by
GitHub
4 years ago
Browse files
Options
Downloads
Patches
Plain Diff
accounts/abi: make GetType public again (#21157)
parent
d5c267fd
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
accounts/abi/error.go
+7
-7
7 additions, 7 deletions
accounts/abi/error.go
accounts/abi/type.go
+5
-4
5 additions, 4 deletions
accounts/abi/type.go
accounts/abi/unpack.go
+4
-4
4 additions, 4 deletions
accounts/abi/unpack.go
with
16 additions
and
15 deletions
accounts/abi/error.go
+
7
−
7
View file @
89043cba
...
@@ -39,11 +39,11 @@ func formatSliceString(kind reflect.Kind, sliceSize int) string {
...
@@ -39,11 +39,11 @@ func formatSliceString(kind reflect.Kind, sliceSize int) string {
// type in t.
// type in t.
func
sliceTypeCheck
(
t
Type
,
val
reflect
.
Value
)
error
{
func
sliceTypeCheck
(
t
Type
,
val
reflect
.
Value
)
error
{
if
val
.
Kind
()
!=
reflect
.
Slice
&&
val
.
Kind
()
!=
reflect
.
Array
{
if
val
.
Kind
()
!=
reflect
.
Slice
&&
val
.
Kind
()
!=
reflect
.
Array
{
return
typeErr
(
formatSliceString
(
t
.
g
etType
()
.
Kind
(),
t
.
Size
),
val
.
Type
())
return
typeErr
(
formatSliceString
(
t
.
G
etType
()
.
Kind
(),
t
.
Size
),
val
.
Type
())
}
}
if
t
.
T
==
ArrayTy
&&
val
.
Len
()
!=
t
.
Size
{
if
t
.
T
==
ArrayTy
&&
val
.
Len
()
!=
t
.
Size
{
return
typeErr
(
formatSliceString
(
t
.
Elem
.
g
etType
()
.
Kind
(),
t
.
Size
),
formatSliceString
(
val
.
Type
()
.
Elem
()
.
Kind
(),
val
.
Len
()))
return
typeErr
(
formatSliceString
(
t
.
Elem
.
G
etType
()
.
Kind
(),
t
.
Size
),
formatSliceString
(
val
.
Type
()
.
Elem
()
.
Kind
(),
val
.
Len
()))
}
}
if
t
.
Elem
.
T
==
SliceTy
||
t
.
Elem
.
T
==
ArrayTy
{
if
t
.
Elem
.
T
==
SliceTy
||
t
.
Elem
.
T
==
ArrayTy
{
...
@@ -52,8 +52,8 @@ func sliceTypeCheck(t Type, val reflect.Value) error {
...
@@ -52,8 +52,8 @@ func sliceTypeCheck(t Type, val reflect.Value) error {
}
}
}
}
if
elemKind
:=
val
.
Type
()
.
Elem
()
.
Kind
();
elemKind
!=
t
.
Elem
.
g
etType
()
.
Kind
()
{
if
elemKind
:=
val
.
Type
()
.
Elem
()
.
Kind
();
elemKind
!=
t
.
Elem
.
G
etType
()
.
Kind
()
{
return
typeErr
(
formatSliceString
(
t
.
Elem
.
g
etType
()
.
Kind
(),
t
.
Size
),
val
.
Type
())
return
typeErr
(
formatSliceString
(
t
.
Elem
.
G
etType
()
.
Kind
(),
t
.
Size
),
val
.
Type
())
}
}
return
nil
return
nil
}
}
...
@@ -66,10 +66,10 @@ func typeCheck(t Type, value reflect.Value) error {
...
@@ -66,10 +66,10 @@ func typeCheck(t Type, value reflect.Value) error {
}
}
// Check base type validity. Element types will be checked later on.
// Check base type validity. Element types will be checked later on.
if
t
.
g
etType
()
.
Kind
()
!=
value
.
Kind
()
{
if
t
.
G
etType
()
.
Kind
()
!=
value
.
Kind
()
{
return
typeErr
(
t
.
g
etType
()
.
Kind
(),
value
.
Kind
())
return
typeErr
(
t
.
G
etType
()
.
Kind
(),
value
.
Kind
())
}
else
if
t
.
T
==
FixedBytesTy
&&
t
.
Size
!=
value
.
Len
()
{
}
else
if
t
.
T
==
FixedBytesTy
&&
t
.
Size
!=
value
.
Len
()
{
return
typeErr
(
t
.
g
etType
(),
value
.
Type
())
return
typeErr
(
t
.
G
etType
(),
value
.
Type
())
}
else
{
}
else
{
return
nil
return
nil
}
}
...
...
This diff is collapsed.
Click to expand it.
accounts/abi/type.go
+
5
−
4
View file @
89043cba
...
@@ -176,7 +176,7 @@ func NewType(t string, internalType string, components []ArgumentMarshaling) (ty
...
@@ -176,7 +176,7 @@ func NewType(t string, internalType string, components []ArgumentMarshaling) (ty
overloadedNames
[
fieldName
]
=
fieldName
overloadedNames
[
fieldName
]
=
fieldName
fields
=
append
(
fields
,
reflect
.
StructField
{
fields
=
append
(
fields
,
reflect
.
StructField
{
Name
:
fieldName
,
// reflect.StructOf will panic for any exported field.
Name
:
fieldName
,
// reflect.StructOf will panic for any exported field.
Type
:
cType
.
g
etType
(),
Type
:
cType
.
G
etType
(),
Tag
:
reflect
.
StructTag
(
"json:
\"
"
+
c
.
Name
+
"
\"
"
),
Tag
:
reflect
.
StructTag
(
"json:
\"
"
+
c
.
Name
+
"
\"
"
),
})
})
elems
=
append
(
elems
,
&
cType
)
elems
=
append
(
elems
,
&
cType
)
...
@@ -214,7 +214,8 @@ func NewType(t string, internalType string, components []ArgumentMarshaling) (ty
...
@@ -214,7 +214,8 @@ func NewType(t string, internalType string, components []ArgumentMarshaling) (ty
return
return
}
}
func
(
t
Type
)
getType
()
reflect
.
Type
{
// GetType returns the reflection type of the ABI type.
func
(
t
Type
)
GetType
()
reflect
.
Type
{
switch
t
.
T
{
switch
t
.
T
{
case
IntTy
:
case
IntTy
:
return
reflectIntType
(
false
,
t
.
Size
)
return
reflectIntType
(
false
,
t
.
Size
)
...
@@ -225,9 +226,9 @@ func (t Type) getType() reflect.Type {
...
@@ -225,9 +226,9 @@ func (t Type) getType() reflect.Type {
case
StringTy
:
case
StringTy
:
return
reflect
.
TypeOf
(
""
)
return
reflect
.
TypeOf
(
""
)
case
SliceTy
:
case
SliceTy
:
return
reflect
.
SliceOf
(
t
.
Elem
.
g
etType
())
return
reflect
.
SliceOf
(
t
.
Elem
.
G
etType
())
case
ArrayTy
:
case
ArrayTy
:
return
reflect
.
ArrayOf
(
t
.
Size
,
t
.
Elem
.
g
etType
())
return
reflect
.
ArrayOf
(
t
.
Size
,
t
.
Elem
.
G
etType
())
case
TupleTy
:
case
TupleTy
:
return
t
.
TupleType
return
t
.
TupleType
case
AddressTy
:
case
AddressTy
:
...
...
This diff is collapsed.
Click to expand it.
accounts/abi/unpack.go
+
4
−
4
View file @
89043cba
...
@@ -110,7 +110,7 @@ func ReadFixedBytes(t Type, word []byte) (interface{}, error) {
...
@@ -110,7 +110,7 @@ func ReadFixedBytes(t Type, word []byte) (interface{}, error) {
return
nil
,
fmt
.
Errorf
(
"abi: invalid type in call to make fixed byte array"
)
return
nil
,
fmt
.
Errorf
(
"abi: invalid type in call to make fixed byte array"
)
}
}
// convert
// convert
array
:=
reflect
.
New
(
t
.
g
etType
())
.
Elem
()
array
:=
reflect
.
New
(
t
.
G
etType
())
.
Elem
()
reflect
.
Copy
(
array
,
reflect
.
ValueOf
(
word
[
0
:
t
.
Size
]))
reflect
.
Copy
(
array
,
reflect
.
ValueOf
(
word
[
0
:
t
.
Size
]))
return
array
.
Interface
(),
nil
return
array
.
Interface
(),
nil
...
@@ -131,10 +131,10 @@ func forEachUnpack(t Type, output []byte, start, size int) (interface{}, error)
...
@@ -131,10 +131,10 @@ func forEachUnpack(t Type, output []byte, start, size int) (interface{}, error)
if
t
.
T
==
SliceTy
{
if
t
.
T
==
SliceTy
{
// declare our slice
// declare our slice
refSlice
=
reflect
.
MakeSlice
(
t
.
g
etType
(),
size
,
size
)
refSlice
=
reflect
.
MakeSlice
(
t
.
G
etType
(),
size
,
size
)
}
else
if
t
.
T
==
ArrayTy
{
}
else
if
t
.
T
==
ArrayTy
{
// declare our array
// declare our array
refSlice
=
reflect
.
New
(
t
.
g
etType
())
.
Elem
()
refSlice
=
reflect
.
New
(
t
.
G
etType
())
.
Elem
()
}
else
{
}
else
{
return
nil
,
fmt
.
Errorf
(
"abi: invalid type in array/slice unpacking stage"
)
return
nil
,
fmt
.
Errorf
(
"abi: invalid type in array/slice unpacking stage"
)
}
}
...
@@ -158,7 +158,7 @@ func forEachUnpack(t Type, output []byte, start, size int) (interface{}, error)
...
@@ -158,7 +158,7 @@ func forEachUnpack(t Type, output []byte, start, size int) (interface{}, error)
}
}
func
forTupleUnpack
(
t
Type
,
output
[]
byte
)
(
interface
{},
error
)
{
func
forTupleUnpack
(
t
Type
,
output
[]
byte
)
(
interface
{},
error
)
{
retval
:=
reflect
.
New
(
t
.
g
etType
())
.
Elem
()
retval
:=
reflect
.
New
(
t
.
G
etType
())
.
Elem
()
virtualArgs
:=
0
virtualArgs
:=
0
for
index
,
elem
:=
range
t
.
TupleElems
{
for
index
,
elem
:=
range
t
.
TupleElems
{
marshalledValue
,
err
:=
toGoType
((
index
+
virtualArgs
)
*
32
,
*
elem
,
output
)
marshalledValue
,
err
:=
toGoType
((
index
+
virtualArgs
)
*
32
,
*
elem
,
output
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment