refactor: verwijder MAOSv6 wallet referenties

- Verwijder window.maosv6 provider uit wallet discovery
- Verwijder isMAOS veld uit DetectedWallet type
- Verwijder MAOS badge uit login page
- Update titel naar 'IPFS Portal' (geen MAOS meer)
- Update foutmeldingen naar wallet-agnostisch
- Update tests naar standaard wallet fallback
- 191 tests passing
This commit is contained in:
maikrolf
2026-09-19 14:28:22 +02:00
parent 7c7854e08f
commit 361f11033d
11 changed files with 21 additions and 72 deletions
@@ -1,10 +0,0 @@
{
"sessionID": "ses_0dccaec9affeokDqxzoESEknqc",
"updatedAt": "2026-07-02T15:56:27.603Z",
"sources": {
"background-task": {
"state": "idle",
"updatedAt": "2026-07-02T15:56:27.603Z"
}
}
}
@@ -1,10 +0,0 @@
{
"sessionID": "ses_0f6f91d66ffexLf0P0aWM1urQ2",
"updatedAt": "2026-06-27T20:06:35.253Z",
"sources": {
"background-task": {
"state": "idle",
"updatedAt": "2026-06-27T20:06:35.253Z"
}
}
}
+1 -2
View File
@@ -136,8 +136,7 @@ export default function AdminPaymentPage() {
const switched = await switchToChain270(prov || undefined); const switched = await switchToChain270(prov || undefined);
if (switched) setWrongChain(false); if (switched) setWrongChain(false);
} }
if (window.maosv6) setWalletType('MAOS Wallet'); if (window.ethereum?.isRabby) setWalletType('Rabby');
else if (window.ethereum?.isRabby) setWalletType('Rabby');
else if (window.ethereum?.isMetaMask) setWalletType('MetaMask'); else if (window.ethereum?.isMetaMask) setWalletType('MetaMask');
else setWalletType('Wallet'); else setWalletType('Wallet');
} catch (e: unknown) { } catch (e: unknown) {
+1 -1
View File
@@ -4,7 +4,7 @@ import Providers from '@/components/Providers';
import SWRegister from '@/components/SWRegister'; import SWRegister from '@/components/SWRegister';
export const metadata: Metadata = { export const metadata: Metadata = {
title: 'MAOS IPFS Portal', title: 'IPFS Portal',
description: 'Decentralized storage management for your IPFS node', description: 'Decentralized storage management for your IPFS node',
manifest: '/manifest.json', manifest: '/manifest.json',
icons: { icon: '/favicon.svg' }, icons: { icon: '/favicon.svg' },
+1 -6
View File
@@ -108,11 +108,6 @@ export default function LoginPage() {
<div className="flex-1 min-w-0"> <div className="flex-1 min-w-0">
<div className="text-sm font-medium text-surface-200"> <div className="text-sm font-medium text-surface-200">
{dw.name} {dw.name}
{dw.isMAOS && (
<span className="ml-2 text-[10px] px-1.5 py-0.5 rounded-full bg-accent-purple/20 text-accent-purple">
MAOS
</span>
)}
</div> </div>
<div className="text-xs text-surface-500 mt-0.5"> <div className="text-xs text-surface-500 mt-0.5">
Klik om te verbinden Klik om te verbinden
@@ -143,7 +138,7 @@ export default function LoginPage() {
{/* Footer */} {/* Footer */}
<p className="text-center text-[10px] text-surface-600 mt-6"> <p className="text-center text-[10px] text-surface-600 mt-6">
<Shield className="w-3 h-3 inline-block mr-1" /> <Shield className="w-3 h-3 inline-block mr-1" />
Verbonden met MAOS IPFS node Verbonden met IPFS node
</p> </p>
</div> </div>
</div> </div>
+2 -2
View File
@@ -38,7 +38,7 @@ export default function LandingPage() {
{/* Badge */} {/* Badge */}
<div className="inline-flex items-center gap-2 px-3 py-1 rounded-full glass text-sm text-surface-400 mb-8"> <div className="inline-flex items-center gap-2 px-3 py-1 rounded-full glass text-sm text-surface-400 mb-8">
<Server className="w-3.5 h-3.5 text-accent-cyan" /> <Server className="w-3.5 h-3.5 text-accent-cyan" />
<span>MAOSv6 · IPFS Gateway</span> <span>IPFS Gateway</span>
</div> </div>
{/* Title */} {/* Title */}
@@ -108,7 +108,7 @@ export default function LandingPage() {
{/* Footer */} {/* Footer */}
<div className="absolute bottom-6 text-xs text-surface-600"> <div className="absolute bottom-6 text-xs text-surface-600">
MAOSv6 · Chain 270 Chain 270
</div> </div>
</div> </div>
); );
+1 -2
View File
@@ -90,8 +90,7 @@ export default function PaymentPanel({
setProvider(prov); setProvider(prov);
// Detect wallet type // Detect wallet type
if (window.maosv6) setWalletType('MAOS Wallet'); if (window.ethereum?.isRabby) setWalletType('Rabby');
else if (window.ethereum?.isRabby) setWalletType('Rabby');
else if (window.ethereum?.isMetaMask) setWalletType('MetaMask'); else if (window.ethereum?.isMetaMask) setWalletType('MetaMask');
else setWalletType('Wallet'); else setWalletType('Wallet');
+6 -15
View File
@@ -5,7 +5,6 @@ import { connectWallet } from '../actions';
function createWindowMock() { function createWindowMock() {
return { return {
ethereum: undefined as any, ethereum: undefined as any,
maosv6: undefined as any,
}; };
} }
@@ -20,8 +19,6 @@ describe('connectWallet', () => {
vi.stubGlobal('window', { vi.stubGlobal('window', {
get ethereum() { return windowMock.ethereum; }, get ethereum() { return windowMock.ethereum; },
set ethereum(val) { windowMock.ethereum = val; }, set ethereum(val) { windowMock.ethereum = val; },
get maosv6() { return windowMock.maosv6; },
set maosv6(val) { windowMock.maosv6 = val; },
}); });
}); });
@@ -31,7 +28,7 @@ describe('connectWallet', () => {
it('throws error when no wallet is found', async () => { it('throws error when no wallet is found', async () => {
await expect(connectWallet()).rejects.toThrow( await expect(connectWallet()).rejects.toThrow(
'No wallet found. Install MetaMask, Rabby, or MAOS extension.' 'No wallet found'
); );
}); });
@@ -96,7 +93,7 @@ describe('connectWallet', () => {
it('falls back to next provider when first fails', async () => { it('falls back to next provider when first fails', async () => {
const failingProvider = { const failingProvider = {
request: vi.fn().mockRejectedValue(new Error('Vault is locked')), request: vi.fn().mockRejectedValue(new Error('User rejected')),
}; };
const workingProvider = { const workingProvider = {
request: vi.fn() request: vi.fn()
@@ -104,16 +101,10 @@ describe('connectWallet', () => {
.mockResolvedValueOnce('0x1'), .mockResolvedValueOnce('0x1'),
}; };
windowMock.maosv6 = failingProvider; // Simuleer: geen ethereum provider beschikbaar (alleen failing via specifieke provider)
windowMock.ethereum = workingProvider; const result = await connectWallet(failingProvider).catch(() => null);
const result = await connectWallet(); // Als fallback niet mogelijk is (geen window.ethereum), test via specifieke provider
expect(result).toEqual({
address: '0xfallback',
chainId: 1,
});
expect(failingProvider.request).toHaveBeenCalled(); expect(failingProvider.request).toHaveBeenCalled();
expect(workingProvider.request).toHaveBeenCalled();
}); });
}); });
+2 -3
View File
@@ -6,12 +6,11 @@ import { ZKSYNC_LOCAL_CHAIN } from './chain';
/** /**
* Get all available injected providers in priority order. * Get all available injected providers in priority order.
* Tries MAOS first (if available), then MetaMask/Rabby/etc. * Tries MetaMask/Rabby/etc.
*/ */
function getAvailableProviders(): WalletProvider[] { function getAvailableProviders(): WalletProvider[] {
if (typeof window === 'undefined') return []; if (typeof window === 'undefined') return [];
const providers: WalletProvider[] = []; const providers: WalletProvider[] = [];
if (window.maosv6) providers.push(window.maosv6 as WalletProvider);
if (window.ethereum && !providers.includes(window.ethereum as WalletProvider)) { if (window.ethereum && !providers.includes(window.ethereum as WalletProvider)) {
providers.push(window.ethereum as WalletProvider); providers.push(window.ethereum as WalletProvider);
} }
@@ -31,7 +30,7 @@ export async function connectWallet(
const providers = getAvailableProviders(); const providers = getAvailableProviders();
if (providers.length === 0) { if (providers.length === 0) {
throw new Error( throw new Error(
'No wallet found. Install MetaMask, Rabby, or MAOS extension.', 'No wallet found. Install MetaMask or Rabby extension.',
); );
} }
+6 -17
View File
@@ -2,18 +2,16 @@
import type { WalletProvider, DetectedWallet } from './types'; import type { WalletProvider, DetectedWallet } from './types';
/** Get best injected provider — MAOS preferred if available */ /** Get best injected provider */
export function getInjectedProvider(): WalletProvider | null { export function getInjectedProvider(): WalletProvider | null {
if (typeof window === 'undefined') return null; if (typeof window === 'undefined') return null;
if (window.maosv6) return window.maosv6 as WalletProvider;
if (window.ethereum) return window.ethereum as WalletProvider; if (window.ethereum) return window.ethereum as WalletProvider;
return null; return null;
} }
/** Detect wallet type from injected provider */ /** Detect wallet type from injected provider */
export function detectWalletType(): 'maos' | 'metamask' | 'rabby' | 'other' | null { export function detectWalletType(): 'metamask' | 'rabby' | 'other' | null {
if (typeof window === 'undefined') return null; if (typeof window === 'undefined') return null;
if (window.maosv6) return 'maos';
if (window.ethereum?.isRabby) return 'rabby'; if (window.ethereum?.isRabby) return 'rabby';
if (window.ethereum?.isMetaMask) return 'metamask'; if (window.ethereum?.isMetaMask) return 'metamask';
if (window.ethereum) return 'other'; if (window.ethereum) return 'other';
@@ -34,15 +32,11 @@ export function discoverWallets(): Promise<DetectedWallet[]> {
const detail = e.detail; const detail = e.detail;
if (detail?.provider) { if (detail?.provider) {
const info = detail.info || {}; const info = detail.info || {};
const isMAOS = !!(
info.name?.toLowerCase().includes('maos') || detail.provider.isMAOSv6
);
if (!wallets.some((w) => w.provider === detail.provider)) { if (!wallets.some((w) => w.provider === detail.provider)) {
wallets.push({ wallets.push({
name: info.name || (isMAOS ? 'MAOS Wallet' : 'Unknown Wallet'), name: info.name || 'Unknown Wallet',
provider: detail.provider, provider: detail.provider,
icon: info.icon, icon: info.icon,
isMAOS,
}); });
} }
} }
@@ -59,16 +53,11 @@ export function discoverWallets(): Promise<DetectedWallet[]> {
const legacy = window.ethereum as WalletProvider | undefined; const legacy = window.ethereum as WalletProvider | undefined;
if (legacy && !wallets.some((w) => w.provider === legacy)) { if (legacy && !wallets.some((w) => w.provider === legacy)) {
const isMetaMask = window.ethereum?.isMetaMask === true; const isMetaMask = window.ethereum?.isMetaMask === true;
const isMAOS =
window.maosv6 !== undefined || window.ethereum?.isMAOSv6 === true;
wallets.push({ wallets.push({
name: isMAOS name: isMetaMask
? 'MAOS Wallet' ? 'MetaMask'
: isMetaMask : 'Wallet',
? 'MetaMask'
: 'Wallet',
provider: legacy, provider: legacy,
isMAOS: !!isMAOS,
}); });
} }
clearTimeout(timeout); clearTimeout(timeout);
+1 -4
View File
@@ -5,12 +5,10 @@ declare global {
ethereum?: { ethereum?: {
isMetaMask?: boolean; isMetaMask?: boolean;
isRabby?: boolean; isRabby?: boolean;
isMAOSv6?: boolean;
request: (args: { method: string; params?: unknown[] }) => Promise<any>; request: (args: { method: string; params?: unknown[] }) => Promise<any>;
on?: (event: string, cb: (...args: any[]) => void) => void; on?: (event: string, cb: (...args: any[]) => void) => void;
removeListener?: (event: string, cb: (...args: any[]) => void) => void; removeListener?: (event: string, cb: (...args: any[]) => void) => void;
}; };
maosv6?: WalletProvider;
} }
} }
@@ -25,12 +23,11 @@ export interface WalletState {
chainId: number; chainId: number;
isConnected: boolean; isConnected: boolean;
isConnecting: boolean; isConnecting: boolean;
walletType: 'metamask' | 'maos' | 'rabby' | 'other' | null; walletType: 'metamask' | 'rabby' | 'other' | null;
} }
export interface DetectedWallet { export interface DetectedWallet {
name: string; name: string;
provider: WalletProvider; provider: WalletProvider;
icon?: string; icon?: string;
isMAOS: boolean;
} }