Skip to content

Commit

Permalink
Check for missing addListener (#37)
Browse files Browse the repository at this point in the history
* Check for missing addListener

* Bump version
  • Loading branch information
aryzing authored Aug 13, 2024
1 parent e25f172 commit ed38ea4
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@sats-connect/core",
"version": "0.2.0",
"version": "0.2.1",
"main": "dist/index.mjs",
"module": "dist/index.mjs",
"types": "dist/index.d.mts",
Expand Down
11 changes: 11 additions & 0 deletions src/request/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,17 @@ export const addListener = (
throw new Error('no wallet provider was found');
}

// Clients may have be using the latest version of sats-connect without their
// wallets having been updated. Until we have API versioning for the wallet,
// we can avoid having apps crash by checking whether the adapter actually
// supports `addListener`.
if (!provider.addListener) {
console.error(
`The wallet provider you are using does not support the addListener method. Please update your wallet provider.`
);
return () => {};
}

return provider.addListener(event, cb);
};

Expand Down

0 comments on commit ed38ea4

Please sign in to comment.