Skip to content

Commit

Permalink
Revert "Merge pull request #202 from cosmos/matt/144-sign-in-change"
Browse files Browse the repository at this point in the history
This reverts commit d0d7ef3.
  • Loading branch information
nylira authored and faboweb committed Dec 8, 2017
1 parent 62cd8bf commit fc24ff2
Show file tree
Hide file tree
Showing 10 changed files with 71 additions and 79 deletions.
2 changes: 1 addition & 1 deletion app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"casual": "^1.5.17",
"clipboard": "^1.6.0",
"cosmos-delegation-game": "^0.1.0",
"cosmos-sdk": "^1.5.0",
"cosmos-sdk": "^1.3.0",
"event-to-promise": "^0.8.0",
"express": "^4.16.2",
"express-http-proxy": "^1.1.0",
Expand Down
64 changes: 36 additions & 28 deletions app/src/renderer/components/common/NiSessionWelcome.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,28 +5,34 @@
.ni-session-title Welcome to Cosmos!
a(@click="help"): i.material-icons help_outline
.ni-session-main
li-session(
v-if="accountExists"
@click.native="setState('sign-in')"
icon="lock"
title="Sign in with password"
subtitle="If you have an account, choose this option")
li-session(
@click.native="setState('sign-up')"
icon="create"
title="Create new account"
subtitle="Generate a brand new seed and account")
li-session(
@click.native="setState('restore')"
icon="settings_backup_restore"
title="Restore account from seed"
subtitle="If you have a seed, choose this option")
li-session(
v-if="config.devMode"
@click.native="setState('hardware')"
icon="usb"
title="Sign in with hardware"
subtitle="If you have a Ledger Wallet, choose this option")
template(v-if="accountExists")
li-session(
@click.native="setState('sign-in')"
icon="lock"
title="Sign in with password"
subtitle="If you have an account, choose this option")
li-session(
@click.native="setState('delete')"
icon="delete_forever"
title="Remove account"
subtitle="If you have want to login to a new account, choose this option")
template(v-else)
li-session(
@click.native="setState('sign-up')"
icon="create"
title="Create new account"
subtitle="Generate a brand new seed and account")
li-session(
@click.native="setState('restore')"
icon="settings_backup_restore"
title="Restore account from seed"
subtitle="If you have a seed, choose this option")
li-session(
v-if="config.devMode"
@click.native="setState('hardware')"
icon="usb"
title="Sign in with hardware"
subtitle="If you have a Ledger Wallet, choose this option")
.ni-session-footer
</template>

Expand All @@ -41,15 +47,17 @@ export default {
LiSession
},
computed: {
...mapGetters(['config']),
sessionState () {
return this.config.modals.sessions.state
}
...mapGetters(['config'])
},
methods: {
help () { this.$store.commit('setModalHelp', true) },
setState (value) { this.$store.commit('setModalSessionState', value) },
accountExists () { return !!this.$store.dispatch('accountExists') }
setState (value) { this.$store.commit('setModalSessionState', value) }
},
data: () => ({
accountExists: false
}),
async mounted () {
this.accountExists = !!(await this.$store.dispatch('accountExists'))
}
}
</script>
2 changes: 1 addition & 1 deletion app/src/renderer/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ async function main () {
const store = Store({ node })

store.dispatch('updateNodeStatus')
store.dispatch('showInitialScreen')
store.dispatch('initializeWallet')

return new Vue({
router,
Expand Down
14 changes: 7 additions & 7 deletions app/src/renderer/vuex/modules/user.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import axios from 'axios'
import { KEY_PASSWORD, KEY_NAME } from './wallet'

export default ({ commit, node }) => {
Expand Down Expand Up @@ -37,12 +38,6 @@ export default ({ commit, node }) => {
}

const actions = {
async showInitialScreen ({ dispatch }) {
let exists = await dispatch('accountExists')
let screen = exists ? 'sign-in' : 'welcome'
commit('setModalSessionState', screen)
commit('setModalSession', true)
},
async accountExists (state, account = KEY_NAME) {
try {
let keys = await node.listKeys()
Expand Down Expand Up @@ -81,7 +76,12 @@ export default ({ commit, node }) => {
},
async createKey ({ commit, dispatch }, { seedPhrase, password, name = KEY_NAME }) {
try {
let {key} = await node.recoverKey({ name, password, seed_phrase: seedPhrase })
// TODO replace when cosmos-sdk-js is updated
// let {key} = await node.recoverKey({ name, password, seed_phrase: seedPhrase })
let {key} = await axios.post(
'http://localhost:8998/keys/recover',
{ name, password, seed_phrase: seedPhrase })
.then(res => res.data)
dispatch('initializeWallet')
return key
} catch (err) {
Expand Down
17 changes: 14 additions & 3 deletions app/src/renderer/vuex/modules/wallet.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,20 @@ export default ({ commit, node }) => {
}

let actions = {
initializeWallet ({ commit, dispatch }, key) {
commit('setWalletKey', key)
dispatch('queryWalletState')
async initializeWallet ({ commit, dispatch }) {
let key
// key was already created, fetch it
try {
key = await node.getKey(KEY_NAME)
} catch (e) {
console.log(`Key '${KEY_NAME}' does not exist`)
}
if (key) {
commit('setWalletKey', key)
dispatch('queryWalletState')
} else {
commit('setModalSession', true)
}
},
queryWalletState ({ state, dispatch }) {
dispatch('queryWalletBalances')
Expand Down
6 changes: 3 additions & 3 deletions app/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -385,9 +385,9 @@ cosmos-fundraiser@^7.14.2:
secp256k1 "^3.2.5"
web3 "0.18.1"

cosmos-sdk@^1.5.0:
version "1.5.0"
resolved "https://registry.yarnpkg.com/cosmos-sdk/-/cosmos-sdk-1.5.0.tgz#ccda05c29c88c741a023e8e5196be21ed175d8c2"
cosmos-sdk@^1.3.0:
version "1.4.4"
resolved "https://registry.yarnpkg.com/cosmos-sdk/-/cosmos-sdk-1.4.4.tgz#4c4efa1071c27ea6b3fe365e7b3b32e16453e218"
dependencies:
axios "^0.16.2"
old "^0.2.0"
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "Cosmos",
"productName": "Cosmos",
"version": "1.0.0",
"version": "0.1.0",
"description": "The electron wrapper for Cosmos UI.",
"author": "All In Bits, Inc <hello@tendermint.com>",
"license": "Apache-2.0",
Expand Down Expand Up @@ -103,7 +103,7 @@
"@nylira/vue-field": "1.1.12",
"@nylira/vue-form-msg": "^1.0.3",
"@nylira/vue-input": "^3.2.0",
"@nylira/vue-notifications": "^1.4.4",
"@nylira/vue-notifications": "^1.4.0",
"axios": "^0.17.0",
"babel-jest": "^21.2.0",
"chart.js": "^2.6.0",
Expand Down
2 changes: 1 addition & 1 deletion test/unit/specs/NISessionWelcome.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,6 @@ describe('NISessionWelcome', () => {
accountExists: true
})
wrapper.findAll(LiSession).trigger('click')
expect(store.commit.mock.calls.map(args => args[1])).toEqual(['sign-in', 'sign-up', 'restore', 'hardware'])
expect(store.commit.mock.calls.map(args => args[1])).toEqual(['sign-in', 'delete'])
})
})
33 changes: 3 additions & 30 deletions test/unit/specs/__snapshots__/NISessionWelcome.spec.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ exports[`NISessionWelcome has the expected html structure 1`] = `
<a><i class=\\"material-icons\\">help_outline</i></a>
</div>
<div class=\\"ni-session-main\\">
<!---->
<div class=\\"ni-li-session\\">
<div class=\\"ni-li-session-icon\\">
<i class=\\"material-icons\\">create</i>
Expand Down Expand Up @@ -83,40 +82,14 @@ exports[`NISessionWelcome has the expected html structure if accoutn exists 1`]
</div>
<div class=\\"ni-li-session\\">
<div class=\\"ni-li-session-icon\\">
<i class=\\"material-icons\\">create</i>
<i class=\\"material-icons\\">delete_forever</i>
</div>
<div class=\\"ni-li-session-text\\">
<div class=\\"ni-li-session-title\\">
Create new account
</div>
<div class=\\"ni-li-session-subtitle\\">
Generate a brand new seed and account
</div>
</div>
</div>
<div class=\\"ni-li-session\\">
<div class=\\"ni-li-session-icon\\">
<i class=\\"material-icons\\">settings_backup_restore</i>
</div>
<div class=\\"ni-li-session-text\\">
<div class=\\"ni-li-session-title\\">
Restore account from seed
Remove account
</div>
<div class=\\"ni-li-session-subtitle\\">
If you have a seed, choose this option
</div>
</div>
</div>
<div class=\\"ni-li-session\\">
<div class=\\"ni-li-session-icon\\">
<i class=\\"material-icons\\">usb</i>
</div>
<div class=\\"ni-li-session-text\\">
<div class=\\"ni-li-session-title\\">
Sign in with hardware
</div>
<div class=\\"ni-li-session-subtitle\\">
If you have a Ledger Wallet, choose this option
If you have want to login to a new account, choose this option
</div>
</div>
</div>
Expand Down
6 changes: 3 additions & 3 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@
version "3.4.0"
resolved "https://registry.yarnpkg.com/@nylira/vue-input/-/vue-input-3.4.0.tgz#741346ce0613b831b756fccb253731015fa5c246"

"@nylira/vue-notifications@^1.4.4":
version "1.4.4"
resolved "https://registry.yarnpkg.com/@nylira/vue-notifications/-/vue-notifications-1.4.4.tgz#8ef4d3bbdbcbdf5570feaf17afd45c83c43d5496"
"@nylira/vue-notifications@^1.4.0":
version "1.4.0"
resolved "https://registry.yarnpkg.com/@nylira/vue-notifications/-/vue-notifications-1.4.0.tgz#af51a832f3f5ccae99bdc382d0746659da72e37a"

"@types/node@^7.0.18":
version "7.0.48"
Expand Down

0 comments on commit fc24ff2

Please sign in to comment.