@@ -113,6 +113,8 @@ export default class SetupPrepCharts extends Command {
113113 }
114114
115115 private async processProductionYaml ( valuesDir : string ) : Promise < { updated : number ; skipped : number } > {
116+
117+
116118 const productionFiles = fs . readdirSync ( valuesDir )
117119 . filter ( file => file . endsWith ( '-production.yaml' ) || file . match ( / - p r o d u c t i o n - \d + \. y a m l $ / ) )
118120
@@ -141,36 +143,35 @@ export default class SetupPrepCharts extends Command {
141143 // if (value === '' || value === '[""]' || value === '[]' ||
142144 // (Array.isArray(value) && (value.length === 0 || (value.length === 1 && value[0] === ''))) ||
143145 // value === null || value === undefined) {
144- const configMapping = this . configMapping [ key ]
145- if ( configMapping ) {
146- let configKey : string
147- if ( typeof configMapping === 'function' ) {
148- configKey = configMapping ( chartName , productionNumber )
149- } else {
150- configKey = configMapping
151- }
152- const configValue = this . getConfigValue ( configKey )
153- if ( configValue !== undefined && configValue !== null ) {
154- let newValue : string | string [ ]
155- if ( Array . isArray ( configValue ) ) {
156- newValue = JSON . stringify ( configValue )
157- } else {
158- newValue = String ( configValue )
159- }
146+ const configMapping = this . configMapping [ key ]
147+ if ( configMapping ) {
148+ let configKey : string
149+ if ( typeof configMapping === 'function' ) {
150+ configKey = configMapping ( chartName , productionNumber )
151+ } else {
152+ configKey = configMapping
153+ }
154+ if ( chartName === "l1-devnet" && key === "CHAIN_ID" ) {
155+ configKey = "general.CHAIN_ID_L1" ;
156+ }
160157
161- if ( chartName === "l1-devnet" && key === "CHAIN_ID" ) {
162- continue ;
163- }
164- if ( newValue != value ) {
165- changes . push ( { key, oldValue : JSON . stringify ( value ) , newValue : newValue } )
166- envData [ key ] = newValue
167- updated = true
168- }
158+ const configValue = this . getConfigValue ( configKey )
159+ if ( configValue !== undefined && configValue !== null ) {
160+ let newValue : string | string [ ]
161+ if ( Array . isArray ( configValue ) ) {
162+ newValue = JSON . stringify ( configValue )
169163 } else {
170- this . log ( chalk . yellow ( ` ${ chartName } : No value found for ${ configKey } ` ) )
164+ newValue = String ( configValue )
171165 }
166+ if ( newValue != value ) {
167+ changes . push ( { key, oldValue : JSON . stringify ( value ) , newValue : newValue } )
168+ envData [ key ] = newValue
169+ updated = true
170+ }
171+ } else {
172+ this . log ( chalk . yellow ( `${ chartName } : No value found for ${ configKey } ` ) )
172173 }
173- // }
174+ }
174175 }
175176 }
176177 }
@@ -243,6 +244,126 @@ export default class SetupPrepCharts extends Command {
243244 }
244245 }
245246 }
247+ /*
248+ blockscout-stack.blockscout.ingress.annotations.nginx.ingress.kubernetes.io/cors-allow-origin:https://blockscout.scrollsdk
249+ blockscout-stack.blockscout.ingress.hostname:blockscout.scrollsdk
250+ blockscout-stack.frontend.env.NEXT_PUBLIC_API_HOST:blockscout.scrollsdk
251+ blockscout-stack.frontend.ingress.annotations.nginx.ingress.kubernetes.io/cors-allow-origin: "https://blockscout.scrollsdk"
252+ blockscout-stack.frontend.ingress.hostname: "blockscout.scrollsdk"
253+ */
254+ if ( productionYaml [ "blockscout-stack" ] ) {
255+ let ingressUpdated = false ;
256+ const blockscout = productionYaml [ "blockscout-stack" ] . blockscout ;
257+ const frontend = productionYaml [ "blockscout-stack" ] . frontend ;
258+ let blockscout_host = this . getConfigValue ( "ingress.BLOCKSCOUT_HOST" ) ;
259+ let blockscout_url = this . getConfigValue ( "frontend.EXTERNAL_EXPLORER_URI_L2" ) ;
260+
261+ if ( blockscout ?. ingress ?. annotations ?. [ "nginx.ingress.kubernetes.io/cors-allow-origin" ] ) {
262+ changes . push ( { key : `ingress.blockscout.annotations["nginx.ingress.kubernetes.io/cors-allow-origin"]` , oldValue : blockscout . ingress . annotations [ "nginx.ingress.kubernetes.io/cors-allow-origin" ] , newValue : blockscout_url } ) ;
263+ blockscout . ingress . annotations [ "nginx.ingress.kubernetes.io/cors-allow-origin" ] = blockscout_url ;
264+ ingressUpdated = true ;
265+ }
266+
267+ if ( blockscout ?. ingress ?. hostname ) {
268+ changes . push ( { key : `ingress.blockscout.hostname` , oldValue : blockscout . ingress . hostname , newValue : blockscout_host } ) ;
269+ blockscout . ingress . hostname = blockscout_host ;
270+ ingressUpdated = true ;
271+ }
272+ if ( frontend ?. env ?. NEXT_PUBLIC_API_HOST ) {
273+ changes . push ( { key : `frontend.env.NEXT_PUBLIC_API_HOST` , oldValue : frontend . env . NEXT_PUBLIC_API_HOST , newValue : blockscout_host } ) ;
274+ frontend . env . NEXT_PUBLIC_API_HOST = blockscout_host ;
275+ ingressUpdated = true ;
276+ }
277+ if ( frontend ?. ingress ?. annotations ?. [ "nginx.ingress.kubernetes.io/cors-allow-origin" ] ) {
278+ changes . push ( { key : `frontend.ingress.annotations["nginx.ingress.kubernetes.io/cors-allow-origin"]` , oldValue : frontend . ingress . annotations [ "nginx.ingress.kubernetes.io/cors-allow-origin" ] , newValue : blockscout_url } ) ;
279+ frontend . ingress . annotations [ "nginx.ingress.kubernetes.io/cors-allow-origin" ] = blockscout_url ;
280+ ingressUpdated = true ;
281+ }
282+ if ( frontend ?. ingress ?. hostname ) {
283+ changes . push ( { key : `frontend.ingress.hostname` , oldValue : frontend . ingress . hostname , newValue : blockscout_host } ) ;
284+ frontend . ingress . hostname = blockscout_host ;
285+ ingressUpdated = true ;
286+ }
287+ /*
288+ INDEXER_SCROLL_L1_CHAIN_CONTRACT: ""
289+ INDEXER_SCROLL_L1_BATCH_START_BLOCK: ""
290+ INDEXER_SCROLL_L1_MESSENGER_CONTRACT: ""
291+ INDEXER_SCROLL_L1_MESSENGER_START_BLOCK: ""
292+ INDEXER_SCROLL_L2_MESSENGER_CONTRACT: ""
293+ INDEXER_SCROLL_L2_GAS_ORACLE_CONTRACT: ""
294+ INDEXER_SCROLL_L1_RPC: ""
295+ INDEXER_SCROLL_L2_MESSENGER_START_BLOCK: 0
296+ INDEXER_SCROLL_L1_ETH_GET_LOGS_RANGE_SIZE: 500
297+ INDEXER_SCROLL_L2_ETH_GET_LOGS_RANGE_SIZE: 500
298+ */
299+ interface BlockscoutEnvMapping {
300+ key : string ;
301+ configKey : string ;
302+ defaultValue ?: string ;
303+ }
304+
305+ const BLOCKSCOUT_ENV_MAPPINGS : BlockscoutEnvMapping [ ] = [
306+ {
307+ key : 'INDEXER_SCROLL_L1_BATCH_START_BLOCK' ,
308+ configKey : '' ,
309+ defaultValue : '0'
310+ } ,
311+ {
312+ key : 'INDEXER_SCROLL_L1_MESSENGER_START_BLOCK' ,
313+ configKey : '' ,
314+ defaultValue : '0'
315+ } ,
316+ {
317+ key : 'INDEXER_SCROLL_L1_CHAIN_CONTRACT' ,
318+ configKey : 'contractsFile.L1_SCROLL_CHAIN_PROXY_ADDR'
319+ } ,
320+ {
321+ key : 'INDEXER_SCROLL_L1_MESSENGER_CONTRACT' ,
322+ configKey : 'L1_SCROLL_MESSENGER_PROXY_ADDR'
323+ } ,
324+ {
325+ key : 'INDEXER_SCROLL_L2_MESSENGER_CONTRACT' ,
326+ configKey : 'L2_SCROLL_MESSENGER_PROXY_ADDR'
327+ } ,
328+ {
329+ key : 'INDEXER_SCROLL_L2_GAS_ORACLE_CONTRACT' ,
330+ configKey : 'L1_GAS_PRICE_ORACLE_ADDR'
331+ } ,
332+ {
333+ key : 'INDEXER_SCROLL_L1_RPC' ,
334+ configKey : 'general.L1_RPC_ENDPOINT'
335+ }
336+
337+
338+ ] ;
339+ const benv = productionYaml [ "blockscout-stack" ] . blockscout . env ;
340+
341+ BLOCKSCOUT_ENV_MAPPINGS . forEach ( mapping => {
342+ const { key, configKey, defaultValue } = mapping ;
343+
344+ let newValue = this . getConfigValue ( configKey ) ;
345+ if ( ! newValue ) {
346+ newValue = configKey ? this . contractsConfig [ configKey ] : defaultValue ;
347+ }
348+
349+ if ( newValue !== undefined ) {
350+ changes . push ( {
351+ key : `blockscout.env.${ key } ` ,
352+ oldValue : benv [ key ] ,
353+ newValue : newValue
354+ } ) ;
355+ benv [ key ] = newValue ;
356+ } else {
357+ this . log ( chalk . yellow ( `No value found for ${ key } ` ) ) ;
358+ }
359+ } ) ;
360+
361+ updated = true ;
362+
363+ if ( ingressUpdated ) {
364+ updated = true ;
365+ }
366+ }
246367
247368 if ( productionYaml . grafana ) {
248369 let ingressUpdated = false ;
0 commit comments