From 7a021d3cfe63a03ad5782f5bdc7e1f5a4ccfd154 Mon Sep 17 00:00:00 2001 From: Austin Kline Date: Mon, 9 Sep 2024 14:41:08 -0500 Subject: [PATCH] add getting method to resolve the max number of mints per transaction (#37) --- contracts/DropTypes.cdc | 3 +++ contracts/FlowtyAddressVerifiers.cdc | 8 ++++++++ contracts/FlowtyDrops.cdc | 4 ++++ flow.json | 2 +- 4 files changed, 16 insertions(+), 1 deletion(-) diff --git a/contracts/DropTypes.cdc b/contracts/DropTypes.cdc index bb15bde..09801e6 100644 --- a/contracts/DropTypes.cdc +++ b/contracts/DropTypes.cdc @@ -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? @@ -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) diff --git a/contracts/FlowtyAddressVerifiers.cdc b/contracts/FlowtyAddressVerifiers.cdc index 1fd6a3d..25760ec 100644 --- a/contracts/FlowtyAddressVerifiers.cdc +++ b/contracts/FlowtyAddressVerifiers.cdc @@ -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 } @@ -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 } diff --git a/contracts/FlowtyDrops.cdc b/contracts/FlowtyDrops.cdc index e5da834..8d4028e 100644 --- a/contracts/FlowtyDrops.cdc +++ b/contracts/FlowtyDrops.cdc @@ -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 { diff --git a/flow.json b/flow.json index 106caef..8f81d60 100644 --- a/flow.json +++ b/flow.json @@ -42,7 +42,7 @@ } }, "droptypes-testnet": { - "address": "0xa061e5b10252955d", + "address": "0x22f23883bf122007", "key": { "type": "google-kms", "index": 0,