From 3abec289641e271a311e44ca282381f127a779ac Mon Sep 17 00:00:00 2001 From: Andrew Skubarenko Date: Sat, 20 Aug 2022 00:39:40 +0300 Subject: [PATCH] Make fields of the FilledNewOrderRequest as readonly; Fix typos --- src/atomex/atomex.ts | 5 ++--- src/atomex/models/swapPreview.ts | 6 +++--- src/exchange/models/newOrderRequest.ts | 8 ++++---- 3 files changed, 9 insertions(+), 10 deletions(-) diff --git a/src/atomex/atomex.ts b/src/atomex/atomex.ts index 1a4e494a..210ac595 100644 --- a/src/atomex/atomex.ts +++ b/src/atomex/atomex.ts @@ -83,13 +83,12 @@ export class Atomex implements AtomexService { throw new Error('Swap tracking is not implemented yet'); const swapPreview = newSwapRequestOrSwapId.swapPreview; - if (!swapPreview.errors.length) + if (swapPreview.errors.length) throw new Error('Swap preview has errors'); const fromAddress = swapPreview.to.address; if (!fromAddress) - throw new Error('Swap preview has not the "from" address'); - + throw new Error('Swap preview doesn\'t have the "from" address'); const quoteCurrencyId = symbolsHelper.getQuoteBaseCurrenciesBySymbol(swapPreview.symbol)[0]; const directionName: 'from' | 'to' = quoteCurrencyId === swapPreview.from.currencyId ? 'from' : 'to'; diff --git a/src/atomex/models/swapPreview.ts b/src/atomex/models/swapPreview.ts index f865fad1..078011b2 100644 --- a/src/atomex/models/swapPreview.ts +++ b/src/atomex/models/swapPreview.ts @@ -5,8 +5,8 @@ import type { OrderType } from '../../exchange/index'; export interface SwapPreview { readonly type: OrderType; - readonly from: SwapPreviewData; - readonly to: SwapPreviewData; + readonly from: SwapPreviewDirectionData; + readonly to: SwapPreviewDirectionData; readonly symbol: string; readonly side: Side; readonly fees: { @@ -17,7 +17,7 @@ export interface SwapPreview { readonly warnings: readonly SwapPreviewWarning[]; } -interface SwapPreviewData { +interface SwapPreviewDirectionData { readonly address?: string; readonly currencyId: Currency['id']; readonly actual: SwapPreviewCurrencyData; diff --git a/src/exchange/models/newOrderRequest.ts b/src/exchange/models/newOrderRequest.ts index d3d61204..706d5eff 100644 --- a/src/exchange/models/newOrderRequest.ts +++ b/src/exchange/models/newOrderRequest.ts @@ -23,9 +23,9 @@ export interface NewOrderRequest { } export interface FilledNewOrderRequest { - clientOrderId: string; - orderBody: OrderBody | OrderPreview; - requisites: Mutable; - proofsOfFunds: ProofOfFunds[]; + readonly clientOrderId: string; + readonly orderBody: OrderBody | OrderPreview; + readonly requisites: Mutable; + readonly proofsOfFunds: ProofOfFunds[]; }