From 3e221b973a3cfe387113990bab56b33f78bc0c18 Mon Sep 17 00:00:00 2001 From: Evgenii Stratonikov Date: Mon, 9 Sep 2024 10:27:09 +0300 Subject: [PATCH] [#113] Regenerate wrappers Signed-off-by: Evgenii Stratonikov --- rpcclient/nns/client.go | 73 ----------------------------------------- 1 file changed, 73 deletions(-) diff --git a/rpcclient/nns/client.go b/rpcclient/nns/client.go index 014cbda..b2cfa46 100644 --- a/rpcclient/nns/client.go +++ b/rpcclient/nns/client.go @@ -29,12 +29,6 @@ type AddRecordEvent struct { Type *big.Int } -// SetRecordEvent represents "SetRecord" event emitted by the contract. -type SetRecordEvent struct { - Name string - Type *big.Int -} - // DeleteRecordsEvent represents "DeleteRecords" event emitted by the contract. type DeleteRecordsEvent struct { Name string @@ -516,73 +510,6 @@ func (e *AddRecordEvent) FromStackItem(item *stackitem.Array) error { return nil } -// SetRecordEventsFromApplicationLog retrieves a set of all emitted events -// with "SetRecord" name from the provided [result.ApplicationLog]. -func SetRecordEventsFromApplicationLog(log *result.ApplicationLog) ([]*SetRecordEvent, error) { - if log == nil { - return nil, errors.New("nil application log") - } - - var res []*SetRecordEvent - for i, ex := range log.Executions { - for j, e := range ex.Events { - if e.Name != "SetRecord" { - continue - } - event := new(SetRecordEvent) - err := event.FromStackItem(e.Item) - if err != nil { - return nil, fmt.Errorf("failed to deserialize SetRecordEvent from stackitem (execution #%d, event #%d): %w", i, j, err) - } - res = append(res, event) - } - } - - return res, nil -} - -// FromStackItem converts provided [stackitem.Array] to SetRecordEvent or -// returns an error if it's not possible to do to so. -func (e *SetRecordEvent) 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.Name, err = func(item stackitem.Item) (string, error) { - b, err := item.TryBytes() - if err != nil { - return "", err - } - if !utf8.Valid(b) { - return "", errors.New("not a UTF-8 string") - } - return string(b), nil - }(arr[index]) - if err != nil { - return fmt.Errorf("field Name: %w", err) - } - - index++ - e.Type, err = arr[index].TryInteger() - if err != nil { - return fmt.Errorf("field Type: %w", err) - } - - return nil -} - // DeleteRecordsEventsFromApplicationLog retrieves a set of all emitted events // with "DeleteRecords" name from the provided [result.ApplicationLog]. func DeleteRecordsEventsFromApplicationLog(log *result.ApplicationLog) ([]*DeleteRecordsEvent, error) {