Skip to content

Commit 36096b8

Browse files
committed
Removed null check operator (?) from contract methods
1 parent 1aba0c7 commit 36096b8

File tree

1 file changed

+19
-16
lines changed

1 file changed

+19
-16
lines changed

src/DropKit.ts

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,11 @@ import DropKitCollectionABI from './contracts/DropKitCollection.json'
1313
import DropKitCollectionV2ABI from './contracts/DropKitCollectionV2.json'
1414
import DropKitCollectionV3ABI from './contracts/DropKitCollectionV3.json'
1515
import { handleError } from './errors/utils'
16-
import { DropApiResponse, ErrorApiResponse, ProofApiResponse } from './types/api-responses'
16+
import {
17+
DropApiResponse,
18+
ErrorApiResponse,
19+
ProofApiResponse,
20+
} from './types/api-responses'
1721

1822
const abis: Record<number, any> = {
1923
2: DropKitCollectionABI.abi,
@@ -26,7 +30,7 @@ export default class DropKit {
2630
dev?: boolean
2731
address: string
2832
collectionId?: string
29-
contract: Contract | null
33+
contract: Contract = {} as Contract
3034
walletAddress?: string
3135
version: number
3236

@@ -42,7 +46,6 @@ export default class DropKit {
4246
this.apiKey = key
4347
this.dev = isDev
4448
this.address = ''
45-
this.contract = null
4649
this.version = 0
4750
}
4851

@@ -113,48 +116,48 @@ export default class DropKit {
113116
async price(): Promise<BigNumber> {
114117
const dropPrice: BigNumber =
115118
this.version <= 3
116-
? await this.contract?._price()
117-
: await this.contract?.price()
119+
? await this.contract._price()
120+
: await this.contract.price()
118121

119122
return dropPrice
120123
}
121124

122125
async maxPerMint(): Promise<number> {
123126
const maxMint: BigNumber =
124127
this.version <= 3
125-
? await this.contract?._maxPerMint()
126-
: await this.contract?.maxPerMint()
128+
? await this.contract._maxPerMint()
129+
: await this.contract.maxPerMint()
127130

128131
return maxMint.toNumber()
129132
}
130133

131134
async maxPerWallet(): Promise<number> {
132135
const maxWallet: BigNumber =
133136
this.version <= 3
134-
? await this.contract?._maxPerWallet()
135-
: await this.contract?.maxPerWallet()
137+
? await this.contract._maxPerWallet()
138+
: await this.contract.maxPerWallet()
136139

137140
return maxWallet.toNumber()
138141
}
139142

140143
async walletTokensCount(): Promise<number> {
141-
const balanceOf: BigNumber = await this.contract?.balanceOf(
144+
const balanceOf: BigNumber = await this.contract.balanceOf(
142145
this.walletAddress
143146
)
144147

145148
return balanceOf.toNumber()
146149
}
147150

148151
async totalSupply(): Promise<number> {
149-
const mintedNfts: BigNumber = await this.contract?.totalSupply()
152+
const mintedNfts: BigNumber = await this.contract.totalSupply()
150153
return mintedNfts.toNumber()
151154
}
152155

153156
async saleActive(): Promise<boolean> {
154157
const saleActive: boolean =
155158
this.version <= 3
156-
? await this.contract?.started()
157-
: await this.contract?.saleActive()
159+
? await this.contract.started()
160+
: await this.contract.saleActive()
158161

159162
return saleActive
160163
}
@@ -171,7 +174,7 @@ export default class DropKit {
171174
return !(await this.saleActive())
172175
}
173176

174-
return await this.contract?.presaleActive()
177+
return await this.contract.presaleActive()
175178
}
176179

177180
async generateProof(): Promise<ProofApiResponse & ErrorApiResponse> {
@@ -231,7 +234,7 @@ export default class DropKit {
231234
quantity: number,
232235
amount: BigNumber
233236
): Promise<ContractReceipt> {
234-
const trx: ContractTransaction = await this.contract?.mint(quantity, {
237+
const trx: ContractTransaction = await this.contract.mint(quantity, {
235238
value: amount,
236239
})
237240

@@ -253,7 +256,7 @@ export default class DropKit {
253256
throw new Error('Your wallet is not part of presale.')
254257
}
255258

256-
const trx: ContractTransaction = await this.contract?.presaleMint(
259+
const trx: ContractTransaction = await this.contract.presaleMint(
257260
quantity,
258261
data.proof,
259262
{

0 commit comments

Comments
 (0)