def get_stakers(self, ws_url: str, stash_account_address: str) \ -> PolkadotWrapperType: api_call = 'staking/stakers' endpoint = self._api_endpoint + '/api/query/' + api_call params = { 'websocket': ws_url, 'account_address': stash_account_address } return get_polkadot_json(endpoint, params, self._logger, api_call)
def get_received_heartbeats(self, ws_url: str, session_index: int, auth_index: int) -> PolkadotWrapperType: api_call = 'imOnline/receivedHeartbeats' endpoint = self._api_endpoint + '/api/query/' + api_call params = { 'websocket': ws_url, 'auth_index': auth_index, 'session_index': session_index } return get_polkadot_json(endpoint, params, self._logger, api_call)
def get_slash_amount(self, ws_url: str, block_hash: Optional[str], stash_account_address: str) -> PolkadotWrapperType: api_call = 'custom/getSlashAmount' endpoint = self._api_endpoint + '/api/' + api_call params = { 'websocket': ws_url, 'block_hash': block_hash, 'account_address': stash_account_address } return get_polkadot_json(endpoint, params, self._logger, api_call)
def get_authored_blocks(self, ws_url: str, session_index: int, validator_id: str) -> PolkadotWrapperType: api_call = 'imOnline/authoredBlocks' endpoint = self._api_endpoint + '/api/query/' + api_call params = { 'websocket': ws_url, 'validator_id': validator_id, 'session_index': session_index } return get_polkadot_json(endpoint, params, self._logger, api_call)
def get_system_health(self, ws_url: str) -> PolkadotWrapperType: api_call = 'system/health' endpoint = self._api_endpoint + '/api/rpc/' + api_call params = {'websocket': ws_url} return get_polkadot_json(endpoint, params, self._logger, api_call)
def test_get_polka_json_error_if_no_reply_from_node(self, _): try: get_polkadot_json(ENDPOINT, PARAMS, LOGGER, API_CALL) self.fail('Expected ConnectionWithNodeApiLostException') except ConnectionWithNodeApiLostException: pass
def test_get_polka_json_error_if_api_call_failed(self, _): try: get_polkadot_json(ENDPOINT, PARAMS, LOGGER, API_CALL) self.fail('Expected ApiCallFailedException') except ApiCallFailedException: pass
def test_get_polka_json_error_if_api_returns_unexpected_key(self, _): try: get_polkadot_json(ENDPOINT, PARAMS, LOGGER, API_CALL) self.fail('Expected UnexpectedApiErrorWhenReadingDataException') except UnexpectedApiErrorWhenReadingDataException: pass
def test_get_polka_json_error_if_node_is_not_an_archive_node(self, _): try: get_polkadot_json(ENDPOINT, PARAMS, LOGGER, API_CALL) self.fail('Expected NodeIsNotAnArchiveNodeException') except NodeIsNotAnArchiveNodeException: pass
def get_referendum_info_of(self, ws_url: str, referendum_index: int) \ -> PolkadotWrapperType: api_call = 'democracy/referendumInfoOf' endpoint = self._api_endpoint + '/api/query/' + api_call params = {'websocket': ws_url, 'referendum_index': referendum_index} return get_polkadot_json(endpoint, params, self._logger, api_call)
def get_events(self, ws_url: str, block_hash: Optional[str]) \ -> PolkadotWrapperType: api_call = 'system/events' endpoint = self._api_endpoint + '/api/query/' + api_call params = {'websocket': ws_url, 'block_hash': block_hash} return get_polkadot_json(endpoint, params, self._logger, api_call)
def get_active_era(self, ws_url: str) -> PolkadotWrapperType: api_call = 'staking/activeEra' endpoint = self._api_endpoint + '/api/query/' + api_call params = {'websocket': ws_url} return get_polkadot_json(endpoint, params, self._logger, api_call)
def get_derive_staking_validators(self, ws_url: str) \ -> PolkadotWrapperType: api_call = 'staking/validators' endpoint = self._api_endpoint + '/api/derive/' + api_call params = {'websocket': ws_url} return get_polkadot_json(endpoint, params, self._logger, api_call)
def get_session_validators(self, ws_url: str) -> PolkadotWrapperType: api_call = 'session/validators' endpoint = self._api_endpoint + '/api/query/' + api_call params = {'websocket': ws_url} return get_polkadot_json(endpoint, params, self._logger, api_call)
def get_current_index(self, ws_url: str) -> PolkadotWrapperType: api_call = 'session/currentIndex' endpoint = self._api_endpoint + '/api/query/' + api_call params = {'websocket': ws_url} return get_polkadot_json(endpoint, params, self._logger, api_call)
def get_council_proposal_count(self, ws_url: str) -> PolkadotWrapperType: api_call = 'council/proposalCount' endpoint = self._api_endpoint + '/api/query/' + api_call params = {'websocket': ws_url} return get_polkadot_json(endpoint, params, self._logger, api_call)
def get_referendum_count(self, ws_url: str) -> PolkadotWrapperType: api_call = 'democracy/referendumCount' endpoint = self._api_endpoint + '/api/query/' + api_call params = {'websocket': ws_url} return get_polkadot_json(endpoint, params, self._logger, api_call)
def get_web_sockets_connected_to_an_api(self) -> PolkadotWrapperType: endpoint = self._api_endpoint + '/api/getConnectionsList' params = {} return get_polkadot_json(endpoint, params, self._logger)
def ping_api(self) -> PolkadotWrapperType: endpoint = self._api_endpoint + '/api/pingApi' params = {} return get_polkadot_json(endpoint, params, self._logger)
def ping_node(self, ws_url: str) -> PolkadotWrapperType: api_call = 'pingNode' endpoint = self._api_endpoint + '/api/' + api_call params = {'websocket': ws_url} return get_polkadot_json(endpoint, params, self._logger, api_call)
def test_get_polka_json_error_if_any_other_error(self, _): try: get_polkadot_json(ENDPOINT, PARAMS, LOGGER, API_CALL) self.fail('Expected UnexpectedApiCallErrorException') except UnexpectedApiCallErrorException: pass
def get_block_hash(self, ws_url: str, block_number: int) -> \ PolkadotWrapperType: api_call = 'chain/getBlockHash' endpoint = self._api_endpoint + '/api/rpc/' + api_call params = {'websocket': ws_url, 'block_number': block_number} return get_polkadot_json(endpoint, params, self._logger, api_call)
def test_get_polka_json_result_if_api_return_has_result(self, _): ret = get_polkadot_json(ENDPOINT, PARAMS, LOGGER, API_CALL) self.assertEqual(RESULT, ret)
def get_finalized_head(self, ws_url: str) -> PolkadotWrapperType: api_call = 'chain/getFinalizedHead' endpoint = self._api_endpoint + '/api/rpc/' + api_call params = {'websocket': ws_url} return get_polkadot_json(endpoint, params, self._logger, api_call)
def test_get_polka_json_error_if_api_for_ws_was_not_set_up(self, _): try: get_polkadot_json(ENDPOINT, PARAMS, LOGGER, API_CALL) self.fail('Expected NodeWasNotConnectedToApiServerException') except NodeWasNotConnectedToApiServerException: pass
def get_header(self, ws_url: str, block_hash: str) -> PolkadotWrapperType: api_call = 'chain/getHeader' endpoint = self._api_endpoint + '/api/rpc/' + api_call params = {'websocket': ws_url, 'hash': block_hash} return get_polkadot_json(endpoint, params, self._logger, api_call)
def test_get_polka_json_error_if_invalid_decoded_address(self, _): try: get_polkadot_json(ENDPOINT, PARAMS, LOGGER, API_CALL) self.fail('Expected InvalidStashAccountAddressException') except InvalidStashAccountAddressException: pass
def get_current_elected(self, ws_url: str) -> PolkadotWrapperType: api_call = 'staking/currentElected' endpoint = self._api_endpoint + '/api/query/' + api_call params = {'websocket': ws_url} return get_polkadot_json(endpoint, params, self._logger, api_call)