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
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,15 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Changed

- **BREAKING:** `ErrorReportingService:captureException` is no longer an allowed action on the messenger; consumers must stop allowlisting it ([#572](https://github.com/MetaMask/smart-transactions-controller/pull/572))
- Move controller packages from peer to direct dependencies and bump to latest majors ([#572](https://github.com/MetaMask/smart-transactions-controller/pull/572))
- `@metamask/network-controller` ^25.0.0 → ^30.0.0
- `@metamask/transaction-controller` ^61.0.0 → ^63.0.0
- `@metamask/remote-feature-flag-controller` ^2.0.0 → ^4.1.0
- `@metamask/polling-controller` ^15.0.0 → ^16.0.0

## [22.7.0]

### Added
Expand Down
21 changes: 8 additions & 13 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,11 @@
"@metamask/eth-json-rpc-provider": "^4.1.6",
"@metamask/eth-query": "^4.0.0",
"@metamask/messenger": "^0.3.0",
"@metamask/polling-controller": "^15.0.0",
"@metamask/network-controller": "^30.0.0",
"@metamask/polling-controller": "^16.0.0",
"@metamask/remote-feature-flag-controller": "^4.1.0",
"@metamask/superstruct": "^3.1.0",
"@metamask/transaction-controller": "^63.0.0",
"@metamask/utils": "^11.0.0",
"bignumber.js": "^9.0.1",
"fast-json-patch": "^3.1.0",
Expand All @@ -63,16 +66,12 @@
"@lavamoat/allow-scripts": "^3.2.1",
"@lavamoat/preinstall-always-fail": "^2.1.0",
"@metamask/auto-changelog": "^3.1.0",
"@metamask/error-reporting-service": "^3.0.0",
"@metamask/eslint-config": "^12.2.0",
"@metamask/eslint-config-jest": "^12.1.0",
"@metamask/eslint-config-nodejs": "^12.1.0",
"@metamask/eslint-config-typescript": "^12.1.0",
"@metamask/gas-fee-controller": "^22.0.0",
"@metamask/gas-fee-controller": "^26.0.0",
"@metamask/json-rpc-engine": "^10.0.1",
"@metamask/network-controller": "^25.0.0",
"@metamask/remote-feature-flag-controller": "^2.0.0",
"@metamask/transaction-controller": "^61.0.0",
"@ts-bridge/cli": "^0.6.3",
"@types/jest": "^26.0.24",
"@types/lodash": "^4.14.194",
Expand All @@ -97,12 +96,6 @@
"ts-jest": "^29.1.4",
"typescript": "~4.8.4"
},
"peerDependencies": {
"@metamask/error-reporting-service": "^3.0.0",
"@metamask/network-controller": "^25.0.0",
"@metamask/remote-feature-flag-controller": "^2.0.0",
"@metamask/transaction-controller": "^61.0.0"
},
"peerDependenciesMeta": {
"@metamask/accounts-controller": {
"optional": true
Expand Down Expand Up @@ -130,7 +123,9 @@
"@lavamoat/preinstall-always-fail": false,
"@metamask/controller-utils>ethereumjs-util>ethereum-cryptography>keccak": false,
"@metamask/controller-utils>ethereumjs-util>ethereum-cryptography>secp256k1": false,
"@metamask/controller-utils>babel-runtime>core-js": false
"@metamask/controller-utils>babel-runtime>core-js": false,
"@metamask/transaction-controller>@metamask/core-backend>@metamask/keyring-controller>ethereumjs-wallet>ethereum-cryptography>keccak": false,
"@metamask/transaction-controller>@metamask/core-backend>@metamask/keyring-controller>ethereumjs-wallet>ethereum-cryptography>secp256k1": false
}
}
}
38 changes: 7 additions & 31 deletions src/SmartTransactionsController.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,7 @@ describe('SmartTransactionsController', () => {
const captureExceptionSpy = jest.fn();
const rootMessenger: RootMessenger = new Messenger({
namespace: MOCK_ANY_NAMESPACE,
captureException: captureExceptionSpy,
});

rootMessenger.registerActionHandler(
Expand Down Expand Up @@ -381,10 +382,6 @@ describe('SmartTransactionsController', () => {
},
}),
);
rootMessenger.registerActionHandler(
'ErrorReportingService:captureException',
captureExceptionSpy,
);

const messenger = new Messenger<
'SmartTransactionsController',
Expand All @@ -404,7 +401,6 @@ describe('SmartTransactionsController', () => {
'TransactionController:getNonceLock',
'TransactionController:getTransactions',
'TransactionController:updateTransaction',
'ErrorReportingService:captureException',
],
events: [
'NetworkController:stateChange',
Expand Down Expand Up @@ -451,6 +447,7 @@ describe('SmartTransactionsController', () => {
const captureExceptionSpy = jest.fn();
const rootMessenger: RootMessenger = new Messenger({
namespace: MOCK_ANY_NAMESPACE,
captureException: captureExceptionSpy,
});

rootMessenger.registerActionHandler(
Expand Down Expand Up @@ -489,10 +486,6 @@ describe('SmartTransactionsController', () => {
},
}),
);
rootMessenger.registerActionHandler(
'ErrorReportingService:captureException',
captureExceptionSpy,
);

const messenger = new Messenger<
'SmartTransactionsController',
Expand All @@ -512,7 +505,6 @@ describe('SmartTransactionsController', () => {
'TransactionController:getNonceLock',
'TransactionController:getTransactions',
'TransactionController:updateTransaction',
'ErrorReportingService:captureException',
],
events: [
'NetworkController:stateChange',
Expand Down Expand Up @@ -555,6 +547,7 @@ describe('SmartTransactionsController', () => {
const captureExceptionSpy = jest.fn();
const rootMessenger: RootMessenger = new Messenger({
namespace: MOCK_ANY_NAMESPACE,
captureException: captureExceptionSpy,
});

rootMessenger.registerActionHandler(
Expand Down Expand Up @@ -591,10 +584,6 @@ describe('SmartTransactionsController', () => {
},
}),
);
rootMessenger.registerActionHandler(
'ErrorReportingService:captureException',
captureExceptionSpy,
);

const messenger = new Messenger<
'SmartTransactionsController',
Expand All @@ -614,7 +603,6 @@ describe('SmartTransactionsController', () => {
'TransactionController:getNonceLock',
'TransactionController:getTransactions',
'TransactionController:updateTransaction',
'ErrorReportingService:captureException',
],
events: [
'NetworkController:stateChange',
Expand Down Expand Up @@ -658,16 +646,17 @@ describe('SmartTransactionsController', () => {
});

it('reports error to ErrorReportingService when feature flags become invalid after state change', async () => {
const captureExceptionSpy = jest.fn();
const getStateMock = jest.fn().mockReturnValue({
remoteFeatureFlags: {
smartTransactionsNetworks: {
default: { extensionActive: true },
},
},
});
const captureExceptionSpy = jest.fn();
const rootMessenger: RootMessenger = new Messenger({
namespace: MOCK_ANY_NAMESPACE,
captureException: captureExceptionSpy,
});

rootMessenger.registerActionHandler(
Expand Down Expand Up @@ -700,10 +689,6 @@ describe('SmartTransactionsController', () => {
'RemoteFeatureFlagController:getState',
getStateMock,
);
rootMessenger.registerActionHandler(
'ErrorReportingService:captureException',
captureExceptionSpy,
);

const messenger = new Messenger<
'SmartTransactionsController',
Expand All @@ -723,7 +708,6 @@ describe('SmartTransactionsController', () => {
'TransactionController:getNonceLock',
'TransactionController:getTransactions',
'TransactionController:updateTransaction',
'ErrorReportingService:captureException',
],
events: [
'NetworkController:stateChange',
Expand Down Expand Up @@ -776,6 +760,7 @@ describe('SmartTransactionsController', () => {
const captureExceptionSpy = jest.fn();
const rootMessenger: RootMessenger = new Messenger({
namespace: MOCK_ANY_NAMESPACE,
captureException: captureExceptionSpy,
});

rootMessenger.registerActionHandler(
Expand Down Expand Up @@ -817,10 +802,6 @@ describe('SmartTransactionsController', () => {
},
}),
);
rootMessenger.registerActionHandler(
'ErrorReportingService:captureException',
captureExceptionSpy,
);

const messenger = new Messenger<
'SmartTransactionsController',
Expand All @@ -840,7 +821,6 @@ describe('SmartTransactionsController', () => {
'TransactionController:getNonceLock',
'TransactionController:getTransactions',
'TransactionController:updateTransaction',
'ErrorReportingService:captureException',
],
events: [
'NetworkController:stateChange',
Expand Down Expand Up @@ -3259,6 +3239,7 @@ async function withController<ReturnValue>(

const rootMessenger: RootMessenger = new Messenger({
namespace: MOCK_ANY_NAMESPACE,
captureException: jest.fn(),
});
rootMessenger.registerActionHandler(
'NetworkController:getNetworkClientById',
Expand Down Expand Up @@ -3339,10 +3320,6 @@ async function withController<ReturnValue>(
remoteFeatureFlags,
}),
);
rootMessenger.registerActionHandler(
'ErrorReportingService:captureException',
jest.fn(),
);

const messenger = new Messenger<
'SmartTransactionsController',
Expand All @@ -3362,7 +3339,6 @@ async function withController<ReturnValue>(
'TransactionController:getNonceLock',
'TransactionController:getTransactions',
'TransactionController:updateTransaction',
'ErrorReportingService:captureException',
],
events: [
'NetworkController:stateChange',
Expand Down
7 changes: 2 additions & 5 deletions src/SmartTransactionsController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
isSafeDynamicKey,
type TraceCallback,
} from '@metamask/controller-utils';
import type { ErrorReportingServiceCaptureExceptionAction } from '@metamask/error-reporting-service';
import EthQuery from '@metamask/eth-query';
import type { Messenger } from '@metamask/messenger';
import type {
Expand Down Expand Up @@ -167,8 +166,7 @@
| RemoteFeatureFlagControllerGetStateAction
| TransactionControllerGetNonceLockAction
| TransactionControllerGetTransactionsAction
| TransactionControllerUpdateTransactionAction
| ErrorReportingServiceCaptureExceptionAction;
| TransactionControllerUpdateTransactionAction;

export type SmartTransactionsControllerStateChangeEvent =
ControllerStateChangeEvent<
Expand Down Expand Up @@ -292,8 +290,7 @@

// Report each validation error to Sentry
for (const error of errors) {
this.messenger.call(
'ErrorReportingService:captureException',
this.messenger.captureException?.(
new Error(
`[SmartTransactionsController] Feature flag validation failed: ${
error.message
Expand Down Expand Up @@ -424,9 +421,9 @@
isSmartTransactionPending,
);
if (!this.timeoutHandle && pendingTransactions?.length > 0) {
this.poll();

Check warning on line 424 in src/SmartTransactionsController.ts

View workflow job for this annotation

GitHub Actions / Build, lint, and test / Lint (20.x)

Promises must be awaited, end with a call to .catch, end with a call to .then with a rejection handler or be explicitly marked as ignored with the `void` operator

Check warning on line 424 in src/SmartTransactionsController.ts

View workflow job for this annotation

GitHub Actions / Build, lint, and test / Lint (18.x)

Promises must be awaited, end with a call to .catch, end with a call to .then with a rejection handler or be explicitly marked as ignored with the `void` operator
} else if (this.timeoutHandle && pendingTransactions?.length === 0) {
this.stop();

Check warning on line 426 in src/SmartTransactionsController.ts

View workflow job for this annotation

GitHub Actions / Build, lint, and test / Lint (20.x)

Promises must be awaited, end with a call to .catch, end with a call to .then with a rejection handler or be explicitly marked as ignored with the `void` operator

Check warning on line 426 in src/SmartTransactionsController.ts

View workflow job for this annotation

GitHub Actions / Build, lint, and test / Lint (18.x)

Promises must be awaited, end with a call to .catch, end with a call to .then with a rejection handler or be explicitly marked as ignored with the `void` operator
}
}

Expand All @@ -451,7 +448,7 @@
}

this.timeoutHandle = setInterval(() => {
safelyExecute(async () => this.updateSmartTransactions());

Check warning on line 451 in src/SmartTransactionsController.ts

View workflow job for this annotation

GitHub Actions / Build, lint, and test / Lint (20.x)

Promises must be awaited, end with a call to .catch, end with a call to .then with a rejection handler or be explicitly marked as ignored with the `void` operator

Check warning on line 451 in src/SmartTransactionsController.ts

View workflow job for this annotation

GitHub Actions / Build, lint, and test / Lint (18.x)

Promises must be awaited, end with a call to .catch, end with a call to .then with a rejection handler or be explicitly marked as ignored with the `void` operator
}, this.#interval);
await safelyExecute(async () => this.updateSmartTransactions());
}
Expand Down Expand Up @@ -518,7 +515,7 @@
ethQuery = new EthQuery(provider);
}

this.#createOrUpdateSmartTransaction(smartTransaction, {

Check warning on line 518 in src/SmartTransactionsController.ts

View workflow job for this annotation

GitHub Actions / Build, lint, and test / Lint (20.x)

Promises must be awaited, end with a call to .catch, end with a call to .then with a rejection handler or be explicitly marked as ignored with the `void` operator

Check warning on line 518 in src/SmartTransactionsController.ts

View workflow job for this annotation

GitHub Actions / Build, lint, and test / Lint (18.x)

Promises must be awaited, end with a call to .catch, end with a call to .then with a rejection handler or be explicitly marked as ignored with the `void` operator
chainId,
ethQuery,
});
Expand Down
Loading
Loading