Added service methods to Orion Blockchain

This commit is contained in:
Aleksandr Kraiz
2022-05-12 13:02:40 +04:00
parent c9acc57d68
commit 12ac4da331
4 changed files with 32 additions and 5 deletions

View File

@@ -5,6 +5,7 @@ import {
IDOSchema, atomicHistorySchema,
poolsConfigSchema, poolsInfoSchema, infoSchema, historySchema,
addPoolSchema, adminPoolsListSchema,
atomicSummarySchema,
} from './schemas';
import { OrionBlockchainSocketIO } from './ws';
import redeemOrderSchema from '../OrionAggregator/schemas/redeemOrderSchema';
@@ -90,6 +91,29 @@ class OrionBlockchain {
return `https://${this.apiUrl}/`;
}
private getSummaryRedeem = (brokerAddress: string) => fetchWithValidation(
`https://${this.apiUrl}/api/atomic/summary-redeem/${brokerAddress}`,
atomicSummarySchema,
);
private getSummaryClaim = (brokerAddress: string) => fetchWithValidation(
`https://${this.apiUrl}/api/atomic/summary-claim/${brokerAddress}`,
atomicSummarySchema,
);
private getQueueLength = () => fetchWithValidation(
`https://${this.apiUrl}/api/queueLength`,
z.number().int()
);
get internal() {
return {
getSummaryRedeem: this.getSummaryRedeem.bind(this),
getSummaryClaim: this.getSummaryClaim.bind(this),
getQueueLength: this.getQueueLength.bind(this),
};
}
getAuthToken() {
return fetchWithValidation(`https://${this.apiUrl}/api/auth/token`, z.object({ token: z.string() }));
}
@@ -196,10 +220,6 @@ class OrionBlockchain {
return fetchWithValidation(`https://${this.apiUrl}/api/blocknumber`, z.number().int());
}
getQueueLength() {
return fetchWithValidation(`https://${this.apiUrl}/api/queueLength`, z.number().int());
}
getIDOInfo() {
return fetchWithValidation(`https://${this.apiUrl}/api/solarflare`, IDOSchema);
}

View File

@@ -0,0 +1,6 @@
import { z } from 'zod';
export default z.object({
amount: z.number(),
count: z.number(),
});

View File

@@ -7,3 +7,4 @@ export { default as IDOSchema } from './IDOSchema';
export { default as infoSchema } from './infoSchema';
export { default as poolsConfigSchema } from './poolsConfigSchema';
export { default as poolsInfoSchema } from './poolsInfoSchema';
export { default as atomicSummarySchema } from './atomicSummarySchema';