oasisprotocol / sapphire-paratime

Oasis Sapphire - the confidential EVM-compatible ParaTime for the Oasis Network
https://oasisprotocol.org/sapphire
Apache License 2.0
35 stars 26 forks source link

Can we have a more robust isEthers6Signer than `instanceof ethers6.AbstractSigner`? #159

Closed lukaw3d closed 7 months ago

lukaw3d commented 1 year ago

https://github.com/oasisprotocol/sapphire-paratime/blob/cc2d765dfe08fcca4c51ddff5b4f655b3cf56dd2/clients/js/src/compat.ts#L342-L348

Currently isEthers6Signer and isEthers6Provider are very error prone. For it to work, the end project needs to install the exact same version of ethers6 and their package manager must deduplicate it and their bundler must import the same import the same output format ethers6/dist/ vs ethers6/lib.esm/ vs ethers6/lib.commonjs/ (and our library must not bundle dependencies or be served from CDN). If it isn't the same runtime instance then projectEthers6.6.2AbstractSigner instanceof compatEthers6.6.1AbstractSigner returns false

CedarMist commented 1 year ago

I agree this is a very brittle implementation, and a better method is necessary which doesn't use instanceof.

CedarMist commented 7 months ago

This has been implemented now

lukaw3d commented 7 months ago

https://github.com/oasisprotocol/sapphire-paratime/pull/261