From e105fa717e298ce5cb18929611c802538422c280 Mon Sep 17 00:00:00 2001 From: beer-1 Date: Fri, 23 Aug 2024 15:50:15 +0900 Subject: [PATCH] fix to check it at empty flag --- cmd/move/move.go | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/cmd/move/move.go b/cmd/move/move.go index 2cec99ef..6b6e142a 100644 --- a/cmd/move/move.go +++ b/cmd/move/move.go @@ -678,22 +678,24 @@ func getBuildConfig(cmd *cobra.Command) (*types.CompilerBuildConfig, error) { if err != nil { return nil, err } - namedAddressMap := make(map[string]types.AccountAddress) - for _, namedAddress := range strings.Split(namedAddresses, ",") { - v := strings.Split(namedAddress, "=") - if len(v) != 2 { - return nil, fmt.Errorf("invalid named-addresses: %s", namedAddresses) - } + if len(namedAddresses) > 0 { + namedAddressMap := make(map[string]types.AccountAddress) + for _, namedAddress := range strings.Split(namedAddresses, ",") { + v := strings.Split(namedAddress, "=") + if len(v) != 2 { + return nil, fmt.Errorf("invalid named-addresses: %s", namedAddresses) + } - name := v[0] - addr, err := types.NewAccountAddress(v[1]) // validate address - if err != nil { - return nil, fmt.Errorf("invalid address: %s", v[1]) - } + name := v[0] + addr, err := types.NewAccountAddress(v[1]) // validate address + if err != nil { + return nil, fmt.Errorf("invalid address: %s", v[1]) + } - namedAddressMap[name] = addr + namedAddressMap[name] = addr + } + options = append(options, buildtypes.WithNamedAddresses(namedAddressMap)) } - options = append(options, buildtypes.WithNamedAddresses(namedAddressMap)) bc := buildtypes.NewBuildConfig(options...)