From 099c1a3c4d12be225e4d316f6694f77fcb4150c4 Mon Sep 17 00:00:00 2001 From: Bobo Date: Mon, 22 Jan 2024 15:29:10 +0100 Subject: [PATCH] currentEra and contractEraStake errors fix (#1147) * Import staking v3 * Condition added * Check staking version before era change subscription * One more try * One more try. * Revert some not needed changes * contractEraStake error fix --- src/hooks/dapps-staking/useDispatchGetDapps.ts | 6 ++++++ src/hooks/useClaimAll.ts | 6 ++++++ .../repositories/implementations/DappStakingRepository.ts | 2 +- 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/hooks/dapps-staking/useDispatchGetDapps.ts b/src/hooks/dapps-staking/useDispatchGetDapps.ts index f5c7479c3..29cbcd174 100644 --- a/src/hooks/dapps-staking/useDispatchGetDapps.ts +++ b/src/hooks/dapps-staking/useDispatchGetDapps.ts @@ -1,5 +1,6 @@ import { wait } from '@astar-network/astar-sdk-core'; import { useAccount, useNetworkInfo } from 'src/hooks'; +import { useDappStaking } from 'src/staking-v3'; import { useStore } from 'src/store'; import { computed, watch } from 'vue'; @@ -8,6 +9,7 @@ export function useDispatchGetDapps() { const { isZkEvm, networkNameSubstrate } = useNetworkInfo(); const { senderSs58Account } = useAccount(); const dapps = computed(() => store.getters['dapps/getAllDapps']); + const { isDappStakingV3 } = useDappStaking(); // Memo: invoke this function whenever the users haven't connect to wallets const getDappsForBrowser = async (): Promise => { @@ -30,6 +32,10 @@ export function useDispatchGetDapps() { }; const getDapps = async (): Promise => { + if (isDappStakingV3.value) { + return; + } + const isConnectedWallet = networkNameSubstrate.value && senderSs58Account.value; if (isConnectedWallet && !isZkEvm.value) { const address = !senderSs58Account.value ? '' : senderSs58Account.value; diff --git a/src/hooks/useClaimAll.ts b/src/hooks/useClaimAll.ts index 8486919fb..901a1c280 100644 --- a/src/hooks/useClaimAll.ts +++ b/src/hooks/useClaimAll.ts @@ -13,6 +13,7 @@ import { Symbols } from 'src/v2/symbols'; import { ethers } from 'ethers'; import { computed, ref, watch } from 'vue'; import { useI18n } from 'vue-i18n'; +import { useDappStaking } from 'src/staking-v3'; const MAX_BATCH_WEIGHT = new BN('50000000000'); // Memo: ≒56 eras const MAX_BATCH_WEIGHT_LEDGER = new BN('6000000000'); //Memo: 6 eras @@ -34,6 +35,7 @@ export function useClaimAll() { const { era } = useCurrentEra(); const { accountData } = useBalance(senderSs58Account); const { isLedgerNanoS } = useLedger(); + const { isDappStakingV3 } = useDappStaking(); const maxBatchWeight = computed(() => { if (isLedger.value) { @@ -59,6 +61,10 @@ export function useClaimAll() { const updateClaimEras = async (): Promise => { try { + if (isDappStakingV3.value) { + return; + } + isLoading.value = true; const api = $api; const senderAddressRef = senderSs58Account.value; diff --git a/src/v2/repositories/implementations/DappStakingRepository.ts b/src/v2/repositories/implementations/DappStakingRepository.ts index 895bed67c..2e921b848 100644 --- a/src/v2/repositories/implementations/DappStakingRepository.ts +++ b/src/v2/repositories/implementations/DappStakingRepository.ts @@ -350,7 +350,7 @@ export class DappStakingRepository implements IDappStakingRepository { public async getCurrentEra(): Promise { const api = await this.api.getApi(); - return await api.query.dappsStaking.currentEra(); + return (await api.query.dappsStaking?.currentEra()) ?? 0; } public async getNextEraEta(network: string): Promise {