Skip to content

Commit fa0ead9

Browse files
authored
Merge pull request #14 from niftykit-inc/feature/maxAmount
Add maxAmount
2 parents 5f13bdb + cf76827 commit fa0ead9

File tree

3 files changed

+15
-1
lines changed

3 files changed

+15
-1
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "dropkit.js",
3-
"version": "0.0.12",
3+
"version": "0.0.13",
44
"description": "NiftyKit.js SDK",
55
"main": "dist/cjs/index.js",
66
"module": "dist/esm/index.js",

src/DropKit.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ export default class DropKit {
3636
contract: Contract = {} as Contract
3737
walletAddress?: string
3838
version: number
39+
maxSupply?: number
3940
provider: Web3Provider = {} as Web3Provider
4041
signer: JsonRpcSigner = {} as JsonRpcSigner
4142
ethInstance: any
@@ -55,6 +56,7 @@ export default class DropKit {
5556
this.dev = isDev
5657
this.address = ''
5758
this.version = 0
59+
this.maxSupply = 0
5860
}
5961

6062
async init(providerOptions: IProviderOptions): Promise<DropApiResponse> {
@@ -83,6 +85,7 @@ export default class DropKit {
8385
this.version = data.version
8486
this.networkName = data.networkName
8587
this.chainId = data.chainId
88+
this.maxSupply = data.version <= 3 ? data.maxAmount : 0
8689
const abi = abis[data.version || 1]
8790

8891
const web3Modal = new Web3Modal({
@@ -139,6 +142,16 @@ export default class DropKit {
139142
return dropPrice
140143
}
141144

145+
async maxAmount(): Promise<number> {
146+
if (this.version <= 3) {
147+
return this.maxSupply || 0
148+
}
149+
150+
const dropMaxAmount = await this.contract.maxAmount()
151+
152+
return dropMaxAmount.toNumber()
153+
}
154+
142155
async maxPerMint(): Promise<number> {
143156
const maxMint: BigNumber =
144157
this.version <= 3

src/types/api-responses.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ export type DropApiResponse = {
88
version: number
99
chainId: number
1010
networkName: string
11+
maxAmount?: number
1112
}
1213

1314
export type ErrorApiResponse = {

0 commit comments

Comments
 (0)