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:
parent
951bac9278
commit
b089a9d953
5 changed files with 14 additions and 14 deletions
|
|
@ -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>
|
||||||
|
|
|
||||||
|
|
@ -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()
|
||||||
|
|
@ -18,7 +18,7 @@ export default class BlockSigner {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sign a receive block
|
* Sign a receive block
|
||||||
*
|
*
|
||||||
* @param {ReceiveBlock} data The data required to 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
|
* @param {string} privateKey Private key to sign the data with
|
||||||
* @returns {SignedBlock} the signed block to publish to the blockchain
|
* @returns {SignedBlock} the signed block to publish to the blockchain
|
||||||
|
|
@ -89,7 +89,7 @@ export default class BlockSigner {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sign a send block
|
* Sign a send block
|
||||||
*
|
*
|
||||||
* @param {SendBlock} data The data required to 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
|
* @param {string} privateKey Private key to sign the data with
|
||||||
* @returns {SignedBlock} the signed block to publish to the blockchain
|
* @returns {SignedBlock} the signed block to publish to the blockchain
|
||||||
|
|
|
||||||
|
|
@ -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`)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -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",
|
||||||
|
|
|
||||||
|
|
@ -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')
|
||||||
})
|
})
|
||||||
|
|
||||||
})
|
})
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue