import logging from yuxi.channels.adapters.signal.client import RpcClient, RpcError logger = logging.getLogger(__name__) async def get_identities(rpc_client: RpcClient, account: str) -> list[dict]: try: result = await rpc_client.call("getIdentities", {"account": account}) return result.get("identities", []) except RpcError as e: logger.warning(f"Failed to get identities: {e}") return [] async def trust_identity( rpc_client: RpcClient, account: str, recipient: str, fingerprint: str | None = None, ) -> bool: try: params: dict = {"account": account, "recipient": recipient} if fingerprint: params["fingerprint"] = fingerprint else: params["trustAllKeys"] = True await rpc_client.call("trustIdentity", params) return True except RpcError as e: logger.warning(f"Failed to trust identity {recipient}: {e}") return False async def get_self_number(rpc_client: RpcClient, account: str) -> str | None: try: result = await rpc_client.call("getSelf", {"account": account}) return result.get("number") except RpcError: return account