forked from TrueCloudLab/frostfs-node
[#404] innerring: Get GAS script hash from neo-go client
Signed-off-by: Alex Vanin <alexey@nspcc.ru>
This commit is contained in:
parent
883a2e3e77
commit
948823c392
3 changed files with 7 additions and 23 deletions
|
@ -67,8 +67,6 @@ func defaultConfiguration(cfg *viper.Viper) {
|
|||
cfg.SetDefault("contracts.audit", "")
|
||||
// alphabet contracts
|
||||
cfg.SetDefault("contracts.alphabet.amount", 7)
|
||||
// gas native contract in LE
|
||||
cfg.SetDefault("contracts.gas", "70e2301955bf1e74cbb31d18c2f96972abadb328")
|
||||
|
||||
cfg.SetDefault("timers.epoch", "0")
|
||||
cfg.SetDefault("timers.emit", "0")
|
||||
|
|
|
@ -88,7 +88,6 @@ type (
|
|||
balance util.Uint160 // in morph
|
||||
container util.Uint160 // in morph
|
||||
audit util.Uint160 // in morph
|
||||
gas util.Uint160 // native contract in both chains
|
||||
|
||||
alphabet alphabetContracts // in morph
|
||||
}
|
||||
|
@ -222,7 +221,6 @@ func New(ctx context.Context, log *zap.Logger, cfg *viper.Viper) (*Server, error
|
|||
log: log,
|
||||
cfg: cfg,
|
||||
key: server.key,
|
||||
gas: server.contracts.gas,
|
||||
name: morphPrefix,
|
||||
}
|
||||
|
||||
|
@ -557,7 +555,6 @@ func createClient(ctx context.Context, p *chainParams) (*client.Client, error) {
|
|||
client.WithContext(ctx),
|
||||
client.WithLogger(p.log),
|
||||
client.WithDialTimeout(p.cfg.GetDuration(p.name+".dial_timeouts")),
|
||||
client.WithGasContract(p.gas),
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -570,7 +567,6 @@ func parseContracts(cfg *viper.Viper) (*contracts, error) {
|
|||
netmapContractStr := cfg.GetString("contracts.netmap")
|
||||
neofsContractStr := cfg.GetString("contracts.neofs")
|
||||
balanceContractStr := cfg.GetString("contracts.balance")
|
||||
nativeGasContractStr := cfg.GetString("contracts.gas")
|
||||
containerContractStr := cfg.GetString("contracts.container")
|
||||
auditContractStr := cfg.GetString("contracts.audit")
|
||||
|
||||
|
@ -589,11 +585,6 @@ func parseContracts(cfg *viper.Viper) (*contracts, error) {
|
|||
return nil, errors.Wrap(err, "ir: can't read balance script-hash")
|
||||
}
|
||||
|
||||
result.gas, err = util.Uint160DecodeStringLE(nativeGasContractStr)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "ir: can't read native gas script-hash")
|
||||
}
|
||||
|
||||
result.container, err = util.Uint160DecodeStringLE(containerContractStr)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "ir: can't read container script-hash")
|
||||
|
|
|
@ -5,6 +5,7 @@ import (
|
|||
"crypto/ecdsa"
|
||||
"time"
|
||||
|
||||
"github.com/nspcc-dev/neo-go/pkg/core/native/nativenames"
|
||||
"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/util"
|
||||
|
@ -35,7 +36,6 @@ func defaultConfig() *cfg {
|
|||
ctx: context.Background(),
|
||||
dialTimeout: defaultDialTimeout,
|
||||
logger: zap.L(),
|
||||
gas: util.Uint160{},
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -89,11 +89,16 @@ func New(key *ecdsa.PrivateKey, endpoint string, opts ...Option) (*Client, error
|
|||
return nil, err
|
||||
}
|
||||
|
||||
gas, err := cli.GetNativeContractHash(nativenames.Gas)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &Client{
|
||||
logger: cfg.logger,
|
||||
client: cli,
|
||||
acc: account,
|
||||
gas: cfg.gas,
|
||||
gas: gas,
|
||||
}, nil
|
||||
}
|
||||
|
||||
|
@ -138,13 +143,3 @@ func WithLogger(logger *logger.Logger) Option {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
// WithGasContract returns a client constructor option
|
||||
// that specifies native gas contract script hash.
|
||||
//
|
||||
// If option not provided, empty script hash is used.
|
||||
func WithGasContract(gas util.Uint160) Option {
|
||||
return func(c *cfg) {
|
||||
c.gas = gas
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue