import * as Dialog from '@radix-ui/react-dialog'; import { useState } from 'react'; import { Resolver, useForm } from 'react-hook-form'; import { useStorage } from '@libs/storage/provider'; import { ArrowRightCircleIcon, CancelIcon, LoaderIcon, WorldIcon } from '@shared/icons'; import { useStronghold } from '@stores/stronghold'; type FormValues = { uri: string; }; const resolver: Resolver = async (values) => { return { values: values.uri ? values : {}, errors: !values.uri ? { uri: { type: 'required', message: 'This is required.', }, } : {}, }; }; export function NWCOther() { const { db } = useStorage(); const { register, setError, handleSubmit, formState: { errors, isDirty, isValid }, } = useForm({ resolver }); const [isOpen, setIsOpen] = useState(false); const [isLoading, setIsloading] = useState(false); const setWalletConnectURL = useStronghold((state) => state.setWalletConnectURL); const onSubmit = async (data: { [x: string]: string }) => { try { if (!data.uri.startsWith('nostr+walletconnect:')) { setError('uri', { type: 'custom', message: 'Connect URI is required and must start with format nostr+walletconnect:, please check again', }); return; } setIsloading(true); const uriObj = new URL(data.uri); const params = new URLSearchParams(uriObj.search); if (params.has('relay') && params.has('secret')) { await db.secureSave('walletConnectURL', data.uri, 'nwc'); setWalletConnectURL(data.uri); setIsloading(false); setIsOpen(false); } } catch (e) { setIsloading(false); setError('uri', { type: 'custom', message: 'Connect URI is required and must start with format nostr+walletconnect:, please check again', }); } }; return (
URI String

Using format nostr+walletconnect:

Nostr Wallet Connect
{errors.uri &&

{errors.uri.message}

}
All information will be encrypted and stored on the local machine.
); }