Skip to content

Commit dbc41ea

Browse files
evgenyboxerdvdschwrtz
authored andcommitted
* Fix for: Password is displayed as visible text when creating wallet CityOfZion#342 (CityOfZion#347) * Fix for: Give warning when API is down or wallet lacks connectivity CityOfZion#265 (CityOfZion#346) * Fix lint errors and refactor * Remove RPX from reducers * Move loading indicator to the top * hide scrollbars * finetune the buttons * Move the refresh button code to Dashboard.scss * Remove unused styles * Split token balances into its own component * Add info icon * add tokens balance to initiateGetBalance * Remove unused methods * POC tokenInfo * Use PasswordField for WIF key in secret token sale screen (CityOfZion#351) * Add token info modal and refactor the tokens state * Update snapshots * Remove uneeded code * Better formatting (CityOfZion#350) * Better formatting for bigger numbers * Formating formatters file * Removing mime requirement. Not needed. * Remove exclamation that's not needed in UI (CityOfZion#353) * Enter in textfields submits alt (CityOfZion#354) * Enter button submits forms, simple solution * Code style fixes * Use tight version * Remove unused function * Remove comment * Remove ToggleAsset * Rename Gas -> GAS / Neo -> NEO * Add isToken method * WIP * Use tight versioning * WIP * Rename rpx to sale, and clean it up * Rename reducers to index * Fix paths * Add flow * Add flow * cleanups * Rename initiateGetBalance to LoadWalletData * Add TokenInfo type * Fix tests * Refactor prices (to support in the future) * Add Type suffix for types * Cleanup * Cleanup * Cleanup * Fix typo * Use neon-js constants * Add support for test tokens * Add percent buttons * Fix token sale * Sort imports * Fix typo * Revert back to not using NeonJS for Network * Remove unsued functions * Fix lint errors * Refactor explorer * Fix typo * Revert back to local consts for ASSETS * Load info when modal loads * Rename to openExplorerTx * Pass retrieveTokenInfo to the token info modal * WIP * Change token to symbol
1 parent 3da75c7 commit dbc41ea

File tree

104 files changed

+1321
-896
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

104 files changed

+1321
-896
lines changed

Diff for: ISSUE_TEMPLATE.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
## PLEASE NOTE
22

3-
## For support using the software or concerns about the status of your funds, please go to the #support channel in the Neo Smart Economy Slack.
3+
## For support using the software or concerns about the status of your funds, please go to the #support channel in the NEO Smart Economy Slack.
44

55
## GitHub issues are intended for tracking development tasks, not troubleshooting general usage problems.

Diff for: README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@
2727

2828
### What does it currently do
2929

30-
- View Gas and Neo balances
30+
- View GAS and NEO balances
3131
- Login via Wif and encrypted private keys
32-
- Send Neo to other addresses
32+
- Send NEO to other addresses
3333

3434
## Installation
3535

Diff for: __tests__/components/Claim.test.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ const initialState = {
2525
network: 'network'
2626
},
2727
wallet: {
28-
Neo: 1
28+
NEO: 1
2929
}
3030
}
3131

@@ -90,7 +90,7 @@ describe('Claim', () => {
9090
expect(actions[1]).toEqual({
9191
type: SHOW_NOTIFICATION,
9292
payload: expect.objectContaining({
93-
message: 'Sending Neo to Yourself...',
93+
message: 'Sending NEO to Yourself...',
9494
level: NOTIFICATION_LEVELS.INFO
9595
})
9696
})
@@ -133,7 +133,7 @@ describe('Claim', () => {
133133
expect(actions[1]).toEqual({
134134
type: SHOW_NOTIFICATION,
135135
payload: expect.objectContaining({
136-
message: 'Sending Neo to Yourself...',
136+
message: 'Sending NEO to Yourself...',
137137
level: NOTIFICATION_LEVELS.INFO
138138
})
139139
})

Diff for: __tests__/components/Login.test.js

+21-6
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,29 @@
11
import React from 'react'
22
import configureStore from 'redux-mock-store'
3-
import { shallow } from 'enzyme'
3+
import { Provider } from 'react-redux'
4+
import { BrowserRouter } from 'react-router-dom'
5+
import { shallow, mount } from 'enzyme'
46

57
import Login from '../../app/containers/LoginPrivateKey/LoginPrivateKey'
68

7-
const setup = (state = { account: {
9+
const setup = (shallowRender = true, state = { account: {
810
loggedIn: true,
911
wif: undefined
1012
}}) => {
1113
const store = configureStore()(state)
12-
const wrapper = shallow(<Login store={store} />)
14+
15+
let wrapper
16+
if (shallowRender) {
17+
wrapper = shallow(<Login store={store} />)
18+
} else {
19+
wrapper = mount(
20+
<Provider store={store}>
21+
<BrowserRouter>
22+
<Login store={store} />
23+
</BrowserRouter>
24+
</Provider>
25+
)
26+
}
1327

1428
return {
1529
store,
@@ -24,15 +38,16 @@ describe('Login', () => {
2438
})
2539

2640
test('clicking show key icon toggles private key visibility', () => {
27-
const { wrapper } = setup()
41+
const { wrapper } = setup(false)
2842

29-
expect(wrapper.state('showKey')).toEqual(false)
43+
expect(wrapper.find('input').get(0).props.type).toEqual('password')
3044

3145
wrapper
3246
.find('.viewKey')
47+
.first()
3348
.simulate('click')
3449

35-
expect(wrapper.state('showKey')).toEqual(true)
50+
expect(wrapper.find('input').get(0).props.type).toEqual('text')
3651
})
3752

3853
// test('private key field input onChange dispatches LOGIN action', () => {

Diff for: __tests__/components/LoginNep2.test.js

+12-7
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,18 @@ describe('LoginNep2', () => {
4545
test('renders correctly with initial state', (done) => {
4646
const { wrapper } = setup(false)
4747

48-
const passwordField = wrapper.find('input[type="password"]')
49-
const keyField = wrapper.find('input[type="text"]')
48+
const fields = wrapper.find('input[type="password"]')
49+
expect(fields.length).toEqual(2)
5050

51-
expect(passwordField.text()).toEqual('')
52-
expect(passwordField.html().includes('Enter your passphrase here')).toEqual(true)
53-
expect(keyField.text()).toEqual('')
54-
expect(keyField.html().includes('Enter your encrypted key here')).toEqual(true)
51+
const passwordField = fields.get(0)
52+
const keyField = fields.get(1)
53+
54+
expect(passwordField.props.value).toEqual('')
55+
expect(passwordField.props.placeholder).toEqual('Enter your passphrase here')
56+
expect(passwordField.props.type).toEqual('password')
57+
expect(keyField.props.value).toEqual('')
58+
expect(keyField.props.placeholder).toEqual(('Enter your encrypted key here'))
59+
expect(keyField.props.type).toEqual('password')
5560
done()
5661
})
5762
test('the login button is working correctly with no passphrase or wif', (done) => {
@@ -103,7 +108,7 @@ describe('LoginNep2', () => {
103108
keyField.instance().value = '6PYUGtvXiT5TBetgWf77QyAFidQj61V8FJeFBFtYttmsSxcbmP4vCFRCWu'
104109
keyField.simulate('change')
105110

106-
wrapper.find('.loginButton').simulate('click')
111+
wrapper.find('.loginButton').simulate('submit')
107112
jest.runAllTimers()
108113
const actions = store.getActions()
109114
expect(actions.length).toEqual(2)

Diff for: __tests__/components/WalletInfo.test.js

+35-8
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import { LOADING_TRANSACTIONS } from '../../app/modules/transactions'
99
import { SET_HEIGHT } from '../../app/modules/metadata'
1010
import { SET_CLAIM } from '../../app/modules/claim'
1111
import WalletInfo from '../../app/containers/WalletInfo'
12+
import * as neonjs from 'neon-js'
1213

1314
// TODO research how to move the axios mock code which is repeated in NetworkSwitch to a helper or config file
1415
import axios from 'axios'
@@ -47,8 +48,8 @@ const initialState = {
4748
network: 'TestNet'
4849
},
4950
wallet: {
50-
Neo: 10,
51-
Gas: 1.0001001,
51+
NEO: 100001,
52+
GAS: 1.0001601,
5253
neoPrice: 25.48,
5354
gasPrice: 18.10
5455
},
@@ -89,16 +90,17 @@ describe('WalletInfo', () => {
8990
const neoWalletValue = wrapper.find('.neoWalletValue')
9091
const gasWalletValue = wrapper.find('.gasWalletValue')
9192
const walletValue = wrapper.find('.walletTotal')
92-
const expectedNeoWalletValue = formatFiat(initialState.wallet.neoPrice * initialState.wallet.Neo)
93-
const expectedGasWalletValue = formatFiat(initialState.wallet.gasPrice * initialState.wallet.Gas)
94-
const expectedWalletValue = formatFiat(initialState.wallet.neoPrice * initialState.wallet.Neo + initialState.wallet.gasPrice * initialState.wallet.Gas)
93+
94+
const expectedNeoWalletValue = '2,548,025.48'
95+
const expectedGasWalletValue = '18.10'
96+
const expectedWalletValue = '2,548,043.58'
9597
const neoField = wrapper.find('.amountNeo')
9698
const gasField = wrapper.find('.amountGas')
9799

98100
expect(neoWalletValue.text()).toEqual(`US $${expectedNeoWalletValue}`)
99101
expect(gasWalletValue.text()).toEqual(`US $${expectedGasWalletValue}`)
100102
expect(walletValue.text()).toEqual(`Total US $${expectedWalletValue}`)
101-
expect(neoField.text()).toEqual(`${initialState.wallet.Neo}`)
103+
expect(neoField.text()).toEqual(`${initialState.wallet.NEO}`)
102104
// TODO: Test the gas tooltip value, this is testing the display value, truncated to 4 decimals
103105
expect(gasField.text()).toEqual('1.0001')
104106
done()
@@ -122,7 +124,7 @@ describe('WalletInfo', () => {
122124
jest.runAllTimers()
123125
await Promise.resolve('Pause').then().then().then().then()
124126
const actions = store.getActions()
125-
expect(actions.length).toEqual(16)
127+
expect(actions.length).toEqual(20)
126128
// expect(actions.length).toEqual(12)
127129
actions.forEach(action => {
128130
expect(actionTypes.indexOf(action.type) > -1).toEqual(true)
@@ -131,6 +133,8 @@ describe('WalletInfo', () => {
131133
test('calls the correct number of actions after mounting', async () => {
132134
const { store } = setup(initialState, false)
133135
const actionTypes = [
136+
HIDE_NOTIFICATIONS,
137+
SHOW_NOTIFICATION,
134138
SET_TRANSACTION_HISTORY,
135139
SET_HEIGHT,
136140
SET_CLAIM,
@@ -141,9 +145,32 @@ describe('WalletInfo', () => {
141145
jest.runAllTimers()
142146
await Promise.resolve('Pause').then().then().then()
143147
const actions = store.getActions()
144-
expect(actions.length).toEqual(6)
148+
expect(actions.length).toEqual(10)
145149
actions.forEach(action => {
146150
expect(actionTypes.indexOf(action.type) > -1).toEqual(true)
147151
})
148152
})
153+
test('network error is shown with connectivity error', async () => {
154+
neonjs.getBalance = jest.fn(() => {
155+
return new Promise((resolve, reject) => {
156+
reject(new Error())
157+
})
158+
})
159+
const { wrapper, store } = setup()
160+
wrapper.dive()
161+
162+
jest.runAllTimers()
163+
await Promise.resolve('Pause').then().then().then().then()
164+
165+
const actions = store.getActions()
166+
let notifications = []
167+
actions.forEach(action => {
168+
if (action.type === SHOW_NOTIFICATION) {
169+
notifications.push(action)
170+
}
171+
})
172+
173+
// let's make sure the last notification show was an error.
174+
expect(notifications.pop().payload.level).toEqual('error')
175+
})
149176
})

Diff for: __tests__/components/__snapshots__/Claim.test.js.snap

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ exports[`Claim should not render claim gas button when claim button is disabled
55
id="claim"
66
>
77
<Tooltip
8-
title="You can claim Gas once every 5 minutes"
8+
title="You can claim GAS once every 5 minutes"
99
>
1010
<button
1111
className="disabled"

Diff for: __tests__/components/__snapshots__/Login.test.js.snap

+21-22
Original file line numberDiff line numberDiff line change
@@ -10,29 +10,28 @@ exports[`Login renders without crashing 1`] = `
1010
>
1111
Login using a private key:
1212
</div>
13-
<div
14-
className="loginForm"
13+
<form
14+
onSubmit={[Function]}
1515
>
16-
<input
17-
autoFocus={true}
18-
onChange={[Function]}
19-
placeholder="Enter your private key here (WIF)"
20-
type="password"
21-
/>
22-
<FaEye
23-
className="viewKey"
24-
onClick={[Function]}
25-
/>
26-
</div>
27-
<div>
28-
<button
29-
className="disabled"
30-
disabled={true}
31-
onClick={[Function]}
16+
<div
17+
className="loginForm"
3218
>
33-
Login
34-
</button>
35-
<HomeButtonLink />
36-
</div>
19+
<PasswordField
20+
autoFocus={true}
21+
onChange={[Function]}
22+
placeholder="Enter your private key here (WIF)"
23+
/>
24+
</div>
25+
<div>
26+
<button
27+
className="disabled"
28+
disabled={true}
29+
type="submit"
30+
>
31+
Login
32+
</button>
33+
<HomeButtonLink />
34+
</div>
35+
</form>
3736
</Page>
3837
`;

Diff for: __tests__/components/__snapshots__/Logout.test.js.snap

+1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ exports[`Logout should render without crashing 1`] = `
1111
to=""
1212
>
1313
<Tooltip
14+
position="right"
1415
title="Logout"
1516
>
1617
<MdPowerSettingsNew />

Diff for: __tests__/components/__snapshots__/NetworkSwitch.test.js.snap

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ exports[`NetworkSwitch renders without crashing 1`] = `
44
<NetworkSwitch
55
address="AWy7RNBVr9vDadRMK9p7i7Z1tL7GrLAxoh"
66
checkVersion={[Function]}
7-
initiateGetBalance={[Function]}
7+
loadWalletData={[Function]}
88
net="MainNet"
99
setNetwork={[Function]}
1010
store={

Diff for: __tests__/components/__snapshots__/WalletInfo.test.js.snap

+5-5
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,15 @@
33
exports[`WalletInfo renders without crashing 1`] = `
44
<WalletInfo
55
address="ANqUrhv99rwCiFTL6N1An9NH5UVkPYxTuw"
6-
gas={1.0001001}
6+
gas={1.0001601}
77
gasPrice={18.1}
8-
getTokensBalance={[Function]}
9-
initiateGetBalance={[Function]}
10-
neo={10}
8+
loadWalletData={[Function]}
9+
neo={100001}
1110
neoPrice={25.48}
1211
net="TestNet"
12+
retrieveTokensInfo={[Function]}
1313
showErrorNotification={[Function]}
14-
showInfoNotification={[Function]}
14+
showModal={[Function]}
1515
showSuccessNotification={[Function]}
1616
store={
1717
Object {

0 commit comments

Comments
 (0)