1
This commit is contained in:
parent
9856247a69
commit
288a2fe503
@ -1,11 +1,20 @@
|
|||||||
const log = require('j7/log');
|
const log = require('j7/log');
|
||||||
const utils = require('j7/utils');
|
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');
|
const BaseEventProcess = require('../common/BaseEventProcess');
|
||||||
|
|
||||||
class Transfer extends BaseEventProcess {
|
class Transfer extends BaseEventProcess {
|
||||||
|
|
||||||
async start() {
|
async start() {
|
||||||
const returnValues = this.getReturnValues();
|
const returnValues = this.getReturnValues();
|
||||||
|
if (bcutils.isSysAddress(returnValues['from'])) {
|
||||||
|
await this.mint(returnValues['from'],
|
||||||
|
returnValues['to'],
|
||||||
|
returnValues['tokenId']
|
||||||
|
);
|
||||||
|
}
|
||||||
await this.add721NftRefresh
|
await this.add721NftRefresh
|
||||||
(
|
(
|
||||||
this.getNetId(),
|
this.getNetId(),
|
||||||
@ -16,6 +25,38 @@ class Transfer extends BaseEventProcess {
|
|||||||
await this.markOk();
|
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_GENESIS],
|
||||||
|
['item_id', constant.GENESIS_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;
|
module.exports = Transfer;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user