diff --git a/apps/whale-api/src/e2e.defid.module.ts b/apps/whale-api/src/e2e.defid.module.ts index a50c6ebe15..e08e5ed07d 100644 --- a/apps/whale-api/src/e2e.defid.module.ts +++ b/apps/whale-api/src/e2e.defid.module.ts @@ -11,6 +11,22 @@ import { ApiPagedResponse } from './module.api/_core/api.paged.response' import { AddressToken, AddressHistory } from '@defichain/whale-api-client/dist/api/address' import { Block } from './module.model/block' +import { MasternodeData } from '@defichain/whale-api-client/dist/api/masternodes' +import { + AllSwappableTokensResult, + BestSwapPathResult, DexPricesResult, + PoolPairData, + PoolSwapAggregatedData, + PoolSwapData, + SwapPathsResult +} from '@defichain/whale-api-client/dist/api/poolpairs' +import { Oracle } from './module.model/oracle' +import { OraclePriceAggregated } from './module.model/oracle.price.aggregated' +import { OraclePriceFeed } from './module.model/oracle.price.feed' +import { OraclePriceActive } from './module.model/oracle.price.active' +import { PriceTicker } from './module.model/price.ticker' +import { PriceFeedInterval, PriceOracle } from '@defichain/whale-api-client/dist/api/prices' +import { RawTransaction } from '@defichain/jellyfish-api-core/dist/category/rawtx' import { ScriptActivity } from './module.model/script.activity' import { ScriptAggregation } from './module.model/script.aggregation' import { ScriptUnspent } from './module.model/script.unspent' @@ -26,6 +42,10 @@ export interface OceanListQuery { next?: string } +export interface OceanRawTxQuery { + verbose: boolean +} + class DefidOceanApi { async get (path: string): Promise { const res = await fetch(`${ENDPOINT}${path}`, { @@ -117,131 +137,132 @@ export class DBlockController extends DefidOceanController { } export class DFeeController extends DefidOceanController { - async estimate () { + async estimate (): Promise { return await this.api.get('/fee/estimate') } } export class DMasternodeController extends DefidOceanController { - async list (query: OceanListQuery = { size: 30 }) { + async list (query: OceanListQuery = { size: 30 }): Promise> { if (query.next !== undefined) { return await this.api.get(`/masternodes?size=${query.size}&next=${query.next}`) } return await this.api.get(`/masternodes?size=${query.size}`) } - async get (id: string) { + async get (id: string): Promise { return await this.api.get(`/masternodes/${id}`) } } export class DOracleController extends DefidOceanController { - async list (query: OceanListQuery = { size: 30 }) { + async list (query: OceanListQuery = { size: 30 }): Promise> { if (query.next !== undefined) { return await this.api.get(`/oracles?size=${query.size}&next=${query.next}`) } return await this.api.get(`/oracles?size=${query.size}`) } - async getPriceFeed (id: string, key: string) { + async getPriceFeed (id: string, key: string): Promise> { return await this.api.get(`/oracles/${id}/${key}/feed`) } - async getOracleByAddress (address: string) { + async getOracleByAddress (address: string): Promise { return await this.api.get(`/oracles/${address}`) } } export class DPoolPairController extends DefidOceanController { - async list (query: OceanListQuery = { size: 30 }) { + async list (query: OceanListQuery = { size: 30 }): Promise> { if (query.next !== undefined) { return await this.api.get(`/poolpairs?size=${query.size}&next=${query.next}`) } return await this.api.get(`/poolpairs?size=${query.size}`) } - async get (id: string) { + async get (id: string): Promise { return await this.api.get(`/poolpairs/${id}`) } - async listPoolSwaps (id: string, query: OceanListQuery = { size: 30 }) { + async listPoolSwaps (id: string, query: OceanListQuery = { size: 30 }): Promise> { if (query.next !== undefined) { return await this.api.get(`/poolpairs/${id}/swaps?size=${query.size}&next=${query.next}`) } return await this.api.get(`/poolpairs/${id}/swaps?size=${query.size}`) } - async listPoolSwapsVerbose (id: string, query: OceanListQuery = { size: 30 }) { + async listPoolSwapsVerbose (id: string, query: OceanListQuery = { size: 30 }): Promise> { if (query.next !== undefined) { return await this.api.get(`/poolpairs/${id}/swaps/verbose?size=${query.size}&next=${query.next}`) } return await this.api.get(`/poolpairs/${id}/swaps/verbose?size=${query.size}`) } - async listPoolSwapsAggregate (id: string, interval: number, query: OceanListQuery = { size: 30 }) { + async listPoolSwapsAggregate (id: string, interval: number, query: OceanListQuery = { size: 30 }): Promise> { if (query.next !== undefined) { return await this.api.get(`/poolpairs/${id}/swaps/aggregate/${interval}?size=${query.size}&next=${query.next}`) } return await this.api.get(`/poolpairs/${id}/swaps/aggregate/${interval}?size=${query.size}`) } - async getSwappableTokens (id: string) { + async listSwappableTokens (id: string): Promise { return await this.api.get(`/poolpairs/paths/swappable/${id}`) } - async getBestPath (fromTokenId: string, toTokenId: string) { - return await this.api.get(`/poolpairs/paths/best/from/${fromTokenId}/to/${toTokenId}`) + async listPaths (fromTokenId: string, toTokenId: string): Promise { + return await this.api.get(`/poolpairs/paths/from/${fromTokenId}/to/${toTokenId}`) } - async listPaths (fromTokenId: string, toTokenId: string) { - return await this.api.get(`/poolpairs/paths/from/${fromTokenId}/to/${toTokenId}`) + async getBestPath (fromTokenId: string, toTokenId: string): Promise { + return await this.api.get(`/poolpairs/paths/best/from/${fromTokenId}/to/${toTokenId}`) } - async listDexPrices (denomination: string) { + async listDexPrices (denomination: string): Promise { return await this.api.get(`/poolpairs/dexprices?denomination=${denomination}`) } } export class DPriceController extends DefidOceanController { - async list (query: OceanListQuery = { size: 30 }) { + async list (query: OceanListQuery = { size: 30 }): Promise> { if (query.next !== undefined) { return await this.api.get(`/prices?size=${query.size}&next=${query.next}`) } return await this.api.get(`/prices?size=${query.size}`) } - async get (id: string) { + async get (id: string): Promise { return await this.api.get(`/prices/${id}`) } - async getFeedActive (id: string) { - return await this.api.get(`/prices/${id}/feed/active`) + async getFeed (id: string): Promise> { + return await this.api.get(`/prices/${id}/feed`) } - async getFeed (id: string) { - return await this.api.get(`/prices/${id}/feed`) + async getFeedActive (id: string): Promise> { + return await this.api.get(`/prices/${id}/feed/active`) } - async getFeedWithInterval (id: string, interval: number) { + async getFeedWithInterval (id: string, interval: number): Promise> { return await this.api.get(`/prices/${id}/feed/interval/${interval}`) } - async listPriceOracles (id: string) { + async listPriceOracles (id: string): Promise> { return await this.api.get(`/prices/${id}/oracles`) } } export class DRawTxController extends DefidOceanController { - async sendRawtx () { + async send (): Promise { return await this.api.post('/rawtx/send') } - async testRawtx () { + async test (): Promise { return await this.api.get('/rawtx/test') } - async getRawtx (id: string) { - return await this.api.get(`/rawtx/${id}`) + async get (id: string, query: OceanRawTxQuery = { verbose: false }): Promise { + /* eslint-disable-next-line @typescript-eslint/restrict-template-expressions */ + return await this.api.get(`/rawtx/${id}?verbose=${query.verbose}`) } }