Skip to content

Commit 21c6b3c

Browse files
committed
fix link-token-contracts script
1 parent efb4e55 commit 21c6b3c

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

src/scripts/link-to-wallet.ts

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,11 @@ interface EIP6963AnnounceProviderEvent extends CustomEvent {
2525
detail: EIP6963ProviderDetail
2626
}
2727

28+
interface ExtendedEthereumProvider extends MetaMaskInpageProvider {
29+
isPhantom?: boolean
30+
isRabby?: boolean
31+
}
32+
2833
const separator = "_"
2934
const addressPattern = "0x[0-9a-fA-F]{40}"
3035
const hexStringPattern = "(0x|0X)[a-fA-F0-9]+"
@@ -147,8 +152,8 @@ const detectMetaMaskViaEIP6963 = (): Promise<MetaMaskInpageProvider | null> => {
147152
// Fallback: Check if window.ethereum is actually MetaMask
148153
// This is less reliable but provides backward compatibility
149154
const ethereum = (window as { ethereum?: MetaMaskInpageProvider }).ethereum
150-
// Check if it's really MetaMask and not another wallet pretending to be
151-
if (ethereum?.isMetaMask && !(ethereum as any).isPhantom && !(ethereum as any).isRabby) {
155+
const extendedEthereum = ethereum as ExtendedEthereumProvider
156+
if (ethereum?.isMetaMask && !extendedEthereum.isPhantom && !extendedEthereum.isRabby) {
152157
console.warn("Using fallback MetaMask detection. Please update MetaMask for better compatibility.")
153158
resolve(ethereum)
154159
} else {
@@ -637,9 +642,7 @@ const handleWalletTokenManagement = async () => {
637642
const addSuccess = await validateAndAddToken(address, updatedProvider, ethereum, parameters)
638643
if (addSuccess) {
639644
button.innerText = "✓ Added"
640-
setTimeout(() => {
641-
window.location.reload()
642-
}, 1500)
645+
// Keep the success state visible - no need to reload
643646
} else {
644647
button.innerText = "Failed to add"
645648
setTimeout(() => {

0 commit comments

Comments
 (0)