Merge pull request #1047 from nspcc-dev/neo3/rpc/invoke
rpc: update invoke* RPC-calls
This commit is contained in:
commit
fe31c7ed2d
15 changed files with 464 additions and 187 deletions
|
@ -339,11 +339,16 @@ func (c *Client) GetVersion() (*result.Version, error) {
|
|||
|
||||
// InvokeScript returns the result of the given script after running it true the VM.
|
||||
// NOTE: This is a test invoke and will not affect the blockchain.
|
||||
func (c *Client) InvokeScript(script string) (*result.Invoke, error) {
|
||||
func (c *Client) InvokeScript(script string, cosigners []transaction.Cosigner) (*result.Invoke, error) {
|
||||
var (
|
||||
params = request.NewRawParams(script)
|
||||
params request.RawParams
|
||||
resp = &result.Invoke{}
|
||||
)
|
||||
if cosigners != nil {
|
||||
params = request.NewRawParams(script, cosigners)
|
||||
} else {
|
||||
params = request.NewRawParams(script)
|
||||
}
|
||||
if err := c.performRequest("invokescript", params, resp); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -353,25 +358,17 @@ func (c *Client) InvokeScript(script string) (*result.Invoke, error) {
|
|||
// InvokeFunction returns the results after calling the smart contract scripthash
|
||||
// with the given operation and parameters.
|
||||
// NOTE: this is test invoke and will not affect the blockchain.
|
||||
func (c *Client) InvokeFunction(script, operation string, params []smartcontract.Parameter) (*result.Invoke, error) {
|
||||
func (c *Client) InvokeFunction(script, operation string, params []smartcontract.Parameter, cosigners []transaction.Cosigner) (*result.Invoke, error) {
|
||||
var (
|
||||
p = request.NewRawParams(script, operation, params)
|
||||
p request.RawParams
|
||||
resp = &result.Invoke{}
|
||||
)
|
||||
if err := c.performRequest("invokefunction", p, resp); err != nil {
|
||||
return nil, err
|
||||
if cosigners != nil {
|
||||
p = request.NewRawParams(script, operation, params, cosigners)
|
||||
} else {
|
||||
p = request.NewRawParams(script, operation, params)
|
||||
}
|
||||
return resp, nil
|
||||
}
|
||||
|
||||
// Invoke returns the results after calling the smart contract scripthash
|
||||
// with the given parameters.
|
||||
func (c *Client) Invoke(script string, params []smartcontract.Parameter) (*result.Invoke, error) {
|
||||
var (
|
||||
p = request.NewRawParams(script, params)
|
||||
resp = &result.Invoke{}
|
||||
)
|
||||
if err := c.performRequest("invoke", p, resp); err != nil {
|
||||
if err := c.performRequest("invokefunction", p, resp); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return resp, nil
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue