Skip to content

fix(studio, webapp, shinzohub): chain switching - #290

Merged
VanishMax merged 12 commits into
mainfrom
fix/chain-switching
Jul 15, 2026
Merged

fix(studio, webapp, shinzohub): chain switching#290
VanishMax merged 12 commits into
mainfrom
fix/chain-switching

Conversation

@VanishMax

@VanishMax VanishMax commented Jul 13, 2026

Copy link
Copy Markdown
Collaborator

Deploying ShinzoHub to testnet produced new chain id. This update broke Studio view deployment feature - wallets like Metamask or Rabby weren't able to use the correct chain, thus failing in any transaction sending actions.

This PR creates the testnet global var in Shinzohub package and reuses it in Studio, Webapp, Explorer, and Faucet.

Adds new SHINZOHUB_CHAIN=testnet | internal | devnet | local env variable to every mentioned app.

Steps to test:

  1. Open up https://fix-chain-switching-shinzo-studio.shinzo-492.workers.dev/
  2. Connect your wallet, deploy a view. Requesting data for a view might not be available, this is expected
  3. Open internal faucet https://fix-chain-switching-faucet-internal.shinzo-492.workers.dev
  4. Try requesting funds for your wallet that has "testnet-internal" shinzohub chain added
  5. Check that funds arrived to your testnet-internal address, but the Explorer opens up 404 transaction - this is expected until we haven't deployed internal explorer.
  6. Open up internal registration https://fix-chain-switching-shinzo-webapp-staging.shinzo-492.workers.dev and current registration staging https://registration-staging.shinzo.network/. Check that the numbers and data are exactly the same - it would mean the deploy is correct

@VanishMax
VanishMax requested a review from NiranjanaBinoy July 13, 2026 10:17
@VanishMax VanishMax self-assigned this Jul 13, 2026
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Jul 13, 2026

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
shinzo-studio 609b3a0 Commit Preview URL

Branch Preview URL
Jul 14 2026, 10:27 AM

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Jul 13, 2026

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
shinzo-webapp-staging 609b3a0 Commit Preview URL

Branch Preview URL
Jul 14 2026, 10:28 AM

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Jul 13, 2026

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
shinzo-explorer 609b3a0 Commit Preview URL

Branch Preview URL
Jul 14 2026, 10:28 AM

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Jul 13, 2026

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
faucet-internal e50f0a0 Commit Preview URL

Branch Preview URL
Jul 14 2026, 10:59 AM

@VanishMax
VanishMax requested a review from johnnymatthews July 13, 2026 10:24
@johnnymatthews

johnnymatthews commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

Ran into an issue. Here's what I did:

  1. Went to https://fix-chain-switching-shinzo-studio.shinzo-492.workers.dev/
  2. Clicked Connect wallet. Followed MetaMask prompts.
  3. Wallet address wasn't show at the top right, had to refresh the page. This worked fine.
  4. Clicked ERC 20 Transfers. Selected WBTC.
  5. Clicked Switch to Shinzo. Got the following error:
User rejected the request. Details: Expected an array with at least one valid string HTTPS url 'rpcUrls', Received: http://testnet.shinzo.network:8545 Version: viem@2.48.7

It's probably worth noting that I'm on Firefox.

@VanishMax

VanishMax commented Jul 13, 2026

Copy link
Copy Markdown
Collaborator Author

@johnnymatthews thanks for this report! I've made a fix to point 3 in your list.

As for the HTTP not allowed in Metamask, I've made a workaround. Studio will now show an error in case their wallet doesn't allow switching to a chain with HTTP-based RPC, and prompt users to add the chain manually. For wallets like Rabby, chain switching should be automatic as intended.

Can you try adding the chain manually and proceeding with view deployment?

image

import {
getView,
listViews,
shinzoHubTestnet as shinzoChain,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Question: If we use the hardcoded chain details specific to testnet here, wont that add unnecessary rework when we release mainnet ? or when we need to switch between chain during dev?

Copy link
Copy Markdown
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 is a necessary step at the moment. The env that used to be here was not configured dynamically enough to allow simple switching. I'd plan this as a separate feature for all apps: studio, webapp, faucet, etc.


void (async () => {
try {
const chain = await fetchShinzoHubChain(controller.signal);

@NiranjanaBinoy NiranjanaBinoy Jul 13, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Curious: Do we have to replace the dynamic fetching for chainId in webapp?, This might cause connecting to testnet from https://registraion-staging.shinzo.network. It is configured to use http://testnet-internal.shinzo.network

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

I've changed this to SHINZOHUB_CHAIN env in all application. Static data now

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Jul 14, 2026

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
faucet e50f0a0 Commit Preview URL

Branch Preview URL
Jul 14 2026, 11:00 AM

@VanishMax
VanishMax requested a review from NiranjanaBinoy July 14, 2026 11:58
} as const;

/** Builds a live ShinzoHub viem chain definition from RPC endpoints. */
export async function shinzoHubChain({

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

[nit]: It looks like we are not using this anywhere, may be we can remove it.

}

/** Fetches the live ShinzoHub chain definition through the webapp API proxy. */
export async function fetchShinzoHubChain(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

With new chain switching changes, I think we no longer need these. We could remove this whole page and use the shinzoChain directly where we are calling the resolveShinzoHubChain()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I have added some comments in webapp to remove some deadcodes after the new changes. I am currently doing a cleanup PR for registration v2 feature flag. If you want to go ahead merge this PR, I can include the dead code removal in my PR. Let me know what works better for you.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

This sounds good. I'd appreciate if you could take on removing dead code

export async function fetchShinzoHubChain(
signal?: AbortSignal
): Promise<Chain> {
const response = await fetch("/api/shinzohub/chain", { signal });

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think we could also remove the route at this path, I did a quick search and could not find fetch from this route.

/** Proxies browser EVM requests to the selected chain's HTTP RPC without mixed-content errors. */
export async function POST(request: Request) {
try {
const response = await fetch(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This will help to resolve the CORS error we are facing in the browser for the rpc urls, right? Once this merge can we remove the rpc-proxy and staging-rpc-proxy workers from our projects?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Yes, this is exactly why I made it

@NiranjanaBinoy

Copy link
Copy Markdown
Contributor

Note:-

Not sure if it is currently valid since we do not have a internal app for the explorer ( actually I am not sure if need one since explorer is only fetching the data from the network not altering or updating the network) , but the txnhash and the address data after the faucet transaction is currently connecting to https://explorer.shinzo.network which is showing wrong data in the case of show my balance link and loading or error page in the case of txnhash.

@NiranjanaBinoy NiranjanaBinoy left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I have added some comments but nothing major mostly clean up. but let me know how you want to handle the clean up in webapp. I can add that as part of #185

@NiranjanaBinoy

Copy link
Copy Markdown
Contributor

I did not test the studio, since we do not have the internal app yet and I did not want to add test data to the testnet.

@VanishMax

Copy link
Copy Markdown
Collaborator Author

Not sure if it is currently valid since we do not have a internal app for the explorer ( actually I am not sure if need one since explorer is only fetching the data from the network not altering or updating the network) , but the txnhash and the address data after the faucet transaction is currently connecting to https://explorer.shinzo.network/ which is showing wrong data in the case of show my balance link and loading or error page in the case of txnhash.

@NiranjanaBinoy yes, this is expected for now. We will create internal explorer deployments soon, and the links will start working as expected

@VanishMax
VanishMax merged commit d5f19f6 into main Jul 15, 2026
3 checks passed
@VanishMax
VanishMax deleted the fix/chain-switching branch July 15, 2026 09:13
@VanishMax VanishMax mentioned this pull request Jul 15, 2026
6 tasks
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