Version 1.2.2

* Fixed an issue where the unit converter wasn't able to convert high
precision numbers correctly, generating invalid blocks
This commit is contained in:
Miro Metsänheimo 2020-08-21 21:10:32 +03:00
commit b089a9d953
5 changed files with 14 additions and 14 deletions

View file

@ -210,7 +210,7 @@ const valid = tools.validateMnemonic('edge defense waste choose enrich upon flee
### In web
```html
<script src="https://unpkg.com/nanocurrency-web@1.2.1" type="text/javascript"></script>
<script src="https://unpkg.com/nanocurrency-web@1.2.2" type="text/javascript"></script>
<script type="text/javascript">
NanocurrencyWeb.wallet.generate(...);
</script>

View file

@ -1,13 +1,13 @@
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 Ed25519 from './ed25519'
import NanoAddress from './nano-address'
import NanoConverter from './nano-converter'
import Signer from './signer'
import Convert from './util/convert'
export default class BlockSigner {
nanoAddress = new NanoAddress()
@ -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

View file

@ -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`)
}

View file

@ -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 <miro@metsanheimo.fi>",
"license": "MIT",

View file

@ -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')
})
})