-
Notifications
You must be signed in to change notification settings - Fork 149
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: bitcoin regtest network option #4270
Conversation
500282b
to
842f90d
Compare
<Stack justifyContent={'center'}> | ||
<LeatherButton | ||
onClick={() => setBlockchain('stacks')} | ||
backgroundColor={ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you post a screenshot of these UI changes? There are variants
of the LeatherButton to use here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These would better be tabs than buttons. You can reuse the tabs from the homepage
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Although, wouldn't it be better to have this all on the same page, seeing as you need them all?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So these buttons won't take you to another page, it just changes the blockchain variable. So if you click Bitcoin, you'll add a Bitcoin network with this form.
@@ -165,6 +233,7 @@ export function AddNetwork() { | |||
placeholder="Key" | |||
value={values.key} | |||
width="100%" | |||
isDisabled={blockchain === 'bitcoin' ? true : false} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think you need the ternary here? The boolean itself will be true/false?
@fabric-8 @mica000 are you able to provide to general design guidance for this feature we'd like to get into production? The gist here is that @Polybius93, and many other developers, need to be able to target different network types, such as regtest. Our current UI doesn't support this, and a solution would valuable for many devs. As this is a developer-only feature, we don't need to finesse this particular part of the app, but think some feedback would still go a long way. @Polybius93 for the designer to best help, can you please describe the problem this solves, and what the minimum requirements to fix the problem. I find the buttons added here a little confusing, plus I also don't understand why you don't need to fill in all the fields. Wouldn't a network type select here work too? |
A segmented control would be pretty good here! (figma mockup) While doing a quick mockup I also noticed that we aren't "containerizing" the contents in fullpage view. Do I remember correctly that this is something @pete-watters is looking into as part of the broader brand refinement work? 😅 |
@kyranjamie @fabric-8 @mica000 Hello! In the current dev branch, the "add network" feature only allows users to add a new Stacks network. Afterwards, it associates a Bitcoin network constant with it (either Mainnet or Testnet). However, the network slice and its PersistedNetworkConfiguration are not prepared to handle a custom Bitcoin network. This PR addresses the issue by enabling users to choose whether they want to add a new Stacks or Bitcoin network. If the user selects a Bitcoin network, the key field is disabled and automatically set to "bitcoin-regtest" for differentiation in the network converting logic. The logic for adding Stacks networks remains unchanged, as it will still select a corresponding Bitcoin network. Additionally, when adding a Bitcoin network, the Stacks Testnet network is automatically made available alongside it. Ideally, users should be able to set both Stacks and Bitcoin networks at the same time. However, I have not yet found an easy solution for this. There may be possible ways to modify the objects and functions involved to handle both scenarios effectively. |
Thanks for the summary @Polybius93! Here's a design proposal (Figma), WDYT? |
Hello! It looks really great, but before I proceed with making the changes to align with your design, I would prefer to wait for input from other developers, as the UI might undergo changes afterward (if any changes to the logic are required). Thank you! |
@Polybius93 Discussed this with @kyranjamie yesterday based upon which the design proposal has been updated. We simplified things as much as possible, effectively merging both "tabs" into one unified view as that represents things more accurately. At it's core, we porpose a dropdown ("Bitcoin API") where any selection will populate the text inputs below with defaults we assume would be useful. But since those are just text inputs, the end user can obv. change this to whatever they need. Propose selection / applied defaults:
Happy to hear any thoughts or questions you might have on this and thanks for your support! |
src/shared/utils.ts
Outdated
type NetworkMap<T> = Record<BitcoinNetworkModes, T>; | ||
export function whenNetwork(mode: BitcoinNetworkModes) { | ||
return <T extends NetworkMap<unknown>>(networkMap: T) => | ||
networkMap[mode] as T[BitcoinNetworkModes]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you revert this change, sometimes we need the 2 network map. The function you're looking for exists https://github.com/leather-wallet/extension/blob/b926b27c50269d9f678e82a3aea0e1cdcc695375/src/app/common/utils.ts#L267-L269
src/shared/constants.ts
Outdated
stacksChainId: ChainID.Mainnet, | ||
stacksUrl: HIRO_API_BASE_URL_MAINNET, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it necessary to change these names?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It was cleaner for me to distinguish it from the bitcoin properties, but I can revert this if you think it is unnecessary.
@@ -105,6 +105,7 @@ interface CreateSignersForAllNetworkTypesArgs { | |||
paymentFn: (keychain: HDKey, network: BitcoinNetworkModes) => unknown; | |||
mainnetKeychainFn: (accountIndex: number) => BitcoinAccount | undefined; | |||
testnetKeychainFn: (accountIndex: number) => BitcoinAccount | undefined; | |||
regtestKeychainFn: (accountIndex: number) => BitcoinAccount | undefined; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't understand these changes and don't think they're needed? Afaik, regtest uses the same derivation path, and thus keychain as testnet?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, tried without this, it works just fine, so I'll revert this. At first, even though I used regtest, testnet addresses were shown, thought maybe this is one of the reasons, but turns out, it's not. Thank you!
259b493
to
d726882
Compare
👋 Feel free to ping me once you feel the implementation is ready for a design review — or if there are any design-questions. |
dedeb5e
to
cc27cba
Compare
@fabric-8 Hey! Finished the code and all the checks are passing now, so the PR is ready to be reviewed! Thank you! |
cc27cba
to
86f6c54
Compare
Thank you @fabric-8 ! Yeah, now that you have wrote this, I noticed that there is an extra container in the layout, that's why it was narrow, I've fixed and pushed it up. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
@kyranjamie to do final code review |
86f6c54
to
9c67d10
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry @Polybius93, reviewing this I discovered that there's a breaking change for users with existing networks saved.
Because we changed the name of the networks from stacks.url
--> stacks.stacksUrl
and bitcoin.url
to bitcoin.bitcoinUrl
, users with existing networks persisted will try and read bitcoinUrl
which will be undefined
.
Is it possible to leave the network schema as it was before?
Sure, I'll make it work in the afternoon! Thank you! |
@Polybius93 any updates here? It'd be great to get this merged in soon |
We were having some issues migrating the existing networks into this new structure, @kyranjamie is helping me out in in this issue currently. |
9c67d10
to
8c18929
Compare
8c5e0f1
to
637667b
Compare
…k too feat: modified add network tests fix: fixed types and removed unused exports
704584c
to
a81dace
Compare
We have added a Bitcoin regtest option to the 'Add Network' function. This new feature allows you to add Bitcoin network alongside the Stacks networks.
This feature allows the user to add and use Bitcoin regtest networks, which can be much faster Testnet.
Currently when you add a Bitcoin network, the associated Stacks network will be Stacks Testnet.