-
Notifications
You must be signed in to change notification settings - Fork 394
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Wen Account Selector: Fill in the rest of the account selector data, adjust the wallet tab to only display current account #502
Conversation
4e4b32d
to
9372d7a
Compare
accountSelectors now holds selectAccountAndTimestampedActivities, but just as important selectors are imported directly from the top-level `redux-slices/selectors` package instead of going to the particular subpackage for simplicity. In the process, use a RootState defined at the top level of redux-slices that can be used in the selectors package, since there is no longer a circular dependencies concern.
9372d7a
to
2f290f7
Compare
In addition to the already-functioning address and ENS name in the list, this commit adds the populating of correct per-address totals, updates the account grouping to indicate that the addresses are read-only, and replaces the bolded name with the shortened address in cases where there is no ENS name to work with. It also populates the correct avatar, when available. A new selectAccountTotals selector is introduced that does per-account totaling to make this possible. There is likely an opportunity for refactoring of some of the code that is similar with selectAccountAndTimestampedActivities.
This selector allows for the selection of just the currently selected account's balances, both with a total in the main currency value and per asset owned by that particular account.
These two components were operating on the combined asset data from all accounts, but were always meant to only display the current account's information. Activities/transactions are currently still shown across accounts.
To do this, WalletActivityList now takes an array of activities to display from its caller rather than selecting it directly. The Wallet and SingleAsset components use selectCurrentAccountActivitiesWithTimestamps to pull current activity, and SingleAsset further filters to the asset it is displaying.
This isn't supported yet, and displaying it is confusing to real users. Coming S∞n™.
Use the number of accounts in the account slice to determine if the wallet has any accounts, and update the accounts balance selector to exit early if there is no current account.
This ensures that adding a checksum address doesn't result in two redux entries, only one of which will actually receive data.
These were rendered at-size, and are now rendered scaled to their containing box.
2f290f7
to
e3879fb
Compare
There's an issue remaining with the back button on the single asset page, but it's present on main due to the onboarding flow changes that made it I tried to fix it up but ran into some walls… @henryboldi could use some help with it, maybe as a separate PR? |
Totally my bad! Yes, I'll open up a separate PR with a fix @Shadowfiend |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
} | ||
) | ||
|
||
export type AccountTotal = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The AccountTotal
naming is a tad confusing to me. To someone unfamiliar with the codebase, it might give the impression that it's some sort of total amount
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's the account info + it's total balance, which is in line with how we've done eg AccountNetwork.
Would love a better name though--I don't love that pattern, but I couldn't come up with anything great after giving it some thought.
Either way a jsdoc couldn't hurt.
|
It shall rise again.
Existing avatars are rounded at the image level, but ENS avatars may not be, so the border rounding is now applied at the browser/element level.
The add flow is currently via Add Wallet, while Add address is meant for adding within an account. Thinking through how these pieces will interact will read-only wallets will happen later, so for now hide the (always-disabled-anyway) Add address button.
This also obviates the need to try to auto-select the first account for wallet initialization.
The key error interferes with a linter error, but we can skip the linter error to save our developer console.
Ended up doing all of them + fixing a React console error. Notably, wanting to select the newly-added account led to also removing some hacky code that was in use for initial wallet startup 🎉 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Non-controversial, LGTM!
@@ -5,11 +5,13 @@ import { AnyAction } from "@reduxjs/toolkit" | |||
|
|||
import Main from "./main" | |||
import { encodeJSON, decodeJSON } from "./lib/utils" | |||
import logger from "./lib/logger" | |||
|
|||
import { RootState } from "./redux-slices" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice to be done with the ReturnType
|
||
export default mainReducer | ||
|
||
export type RootState = ReturnType<typeof mainReducer> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Drat
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's overall better, otherwise we'd have to update every time we added a slice 🤷 DRY and all.
Should this close #363? |
I'm interested in your take on that. I didn't set out to refactor the accounts slice as a goal, so there may still be some work to do if it's considered from that perspective. |
This PR fils in the remaining data in the account selector, as
well as adjusting the wallet and single asset tabs to only display
balances and activity related to the currently-selected account. In
the process, almost all of the combined activity-related code in the
accounts slice is removed, since it was meant to populate this view,
which was never meant to display data across accounts.
The other large refactor here was the introduction of the
accountsSelectors
file, following @henryboldi's example with theactivitiesSelectors
file. Both of these are exposed at the top levelvia a re-exporting
background/redux-slices/selectors
package thatexposes all internal selectors for the UI to use, which has allowed
some cleanup in typing dependencies to take place (in particular,
allowing the selectors to reference the full state without having to
resort to redeclaring it to avoid circular dependencies).
A few additional tweaks include trying to resolve avatars where
possible, changing the fixed Trezor header to display read-only mode
(for now), and not displaying a name when an account has no associated
ENS name. Also, the single asset page no longer displays placeholder
“this asset is on Arbitrum” language, which was confusing users and is
rooted in unimplemented functionality. These elements are hidden for
now.