add tx history and delegations
This commit is contained in:
parent
af9f1cac45
commit
8d5cdbf0f4
@ -43,7 +43,8 @@ export function getLocalTxHistory() {
|
||||
return getLocalObject('txHistory')
|
||||
}
|
||||
|
||||
export function setLocalTxHistory(newTx) {
|
||||
export function setLocalTxHistory(tx) {
|
||||
const newTx = tx
|
||||
const txs = getLocalTxHistory()
|
||||
if (txs) {
|
||||
txs.push(newTx)
|
||||
|
@ -516,7 +516,12 @@ export default {
|
||||
signerData,
|
||||
).then(bodyBytes => {
|
||||
this.$http.broadcastTx(bodyBytes).then(res => {
|
||||
setLocalTxHistory({ op: 'delegate', hash: res.tx_response.txhash, time: new Date() })
|
||||
setLocalTxHistory({
|
||||
chain: this.$store.state.chains.selected,
|
||||
op: 'delegate',
|
||||
hash: res.tx_response.txhash,
|
||||
time: new Date(),
|
||||
})
|
||||
this.$bvModal.hide('delegate-window')
|
||||
this.$toast({
|
||||
component: ToastificationContent,
|
||||
|
@ -457,7 +457,12 @@ export default {
|
||||
signerData,
|
||||
).then(bodyBytes => {
|
||||
this.$http.broadcastTx(bodyBytes, this.selectedChain).then(res => {
|
||||
setLocalTxHistory({ op: 'deposit', hash: res.tx_response.txhash, time: new Date() })
|
||||
setLocalTxHistory({
|
||||
chain: this.$store.state.chains.selected,
|
||||
op: 'deposit',
|
||||
hash: res.tx_response.txhash,
|
||||
time: new Date(),
|
||||
})
|
||||
this.$bvModal.hide('deposit-window')
|
||||
this.$toast({
|
||||
component: ToastificationContent,
|
||||
|
@ -453,7 +453,12 @@ export default {
|
||||
signerData,
|
||||
).then(bodyBytes => {
|
||||
this.$http.broadcastTx(bodyBytes).then(res => {
|
||||
setLocalTxHistory({ op: 'redelegate', hash: res.tx_response.txhash, time: new Date() })
|
||||
setLocalTxHistory({
|
||||
chain: this.$store.state.chains.selected,
|
||||
op: 'redelegate',
|
||||
hash: res.tx_response.txhash,
|
||||
time: new Date(),
|
||||
})
|
||||
this.$bvModal.hide('redelegate-window')
|
||||
this.$toast({
|
||||
component: ToastificationContent,
|
||||
|
@ -552,7 +552,12 @@ export default {
|
||||
signerData,
|
||||
).then(bodyBytes => {
|
||||
this.$http.broadcastTx(bodyBytes, this.selectedChain).then(res => {
|
||||
setLocalTxHistory({ op: 'send', hash: res.txhash, time: new Date() })
|
||||
setLocalTxHistory({
|
||||
chain: this.$store.state.chains.selected,
|
||||
op: 'transfer',
|
||||
hash: res.tx_response.txhash,
|
||||
time: new Date(),
|
||||
})
|
||||
this.$bvModal.hide('ibc-transfer-window')
|
||||
this.$toast({
|
||||
component: ToastificationContent,
|
||||
|
@ -455,7 +455,12 @@ export default {
|
||||
signerData,
|
||||
).then(bodyBytes => {
|
||||
this.$http.broadcastTx(bodyBytes, this.selectedChain).then(res => {
|
||||
setLocalTxHistory({ op: 'send', hash: res.txhash, time: new Date() })
|
||||
setLocalTxHistory({
|
||||
chain: this.$store.state.chains.selected,
|
||||
op: 'send',
|
||||
hash: res.tx_response.txhash,
|
||||
time: new Date(),
|
||||
})
|
||||
this.$bvModal.hide('transfer-window')
|
||||
this.$toast({
|
||||
component: ToastificationContent,
|
||||
|
@ -431,7 +431,12 @@ export default {
|
||||
signerData,
|
||||
).then(bodyBytes => {
|
||||
this.$http.broadcastTx(bodyBytes, this.selectedChain).then(res => {
|
||||
setLocalTxHistory({ op: 'unbond', hash: res.tx_response.txhash, time: new Date() })
|
||||
setLocalTxHistory({
|
||||
chain: this.$store.state.chains.selected,
|
||||
op: 'unbond',
|
||||
hash: res.tx_response.txhash,
|
||||
time: new Date(),
|
||||
})
|
||||
this.$bvModal.hide('unbond-window')
|
||||
this.$toast({
|
||||
component: ToastificationContent,
|
||||
|
@ -432,7 +432,12 @@ export default {
|
||||
signerData,
|
||||
).then(bodyBytes => {
|
||||
this.$http.broadcastTx(bodyBytes, this.selectedChain).then(res => {
|
||||
setLocalTxHistory({ op: 'vote', hash: res.tx_response.txhash, time: new Date() })
|
||||
setLocalTxHistory({
|
||||
chain: this.$store.state.chains.selected,
|
||||
op: 'vote',
|
||||
hash: res.tx_response.txhash,
|
||||
time: new Date(),
|
||||
})
|
||||
this.$bvModal.hide('vote-window')
|
||||
this.$toast({
|
||||
component: ToastificationContent,
|
||||
|
@ -338,7 +338,12 @@ export default {
|
||||
signerData,
|
||||
).then(bodyBytes => {
|
||||
this.$http.broadcastTx(bodyBytes, this.selectedChain).then(res => {
|
||||
setLocalTxHistory({ op: 'withdraw', hash: res.tx_response.txhash, time: new Date() })
|
||||
setLocalTxHistory({
|
||||
chain: this.$store.state.chains.selected,
|
||||
op: 'withdraw',
|
||||
hash: res.tx_response.txhash,
|
||||
time: new Date(),
|
||||
})
|
||||
this.$bvModal.hide('withdraw-commission-window')
|
||||
this.$toast({
|
||||
component: ToastificationContent,
|
||||
|
@ -363,7 +363,12 @@ export default {
|
||||
signerData,
|
||||
).then(bodyBytes => {
|
||||
this.$http.broadcastTx(bodyBytes, this.selectedChain).then(res => {
|
||||
setLocalTxHistory({ op: 'withdraw', hash: res.tx_response.txhash, time: new Date() })
|
||||
setLocalTxHistory({
|
||||
chain: this.$store.state.chains.selected,
|
||||
op: 'withdraw',
|
||||
hash: res.tx_response.txhash,
|
||||
time: new Date(),
|
||||
})
|
||||
this.$bvModal.hide('withdraw-window')
|
||||
this.$toast({
|
||||
component: ToastificationContent,
|
||||
|
@ -9,9 +9,13 @@
|
||||
Connect Wallet
|
||||
</b-card>
|
||||
</router-link>
|
||||
<b-card v-else>
|
||||
<b-card
|
||||
v-for="(items,k) in groupedDelegations"
|
||||
:key="k"
|
||||
:title="k"
|
||||
>
|
||||
<b-table
|
||||
:items="formatedDelegations"
|
||||
:items="items"
|
||||
stacked="sm"
|
||||
:fields="fields"
|
||||
>
|
||||
@ -29,8 +33,7 @@
|
||||
</template>
|
||||
<template #cell(delegator)="data">
|
||||
<router-link :to="`/${data.item.validator.chain}/account/${data.item.delegator_address}`">
|
||||
{{ data.value }}<br>
|
||||
<small>{{ data.item.delegator_address }}</small>
|
||||
Withdraw
|
||||
</router-link>
|
||||
</template>
|
||||
<template #cell(action)="data">
|
||||
@ -69,6 +72,8 @@
|
||||
</template>
|
||||
</b-table>
|
||||
</b-card>
|
||||
|
||||
<!--- not completed--->
|
||||
<operation-withdraw-component :address="address" />
|
||||
<operation-unbond-component
|
||||
:address="address"
|
||||
@ -126,11 +131,6 @@ export default {
|
||||
sortable: true,
|
||||
// sortByFormatted: true,
|
||||
},
|
||||
{
|
||||
key: 'delegator',
|
||||
sortable: true,
|
||||
// sortByFormatted: true,
|
||||
},
|
||||
{
|
||||
key: 'delegation',
|
||||
sortable: true,
|
||||
@ -141,6 +141,12 @@ export default {
|
||||
sortable: true,
|
||||
// sortByFormatted: true,
|
||||
},
|
||||
{
|
||||
key: 'delegator',
|
||||
label: '',
|
||||
sortable: true,
|
||||
// sortByFormatted: true,
|
||||
},
|
||||
],
|
||||
address: '',
|
||||
selectedValidator: '',
|
||||
@ -165,6 +171,30 @@ export default {
|
||||
// action: '',
|
||||
}))
|
||||
},
|
||||
groupedDelegations() {
|
||||
const group = {}
|
||||
this.delegations.forEach(x => {
|
||||
const d = {
|
||||
validator: {
|
||||
logo: x.chain.logo,
|
||||
validator: x.delegation.validator_address,
|
||||
moniker: this.findMoniker(x.chain.chain_name, x.delegation.validator_address),
|
||||
chain: x.chain.chain_name,
|
||||
},
|
||||
delegator: x.keyname,
|
||||
delegator_address: x.delegation.delegator_address,
|
||||
delegation: formatToken(x.balance),
|
||||
reward: this.findReward(x.delegation.delegator_address, x.delegation.validator_address),
|
||||
// action: '',
|
||||
}
|
||||
if (group[x.keyname]) {
|
||||
group[x.keyname].push(d)
|
||||
} else {
|
||||
group[x.keyname] = [d]
|
||||
}
|
||||
})
|
||||
return group
|
||||
},
|
||||
},
|
||||
created() {
|
||||
this.init()
|
||||
|
@ -1,62 +1,62 @@
|
||||
<template>
|
||||
<div>
|
||||
<b-table
|
||||
:items="deleTable"
|
||||
:items="history"
|
||||
:fields="fields"
|
||||
stacked="sm"
|
||||
>
|
||||
<template #cell(action)="data">
|
||||
<!-- size -->
|
||||
<b-button-group
|
||||
<template #cell(chain)="data">
|
||||
<b-avatar
|
||||
size="sm"
|
||||
>
|
||||
<b-button
|
||||
v-b-modal.delegate-window
|
||||
v-ripple.400="'rgba(113, 102, 240, 0.15)'"
|
||||
v-b-tooltip.hover.top="'Delegate'"
|
||||
variant="outline-primary"
|
||||
@click="selectValue(data.value)"
|
||||
>
|
||||
<feather-icon icon="LogInIcon" />
|
||||
</b-button>
|
||||
<b-button
|
||||
v-b-modal.redelegate-window
|
||||
v-ripple.400="'rgba(113, 102, 240, 0.15)'"
|
||||
v-b-tooltip.hover.top="'Redelegate'"
|
||||
variant="outline-primary"
|
||||
@click="selectValue(data.value)"
|
||||
>
|
||||
<feather-icon icon="ShuffleIcon" />
|
||||
</b-button>
|
||||
<b-button
|
||||
v-b-modal.unbond-window
|
||||
v-ripple.400="'rgba(113, 102, 240, 0.15)'"
|
||||
v-b-tooltip.hover.top="'Unbond'"
|
||||
variant="outline-primary"
|
||||
@click="selectValue(data.value)"
|
||||
>
|
||||
<feather-icon icon="LogOutIcon" />
|
||||
</b-button>
|
||||
</b-button-group>
|
||||
:src="data.item.chain.logo"
|
||||
/> {{ data.item.chain.chain_name }}
|
||||
</template>
|
||||
<template #cell(hash)="data">
|
||||
<router-link :to="`/${data.item.chain.chain_name}/tx/${data.value}`">
|
||||
{{ data.value }}
|
||||
</router-link>
|
||||
</template>
|
||||
</b-table>
|
||||
<div class="text-center">
|
||||
<b-button @click="clear()">
|
||||
Clear History
|
||||
</b-button>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import {
|
||||
BButton, VBTooltip, BTable,
|
||||
VBTooltip, BTable, BAvatar, BButton,
|
||||
} from 'bootstrap-vue'
|
||||
import { getLocalTxHistory } from '@/libs/utils'
|
||||
|
||||
export default {
|
||||
components: {
|
||||
BButton,
|
||||
BTable,
|
||||
BTable, BAvatar, BButton,
|
||||
},
|
||||
directives: {
|
||||
'b-tooltip': VBTooltip,
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
fields: [
|
||||
{ key: 'chain', label: 'BLOCKCHAIN' },
|
||||
{ key: 'op', label: 'ACTION' },
|
||||
{ key: 'hash', label: 'TX HASH' },
|
||||
{ key: 'time', label: 'TIME' },
|
||||
],
|
||||
history: [],
|
||||
}
|
||||
},
|
||||
created() {
|
||||
|
||||
this.history = getLocalTxHistory()
|
||||
},
|
||||
methods: {
|
||||
clear() {
|
||||
this.history = []
|
||||
localStorage.setItem('txHistory', [])
|
||||
},
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
Loading…
Reference in New Issue
Block a user