utils icon indicating copy to clipboard operation
utils copied to clipboard

types: export EIP1193Provider and LegacyEthereumProvider interfaces

Open legobeat opened this issue 2 years ago • 8 comments

Description

This exports two new TypeScript declarations:

  • EIP1993Provider: Encodes a provider for EIP1993
  • LegacyEthereumProvider: Encodes a legacy Ethereum JSON RPC provider. Based on original work in https://github.com/MetaMask/eth-json-rpc-provider/pull/14

Motivation

As far as I know, there is no common explicit interface for the de-facto interface implemented by various Ethereum Json RPC providers. Across the MetaMask npm packages, there are currently use of differing implementations with mostly overlapping interfaces.

This PR introduces a common interface that can be applied regardless of implementations and used in MetaMask packages.

Example of situation where this will be useful

  • https://github.com/MetaMask/nonce-tracker/pull/39/files#diff-32c87e191294c6b28ce5bdbc2b2052f6810d981faf6c323ebb1982a2f370a84aL108
  • https://github.com/MetaMask/core/pull/1653/commits/4d4a8d4b2024f6f38766b0118a4f458854aef1ae

legobeat avatar Sep 13 '23 06:09 legobeat

No top level dependency changes detected. Learn more about Socket for GitHub ↗︎

socket-security[bot] avatar Sep 13 '23 06:09 socket-security[bot]

👍 Dependency issues cleared. Learn more about Socket for GitHub ↗︎

This PR previously contained dependency changes with security issues that have been resolved, removed, or ignored.

socket-security[bot] avatar Sep 13 '23 06:09 socket-security[bot]

@SocketSecurity ignore @metamask/[email protected]

legobeat avatar Sep 13 '23 06:09 legobeat

In Snaps we typically just import MetaMaskInpageProvider from @metamask/providers to get types for this. Do you think it's useful to export this from @metamask/utils?

~MetaMaskInpageprovider is a class which would satisfy the interface here.~ The intention here is to supply that common interface that can be used regardless of implementation when interfacing with internal providers like EthQuery et al.

legobeat avatar Sep 13 '23 21:09 legobeat

Related: https://github.com/MetaMask/eth-json-rpc-provider/pull/14

legobeat avatar Sep 13 '23 22:09 legobeat

looks good. I think we can do without EthJsonRpcProvider as I don't see when we would use the extra properties being defined

jiexi avatar Oct 03 '23 18:10 jiexi

Updated:

  • Removed EthJsonRpcProvider
  • Added LegacyEthereumProvider
    • Unification of https://github.com/MetaMask/eth-json-rpc-provider/pull/14/files#diff-eb5ad9e4a58317c1917e5ce8ce71ffca663c150c81ad4ed36706d7295821249dR10 and https://github.com/MetaMask/eth-query/blob/main/index.d.ts

legobeat avatar Oct 04 '23 04:10 legobeat

@SocketSecurity ignore [email protected]
@SocketSecurity ignore @ethersproject/[email protected]
@SocketSecurity ignore [email protected]

legobeat avatar Oct 04 '23 06:10 legobeat

Nobody appears to be championing this anymore.

rekmarks avatar Mar 13 '25 21:03 rekmarks