From 8c529413de227f12b5bf87e4874b8e11a81da899 Mon Sep 17 00:00:00 2001 From: Vladimir Date: Wed, 14 Aug 2024 22:05:44 +0300 Subject: [PATCH] feat: add toJSON to immutables (#17) --- src/immutables/dst-immutables-complement.ts | 14 ++++++++++++++ src/immutables/immutables.ts | 4 ++++ 2 files changed, 18 insertions(+) diff --git a/src/immutables/dst-immutables-complement.ts b/src/immutables/dst-immutables-complement.ts index 281d3d3..0663242 100644 --- a/src/immutables/dst-immutables-complement.ts +++ b/src/immutables/dst-immutables-complement.ts @@ -21,4 +21,18 @@ export class DstImmutablesComplement { params.safetyDeposit ) } + + public toJSON(): { + maker: string + amount: string + token: string + safetyDeposit: string + } { + return { + maker: this.maker.toString(), + amount: this.amount.toString(), + token: this.token.toString(), + safetyDeposit: this.safetyDeposit.toString() + } + } } diff --git a/src/immutables/immutables.ts b/src/immutables/immutables.ts index 11636c0..28cd61b 100644 --- a/src/immutables/immutables.ts +++ b/src/immutables/immutables.ts @@ -96,6 +96,10 @@ export class Immutables { ) } + public toJSON(): ImmutablesData { + return this.build() + } + public withComplement(dstComplement: DstImmutablesComplement): Immutables { return Immutables.new({...this, ...dstComplement}) }