Merge commit '993e7b7154300e8e050898d3f71b5322cde01932' into task/OP-2896

This commit is contained in:
Dmitry Leleko
2022-11-10 10:48:44 +03:00
5 changed files with 51 additions and 37 deletions

View File

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

View File

@@ -1,14 +1,15 @@
import { z } from 'zod';
import fetchWithValidation from '../../fetchWithValidation';
import { PairStatusEnum, pairStatusSchema } from './schemas/adminPoolsListSchema';
import {
IDOSchema, atomicHistorySchema,
poolsConfigSchema, poolsInfoSchema, infoSchema, historySchema,
addPoolSchema, adminPoolsListSchema,
addPoolSchema, adminPoolsListSchema, adminPoolSchema,
atomicSummarySchema,
poolsLpAndStakedSchema,
userVotesSchema,
userEarnedSchema,
PairStatusEnum,
pairStatusSchema,
} from './schemas';
import redeemOrderSchema from '../OrionAggregator/schemas/redeemOrderSchema';
import { sourceAtomicHistorySchema, targetAtomicHistorySchema } from './schemas/atomicHistorySchema';
@@ -79,6 +80,7 @@ class OrionBlockchain {
this.checkAuth = this.checkAuth.bind(this);
this.addPool = this.addPool.bind(this);
this.editPool = this.editPool.bind(this);
this.getPool = this.getPool.bind(this);
this.getPoolsList = this.getPoolsList.bind(this);
this.getSourceAtomicSwapHistory = this.getSourceAtomicSwapHistory.bind(this);
this.getTargetAtomicSwapHistory = this.getTargetAtomicSwapHistory.bind(this);
@@ -274,6 +276,12 @@ class OrionBlockchain {
auth: z.boolean(),
}), { headers });
getPool = (address: string, headers: IAdminAuthHeaders) => fetchWithValidation(
`${this.apiUrl}/api/pools/${address}`,
adminPoolSchema,
{ headers },
);
getPoolsList = (headers: IAdminAuthHeaders) => fetchWithValidation(
`${this.apiUrl}/api/pools/list`,
adminPoolsListSchema,

View File

@@ -0,0 +1,36 @@
import { z } from 'zod';
export enum PairStatusEnum {
DOESNT_EXIST = -1,
REVIEW = 0,
ACCEPTED = 1,
REJECTED = 2,
}
export const pairStatusSchema = z.nativeEnum(PairStatusEnum);
const tokenSchema = z.object({
symbol: z.string(),
icon: z.string().optional(),
address: z.string(),
decimals: z.number().optional(),
isUser: z.boolean().optional(),
});
export const poolOnVerificationSchema = z.object({
tokenA: tokenSchema,
tokenB: tokenSchema,
_id: z.string().optional(),
address: z.string(),
symbol: z.string(),
isUser: z.boolean(),
minQty: z.number().optional(),
tokensReversed: z.boolean(),
status: pairStatusSchema,
updatedAt: z.number(),
createdAt: z.number(),
});
export type adminPoolType = z.infer<typeof poolOnVerificationSchema>;
export const adminPoolSchema = poolOnVerificationSchema;

View File

@@ -1,36 +1,5 @@
import { z } from 'zod';
export enum PairStatusEnum {
DOESNT_EXIST = -1,
REVIEW = 0,
ACCEPTED = 1,
REJECTED = 2,
}
import { poolOnVerificationSchema } from './adminPoolSchema';
export const pairStatusSchema = z.nativeEnum(PairStatusEnum);
const tokenSchema = z.object({
symbol: z.string(),
icon: z.string().optional(),
address: z.string(),
decimals: z.number().optional(),
isUser: z.boolean().optional(),
});
const poolOnVerificationSchema = z.object({
tokenA: tokenSchema,
tokenB: tokenSchema,
_id: z.string().optional(),
address: z.string(),
symbol: z.string(),
isUser: z.boolean(),
minQty: z.number().optional(),
tokensReversed: z.boolean(),
status: pairStatusSchema,
updatedAt: z.number(),
createdAt: z.number(),
});
export type adminPoolType = z.infer<typeof poolOnVerificationSchema>;
export const adminPoolsListSchema = z.array(poolOnVerificationSchema);
export default z.array(poolOnVerificationSchema);

View File

@@ -1,4 +1,5 @@
export * from './adminPoolsListSchema';
export * from './adminPoolSchema';
export { default as adminPoolsListSchema } from './adminPoolsListSchema';
export { default as addPoolSchema } from './addPoolSchema';
export { default as atomicHistorySchema } from './atomicHistorySchema';
export { default as checkRedeemOrderSchema } from './checkRedeemOrderSchema';