[#355] innerring: Add fee to NoFee
wrappers
There is no point of making separate `Fee` and `NoFee` wrappers because all reading operations are free disregarding of fee value in static client. However we can use these same wrappers so send transaction. Signed-off-by: Alex Vanin <alexey@nspcc.ru>
This commit is contained in:
parent
70aa73cbd2
commit
402192c8c4
3 changed files with 14 additions and 16 deletions
|
@ -220,17 +220,17 @@ func New(ctx context.Context, log *zap.Logger, cfg *viper.Viper) (*Server, error
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
server.auditClient, err = invoke.NewNoFeeAuditClient(server.morphClient, server.contracts.audit)
|
server.auditClient, err = invoke.NewAuditClient(server.morphClient, server.contracts.audit)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
cnrClient, err := invoke.NewNoFeeContainerClient(server.morphClient, server.contracts.container)
|
cnrClient, err := invoke.NewContainerClient(server.morphClient, server.contracts.container)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
nmClient, err := invoke.NewNoFeeNetmapClient(server.morphClient, server.contracts.netmap)
|
nmClient, err := invoke.NewNetmapClient(server.morphClient, server.contracts.netmap)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,11 +16,9 @@ import (
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
)
|
)
|
||||||
|
|
||||||
const readOnlyFee = 0
|
// NewContainerClient creates wrapper to access data from container contract.
|
||||||
|
func NewContainerClient(cli *client.Client, contract util.Uint160) (*wrapContainer.Wrapper, error) {
|
||||||
// NewNoFeeContainerClient creates wrapper to access data from container contract.
|
staticClient, err := client.NewStatic(cli, contract, extraFee)
|
||||||
func NewNoFeeContainerClient(cli *client.Client, contract util.Uint160) (*wrapContainer.Wrapper, error) {
|
|
||||||
staticClient, err := client.NewStatic(cli, contract, readOnlyFee)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("can't create container static client: %w", err)
|
return nil, fmt.Errorf("can't create container static client: %w", err)
|
||||||
}
|
}
|
||||||
|
@ -33,9 +31,9 @@ func NewNoFeeContainerClient(cli *client.Client, contract util.Uint160) (*wrapCo
|
||||||
return wrapContainer.New(enhancedContainerClient)
|
return wrapContainer.New(enhancedContainerClient)
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewNoFeeNetmapClient creates wrapper to access data from netmap contract.
|
// NewNetmapClient creates wrapper to access data from netmap contract.
|
||||||
func NewNoFeeNetmapClient(cli *client.Client, contract util.Uint160) (*wrapNetmap.Wrapper, error) {
|
func NewNetmapClient(cli *client.Client, contract util.Uint160) (*wrapNetmap.Wrapper, error) {
|
||||||
staticClient, err := client.NewStatic(cli, contract, readOnlyFee)
|
staticClient, err := client.NewStatic(cli, contract, extraFee)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("can't create netmap static client: %w", err)
|
return nil, fmt.Errorf("can't create netmap static client: %w", err)
|
||||||
}
|
}
|
||||||
|
@ -48,9 +46,9 @@ func NewNoFeeNetmapClient(cli *client.Client, contract util.Uint160) (*wrapNetma
|
||||||
return wrapNetmap.New(enhancedNetmapClient)
|
return wrapNetmap.New(enhancedNetmapClient)
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewNoFeeAuditClient creates wrapper to work with Audit contract.
|
// NewAuditClient creates wrapper to work with Audit contract.
|
||||||
func NewNoFeeAuditClient(cli *client.Client, contract util.Uint160) (*auditWrapper.ClientWrapper, error) {
|
func NewAuditClient(cli *client.Client, contract util.Uint160) (*auditWrapper.ClientWrapper, error) {
|
||||||
staticClient, err := client.NewStatic(cli, contract, readOnlyFee)
|
staticClient, err := client.NewStatic(cli, contract, extraFee)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
|
@ -105,13 +105,13 @@ func New(p *Params) (*Processor, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// creating enhanced client for getting network map
|
// creating enhanced client for getting network map
|
||||||
netmapClient, err := invoke.NewNoFeeNetmapClient(p.MorphClient, p.NetmapContract)
|
netmapClient, err := invoke.NewNetmapClient(p.MorphClient, p.NetmapContract)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
// creating enhanced client for getting containers
|
// creating enhanced client for getting containers
|
||||||
containerClient, err := invoke.NewNoFeeContainerClient(p.MorphClient, p.ContainerContract)
|
containerClient, err := invoke.NewContainerClient(p.MorphClient, p.ContainerContract)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue