From 3d4bbc0fbedcaba1411dbf9ef45ec668bc72c51e Mon Sep 17 00:00:00 2001 From: Austin Kline Date: Thu, 25 Apr 2024 07:56:58 -0700 Subject: [PATCH] make minter optional in Pricer.getPrice (#15) --- contracts/DropTypes.cdc | 4 ++-- contracts/FlowtyDrops.cdc | 2 +- contracts/FlowtyPricers.cdc | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/contracts/DropTypes.cdc b/contracts/DropTypes.cdc index 3858729..a01f50f 100644 --- a/contracts/DropTypes.cdc +++ b/contracts/DropTypes.cdc @@ -146,8 +146,8 @@ pub contract DropTypes { self.remainingForAddress = nil } - if minter != nil && paymentIdentifier != nil && minter != 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 { diff --git a/contracts/FlowtyDrops.cdc b/contracts/FlowtyDrops.cdc index 7b99773..c3bc1c1 100644 --- a/contracts/FlowtyDrops.cdc +++ b/contracts/FlowtyDrops.cdc @@ -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] } diff --git a/contracts/FlowtyPricers.cdc b/contracts/FlowtyPricers.cdc index 7229275..08cdfc4 100644 --- a/contracts/FlowtyPricers.cdc +++ b/contracts/FlowtyPricers.cdc @@ -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) } @@ -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 }