add sign_schnorr RPC

This commit is contained in:
tiero
2023-02-04 00:06:14 +01:00
parent 715f923455
commit 6f6575a1d0

View File

@@ -24,6 +24,7 @@ const App = () => {
const [pubkey, setPubkey] = useStatePersist('@pubkey', '');
const [getPublicKeyReply, setGetPublicKeyReply] = useState('');
const [eventWithSig, setEvent] = useState({});
const [schnorrSig, setSchnorrSig] = useState('');
useEffect(() => {
(async () => {
@@ -83,6 +84,29 @@ const App = () => {
}
const getSchnorrSig = async () => {
try {
if (pubkey.length === 0) return;
const connect = new Connect({
secretKey,
target: pubkey,
});
const sig = await connect.rpc.call({
target: pubkey,
request: {
method: 'sign_schnorr',
params: ['Hello World'],
}
});
setSchnorrSig(sig);
} catch (error) {
console.error(error);
}
}
const isConnected = () => {
return pubkey.length > 0;
}
@@ -172,6 +196,21 @@ const App = () => {
/>
}
</div>
<div className='content'>
<h2 className='title is-5 has-text-white'>Get a Schnorr signature for the message <b>Hello World</b></h2>
<button className='button is-info' onClick={getSchnorrSig}>
Sign Schnorr
</button>
{
Object.keys(schnorrSig).length > 0 &&
<input
className='input is-info mt-3'
type='text'
value={schnorrSig}
readOnly
/>
}
</div>
</div>
}
</section>