forked from TrueCloudLab/frostfs-node
[#835] neofs-adm: rename contract update method
Signed-off-by: Evgenii Stratonikov <evgeniy@nspcc.ru>
This commit is contained in:
parent
f2a61451b7
commit
4ccb3d05d8
2 changed files with 9 additions and 7 deletions
|
@ -66,6 +66,8 @@ type contractState struct {
|
||||||
Hash util.Uint160
|
Hash util.Uint160
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const updateMethodName = "update"
|
||||||
|
|
||||||
func (c *initializeContext) deployNNS(method string) error {
|
func (c *initializeContext) deployNNS(method string) error {
|
||||||
cs, err := c.readContract(nnsContract)
|
cs, err := c.readContract(nnsContract)
|
||||||
if err != nil {
|
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.
|
// alphabet contracts should be deployed by individual nodes to get different hashes.
|
||||||
for i, acc := range c.Accounts {
|
for i, acc := range c.Accounts {
|
||||||
ctrHash := state.CreateContractHash(acc.Contract.ScriptHash(), alphaCs.NEF.Checksum, alphaCs.Manifest.Name)
|
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)
|
c.Command.Printf("Alphabet contract #%d is already deployed.\n", i)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
invokeHash := mgmtHash
|
invokeHash := mgmtHash
|
||||||
if method == "migrate" {
|
if method == updateMethodName {
|
||||||
invokeHash, err = nnsResolveHash(c.Client, nnsHash, getAlphabetNNSDomain(i))
|
invokeHash, err = nnsResolveHash(c.Client, nnsHash, getAlphabetNNSDomain(i))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("can't resolve hash for contract update: %w", err)
|
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(),
|
Account: acc.Contract.ScriptHash(),
|
||||||
Scopes: transaction.CalledByEntry,
|
Scopes: transaction.CalledByEntry,
|
||||||
}
|
}
|
||||||
if method == "migrate" {
|
if method == updateMethodName {
|
||||||
signer = transaction.Signer{
|
signer = transaction.Signer{
|
||||||
Account: c.CommitteeAcc.Contract.ScriptHash(),
|
Account: c.CommitteeAcc.Contract.ScriptHash(),
|
||||||
Scopes: transaction.CalledByEntry,
|
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)
|
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 {
|
if err := c.sendCommitteeTx(res.Script, res.GasConsumed); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -204,13 +206,13 @@ func (c *initializeContext) deployContracts(method string) error {
|
||||||
|
|
||||||
for _, ctrName := range contractList {
|
for _, ctrName := range contractList {
|
||||||
cs := c.Contracts[ctrName]
|
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)
|
c.Command.Printf("%s contract is already deployed.\n", ctrName)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
invokeHash := mgmtHash
|
invokeHash := mgmtHash
|
||||||
if method == "migrate" {
|
if method == updateMethodName {
|
||||||
invokeHash, err = nnsResolveHash(c.Client, nnsHash, ctrName+".neofs")
|
invokeHash, err = nnsResolveHash(c.Client, nnsHash, ctrName+".neofs")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("can't resolve hash for contract update: %w", err)
|
return fmt.Errorf("can't resolve hash for contract update: %w", err)
|
||||||
|
|
|
@ -13,7 +13,7 @@ func updateContracts(cmd *cobra.Command, _ []string) error {
|
||||||
return fmt.Errorf("initialization error: %w", err)
|
return fmt.Errorf("initialization error: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := wCtx.deployContracts("migrate"); err != nil {
|
if err := wCtx.deployContracts(updateMethodName); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue