mirror of
https://github.com/nostr-connect/connect.git
synced 2026-02-07 13:24:21 +01:00
update nostr-tools
This commit is contained in:
@@ -3,20 +3,20 @@ import { useEffect, useState } from 'react';
|
||||
import { useStatePersist } from 'use-state-persist';
|
||||
|
||||
import * as ReactDOM from 'react-dom';
|
||||
import { broadcastToRelay, Connect, connectToRelay, ConnectURI, TimeRanges } from '../src/index';
|
||||
import { broadcastToRelay, Connect, connectToRelay, ConnectURI } from '@nostr-connect/connect';
|
||||
|
||||
import { QRCodeSVG } from 'qrcode.react';
|
||||
import { getEventHash, getPublicKey, Event, nip19 } from 'nostr-tools';
|
||||
import { getEventHash, getPublicKey, Event } from 'nostr-tools';
|
||||
|
||||
const secretKey = "5acff99d1ad3e1706360d213fd69203312d9b5e91a2d5f2e06100cc6f686e5b3";
|
||||
const connectURI = new ConnectURI({
|
||||
target: getPublicKey(secretKey),
|
||||
relay: 'wss://nostr.vulpem.com',
|
||||
metadata: {
|
||||
name: 'Vulpem',
|
||||
description: 'Bitcoin company',
|
||||
url: 'https://vulpem.com',
|
||||
icons: ['https://vulpem.com/favicon.ico'],
|
||||
name: 'Example',
|
||||
description: '🔉🔉🔉',
|
||||
url: 'https://example.com',
|
||||
icons: ['https://example.com/icon.png'],
|
||||
},
|
||||
});
|
||||
|
||||
@@ -54,7 +54,7 @@ const App = () => {
|
||||
target: pubkey,
|
||||
});
|
||||
const pk = await connect.getPublicKey();
|
||||
setGetPublicKeyReply(nip19.npubEncode(pk));
|
||||
setGetPublicKeyReply(pk);
|
||||
}
|
||||
|
||||
const sendMessage = async () => {
|
||||
@@ -116,13 +116,19 @@ const App = () => {
|
||||
target: pubkey,
|
||||
});
|
||||
|
||||
const sig = await connect.delegate(
|
||||
getPublicKey(secretKey),
|
||||
{
|
||||
kind: 1,
|
||||
until: TimeRanges.ONE_DAY,
|
||||
const sig = await connect.rpc.call({
|
||||
target: pubkey,
|
||||
request: {
|
||||
method: 'delegate',
|
||||
params: [
|
||||
getPublicKey(secretKey),
|
||||
{
|
||||
kind: 0,
|
||||
until: Math.floor(Date.now() / 1000) + 60 * 60 * 24 * 365,
|
||||
}
|
||||
],
|
||||
}
|
||||
);
|
||||
});
|
||||
setDelegateSig(sig);
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
@@ -152,7 +158,6 @@ const App = () => {
|
||||
});
|
||||
}
|
||||
|
||||
const appEpehemeralPubKey = nip19.npubEncode(getPublicKey(secretKey));
|
||||
return (
|
||||
<div className='hero is-fullheight has-background-black has-text-white'>
|
||||
<section className="container">
|
||||
@@ -160,7 +165,7 @@ const App = () => {
|
||||
<h1 className='title has-text-white'>Nostr Connect Playground</h1>
|
||||
</div>
|
||||
<div className='content'>
|
||||
<p className='subtitle is-6 has-text-white'><b>Nostr ID (ephemeral)</b> {appEpehemeralPubKey}</p>
|
||||
<p className='subtitle is-6 has-text-white'><b>Nostr ID</b> {getPublicKey(secretKey)}</p>
|
||||
</div>
|
||||
<div className='content'>
|
||||
<p className='subtitle is-6 has-text-white'><b>Status</b> {isConnected() ? '🟢 Connected' : '🔴 Disconnected'}</p>
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
},
|
||||
"dependencies": {
|
||||
"@nostr-connect/connect": "^0.2.3",
|
||||
"nostr-tools": "^1.1.1",
|
||||
"nostr-tools": "^1.6.0",
|
||||
"qrcode.react": "^3.1.0",
|
||||
"react": "^18.2.0",
|
||||
"react-app-polyfill": "^1.0.0",
|
||||
|
||||
Reference in New Issue
Block a user