rpc/client: implement GetNativeContracts

This commit is contained in:
Evgeniy Stratonikov 2021-02-11 12:37:03 +03:00
parent 02ca3d3dfd
commit 4f1bea0bcb
2 changed files with 26 additions and 0 deletions

View file

@ -240,6 +240,18 @@ func (c *Client) getContractState(param interface{}) (*state.Contract, error) {
return resp, nil
}
// GetNativeContracts queries information about native contracts.
func (c *Client) GetNativeContracts() ([]state.NativeContract, error) {
var (
params = request.NewRawParams()
resp []state.NativeContract
)
if err := c.performRequest("getnativecontracts", params, &resp); err != nil {
return resp, err
}
return resp, nil
}
// GetNEP17Balances is a wrapper for getnep17balances RPC.
func (c *Client) GetNEP17Balances(address util.Uint160) (*result.NEP17Balances, error) {
params := request.NewRawParams(address.StringLE())

View file

@ -322,3 +322,17 @@ func TestInvokeVerify(t *testing.T) {
require.False(t, res.Stack[0].Value().(bool))
})
}
func TestClient_GetNativeContracts(t *testing.T) {
chain, rpcSrv, httpSrv := initServerWithInMemoryChain(t)
defer chain.Close()
defer rpcSrv.Shutdown()
c, err := client.New(context.Background(), httpSrv.URL, client.Options{})
require.NoError(t, err)
require.NoError(t, c.Init())
cs, err := c.GetNativeContracts()
require.NoError(t, err)
require.Equal(t, chain.GetNatives(), cs)
}