diff --git a/package.json b/package.json index 6e223a8..3c1b100 100644 --- a/package.json +++ b/package.json @@ -29,12 +29,12 @@ "@ethereumjs/tx": "^5.2.1", "@ethereumjs/util": "^9.0.2", "@ethersproject/bytes": "^5.7.0", - "@metamask/base-controller": "^6.0.0", + "@metamask/base-controller": "^7.0.1", "@metamask/controller-utils": "^11.0.0", "@metamask/eth-json-rpc-provider": "^4.1.0", "@metamask/eth-query": "^4.0.0", "@metamask/network-controller": "^21.1.0", - "@metamask/polling-controller": "^8.0.0", + "@metamask/polling-controller": "^11.0.0", "@metamask/transaction-controller": "^34.0.0", "bignumber.js": "^9.0.1", "events": "^3.3.0", diff --git a/src/SmartTransactionsController.test.ts b/src/SmartTransactionsController.test.ts index d4d19b5..14f0f4a 100644 --- a/src/SmartTransactionsController.test.ts +++ b/src/SmartTransactionsController.test.ts @@ -1383,7 +1383,7 @@ describe('SmartTransactionsController', () => { }); }); - describe('startPollingByNetworkClientId', () => { + describe('startPolling', () => { let clock: sinon.SinonFakeTimers; beforeEach(() => { @@ -1431,9 +1431,9 @@ describe('SmartTransactionsController', () => { }, async ({ controller }) => { const handleFetchSpy = jest.spyOn(utils, 'handleFetch'); - const mainnetPollingToken = controller.startPollingByNetworkClientId( - NetworkType.mainnet, - ); + const mainnetPollingToken = controller.startPolling({ + networkClientId: NetworkType.mainnet, + }); await advanceTime({ clock, duration: 0 }); @@ -1462,7 +1462,7 @@ describe('SmartTransactionsController', () => { fetchHeaders, ); - controller.startPollingByNetworkClientId(NetworkType.sepolia); + controller.startPolling({ networkClientId: NetworkType.sepolia }); await advanceTime({ clock, duration: 0 }); expect(handleFetchSpy).toHaveBeenNthCalledWith( diff --git a/src/SmartTransactionsController.ts b/src/SmartTransactionsController.ts index d7e9fc6..1251d86 100644 --- a/src/SmartTransactionsController.ts +++ b/src/SmartTransactionsController.ts @@ -200,7 +200,11 @@ type SmartTransactionsControllerOptions = { getMetaMetricsProps: () => Promise; }; -export default class SmartTransactionsController extends StaticIntervalPollingController< +export type SmartTransactionsControllerPollingInput = { + networkClientId: string; +}; + +export default class SmartTransactionsController extends StaticIntervalPollingController()< typeof controllerName, SmartTransactionsControllerState, SmartTransactionsControllerMessenger @@ -301,7 +305,9 @@ export default class SmartTransactionsController extends StaticIntervalPollingCo ); } - async _executePoll(networkClientId: string): Promise { + async _executePoll({ + networkClientId, + }: SmartTransactionsControllerPollingInput): Promise { // if this is going to be truly UI driven polling we shouldn't really reach here // with a networkClientId that is not supported, but for now I'll add a check in case // wondering if we should add some kind of predicate to the polling controller to check whether diff --git a/yarn.lock b/yarn.lock index 1fd3a44..65537ba 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2090,6 +2090,22 @@ __metadata: languageName: node linkType: hard +"@metamask/polling-controller@npm:^11.0.0": + version: 11.0.0 + resolution: "@metamask/polling-controller@npm:11.0.0" + dependencies: + "@metamask/base-controller": ^7.0.1 + "@metamask/controller-utils": ^11.3.0 + "@metamask/utils": ^9.1.0 + "@types/uuid": ^8.3.0 + fast-json-stable-stringify: ^2.1.0 + uuid: ^8.3.2 + peerDependencies: + "@metamask/network-controller": ^21.0.0 + checksum: 52a8f72a9ef3633d0a3dae2c148923f14462c6bc3058ebb93d3b6288b4faa56d7b62396038fdb855053f711c1f9b214a572c1bb7bf3e9e1613c55bbeace69966 + languageName: node + linkType: hard + "@metamask/polling-controller@npm:^8.0.0": version: 8.0.0 resolution: "@metamask/polling-controller@npm:8.0.0" @@ -2213,7 +2229,7 @@ __metadata: "@ethersproject/bytes": ^5.7.0 "@lavamoat/allow-scripts": ^2.3.1 "@metamask/auto-changelog": ^3.1.0 - "@metamask/base-controller": ^6.0.0 + "@metamask/base-controller": ^7.0.1 "@metamask/controller-utils": ^11.0.0 "@metamask/eslint-config": ^12.2.0 "@metamask/eslint-config-jest": ^12.1.0 @@ -2223,7 +2239,7 @@ __metadata: "@metamask/eth-query": ^4.0.0 "@metamask/json-rpc-engine": ^9.0.0 "@metamask/network-controller": ^21.1.0 - "@metamask/polling-controller": ^8.0.0 + "@metamask/polling-controller": ^11.0.0 "@metamask/transaction-controller": ^34.0.0 "@types/jest": ^26.0.24 "@types/lodash": ^4.14.194