This commit is contained in:
aozhiwei 2024-06-03 16:25:21 +08:00
parent d6476cef77
commit c48d838b8a
12 changed files with 4 additions and 628 deletions

View File

@ -1,66 +0,0 @@
const log = require('j7/log');
const utils = require('j7/utils');
const BaseEventProcess = require('../common/BaseEventProcess');
/*
// 操作成功的事件
event BuyOrder(
uint256 indexed tokenId,
uint256 orderId,
address nftToken,
uint256 amount,
address seller,
address buyer,
address erc20,
uint256 price
);
*/
class BuyOrder extends BaseEventProcess {
async start() {
const returnValues = this.getReturnValues();
const tokenId = returnValues['tokenId'];
const orderId = returnValues['orderId'];
const nftToken = returnValues['nftToken'];
const amount = returnValues['amount'];
const seller = returnValues['seller'];
const buyer = returnValues['buyer'];
const erc20 = returnValues['erc20'];
const price = returnValues['price'];
const params = {
//'c': 'Market',
//'a': 'eventBuyOrder',
'c': 'Callback',
'a': 'dispatch',
'action': 'MarketBuyOrderOk',
'tokenId': tokenId,
'orderId': orderId,
'nftToken': nftToken,
'amount': amount,
'seller': seller,
'buyer': buyer,
'erc20': erc20,
'price': price,
'net_id': this.getNetId()
};
await this.callGameApi
(params,
async (data) => {
if (!data) {
this.throwError('callGameApi error:' + data);
}
if (data['errcode'] == 0 ||
data['errcode'] == 1) {
return true;
}
return true;
});
await this.markOk();
}
}
module.exports = BuyOrder;

View File

@ -1,52 +0,0 @@
const log = require('j7/log');
const utils = require('j7/utils');
const BaseEventProcess = require('../common/BaseEventProcess');
/*
// 操作成功的事件
event CancelOrder(
uint256 indexed orderId,
address indexed nftToken,
uint256 indexed tokenId
);
*/
class CancelOrder extends BaseEventProcess {
async start() {
const returnValues = this.getReturnValues();
const orderId = returnValues['orderId'];
const nftToken = returnValues['nftToken'];
const tokenId = returnValues['tokenId'];
const params = {
//'c': 'Market',
//'a': 'eventCancelOrder',
'c': 'Callback',
'a': 'dispatch',
'action': 'MarketCancelOrderOk',
'orderId': orderId,
'nftToken': nftToken,
'tokenId': tokenId,
'net_id': this.getNetId()
};
await this.callGameApi
(params,
async (data) => {
if (!data) {
this.throwError('callGameApi error:' + data);
}
if (data['errcode'] == 0 ||
data['errcode'] == 1) {
return true;
}
return true;
});
await this.markOk();
}
}
module.exports = CancelOrder;

View File

@ -1,57 +0,0 @@
const log = require('j7/log');
const utils = require('j7/utils');
const BaseEventProcess = require('../common/BaseEventProcess');
/*
// 操作成功的事件
event PriceUpdate(
uint256 indexed orderId,
address indexed nftToken,
uint256 indexed tokenId,
uint256 priceOld,
uint256 price
);
*/
class PriceUpdate extends BaseEventProcess {
async start() {
const returnValues = this.getReturnValues();
const orderId = returnValues['orderId'];
const nftToken = returnValues['nftToken'];
const tokenId = returnValues['tokenId'];
const priceOld = returnValues['priceOld'];
const price = returnValues['price'];
const params = {
//'c': 'Market',
//'a': 'eventPriceUpdateOrder',
'c': 'Callback',
'a': 'dispatch',
'action': 'MarketPriceUpdateOrderOk',
'orderId': orderId,
'nftToken': nftToken,
'tokenId': tokenId,
'priceOld': priceOld,
'price': price,
'net_id': this.getNetId()
};
await this.callGameApi
(params,
async (data) => {
if (!data) {
this.throwError('callGameApi error:' + data);
}
if (data['errcode'] == 0 ||
data['errcode'] == 1) {
return true;
}
return true;
});
await this.markOk();
}
}
module.exports = PriceUpdate;

View File

@ -1,63 +0,0 @@
const log = require('j7/log');
const utils = require('j7/utils');
const BaseEventProcess = require('../common/BaseEventProcess');
/*
// 操作成功的事件
event SellOrder(
uint256 indexed tokenId,
address indexed owner,
address indexed nftToken,
uint256 amount,
uint256 orderId,
address currency,
uint256 price
);
*/
class SellOrder extends BaseEventProcess {
async start() {
const returnValues = this.getReturnValues();
const tokenId = returnValues['tokenId'];
const owner = returnValues['owner'];
const nftToken = returnValues['nftToken'];
const amount = returnValues['amount'];
const orderId = returnValues['orderId'];
const currency = returnValues['currency'];
const price = returnValues['price'];
const params = {
//'c': 'Market',
//'a': 'eventSellOrder',
'c': 'Callback',
'a': 'dispatch',
'action': 'MarketSellOrderOk',
'tokenId': tokenId,
'owner': owner,
'nftToken': nftToken,
'amount': amount,
'orderId': orderId,
'currency': currency,
'price': price,
'net_id': this.getNetId()
};
await this.callGameApi
(params,
async (data) => {
if (!data) {
this.throwError('callGameApi error:' + data);
}
if (data['errcode'] == 0 ||
data['errcode'] == 1) {
return true;
}
return true;
});
await this.markOk();
}
}
module.exports = SellOrder;

View File

@ -1,21 +0,0 @@
const log = require('j7/log');
const utils = require('j7/utils');
const BaseEventProcess = require('../common/BaseEventProcess');
class Transfer extends BaseEventProcess {
async start() {
const returnValues = this.getReturnValues();
await this.add721NftRefresh
(
this.getNetId(),
this.getContractAddress(),
this.getContractName(),
returnValues['tokenId']
);
await this.markOk();
}
}
module.exports = Transfer;

View File

@ -1,64 +0,0 @@
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;

View File

@ -1,64 +0,0 @@
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_CLAIM_BOX],
['item_id', constant.GACHA_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;

View File

@ -1,47 +0,0 @@
const log = require('j7/log');
const utils = require('j7/utils');
const BaseEventProcess = require('../common/BaseEventProcess');
/*
操作成功的事件
event ItemSoldOut(
address indexed buyer,
uint256 indexed orderId,
address currency,
uint256 price
);
*/
class ItemSoldOut extends BaseEventProcess {
async start() {
const returnValues = this.getReturnValues();
const transId = returnValues['orderId'];
const orderId = returnValues['orderId'];
const params = {
'c': 'Callback',
'a': 'dispatch',
'action': 'gameItemMallBuyOk',
'trans_id': transId,
'order_id': orderId,
};
await this.callGameApi
(params,
async (data) => {
if (!data) {
this.throwError('callGameApi error:' + data);
}
if (data['errcode'] == 0 ||
data['errcode'] == 1 ||
data['errcode'] == 2) {
return true;
}
return true;
});
await this.markOk();
}
}
module.exports = ItemSoldOut;

View File

@ -1,51 +0,0 @@
const log = require('j7/log');
const utils = require('j7/utils');
const BaseEventProcess = require('../common/BaseEventProcess');
/*
操作成功的事件
event ItemSoldOut(
address indexed buyer,
uint256 indexed orderId,
address currency,
uint256 price
);
*/
class ItemSoldOut extends BaseEventProcess {
async start() {
const returnValues = this.getReturnValues();
const buyer = returnValues['buyer'];
const orderId = returnValues['orderId'];
const currency = returnValues['currency'];
const price = returnValues['price'];
const params = {
'c': 'Callback',
'a': 'dispatch',
'action': 'gameItemMarketBuyOk',
'buyer': buyer,
'order_id': orderId,
'currency': currency,
'price': price
};
await this.callGameApi
(params,
async (data) => {
if (!data) {
this.throwError('callGameApi error:' + data);
}
if (data['errcode'] == 0 ||
data['errcode'] == 1 ||
data['errcode'] == 2) {
return true;
}
return true;
});
await this.markOk();
}
}
module.exports = ItemSoldOut;

View File

@ -1,64 +0,0 @@
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_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()],
],
[
['owner_address', bcutils.toNormalAddress(to)],
],
fieldList
);
if (err) {
this.throwError('mintNft ' + err);
}
}
}
module.exports = Transfer;

View File

@ -1,64 +0,0 @@
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_PLANET],
['item_id', tokenId],
['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;

View File

@ -18,21 +18,10 @@ async function add(clsName, modName) {
}
async function init() {
await add('HERO.Transfer', 'HERO/transfer');
await add('CHIP.Transfer', 'CHIP/transfer');
await add('Gacha.Transfer', 'Gacha/transfer');
await add('Explorer.Transfer', 'Explorer/transfer');
await add('Genesis.Transfer', 'Genesis/transfer');
await add('PLANET.Transfer', 'PLANET/transfer');
await add('UserMinterFactory.TokenMinted', 'UserMinterFactory/activate721nft');
await add('BENftMarket.SellOrder', 'BENftMarket/sell_order');
await add('BENftMarket.CancelOrder', 'BENftMarket/cancel_order');
await add('BENftMarket.PriceUpdate', 'BENftMarket/price_update');
await add('BENftMarket.BuyOrder', 'BENftMarket/buy_order');
await add('GameItemMall.ItemSoldOut', 'GameItemMall/item_soldout');
await add('GameItemMarket.ItemSoldOut', 'GameItemMarket/item_soldout');
await add('ERC721Staking.Staked', 'ERC721Staking/staked');
await add('ERC721Staking.Redeem', 'ERC721Staking/redeem');
await add('CFHero.Transfer', 'CFHero/transfer');
//await add('UserMinterFactory.TokenMinted', 'UserMinterFactory/activate721nft');
//await add('ERC721Staking.Staked', 'ERC721Staking/staked');
//await add('ERC721Staking.Redeem', 'ERC721Staking/redeem');
}
function getEventHandle(eventProc) {