update visual fixes

This commit is contained in:
EmberSpirit
2023-10-18 23:26:29 +02:00
parent 32ababbb39
commit f45128ceb9
14 changed files with 2349 additions and 2246 deletions
+60 -11
View File
@@ -30,13 +30,9 @@
</div>
<div class="connected-stake-body">
<slot name="body">
<token-name-price
v-if="walletStore.memeToken?.staked"
:name="tokenStore.getToken(walletStore.memeToken?.contractAddress)?.name"
:price="formatNumber(walletStore.memeToken?.staked / 10n ** tokenStore.memeToken.decimals)"
></token-name-price>
<token-name-price name="$BLOOD staked" :price="formatNumber(walletStore.staked)"></token-name-price>
<token-logo img="/assets/img/token/bloodline.png" :alt="'bloodline-token'"></token-logo>
<token-name-price class="stake-reward" name="Extra Reward" price="+25%"></token-name-price>
<token-name-price class="stake-reward" name="Bonus" price="+25%"></token-name-price>
</slot>
</div>
<slot name="actions">
@@ -134,8 +130,26 @@
<div class="connected-stake-first-round small-text text-center" v-if="cycleStore.currentCycle === 0">
No $BLOOD on the market. Staking is activated after the first cycle is finished.
</div>
<div class="connected-stake-first-round small-text text-center" v-else>
You can claim your stake next cycle
<div
class="connected-stake-first-round small-text text-center"
v-if="walletStore.orderedUnstakedAmount > 0"
>
You can claim {{ formatNumber(walletStore.orderedUnstakedAmount) }} $BLOOD next cycle.
</div>
<div>
<div
class="btn btn-immortal mid-mid-text text-center"
v-if="unstakeState === 0 && walletStore.orderedUnstakedAmount > 0n && ableToUnstake"
@click="unstake"
>
Claim Unstaked $BLOOD
</div>
<div class="btn btn--disabled mid-mid-text text-center" v-else-if="unstakeState === 1">
Sign Transaction
</div>
<div class="btn btn--disabled mid-mid-text text-center" v-else-if="unstakeState === 2">
<loading-component></loading-component>
</div>
</div>
</slot>
<slot></slot>
@@ -197,6 +211,7 @@ const loading = ref(false);
* state 4 staked
*/
const state = ref(0);
const unstakeState = ref(0);
function openStake() {
stake.value = true;
@@ -210,6 +225,31 @@ function openUnstake() {
stakeMenu.value = true;
}
async function unstake() {
try {
unstakeState.value = 1;
const hash = await rewardLockerStore.unstake();
unstakeState.value = 2;
const data = await waitForTransaction({
hash: hash,
});
var rewardData = data.logs.find((logObject) => {
return logObject.topics.find(
(topic) => topic === "0xb89343427f692590c388d6346a8e42ea497eb6682a04db1a53f77ea81771ca91"
);
});
console.log("rewardData", rewardData);
const outputClaim = BigInt(rewardData.topics[3]) / 10n ** tokenStore.memeToken.decimals;
showSuccessToast(formatNumber(outputClaim), "Success!", "You just unstaked");
await walletStore.loadWalletData();
} catch (error) {
console.error("unstake", error);
} finally {
unstakeState.value = 0;
}
}
async function orderUnstake() {
try {
state.value = 2;
@@ -221,22 +261,23 @@ async function orderUnstake() {
state.value = 4;
var rewardData = data.logs.find((logObject) => {
return logObject.topics.find(
(topic) => topic === "0xd0813ff03c470dcc7baa9ce36914dc2febdfd276d639deffaac383fd3db42ba3"
(topic) => topic === "0xf86340d97020c624010a208b733db95795281fbc45cb6e6a40d161f91fa3e4a0"
);
});
console.log("rewardData", rewardData);
const outputClaim = Number(rewardData.topics[2]) / 10n ** tokenStore.memeToken.decimals;
const outputClaim = BigInt(rewardData.topics[3]) / 10n ** tokenStore.memeToken.decimals;
showSuccessToast(
formatNumber(outputClaim),
"Success!",
"You just unstaked",
"You can claim your stake next cycle."
);
await walletStore.loadWalletData();
stakeMenu.value = false;
} catch (error) {
console.error("orderUnstake", error);
} finally {
await walletStore.loadWalletData();
state.value = 0;
}
}
@@ -277,6 +318,14 @@ async function stakeToken() {
}
}
const ableToUnstake = computed(() => {
var cycleList = walletStore.memeToken.orderedUnstakedCycles.findIndex((obj) => obj.result > 0n);
if (cycleList && cycleList + 1 <= cycleStore.currentCycle) {
return true;
}
return false;
});
const balanceOf = computed(() => {
if (!walletStore.memeToken?.balanceOf) {
return 0n;