Open saranshisatgit opened 2 years ago
@thozinza and @thotrung
@saranshisatgit I am not very clear about this, could you add more detail?
They expose certain functions or methods that can be or should be used via any service or UI or anything
npm packages like @2nd/sdk
What do they contain ?
async initConnection(): Promise<NostrEvent[]> {
logger.info('Init Connection Services')
const fetchedEvents: NostrEvent[] = [];
let userList = [];
if (typeof window !== undefined) {
const privKey =
localStorage.getItem("keys") !== null
? JSON.parse(localStorage.getItem("keys")!).privateKey
: null;
if (privKey !== null) pool.setPrivateKey(privKey);
const userIdList =
localStorage.getItem("follow-list") !== null
? JSON.parse(JSON.stringify(localStorage.getItem("follow-list")))
: '[]';
console.log(userIdList);
// console.log(JSON.parse(userIdList));
userList = JSON.parse(userIdList);
// userList =
// typeof userIdList === "object" ? JSON.parse(userIdList) : userList;
}
const relays = await getRelays();
relays.map(async (relayUrl: string) => await pool.addRelay(relayUrl));
await pool.sub(
{
cb: async (event: NostrEvent) => {
switch (event.kind) {
case 0:
case 1:
case 2:
fetchedEvents.push(event);
return;
}
},
filter: [
{
authors: userList,
kinds: [0, 1, 3],
},
],
},
"profile-browser"
);
return fetchedEvents;
},
import {sdk} 2nd/sdk
sdk.initConnection()
sdk.createKeyPair()
Hence its standardised