Skip to content

Commit da787cb

Browse files
authored
chore: bump deps, replace ErrorReportingService with messenger.captureException (#572)
* chore: bump deps, replace ErrorReportingService with messenger.captureException - Bump network-controller ^25 → ^30, transaction-controller ^61 → ^63, remote-feature-flag-controller ^2 → ^4.1 - Replace ErrorReportingService:captureException action with messenger.captureException - Move controller peer deps to direct dependencies - Remove @metamask/error-reporting-service (deprecated) * docs: add changelog entry for #572
1 parent d7fe982 commit da787cb

5 files changed

Lines changed: 2100 additions & 623 deletions

File tree

CHANGELOG.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,15 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10+
### Changed
11+
12+
- **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))
13+
- Move controller packages from peer to direct dependencies and bump to latest majors ([#572](https://github.com/MetaMask/smart-transactions-controller/pull/572))
14+
- `@metamask/network-controller` ^25.0.0 → ^30.0.0
15+
- `@metamask/transaction-controller` ^61.0.0 → ^63.0.0
16+
- `@metamask/remote-feature-flag-controller` ^2.0.0 → ^4.1.0
17+
- `@metamask/polling-controller` ^15.0.0 → ^16.0.0
18+
1019
## [22.7.0]
1120

1221
### Added

package.json

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,11 @@
5050
"@metamask/eth-json-rpc-provider": "^4.1.6",
5151
"@metamask/eth-query": "^4.0.0",
5252
"@metamask/messenger": "^0.3.0",
53-
"@metamask/polling-controller": "^15.0.0",
53+
"@metamask/network-controller": "^30.0.0",
54+
"@metamask/polling-controller": "^16.0.0",
55+
"@metamask/remote-feature-flag-controller": "^4.1.0",
5456
"@metamask/superstruct": "^3.1.0",
57+
"@metamask/transaction-controller": "^63.0.0",
5558
"@metamask/utils": "^11.0.0",
5659
"bignumber.js": "^9.0.1",
5760
"fast-json-patch": "^3.1.0",
@@ -63,16 +66,12 @@
6366
"@lavamoat/allow-scripts": "^3.2.1",
6467
"@lavamoat/preinstall-always-fail": "^2.1.0",
6568
"@metamask/auto-changelog": "^3.1.0",
66-
"@metamask/error-reporting-service": "^3.0.0",
6769
"@metamask/eslint-config": "^12.2.0",
6870
"@metamask/eslint-config-jest": "^12.1.0",
6971
"@metamask/eslint-config-nodejs": "^12.1.0",
7072
"@metamask/eslint-config-typescript": "^12.1.0",
71-
"@metamask/gas-fee-controller": "^22.0.0",
73+
"@metamask/gas-fee-controller": "^26.0.0",
7274
"@metamask/json-rpc-engine": "^10.0.1",
73-
"@metamask/network-controller": "^25.0.0",
74-
"@metamask/remote-feature-flag-controller": "^2.0.0",
75-
"@metamask/transaction-controller": "^61.0.0",
7675
"@ts-bridge/cli": "^0.6.3",
7776
"@types/jest": "^26.0.24",
7877
"@types/lodash": "^4.14.194",
@@ -97,12 +96,6 @@
9796
"ts-jest": "^29.1.4",
9897
"typescript": "~4.8.4"
9998
},
100-
"peerDependencies": {
101-
"@metamask/error-reporting-service": "^3.0.0",
102-
"@metamask/network-controller": "^25.0.0",
103-
"@metamask/remote-feature-flag-controller": "^2.0.0",
104-
"@metamask/transaction-controller": "^61.0.0"
105-
},
10699
"peerDependenciesMeta": {
107100
"@metamask/accounts-controller": {
108101
"optional": true
@@ -130,7 +123,9 @@
130123
"@lavamoat/preinstall-always-fail": false,
131124
"@metamask/controller-utils>ethereumjs-util>ethereum-cryptography>keccak": false,
132125
"@metamask/controller-utils>ethereumjs-util>ethereum-cryptography>secp256k1": false,
133-
"@metamask/controller-utils>babel-runtime>core-js": false
126+
"@metamask/controller-utils>babel-runtime>core-js": false,
127+
"@metamask/transaction-controller>@metamask/core-backend>@metamask/keyring-controller>ethereumjs-wallet>ethereum-cryptography>keccak": false,
128+
"@metamask/transaction-controller>@metamask/core-backend>@metamask/keyring-controller>ethereumjs-wallet>ethereum-cryptography>secp256k1": false
134129
}
135130
}
136131
}

src/SmartTransactionsController.test.ts

Lines changed: 7 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -345,6 +345,7 @@ describe('SmartTransactionsController', () => {
345345
const captureExceptionSpy = jest.fn();
346346
const rootMessenger: RootMessenger = new Messenger({
347347
namespace: MOCK_ANY_NAMESPACE,
348+
captureException: captureExceptionSpy,
348349
});
349350

350351
rootMessenger.registerActionHandler(
@@ -381,10 +382,6 @@ describe('SmartTransactionsController', () => {
381382
},
382383
}),
383384
);
384-
rootMessenger.registerActionHandler(
385-
'ErrorReportingService:captureException',
386-
captureExceptionSpy,
387-
);
388385

389386
const messenger = new Messenger<
390387
'SmartTransactionsController',
@@ -404,7 +401,6 @@ describe('SmartTransactionsController', () => {
404401
'TransactionController:getNonceLock',
405402
'TransactionController:getTransactions',
406403
'TransactionController:updateTransaction',
407-
'ErrorReportingService:captureException',
408404
],
409405
events: [
410406
'NetworkController:stateChange',
@@ -451,6 +447,7 @@ describe('SmartTransactionsController', () => {
451447
const captureExceptionSpy = jest.fn();
452448
const rootMessenger: RootMessenger = new Messenger({
453449
namespace: MOCK_ANY_NAMESPACE,
450+
captureException: captureExceptionSpy,
454451
});
455452

456453
rootMessenger.registerActionHandler(
@@ -489,10 +486,6 @@ describe('SmartTransactionsController', () => {
489486
},
490487
}),
491488
);
492-
rootMessenger.registerActionHandler(
493-
'ErrorReportingService:captureException',
494-
captureExceptionSpy,
495-
);
496489

497490
const messenger = new Messenger<
498491
'SmartTransactionsController',
@@ -512,7 +505,6 @@ describe('SmartTransactionsController', () => {
512505
'TransactionController:getNonceLock',
513506
'TransactionController:getTransactions',
514507
'TransactionController:updateTransaction',
515-
'ErrorReportingService:captureException',
516508
],
517509
events: [
518510
'NetworkController:stateChange',
@@ -555,6 +547,7 @@ describe('SmartTransactionsController', () => {
555547
const captureExceptionSpy = jest.fn();
556548
const rootMessenger: RootMessenger = new Messenger({
557549
namespace: MOCK_ANY_NAMESPACE,
550+
captureException: captureExceptionSpy,
558551
});
559552

560553
rootMessenger.registerActionHandler(
@@ -591,10 +584,6 @@ describe('SmartTransactionsController', () => {
591584
},
592585
}),
593586
);
594-
rootMessenger.registerActionHandler(
595-
'ErrorReportingService:captureException',
596-
captureExceptionSpy,
597-
);
598587

599588
const messenger = new Messenger<
600589
'SmartTransactionsController',
@@ -614,7 +603,6 @@ describe('SmartTransactionsController', () => {
614603
'TransactionController:getNonceLock',
615604
'TransactionController:getTransactions',
616605
'TransactionController:updateTransaction',
617-
'ErrorReportingService:captureException',
618606
],
619607
events: [
620608
'NetworkController:stateChange',
@@ -658,16 +646,17 @@ describe('SmartTransactionsController', () => {
658646
});
659647

660648
it('reports error to ErrorReportingService when feature flags become invalid after state change', async () => {
661-
const captureExceptionSpy = jest.fn();
662649
const getStateMock = jest.fn().mockReturnValue({
663650
remoteFeatureFlags: {
664651
smartTransactionsNetworks: {
665652
default: { extensionActive: true },
666653
},
667654
},
668655
});
656+
const captureExceptionSpy = jest.fn();
669657
const rootMessenger: RootMessenger = new Messenger({
670658
namespace: MOCK_ANY_NAMESPACE,
659+
captureException: captureExceptionSpy,
671660
});
672661

673662
rootMessenger.registerActionHandler(
@@ -700,10 +689,6 @@ describe('SmartTransactionsController', () => {
700689
'RemoteFeatureFlagController:getState',
701690
getStateMock,
702691
);
703-
rootMessenger.registerActionHandler(
704-
'ErrorReportingService:captureException',
705-
captureExceptionSpy,
706-
);
707692

708693
const messenger = new Messenger<
709694
'SmartTransactionsController',
@@ -723,7 +708,6 @@ describe('SmartTransactionsController', () => {
723708
'TransactionController:getNonceLock',
724709
'TransactionController:getTransactions',
725710
'TransactionController:updateTransaction',
726-
'ErrorReportingService:captureException',
727711
],
728712
events: [
729713
'NetworkController:stateChange',
@@ -776,6 +760,7 @@ describe('SmartTransactionsController', () => {
776760
const captureExceptionSpy = jest.fn();
777761
const rootMessenger: RootMessenger = new Messenger({
778762
namespace: MOCK_ANY_NAMESPACE,
763+
captureException: captureExceptionSpy,
779764
});
780765

781766
rootMessenger.registerActionHandler(
@@ -817,10 +802,6 @@ describe('SmartTransactionsController', () => {
817802
},
818803
}),
819804
);
820-
rootMessenger.registerActionHandler(
821-
'ErrorReportingService:captureException',
822-
captureExceptionSpy,
823-
);
824805

825806
const messenger = new Messenger<
826807
'SmartTransactionsController',
@@ -840,7 +821,6 @@ describe('SmartTransactionsController', () => {
840821
'TransactionController:getNonceLock',
841822
'TransactionController:getTransactions',
842823
'TransactionController:updateTransaction',
843-
'ErrorReportingService:captureException',
844824
],
845825
events: [
846826
'NetworkController:stateChange',
@@ -3259,6 +3239,7 @@ async function withController<ReturnValue>(
32593239

32603240
const rootMessenger: RootMessenger = new Messenger({
32613241
namespace: MOCK_ANY_NAMESPACE,
3242+
captureException: jest.fn(),
32623243
});
32633244
rootMessenger.registerActionHandler(
32643245
'NetworkController:getNetworkClientById',
@@ -3339,10 +3320,6 @@ async function withController<ReturnValue>(
33393320
remoteFeatureFlags,
33403321
}),
33413322
);
3342-
rootMessenger.registerActionHandler(
3343-
'ErrorReportingService:captureException',
3344-
jest.fn(),
3345-
);
33463323

33473324
const messenger = new Messenger<
33483325
'SmartTransactionsController',
@@ -3362,7 +3339,6 @@ async function withController<ReturnValue>(
33623339
'TransactionController:getNonceLock',
33633340
'TransactionController:getTransactions',
33643341
'TransactionController:updateTransaction',
3365-
'ErrorReportingService:captureException',
33663342
],
33673343
events: [
33683344
'NetworkController:stateChange',

src/SmartTransactionsController.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import {
1111
isSafeDynamicKey,
1212
type TraceCallback,
1313
} from '@metamask/controller-utils';
14-
import type { ErrorReportingServiceCaptureExceptionAction } from '@metamask/error-reporting-service';
1514
import EthQuery from '@metamask/eth-query';
1615
import type { Messenger } from '@metamask/messenger';
1716
import type {
@@ -167,8 +166,7 @@ type AllowedActions =
167166
| RemoteFeatureFlagControllerGetStateAction
168167
| TransactionControllerGetNonceLockAction
169168
| TransactionControllerGetTransactionsAction
170-
| TransactionControllerUpdateTransactionAction
171-
| ErrorReportingServiceCaptureExceptionAction;
169+
| TransactionControllerUpdateTransactionAction;
172170

173171
export type SmartTransactionsControllerStateChangeEvent =
174172
ControllerStateChangeEvent<
@@ -292,8 +290,7 @@ export class SmartTransactionsController extends StaticIntervalPollingController
292290

293291
// Report each validation error to Sentry
294292
for (const error of errors) {
295-
this.messenger.call(
296-
'ErrorReportingService:captureException',
293+
this.messenger.captureException?.(
297294
new Error(
298295
`[SmartTransactionsController] Feature flag validation failed: ${
299296
error.message

0 commit comments

Comments
 (0)