Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: 7.38.0 stable main sync #13131

Merged
merged 20 commits into from
Jan 27, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
feat: 7.37.1 (#12662)
This is the hot fix release candidate for version 7.37.1.

  # Team sign-off checklist
  - [x] team-confirmations

---------

Co-authored-by: metamaskbot <metamaskbot@users.noreply.github.com>
Co-authored-by: runway-github[bot] <73448015+runway-github[bot]@users.noreply.github.com>
Co-authored-by: Daniel <80175477+dan437@users.noreply.github.com>
Co-authored-by: sethkfman <10342624+sethkfman@users.noreply.github.com>
Co-authored-by: cryptodev-2s <109512101+cryptodev-2s@users.noreply.github.com>
  • Loading branch information
6 people authored Dec 20, 2024
commit 0f7453072fe29b00f61e4ad7ceaec8e784859f4b
4 changes: 2 additions & 2 deletions android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -173,8 +173,8 @@ android {
applicationId "io.metamask"
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
versionName "7.37.0"
versionCode 1512
versionName "7.37.1"
versionCode 1520
testBuildType System.getProperty('testBuildType', 'debug')
missingDimensionStrategy 'react-native-camera', 'general'
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
Expand Down
7 changes: 5 additions & 2 deletions app/lib/ppom/ppom-util.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ describe('PPOM Utils', () => {
url: 'https://mainnet.infura.io/v3',
},
],
lastUpdatedAt: Date.now(),
},
},
networksMetadata: {},
Expand All @@ -176,8 +177,10 @@ describe('PPOM Utils', () => {
MockEngine.context.PreferencesController.state.securityAlertsEnabled =
false;
await PPOMUtil.validateRequest(mockRequest, CHAIN_ID_MOCK);
expect(MockEngine.context.PPOMController?.usePPOM).toBeCalledTimes(0);
expect(spyTransactionAction).toBeCalledTimes(0);
expect(MockEngine.context.PPOMController?.usePPOM).toHaveBeenCalledTimes(
0,
);
expect(spyTransactionAction).toHaveBeenCalledTimes(0);
});

it('should not validate if request is send to users own account ', async () => {
Expand Down
328 changes: 328 additions & 0 deletions app/store/migrations/063.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,328 @@
import migrate from './063';
import { merge } from 'lodash';
import { captureException } from '@sentry/react-native';
import initialRootState from '../../util/test/initial-root-state';
import { SmartTransactionStatuses } from '@metamask/smart-transactions-controller/dist/types';
import { TransactionStatus, CHAIN_IDS } from '@metamask/transaction-controller';

const expectedState = {
engine: {
backgroundState: {
TransactionController: {
transactions: [
{
chainId: CHAIN_IDS.MAINNET,
id: '1',
origin: 'test.com',
status: TransactionStatus.confirmed,
time: 1631714312,
txParams: {
from: '0x1',
},
hash: '0x2',
rawTx: '0x3',
},
{
chainId: CHAIN_IDS.LINEA_MAINNET,
id: '2',
origin: 'test.com',
status: TransactionStatus.confirmed,
time: 1631714312,
txParams: {
from: '0x1',
},
hash: '0x3',
},
{
chainId: CHAIN_IDS.MAINNET,
id: '3',
origin: 'test2.com',
status: TransactionStatus.failed,
time: 1631714313,
txParams: {
from: '0x6',
},
hash: '0x4',
rawTx: '0x5',
},
{
chainId: CHAIN_IDS.MAINNET,
id: '4',
origin: 'test2.com',
status: TransactionStatus.failed,
time: 1631714313,
txParams: {
from: '0x6',
},
hash: '0x5',
rawTx: '0x6',
error: {
name: 'SmartTransactionCancelled',
message: 'Smart transaction cancelled. Previous status: submitted',
},
},
{
chainId: CHAIN_IDS.MAINNET,
id: '5',
origin: 'test2.com',
status: TransactionStatus.failed,
time: 1631714313,
txParams: {
from: '0x6',
},
hash: '0x6',
rawTx: '0x7',
error: {
name: 'SmartTransactionCancelled',
message: 'Smart transaction cancelled. Previous status: signed',
},
},
{
chainId: CHAIN_IDS.MAINNET,
id: '6',
origin: 'test2.com',
status: TransactionStatus.failed,
time: 1631714313,
txParams: {
from: '0x6',
},
hash: '0x7',
rawTx: '0x8',
error: {
name: 'SmartTransactionCancelled',
message: 'Smart transaction cancelled. Previous status: signed',
},
},
],
},
SmartTransactionsController: {
smartTransactionsState: {
smartTransactions: {
[CHAIN_IDS.MAINNET]: [
{
txHash: '0x2',
status: SmartTransactionStatuses.SUCCESS,
},
{
txHash: '0x4',
status: SmartTransactionStatuses.CANCELLED,
},
{
txHash: '0x5',
status: SmartTransactionStatuses.CANCELLED,
},
{
txHash: '0x6',
status: SmartTransactionStatuses.UNKNOWN,
},
{
txHash: '0x7',
status: SmartTransactionStatuses.RESOLVED,
},
],
},
},
},
},
},
};

jest.mock('@sentry/react-native', () => ({
captureException: jest.fn(),
}));
const mockedCaptureException = jest.mocked(captureException);

describe('Migration #63', () => {
beforeEach(() => {
jest.restoreAllMocks();
jest.resetAllMocks();
});

const invalidStates = [
{
state: null,
errorMessage: "FATAL ERROR: Migration 63: Invalid state error: 'object'",
scenario: 'state is invalid',
},
{
state: merge({}, initialRootState, {
engine: null,
}),
errorMessage:
"FATAL ERROR: Migration 63: Invalid engine state error: 'object'",
scenario: 'engine state is invalid',
},
{
state: merge({}, initialRootState, {
engine: {
backgroundState: null,
},
}),
errorMessage:
"FATAL ERROR: Migration 63: Invalid engine backgroundState error: 'object'",
scenario: 'backgroundState is invalid',
},
{
state: merge({}, initialRootState, {
engine: {
backgroundState: { TransactionController: null },
},
}),
errorMessage: "Migration 63: Invalid TransactionController state: 'null'",
scenario: 'transactionController is invalid',
},
{
state: merge({}, initialRootState, {
engine: {
backgroundState: { SmartTransactionsController: null },
},
}),
errorMessage:
"Migration 63: Invalid SmartTransactionsController state: 'null'",
scenario: 'smartTransactionsController is invalid',
},
{
state: merge({}, initialRootState, {
engine: {
backgroundState: {
SmartTransactionsController: {
smartTransactionsState: { smartTransactions: null },
},
},
},
}),
errorMessage:
"Migration 63: Missing smart transactions property from SmartTransactionsController: 'object'",
scenario:
'smartTransactionsController.smartTransactionsState.smartTransactions is invalid',
},
];
it.each(invalidStates)(
'captures exception if $scenario',
({ errorMessage, state }) => {
const newState = migrate(state);

expect(newState).toStrictEqual(state);
expect(mockedCaptureException).toHaveBeenCalledWith(expect.any(Error));
expect(mockedCaptureException.mock.calls[0][0].message).toBe(
errorMessage,
);
},
);

it('applies migration, changes transaction status to failed if a smart transaction was cancelled or unknown', () => {
const oldState = {
engine: {
backgroundState: {
TransactionController: {
transactions: [
{
chainId: CHAIN_IDS.MAINNET,
id: '1',
origin: 'test.com',
status: TransactionStatus.confirmed,
time: 1631714312,
txParams: {
from: '0x1',
},
hash: '0x2',
rawTx: '0x3',
},
{
chainId: CHAIN_IDS.LINEA_MAINNET,
id: '2',
origin: 'test.com',
status: TransactionStatus.confirmed,
time: 1631714312,
txParams: {
from: '0x1',
},
hash: '0x3',
},
{
chainId: CHAIN_IDS.MAINNET,
id: '3',
origin: 'test2.com',
status: TransactionStatus.failed,
time: 1631714313,
txParams: {
from: '0x6',
},
hash: '0x4',
rawTx: '0x5',
},
{
chainId: CHAIN_IDS.MAINNET,
id: '4',
origin: 'test2.com',
status: TransactionStatus.submitted,
time: 1631714313,
txParams: {
from: '0x6',
},
hash: '0x5',
rawTx: '0x6',
},
{
chainId: CHAIN_IDS.MAINNET,
id: '5',
origin: 'test2.com',
status: TransactionStatus.signed,
time: 1631714313,
txParams: {
from: '0x6',
},
hash: '0x6',
rawTx: '0x7',
},
{
chainId: CHAIN_IDS.MAINNET,
id: '6',
origin: 'test2.com',
status: TransactionStatus.signed,
time: 1631714313,
txParams: {
from: '0x6',
},
hash: '0x7',
rawTx: '0x8',
},
],
},
SmartTransactionsController: {
smartTransactionsState: {
smartTransactions: {
[CHAIN_IDS.MAINNET]: [
{
txHash: '0x2',
status: SmartTransactionStatuses.SUCCESS,
},
{
txHash: '0x4',
status: SmartTransactionStatuses.CANCELLED,
},
{
txHash: '0x5',
status: SmartTransactionStatuses.CANCELLED,
},
{
txHash: '0x6',
status: SmartTransactionStatuses.UNKNOWN,
},
{
txHash: '0x7',
status: SmartTransactionStatuses.RESOLVED,
},
],
},
},
},
},
},
};

const newState = migrate(oldState);

expect(newState).toStrictEqual(expectedState);
});
});
Loading