diff --git a/cmd/neofs-adm/internal/modules/morph/initialize.go b/cmd/neofs-adm/internal/modules/morph/initialize.go index feceba00..0c9958db 100644 --- a/cmd/neofs-adm/internal/modules/morph/initialize.go +++ b/cmd/neofs-adm/internal/modules/morph/initialize.go @@ -26,6 +26,8 @@ type initializeContext struct { // ConsensusAcc is used for retrieving committee address and verification script. ConsensusAcc *wallet.Account Wallets []*wallet.Wallet + // Accounts contains simple signature accounts in the same order as in Wallets. + Accounts []*wallet.Account Hashes []util.Uint256 WaitDuration time.Duration PollInterval time.Duration @@ -134,11 +136,21 @@ func newInitializeContext(cmd *cobra.Command, v *viper.Viper) (*initializeContex nativeHashes[ns[i].Manifest.Name] = ns[i].Hash } + accounts := make([]*wallet.Account, len(wallets)) + for i, w := range wallets { + acc, err := getWalletAccount(w, singleAccountName) + if err != nil { + return nil, fmt.Errorf("wallet %s is invalid (no single account): %w", w.Path(), err) + } + accounts[i] = acc + } + initCtx := &initializeContext{ Client: c, ConsensusAcc: consensusAcc, CommitteeAcc: committeeAcc, Wallets: wallets, + Accounts: accounts, WaitDuration: time.Second * 30, PollInterval: time.Second, Command: cmd, diff --git a/cmd/neofs-adm/internal/modules/morph/initialize_deploy.go b/cmd/neofs-adm/internal/modules/morph/initialize_deploy.go index 252cd1ef..0da8dca5 100644 --- a/cmd/neofs-adm/internal/modules/morph/initialize_deploy.go +++ b/cmd/neofs-adm/internal/modules/morph/initialize_deploy.go @@ -122,12 +122,7 @@ func (c *initializeContext) deployContracts() error { var keysParam []smartcontract.Parameter // alphabet contracts should be deployed by individual nodes to get different hashes. - for i, w := range c.Wallets { - acc, err := getWalletAccount(w, singleAccountName) - if err != nil { - return err - } - + for i, acc := range c.Accounts { cs, err := c.readContract(alphabetContract) if err != nil { return err diff --git a/cmd/neofs-adm/internal/modules/morph/initialize_nns.go b/cmd/neofs-adm/internal/modules/morph/initialize_nns.go index a4b8a824..56d03ac9 100644 --- a/cmd/neofs-adm/internal/modules/morph/initialize_nns.go +++ b/cmd/neofs-adm/internal/modules/morph/initialize_nns.go @@ -45,12 +45,7 @@ func (c *initializeContext) setNNS() error { if err != nil { return fmt.Errorf("can't read alphabet contract: %w", err) } - for i, w := range c.Wallets { - acc, err := getWalletAccount(w, singleAccountName) - if err != nil { - return err - } - + for i, acc := range c.Accounts { alphaCs.Hash = state.CreateContractHash(acc.Contract.ScriptHash(), alphaCs.NEF.Checksum, alphaCs.Manifest.Name) domain := getAlphabetNNSDomain(i) diff --git a/cmd/neofs-adm/internal/modules/morph/initialize_register.go b/cmd/neofs-adm/internal/modules/morph/initialize_register.go index 46433923..7f16ab9a 100644 --- a/cmd/neofs-adm/internal/modules/morph/initialize_register.go +++ b/cmd/neofs-adm/internal/modules/morph/initialize_register.go @@ -41,12 +41,7 @@ func (c *initializeContext) registerCandidates() error { } sysGas := regPrice + native.GASFactor // + 1 GAS - for _, w := range c.Wallets { - acc, err := getWalletAccount(w, singleAccountName) - if err != nil { - return err - } - + for _, acc := range c.Accounts { w := io.NewBufBinWriter() emit.AppCall(w.BinWriter, neoHash, "registerCandidate", callflag.States, acc.PrivateKey().PublicKey().Bytes()) emit.Opcodes(w.BinWriter, opcode.ASSERT) @@ -84,12 +79,7 @@ func (c *initializeContext) transferNEOToAlphabetContracts() error { amount := initialAlphabetNEOAmount / len(c.Wallets) bw := io.NewBufBinWriter() - for _, w := range c.Wallets { - acc, err := getWalletAccount(w, singleAccountName) - if err != nil { - return err - } - + for _, acc := range c.Accounts { h := state.CreateContractHash(acc.Contract.ScriptHash(), cs.NEF.Checksum, cs.Manifest.Name) emit.AppCall(bw.BinWriter, neoHash, "transfer", callflag.All, c.CommitteeAcc.Contract.ScriptHash(), h, int64(amount), nil) diff --git a/cmd/neofs-adm/internal/modules/morph/initialize_roles.go b/cmd/neofs-adm/internal/modules/morph/initialize_roles.go index 705e6437..2c9614eb 100644 --- a/cmd/neofs-adm/internal/modules/morph/initialize_roles.go +++ b/cmd/neofs-adm/internal/modules/morph/initialize_roles.go @@ -19,12 +19,7 @@ func (c *initializeContext) setNotaryAndAlphabetNodes() error { designateHash := c.nativeHash(nativenames.Designation) var pubs []interface{} - for _, w := range c.Wallets { - acc, err := getWalletAccount(w, singleAccountName) - if err != nil { - return err - } - + for _, acc := range c.Accounts { pubs = append(pubs, acc.PrivateKey().PublicKey().Bytes()) } diff --git a/cmd/neofs-adm/internal/modules/morph/initialize_transfer.go b/cmd/neofs-adm/internal/modules/morph/initialize_transfer.go index b5e18541..b7ef6fc9 100644 --- a/cmd/neofs-adm/internal/modules/morph/initialize_transfer.go +++ b/cmd/neofs-adm/internal/modules/morph/initialize_transfer.go @@ -32,12 +32,7 @@ func (c *initializeContext) transferFunds() error { neoHash := c.nativeHash(nativenames.Neo) var transfers []client.TransferTarget - for _, w := range c.Wallets { - acc, err := getWalletAccount(w, singleAccountName) - if err != nil { - return err - } - + for _, acc := range c.Accounts { to := acc.Contract.ScriptHash() transfers = append(transfers, client.TransferTarget{ @@ -82,11 +77,7 @@ func (c *initializeContext) transferFunds() error { func (c *initializeContext) transferFundsFinished() (bool, error) { gasHash := c.nativeHash(nativenames.Gas) - - acc, err := getWalletAccount(c.Wallets[0], singleAccountName) - if err != nil { - return false, err - } + acc := c.Accounts[0] res, err := c.Client.NEP17BalanceOf(gasHash, acc.Contract.ScriptHash()) return res > initialAlphabetGASAmount/2, err