-
-
Notifications
You must be signed in to change notification settings - Fork 252
feat(core-backend): update websocket behavior #6819
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -844,12 +844,10 @@ export class TokenBalancesController extends StaticIntervalPollingController<{ | |
account: ChecksumAddress, | ||
chainId: ChainIdHex, | ||
): boolean { | ||
const normalizedAddress = tokenAddress.toLowerCase(); | ||
|
||
// Check if token exists in allTokens | ||
if ( | ||
this.#allTokens?.[chainId]?.[account.toLowerCase()]?.some( | ||
(token) => token.address.toLowerCase() === normalizedAddress, | ||
(token) => token.address === tokenAddress, | ||
) | ||
) { | ||
return true; | ||
|
@@ -858,7 +856,7 @@ export class TokenBalancesController extends StaticIntervalPollingController<{ | |
// Check if token exists in allIgnoredTokens | ||
if ( | ||
this.#allIgnoredTokens?.[chainId]?.[account.toLowerCase()]?.some( | ||
(addr) => addr.toLowerCase() === normalizedAddress, | ||
(token) => token === tokenAddress, | ||
Kriys94 marked this conversation as resolved.
Show resolved
Hide resolved
Kriys94 marked this conversation as resolved.
Show resolved
Hide resolved
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Bug: Token Tracking Case Sensitivity IssueThe There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Bug: Token Address Matching Case Sensitivity IssueThe |
||
) | ||
) { | ||
return true; | ||
|
@@ -1124,23 +1122,26 @@ export class TokenBalancesController extends StaticIntervalPollingController<{ | |
updates: BalanceUpdate[]; | ||
}) => { | ||
const chainId = caipChainIdToHex(chain); | ||
const account = checksum(address); | ||
const checksummedAccount = checksum(address); | ||
|
||
try { | ||
// Process all balance updates at once | ||
const { tokenBalances, newTokens, nativeBalanceUpdates } = | ||
this.#prepareBalanceUpdates(updates, account, chainId); | ||
this.#prepareBalanceUpdates(updates, checksummedAccount, chainId); | ||
|
||
// Update state once with all token balances | ||
if (tokenBalances.length > 0) { | ||
this.update((state) => { | ||
// Initialize account and chain structure | ||
state.tokenBalances[account] ??= {}; | ||
state.tokenBalances[account][chainId] ??= {}; | ||
// Temporary until ADR to normalize all keys - tokenBalances state requires: account in lowercase, token in checksum | ||
const lowercaseAccount = | ||
checksummedAccount.toLowerCase() as ChecksumAddress; | ||
state.tokenBalances[lowercaseAccount] ??= {}; | ||
state.tokenBalances[lowercaseAccount][chainId] ??= {}; | ||
|
||
// Apply all token balance updates | ||
for (const { tokenAddress, balance } of tokenBalances) { | ||
state.tokenBalances[account][chainId][tokenAddress] = balance; | ||
state.tokenBalances[lowercaseAccount][chainId][tokenAddress] = | ||
balance; | ||
} | ||
}); | ||
} | ||
|
Uh oh!
There was an error while loading. Please reload this page.