Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "wallet",
"version": "1.23.3",
"version": "1.23.4",
"description": "Web wallet for managing $EDGE",
"private": true,
"license": "GPL",
Expand Down
16 changes: 2 additions & 14 deletions src/components/Overviews.vue
Original file line number Diff line number Diff line change
@@ -1,31 +1,19 @@
<template>
<div>
<div class="overview-items" v-if="overviews">
<OverviewItem
v-for="(item, index) in overviews"
:key="index"
:setting="item" />
</div>

<div class="transactions-items" v-if="transactions">
<TransactionsTable :transactions="transactions" :limit="5" />
<div class="transactions-items">
<TransactionsTable :limit="5" />
</div>
</div>
</template>

<script>
import OverviewItem from '@/components/OverviewItem.vue'
import TransactionsTable from '@/components/TransactionsTable.vue'

export default {
// eslint-disable-next-line vue/multi-word-component-names
name: 'Overviews',
components: {
OverviewItem,
TransactionsTable
},
props: ['overviews', 'transactions'],
methods: {
}
}
</script>
Expand Down
3 changes: 3 additions & 0 deletions src/components/RecentBlocks.vue
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,9 @@ export default {
this.fetchBlocks()
this.pollData()
},
unmounted() {
clearInterval(this.polling)
},
methods: {
async fetchBlocks() {
const limit = this.isTestnet ? 5 : 7
Expand Down
2 changes: 1 addition & 1 deletion src/components/TransactionsTable.vue
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ export default {
addr,
{
limit: this.limit,
page: this.page,
page: this.page || 1,
sort: sortQuery
}
)
Expand Down
1 change: 1 addition & 0 deletions src/components/index/CreateModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,7 @@ export default {
}, this.sessionPassword)

await this.$store.dispatch('loadWallets', this.sessionPassword)
this.$store.dispatch('refresh')
this.$emit('created')
this.reset()
this.close()
Expand Down
1 change: 1 addition & 0 deletions src/components/index/RestoreModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,7 @@ export default {
}, this.sessionPassword)

await this.$store.dispatch('loadWallets', this.sessionPassword)
this.$store.dispatch('refresh')
this.$emit('imported')
this.reset()
this.close()
Expand Down
20 changes: 9 additions & 11 deletions src/components/stakes/CreateStakeModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -174,9 +174,7 @@ export default {
stakeType: '',

completedTx: null,
submitError: '',

vars: null
submitError: ''
}
},
validations() {
Expand All @@ -189,8 +187,9 @@ export default {
}
},
computed: {
...mapState(['address', 'balance', 'nextNonce']),
...mapState(['address', 'balance', 'nextNonce', 'vars']),
canAffordStake() {
if (!this.vars) return false
return this.balance >= this.vars.host_stake_amount
},
canCreate() {
Expand All @@ -200,15 +199,19 @@ export default {
return (this.balance - this.stakeAmount) / 1e6
},
shortHostStakeAmount() {
if (!this.vars) return ''
return this.formatShortAmount(this.vars.host_stake_amount)
},
shortGatewayStakeAmount() {
if (!this.vars) return ''
return this.formatShortAmount(this.vars.gateway_stake_amount)
},
shortStargateStakeAmount() {
if (!this.vars) return ''
return this.formatShortAmount(this.vars.stargate_stake_amount)
},
stakeAmount() {
if (!this.vars) return 0
switch (this.stakeType) {
case 'host':
return this.vars.host_stake_amount
Expand Down Expand Up @@ -290,10 +293,8 @@ export default {
goto(step) {
this.step = step
},
async updateVars() {
this.vars = await xe.vars(import.meta.env.VITE_BLOCKCHAIN_API_URL)
},
isStakeAffordable(type) {
if (!this.vars) return false
return this.balance - this.vars[type + '_stake_amount'] > 0
},
reset() {
Expand All @@ -313,9 +314,6 @@ export default {
}
}
},
mounted() {
this.updateVars()
},
setup() {
return {
v$: useVuelidate()
Expand All @@ -326,7 +324,7 @@ export default {
if (v === oldv) return
if (v) {
this.$store.dispatch('refresh')
this.updateVars()
this.$store.dispatch('refreshVars')
this.stakeType = 'host'
}
}
Expand Down
18 changes: 5 additions & 13 deletions src/components/stakes/ReleaseStakeModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -242,9 +242,7 @@ export default {
confirmPhrase: '',

completedTx: null,
submitError: '',

vars: null
submitError: ''
}
},
validations() {
Expand All @@ -260,7 +258,7 @@ export default {
}
},
computed: {
...mapState(['address', 'nextNonce']),
...mapState(['address', 'nextNonce', 'vars']),
canRelease() {
if (this.isUnlocked) return !this.v$.password.$invalid
else return !this.v$.$invalid
Expand All @@ -273,11 +271,11 @@ export default {
return this.unlocksAt < this.currentTime
},
releaseFeeParsed() {
if (this.isUnlocked) return 0
if (this.isUnlocked || !this.vars) return 0
else return this.stake.amount * this.vars.stake_express_release_fee / 1e6
},
releasePc() {
if (this.isUnlocked) return 0
if (this.isUnlocked || !this.vars) return 0
else return this.vars.stake_express_release_fee * 100
},
returnAmountParsed() {
Expand Down Expand Up @@ -335,9 +333,6 @@ export default {
return false
}
},
async updateVars() {
this.vars = await xe.vars(import.meta.env.VITE_BLOCKCHAIN_API_URL)
},
goto(step) {
this.step = step
},
Expand Down Expand Up @@ -407,9 +402,6 @@ export default {
}
}
},
mounted() {
this.updateVars()
},
setup() {
return {
v$: useVuelidate()
Expand All @@ -420,7 +412,7 @@ export default {
if (v === oldv) return
if (v) {
this.$store.dispatch('refresh')
this.updateVars()
this.$store.dispatch('refreshVars')
}
},
stake() {
Expand Down
1 change: 1 addition & 0 deletions src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ const init = async () => {

if (store.state.address) store.dispatch('refresh')
store.dispatch('refreshIndexConfig')
store.dispatch('refreshVars')
setInterval(() => store.dispatch('backgroundRefresh'), WALLET_REFRESH_INTERVAL)
}

Expand Down
22 changes: 20 additions & 2 deletions src/store.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ const init = async () => {
},

bridgeOnline: false,
vars: null,

// Multi-wallet support
wallets: [],
Expand Down Expand Up @@ -93,6 +94,9 @@ const init = async () => {
setBridgeOnline(state, online) {
state.bridgeOnline = online
},
setVars(state, vars) {
state.vars = vars
},
setNextNonce(state, nextNonce) {
state.nextNonce = nextNonce
},
Expand Down Expand Up @@ -183,6 +187,10 @@ const init = async () => {
console.error('Refresh failed:', err)
}
},
async refreshVars({ commit, state }) {
const vars = await xe.vars(state.config.blockchain.baseURL)
commit('setVars', vars)
},
async refreshIndexConfig({ commit, state }) {
const res = await fetch(`${state.config.index.baseURL}/v2/config`)
if (!res.ok) {
Expand Down Expand Up @@ -262,6 +270,15 @@ const init = async () => {
if (activeWallet) {
commit('setActiveWalletId', activeWallet.id)
commit('setAddress', activeWallet.address)
// Reset balance state so stale values from a previous wallet don't linger
const cachedBalance = state.walletBalances[activeWallet.id]
commit('setBalance', cachedBalance != null ? cachedBalance : 0)
commit('setNextNonce', 0)
if (cachedBalance != null && state.usdPerXE != null) {
commit('setUSDBalance', state.usdPerXE * (cachedBalance / 1e6))
} else {
commit('setUSDBalance', undefined)
}
await storage.setActiveWalletId(activeWallet.id)
}
} catch (err) {
Expand All @@ -275,11 +292,12 @@ const init = async () => {
const walletIds = state.wallets.map(w => w.id)
commit('setWalletBalancesLoading', walletIds)

// Fetch balances in parallel
// Fetch balances in parallel (uses info, not infoWithNextNonce,
// to avoid unnecessary pending transaction requests for non-active wallets)
const results = await Promise.allSettled(
state.wallets.map(async (wallet) => {
try {
const info = await xe.wallet.infoWithNextNonce(state.config.blockchain.baseURL, wallet.address)
const info = await xe.wallet.info(state.config.blockchain.baseURL, wallet.address)
return { walletId: wallet.id, balance: info.balance }
} catch (err) {
console.error(`Failed to fetch balance for ${wallet.address}:`, err)
Expand Down
63 changes: 2 additions & 61 deletions src/views/Overview.vue
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,11 @@

<div class="mt-35">
<h3>Recent transactions</h3>
<p v-if="error">{{error}}</p>

<Overviews :overviews="overviews" :transactions="transactions" />
<Overviews />
</div>

<div class="w-full text-right mt-20" v-if="transactions.length">
<div class="w-full text-right mt-20">
<router-link to="/transactions" class="button button--success">View all</router-link>
</div>
</div>
Expand All @@ -36,26 +35,11 @@ import NewsPromo from '@/components/NewsPromo.vue'
import Overviews from '@/components/Overviews.vue'
import RecentBlocks from '@/components/RecentBlocks.vue'
import TestnetFaucet from '@/components/Faucet.vue'
import dayjs from 'dayjs'
import { fetchTransactions } from '../utils/api'
import { mapState } from 'vuex'
import relativeTime from 'dayjs/plugin/relativeTime'

dayjs.extend(relativeTime)

const txCache = {}

export default {
name: 'ViewOverview',
title: 'Overview',
data: function () {
return {
transactions: [],
loading: true,
error: '',
polling: null,
overviews: [],
transactionRefreshInterval: 5000,
isTestnet: import.meta.env.VITE_IS_TESTNET === 'true'
}
},
Expand All @@ -66,49 +50,6 @@ export default {
NewsPromo,
RecentBlocks,
TestnetFaucet
},
computed: mapState(['address']),
watch: {
address(newAddr) {
const cached = txCache[newAddr]
if (cached) {
this.transactions = cached.transactions
this.metadata = cached.metadata
} else {
this.transactions = []
}
this.updateTransactions()
}
},
mounted() {
this.initialise()
},
unmounted() {
clearInterval(this.polling)
},
methods: {
async initialise() {
await this.updateTransactions()
this.pollData()
},
async updateTransactions() {
const addr = this.address
if (!addr) return
const { transactions, metadata } = await fetchTransactions(addr, { limit: 5 })

txCache[addr] = { transactions, metadata }
// Only update display if address hasn't changed during fetch
if (this.address === addr) {
this.transactions = transactions
this.metadata = metadata
this.loading = false
}
},
pollData() {
this.polling = setInterval(() => {
this.updateTransactions()
}, this.transactionRefreshInterval)
}
}
}
</script>