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

refactor: Change the logic for waiting about the isSignedIn() in Sender #945

Merged
merged 1 commit into from
Sep 27, 2023
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
19 changes: 10 additions & 9 deletions packages/sender/src/lib/sender.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,16 @@ const Sender: WalletBehaviourFactory<InjectedWallet> = async ({
};

const getAccounts = async (): Promise<Array<Account>> => {
// Add extra wait to ensure Sender's sign in status is read from the
// browser extension background env.
// Check for isSignedIn() in only if selectedWalletId is set.
const { selectedWalletId } = store.getState();
if (selectedWalletId) {
await waitFor(() => !!_state.wallet?.isSignedIn(), {
timeout: 1000,
}).catch();
}

const accountId = _state.wallet.getAccountId();

if (!accountId) {
Expand Down Expand Up @@ -322,15 +332,6 @@ export function setupSender({

const installed = await isInstalled();

// Add extra wait to ensure Sender's sign in status is read from the
// browser extension background env.
// Check for isSignedIn() in only if extension is installed.
if (installed) {
await waitFor(() => !!window.near?.isSignedIn(), { timeout: 200 }).catch(
() => false
);
}

return {
id: "sender",
type: "injected",
Expand Down
Loading