|
@ -24,11 +24,12 @@ type Client interface { |
|
|
Genesis() (*string, error) |
|
|
Genesis() (*string, error) |
|
|
GetAccount(address []byte) (*ctypes.ResponseGetAccount, error) |
|
|
GetAccount(address []byte) (*ctypes.ResponseGetAccount, error) |
|
|
GetBlock(height uint) (*ctypes.ResponseGetBlock, error) |
|
|
GetBlock(height uint) (*ctypes.ResponseGetBlock, error) |
|
|
|
|
|
GetName(name string) (*types.NameRegEntry, error) |
|
|
GetStorage(address []byte, key []byte) (*ctypes.ResponseGetStorage, error) |
|
|
GetStorage(address []byte, key []byte) (*ctypes.ResponseGetStorage, error) |
|
|
ListAccounts() (*ctypes.ResponseListAccounts, error) |
|
|
ListAccounts() (*ctypes.ResponseListAccounts, error) |
|
|
|
|
|
ListNames() (*ctypes.ResponseListNames, error) |
|
|
ListUnconfirmedTxs() (*ctypes.ResponseListUnconfirmedTxs, error) |
|
|
ListUnconfirmedTxs() (*ctypes.ResponseListUnconfirmedTxs, error) |
|
|
ListValidators() (*ctypes.ResponseListValidators, error) |
|
|
ListValidators() (*ctypes.ResponseListValidators, error) |
|
|
NameRegEntry(name string) (*ctypes.ResponseNameRegEntry, error) |
|
|
|
|
|
NetInfo() (*ctypes.ResponseNetInfo, error) |
|
|
NetInfo() (*ctypes.ResponseNetInfo, error) |
|
|
SignTx(tx types.Tx, privAccounts []*account.PrivAccount) (*ctypes.ResponseSignTx, error) |
|
|
SignTx(tx types.Tx, privAccounts []*account.PrivAccount) (*ctypes.ResponseSignTx, error) |
|
|
Status() (*ctypes.ResponseStatus, error) |
|
|
Status() (*ctypes.ResponseStatus, error) |
|
@ -334,6 +335,36 @@ func (c *ClientHTTP) GetBlock(height uint) (*ctypes.ResponseGetBlock, error) { |
|
|
return response.Result, nil |
|
|
return response.Result, nil |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
func (c *ClientHTTP) GetName(name string) (*types.NameRegEntry, error) { |
|
|
|
|
|
values, err := argsToURLValues([]string{"name"}, name) |
|
|
|
|
|
if err != nil { |
|
|
|
|
|
return nil, err |
|
|
|
|
|
} |
|
|
|
|
|
resp, err := http.PostForm(c.addr+reverseFuncMap["GetName"], values) |
|
|
|
|
|
if err != nil { |
|
|
|
|
|
return nil, err |
|
|
|
|
|
} |
|
|
|
|
|
defer resp.Body.Close() |
|
|
|
|
|
body, err := ioutil.ReadAll(resp.Body) |
|
|
|
|
|
if err != nil { |
|
|
|
|
|
return nil, err |
|
|
|
|
|
} |
|
|
|
|
|
var response struct { |
|
|
|
|
|
Result *types.NameRegEntry `json:"result"` |
|
|
|
|
|
Error string `json:"error"` |
|
|
|
|
|
Id string `json:"id"` |
|
|
|
|
|
JSONRPC string `json:"jsonrpc"` |
|
|
|
|
|
} |
|
|
|
|
|
binary.ReadJSON(&response, body, &err) |
|
|
|
|
|
if err != nil { |
|
|
|
|
|
return nil, err |
|
|
|
|
|
} |
|
|
|
|
|
if response.Error != "" { |
|
|
|
|
|
return nil, fmt.Errorf(response.Error) |
|
|
|
|
|
} |
|
|
|
|
|
return response.Result, nil |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
func (c *ClientHTTP) GetStorage(address []byte, key []byte) (*ctypes.ResponseGetStorage, error) { |
|
|
func (c *ClientHTTP) GetStorage(address []byte, key []byte) (*ctypes.ResponseGetStorage, error) { |
|
|
values, err := argsToURLValues([]string{"address", "key"}, address, key) |
|
|
values, err := argsToURLValues([]string{"address", "key"}, address, key) |
|
|
if err != nil { |
|
|
if err != nil { |
|
@ -394,12 +425,12 @@ func (c *ClientHTTP) ListAccounts() (*ctypes.ResponseListAccounts, error) { |
|
|
return response.Result, nil |
|
|
return response.Result, nil |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
func (c *ClientHTTP) ListUnconfirmedTxs() (*ctypes.ResponseListUnconfirmedTxs, error) { |
|
|
|
|
|
|
|
|
func (c *ClientHTTP) ListNames() (*ctypes.ResponseListNames, error) { |
|
|
values, err := argsToURLValues(nil) |
|
|
values, err := argsToURLValues(nil) |
|
|
if err != nil { |
|
|
if err != nil { |
|
|
return nil, err |
|
|
return nil, err |
|
|
} |
|
|
} |
|
|
resp, err := http.PostForm(c.addr+reverseFuncMap["ListUnconfirmedTxs"], values) |
|
|
|
|
|
|
|
|
resp, err := http.PostForm(c.addr+reverseFuncMap["ListNames"], values) |
|
|
if err != nil { |
|
|
if err != nil { |
|
|
return nil, err |
|
|
return nil, err |
|
|
} |
|
|
} |
|
@ -409,10 +440,10 @@ func (c *ClientHTTP) ListUnconfirmedTxs() (*ctypes.ResponseListUnconfirmedTxs, e |
|
|
return nil, err |
|
|
return nil, err |
|
|
} |
|
|
} |
|
|
var response struct { |
|
|
var response struct { |
|
|
Result *ctypes.ResponseListUnconfirmedTxs `json:"result"` |
|
|
|
|
|
Error string `json:"error"` |
|
|
|
|
|
Id string `json:"id"` |
|
|
|
|
|
JSONRPC string `json:"jsonrpc"` |
|
|
|
|
|
|
|
|
Result *ctypes.ResponseListNames `json:"result"` |
|
|
|
|
|
Error string `json:"error"` |
|
|
|
|
|
Id string `json:"id"` |
|
|
|
|
|
JSONRPC string `json:"jsonrpc"` |
|
|
} |
|
|
} |
|
|
binary.ReadJSON(&response, body, &err) |
|
|
binary.ReadJSON(&response, body, &err) |
|
|
if err != nil { |
|
|
if err != nil { |
|
@ -424,12 +455,12 @@ func (c *ClientHTTP) ListUnconfirmedTxs() (*ctypes.ResponseListUnconfirmedTxs, e |
|
|
return response.Result, nil |
|
|
return response.Result, nil |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
func (c *ClientHTTP) ListValidators() (*ctypes.ResponseListValidators, error) { |
|
|
|
|
|
|
|
|
func (c *ClientHTTP) ListUnconfirmedTxs() (*ctypes.ResponseListUnconfirmedTxs, error) { |
|
|
values, err := argsToURLValues(nil) |
|
|
values, err := argsToURLValues(nil) |
|
|
if err != nil { |
|
|
if err != nil { |
|
|
return nil, err |
|
|
return nil, err |
|
|
} |
|
|
} |
|
|
resp, err := http.PostForm(c.addr+reverseFuncMap["ListValidators"], values) |
|
|
|
|
|
|
|
|
resp, err := http.PostForm(c.addr+reverseFuncMap["ListUnconfirmedTxs"], values) |
|
|
if err != nil { |
|
|
if err != nil { |
|
|
return nil, err |
|
|
return nil, err |
|
|
} |
|
|
} |
|
@ -439,10 +470,10 @@ func (c *ClientHTTP) ListValidators() (*ctypes.ResponseListValidators, error) { |
|
|
return nil, err |
|
|
return nil, err |
|
|
} |
|
|
} |
|
|
var response struct { |
|
|
var response struct { |
|
|
Result *ctypes.ResponseListValidators `json:"result"` |
|
|
|
|
|
Error string `json:"error"` |
|
|
|
|
|
Id string `json:"id"` |
|
|
|
|
|
JSONRPC string `json:"jsonrpc"` |
|
|
|
|
|
|
|
|
Result *ctypes.ResponseListUnconfirmedTxs `json:"result"` |
|
|
|
|
|
Error string `json:"error"` |
|
|
|
|
|
Id string `json:"id"` |
|
|
|
|
|
JSONRPC string `json:"jsonrpc"` |
|
|
} |
|
|
} |
|
|
binary.ReadJSON(&response, body, &err) |
|
|
binary.ReadJSON(&response, body, &err) |
|
|
if err != nil { |
|
|
if err != nil { |
|
@ -454,12 +485,12 @@ func (c *ClientHTTP) ListValidators() (*ctypes.ResponseListValidators, error) { |
|
|
return response.Result, nil |
|
|
return response.Result, nil |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
func (c *ClientHTTP) NameRegEntry(name string) (*ctypes.ResponseNameRegEntry, error) { |
|
|
|
|
|
values, err := argsToURLValues([]string{"name"}, name) |
|
|
|
|
|
|
|
|
func (c *ClientHTTP) ListValidators() (*ctypes.ResponseListValidators, error) { |
|
|
|
|
|
values, err := argsToURLValues(nil) |
|
|
if err != nil { |
|
|
if err != nil { |
|
|
return nil, err |
|
|
return nil, err |
|
|
} |
|
|
} |
|
|
resp, err := http.PostForm(c.addr+reverseFuncMap["NameRegEntry"], values) |
|
|
|
|
|
|
|
|
resp, err := http.PostForm(c.addr+reverseFuncMap["ListValidators"], values) |
|
|
if err != nil { |
|
|
if err != nil { |
|
|
return nil, err |
|
|
return nil, err |
|
|
} |
|
|
} |
|
@ -469,10 +500,10 @@ func (c *ClientHTTP) NameRegEntry(name string) (*ctypes.ResponseNameRegEntry, er |
|
|
return nil, err |
|
|
return nil, err |
|
|
} |
|
|
} |
|
|
var response struct { |
|
|
var response struct { |
|
|
Result *ctypes.ResponseNameRegEntry `json:"result"` |
|
|
|
|
|
Error string `json:"error"` |
|
|
|
|
|
Id string `json:"id"` |
|
|
|
|
|
JSONRPC string `json:"jsonrpc"` |
|
|
|
|
|
|
|
|
Result *ctypes.ResponseListValidators `json:"result"` |
|
|
|
|
|
Error string `json:"error"` |
|
|
|
|
|
Id string `json:"id"` |
|
|
|
|
|
JSONRPC string `json:"jsonrpc"` |
|
|
} |
|
|
} |
|
|
binary.ReadJSON(&response, body, &err) |
|
|
binary.ReadJSON(&response, body, &err) |
|
|
if err != nil { |
|
|
if err != nil { |
|
@ -844,6 +875,33 @@ func (c *ClientJSON) GetBlock(height uint) (*ctypes.ResponseGetBlock, error) { |
|
|
return response.Result, nil |
|
|
return response.Result, nil |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
func (c *ClientJSON) GetName(name string) (*types.NameRegEntry, error) { |
|
|
|
|
|
request := rpctypes.RPCRequest{ |
|
|
|
|
|
JSONRPC: "2.0", |
|
|
|
|
|
Method: reverseFuncMap["GetName"], |
|
|
|
|
|
Params: []interface{}{name}, |
|
|
|
|
|
Id: 0, |
|
|
|
|
|
} |
|
|
|
|
|
body, err := c.RequestResponse(request) |
|
|
|
|
|
if err != nil { |
|
|
|
|
|
return nil, err |
|
|
|
|
|
} |
|
|
|
|
|
var response struct { |
|
|
|
|
|
Result *types.NameRegEntry `json:"result"` |
|
|
|
|
|
Error string `json:"error"` |
|
|
|
|
|
Id string `json:"id"` |
|
|
|
|
|
JSONRPC string `json:"jsonrpc"` |
|
|
|
|
|
} |
|
|
|
|
|
binary.ReadJSON(&response, body, &err) |
|
|
|
|
|
if err != nil { |
|
|
|
|
|
return nil, err |
|
|
|
|
|
} |
|
|
|
|
|
if response.Error != "" { |
|
|
|
|
|
return nil, fmt.Errorf(response.Error) |
|
|
|
|
|
} |
|
|
|
|
|
return response.Result, nil |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
func (c *ClientJSON) GetStorage(address []byte, key []byte) (*ctypes.ResponseGetStorage, error) { |
|
|
func (c *ClientJSON) GetStorage(address []byte, key []byte) (*ctypes.ResponseGetStorage, error) { |
|
|
request := rpctypes.RPCRequest{ |
|
|
request := rpctypes.RPCRequest{ |
|
|
JSONRPC: "2.0", |
|
|
JSONRPC: "2.0", |
|
@ -898,10 +956,10 @@ func (c *ClientJSON) ListAccounts() (*ctypes.ResponseListAccounts, error) { |
|
|
return response.Result, nil |
|
|
return response.Result, nil |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
func (c *ClientJSON) ListUnconfirmedTxs() (*ctypes.ResponseListUnconfirmedTxs, error) { |
|
|
|
|
|
|
|
|
func (c *ClientJSON) ListNames() (*ctypes.ResponseListNames, error) { |
|
|
request := rpctypes.RPCRequest{ |
|
|
request := rpctypes.RPCRequest{ |
|
|
JSONRPC: "2.0", |
|
|
JSONRPC: "2.0", |
|
|
Method: reverseFuncMap["ListUnconfirmedTxs"], |
|
|
|
|
|
|
|
|
Method: reverseFuncMap["ListNames"], |
|
|
Params: []interface{}{}, |
|
|
Params: []interface{}{}, |
|
|
Id: 0, |
|
|
Id: 0, |
|
|
} |
|
|
} |
|
@ -910,10 +968,10 @@ func (c *ClientJSON) ListUnconfirmedTxs() (*ctypes.ResponseListUnconfirmedTxs, e |
|
|
return nil, err |
|
|
return nil, err |
|
|
} |
|
|
} |
|
|
var response struct { |
|
|
var response struct { |
|
|
Result *ctypes.ResponseListUnconfirmedTxs `json:"result"` |
|
|
|
|
|
Error string `json:"error"` |
|
|
|
|
|
Id string `json:"id"` |
|
|
|
|
|
JSONRPC string `json:"jsonrpc"` |
|
|
|
|
|
|
|
|
Result *ctypes.ResponseListNames `json:"result"` |
|
|
|
|
|
Error string `json:"error"` |
|
|
|
|
|
Id string `json:"id"` |
|
|
|
|
|
JSONRPC string `json:"jsonrpc"` |
|
|
} |
|
|
} |
|
|
binary.ReadJSON(&response, body, &err) |
|
|
binary.ReadJSON(&response, body, &err) |
|
|
if err != nil { |
|
|
if err != nil { |
|
@ -925,10 +983,10 @@ func (c *ClientJSON) ListUnconfirmedTxs() (*ctypes.ResponseListUnconfirmedTxs, e |
|
|
return response.Result, nil |
|
|
return response.Result, nil |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
func (c *ClientJSON) ListValidators() (*ctypes.ResponseListValidators, error) { |
|
|
|
|
|
|
|
|
func (c *ClientJSON) ListUnconfirmedTxs() (*ctypes.ResponseListUnconfirmedTxs, error) { |
|
|
request := rpctypes.RPCRequest{ |
|
|
request := rpctypes.RPCRequest{ |
|
|
JSONRPC: "2.0", |
|
|
JSONRPC: "2.0", |
|
|
Method: reverseFuncMap["ListValidators"], |
|
|
|
|
|
|
|
|
Method: reverseFuncMap["ListUnconfirmedTxs"], |
|
|
Params: []interface{}{}, |
|
|
Params: []interface{}{}, |
|
|
Id: 0, |
|
|
Id: 0, |
|
|
} |
|
|
} |
|
@ -937,10 +995,10 @@ func (c *ClientJSON) ListValidators() (*ctypes.ResponseListValidators, error) { |
|
|
return nil, err |
|
|
return nil, err |
|
|
} |
|
|
} |
|
|
var response struct { |
|
|
var response struct { |
|
|
Result *ctypes.ResponseListValidators `json:"result"` |
|
|
|
|
|
Error string `json:"error"` |
|
|
|
|
|
Id string `json:"id"` |
|
|
|
|
|
JSONRPC string `json:"jsonrpc"` |
|
|
|
|
|
|
|
|
Result *ctypes.ResponseListUnconfirmedTxs `json:"result"` |
|
|
|
|
|
Error string `json:"error"` |
|
|
|
|
|
Id string `json:"id"` |
|
|
|
|
|
JSONRPC string `json:"jsonrpc"` |
|
|
} |
|
|
} |
|
|
binary.ReadJSON(&response, body, &err) |
|
|
binary.ReadJSON(&response, body, &err) |
|
|
if err != nil { |
|
|
if err != nil { |
|
@ -952,11 +1010,11 @@ func (c *ClientJSON) ListValidators() (*ctypes.ResponseListValidators, error) { |
|
|
return response.Result, nil |
|
|
return response.Result, nil |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
func (c *ClientJSON) NameRegEntry(name string) (*ctypes.ResponseNameRegEntry, error) { |
|
|
|
|
|
|
|
|
func (c *ClientJSON) ListValidators() (*ctypes.ResponseListValidators, error) { |
|
|
request := rpctypes.RPCRequest{ |
|
|
request := rpctypes.RPCRequest{ |
|
|
JSONRPC: "2.0", |
|
|
JSONRPC: "2.0", |
|
|
Method: reverseFuncMap["NameRegEntry"], |
|
|
|
|
|
Params: []interface{}{name}, |
|
|
|
|
|
|
|
|
Method: reverseFuncMap["ListValidators"], |
|
|
|
|
|
Params: []interface{}{}, |
|
|
Id: 0, |
|
|
Id: 0, |
|
|
} |
|
|
} |
|
|
body, err := c.RequestResponse(request) |
|
|
body, err := c.RequestResponse(request) |
|
@ -964,10 +1022,10 @@ func (c *ClientJSON) NameRegEntry(name string) (*ctypes.ResponseNameRegEntry, er |
|
|
return nil, err |
|
|
return nil, err |
|
|
} |
|
|
} |
|
|
var response struct { |
|
|
var response struct { |
|
|
Result *ctypes.ResponseNameRegEntry `json:"result"` |
|
|
|
|
|
Error string `json:"error"` |
|
|
|
|
|
Id string `json:"id"` |
|
|
|
|
|
JSONRPC string `json:"jsonrpc"` |
|
|
|
|
|
|
|
|
Result *ctypes.ResponseListValidators `json:"result"` |
|
|
|
|
|
Error string `json:"error"` |
|
|
|
|
|
Id string `json:"id"` |
|
|
|
|
|
JSONRPC string `json:"jsonrpc"` |
|
|
} |
|
|
} |
|
|
binary.ReadJSON(&response, body, &err) |
|
|
binary.ReadJSON(&response, body, &err) |
|
|
if err != nil { |
|
|
if err != nil { |
|
|