From 2290109849e2b5d8c664dd7e9de69f96642cca2c Mon Sep 17 00:00:00 2001 From: Evgenii Stratonikov Date: Wed, 28 Jul 2021 17:42:07 +0300 Subject: [PATCH] [#726] neofs-adm: use `NNSIsAvailable` from neo-go There is no need in writing another wrapper. Signed-off-by: Evgenii Stratonikov --- .../internal/modules/morph/initialize_nns.go | 19 ++----------------- 1 file changed, 2 insertions(+), 17 deletions(-) diff --git a/cmd/neofs-adm/internal/modules/morph/initialize_nns.go b/cmd/neofs-adm/internal/modules/morph/initialize_nns.go index 51ab2f01..27d47279 100644 --- a/cmd/neofs-adm/internal/modules/morph/initialize_nns.go +++ b/cmd/neofs-adm/internal/modules/morph/initialize_nns.go @@ -59,7 +59,7 @@ func (c *initializeContext) setNNS() error { alphaCs.Hash = state.CreateContractHash(acc.Contract.ScriptHash(), alphaCs.NEF.Checksum, alphaCs.Manifest.Name) domain := getAlphabetNNSDomain(i) - if ok, err := c.nnsDomainAvailable(h, domain); err != nil { + if ok, err := c.Client.NNSIsAvailable(h, domain); err != nil { return err } else if !ok { continue @@ -86,7 +86,7 @@ func (c *initializeContext) setNNS() error { cs.Hash = state.CreateContractHash(c.CommitteeAcc.Contract.ScriptHash(), cs.NEF.Checksum, cs.Manifest.Name) domain := ctrName + ".neofs" - if ok, err := c.nnsDomainAvailable(h, domain); err != nil { + if ok, err := c.Client.NNSIsAvailable(h, domain); err != nil { return err } else if !ok { continue @@ -117,21 +117,6 @@ func (c *initializeContext) nnsRootRegistered(nnsHash util.Uint160) (bool, error return res.State == vm.HaltState.String(), nil } -func (c *initializeContext) nnsDomainAvailable(nnsHash util.Uint160, domain string) (bool, error) { - params := []smartcontract.Parameter{{Type: smartcontract.StringType, Value: domain}} - res, err := c.Client.InvokeFunction(nnsHash, "isAvailable", params, nil) - if err != nil { - return false, err - } - if len(res.Stack) == 0 { - return true, nil - } - if ok, err := res.Stack[0].TryBool(); err == nil { - return ok, nil - } - return true, nil -} - func getAlphabetNNSDomain(i int) string { return alphabetContract + strconv.FormatUint(uint64(i), 10) + ".neofs" }