mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-10 06:54:26 +00:00
## Why this should be merged The current rlpgen partially supports named types with basic underlying, and it generates the rlp without correct conversion i.e: `w.WriteUint64(obj.Uint64NewT)` This PR adds the full support it ## How this works Adds check for `isNamedWithBasicUnderlying` and then returns a `op` with `makeNamedBasicOp` which is basically a `basicOp` but with the `typ` refers to the named type so that it can correctly encode decode with the named type. ## How this was tested Added UT tests --------- Signed-off-by: Ceyhun Onur <ceyhunonur54@gmail.com>
49 lines
931 B
Text
49 lines
931 B
Text
package test
|
|
|
|
import "github.com/ava-labs/libevm/rlp"
|
|
import "io"
|
|
|
|
func (obj *Test) EncodeRLP(_w io.Writer) error {
|
|
w := rlp.NewEncoderBuffer(_w)
|
|
_tmp0 := w.List()
|
|
w.WriteBool(bool(obj.BoolNewT))
|
|
w.WriteUint64(uint64(obj.Uint64NewT))
|
|
w.WriteString(string(obj.StringNewT))
|
|
w.ListEnd(_tmp0)
|
|
return w.Flush()
|
|
}
|
|
|
|
func (obj *Test) DecodeRLP(dec *rlp.Stream) error {
|
|
var _tmp0 Test
|
|
{
|
|
if _, err := dec.List(); err != nil {
|
|
return err
|
|
}
|
|
// BoolNewT:
|
|
_tmp1, err := dec.Bool()
|
|
if err != nil {
|
|
return err
|
|
}
|
|
_tmp2 := BoolT(_tmp1)
|
|
_tmp0.BoolNewT = _tmp2
|
|
// Uint64NewT:
|
|
_tmp3, err := dec.Uint64()
|
|
if err != nil {
|
|
return err
|
|
}
|
|
_tmp4 := Uint64T(_tmp3)
|
|
_tmp0.Uint64NewT = _tmp4
|
|
// StringNewT:
|
|
_tmp5, err := dec.String()
|
|
if err != nil {
|
|
return err
|
|
}
|
|
_tmp6 := StringT(_tmp5)
|
|
_tmp0.StringNewT = _tmp6
|
|
if err := dec.ListEnd(); err != nil {
|
|
return err
|
|
}
|
|
}
|
|
*obj = _tmp0
|
|
return nil
|
|
}
|