1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-11-22 18:00:18 +01:00

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

This commit is contained in:
Dan J Miller 2023-05-19 13:33:39 -02:30
commit 301c2e1beb
11 changed files with 164 additions and 30 deletions

View File

@ -33,6 +33,21 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- [FLASK] Fix overflowing notification content ([#18881](https://github.com/MetaMask/metamask-extension/pull/18881)) - [FLASK] Fix overflowing notification content ([#18881](https://github.com/MetaMask/metamask-extension/pull/18881))
- [FLASK] Fix missing icon for webassembly endowment ([#18781](https://github.com/MetaMask/metamask-extension/pull/18781)) - [FLASK] Fix missing icon for webassembly endowment ([#18781](https://github.com/MetaMask/metamask-extension/pull/18781))
- [FLASK] Fix text selection bug in snap ui ([#18719](https://github.com/MetaMask/metamask-extension/pull/18719)) - [FLASK] Fix text selection bug in snap ui ([#18719](https://github.com/MetaMask/metamask-extension/pull/18719))
## [10.30.4]
### Fixed
- Fix error upon submitting multiple requests that require approval ([#19050](https://github.com/MetaMask/metamask-extension/pull/19050))
- The affected requests were `eth_sendTransaction`, `wallet_watchAsset`, `eth_getEncryptionPublicKey`, and `eth_decrypt`
## [10.30.3]
### Fixed
- Restore support for chains that return hex or number responses to `net_version` ([#19156](https://github.com/MetaMask/metamask-extension/pull/19156))
## [10.30.2]
### Changed
- Improve `eth_signTypedData_v4` validation ([#19110](https://github.com/MetaMask/metamask-extension/pull/19110))
### Fixed
- Fix crash when confirming an approval where the `maxPriorityFeePerGas` is zero ([#19102](https://github.com/MetaMask/metamask-extension/pull/19102))
## [10.30.1] ## [10.30.1]
### Fixed ### Fixed
@ -3740,7 +3755,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- 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.31.0...HEAD [Unreleased]: https://github.com/MetaMask/metamask-extension/compare/v10.31.0...HEAD
[10.31.0]: https://github.com/MetaMask/metamask-extension/compare/v10.30.1...v10.31.0 [10.31.0]: https://github.com/MetaMask/metamask-extension/compare/v10.30.4...v10.31.0
[10.30.4]: https://github.com/MetaMask/metamask-extension/compare/v10.30.3...v10.30.4
[10.30.3]: https://github.com/MetaMask/metamask-extension/compare/v10.30.2...v10.30.3
[10.30.2]: https://github.com/MetaMask/metamask-extension/compare/v10.30.1...v10.30.2
[10.30.1]: https://github.com/MetaMask/metamask-extension/compare/v10.30.0...v10.30.1 [10.30.1]: https://github.com/MetaMask/metamask-extension/compare/v10.30.0...v10.30.1
[10.30.0]: https://github.com/MetaMask/metamask-extension/compare/v10.29.0...v10.30.0 [10.30.0]: https://github.com/MetaMask/metamask-extension/compare/v10.29.0...v10.30.0
[10.29.0]: https://github.com/MetaMask/metamask-extension/compare/v10.28.3...v10.29.0 [10.29.0]: https://github.com/MetaMask/metamask-extension/compare/v10.28.3...v10.29.0

View File

@ -10,10 +10,11 @@ import {
import EthQuery from 'eth-query'; import EthQuery from 'eth-query';
import { RestrictedControllerMessenger } from '@metamask/base-controller'; import { RestrictedControllerMessenger } from '@metamask/base-controller';
import { v4 as uuid } from 'uuid'; import { v4 as uuid } from 'uuid';
import { Hex, isPlainObject } from '@metamask/utils'; import { Hex, isPlainObject, isStrictHexString } from '@metamask/utils';
import { errorCodes } from 'eth-rpc-errors'; import { errorCodes } from 'eth-rpc-errors';
import { SafeEventEmitterProvider } from '@metamask/eth-json-rpc-provider'; import { SafeEventEmitterProvider } from '@metamask/eth-json-rpc-provider';
import { PollingBlockTracker } from 'eth-block-tracker'; import { PollingBlockTracker } from 'eth-block-tracker';
import { hexToDecimal } from '../../../../shared/modules/conversion.utils';
import { import {
INFURA_PROVIDER_TYPES, INFURA_PROVIDER_TYPES,
INFURA_BLOCKED_KEY, INFURA_BLOCKED_KEY,
@ -301,16 +302,22 @@ function isErrorWithCode(error: unknown): error is { code: string | number } {
} }
/** /**
* Asserts that the given value is a network ID, i.e., that it is a decimal * Convert the given value into a valid network ID. The ID is accepted
* number represented as a string. * as either a number, a decimal string, or a 0x-prefixed hex string.
* *
* @param value - The value to check. * @param value - The network ID to convert, in an unknown format.
* @returns A valid network ID (as a decimal string)
* @throws If the given value cannot be safely parsed.
*/ */
function assertNetworkId(value: any): asserts value is NetworkId { function convertNetworkId(value: unknown): NetworkId {
assert( if (typeof value === 'number' && !Number.isNaN(value)) {
/^\d+$/u.test(value) && !Number.isNaN(Number(value)), return `${value}`;
'value is not a number', } else if (isStrictHexString(value)) {
); return hexToDecimal(value) as NetworkId;
} else if (typeof value === 'string' && /^\d+$/u.test(value)) {
return value as NetworkId;
}
throw new Error(`Cannot parse as a valid network ID: '${value}'`);
} }
/** /**
@ -619,8 +626,7 @@ export class NetworkController extends EventEmitter {
this.#determineEIP1559Compatibility(provider), this.#determineEIP1559Compatibility(provider),
]); ]);
const possibleNetworkId = results[0]; const possibleNetworkId = results[0];
assertNetworkId(possibleNetworkId); networkId = convertNetworkId(possibleNetworkId);
networkId = possibleNetworkId;
supportsEIP1559 = results[1]; supportsEIP1559 = results[1];
networkStatus = NetworkStatus.Available; networkStatus = NetworkStatus.Available;
} catch (error) { } catch (error) {

View File

@ -63,6 +63,7 @@ import {
///: END:ONLY_INCLUDE_IN ///: END:ONLY_INCLUDE_IN
import { SignatureController } from '@metamask/signature-controller'; import { SignatureController } from '@metamask/signature-controller';
import { ApprovalType } from '@metamask/controller-utils';
import { import {
AssetType, AssetType,
TransactionStatus, TransactionStatus,
@ -94,7 +95,6 @@ import { UI_NOTIFICATIONS } from '../../shared/notifications';
import { MILLISECOND, SECOND } from '../../shared/constants/time'; import { MILLISECOND, SECOND } from '../../shared/constants/time';
import { import {
ORIGIN_METAMASK, ORIGIN_METAMASK,
MESSAGE_TYPE,
///: BEGIN:ONLY_INCLUDE_IN(snaps) ///: BEGIN:ONLY_INCLUDE_IN(snaps)
SNAP_DIALOG_TYPES, SNAP_DIALOG_TYPES,
///: END:ONLY_INCLUDE_IN ///: END:ONLY_INCLUDE_IN
@ -256,9 +256,13 @@ export default class MetamaskController extends EventEmitter {
}), }),
showApprovalRequest: opts.showUserConfirmation, showApprovalRequest: opts.showUserConfirmation,
typesExcludedFromRateLimiting: [ typesExcludedFromRateLimiting: [
MESSAGE_TYPE.ETH_SIGN, ApprovalType.EthSign,
MESSAGE_TYPE.PERSONAL_SIGN, ApprovalType.PersonalSign,
MESSAGE_TYPE.ETH_SIGN_TYPED_DATA, ApprovalType.EthSignTypedData,
ApprovalType.Transaction,
ApprovalType.WatchAsset,
ApprovalType.EthGetEncryptionPublicKey,
ApprovalType.EthDecrypt,
], ],
}); });

View File

@ -1653,13 +1653,25 @@
"packages": { "packages": {
"@metamask/base-controller": true, "@metamask/base-controller": true,
"@metamask/controller-utils": true, "@metamask/controller-utils": true,
"@metamask/message-manager": true, "@metamask/signature-controller>@metamask/message-manager": true,
"browserify>buffer": true, "browserify>buffer": true,
"browserify>events": true, "browserify>events": true,
"eth-rpc-errors": true, "eth-rpc-errors": true,
"ethereumjs-util": true "ethereumjs-util": true
} }
}, },
"@metamask/signature-controller>@metamask/message-manager": {
"packages": {
"@metamask/base-controller": true,
"@metamask/controller-utils": true,
"@metamask/message-manager>jsonschema": true,
"browserify>buffer": true,
"browserify>events": true,
"eth-sig-util": true,
"ethereumjs-util": true,
"uuid": true
}
},
"@metamask/smart-transactions-controller": { "@metamask/smart-transactions-controller": {
"globals": { "globals": {
"URLSearchParams": true, "URLSearchParams": true,

View File

@ -1829,13 +1829,25 @@
"packages": { "packages": {
"@metamask/base-controller": true, "@metamask/base-controller": true,
"@metamask/controller-utils": true, "@metamask/controller-utils": true,
"@metamask/message-manager": true, "@metamask/signature-controller>@metamask/message-manager": true,
"browserify>buffer": true, "browserify>buffer": true,
"browserify>events": true, "browserify>events": true,
"eth-rpc-errors": true, "eth-rpc-errors": true,
"ethereumjs-util": true "ethereumjs-util": true
} }
}, },
"@metamask/signature-controller>@metamask/message-manager": {
"packages": {
"@metamask/base-controller": true,
"@metamask/controller-utils": true,
"@metamask/message-manager>jsonschema": true,
"browserify>buffer": true,
"browserify>events": true,
"eth-sig-util": true,
"ethereumjs-util": true,
"uuid": true
}
},
"@metamask/smart-transactions-controller": { "@metamask/smart-transactions-controller": {
"globals": { "globals": {
"URLSearchParams": true, "URLSearchParams": true,

View File

@ -1829,13 +1829,25 @@
"packages": { "packages": {
"@metamask/base-controller": true, "@metamask/base-controller": true,
"@metamask/controller-utils": true, "@metamask/controller-utils": true,
"@metamask/message-manager": true, "@metamask/signature-controller>@metamask/message-manager": true,
"browserify>buffer": true, "browserify>buffer": true,
"browserify>events": true, "browserify>events": true,
"eth-rpc-errors": true, "eth-rpc-errors": true,
"ethereumjs-util": true "ethereumjs-util": true
} }
}, },
"@metamask/signature-controller>@metamask/message-manager": {
"packages": {
"@metamask/base-controller": true,
"@metamask/controller-utils": true,
"@metamask/message-manager>jsonschema": true,
"browserify>buffer": true,
"browserify>events": true,
"eth-sig-util": true,
"ethereumjs-util": true,
"uuid": true
}
},
"@metamask/smart-transactions-controller": { "@metamask/smart-transactions-controller": {
"globals": { "globals": {
"URLSearchParams": true, "URLSearchParams": true,

View File

@ -1653,13 +1653,25 @@
"packages": { "packages": {
"@metamask/base-controller": true, "@metamask/base-controller": true,
"@metamask/controller-utils": true, "@metamask/controller-utils": true,
"@metamask/message-manager": true, "@metamask/signature-controller>@metamask/message-manager": true,
"browserify>buffer": true, "browserify>buffer": true,
"browserify>events": true, "browserify>events": true,
"eth-rpc-errors": true, "eth-rpc-errors": true,
"ethereumjs-util": true "ethereumjs-util": true
} }
}, },
"@metamask/signature-controller>@metamask/message-manager": {
"packages": {
"@metamask/base-controller": true,
"@metamask/controller-utils": true,
"@metamask/message-manager>jsonschema": true,
"browserify>buffer": true,
"browserify>events": true,
"eth-sig-util": true,
"ethereumjs-util": true,
"uuid": true
}
},
"@metamask/smart-transactions-controller": { "@metamask/smart-transactions-controller": {
"globals": { "globals": {
"URLSearchParams": true, "URLSearchParams": true,

View File

@ -248,7 +248,7 @@
"@metamask/jazzicon": "^2.0.0", "@metamask/jazzicon": "^2.0.0",
"@metamask/key-tree": "^7.0.0", "@metamask/key-tree": "^7.0.0",
"@metamask/logo": "^3.1.1", "@metamask/logo": "^3.1.1",
"@metamask/message-manager": "^4.0.0", "@metamask/message-manager": "^5.0.0",
"@metamask/metamask-eth-abis": "^3.0.0", "@metamask/metamask-eth-abis": "^3.0.0",
"@metamask/notification-controller": "^2.0.0", "@metamask/notification-controller": "^2.0.0",
"@metamask/obs-store": "^8.1.0", "@metamask/obs-store": "^8.1.0",

View File

@ -50,6 +50,16 @@ const GasDetailsItem = ({ userAcknowledgedGasMissing = false }) => {
return null; return null;
} }
const maxPriorityFeePerGasToRender = (
maxPriorityFeePerGas ??
hexWEIToDecGWEI(transactionData.txParams?.maxPriorityFeePerGas ?? '0x0')
).toString();
const maxFeePerGasToRender = (
maxFeePerGas ??
hexWEIToDecGWEI(transactionData.txParams?.maxFeePerGas ?? '0x0')
).toString();
return ( return (
<TransactionDetailItem <TransactionDetailItem
key="gas-details-item" key="gas-details-item"
@ -113,14 +123,8 @@ const GasDetailsItem = ({ userAcknowledgedGasMissing = false }) => {
} }
subTitle={ subTitle={
<GasTiming <GasTiming
maxPriorityFeePerGas={( maxPriorityFeePerGas={maxPriorityFeePerGasToRender}
maxPriorityFeePerGas || maxFeePerGas={maxFeePerGasToRender}
hexWEIToDecGWEI(transactionData.txParams.maxPriorityFeePerGas)
).toString()}
maxFeePerGas={(
maxFeePerGas ||
hexWEIToDecGWEI(transactionData.txParams.maxFeePerGas)
).toString()}
/> />
} }
/> />

View File

@ -110,4 +110,43 @@ describe('GasDetailsItem', () => {
expect(screen.queryAllByText('ETH').length).toBeGreaterThan(0); expect(screen.queryAllByText('ETH').length).toBeGreaterThan(0);
}); });
}); });
it('should render gas fee details if maxPriorityFeePerGas is 0', async () => {
render({
contextProps: {
transaction: {
txParams: {
gas: '0x5208',
maxFeePerGas: '0x59682f10',
maxPriorityFeePerGas: '0',
},
simulationFails: false,
userFeeLevel: 'low',
},
},
});
await waitFor(() => {
expect(screen.queryAllByTitle('0.0000315 ETH').length).toBeGreaterThan(0);
expect(screen.queryAllByText('ETH').length).toBeGreaterThan(0);
});
});
it('should render gas fee details if maxPriorityFeePerGas is undefined', async () => {
render({
contextProps: {
transaction: {
txParams: {
gas: '0x5208',
maxFeePerGas: '0x59682f10',
},
simulationFails: false,
userFeeLevel: 'low',
},
},
});
await waitFor(() => {
expect(screen.queryAllByTitle('0.0000315 ETH').length).toBeGreaterThan(0);
expect(screen.queryAllByText('ETH').length).toBeGreaterThan(0);
});
});
}); });

View File

@ -4060,6 +4060,21 @@ __metadata:
languageName: node languageName: node
linkType: hard linkType: hard
"@metamask/message-manager@npm:^5.0.0":
version: 5.0.0
resolution: "@metamask/message-manager@npm:5.0.0"
dependencies:
"@metamask/base-controller": ^2.0.0
"@metamask/controller-utils": ^3.4.0
"@types/uuid": ^8.3.0
eth-sig-util: ^3.0.0
ethereumjs-util: ^7.0.10
jsonschema: ^1.2.4
uuid: ^8.3.2
checksum: 078c7eeca03975c3a899dcaa7485ce7aaff6d97b53c2a8e8563ec4e17791b836914fbc0f57a64cbf263be231609e0ffc77eabbe9a98fdcc1240af09a733ba574
languageName: node
linkType: hard
"@metamask/metamask-eth-abis@npm:3.0.0, @metamask/metamask-eth-abis@npm:^3.0.0": "@metamask/metamask-eth-abis@npm:3.0.0, @metamask/metamask-eth-abis@npm:^3.0.0":
version: 3.0.0 version: 3.0.0
resolution: "@metamask/metamask-eth-abis@npm:3.0.0" resolution: "@metamask/metamask-eth-abis@npm:3.0.0"
@ -24006,7 +24021,7 @@ __metadata:
"@metamask/jazzicon": ^2.0.0 "@metamask/jazzicon": ^2.0.0
"@metamask/key-tree": ^7.0.0 "@metamask/key-tree": ^7.0.0
"@metamask/logo": ^3.1.1 "@metamask/logo": ^3.1.1
"@metamask/message-manager": ^4.0.0 "@metamask/message-manager": ^5.0.0
"@metamask/metamask-eth-abis": ^3.0.0 "@metamask/metamask-eth-abis": ^3.0.0
"@metamask/notification-controller": ^2.0.0 "@metamask/notification-controller": ^2.0.0
"@metamask/obs-store": ^8.1.0 "@metamask/obs-store": ^8.1.0