Skip to content

Commit 10ca0bc

Browse files
committed
[SDK] Fix: Limit WC chains connected to 10 for max payload size (#5427)
CNCT-2231 <!-- start pr-codex --> --- ## PR-Codex overview This PR introduces a validation check for the `chains` option in the WalletConnect integration, ensuring that no more than 10 chains can be specified. If more than 10 chains are provided, a warning is logged, and only the first 10 chains are used. ### Detailed summary - Added a check for `options.chains` to limit the number of chains to a maximum of 10. - Implemented a warning message if more than 10 chains are specified, informing the user of the truncation. - Used `slice(0, 10)` to return only the first 10 chains if the limit is exceeded. > ✨ Ask PR-Codex anything about this PR by commenting with `/codex {your question}` <!-- end pr-codex -->
1 parent 7b21f1b commit 10ca0bc

File tree

1 file changed

+9
-1
lines changed
  • packages/thirdweb/src/wallets/wallet-connect/receiver

1 file changed

+9
-1
lines changed

packages/thirdweb/src/wallets/wallet-connect/receiver/index.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,11 +161,19 @@ export async function createWalletConnectClient(
161161
const {
162162
wallet,
163163
requestHandlers,
164-
chains,
165164
onConnect,
166165
onDisconnect,
167166
client: thirdwebClient,
168167
} = options;
168+
const chains = (() => {
169+
if (options.chains && options.chains.length > 10) {
170+
console.warn(
171+
"WalletConnect: Can specify no more than 10 chains, truncating to the first 10 provided chains...",
172+
);
173+
return options.chains.slice(0, 10);
174+
}
175+
return options.chains;
176+
})();
169177

170178
if (walletConnectClientCache.has(thirdwebClient)) {
171179
return walletConnectClientCache.get(thirdwebClient) as WalletConnectClient;

0 commit comments

Comments
 (0)