@@ -3,7 +3,10 @@ import type {
3
3
ControllerStateChangeEvent ,
4
4
RestrictedMessenger ,
5
5
} from '@metamask/base-controller' ;
6
- import { BaseController } from '@metamask/base-controller' ;
6
+ import {
7
+ BaseController ,
8
+ registerMethodActionHandlers ,
9
+ } from '@metamask/base-controller' ;
7
10
import type { Partialize } from '@metamask/controller-utils' ;
8
11
import {
9
12
InfuraNetworkType ,
@@ -1228,94 +1231,23 @@ export class NetworkController extends BaseController<
1228
1231
this . state . networkConfigurationsByChainId ,
1229
1232
) ;
1230
1233
1231
- this . messagingSystem . registerActionHandler (
1232
- // TODO: Either fix this lint violation or explain why it's necessary to ignore.
1233
- // eslint-disable-next-line @typescript-eslint/restrict-template-expressions
1234
- `${ this . name } :getEthQuery` ,
1235
- ( ) => {
1236
- return this . #ethQuery;
1237
- } ,
1238
- ) ;
1239
-
1240
- this . messagingSystem . registerActionHandler (
1241
- // TODO: Either fix this lint violation or explain why it's necessary to ignore.
1242
- // eslint-disable-next-line @typescript-eslint/restrict-template-expressions
1243
- `${ this . name } :getNetworkClientById` ,
1244
- this . getNetworkClientById . bind ( this ) ,
1245
- ) ;
1246
-
1247
- this . messagingSystem . registerActionHandler (
1248
- // TODO: Either fix this lint violation or explain why it's necessary to ignore.
1249
- // eslint-disable-next-line @typescript-eslint/restrict-template-expressions
1250
- `${ this . name } :getEIP1559Compatibility` ,
1251
- this . getEIP1559Compatibility . bind ( this ) ,
1252
- ) ;
1253
-
1254
- this . messagingSystem . registerActionHandler (
1255
- // TODO: Either fix this lint violation or explain why it's necessary to ignore.
1256
- // eslint-disable-next-line @typescript-eslint/restrict-template-expressions
1257
- `${ this . name } :setActiveNetwork` ,
1258
- this . setActiveNetwork . bind ( this ) ,
1259
- ) ;
1260
-
1261
- this . messagingSystem . registerActionHandler (
1262
- // TODO: Either fix this lint violation or explain why it's necessary to ignore.
1263
- // eslint-disable-next-line @typescript-eslint/restrict-template-expressions
1264
- `${ this . name } :setProviderType` ,
1265
- this . setProviderType . bind ( this ) ,
1266
- ) ;
1267
-
1268
- this . messagingSystem . registerActionHandler (
1269
- // TODO: Either fix this lint violation or explain why it's necessary to ignore.
1270
- // eslint-disable-next-line @typescript-eslint/restrict-template-expressions
1271
- `${ this . name } :findNetworkClientIdByChainId` ,
1272
- this . findNetworkClientIdByChainId . bind ( this ) ,
1273
- ) ;
1274
-
1275
- this . messagingSystem . registerActionHandler (
1276
- // TODO: Either fix this lint violation or explain why it's necessary to ignore.
1277
- // eslint-disable-next-line @typescript-eslint/restrict-template-expressions
1278
- `${ this . name } :getNetworkConfigurationByChainId` ,
1279
- this . getNetworkConfigurationByChainId . bind ( this ) ,
1280
- ) ;
1281
-
1282
- this . messagingSystem . registerActionHandler (
1283
- // ESLint is mistaken here; `name` is a string.
1284
- // eslint-disable-next-line @typescript-eslint/restrict-template-expressions
1285
- `${ this . name } :getNetworkConfigurationByNetworkClientId` ,
1286
- this . getNetworkConfigurationByNetworkClientId . bind ( this ) ,
1287
- ) ;
1288
-
1289
- this . messagingSystem . registerActionHandler (
1290
- `${ this . name } :getSelectedNetworkClient` ,
1291
- this . getSelectedNetworkClient . bind ( this ) ,
1292
- ) ;
1293
-
1294
- this . messagingSystem . registerActionHandler (
1295
- `${ this . name } :getSelectedChainId` ,
1296
- this . getSelectedChainId . bind ( this ) ,
1297
- ) ;
1298
-
1299
- this . messagingSystem . registerActionHandler (
1300
- // ESLint is mistaken here; `name` is a string.
1301
- // eslint-disable-next-line @typescript-eslint/restrict-template-expressions
1302
- `${ this . name } :addNetwork` ,
1303
- this . addNetwork . bind ( this ) ,
1304
- ) ;
1305
-
1306
- this . messagingSystem . registerActionHandler (
1307
- // ESLint is mistaken here; `name` is a string.
1308
- // eslint-disable-next-line @typescript-eslint/restrict-template-expressions
1309
- `${ this . name } :removeNetwork` ,
1310
- this . removeNetwork . bind ( this ) ,
1311
- ) ;
1312
-
1313
- this . messagingSystem . registerActionHandler (
1314
- // ESLint is mistaken here; `name` is a string.
1315
- // eslint-disable-next-line @typescript-eslint/restrict-template-expressions
1316
- `${ this . name } :updateNetwork` ,
1317
- this . updateNetwork . bind ( this ) ,
1318
- ) ;
1234
+ registerMethodActionHandlers ( this , this . messagingSystem , [
1235
+ 'getEthQuery' ,
1236
+ 'getNetworkClientById' ,
1237
+ 'getEIP1559Compatibility' ,
1238
+ 'getSelectedNetworkClient' ,
1239
+ 'setActiveNetwork' ,
1240
+ 'setProviderType' ,
1241
+ 'notExisting' ,
1242
+ 'findNetworkClientIdByChainId' ,
1243
+ 'getNetworkConfigurationByChainId' ,
1244
+ 'getNetworkConfigurationByNetworkClientId' ,
1245
+ 'getSelectedNetworkClient' ,
1246
+ 'getSelectedChainId' ,
1247
+ 'addNetwork' ,
1248
+ 'removeNetwork' ,
1249
+ 'updateNetwork' ,
1250
+ ] ) ;
1319
1251
}
1320
1252
1321
1253
/**
0 commit comments