Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@metamask/core-monorepo",
"version": "384.0.0",
"version": "385.0.0",
"private": true,
"description": "Monorepo for packages shared between MetaMask clients",
"repository": {
Expand Down
5 changes: 4 additions & 1 deletion packages/notification-services-controller/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## [6.0.1]

### Changed

- Bump `@metamask/base-controller` from ^8.0.0 to ^8.0.1 ([#5722](https://github.com/MetaMask/core/pull/5722))
Expand Down Expand Up @@ -397,7 +399,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

- Initial release

[Unreleased]: https://github.com/MetaMask/core/compare/@metamask/notification-services-controller@6.0.0...HEAD
[Unreleased]: https://github.com/MetaMask/core/compare/@metamask/notification-services-controller@6.0.1...HEAD
[6.0.1]: https://github.com/MetaMask/core/compare/@metamask/notification-services-controller@6.0.0...@metamask/notification-services-controller@6.0.1
[6.0.0]: https://github.com/MetaMask/core/compare/@metamask/notification-services-controller@5.0.1...@metamask/notification-services-controller@6.0.0
[5.0.1]: https://github.com/MetaMask/core/compare/@metamask/notification-services-controller@5.0.0...@metamask/notification-services-controller@5.0.1
[5.0.0]: https://github.com/MetaMask/core/compare/@metamask/notification-services-controller@4.0.0...@metamask/notification-services-controller@5.0.0
Expand Down
2 changes: 1 addition & 1 deletion packages/notification-services-controller/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@metamask/notification-services-controller",
"version": "6.0.0",
"version": "6.0.1",
"description": "Manages New MetaMask decentralized Notification system",
"keywords": [
"MetaMask",
Expand Down
5 changes: 5 additions & 0 deletions packages/transaction-controller/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Added

- Add optional `isEIP7702GasFeeTokensEnabled` constructor callback ([#5706](https://github.com/MetaMask/core/pull/5706))
- Add `lendingDeposit` `TransactionType` ([#5747](https://github.com/MetaMask/core/pull/5747))

## [54.4.0]

### Changed
Expand Down
144 changes: 140 additions & 4 deletions packages/transaction-controller/src/TransactionController.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,12 @@ import {
WalletDevice,
} from './types';
import { addTransactionBatch } from './utils/batch';
import { DELEGATION_PREFIX, getDelegationAddress } from './utils/eip7702';
import {
DELEGATION_PREFIX,
doesChainSupportEIP7702,
getDelegationAddress,
} from './utils/eip7702';
import { getEIP7702UpgradeContractAddress } from './utils/feature-flags';
import { addGasBuffer, estimateGas, updateGas } from './utils/gas';
import { updateGasFees } from './utils/gas-fees';
import { getGasFeeFlow } from './utils/gas-flow';
Expand Down Expand Up @@ -125,6 +130,7 @@ jest.mock('./helpers/MultichainTrackingHelper');
jest.mock('./helpers/PendingTransactionTracker');
jest.mock('./hooks/ExtraTransactionsPublishHook');
jest.mock('./utils/batch');
jest.mock('./utils/feature-flags');
jest.mock('./utils/gas');
jest.mock('./utils/gas-fees');
jest.mock('./utils/gas-flow');
Expand All @@ -141,6 +147,7 @@ jest.mock('./helpers/ResimulateHelper', () => ({
jest.mock('./utils/eip7702', () => ({
...jest.requireActual('./utils/eip7702'),
getDelegationAddress: jest.fn(),
doesChainSupportEIP7702: jest.fn(),
}));

// TODO: Replace `any` with type
Expand Down Expand Up @@ -535,6 +542,10 @@ describe('TransactionController', () => {
const addTransactionBatchMock = jest.mocked(addTransactionBatch);
const methodDataHelperClassMock = jest.mocked(MethodDataHelper);
const getDelegationAddressMock = jest.mocked(getDelegationAddress);
const doesChainSupportEIP7702Mock = jest.mocked(doesChainSupportEIP7702);
const getEIP7702UpgradeContractAddressMock = jest.mocked(
getEIP7702UpgradeContractAddress,
);

let mockEthQuery: EthQuery;
let getNonceLockSpy: jest.Mock;
Expand All @@ -549,6 +560,7 @@ describe('TransactionController', () => {
let methodDataHelperMock: jest.Mocked<MethodDataHelper>;
let timeCounter = 0;
let signMock: jest.Mock;
let isEIP7702GasFeeTokensEnabledMock: jest.Mock;

const incomingTransactionHelperClassMock =
IncomingTransactionHelper as jest.MockedClass<
Expand Down Expand Up @@ -672,6 +684,8 @@ describe('TransactionController', () => {
mockNetworkClientConfigurationsByNetworkClientId as any,
getPermittedAccounts: async () => [ACCOUNT_MOCK],
hooks: {},
isEIP7702GasFeeTokensEnabled: isEIP7702GasFeeTokensEnabledMock,
publicKeyEIP7702: '0x1234',
sign: signMock,
transactionHistoryLimit: 40,
...givenOptions,
Expand Down Expand Up @@ -970,6 +984,7 @@ describe('TransactionController', () => {
});

signMock = jest.fn().mockImplementation(async (transaction) => transaction);
isEIP7702GasFeeTokensEnabledMock = jest.fn().mockResolvedValue(false);
});

describe('constructor', () => {
Expand Down Expand Up @@ -2197,6 +2212,8 @@ describe('TransactionController', () => {
},
{
blockTime: undefined,
senderCode: undefined,
use7702Fees: false,
},
);

Expand Down Expand Up @@ -2277,9 +2294,124 @@ describe('TransactionController', () => {

await flushPromises();

expect(getSimulationDataMock).toHaveBeenCalledWith(expect.any(Object), {
senderCode: DELEGATION_PREFIX + ACCOUNT_2_MOCK.slice(2),
});
expect(getSimulationDataMock).toHaveBeenCalledWith(
expect.any(Object),
expect.objectContaining({
senderCode: DELEGATION_PREFIX + ACCOUNT_2_MOCK.slice(2),
}),
);
});

it('with use7702Fees if isEIP7702GasFeeTokensEnabled returns true and chain supports 7702', async () => {
isEIP7702GasFeeTokensEnabledMock.mockResolvedValueOnce(true);
doesChainSupportEIP7702Mock.mockReturnValueOnce(true);
getDelegationAddressMock.mockResolvedValueOnce(ACCOUNT_2_MOCK);

getSimulationDataMock.mockResolvedValueOnce(
SIMULATION_DATA_RESULT_MOCK,
);

const { controller } = setupController();

await controller.addTransaction(
{
from: ACCOUNT_MOCK,
to: ACCOUNT_MOCK,
},
{
networkClientId: NETWORK_CLIENT_ID_MOCK,
},
);

await flushPromises();

expect(getSimulationDataMock).toHaveBeenCalledWith(
expect.any(Object),
expect.objectContaining({
use7702Fees: true,
}),
);
});

it('with authorization list if isEIP7702GasFeeTokensEnabled returns true and no delegation address', async () => {
isEIP7702GasFeeTokensEnabledMock.mockResolvedValueOnce(true);
doesChainSupportEIP7702Mock.mockReturnValueOnce(true);

getSimulationDataMock.mockResolvedValueOnce(
SIMULATION_DATA_RESULT_MOCK,
);

getEIP7702UpgradeContractAddressMock.mockReturnValueOnce(
ACCOUNT_2_MOCK,
);

const { controller } = setupController();

await controller.addTransaction(
{
from: ACCOUNT_MOCK,
to: ACCOUNT_MOCK,
},
{
networkClientId: NETWORK_CLIENT_ID_MOCK,
},
);

await flushPromises();

expect(getSimulationDataMock).toHaveBeenCalledWith(
expect.objectContaining({
authorizationList: [
{
address: ACCOUNT_2_MOCK,
from: ACCOUNT_MOCK,
},
],
}),
expect.any(Object),
);
});

it('with authorization list if in transaction params', async () => {
getSimulationDataMock.mockResolvedValueOnce(
SIMULATION_DATA_RESULT_MOCK,
);

const { controller } = setupController();

await controller.addTransaction(
{
authorizationList: [
{
address: ACCOUNT_2_MOCK,
chainId: CHAIN_ID_MOCK,
nonce: toHex(NONCE_MOCK),
r: '0x1',
s: '0x2',
yParity: '0x1',
},
],
from: ACCOUNT_MOCK,
to: ACCOUNT_MOCK,
},
{
networkClientId: NETWORK_CLIENT_ID_MOCK,
},
);

await flushPromises();

expect(getSimulationDataMock).toHaveBeenCalledWith(
expect.objectContaining({
authorizationList: [
{
address: ACCOUNT_2_MOCK,
from: ACCOUNT_MOCK,
},
],
}),
expect.any(Object),
);
});
});

Expand Down Expand Up @@ -6857,6 +6989,8 @@ describe('TransactionController', () => {
},
{
blockTime: 123,
senderCode: undefined,
use7702Fees: false,
},
);
});
Expand Down Expand Up @@ -6896,6 +7030,8 @@ describe('TransactionController', () => {
},
{
blockTime: 123,
senderCode: undefined,
use7702Fees: false,
},
);
});
Expand Down
Loading
Loading