Comment on page

DrawBuffer

The DrawBuffer provides historical lookups of Draws via a circular ring buffer. Historical Draws can be accessed on-chain using a Draw ID to calculate ring buffer storage slots. The Draw settings can be created by manager/owner and existing Draws can only be updated by the owner. Once a starting Draw has been added to the ring buffer, all following draws must have a sequential Draw ID.
A DrawBuffer stores a limited number of Draws before beginning to overwrite (managed via the cardinality) previous Draws. Mainnet DrawBuffer is updated directly from a DrawBeacon.

Write methods description

initialize()

Allows to initialize the contract during the deployment.
Parameters:
Name
Type
Description
_owner
address
Address of the owner of the DrawBuffer.
_cardinality
uint8
Draw ring buffer cardinality.

markDrawAsPaid()

Mark a draw as paid. It means that the winners of the draw were paid and the draw can not be paid again.
Parameters:
Name
Type
Description
_drawId
uint32
An ID of a draw that should be marked as paid.

pushDraw()

Push draw onto draws ring buffer history. Push new draw onto draws history via authorized manager or owner.
Parameters:
Name
Type
Description
_draw
IDrawBeacon.Draw
Draw information that was pushed.

setDraw()

Set existing draw in draws ring buffer with new parameters. Push new draw onto draws history via authorized manager or owner.
Parameters:
Name
Type
Description
_draw
IDrawBeacon.Draw
Draw to set.
Return:
Name
Type
Description
_drawId
uint32
Draw ID.

setPrizeDistributor()

Set a new PrizeDistributor contract address.
Parameters:
Name
Type
Description
_prizeDistributor
address
A new PrizeDistributor contract address

claimOwnership()

Allows the pendingOwner address to claim the owner role. This function is only callable by the pendingOwner.

renounceOwnership()

Leaves the contract without owner. It will not be possible to call the owner's functions anymore. Can only be called by the current owner. The method does not take any parameters. Renouncing ownership will leave the contract without an owner, thereby removing any functionality that is only available to the owner.

transferOwnership()

Transfers ownership of the contract to a _pendingOwner. Can only be called by the current owner.
Parameters:
Name
Type
Description
_newOwner
address
An account that will become the _pendingOwner.

setManager()

Allows the owner to give the manager role to an address. The manager role has access to the functions with the modified onlyManager or onlyManagerOrOwner.
Parameters:
Name
Type
Description
_newManager
address
An account that will become the new manager.

Read methods description

MAX_CARDINALITY()

Ring buffer max length.

getBufferCardinality()

Read a ring buffer cardinality.

getDraw()

Read a draw from the draws ring buffer. Read a draw using the draw.drawId to calculate position in the draws ring buffer.
Parameters:
Name
Type
Description
_drawId
uint32
The draw ID to retrieve the draw data from.

getDrawCount()

Gets the number of draws held in the draw ring buffer. If no draws have been pushed, it will return 0. If the ring buffer is full, it will return the cardinality. Otherwise, it will return the newest draw index + 1.
Return:
Name
Type
Description
_count
uint32
Number of draws held in the draw ring buffer.

getDraws()

Read multiple draws from the draws ring buffer. Read multiple draws using each draw.drawId to calculate position in the draws ring buffer.
Parameters:
Name
Type
Description
_drawIds
uint32[]
Array of draw IDs.
Return:
Name
Type
Description
_draws
IDrawBeacon.Draw[]
Array with the draw information of the requested draw IDs.

getNewestDraw()

Read newest draw from draws ring buffer. Uses the nextDrawIndex to calculate the most recently added draw.

getOldestDraw()

Read oldest draw from draws ring buffer. Finds the oldest draw by comparing and/or diffing totalDraws with the cardinality.

getPrizeDistributor()

Read a PrizeDistributor contract address.

owner()

Owner role that can be granted exclusive access to specific functions with the modifier onlyOwner.

manager()

Manager role that can be granted exclusive access to specific functions with the modifier onlyManager or onlyManagerOrOwner.

pendingOwner()

Address that can claim the owner role. It is used to transfer the owner.