From 6bc787bb19a4d9b897ea2e138b02482e7ea7b463 Mon Sep 17 00:00:00 2001 From: Alex Vanin Date: Mon, 12 Oct 2020 12:29:27 +0300 Subject: [PATCH] [#86] Add alphabet contract configuration Signed-off-by: Alex Vanin --- cmd/neofs-ir/defaults.go | 8 ++++++++ pkg/innerring/innerring.go | 25 +++++++++++++++++++++++++ 2 files changed, 33 insertions(+) diff --git a/cmd/neofs-ir/defaults.go b/cmd/neofs-ir/defaults.go index c2017e5d2..99f0477ad 100644 --- a/cmd/neofs-ir/defaults.go +++ b/cmd/neofs-ir/defaults.go @@ -64,6 +64,14 @@ func defaultConfiguration(cfg *viper.Viper) { cfg.SetDefault("contracts.neofs", "") cfg.SetDefault("contracts.balance", "") cfg.SetDefault("contracts.container", "") + // alphabet contracts + cfg.SetDefault("contracts.alphabet.az", "") + cfg.SetDefault("contracts.alphabet.buky", "") + cfg.SetDefault("contracts.alphabet.vedi", "") + cfg.SetDefault("contracts.alphabet.glagoli", "") + cfg.SetDefault("contracts.alphabet.dobro", "") + cfg.SetDefault("contracts.alphabet.jest", "") + cfg.SetDefault("contracts.alphabet.zhivete", "") // gas native contract in LE cfg.SetDefault("contracts.gas", "668e0c1f9d7b70a99dd9e06eadd4c784d641afbc") diff --git a/pkg/innerring/innerring.go b/pkg/innerring/innerring.go index cb97edbbd..4931d4add 100644 --- a/pkg/innerring/innerring.go +++ b/pkg/innerring/innerring.go @@ -51,6 +51,8 @@ type ( reputation util.Uint160 // in morph neofsid util.Uint160 // in morph gas util.Uint160 // native contract in both chains + + alphabet [alphabetContractsN]util.Uint160 // in morph } chainParams struct { @@ -65,6 +67,8 @@ type ( const ( morphPrefix = "morph" mainnetPrefix = "mainnet" + + alphabetContractsN = 7 // az, buky, vedi, glagoli, dobro, jest, zhivete ) // Start runs all event providers. @@ -297,9 +301,30 @@ func parseContracts(cfg *viper.Viper) (*contracts, error) { return nil, errors.Wrap(err, "ir: can't read container script-hash") } + result.alphabet, err = parseAlphabetContracts(cfg) + if err != nil { + return nil, err + } + return result, nil } +func parseAlphabetContracts(cfg *viper.Viper) (res [7]util.Uint160, err error) { + // list of glagolic script letters that represent alphabet contracts + glagolic := []string{"az", "buky", "vedi", "glagoli", "dobro", "jest", "zhivete"} + + for i, letter := range glagolic { + contractStr := cfg.GetString("contracts.alphabet." + letter) + + res[i], err = util.Uint160DecodeStringLE(contractStr) + if err != nil { + return res, errors.Wrapf(err, "ir: can't read alphabet %s contract", letter) + } + } + + return res, nil +} + func initConfigFromBlockchain(s *Server, c *contracts, key *ecdsa.PublicKey) error { // get current epoch epoch, err := invoke.Epoch(s.morphClient, c.netmap)