From 0065dc7efe1201623692a04539c5100ec7fb15d1 Mon Sep 17 00:00:00 2001 From: beer-1 <147697694+beer-1@users.noreply.github.com> Date: Thu, 30 Nov 2023 11:29:27 +0900 Subject: [PATCH] fix to use serde not vmtypes serises --- x/move/client/cli/utils.go | 34 ++++++++++++++++++++++++++-------- 1 file changed, 26 insertions(+), 8 deletions(-) diff --git a/x/move/client/cli/utils.go b/x/move/client/cli/utils.go index b1c32a85..30ff2e53 100644 --- a/x/move/client/cli/utils.go +++ b/x/move/client/cli/utils.go @@ -12,7 +12,6 @@ import ( sdkmath "cosmossdk.io/math" "github.com/initia-labs/initia/x/move/types" - vmtypes "github.com/initia-labs/initiavm/types" "github.com/novifinancial/serde-reflection/serde-generate/runtime/golang/bcs" "github.com/novifinancial/serde-reflection/serde-generate/runtime/golang/serde" flag "github.com/spf13/pflag" @@ -66,7 +65,8 @@ func asciiDecodeString(s string) ([]byte, error) { func BcsSerializeArg(argType string, arg string, s serde.Serializer) ([]byte, error) { if arg == "" { - return vmtypes.SerializeBytes([]byte(arg)) + err := s.SerializeBytes([]byte(arg)) + return s.GetBytes(), err } switch argType { case "raw_hex": @@ -74,28 +74,46 @@ func BcsSerializeArg(argType string, arg string, s serde.Serializer) ([]byte, er if err != nil { return nil, err } - return vmtypes.SerializeBytes(decoded) + + err = s.SerializeBytes(decoded) + return s.GetBytes(), err case "raw_base64": decoded, err := base64.StdEncoding.DecodeString(arg) if err != nil { return nil, err } - return vmtypes.SerializeBytes(decoded) + + err = s.SerializeBytes(decoded) + return s.GetBytes(), err case "address", "object": accAddr, err := types.AccAddressFromString(arg) if err != nil { return nil, err } - return accAddr.BcsSerialize() + err = s.IncreaseContainerDepth() + if err != nil { + return nil, err + } + for _, item := range accAddr { + if err := s.SerializeU8(item); err != nil { + return nil, err + } + } + s.DecreaseContainerDepth() + + return s.GetBytes(), nil case "string": - return vmtypes.SerializeString(arg) + err := s.SerializeBytes([]byte(arg)) + return s.GetBytes(), err case "bool": if arg == "true" || arg == "True" { - return vmtypes.SerializeBool(true) + err := s.SerializeBool(true) + return s.GetBytes(), err } else if arg == "false" || arg == "False" { - return vmtypes.SerializeBool(false) + err := s.SerializeBool(false) + return s.GetBytes(), err } else { return nil, errors.New("unsupported bool value") }