frostfs-node/pkg/morph/event/neofs/config.go
Alex Vanin 7d154f8659 [] Add neofs config event
Signed-off-by: Alex Vanin <alexey@nspcc.ru>
2020-10-02 11:25:35 +03:00

45 lines
961 B
Go

package neofs
import (
"github.com/nspcc-dev/neo-go/pkg/smartcontract"
"github.com/nspcc-dev/neofs-node/pkg/morph/client"
"github.com/nspcc-dev/neofs-node/pkg/morph/event"
"github.com/pkg/errors"
)
type Config struct {
key []byte
value []byte
}
// MorphEvent implements Neo:Morph Event interface.
func (Config) MorphEvent() {}
func (u Config) Key() []byte { return u.key }
func (u Config) Value() []byte { return u.value }
func ParseConfig(params []smartcontract.Parameter) (event.Event, error) {
var (
ev Config
err error
)
if ln := len(params); ln != 2 {
return nil, event.WrongNumberOfParameters(2, ln)
}
// parse key
ev.key, err = client.BytesFromStackParameter(params[0])
if err != nil {
return nil, errors.Wrap(err, "could not get config key")
}
// parse value
ev.value, err = client.BytesFromStackParameter(params[1])
if err != nil {
return nil, errors.Wrap(err, "could not get config value")
}
return ev, nil
}