Skip to content

Commit

Permalink
sync drops contracts
Browse files Browse the repository at this point in the history
  • Loading branch information
austinkline committed Sep 24, 2024
1 parent b822c81 commit 343aaf5
Show file tree
Hide file tree
Showing 6 changed files with 110 additions and 65 deletions.
4 changes: 2 additions & 2 deletions contracts/flowty-drops/DropFactory.cdc
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ access(all) contract DropFactory {


let nftType = CompositeType(nftTypeIdentifier) ?? panic("invalid nft type identifier")
let dropDetails = FlowtyDrops.DropDetails(display: dropDisplay, medias: nil, commissionRate: 0.05, nftType: nftTypeIdentifier)
let dropDetails = FlowtyDrops.DropDetails(display: dropDisplay, medias: nil, commissionRate: 0.05, nftType: nftTypeIdentifier, paymentTokenTypes: {paymentTokenType.identifier: true})
let drop <- FlowtyDrops.createDrop(details: dropDetails, minterCap: minterCap, phases: <- [<-phase])

return <- drop
Expand Down Expand Up @@ -67,7 +67,7 @@ access(all) contract DropFactory {
let phase <- FlowtyDrops.createPhase(details: phaseDetails)

let nftType = CompositeType(nftTypeIdentifier) ?? panic("invalid nft type identifier")
let dropDetails = FlowtyDrops.DropDetails(display: dropDisplay, medias: nil, commissionRate: 0.05, nftType: nftTypeIdentifier)
let dropDetails = FlowtyDrops.DropDetails(display: dropDisplay, medias: nil, commissionRate: 0.05, nftType: nftTypeIdentifier, paymentTokenTypes: {paymentTokenType.identifier: true})
let drop <- FlowtyDrops.createDrop(details: dropDetails, minterCap: minterCap, phases: <- [<-phase])

return <- drop
Expand Down
35 changes: 19 additions & 16 deletions contracts/flowty-drops/DropTypes.cdc
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ access(all) contract DropTypes {
access(all) let commissionRate: UFix64
access(all) let nftType: String
access(all) let creator: Address?
access(all) let paymentTokenTypes: {String: Bool}

access(all) let address: Address?
access(all) let mintedByAddress: Int?
Expand All @@ -58,7 +59,8 @@ access(all) contract DropTypes {
address: Address?,
phases: [PhaseSummary],
royaltyRate: UFix64,
creator: Address?
creator: Address?,
paymentTokenTypes: {String: Bool}
) {
self.id = id
self.display = Display(display)
Expand All @@ -82,6 +84,7 @@ access(all) contract DropTypes {
self.blockHeight = b.height
self.blockTimestamp = UInt64(b.timestamp)
self.royaltyRate = royaltyRate
self.paymentTokenTypes = paymentTokenTypes
}
}

Expand Down Expand Up @@ -118,7 +121,7 @@ access(all) contract DropTypes {
access(all) let remainingForAddress: Int?
access(all) let maxPerMint: Int?

access(all) let quote: Quote?
access(all) let quotes: {String: Quote}

init(
index: Int,
Expand All @@ -127,7 +130,7 @@ access(all) contract DropTypes {
totalMinted: Int?,
minter: Address?,
quantity: Int?,
paymentIdentifier: String?
paymentIdentifiers: [String]
) {
self.index = index
self.id = phase.uuid
Expand Down Expand Up @@ -155,19 +158,17 @@ access(all) contract DropTypes {
self.remainingForAddress = nil
}

self.maxPerMint = d.addressVerifier.getMaxPerMint(addr: self.address, totalMinted: totalMinted ?? 0, data: {} as {String: AnyStruct})
self.maxPerMint = d.addressVerifier.getMaxPerMint(addr: self.address, totalMinted: totalMinted ?? 0, data: {})
self.quotes = {}

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 {
self.quote = nil
for paymentIdentifier in paymentIdentifiers {
let price = d.pricer.getPrice(num: quantity!, paymentTokenType: CompositeType(paymentIdentifier)!, minter: minter)
self.quotes[paymentIdentifier] = Quote(price: price, quantity: quantity!, paymentIdentifier: paymentIdentifier, minter: minter)
}
}
}

access(all) fun getDropSummary(nftTypeIdentifier: String, dropID: UInt64, minter: Address?, quantity: Int?, paymentIdentifier: String?): DropSummary? {
access(all) fun getDropSummary(nftTypeIdentifier: String, dropID: UInt64, minter: Address?, quantity: Int?, paymentIdentifiers: [String]): DropSummary? {
let nftType = CompositeType(nftTypeIdentifier) ?? panic("invalid nft type identifier")
let segments = nftTypeIdentifier.split(separator: ".")
let contractAddress = AddressUtils.parseAddress(nftType)!
Expand Down Expand Up @@ -206,7 +207,7 @@ access(all) contract DropTypes {
totalMinted: minter != nil ? dropDetails.minters[minter!] : nil,
minter: minter,
quantity: quantity,
paymentIdentifier: paymentIdentifier
paymentIdentifiers: paymentIdentifiers.length > 0 ? paymentIdentifiers : dropDetails.paymentTokenTypes.keys
)
phaseSummaries.append(summary)
}
Expand All @@ -231,13 +232,14 @@ access(all) contract DropTypes {
address: minter,
phases: phaseSummaries,
royaltyRate: royaltyRate,
creator: creator
creator: creator,
paymentTokenTypes: dropDetails.paymentTokenTypes
)

return dropSummary
}

access(all) fun getAllDropSummaries(nftTypeIdentifier: String, minter: Address?, quantity: Int?, paymentIdentifier: String?): [DropSummary] {
access(all) fun getAllDropSummaries(nftTypeIdentifier: String, minter: Address?, quantity: Int?, paymentIdentifiers: [String]): [DropSummary] {
let nftType = CompositeType(nftTypeIdentifier) ?? panic("invalid nft type identifier")
let segments = nftTypeIdentifier.split(separator: ".")
let contractAddress = AddressUtils.parseAddress(nftType)!
Expand Down Expand Up @@ -278,7 +280,7 @@ access(all) contract DropTypes {
totalMinted: minter != nil ? dropDetails.minters[minter!] : nil,
minter: minter,
quantity: quantity,
paymentIdentifier: paymentIdentifier
paymentIdentifiers: paymentIdentifiers.length > 0 ? paymentIdentifiers : dropDetails.paymentTokenTypes.keys
)
phaseSummaries.append(summary)
}
Expand Down Expand Up @@ -307,7 +309,8 @@ access(all) contract DropTypes {
address: minter,
phases: phaseSummaries,
royaltyRate: royaltyRate,
creator: creator
creator: creator,
paymentTokenTypes: dropDetails.paymentTokenTypes
))
}

Expand Down
Loading

0 comments on commit 343aaf5

Please sign in to comment.