agent0.chainsync.dashboard.usernames ==================================== .. py:module:: agent0.chainsync.dashboard.usernames .. autoapi-nested-parse:: Helper functions for mapping addresses to usernames. .. !! processed by numpydoc !! Functions --------- .. autoapisummary:: agent0.chainsync.dashboard.usernames.build_user_mapping agent0.chainsync.dashboard.usernames.map_addresses agent0.chainsync.dashboard.usernames.abbreviate_address Module Contents --------------- .. py:function:: build_user_mapping(addresses: pandas.Series, addr_to_username: pandas.DataFrame) -> pandas.DataFrame Builds a mapping from wallet addresses to usernames and any additional aliases that address may have. Given a pd.Series of wallet addresses, we build a corresponding dataframe that contains the mapping between that wallet address and any additional aliases that address may have. Specifically, the output dataframe contains the following columns: address: The original wallet address abbr_address: The wallet address abbreviated (e.g., 0x0000...0000) username: The one-to-one mapped username for that address gathered from the `addr_to_username` postgres table format_name: A formatted name for labels combining username with abbr_address If the address doesn't exist in the lookup, the username and user will reflect the abbr_address. :param addresses: The list of addresses to build the user map for. :type addresses: pd.Series :param addr_to_username: The mapping of addresses to username returned from `get_addr_to_username`. :type addr_to_username: pd.DataFrame :returns: A dataframe with 4 columns (address, abbr_address, username, format_name) :rtype: pd.Dataframe .. !! processed by numpydoc !! .. py:function:: map_addresses(key: str, user_map: pandas.DataFrame, map_column=None) -> pandas.Series map_addresses(key: pandas.Series | list, user_map: pandas.DataFrame, map_column=None) -> pandas.Series Helper function to look up the aliases for an address. :param key: The pd.Series, list, or individual key(s) to look up. :type key: pd.Series | list | str :param user_map: The lookup dataframe returned from build_user_mapping :type user_map: pd.DataFrame :param map_column: The column that key is mapped to. If None, will default to address. :type map_column: str | None :returns: A dataframe or series with 5 columns (address, abbr_address, username, user, format_name) in the same order as the input addresses series. Will return a dataframe if a series or list is passed in Will return a series if a single key is passed in :rtype: pd.Dataframe | pd.Series .. !! processed by numpydoc !! .. py:function:: abbreviate_address(address: pandas.Series) -> pandas.Series abbreviate_address(address: str) -> str Given a series of addresses, return the corresponding addresses in a human readable way. :param address: :type address: pd.Series | str :returns: The corresponding abbreviated addresses in the same order (with the same indices), or a single abbreviated address string. :rtype: pd.Series | str .. !! processed by numpydoc !!