Skip to content

Commit

Permalink
Fix nodejs balance amounts (#975)
Browse files Browse the repository at this point in the history
* Fix amounts

* Update bindings/nodejs/CHANGELOG.md

Co-authored-by: Thibault Martinez <[email protected]>

* Update version

---------

Co-authored-by: Thibault Martinez <[email protected]>
  • Loading branch information
Thoralf-M and thibault-martinez authored Jul 31, 2023
1 parent 85ce3b2 commit d3a9096
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 10 deletions.
7 changes: 7 additions & 0 deletions bindings/nodejs/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 2 additions & 3 deletions bindings/nodejs/lib/utils/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import {
Output,
IRent,
OutputId,
hexToBigInt,
} from '../types';
import { AliasId, BlockId, FoundryId, NftId, TokenId } from '../types/block/id';

Expand Down Expand Up @@ -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);
}

/**
Expand Down
12 changes: 6 additions & 6 deletions bindings/nodejs/lib/wallet/account.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
);

Expand Down
2 changes: 1 addition & 1 deletion bindings/nodejs/package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down

0 comments on commit d3a9096

Please sign in to comment.