Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix atoms <––> uatoms conversion #2274

Merged
merged 4 commits into from
Mar 15, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions PENDING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
### Fixed

- [\#2257](https://github.com/cosmos/voyager/pull/2257) fixed console
- [\#2273](https://github.com/cosmos/voyager/issues/2273) fixed atoms and uatoms conversion @fedekunze
12 changes: 6 additions & 6 deletions app/src/renderer/scripts/num.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ import BigNumber from "bignumber.js"
* @module num
*/

const SMALLEST = 1e-7
const SMALLEST = 1e-6
const language = window.navigator.userLanguage || window.navigator.language
function full(number = 0) {
return new Intl.NumberFormat(language, { minimumFractionDigits: 7 })
return new Intl.NumberFormat(language, { minimumFractionDigits: 6 })
.format(number)
}
function shortNumber(number = 0) {
Expand All @@ -29,12 +29,12 @@ function prettyDecimals(number = 0) {
).format(number)

// remove all trailing zeros
while(longDecimals.charAt(longDecimals.length - 1) === `0`) {
while (longDecimals.charAt(longDecimals.length - 1) === `0`) {
longDecimals = longDecimals.substr(0, longDecimals.length - 1)
}

// remove decimal separator from whole numbers
if(Number.isNaN(Number(longDecimals.charAt(longDecimals.length - 1)))) {
if (Number.isNaN(Number(longDecimals.charAt(longDecimals.length - 1)))) {
longDecimals = longDecimals.substr(0, longDecimals.length - 1)
}

Expand All @@ -53,10 +53,10 @@ function percent(number = 0) {
).format(Math.round(number * 10000) / 100) + `%`
}
function atoms(number = 0) {
return BigNumber(number).div(10e6).toNumber()
return BigNumber(number).div(1e6).toNumber()
}
function uatoms(number = 0) {
return BigNumber(number).times(10e6).toString()
return BigNumber(number).times(1e6).toString()
}

module.exports = {
Expand Down
4 changes: 2 additions & 2 deletions test/unit/specs/components/common/TmBalance.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,10 @@ describe(`TmBalance`, () => {
})

it(`displays unbonded tokens`, () => {
expect(wrapper.vm.unbondedAtoms).toBe(`123.0000…`)
expect(wrapper.vm.unbondedAtoms).toBe(`1,230.0000…`)
})
it(`gets user rewards`, () => {
expect(wrapper.vm.rewards).toBe(`100,045.0000…`)
expect(wrapper.vm.rewards).toBe(`1,000,450.0000…`)
})

it(`shows 0 if user doesn't have rewards`, () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ exports[`TmBalance has the expected html structure before adding props 1`] = `
class="total-atoms__value"
>

321.0000…
3,210.0000…

</h2>

Expand All @@ -44,7 +44,7 @@ exports[`TmBalance has the expected html structure before adding props 1`] = `
</h3>

<h2>
123.0000…
1,230.0000…
</h2>
</div>

Expand All @@ -56,7 +56,7 @@ exports[`TmBalance has the expected html structure before adding props 1`] = `
</h3>

<h2>
100,045.0000…
1,000,450.0000…
</h2>

<tm-btn-stub
Expand Down
8 changes: 4 additions & 4 deletions test/unit/specs/components/governance/ModalDeposit.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ describe(`ModalDeposit`, () => {
let wrapper, store
const { mount, localVue } = setup()
localVue.use(Vuelidate)
localVue.directive(`tooltip`, () => {})
localVue.directive(`focus`, () => {})
localVue.directive(`tooltip`, () => { })
localVue.directive(`focus`, () => { })

beforeEach(async () => {
const coins = [
Expand Down Expand Up @@ -68,7 +68,7 @@ describe(`ModalDeposit`, () => {
})

it(`when the amount deposited higher than the user's balance`, async () => {
wrapper.setData({ amount: 25 })
wrapper.setData({ amount: 250 })
expect(wrapper.vm.validateForm()).toBe(false)
await wrapper.vm.$nextTick()
const errorMessage = wrapper.find(`input#amount + div`)
Expand Down Expand Up @@ -110,7 +110,7 @@ describe(`ModalDeposit`, () => {
{
amount: [
{
amount: `100000000`,
amount: `10000000`,
denom: `stake`
}
],
Expand Down
4 changes: 2 additions & 2 deletions test/unit/specs/components/governance/ModalPropose.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ describe(`ModalPropose`, () => {

it(`if the amount for initial deposit is higher than the user's balance`, async () => {
wrapper.setData(inputs)
wrapper.setData({ amount: 25 })
wrapper.setData({ amount: 250 })
await wrapper.vm.$nextTick()
expect(wrapper.vm.validateForm()).toBe(false)
await wrapper.vm.$nextTick()
Expand Down Expand Up @@ -162,7 +162,7 @@ describe(`ModalPropose`, () => {
`submitProposal`,
{
description: `a valid description for the proposal`,
initial_deposit: [{ amount: `150000000`, denom: `stake` }],
initial_deposit: [{ amount: `15000000`, denom: `stake` }],
title: `A new text proposal for Cosmos`,
type: `Text`,
password: `1234567890`,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ describe(`TabGovernanceParameters`, () => {
let wrapper, store
const { mount, localVue } = setup()
localVue.use(Vuelidate)
localVue.directive(`tooltip`, () => {})
localVue.directive(`focus`, () => {})
localVue.directive(`tooltip`, () => { })
localVue.directive(`focus`, () => { })

const $store = {
commit: jest.fn(),
Expand Down Expand Up @@ -47,7 +47,7 @@ describe(`TabGovernanceParameters`, () => {
})

it(`displays the minimum deposit`, () => {
expect(wrapper.vm.minimumDeposit).toEqual(`10 STAKEs`)
expect(wrapper.vm.minimumDeposit).toEqual(`100 STAKEs`)
})

it(`displays deposit period in days`, () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,31 +45,31 @@ exports[`LiProposal has the expected html structure 1`] = `
class="li-proposal__value yes"
>

500
5000

</td>

<td
class="li-proposal__value no"
>

25
250

</td>

<td
class="li-proposal__value no_with_veto"
>

10
100

</td>

<td
class="li-proposal__value abstain"
>

56
560

</td>
</tr>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ exports[`PageProposal has the expected html structure if user has signed in 1`]

<dd>

200 stake
2000 stake

</dd>
</dl>
Expand Down Expand Up @@ -302,7 +302,7 @@ exports[`PageProposal renders votes in HTML when voting is open 1`] = `

<dd>

200 stake
2000 stake

</dd>
</dl>
Expand All @@ -315,7 +315,7 @@ exports[`PageProposal renders votes in HTML when voting is open 1`] = `
</dt>

<dd>
1000
10000
</dd>
</dl>
</div>
Expand All @@ -335,7 +335,7 @@ exports[`PageProposal renders votes in HTML when voting is open 1`] = `
</dt>

<dd>
100 / 10%
1000 / 10%
</dd>
</dl>

Expand All @@ -347,7 +347,7 @@ exports[`PageProposal renders votes in HTML when voting is open 1`] = `
</dt>

<dd>
200 / 20%
2000 / 20%
</dd>
</dl>

Expand All @@ -360,7 +360,7 @@ exports[`PageProposal renders votes in HTML when voting is open 1`] = `

<dd>

300 / 30%
3000 / 30%

</dd>
</dl>
Expand All @@ -373,7 +373,7 @@ exports[`PageProposal renders votes in HTML when voting is open 1`] = `
</dt>

<dd>
400 / 40%
4000 / 40%
</dd>
</dl>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ exports[`TabGovernanceParameters has the expected html structure 1`] = `

<dd>

10 STAKEs
100 STAKEs

</dd>
</dl>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,31 +143,31 @@ exports[`TabProposals has the expected html structure 1`] = `
class="li-proposal__value yes"
>

10
100

</td>

<td
class="li-proposal__value no"
>

30
300

</td>

<td
class="li-proposal__value no_with_veto"
>

100
1000

</td>

<td
class="li-proposal__value abstain"
>

20
200

</td>
</tr>
Expand Down Expand Up @@ -351,31 +351,31 @@ exports[`TabProposals has the expected html structure 1`] = `
class="li-proposal__value yes"
>

500
5000

</td>

<td
class="li-proposal__value no"
>

25
250

</td>

<td
class="li-proposal__value no_with_veto"
>

10
100

</td>

<td
class="li-proposal__value abstain"
>

56
560

</td>
</tr>
Expand Down
Loading