1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-12-23 09:52:26 +01:00

Merge remote-tracking branch 'origin/master' into Version-v10.16.0

This commit is contained in:
seaona 2022-06-23 13:54:49 +02:00
commit 7afa381b49
6 changed files with 53 additions and 8 deletions

1
.iyarc
View File

@ -2,3 +2,4 @@
GHSA-93q8-gq69-wqmw
GHSA-257v-vj4p-3w2h
GHSA-wm7h-9275-46v2
GHSA-pfrx-2q88-qq97

View File

@ -67,6 +67,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- **[FLASK]** Fix issues with the snap startup process and usage of `WebAssembly` ([#14772](https://github.com/MetaMask/metamask-extension/pull/14772))
- **[FLASK]** Fix issues with snap id encoding ([#14693](https://github.com/MetaMask/metamask-extension/pull/14693))
- **[FLASK]** Fix multiple smaller bugs with snaps ([#14670](https://github.com/MetaMask/metamask-extension/pull/14670))
## [10.15.1]
### Fixed
- Fix Ledger connection failures that can occur after remove all hardware wallet accounts and reconnecting ([#14993](https://github.com/MetaMask/metamask-extension/pull/14993))
- Fix bug that could cause MetaMask to crash in some cases when interacting with tokens or NFTs ([#14962](https://github.com/MetaMask/metamask-extension/pull/14962))
## [10.15.0]
### Added
@ -3028,6 +3032,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
[Unreleased]: https://github.com/MetaMask/metamask-extension/compare/v10.16.0...HEAD
[10.16.0]: https://github.com/MetaMask/metamask-extension/compare/v10.15.0...v10.16.0
[Unreleased]: https://github.com/MetaMask/metamask-extension/compare/v10.15.1...HEAD
[10.15.1]: https://github.com/MetaMask/metamask-extension/compare/v10.15.0...v10.15.1
[10.15.0]: https://github.com/MetaMask/metamask-extension/compare/v10.14.7...v10.15.0
[10.14.7]: https://github.com/MetaMask/metamask-extension/compare/v10.14.6...v10.14.7
[10.14.6]: https://github.com/MetaMask/metamask-extension/compare/v10.14.5...v10.14.6

View File

@ -630,11 +630,9 @@ export default class MetaMetricsController {
* @returns {[]}
*/
_getAllNFTsFlattened = memoize((allCollectibles = {}) => {
return Object.values(allCollectibles)
.reduce((result, chainNFTs) => {
return result.concat(Object.values(chainNFTs));
}, [])
.flat();
return Object.values(allCollectibles).reduce((result, chainNFTs) => {
return result.concat(...Object.values(chainNFTs));
}, []);
});
/**

View File

@ -77,14 +77,27 @@ async function addEthereumChainHandler(
);
}
const isLocalhost = (strUrl) => {
try {
const url = new URL(strUrl);
return url.hostname === 'localhost' || url.hostname === '127.0.0.1';
} catch (error) {
return false;
}
};
const firstValidRPCUrl = Array.isArray(rpcUrls)
? rpcUrls.find((rpcUrl) => validUrl.isHttpsUri(rpcUrl))
? rpcUrls.find(
(rpcUrl) => isLocalhost(rpcUrl) || validUrl.isHttpsUri(rpcUrl),
)
: null;
const firstValidBlockExplorerUrl =
blockExplorerUrls !== null && Array.isArray(blockExplorerUrls)
? blockExplorerUrls.find((blockExplorerUrl) =>
validUrl.isHttpsUri(blockExplorerUrl),
? blockExplorerUrls.find(
(blockExplorerUrl) =>
isLocalhost(blockExplorerUrl) ||
validUrl.isHttpsUri(blockExplorerUrl),
)
: null;

View File

@ -2668,8 +2668,14 @@ export default class MetamaskController extends EventEmitter {
// Remove account from the account tracker controller
this.accountTracker.removeAccount([address]);
const keyring = await this.keyringController.getKeyringForAccount(address);
// Remove account from the keyring
await this.keyringController.removeAccount(address);
const updatedKeyringAccounts = keyring ? await keyring.getAccounts() : {};
if (updatedKeyringAccounts?.length === 0) {
keyring.destroy?.();
}
return address;
}

View File

@ -782,12 +782,20 @@ describe('MetaMaskController', function () {
describe('#removeAccount', function () {
let ret;
const addressToRemove = '0x1';
let mockKeyring;
beforeEach(async function () {
mockKeyring = {
getAccounts: sinon.stub().returns(Promise.resolve([])),
destroy: sinon.stub(),
};
sinon.stub(metamaskController.preferencesController, 'removeAddress');
sinon.stub(metamaskController.accountTracker, 'removeAccount');
sinon.stub(metamaskController.keyringController, 'removeAccount');
sinon.stub(metamaskController, 'removeAllAccountPermissions');
sinon
.stub(metamaskController.keyringController, 'getKeyringForAccount')
.returns(Promise.resolve(mockKeyring));
ret = await metamaskController.removeAccount(addressToRemove);
});
@ -797,6 +805,9 @@ describe('MetaMaskController', function () {
metamaskController.accountTracker.removeAccount.restore();
metamaskController.preferencesController.removeAddress.restore();
metamaskController.removeAllAccountPermissions.restore();
mockKeyring.getAccounts.resetHistory();
mockKeyring.destroy.resetHistory();
});
it('should call preferencesController.removeAddress', async function () {
@ -830,6 +841,16 @@ describe('MetaMaskController', function () {
it('should return address', async function () {
assert.equal(ret, '0x1');
});
it('should call keyringController.getKeyringForAccount', async function () {
assert(
metamaskController.keyringController.getKeyringForAccount.calledWith(
addressToRemove,
),
);
});
it('should call keyring.destroy', async function () {
assert(mockKeyring.destroy.calledOnce);
});
});
describe('#newUnsignedMessage', function () {