| 27 | } |
| 28 | |
| 29 | function parseFile(data: any, onError?: (error: string) => void): UpgradeStage[] { |
| 30 | const parser = new ObjectParser({ |
| 31 | input: data, |
| 32 | onError: onError && (e => { onError(`Error while parsing Upgrades: ${e.toString()}`); }) |
| 33 | }); |
| 34 | const stages: UpgradeStage[] = []; |
| 35 | for (const key in data) { |
| 36 | stages.push(parseUpgradeStage(parser.prop(key), key, onError)); |
| 37 | } |
| 38 | return stages; |
| 39 | } |
| 40 | |
| 41 | function parseUpgradeStage(parser: IObjectParserProp<any>, key: string, onError?: (error: string) => void): UpgradeStage { |
| 42 | const parsed: UpgradeStage = { |