Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Felipe tests 2 #3

Closed
wants to merge 1 commit into from
Closed

Felipe tests 2 #3

wants to merge 1 commit into from

Conversation

FelipeRibeiroLabs
Copy link
Collaborator

No description provided.

Copy link
Collaborator

@austinkline austinkline left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like there's some confusion for what the goal is to abstracting away the source of a raffle into its own resource. I'll make a PR that fills in some of these details to help, but the TL;DR to some of this is that a raffle cannot have any knowledge about the kind of raffle it is, and so we cannot include anything that makes assumptions about it

Comment on lines +39 to +42
pub fun getAddressSource(): &AddressRaffleSource {
let source = &self.source as auth &{RaffleSource}
return source as! &AddressRaffleSource
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This cannot be added here, unfortunately. The Raffle itself should have no knowledge of the "source" it is using

What we likely have to do is permit returning an auth reference source to the owner of the raffle so that they can cast it to the original type at will

Comment on lines +48 to +51
pub fun getAddresses(): [Address] {
return self.getAddressSource().getAddresses()
}

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same with this, unfortunately can't be included

Comment on lines +127 to +129
pub fun getRaffleAddresses(id: UInt64): [Address] {
return (&self.raffles[id] as &Raffle?)!.getAddresses()
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Generally with method like this, they should exist in the underlying resource you are calling, and a borrow method should be used to get to it (borrowRafflePublic in this case)

Comment on lines +163 to +173
pub fun draw(id: UInt64) {
let raffle: &Raffles.Raffle? = &self.raffles[id] as &Raffle?
if raffle == nil {
panic("raffle with id ".concat(id.toString()).concat(" does not exist"))
}

let index = raffle!.draw()
let value = raffle!.getEntryAt(index: index)

Raffles.emitDrawing(address: self.owner!.address, raffleID: id, sourceType: raffle!.getSourceType() ,index: index, value: value)
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here on borrowing, the Raffle resource itself can encapsulate this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants