Skip to content

Commit 73c612a

Browse files
committed
Better comments regarding lud16 domain handling in wallet forms
1 parent 6762fc0 commit 73c612a

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

wallets/client/components/form/hooks.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ export function useProtocolForm (protocol) {
104104
const { lud16 } = parseNwcUrl(nwcSendFormState.config.url)
105105
if (lud16?.split('@')[1] === lud16Domain) value = lud16
106106
}
107-
// remove domain part since we will append it automatically if lud16Domain is set
107+
// remove domain part since we will append it automatically on submit if lud16Domain is set
108108
if (lud16Domain && value) {
109109
value = value.split('@')[0]
110110
}
@@ -120,6 +120,7 @@ export function useProtocolForm (protocol) {
120120
if (lud16Domain) {
121121
schema = schema.transform(({ address, ...rest }) => {
122122
return {
123+
// append domain part to pass validation on submit
123124
address: address ? `${address}@${lud16Domain}` : '',
124125
...rest
125126
}

wallets/client/components/form/index.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,8 @@ function WalletProtocolForm () {
100100

101101
// create a copy of values to avoid mutating the original
102102
const onSubmit = useCallback(async ({ ...values }) => {
103+
// the schema transformation already does this to pass validation on submit
104+
// so it would be better to use the transformed values instead of manually appending the domain part again here
103105
const lud16Domain = walletLud16Domain(wallet.name)
104106
if (values.address && lud16Domain) {
105107
values.address = `${values.address}@${lud16Domain}`

0 commit comments

Comments
 (0)