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 ### In web
```html ```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"> <script type="text/javascript">
NanocurrencyWeb.wallet.generate(...); NanocurrencyWeb.wallet.generate(...);
</script> </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' import BigNumber from 'bignumber.js'
//@ts-ignore //@ts-ignore
import { blake2b } from 'blakejs' 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 { export default class BlockSigner {
nanoAddress = new NanoAddress() nanoAddress = new NanoAddress()

View file

@ -35,11 +35,11 @@ export default class NanoConverter {
return value.toFixed(0) return value.toFixed(0)
case 'NANO': case 'NANO':
case 'MRAI': case 'MRAI':
return value.shiftedBy(-30).toFixed(15, 1) return value.shiftedBy(-30).toFixed(30, 1)
case 'KRAI': case 'KRAI':
return value.shiftedBy(-27).toFixed(12, 1) return value.shiftedBy(-27).toFixed(27, 1)
case 'RAI': case 'RAI':
return value.shiftedBy(-24).toFixed(9, 1) return value.shiftedBy(-24).toFixed(24, 1)
default: default:
throw new Error(`Unknown output unit ${outputUnit}, expected one of the following: RAW, NANO, MRAI, KRAI, RAI`) 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", "name": "nanocurrency-web",
"version": "1.2.1", "version": "1.2.2",
"description": "Toolkit for Nano cryptocurrency client side offline integrations", "description": "Toolkit for Nano cryptocurrency client side offline integrations",
"author": "Miro Metsänheimo <miro@metsanheimo.fi>", "author": "Miro Metsänheimo <miro@metsanheimo.fi>",
"license": "MIT", "license": "MIT",

View file

@ -193,7 +193,7 @@ describe('unit conversion tests', () => {
it('should convert raw to nano', () => { it('should convert raw to nano', () => {
const result = tools.convert('1000000000000000000000000000000', 'RAW', 'NANO') const result = tools.convert('1000000000000000000000000000000', 'RAW', 'NANO')
expect(result).to.equal('1.000000000000000') expect(result).to.equal('1.000000000000000000000000000000')
}) })
}) })