Commit 7fa5aef5 authored by 1486327116's avatar 1486327116

update

parent a5e65322
// @madex/ex-ts-dao 是 ts 的 dao, 代码在 bitbucket/ex-js-dao 的 ts 分支上 // @madex/ex-ts-dao 是 ts 的 dao, 代码在 bitbucket/ex-js-dao 的 ts 分支上
import { coinType, ormDB, spotPairs ,mixinCoin} from "@madex/ex-ts-dao"; import { coinType, ormDB, spotPairs ,mixinCoin,mixinChain} from "@madex/ex-ts-dao";
import { addCoin2Core } from "../../../utils/coreSystemUtils"; import { addCoin2Core } from "../../../utils/coreSystemUtils";
import { ErrorCode } from "../../../constant/errorCode"; import { ErrorCode } from "../../../constant/errorCode";
import { addOptLog } from "./userOptLog.service"; import { addOptLog } from "./userOptLog.service";
const _ = require("lodash");
let { logger, datetimeUtils } = require('@madex/ex-js-public'); let { logger, datetimeUtils } = require('@madex/ex-js-public');
...@@ -276,12 +277,45 @@ export async function mixinCoinList(param: ListParam) { ...@@ -276,12 +277,45 @@ export async function mixinCoinList(param: ListParam) {
where["symbol"] = { [ormDB.Op.like]: `%${param.symbol}%` }; where["symbol"] = { [ormDB.Op.like]: `%${param.symbol}%` };
} }
let resList = await mixinCoin.prototype.findAndCount({ let resList = await mixinCoin.prototype.findAndCount({
attributes:['symbol','name','symbol_id','display_symbol','chain_id','address','precision','dust','confirm','price_btc','price_usd','balance','comment'], attributes:['symbol','name','symbol_id',['symbol_id','mixin_id'],'display_symbol','chain_id',
['address','contract'],['precision','original_decimals'],['dust','deposit_min'],['dust','withdraw_min'],
['confirm','deposit_confirm_count'],['confirm','safe_confirm_count'],
'price_btc','price_usd','balance','comment'],
// include:{
// model:mixinChain.prototype,
// required:true, //INNER JOIN
// attributes:['name','symbol','threshold','withdrawal_fee','is_memo'],
// },
where: where, where: where,
limit: param.size, limit: param.size,
offset: (param.page - 1) * param.size, offset: (param.page - 1) * param.size,
order: [["symbol", "asc"]], order: [["symbol", "asc"]],
raw: true raw: true
}); });
let chainIDs =_.map(resList.rows,'chain_id')
let m = await mixinChain.prototype.findAll({
attributes:['name','symbol','threshold','withdrawal_fee','is_memo','chain_id'],
where:{
chain_id:chainIDs
},
raw: true,
})
let chainMap = _.keyBy(m,'chain_id');
for (const item of resList.rows) {
let isMainToken = (item.symbol_id ==item.chain_id &&item.chain_id ==item.contract)
if (chainMap[item.chain_id]) {
item.chain_type = chainMap[item.chain_id].symbol
item.issupport_memo = chainMap[item.chain_id].is_memo;
item.valid_decimals = 8;
item.withdraw_fee = isMainToken ? chainMap[item.chain_id].withdrawal_fee : (5 / (item.price_usd > 0 ? item.price_usd : 0.001)).toFixed(4);
}
if (item.contract) {
item.is_erc20=1;
}else {
item.is_erc20=0;
}
}
return resList; return resList;
} }
\ No newline at end of file
...@@ -23,6 +23,7 @@ export interface CoinTypeApplyVO { ...@@ -23,6 +23,7 @@ export interface CoinTypeApplyVO {
chain_type?: string; chain_type?: string;
issupport_memo?: number;
forbid_info?: string; forbid_info?: string;
...@@ -302,6 +303,8 @@ export async function review(id: any, currentUser: any, ip: string | undefined) ...@@ -302,6 +303,8 @@ export async function review(id: any, currentUser: any, ip: string | undefined)
main_status:main_status, main_status:main_status,
name: dbApply.name, name: dbApply.name,
mixin_id:dbApply.mixin_id, mixin_id:dbApply.mixin_id,
issupport_memo:dbApply.issupport_memo,
deposit_min:dbApply.deposit_min,
general_name: dbApply.general_name, general_name: dbApply.general_name,
chain_type:dbApply.chain_type, chain_type:dbApply.chain_type,
original_decimals: dbApply.original_decimals, original_decimals: dbApply.original_decimals,
......
import WebSocket from 'ws';
const client = new WebSocket('ws://127.0.0.1:8443?sid=12312',[],{"headers":{"api-key":111}});
// 心跳
let heartbeatInterval: any;
const heartbeatConfig = {
interval: 30000, // 心跳间隔
};
function heartBeat (){
console.log(new Date() +" send ping...")
client.ping()
}
client.on('error', console.error);
client.on('open', function open() {
console.log("success open!")
if (heartbeatInterval) {
clearInterval(heartbeatInterval);
}
heartbeatInterval = setInterval(heartBeat, heartbeatConfig.interval); // 设置心跳
});
client.on('message', function message(data) {
console.log('received: %s', data);
});
client.on('onclose', function message(data) {
if (heartbeatInterval) {
clearInterval(heartbeatInterval); // 清除心跳定时器
}
console.log('Connection closed');
});
client.on('pong',function (){
console.log("rec pong")
})
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment