Skip to content

Commit

Permalink
fix remove network
Browse files Browse the repository at this point in the history
  • Loading branch information
jiexi committed Jan 24, 2025
1 parent 67dae48 commit d65cabf
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
4 changes: 3 additions & 1 deletion app/scripts/metamask-controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -421,6 +421,7 @@ import { walletCreateSession } from './lib/rpc-method-middleware/handlers/wallet
import BridgeStatusController from './controllers/bridge-status/bridge-status-controller';
import { BRIDGE_STATUS_CONTROLLER_NAME } from './controllers/bridge-status/constants';
import { rejectAllApprovals } from './lib/approval/utils';
import { hexToBigInt, toCaipChainId } from '@metamask/utils';

Check failure on line 424 in app/scripts/metamask-controller.js

View workflow job for this annotation

GitHub Actions / Test lint / Test lint

`@metamask/utils` import should occur before import of `../../shared/constants/methods-tags`

const { TRIGGER_TYPES } = NotificationServicesController.Constants;
export const METAMASK_CONTROLLER_EVENTS = {
Expand Down Expand Up @@ -3308,7 +3309,8 @@ export default class MetamaskController extends EventEmitter {
this.controllerMessenger.subscribe(
'NetworkController:networkRemoved',
({ chainId }) => {
this.removeAllChainIdPermissions(chainId);
const scopeString = toCaipChainId('eip155', hexToBigInt(chainId).toString(10))

Check failure on line 3312 in app/scripts/metamask-controller.js

View workflow job for this annotation

GitHub Actions / Test lint / Test lint

Replace `'eip155',·hexToBigInt(chainId).toString(10))` with `⏎··········'eip155',⏎··········hexToBigInt(chainId).toString(10),⏎········);`
this.removeAllScopePermissions(scopeString);
},
);

Expand Down
8 changes: 4 additions & 4 deletions app/scripts/metamask-controller.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2099,19 +2099,19 @@ describe('MetaMaskController', () => {
describe('NetworkConfiguration is removed', () => {
it('should remove the permitted chain from all existing permissions', () => {
jest
.spyOn(metamaskController, 'removeAllChainIdPermissions')
.spyOn(metamaskController, 'removeAllScopePermissions')
.mockReturnValue();

metamaskController.controllerMessenger.publish(
'NetworkController:networkRemoved',
{
chainId: '0xdeadbeef',
chainId: '0xa',
},
);

expect(
metamaskController.removeAllChainIdPermissions,
).toHaveBeenCalledWith('0xdeadbeef');
metamaskController.removeAllScopePermissions,
).toHaveBeenCalledWith('eip155:10');
});
});

Expand Down

0 comments on commit d65cabf

Please sign in to comment.