]> zoso.dev Git - libnemo.git/commitdiff
Version 1.2.2
authorMiro Metsänheimo <miro@metsanheimo.fi>
Fri, 21 Aug 2020 18:10:32 +0000 (21:10 +0300)
committerMiro Metsänheimo <miro@metsanheimo.fi>
Fri, 21 Aug 2020 18:10:32 +0000 (21:10 +0300)
* Fixed an issue where the unit converter wasn't able to convert high
precision numbers correctly, generating invalid blocks

README.md
lib/block-signer.ts
lib/nano-converter.ts
package.json
test/test.js

index b78e481232bfc9aa0fe2e3c3283ef48c45b57143..a3663f0756c0f610532c4acbf4f39cebbfa7ee9b 100644 (file)
--- a/README.md
+++ b/README.md
@@ -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>
index 369ddaca60fe8970d3e6cd073d2463d03c210c0c..6e41e9405a1c30896765f594aef90f75f1b9a8fc 100644 (file)
@@ -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
index 096beb63d868ee7389199a8074e3161d69d8624d..3c460061579119a47f0d6cae1603c49b1099a2f6 100644 (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`)
                }
index 3bffa75f5995da571600259ce0998dad61af78a6..5b46d84e29dbc3e337e826f62c4e52348395bd87 100644 (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",
index 3edf7bf4255a868474d261bb625107bc07bfc7de..a93b9ad02d03744e591d9654c66a560307148a78 100644 (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')
        })
 
 })