[#726] neofs-adm: use NNSIsAvailable
from neo-go
There is no need in writing another wrapper. Signed-off-by: Evgenii Stratonikov <evgeniy@nspcc.ru>
This commit is contained in:
parent
9e56012760
commit
2290109849
1 changed files with 2 additions and 17 deletions
|
@ -59,7 +59,7 @@ func (c *initializeContext) setNNS() error {
|
||||||
alphaCs.Hash = state.CreateContractHash(acc.Contract.ScriptHash(), alphaCs.NEF.Checksum, alphaCs.Manifest.Name)
|
alphaCs.Hash = state.CreateContractHash(acc.Contract.ScriptHash(), alphaCs.NEF.Checksum, alphaCs.Manifest.Name)
|
||||||
|
|
||||||
domain := getAlphabetNNSDomain(i)
|
domain := getAlphabetNNSDomain(i)
|
||||||
if ok, err := c.nnsDomainAvailable(h, domain); err != nil {
|
if ok, err := c.Client.NNSIsAvailable(h, domain); err != nil {
|
||||||
return err
|
return err
|
||||||
} else if !ok {
|
} else if !ok {
|
||||||
continue
|
continue
|
||||||
|
@ -86,7 +86,7 @@ func (c *initializeContext) setNNS() error {
|
||||||
cs.Hash = state.CreateContractHash(c.CommitteeAcc.Contract.ScriptHash(), cs.NEF.Checksum, cs.Manifest.Name)
|
cs.Hash = state.CreateContractHash(c.CommitteeAcc.Contract.ScriptHash(), cs.NEF.Checksum, cs.Manifest.Name)
|
||||||
|
|
||||||
domain := ctrName + ".neofs"
|
domain := ctrName + ".neofs"
|
||||||
if ok, err := c.nnsDomainAvailable(h, domain); err != nil {
|
if ok, err := c.Client.NNSIsAvailable(h, domain); err != nil {
|
||||||
return err
|
return err
|
||||||
} else if !ok {
|
} else if !ok {
|
||||||
continue
|
continue
|
||||||
|
@ -117,21 +117,6 @@ func (c *initializeContext) nnsRootRegistered(nnsHash util.Uint160) (bool, error
|
||||||
return res.State == vm.HaltState.String(), nil
|
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 {
|
func getAlphabetNNSDomain(i int) string {
|
||||||
return alphabetContract + strconv.FormatUint(uint64(i), 10) + ".neofs"
|
return alphabetContract + strconv.FormatUint(uint64(i), 10) + ".neofs"
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue