This commit is contained in:
aozhiwei 2023-07-09 15:27:32 +08:00
parent 5087125525
commit f02757387e
2 changed files with 22 additions and 54 deletions

View File

@ -1,8 +1,5 @@
const log = require('j7/log');
const app = require('j7/app');
const utils = require('j7/utils');
const j7event = require('j7/event');
const metaFactory = require('../../metadata/factory');
const BaseEventProcess = require('../common/BaseEventProcess');
/*

View File

@ -1,15 +1,6 @@
const log = require('j7/log');
const app = require('j7/app');
const bcutils = require('j7/bcutils');
const utils = require('j7/utils');
const j7event = require('j7/event');
const metaFactory = require('../../metadata/factory');
const C = require('../../C');
const gameapi = require('../gameapi');
const http = require('j7/http');
const config = require('j7/config');
const BASE_URL = config('market_api');
const BaseEventProcess = require('../common/BaseEventProcess');
/*
// 操作成功的事件
@ -26,14 +17,8 @@ event SellOrder(
class SellOrder {
async start(instance, conn, event) {
this.instance = instance;
this.conn = conn;
this.event = event;
console.log('SellOrder', event);
const blockNumber = event['blockNumber'];
const returnValues = event['returnValues'];
async start() {
const returnValues = this.getReturnValues();
const tokenId = returnValues['tokenId'];
const owner = returnValues['owner'];
@ -43,44 +28,30 @@ class SellOrder {
const currency = returnValues['currency'];
const price = returnValues['price'];
while (true) {
try {
const {err, data} = await http.get
(BASE_URL,
{
'c': 'Market',
'a': 'eventSellOrder',
'tokenId': tokenId,
'owner': owner,
'nftToken': nftToken,
'amount': amount,
'orderId': orderId,
'currency': currency,
'price': price
});
if (err) {
throw err;
}
console.log(err, data);
const params = {
'c': 'Market',
'a': 'eventSellOrder',
'tokenId': tokenId,
'owner': owner,
'nftToken': nftToken,
'amount': amount,
'orderId': orderId,
'currency': currency,
'price': price
};
await this.callGameApi
(params,
async (data) => {
if (!data) {
throw 'data is empty2';
this.throwError('callGameApi error:' + data);
}
if (data['errcode'] == 0 ||
data['errcode'] == 1) {
return;
return true;
}
} catch (e) {
log.error(e);
}
await utils.sleep(3000 + utils.randRange(500, 1500));
}
}
throwError(err) {
const errMsg = 'processSellOrderEvent:' +
utils.jsonEncode(this.instance) +
' err:' + err;
throw errMsg;
return true;
});
await this.markOk();
}
}