Skip to content

Commit

Permalink
feat: add EIP1193Provider type (#344)
Browse files Browse the repository at this point in the history
* feat: add EIP1193Provider type

* chore: format
  • Loading branch information
jxom authored Apr 10, 2023
1 parent ba92ff5 commit bb9c2a4
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 4 deletions.
5 changes: 5 additions & 0 deletions .changeset/pink-pugs-allow.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"viem": patch
---

Added `EIP1193Provider` type.
1 change: 1 addition & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,7 @@ export type {
ContractFunctionConfig,
ContractFunctionResult,
CustomSource,
EIP1193Provider,
FeeHistory,
FeeValues,
FeeValuesEIP1559,
Expand Down
5 changes: 5 additions & 0 deletions src/types/eip1193.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ import type {
RpcUncle as Uncle,
} from './rpc.js'

//////////////////////////////////////////////////
// Provider

export type EIP1193Provider = Requests & Events

//////////////////////////////////////////////////
// Errors

Expand Down
2 changes: 2 additions & 0 deletions src/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ export type {
MaybeExtractEventArgsFromAbi,
} from './contract.js'

export type { EIP1193Provider } from './eip1193.js'

export type { AssetGateway, AssetGatewayUrls } from './ens.js'

export type {
Expand Down
6 changes: 2 additions & 4 deletions src/types/window.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import type { Events, Requests } from './eip1193.js'

type WindowProvider = Requests & Events
import type { EIP1193Provider } from './eip1193.js'

declare global {
interface Window {
ethereum?: WindowProvider
ethereum?: EIP1193Provider
}
}

2 comments on commit bb9c2a4

@vercel
Copy link

@vercel vercel bot commented on bb9c2a4 Apr 10, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vercel
Copy link

@vercel vercel bot commented on bb9c2a4 Apr 10, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

viem-playground – ./playgrounds/browser

viem-playground.vercel.app
viem-playground-wagmi-dev.vercel.app
viem-playground-git-main-wagmi-dev.vercel.app

Please sign in to comment.