Skip to content

Commit

Permalink
currentEra and contractEraStake errors fix (#1147)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
bobo-k2 authored Jan 22, 2024
1 parent 305b93f commit 099c1a3
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
6 changes: 6 additions & 0 deletions src/hooks/dapps-staking/useDispatchGetDapps.ts
Original file line number Diff line number Diff line change
@@ -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';

Expand All @@ -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<void> => {
Expand All @@ -30,6 +32,10 @@ export function useDispatchGetDapps() {
};

const getDapps = async (): Promise<void> => {
if (isDappStakingV3.value) {
return;
}

const isConnectedWallet = networkNameSubstrate.value && senderSs58Account.value;
if (isConnectedWallet && !isZkEvm.value) {
const address = !senderSs58Account.value ? '' : senderSs58Account.value;
Expand Down
6 changes: 6 additions & 0 deletions src/hooks/useClaimAll.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -34,6 +35,7 @@ export function useClaimAll() {
const { era } = useCurrentEra();
const { accountData } = useBalance(senderSs58Account);
const { isLedgerNanoS } = useLedger();
const { isDappStakingV3 } = useDappStaking();

const maxBatchWeight = computed<BN>(() => {
if (isLedger.value) {
Expand All @@ -59,6 +61,10 @@ export function useClaimAll() {

const updateClaimEras = async (): Promise<void> => {
try {
if (isDappStakingV3.value) {
return;
}

isLoading.value = true;
const api = $api;
const senderAddressRef = senderSs58Account.value;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,7 @@ export class DappStakingRepository implements IDappStakingRepository {
public async getCurrentEra(): Promise<u32> {
const api = await this.api.getApi();

return await api.query.dappsStaking.currentEra<u32>();
return (await api.query.dappsStaking?.currentEra<u32>()) ?? 0;
}

public async getNextEraEta(network: string): Promise<number> {
Expand Down

0 comments on commit 099c1a3

Please sign in to comment.