diff --git a/pkg/rpcclient/helper.go b/pkg/rpcclient/helper.go index 3db0052d3..6f91a5855 100644 --- a/pkg/rpcclient/helper.go +++ b/pkg/rpcclient/helper.go @@ -116,7 +116,14 @@ func (c *Client) InvokeAndPackIteratorResults(contract util.Uint160, operation s if len(maxIteratorResultItems) != 0 { max = maxIteratorResultItems[0] } - bytes, err := smartcontract.CreateCallAndUnwrapIteratorScript(contract, operation, params, max) + values, err := smartcontract.ExpandParameterToEmitable(smartcontract.Parameter{ + Type: smartcontract.ArrayType, + Value: params, + }) + if err != nil { + return nil, fmt.Errorf("expanding params to emitable: %w", err) + } + bytes, err := smartcontract.CreateCallAndUnwrapIteratorScript(contract, operation, max, values.([]interface{})...) if err != nil { return nil, fmt.Errorf("failed to create iterator unwrapper script: %w", err) } diff --git a/pkg/smartcontract/entry.go b/pkg/smartcontract/entry.go index a3fb44262..c6f6b211a 100644 --- a/pkg/smartcontract/entry.go +++ b/pkg/smartcontract/entry.go @@ -18,20 +18,11 @@ import ( // processed this way (and this number can't exceed VM limits), the result of the // script is an array containing extracted value elements. This script can be useful // for interactions with RPC server that have iterator sessions disabled. -func CreateCallAndUnwrapIteratorScript(contract util.Uint160, operation string, params []Parameter, maxIteratorResultItems int) ([]byte, error) { +func CreateCallAndUnwrapIteratorScript(contract util.Uint160, operation string, maxIteratorResultItems int, params ...interface{}) ([]byte, error) { script := io.NewBufBinWriter() emit.Int(script.BinWriter, int64(maxIteratorResultItems)) - // Pack arguments for System.Contract.Call. - arr, err := ExpandParameterToEmitable(Parameter{ - Type: ArrayType, - Value: params, - }) - if err != nil { - return nil, fmt.Errorf("expanding params to emitable: %w", err) - } - emit.Array(script.BinWriter, arr.([]interface{})...) - emit.AppCallNoArgs(script.BinWriter, contract, operation, callflag.All) // The System.Contract.Call itself, it will push Iterator on estack. - emit.Opcodes(script.BinWriter, opcode.NEWARRAY0) // Push new empty array to estack. This array will store iterator's elements. + emit.AppCall(script.BinWriter, contract, operation, callflag.All, params...) // The System.Contract.Call itself, it will push Iterator on estack. + emit.Opcodes(script.BinWriter, opcode.NEWARRAY0) // Push new empty array to estack. This array will store iterator's elements. // Start the iterator traversal cycle. iteratorTraverseCycleStartOffset := script.Len()