go-ethereum icon indicating copy to clipboard operation
go-ethereum copied to clipboard

accounts/abi: fix set function

Open zhiqiangxu opened this issue 2 years ago • 1 comments

Without this patch, this test will report abi: cannot unmarshal string in to string:

After this patch, the above test will pass.

After all, there's no point to call set on dst.Elem() if dst.Elem() can not be set (CanSet returns false)

zhiqiangxu avatar Aug 04 '22 12:08 zhiqiangxu

Could you please:

  • [x] Fix the geth test that this PR breaks
  • [x] Add a simpler test into this PR that reproduces the issue. The test you provided belongs to a different repository, and does way more things than needed to reproduce the issue.

Done. Basically now you can unpack a solidity string into both []interface{}{""} and []interface{}{new(string)}, previously you can only unpack it into []interface{}{new(string)}(the indirection is mandated,or you'll get an error like "abi: cannot unmarshal string in to string", which is technically unnecessary).

The same for other types like uint8 etc.

zhiqiangxu avatar Aug 04 '22 16:08 zhiqiangxu

@gballet lgty ?

holiman avatar Aug 18 '22 11:08 holiman