[#755] neofs-adm: add contract hash flag to dump-containers

`--container-contract` flag must be used for deployments without NNS.
Our current testnet sidechain is like this, for example.

Signed-off-by: Evgenii Stratonikov <evgeniy@nspcc.ru>
This commit is contained in:
Evgenii Stratonikov 2021-08-10 11:51:11 +03:00 committed by Alex Vanin
parent 5072b703bc
commit 00a299c1a4
2 changed files with 12 additions and 2 deletions

View file

@ -10,6 +10,7 @@ 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/emit"
"github.com/nspcc-dev/neo-go/pkg/vm/stackitem"
cid "github.com/nspcc-dev/neofs-api-go/pkg/container/id"
@ -35,9 +36,16 @@ func dumpContainers(cmd *cobra.Command, _ []string) error {
return fmt.Errorf("can't get NNS contract state: %w", err)
}
ch, err := nnsResolveHash(c, nnsCs.Hash, containerContract+".neofs")
var ch util.Uint160
s, err := cmd.Flags().GetString(containerContractFlag)
if err == nil {
ch, err = util.Uint160DecodeStringLE(s)
}
if err != nil {
return fmt.Errorf("can't fetch container contract hash: %w", err)
ch, err = nnsResolveHash(c, nnsCs.Hash, containerContract+".neofs")
if err != nil {
return err
}
}
res, err := c.InvokeFunction(ch, "list",

View file

@ -28,6 +28,7 @@ const (
withdrawFeeInitFlag = "network.fee.withdraw"
withdrawFeeCLIFlag = "withdraw-fee"
containerDumpFlag = "dump"
containerContractFlag = "container-contract"
)
var (
@ -169,6 +170,7 @@ func init() {
RootCmd.AddCommand(dumpContainersCmd)
dumpContainersCmd.Flags().StringP(endpointFlag, "r", "", "N3 RPC node endpoint")
dumpContainersCmd.Flags().String(containerDumpFlag, "", "file where to save dumped containers")
dumpContainersCmd.Flags().String(containerContractFlag, "", "container contract hash (for networks without NNS)")
RootCmd.AddCommand(restoreContainersCmd)
restoreContainersCmd.Flags().String(alphabetWalletsFlag, "", "path to alphabet wallets dir")