Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions icons/wallet_watchAsset
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
const tokenAddress = '0x25f2aabC1180DddAF5a859Be517dDA6dEC418773';
const tokenSymbol = 'sETH';
const tokenDecimals = 18;
const tokenImage = 'https://bafkreiamy6stfz25ez2ggmz3cj6apixuctmbl4cotlqkim4ke5ch5jlu2i.ipfs.inbrowser.link/';

try {
const wasAdded = await window.ethereum.request({
method: 'wallet_watchAsset',
params: {
type: 'ERC20',
options: {
address: tokenAddress,
symbol: tokenSymbol,
decimals: tokenDecimals,
image: tokenImage,
},
},
});

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ignored watchAsset boolean result

Medium Severity

wallet_watchAsset resolves to a boolean for success or user decline, but wasAdded is never read. When MetaMask returns false without throwing, the snippet exits with no feedback, so a declined add looks like a silent success.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 7e04e68. Configure here.

} catch (error) {
console.log(error);
}