From 870421e950c8bbb41a40ac79c5f62bd3499098b4 Mon Sep 17 00:00:00 2001 From: Ekaterina Pavlova Date: Thu, 28 Nov 2024 15:52:05 +0300 Subject: [PATCH] cli: add check config field for `generate-rpcwrapper` Close #3646 Signed-off-by: Ekaterina Pavlova --- cli/smartcontract/generate.go | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/cli/smartcontract/generate.go b/cli/smartcontract/generate.go index 03a2803caa..be79a088c8 100644 --- a/cli/smartcontract/generate.go +++ b/cli/smartcontract/generate.go @@ -1,6 +1,7 @@ package smartcontract import ( + "bytes" "fmt" "os" "strings" @@ -17,7 +18,8 @@ var generatorFlags = []cli.Flag{ &cli.StringFlag{ Name: "config", Aliases: []string{"c"}, - Usage: "Configuration file to use", + Usage: `Configuration bindings file to use (*.yml). Configuration file is + generated by 'contract compile' command with --bindings flag`, }, &cli.StringFlag{ Name: "manifest", @@ -95,7 +97,10 @@ func contractGenerateSomething(ctx *cli.Context, cb func(binding.Config) error) if err != nil { return cli.Exit(fmt.Errorf("can't read config file: %w", err), 1) } - err = yaml.Unmarshal(bs, &cfg) + decoder := yaml.NewDecoder(bytes.NewReader(bs)) + decoder.KnownFields(true) + + err = decoder.Decode(&cfg) if err != nil { return cli.Exit(fmt.Errorf("can't parse config file: %w", err), 1) }