This commit is contained in:
aozhiwei 2023-07-22 21:14:10 +08:00
parent eb682da7ff
commit 0f4e6cc563
2 changed files with 28 additions and 8 deletions

View File

@ -16,6 +16,8 @@ class Transfer extends BaseEventProcess {
if (bcutils.isSysAddress(from)) {
const airDropMeta = metaFactory.getAirDrop(tokenId);
if (airDropMeta) {
const exists = await this.exists721Nft(tokenId, this.getContractAddress());
if (!exists) {
await this.mint721Nft(
to,
tokenId,
@ -24,6 +26,7 @@ class Transfer extends BaseEventProcess {
this.getContractAddress(),
this.getBlockNumber()
);
}
await this.apiMint(airDropMeta);
}
}

View File

@ -300,6 +300,23 @@ class BaseEventProcess {
}
}
async exists721Nft(tokenId, contractAddress) {
const logHead = this.genLogHead(' exists721Nft ');
const {err, row} = await this.bcNftDbConn(
'ormSelectOne',
't_nft',
[
['net_id', this.getNetId()],
['contract_address', contractAddress],
['token_id', tokenId],
]
);
if (err) {
this.throwError(logHead + err);
}
return row ? true : false;
}
async mint721Nft(address, tokenId, itemId, tokenType,
contractAddress, blockNumber) {
const logHead = this.genLogHead(' mint721Nft ');