Esempio n. 1
0
 async def get_storage(self, hex_contract_address: str, hex_key: str,
                       is_full: bool = False) -> str or dict:
     url = RestfulMethod.get_storage(self._url, hex_contract_address, hex_key)
     response = await self.__get(url)
     if is_full:
         return response
     return response['Result']
Esempio n. 2
0
 async def get_balance(self, b58_address: str, is_full: bool = False):
     url = RestfulMethod.get_account_balance(self._url, b58_address)
     response = await self.__get(url)
     response['Result'] = dict((k.upper(), int(v)) for k, v in response.get('Result', dict()).items())
     if is_full:
         return response
     return response['Result']
Esempio n. 3
0
 async def get_allowance(self, asset: str, b58_from_address: str, b58_to_address: str,
                         is_full: bool = False):
     url = RestfulMethod.get_allowance(self._url, asset, b58_from_address, b58_to_address)
     response = await self.__get(url)
     if is_full:
         return response
     return response['Result']
Esempio n. 4
0
 async def get_block_by_hash(self, block_hash: str,
                             is_full: bool = False) -> int or dict:
     url = RestfulMethod.get_block_by_hash(self._url, block_hash)
     response = await self.__get(url)
     if is_full:
         return response
     return response['Result']
Esempio n. 5
0
 async def send_raw_transaction(self, tx: Transaction, is_full: bool = False):
     hex_tx_data = tx.serialize(is_hex=True)
     data = f'{{"Action":"sendrawtransaction", "Version":"1.0.0","Data":"{hex_tx_data}"}}'
     url = RestfulMethod.send_transaction(self._url)
     response = await self.__post(url, data)
     if is_full:
         return response
     return response['Result']
Esempio n. 6
0
 async def get_block_height_by_tx_hash(self, tx_hash: str, is_full: bool = False):
     url = RestfulMethod.get_block_height_by_tx_hash(self._url, tx_hash)
     response = await self.__get(url)
     if response.get('Result', '') == '':
         raise SDKException(ErrorCode.invalid_tx_hash(tx_hash))
     if is_full:
         return response
     return response['Result']
Esempio n. 7
0
 async def get_memory_pool_tx_state(self, tx_hash: str, is_full: bool = False) -> \
         List[dict] or dict:
     url = RestfulMethod.get_mem_pool_tx_state(self._url, tx_hash)
     response = await self.__get(url)
     if response.get('Result', '') == '':
         raise SDKException(ErrorCode.invalid_tx_hash(tx_hash))
     if is_full:
         return response
     return response['Result']['State']
Esempio n. 8
0
 async def get_contract_event_by_height(self, height: int, is_full: bool = False) -> \
         List[
             dict]:
     url = RestfulMethod.get_contract_event_by_height(self._url, height)
     response = await self.__get(url)
     if is_full:
         return response
     result = response['Result']
     if result == '':
         result = list()
     return result
Esempio n. 9
0
 async def get_memory_pool_tx_count(self, is_full: bool = False):
     url = RestfulMethod.get_mem_pool_tx_count(self._url)
     response = await self.__get(url)
     if is_full:
         return response
     return response['Result']
Esempio n. 10
0
 async def get_merkle_proof(self, tx_hash: str, is_full: bool = False):
     url = RestfulMethod.get_merkle_proof(self._url, tx_hash)
     response = await self.__get(url)
     if is_full:
         return response
     return response['Result']
Esempio n. 11
0
 async def get_transaction_by_tx_hash(self, tx_hash: str, is_full: bool = False):
     url = RestfulMethod.get_transaction(self._url, tx_hash)
     response = await self.__get(url)
     if is_full:
         return response
     return response['Result']
Esempio n. 12
0
 async def get_block_height(self, is_full: bool = False) -> int or dict:
     url = RestfulMethod.get_block_height(self._url)
     response = await self.__get(url)
     if is_full:
         return response
     return response['Result']
Esempio n. 13
0
 async def get_contract(self, contract_address: str, is_full: bool = False):
     url = RestfulMethod.get_contract(self._url, contract_address)
     response = await self.__get(url)
     if is_full:
         return response
     return response['Result']
Esempio n. 14
0
 async def get_block_by_height(self, height: int, is_full: bool = False):
     url = RestfulMethod.get_block_by_height(self._url, height)
     response = await self.__get(url)
     if is_full:
         return response
     return response['Result']
Esempio n. 15
0
 async def get_version(self, is_full: bool = False):
     url = RestfulMethod.get_version(self._url)
     response = await self.__get(url)
     if is_full:
         return response
     return response['Result']
Esempio n. 16
0
 async def get_connection_count(self, is_full: bool = False) -> int:
     url = RestfulMethod.get_connection_count(self._url)
     response = await self.__get(url)
     if is_full:
         return response
     return response['Result']
Esempio n. 17
0
 async def get_gas_price(self, is_full: bool = False) -> int or dict:
     url = RestfulMethod.get_gas_price(self._url)
     response = await self.__get(url)
     if is_full:
         return response
     return response['Result']['gasprice']