diff --git a/server/web3dbspider/services/events/Explorer/transfer.js b/server/web3dbspider/services/events/Explorer/transfer.js new file mode 100644 index 0000000..4ae9477 --- /dev/null +++ b/server/web3dbspider/services/events/Explorer/transfer.js @@ -0,0 +1,64 @@ +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(), + this.getContractAddress(), + this.getContractName(), + returnValues['tokenId'] + );*/ + 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_EXPLORER], + ['item_id', constant.EXPLORER_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()], + ], + [ + ['owner_address', bcutils.toNormalAddress(to)], + ], + fieldList + ); + if (err) { + this.throwError('mintNft ' + err); + } + } + +} + +module.exports = Transfer;