(requestId: string)
| 9 | } from '../'; |
| 10 | |
| 11 | const waitForFulfillment = async (requestId: string) => { |
| 12 | const airnodeRrp = await getDeployedContract('@api3/airnode-protocol/contracts/rrp/AirnodeRrpV0.sol'); |
| 13 | const provider = getProvider(); |
| 14 | |
| 15 | const fulfilled = new Promise((resolve) => |
| 16 | provider.once(airnodeRrp.filters.FulfilledRequest(null, requestId), resolve) |
| 17 | ); |
| 18 | const failed = new Promise((resolve) => |
| 19 | provider.once(airnodeRrp.filters.FailedRequest(null, requestId), resolve) |
| 20 | ).then((rawRequestFailedLog) => { |
| 21 | const log = airnodeRrp.interface.parseLog(rawRequestFailedLog as ethers.Event); |
| 22 | throw new Error(`Request failed. Reason:\n${log.args.errorMessage}`); |
| 23 | }); |
| 24 | |
| 25 | // Airnode request can either: |
| 26 | // 1) be fulfilled - in that case this promise resolves |
| 27 | // 2) fail - in that case, this promise rejects and this function throws an error |
| 28 | // 3) never be processed - this means the request is invalid or a bug in Airnode. This should not happen. |
| 29 | await Promise.race([fulfilled, failed]); |
| 30 | }; |
| 31 | |
| 32 | const makeRequest = async (): Promise<string> => { |
| 33 | const integrationInfo = readIntegrationInfo(); |
no test coverage detected