From 402192c8c408efa5f3ba6e432a41a50523fe3eeb Mon Sep 17 00:00:00 2001 From: Alex Vanin Date: Fri, 29 Jan 2021 10:04:03 +0300 Subject: [PATCH] [#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 --- pkg/innerring/innerring.go | 6 +++--- pkg/innerring/invoke/enhanced.go | 20 +++++++++----------- pkg/innerring/processors/audit/processor.go | 4 ++-- 3 files changed, 14 insertions(+), 16 deletions(-) diff --git a/pkg/innerring/innerring.go b/pkg/innerring/innerring.go index ef401bebf..b0d7cba24 100644 --- a/pkg/innerring/innerring.go +++ b/pkg/innerring/innerring.go @@ -220,17 +220,17 @@ func New(ctx context.Context, log *zap.Logger, cfg *viper.Viper) (*Server, error 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 { return nil, err } - cnrClient, err := invoke.NewNoFeeContainerClient(server.morphClient, server.contracts.container) + cnrClient, err := invoke.NewContainerClient(server.morphClient, server.contracts.container) if err != nil { return nil, err } - nmClient, err := invoke.NewNoFeeNetmapClient(server.morphClient, server.contracts.netmap) + nmClient, err := invoke.NewNetmapClient(server.morphClient, server.contracts.netmap) if err != nil { return nil, err } diff --git a/pkg/innerring/invoke/enhanced.go b/pkg/innerring/invoke/enhanced.go index c3a0ebdfd..1b2880bbb 100644 --- a/pkg/innerring/invoke/enhanced.go +++ b/pkg/innerring/invoke/enhanced.go @@ -16,11 +16,9 @@ import ( "github.com/pkg/errors" ) -const readOnlyFee = 0 - -// NewNoFeeContainerClient creates wrapper to access data from container contract. -func NewNoFeeContainerClient(cli *client.Client, contract util.Uint160) (*wrapContainer.Wrapper, error) { - staticClient, err := client.NewStatic(cli, contract, readOnlyFee) +// NewContainerClient creates wrapper to access data from container contract. +func NewContainerClient(cli *client.Client, contract util.Uint160) (*wrapContainer.Wrapper, error) { + staticClient, err := client.NewStatic(cli, contract, extraFee) if err != nil { 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) } -// NewNoFeeNetmapClient creates wrapper to access data from netmap contract. -func NewNoFeeNetmapClient(cli *client.Client, contract util.Uint160) (*wrapNetmap.Wrapper, error) { - staticClient, err := client.NewStatic(cli, contract, readOnlyFee) +// NewNetmapClient creates wrapper to access data from netmap contract. +func NewNetmapClient(cli *client.Client, contract util.Uint160) (*wrapNetmap.Wrapper, error) { + staticClient, err := client.NewStatic(cli, contract, extraFee) if err != nil { 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) } -// NewNoFeeAuditClient creates wrapper to work with Audit contract. -func NewNoFeeAuditClient(cli *client.Client, contract util.Uint160) (*auditWrapper.ClientWrapper, error) { - staticClient, err := client.NewStatic(cli, contract, readOnlyFee) +// NewAuditClient creates wrapper to work with Audit contract. +func NewAuditClient(cli *client.Client, contract util.Uint160) (*auditWrapper.ClientWrapper, error) { + staticClient, err := client.NewStatic(cli, contract, extraFee) if err != nil { return nil, err } diff --git a/pkg/innerring/processors/audit/processor.go b/pkg/innerring/processors/audit/processor.go index 8652486b8..be55edd4f 100644 --- a/pkg/innerring/processors/audit/processor.go +++ b/pkg/innerring/processors/audit/processor.go @@ -105,13 +105,13 @@ func New(p *Params) (*Processor, error) { } // 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 { return nil, err } // 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 { return nil, err }