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,14 +16,17 @@ class Transfer extends BaseEventProcess {
if (bcutils.isSysAddress(from)) { if (bcutils.isSysAddress(from)) {
const airDropMeta = metaFactory.getAirDrop(tokenId); const airDropMeta = metaFactory.getAirDrop(tokenId);
if (airDropMeta) { if (airDropMeta) {
await this.mint721Nft( const exists = await this.exists721Nft(tokenId, this.getContractAddress());
to, if (!exists) {
tokenId, await this.mint721Nft(
airDropMeta['item_id'], to,
bcconst.BC_NFT_HERO, tokenId,
this.getContractAddress(), airDropMeta['item_id'],
this.getBlockNumber() bcconst.BC_NFT_HERO,
); this.getContractAddress(),
this.getBlockNumber()
);
}
await this.apiMint(airDropMeta); 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, async mint721Nft(address, tokenId, itemId, tokenType,
contractAddress, blockNumber) { contractAddress, blockNumber) {
const logHead = this.genLogHead(' mint721Nft '); const logHead = this.genLogHead(' mint721Nft ');