Commit 911a6fe1 authored by 1486327116's avatar 1486327116

format

parent 848d1110
// @madex/ex-ts-dao 是 ts 的 dao, 代码在 bitbucket/ex-js-dao 的 ts 分支上
import { coinType, ormDB } from "@madex/ex-ts-dao";
import { coinType, ormDB, spotPairs } from "@madex/ex-ts-dao";
import { addCoin2Core, addPairToCore } from "../../../utils/coreSystemUtils";
export interface ListParam {
......@@ -11,7 +12,7 @@ export interface ListParam {
}
export interface AddParam {
id:any,
id: any,
symbol: string;
......@@ -62,29 +63,29 @@ export interface AddParam {
total_amount?: number;
supply_amount?: number ;
supply_amount?: number;
circulation_rate?: number ;
circulation_rate?: number;
address_num?: number;
price?: string ;
price?: string;
supply_time?:string ;
supply_time?: string;
deflation_rate?:number ;
deflation_rate?: number;
comment?: string ;
comment?: string;
max_transfer_amount?: number ;
max_transfer_amount?: number;
tag: string;
forbid_info_related?: number ;
forbid_info_related?: number;
is_hidden?: number ;
is_hidden?: number;
main_status?: number ;
main_status?: number;
}
......@@ -107,10 +108,11 @@ export const save = async (param: AddParam) => {
let id = param.id;
if (id) {
delete param.id
await coinType.prototype.update(param,{
where:{id:id}
await coinType.prototype.update(param, {
where: { id: id }
})
}else {
}
else {
await coinType.prototype.create(param);
}
......@@ -118,9 +120,23 @@ export const save = async (param: AddParam) => {
};
export const pushToCoreSystem = async (id: any) => {
await coinType.prototype.update({ main_status:1 },{
where:{id:id,main_status:0}
})
let where = { id: id, main_status: 0, is_main: 1 };
let cfg = await coinType.prototype.find({
where: where, raw: true
});
if (cfg) {
let symbol = cfg.general_name;
let optResult = await addCoin2Core(symbol);
if (optResult) {
await coinType.prototype.update({ main_status: 1 }, {
where: where
})
}
}
return 'ok';
};
// @madex/ex-ts-dao 是 ts 的 dao, 代码在 bitbucket/ex-js-dao 的 ts 分支上
import { spotPairs, ormDB, coinType } from "@madex/ex-ts-dao";
import { NUMBER } from "sequelize";
import { addPairToCore } from "../../../utils/coreSystemUtils";
export interface ListParam {
......@@ -62,9 +63,29 @@ export const save = async (param: AddParam) => {
};
export const pushToCoreSystem = async (id: any) => {
await spotPairs.prototype.update({ status: 1 }, {
where: { id: id, status: 0 }
})
let where = { id: id, status: 0 };
let cfg = await spotPairs.prototype.find({
where: where, raw: true
});
if (cfg) {
let symbol = cfg.symbol;
let sps = symbol.split("_");
let base = sps[0];
let quote = sps[1]
let param = {
"base": base, "quote": quote, "symbol": symbol, "name": symbol,
"price-scale": cfg.price_scale, "quantity-scale": cfg.quantity_scale,
"maker-fee": cfg.maker_fee, "taker-fee": cfg.taker_fee
}
let optResult = await addPairToCore(param);
if (optResult) {
await spotPairs.prototype.update({ status: 1 }, {
where: where
});
}
}
return 'ok';
};
......@@ -34,4 +34,29 @@ export const getPairFromCore = async(symbol,market="spot")=> {
return data[0]
}
export const addCoin2Core = async(symbol)=> {
const url = `${webadmin_endpoint}/asset/add`
let body = {
"symbol":symbol,
}
let { data } = await axios.post(url,body);
if (data.error) {
logger.error(data);
return false;
}
return true;
}
export const addPairToCore = async(body)=> {
const url = `${webadmin_endpoint}/pair/add_product`
let { data } = await axios.post(url,body);
if (data.error) {
logger.error(data);
return false;
}
return true;
}
// getPairFromCore("BTC_USDT").then(console.log)
\ 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