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

fedekunze/remove demo mode #1792

Merged
merged 9 commits into from
Jan 4, 2019
Merged
Show file tree
Hide file tree
Changes from 8 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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
- [\#1277](https://github.com/cosmos/voyager/issues/1277) change name of VmToolBar to ToolBar, update all snapshots and import statements @coreycosman
- [\#1432](https://github.com/cosmos/voyager/issues/1432) Moved @tendermint/UI components back into the Voyager repository @faboweb
- Improved the readme @faboweb
- [\#1792](https://github.com/cosmos/voyager/pull/1792) removed mocked demo mode @fedekunze

### Fixed

Expand Down
3 changes: 1 addition & 2 deletions app/src/renderer/components/common/AppMenu.vue
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
<i class="material-icons">chevron_right</i>
</router-link>
<router-link
v-if="config.devMode || mockedConnector"
id="app-menu__transactions"
class="app-menu-item"
to="/transactions"
Expand Down Expand Up @@ -65,7 +64,7 @@ export default {
ps: {}
}),
computed: {
...mapGetters([`validators`, `config`, `lastHeader`, `mockedConnector`])
...mapGetters([`validators`, `config`, `lastHeader`])
},
mounted() {
this.ps = new PerfectScrollbar(this.$el.querySelector(`.app-menu-main`))
Expand Down
35 changes: 1 addition & 34 deletions app/src/renderer/components/common/PagePreferences.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,6 @@
<tool-bar />
</template>
<tm-part title="Settings">
<tm-list-item type="field" title="Select network to connect to">
fedekunze marked this conversation as resolved.
Show resolved Hide resolved
<tm-field
id="select-network"
v-model="networkSelectActive"
:options="networkSelectOptions"
type="select"
placeholder="Select network..."
@change.native="setMockedConnector()"
/>
</tm-list-item>
<tm-list-item type="field" title="Node IP">
<tm-btn :value="nodeURL" icon="exit_to_app" type="button" />
</tm-list-item>
Expand Down Expand Up @@ -91,31 +81,12 @@ export default {
value: `dark`,
key: `Dark`
}
],
networkSelectActive: null,
networkSelectOptions: [
{
value: `live`,
key: `Live Testnet`
},
{
value: `mock`,
key: `Offline Mode`
}
]
}),
computed: {
...mapGetters([
`user`,
`themes`,
`onboarding`,
`mockedConnector`,
`config`,
`nodeURL`
])
...mapGetters([`user`, `themes`, `onboarding`, `config`, `nodeURL`])
},
mounted() {
this.networkSelectActive = this.mockedConnector ? `mock` : `live`
this.themeSelectActive = this.themes.active
},
methods: {
Expand All @@ -139,10 +110,6 @@ export default {
setOnboarding({ $store } = this) {
$store.commit(`setOnboardingState`, 0)
$store.commit(`setOnboardingActive`, true)
},

setMockedConnector({ $store, networkSelectActive } = this) {
$store.dispatch(`setMockedConnector`, networkSelectActive === `mock`)
}
}
}
Expand Down
48 changes: 13 additions & 35 deletions app/src/renderer/components/common/TmConnectedNetwork.vue
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
<template>
<div
v-if="connected"
id="tm-connected-network"
:class="cssClass"
class="tm-connected-network"
>
<div v-if="connected" id="tm-connected-network" class="tm-connected-network">
<div class="tm-connected-network__connection">
<div id="tm-connected-network__icon" class="tm-connected-network__icon">
<i class="material-icons">lock</i>
Expand All @@ -14,17 +9,13 @@
class="tm-connected-network__string"
>
<span v-tooltip.top="networkTooltip" class="chain-id">{{
chainId
lastHeader.chain_id
}}</span>
</div>
</div>
<div id="tm-connected-network__block" class="tm-connected-network__string">
<span v-tooltip.top="'Current block number'" v-if="mockedConnector">{{
blockHeight
}}</span
><a
<a
v-tooltip.top="'View block details on the Cosmos explorer.'"
v-if="!mockedConnector"
:href="explorerLink"
>{{ blockHeight }}<i class="material-icons exit">exit_to_app</i></a
>
Expand All @@ -40,42 +31,29 @@
v-tooltip.top="networkTooltip"
class="tm-connected-network__string tm-connected-network__string--connecting"
>
Connecting to {{ chainId }}…
Connecting to {{ lastHeader.chain_id }}…
</div>
</div>
</template>

<script>
import { mapGetters } from "vuex"
import num from "scripts/num"
import { startCase, toLower } from "lodash"
export default {
name: `tm-connected-network`,
data: () => ({
num: num
}),
computed: {
...mapGetters([`lastHeader`, `nodeURL`, `connected`, `mockedConnector`]),
cssClass() {
if (this.mockedConnector) {
return `tm-connected-network--mocked`
}
},
networkTooltip({ mockedConnector, connected, nodeURL, chainId } = this) {
if (mockedConnector) {
return `You\'re using the offline demo and are not connected to any real nodes.`
} else if (connected) {
return `You\'re connected to the ${chainId} testnet via node ${nodeURL}.`
} else if (!mockedConnector && !connected) {
return `We\'re pinging nodes to try to connect you to ${chainId}.`
}
},
chainId() {
if (this.mockedConnector) {
return startCase(toLower(this.lastHeader.chain_id))
} else {
return this.lastHeader.chain_id
...mapGetters([`lastHeader`, `nodeURL`, `connected`]),
networkTooltip({ connected, nodeURL } = this) {
if (connected) {
return `You\'re connected to the ${
this.lastHeader.chain_id
} testnet via node ${nodeURL}.`
}
return `We\'re pinging nodes to try to connect you to ${
this.lastHeader.chain_id
}.`
},
blockHeight() {
return `#` + num.prettyInt(this.lastHeader.height)
Expand Down
11 changes: 0 additions & 11 deletions app/src/renderer/components/common/TmModalNodeHalted.vue
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,6 @@
value="Switch Node"
@click.native="switchNode"
/>
<tm-btn
id="tm-modal-error__btn-mock"
size="lg"
icon="pageview"
value="Try Demo"
@click.native="useMock"
/>
</div>
</div>
</div>
Expand All @@ -41,10 +34,6 @@ export default {
switchNode() {
ipcRenderer.send(`reconnect`)
this.$store.commit(`setModalNodeHalted`, false)
},
useMock() {
this.$store.dispatch(`setMockedConnector`, true)
this.$store.commit(`setModalNodeHalted`, false)
}
}
}
Expand Down
8 changes: 1 addition & 7 deletions app/src/renderer/components/common/TmSessionSignIn.vue
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,6 @@
type="minLength"
min="10"
/>
<tm-form-msg v-if="mockedConnector"
>default password is 1234567890</tm-form-msg
>
</tm-form-group>
</div>
<div class="tm-session-footer">
Expand Down Expand Up @@ -94,7 +91,7 @@ export default {
}
}),
computed: {
...mapGetters([`user`, `mockedConnector`, `lastHeader`, `connected`]),
...mapGetters([`user`, `lastHeader`, `connected`]),
accounts() {
let accounts = this.user.accounts
accounts = accounts.filter(({ name }) => name !== `trunk`)
Expand All @@ -103,9 +100,6 @@ export default {
},
mounted() {
this.setDefaultAccount(this.accounts)
if (this.mockedConnector) {
this.fields.signInPassword = `1234567890`
}
},
methods: {
help() {
Expand Down
17 changes: 1 addition & 16 deletions app/src/renderer/components/wallet/PageSend.vue
Original file line number Diff line number Diff line change
Expand Up @@ -81,15 +81,6 @@
type="between"
/>
</tm-form-group>
<p v-if="mockedConnector">
<span>Try sending to the address "</span
><strong style="font-weight: bold"
>cosmos1p6zajjw6xged056andyhn62lm7axwzyspkzjq0</strong
><span
>", it's a friendly bot which will send the money back to you!</span
>
</p>
<br v-if="mockedConnector" />
<hr />
</tm-part>
<tm-part>
Expand Down Expand Up @@ -205,13 +196,7 @@ export default {
showPassword: false
}),
computed: {
...mapGetters([
`wallet`,
`lastHeader`,
`config`,
`mockedConnector`,
`connected`
]),
...mapGetters([`wallet`, `lastHeader`, `config`, `connected`]),
max() {
let denom = this.wallet.balances.find(b => b.denom === this.denom)
return (denom && denom.amount) || 0
Expand Down
1 change: 0 additions & 1 deletion app/src/renderer/vuex/getters.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,4 +81,3 @@ export const connected = state => state.connection.connected
export const lastHeader = state => state.connection.lastHeader
export const nodeURL = state =>
state.connection.node ? state.connection.node.remoteLcdURL : undefined
export const mockedConnector = state => state.connection.mocked
33 changes: 0 additions & 33 deletions app/src/renderer/vuex/modules/connection.js
Original file line number Diff line number Diff line change
Expand Up @@ -145,39 +145,6 @@ export default function({ node }) {
disapproveNodeHash({ state }, hash) {
state.approvalRequired = null
ipcRenderer.send(`hash-disapproved`, hash)
},
async setMockedConnector({ state, dispatch, commit }, mocked) {
state.mocked = mocked

// Tell the main process our status in case of reload.
ipcRenderer.send(`mocked`, mocked)

// disable updates from the live node
node.rpcDisconnect()

// switch to a mocked or live node
node.setup(mocked)

// reconnect to the node
node.rpcReconnect()

if (mocked) {
// if we run a mocked version only, we don't want the lcd to run in the meantime
ipcRenderer.send(`stop-lcd`)

// we need to trigger this event for the mocked mode as it is usually triggered by the "connected" event from the main thread
dispatch(`rpcSubscribe`)

// the mocked node is automatically connected
dispatch(`reconnected`)
} else {
// if we switch to a live connector, we need to wait for the process to have started up again so we can access the KMS
commit(`setModalSession`, `loading`)
await new Promise(resolve => ipcRenderer.once(`connected`, resolve))
}

// sign user out, as when switching from mocked to live node, the account address needs to be clarified again
dispatch(`signOut`)
}
}

Expand Down
43 changes: 6 additions & 37 deletions test/e2e/preferences.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,54 +2,23 @@

let test = require(`tape-promise/tape`)
let { getApp, restart } = require(`./launch.js`)
let {
navigateToPreferences,
sleep,
login,
selectOption
} = require(`./common.js`)
let { navigateToPreferences, login } = require(`./common.js`)

/*
* NOTE: don't use a global `let client = app.client` as the client object changes when restarting the app
*/

test(`preferences`, async function(t) {
let { app } = await getApp(t)
await restart(app)

let $ = (...args) => app.client.$(...args)

await restart(app)
await login(app, `testkey`)
await navigateToPreferences(app)

t.test(`change`, async function(t) {
await navigateToPreferences(app)

let networkSelect = () => $(`#select-network select`)

t.test(`default network`, async function(t) {
let option = await networkSelect().getValue()
t.equal(option.toString(), `live`, `Live Testnet is correct`)
t.end()
})
t.test(`mock network`, async function(t) {
await selectOption(app, `#select-network select`, `Offline`)
await app.client.waitForVisible(`.tm-session-wrapper`, 5000)

await login(app, `default`)
await navigateToPreferences(app)

await sleep(1000)
let network = await app.client
.$(`#tm-connected-network__string`)
.getHTML()
t.ok(
network.indexOf(`Offline Demo`) !== -1,
`network indicator shows 'Offline Demo'`
)

t.end()
})

t.test(`shows preferences`, async function(t) {
t.ok(await $(`div*=Settings`).waitForExist(), `shows Settings`)
t.ok(await $(`div*=Account`).waitForExist(), `shows Account`)
t.end()
})

Expand Down
Loading