(receiptFilename: string)
| 42 | } |
| 43 | |
| 44 | export function parseReceiptFile(receiptFilename: string) { |
| 45 | logger.debug('Parsing receipt file'); |
| 46 | |
| 47 | const goParse = goSync(() => JSON.parse(fs.readFileSync(receiptFilename, 'utf8'))); |
| 48 | if (!goParse.success) throw logAndReturnError(`Failed to parse receipt file: ${goParse.error}`); |
| 49 | |
| 50 | const receipt = goParse.data; |
| 51 | |
| 52 | const validationResult = parseReceipt(receipt); |
| 53 | if (!validationResult.success) { |
| 54 | throw logAndReturnError(`Invalid Airnode receipt file: ${validationResult.error}`); |
| 55 | } |
| 56 | |
| 57 | return receipt as receipt.Receipt; |
| 58 | } |
no test coverage detected