frostfs-node/pkg/morph/client/reputation/wrapper/list.go
Leonard Lyubich d6c0307431 [#627] morph: Inherit internal.StaticClient interface in all wrappers
There is a need to provide contract address getter from all contract client
wrappers.

Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
2021-09-30 14:47:04 +03:00

55 lines
1.2 KiB
Go

package wrapper
import (
reputationClient "github.com/nspcc-dev/neofs-node/pkg/morph/client/reputation"
)
type (
// ReputationID is an ID of the reputation record in reputation contract.
ReputationID []byte
// ListByEpochArgs groups the arguments of
// "list reputation ids by epoch" test invoke call.
ListByEpochArgs struct {
epoch uint64
}
// ListByEpochResult groups the result of "list reputation ids by epoch"
// test invoke.
ListByEpochResult struct {
ids []ReputationID
}
)
// SetEpoch sets epoch of expected reputation ids.
func (l *ListByEpochArgs) SetEpoch(v uint64) {
l.epoch = v
}
// IDs returns slice of reputation id values.
func (l ListByEpochResult) IDs() []ReputationID {
return l.ids
}
// ListByEpoch invokes the call of "list reputation ids by epoch" method of
// reputation contract.
func (w *ClientWrapper) ListByEpoch(v ListByEpochArgs) (*ListByEpochResult, error) {
args := reputationClient.ListByEpochArgs{}
args.SetEpoch(v.epoch)
data, err := w.client.ListByEpoch(args)
if err != nil {
return nil, err
}
ids := data.IDs()
result := make([]ReputationID, 0, len(ids))
for i := range ids {
result = append(result, ids[i])
}
return &ListByEpochResult{
ids: result,
}, nil
}