Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: display the staking list for EVM accounts #1030

Merged
merged 1 commit into from
Nov 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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