(contract)
| 100 | } |
| 101 | |
| 102 | function validateLoopContract(contract) { |
| 103 | const errors = []; |
| 104 | if (!contract || typeof contract !== 'object') errors.push('contract must be an object'); |
| 105 | if (!contract?.id) errors.push('id is required'); |
| 106 | if (!contract?.type) errors.push('type is required'); |
| 107 | if (!contract?.trigger?.kind) errors.push('trigger.kind is required'); |
| 108 | if (!contract?.budget || !Number.isFinite(Number(contract.budget.maxAttempts)) || Number(contract.budget.maxAttempts) < 1) { |
| 109 | errors.push('budget.maxAttempts must be >= 1'); |
| 110 | } |
| 111 | if (!Array.isArray(contract?.stopConditions) || contract.stopConditions.length === 0) { |
| 112 | errors.push('stopConditions must be a non-empty array'); |
| 113 | } |
| 114 | if (!contract?.statePath) errors.push('statePath is required'); |
| 115 | return { |
| 116 | pass: errors.length === 0, |
| 117 | errors, |
| 118 | }; |
| 119 | } |
| 120 | |
| 121 | module.exports = Object.freeze({ |
| 122 | CONTRACT_VERSION, |
no outgoing calls
no test coverage detected