Skip to content
Merged
Show file tree
Hide file tree
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
5 changes: 5 additions & 0 deletions .changeset/fix-swidge-session-relay-errors.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@walletconnect/cli-sdk": patch
---

Fix swidge NO_MATCHING_KEY error by only requiring source chain in session namespaces, and prevent unhandled relay errors from crashing Node during wallet request rejection/timeout
7 changes: 4 additions & 3 deletions packages/cli-sdk/src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -298,9 +298,10 @@ async function cmdSwidge(browser: boolean, args: string[]): Promise<void> {
process.exit(1);
}

const chains = [fromChain];
if (!chains.includes(toChain)) chains.push(toChain);
const sdk = createSDK({ projectId, browser, chains });
// Only require the source chain in the session — the bridge tx is sent on fromChain.
// Including toChain causes NO_MATCHING_KEY when restoring a session that doesn't
// include the destination chain in its approved namespaces.
const sdk = createSDK({ projectId, browser, chains: [fromChain] });

try {
let result = await sdk.tryRestore();
Expand Down
7 changes: 7 additions & 0 deletions packages/cli-sdk/src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,11 @@ export class WalletConnectCLI extends EventEmitter {

this.logRequestDetails(options);

// Absorb relay WebSocket errors so they don't crash the process
// as unhandled 'error' events (the actual rejection is caught below).
const swallow = () => {};
client.core.relayer.on("error", swallow);

try {
return await client.request<T>({
topic,
Expand All @@ -162,6 +167,8 @@ export class WalletConnectCLI extends EventEmitter {
}

throw error;
} finally {
client.core.relayer.off("error", swallow);
}
}

Expand Down