From f64e19ba6d9f94acbe5ec41963dcd725b51d05d9 Mon Sep 17 00:00:00 2001 From: Marton Lederer Date: Sat, 13 Apr 2024 13:08:18 +0200 Subject: [PATCH] fix: keep denomination with quantity init value --- src/Quantity.ts | 3 ++- src/Token.ts | 11 +++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/Quantity.ts b/src/Quantity.ts index 5de557e..5322531 100644 --- a/src/Quantity.ts +++ b/src/Quantity.ts @@ -35,8 +35,9 @@ export default class Quantity { throw new Error("Could not convert object to quantity"); } + base = base.clone(); + base._convert(this.#D); this.#qty = base.#qty; - this.#D = base.#D; break; case "undefined": break; diff --git a/src/Token.ts b/src/Token.ts index 2a42223..e2e254e 100644 --- a/src/Token.ts +++ b/src/Token.ts @@ -81,6 +81,17 @@ export class TokenInstance { return this.#info; } + /** + * Get a quantity instance for this token. The instance + * will have the token's denomination defined by default. + */ + get Quantity() { + return new Quantity( + 0n, + this.info.Denomination + ); + } + /** * Get balance for an address * @param address Wallet address