diff --git a/contracts/Raffles.cdc b/contracts/Raffles.cdc index f1b9765..39183e4 100644 --- a/contracts/Raffles.cdc +++ b/contracts/Raffles.cdc @@ -57,12 +57,10 @@ pub contract Raffles { init( source: @{RaffleSource}, - start: UInt64?, - end: UInt64, - display: MetadataViews.Display + details: Details ) { self.source <- source - self.details = Details(start, end, display) + self.details = details } destroy() { @@ -134,6 +132,19 @@ pub contract Raffles { return <- create Manager() } + pub fun createRaffle(source: @{RaffleSource}, details: Details): @Raffle { + return <- create Raffle(source: <- source, details: details) + } + + pub fun createRaffleSource(_ type: Type): @{RaffleSource} { + switch type { + case Type<@AddressRaffleSource>(): + return <- create AddressRaffleSource() + } + + panic("raffle source type ".concat(type.identifier).concat(" is not valid")) + } + init() { let identifier = "Raffle_".concat(self.account.address.toString()) self.ManagerStoragePath = StoragePath(identifier: identifier)!