From: Miro Metsänheimo Date: Fri, 21 Aug 2020 18:10:32 +0000 (+0300) Subject: Version 1.2.2 X-Git-Tag: v0.0.1~26 X-Git-Url: https://zoso.dev/?a=commitdiff_plain;h=b089a9d953db3cdc41dbb1587ee2d927705b14ad;p=libnemo.git Version 1.2.2 * Fixed an issue where the unit converter wasn't able to convert high precision numbers correctly, generating invalid blocks --- diff --git a/README.md b/README.md index b78e481..a3663f0 100644 --- a/README.md +++ b/README.md @@ -210,7 +210,7 @@ const valid = tools.validateMnemonic('edge defense waste choose enrich upon flee ### In web ```html - + diff --git a/lib/block-signer.ts b/lib/block-signer.ts index 369ddac..6e41e94 100644 --- a/lib/block-signer.ts +++ b/lib/block-signer.ts @@ -1,12 +1,12 @@ +import BigNumber from 'bignumber.js' +//@ts-ignore +import { blake2b } from 'blakejs' + import Ed25519 from './ed25519' -import Convert from './util/convert' import NanoAddress from './nano-address' import NanoConverter from './nano-converter' import Signer from './signer' - -import BigNumber from 'bignumber.js' -//@ts-ignore -import { blake2b } from 'blakejs' +import Convert from './util/convert' export default class BlockSigner { @@ -18,7 +18,7 @@ export default class BlockSigner { /** * Sign a receive block - * + * * @param {ReceiveBlock} data The data required to sign a receive block * @param {string} privateKey Private key to sign the data with * @returns {SignedBlock} the signed block to publish to the blockchain @@ -89,7 +89,7 @@ export default class BlockSigner { /** * Sign a send block - * + * * @param {SendBlock} data The data required to sign a send block * @param {string} privateKey Private key to sign the data with * @returns {SignedBlock} the signed block to publish to the blockchain diff --git a/lib/nano-converter.ts b/lib/nano-converter.ts index 096beb6..3c46006 100644 --- a/lib/nano-converter.ts +++ b/lib/nano-converter.ts @@ -35,11 +35,11 @@ export default class NanoConverter { return value.toFixed(0) case 'NANO': case 'MRAI': - return value.shiftedBy(-30).toFixed(15, 1) + return value.shiftedBy(-30).toFixed(30, 1) case 'KRAI': - return value.shiftedBy(-27).toFixed(12, 1) + return value.shiftedBy(-27).toFixed(27, 1) case 'RAI': - return value.shiftedBy(-24).toFixed(9, 1) + return value.shiftedBy(-24).toFixed(24, 1) default: throw new Error(`Unknown output unit ${outputUnit}, expected one of the following: RAW, NANO, MRAI, KRAI, RAI`) } diff --git a/package.json b/package.json index 3bffa75..5b46d84 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "nanocurrency-web", - "version": "1.2.1", + "version": "1.2.2", "description": "Toolkit for Nano cryptocurrency client side offline integrations", "author": "Miro Metsänheimo ", "license": "MIT", diff --git a/test/test.js b/test/test.js index 3edf7bf..a93b9ad 100644 --- a/test/test.js +++ b/test/test.js @@ -193,7 +193,7 @@ describe('unit conversion tests', () => { it('should convert raw to nano', () => { const result = tools.convert('1000000000000000000000000000000', 'RAW', 'NANO') - expect(result).to.equal('1.000000000000000') + expect(result).to.equal('1.000000000000000000000000000000') }) })