diff --git a/pkg/vm/stack.go b/pkg/vm/stack.go index e0987637d..86f652166 100644 --- a/pkg/vm/stack.go +++ b/pkg/vm/stack.go @@ -92,6 +92,8 @@ func (e *Element) Bool() bool { } } return false + case *InteropItem: + return t.value != nil default: panic("can't convert to bool: " + t.String()) } diff --git a/pkg/vm/stack_item.go b/pkg/vm/stack_item.go index 9389178f8..b00d32383 100644 --- a/pkg/vm/stack_item.go +++ b/pkg/vm/stack_item.go @@ -248,3 +248,30 @@ func toMapKey(key StackItem) interface{} { panic("wrong key type") } } + +// InteropItem represents interop data on the stack. +type InteropItem struct { + value interface{} +} + +// NewInteropItem returns new InteropItem object. +func NewInteropItem(value interface{}) *InteropItem { + return &InteropItem{ + value: value, + } +} + +// Value implements StackItem interface. +func (i *InteropItem) Value() interface{} { + return i.value +} + +// String implements stringer interface. +func (i *InteropItem) String() string { + return "InteropItem" +} + +// MarshalJSON implements the json.Marshaler interface. +func (i *InteropItem) MarshalJSON() ([]byte, error) { + return json.Marshal(i.value) +}