diff --git a/cmd/neofs-adm/internal/modules/morph/initialize.go b/cmd/neofs-adm/internal/modules/morph/initialize.go index 6f2912280..1ca762ff8 100644 --- a/cmd/neofs-adm/internal/modules/morph/initialize.go +++ b/cmd/neofs-adm/internal/modules/morph/initialize.go @@ -57,7 +57,7 @@ func initializeSideChainCmd(cmd *cobra.Command, args []string) error { // 3. Deploy NNS contract. cmd.Println("Stage 3: deploy NNS contract.") - if err := initCtx.deployNNS(); err != nil { + if err := initCtx.deployNNS("deploy"); err != nil { return err } diff --git a/cmd/neofs-adm/internal/modules/morph/initialize_deploy.go b/cmd/neofs-adm/internal/modules/morph/initialize_deploy.go index 00e8a2190..f5fa2d004 100644 --- a/cmd/neofs-adm/internal/modules/morph/initialize_deploy.go +++ b/cmd/neofs-adm/internal/modules/morph/initialize_deploy.go @@ -66,25 +66,37 @@ type contractState struct { Hash util.Uint160 } -func (c *initializeContext) deployNNS() error { +func (c *initializeContext) deployNNS(method string) error { cs, err := c.readContract(nnsContract) if err != nil { return err } h := state.CreateContractHash(c.CommitteeAcc.Contract.ScriptHash(), cs.NEF.Checksum, cs.Manifest.Name) - if _, err := c.Client.GetContractStateByHash(h); err == nil { + if _, err := c.Client.GetContractStateByHash(h); err == nil && method != "update" { return nil } params := getContractDeployParameters(cs.RawNEF, cs.RawManifest, nil) + if method == "update" { + params = params[:len(params)-1] // update has only NEF and manifest args + } + signer := transaction.Signer{ Account: c.CommitteeAcc.Contract.ScriptHash(), Scopes: transaction.CalledByEntry, } mgmtHash := c.nativeHash(nativenames.Management) - res, err := c.Client.InvokeFunction(mgmtHash, "deploy", params, []transaction.Signer{signer}) + if method == "update" { + nnsCs, err := c.Client.GetContractStateByID(1) + if err != nil { + return fmt.Errorf("can't resolve NNS hash for contract update: %w", err) + } + mgmtHash = nnsCs.Hash + } + + res, err := c.Client.InvokeFunction(mgmtHash, method, params, []transaction.Signer{signer}) if err != nil { return fmt.Errorf("can't deploy NNS contract: %w", err) } diff --git a/cmd/neofs-adm/internal/modules/morph/update.go b/cmd/neofs-adm/internal/modules/morph/update.go index ad17544cf..86c01e7b2 100644 --- a/cmd/neofs-adm/internal/modules/morph/update.go +++ b/cmd/neofs-adm/internal/modules/morph/update.go @@ -17,5 +17,5 @@ func updateContracts(cmd *cobra.Command, _ []string) error { return err } - return wCtx.setNNS() + return wCtx.deployNNS("update") }