@@ -252,7 +252,7 @@ watch(isReady, (ready) => {
252252 if (config .value .source === " browser-wallet" ) {
253253 config .value .connectedAddress = connectedAddress .value ;
254254 }
255- });
255+ }, { immediate : true , flush : " sync " } );
256256
257257/**
258258 * Connect to browser wallet (MetaMask, etc.)
@@ -317,9 +317,10 @@ function handleAccountsChanged(accounts) {
317317}
318318
319319/**
320- * Detect network environment
320+ * Detect network environment and check for query parameters
321321 */
322322async function detectEnvironment () {
323+ // First, detect if we're on Anvil
323324 try {
324325 const response = await fetch (" /contracts.json" );
325326 if (response .ok ) {
@@ -338,6 +339,24 @@ async function detectEnvironment() {
338339 // eslint-disable-next-line no-console
339340 console .warn (" Could not load contracts.json:" , err);
340341 }
342+
343+ // Then, check for fundingAccount query parameter (for E2E tests)
344+ // This must happen after we've detected isAnvil
345+ if (typeof window !== " undefined" ) {
346+ const urlParams = new URLSearchParams (window .location .search );
347+ const fundingAccountParam = urlParams .get (" fundingAccount" );
348+ if (fundingAccountParam !== null ) {
349+ const accountIndex = parseInt (fundingAccountParam, 10 );
350+ if (! isNaN (accountIndex) && accountIndex >= 0 && accountIndex <= 9 ) {
351+ // eslint-disable-next-line no-console
352+ console .log (" Setting Anvil account from query parameter:" , accountIndex);
353+ config .value .source = " anvil" ;
354+ config .value .anvilAccountIndex = accountIndex;
355+ // Since isAnvil might already be true from detectEnvironment,
356+ // the isReady computed property should now evaluate to true
357+ }
358+ }
359+ }
341360}
342361
343362// Initialize on mount
0 commit comments