Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rpcbinding: handle NULL results for structures, fix #3581 #3584

Merged
merged 1 commit into from
Sep 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -186,10 +186,15 @@ func (c *Contract) UnexportedFieldUnsigned() (*transaction.Transaction, error) {
}

// itemToCrazyStruct converts stack item into *CrazyStruct.
// NULL item is returned as nil pointer without error.
func itemToCrazyStruct(item stackitem.Item, err error) (*CrazyStruct, error) {
if err != nil {
return nil, err
}
_, null := item.(stackitem.Null)
if null {
return nil, nil
}
var res = new(CrazyStruct)
err = res.FromStackItem(item)
return res, err
Expand Down Expand Up @@ -226,10 +231,15 @@ func (res *CrazyStruct) FromStackItem(item stackitem.Item) error {
}

// itemToSimpleStruct converts stack item into *SimpleStruct.
// NULL item is returned as nil pointer without error.
func itemToSimpleStruct(item stackitem.Item, err error) (*SimpleStruct, error) {
if err != nil {
return nil, err
}
_, null := item.(stackitem.Null)
if null {
return nil, nil
}
var res = new(SimpleStruct)
err = res.FromStackItem(item)
return res, err
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -186,10 +186,15 @@ func (c *Contract) UnexportedFieldUnsigned() (*transaction.Transaction, error) {
}

// itemToUnnamed converts stack item into *Unnamed.
// NULL item is returned as nil pointer without error.
func itemToUnnamed(item stackitem.Item, err error) (*Unnamed, error) {
if err != nil {
return nil, err
}
_, null := item.(stackitem.Null)
if null {
return nil, nil
}
var res = new(Unnamed)
err = res.FromStackItem(item)
return res, err
Expand Down Expand Up @@ -226,10 +231,15 @@ func (res *Unnamed) FromStackItem(item stackitem.Item) error {
}

// itemToUnnamedX converts stack item into *UnnamedX.
// NULL item is returned as nil pointer without error.
func itemToUnnamedX(item stackitem.Item, err error) (*UnnamedX, error) {
if err != nil {
return nil, err
}
_, null := item.(stackitem.Null)
if null {
return nil, nil
}
var res = new(UnnamedX)
err = res.FromStackItem(item)
return res, err
Expand Down
55 changes: 55 additions & 0 deletions cli/smartcontract/testdata/rpcbindings/structs/rpcbindings.out
Original file line number Diff line number Diff line change
Expand Up @@ -161,10 +161,15 @@ func (c *ContractReader) Transaction(t *LedgerTransaction) (*LedgerTransaction,
}

// itemToLedgerBlock converts stack item into *LedgerBlock.
// NULL item is returned as nil pointer without error.
func itemToLedgerBlock(item stackitem.Item, err error) (*LedgerBlock, error) {
if err != nil {
return nil, err
}
_, null := item.(stackitem.Null)
if null {
return nil, nil
}
var res = new(LedgerBlock)
err = res.FromStackItem(item)
return res, err
Expand Down Expand Up @@ -289,10 +294,15 @@ func (res *LedgerBlock) FromStackItem(item stackitem.Item) error {
}

// itemToLedgerTransaction converts stack item into *LedgerTransaction.
// NULL item is returned as nil pointer without error.
func itemToLedgerTransaction(item stackitem.Item, err error) (*LedgerTransaction, error) {
if err != nil {
return nil, err
}
_, null := item.(stackitem.Null)
if null {
return nil, nil
}
var res = new(LedgerTransaction)
err = res.FromStackItem(item)
return res, err
Expand Down Expand Up @@ -385,10 +395,15 @@ func (res *LedgerTransaction) FromStackItem(item stackitem.Item) error {
}

// itemToManagementABI converts stack item into *ManagementABI.
// NULL item is returned as nil pointer without error.
func itemToManagementABI(item stackitem.Item, err error) (*ManagementABI, error) {
if err != nil {
return nil, err
}
_, null := item.(stackitem.Null)
if null {
return nil, nil
}
var res = new(ManagementABI)
err = res.FromStackItem(item)
return res, err
Expand Down Expand Up @@ -451,10 +466,15 @@ func (res *ManagementABI) FromStackItem(item stackitem.Item) error {
}

// itemToManagementContract converts stack item into *ManagementContract.
// NULL item is returned as nil pointer without error.
func itemToManagementContract(item stackitem.Item, err error) (*ManagementContract, error) {
if err != nil {
return nil, err
}
_, null := item.(stackitem.Null)
if null {
return nil, nil
}
var res = new(ManagementContract)
err = res.FromStackItem(item)
return res, err
Expand Down Expand Up @@ -519,10 +539,15 @@ func (res *ManagementContract) FromStackItem(item stackitem.Item) error {
}

// itemToManagementEvent converts stack item into *ManagementEvent.
// NULL item is returned as nil pointer without error.
func itemToManagementEvent(item stackitem.Item, err error) (*ManagementEvent, error) {
if err != nil {
return nil, err
}
_, null := item.(stackitem.Null)
if null {
return nil, nil
}
var res = new(ManagementEvent)
err = res.FromStackItem(item)
return res, err
Expand Down Expand Up @@ -581,10 +606,15 @@ func (res *ManagementEvent) FromStackItem(item stackitem.Item) error {
}

// itemToManagementGroup converts stack item into *ManagementGroup.
// NULL item is returned as nil pointer without error.
func itemToManagementGroup(item stackitem.Item, err error) (*ManagementGroup, error) {
if err != nil {
return nil, err
}
_, null := item.(stackitem.Null)
if null {
return nil, nil
}
var res = new(ManagementGroup)
err = res.FromStackItem(item)
return res, err
Expand Down Expand Up @@ -631,10 +661,15 @@ func (res *ManagementGroup) FromStackItem(item stackitem.Item) error {
}

// itemToManagementManifest converts stack item into *ManagementManifest.
// NULL item is returned as nil pointer without error.
func itemToManagementManifest(item stackitem.Item, err error) (*ManagementManifest, error) {
if err != nil {
return nil, err
}
_, null := item.(stackitem.Null)
if null {
return nil, nil
}
var res = new(ManagementManifest)
err = res.FromStackItem(item)
return res, err
Expand Down Expand Up @@ -823,10 +858,15 @@ func (res *ManagementManifest) FromStackItem(item stackitem.Item) error {
}

// itemToManagementMethod converts stack item into *ManagementMethod.
// NULL item is returned as nil pointer without error.
func itemToManagementMethod(item stackitem.Item, err error) (*ManagementMethod, error) {
if err != nil {
return nil, err
}
_, null := item.(stackitem.Null)
if null {
return nil, nil
}
var res = new(ManagementMethod)
err = res.FromStackItem(item)
return res, err
Expand Down Expand Up @@ -903,10 +943,15 @@ func (res *ManagementMethod) FromStackItem(item stackitem.Item) error {
}

// itemToManagementParameter converts stack item into *ManagementParameter.
// NULL item is returned as nil pointer without error.
func itemToManagementParameter(item stackitem.Item, err error) (*ManagementParameter, error) {
if err != nil {
return nil, err
}
_, null := item.(stackitem.Null)
if null {
return nil, nil
}
var res = new(ManagementParameter)
err = res.FromStackItem(item)
return res, err
Expand Down Expand Up @@ -952,10 +997,15 @@ func (res *ManagementParameter) FromStackItem(item stackitem.Item) error {
}

// itemToManagementPermission converts stack item into *ManagementPermission.
// NULL item is returned as nil pointer without error.
func itemToManagementPermission(item stackitem.Item, err error) (*ManagementPermission, error) {
if err != nil {
return nil, err
}
_, null := item.(stackitem.Null)
if null {
return nil, nil
}
var res = new(ManagementPermission)
err = res.FromStackItem(item)
return res, err
Expand Down Expand Up @@ -1024,10 +1074,15 @@ func (res *ManagementPermission) FromStackItem(item stackitem.Item) error {
}

// itemToStructsInternal converts stack item into *StructsInternal.
// NULL item is returned as nil pointer without error.
func itemToStructsInternal(item stackitem.Item, err error) (*StructsInternal, error) {
if err != nil {
return nil, err
}
_, null := item.(stackitem.Null)
if null {
return nil, nil
}
var res = new(StructsInternal)
err = res.FromStackItem(item)
return res, err
Expand Down
Loading
Loading