[#757] neofs-adm: ensure notary contract is enabled

This is the only case we support, it makes sense to fail early.

Signed-off-by: Evgenii Stratonikov <evgeniy@nspcc.ru>
This commit is contained in:
Evgenii Stratonikov 2021-08-19 13:27:43 +03:00 committed by Stanislav Bogatyrev
parent 33c3f18b4f
commit 8178c5e69b

View file

@ -7,6 +7,7 @@ import (
"path" "path"
"time" "time"
"github.com/nspcc-dev/neo-go/pkg/core/native/nativenames"
"github.com/nspcc-dev/neo-go/pkg/core/transaction" "github.com/nspcc-dev/neo-go/pkg/core/transaction"
"github.com/nspcc-dev/neo-go/pkg/crypto/keys" "github.com/nspcc-dev/neo-go/pkg/crypto/keys"
"github.com/nspcc-dev/neo-go/pkg/rpc/client" "github.com/nspcc-dev/neo-go/pkg/rpc/client"
@ -133,10 +134,17 @@ func newInitializeContext(cmd *cobra.Command, v *viper.Viper) (*initializeContex
return nil, fmt.Errorf("can't get native contract hashes: %w", err) return nil, fmt.Errorf("can't get native contract hashes: %w", err)
} }
notaryEnabled := false
nativeHashes := make(map[string]util.Uint160, len(ns)) nativeHashes := make(map[string]util.Uint160, len(ns))
for i := range ns { for i := range ns {
if ns[i].Manifest.Name == nativenames.Notary {
notaryEnabled = len(ns[i].UpdateHistory) > 0
}
nativeHashes[ns[i].Manifest.Name] = ns[i].Hash nativeHashes[ns[i].Manifest.Name] = ns[i].Hash
} }
if !notaryEnabled {
return nil, errors.New("notary contract must be enabled")
}
accounts := make([]*wallet.Account, len(wallets)) accounts := make([]*wallet.Account, len(wallets))
for i, w := range wallets { for i, w := range wallets {