[#932] adm: Move const
to package constants
Signed-off-by: Anton Nikiforov <an.nikiforov@yadro.com>
This commit is contained in:
parent
814c411f4a
commit
e2cee4cf09
29 changed files with 140 additions and 114 deletions
|
@ -8,6 +8,7 @@ import (
|
|||
|
||||
"git.frostfs.info/TrueCloudLab/frostfs-contract/common"
|
||||
"git.frostfs.info/TrueCloudLab/frostfs-contract/nns"
|
||||
"git.frostfs.info/TrueCloudLab/frostfs-node/cmd/frostfs-adm/internal/modules/morph/constants"
|
||||
morphUtil "git.frostfs.info/TrueCloudLab/frostfs-node/cmd/frostfs-adm/internal/modules/morph/util"
|
||||
morphClient "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/morph/client"
|
||||
"github.com/nspcc-dev/neo-go/pkg/encoding/address"
|
||||
|
@ -29,7 +30,7 @@ func updateContracts(cmd *cobra.Command, _ []string) error {
|
|||
return fmt.Errorf("initialization error: %w", err)
|
||||
}
|
||||
|
||||
if err := morphUtil.DeployNNS(wCtx, morphUtil.UpdateMethodName); err != nil {
|
||||
if err := morphUtil.DeployNNS(wCtx, constants.UpdateMethodName); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
|
@ -37,7 +38,7 @@ func updateContracts(cmd *cobra.Command, _ []string) error {
|
|||
}
|
||||
|
||||
func updateContractsInternal(c *morphUtil.InitializeContext) error {
|
||||
alphaCs := c.GetContract(morphUtil.AlphabetContract)
|
||||
alphaCs := c.GetContract(constants.AlphabetContract)
|
||||
|
||||
nnsCs, err := c.NNSContractState()
|
||||
if err != nil {
|
||||
|
@ -116,7 +117,7 @@ func deployAlphabetAccounts(c *morphUtil.InitializeContext, nnsHash neoUtil.Uint
|
|||
emit.Opcodes(w.BinWriter, opcode.LDSFLD0)
|
||||
emit.Int(w.BinWriter, 3)
|
||||
emit.Opcodes(w.BinWriter, opcode.PACK)
|
||||
emit.AppCallNoArgs(w.BinWriter, ctrHash, morphUtil.UpdateMethodName, callflag.All)
|
||||
emit.AppCallNoArgs(w.BinWriter, ctrHash, constants.UpdateMethodName, callflag.All)
|
||||
}
|
||||
if err := c.SendCommitteeTx(w.Bytes(), false); err != nil {
|
||||
if !strings.Contains(err.Error(), common.ErrAlreadyUpdated) {
|
||||
|
@ -134,15 +135,15 @@ func deployOrUpdateContracts(c *morphUtil.InitializeContext, w *io2.BufBinWriter
|
|||
emit.Opcodes(w.BinWriter, opcode.STSFLD0)
|
||||
emit.AppCall(w.BinWriter, nnsHash, "setPrice", callflag.All, 1)
|
||||
|
||||
for _, ctrName := range morphUtil.ContractList {
|
||||
for _, ctrName := range constants.ContractList {
|
||||
cs := c.GetContract(ctrName)
|
||||
|
||||
method := morphUtil.UpdateMethodName
|
||||
method := constants.UpdateMethodName
|
||||
ctrHash, err := morphUtil.NNSResolveHash(c.ReadOnlyInvoker, nnsHash, morphUtil.DomainOf(ctrName))
|
||||
if err != nil {
|
||||
if errors.Is(err, errMissingNNSRecord) {
|
||||
// if contract not found we deploy it instead of update
|
||||
method = morphUtil.DeployMethodName
|
||||
method = constants.DeployMethodName
|
||||
} else {
|
||||
return fmt.Errorf("can't resolve hash for contract update: %w", err)
|
||||
}
|
||||
|
@ -154,18 +155,18 @@ func deployOrUpdateContracts(c *morphUtil.InitializeContext, w *io2.BufBinWriter
|
|||
}
|
||||
|
||||
invokeHash := management.Hash
|
||||
if method == morphUtil.UpdateMethodName {
|
||||
if method == constants.UpdateMethodName {
|
||||
invokeHash = ctrHash
|
||||
}
|
||||
|
||||
args, err := morphUtil.GetContractDeployData(c, ctrName, keysParam, morphUtil.UpdateMethodName)
|
||||
args, err := morphUtil.GetContractDeployData(c, ctrName, keysParam, constants.UpdateMethodName)
|
||||
if err != nil {
|
||||
return fmt.Errorf("%s: getting update params: %v", ctrName, err)
|
||||
}
|
||||
params := morphUtil.GetContractDeployParameters(cs, args)
|
||||
res, err := c.CommitteeAct.MakeCall(invokeHash, method, params...)
|
||||
if err != nil {
|
||||
if method != morphUtil.UpdateMethodName || !strings.Contains(err.Error(), common.ErrAlreadyUpdated) {
|
||||
if method != constants.UpdateMethodName || !strings.Contains(err.Error(), common.ErrAlreadyUpdated) {
|
||||
return fmt.Errorf("deploy contract: %w", err)
|
||||
}
|
||||
c.Command.Printf("%s contract is already updated.\n", ctrName)
|
||||
|
@ -174,7 +175,7 @@ func deployOrUpdateContracts(c *morphUtil.InitializeContext, w *io2.BufBinWriter
|
|||
|
||||
w.WriteBytes(res.Script)
|
||||
|
||||
if method == morphUtil.DeployMethodName {
|
||||
if method == constants.DeployMethodName {
|
||||
// same actions are done in InitializeContext.setNNS, can be unified
|
||||
domain := ctrName + ".frostfs"
|
||||
script, ok, err := c.NNSRegisterDomainScript(nnsHash, cs.Hash, domain)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue