Skip to content

Commit

Permalink
chore: fix window.ethereum (#150)
Browse files Browse the repository at this point in the history
  • Loading branch information
joepegler committed Dec 10, 2024
1 parent 12b47a5 commit a1e34e7
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 3 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# @biconomy/sdk

## 0.0.18

### Patch Changes

- fix window.ethereum

## 0.0.17

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@biconomy/sdk",
"version": "0.0.17",
"version": "0.0.18",
"author": "Biconomy",
"repository": "github:bcnmy/sdk",
"main": "./dist/_cjs/index.js",
Expand Down
11 changes: 9 additions & 2 deletions src/sdk/account/utils/toSigner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ export async function toSigner<
| WalletClient<Transport, Chain | undefined, Account>
| undefined = undefined

if ("request" in signer && signer?.type !== "walletClient") {
if ("request" in signer) {
if (!address) {
try {
;[address] = await (signer as EthereumProvider).request({
Expand All @@ -112,8 +112,15 @@ export async function toSigner<
walletClient = signer as WalletClient<Transport, Chain | undefined, Account>
}

const addressFromWalletClient =
walletClient?.account?.address ?? (await walletClient?.getAddresses())?.[0]

if (!addressFromWalletClient) {
throw new Error("address not found in wallet client")
}

return toAccount({
address: walletClient.account.address,
address: addressFromWalletClient,
async signMessage({ message }) {
return walletClient.signMessage({ message })
},
Expand Down

0 comments on commit a1e34e7

Please sign in to comment.