diff --git a/src/chain/ERC721Reactor.ts b/src/chain/ERC721Reactor.ts index 9e146bd..c83e0ef 100644 --- a/src/chain/ERC721Reactor.ts +++ b/src/chain/ERC721Reactor.ts @@ -9,7 +9,7 @@ export const ERC721_INTERFACE_ID = '0x80ac58cd' export const ERC721_METADATA_INTERFACE_ID = '0x5b5e139f' export const ERC721_ENUMERABLE_INTERFACE_ID = '0x780e9d63' -const ablNft = require('abis/BEBadge.json').abi +const abiNft = require('abis/BEBadge.json').abi export class ERC721Reactor { private web3: Web3 @@ -19,7 +19,7 @@ export class ERC721Reactor { constructor({ web3, address }: { web3: Web3; address: string }) { this.web3 = web3 this.account = this.web3.eth.accounts.wallet[0] - this.contract = new this.web3.eth.Contract(ablNft, address, { from: this.account.address }) + this.contract = new this.web3.eth.Contract(abiNft, address, { from: this.account.address }) } /** @@ -70,7 +70,7 @@ export class ERC721Reactor { index: number }): Promise => { const contract = address - ? new this.web3.eth.Contract(ablNft, address, { from: this.account.address }) + ? new this.web3.eth.Contract(abiNft, address, { from: this.account.address }) : this.contract return new Promise((resolve, reject) => { contract.methods.tokenOfOwnerByIndex(selectedAddress, index).call((error: Error, result: string) => { @@ -86,7 +86,7 @@ export class ERC721Reactor { getBalance = async ({ address, selectedAddress }: { address?: string; selectedAddress: string }): Promise => { const contract = address - ? new this.web3.eth.Contract(ablNft, address, { from: this.account.address }) + ? new this.web3.eth.Contract(abiNft, address, { from: this.account.address }) : this.contract return new Promise((resolve, reject) => { contract.methods.balanceOf(selectedAddress).call((error: Error, result: number) => { @@ -109,7 +109,7 @@ export class ERC721Reactor { */ getTokenURI = async ({ address, tokenId }: { address?: string; tokenId: string }): Promise => { const contract = address - ? new this.web3.eth.Contract(ablNft, address, { from: this.account.address }) + ? new this.web3.eth.Contract(abiNft, address, { from: this.account.address }) : this.contract const supportsMetadata = await this.contractSupportsMetadataInterface(address) if (!supportsMetadata) { @@ -135,7 +135,7 @@ export class ERC721Reactor { */ getAssetName = async (address?: string): Promise => { const contract = address - ? new this.web3.eth.Contract(ablNft, address, { from: this.account.address }) + ? new this.web3.eth.Contract(abiNft, address, { from: this.account.address }) : this.contract return new Promise((resolve, reject) => { contract.methods.name().call((error: Error, result: string) => { @@ -157,7 +157,7 @@ export class ERC721Reactor { */ getAssetSymbol = async (address?: string): Promise => { const contract = address - ? new this.web3.eth.Contract(ablNft, address, { from: this.account.address }) + ? new this.web3.eth.Contract(abiNft, address, { from: this.account.address }) : this.contract return new Promise((resolve, reject) => { contract.methods.symbol().call((error: Error, result: string) => { @@ -180,7 +180,7 @@ export class ERC721Reactor { */ async getOwnerOf({ address, tokenId }: { address?: string; tokenId: string }): Promise { const contract = address - ? new this.web3.eth.Contract(ablNft, address, { from: this.account.address }) + ? new this.web3.eth.Contract(abiNft, address, { from: this.account.address }) : this.contract return new Promise((resolve, reject) => { contract.methods.ownerOf(tokenId).call((error: Error, result: string) => { @@ -209,7 +209,7 @@ export class ERC721Reactor { interfaceId: string }): Promise => { const contract = address - ? new this.web3.eth.Contract(ablNft, address, { from: this.account.address }) + ? new this.web3.eth.Contract(abiNft, address, { from: this.account.address }) : this.contract return new Promise((resolve, reject) => { contract.methods.supportsInterface(interfaceId).call((error: Error, result: boolean) => { @@ -309,7 +309,7 @@ export class ERC721Reactor { gas?: number }) { const contract = address - ? new this.web3.eth.Contract(ablNft, address, { from: account || this.account.address }) + ? new this.web3.eth.Contract(abiNft, address, { from: account || this.account.address }) : this.contract return contract.methods.safeTransferFrom(from, to, tokenId).send({ from, @@ -317,12 +317,12 @@ export class ERC721Reactor { }) } - async mint({ address, to, tokenId, configId }: { address?: string; to: string; tokenId: string; configId: string }) { + async mint({ address, to, tokenId }: { address?: string; to: string; tokenId: string }) { const contract = address - ? new this.web3.eth.Contract(ablNft, address, { from: this.account.address }) + ? new this.web3.eth.Contract(abiNft, address, { from: this.account.address }) : this.contract - let gas = await contract.methods.mint(to, tokenId, configId).estimateGas({ gas: 1000000 }) - return contract.methods.mint(to, tokenId, configId).send({ gas: (gas * 1.1) | 0 }) + let gas = await contract.methods.mint(to, tokenId).estimateGas({ gas: 1000000 }) + return contract.methods.mint(to, tokenId).send({ gas: (gas * 1.1) | 0 }) } async batchMint({ @@ -330,44 +330,22 @@ export class ERC721Reactor { address, to, tokenIds, - configIds, }: { account?: string address?: string to: string tokenIds: string[] - configIds: string[] }) { const contract = address - ? new this.web3.eth.Contract(ablNft, address, { from: account || this.account.address }) + ? new this.web3.eth.Contract(abiNft, address, { from: account || this.account.address }) : this.contract // let gas = await contract.methods.batchMint(to, tokenIds, configIds).estimateGas({ gas: 1000000 }) - return contract.methods.batchMint(to, tokenIds, configIds).send({ gas: 1000000 }) - } - - async mintOne({ - account, - address, - to, - tokenId, - nftType, - }: { - account?: string - address?: string - to: string - tokenId: string - nftType: string - }) { - const contract = address - ? new this.web3.eth.Contract(ablNft, address, { from: account || this.account.address }) - : this.contract - let gas = await contract.methods.mintBox(to, tokenId, nftType).estimateGas({ gas: 1000000 }) - return contract.methods.mintBox(to, tokenId, nftType).send({ gas: 1000000 }) + return contract.methods.batchMint(to, tokenIds).send({ gas: 1000000 }) } async getPastEvents({ address, fromBlock }: { address?: string; fromBlock: number }) { const contract = address - ? new this.web3.eth.Contract(ablNft, address, { from: this.account.address }) + ? new this.web3.eth.Contract(abiNft, address, { from: this.account.address }) : this.contract return contract.getPastEvents('BatchMint', { fromBlock, diff --git a/src/models/RequestTask.ts b/src/models/RequestTask.ts index 78ee5ba..fac9ce9 100644 --- a/src/models/RequestTask.ts +++ b/src/models/RequestTask.ts @@ -96,7 +96,7 @@ export class RequestTaskClass extends BaseModule { result = await new BlockChain().erc721Reactor.transfer(self.reqData) break case TaskType.MINT_PRESALE_BOX: - result = await new BlockChain().erc721Reactor.mintOne(self.reqData) + result = await new BlockChain().erc721Reactor.mint(self.reqData) break } logger.info(result)