Skip to main content

PrizeDistributor

A Prize Distributor. Provides access to the contracts for viewing expiration times on draws, timelock timers and checking/claiming prizes for a user. Can be instantiated with an ethers Signer or Provider. Use a Signer if you want to claim transactions for a user. If a provider is provided, only read methods are available.

Table of contents

Constructors

Properties

Methods

Constructors

constructor

new PrizeDistributor(prizeDistributorMetadata, signerOrProvider, contractMetadataList)

Create an instance of a PrizeDistributor by providing the metadata of the PrizeDistributor contract, an ethers Provider or Signer for the network the PrizeDistributor contract is deployed on and a list of contract metadata for the other contracts that make up the PrizeDistributor.

Parameters

NameType
prizeDistributorMetadataContract
signerOrProviderSigner | Provider
contractMetadataListContract[]

Defined in

src/PrizeDistributor.ts:63

Properties

address

Readonly address: string

Defined in

src/PrizeDistributor.ts:39


chainId

Readonly chainId: number

Defined in

src/PrizeDistributor.ts:38


contractMetadataList

Readonly contractMetadataList: Contract[]

Defined in

src/PrizeDistributor.ts:36


drawBufferContract

drawBufferContract: Contract

Defined in

src/PrizeDistributor.ts:53


drawBufferMetadata

drawBufferMetadata: Contract

Defined in

src/PrizeDistributor.ts:45


drawCalculatorContract

drawCalculatorContract: Contract

Defined in

src/PrizeDistributor.ts:52


drawCalculatorMetadata

drawCalculatorMetadata: Contract

Defined in

src/PrizeDistributor.ts:44


drawCalculatorTimelockContract

Readonly drawCalculatorTimelockContract: Contract

Defined in

src/PrizeDistributor.ts:51


drawCalculatorTimelockMetadata

Readonly drawCalculatorTimelockMetadata: Contract

Defined in

src/PrizeDistributor.ts:43


prizeDistributionsBufferContract

prizeDistributionsBufferContract: Contract

Defined in

src/PrizeDistributor.ts:54


prizeDistributionsBufferMetadata

prizeDistributionsBufferMetadata: Contract

Defined in

src/PrizeDistributor.ts:46


prizeDistributorContract

Readonly prizeDistributorContract: Contract

Defined in

src/PrizeDistributor.ts:50


prizeDistributorMetadata

Readonly prizeDistributorMetadata: Contract

Defined in

src/PrizeDistributor.ts:42


signerOrProvider

Readonly signerOrProvider: Signer | Provider

Defined in

src/PrizeDistributor.ts:37


tokenContract

tokenContract: Contract

Defined in

src/PrizeDistributor.ts:55


tokenMetadata

tokenMetadata: Contract

Defined in

src/PrizeDistributor.ts:47

Methods

claimPrizesAcrossMultipleDrawsByDrawResults

claimPrizesAcrossMultipleDrawsByDrawResults(drawResults, overrides?): Promise<TransactionResponse>

Submits a transaction to claim a users prizes across multiple draws PrizeDistributor must be initialized with a Signer.

Parameters

NameTypeDescription
drawResultsObjectan object of the users draw results to claim keyed by draw ids
overrides?Overridesoptional overrides for the transaction creation

Returns

Promise<TransactionResponse>

the transaction response

Defined in

src/PrizeDistributor.ts:185


claimPrizesByDraw

claimPrizesByDraw(drawId, maxPicksPerUser, overrides?): Promise<TransactionResponse>

Fetches a users prizes for the provided draw and submits a transaction to claim them to the Signer. PrizeDistributor must be initialized with a Signer.

Parameters

NameTypeDescription
drawIdnumberthe draw id to claim prizes for
maxPicksPerUsernumberthe maximum picks per user from the PrizeDistribution for the provided draw id
overrides?Overridesoptional overrides for the transaction creation

Returns

Promise<TransactionResponse>

the transaction response

Defined in

src/PrizeDistributor.ts:126


claimPrizesByDrawResults

claimPrizesByDrawResults(drawResults, overrides?): Promise<TransactionResponse>

Submits a transaction to claim a users prizes PrizeDistributor must be initialized with a Signer.

Parameters

NameTypeDescription
drawResultsDrawResultsthe prize results for a user for a specific draw
overrides?Overridesoptional overrides for the transaction creation

Returns

Promise<TransactionResponse>

the transaction response

Defined in

src/PrizeDistributor.ts:149


getAndSetEthersContract

Private getAndSetEthersContract(key, contractType, getContractAddress): Promise<Contract>

Fetches a contract address, finds the relevant metadata in the ContractList and creates an ethers Contract for that contract. The ethers Contract is cached on the instance of the PrizeDistributor and is returned immediately if already stored.

Parameters

NameTypeDescription
keystringthe key for the requested contract to be stored on the PrizeDistributor
contractTypeContractTypethe contract name
getContractAddress() => Promise<string>a function to fetch the contract address

Returns

Promise<Contract>

an ethers Contract for the provided address and contract type

Defined in

src/PrizeDistributor.ts:720


getDraw

getDraw(drawId): Promise<Draw>

Fetches a Draw from the DrawBuffer.

Parameters

NameTypeDescription
drawIdnumberthe draw id of the Draw to fetch

Returns

Promise<Draw>

the Draw

Defined in

src/PrizeDistributor.ts:494


getDrawBufferContract

getDrawBufferContract(): Promise<Contract>

Fetches the address of the DrawBuffer and caches the ethers Contract for the DrawBuffer.

Returns

Promise<Contract>

an ethers Contract for the DrawBuffer related to this PrizeDistributor

Defined in

src/PrizeDistributor.ts:772


getDrawCalculatorContract

getDrawCalculatorContract(): Promise<Contract>

Fetches the address of the DrawCalculator and caches the ethers Contract for the DrawCalculator

Returns

Promise<Contract>

an ethers Contract for the DrawCalculator related to this PrizeDistributor

Defined in

src/PrizeDistributor.ts:749


getDrawIdsFromDrawBuffer

getDrawIdsFromDrawBuffer(): Promise<number[]>

Fetches the range of draw ids that are available in the DrawBuffer.

Returns

Promise<number[]>

a list of draw ids in the buffer

Defined in

src/PrizeDistributor.ts:355


getDrawIdsFromPrizeDistributionBuffer

getDrawIdsFromPrizeDistributionBuffer(): Promise<number[]>

Fetches the range of draw ids for the prize distributions that are available in the PrizeDistributionBuffer.

Returns

Promise<number[]>

a list of draw ids in the buffer

Defined in

src/PrizeDistributor.ts:380


getDraws

getDraws(drawIds): Promise<{ [drawId: number]: Draw; }>

Fetches multiple Draws from the DrawBuffer.

Parameters

NameTypeDescription
drawIdsnumber[]a list of draw ids to fetch

Returns

Promise<{ [drawId: number]: Draw; }>

an object with Draws keyed by their draw ids

Defined in

src/PrizeDistributor.ts:511


getDrawsAndPrizeDistributions

getDrawsAndPrizeDistributions(drawIds): Promise<{ [drawId: number]: { draw: Draw ; prizeDistribution: PrizeDistribution }; }>

Fetches Draws and PrizeDistributions from their respective buffers for the provided list of draw ids.

Parameters

NameTypeDescription
drawIdsnumber[]the list of draw ids to fetch Draws and PrizeDistributions for

Returns

Promise<{ [drawId: number]: { draw: Draw ; prizeDistribution: PrizeDistribution }; }>

an object full of Draws and PrizeDistributions keyed by their draw id

Defined in

src/PrizeDistributor.ts:459


getNewestDraw

getNewestDraw(): Promise<Draw>

Fetches the newest Draw in the DrawBuffer related to the PrizeDistributor. NOTE: Will throw an error if the buffer is empty.

Returns

Promise<Draw>

the newest draw in the draw buffer

Defined in

src/PrizeDistributor.ts:250


getNewestPrizeDistribution

getNewestPrizeDistribution(): Promise<{ drawId: number ; prizeDistribution: PrizeDistribution }>

Fetches the newest PrizeDistribution in the PrizeDistributionBuffer related to the PrizeDistributor. NOTE: Will throw an error if the buffer is empty.

Returns

Promise<{ drawId: number ; prizeDistribution: PrizeDistribution }>

the newest prize distribution in the prize distribution buffer

Defined in

src/PrizeDistributor.ts:285


getOldestDraw

getOldestDraw(): Promise<Draw>

Fetches the oldest Draw in the DrawBuffer related to the PrizeDistributor.

Returns

Promise<Draw>

the oldest draw in the draw buffer

Defined in

src/PrizeDistributor.ts:267


getOldestPrizeDistribution

getOldestPrizeDistribution(): Promise<{ drawId: number ; prizeDistribution: PrizeDistribution }>

Fetches the oldest PrizeDistribution in the PrizeDistributionBuffer related to the PrizeDistributor.

Returns

Promise<{ drawId: number ; prizeDistribution: PrizeDistribution }>

the oldest prize distribution in the prize distribution buffer

Defined in

src/PrizeDistributor.ts:312


getPrizeDistribution

getPrizeDistribution(drawId): Promise<PrizeDistribution>

Fetches a PrizeDistribution from the PrizeDistributionBuffer.

Parameters

NameTypeDescription
drawIdnumberthe draw id for the PrizeDistribution to fetch

Returns

Promise<PrizeDistribution>

the PrizeDistribution

Defined in

src/PrizeDistributor.ts:535


getPrizeDistributions

getPrizeDistributions(drawIds): Promise<{ [drawId: number]: PrizeDistribution; }>

Fetches multiple PrizeDistributions from the PrizeDistributionBuffer.

Parameters

NameTypeDescription
drawIdsnumber[]a list of draw ids to fetch PrizeDistributions for

Returns

Promise<{ [drawId: number]: PrizeDistribution; }>

an object with PrizeDistributions keyed by draw ids

Defined in

src/PrizeDistributor.ts:558


getPrizeDistributionsBufferContract

getPrizeDistributionsBufferContract(): Promise<Contract>

Fetches the address of the PrizeDistributionsBuffer and caches the ethers Contract for the PrizeDistributionsBuffer.

Returns

Promise<Contract>

an ethers Contract for the PrizeDistributionsBuffer related to this PrizeDistributor

Defined in

src/PrizeDistributor.ts:785


getTimelockDrawId

getTimelockDrawId(): Promise<{ drawId: number ; endTimeSeconds: BigNumber }>

Fetches the id and end time stamp of the draw that is currently in the DrawCalcluatorTimelock.

Returns

Promise<{ drawId: number ; endTimeSeconds: BigNumber }>

the draw id and the end time as a unix time stamp in seconds

Defined in

src/PrizeDistributor.ts:339


getTokenContract

getTokenContract(): Promise<Contract>

Fetches the address of the Token that is distributed by this PrizeDistributor and caches the ethers Contract for the ERC20 Token.

Returns

Promise<Contract>

an ethers Contract for the ERC20 Token related to this PrizeDistributor

Defined in

src/PrizeDistributor.ts:802


getTokenData

getTokenData(): Promise<TokenData>

Fetches decimals, name and symbol for the Token that will be distributed.

Returns

Promise<TokenData>

the decimals, name and symbol for the token

Defined in

src/PrizeDistributor.ts:240


getUsersAddress

getUsersAddress(errorPrefix?): Promise<string>

Returns the users address of the provided Signer. PrizeDistributor must be initialized with a Signer.

Parameters

NameTypeDefault valueDescription
errorPrefixstring`'PrizeDistributors [getUsersAddress]'`

Returns

Promise<string>

the address of the user

Defined in

src/PrizeDistributor.ts:833


getUsersClaimedAmount

getUsersClaimedAmount(usersAddress, drawId): Promise<BigNumber>

Fetches the amount of tokens a user claimed for a draw.

Parameters

NameTypeDescription
usersAddressstringthe address of the user to check
drawIdnumberthe draw id to check

Returns

Promise<BigNumber>

the amount a user claimed

Defined in

src/PrizeDistributor.ts:589


getUsersClaimedAmounts

getUsersClaimedAmounts(usersAddress, drawIds): Promise<{ [drawId: number]: BigNumber; }>

Fetches the amount of tokens a user claimed for multiple draws.

Parameters

NameTypeDescription
usersAddressstringthe address of the user to check
drawIdsnumber[]a list of draw ids to check

Returns

Promise<{ [drawId: number]: BigNumber; }>

an object of claimed amounts keyed by the draw ids

Defined in

src/PrizeDistributor.ts:606


getUsersDrawResultsForDrawId

getUsersDrawResultsForDrawId(usersAddress, drawId, maxPicksPerUser): Promise<DrawResults>

Fetches the claimable prizes a user won for a specific Draw.

Parameters

NameTypeDescription
usersAddressstringthe users address to fetch prizes for
drawIdnumberthe draw id to fetch prizes for
maxPicksPerUsernumberthe maximum number of picks per user from the matching prize distribution

Returns

Promise<DrawResults>

the results for user for the provided draw

Defined in

src/PrizeDistributor.ts:649


getUsersDrawResultsForDrawIds

getUsersDrawResultsForDrawIds(usersAddress, drawIds, maxPicksPerUserPerDraw): Promise<{ [drawId: number]: DrawResults; }>

Fetches the claimable prizes a user won for multiple Draws.

Parameters

NameTypeDescription
usersAddressstringthe users address to fetch prizes for
drawIdsnumber[]the draw ids to fetch prizes for
maxPicksPerUserPerDrawnumber[]the maximum number of picks per user from the matching prize distribution for each draw

Returns

Promise<{ [drawId: number]: DrawResults; }>

the results for user for the provided draw

Defined in

src/PrizeDistributor.ts:670


getUsersNormalizedBalancesForDrawIds

getUsersNormalizedBalancesForDrawIds(usersAddress, drawIds): Promise<{ [drawId: number]: BigNumber; }>

Fetches a users normalized balance for several draw ids.

Parameters

NameTypeDescription
usersAddressstringthe address of a user to fetch normalized balances for
drawIdsnumber[]a list of draw ids to fetch normalized balances for

Returns

Promise<{ [drawId: number]: BigNumber; }>

an object of normalized balances keyed by draw ids

Defined in

src/PrizeDistributor.ts:627


getValidDrawIds

getValidDrawIds(): Promise<number[]>

Gets the list of draw ids of draws that have are available in both the DrawBuffer and PrizeDistributionBuffer.

Returns

Promise<number[]>

a list of draw ids in both buffers

Defined in

src/PrizeDistributor.ts:411


id

id(): string

Returns a unique id string for this PrizeDistributor.

Returns

string

a unique id for the PrizeDistributor

Defined in

src/PrizeDistributor.ts:112


validateIsSigner

validateIsSigner(errorPrefix): Promise<void>

Validates that the data provided for providerOrSigner is a Signer.

Parameters

NameTypeDescription
errorPrefixstringthe class and function name of where the error occurred

Returns

Promise<void>

Defined in

src/PrizeDistributor.ts:852


validateSignerNetwork

validateSignerNetwork(errorPrefix): Promise<void>

Validates that a Signer is on the network the PrizeDistributor is deployed on.

Parameters

NameTypeDescription
errorPrefixstringthe class and function name of where the error occurred

Returns

Promise<void>

Defined in

src/PrizeDistributor.ts:844