Skip to content

Commit

Permalink
fix(aeternity): share wallet info with dapp
Browse files Browse the repository at this point in the history
  • Loading branch information
CedrikNikita committed Dec 17, 2024
1 parent ef41173 commit e8941c4
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/composables/aeSdk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {
Encoded,
} from '@aeternity/aepp-sdk';
import { WalletApi } from '@aeternity/aepp-sdk/es/aepp-wallet-communication/rpc/types';
import { isEmpty } from 'lodash-es';

import type {
INetwork,
Expand Down Expand Up @@ -79,8 +80,8 @@ export function useAeSdk() {
onNetworkChange,
} = useNetworks();
const {
activeAccount,
accountsAddressList,
isLoggedIn,
getLastActiveProtocolAccount,
onAccountChange,
} = useAccounts();
Expand Down Expand Up @@ -130,10 +131,7 @@ export function useAeSdk() {
async function initAeSdk() {
isAeSdkUpdating.value = true;

await Promise.all([
watchUntilTruthy(isLoggedIn),
watchUntilTruthy(areNetworksRestored),
]);
await watchUntilTruthy(areNetworksRestored);

const nodeInstance = await createNodeInstance(aeActiveNetworkSettings.value.nodeUrl);

Expand All @@ -156,6 +154,8 @@ export function useAeSdk() {
const aepp = aeppInfo[aeppId];
const host = IS_OFFSCREEN_TAB ? aepp.origin : origin;
if (await checkOrAskPermission(METHODS.subscribeAddress, host)) {
// Waiting for activeAccount to sync back to the background
await watchUntilTruthy(() => !isEmpty(activeAccount.value));
return getLastActiveProtocolAccount(PROTOCOLS.aeternity)!.address;
}
return Promise.reject(new RpcRejectedByUserError());
Expand All @@ -164,6 +164,8 @@ export function useAeSdk() {
const aepp = aeppInfo[aeppId];
const host = IS_OFFSCREEN_TAB ? aepp.origin : origin;
if (await checkOrAskPermission(METHODS.address, host)) {
// Waiting for activeAccount to sync back to the background
await watchUntilTruthy(() => !isEmpty(activeAccount.value));
return accountsAddressList.value;
}
return Promise.reject(new RpcRejectedByUserError());
Expand Down

0 comments on commit e8941c4

Please sign in to comment.