Skip to content

feat: forward custom RPC URLs to embedded wallet #4570

Merged
tomiir merged 20 commits intomainfrom
feat/custom-rpc-url-ew
Jun 30, 2025
Merged

feat: forward custom RPC URLs to embedded wallet #4570
tomiir merged 20 commits intomainfrom
feat/custom-rpc-url-ew

Conversation

@tomiir
Copy link
Copy Markdown
Collaborator

@tomiir tomiir commented Jun 25, 2025

Description

  • Forwards urls set in customRPCUrlparameter to embedded wallet to ensure this RPC is used for requests
  • Adds rpcUrl to getUser, connect, connectSocial, switchNetwork and rpcRequest schemas
  • Adds getRpcUrl to W3mFrameProvider to fetch rpc url for active network for every request that requires it

Type of change

  • Chore (non-breaking change that addresses non-functional tasks, maintenance, or code quality improvements)
  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)

Associated Issues

APKT-3087

Checklist

  • Code in this PR is covered by automated tests (Unit tests, E2E tests)
  • My changes generate no new warnings
  • I have reviewed my own code
  • I have filled out all required sections
  • I have tested my changes on the preview link
  • Approver of this PR confirms that the changes are tested on the preview link

@changeset-bot
Copy link
Copy Markdown

changeset-bot bot commented Jun 25, 2025

🦋 Changeset detected

Latest commit: b8cb393

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 23 packages
Name Type
@reown/appkit-adapter-ethers5 Patch
@reown/appkit-adapter-ethers Patch
@reown/appkit-adapter-solana Patch
@reown/appkit-adapter-wagmi Patch
@reown/appkit-utils Patch
@reown/appkit-controllers Patch
@reown/appkit Patch
@reown/appkit-wallet Patch
@reown/appkit-adapter-bitcoin Patch
@reown/appkit-cdn Patch
@reown/appkit-cli Patch
@reown/appkit-codemod Patch
@reown/appkit-common Patch
@reown/appkit-core Patch
@reown/appkit-experimental Patch
@reown/appkit-pay Patch
@reown/appkit-polyfills Patch
@reown/appkit-scaffold-ui Patch
@reown/appkit-siwe Patch
@reown/appkit-siwx Patch
@reown/appkit-testing Patch
@reown/appkit-ui Patch
@reown/appkit-wallet-button Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@vercel
Copy link
Copy Markdown

vercel bot commented Jun 25, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
appkit-basic-html ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jun 30, 2025 6:09pm
appkit-demo ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jun 30, 2025 6:09pm
appkit-laboratory ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jun 30, 2025 6:09pm
10 Skipped Deployments
Name Status Preview Comments Updated (UTC)
appkit-basic-example ⬜️ Ignored (Inspect) Jun 30, 2025 6:09pm
appkit-basic-sign-client-example ⬜️ Ignored (Inspect) Jun 30, 2025 6:09pm
appkit-basic-up-example ⬜️ Ignored (Inspect) Visit Preview Jun 30, 2025 6:09pm
appkit-ethers5-bera ⬜️ Ignored (Inspect) Jun 30, 2025 6:09pm
appkit-nansen-demo ⬜️ Ignored (Inspect) Jun 30, 2025 6:09pm
appkit-vue-solana ⬜️ Ignored (Inspect) Jun 30, 2025 6:09pm
appkit-wagmi-cdn-example ⬜️ Ignored (Inspect) Jun 30, 2025 6:09pm
ethereum-provider-wagmi-example ⬜️ Ignored (Inspect) Jun 30, 2025 6:09pm
next-wagmi-solana-bitcoin-example ⬜️ Ignored (Inspect) Jun 30, 2025 6:09pm
vue-wagmi-example ⬜️ Ignored (Inspect) Jun 30, 2025 6:09pm

cursor[bot]

This comment was marked as outdated.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Jun 25, 2025

Warnings
⚠️

🔑 Potential High‑entropy string detected in packages/adapters/solana/src/tests/mocks/W3mFrameProvider.ts (line 25): 5bW5EoLn696QKxgJbsDb...

⚠️

🔑 Potential High‑entropy string detected in packages/adapters/solana/src/tests/mocks/W3mFrameProvider.ts (line 30): 4zZMC2ddAFY1YHcA2uFC...

⚠️

🔑 Potential High‑entropy string detected in packages/adapters/solana/src/tests/mocks/W3mFrameProvider.ts (line 35): 2Lb1KQHWfbV3pWMqXZve...

⚠️

🔑 Potential High‑entropy string detected in packages/adapters/solana/src/tests/mocks/W3mFrameProvider.ts (line 30): 4zZMC2ddAFY1YHcA2uFC...

⚠️

🔑 Potential UUID detected in packages/adapters/wagmi/src/tests/client.test.ts (line 405): 07ba87ed-43aa-4adf-4...

⚠️

🔑 Potential UUID detected in packages/adapters/ethers/src/tests/client.test.ts (line 947): ba0ba0cd-17c6-4806-a...

⚠️

🔑 Potential High‑entropy string detected in packages/wallet/src/W3mFrame.ts (line 149): 5eykt4UsFv8P8NJdTREp...

⚠️

🔑 Potential High‑entropy string detected in packages/wallet/src/W3mFrame.ts (line 150): 4uhcVJyU9pJkvQyS88uR...

⚠️

🔑 Potential High‑entropy string detected in packages/wallet/src/W3mFrame.ts (line 151): EtWTRABZaYq6iMfeYKou...

Generated by 🚫 dangerJS against b8cb393

cursor[bot]

This comment was marked as outdated.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Jun 25, 2025

Coverage Report

Status Category Percentage Covered / Total
🔵 Lines 77.83% 30827 / 39604
🔵 Statements 77.83% 30827 / 39604
🔵 Functions 68.74% 2538 / 3692
🔵 Branches 84.41% 6395 / 7576
File Coverage
File Stmts Branches Functions Lines Uncovered Lines
Changed Files
packages/adapters/solana/src/tests/mocks/W3mFrameProvider.ts 96.07% 84.61% 100% 96.07% 46, 50
packages/adapters/wagmi/src/connectors/AuthConnector.ts 6.52% 100% 25% 6.52% 54-55, 58-79, 82-129, 132-271
packages/appkit/src/adapters/ChainAdapterBlueprint.ts 75% 91.66% 75.75% 75% 150-161, 243-244, 248-249, 272-276, 282-285, 511-538, 566-571, 598-599, 612-640, 649-650, 549
packages/controllers/src/utils/ConnectorControllerUtil.ts 18.55% 88.88% 33.33% 18.55% 73-74, 94-107, 110-282, 285-315, 318-358, 361-367
packages/siwx/src/configs/DefaultSIWX.ts 34.61% 100% 0% 34.61% 9-18, 34-40
packages/wallet/src/W3mFrame.ts 98.87% 92.3% 76.47% 98.87% 102-103
packages/wallet/src/W3mFrameProvider.ts 49.6% 76.31% 48.71% 49.6% 74-77, 81-82, 90-96, 113-121, 141-149, 158-160, 169-171, 174-182, 186-198, 201-214, 217-229, 232-243, 246-261, 270-272, 284-286, 290-303, 306-315, 335-336, 345-347, 365-367, 383-385, 389-414, 417-428, 431-445, 459-461, 465-483, 486-515, 532-540, 544-552, 559-561, 569-571, 576-585, 591-595, 600-601, 608-614, 619-620, 681-683, 685-689, 694-695, 710-720, 735-736, 748-752, 761-765, 768-769, 202-277, 392-589
packages/wallet/src/W3mFrameSchema.ts 100% 100% 100% 100%
Generated in workflow #13057 for commit b8cb393 by the Vitest Coverage Report Action

cursor[bot]

This comment was marked as outdated.

Comment thread packages/wallet/src/W3mFrame.ts
Comment thread packages/wallet/src/W3mFrameSchema.ts
cursor[bot]

This comment was marked as outdated.

cursor[bot]

This comment was marked as outdated.

Comment thread packages/wallet/src/W3mFrameProvider.ts Outdated
Copy link
Copy Markdown
Contributor

@enesozturk enesozturk left a comment

Choose a reason for hiding this comment

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

Left a single comment 🙏🏽

cursor[bot]

This comment was marked as outdated.

cursor[bot]

This comment was marked as outdated.

Copy link
Copy Markdown

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

Bug: `getRpcUrl` Misclassifies Chain IDs

The getRpcUrl method has flawed logic for determining the ChainNamespace from chainId. It incorrectly assumes all numeric chainIds (number or integer-like strings) are eip155. Additionally, it aggressively defaults any non-CAIP-2, non-integer string chainId to solana. This misclassifies inputs like decimal number strings, empty strings, scientific notation, or arbitrary non-numeric strings, leading to incorrect RPC URL selection for non-EIP155/non-Solana chains or invalid inputs.

packages/wallet/src/W3mFrameProvider.ts#L770-L787

private getRpcUrl(chainId?: number | string) {
let namespace: ChainNamespace | undefined = chainId === undefined ? undefined : 'eip155'
if (typeof chainId === 'string') {
if (chainId.includes(':')) {
namespace = ParseUtil.parseCaipNetworkId(chainId as CaipNetworkId)?.chainNamespace
} else if (Number.isInteger(Number(chainId))) {
namespace = 'eip155'
} else {
namespace = 'solana'
}
}
const activeNetwork = this.getActiveCaipNetwork(namespace)
return activeNetwork?.rpcUrls.default.http?.[0]
}

Fix in Cursor


Bug: getUser Method Missing RPC URL Handling

The getUser method does not automatically add the rpcUrl to its payload when called directly. While the connect method passes the rpcUrl to getUser, other direct callers of getUser will not forward custom RPC URLs to the embedded wallet. This is inconsistent with other methods (e.g., connectSocial, switchNetwork, request) which automatically derive and include the rpcUrl via this.getRpcUrl(chainId), contradicting the PR's goal of forwarding custom RPC URLs.

packages/wallet/src/W3mFrameProvider.ts#L370-L385

public async getUser(payload: W3mFrameTypes.Requests['AppGetUserRequest']) {
try {
await this.init()
const chainId = payload?.chainId || this.getLastUsedChainId() || 1
const response = await this.appEvent<'GetUser'>({
type: W3mFrameConstants.APP_GET_USER,
payload: { ...payload, chainId }
} as W3mFrameTypes.AppEvent)
this.user = response
return response
} catch (error) {
this.w3mLogger?.logger.error({ error }, 'Error connecting')
throw error
}

Fix in Cursor


Was this report helpful? Give feedback by reacting with 👍 or 👎

@tomiir tomiir merged commit df78462 into main Jun 30, 2025
57 of 60 checks passed
@tomiir tomiir deleted the feat/custom-rpc-url-ew branch June 30, 2025 19:35
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