Skip to content
Permalink
Browse files

Merge pull request #1320 from ArkEcosystem/develop

chore: merge develop into master
  • Loading branch information...
alexbarnsley committed Jul 12, 2019
2 parents c231579 + 8d64e18 commit cf930c715cfc62d8d2366f2d4f54c9aec373ade0
Showing with 762 additions and 499 deletions.
  1. +8 −8 __tests__/unit/__fixtures__/store/delegate.js
  2. +10 −7 __tests__/unit/components/Input/InputCurrency.spec.js
  3. +31 −24 __tests__/unit/components/Input/InputFee.spec.js
  4. +1 −1 __tests__/unit/components/Menu/MenuNavigation.spec.js
  5. +11 −4 __tests__/unit/mixins/currency.spec.js
  6. +13 −20 __tests__/unit/pages/Profile/ProfileAll.spec.js
  7. +7 −2 __tests__/unit/services/client.spec.js
  8. +2 −2 __tests__/unit/store/modules/delegate.spec.js
  9. +13 −4 __tests__/unit/store/modules/profile.spec.js
  10. +1 −1 package.json
  11. +10 −5 src/renderer/App.vue
  12. +0 −44 src/renderer/components/App/AppSidemenu/AppSidemenu.vue
  13. +156 −133 src/renderer/components/App/AppSidemenu/AppSidemenuNetworkStatus.vue
  14. +141 −118 src/renderer/components/App/AppSidemenu/AppSidemenuSettings.vue
  15. +20 −16 src/renderer/components/Input/InputCurrency.vue
  16. +17 −24 src/renderer/components/Input/InputFee.vue
  17. +6 −0 src/renderer/components/MarketChart/MarketChart.vue
  18. +43 −3 src/renderer/components/MarketChart/MarketChartHeader.vue
  19. +6 −2 src/renderer/components/Menu/MenuTab/MenuTab.vue
  20. +7 −1 src/renderer/components/Menu/MenuTab/MenuTabItem.vue
  21. +2 −2 src/renderer/components/Transaction/TransactionConfirm/TransactionConfirm.vue
  22. +7 −4 src/renderer/components/Transaction/TransactionForm/TransactionFormTransfer.vue
  23. +1 −1 src/renderer/components/Transaction/TransactionForm/TransactionFormVote.vue
  24. +1 −6 src/renderer/components/Wallet/WalletAddress.vue
  25. +33 −0 src/renderer/components/Wallet/WalletDetails/WalletDetails.vue
  26. +13 −6 src/renderer/components/Wallet/WalletHeading/WalletHeadingInfo.vue
  27. +2 −1 src/renderer/i18n/locales/en-US.js
  28. +28 −2 src/renderer/i18n/locales/it-IT.js
  29. +13 −6 src/renderer/mixins/currency.js
  30. +9 −6 src/renderer/models/base.js
  31. +9 −13 src/renderer/models/delegate.js
  32. +1 −1 src/renderer/models/peer.js
  33. +1 −1 src/renderer/models/profile.js
  34. +5 −6 src/renderer/models/transaction.js
  35. +6 −4 src/renderer/models/wallet.js
  36. +36 −14 src/renderer/pages/Dashboard.vue
  37. +3 −1 src/renderer/pages/Profile/ProfileAll.vue
  38. +81 −0 src/renderer/plugins/bignumber.js
  39. +3 −2 src/renderer/services/client.js
  40. +2 −2 src/renderer/store/modules/delegate.js
  41. +3 −2 src/renderer/store/modules/profile.js
@@ -2,35 +2,35 @@ const delegate1 = {
username: 'delegate1',
address: 'AKdr5d9AMEnsKYxpDcoHdyyjSCKVx3r9Nj',
publicKey: '020431436cf94f3c6a6ba566fe9e42678db8486590c732ca6c3803a10a86f50b92',
voteWeight: 4202880284636,
votes: '4202880284636',
blocks: {
produced: 108940
},
production: {
approval: 0.03
},
forged: {
fees: 1173040419815,
rewards: 21788000000000,
total: 22961040419815
fees: '1173040419815',
rewards: '21788000000000',
total: '22961040419815'
},
rank: 59
}
const delegate2 = {
username: 'delegate2',
address: 'AU1TGCYoWzBnGMyMK9GTS8BG6EFbgc5xxC',
publicKey: '02bf72c578a12c35a97ca1230b93017161ee42c3f0ab82f6fe7c95b3b43561a076',
voteWeight: 2500294939144,
votes: '2500294939144',
blocks: {
produced: 2497
},
production: {
approval: 0.02
},
forged: {
fees: 3085620625,
rewards: 499400000000,
total: 502485620625
fees: '3085620625',
rewards: '499400000000',
total: '502485620625'
},
rank: 62
}
@@ -5,6 +5,7 @@ import { mount } from '@vue/test-utils'
import { useI18n } from '../../__utils__/i18n'
import { InputCurrency } from '@/components/Input'
import store from '@/store'
import BigNumber from '@/plugins/bignumber'

jest.mock('@/store', () => {
return {
@@ -38,7 +39,9 @@ describe('InputCurrency', () => {
i18n,
propsData: {
currency: mockNetwork.token,
value: ''
value: '',
minimumAmount: new BigNumber(1e8),
maximumAmount: new BigNumber(1e8)
},
mocks: {
currency_format: () => 'NET 9.9',
@@ -119,7 +122,7 @@ describe('InputCurrency', () => {
const wrapper = mountComponent()
wrapper.find('.InputCurrency input').setValue(99)

expect(wrapper.emitted('input')[0][0]).toEqual(99)
expect(wrapper.emitted('input')[0][0]).toEqual('99')
})

it('should emit the `raw` event', () => {
@@ -135,10 +138,10 @@ describe('InputCurrency', () => {
const wrapper = mountComponent()

wrapper.vm.emitInput('not')
expect(wrapper.emitted('input')[0][0]).toEqual(0)
expect(wrapper.emitted('input')[0][0]).toEqual('0')

wrapper.vm.emitInput(null)
expect(wrapper.emitted('input')[1][0]).toEqual(0)
expect(wrapper.emitted('input')[1][0]).toEqual('0')
})

it('should sanitize the values', () => {
@@ -154,13 +157,13 @@ describe('InputCurrency', () => {
const wrapper = mountComponent()

wrapper.vm.emitInput('122,0122')
expect(wrapper.emitted('input')[0][0]).toEqual(122.0122)
expect(wrapper.emitted('input')[0][0]).toEqual('122.0122')

wrapper.vm.emitInput('1,,23')
expect(wrapper.emitted('input')[1][0]).toEqual(1.23)
expect(wrapper.emitted('input')[1][0]).toEqual('1.23')

wrapper.vm.emitInput('6,,97')
expect(wrapper.emitted('input')[2][0]).toEqual(6.97)
expect(wrapper.emitted('input')[2][0]).toEqual('6.97')
})
})

@@ -7,6 +7,7 @@ import CurrencyMixin from '@/mixins/currency'
import FormatterMixin from '@/mixins/formatter'
import { InputFee } from '@/components/Input'
import store from '@/store'
import BigNumber from '@/plugins/bignumber'

jest.mock('@/store', () => {
return {
@@ -64,12 +65,14 @@ describe('InputFee', () => {
i18n,
propsData: {
currency: mockNetwork.token,
transactionType: 0
transactionType: 0,
minimumAmount: new BigNumber(1e8),
maximumAmount: new BigNumber(1e8)
},
mixins: [CurrencyMixin, FormatterMixin],
mocks: {
session_network: mockNetwork,
wallet_fromRoute: { balance: 10 },
wallet_fromRoute: { balance: '10' },
$store: store,
$synchronizer: {
focus: jest.fn(),
@@ -99,22 +102,21 @@ describe('InputFee', () => {
let wrapper = mountComponent({
propsData: { transactionType: 0 }
})
expect(wrapper.vm.maxV1fee).toEqual(V1.fees[0] * 1e-8)
expect(wrapper.vm.maxV1fee).toEqual(0.1)
expect(wrapper.vm.maxV1fee).toEqual(V1.fees[0])

wrapper = mountComponent({
propsData: { transactionType: 3 }
})
expect(wrapper.vm.maxV1fee).toEqual(V1.fees[3] * 1e-8)
expect(wrapper.vm.maxV1fee).toEqual(V1.fees[3])
})
})

describe('rangePercentage', () => {
const mockedComponent = (min, max) => {
return mountComponent({
computed: {
feeChoiceMin: () => min,
feeChoiceMax: () => max
feeChoiceMin: () => new BigNumber(min),
feeChoiceMax: () => new BigNumber(max)
}
})
}
@@ -151,9 +153,9 @@ describe('InputFee', () => {
return mountComponent({
computed: {
feeChoices: () => ({
MINIMUM: 1e-8,
INPUT: 1e-8,
ADVANCED: 1e-8,
MINIMUM: new BigNumber(1e-8),
INPUT: new BigNumber(1e-8),
ADVANCED: new BigNumber(1e-8),
...fees
})
}
@@ -162,31 +164,31 @@ describe('InputFee', () => {

it('should be `true` if the current fee matches, average and maximum fee are the same', () => {
const wrapper = mockedComponent({
AVERAGE: 1,
MAXIMUM: 1
AVERAGE: new BigNumber(1),
MAXIMUM: new BigNumber(1)
})
wrapper.vm.fee = 1
expect(wrapper.vm.isStaticFee).toBeTrue()
})

it('should be `false` if the current fee matches, average and maximum fee are not the same', () => {
let wrapper = mockedComponent({
AVERAGE: 2,
MAXIMUM: 1
AVERAGE: new BigNumber(2),
MAXIMUM: new BigNumber(1)
})
wrapper.vm.fee = 1
expect(wrapper.vm.isStaticFee).toBeFalse()

wrapper = mockedComponent({
AVERAGE: 1,
MAXIMUM: 2
AVERAGE: new BigNumber(1),
MAXIMUM: new BigNumber(2)
})
wrapper.vm.fee = 1

expect(wrapper.vm.isStaticFee).toBeFalse()
wrapper = mockedComponent({
AVERAGE: 1,
MAXIMUM: 1
AVERAGE: new BigNumber(1),
MAXIMUM: new BigNumber(1)
})
wrapper.vm.fee = 2
expect(wrapper.vm.isStaticFee).toBeFalse()
@@ -224,7 +226,7 @@ describe('InputFee', () => {
const wrapper = mountComponent()

wrapper.vm.emitFee('97')
expect(wrapper.emitted('input')[0][0]).toBeNumber()
expect(wrapper.emitted('input')[0][0]).toBeString()
})
})

@@ -244,7 +246,8 @@ describe('InputFee', () => {
it('should use the V1 fee as average always', () => {
const wrapper = mountComponent()

expect(wrapper.vm.feeChoices.AVERAGE).toEqual(0.1)
expect(wrapper.vm.feeChoices.AVERAGE).toBeInstanceOf(BigNumber)
expect(wrapper.vm.feeChoices.AVERAGE.toString()).toEqual('0.1')
})
})

@@ -263,6 +266,7 @@ describe('InputFee', () => {
it('should use it as average', () => {
const wrapper = mountComponent()

expect(wrapper.vm.feeChoices.AVERAGE).toBeInstanceOf(BigNumber)
expect(wrapper.vm.feeChoices.AVERAGE).toBeWithin(0.0048, 0.0048000001)
})
})
@@ -282,7 +286,8 @@ describe('InputFee', () => {
it('should use the V1 fee as maximum always', () => {
const wrapper = mountComponent()

expect(wrapper.vm.feeChoices.MAXIMUM).toEqual(0.1)
expect(wrapper.vm.feeChoices.MAXIMUM).toBeInstanceOf(BigNumber)
expect(wrapper.vm.feeChoices.MAXIMUM.toString()).toEqual('0.1')
})
})

@@ -301,6 +306,7 @@ describe('InputFee', () => {
it('should use it as maximum', () => {
const wrapper = mountComponent()

expect(wrapper.vm.feeChoices.MAXIMUM).toBeInstanceOf(BigNumber)
expect(wrapper.vm.feeChoices.MAXIMUM).toBeWithin(0.03, 0.03000001)
})
})
@@ -313,7 +319,8 @@ describe('InputFee', () => {
it('should use it as maximum', () => {
const wrapper = mountComponent()

expect(wrapper.vm.feeChoices.MAXIMUM).toBe(0.1)
expect(wrapper.vm.feeChoices.MAXIMUM).toBeInstanceOf(BigNumber)
expect(wrapper.vm.feeChoices.MAXIMUM.toString()).toBe('0.1')
})
})
})
@@ -328,7 +335,7 @@ describe('InputFee', () => {

describe('when the balance is smaller than the fee', () => {
it('should return the message about funds', () => {
wrapper.vm.wallet_fromRoute.balance = 50000
wrapper.vm.wallet_fromRoute.balance = '50000'
wrapper.vm.fee = 20e8
expect(wrapper.vm.insufficientFundsError).toEqual('TRANSACTION_FORM.ERROR.NOT_ENOUGH_BALANCE')

@@ -341,7 +348,7 @@ describe('InputFee', () => {
describe('when the balance is bigger than the fee', () => {
it('should return an empty message', () => {
// NOTE: Balance is in arktoshi, while fee is in ARK
wrapper.vm.wallet_fromRoute.balance = 20e8
wrapper.vm.wallet_fromRoute.balance = '20e8'
wrapper.vm.fee = 1
expect(wrapper.vm.insufficientFundsError).toBeNull()

@@ -32,7 +32,7 @@ describe('MenuNavigation', () => {
const slot = 'My MenuNavigationItem component'
const wrapper = mount(MenuNavigationItem, {
provide: {
switchToId: jest.fn()
switchToItem: jest.fn()
},
slots: {
default: slot
@@ -1,6 +1,7 @@
import { createLocalVue, shallowMount } from '@vue/test-utils'
import useI18n from '../__utils__/i18n'
import CurrencyMixin from '@/mixins/currency'
import BigNumber from '@/plugins/bignumber'

describe('Mixins > Currency', () => {
const network = {
@@ -182,10 +183,13 @@ describe('Mixins > Currency', () => {
describe('when not receiving a network', () => {
it('should use the session network to convert an amount from arktoshi to ARK', () => {
let amount = Math.pow(10, 9)
expect(subToUnit(amount)).toEqual('10')
let unit = subToUnit(amount)
expect(unit).toBeInstanceOf(BigNumber)
expect(unit.toString()).toEqual('10')

amount = Math.pow(10, 12) + 9800 + 1
expect(subToUnit(amount)).toEqual('10000.00009801')
unit = subToUnit(amount)
expect(unit.toString()).toEqual('10000.00009801')
})
})

@@ -194,10 +198,13 @@ describe('Mixins > Currency', () => {
const network = { fractionDigits: 3 }

let amount = Math.pow(10, 3)
expect(subToUnit(amount, network)).toEqual('1')
let unit = subToUnit(amount, network)
expect(unit).toBeInstanceOf(BigNumber)
expect(unit.toString()).toEqual('1')

amount = Math.pow(10, 9) + 9800 + 1
expect(subToUnit(amount, network)).toEqual('1000009.801')
unit = subToUnit(amount, network)
expect(unit.toString()).toEqual('1000009.801')
})
})
})
@@ -4,6 +4,7 @@ import { useI18n } from '../../__utils__/i18n'
import router from '@/router'
import CurrencyMixin from '@/mixins/currency'
import ProfileAll from '@/pages/Profile/ProfileAll'
import BigNumber from '@/plugins/bignumber.js'

const localVue = createLocalVue()
const i18n = useI18n(localVue)
@@ -88,11 +89,9 @@ describe('pages > ProfileAll', () => {
describe('aggregatedBalances', () => {
it('should aggregate the sum of the balances of all profiles by network', () => {
wrapper = mountPage()
expect(wrapper.vm.aggregatedBalances).toEqual({
main: 50015090900,
other: 12190000,
dev: 52010000
})
expect(wrapper.vm.aggregatedBalances).toHaveProperty('main', new BigNumber(50015090900))
expect(wrapper.vm.aggregatedBalances).toHaveProperty('other', new BigNumber(12190000))
expect(wrapper.vm.aggregatedBalances).toHaveProperty('dev', new BigNumber(52010000))
})

describe('when there are profiles with the same wallets', () => {
@@ -102,11 +101,9 @@ describe('pages > ProfileAll', () => {

it('should include those wallets only 1 time', () => {
wrapper = mountPage()
expect(wrapper.vm.aggregatedBalances).toEqual({
main: 15090900,
other: 12190000,
dev: 52010000
})
expect(wrapper.vm.aggregatedBalances).toHaveProperty('main', new BigNumber(15090900))
expect(wrapper.vm.aggregatedBalances).toHaveProperty('other', new BigNumber(12190000))
expect(wrapper.vm.aggregatedBalances).toHaveProperty('dev', new BigNumber(52010000))
})
})

@@ -120,11 +117,9 @@ describe('pages > ProfileAll', () => {

it('should include their balances', () => {
wrapper = mountPage()
expect(wrapper.vm.aggregatedBalances).toEqual({
main: 66622093608,
other: 12190000,
dev: 52010000
})
expect(wrapper.vm.aggregatedBalances).toHaveProperty('main', new BigNumber(66622093608))
expect(wrapper.vm.aggregatedBalances).toHaveProperty('other', new BigNumber(12190000))
expect(wrapper.vm.aggregatedBalances).toHaveProperty('dev', new BigNumber(52010000))
})

describe('when they are included as non-Ledger wallets', () => {
@@ -134,11 +129,9 @@ describe('pages > ProfileAll', () => {

it('should include those wallets only 1 time', () => {
wrapper = mountPage()
expect(wrapper.vm.aggregatedBalances).toEqual({
main: 59898192907,
other: 12190000,
dev: 52010000
})
expect(wrapper.vm.aggregatedBalances).toHaveProperty('main', new BigNumber(59898192907))
expect(wrapper.vm.aggregatedBalances).toHaveProperty('other', new BigNumber(12190000))
expect(wrapper.vm.aggregatedBalances).toHaveProperty('dev', new BigNumber(52010000))
})
})
})

0 comments on commit cf930c7

Please sign in to comment.
You can’t perform that action at this time.