diff --git a/pkg/rpc/client/rpc.go b/pkg/rpc/client/rpc.go index 07da05f13..7466be043 100644 --- a/pkg/rpc/client/rpc.go +++ b/pkg/rpc/client/rpc.go @@ -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()) diff --git a/pkg/rpc/server/client_test.go b/pkg/rpc/server/client_test.go index ddc2b1c1d..c99bdfe5c 100644 --- a/pkg/rpc/server/client_test.go +++ b/pkg/rpc/server/client_test.go @@ -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) +}