Skip to content

Commit

Permalink
Update Staking UI (hacky)
Browse files Browse the repository at this point in the history
  • Loading branch information
sisou committed Nov 21, 2024
1 parent a5a6bba commit 7533c2c
Show file tree
Hide file tree
Showing 12 changed files with 1,416 additions and 1,308 deletions.
20 changes: 20 additions & 0 deletions src/components/staking/StakingGraphPage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,12 @@ export default defineComponent({
);
const txs = await sendStaking({
transaction: transaction.serialize(),
recipientLabel: 'name' in activeValidator.value! ? activeValidator.value.name : 'Validator',
// @ts-expect-error Not typed yet in Hub
validatorImageUrl: 'logo' in activeValidator.value!
&& !activeValidator.value.hasDefaultIcon
? activeValidator.value.logo
: undefined,
}).catch((error) => {
throw new Error(error.data);
});
Expand Down Expand Up @@ -185,6 +191,13 @@ export default defineComponent({
);
const txs = await sendStaking({
transaction: transaction.serialize(),
recipientLabel: 'name' in activeValidator.value! ? activeValidator.value.name : 'Validator',
// @ts-expect-error Not typed yet in Hub
validatorAddress: activeValidator.value!.address,
validatorImageUrl: ('logo' in activeValidator.value!
&& !activeValidator.value.hasDefaultIcon)
? activeValidator.value.logo
: undefined,
}).catch((error) => {
throw new Error(error.data);
});
Expand Down Expand Up @@ -227,6 +240,13 @@ export default defineComponent({
);
const txs = await sendStaking({
transaction: transaction.serialize(),
recipientLabel: 'name' in activeValidator.value! ? activeValidator.value.name : 'Validator',
// @ts-expect-error Not typed yet in Hub
validatorAddress: activeValidator.value!.address,
validatorImageUrl: 'logo' in activeValidator.value! && !activeValidator.value.hasDefaultIcon
? activeValidator.value.logo
: undefined,
amount: Math.abs(stakeDelta.value),
}).catch((error) => {
throw new Error(error.data);
});
Expand Down
14 changes: 14 additions & 0 deletions src/components/staking/StakingInfoPage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@
>
<a href="#" slot="unstakeEverythingLink" @click="deactivateAll">{{ $t('unstake everything') }}</a>
</i18n>
<div v-else class="switch-validator"></div>

<!-- <button class="nq-button-s rewards-history" @click="$emit('next')">
{{ $t('Rewards history') }} &gt;
Expand Down Expand Up @@ -273,6 +274,13 @@ export default defineComponent({
const txs = await sendStaking({
transaction: transaction.serialize(),
recipientLabel: 'name' in validator.value! ? validator.value.name : 'Validator',
// @ts-expect-error Not typed yet in Hub
validatorAddress: validator.value!.address,
validatorImageUrl: 'logo' in validator.value! && !validator.value.hasDefaultIcon
? validator.value.logo
: undefined,
amount: Math.abs(stake.value.activeBalance),
});
if (!txs) {
Expand Down Expand Up @@ -352,6 +360,12 @@ export default defineComponent({
const txs = await sendStaking({
transaction: transactions.map((tx) => tx.serialize()),
recipientLabel: 'name' in validator.value! ? validator.value.name : 'Validator',
// @ts-expect-error Not typed yet in Hub
validatorAddress: validator.value!.address,
validatorImageUrl: 'logo' in validator.value! && !validator.value.hasDefaultIcon
? validator.value.logo
: undefined,
});
if (!txs) {
Expand Down
14 changes: 13 additions & 1 deletion src/components/staking/ValidatorDetailsOverlay.vue
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ export default defineComponent({
},
setup(props, context) {
const { activeAddress } = useAddressStore();
const { activeStake, setStake } = useStakingStore();
const { activeStake, setStake, activeValidator } = useStakingStore();
async function selectValidator() {
const validatorLabelOrAddress = 'name' in props.validator
Expand Down Expand Up @@ -125,6 +125,18 @@ export default defineComponent({
const txs = await sendStaking({
transaction: transaction.serialize(),
senderLabel: 'name' in activeValidator.value! ? activeValidator.value.name : 'Validator',
recipientLabel: 'name' in props.validator ? props.validator.name : 'Validator',
// @ts-expect-error Not typed yet in Hub
validatorAddress: props.validator.address,
validatorImageUrl: 'logo' in props.validator && !props.validator.hasDefaultIcon
? props.validator.logo
: undefined,
fromValidatorAddress: activeValidator.value!.address,
fromValidatorImageUrl: 'logo' in activeValidator.value! && !activeValidator.value.hasDefaultIcon
? activeValidator.value.logo
: undefined,
amount: activeStake.value.inactiveBalance,
}).catch((error) => {
throw new Error(error.data);
});
Expand Down
Loading

0 comments on commit 7533c2c

Please sign in to comment.