Skip to content

Conversation

@andrewkmin
Copy link
Collaborator

@andrewkmin andrewkmin commented Oct 26, 2025

Summary & Motivation

$title

How I Tested These Changes

via CSB

Did you add a changeset?

yes!

If updating one of our packages, you'll likely need to add a changeset to your PR. To do so, run pnpm changeset. pnpm changeset will generate a file where you should write a human friendly message about the changes. Note how this (example) includes the package name (should be auto added by the command) along with the type of semver change (major.minor.patch) (which you should set).

These changes will be used at release time to determine what packages to publish and how to bump their version. For more context see this comment.

@codesandbox-ci
Copy link

codesandbox-ci bot commented Oct 26, 2025

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit c0fa69c:

Sandbox Source
@turnkey/example-react-components Configuration

@andrewkmin andrewkmin changed the title Andrew/eip 1193 fixes rebased 2 fixes: eip-1193-provider should only return ethereum wallet accounts Oct 27, 2025
@andrewkmin andrewkmin force-pushed the andrew/eip-1193-fixes-rebased-2 branch from 4599aac to 6e9ff45 Compare October 27, 2025 20:08
@andrewkmin andrewkmin force-pushed the andrew/eip-1193-fixes-rebased-2 branch from 6e9ff45 to c0fa69c Compare October 28, 2025 16:48
client: turnkeyClient,
});
setConnected(true, { chainId: activeChain.chainId });

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

understandable


addedChains.push({ ...chain, connected: true });
// Only add if it hasn't been added already
if (!addedChains.some((c) => c.chainId === rpcChainId)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not too familiar with the flow here but normally with eip-1193 providers they prompt the user to approve the action of adding a chain since this could potentially be done silently with malicous intent

wondering why we don't do the same here? Or if someone wanted to use this provider and do that, could they easily?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this piece of code executes once a wallet has emitted a wallet_addEthereumChain action, meaning the end-user has been prompted and has approved this

we were just seeing slightly buggy behavior; namely, someone was seeing the same chain multiple times in their chain list, and that's what we're trying to prevent here

btw: addedChains can probably be a hashmap for speed but that's a micro optimization that we don't have to make rn

) => {
const { rpcUrls, blockExplorerUrls, chainId, nativeCurrency } = chain;

if (addedChains.some((c) => c.chainId === chainId)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can't we just remove this?

this is opinionated, but IMO if someone passes a chainId that already exists, but with an invalid RPC, we should throw an error about the RPC being invalid

right now, it'll silently succeeds without any action

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that's a good point; will note down as a followup

Copy link
Contributor

@moeodeh3 moeodeh3 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

small non-blocking nits :)

@andrewkmin andrewkmin merged commit 7a723b9 into main Oct 28, 2025
7 of 8 checks passed
@andrewkmin andrewkmin deleted the andrew/eip-1193-fixes-rebased-2 branch October 28, 2025 18:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants