Skip to content

Commit

Permalink
fix: display the staking list for EVM accounts (#1030)
Browse files Browse the repository at this point in the history
  • Loading branch information
impelcrypto committed Nov 16, 2023
1 parent 168f981 commit 9613a72
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
14 changes: 7 additions & 7 deletions src/hooks/dapps-staking/useDispatchGetDapps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { computed, watch } from 'vue';
export function useDispatchGetDapps() {
const store = useStore();
const { isZkEvm, networkNameSubstrate } = useNetworkInfo();
const { currentAccount } = useAccount();
const { senderSs58Account } = useAccount();
const dapps = computed(() => store.getters['dapps/getAllDapps']);

// Memo: invoke this function whenever the users haven't connect to wallets
Expand All @@ -17,30 +17,30 @@ export function useDispatchGetDapps() {

const isBrowsingOnly = !!(
dapps.value.length === 0 &&
!currentAccount.value &&
!senderSs58Account.value &&
networkNameSubstrate.value
);

if (isBrowsingOnly || isZkEvm.value) {
store.dispatch('dapps/getDapps', {
network: networkNameSubstrate.value.toLowerCase(),
currentAccount: '',
senderSs58Account: '',
});
}
};

const getDapps = async (): Promise<void> => {
const isConnectedWallet = networkNameSubstrate.value && currentAccount.value;
const isConnectedWallet = networkNameSubstrate.value && senderSs58Account.value;
if (isConnectedWallet && !isZkEvm.value) {
const address = !currentAccount.value ? '' : currentAccount.value;
const address = !senderSs58Account.value ? '' : senderSs58Account.value;
store.dispatch('dapps/getDapps', {
network: networkNameSubstrate.value.toLowerCase(),
currentAccount: address,
senderSs58Account: address,
});
} else {
getDappsForBrowser();
}
};

watch([currentAccount, networkNameSubstrate], getDapps, { immediate: true });
watch([senderSs58Account, networkNameSubstrate], getDapps, { immediate: true });
}
8 changes: 4 additions & 4 deletions src/store/dapp-staking/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ export const hasExtrinsicFailedEvent = (
const actions: ActionTree<State, StateInterface> = {
async getDapps(
{ commit, dispatch },
{ network, currentAccount }: { network: string; currentAccount: string }
{ network, senderSs58Account }: { network: string; senderSs58Account: string }
) {
const accountUnificationService = container.get<IAccountUnificationService>(
Symbols.AccountUnificationService
Expand All @@ -98,9 +98,9 @@ const actions: ActionTree<State, StateInterface> = {
// Fetch dapps
const dappsUrl = `${TOKEN_API_URL}/v1/${network.toLowerCase()}/dapps-staking/dappssimple`;
const service = container.get<IDappStakingService>(Symbols.DappStakingService);
const address = isValidEvmAddress(currentAccount)
? await accountUnificationService.getMappedNativeAddress(currentAccount)
: currentAccount;
const address = isValidEvmAddress(senderSs58Account)
? await accountUnificationService.getMappedNativeAddress(senderSs58Account)
: senderSs58Account;
const [dapps, combinedInfo] = await Promise.all([
axios.get<DappItem[]>(dappsUrl),
service.getCombinedInfo(address),
Expand Down

0 comments on commit 9613a72

Please sign in to comment.