Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
T
ts-api-demo
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wmvm
ts-api-demo
Commits
95678d2c
Project 'zhuangke/ts-api-demo' was moved to 'wmvm/ts-api-demo'. Please update any links and bookmarks that may still have the old path.
Commit
95678d2c
authored
Sep 02, 2024
by
ml
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' of
ssh://gitlab.mytoken.org:10022/zhuangke/ts-api-demo
parents
92b86611
157852e2
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
54 additions
and
0 deletions
+54
-0
coreSystemUtils.ts
src/utils/coreSystemUtils.ts
+54
-0
No files found.
src/utils/coreSystemUtils.ts
View file @
95678d2c
import
{
coinType
}
from
"@madex/ex-ts-dao"
;
const
axios
=
require
(
"axios"
);
const
_
=
require
(
"lodash"
);
import
configSetting
from
"./../../config"
const
webadmin_endpoint
=
configSetting
.
webadmin_endpoint
...
...
@@ -33,6 +36,57 @@ export const getPairFromCore = async(symbol,market="spot")=> {
return
data
[
0
]
}
export
const
getUserAccountFromCore
=
async
(
userId
,
withName
=
true
)
=>
{
const
url
=
`
${
webadmin_endpoint
}
/account/list?user_id=
${
userId
}
`
let
{
data
}
=
await
axios
.
get
(
url
);
if
(
data
.
error
)
{
logger
.
error
(
"getPairFromCore"
,
data
);
return
null
}
let
asset_id
=
_
.
map
(
data
,
'asset'
);
if
(
withName
)
{
let
names
=
await
coinType
.
prototype
.
findAll
({
attributes
:[
'general_name'
,
'asset_id'
],
where
:{
asset_id
,
is_main
:
1
},
raw
:
true
})
let
m
=
_
.
keyBy
(
names
,
'asset_id'
);
for
(
const
item
of
data
)
{
if
(
m
[
item
.
asset
])
{
item
.
name
=
m
[
item
.
asset
].
general_name
}
}
}
// console.log(data)
return
data
;
}
// user_id
// status, // 必须 unsettled或者settled
// symbol, // 可选,交易对
// start_time, // 成交时间
// end_time, // 成交时间
// before, // update_id
// after, // update_id
// limit, / 数量
export
const
getUserOrdersFromCore
=
async
(
params
)
=>
{
// let params = new URLSearchParams();
const
url
=
`
${
webadmin_endpoint
}
/order/list`
let
{
data
}
=
await
axios
.
get
(
url
,{
params
});
if
(
data
.
error
)
{
logger
.
error
(
"getPairFromCore"
,
data
);
return
null
}
// console.log(data)
return
data
}
// getUserOrdersFromCore({user_id:1})
export
const
addCoin2Core
=
async
(
symbol
)
=>
{
const
url
=
`
${
webadmin_endpoint
}
/asset/add`
let
body
=
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment