Skip to content

Commit 999e719

Browse files
authored
Apply suggestion from @jiexi
1 parent 5997f89 commit 999e719

File tree

1 file changed

+5
-13
lines changed

1 file changed

+5
-13
lines changed

packages/connect-evm/src/connect.ts

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -279,22 +279,14 @@ export class MetamaskConnectEVM {
279279
forceRequest,
280280
});
281281

282-
// If account is already available, proceed immediately
283-
if (this.#provider.selectedAccount) {
284-
const resolvedParams =
285-
typeof params === 'function'
286-
? params(this.#provider.selectedAccount)
287-
: params;
288-
return await this.#provider.request({
289-
method,
290-
params: resolvedParams,
291-
});
292-
}
293-
294-
// Otherwise, wait for the accountsChanged event to be triggered
295282
// This is only needed for methods that require an account
296283
const timeout = 5000;
297284
const accountPromise = new Promise<Address>((resolve, reject) => {
285+
// If account is already available, proceed immediately
286+
if (this.#provider.selectedAccount) {
287+
return this.#provider.selectedAccount;
288+
}
289+
// Otherwise, wait for the accountsChanged event to be triggered
298290
// eslint-disable-next-line prefer-const
299291
let timeoutId: ReturnType<typeof setTimeout>;
300292

0 commit comments

Comments
 (0)