frostfs-node/pkg/morph/event/rolemanagement/designate.go
Evgenii Stratonikov 2e31cd34e6 [#502] innerring: synchronize validators on mainnet alphabet update
Signed-off-by: Evgenii Stratonikov <evgeniy@nspcc.ru>
2021-05-25 11:10:01 +03:00

31 lines
814 B
Go

package rolemanagement
import (
"fmt"
"github.com/nspcc-dev/neo-go/pkg/core/native/noderoles"
"github.com/nspcc-dev/neo-go/pkg/vm/stackitem"
"github.com/nspcc-dev/neofs-node/pkg/morph/event"
)
// Designate represents designation event of the mainnet RoleManagement contract.
type Designate struct {
Role noderoles.Role
}
// MorphEvent implements Neo:Morph Event interface.
func (Designate) MorphEvent() {}
// ParseDesignate from notification into container event structure.
func ParseDesignate(params []stackitem.Item) (event.Event, error) {
if len(params) != 2 {
return nil, event.WrongNumberOfParameters(2, len(params))
}
bi, err := params[0].TryInteger()
if err != nil {
return nil, fmt.Errorf("invalid stackitem type: %w", err)
}
return Designate{Role: noderoles.Role(bi.Int64())}, nil
}