Evgenii Stratonikov
9073e555db
`nns get-records` and `nns tokens` command do not need to sign anything, so remove useless actor and use invoker directly. `NewLocalActor()` is only used in `ape` and `nns` packages. `ape` package seem to use it correctly, only when alphabet wallets are provided, so no changes there. Also, remove --alphabet-wallets flag from commands that do not need it. Signed-off-by: Evgenii Stratonikov <e.stratonikov@yadro.com>
39 lines
1.5 KiB
Go
39 lines
1.5 KiB
Go
package nns
|
|
|
|
import (
|
|
client "git.frostfs.info/TrueCloudLab/frostfs-contract/rpcclient/nns"
|
|
"git.frostfs.info/TrueCloudLab/frostfs-node/cmd/frostfs-adm/internal/modules/morph/constants"
|
|
"git.frostfs.info/TrueCloudLab/frostfs-node/cmd/frostfs-adm/internal/modules/morph/helper"
|
|
commonCmd "git.frostfs.info/TrueCloudLab/frostfs-node/cmd/internal/common"
|
|
"github.com/nspcc-dev/neo-go/pkg/rpcclient/invoker"
|
|
"github.com/nspcc-dev/neo-go/pkg/rpcclient/management"
|
|
"github.com/nspcc-dev/neo-go/pkg/util"
|
|
"github.com/spf13/cobra"
|
|
"github.com/spf13/viper"
|
|
)
|
|
|
|
func getRPCClient(cmd *cobra.Command) (*client.Contract, *helper.LocalActor, util.Uint160) {
|
|
v := viper.GetViper()
|
|
c, err := helper.GetN3Client(v)
|
|
commonCmd.ExitOnErr(cmd, "unable to create NEO rpc client: %w", err)
|
|
|
|
ac, err := helper.NewLocalActor(cmd, c, constants.CommitteeAccountName)
|
|
commonCmd.ExitOnErr(cmd, "can't create actor: %w", err)
|
|
|
|
r := management.NewReader(ac.Invoker)
|
|
nnsCs, err := helper.GetContractByID(r, 1)
|
|
commonCmd.ExitOnErr(cmd, "can't get NNS contract state: %w", err)
|
|
return client.New(ac, nnsCs.Hash), ac, nnsCs.Hash
|
|
}
|
|
|
|
func nnsReader(cmd *cobra.Command) (*client.ContractReader, *invoker.Invoker) {
|
|
c, err := helper.GetN3Client(viper.GetViper())
|
|
commonCmd.ExitOnErr(cmd, "unable to create NEO rpc client: %w", err)
|
|
|
|
inv := invoker.New(c, nil)
|
|
r := management.NewReader(inv)
|
|
nnsCs, err := helper.GetContractByID(r, 1)
|
|
commonCmd.ExitOnErr(cmd, "can't get NNS contract state: %w", err)
|
|
|
|
return client.NewReader(inv, nnsCs.Hash), inv
|
|
}
|