1
This commit is contained in:
parent
d82546500b
commit
f078aaaa25
@ -41,4 +41,25 @@ function getItemMetaNftType(itemMeta) {
|
|||||||
return bcconst.BC_NFT_NONE;
|
return bcconst.BC_NFT_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getNftTableName(tokenType) {
|
||||||
|
switch (Number(tokenType)) {
|
||||||
|
case bcconst.BC_NFT_HERO:
|
||||||
|
{
|
||||||
|
return 't_hero';
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case bcconst.BC_NFT_CHIP:
|
||||||
|
{
|
||||||
|
return 't_chip';
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
{
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
exports.getItemMetaNftType = getItemMetaNftType;
|
exports.getItemMetaNftType = getItemMetaNftType;
|
||||||
|
exports.getNftTableName = getNftTableName;
|
||||||
|
@ -5,6 +5,7 @@ const utils = require('j7/utils');
|
|||||||
const j7event = require('j7/event');
|
const j7event = require('j7/event');
|
||||||
const constant = require('common/constant');
|
const constant = require('common/constant');
|
||||||
const bcconst = require('common/bcconst');
|
const bcconst = require('common/bcconst');
|
||||||
|
const bchelper = require('common/bchelper');
|
||||||
const metaFactory = require('../../../metadata/factory');
|
const metaFactory = require('../../../metadata/factory');
|
||||||
const BaseEventProcess = require('../common/BaseEventProcess');
|
const BaseEventProcess = require('../common/BaseEventProcess');
|
||||||
|
|
||||||
@ -60,7 +61,7 @@ class Activate721Nft extends BaseEventProcess {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
await this.updateGameDbInfo(transId, itemUniId, itemId, tokenId, tokenType);
|
await this.updateGameDbInfo(transId, itemUniId, itemId, tokenId, tokenType);
|
||||||
const {err, row} = await this.bcNftConn(
|
const {err} = await this.bcNftConn(
|
||||||
'ormSelectOne',
|
'ormSelectOne',
|
||||||
't_nft',
|
't_nft',
|
||||||
[
|
[
|
||||||
@ -94,50 +95,17 @@ class Activate721Nft extends BaseEventProcess {
|
|||||||
log.error('processEvent:' + err);
|
log.error('processEvent:' + err);
|
||||||
throw 'processEvent:' + err;
|
throw 'processEvent:' + err;
|
||||||
}
|
}
|
||||||
try {
|
|
||||||
j7event.emitEvent(C.CREATE_EXEC_CONFIRM_OWNER_EVENT, tokenId);
|
|
||||||
} catch (err) {
|
|
||||||
log.warning('processEvent:' + err);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async updateGameDbInfo(transId, itemUniId, itemId, tokenId, tokenType) {
|
async updateGameDbInfo(transId, itemUniId, itemId, tokenId, tokenType) {
|
||||||
const {err, conn} = await app.getDbConn(constant.GAMEDB_NAME);
|
const tblName = bchelper.getNftTableName(tokenType);
|
||||||
if (err) {
|
|
||||||
this.throwError('gamedb connection err:' + err);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
const gameDbConn = conn;
|
|
||||||
try {
|
|
||||||
try {
|
|
||||||
let tblName = '';
|
|
||||||
switch (tokenType) {
|
|
||||||
case bcconst.BC_NFT_HERO:
|
|
||||||
{
|
|
||||||
tblName = 't_hero';
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case bcconst.BC_NFT_EQUIP:
|
|
||||||
{
|
|
||||||
tblName = 't_gun';
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case bcconst.BC_NFT_CHIP:
|
|
||||||
{
|
|
||||||
tblName = 't_chip';
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
{
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (!tblName) {
|
if (!tblName) {
|
||||||
this.throwError('error token_type:' + tokenType);
|
this.throwError('error token_type:' + tokenType);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
await gameDbConn.update(
|
const {err} = await this.gameDbConn(
|
||||||
|
'update',
|
||||||
tblName,
|
tblName,
|
||||||
[
|
[
|
||||||
['idx', itemUniId],
|
['idx', itemUniId],
|
||||||
@ -149,12 +117,8 @@ class Activate721Nft extends BaseEventProcess {
|
|||||||
}],
|
}],
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
} finally {
|
if (err) {
|
||||||
gameDbConn.release();
|
this.throwError('updateGameDbInfo transId:' + transId);
|
||||||
}
|
|
||||||
} catch (e) {
|
|
||||||
this.throwError('updateGameDbInfo err:' + e);
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user