mirror of
https://github.com/nspcc-dev/neo-go.git
synced 2025-05-06 19:55:10 +00:00
core: allow Null in System.Contract.Update
Null means absense of script or manifest, empty byte-slice is an error. Related #1459.
This commit is contained in:
parent
0e82d4cbd1
commit
0b76f875c7
3 changed files with 61 additions and 24 deletions
|
@ -100,6 +100,19 @@ func (e *Element) Bytes() []byte {
|
|||
return bs
|
||||
}
|
||||
|
||||
// BytesOrNil attempts to get the underlying value of the element as a byte array or nil.
|
||||
// Will panic if the assertion failed which will be caught by the VM.
|
||||
func (e *Element) BytesOrNil() []byte {
|
||||
if _, ok := e.value.(stackitem.Null); ok {
|
||||
return nil
|
||||
}
|
||||
bs, err := e.value.TryBytes()
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return bs
|
||||
}
|
||||
|
||||
// String attempts to get string from the element value.
|
||||
// It is assumed to be use in interops and panics if string is not a valid UTF-8 byte sequence.
|
||||
func (e *Element) String() string {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue