From b4c36a109d6d36423b2209f1d3b3160acf766cfc Mon Sep 17 00:00:00 2001 From: Pavel Karpy Date: Wed, 8 Dec 2021 11:22:02 +0300 Subject: [PATCH] [#1019] adm: Fetch `subnet` SH from NNS Also, delete `-a` (`--contract`) flag. Signed-off-by: Pavel Karpy --- cmd/neofs-adm/internal/modules/morph/subnet.go | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/cmd/neofs-adm/internal/modules/morph/subnet.go b/cmd/neofs-adm/internal/modules/morph/subnet.go index 88e89dd6..c3676e55 100644 --- a/cmd/neofs-adm/internal/modules/morph/subnet.go +++ b/cmd/neofs-adm/internal/modules/morph/subnet.go @@ -8,7 +8,6 @@ import ( "os" "github.com/nspcc-dev/neo-go/pkg/crypto/keys" - "github.com/nspcc-dev/neo-go/pkg/util" "github.com/nspcc-dev/neofs-node/cmd/neofs-adm/internal/modules/morph/internal" "github.com/nspcc-dev/neofs-node/pkg/morph/client" morphsubnet "github.com/nspcc-dev/neofs-node/pkg/morph/client/subnet" @@ -26,8 +25,6 @@ const ( flagSubnetEndpoint = endpointFlag // filepath to private key flagSubnetKey = "key" - // contract address - flagSubnetContract = "contract" ) func viperBindFlags(cmd *cobra.Command, flags ...string) { @@ -44,7 +41,6 @@ var cmdSubnet = &cobra.Command{ viperBindFlags(cmd, flagSubnetEndpoint, flagSubnetKey, - flagSubnetContract, ) }, } @@ -105,18 +101,18 @@ func initSubnetClientCheckNotary(c *morphsubnet.Client, key *keys.PrivateKey, ch return errors.New("missing endpoint") } - // read contract address - contractAddr, err := util.Uint160DecodeStringLE(viper.GetString(flagSubnetContract)) - if err != nil { - return fmt.Errorf("subnet contract address: %w", err) - } - // create base morph client cMorph, err := client.New(key, endpoint) if err != nil { return err } + // read contract address + contractAddr, err := cMorph.NNSContractAddress(client.NNSSubnetworkContractName) + if err != nil { + return fmt.Errorf("read subnet contract address in NNS: %w", err) + } + // calc client mode cMode := morphsubnet.NonNotary @@ -856,7 +852,6 @@ func init() { _ = cmdSubnet.MarkFlagRequired(flagSubnetEndpoint) cmdSubnetFlags.StringP(flagSubnetKey, "k", "", "Path to file with private key") _ = cmdSubnet.MarkFlagRequired(flagSubnetKey) - cmdSubnetFlags.StringP(flagSubnetContract, "a", "", "Subnet contract address (string LE)") // add all subnet commands to corresponding command section addCommandInheritPreRun(cmdSubnet,