Uniswap / widgets

widgets-uniswap.vercel.app
GNU General Public License v3.0
125 stars 180 forks source link

Restricted Access to ethers EIP-1193 Bridge Provider in <SwapWidget/> Component #583

Open samokander opened 1 year ago

samokander commented 1 year ago

Issue Description

<SwapWidget/> component accepts wallet-connected JSON-RPC Providers as its provider prop. However, accessing these providers can be challenging, as they are typically tied to the window.ethereum object, which is not always accessible in certain environments. This can make it difficult to use alternative providers, such as the EIP-1193 Bridge provider provided by the @ethersproject/experimental library, which includes both provider and signer and may be a great tool to interact with swap widget, passing e.g. the JSON-RPC Provider and Wallet signer combined.

image

Unfortunately, the @uniswap/widgets library has specifically restricted access to the EIP-1193 Bridge provider in the component by using code checks.

Proposed Solution

To resolve this issue, it would be beneficial for the @uniswap/widgets library to remove the code checks that restrict access to the EIP-1193 Bridge provider in the component.

Alternatively, the library could add an additional prop to the <SwapWidget/>component that accepts the Signer object directly.

Motivation

Providing support for the EIP-1193 Bridge provider would be a valuable addition to the @uniswap/widgets library. This would make it easier for developers to use this component and would help to reduce the dependency on the window.ethereum object.

Moreover, this could help to resolve both issues #216 and #559 as well.