Skip to content

Commit

Permalink
add getting method to resolve the max number of mints per transaction (
Browse files Browse the repository at this point in the history
  • Loading branch information
austinkline authored Sep 9, 2024
1 parent 25791dd commit 7a021d3
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 1 deletion.
3 changes: 3 additions & 0 deletions contracts/DropTypes.cdc
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ access(all) contract DropTypes {

access(all) let address: Address?
access(all) let remainingForAddress: Int?
access(all) let maxPerMint: Int?

access(all) let quote: Quote?

Expand Down Expand Up @@ -150,6 +151,8 @@ access(all) contract DropTypes {
self.remainingForAddress = nil
}

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

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

Expand Down
8 changes: 8 additions & 0 deletions contracts/FlowtyAddressVerifiers.cdc
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ access(all) contract FlowtyAddressVerifiers {
return num <= self.maxPerMint
}

access(all) view fun getMaxPerMint(addr: Address?, totalMinted: Int, data: {String: AnyStruct}): Int? {
return self.maxPerMint
}

access(Mutate) fun setMaxPerMint(_ value: Int) {
self.maxPerMint = value
}
Expand Down Expand Up @@ -49,6 +53,10 @@ access(all) contract FlowtyAddressVerifiers {
return nil
}

access(all) view fun getMaxPerMint(addr: Address?, totalMinted: Int, data: {String: AnyStruct}): Int? {
return addr != nil ? self.remainingForAddress(addr: addr!, totalMinted: totalMinted) : nil
}

access(Mutate) fun setAddress(addr: Address, value: Int) {
self.allowedAddresses[addr] = value
}
Expand Down
4 changes: 4 additions & 0 deletions contracts/FlowtyDrops.cdc
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,10 @@ access(all) contract FlowtyDrops {
access(all) fun remainingForAddress(addr: Address, totalMinted: Int): Int? {
return nil
}

access(all) view fun getMaxPerMint(addr: Address?, totalMinted: Int, data: {String: AnyStruct}): Int? {
return nil
}
}

access(all) struct interface Pricer {
Expand Down
2 changes: 1 addition & 1 deletion flow.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
}
},
"droptypes-testnet": {
"address": "0xa061e5b10252955d",
"address": "0x22f23883bf122007",
"key": {
"type": "google-kms",
"index": 0,
Expand Down

0 comments on commit 7a021d3

Please sign in to comment.