Skip to content
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

Fix account balance discrepancies #5959

Merged
merged 41 commits into from
Aug 14, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
415e800
fix balance discrepency between bx and app and app and change wallet …
walmat Jul 26, 2024
2f82761
Update src/helpers/buildWalletSections.tsx
walmat Jul 26, 2024
4ff91ef
fix missing import from commit
walmat Jul 26, 2024
d010309
also fix send sheet balance discrepancy
walmat Jul 26, 2024
50df200
fix swap user assets not refetching on pending txn resolution and PTR
walmat Jul 31, 2024
cf6a796
.
walmat Jul 31, 2024
2605a21
update en_US key
walmat Aug 3, 2024
eb8bbe2
rmeove unused hook and bake it into the user assets store
walmat Aug 5, 2024
bc4c6e8
good lord
walmat Aug 5, 2024
148a1eb
separate invalidateQueries because they don't update when grouped for…
walmat Aug 5, 2024
d5a2a67
more instances
walmat Aug 5, 2024
1b4013f
cleanup
walmat Aug 5, 2024
a151992
Merge branch 'develop' into @matthew/APP-1689
walmat Aug 5, 2024
207e811
remove stuff
walmat Aug 7, 2024
1277e6d
cleanup useWatchPendingTxs
walmat Aug 8, 2024
9efc708
code suggestions
walmat Aug 8, 2024
2c018d8
break up useWallets
benisgold Aug 8, 2024
647d1b0
rm latestBackup from useWallets
benisgold Aug 8, 2024
c05f854
useMemo -> useEffect
benisgold Aug 8, 2024
4f05b85
logging
benisgold Aug 8, 2024
bb5cd77
cleanup
benisgold Aug 8, 2024
8061f7a
remove unused withPositions params
benisgold Aug 8, 2024
2aa197b
type
benisgold Aug 8, 2024
f9bf7ab
fix PROFILE_STICKY_HEADER loading value
benisgold Aug 8, 2024
423f6df
Merge branch 'develop' of https://github.com/rainbow-me/rainbow into …
benisgold Aug 8, 2024
5e81f25
fix
benisgold Aug 8, 2024
fc10958
optional chaining
benisgold Aug 9, 2024
b0eb61b
fixes to buildWalletSections + related code
benisgold Aug 9, 2024
943117b
fix accountInfo isLoadingAccountBalance
benisgold Aug 9, 2024
7a11e75
clean up useWalletBalances
benisgold Aug 9, 2024
38e9eb5
stuff is still broken but committing walletsWithBalancesAndNames fix
benisgold Aug 9, 2024
335bb0d
refactor useWalletsWithBalancesAndNames and fix consumers
benisgold Aug 9, 2024
04069ba
fix wallet screen balance loading state
benisgold Aug 9, 2024
4c6855d
Merge branch 'develop' of https://github.com/rainbow-me/rainbow into …
benisgold Aug 9, 2024
4240c4e
console.log
benisgold Aug 13, 2024
cbf63df
switch amount types from string | number -> string
benisgold Aug 13, 2024
e1349b0
align stale/cache times, remove keepPreviousData
benisgold Aug 13, 2024
6acff71
remove spammy isDamaged logging
benisgold Aug 13, 2024
5e06f01
add loading balance copy + remove incorrectly used no balance copy
benisgold Aug 13, 2024
33c8024
Merge branch 'develop' of https://github.com/rainbow-me/rainbow into …
benisgold Aug 13, 2024
3ada8f0
fix i18n mistake
benisgold Aug 14, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
rmeove unused hook and bake it into the user assets store
  • Loading branch information
walmat committed Aug 5, 2024
commit eb8bbe257e41ec948eec95eecea599479d91369d
18 changes: 0 additions & 18 deletions src/hooks/useUserAssetsBalance.ts

This file was deleted.

23 changes: 23 additions & 0 deletions src/state/assets/userAssets.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { ParsedSearchAsset, UniqueId, UserAssetFilter } from '@/__swaps__/types/assets';
import { ChainId } from '@/__swaps__/types/chains';
import { add, convertAmountToNativeDisplayWorklet } from '@/__swaps__/utils/numbers';
import { RainbowError, logger } from '@/logger';
import store from '@/redux/store';
import { SUPPORTED_CHAIN_IDS, supportedNativeCurrencies } from '@/references';
Expand All @@ -26,6 +27,12 @@ export interface UserAssetsState {
associatedWalletAddress: Address | undefined;
chainBalances: Map<ChainId, number>;
currentAbortController: AbortController;
totalAssetNativeBalance:
| {
amount: string;
display: string;
}
| undefined;
filter: UserAssetFilter;
idsByChain: Map<UserAssetFilter, UniqueId[]>;
inputSearchQuery: string;
Expand All @@ -37,6 +44,10 @@ export interface UserAssetsState {
getHighestValueAsset: () => ParsedSearchAsset | null;
getUserAsset: (uniqueId: UniqueId) => ParsedSearchAsset | null;
getUserAssets: () => ParsedSearchAsset[];
getTotalAssetNativeBalance: () => {
amount: string;
display: string;
};
selectUserAssetIds: (selector: (asset: ParsedSearchAsset) => boolean, filter?: UserAssetFilter) => Generator<UniqueId, void, unknown>;
selectUserAssets: (selector: (asset: ParsedSearchAsset) => boolean) => Generator<[UniqueId, ParsedSearchAsset], void, unknown>;
setSearchCache: (queryKey: string, filteredIds: UniqueId[]) => void;
Expand Down Expand Up @@ -129,6 +140,7 @@ export const userAssetsStore = createRainbowStore<UserAssetsState>(
inputSearchQuery: '',
searchCache: new Map(),
userAssets: new Map(),
totalAssetNativeBalance: undefined,

getBalanceSortedChainList: () => {
const chainBalances = [...get().chainBalances.entries()];
Expand Down Expand Up @@ -185,6 +197,17 @@ export const userAssetsStore = createRainbowStore<UserAssetsState>(

getUserAssets: () => Array.from(get().userAssets.values()) || [],

getTotalAssetNativeBalance: () => {
const { getUserAssets } = get();

const amount = getUserAssets().reduce((prev, curr) => add(prev, curr.native.balance.amount), '0');

return {
amount,
display: convertAmountToNativeDisplayWorklet(amount, store.getState().settings.nativeCurrency),
};
},

selectUserAssetIds: function* (selector: (asset: ParsedSearchAsset) => boolean, filter?: UserAssetFilter) {
const { currentAbortController, idsByChain, userAssets } = get();

Expand Down