mirror of
https://github.com/nspcc-dev/neo-go.git
synced 2025-05-04 09:02:28 +00:00
RPC client (#42)
* Started RPC package to allow querying balances and sending raw transactions for sc's * integrate invoke cmd in cli * bumped version * added sendrawtransaction to the rpc client.
This commit is contained in:
parent
1a1a19da7d
commit
b2a5e34aac
7 changed files with 343 additions and 4 deletions
72
pkg/rpc/types.go
Normal file
72
pkg/rpc/types.go
Normal file
|
@ -0,0 +1,72 @@
|
|||
package rpc
|
||||
|
||||
type InvokeScriptResponse struct {
|
||||
responseHeader
|
||||
Result *InvokeResult
|
||||
}
|
||||
|
||||
// InvokeResult represents the outcome of a script that is
|
||||
// executed by the NEO VM.
|
||||
type InvokeResult struct {
|
||||
State string `json:"state"`
|
||||
GasConsumed string `json:"gas_consumed"`
|
||||
Stack []*StackParam
|
||||
}
|
||||
|
||||
// StackParam respresent a stack parameter.
|
||||
type StackParam struct {
|
||||
Type string `json:"type"`
|
||||
Value string `json:"value"`
|
||||
}
|
||||
|
||||
// AccountStateResponse holds the getaccountstate response.
|
||||
type AccountStateResponse struct {
|
||||
responseHeader
|
||||
Result *Account `json:"result"`
|
||||
}
|
||||
|
||||
// Account respresents details about a NEO account.
|
||||
type Account struct {
|
||||
Version int `json:"version"`
|
||||
ScriptHash string `json:"script_hash"`
|
||||
Frozen bool
|
||||
// TODO: need to check this field out.
|
||||
Votes []interface{}
|
||||
Balances []*Balance
|
||||
}
|
||||
|
||||
// Balance respresents details about a NEO account balance.
|
||||
type Balance struct {
|
||||
Asset string `json:"asset"`
|
||||
Value string `json:"value"`
|
||||
}
|
||||
|
||||
type params struct {
|
||||
values []interface{}
|
||||
}
|
||||
|
||||
func newParams(vals ...interface{}) params {
|
||||
p := params{}
|
||||
p.values = make([]interface{}, len(vals))
|
||||
for i := 0; i < len(p.values); i++ {
|
||||
p.values[i] = vals[i]
|
||||
}
|
||||
return p
|
||||
}
|
||||
|
||||
type request struct {
|
||||
JSONRPC string `json:"jsonrpc"`
|
||||
Method string `json:"method"`
|
||||
Params []interface{} `json:"params"`
|
||||
ID int `json:"id"`
|
||||
}
|
||||
|
||||
type responseHeader struct {
|
||||
ID int `json:"id"`
|
||||
JSONRPC string `json:"jsonrpc"`
|
||||
}
|
||||
|
||||
type response struct {
|
||||
responseHeader
|
||||
Result interface{} `json:"result"`
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue