Skip to content

Commit

Permalink
Make provider optional in ethersAdapter
Browse files Browse the repository at this point in the history
  • Loading branch information
ryangoree committed Nov 22, 2024
1 parent 70665e6 commit 483d60a
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
5 changes: 5 additions & 0 deletions .changeset/sharp-mangos-search.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@delvtech/drift-ethers": patch
---

Made `provider` optional, in which case `window.ethereum` is used.
2 changes: 1 addition & 1 deletion packages/drift-ethers/src/EthersReadAdapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export class EthersReadAdapter implements ReadAdapter {
provider: Provider;

constructor({
provider = "ethereum" in window
provider = "window" in globalThis && "ethereum" in window
? new BrowserProvider(window.ethereum)
: getDefaultProvider(),
}: EthersReadAdapterParams = {}) {
Expand Down
4 changes: 2 additions & 2 deletions packages/drift-ethers/src/ethersAdapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ export interface EthersAdapterParams<
TProvider extends Provider = Provider,
TSigner extends Signer | undefined = Signer | undefined,
> {
provider: TProvider;
provider?: TProvider;
signer?: TSigner;
}

export function ethersAdapter<
TProvider extends Provider,
TProvider extends Provider = Provider,
TSigner extends Signer | undefined = undefined,
>({
provider,
Expand Down

0 comments on commit 483d60a

Please sign in to comment.