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

make minter optional in Pricer.getPrice #15

Merged
merged 1 commit into from
Apr 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions contracts/DropTypes.cdc
Original file line number Diff line number Diff line change
Expand Up @@ -146,8 +146,8 @@ pub contract DropTypes {
self.remainingForAddress = nil
}

if minter != nil && paymentIdentifier != nil && minter != nil {

Choose a reason for hiding this comment

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

Without this script it's breaking because minter will be nil

let price = d.pricer.getPrice(num: quantity!, paymentTokenType: CompositeType(paymentIdentifier!)!, minter: minter!)
if paymentIdentifier != nil && quantity != nil {
let price = d.pricer.getPrice(num: quantity!, paymentTokenType: CompositeType(paymentIdentifier!)!, minter: minter)

self.quote = Quote(price: price, quantity: quantity!, paymentIdentifier: paymentIdentifier!, minter: minter!)
} else {
Expand Down
2 changes: 1 addition & 1 deletion contracts/FlowtyDrops.cdc
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ pub contract FlowtyDrops {
}

pub struct interface Pricer {
pub fun getPrice(num: Int, paymentTokenType: Type, minter: Address): UFix64
pub fun getPrice(num: Int, paymentTokenType: Type, minter: Address?): UFix64
pub fun getPaymentTypes(): [Type]
}

Expand Down
4 changes: 2 additions & 2 deletions contracts/FlowtyPricers.cdc
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ pub contract FlowtyPricers {
pub var price: UFix64
pub let paymentTokenType: Type

pub fun getPrice(num: Int, paymentTokenType: Type, minter: Address): UFix64 {
pub fun getPrice(num: Int, paymentTokenType: Type, minter: Address?): UFix64 {
return self.price * UFix64(num)
}

Expand All @@ -37,7 +37,7 @@ pub contract FlowtyPricers {
The Free Pricer can be used for a free mint, it has no price and always marks its payment type as @FlowToken.Vault
*/
pub struct Free: FlowtyDrops.Pricer {
pub fun getPrice(num: Int, paymentTokenType: Type, minter: Address): UFix64 {
pub fun getPrice(num: Int, paymentTokenType: Type, minter: Address?): UFix64 {
return 0.0
}

Expand Down
Loading