Skip to content

Commit ba29615

Browse files
committed
Enhance vault selection functionality in vaults page due to linter/type errors introduced after moving to basedpyright from pylance
- Introduced a new function `format_vault_option` to improve the display of vault options in the selection dropdown. - Updated the `st.selectbox` to utilize the new formatting function, providing a clearer presentation of vault names and net deposits. - The new format includes the vault name, true net deposits in USD, and a shortened version of the public key for better user experience.
1 parent 0629bcd commit ba29615

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

src/page/vaults.py

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,10 +60,21 @@ def vaults_page():
6060

6161
st.subheader("Vault Depositor Details")
6262

63+
all_vaults_df_indexed = all_vaults_df.set_index("pubkey")
64+
65+
def format_vault_option(pubkey: str) -> str:
66+
try:
67+
vault_info = all_vaults_df_indexed.loc[pubkey]
68+
name = vault_info["name"]
69+
net_deposits = vault_info["true_net_deposits"]
70+
return f"{name} (${net_deposits:,.2f} USD) - {pubkey[:4]}...{pubkey[-4:]}"
71+
except KeyError:
72+
return f"Unknown Vault - {pubkey[:4]}...{pubkey[-4:]}"
73+
6374
selected_vault = st.selectbox(
6475
"Select Vault",
65-
[vault["pubkey"] for vault in all_vaults_df.to_dict(orient="records")],
66-
format_func=lambda x: f"{all_vaults_df[all_vaults_df['pubkey'] == x]['name'].values[0]} (${all_vaults_df[all_vaults_df['pubkey'] == x]['true_net_deposits'].values[0]:,.2f} USD) - {x[:4]}...{x[-4:]}",
76+
all_vaults_df["pubkey"].tolist(),
77+
format_func=format_vault_option,
6778
)
6879

6980
if selected_vault:

0 commit comments

Comments
 (0)