@@ -2,7 +2,6 @@ import { isTemplate, isWallet, protocolClientSchema, protocolFields, protocolFor
22import { createContext , useContext , useEffect , useMemo , useCallback , useState } from 'react'
33import { useWalletProtocolUpsert } from '@/wallets/client/hooks'
44import { MultiStepForm , useFormState , useStep } from '@/components/multi-step-form'
5- import { parseNwcUrl } from '@/wallets/lib/validate'
65
76export const Step = {
87 SEND : 'send' ,
@@ -83,9 +82,9 @@ function useProtocolFormState (protocol) {
8382}
8483
8584export function useProtocolForm ( protocol ) {
85+ const [ globalFormState ] = useFormState ( )
8686 const [ formState , setFormState ] = useProtocolFormState ( protocol )
8787 const [ complementaryFormState ] = useProtocolFormState ( { name : protocol . name , send : ! protocol . send } )
88- const [ nwcSendFormState ] = useProtocolFormState ( { name : 'NWC' , send : true } )
8988 const wallet = useWallet ( )
9089 const lud16Domain = walletLud16Domain ( wallet . name )
9190 const fields = protocolFields ( protocol )
@@ -98,16 +97,13 @@ export function useProtocolForm (protocol) {
9897 value = complementaryFormState ?. config ?. [ field . name ]
9998 }
10099
101- if ( protocol . name === 'LN_ADDR' && field . name === 'address' && lud16Domain ) {
102- // automatically set lightning addresses from NWC urls if lud16 parameter is present
103- if ( nwcSendFormState ?. config ?. url ) {
104- const { lud16 } = parseNwcUrl ( nwcSendFormState . config . url )
105- if ( lud16 ?. split ( '@' ) [ 1 ] === lud16Domain ) value = lud16
106- }
100+ if ( ! value && field . populate && globalFormState ) {
101+ value = field . populate ( wallet , globalFormState )
102+ }
103+
104+ if ( lud16Domain && value ) {
107105 // remove domain part since we will append it automatically on submit if lud16Domain is set
108- if ( lud16Domain && value ) {
109- value = value . split ( '@' ) [ 0 ]
110- }
106+ value = value . split ( '@' ) [ 0 ]
111107 }
112108
113109 return {
0 commit comments