1
This commit is contained in:
parent
9df5e6ef19
commit
40a372b75b
@ -13,6 +13,7 @@ class Transfer extends BaseEventProcess {
|
|||||||
const to = returnValues['to'];
|
const to = returnValues['to'];
|
||||||
const tokenId = returnValues['tokenId'];
|
const tokenId = returnValues['tokenId'];
|
||||||
|
|
||||||
|
await this.mustBeMint(to, tokenId, bcconst.BC_NFT_HERO);
|
||||||
if (bcutils.isSysAddress(from)) {
|
if (bcutils.isSysAddress(from)) {
|
||||||
const airDropMeta = metaFactory.getAirDrop(
|
const airDropMeta = metaFactory.getAirDrop(
|
||||||
tokenId,
|
tokenId,
|
||||||
@ -20,21 +21,11 @@ class Transfer extends BaseEventProcess {
|
|||||||
bcconst.BC_NFT_HERO,
|
bcconst.BC_NFT_HERO,
|
||||||
this.getContractAddress());
|
this.getContractAddress());
|
||||||
if (airDropMeta) {
|
if (airDropMeta) {
|
||||||
const exists = await this.exists721Nft(tokenId, this.getContractAddress());
|
|
||||||
if (!exists) {
|
|
||||||
await this.mint721Nft(
|
|
||||||
to,
|
|
||||||
tokenId,
|
|
||||||
airDropMeta['item_id'],
|
|
||||||
bcconst.BC_NFT_HERO,
|
|
||||||
this.getContractAddress(),
|
|
||||||
this.getBlockNumber()
|
|
||||||
);
|
|
||||||
}
|
|
||||||
await this.apiMint(to, tokenId, airDropMeta);
|
await this.apiMint(to, tokenId, airDropMeta);
|
||||||
|
} else {
|
||||||
|
await this.ingameActivate(tokenId, bcconst.BC_NFT_HERO);
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
|
|
||||||
await this.add721NftRefresh
|
await this.add721NftRefresh
|
||||||
(
|
(
|
||||||
this.getNetId(),
|
this.getNetId(),
|
||||||
@ -42,6 +33,7 @@ class Transfer extends BaseEventProcess {
|
|||||||
this.getContractName(),
|
this.getContractName(),
|
||||||
tokenId
|
tokenId
|
||||||
);
|
);
|
||||||
|
}
|
||||||
await this.update721NftOwner(tokenId, this.getContractAddress(), to);
|
await this.update721NftOwner(tokenId, this.getContractAddress(), to);
|
||||||
await this.markOk();
|
await this.markOk();
|
||||||
}
|
}
|
||||||
|
@ -7,6 +7,8 @@ const config = require('j7/config');
|
|||||||
const constant = require('common/constant');
|
const constant = require('common/constant');
|
||||||
const dbpool = require('common/dbpool');
|
const dbpool = require('common/dbpool');
|
||||||
const metaFactory = require('../../../metadata/factory');
|
const metaFactory = require('../../../metadata/factory');
|
||||||
|
const bchelper = require('common/bchelper');
|
||||||
|
const bcconst = require('common/bcconst');
|
||||||
|
|
||||||
let gSeqId = 1;
|
let gSeqId = 1;
|
||||||
function genSeqId() {
|
function genSeqId() {
|
||||||
@ -379,6 +381,90 @@ class BaseEventProcess {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async mustBeMint(to, tokenId, tokenType) {
|
||||||
|
const exists = await this.exists721Nft(tokenId, this.getContractAddress());
|
||||||
|
if (!exists) {
|
||||||
|
await this.mint721Nft(
|
||||||
|
to,
|
||||||
|
tokenId,
|
||||||
|
0,
|
||||||
|
tokenType,
|
||||||
|
this.getContractAddress(),
|
||||||
|
this.getBlockNumber()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async ingameActivate(tokenId, tokenType) {
|
||||||
|
const logHead = this.genLogHead(' ingameActivate ');
|
||||||
|
const tblName = bchelper.getNftTableName(tokenType);
|
||||||
|
if (!tblName) {
|
||||||
|
this.throwError(logHead + ' token_type error :' + tokenType);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (tokenType == bcconst.BC_NFT_HERO) {
|
||||||
|
await this.ingameActivateHero(tblName, tokenId, tokenType);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async ingameActivateHero(tblName, tokenId, tokenType) {
|
||||||
|
const logHead = this.genLogHead(' ingameActivateHero ');
|
||||||
|
{
|
||||||
|
const {err, row} = await this.gameDbConn(
|
||||||
|
'ormSelectOne',
|
||||||
|
tblName,
|
||||||
|
[
|
||||||
|
['active_token_id', tokenId],
|
||||||
|
]
|
||||||
|
);
|
||||||
|
if (err) {
|
||||||
|
this.throwError(logHead + err);
|
||||||
|
}
|
||||||
|
if (row) {
|
||||||
|
if (row['token_id'] == tokenId) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
await this.addLog([
|
||||||
|
['type', 'ingameActivateHero'],
|
||||||
|
['subtype', 'active_token_id.notfound'],
|
||||||
|
['net_id', this.getNetId()],
|
||||||
|
['param1', tokenId],
|
||||||
|
['createtime', nowTime],
|
||||||
|
['modifytime', nowTime],
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
const nowTime = utils.getUtcTime();
|
||||||
|
const {err} = await this.gameDbConn(
|
||||||
|
'update',
|
||||||
|
tblName,
|
||||||
|
[
|
||||||
|
['active_token_id', tokenId],
|
||||||
|
],
|
||||||
|
[
|
||||||
|
['token_id', tokenId],
|
||||||
|
['activate', 1],
|
||||||
|
['activate_time', nowTime],
|
||||||
|
['modifytime', nowTime],
|
||||||
|
['!account_id', () => {
|
||||||
|
return 'null';
|
||||||
|
}],
|
||||||
|
]
|
||||||
|
);
|
||||||
|
if (err) {
|
||||||
|
this.throwError(logHead + err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async addLog(fieldsKv) {
|
||||||
|
const {err} = await this.bcEventDbConn(
|
||||||
|
'insert',
|
||||||
|
't_log',
|
||||||
|
fieldsKv
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = BaseEventProcess;
|
module.exports = BaseEventProcess;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user