From d3a90960297264af3c46fb068b4f07ba1f4831e4 Mon Sep 17 00:00:00 2001 From: Thoralf-M <46689931+Thoralf-M@users.noreply.github.com> Date: Mon, 31 Jul 2023 11:58:39 +0200 Subject: [PATCH] Fix nodejs balance amounts (#975) * Fix amounts * Update bindings/nodejs/CHANGELOG.md Co-authored-by: Thibault Martinez * Update version --------- Co-authored-by: Thibault Martinez --- bindings/nodejs/CHANGELOG.md | 7 +++++++ bindings/nodejs/lib/utils/utils.ts | 5 ++--- bindings/nodejs/lib/wallet/account.ts | 12 ++++++------ bindings/nodejs/package.json | 2 +- 4 files changed, 16 insertions(+), 10 deletions(-) diff --git a/bindings/nodejs/CHANGELOG.md b/bindings/nodejs/CHANGELOG.md index 8568883ef6..3d61daf705 100644 --- a/bindings/nodejs/CHANGELOG.md +++ b/bindings/nodejs/CHANGELOG.md @@ -19,6 +19,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Security --> +## 1.0.3 - 2023-07-31 + +### Fixed + +- `Balance::{baseCoin, requiredStorageDeposit}` amounts; +- `Utils::computeStorageDeposit()` return amount; + ## 1.0.2 - 2023-07-28 ### Changed diff --git a/bindings/nodejs/lib/utils/utils.ts b/bindings/nodejs/lib/utils/utils.ts index d174c64450..3bb2922db8 100644 --- a/bindings/nodejs/lib/utils/utils.ts +++ b/bindings/nodejs/lib/utils/utils.ts @@ -16,7 +16,6 @@ import { Output, IRent, OutputId, - hexToBigInt, } from '../types'; import { AliasId, BlockId, FoundryId, NftId, TokenId } from '../types/block/id'; @@ -122,14 +121,14 @@ export class Utils { * @returns The required storage deposit. */ static computeStorageDeposit(output: Output, rent: IRent): bigint { - const depositHex = callUtilsMethod({ + const minStorageDepositAmount = callUtilsMethod({ name: 'computeStorageDeposit', data: { output, rent, }, }); - return hexToBigInt(depositHex); + return BigInt(minStorageDepositAmount); } /** diff --git a/bindings/nodejs/lib/wallet/account.ts b/bindings/nodejs/lib/wallet/account.ts index cabc5f95cb..6404084ef3 100644 --- a/bindings/nodejs/lib/wallet/account.ts +++ b/bindings/nodejs/lib/wallet/account.ts @@ -448,19 +448,19 @@ export class Account { payload.nativeTokens[i].available, ); } - payload.baseCoin.total = hexToBigInt(payload.baseCoin.total); - payload.baseCoin.available = hexToBigInt(payload.baseCoin.available); + payload.baseCoin.total = BigInt(payload.baseCoin.total); + payload.baseCoin.available = BigInt(payload.baseCoin.available); - payload.requiredStorageDeposit.alias = hexToBigInt( + payload.requiredStorageDeposit.alias = BigInt( payload.requiredStorageDeposit.alias, ); - payload.requiredStorageDeposit.basic = hexToBigInt( + payload.requiredStorageDeposit.basic = BigInt( payload.requiredStorageDeposit.basic, ); - payload.requiredStorageDeposit.foundry = hexToBigInt( + payload.requiredStorageDeposit.foundry = BigInt( payload.requiredStorageDeposit.foundry, ); - payload.requiredStorageDeposit.nft = hexToBigInt( + payload.requiredStorageDeposit.nft = BigInt( payload.requiredStorageDeposit.nft, ); diff --git a/bindings/nodejs/package.json b/bindings/nodejs/package.json index 3adfc34da4..a307cc7c5d 100644 --- a/bindings/nodejs/package.json +++ b/bindings/nodejs/package.json @@ -1,6 +1,6 @@ { "name": "@iota/sdk", - "version": "1.0.2", + "version": "1.0.3", "description": "Node.js binding to the IOTA SDK library", "main": "out/index.js", "types": "out/index.d.ts",