Skip to content

Commit

Permalink
Merge pull request #14 from niftykit-inc/feature/maxAmount
Browse files Browse the repository at this point in the history
Add maxAmount
  • Loading branch information
jcurbelo authored Mar 4, 2022
2 parents 5f13bdb + cf76827 commit fa0ead9
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "dropkit.js",
"version": "0.0.12",
"version": "0.0.13",
"description": "NiftyKit.js SDK",
"main": "dist/cjs/index.js",
"module": "dist/esm/index.js",
Expand Down
13 changes: 13 additions & 0 deletions src/DropKit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ export default class DropKit {
contract: Contract = {} as Contract
walletAddress?: string
version: number
maxSupply?: number
provider: Web3Provider = {} as Web3Provider
signer: JsonRpcSigner = {} as JsonRpcSigner
ethInstance: any
Expand All @@ -55,6 +56,7 @@ export default class DropKit {
this.dev = isDev
this.address = ''
this.version = 0
this.maxSupply = 0
}

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

const web3Modal = new Web3Modal({
Expand Down Expand Up @@ -139,6 +142,16 @@ export default class DropKit {
return dropPrice
}

async maxAmount(): Promise<number> {
if (this.version <= 3) {
return this.maxSupply || 0
}

const dropMaxAmount = await this.contract.maxAmount()

return dropMaxAmount.toNumber()
}

async maxPerMint(): Promise<number> {
const maxMint: BigNumber =
this.version <= 3
Expand Down
1 change: 1 addition & 0 deletions src/types/api-responses.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ export type DropApiResponse = {
version: number
chainId: number
networkName: string
maxAmount?: number
}

export type ErrorApiResponse = {
Expand Down

0 comments on commit fa0ead9

Please sign in to comment.