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

Parsed Err msg #1094

Merged
merged 18 commits into from
Aug 14, 2018
Merged
Show file tree
Hide file tree
Changes from 5 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 @@ -19,6 +19,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.

### Fixed

* delegation error message properly parsed @fedekunze
* testnets not properly available after download @faboweb
* Tell the main process when we switch to the mock network. @NodeGuy

Expand Down
19 changes: 14 additions & 5 deletions app/src/renderer/components/staking/PageBond.vue
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ tm-page.page-bond(:title="`Bond ${denom}`")
type="number"
placeholder="Atoms"
:value="newUnbondedAtoms")

tm-form-msg(type="between"
v-if="newUnbondedAtoms < 0")
| You can't bond more Atoms then you have
Expand Down Expand Up @@ -237,10 +237,19 @@ export default {
})
this.$router.push("/staking")
} catch (err) {
this.$store.commit("notifyError", {
title: "Error While Bonding Atoms",
body: err.message
})
let errData = err.message.split("\n")[5]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will probably be used more often (like with sending coins). Can we implement this somehow in send.js like changing the error message there?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm trying to figure out which types of errors are encountered while transferring tokens

if (errData) {
let parsedErr = errData.split('"')[1]
this.$store.commit("notifyError", {
title: "Error While Bonding Atoms",
body: parsedErr[0].toUpperCase() + parsedErr.slice(1)
})
} else {
this.$store.commit("notifyError", {
title: "Error While Bonding Atoms",
body: err.message
})
}
} finally {
this.delegating = false
}
Expand Down
26 changes: 26 additions & 0 deletions test/unit/specs/components/staking/PageBond.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -423,4 +423,30 @@ describe("PageBond", () => {
expect(wrapper.vm.showsRevokedValidators).toBe(true)
expect(wrapper.vm.$el).toMatchSnapshot()
})

it("shows an error if trying to bond to revoked candidates", () => {
wrapper.setData({
fields: {
delegates: [
{
id: "pubkeyX",
delegate: Object.assign(
{},
store.getters.shoppingCart[0].delegate,
{ revoked: true }
),
atoms: 0
},
{
id: "pubkeyY",
delegate: store.getters.shoppingCart[1].delegate,
atoms: 25
}
]
}
})
wrapper.findAll("#btn-bond").trigger("click")
expect(store.dispatch.mock.calls[0]).toBeUndefined()
expect(wrapper.vm.$el.querySelector(".tm-form-msg--error")).not.toBeNull()
})
})