-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
release: 7.64.1.1 OTA #25920
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
Closed
+124
−74
Closed
release: 7.64.1.1 OTA #25920
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
61903fe
bump semvar version to 7.64.2 && build version to 3677
metamaskbot d78c536
Revert "bump semvar version to 7.64.2 && build version to 3677"
joaoloureirop 632fe2d
bump ota version
joaoloureirop b2344ac
Merge branch 'stable' into release/7.64.1.1
joaoloureirop 9a77edc
chore: cherry-pick: PR #25797
Prithpal-Sooriya 9d23fe3
chore: cherry-pick: PR #25797 (#25976)
joaoloureirop 02f2728
[skip ci] Bump version number to 3698
metamaskbot File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
101 changes: 101 additions & 0 deletions
101
.yarn/patches/@metamask-assets-controllers-npm-98.0.0-ebc0dfef4f.patch
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,101 @@ | ||
| diff --git a/dist/TokenBalancesController.cjs b/dist/TokenBalancesController.cjs | ||
| index 9c91f20ce150a49fc9c914ca25cc6885e8800f34..075edb48321640a2abed5b038fbcb2e17661071e 100644 | ||
| --- a/dist/TokenBalancesController.cjs | ||
| +++ b/dist/TokenBalancesController.cjs | ||
| @@ -123,7 +123,7 @@ class TokenBalancesController extends (0, polling_controller_1.StaticIntervalPol | ||
| return this.messenger.call('NetworkController:getNetworkClientById', networkClientId); | ||
| }); | ||
| _TokenBalancesController_createAccountsApiFetcher.set(this, () => { | ||
| - const originalFetcher = new api_balance_fetcher_1.AccountsApiBalanceFetcher(__classPrivateFieldGet(this, _TokenBalancesController_platform, "f"), __classPrivateFieldGet(this, _TokenBalancesController_getProvider, "f")); | ||
| + const originalFetcher = new api_balance_fetcher_1.AccountsApiBalanceFetcher(__classPrivateFieldGet(this, _TokenBalancesController_platform, "f"), __classPrivateFieldGet(this, _TokenBalancesController_getProvider, "f"), () => this.state.tokenBalances); | ||
| return { | ||
| // Dynamically check allowExternalServices() at call time, not just at construction time | ||
| supports: (chainId) => __classPrivateFieldGet(this, _TokenBalancesController_allowExternalServices, "f").call(this) && | ||
| diff --git a/dist/multi-chain-accounts-service/api-balance-fetcher.cjs b/dist/multi-chain-accounts-service/api-balance-fetcher.cjs | ||
| index 50d8ee9fb47ecc6e08f6322095e7689b8e3bd5a7..bc6da747274e5ebdc7b8ae052ae7ff7b88d2988d 100644 | ||
| --- a/dist/multi-chain-accounts-service/api-balance-fetcher.cjs | ||
| +++ b/dist/multi-chain-accounts-service/api-balance-fetcher.cjs | ||
| @@ -13,7 +13,7 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function ( | ||
| var __importDefault = (this && this.__importDefault) || function (mod) { | ||
| return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
| }; | ||
| -var _AccountsApiBalanceFetcher_instances, _AccountsApiBalanceFetcher_platform, _AccountsApiBalanceFetcher_getProvider, _AccountsApiBalanceFetcher_fetchStakedBalances, _AccountsApiBalanceFetcher_fetchBalances; | ||
| +var _AccountsApiBalanceFetcher_instances, _AccountsApiBalanceFetcher_platform, _AccountsApiBalanceFetcher_getProvider, _AccountsApiBalanceFetcher_getUserTokens, _AccountsApiBalanceFetcher_fetchStakedBalances, _AccountsApiBalanceFetcher_fetchBalances; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| exports.AccountsApiBalanceFetcher = void 0; | ||
| const contracts_1 = require("@ethersproject/contracts"); | ||
| @@ -31,12 +31,14 @@ const ACCOUNTS_API_TIMEOUT_MS = 10000; | ||
| const checksum = (addr) => (0, controller_utils_1.toChecksumHexAddress)(addr); | ||
| const toCaipAccount = (chainId, account) => (0, assetsUtil_1.accountAddressToCaipReference)(chainId, account); | ||
| class AccountsApiBalanceFetcher { | ||
| - constructor(platform = 'extension', getProvider) { | ||
| + constructor(platform = 'extension', getProvider, getUserTokens) { | ||
| _AccountsApiBalanceFetcher_instances.add(this); | ||
| _AccountsApiBalanceFetcher_platform.set(this, 'extension'); | ||
| _AccountsApiBalanceFetcher_getProvider.set(this, void 0); | ||
| + _AccountsApiBalanceFetcher_getUserTokens.set(this, void 0); | ||
| __classPrivateFieldSet(this, _AccountsApiBalanceFetcher_platform, platform, "f"); | ||
| __classPrivateFieldSet(this, _AccountsApiBalanceFetcher_getProvider, getProvider, "f"); | ||
| + __classPrivateFieldSet(this, _AccountsApiBalanceFetcher_getUserTokens, getUserTokens, "f"); | ||
| } | ||
| supports(chainId) { | ||
| return constants_1.SUPPORTED_NETWORKS_ACCOUNTS_API_V4.includes(chainId); | ||
| @@ -91,7 +93,8 @@ class AccountsApiBalanceFetcher { | ||
| }); | ||
| // Ensure native token entries exist for all addresses on all requested chains | ||
| const ZERO_ADDRESS = '0x0000000000000000000000000000000000000000'; | ||
| - const nativeBalancesFromAPI = new Map(); // key: `${address}-${chainId}` | ||
| + const nativeBalancesFromAPI = new Map(); // key: `${accountAddress}-${chainId}` | ||
| + const nonNativeBalancesFromAPI = new Map(); // key: `${accountAddress}-${tokenAddress}-${chainId}` | ||
| // Process regular API balances | ||
| if (apiResponse.balances) { | ||
| const apiBalances = apiResponse.balances.flatMap((b) => { | ||
| @@ -127,6 +130,9 @@ class AccountsApiBalanceFetcher { | ||
| if (token === ZERO_ADDRESS && value !== undefined) { | ||
| nativeBalancesFromAPI.set(`${finalAccount}-${chainId}`, value); | ||
| } | ||
| + if (token !== ZERO_ADDRESS && value !== undefined) { | ||
| + nonNativeBalancesFromAPI.set(`${finalAccount.toLowerCase()}-${token.toLowerCase()}-${chainId}`, value); | ||
| + } | ||
| return [ | ||
| { | ||
| success: value !== undefined, | ||
| @@ -156,6 +162,29 @@ class AccountsApiBalanceFetcher { | ||
| } | ||
| }); | ||
| }); | ||
| + // Add zero erc-20 balance entries for addresses that API didn't return | ||
| + if (__classPrivateFieldGet(this, _AccountsApiBalanceFetcher_getUserTokens, "f")) { | ||
| + const userTokens = __classPrivateFieldGet(this, _AccountsApiBalanceFetcher_getUserTokens, "f").call(this); | ||
| + Object.entries(userTokens).forEach(([account, chains]) => { | ||
| + Object.entries(chains).forEach(([chainId, tokens]) => { | ||
| + Object.entries(tokens).forEach(([tokenAddress]) => { | ||
| + const tokenLowerCase = tokenAddress.toLowerCase(); | ||
| + const key = `${account.toLowerCase()}-${tokenLowerCase}-${chainId}`; | ||
| + const isERC = tokenAddress !== ZERO_ADDRESS; | ||
| + const existingBalance = nonNativeBalancesFromAPI.get(key); | ||
| + if (isERC && !existingBalance) { | ||
| + results.push({ | ||
| + success: true, | ||
| + value: new bn_js_1.default('0'), | ||
| + account: account, | ||
| + token: tokenLowerCase, | ||
| + chainId: chainId, | ||
| + }); | ||
| + } | ||
| + }); | ||
| + }); | ||
| + }); | ||
| + } | ||
| // Add staked balances | ||
| results.push(...stakedBalances); | ||
| return { | ||
| @@ -165,7 +194,7 @@ class AccountsApiBalanceFetcher { | ||
| } | ||
| } | ||
| exports.AccountsApiBalanceFetcher = AccountsApiBalanceFetcher; | ||
| -_AccountsApiBalanceFetcher_platform = new WeakMap(), _AccountsApiBalanceFetcher_getProvider = new WeakMap(), _AccountsApiBalanceFetcher_instances = new WeakSet(), _AccountsApiBalanceFetcher_fetchStakedBalances = async function _AccountsApiBalanceFetcher_fetchStakedBalances(addrs) { | ||
| +_AccountsApiBalanceFetcher_platform = new WeakMap(), _AccountsApiBalanceFetcher_getProvider = new WeakMap(), _AccountsApiBalanceFetcher_getUserTokens = new WeakMap(), _AccountsApiBalanceFetcher_instances = new WeakSet(), _AccountsApiBalanceFetcher_fetchStakedBalances = async function _AccountsApiBalanceFetcher_fetchStakedBalances(addrs) { | ||
| // Return empty array if no provider is available for blockchain calls | ||
| if (!__classPrivateFieldGet(this, _AccountsApiBalanceFetcher_getProvider, "f")) { | ||
| return []; | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Truthiness check instead of Map.has() for balance existence
Low Severity
The check
!existingBalanceuses truthiness to determine whether the API returned a balance for a token, butnonNativeBalancesFromAPI.get(key)returns the stored value, not a boolean. If a balance value is ever falsy (e.g., numeric0instead of aBNobject), the check passes incorrectly and a duplicate zero-balance entry gets pushed intoresults. Using!nonNativeBalancesFromAPI.has(key)would correctly test for key existence regardless of the stored value's truthiness.Additional Locations (1)
.yarn/patches/@metamask-assets-controllers-npm-98.0.0-ebc0dfef4f.patch#L75-L76