accounts/abi: ABI explicit difference between Unpack and UnpackIntoInterface (#21091)
* accounts/abi: refactored abi.Unpack * accounts/abi/bind: fixed error * accounts/abi/bind: modified template * accounts/abi/bind: added ToStruct for conversion * accounts/abi: reenabled tests * accounts/abi: fixed tests * accounts/abi: fixed tests for packing/unpacking * accounts/abi: fixed tests * accounts/abi: added more logic to ToStruct * accounts/abi/bind: fixed template * accounts/abi/bind: fixed ToStruct conversion * accounts/abi/: removed unused code * accounts/abi: updated template * accounts/abi: refactored unused code * contracts/checkpointoracle: updated contracts to sol ^0.6.0 * accounts/abi: refactored reflection logic * accounts/abi: less code duplication in Unpack* * accounts/abi: fixed rebasing bug * fix a few typos in comments * rebase on master Co-authored-by: Guillaume Ballet <gballet@gmail.com>
This commit is contained in:
committed by
GitHub
parent
c9959145a9
commit
420b78659b
@ -30,7 +30,7 @@ import (
|
||||
|
||||
func unpackPack(abi abi.ABI, method string, inputType []interface{}, input []byte) bool {
|
||||
outptr := reflect.New(reflect.TypeOf(inputType))
|
||||
if err := abi.Unpack(outptr.Interface(), method, input); err == nil {
|
||||
if err := abi.UnpackIntoInterface(outptr.Interface(), method, input); err == nil {
|
||||
output, err := abi.Pack(method, input)
|
||||
if err != nil {
|
||||
// We have some false positives as we can unpack these type successfully, but not pack them
|
||||
@ -51,7 +51,7 @@ func unpackPack(abi abi.ABI, method string, inputType []interface{}, input []byt
|
||||
func packUnpack(abi abi.ABI, method string, input []interface{}) bool {
|
||||
if packed, err := abi.Pack(method, input); err == nil {
|
||||
outptr := reflect.New(reflect.TypeOf(input))
|
||||
err := abi.Unpack(outptr.Interface(), method, packed)
|
||||
err := abi.UnpackIntoInterface(outptr.Interface(), method, packed)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
Reference in New Issue
Block a user