Skip to content

Commit 68f14c3

Browse files
committed
Fix contract
1 parent 9d50f8a commit 68f14c3

34 files changed

+9876
-639
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.2",
3+
"version": "0.0.3",
44
"description": "",
55
"main": "dist/cjs/index.js",
66
"module": "dist/esm/index.js",

src/DropKit.ts

Lines changed: 13 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,21 @@
1+
import detectEthereumProvider from '@metamask/detect-provider'
12
import axios from 'axios'
23
import { ethers } from 'ethers'
34
import {
45
ADDRESS_CHECK_ENDPOINT,
56
ADDRESS_CHECK_ENDPOINT_DEV,
67
} from './config/endpoint'
7-
import DropKitCollectionABI from './contracts/DropKitCollection.json'
8-
import detectEthereumProvider from '@metamask/detect-provider'
8+
import {
9+
DropKitCollection,
10+
// eslint-disable-next-line camelcase
11+
DropKitCollection__factory,
12+
} from './typechain-types'
913

1014
export default class DropKit {
1115
apiKey: string
1216
dev?: boolean
1317
address: string
14-
contract: ethers.Contract | null
18+
contract: DropKitCollection | null
1519

1620
constructor(key: string, isDev?: boolean) {
1721
if (!key) {
@@ -51,13 +55,7 @@ export default class DropKit {
5155

5256
const provider = new ethers.providers.Web3Provider(ethereum)
5357

54-
const contract = new ethers.Contract(
55-
data.address,
56-
DropKitCollectionABI.abi,
57-
provider.getSigner()
58-
)
59-
60-
this.contract = contract
58+
this.contract = DropKitCollection__factory.connect(data.address, provider)
6159
}
6260

6361
return data.address
@@ -74,7 +72,7 @@ export default class DropKit {
7472
throw new Error('Initialization failed')
7573
}
7674

77-
const dropPrice = await this.contract?.price()
75+
const dropPrice = await this.contract.price()
7876
return Number(ethers.utils.formatEther(dropPrice))
7977
}
8078

@@ -83,7 +81,7 @@ export default class DropKit {
8381
throw new Error('Initialization failed')
8482
}
8583

86-
const maxMint = await await this.contract?.maxPerMint()
84+
const maxMint = await this.contract.maxPerMint()
8785
return maxMint.toNumber()
8886
}
8987

@@ -92,24 +90,16 @@ export default class DropKit {
9290
throw new Error('Initialization failed')
9391
}
9492

95-
const maxWallet = await await this.contract?.maxPerWallet()
93+
const maxWallet = await this.contract.maxPerWallet()
9694
return maxWallet.toNumber()
9795
}
9896

99-
async started(): Promise<boolean> {
100-
if (!this.contract) {
101-
throw new Error('Initialization failed')
102-
}
103-
104-
return await this.contract?.started()
105-
}
106-
10797
async totalSupply(): Promise<number> {
10898
if (!this.contract) {
10999
throw new Error('Initialization failed')
110100
}
111101

112-
const mintedNfts = await this.contract?.totalSupply()
102+
const mintedNfts = await this.contract.totalSupply()
113103
return mintedNfts.toNumber()
114104
}
115105

@@ -120,7 +110,7 @@ export default class DropKit {
120110

121111
const price = await this.price()
122112

123-
const results = await this.contract?.mint(quantity, {
113+
const results = await this.contract.mint(quantity, {
124114
value: ethers.utils.parseEther(price.toString()).mul(quantity),
125115
})
126116
await results.wait()

0 commit comments

Comments
 (0)