Skip to content

Commit

Permalink
Merge commit '7f190d6bdac3313462bbe8f2bc1591e061481505' into david/14…
Browse files Browse the repository at this point in the history
…02-proposal-creation
  • Loading branch information
David Braun authored and David Braun committed Nov 8, 2018
2 parents c3cd7c6 + 7f190d6 commit bfcb33e
Show file tree
Hide file tree
Showing 16 changed files with 96 additions and 1,404 deletions.
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
* [\#1449](https://github.com/cosmos/voyager/issues/1449) shortNumber to num scripts for more readable numbers. @jbibla
* [\#1464](https://github.com/cosmos/voyager/issues/1464) Added governance transactions to tx history page @fedekunze
* [\1401](https://github.com/cosmos/voyager/issues/1401) Display governance proposals index. @fedekunze
* [\#1472](https://github.com/cosmos/voyager/issues/1472) Added mock functionality for redelegation @fedekunze + @faboweb
* [\#1472](https://github.com/cosmos/voyager/issues/1472) Added mock functionality for redelegation @fedekunze + @faboweb

### Changed

Expand All @@ -32,6 +32,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
* [\#1497](https://github.com/cosmos/voyager/issues/1451) Using an html table for table validators component @jbibla
* [\#1496](https://github.com/cosmos/voyager/issues/1496) display validator pub_key instead of operator_address on livalidator and validator profile @jbibla
* made running a local node easier by reducing it to 2 commands and presetting an account. @faboweb
* [\#1504](https://github.com/cosmos/voyager/issues/1504) updates @tendermint/UI library to 0.4.1 @faboweb
* [\#1504](https://github.com/cosmos/voyager/issues/1504) updates @tendermint/UI library @faboweb
* [\#1410](https://github.com/cosmos/voyager/issues/1410) removed end undelegations as not needed in the SDK anymore

Expand All @@ -46,8 +47,11 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
* [\#1480](https://github.com/cosmos/voyager/issues/1480) Fixed false detection of node crash in e2e test start. @faboweb
* [\#1451](https://github.com/cosmos/voyager/issues/1451) Provide better sourcemaps to make debugging easier. @faboweb
* [\#1409](https://github.com/cosmos/voyager/issues/1409) Fixed disabled unbond and redelegation button when delegation amount was less than 1 @fedekunze
* [\#1500](https://github.com/cosmos/voyager/issues/1500) Fixed wrong optimistic updates to the atom balance after staking @faboweb @fedekunze
* [\#1517](https://github.com/cosmos/voyager/issues/1517) Fixed wrong account format used for querying selfBond @faboweb
* [\#1503](https://github.com/cosmos/voyager/issues/1503) Added e2e test for balance updates after delegation @faboweb
* [\#1131](https://github.com/cosmos/voyager/issues/1131) Display only error message on notifications @fedekunze
* [\#1440](https://github.com/cosmos/voyager/issues/1440) Fixed an error that prevented disconnecting from the RPC websocket if it wasn't defined @fedekunze

## [0.10.7] - 2018-10-10

Expand Down
12 changes: 6 additions & 6 deletions app/src/main/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,14 +82,14 @@ function sleep(ms) {
return new Promise(resolve => setTimeout(resolve, ms))
}

function handleCrash(error) {
function handleCrash(err) {
afterBooted(() => {
if (mainWindow) {
mainWindow.webContents.send(`error`, {
message: error
? error.message
? error.message
: error
message: err
? err.message
? err.message
: err
: `An unspecified error occurred`
})
}
Expand Down Expand Up @@ -315,7 +315,7 @@ function stopLCD() {
lcdProcess.kill(`SIGKILL`)
} catch (err) {
handleCrash(err)
reject(`Stopping the LCD resulted in an error: ` + err.message)
reject(`Stopping the LCD resulted in an error: ${err.message}`)
}
})
}
Expand Down
8 changes: 4 additions & 4 deletions app/src/renderer/components/wallet/PageSend.vue
Original file line number Diff line number Diff line change
Expand Up @@ -168,8 +168,8 @@ export default {
} catch (err) {
this.sending = false
this.$store.commit(`notifyError`, {
title: `Error Sending`,
body: `An error occurred while trying to send: "${err.message}"`
title: `Error Sending transaction`,
body: err.message
})
}
},
Expand All @@ -181,8 +181,8 @@ export default {
b32.decode(param)
this.bech32error = null
return true
} catch (error) {
this.bech32error = error.message
} catch (err) {
this.bech32error = err.message
return false
}
},
Expand Down
4 changes: 2 additions & 2 deletions app/src/renderer/connectors/lcdClientMock.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ let state = {
amount: `1234`
}
],
address: makeHash()
address: addresses[1]
}
],
outputs: [
Expand Down Expand Up @@ -106,7 +106,7 @@ let state = {
amount: `1234`
}
],
address: makeHash()
address: addresses[1]
}
]
}
Expand Down
2 changes: 1 addition & 1 deletion app/src/renderer/connectors/rpcWrapper.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ module.exports = function setRpcWrapper(container) {
connected: true
},
rpcDisconnect() {
if (!container.rpc) return
if (!container.rpc || !container.rpc.ws) return

console.log(`removing old websocket`)

Expand Down
6 changes: 3 additions & 3 deletions app/src/renderer/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,14 +86,14 @@ async function main() {
next()
})

ipcRenderer.on(`error`, (event, error) => {
switch (error.code) {
ipcRenderer.on(`error`, (event, err) => {
switch (err.code) {
case `NO_NODES_AVAILABLE`:
store.commit(`setModalNoNodes`, true)
break
default:
store.commit(`setModalError`, true)
store.commit(`setModalErrorMessage`, error.message)
store.commit(`setModalErrorMessage`, err.message)
}
})
ipcRenderer.on(`approve-hash`, (event, hash) => {
Expand Down
4 changes: 1 addition & 3 deletions app/src/renderer/vuex/modules/blockchain.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,7 @@ export default ({ node }) => {

function error(err) {
dispatch(`nodeHasHalted`)
console.error(
`Error subscribing to new blocks: ${err.message} ${err.data || ``}`
)
console.error(err.message)
}

node.rpc.status((err, status) => {
Expand Down
45 changes: 14 additions & 31 deletions app/src/renderer/vuex/modules/delegation.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"use strict"

import { calculateShares, calculateTokens } from "scripts/common"
import { calculateShares } from "scripts/common"
export default ({ node }) => {
let emptyState = {
loading: false,
Expand Down Expand Up @@ -194,32 +194,24 @@ export default ({ node }) => {

if (mappedDelegations) {
// (optimistic update) we update the atoms of the user before we get the new values from chain
let atomsDiff =
stakingTransactions.delegations &&
stakingTransactions.delegations
// compare old and new delegations and diff against old atoms
.map(
delegation =>
calculateTokens(
delegation.validator,
state.committedDelegates[
delegation.validator.operator_address
]
) - delegation.atoms
)
.reduce((sum, diff) => sum + diff, 0)
commit(`setAtoms`, user.atoms + atomsDiff)

let atomsSum = stakingTransactions.delegations.reduce(
(sum, delegation) => sum + delegation.atoms,
0
)
commit(`setAtoms`, user.atoms - atomsSum)

// optimistically update the committed delegations
stakingTransactions.delegations.forEach(delegation => {
state.committedDelegates[delegation.validator.operator_address] +=
delegation.atoms
})
}

// we optimistically update the committed delegations
// TODO usually I would just query the new state through the LCD and update the state with the result, but at this point we still get the old shares
setTimeout(async () => {
dispatch(`updateDelegates`) //.then(() =>
// updateCommittedDelegations(
// delegations,
// commit
// )
// )
dispatch(`updateDelegates`)
}, 5000)
}
// deprecated
Expand Down Expand Up @@ -262,12 +254,3 @@ export default ({ node }) => {
actions
}
}
// needed for optimistic updates, uncomment or delete this when that issue is addressed
// function updateCommittedDelegations(delegations, commit) {
// for (let delegation of delegations) {
// commit("setCommittedDelegation", {
// candidateId: delegation.delegate.operator_address,
// value: delegation.atoms
// })
// }
// }
4 changes: 2 additions & 2 deletions app/src/renderer/vuex/modules/send.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,13 +86,13 @@ export default ({ node }) => {

function assertOk(res) {
if (Array.isArray(res)) {
if (res.length === 0) throw new Error(`Error sending transaction.`)
if (res.length === 0) throw new Error(`Error sending transaction`)

return res.forEach(assertOk)
}

if (res.check_tx.code || res.deliver_tx.code) {
let message = res.check_tx.log || res.deliver_tx.log
throw new Error(`Error sending transaction: ` + message)
throw new Error(message)
}
}
4 changes: 2 additions & 2 deletions archive/components/NiVotes.vue
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,10 @@ export default {
rootId: this.parent.rootId, // for comments
userUid: this.user.uid
})
.then(null, error => {
.then(null, err => {
this.$store.commit("notifyError", {
title: "Updating vote failed",
body: error.message
body: err.message
})
})
}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@
"webpack-dev-server": "2.11.2"
},
"dependencies": {
"@tendermint/ui": "0.3.1",
"@tendermint/ui": "0.4.1",
"@vue/test-utils": "1.0.0-beta.11",
"autosize": "4.0.2",
"axios": "0.18.0",
Expand Down
2 changes: 1 addition & 1 deletion test/unit/specs/components/wallet/PageSend.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ describe(`PageSend`, () => {
node.sign = () => Promise.reject()
await wrapper.vm.onApproved()
expect(store.state.notifications.length).toBe(1)
expect(store.state.notifications[0].title).toBe(`Error Sending`)
expect(store.state.notifications[0].title).toBe(`Error Sending transaction`)
expect(store.state.notifications[0]).toMatchSnapshot()
})

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2056,11 +2056,11 @@ exports[`PageSend should show bech32 error when alphanumeric is wrong 1`] = `

exports[`PageSend should show notification for unsuccessful send 1`] = `
Object {
"body": "An error occurred while trying to send: \\"Error sending transaction: Not enough coins in your account\\"",
"body": "Not enough coins in your account",
"icon": "error",
"layout": "alert",
"time": 42000,
"title": "Error Sending",
"title": "Error Sending transaction",
"type": "error",
}
`;
Expand Down
4 changes: 2 additions & 2 deletions test/unit/specs/store/__snapshots__/transactions.spec.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,7 @@ Array [
"value": Object {
"inputs": Array [
Object {
"address": "tb1cy0q7p",
"address": "cosmos1pxdf0lvq5jvl9uxznklgc5gxuwzpdy5ynem546",
"coins": Array [
Object {
"amount": "1234",
Expand Down Expand Up @@ -409,7 +409,7 @@ Array [
],
"outputs": Array [
Object {
"address": "tb1cy0q7p",
"address": "cosmos1pxdf0lvq5jvl9uxznklgc5gxuwzpdy5ynem546",
"coins": Array [
Object {
"amount": "1234",
Expand Down
47 changes: 47 additions & 0 deletions test/unit/specs/store/delegation.spec.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import setup from "../../helpers/vuex-setup"
import lcdClientMock from "renderer/connectors/lcdClientMock.js"
import delegationModule from "renderer/vuex/modules/delegation.js"

let instance = setup()

Expand Down Expand Up @@ -252,6 +253,52 @@ describe(`Module: Delegations`, () => {
expect(store.state.delegation.committedDelegates).toBeTruthy()
})

it(`should update the atoms on a delegation optimistically`, async () => {
const commit = jest.fn()
const delegates = store.state.delegates.delegates
let stakingTransactions = {}
stakingTransactions.delegations = [
{
validator: delegates[0],
atoms: 109
},
{
validator: delegates[1],
atoms: 456
}
]
let committedDelegates = {
[delegates[0].operator_address]: 10,
[delegates[1].operator_address]: 50
}

await delegationModule({}).actions.submitDelegation(
{
rootState: {
config: {
bondingDenom: `atom`
},
user: {
atoms: 1000
},
wallet: {}
},
state: {
committedDelegates
},
dispatch: () => {},
commit
},
{ stakingTransactions }
)

expect(commit).toHaveBeenCalledWith(`setAtoms`, 435)
expect(committedDelegates).toEqual({
[delegates[0].operator_address]: 119,
[delegates[1].operator_address]: 506
})
})

it(`should update updateDelegates after delegation`, async () => {
jest.useFakeTimers()
let stakingTransactions = {}
Expand Down
Loading

0 comments on commit bfcb33e

Please sign in to comment.