adding a switch between testnet and mainnet in the navbar
It is off by default, but can be specified in the config.toml for people who want to run it
Details
- Reviewers
Fabien - Group Reviewers
Restricted Project - Commits
- rABCd89ea22e29c3: [explorer] add testnet toggle in menu bar
add network_selector = true to the config.toml
cargo run in /explorer-exe
check out the switcher
Diff Detail
- Repository
- rABC Bitcoin ABC
- Lint
Lint Not Applicable - Unit
Tests Not Applicable
Event Timeline
Ideally would add to the testnet page as well...Im not sure where that one is maintained
Guess what: this is the same explorer code :) So the selection should reflect whether it's mainnet or testnet. You can look at the url or use the config file which has an chain parameter (see server.rs).
I suggest also that this feature is behind a config flag or an environment variable, because it makes it more convenient to reuse if it's off by default. This is quite specialized for our needs.
Okay made some adjustments.
Im not to sure how to execute your second point though, to have it be in the config...The idea there is to only have it show if someone explicitly says so in the config and runs it themselves? but for the normal user this will not be shown?
Yes the idea is to have the selector only displayed if it's explicitly requested, either via an entry in the config file or via an environment variable for example.
Any specific tips how to make that? I'm still not up to speed on any rust programming
You could pass the config down via the templating. But if you want to avoid this it's also possible, I don't see any rust in your code changes.
Well yeah I havent added any rust code yet cause I dont know it!
I did try messing with the config.toml and the templating, but was guessing my way through. Base.html doesnt use a template currently afaict
How can you do it without using the templating? Is there a simple way to access a config variable in base.html that I'm missing?
base.html is a template as well so you can inject whatever you want just like the various pages content is injected.
You can look at what I've done in D14451. The idea is to add a member to the templating object, fill it in the server and use that in the template. You'll need to repeat for each page.
To begin I suggest you use a simple flag to turn the feature on or off, defaulting to off if not set.
Would it be possible to actually switch between testnet and mainnet instead of just urls?
Like what makes it run testnet? you need to change the chain parameter and the chronik instance in the config? But I guess it would require a recompile so maybe not doable?
Also how useful will this actually be, if we are not going to have it on explorer.e.cash? The scenario would be you are on texplorer.fabien.cash and then hit the switch and go to explorer.e.cash with no switcher....what is it solving?
I'm not sure I understand your question, so forgive me if I don't give you a good answer.
We can't switch between testnet and mainnet in the same explorer the way it is designed. This would need an edit of the config and a restart of the app.
The plan is to have the switch on both explorer.e.cash, pointing to texplorer.e.cash and on texplorer.e.cash, pointing to explorer.e.cash so we can navigate back and forth just like it's done on explorer.bitcoinabc.org.
The switch should be disabled by default and only enabled via some config because we might not be the only users of this code and this is very specific to our infra.
Ah okay cool, yeah sorry think I misunderstood you the first time.
I thought we were not going to have it on explorer.e.cash. But I'm with you now
web/explorer/explorer-server/templates/base.html | ||
---|---|---|
129–133 ↗ | (On Diff #49721) | This avoids showing the wrong selector when debugging with it is enabled, or using preview. |
web/explorer/explorer-server/templates/base.html | ||
---|---|---|
129 ↗ | (On Diff #49746) | copy pasta |