2024-02-14 05:58:43 +00:00
|
|
|
package nns
|
|
|
|
|
|
|
|
import (
|
|
|
|
client "git.frostfs.info/TrueCloudLab/frostfs-contract/rpcclient/nns"
|
2024-10-30 14:39:02 +00:00
|
|
|
"git.frostfs.info/TrueCloudLab/frostfs-node/cmd/frostfs-adm/internal/modules/morph/constants"
|
2024-02-14 05:58:43 +00:00
|
|
|
"git.frostfs.info/TrueCloudLab/frostfs-node/cmd/frostfs-adm/internal/modules/morph/helper"
|
|
|
|
commonCmd "git.frostfs.info/TrueCloudLab/frostfs-node/cmd/internal/common"
|
2024-11-21 07:43:53 +00:00
|
|
|
"github.com/nspcc-dev/neo-go/pkg/rpcclient/invoker"
|
2024-02-14 05:58:43 +00:00
|
|
|
"github.com/nspcc-dev/neo-go/pkg/rpcclient/management"
|
|
|
|
"github.com/spf13/cobra"
|
|
|
|
"github.com/spf13/viper"
|
|
|
|
)
|
|
|
|
|
2024-11-21 07:51:38 +00:00
|
|
|
func getRPCClient(cmd *cobra.Command) (*client.Contract, *helper.LocalActor) {
|
2024-02-14 05:58:43 +00:00
|
|
|
v := viper.GetViper()
|
|
|
|
c, err := helper.GetN3Client(v)
|
|
|
|
commonCmd.ExitOnErr(cmd, "unable to create NEO rpc client: %w", err)
|
|
|
|
|
2024-10-30 14:39:02 +00:00
|
|
|
ac, err := helper.NewLocalActor(cmd, c, constants.CommitteeAccountName)
|
2024-02-14 05:58:43 +00:00
|
|
|
commonCmd.ExitOnErr(cmd, "can't create actor: %w", err)
|
|
|
|
|
2024-02-20 08:36:36 +00:00
|
|
|
r := management.NewReader(ac.Invoker)
|
2024-06-28 13:35:18 +00:00
|
|
|
nnsCs, err := helper.GetContractByID(r, 1)
|
2024-02-14 05:58:43 +00:00
|
|
|
commonCmd.ExitOnErr(cmd, "can't get NNS contract state: %w", err)
|
2024-11-21 07:51:38 +00:00
|
|
|
return client.New(ac, nnsCs.Hash), ac
|
2024-02-14 05:58:43 +00:00
|
|
|
}
|
2024-11-21 07:43:53 +00:00
|
|
|
|
|
|
|
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
|
|
|
|
}
|