@@ -21,6 +21,7 @@ import PortManager, { ResourceType } from '../framework/PortManager.ts';
2121import {
2222 FALLBACK_GANACHE_PORT ,
2323 FALLBACK_DAPP_SERVER_PORT ,
24+ FALLBACK_FIXTURE_SERVER_PORT ,
2425} from '../framework/Constants.ts' ;
2526import { DEFAULT_ANVIL_PORT } from '../seeder/anvil-manager.ts' ;
2627import { logLiveMetaMetricsPostIfDebug } from '../helpers/analytics/analyticsDebug.ts' ;
@@ -124,6 +125,8 @@ const translateFallbackPortToActual = (url: string): string => {
124125 if ( actualPort === undefined ) {
125126 actualPort = portManager . getPort ( ResourceType . ANVIL ) ;
126127 }
128+ } else if ( portNum === FALLBACK_FIXTURE_SERVER_PORT ) {
129+ actualPort = portManager . getPort ( ResourceType . FIXTURE_SERVER ) ;
127130 } else if ( portNum === DEFAULT_ANVIL_PORT ) {
128131 actualPort = portManager . getPort ( ResourceType . ANVIL ) ;
129132 } else if (
@@ -152,12 +155,33 @@ const translateFallbackPortToActual = (url: string): string => {
152155 }
153156} ;
154157
158+ const isFixtureServerStateUrl = ( url : string ) : boolean => {
159+ try {
160+ const parsedUrl = new URL ( url ) ;
161+ const port = parseInt ( parsedUrl . port , 10 ) ;
162+ const fixtureServerPort = PortManager . getInstance ( ) . getPort (
163+ ResourceType . FIXTURE_SERVER ,
164+ ) ;
165+
166+ return (
167+ parsedUrl . pathname === '/state.json' &&
168+ ( port === FALLBACK_FIXTURE_SERVER_PORT || port === fixtureServerPort )
169+ ) ;
170+ } catch {
171+ return false ;
172+ }
173+ } ;
174+
155175const isUrlAllowed = ( url : string ) : boolean => {
156176 try {
157177 if ( ALLOWLISTED_URLS . includes ( url ) ) {
158178 return true ;
159179 }
160180
181+ if ( isFixtureServerStateUrl ( url ) ) {
182+ return true ;
183+ }
184+
161185 // Malformed npm: package URIs that leak through the snap proxy
162186 // e.g. https://https//npm:@metamask /... or npm:@metamask /...
163187 if ( / ^ (?: h t t p s ? : \/ \/ .* ) ? n p m [: @ ] @ ? m e t a m a s k \/ / . test ( url ) ) {
0 commit comments