2021-04-29 13:37:16 +00:00
|
|
|
package config
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/nspcc-dev/neo-go/pkg/encoding/fixedn"
|
|
|
|
"github.com/spf13/viper"
|
|
|
|
)
|
|
|
|
|
|
|
|
// FeeConfig is an instance that returns extra fee values for contract
|
|
|
|
// invocations without notary support.
|
|
|
|
type FeeConfig struct {
|
2021-12-07 09:54:21 +00:00
|
|
|
registerNamedCnr,
|
|
|
|
mainchain,
|
|
|
|
sidechain fixedn.Fixed8
|
2021-04-29 13:37:16 +00:00
|
|
|
}
|
|
|
|
|
2021-12-07 09:54:21 +00:00
|
|
|
// NewFeeConfig constructs FeeConfig from viper.Viper instance. Latter must not be nil.
|
|
|
|
//
|
|
|
|
// Fee for named container registration is taken from "fee.named_container_register" value.
|
2021-04-29 13:37:16 +00:00
|
|
|
func NewFeeConfig(v *viper.Viper) *FeeConfig {
|
|
|
|
return &FeeConfig{
|
2021-12-07 09:54:21 +00:00
|
|
|
registerNamedCnr: fixedn.Fixed8(v.GetInt64("fee.named_container_register")),
|
|
|
|
mainchain: fixedn.Fixed8(v.GetInt64("fee.main_chain")),
|
|
|
|
sidechain: fixedn.Fixed8(v.GetInt64("fee.side_chain")),
|
2021-04-29 13:37:16 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func (f FeeConfig) MainChainFee() fixedn.Fixed8 {
|
|
|
|
return f.mainchain
|
|
|
|
}
|
|
|
|
|
|
|
|
func (f FeeConfig) SideChainFee() fixedn.Fixed8 {
|
|
|
|
return f.sidechain
|
|
|
|
}
|
2021-12-07 09:54:21 +00:00
|
|
|
|
2023-02-05 15:59:38 +00:00
|
|
|
// NamedContainerRegistrationFee returns additional GAS fee for named container registration in FrostFS network.
|
2021-12-07 09:54:21 +00:00
|
|
|
func (f FeeConfig) NamedContainerRegistrationFee() fixedn.Fixed8 {
|
|
|
|
return f.registerNamedCnr
|
|
|
|
}
|