forked from TrueCloudLab/frostfs-node
[#932] adm: Rename util
to helper
To avoid conflicts with `util` packages in other imports. Signed-off-by: Anton Nikiforov <an.nikiforov@yadro.com>
This commit is contained in:
parent
e2cee4cf09
commit
802192cfef
34 changed files with 144 additions and 144 deletions
|
@ -9,7 +9,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"
|
||||
"git.frostfs.info/TrueCloudLab/frostfs-node/cmd/frostfs-adm/internal/modules/morph/helper"
|
||||
morphClient "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/morph/client"
|
||||
"github.com/nspcc-dev/neo-go/pkg/encoding/address"
|
||||
io2 "github.com/nspcc-dev/neo-go/pkg/io"
|
||||
|
@ -25,19 +25,19 @@ import (
|
|||
var errMissingNNSRecord = errors.New("missing NNS record")
|
||||
|
||||
func updateContracts(cmd *cobra.Command, _ []string) error {
|
||||
wCtx, err := morphUtil.NewInitializeContext(cmd, viper.GetViper())
|
||||
wCtx, err := helper.NewInitializeContext(cmd, viper.GetViper())
|
||||
if err != nil {
|
||||
return fmt.Errorf("initialization error: %w", err)
|
||||
}
|
||||
|
||||
if err := morphUtil.DeployNNS(wCtx, constants.UpdateMethodName); err != nil {
|
||||
if err := helper.DeployNNS(wCtx, constants.UpdateMethodName); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return updateContractsInternal(wCtx)
|
||||
}
|
||||
|
||||
func updateContractsInternal(c *morphUtil.InitializeContext) error {
|
||||
func updateContractsInternal(c *helper.InitializeContext) error {
|
||||
alphaCs := c.GetContract(constants.AlphabetContract)
|
||||
|
||||
nnsCs, err := c.NNSContractState()
|
||||
|
@ -90,14 +90,14 @@ func updateContractsInternal(c *morphUtil.InitializeContext) error {
|
|||
return c.AwaitTx()
|
||||
}
|
||||
|
||||
func deployAlphabetAccounts(c *morphUtil.InitializeContext, nnsHash neoUtil.Uint160, w *io2.BufBinWriter, alphaCs *morphUtil.ContractState) ([]any, error) {
|
||||
func deployAlphabetAccounts(c *helper.InitializeContext, nnsHash neoUtil.Uint160, w *io2.BufBinWriter, alphaCs *helper.ContractState) ([]any, error) {
|
||||
var keysParam []any
|
||||
|
||||
baseGroups := alphaCs.Manifest.Groups
|
||||
|
||||
// alphabet contracts should be deployed by individual nodes to get different hashes.
|
||||
for i, acc := range c.Accounts {
|
||||
ctrHash, err := morphUtil.NNSResolveHash(c.ReadOnlyInvoker, nnsHash, morphUtil.GetAlphabetNNSDomain(i))
|
||||
ctrHash, err := helper.NNSResolveHash(c.ReadOnlyInvoker, nnsHash, helper.GetAlphabetNNSDomain(i))
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("can't resolve hash for contract update: %w", err)
|
||||
}
|
||||
|
@ -108,7 +108,7 @@ func deployAlphabetAccounts(c *morphUtil.InitializeContext, nnsHash neoUtil.Uint
|
|||
emit.Array(w.BinWriter, params...)
|
||||
|
||||
alphaCs.Manifest.Groups = baseGroups
|
||||
err = morphUtil.AddManifestGroup(c.ContractWallet, ctrHash, alphaCs)
|
||||
err = helper.AddManifestGroup(c.ContractWallet, ctrHash, alphaCs)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("can't sign manifest group: %v", err)
|
||||
}
|
||||
|
@ -129,7 +129,7 @@ func deployAlphabetAccounts(c *morphUtil.InitializeContext, nnsHash neoUtil.Uint
|
|||
return keysParam, nil
|
||||
}
|
||||
|
||||
func deployOrUpdateContracts(c *morphUtil.InitializeContext, w *io2.BufBinWriter, nnsHash neoUtil.Uint160, keysParam []any) error {
|
||||
func deployOrUpdateContracts(c *helper.InitializeContext, w *io2.BufBinWriter, nnsHash neoUtil.Uint160, keysParam []any) error {
|
||||
emit.Instruction(w.BinWriter, opcode.INITSSLOT, []byte{1})
|
||||
emit.AppCall(w.BinWriter, nnsHash, "getPrice", callflag.All)
|
||||
emit.Opcodes(w.BinWriter, opcode.STSFLD0)
|
||||
|
@ -139,7 +139,7 @@ func deployOrUpdateContracts(c *morphUtil.InitializeContext, w *io2.BufBinWriter
|
|||
cs := c.GetContract(ctrName)
|
||||
|
||||
method := constants.UpdateMethodName
|
||||
ctrHash, err := morphUtil.NNSResolveHash(c.ReadOnlyInvoker, nnsHash, morphUtil.DomainOf(ctrName))
|
||||
ctrHash, err := helper.NNSResolveHash(c.ReadOnlyInvoker, nnsHash, helper.DomainOf(ctrName))
|
||||
if err != nil {
|
||||
if errors.Is(err, errMissingNNSRecord) {
|
||||
// if contract not found we deploy it instead of update
|
||||
|
@ -149,7 +149,7 @@ func deployOrUpdateContracts(c *morphUtil.InitializeContext, w *io2.BufBinWriter
|
|||
}
|
||||
}
|
||||
|
||||
err = morphUtil.AddManifestGroup(c.ContractWallet, ctrHash, cs)
|
||||
err = helper.AddManifestGroup(c.ContractWallet, ctrHash, cs)
|
||||
if err != nil {
|
||||
return fmt.Errorf("can't sign manifest group: %v", err)
|
||||
}
|
||||
|
@ -159,11 +159,11 @@ func deployOrUpdateContracts(c *morphUtil.InitializeContext, w *io2.BufBinWriter
|
|||
invokeHash = ctrHash
|
||||
}
|
||||
|
||||
args, err := morphUtil.GetContractDeployData(c, ctrName, keysParam, constants.UpdateMethodName)
|
||||
args, err := helper.GetContractDeployData(c, ctrName, keysParam, constants.UpdateMethodName)
|
||||
if err != nil {
|
||||
return fmt.Errorf("%s: getting update params: %v", ctrName, err)
|
||||
}
|
||||
params := morphUtil.GetContractDeployParameters(cs, args)
|
||||
params := helper.GetContractDeployParameters(cs, args)
|
||||
res, err := c.CommitteeAct.MakeCall(invokeHash, method, params...)
|
||||
if err != nil {
|
||||
if method != constants.UpdateMethodName || !strings.Contains(err.Error(), common.ErrAlreadyUpdated) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue