diff --git a/pkg/rpc/crawler.go b/pkg/rpc/crawler.go index 7d789ae..5862b9d 100644 --- a/pkg/rpc/crawler.go +++ b/pkg/rpc/crawler.go @@ -41,6 +41,22 @@ func (s *CrawlerService) GetNetworkInfo(opts *GetNetworkInfoOptions) (*GetNetwor return r, resp, nil } +// GetVersion returns the application version for the service +func (s *CrawlerService) GetVersion(opts *GetVersionOptions) (*GetVersionResponse, *http.Response, error) { + request, err := s.NewRequest("get_version", opts) + if err != nil { + return nil, nil, err + } + + r := &GetVersionResponse{} + resp, err := s.Do(request, r) + if err != nil { + return nil, resp, err + } + + return r, resp, nil +} + // GetPeerCountsResponse Response for get_get_peer_counts on crawler type GetPeerCountsResponse struct { Response diff --git a/pkg/rpc/daemon.go b/pkg/rpc/daemon.go index 3cf2d67..f6f4866 100644 --- a/pkg/rpc/daemon.go +++ b/pkg/rpc/daemon.go @@ -39,6 +39,22 @@ func (s *DaemonService) GetNetworkInfo(opts *GetNetworkInfoOptions) (*GetNetwork return r, resp, nil } +// GetVersion returns the application version for the service +func (s *DaemonService) GetVersion(opts *GetVersionOptions) (*GetVersionResponse, *http.Response, error) { + request, err := s.NewRequest("get_version", opts) + if err != nil { + return nil, nil, err + } + + r := &GetVersionResponse{} + resp, err := s.Do(request, r) + if err != nil { + return nil, resp, err + } + + return r, resp, nil +} + // GetKeysOptions configures how keys are returned in get_keys type GetKeysOptions struct { IncludeSecrets bool `json:"include_secrets"` diff --git a/pkg/rpc/datalayer.go b/pkg/rpc/datalayer.go index f4dc6ee..588cd73 100644 --- a/pkg/rpc/datalayer.go +++ b/pkg/rpc/datalayer.go @@ -20,3 +20,19 @@ func (s *DataLayerService) NewRequest(rpcEndpoint rpcinterface.Endpoint, opt int func (s *DataLayerService) Do(req *rpcinterface.Request, v interface{}) (*http.Response, error) { return s.client.Do(req, v) } + +// GetVersion returns the application version for the service +func (s *DataLayerService) GetVersion(opts *GetVersionOptions) (*GetVersionResponse, *http.Response, error) { + request, err := s.NewRequest("get_version", opts) + if err != nil { + return nil, nil, err + } + + r := &GetVersionResponse{} + resp, err := s.Do(request, r) + if err != nil { + return nil, resp, err + } + + return r, resp, nil +} diff --git a/pkg/rpc/farmer.go b/pkg/rpc/farmer.go index 15abd5e..04b85d4 100644 --- a/pkg/rpc/farmer.go +++ b/pkg/rpc/farmer.go @@ -58,6 +58,22 @@ func (s *FarmerService) GetNetworkInfo(opts *GetNetworkInfoOptions) (*GetNetwork return r, resp, nil } +// GetVersion returns the application version for the service +func (s *FarmerService) GetVersion(opts *GetVersionOptions) (*GetVersionResponse, *http.Response, error) { + request, err := s.NewRequest("get_version", opts) + if err != nil { + return nil, nil, err + } + + r := &GetVersionResponse{} + resp, err := s.Do(request, r) + if err != nil { + return nil, resp, err + } + + return r, resp, nil +} + // FarmerGetHarvestersOptions optoins for get_harvesters endpoint. Currently, accepts no options type FarmerGetHarvestersOptions struct{} diff --git a/pkg/rpc/fullnode.go b/pkg/rpc/fullnode.go index e1d9c9d..ba587b1 100644 --- a/pkg/rpc/fullnode.go +++ b/pkg/rpc/fullnode.go @@ -74,6 +74,22 @@ type GetBlockchainStateResponse struct { BlockchainState mo.Option[types.BlockchainState] `json:"blockchain_state,omitempty"` } +// GetVersion returns the application version for the service +func (s *FullNodeService) GetVersion(opts *GetVersionOptions) (*GetVersionResponse, *http.Response, error) { + request, err := s.NewRequest("get_version", opts) + if err != nil { + return nil, nil, err + } + + r := &GetVersionResponse{} + resp, err := s.Do(request, r) + if err != nil { + return nil, resp, err + } + + return r, resp, nil +} + // GetBlockchainState returns blockchain state func (s *FullNodeService) GetBlockchainState() (*GetBlockchainStateResponse, *http.Response, error) { request, err := s.NewRequest("get_blockchain_state", nil) diff --git a/pkg/rpc/harvester.go b/pkg/rpc/harvester.go index 556c349..80b14b2 100644 --- a/pkg/rpc/harvester.go +++ b/pkg/rpc/harvester.go @@ -57,6 +57,22 @@ func (s *HarvesterService) GetNetworkInfo(opts *GetNetworkInfoOptions) (*GetNetw return r, resp, nil } +// GetVersion returns the application version for the service +func (s *HarvesterService) GetVersion(opts *GetVersionOptions) (*GetVersionResponse, *http.Response, error) { + request, err := s.NewRequest("get_version", opts) + if err != nil { + return nil, nil, err + } + + r := &GetVersionResponse{} + resp, err := s.Do(request, r) + if err != nil { + return nil, resp, err + } + + return r, resp, nil +} + // HarvesterGetPlotsResponse get_plots response format type HarvesterGetPlotsResponse struct { Response diff --git a/pkg/rpc/shared.go b/pkg/rpc/shared.go index 2d189b9..3dab056 100644 --- a/pkg/rpc/shared.go +++ b/pkg/rpc/shared.go @@ -13,3 +13,12 @@ type GetNetworkInfoResponse struct { NetworkName mo.Option[string] `json:"network_name"` NetworkPrefix mo.Option[string] `json:"network_prefix"` } + +// GetVersionOptions options for the get_version rpc calls +type GetVersionOptions struct{} + +// GetVersionResponse is the response of get_version from all RPC services +type GetVersionResponse struct { + Response + Version string `json:"version"` +} diff --git a/pkg/rpc/timelord.go b/pkg/rpc/timelord.go index 9ca4b93..f102e3b 100644 --- a/pkg/rpc/timelord.go +++ b/pkg/rpc/timelord.go @@ -53,3 +53,19 @@ func (s *TimelordService) GetNetworkInfo(opts *GetNetworkInfoOptions) (*GetNetwo return r, resp, nil } + +// GetVersion returns the application version for the service +func (s *TimelordService) GetVersion(opts *GetVersionOptions) (*GetVersionResponse, *http.Response, error) { + request, err := s.NewRequest("get_version", opts) + if err != nil { + return nil, nil, err + } + + r := &GetVersionResponse{} + resp, err := s.Do(request, r) + if err != nil { + return nil, resp, err + } + + return r, resp, nil +} diff --git a/pkg/rpc/wallet.go b/pkg/rpc/wallet.go index b5e9654..b266eb7 100644 --- a/pkg/rpc/wallet.go +++ b/pkg/rpc/wallet.go @@ -56,6 +56,22 @@ func (s *WalletService) GetNetworkInfo(opts *GetNetworkInfoOptions) (*GetNetwork return r, resp, nil } +// GetVersion returns the application version for the service +func (s *WalletService) GetVersion(opts *GetVersionOptions) (*GetVersionResponse, *http.Response, error) { + request, err := s.NewRequest("get_version", opts) + if err != nil { + return nil, nil, err + } + + r := &GetVersionResponse{} + resp, err := s.Do(request, r) + if err != nil { + return nil, resp, err + } + + return r, resp, nil +} + // GetPublicKeysResponse response from get_public_keys type GetPublicKeysResponse struct { Response