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/1010 lcd stake #1068

Merged
merged 32 commits into from
Aug 10, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
fc2e561
updated endpoints with newest refactor
Aug 2, 2018
ee7ca94
Merge branch 'develop' of https://github.com/cosmos/voyager into fede…
Aug 2, 2018
bbffa6d
minor fixes
Aug 2, 2018
db90be8
switched to branch for testing staking
Aug 2, 2018
4c2da75
typo
Aug 2, 2018
b21b00b
adjusting to new API
Aug 2, 2018
61ba76e
made delegation kind of work
Aug 2, 2018
daef71f
showing old unbonding in pagebond
Aug 3, 2018
4ed2522
compatible to lcd staking refactor
Aug 3, 2018
a367f2b
Merge remote-tracking branch 'origin/develop' into fedekunze/1010-lcd…
Aug 6, 2018
dd65b7c
txs and other stuff working
Aug 6, 2018
18fa260
fixed some tests
Aug 7, 2018
6fbd396
linted
Aug 7, 2018
60d3bcc
fixed lcd mock tests
Aug 7, 2018
82e2d99
fixed lcdclient test
Aug 7, 2018
d2ac597
fixed pagetranscation test
Aug 7, 2018
e75045e
fixed app header tests (sideeffect)
Aug 7, 2018
22c49b4
Merge branch 'develop' into fedekunze/1010-lcd-stake
fedekunze Aug 8, 2018
6cc9ec2
Merge remote-tracking branch 'origin/develop' into fedekunze/1010-lcd…
Aug 8, 2018
ed7042b
fixed wrong indexing command
Aug 9, 2018
c01a5a8
added lcdclient mock tests
Aug 9, 2018
105a4b9
added merged commit
Aug 9, 2018
4033833
Merge branch 'fedekunze/1010-lcd-stake' of https://github.com/cosmos/…
Aug 9, 2018
28c660d
fix e2e tests
Aug 9, 2018
3bbe5da
using the commit of the delegation endpoint fix
Aug 9, 2018
2e8a7c0
Merge branch 'develop' into fedekunze/1010-lcd-stake
faboweb Aug 9, 2018
e58935b
increased coverage
Aug 9, 2018
9737d72
Merge branch 'fedekunze/1010-lcd-stake' of https://github.com/cosmos/…
Aug 9, 2018
b3119ad
removed notes
faboweb Aug 9, 2018
f9c20b8
increased coverage
Aug 9, 2018
0f2c28d
Merge branch 'fedekunze/1010-lcd-stake' of https://github.com/cosmos/…
Aug 9, 2018
f272b6b
Merge branch 'develop' into fedekunze/1010-lcd-stake
fedekunze Aug 10, 2018
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
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,13 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
* removed light theme option from preferences page @jolesbi
* enabled staked balance on PageWallet in production @faboweb
* removed unused xmlhttprequest dependency @faboweb
* LCD staking endpoints @fedekunze @faboweb

### Added

* storing balance, tx history and delegations locally to serve an old state faster @faboweb
* added error message for missing network config @faboweb
* showing staking txs in history @faboweb

### Fixed

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ $ sed -i.bak 's/seeds = ""/seeds = "localhost"/g' ./builds/testnets/local-testne
Activate TX indexing in your local node:

```bash
$ sed -i.bak 's/index_all_tags = true/index_all_tags = false/g' ./builds/testnets/local-testnet/config.toml
$ sed -i.bak 's/index_all_tags = false/index_all_tags = true/g' ~/.gaiad-testnet/config/config.toml
```

Store the gaia version used in your local testnet:
Expand Down
5 changes: 3 additions & 2 deletions app/src/renderer/components/common/AppHeader.vue
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ export default {
document.documentElement.clientWidth,
window.innerWidth || 0
)

if (w >= 1024) {
this.close()
this.$store.commit("setConfigDesktop", true)
Expand All @@ -65,6 +66,7 @@ export default {

#app-header
z-index z(appHeader)

.container
-webkit-app-region drag

Expand All @@ -85,7 +87,6 @@ export default {
top 0
left 0
width 100%

background var(--app-bg)

> .container
Expand All @@ -103,7 +104,6 @@ export default {
align-items center
justify-content center
padding 0 1rem

color var(--link)
cursor pointer

Expand Down Expand Up @@ -131,6 +131,7 @@ export default {
border-bottom px solid var(--bc)
padding 2.5rem 1rem 1rem 1rem
line-height normal

img
height 1.75rem
</style>
20 changes: 15 additions & 5 deletions app/src/renderer/components/staking/PageBond.vue
Original file line number Diff line number Diff line change
Expand Up @@ -152,15 +152,17 @@ export default {
ToolBar
},
computed: {
...mapGetters(["shoppingCart", "user", "committedDelegations", "config"]),
...mapGetters(["shoppingCart", "user", "delegation", "config"]),
denom() {
return this.config.bondingDenom.toUpperCase()
},
totalAtoms() {
return parseInt(this.user.atoms) + this.oldBondedAtoms
return (
parseInt(this.user.atoms) + this.oldBondedAtoms + this.oldUnbondingAtoms
)
},
oldBondedAtoms() {
return Object.values(this.committedDelegations).reduce(
return Object.values(this.delegation.committedDelegates).reduce(
(sum, d) => sum + parseInt(d),
0
)
Expand All @@ -177,14 +179,22 @@ export default {
return atoms
}, this.oldUnbondedAtoms)
},
oldUnbondingAtoms() {
return Object.values(this.delegation.unbondingDelegations).reduce(
(atoms, value) => {
return atoms + value
},
0
)
},
newUnbondingAtoms() {
return this.fields.delegates.reduce((atoms, d) => {
let delta = d.oldAtoms - d.atoms
if (delta > 0) {
return atoms + delta
}
return atoms
}, 0)
}, this.oldUnbondingAtoms)
},
newUnbondingAtomsDelta() {
return this.delta(this.newUnbondingAtoms, 0)
Expand Down Expand Up @@ -247,7 +257,7 @@ export default {
}
},
resetFields() {
let committedDelegations = this.committedDelegations
let committedDelegations = this.delegation.committedDelegates
let totalAtoms = this.totalAtoms
this.fields.bondConfirm = false
this.fields.delegates = this.shoppingCart.map(c =>
Expand Down
57 changes: 46 additions & 11 deletions app/src/renderer/components/wallet/PageTransactions.vue
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,19 @@ tm-page(title='Transactions')
modal-search(type="transactions" v-if="somethingToSearch")

tm-data-loading(v-if="wallet.historyLoading")
data-empty-tx(v-else-if='transactions.length === 0')
data-empty-tx(v-else-if='allTransactions.length === 0')
data-empty-search(v-else-if="filteredTransactions.length === 0")
tm-li-transaction(
v-else
v-for="i in filteredTransactions"
:key="shortid.generate()"
:transaction="i"
:address="wallet.address")
template(v-else v-for="i in filteredTransactions")
tm-li-transaction(
v-if="i.type === 'wallet'"
:key="shortid.generate()"
:transaction="i"
:address="wallet.address")
tm-li-staking-transaction(
v-if="i.type === 'staking'"
:key="shortid.generate()"
:transaction="i"
:address="wallet.address")
</template>

<script>
Expand All @@ -27,12 +32,15 @@ import Mousetrap from "mousetrap"
import DataEmptySearch from "common/TmDataEmptySearch"
import DataEmptyTx from "common/TmDataEmptyTx"
import ModalSearch from "common/TmModalSearch"
import { TmPage, TmDataLoading, TmLiTransaction } from "@tendermint/ui"
import { TmPage, TmDataLoading } from "@tendermint/ui"
import TmLiTransaction from "./TmLiTransaction"
import TmLiStakingTransaction from "./TmLiStakingTransaction"
import ToolBar from "common/TmToolBar"
export default {
name: "page-transactions",
components: {
TmLiTransaction,
TmLiStakingTransaction,
TmDataLoading,
DataEmptySearch,
DataEmptyTx,
Expand All @@ -41,12 +49,37 @@ export default {
ToolBar
},
computed: {
...mapGetters(["filters", "transactions", "wallet", "config"]),
...mapGetters([
"filters",
"transactions",
"wallet",
"config",
"delegation"
]),
somethingToSearch() {
return !this.wallet.historyLoading && !!this.transactions.length
return !this.wallet.historyLoading && !!this.allTransactions.length
},
allTransactions() {
return [].concat(
this.transactions.map(t => {
t.type = "wallet"
return t
}),
this.delegation.delegationTxs.map(t => {
t.type = "staking"
return t
})
)
},
orderedTransactions() {
return orderBy(this.transactions, [this.sort.property], [this.sort.order])
return orderBy(
this.allTransactions.map(t => {
t.height = parseInt(t.height)
return t // TODO what happens if block height is bigger then int?
}),
[this.sort.property],
[this.sort.order]
)
},
filteredTransactions() {
let query = this.filters.transactions.search.query
Expand All @@ -70,6 +103,7 @@ export default {
methods: {
refreshTransactions() {
this.$store.dispatch("queryWalletHistory")
this.$store.dispatch("getDelegationTxs")
},
setSearch(bool = !this.filters["transactions"].search.visible) {
if (!this.somethingToSearch) return false
Expand All @@ -79,6 +113,7 @@ export default {
mounted() {
Mousetrap.bind(["command+f", "ctrl+f"], () => this.setSearch(true))
Mousetrap.bind("esc", () => this.setSearch(false))
this.refreshTransactions()
}
}
</script>
160 changes: 160 additions & 0 deletions app/src/renderer/components/wallet/TmLiStakingTransaction.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,160 @@
<template lang='pug'>
.tm-li-tx(v-if="type === 'cosmos-sdk/MsgDelegate'" @click="() => devMode && viewTransaction()")
.tx-icon: i.material-icons remove_circle
.tx-container
.tx-element.tx-coins
.tx-coin
.key {{ tx.delegation.denom.toUpperCase() }}
.value {{ pretty(tx.delegation.amount) }}
div
.tx-element.tx-date(v-if="devMode") {{ date }}
.tx-element.tx-address Staked to {{ tx.validator_addr }}

.tm-li-tx.tm-li-tx-sent(v-else-if="type === 'cosmos-sdk/BeginUnbonding'" @click="() => devMode && viewTransaction()")
.tx-icon: i.material-icons add_circle
.tx-container
.tx-element.tx-coins
.tx-coin
.key STEAK
.value {{ pretty(tx.shares_amount) }}
div
.tx-element.tx-date(v-if="devMode") {{ date }}
.tx-element.tx-address Started unbonding from {{ tx.validator_addr }}
</template>

<script>
import moment from "moment"
import numeral from "numeral"

export default {
name: "tm-li-staking-transaction",
computed: {
tx() {
return this.transaction.tx.value.msg[0].value
},
type() {
return this.transaction.tx.value.msg[0].type
},
date() {
try {
return moment(this.transaction.time).format("MMMM Do YYYY, h:mm:ss a")
} catch (error) {
return null
}
}
},
data: () => ({
devMode:
process.env.PREVIEW !== undefined
? JSON.parse(process.env.PREVIEW)
: process.env.NODE_ENV === "development"
}),
methods: {
pretty(num) {
return numeral(num).format("0,0.00")
},
viewTransaction() {
// console.log("TODO: implement tx viewer")
}
},
props: {
transaction: {},
address: null
}
}
</script>

<style lang="stylus">
@require '~variables'

.tm-li-tx
display flex
font-size sm
border-bottom 1px solid var(--bc-dim)

&:nth-of-type(2n-1)
background var(--app-fg)

.tx-icon
padding 0 0.5rem
background var(--app-fg)
display flex
align-items center
justify-content center

.tx-container
flex-direction column
flex-wrap nowrap
padding 0.5rem 0
margin 0.5rem 0
display flex
width 100%
min-width 0 // fix text-overflow

.tx-element
padding 0 2rem 0 1.5rem
line-height 1.5rem

.tx-coin
.value
flex 0 0 100%
font-size sm
color var(--dim)

&:before
content ''
display inline

.key
font-weight 500
font-size m

.value, .key
line-height 1.5rem

.tx-address
white-space nowrap
overflow hidden
text-overflow ellipsis
color var(--dim)
font-size sm

&.tm-li-tx-sent
.tx-coin .value
&:before
content '-'

&.tm-li-tx-received
.tx-icon
background var(--app-fg)

.tx-coin .value
color success

&:before
content '+'

&:hover
cursor pointer
background var(--hover-bg)

@media screen and (min-width: 700px)
.tm-li-tx
font-size 0.875rem

.tx-container
flex-direction row

.tx-coins
flex 0 0 9rem
padding 0
min-width 0

.tx-coin
padding 0 1.5rem 0

.key
white-space nowrap
overflow hidden
text-overflow ellipsis
</style>
Loading