diff --git a/package.json b/package.json index 40b29cf..0e656a8 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@orionprotocol/sdk", - "version": "0.5.7", + "version": "0.5.8", "description": "Orion Protocol SDK", "main": "./lib/esm/index.js", "module": "./lib/esm/index.js", diff --git a/src/services/OrionBlockchain/index.ts b/src/services/OrionBlockchain/index.ts index 80398f9..d75fc2f 100644 --- a/src/services/OrionBlockchain/index.ts +++ b/src/services/OrionBlockchain/index.ts @@ -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); } diff --git a/src/services/OrionBlockchain/schemas/atomicSummarySchema.ts b/src/services/OrionBlockchain/schemas/atomicSummarySchema.ts new file mode 100644 index 0000000..88edc19 --- /dev/null +++ b/src/services/OrionBlockchain/schemas/atomicSummarySchema.ts @@ -0,0 +1,6 @@ +import { z } from 'zod'; + +export default z.object({ + amount: z.number(), + count: z.number(), +}); diff --git a/src/services/OrionBlockchain/schemas/index.ts b/src/services/OrionBlockchain/schemas/index.ts index b0d6b36..d8a7af3 100644 --- a/src/services/OrionBlockchain/schemas/index.ts +++ b/src/services/OrionBlockchain/schemas/index.ts @@ -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';