Skip to content

Commit

Permalink
Introduce OracleStatus for explicit API response
Browse files Browse the repository at this point in the history
  • Loading branch information
nichellekoh committed Apr 6, 2022
1 parent 0e8f9b8 commit 4d153e9
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion apps/status-api/src/controllers/OracleStatusController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,16 @@ export class OracleStatusController {
) {
}

/**
* To provide the status of each oracle given the address based on the last published time for any given token
*
* @param oracleAddress
* @return {Promise<OracleStatus>}
*/
@Get()
async getOracleStatus (
@Query('address') oracleAddress: string
): Promise<{ [key: string]: string }> {
): Promise<{status: OracleStatus}> {
const oraclePriceFeed: OraclePriceFeed = await this.cachedGet(`oracle-${oracleAddress}`, async () => {
const oracle = await this.client.oracles.getOracleByAddress(oracleAddress)
return (await this.client.oracles.getPriceFeed(oracle.id, oracle.priceFeeds[0].token, oracle.priceFeeds[0].currency, 1))[0]
Expand All @@ -41,3 +47,5 @@ function requireValue<T> (value: T | undefined, name: string): T {
}
return value
}

export type OracleStatus = 'outage' | 'operational'

0 comments on commit 4d153e9

Please sign in to comment.