From adcae12331893cb853a46848d2df9ef51f9ac9a0 Mon Sep 17 00:00:00 2001 From: Evgeniy Stratonikov Date: Mon, 2 Aug 2021 13:47:19 +0300 Subject: [PATCH] cli/smartcontract: reuse read functions in `contractDeploy` Signed-off-by: Evgeniy Stratonikov --- cli/smartcontract/smart_contract.go | 23 ++--------------------- 1 file changed, 2 insertions(+), 21 deletions(-) diff --git a/cli/smartcontract/smart_contract.go b/cli/smartcontract/smart_contract.go index 0c9cd6770..dc7ac6512 100644 --- a/cli/smartcontract/smart_contract.go +++ b/cli/smartcontract/smart_contract.go @@ -810,34 +810,15 @@ func getUnlockedAccount(wall *wallet.Wallet, addr util.Uint160) (*wallet.Account // contractDeploy deploys contract. func contractDeploy(ctx *cli.Context) error { - in := ctx.String("in") - if len(in) == 0 { - return cli.NewExitError(errNoInput, 1) - } - manifestFile := ctx.String("manifest") - if len(manifestFile) == 0 { - return cli.NewExitError(errNoManifestFile, 1) - } - - f, err := ioutil.ReadFile(in) + nefFile, f, err := readNEFFile(ctx.String("in")) if err != nil { return cli.NewExitError(err, 1) } - // Check the file. - nefFile, err := nef.FileFromBytes(f) - if err != nil { - return cli.NewExitError(fmt.Errorf("failed to read .nef file: %w", err), 1) - } - manifestBytes, err := ioutil.ReadFile(manifestFile) + m, manifestBytes, err := readManifest(ctx.String("manifest")) if err != nil { return cli.NewExitError(fmt.Errorf("failed to read manifest file: %w", err), 1) } - m := &manifest.Manifest{} - err = json.Unmarshal(manifestBytes, m) - if err != nil { - return cli.NewExitError(fmt.Errorf("failed to restore manifest file: %w", err), 1) - } appCallParams := []smartcontract.Parameter{ {