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

Merge pull request #13540 from MetaMask/Version-v10.9.2

Version v10.9.2 RC
This commit is contained in:
Dan J Miller 2022-02-08 16:31:50 -03:30 committed by GitHub
commit 1b57e6a9e8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 53 additions and 9 deletions

View File

@ -6,6 +6,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased] ## [Unreleased]
## [10.9.2]
### Fixed
- Prevent errors on the swaps "View Quote" screen that can occur if the swaps API returns incorrect refund and max gas fees on some test networks ([#13511](https://github.com/MetaMask/metamask-extension/pull/13511))
- Prevent errors on startup in Chrome Versions earlier than 69, caused by use of unsupported browser `Array.prototype.flat` method ([#13520](https://github.com/MetaMask/metamask-extension/pull/13520))
## [10.9.1] ## [10.9.1]
### Fixed ### Fixed
- Fixed application error when adding certain tokens ([#13484](https://github.com/MetaMask/metamask-extension/pull/13484)) - Fixed application error when adding certain tokens ([#13484](https://github.com/MetaMask/metamask-extension/pull/13484))
@ -2691,7 +2697,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Uncategorized ### Uncategorized
- Added the ability to restore accounts from seed words. - Added the ability to restore accounts from seed words.
[Unreleased]: https://github.com/MetaMask/metamask-extension/compare/v10.9.1...HEAD [Unreleased]: https://github.com/MetaMask/metamask-extension/compare/v10.9.2...HEAD
[10.9.2]: https://github.com/MetaMask/metamask-extension/compare/v10.9.1...v10.9.2
[10.9.1]: https://github.com/MetaMask/metamask-extension/compare/v10.9.0...v10.9.1 [10.9.1]: https://github.com/MetaMask/metamask-extension/compare/v10.9.0...v10.9.1
[10.9.0]: https://github.com/MetaMask/metamask-extension/compare/v10.8.2...v10.9.0 [10.9.0]: https://github.com/MetaMask/metamask-extension/compare/v10.8.2...v10.9.0
[10.8.2]: https://github.com/MetaMask/metamask-extension/compare/v10.8.1...v10.8.2 [10.8.2]: https://github.com/MetaMask/metamask-extension/compare/v10.8.1...v10.8.2

View File

@ -78,11 +78,15 @@ export const getCaveatSpecifications = ({ getIdentities }) => {
* in the current MetaMask instance. * in the current MetaMask instance.
* @param options.getIdentities - A function that returns the * @param options.getIdentities - A function that returns the
* `PreferencesController` identity objects for all Ethereum accounts in the * `PreferencesController` identity objects for all Ethereum accounts in the
* @param options.captureKeyringTypesWithMissingIdentities - A function that
* captures extra error information about the "Missing identity for address"
* error.
* current MetaMask instance. * current MetaMask instance.
*/ */
export const getPermissionSpecifications = ({ export const getPermissionSpecifications = ({
getAllAccounts, getAllAccounts,
getIdentities, getIdentities,
captureKeyringTypesWithMissingIdentities,
}) => { }) => {
return { return {
[PermissionKeys.eth_accounts]: { [PermissionKeys.eth_accounts]: {
@ -119,8 +123,10 @@ export const getPermissionSpecifications = ({
return accounts.sort((firstAddress, secondAddress) => { return accounts.sort((firstAddress, secondAddress) => {
if (!identities[firstAddress]) { if (!identities[firstAddress]) {
captureKeyringTypesWithMissingIdentities(identities, accounts);
throw new Error(`Missing identity for address: "${firstAddress}".`); throw new Error(`Missing identity for address: "${firstAddress}".`);
} else if (!identities[secondAddress]) { } else if (!identities[secondAddress]) {
captureKeyringTypesWithMissingIdentities(identities, accounts);
throw new Error( throw new Error(
`Missing identity for address: "${secondAddress}".`, `Missing identity for address: "${secondAddress}".`,
); );

View File

@ -247,6 +247,7 @@ describe('PermissionController specifications', () => {
const { methodImplementation } = getPermissionSpecifications({ const { methodImplementation } = getPermissionSpecifications({
getIdentities, getIdentities,
getAllAccounts, getAllAccounts,
captureKeyringTypesWithMissingIdentities: jest.fn(),
})[RestrictedMethods.eth_accounts]; })[RestrictedMethods.eth_accounts];
await expect(() => methodImplementation()).rejects.toThrow( await expect(() => methodImplementation()).rejects.toThrow(
@ -272,6 +273,7 @@ describe('PermissionController specifications', () => {
const { methodImplementation } = getPermissionSpecifications({ const { methodImplementation } = getPermissionSpecifications({
getIdentities, getIdentities,
getAllAccounts, getAllAccounts,
captureKeyringTypesWithMissingIdentities: jest.fn(),
})[RestrictedMethods.eth_accounts]; })[RestrictedMethods.eth_accounts];
await expect(() => methodImplementation()).rejects.toThrow( await expect(() => methodImplementation()).rejects.toThrow(

View File

@ -51,9 +51,11 @@ function calculateGasEstimateWithRefund(
estimatedRefund, estimatedRefund,
10, 10,
); );
const isMaxGasMinusRefundNegative = maxGasMinusRefund.lt(0);
const gasEstimateWithRefund = maxGasMinusRefund.lt(estimatedGas, 16) const gasEstimateWithRefund =
? maxGasMinusRefund.toString(16) !isMaxGasMinusRefundNegative && maxGasMinusRefund.lt(estimatedGas, 16)
? `0x${maxGasMinusRefund.toString(16)}`
: estimatedGas; : estimatedGas;
return gasEstimateWithRefund; return gasEstimateWithRefund;

View File

@ -372,7 +372,9 @@ describe('SwapsController', function () {
assert.strictEqual(gasEstimate, bufferedGasLimit); assert.strictEqual(gasEstimate, bufferedGasLimit);
assert.strictEqual( assert.strictEqual(
gasEstimateWithRefund, gasEstimateWithRefund,
new BigNumber(maxGas, 10).minus(estimatedRefund, 10).toString(16), `0x${new BigNumber(maxGas, 10)
.minus(estimatedRefund, 10)
.toString(16)}`,
); );
}); });
@ -690,7 +692,7 @@ describe('SwapsController', function () {
isBestQuote: true, isBestQuote: true,
// TODO: find a way to calculate these values dynamically // TODO: find a way to calculate these values dynamically
gasEstimate: 2000000, gasEstimate: 2000000,
gasEstimateWithRefund: 'b8cae', gasEstimateWithRefund: '0xb8cae',
savings: { savings: {
fee: '0', fee: '0',
metaMaskFee: '0.5050505050505050505', metaMaskFee: '0.5050505050505050505',

View File

@ -1,3 +1,4 @@
import { flatten } from 'lodash';
import { permissionRpcMethods } from '@metamask/snap-controllers'; import { permissionRpcMethods } from '@metamask/snap-controllers';
import { selectHooks } from '@metamask/rpc-methods'; import { selectHooks } from '@metamask/rpc-methods';
import { ethErrors } from 'eth-rpc-errors'; import { ethErrors } from 'eth-rpc-errors';
@ -15,7 +16,7 @@ const handlerMap = allHandlers.reduce((map, handler) => {
const expectedHookNames = Array.from( const expectedHookNames = Array.from(
new Set( new Set(
allHandlers.map(({ hookNames }) => Object.keys(hookNames)).flat(), flatten(allHandlers.map(({ hookNames }) => Object.keys(hookNames))),
).values(), ).values(),
); );

View File

@ -503,6 +503,30 @@ export default class MetamaskController extends EventEmitter {
getAllAccounts: this.keyringController.getAccounts.bind( getAllAccounts: this.keyringController.getAccounts.bind(
this.keyringController, this.keyringController,
), ),
captureKeyringTypesWithMissingIdentities: (
identities = {},
accounts = [],
) => {
const accountsMissingIdentities = accounts.filter(
(address) => !identities[address],
);
const keyringTypesWithMissingIdentities = accountsMissingIdentities.map(
(address) =>
this.keyringController.getKeyringForAccount(address)?.type,
);
const identitiesCount = Object.keys(identities || {}).length;
const accountTrackerCount = Object.keys(
this.accountTracker.store.getState().accounts || {},
).length;
captureException(
new Error(
`Attempt to get permission specifications failed because their were ${accounts.length} accounts, but ${identitiesCount} identities, and the ${keyringTypesWithMissingIdentities} keyrings included accounts with missing identities. Meanwhile, there are ${accountTrackerCount} accounts in the account tracker.`,
),
);
},
}), }),
unrestrictedMethods, unrestrictedMethods,
}); });

View File

@ -1,6 +1,6 @@
{ {
"name": "metamask-crx", "name": "metamask-crx",
"version": "10.9.1", "version": "10.9.2",
"private": true, "private": true,
"repository": { "repository": {
"type": "git", "type": "git",

View File

@ -111,7 +111,7 @@ export function useGasEstimates({
const maximumCostInHexWei = getMaximumGasTotalInHexWei(gasSettings); const maximumCostInHexWei = getMaximumGasTotalInHexWei(gasSettings);
if (editGasMode === EDIT_GAS_MODES.SWAPS) { if (editGasMode === EDIT_GAS_MODES.SWAPS) {
gasSettings = { ...gasSettings, gasLimit: decimalToHex(minimumGasLimit) }; gasSettings = { ...gasSettings, gasLimit: minimumGasLimit };
} }
// The minimum amount this transaction will cost // The minimum amount this transaction will cost