Skip to content

Commit 2645a3a

Browse files
revert(assets): drop wallet_watchAsset change to keep PR minimal
Review follow-up on PR #47928: the metamask-controller fire-and-forget change is not proven to fix the user-reported dApp failure (the only deterministic repro was a poisoned RPC, not the reported error), so the controller change and its tests are reverted to main. The PR now covers only the custom token import fix: the early-return removal before the on-chain lookup and the warning check removal in isValid, plus the UI tests. The dApp wallet_watchAsset path is tracked separately.
1 parent 534cdbb commit 2645a3a

2 files changed

Lines changed: 5 additions & 64 deletions

File tree

‎app/scripts/metamask-controller.js‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3161,11 +3161,11 @@ export default class MetamaskController extends EventEmitter {
31613161
...(iconUrl ? { iconUrl } : {}),
31623162
};
31633163

3164-
this.assetsController
3165-
.addCustomAsset(accountId, assetId, pendingMetadata)
3166-
.catch((error) => {
3167-
captureException(error);
3168-
});
3164+
await this.assetsController.addCustomAsset(
3165+
accountId,
3166+
assetId,
3167+
pendingMetadata,
3168+
);
31693169
};
31703170

31713171
handleWatchAssetRequest = async ({

‎app/scripts/metamask-controller.test.js‎

Lines changed: 0 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ import { JsonRpcEngine } from '@metamask/json-rpc-engine';
3737
import { errorCodes } from '@metamask/rpc-errors';
3838
import { ApprovalType, ERC20 } from '@metamask/controller-utils';
3939
import { parseCaipAccountId } from '@metamask/utils';
40-
import { captureException } from '../../shared/lib/sentry';
4140

4241
import { createTestProviderTools } from '../../test/stub/provider';
4342
import {
@@ -100,11 +99,6 @@ jest.mock('./messenger-client-init/perps-controller-init', () => ({
10099
}),
101100
}));
102101

103-
jest.mock('../../shared/lib/sentry', () => ({
104-
...jest.requireActual('../../shared/lib/sentry'),
105-
captureException: jest.fn(),
106-
}));
107-
108102
jest.mock('./messenger-client-init/ramps-controller-init', () => ({
109103
...jest.requireActual('./messenger-client-init/ramps-controller-init'),
110104
RampsControllerInit: jest.fn().mockImplementation(() => ({
@@ -898,59 +892,6 @@ describe('MetaMaskController', () => {
898892
metamaskController.assetsController.addCustomAsset,
899893
).not.toHaveBeenCalled();
900894
});
901-
902-
it('resolves the watch asset request even when persisting the watched asset never settles', async () => {
903-
jest
904-
.spyOn(metamaskController.assetsController, 'addCustomAsset')
905-
.mockImplementation(() => new Promise(() => undefined));
906-
907-
const asset = {
908-
address: watchAssetTokenAddress,
909-
symbol: 'TST',
910-
decimals: 4,
911-
};
912-
913-
await expect(
914-
metamaskController.handleWatchAssetRequest({
915-
asset,
916-
type: ERC20,
917-
origin: 'https://example.com',
918-
networkClientId: watchAssetNetworkClientId,
919-
}),
920-
).resolves.toBeUndefined();
921-
922-
expect(
923-
metamaskController.assetsController.addCustomAsset,
924-
).toHaveBeenCalledTimes(1);
925-
});
926-
927-
it('resolves the watch asset request and reports the failure when persisting the watched asset rejects', async () => {
928-
const persistenceError = new Error(
929-
'No provider available for chain 0x171',
930-
);
931-
captureException.mockClear();
932-
jest
933-
.spyOn(metamaskController.assetsController, 'addCustomAsset')
934-
.mockRejectedValue(persistenceError);
935-
936-
const asset = {
937-
address: watchAssetTokenAddress,
938-
symbol: 'TST',
939-
decimals: 4,
940-
};
941-
942-
await expect(
943-
metamaskController.handleWatchAssetRequest({
944-
asset,
945-
type: ERC20,
946-
origin: 'https://example.com',
947-
networkClientId: watchAssetNetworkClientId,
948-
}),
949-
).resolves.toBeUndefined();
950-
951-
await waitForAllPromises();
952-
expect(captureException).toHaveBeenCalledWith(persistenceError);
953-
});
954895
});
955896
});
956897

0 commit comments

Comments
 (0)