From 288a2fe503693e4e6ad4b716daa77577851a5777 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Sat, 15 Jul 2023 15:55:25 +0800 Subject: [PATCH] 1 --- .../services/events/Genesis/transfer.js | 41 +++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/server/web3dbspider/services/events/Genesis/transfer.js b/server/web3dbspider/services/events/Genesis/transfer.js index e89392c..4a198f7 100644 --- a/server/web3dbspider/services/events/Genesis/transfer.js +++ b/server/web3dbspider/services/events/Genesis/transfer.js @@ -1,11 +1,20 @@ 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 { async start() { const returnValues = this.getReturnValues(); + if (bcutils.isSysAddress(returnValues['from'])) { + await this.mint(returnValues['from'], + returnValues['to'], + returnValues['tokenId'] + ); + } await this.add721NftRefresh ( this.getNetId(), @@ -16,6 +25,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_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;