From c6547781299d48f8343e941a6e28b3f3762ec92c Mon Sep 17 00:00:00 2001 From: TheJuze Date: Wed, 10 Jan 2024 15:29:06 +0300 Subject: [PATCH] add getCrossChainAssetsByNetwork method --- package.json | 2 +- src/services/Aggregator/index.ts | 17 +++++++++++++++-- src/types.ts | 17 +++++++++++++++++ 3 files changed, 33 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index fc99e35..3570f29 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@orionprotocol/sdk", - "version": "0.20.41", + "version": "0.20.42-rc0", "description": "Orion Protocol SDK", "main": "./lib/index.cjs", "module": "./lib/index.js", diff --git a/src/services/Aggregator/index.ts b/src/services/Aggregator/index.ts index 1a4b229..0d9d4ab 100644 --- a/src/services/Aggregator/index.ts +++ b/src/services/Aggregator/index.ts @@ -6,9 +6,9 @@ import cancelOrderSchema from './schemas/cancelOrderSchema.js'; import orderBenefitsSchema from './schemas/orderBenefitsSchema.js'; import errorSchema from './schemas/errorSchema.js'; import placeAtomicSwapSchema from './schemas/placeAtomicSwapSchema.js'; -import { AggregatorWS } from './ws/index.js'; +import { AggregatorWS } from './ws'; import { atomicSwapHistorySchema } from './schemas/atomicSwapHistorySchema.js'; -import type { BasicAuthCredentials, SignedCancelOrderRequest, SignedOrder } from '../../types.js'; +import type { BasicAuthCredentials, SignedCancelOrderRequest, SignedOrder, SupportedChainShortNames } from '../../types.js'; import { pairConfigSchema, aggregatedOrderbookSchema, exchangeOrderbookSchema, poolReservesSchema, @@ -51,6 +51,7 @@ class Aggregator { this.getPairConfigs = this.getPairConfigs.bind(this); this.getPairsList = this.getPairsList.bind(this); this.getSwapInfo = this.getSwapInfo.bind(this); + this.getCrossChainAssetsByNetwork = this.getCrossChainAssetsByNetwork.bind(this); this.getTradeProfits = this.getTradeProfits.bind(this); this.placeAtomicSwap = this.placeAtomicSwap.bind(this); this.placeOrder = this.placeOrder.bind(this); @@ -290,6 +291,18 @@ class Aggregator { ); }; + getCrossChainAssetsByNetwork = (sourceChain: SupportedChainShortNames) => { + const url = new URL(`${this.apiUrl}/api/v1/cross-chain/assets`); + url.searchParams.append('sourceChain', sourceChain); + + return fetchWithValidation( + url.toString(), + z.array(z.number()), + { headers: this.basicAuthHeaders }, + errorSchema, + ) + } + getPrices = (assetPair: string, includePools: boolean) => { const url = new URL(`${this.apiUrl}/api/v1/prices/`); url.searchParams.append('assetPair', assetPair); diff --git a/src/types.ts b/src/types.ts index 7511476..8434867 100644 --- a/src/types.ts +++ b/src/types.ts @@ -99,6 +99,23 @@ export enum SupportedChainId { // BROKEN = '0', } +export enum SupportedChainShortNames { + MAINNET = 'ETH', + ROPSTEN = 'ETH-Ropsten', + GOERLI = 'ETH-Goerli', + ARBITRUM_GOERLI = 'Arbitrum Goerli', + FANTOM_OPERA = 'FTM', + POLYGON = 'Polygon', + OKC = 'OKC', + + POLYGON_TESTNET = 'Polygon Mumbai', + FANTOM_TESTNET = 'FTM-Testnet', + BSC = 'BSC', + BSC_TESTNET = 'BSC-Testnet', + OKC_TESTNET = 'OKC-Testnet', + DRIP_TESTNET = 'DRIP Chain', +} + const balanceTypes = ['exchange', 'wallet'] as const; export type Source = typeof balanceTypes[number];