Refactor NWC lud16 parsing to set initial value for lightning address#2633
Open
Refactor NWC lud16 parsing to set initial value for lightning address#2633
Conversation
5dccad5 to
02a900d
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This is a partial refactor of #2564.
Only partial, because the automatic switch to the lightning address if it has an initial value is still hard-coded in a
useEffect:stacker.news/wallets/client/components/form/hooks.js
Lines 59 to 64 in 6762fc0
Ideally, we would generally switch to the first protocol form that has an initial value.
Additional Context
#2575 will also use this code to set the identity public key from the mnemonic.
Checklist
Are your changes backward compatible? Please answer below:
yes
On a scale of 1-10 how well and how have you QA'd this change and any features it might affect? Please answer below:
8. Tested by pasting a Coinos NWC string and seeing the initial lightning address value set to thelud16parameter. Also tested skipping NWC and SSR.For frontend changes: Tested on mobile, light and dark mode? Please answer below:
n/a
Did you introduce any new environment variables? If so, call them out explicitly here:
no
Did you use AI for this? If so, how much did it assist you?
no
Note
Adds a generic
populatefor protocol fields and moves Lightning Address initial value derivation from NWC into theLN_ADDRprotocol, with domain handling done via schema transform.field.populatesupport inuseProtocolForm, using global form state to prefill values; remove NWC-specific parsing fromhooks.js.addressin initial values and append via schema transform on submit.ProtocolFieldtype withpopulatecallback.LN_ADDR: addpopulatethat readslud16fromNWCURL (when present and domain-compatible) to prefilladdress.WalletProtocolFormFieldtransforms now accept and ignorepopulateprop to avoid passing it to inputs.Written by Cursor Bugbot for commit 02a900d. This will update automatically on new commits. Configure here.