mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-11-22 18:00:18 +01:00
Merge branch 'master' into Version-v10.10.0
This commit is contained in:
commit
b0dfe2109c
@ -92,6 +92,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||
- Adding user setting option for EIP-1559 V2 ([#13242](https://github.com/MetaMask/metamask-extension/pull/13242))
|
||||
- Update Bug Report issue template ([#13267](https://github.com/MetaMask/metamask-extension/pull/13267))
|
||||
- Remove unused localized messages ([#13272](https://github.com/MetaMask/metamask-extension/pull/13272))
|
||||
## [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]
|
||||
### Fixed
|
||||
@ -2780,6 +2785,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||
|
||||
[Unreleased]: https://github.com/MetaMask/metamask-extension/compare/v10.10.0...HEAD
|
||||
[10.10.0]: https://github.com/MetaMask/metamask-extension/compare/v10.9.1...v10.10.0
|
||||
[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.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
|
||||
|
@ -78,11 +78,15 @@ export const getCaveatSpecifications = ({ getIdentities }) => {
|
||||
* in the current MetaMask instance.
|
||||
* @param options.getIdentities - A function that returns 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.
|
||||
*/
|
||||
export const getPermissionSpecifications = ({
|
||||
getAllAccounts,
|
||||
getIdentities,
|
||||
captureKeyringTypesWithMissingIdentities,
|
||||
}) => {
|
||||
return {
|
||||
[PermissionKeys.eth_accounts]: {
|
||||
@ -119,8 +123,10 @@ export const getPermissionSpecifications = ({
|
||||
|
||||
return accounts.sort((firstAddress, secondAddress) => {
|
||||
if (!identities[firstAddress]) {
|
||||
captureKeyringTypesWithMissingIdentities(identities, accounts);
|
||||
throw new Error(`Missing identity for address: "${firstAddress}".`);
|
||||
} else if (!identities[secondAddress]) {
|
||||
captureKeyringTypesWithMissingIdentities(identities, accounts);
|
||||
throw new Error(
|
||||
`Missing identity for address: "${secondAddress}".`,
|
||||
);
|
||||
|
@ -247,6 +247,7 @@ describe('PermissionController specifications', () => {
|
||||
const { methodImplementation } = getPermissionSpecifications({
|
||||
getIdentities,
|
||||
getAllAccounts,
|
||||
captureKeyringTypesWithMissingIdentities: jest.fn(),
|
||||
})[RestrictedMethods.eth_accounts];
|
||||
|
||||
await expect(() => methodImplementation()).rejects.toThrow(
|
||||
@ -272,6 +273,7 @@ describe('PermissionController specifications', () => {
|
||||
const { methodImplementation } = getPermissionSpecifications({
|
||||
getIdentities,
|
||||
getAllAccounts,
|
||||
captureKeyringTypesWithMissingIdentities: jest.fn(),
|
||||
})[RestrictedMethods.eth_accounts];
|
||||
|
||||
await expect(() => methodImplementation()).rejects.toThrow(
|
||||
|
@ -51,10 +51,12 @@ function calculateGasEstimateWithRefund(
|
||||
estimatedRefund,
|
||||
10,
|
||||
);
|
||||
const isMaxGasMinusRefundNegative = maxGasMinusRefund.lt(0);
|
||||
|
||||
const gasEstimateWithRefund = maxGasMinusRefund.lt(estimatedGas, 16)
|
||||
? maxGasMinusRefund.toString(16)
|
||||
: estimatedGas;
|
||||
const gasEstimateWithRefund =
|
||||
!isMaxGasMinusRefundNegative && maxGasMinusRefund.lt(estimatedGas, 16)
|
||||
? `0x${maxGasMinusRefund.toString(16)}`
|
||||
: estimatedGas;
|
||||
|
||||
return gasEstimateWithRefund;
|
||||
}
|
||||
|
@ -372,7 +372,9 @@ describe('SwapsController', function () {
|
||||
assert.strictEqual(gasEstimate, bufferedGasLimit);
|
||||
assert.strictEqual(
|
||||
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,
|
||||
// TODO: find a way to calculate these values dynamically
|
||||
gasEstimate: 2000000,
|
||||
gasEstimateWithRefund: 'b8cae',
|
||||
gasEstimateWithRefund: '0xb8cae',
|
||||
savings: {
|
||||
fee: '0',
|
||||
metaMaskFee: '0.5050505050505050505',
|
||||
|
@ -1,3 +1,4 @@
|
||||
import { flatten } from 'lodash';
|
||||
import { permissionRpcMethods } from '@metamask/snap-controllers';
|
||||
import { selectHooks } from '@metamask/rpc-methods';
|
||||
import { ethErrors } from 'eth-rpc-errors';
|
||||
@ -15,7 +16,7 @@ const handlerMap = allHandlers.reduce((map, handler) => {
|
||||
|
||||
const expectedHookNames = Array.from(
|
||||
new Set(
|
||||
allHandlers.map(({ hookNames }) => Object.keys(hookNames)).flat(),
|
||||
flatten(allHandlers.map(({ hookNames }) => Object.keys(hookNames))),
|
||||
).values(),
|
||||
);
|
||||
|
||||
|
@ -505,6 +505,30 @@ export default class MetamaskController extends EventEmitter {
|
||||
getAllAccounts: this.keyringController.getAccounts.bind(
|
||||
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,
|
||||
});
|
||||
|
@ -111,7 +111,7 @@ export function useGasEstimates({
|
||||
const maximumCostInHexWei = getMaximumGasTotalInHexWei(gasSettings);
|
||||
|
||||
if (editGasMode === EDIT_GAS_MODES.SWAPS) {
|
||||
gasSettings = { ...gasSettings, gasLimit: decimalToHex(minimumGasLimit) };
|
||||
gasSettings = { ...gasSettings, gasLimit: minimumGasLimit };
|
||||
}
|
||||
|
||||
// The minimum amount this transaction will cost
|
||||
|
Loading…
Reference in New Issue
Block a user