forked from TrueCloudLab/frostfs-node
neofs-adm: use nnsResolveHash
instead of custom code
Signed-off-by: Evgenii Stratonikov <evgeniy@nspcc.ru>
This commit is contained in:
parent
72b8d919fe
commit
f9d9f33461
2 changed files with 4 additions and 37 deletions
|
@ -13,7 +13,6 @@ import (
|
|||
"github.com/nspcc-dev/neo-go/pkg/io"
|
||||
"github.com/nspcc-dev/neo-go/pkg/smartcontract"
|
||||
"github.com/nspcc-dev/neo-go/pkg/smartcontract/callflag"
|
||||
"github.com/nspcc-dev/neo-go/pkg/util"
|
||||
"github.com/nspcc-dev/neo-go/pkg/vm"
|
||||
"github.com/nspcc-dev/neo-go/pkg/vm/emit"
|
||||
"github.com/nspcc-dev/neo-go/pkg/vm/stackitem"
|
||||
|
@ -113,27 +112,12 @@ func dumpNetworkConfig(cmd *cobra.Command, _ []string) error {
|
|||
return fmt.Errorf("can't get NNS contract info: %w", err)
|
||||
}
|
||||
|
||||
res, err := wCtx.Client.InvokeFunction(cs.Hash, "resolve", []smartcontract.Parameter{
|
||||
{Type: smartcontract.StringType, Value: netmapContract + ".neofs"},
|
||||
{Type: smartcontract.IntegerType, Value: int64(nns.TXT)},
|
||||
}, nil)
|
||||
nmHash, err := nnsResolveHash(wCtx.Client, cs.Hash, netmapContract+".neofs")
|
||||
if err != nil {
|
||||
return fmt.Errorf("can't get netmap contract hash: %w", err)
|
||||
}
|
||||
if len(res.Stack) == 0 {
|
||||
return errors.New("empty response from NNS")
|
||||
}
|
||||
|
||||
var nmHash util.Uint160
|
||||
bs, err := res.Stack[0].TryBytes()
|
||||
if err == nil {
|
||||
nmHash, err = util.Uint160DecodeStringLE(string(bs))
|
||||
}
|
||||
if err != nil {
|
||||
return fmt.Errorf("invalid response from NNS contract: %w", err)
|
||||
}
|
||||
|
||||
res, err = wCtx.Client.InvokeFunction(nmHash, "listConfig",
|
||||
res, err := wCtx.Client.InvokeFunction(nmHash, "listConfig",
|
||||
[]smartcontract.Parameter{}, []transaction.Signer{{}})
|
||||
if err != nil || res.State != vm.HaltState.String() || len(res.Stack) == 0 {
|
||||
return errors.New("can't fetch list of network config keys from the netmap contract")
|
||||
|
|
|
@ -4,12 +4,10 @@ import (
|
|||
"errors"
|
||||
"fmt"
|
||||
|
||||
nns "github.com/nspcc-dev/neo-go/examples/nft-nd-nns"
|
||||
"github.com/nspcc-dev/neo-go/pkg/core/transaction"
|
||||
"github.com/nspcc-dev/neo-go/pkg/io"
|
||||
"github.com/nspcc-dev/neo-go/pkg/smartcontract"
|
||||
"github.com/nspcc-dev/neo-go/pkg/smartcontract/callflag"
|
||||
"github.com/nspcc-dev/neo-go/pkg/util"
|
||||
"github.com/nspcc-dev/neo-go/pkg/vm"
|
||||
"github.com/nspcc-dev/neo-go/pkg/vm/emit"
|
||||
"github.com/spf13/cobra"
|
||||
|
@ -27,27 +25,12 @@ func forceNewEpochCmd(cmd *cobra.Command, args []string) error {
|
|||
return fmt.Errorf("can't get NNS contract info: %w", err)
|
||||
}
|
||||
|
||||
res, err := wCtx.Client.InvokeFunction(cs.Hash, "resolve", []smartcontract.Parameter{
|
||||
{Type: smartcontract.StringType, Value: netmapContract + ".neofs"},
|
||||
{Type: smartcontract.IntegerType, Value: int64(nns.TXT)},
|
||||
}, nil)
|
||||
nmHash, err := nnsResolveHash(wCtx.Client, cs.Hash, netmapContract+".neofs")
|
||||
if err != nil {
|
||||
return fmt.Errorf("can't get netmap contract hash: %w", err)
|
||||
}
|
||||
if len(res.Stack) == 0 {
|
||||
return errors.New("empty response from NNS")
|
||||
}
|
||||
|
||||
var nmHash util.Uint160
|
||||
bs, err := res.Stack[0].TryBytes()
|
||||
if err == nil {
|
||||
nmHash, err = util.Uint160DecodeStringLE(string(bs))
|
||||
}
|
||||
if err != nil {
|
||||
return fmt.Errorf("invalid response from NNS contract: %w", err)
|
||||
}
|
||||
|
||||
res, err = wCtx.Client.InvokeFunction(nmHash, "epoch", []smartcontract.Parameter{}, []transaction.Signer{{
|
||||
res, err := wCtx.Client.InvokeFunction(nmHash, "epoch", []smartcontract.Parameter{}, []transaction.Signer{{
|
||||
Account: wCtx.CommitteeAcc.Contract.ScriptHash(),
|
||||
Scopes: transaction.Global, // Scope is important, as we have nested call to container contract.
|
||||
}})
|
||||
|
|
Loading…
Reference in a new issue