This commit is contained in:
aozhiwei 2023-07-15 15:48:39 +08:00
parent f8e3ee9bde
commit d8a6c34364

View File

@ -1,5 +1,8 @@
const log = require('j7/log');
const utils = require('j7/utils');
const bcutils = require('j7/bcutils');
const bcconst = require('common/bcconst');
const constant = require('common/constant');
const BaseEventProcess = require('../common/BaseEventProcess');
class Transfer extends BaseEventProcess {
@ -16,6 +19,38 @@ class Transfer extends BaseEventProcess {
await this.markOk();
}
async mint(from, to, tokenId) {
const logHead = this.genLogHead(' mint ');
const nowTime = utils.getUtcTime();
const fieldList = [
['token_id', tokenId],
['token_type', bcconst.BC_NFT_CLAIM_BOX],
['item_id', constant.GACHA_ITEM_ID],
['owner_address', bcutils.toNormalAddress(to)],
['creator_address', bcutils.toNormalAddress(to)],
['confirm_block_number', this.getBlockNumber()],
['net_id', this.getNetId()],
['contract_address', this.getContractAddress()],
['createtime', nowTime],
['modifytime', nowTime],
];
const {err} = await this.bcNftDbConn(
'upsert',
't_nft',
[
['token_id', tokenId],
['net_id', this.getNetId()],
['contract_address', this.getContractAddress()],
],
[
],
fieldList
);
if (err) {
this.throwError('mintNft ' + err);
}
}
}
module.exports = Transfer;