From bb9c2a4b769655f230b8af22efb871393e78a80d Mon Sep 17 00:00:00 2001 From: jxom Date: Mon, 10 Apr 2023 14:27:07 +1000 Subject: [PATCH] feat: add EIP1193Provider type (#344) * feat: add EIP1193Provider type * chore: format --- .changeset/pink-pugs-allow.md | 5 +++++ src/index.ts | 1 + src/types/eip1193.ts | 5 +++++ src/types/index.ts | 2 ++ src/types/window.ts | 6 ++---- 5 files changed, 15 insertions(+), 4 deletions(-) create mode 100644 .changeset/pink-pugs-allow.md diff --git a/.changeset/pink-pugs-allow.md b/.changeset/pink-pugs-allow.md new file mode 100644 index 0000000000..735c8f5257 --- /dev/null +++ b/.changeset/pink-pugs-allow.md @@ -0,0 +1,5 @@ +--- +"viem": patch +--- + +Added `EIP1193Provider` type. diff --git a/src/index.ts b/src/index.ts index 8f35335c55..6103e730dd 100644 --- a/src/index.ts +++ b/src/index.ts @@ -260,6 +260,7 @@ export type { ContractFunctionConfig, ContractFunctionResult, CustomSource, + EIP1193Provider, FeeHistory, FeeValues, FeeValuesEIP1559, diff --git a/src/types/eip1193.ts b/src/types/eip1193.ts index 091c40b9a7..733074f90f 100644 --- a/src/types/eip1193.ts +++ b/src/types/eip1193.ts @@ -14,6 +14,11 @@ import type { RpcUncle as Uncle, } from './rpc.js' +////////////////////////////////////////////////// +// Provider + +export type EIP1193Provider = Requests & Events + ////////////////////////////////////////////////// // Errors diff --git a/src/types/index.ts b/src/types/index.ts index 09eff10fa3..715e7dea17 100644 --- a/src/types/index.ts +++ b/src/types/index.ts @@ -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 { diff --git a/src/types/window.ts b/src/types/window.ts index 1a211bfcec..332c27b3b4 100644 --- a/src/types/window.ts +++ b/src/types/window.ts @@ -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 } }