From 6f6575a1d0897a4fcaa25bc2a59f9abd67513cd1 Mon Sep 17 00:00:00 2001 From: tiero <3596602+tiero@users.noreply.github.com> Date: Sat, 4 Feb 2023 00:06:14 +0100 Subject: [PATCH] add sign_schnorr RPC --- example/index.tsx | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/example/index.tsx b/example/index.tsx index 4abeeb0..bef6b5c 100644 --- a/example/index.tsx +++ b/example/index.tsx @@ -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 = () => { /> } +
+

Get a Schnorr signature for the message Hello World

+ + { + Object.keys(schnorrSig).length > 0 && + + } +
}