From 51311e4024135cd9515f4d82d1647f24e215d093 Mon Sep 17 00:00:00 2001 From: MetaMask Bot Date: Tue, 28 Jun 2022 14:42:13 +0000 Subject: [PATCH 1/5] Version v10.16.1 --- CHANGELOG.md | 8 +++++++- package.json | 2 +- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 08d466ef2..b9d96a208 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +## [10.16.1] +### Uncategorized +- Revert v10.16.0 ([#15063](https://github.com/MetaMask/metamask-extension/pull/15063)) +- This reverts commit f09ab8889148c406551dea1643966e3331fde4aa, reversing ([#14912](https://github.com/MetaMask/metamask-extension/pull/14912)) + ## [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)) @@ -2969,7 +2974,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Uncategorized - Added the ability to restore accounts from seed words. -[Unreleased]: https://github.com/MetaMask/metamask-extension/compare/v10.15.1...HEAD +[Unreleased]: https://github.com/MetaMask/metamask-extension/compare/v10.16.1...HEAD +[10.16.1]: https://github.com/MetaMask/metamask-extension/compare/v10.15.1...v10.16.1 [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 diff --git a/package.json b/package.json index a8aecef00..9a2d06e5d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "metamask-crx", - "version": "10.15.1", + "version": "10.16.1", "private": true, "repository": { "type": "git", From 7f9e24c4f03f9b32c14798221d9e70ab043f9128 Mon Sep 17 00:00:00 2001 From: Dan J Miller Date: Tue, 28 Jun 2022 14:21:09 -0230 Subject: [PATCH 2/5] Ensure that addresses are properly hex-prefixed in the generate ERC token transfer functions (#15064) * Ensure that addresses are properly hex-prefixed in the generate ERC token transfer functions * Ensure hex-prefixed addresses in send input * Update unit tests Co-authored-by: Frederik Bolding --- ui/ducks/send/send.test.js | 59 +++++++++++++++++++ .../add-recipient/ens-input.component.js | 6 +- ui/pages/send/send.utils.js | 4 +- ui/pages/send/send.utils.test.js | 2 +- 4 files changed, 66 insertions(+), 5 deletions(-) diff --git a/ui/ducks/send/send.test.js b/ui/ducks/send/send.test.js index a8466753b..c7ea60bf4 100644 --- a/ui/ducks/send/send.test.js +++ b/ui/ducks/send/send.test.js @@ -88,11 +88,16 @@ setBackgroundConnection({ describe('Send Slice', () => { let getTokenStandardAndDetailsStub; + let addUnapprovedTransactionAndRouteToConfirmationPageStub; beforeEach(() => { jest.useFakeTimers(); getTokenStandardAndDetailsStub = jest .spyOn(Actions, 'getTokenStandardAndDetails') .mockImplementation(() => Promise.resolve({ standard: 'ERC20' })); + addUnapprovedTransactionAndRouteToConfirmationPageStub = jest.spyOn( + Actions, + 'addUnapprovedTransactionAndRouteToConfirmationPage', + ); jest .spyOn(Actions, 'estimateGas') .mockImplementation(() => Promise.resolve('0x0')); @@ -2144,6 +2149,60 @@ describe('Send Slice', () => { expect(actionResult[1].type).toStrictEqual('SHOW_CONF_TX_PAGE'); }); + describe('with token transfers', () => { + it('should pass the correct transaction parameters to addUnapprovedTransactionAndRouteToConfirmationPage', async () => { + const tokenTransferTxState = { + metamask: { + unapprovedTxs: { + 1: { + id: 1, + txParams: { + value: 'oldTxValue', + }, + }, + }, + }, + send: { + ...signTransactionState.send, + stage: SEND_STAGES.DRAFT, + id: 1, + account: { + address: '0x6784e8507A1A46443f7bDc8f8cA39bdA92A675A6', + }, + asset: { + details: { + address: '0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2', + }, + type: 'TOKEN', + }, + recipient: { + address: '4F90e18605Fd46F9F9Fab0e225D88e1ACf5F5324', + }, + amount: { + value: '0x1', + }, + }, + }; + + jest.mock('../../store/actions.js'); + + const store = mockStore(tokenTransferTxState); + + await store.dispatch(signTransaction()); + + expect( + addUnapprovedTransactionAndRouteToConfirmationPageStub.mock + .calls[0][0].data, + ).toStrictEqual( + '0xa9059cbb0000000000000000000000004f90e18605fd46f9f9fab0e225d88e1acf5f53240000000000000000000000000000000000000000000000000000000000000001', + ); + expect( + addUnapprovedTransactionAndRouteToConfirmationPageStub.mock + .calls[0][0].to, + ).toStrictEqual('0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2'); + }); + }); + it('should create actions for updateTransaction rejecting', async () => { const editStageSignTxState = { metamask: { diff --git a/ui/pages/send/send-content/add-recipient/ens-input.component.js b/ui/pages/send/send-content/add-recipient/ens-input.component.js index 4cf63a7fa..a8ae49439 100644 --- a/ui/pages/send/send-content/add-recipient/ens-input.component.js +++ b/ui/pages/send/send-content/add-recipient/ens-input.component.js @@ -2,6 +2,7 @@ import React, { Component } from 'react'; import PropTypes from 'prop-types'; import classnames from 'classnames'; +import { addHexPrefix } from '../../../../../app/scripts/lib/util'; import { isValidDomainName } from '../../../../helpers/utils/util'; import { isBurnAddress, @@ -36,6 +37,7 @@ export default class EnsInput extends Component { onPaste = (event) => { if (event.clipboardData.items?.length) { + event.preventDefault(); const clipboardItem = event.clipboardData.items[0]; clipboardItem?.getAsString((text) => { const input = text.trim(); @@ -43,7 +45,7 @@ export default class EnsInput extends Component { !isBurnAddress(input) && isValidHexAddress(input, { mixedCaseUseChecksum: true }) ) { - this.props.onPaste(input); + this.props.onPaste(addHexPrefix(input)); } }); } @@ -74,7 +76,7 @@ export default class EnsInput extends Component { !isBurnAddress(input) && isValidHexAddress(input, { mixedCaseUseChecksum: true }) ) { - onValidAddressTyped(input); + onValidAddressTyped(addHexPrefix(input)); } } diff --git a/ui/pages/send/send.utils.js b/ui/pages/send/send.utils.js index 6935a8b0c..c53b39d54 100644 --- a/ui/pages/send/send.utils.js +++ b/ui/pages/send/send.utils.js @@ -142,7 +142,7 @@ function generateERC20TransferData({ .call( abi.rawEncode( ['address', 'uint256'], - [toAddress, addHexPrefix(amount)], + [addHexPrefix(toAddress), addHexPrefix(amount)], ), (x) => `00${x.toString(16)}`.slice(-2), ) @@ -164,7 +164,7 @@ function generateERC721TransferData({ .call( abi.rawEncode( ['address', 'address', 'uint256'], - [fromAddress, toAddress, tokenId], + [addHexPrefix(fromAddress), addHexPrefix(toAddress), tokenId], ), (x) => `00${x.toString(16)}`.slice(-2), ) diff --git a/ui/pages/send/send.utils.test.js b/ui/pages/send/send.utils.test.js index f6da81d0e..39f7c7b8f 100644 --- a/ui/pages/send/send.utils.test.js +++ b/ui/pages/send/send.utils.test.js @@ -73,7 +73,7 @@ describe('send utils', () => { expect(rawEncode.mock.calls[0].toString()).toStrictEqual( [ ['address', 'uint256'], - ['mockAddress', '0xab'], + ['0xmockAddress', '0xab'], ].toString(), ); }); From 60a8d92e9c79a4c16c9606a93f286783cd13e56f Mon Sep 17 00:00:00 2001 From: Dan Miller Date: Tue, 28 Jun 2022 14:28:09 -0230 Subject: [PATCH 3/5] Update changelog for v10.16.1 --- CHANGELOG.md | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b9d96a208..ad17829ab 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,9 +7,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] ## [10.16.1] -### Uncategorized -- Revert v10.16.0 ([#15063](https://github.com/MetaMask/metamask-extension/pull/15063)) -- This reverts commit f09ab8889148c406551dea1643966e3331fde4aa, reversing ([#14912](https://github.com/MetaMask/metamask-extension/pull/14912)) +### Changed +- This release is a patch for v10.15.2, so all changes in v10.16.0 have been temporarily reverted. They will be restored in a future v16 release. ([#15063](https://github.com/MetaMask/metamask-extension/pull/15063)) + +### Fixed +- Fix bug that could cause an incorrect recipient address after pasting an address, without a 0x prefix, in the send flow while sending a token ([#15064](https://github.com/MetaMask/metamask-extension/pull/15064) + ## [10.15.1] ### Fixed From 52590b8fe3050f3eb9331d30cd56071a7c8316b0 Mon Sep 17 00:00:00 2001 From: Dan Miller Date: Tue, 28 Jun 2022 15:09:54 -0230 Subject: [PATCH 4/5] Replace unit test from 7f9e24c4 with a test that is compatible with the state of ducks/send on master --- ui/ducks/send/send.test.js | 101 +++++++++++++++---------------------- 1 file changed, 42 insertions(+), 59 deletions(-) diff --git a/ui/ducks/send/send.test.js b/ui/ducks/send/send.test.js index c7ea60bf4..20be192f3 100644 --- a/ui/ducks/send/send.test.js +++ b/ui/ducks/send/send.test.js @@ -88,16 +88,11 @@ setBackgroundConnection({ describe('Send Slice', () => { let getTokenStandardAndDetailsStub; - let addUnapprovedTransactionAndRouteToConfirmationPageStub; beforeEach(() => { jest.useFakeTimers(); getTokenStandardAndDetailsStub = jest .spyOn(Actions, 'getTokenStandardAndDetails') .mockImplementation(() => Promise.resolve({ standard: 'ERC20' })); - addUnapprovedTransactionAndRouteToConfirmationPageStub = jest.spyOn( - Actions, - 'addUnapprovedTransactionAndRouteToConfirmationPage', - ); jest .spyOn(Actions, 'estimateGas') .mockImplementation(() => Promise.resolve('0x0')); @@ -588,6 +583,48 @@ describe('Send Slice', () => { ); }); }); + + it('should set the correct token transfers', () => { + const tokenTransferTxState = { + ...initialState, + status: SEND_STATUSES.VALID, + transactionType: TRANSACTION_ENVELOPE_TYPES.FEE_MARKET, + account: { + address: '0x6784e8507A1A46443f7bDc8f8cA39bdA92A675A6', + }, + asset: { + details: { + address: '0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2', + }, + type: 'TOKEN', + }, + recipient: { + address: '4F90e18605Fd46F9F9Fab0e225D88e1ACf5F5324', + }, + amount: { + value: '0x1', + }, + gas: { + maxFeePerGas: '0x2540be400', // 10 GWEI + maxPriorityFeePerGas: '0x3b9aca00', // 1 GWEI + gasLimit: '0x5208', // 21000 + }, + eip1559support: true, + }; + + const action = { + type: 'send/updateDraftTransaction', + }; + + const result = sendReducer(tokenTransferTxState, action); + + expect(result.draftTransaction.txParams.data).toStrictEqual( + '0xa9059cbb0000000000000000000000004f90e18605fd46f9f9fab0e225d88e1acf5f53240000000000000000000000000000000000000000000000000000000000000001', + ); + expect(result.draftTransaction.txParams.to).toStrictEqual( + '0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2', + ); + }); }); describe('useDefaultGas', () => { @@ -2149,60 +2186,6 @@ describe('Send Slice', () => { expect(actionResult[1].type).toStrictEqual('SHOW_CONF_TX_PAGE'); }); - describe('with token transfers', () => { - it('should pass the correct transaction parameters to addUnapprovedTransactionAndRouteToConfirmationPage', async () => { - const tokenTransferTxState = { - metamask: { - unapprovedTxs: { - 1: { - id: 1, - txParams: { - value: 'oldTxValue', - }, - }, - }, - }, - send: { - ...signTransactionState.send, - stage: SEND_STAGES.DRAFT, - id: 1, - account: { - address: '0x6784e8507A1A46443f7bDc8f8cA39bdA92A675A6', - }, - asset: { - details: { - address: '0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2', - }, - type: 'TOKEN', - }, - recipient: { - address: '4F90e18605Fd46F9F9Fab0e225D88e1ACf5F5324', - }, - amount: { - value: '0x1', - }, - }, - }; - - jest.mock('../../store/actions.js'); - - const store = mockStore(tokenTransferTxState); - - await store.dispatch(signTransaction()); - - expect( - addUnapprovedTransactionAndRouteToConfirmationPageStub.mock - .calls[0][0].data, - ).toStrictEqual( - '0xa9059cbb0000000000000000000000004f90e18605fd46f9f9fab0e225d88e1acf5f53240000000000000000000000000000000000000000000000000000000000000001', - ); - expect( - addUnapprovedTransactionAndRouteToConfirmationPageStub.mock - .calls[0][0].to, - ).toStrictEqual('0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2'); - }); - }); - it('should create actions for updateTransaction rejecting', async () => { const editStageSignTxState = { metamask: { From 05f29edbeb61e9f96f655ebcdc3e5fc639fdbc52 Mon Sep 17 00:00:00 2001 From: Dan J Miller Date: Tue, 28 Jun 2022 17:06:55 -0230 Subject: [PATCH 5/5] Remove change from cb77f94 that breaks ens inputs in send flow (#15069) --- ui/pages/send/send-content/add-recipient/ens-input.component.js | 1 - 1 file changed, 1 deletion(-) diff --git a/ui/pages/send/send-content/add-recipient/ens-input.component.js b/ui/pages/send/send-content/add-recipient/ens-input.component.js index a8ae49439..d220d753e 100644 --- a/ui/pages/send/send-content/add-recipient/ens-input.component.js +++ b/ui/pages/send/send-content/add-recipient/ens-input.component.js @@ -37,7 +37,6 @@ export default class EnsInput extends Component { onPaste = (event) => { if (event.clipboardData.items?.length) { - event.preventDefault(); const clipboardItem = event.clipboardData.items[0]; clipboardItem?.getAsString((text) => { const input = text.trim();