Skip to content

Commit

Permalink
chore: refactor - remove unused
Browse files Browse the repository at this point in the history
  • Loading branch information
MGrgr committed May 6, 2022
1 parent b3c5186 commit 9cc4706
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 73 deletions.
28 changes: 0 additions & 28 deletions src/store/validators-all.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,8 @@ import { useWallet } from 'solana-wallets-vue';
import { useConnectionStore, useStakeAccountStore } from '@/store';
import { useEmitter } from '@/hooks';
import {
ApyStats,
ValidatorStats,
formatPct,
getAverageApy,
getValidatorsStats,
lamportsToSol,
priceFormatter,
Expand Down Expand Up @@ -96,8 +94,6 @@ export const useValidatorsAllStore = defineStore('validators-all', () => {
const { connected } = useWallet();

const validatorsStats = shallowRef<Array<ValidatorStats>>([]);
const averageApy = shallowRef<Array<ApyStats>>([]);
const averageApyLoading = ref(false);
const loading = ref(false);

const nameFilter = ref('');
Expand Down Expand Up @@ -136,27 +132,6 @@ export const useValidatorsAllStore = defineStore('validators-all', () => {
}
};

const loadAverageApy = async () => {
if (averageApyLoading.value) {
return;
}
if (cluster.value === 'mainnet-beta') {
averageApyLoading.value = true;
console.log('[useValidatorsAllStore] Loading average APY...');
averageApy.value = await getAverageApy();
averageApyLoading.value = false;
} else {
averageApy.value = [];
}
};

// onBeforeMount(() => {
// loadAverageApy();
// if (validatorsStats.value.length < 1) {
// loadAllValidators();
// }
// });

watch(
connected,
(connected) => {
Expand All @@ -169,7 +144,6 @@ export const useValidatorsAllStore = defineStore('validators-all', () => {
cluster,
useDebounceFn(() => {
loadAllValidators();
loadAverageApy();
}, 250),
{ immediate: true },
);
Expand Down Expand Up @@ -313,12 +287,10 @@ export const useValidatorsAllStore = defineStore('validators-all', () => {
filters,
itemsTotal: computed(() => items.value.length),
items: itemsComputed,
averageApy,
loading,
showControls,
showControlsMob,

loadAllValidators,
loadAverageApy,
};
});
45 changes: 0 additions & 45 deletions src/utils/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,6 @@ export interface ValidatorStats {
apyComparedMax: Number;
}

export interface ApyStats {
apy: number;
epoch: number;
}

export async function getValidatorsStats(network) {
return new Promise<Array<ValidatorStats>>((resolve, reject) => {
// fetch(`http://localhost:3000/validators/list?network=${network}`)
Expand All @@ -73,43 +68,3 @@ export async function getValidatorsStats(network) {
);
});
}

export async function getApyHistory(voterKey) {
return new Promise<Array<ApyStats>>((resolve, _reject) => {
fetch(`${API_COLLECTOR_URL}/apy/history?voter_id=${voterKey}`)
.then((res) => res.json())
.then(
(res) => {
if (res.data?.length > 0) {
resolve(res.data);
} else {
// resolve([]);
// reject(Error('Promise rejected'));
}
},
(error) => {
console.error(error);
},
);
});
}

export async function getAverageApy() {
return new Promise<Array<ApyStats>>((resolve, _reject) => {
fetch(`${API_COLLECTOR_URL}/apy-average/history`)
.then((res) => res.json())
.then(
(res) => {
if (res.data?.length > 0) {
resolve(res.data);
} else {
// resolve([]);
// reject(Error('Promise rejected'));
}
},
(error) => {
console.error(error);
},
);
});
}

0 comments on commit 9cc4706

Please sign in to comment.