frostfs: Remove AlphabetUpdate event from the configuration #138
2 changed files with 0 additions and 83 deletions
|
@ -47,12 +47,6 @@ events:
|
||||||
type: ByteArray
|
type: ByteArray
|
||||||
- name: keys
|
- name: keys
|
||||||
type: Array
|
type: Array
|
||||||
- name: AlphabetUpdate
|
|
||||||
parameters:
|
|
||||||
- name: id
|
|
||||||
type: ByteArray
|
|
||||||
- name: alphabet
|
|
||||||
type: Array
|
|
||||||
- name: SetConfig
|
- name: SetConfig
|
||||||
parameters:
|
parameters:
|
||||||
- name: id
|
- name: id
|
||||||
|
|
|
@ -50,12 +50,6 @@ type UnbindEvent struct {
|
||||||
Keys []any
|
Keys []any
|
||||||
}
|
}
|
||||||
|
|
||||||
// AlphabetUpdateEvent represents "AlphabetUpdate" event emitted by the contract.
|
|
||||||
type AlphabetUpdateEvent struct {
|
|
||||||
Id []byte
|
|
||||||
Alphabet []any
|
|
||||||
}
|
|
||||||
|
|
||||||
// SetConfigEvent represents "SetConfig" event emitted by the contract.
|
// SetConfigEvent represents "SetConfig" event emitted by the contract.
|
||||||
type SetConfigEvent struct {
|
type SetConfigEvent struct {
|
||||||
Id []byte
|
Id []byte
|
||||||
|
@ -710,77 +704,6 @@ func (e *UnbindEvent) FromStackItem(item *stackitem.Array) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// AlphabetUpdateEventsFromApplicationLog retrieves a set of all emitted events
|
|
||||||
// with "AlphabetUpdate" name from the provided [result.ApplicationLog].
|
|
||||||
func AlphabetUpdateEventsFromApplicationLog(log *result.ApplicationLog) ([]*AlphabetUpdateEvent, error) {
|
|
||||||
if log == nil {
|
|
||||||
return nil, errors.New("nil application log")
|
|
||||||
}
|
|
||||||
|
|
||||||
var res []*AlphabetUpdateEvent
|
|
||||||
for i, ex := range log.Executions {
|
|
||||||
for j, e := range ex.Events {
|
|
||||||
if e.Name != "AlphabetUpdate" {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
event := new(AlphabetUpdateEvent)
|
|
||||||
err := event.FromStackItem(e.Item)
|
|
||||||
if err != nil {
|
|
||||||
return nil, fmt.Errorf("failed to deserialize AlphabetUpdateEvent from stackitem (execution #%d, event #%d): %w", i, j, err)
|
|
||||||
}
|
|
||||||
res = append(res, event)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return res, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// FromStackItem converts provided [stackitem.Array] to AlphabetUpdateEvent or
|
|
||||||
// returns an error if it's not possible to do to so.
|
|
||||||
func (e *AlphabetUpdateEvent) FromStackItem(item *stackitem.Array) error {
|
|
||||||
if item == nil {
|
|
||||||
return errors.New("nil item")
|
|
||||||
}
|
|
||||||
arr, ok := item.Value().([]stackitem.Item)
|
|
||||||
if !ok {
|
|
||||||
return errors.New("not an array")
|
|
||||||
}
|
|
||||||
if len(arr) != 2 {
|
|
||||||
return errors.New("wrong number of structure elements")
|
|
||||||
}
|
|
||||||
|
|
||||||
var (
|
|
||||||
index = -1
|
|
||||||
err error
|
|
||||||
)
|
|
||||||
index++
|
|
||||||
e.Id, err = arr[index].TryBytes()
|
|
||||||
if err != nil {
|
|
||||||
return fmt.Errorf("field Id: %w", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
index++
|
|
||||||
e.Alphabet, err = func(item stackitem.Item) ([]any, error) {
|
|
||||||
arr, ok := item.Value().([]stackitem.Item)
|
|
||||||
if !ok {
|
|
||||||
return nil, errors.New("not an array")
|
|
||||||
}
|
|
||||||
res := make([]any, len(arr))
|
|
||||||
for i := range res {
|
|
||||||
res[i], err = arr[i].Value(), error(nil)
|
|
||||||
if err != nil {
|
|
||||||
return nil, fmt.Errorf("item %d: %w", i, err)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return res, nil
|
|
||||||
}(arr[index])
|
|
||||||
if err != nil {
|
|
||||||
return fmt.Errorf("field Alphabet: %w", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// SetConfigEventsFromApplicationLog retrieves a set of all emitted events
|
// SetConfigEventsFromApplicationLog retrieves a set of all emitted events
|
||||||
// with "SetConfig" name from the provided [result.ApplicationLog].
|
// with "SetConfig" name from the provided [result.ApplicationLog].
|
||||||
func SetConfigEventsFromApplicationLog(log *result.ApplicationLog) ([]*SetConfigEvent, error) {
|
func SetConfigEventsFromApplicationLog(log *result.ApplicationLog) ([]*SetConfigEvent, error) {
|
||||||
|
|
Loading…
Reference in a new issue