Exchange and CFD history schemas was transformed

package.json version 0.16.0-rc.8 was updated
This commit is contained in:
Mikhail Gladchenko
2023-01-05 12:35:05 +00:00
parent 4931a7b919
commit 95366b88e9
3 changed files with 33 additions and 2 deletions

View File

@@ -1,6 +1,6 @@
{
"name": "@orionprotocol/sdk",
"version": "0.16.0-rc.7",
"version": "0.16.0-rc.8",
"description": "Orion Protocol SDK",
"main": "./lib/esm/index.js",
"module": "./lib/esm/index.js",

View File

@@ -24,6 +24,22 @@ const cfdHistorySchema = z.object({
total: z.number(),
pagination: z.object({}),
data: z.array(cfdHistoryItem),
}).transform((response) => {
return response.data.map((item) => {
const {
createdAt, reason, transactionHash, amountNumber,
} = item;
return {
type: reason === 'WITHDRAW' ? 'withdrawal' : 'deposit',
date: createdAt,
token: 'USDT',
amount: amountNumber,
status: 'Done',
transactionHash,
user: item.address,
};
});
});
export default cfdHistorySchema;

View File

@@ -13,6 +13,21 @@ const historySchema = z.array(z.object(
user: z.string(),
walletBalance: z.string().nullable().optional(),
},
));
)).transform((response) => {
return response.map((item) => {
const {
type, createdAt, transactionHash, user,
} = item;
return {
type,
date: createdAt * 1000,
token: item.asset,
amount: item.amountNumber,
status: 'Done',
transactionHash,
user,
};
});
});
export default historySchema;