RPC invocation parameters (#106)
* added rpc.invoke and parameters marshalling * removed debug output * stringer and marshalling corrections * version
This commit is contained in:
parent
6ccb518ab0
commit
de45c58551
2 changed files with 42 additions and 0 deletions
|
@ -57,6 +57,19 @@ func (c *Client) InvokeFunction(script, operation string, params []smartcontract
|
||||||
return resp, nil
|
return resp, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// InvokeFunction return the results after calling a the smart contract scripthash
|
||||||
|
// with the given parameters.
|
||||||
|
func (c *Client) Invoke(script string, params []smartcontract.Parameter) (*InvokeScriptResponse, error) {
|
||||||
|
var (
|
||||||
|
p = newParams(script, params)
|
||||||
|
resp = &InvokeScriptResponse{}
|
||||||
|
)
|
||||||
|
if err := c.performRequest("invoke", p, resp); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
// GetRawTransaction queries a transaction by hash.
|
// GetRawTransaction queries a transaction by hash.
|
||||||
func (c *Client) GetRawTransaction(hash string, verbose bool) (*response, error) {
|
func (c *Client) GetRawTransaction(hash string, verbose bool) (*response, error) {
|
||||||
var (
|
var (
|
||||||
|
|
|
@ -26,6 +26,35 @@ type Parameter struct {
|
||||||
Value interface{} `json:"value"`
|
Value interface{} `json:"value"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (pt ParamType) String() string {
|
||||||
|
switch pt {
|
||||||
|
case SignatureType:
|
||||||
|
return "Signature"
|
||||||
|
case BoolType:
|
||||||
|
return "Boolean"
|
||||||
|
case IntegerType:
|
||||||
|
return "Integer"
|
||||||
|
case Hash160Type:
|
||||||
|
return "Hash160"
|
||||||
|
case Hash256Type:
|
||||||
|
return "Hash256"
|
||||||
|
case ByteArrayType:
|
||||||
|
return "ByteArray"
|
||||||
|
case PublicKeyType:
|
||||||
|
return "PublicKey"
|
||||||
|
case StringType:
|
||||||
|
return "String"
|
||||||
|
case ArrayType:
|
||||||
|
return "Array"
|
||||||
|
default:
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (pt ParamType) MarshalJSON() ([]byte, error) {
|
||||||
|
return []byte(`"` + pt.String() + `"`), nil
|
||||||
|
}
|
||||||
|
|
||||||
// NewParameter returns a Parameter with proper initialized Value
|
// NewParameter returns a Parameter with proper initialized Value
|
||||||
// of the given ParamType.
|
// of the given ParamType.
|
||||||
func NewParameter(t ParamType) Parameter {
|
func NewParameter(t ParamType) Parameter {
|
||||||
|
|
Loading…
Reference in a new issue