Skip to content

Commit

Permalink
Merge branch 'develop' into fix-erc20-e2e
Browse files Browse the repository at this point in the history
  • Loading branch information
pnarayanaswamy authored Dec 2, 2024
2 parents aaa11aa + 7143c96 commit a0f03c6
Show file tree
Hide file tree
Showing 75 changed files with 1,054 additions and 1,468 deletions.
20 changes: 18 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,15 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## [12.7.2]
### Fixed
- Fix message signatures for Gridplus lattice hardware wallets ([#28694](https://github.com/MetaMask/metamask-extension/pull/28694))

## [12.7.1]
### Fixed
- Fix bug that could prevent security warnings from being shown on token transfer confirmations in some cases ([#28487](https://github.com/MetaMask/metamask-extension/pull/28487))
- Fix balance display, so that it correctly shows ETH and fiat values, when the "Show balane and token price checker" toggle is off ([#28569](https://github.com/MetaMask/metamask-extension/pull/28569))

## [12.7.0]
### Added
- Added Token Network Filter UI, allowing users to filter tokens by network (behind a feature flag) ([#27884](https://github.com/MetaMask/metamask-extension/pull/27884))
Expand Down Expand Up @@ -42,6 +51,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Improved handling of network switching and adding networks to prevent issues with queued transactions ([#28090](https://github.com/MetaMask/metamask-extension/pull/28090))
- Prevented redirect after adding a network in Onboarding Settings ([#28165](https://github.com/MetaMask/metamask-extension/pull/28165))

## [12.6.2]
### Fixed
- Prevent QR code scanning from setting incorrect recipient addresses during the send flow by restricting the QR scanner feature to only handle simple sends, and fail on QR codes that encode more complex transaction types ([#28521](https://github.com/MetaMask/metamask-extension/pull/28521))

## [12.6.1]
### Fixed
- Fixed gas limit estimation on Base and BNB chains ([#28327](https://github.com/MetaMask/metamask-extension/pull/28327))
Expand Down Expand Up @@ -5343,8 +5356,11 @@ Update styles and spacing on the critical error page ([#20350](https://github.c
- Added the ability to restore accounts from seed words.


[Unreleased]: https://github.com/MetaMask/metamask-extension/compare/v12.7.0...HEAD
[12.7.0]: https://github.com/MetaMask/metamask-extension/compare/v12.6.1...v12.7.0
[Unreleased]: https://github.com/MetaMask/metamask-extension/compare/v12.7.2...HEAD
[12.7.2]: https://github.com/MetaMask/metamask-extension/compare/v12.7.1...v12.7.2
[12.7.1]: https://github.com/MetaMask/metamask-extension/compare/v12.7.0...v12.7.1
[12.7.0]: https://github.com/MetaMask/metamask-extension/compare/v12.6.2...v12.7.0
[12.6.2]: https://github.com/MetaMask/metamask-extension/compare/v12.6.1...v12.6.2
[12.6.1]: https://github.com/MetaMask/metamask-extension/compare/v12.6.0...v12.6.1
[12.6.0]: https://github.com/MetaMask/metamask-extension/compare/v12.5.1...v12.6.0
[12.5.1]: https://github.com/MetaMask/metamask-extension/compare/v12.5.0...v12.5.1
Expand Down
1 change: 0 additions & 1 deletion app/scripts/constants/sentry-state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,6 @@ export const SENTRY_BACKGROUND_STATE = {
termsOfUseLastAgreed: true,
timeoutMinutes: true,
trezorModel: true,
usedNetworks: true,
},
MultichainBalancesController: {
balances: false,
Expand Down
11 changes: 0 additions & 11 deletions app/scripts/controllers/app-state-controller.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -374,17 +374,6 @@ describe('AppStateController', () => {
});
});

describe('setFirstTimeUsedNetwork', () => {
it('updates the array of the first time used networks', () => {
const chainId = '0x1';

appStateController.setFirstTimeUsedNetwork(chainId);
expect(appStateController.store.getState().usedNetworks[chainId]).toBe(
true,
);
});
});

describe('setLastInteractedConfirmationInfo', () => {
it('sets information about last confirmation user has interacted with', () => {
const lastInteractedConfirmationInfo = {
Expand Down
20 changes: 0 additions & 20 deletions app/scripts/controllers/app-state-controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ export type AppStateControllerState = {
hadAdvancedGasFeesSetPriorToMigration92_3: boolean;
qrHardware: Json;
nftsDropdownState: Json;
usedNetworks: Record<string, boolean>;
surveyLinkLastClickedOrClosed: number | null;
signatureSecurityAlertResponses: Record<string, SecurityAlertResponse>;
// States used for displaying the changed network toast
Expand Down Expand Up @@ -138,7 +137,6 @@ type AppStateControllerInitState = Partial<
AppStateControllerState,
| 'qrHardware'
| 'nftsDropdownState'
| 'usedNetworks'
| 'surveyLinkLastClickedOrClosed'
| 'signatureSecurityAlertResponses'
| 'switchedNetworkDetails'
Expand Down Expand Up @@ -184,11 +182,6 @@ const getDefaultAppStateControllerState = (
...initState,
qrHardware: {},
nftsDropdownState: {},
usedNetworks: {
'0x1': true,
'0x5': true,
'0x539': true,
},
surveyLinkLastClickedOrClosed: null,
signatureSecurityAlertResponses: {},
switchedNetworkDetails: null,
Expand Down Expand Up @@ -704,19 +697,6 @@ export class AppStateController extends EventEmitter {
});
}

/**
* Updates the array of the first time used networks
*
* @param chainId
*/
setFirstTimeUsedNetwork(chainId: string): void {
const currentState = this.store.getState();
const { usedNetworks } = currentState;
usedNetworks[chainId] = true;

this.store.updateState({ usedNetworks });
}

///: BEGIN:ONLY_INCLUDE_IF(build-mmi)
/**
* Set the interactive replacement token with a url and the old refresh token
Expand Down
2 changes: 1 addition & 1 deletion app/scripts/controllers/mmi-controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ export class MMIController {
}
}

const txList = this.txStateManager.getTransactions({}, [], false); // Includes all transactions, but we are looping through keyrings. Currently filtering is done in updateCustodianTransactions :-/
const txList = this.txStateManager.getTransactions(); // Includes all transactions, but we are looping through keyrings. Currently filtering is done in updateCustodianTransactions :-/

try {
updateCustodianTransactions({
Expand Down
9 changes: 6 additions & 3 deletions app/scripts/controllers/preferences-controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,18 +124,21 @@ export type Preferences = {
shouldShowAggregatedBalancePopover: boolean;
};

// Omitting showTestNetworks and smartTransactionsOptInStatus, as they already exists here in Preferences type
// Omitting properties that already exist in the PreferencesState, as part of the preferences property.
export type PreferencesControllerState = Omit<
PreferencesState,
'showTestNetworks' | 'smartTransactionsOptInStatus'
| 'showTestNetworks'
| 'smartTransactionsOptInStatus'
| 'privacyMode'
| 'tokenSortConfig'
| 'useMultiRpcMigration'
> & {
useBlockie: boolean;
useNonceField: boolean;
usePhishDetect: boolean;
dismissSeedBackUpReminder: boolean;
overrideContentSecurityPolicyHeader: boolean;
useMultiAccountBalanceChecker: boolean;
useSafeChainsListValidation: boolean;
use4ByteResolution: boolean;
useCurrencyRateCheck: boolean;
useRequestQueue: boolean;
Expand Down
1 change: 1 addition & 0 deletions app/scripts/lib/transaction/metrics.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ describe('Transaction metrics', () => {
type: TransactionType.simpleSend,
origin: ORIGIN_METAMASK,
chainId: mockChainId,
networkClientId: 'testNetworkClientId',
time: 1624408066355,
defaultGasEstimates: {
gas: '0x7b0d',
Expand Down
11 changes: 7 additions & 4 deletions app/scripts/lib/transaction/smart-transactions.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import SmartTransactionsController, {
} from '@metamask/smart-transactions-controller';
import { NetworkControllerStateChangeEvent } from '@metamask/network-controller';
import type { SmartTransaction } from '@metamask/smart-transactions-controller/dist/types';
import { ClientId } from '@metamask/smart-transactions-controller/dist/types';
import { CHAIN_IDS } from '../../../../shared/constants/network';
import { submitSmartTransactionHook } from './smart-transactions';
import type {
Expand Down Expand Up @@ -107,13 +108,15 @@ function withRequest<ReturnValue>(
});

const smartTransactionsController = new SmartTransactionsController({
// @ts-expect-error TODO: Resolve mismatch between base-controller versions.
messenger,
getNonceLock: jest.fn(),
confirmExternalTransaction: jest.fn(),
trackMetaMetricsEvent: jest.fn(),
getTransactions: jest.fn(),
getMetaMetricsProps: jest.fn(),
clientId: ClientId.Extension,
getFeatureFlags: jest.fn(),
updateTransaction: jest.fn(),
});

jest.spyOn(smartTransactionsController, 'getFees').mockResolvedValue({
Expand Down Expand Up @@ -147,6 +150,7 @@ function withRequest<ReturnValue>(
},
type: TransactionType.simpleSend,
chainId: CHAIN_IDS.MAINNET,
networkClientId: 'testNetworkClientId',
time: 1624408066355,
defaultGasEstimates: {
gas: '0x7b0d',
Expand All @@ -169,15 +173,14 @@ function withRequest<ReturnValue>(
smartTransactions: {
expectedDeadline: 45,
maxDeadline: 150,
returnTxHashAsap: false,
extensionReturnTxHashAsap: false,
},
},
...options,
};

return fn({
request,
// @ts-expect-error TODO: Resolve mismatch between base-controller versions.
messenger,
startFlowSpy,
addRequestSpy,
Expand Down Expand Up @@ -238,7 +241,7 @@ describe('submitSmartTransactionHook', () => {

it('returns a txHash asap if the feature flag requires it', async () => {
withRequest(async ({ request }) => {
request.featureFlags.smartTransactions.returnTxHashAsap = true;
request.featureFlags.smartTransactions.extensionReturnTxHashAsap = true;
const result = await submitSmartTransactionHook(request);
expect(result).toEqual({ transactionHash: txHash });
});
Expand Down
10 changes: 5 additions & 5 deletions app/scripts/lib/transaction/smart-transactions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export type FeatureFlags = {
smartTransactions: {
expectedDeadline?: number;
maxDeadline?: number;
returnTxHashAsap?: boolean;
extensionReturnTxHashAsap?: boolean;
};
};

Expand Down Expand Up @@ -83,7 +83,7 @@ class SmartTransactionHook {
smartTransactions: {
expectedDeadline?: number;
maxDeadline?: number;
returnTxHashAsap?: boolean;
extensionReturnTxHashAsap?: boolean;
};
};

Expand Down Expand Up @@ -167,16 +167,16 @@ class SmartTransactionHook {
if (!uuid) {
throw new Error('No smart transaction UUID');
}
const returnTxHashAsap =
this.#featureFlags?.smartTransactions?.returnTxHashAsap;
const extensionReturnTxHashAsap =
this.#featureFlags?.smartTransactions?.extensionReturnTxHashAsap;
this.#addApprovalRequest({
uuid,
});
this.#addListenerToUpdateStatusPage({
uuid,
});
let transactionHash: string | undefined | null;
if (returnTxHashAsap && submitTransactionResponse?.txHash) {
if (extensionReturnTxHashAsap && submitTransactionResponse?.txHash) {
transactionHash = submitTransactionResponse.txHash;
} else {
transactionHash = await this.#waitForTransactionHash({
Expand Down
39 changes: 1 addition & 38 deletions app/scripts/lib/transaction/util.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ const TRANSACTION_PARAMS_MOCK: TransactionParams = {

const TRANSACTION_OPTIONS_MOCK: AddTransactionOptions = {
actionId: 'mockActionId',
networkClientId: 'mockNetworkClientId',
origin: 'mockOrigin',
requireApproval: false,
type: TransactionType.simpleSend,
Expand Down Expand Up @@ -151,23 +152,6 @@ describe('Transaction Utils', () => {
});
});

it('adds transaction with networkClientId if process.env.TRANSACTION_MULTICHAIN is set', async () => {
process.env.TRANSACTION_MULTICHAIN = '1';

await addTransaction(request);

expect(
request.transactionController.addTransaction,
).toHaveBeenCalledTimes(1);
expect(
request.transactionController.addTransaction,
).toHaveBeenCalledWith(TRANSACTION_PARAMS_MOCK, {
...TRANSACTION_OPTIONS_MOCK,
networkClientId: 'mockNetworkClientId',
});
process.env.TRANSACTION_MULTICHAIN = '';
});

it('returns transaction meta', async () => {
const transactionMeta = await addTransaction(request);
expect(transactionMeta).toStrictEqual(TRANSACTION_META_MOCK);
Expand Down Expand Up @@ -541,27 +525,6 @@ describe('Transaction Utils', () => {
});
});

it('adds transaction with networkClientId if process.env.TRANSACTION_MULTICHAIN is set', async () => {
process.env.TRANSACTION_MULTICHAIN = '1';

await addDappTransaction(dappRequest);

expect(
request.transactionController.addTransaction,
).toHaveBeenCalledTimes(1);
expect(
request.transactionController.addTransaction,
).toHaveBeenCalledWith(TRANSACTION_PARAMS_MOCK, {
...TRANSACTION_OPTIONS_MOCK,
networkClientId: 'mockNetworkClientId',
method: DAPP_REQUEST_MOCK.method,
requireApproval: true,
securityAlertResponse: DAPP_REQUEST_MOCK.securityAlertResponse,
type: undefined,
});
process.env.TRANSACTION_MULTICHAIN = '';
});

it('returns transaction hash', async () => {
const transactionHash = await addDappTransaction(dappRequest);
expect(transactionHash).toStrictEqual(TRANSACTION_META_MOCK.hash);
Expand Down
7 changes: 4 additions & 3 deletions app/scripts/lib/transaction/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ type BaseAddTransactionRequest = {
};

type FinalAddTransactionRequest = BaseAddTransactionRequest & {
transactionOptions: AddTransactionOptions;
transactionOptions: Partial<AddTransactionOptions>;
};

export type AddTransactionRequest = FinalAddTransactionRequest & {
Expand All @@ -66,7 +66,7 @@ export async function addDappTransaction(
const { id: actionId, method, origin } = dappRequest;
const { securityAlertResponse, traceContext } = dappRequest;

const transactionOptions: AddTransactionOptions = {
const transactionOptions: Partial<AddTransactionOptions> = {
actionId,
method,
origin,
Expand Down Expand Up @@ -143,10 +143,11 @@ async function addTransactionWithController(
transactionParams,
networkClientId,
} = request;

const { result, transactionMeta } =
await transactionController.addTransaction(transactionParams, {
...transactionOptions,
...(process.env.TRANSACTION_MULTICHAIN ? { networkClientId } : {}),
networkClientId,
});

return {
Expand Down
Loading

0 comments on commit a0f03c6

Please sign in to comment.