wagmi icon indicating copy to clipboard operation
wagmi copied to clipboard

bug: <Connector base class missing decimals on watchAsset() declaration>

Open GeminonProtocol opened this issue 3 years ago • 0 comments

Is there an existing issue for this?

  • [X] I have searched the existing issues

Package Version

0.6.0

Current Behavior

Hi

We are trying to implement EIP-747, the famous "wallet_watchAsset" method. While trying to implement it from scratch, we found that the watchAsset() method was already available under the Connector class of Wagmi. The problem is that when passing in the arguments {address, symbol, decimals, image} to the function, it is giving an error because decimals is not a valid argument. After investigating, we found that, although it is declared in the Injected.watchAsset() declaration, it is missing in the declaration of the base Connector class, and hence the error typescript is giving.

watchAsset?(asset: { address: string image?: string symbol: string }): Promise<boolean>

Unless we are missing out something here, we think this should be fixed by adding "decimals?: number" in the base declaration. We also think it should be a good idea to add an example of the use of EIP-747 to the Wagmi docs, we didn't even know this was implemented in the library.

Expected Behavior

async watchAsset({ address, decimals = 18, image, symbol, }: { address: string decimals?: number image?: string symbol: string }) { const provider = await this.getProvider() if (!provider) throw new ConnectorNotFoundError() return await provider.request({ method: 'wallet_watchAsset', params: { type: 'ERC20', options: { address, decimals, image, symbol, }, }, }) }

Steps To Reproduce

No response

Link to Minimal Reproducible Example (CodeSandbox, StackBlitz, etc.)

No response

Anything else?

No response

GeminonProtocol avatar Sep 19 '22 15:09 GeminonProtocol