@@ -5,6 +5,7 @@ import YAML from "yaml";
55
66import {
77 compatPolicyForState ,
8+ requiresLegacyRelayerReadinessConfig ,
89 requiresMultichainAclAddress ,
910 type CompatPolicy ,
1011} from "./compat" ;
@@ -30,7 +31,6 @@ import {
3031import type { BuiltImage , InstanceOverride , OverrideGroup , State } from "./types" ;
3132import type { RunOptions , Runner } from "./utils" ;
3233import {
33- copyFile ,
3434 ensureDir ,
3535 exists ,
3636 mergeArgs ,
@@ -351,6 +351,33 @@ const deriveWallet = async (runner: Runner, mnemonic: string, index: number) =>
351351 return { address, privateKey } ;
352352} ;
353353
354+ export const rewriteRelayerConfig = ( config : Record < string , unknown > , state : Pick < State , "versions" > ) => {
355+ if ( ! requiresLegacyRelayerReadinessConfig ( state ) ) {
356+ return config ;
357+ }
358+ const gateway = config . gateway ;
359+ if ( ! gateway || typeof gateway !== "object" ) {
360+ return config ;
361+ }
362+ const readiness = ( gateway as Record < string , unknown > ) . readiness_checker ;
363+ if ( ! readiness || typeof readiness !== "object" ) {
364+ return config ;
365+ }
366+ const current = readiness as Record < string , unknown > ;
367+ ( gateway as Record < string , unknown > ) . readiness_checker = Object . fromEntries (
368+ Object . entries ( {
369+ retry :
370+ current . retry ??
371+ ( current . gw_ciphertext_check as Record < string , unknown > | undefined ) ?. retry ??
372+ ( current . host_acl_check as Record < string , unknown > | undefined ) ?. retry ,
373+ public_decrypt : current . public_decrypt ,
374+ user_decrypt : current . user_decrypt ,
375+ delegated_user_decrypt : current . delegated_user_decrypt ,
376+ } ) . filter ( ( [ , value ] ) => value !== undefined ) ,
377+ ) ;
378+ return config ;
379+ } ;
380+
354381const writeRuntimeEnvFiles = async ( state : State , deps : Pick < ArtifactDeps , "runner" > ) => {
355382 await ensureDir ( ENV_DIR ) ;
356383 const compat = compatPolicyForState ( state ) ;
@@ -467,7 +494,11 @@ const writeRuntimeEnvFiles = async (state: State, deps: Pick<ArtifactDeps, "runn
467494 versionsEnvPath ,
468495 state . versions . env ,
469496 ) ;
470- await copyFile ( TEMPLATE_RELAYER_CONFIG , relayerConfigPath ) ;
497+ const relayerConfig = rewriteRelayerConfig (
498+ YAML . parse ( await fs . readFile ( TEMPLATE_RELAYER_CONFIG , "utf8" ) ) as Record < string , unknown > ,
499+ state ,
500+ ) ;
501+ await fs . writeFile ( relayerConfigPath , YAML . stringify ( relayerConfig ) ) ;
471502} ;
472503
473504const imageRefsForServices = async ( component : string , services : string [ ] ) => {
0 commit comments