Skip to content

Commit b8fcc9d

Browse files
author
Fabrice Bascoulergue
authored
Bring changes to production (#21)
* Fix ulum to ulum unit conversion * Bump version to 0.4.5
1 parent 2873956 commit b8fcc9d

File tree

3 files changed

+5
-2
lines changed

3 files changed

+5
-2
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@lum-network/sdk-javascript",
3-
"version": "0.4.4",
3+
"version": "0.4.5",
44
"license": "Apache-2.0",
55
"description": "Javascript SDK library for NodeJS and Web browsers to interact with the Lum Network.",
66
"homepage": "https://github.com/lum-network/sdk-javascript#readme",

src/utils/units.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@ export const convertUnit = (coin: LumTypes.Coin, toDenom: string): string => {
1616
throw new Error('More than one separator found');
1717
}
1818

19-
if (coin.denom.startsWith('u') && coin.denom.endsWith(toDenom)) {
19+
if (coin.denom === toDenom) {
20+
return coin.amount;
21+
} else if (coin.denom.startsWith('u') && coin.denom.endsWith(toDenom)) {
2022
// from micro to base
2123
if (parts.length !== 1) {
2224
throw new Error('Micro units cannot have floating precision');

tests/utils.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { LumConstants, LumUtils } from '../src';
22

33
describe('Utils', () => {
44
it('Unit conversion should output consistent results', () => {
5+
expect(LumUtils.convertUnit({ denom: LumConstants.MicroLumDenom, amount: '23456789' }, LumConstants.MicroLumDenom)).toEqual('23456789');
56
expect(LumUtils.convertUnit({ denom: LumConstants.LumDenom, amount: '23.456789' }, LumConstants.LumDenom)).toEqual('23.456789');
67
expect(LumUtils.convertUnit({ denom: LumConstants.LumDenom, amount: '23.456789' }, LumConstants.MicroLumDenom)).toEqual('23456789');
78
expect(LumUtils.convertUnit({ denom: LumConstants.LumDenom, amount: '23456789' }, LumConstants.MicroLumDenom)).toEqual('23456789000000');

0 commit comments

Comments
 (0)