def to_bytes_address(hex_address: str) -> bytes:
     try:
         bytes_address = binascii.a2b_hex(hex_address)
     except binascii.Error as e:
         raise SDKException(ErrorCode.other_error(e.args[0]))
     address = Address(bytes_address)
     return address.to_bytes()
 def to_bytes_address(hex_address: str) -> bytes:
     try:
         bytes_address = bytes.fromhex(hex_address)
     except ValueError as e:
         raise SDKException(ErrorCode.other_error(e.args[0]))
     address = Address(bytes_address)
     return address.to_bytes()
Beispiel #3
0
 def get_authorize_info(self, peer_pubkey: str, addr: Address):
     contract_address = bytearray.fromhex(self.CONTRACT_ADDRESS)
     contract_address.reverse()
     peer_pubkey_prefix = bytearray.fromhex(peer_pubkey)
     address_bytes = addr.to_bytes()
     authorize_info_pool = self.AUTHORIZE_INFO_POOL.encode()
     key = authorize_info_pool + peer_pubkey_prefix + address_bytes
     res = self.__sdk.rpc.get_storage(contract_address.hex(), key.hex())
     if res is None or res == '':
         return None
     stream = StreamManager.get_stream(bytearray.fromhex(res))
     reader = BinaryReader(stream)
     authorize_info = AuthorizeInfo()
     authorize_info.deserialize(reader)
     return authorize_info.to_json()