diff --git a/packages/wallet-sdk/src/CoinbaseWalletProvider.ts b/packages/wallet-sdk/src/CoinbaseWalletProvider.ts index 8e01cda0be..589073e61f 100644 --- a/packages/wallet-sdk/src/CoinbaseWalletProvider.ts +++ b/packages/wallet-sdk/src/CoinbaseWalletProvider.ts @@ -103,7 +103,7 @@ export class CoinbaseWalletProvider extends ProviderEventEmitter implements Prov } const signer = this.initSigner(signerType); - if (signerType === 'scw' && subAccountsConfig?.enableAutoSubAccounts) { + if (signerType === 'scw') { await signer.handshake({ method: 'handshake' }); // eth_requestAccounts gets translated to wallet_connect at SCWSigner level await signer.request(args); diff --git a/packages/wallet-sdk/src/sign/scw/SCWSigner.ts b/packages/wallet-sdk/src/sign/scw/SCWSigner.ts index 612c9a36a6..b94a025441 100644 --- a/packages/wallet-sdk/src/sign/scw/SCWSigner.ts +++ b/packages/wallet-sdk/src/sign/scw/SCWSigner.ts @@ -176,10 +176,10 @@ export class SCWSigner implements Signer { }, ], }); - this.callback?.('connect', { chainId: numberToHex(this.chain.id) }); + return this.accounts; } - case 'wallet_switchEthereumChain': { + case 'wallet_switchEthereumChain': { assertParamsChainId(request.params); this.chain.id = Number(request.params[0].chainId); return; @@ -236,6 +236,7 @@ export class SCWSigner implements Signer { : appendWithoutDuplicates(this.accounts, subAccount.address); } + this.callback?.('connect', { chainId: numberToHex(this.chain.id) }); return this.accounts; } case 'eth_coinbase': @@ -279,6 +280,8 @@ export class SCWSigner implements Signer { request, subAccountsConfig?.capabilities ?? {} ); + + this.callback?.('connect', { chainId: numberToHex(this.chain.id) }); return this.sendRequestToPopup(modifiedRequest); } // Sub Account Support @@ -293,7 +296,10 @@ export class SCWSigner implements Signer { if (!this.chain.rpcUrl) { throw standardErrors.rpc.internal('No RPC URL set for chain'); } - const response = await fetchRPCRequest(request, this.chain.rpcUrl) as GetSubAccountsResponse; + const response = (await fetchRPCRequest( + request, + this.chain.rpcUrl + )) as GetSubAccountsResponse; assertArrayPresence(response.subAccounts, 'subAccounts'); if (response.subAccounts.length > 0) { // cache the sub account