@metamask-previews/network-controller 22.0.2-preview-aef155f6 → 22.0.2-preview-d1104b69

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -336,6 +336,18 @@ class NetworkController extends base_controller_1.BaseController {
336
336
  // TODO: Either fix this lint violation or explain why it's necessary to ignore.
337
337
  // eslint-disable-next-line @typescript-eslint/restrict-template-expressions
338
338
  `${this.name}:getSelectedNetworkClient`, this.getSelectedNetworkClient.bind(this));
339
+ this.messagingSystem.registerActionHandler(
340
+ // ESLint is mistaken here; `name` is a string.
341
+ // eslint-disable-next-line @typescript-eslint/restrict-template-expressions
342
+ `${this.name}:addNetwork`, this.addNetwork.bind(this));
343
+ this.messagingSystem.registerActionHandler(
344
+ // ESLint is mistaken here; `name` is a string.
345
+ // eslint-disable-next-line @typescript-eslint/restrict-template-expressions
346
+ `${this.name}:removeNetwork`, this.removeNetwork.bind(this));
347
+ this.messagingSystem.registerActionHandler(
348
+ // ESLint is mistaken here; `name` is a string.
349
+ // eslint-disable-next-line @typescript-eslint/restrict-template-expressions
350
+ `${this.name}:updateNetwork`, this.updateNetwork.bind(this));
339
351
  }
340
352
  /**
341
353
  * Accesses the provider and block tracker for the currently selected network.
@@ -708,7 +720,7 @@ class NetworkController extends base_controller_1.BaseController {
708
720
  const rpcEndpoint = defaultOrCustomRpcEndpointFields.type === RpcEndpointType.Custom
709
721
  ? {
710
722
  ...defaultOrCustomRpcEndpointFields,
711
- networkClientId: (0, uuid_1.v4)(),
723
+ networkClientId: defaultOrCustomRpcEndpointFields.networkClientId ?? (0, uuid_1.v4)(),
712
724
  }
713
725
  : defaultOrCustomRpcEndpointFields;
714
726
  return {
@@ -987,6 +999,7 @@ class NetworkController extends base_controller_1.BaseController {
987
999
  });
988
1000
  });
989
1001
  __classPrivateFieldSet(this, _NetworkController_networkConfigurationsByNetworkClientId, buildNetworkConfigurationsByNetworkClientId(this.state.networkConfigurationsByChainId), "f");
1002
+ this.messagingSystem.publish('NetworkController:networkRemoved', existingNetworkConfiguration);
990
1003
  }
991
1004
  /**
992
1005
  * Assuming that the network has been previously switched, switches to this
@@ -1280,6 +1293,9 @@ async function _NetworkController_determineEIP1559Compatibility(networkClientId)
1280
1293
  delete state.networkConfigurationsByChainId[args.existingNetworkConfiguration.chainId];
1281
1294
  }
1282
1295
  if (mode === 'add' || mode === 'update') {
1296
+ if (JSON.stringify(state.networkConfigurationsByChainId[args.networkFields.chainId]) !== JSON.stringify(args.networkConfigurationToPersist)) {
1297
+ args.networkConfigurationToPersist.lastUpdatedAt = Date.now();
1298
+ }
1283
1299
  state.networkConfigurationsByChainId[args.networkFields.chainId] =
1284
1300
  args.networkConfigurationToPersist;
1285
1301
  }