예제 #1
0
 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)
예제 #2
0
 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)
예제 #3
0
 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)
예제 #4
0
 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)
예제 #5
0
 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)
예제 #6
0
 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
예제 #7
0
 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
예제 #8
0
 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
예제 #9
0
 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
예제 #10
0
 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)
예제 #11
0
 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)
예제 #12
0
 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)
예제 #13
0
 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)
예제 #14
0
 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)
예제 #15
0
 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)
예제 #16
0
 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)
예제 #17
0
 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)
예제 #18
0
 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)
예제 #19
0
 def ping_api(self) -> PolkadotWrapperType:
     endpoint = self._api_endpoint + '/api/pingApi'
     params = {}
     return get_polkadot_json(endpoint, params, self._logger)
예제 #20
0
 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)
예제 #21
0
 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
예제 #22
0
 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)
예제 #23
0
 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)
예제 #24
0
 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)
예제 #25
0
 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
예제 #26
0
 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)
예제 #27
0
 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
예제 #28
0
 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)