SDK
Utils
getGameStatus

Returns detailed game status based on game's status derived from the subgraph and start date.

This helper extends the GameStatus from the subgraph. However, it's noticeable that there might not be sufficient statuses to create a detailed UI representation of the game state. For instance, there might be ambiguity in understanding what occurred with the bet between the 'Created' and 'Resolved' statuses.

export enum GraphGameStatus {
  Created = 'Created', // game was created
  Resolved = 'Resolved' // game was resolved
  Paused = 'Paused', // games was paused
  Canceled = 'Canceled', // game was calnceled
}

Thus, we've introduced additional statuses:

enum GameStatus {
  Preparing, // status before the game starts
  Live, // game was started
  PendingResolution, // game status 100 minutes after the start
  Resolved, // same as GraphGameStatus.Resolved
  Canceled, // same as GraphGameStatus.Canceled
  Paused, // same as GraphGameStatus.Paused
}

Usage

import { getGameStatus, GameStatus } from '@azuro-org/sdk'
 
const { status, startsAt } = game // game's data from subgraph
 
const gameStatus = getGameStatus({ 
  graphStatus: status,
  startsAt,
})
 
const isGameInLive = gameStatus === GameStatus.Live

Props

{
  graphStatus: GameStatus // game's status from subgraph
  startsAt: number
}

Return Value

enum GameStatus {
  Preparing,
  Live,
  PendingResolution,
  Resolved,
  Canceled,
  Paused,
}