Adds detail to the wallet page about accumulated rewards from batching

This commit is contained in:
Sean Darcy 2022-06-08 16:38:28 +10:00
parent e7015e7d14
commit 05441b4689
8 changed files with 22605 additions and 2081 deletions

24576
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -63,7 +63,6 @@
"eslint-plugin-vue": "^5.2.3",
"husky": "^4.2.3",
"lint-staged": "^10.0.8",
"node-sass": "^4.13.1",
"prettier": "^1.19.1",
"sass-loader": "^7.1.0",
"strip-ansi": "^3.0.1"

View File

@ -25,6 +25,8 @@ export class WalletRPC {
password_hash: null,
balance: null,
unlocked_balance: null,
accrued_balance: null,
accrued_balance_next_payout: null,
onsRecords: []
};
this.isRPCSyncing = false;
@ -757,6 +759,8 @@ export class WalletRPC {
address: "",
balance: 0,
unlocked_balance: 0,
accrued_balance: 0,
accrued_balance_next_payout: 0,
height: 0,
view_only: false
},
@ -777,6 +781,9 @@ export class WalletRPC {
} else if (n.method == "getbalance") {
wallet.info.balance = n.result.balance;
wallet.info.unlocked_balance = n.result.unlocked_balance;
wallet.info.accrued_balance = n.result.accrued_balance;
wallet.info.accrued_balance_next_payout =
n.result.accrued_balance_next_payout;
} else if (n.method == "query_key") {
wallet.secret[n.params.key_type] = n.result.key;
if (n.params.key_type == "spend_key") {
@ -928,7 +935,10 @@ export class WalletRPC {
} else if (n.method == "getbalance") {
if (
this.wallet_state.balance == n.result.balance &&
this.wallet_state.unlocked_balance == n.result.unlocked_balance
this.wallet_state.unlocked_balance == n.result.unlocked_balance &&
this.wallet_state.accrued_balance == n.result.accrued_balance &&
this.wallet_state.accrued_balance_next_payout ==
n.result.accrued_balance_next_payout
) {
continue;
}
@ -936,6 +946,10 @@ export class WalletRPC {
this.wallet_state.balance = wallet.info.balance = n.result.balance;
this.wallet_state.unlocked_balance = wallet.info.unlocked_balance =
n.result.unlocked_balance;
this.wallet_state.accrued_balance = wallet.info.accrued_balance =
n.result.accrued_balance;
this.wallet_state.accrued_balance_next_payout = wallet.info.accrued_balance_next_payout =
n.result.accrued_balance_next_payout;
this.sendGateway("set_wallet_data", {
info: wallet.info
});
@ -2115,7 +2129,10 @@ export class WalletRPC {
info: {
address: data[0].result.address,
balance: data[1].result.balance,
unlocked_balance: data[1].result.unlocked_balance
unlocked_balance: data[1].result.unlocked_balance,
accrued_balance: data[1].result.accrued_balance,
accrued_balance_next_payout:
data[1].result.accrued_balance_next_payout
// num_unspent_outputs: data[1].result.num_unspent_outputs
},
address_list: {
@ -2879,6 +2896,8 @@ export class WalletRPC {
password_hash: null,
balance: null,
unlocked_balance: null,
accrued_balance: null,
accrued_balance_next_payout: null,
onsRecords: []
};

View File

@ -0,0 +1,35 @@
<template>
<span> {{ value }} </span>
</template>
<script>
export default {
name: "FormatNextPayout",
props: {
payoutBlock: {
type: Number,
required: true
},
currentBlock: {
type: Number,
required: true
}
},
computed: {
value() {
console.log(this.payoutBlock);
console.log(this.currentBlock);
if (this.payoutBlock == 0) return "";
let blocks = this.payoutBlock - this.currentBlock;
console.log(this.currentBlock);
if (blocks > 720) return (blocks / 720).toFixed(1) + " days";
else if (blocks > 30) return (blocks / 30).toFixed(1) + " hours";
else return blocks * 2 + " minutes";
}
}
};
</script>
<style></style>

View File

@ -8,19 +8,46 @@
<div class="row justify-center">
<div class="funds column items-center">
<div class="balance">
<div class="text">
<span>{{ $t("strings.oxenBalance") }}</span>
</div>
<q-btn-toggle
v-model="balancestakeselector"
text-color="white"
toggle-text-color="primary"
flat
:options="[
{
label: $t('strings.oxenBalance'),
value: 'balance'
},
{
label: $t('strings.stake'),
value: 'stake'
}
]"
/>
<div class="value">
<span><FormatOxen :amount="info.balance"/></span>
</div>
</div>
<div class="row unlocked">
<div v-if="balancestakeselector != 'stake'" class="row unlocked">
<span
>{{ $t("strings.oxenUnlockedShort") }}:
<FormatOxen :amount="info.unlocked_balance"
/></span>
</div>
<div v-if="balancestakeselector == 'stake'" class="row unlocked">
<span v-if="info.accrued_balance > 0"
>{{ $t("strings.oxenAccumulatedRewards") }}:
<FormatOxen :amount="info.accrued_balance" />
{{ $t("strings.nextPayout") }}:
<FormatNextPayout
:payout-block="info.accrued_balance_next_payout"
:current-block="info.height"
/>
</span>
<span v-if="info.accrued_balance == 0">
No accumulated rewards from staking
</span>
</div>
</div>
</div>
<div class="wallet-address row justify-center items-center">
@ -34,19 +61,26 @@
<script>
import { mapState } from "vuex";
import FormatOxen from "components/format_oxen";
import FormatNextPayout from "components/format_next_payout";
import WalletSettings from "components/menus/wallet_settings";
import CopyIcon from "components/icons/copy_icon";
export default {
name: "WalletDetails",
components: {
FormatOxen,
FormatNextPayout,
WalletSettings,
CopyIcon
},
computed: mapState({
theme: state => state.gateway.app.config.appearance.theme,
info: state => state.gateway.wallet.info
})
}),
data() {
return {
balancestakeselector: "balance"
};
}
};
</script>

View File

@ -504,6 +504,7 @@ export default {
destinationUnknown: "Destination Unknown",
editAddressBookEntry: "Edit address book entry",
expirationHeight: "Expiration height",
nextPayout: "Next payout",
ons: {
sessionID: "Session ID",
wallet: "Wallet Address",
@ -519,6 +520,7 @@ export default {
oxenBalance: "Balance",
lokinetNameDescription:
"Purchase or update a name on Lokinet. If you purchase a name it may take a minute or two for it to show up in the list. To learn more about lokinet visit: ",
oxenAccumulatedRewards: "Accumulated rewards",
oxenUnlockedBalance: "Unlocked balance",
oxenUnlockedShort: "Unlocked",
me: "Me",
@ -575,6 +577,7 @@ export default {
signAndVerifyDescription:
"Sign data with your primary address's private key or verify a signature against a public address.",
spendKey: "Spend key",
stake: "Staking",
startingDaemon: "Starting daemon",
startingWallet: "Starting wallet",
switchToDateSelect: "Switch to date select",

View File

@ -10,6 +10,8 @@ export const resetWalletData = state => {
height: 0,
balance: 0,
unlocked_balance: 0,
accrued_balance: 0,
accrued_balance_next_payout: 0,
view_only: false
},
secret: {

View File

@ -33,6 +33,8 @@ export default {
height: 0,
balance: 0,
unlocked_balance: 0,
accrued_balance: 0,
accrued_balance_next_payout: 0,
view_only: false
},
secret: {