Skip to content

Commit d279dbb

Browse files
committed
Merge branch 'release/7.62.1' into release/7.62.1-Changelog
2 parents 8f8caca + af66d60 commit d279dbb

12 files changed

Lines changed: 420 additions & 106 deletions

File tree

CHANGELOG.md

Lines changed: 220 additions & 1 deletion
Large diffs are not rendered by default.

android/app/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ android {
188188
minSdkVersion rootProject.ext.minSdkVersion
189189
targetSdkVersion rootProject.ext.targetSdkVersion
190190
versionName "7.62.1"
191-
versionCode 3527
191+
versionCode 3561
192192
testBuildType System.getProperty('testBuildType', 'debug')
193193
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
194194
manifestPlaceholders.MM_BRANCH_KEY_TEST = "$System.env.MM_BRANCH_KEY_TEST"

app/components/UI/Perps/controllers/PerpsController.test.ts

Lines changed: 14 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -20,17 +20,6 @@ import {
2020
import type { IPerpsProvider } from './types';
2121
import { HyperLiquidProvider } from './providers/HyperLiquidProvider';
2222
import { createMockHyperLiquidProvider } from '../__mocks__/providerMocks';
23-
import Logger from '../../../../util/Logger';
24-
import { FeatureFlagConfigurationService } from './services/FeatureFlagConfigurationService';
25-
import { DepositService } from './services/DepositService';
26-
import { MarketDataService } from './services/MarketDataService';
27-
import { TradingService } from './services/TradingService';
28-
import { AccountService } from './services/AccountService';
29-
import { DataLakeService } from './services/DataLakeService';
30-
import {
31-
ARBITRUM_MAINNET_CHAIN_ID_HEX,
32-
USDC_ARBITRUM_MAINNET_ADDRESS,
33-
} from '../constants/hyperLiquidConfig';
3423
import Engine from '../../../../core/Engine';
3524

3625
jest.mock('./providers/HyperLiquidProvider');
@@ -102,6 +91,7 @@ jest.mock('../../../../core/Engine', () => {
10291
getNetworkClientById: jest.fn().mockReturnValue({
10392
configuration: { chainId: '0x1' },
10493
}),
94+
findNetworkClientIdByChainId: jest.fn().mockReturnValue('mainnet'),
10595
};
10696

10797
const mockAccountTreeController = {
@@ -116,6 +106,10 @@ jest.mock('../../../../core/Engine', () => {
116106
const mockTransactionController = {
117107
estimateGasFee: jest.fn(),
118108
estimateGas: jest.fn(),
109+
addTransaction: jest.fn().mockResolvedValue({
110+
result: Promise.resolve('0xmocktxhash'),
111+
transactionMeta: { id: 'mock-tx-id', hash: '0xmocktxhash' },
112+
}),
119113
};
120114

121115
const mockAccountTrackerController = {
@@ -286,6 +280,15 @@ jest.mock('./services/FeatureFlagConfigurationService', () => ({
286280
},
287281
}));
288282

283+
// Import mocked modules - these imports get the mocked versions
284+
import Logger from '../../../../util/Logger';
285+
import { DepositService } from './services/DepositService';
286+
import { MarketDataService } from './services/MarketDataService';
287+
import { TradingService } from './services/TradingService';
288+
import { AccountService } from './services/AccountService';
289+
import { DataLakeService } from './services/DataLakeService';
290+
import { FeatureFlagConfigurationService } from './services/FeatureFlagConfigurationService';
291+
289292
/**
290293
* Testable version of PerpsController that exposes protected methods for testing.
291294
* This follows the pattern used in RewardsController.test.ts
@@ -2348,50 +2351,9 @@ describe('PerpsController', () => {
23482351
origin: 'metamask',
23492352
type: 'perpsDeposit',
23502353
skipInitialGasEstimate: true,
2351-
gasFeeToken: undefined,
23522354
});
23532355
});
23542356

2355-
it('adds gasFeeToken for Arbitrum USDC deposits', async () => {
2356-
markControllerAsInitialized();
2357-
controller.testSetProviders(new Map([['hyperliquid', mockProvider]]));
2358-
2359-
Engine.context.AccountTrackerController.state.accountsByChainId = {
2360-
[ARBITRUM_MAINNET_CHAIN_ID_HEX]: {
2361-
[mockTransaction.from.toLowerCase()]: {
2362-
balance: '0x0',
2363-
},
2364-
},
2365-
};
2366-
2367-
jest.spyOn(DepositService, 'prepareTransaction').mockResolvedValueOnce({
2368-
transaction: {
2369-
...mockTransaction,
2370-
to: USDC_ARBITRUM_MAINNET_ADDRESS,
2371-
},
2372-
assetChainId: ARBITRUM_MAINNET_CHAIN_ID_HEX,
2373-
currentDepositId: mockDepositId,
2374-
});
2375-
2376-
await controller.depositWithConfirmation('100');
2377-
2378-
expect(
2379-
Engine.context.TransactionController.addTransaction,
2380-
).toHaveBeenCalledWith(
2381-
{
2382-
...mockTransaction,
2383-
to: USDC_ARBITRUM_MAINNET_ADDRESS,
2384-
},
2385-
{
2386-
networkClientId: mockNetworkClientId,
2387-
origin: 'metamask',
2388-
type: 'perpsDeposit',
2389-
skipInitialGasEstimate: true,
2390-
gasFeeToken: USDC_ARBITRUM_MAINNET_ADDRESS,
2391-
},
2392-
);
2393-
});
2394-
23952357
it('throws error when controller not initialized', async () => {
23962358
controller.testSetInitialized(false);
23972359

app/components/UI/Perps/controllers/PerpsController.ts

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -13,18 +13,13 @@ import {
1313
TransactionControllerTransactionSubmittedEvent,
1414
TransactionType,
1515
} from '@metamask/transaction-controller';
16-
import { Hex } from '@metamask/utils';
17-
import Engine from '../../../../core/Engine';
18-
import {
19-
ARBITRUM_MAINNET_CHAIN_ID_HEX,
20-
USDC_ARBITRUM_MAINNET_ADDRESS,
21-
USDC_SYMBOL,
22-
} from '../constants/hyperLiquidConfig';
16+
import { USDC_SYMBOL } from '../constants/hyperLiquidConfig';
2317
import {
2418
LastTransactionResult,
2519
TransactionStatus,
2620
} from '../types/transactionTypes';
2721
import { DevLogger } from '../../../../core/SDKConnect/utils/DevLogger';
22+
import Engine from '../../../../core/Engine';
2823
import Logger, { type LoggerErrorOptions } from '../../../../util/Logger';
2924
import { MetaMetrics, MetaMetricsEvents } from '../../../../core/Analytics';
3025
import { MetricsEventBuilder } from '../../../../core/Analytics/MetricsEventBuilder';
@@ -1390,23 +1385,20 @@ export class PerpsController extends BaseController<
13901385
const networkClientId =
13911386
NetworkController.findNetworkClientIdByChainId(assetChainId);
13921387

1393-
const gasFeeToken =
1394-
transaction.to &&
1395-
assetChainId.toLowerCase() === ARBITRUM_MAINNET_CHAIN_ID_HEX &&
1396-
transaction.to.toLowerCase() ===
1397-
USDC_ARBITRUM_MAINNET_ADDRESS.toLowerCase()
1398-
? (transaction.to as Hex)
1399-
: undefined;
1400-
1388+
if (!networkClientId) {
1389+
throw new Error(
1390+
`No network client found for chain ${assetChainId}. Please add the network first.`,
1391+
);
1392+
}
14011393
// addTransaction shows the confirmation screen and returns a promise
1394+
// submit shows the confirmation screen and returns a promise
14021395
// The promise will resolve when transaction completes or reject if cancelled/failed
14031396
const { result, transactionMeta } =
14041397
await TransactionController.addTransaction(transaction, {
14051398
networkClientId,
14061399
origin: 'metamask',
14071400
type: TransactionType.perpsDeposit,
14081401
skipInitialGasEstimate: true,
1409-
gasFeeToken,
14101402
});
14111403

14121404
// Store the transaction ID and try to get amount from transaction

app/components/UI/Predict/controllers/PredictController.test.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ import {
1313
} from '@metamask/transaction-controller';
1414
import type { NetworkState } from '@metamask/network-controller';
1515
import type { InternalAccount } from '@metamask/keyring-internal-api';
16-
import type { Hex } from '@metamask/utils';
1716

1817
import Engine from '../../../../core/Engine';
1918
import DevLogger from '../../../../core/SDKConnect/utils/DevLogger';
@@ -22,7 +21,6 @@ import {
2221
addTransactionBatch,
2322
} from '../../../../util/transaction-controller';
2423
import { PolymarketProvider } from '../providers/polymarket/PolymarketProvider';
25-
import { MATIC_CONTRACTS } from '../providers/polymarket/constants';
2624
import type { OrderPreview } from '../providers/types';
2725
import {
2826
PredictBalance,
@@ -3005,7 +3003,6 @@ describe('PredictController', () => {
30053003
mockPolymarketProvider.prepareDeposit.mockResolvedValue({
30063004
transactions: mockTransactions,
30073005
chainId: mockChainId,
3008-
gasFeeToken: MATIC_CONTRACTS.collateral as Hex,
30093006
});
30103007

30113008
(addTransactionBatch as jest.Mock).mockResolvedValue({
@@ -3073,7 +3070,6 @@ describe('PredictController', () => {
30733070
disableUpgrade: true,
30743071
skipInitialGasEstimate: true,
30753072
transactions: mockTransactions,
3076-
gasFeeToken: MATIC_CONTRACTS.collateral,
30773073
});
30783074
});
30793075
});

app/components/UI/Predict/controllers/PredictController.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1863,7 +1863,7 @@ export class PredictController extends BaseController<
18631863
throw new Error('Deposit preparation returned undefined');
18641864
}
18651865

1866-
const { transactions, chainId, gasFeeToken } = depositPreparation;
1866+
const { transactions, chainId } = depositPreparation;
18671867

18681868
if (!transactions || transactions.length === 0) {
18691869
throw new Error('No transactions returned from deposit preparation');
@@ -1896,7 +1896,6 @@ export class PredictController extends BaseController<
18961896
disableUpgrade: true,
18971897
skipInitialGasEstimate: true,
18981898
transactions,
1899-
gasFeeToken,
19001899
});
19011900

19021901
if (!batchResult?.batchId) {

app/components/UI/Predict/providers/polymarket/PolymarketProvider.ts

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1512,15 +1512,9 @@ export class PolymarketProvider implements PredictProvider {
15121512
type: TransactionType.predictDeposit,
15131513
});
15141514

1515-
const chainId = CHAIN_IDS.POLYGON;
1516-
const isPolygonChain =
1517-
chainId.toLowerCase() ===
1518-
numberToHex(POLYGON_MAINNET_CHAIN_ID).toLowerCase();
1519-
15201515
return {
1521-
chainId,
1516+
chainId: CHAIN_IDS.POLYGON,
15221517
transactions,
1523-
gasFeeToken: isPolygonChain ? (collateral as Hex) : undefined,
15241518
};
15251519
}
15261520

app/components/UI/Predict/providers/types.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,6 @@ export interface PrepareDepositResponse {
180180
};
181181
type?: TransactionType;
182182
}[];
183-
gasFeeToken?: Hex;
184183
}
185184

186185
export interface GetPredictWalletParams {

0 commit comments

Comments
 (0)