From 4ccb3d05d85cb2a916f04e076c876af2df59d28d Mon Sep 17 00:00:00 2001 From: Evgenii Stratonikov Date: Thu, 30 Sep 2021 18:11:35 +0300 Subject: [PATCH] [#835] neofs-adm: rename contract update method Signed-off-by: Evgenii Stratonikov --- .../internal/modules/morph/initialize_deploy.go | 14 ++++++++------ cmd/neofs-adm/internal/modules/morph/update.go | 2 +- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/cmd/neofs-adm/internal/modules/morph/initialize_deploy.go b/cmd/neofs-adm/internal/modules/morph/initialize_deploy.go index 14d21795..e982a9a7 100644 --- a/cmd/neofs-adm/internal/modules/morph/initialize_deploy.go +++ b/cmd/neofs-adm/internal/modules/morph/initialize_deploy.go @@ -66,6 +66,8 @@ type contractState struct { Hash util.Uint160 } +const updateMethodName = "update" + func (c *initializeContext) deployNNS(method string) error { cs, err := c.readContract(nnsContract) if err != nil { @@ -146,13 +148,13 @@ func (c *initializeContext) deployContracts(method string) error { // alphabet contracts should be deployed by individual nodes to get different hashes. for i, acc := range c.Accounts { ctrHash := state.CreateContractHash(acc.Contract.ScriptHash(), alphaCs.NEF.Checksum, alphaCs.Manifest.Name) - if _, err := c.Client.GetContractStateByHash(ctrHash); err == nil && method != "migrate" { + if _, err := c.Client.GetContractStateByHash(ctrHash); err == nil && method != updateMethodName { c.Command.Printf("Alphabet contract #%d is already deployed.\n", i) continue } invokeHash := mgmtHash - if method == "migrate" { + if method == updateMethodName { invokeHash, err = nnsResolveHash(c.Client, nnsHash, getAlphabetNNSDomain(i)) if err != nil { return fmt.Errorf("can't resolve hash for contract update: %w", err) @@ -170,7 +172,7 @@ func (c *initializeContext) deployContracts(method string) error { Account: acc.Contract.ScriptHash(), Scopes: transaction.CalledByEntry, } - if method == "migrate" { + if method == updateMethodName { signer = transaction.Signer{ Account: c.CommitteeAcc.Contract.ScriptHash(), Scopes: transaction.CalledByEntry, @@ -185,7 +187,7 @@ func (c *initializeContext) deployContracts(method string) error { return fmt.Errorf("can't deploy alpabet #%d contract: %s", i, res.FaultException) } - if method == "migrate" { + if method == updateMethodName { if err := c.sendCommitteeTx(res.Script, res.GasConsumed); err != nil { return err } @@ -204,13 +206,13 @@ func (c *initializeContext) deployContracts(method string) error { for _, ctrName := range contractList { cs := c.Contracts[ctrName] - if _, err := c.Client.GetContractStateByHash(cs.Hash); err == nil && method != "migrate" { + if _, err := c.Client.GetContractStateByHash(cs.Hash); err == nil && method != updateMethodName { c.Command.Printf("%s contract is already deployed.\n", ctrName) continue } invokeHash := mgmtHash - if method == "migrate" { + if method == updateMethodName { invokeHash, err = nnsResolveHash(c.Client, nnsHash, ctrName+".neofs") if err != nil { return fmt.Errorf("can't resolve hash for contract update: %w", err) diff --git a/cmd/neofs-adm/internal/modules/morph/update.go b/cmd/neofs-adm/internal/modules/morph/update.go index 86c01e7b..cdc9e6d6 100644 --- a/cmd/neofs-adm/internal/modules/morph/update.go +++ b/cmd/neofs-adm/internal/modules/morph/update.go @@ -13,7 +13,7 @@ func updateContracts(cmd *cobra.Command, _ []string) error { return fmt.Errorf("initialization error: %w", err) } - if err := wCtx.deployContracts("migrate"); err != nil { + if err := wCtx.deployContracts(updateMethodName); err != nil { return err }