@@ -100,79 +100,6 @@ const RESPONSE_OUTGOING_TRANSACTION_MOCK = {
100100 from : DEFAULT_FIXTURE_ACCOUNT ,
101101} ;
102102
103- const createInfuraRpcResponses = (
104- rpcUrl = '' ,
105- ) : Record < string , unknown > => {
106- const chainId = rpcUrl . includes ( 'linea-sepolia' )
107- ? '0xe705'
108- : rpcUrl . includes ( 'sepolia' )
109- ? '0xaa36a7'
110- : '0x1' ;
111-
112- return {
113- eth_chainId : chainId ,
114- eth_getBalance : '0x0' ,
115- eth_call : '0x' ,
116- eth_estimateGas : '0x5208' ,
117- eth_gasPrice : '0x3B9ACA00' ,
118- eth_getTransactionCount : '0x0' ,
119- eth_blockNumber : '0x1234567' ,
120- eth_getBlockByNumber : {
121- number : '0x1234567' ,
122- hash : '0xabc123' ,
123- timestamp : '0x' + Math . floor ( Date . now ( ) / 1000 ) . toString ( 16 ) ,
124- gasLimit : '0x1c9c380' ,
125- gasUsed : '0x5208' ,
126- baseFeePerGas : '0x3B9ACA00' ,
127- transactions : [ ] ,
128- } ,
129- eth_maxPriorityFeePerGas : '0x3B9ACA00' ,
130- eth_feeHistory : {
131- baseFeePerGas : [ '0x3B9ACA00' , '0x3B9ACA00' ] ,
132- gasUsedRatio : [ 0.5 ] ,
133- oldestBlock : '0x1234566' ,
134- reward : [ [ '0x3B9ACA00' ] ] ,
135- } ,
136- net_version : parseInt ( chainId , 16 ) . toString ( 10 ) ,
137- } ;
138- } ;
139-
140- const createMainnetRpcCallback =
141- ( ) =>
142- async ( request : {
143- url : string ;
144- body : { getText : ( ) => Promise < string | undefined > } ;
145- } ) => {
146- const proxiedUrl = new URL ( request . url , 'http://localhost' ) . searchParams . get (
147- 'url' ,
148- ) ;
149- const rpcResponses = createInfuraRpcResponses ( proxiedUrl ?? request . url ) ;
150- const bodyText = await request . body . getText ( ) ;
151- const body = bodyText ? JSON . parse ( bodyText ) : undefined ;
152-
153- if ( Array . isArray ( body ) ) {
154- return {
155- statusCode : 200 ,
156- body : JSON . stringify (
157- body . map ( ( req : { id ?: number ; method ?: string } ) => ( {
158- id : req . id ?? 1 ,
159- jsonrpc : '2.0' ,
160- result : rpcResponses [ req . method ?? '' ] ?? '0x' ,
161- } ) ) ,
162- ) ,
163- } ;
164- }
165-
166- return {
167- statusCode : 200 ,
168- body : JSON . stringify ( {
169- id : body ?. id ?? 1 ,
170- jsonrpc : '2.0' ,
171- result : rpcResponses [ body ?. method ?? '' ] ?? '0x' ,
172- } ) ,
173- } ;
174- } ;
175-
176103function mockAccountsApi (
177104 transactions : Record < string , unknown > [ ] = [ ] ,
178105) : MockApiEndpoint {
@@ -197,20 +124,6 @@ function createAccountsTestSpecificMock(
197124 transactions : Record < string , unknown > [ ] = [ ] ,
198125) : TestSpecificMock {
199126 return async ( mockServer : Mockttp ) => {
200- await mockServer
201- . forPost ( / ^ h t t p s : \/ \/ .* i n f u r a \. i o \/ v 3 \/ .* $ / )
202- . asPriority ( 1000 )
203- . thenCallback ( createMainnetRpcCallback ( ) ) ;
204-
205- await mockServer
206- . forPost ( '/proxy' )
207- . matching ( ( request ) => {
208- const url = new URL ( request . url ) . searchParams . get ( 'url' ) ;
209- return Boolean ( url ?. includes ( 'infura.io' ) ) ;
210- } )
211- . asPriority ( 1000 )
212- . thenCallback ( createMainnetRpcCallback ( ) ) ;
213-
214127 await setupRemoteFeatureFlagsMock ( mockServer , {
215128 homepageRedesignV1 : { enabled : false , minimumVersion : '0.0.0' } ,
216129 homepageSectionsV1 : { enabled : false , minimumVersion : '0.0.0' } ,
0 commit comments