Skip to content

Commit

Permalink
Make fields of the FilledNewOrderRequest as readonly;
Browse files Browse the repository at this point in the history
Fix typos
  • Loading branch information
skubarenko committed Aug 19, 2022
1 parent 25a79d1 commit 3abec28
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 10 deletions.
5 changes: 2 additions & 3 deletions src/atomex/atomex.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
6 changes: 3 additions & 3 deletions src/atomex/models/swapPreview.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand All @@ -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;
Expand Down
8 changes: 4 additions & 4 deletions src/exchange/models/newOrderRequest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ export interface NewOrderRequest {
}

export interface FilledNewOrderRequest {
clientOrderId: string;
orderBody: OrderBody | OrderPreview;
requisites: Mutable<SwapParticipantRequisites>;
proofsOfFunds: ProofOfFunds[];
readonly clientOrderId: string;
readonly orderBody: OrderBody | OrderPreview;
readonly requisites: Mutable<SwapParticipantRequisites>;
readonly proofsOfFunds: ProofOfFunds[];
}

0 comments on commit 3abec28

Please sign in to comment.