From 00a299c1a47bb1d6a8975062940dec7170042faf Mon Sep 17 00:00:00 2001 From: Evgenii Stratonikov Date: Tue, 10 Aug 2021 11:51:11 +0300 Subject: [PATCH] [#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 --- cmd/neofs-adm/internal/modules/morph/container.go | 12 ++++++++++-- cmd/neofs-adm/internal/modules/morph/root.go | 2 ++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/cmd/neofs-adm/internal/modules/morph/container.go b/cmd/neofs-adm/internal/modules/morph/container.go index 11f1cfcc..2d3fbec1 100644 --- a/cmd/neofs-adm/internal/modules/morph/container.go +++ b/cmd/neofs-adm/internal/modules/morph/container.go @@ -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", diff --git a/cmd/neofs-adm/internal/modules/morph/root.go b/cmd/neofs-adm/internal/modules/morph/root.go index 74daf97d..928cb470 100644 --- a/cmd/neofs-adm/internal/modules/morph/root.go +++ b/cmd/neofs-adm/internal/modules/morph/root.go @@ -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")