agent0.chainsync.dashboard.usernames

Helper functions for mapping addresses to usernames.

Functions

build_user_mapping(→ pandas.DataFrame)

Builds a mapping from wallet addresses to usernames and any additional aliases

map_addresses(…)

Helper function to look up the aliases for an address.

abbreviate_address(…)

Given a series of addresses, return the corresponding addresses in a human readable way.

Module Contents

agent0.chainsync.dashboard.usernames.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.

Parameters:
  • addresses (pd.Series) – The list of addresses to build the user map for.

  • addr_to_username (pd.DataFrame) – The mapping of addresses to username returned from get_addr_to_username.

Returns:

A dataframe with 4 columns (address, abbr_address, username, format_name)

Return type:

pd.Dataframe

agent0.chainsync.dashboard.usernames.map_addresses(key: str, user_map: pandas.DataFrame, map_column=None) pandas.Series
agent0.chainsync.dashboard.usernames.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.

Parameters:
  • key (pd.Series | list | str) – The pd.Series, list, or individual key(s) to look up.

  • user_map (pd.DataFrame) – The lookup dataframe returned from build_user_mapping

  • map_column (str | None) – The column that key is mapped to. If None, will default to address.

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

Return type:

pd.Dataframe | pd.Series

agent0.chainsync.dashboard.usernames.abbreviate_address(address: pandas.Series) pandas.Series
agent0.chainsync.dashboard.usernames.abbreviate_address(address: str) str

Given a series of addresses, return the corresponding addresses in a human readable way.

Parameters:

address (pd.Series | str)

Returns:

The corresponding abbreviated addresses in the same order (with the same indices), or a single abbreviated address string.

Return type:

pd.Series | str