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(aeternity): share wallet info with dapp #3432

Merged
merged 1 commit into from
Dec 18, 2024
Merged
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
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
Loading