🌳
pt0/deployF/ethF/guardValidatorAI.mts
3export type GuardValidatorFn = (p: {ethNetwork: string, name: string, cluster_name: string, action: string}) => Promise<void>
5export const mkGuardValidator = ({getSafeEthVal}: {getSafeEthVal: (p: {ethNetwork: string}) => {name: string, cluster_name: string, ethValidatorNums?: number[]}}): GuardValidatorFn => async ({ethNetwork, name, cluster_name, action}) => {
6 if (action == 'delete') return
7 const ethVal = getSafeEthVal({ethNetwork})
8 const isMatch = ethVal.name == name && ethVal.cluster_name == cluster_name
9 if (!isMatch) {
10 console.log({ethVal, name, cluster_name})
11 throw new Error('NOT SAFE, CANNOT DEPLOY')
12 }
13 for (const ethValidatorNum of ethVal.ethValidatorNums ?? []) {
14 await assertEthValidatorSilent({ethValidatorNum})
15 }