fix tests
This commit is contained in:
parent
c36544f9a3
commit
8f7a9a1327
@ -3,5 +3,7 @@ module.exports = {
|
||||
bail: true,
|
||||
preset: "ts-jest",
|
||||
testEnvironment: "jsdom",
|
||||
roots: ["./src/"],
|
||||
roots: ["src"],
|
||||
moduleDirectories: ["src", "node_modules"],
|
||||
setupFiles: ["./src/setupTests.ts"],
|
||||
};
|
||||
|
@ -1,6 +1,6 @@
|
||||
import { db, EventInteraction } from "Db";
|
||||
import { LoginStore } from "Login";
|
||||
import { sha256 } from "Util";
|
||||
import { sha256 } from "SnortUtils";
|
||||
import FeedCache from "./FeedCache";
|
||||
|
||||
class EventInteractionCache extends FeedCache<EventInteraction> {
|
||||
|
@ -1,6 +1,6 @@
|
||||
import { db } from "Db";
|
||||
import { Table } from "dexie";
|
||||
import { unixNowMs, unwrap } from "Util";
|
||||
import { unixNowMs, unwrap } from "SnortUtils";
|
||||
|
||||
type HookFn = () => void;
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
import { HexKey, RawEvent, UserMetadata } from "@snort/nostr";
|
||||
import { hexToBech32, unixNowMs } from "Util";
|
||||
import { hexToBech32, unixNowMs } from "SnortUtils";
|
||||
import { DmCache } from "./DMCache";
|
||||
import { InteractionCache } from "./EventInteractionCache";
|
||||
import { UserCache } from "./UserCache";
|
||||
|
@ -1,7 +1,7 @@
|
||||
import Icon from "Icons/Icon";
|
||||
import { useState } from "react";
|
||||
import useFileUpload from "Upload";
|
||||
import { openFile, unwrap } from "Util";
|
||||
import { openFile, unwrap } from "SnortUtils";
|
||||
|
||||
interface AvatarEditorProps {
|
||||
picture?: string;
|
||||
|
@ -9,7 +9,7 @@ import { ProxyImg } from "Element/ProxyImg";
|
||||
import Icon from "Icons/Icon";
|
||||
import Modal from "Element/Modal";
|
||||
import Username from "Element/Username";
|
||||
import { findTag } from "Util";
|
||||
import { findTag } from "SnortUtils";
|
||||
|
||||
export default function BadgeList({ badges }: { badges: TaggedRawEvent[] }) {
|
||||
const [showModal, setShowModal] = useState(false);
|
||||
|
@ -8,7 +8,7 @@ import useEventPublisher from "Feed/EventPublisher";
|
||||
import NoteTime from "Element/NoteTime";
|
||||
import Text from "Element/Text";
|
||||
import { setLastReadDm } from "Pages/MessagesPage";
|
||||
import { unwrap } from "Util";
|
||||
import { unwrap } from "SnortUtils";
|
||||
import useLogin from "Hooks/useLogin";
|
||||
|
||||
import messages from "./messages";
|
||||
|
@ -9,7 +9,7 @@ import NoteToSelf from "Element/NoteToSelf";
|
||||
import { useDmCache } from "Hooks/useDmsCache";
|
||||
import useLogin from "Hooks/useLogin";
|
||||
import WriteDm from "Element/WriteDm";
|
||||
import { unwrap } from "Util";
|
||||
import { unwrap } from "SnortUtils";
|
||||
|
||||
export default function DmWindow({ id }: { id: string }) {
|
||||
const pubKey = useLogin().publicKey;
|
||||
|
@ -3,7 +3,7 @@ import { FormattedMessage } from "react-intl";
|
||||
import { HexKey } from "@snort/nostr";
|
||||
|
||||
import useEventPublisher from "Feed/EventPublisher";
|
||||
import { parseId } from "Util";
|
||||
import { parseId } from "SnortUtils";
|
||||
import useLogin from "Hooks/useLogin";
|
||||
import AsyncButton from "Element/AsyncButton";
|
||||
|
||||
|
@ -13,7 +13,7 @@ import {
|
||||
NostrNestsRegex,
|
||||
WavlakeRegex,
|
||||
} from "Const";
|
||||
import { magnetURIDecode } from "Util";
|
||||
import { magnetURIDecode } from "SnortUtils";
|
||||
import SoundCloudEmbed from "Element/SoundCloudEmded";
|
||||
import MixCloudEmbed from "Element/MixCloudEmbed";
|
||||
import SpotifyEmbed from "Element/SpotifyEmbed";
|
||||
|
@ -6,7 +6,7 @@ import { useMemo } from "react";
|
||||
import SendSats from "Element/SendSats";
|
||||
import Icon from "Icons/Icon";
|
||||
import { useWallet } from "Wallet";
|
||||
import { decodeInvoice } from "Util";
|
||||
import { decodeInvoice } from "SnortUtils";
|
||||
|
||||
import messages from "./messages";
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
import { FormattedMessage } from "react-intl";
|
||||
|
||||
import { Magnet } from "Util";
|
||||
import { Magnet } from "SnortUtils";
|
||||
|
||||
interface MagnetLinkProps {
|
||||
magnet: Magnet;
|
||||
|
@ -3,7 +3,7 @@ import { Link } from "react-router-dom";
|
||||
import { HexKey } from "@snort/nostr";
|
||||
|
||||
import { useUserProfile } from "Hooks/useUserProfile";
|
||||
import { profileLink } from "Util";
|
||||
import { profileLink } from "SnortUtils";
|
||||
import { getDisplayName } from "Element/ProfileImage";
|
||||
|
||||
export default function Mention({ pubkey, relays }: { pubkey: HexKey; relays?: Array<string> | string }) {
|
||||
|
@ -3,7 +3,7 @@ import { useIntl, FormattedMessage } from "react-intl";
|
||||
import { useNavigate } from "react-router-dom";
|
||||
import { UserMetadata } from "@snort/nostr";
|
||||
|
||||
import { unwrap } from "Util";
|
||||
import { unwrap } from "SnortUtils";
|
||||
import { formatShort } from "Number";
|
||||
import {
|
||||
ServiceProvider,
|
||||
@ -19,7 +19,7 @@ import SendSats from "Element/SendSats";
|
||||
import Copy from "Element/Copy";
|
||||
import { useUserProfile } from "Hooks/useUserProfile";
|
||||
import useEventPublisher from "Feed/EventPublisher";
|
||||
import { debounce } from "Util";
|
||||
import { debounce } from "SnortUtils";
|
||||
import useLogin from "Hooks/useLogin";
|
||||
import SnortServiceProvider from "Nip05/SnortServiceProvider";
|
||||
import { mapEventToProfile, UserCache } from "Cache";
|
||||
|
@ -1,7 +1,7 @@
|
||||
import { FormattedMessage } from "react-intl";
|
||||
import { RawEvent } from "@snort/nostr";
|
||||
|
||||
import { findTag, NostrLink } from "Util";
|
||||
import { findTag, NostrLink } from "SnortUtils";
|
||||
import useEventFeed from "Feed/EventFeed";
|
||||
import PageSpinner from "Element/PageSpinner";
|
||||
import Reveal from "Element/Reveal";
|
||||
|
@ -2,7 +2,7 @@ import { Link } from "react-router-dom";
|
||||
import { NostrPrefix } from "@snort/nostr";
|
||||
|
||||
import Mention from "Element/Mention";
|
||||
import { parseNostrLink } from "Util";
|
||||
import { parseNostrLink } from "SnortUtils";
|
||||
import NoteQuote from "Element/NoteQuote";
|
||||
|
||||
export default function NostrLink({ link, depth }: { link: string; depth?: number }) {
|
||||
|
@ -19,7 +19,7 @@ import {
|
||||
normalizeReaction,
|
||||
Reaction,
|
||||
profileLink,
|
||||
} from "Util";
|
||||
} from "SnortUtils";
|
||||
import NoteFooter, { Translation } from "Element/NoteFooter";
|
||||
import NoteTime from "Element/NoteTime";
|
||||
import Reveal from "Element/Reveal";
|
||||
|
@ -5,7 +5,7 @@ import { encodeTLV, EventKind, NostrPrefix, TaggedRawEvent } from "@snort/nostr"
|
||||
|
||||
import Icon from "Icons/Icon";
|
||||
import useEventPublisher from "Feed/EventPublisher";
|
||||
import { openFile } from "Util";
|
||||
import { openFile } from "SnortUtils";
|
||||
import Textarea from "Element/Textarea";
|
||||
import Modal from "Element/Modal";
|
||||
import ProfileImage from "Element/ProfileImage";
|
||||
|
@ -10,7 +10,7 @@ import Spinner from "Icons/Spinner";
|
||||
|
||||
import { formatShort } from "Number";
|
||||
import useEventPublisher from "Feed/EventPublisher";
|
||||
import { delay, normalizeReaction, unwrap } from "Util";
|
||||
import { delay, normalizeReaction, unwrap } from "SnortUtils";
|
||||
import { NoteCreator } from "Element/NoteCreator";
|
||||
import { ReBroadcaster } from "Element/ReBroadcaster";
|
||||
import Reactions from "Element/Reactions";
|
||||
|
@ -1,5 +1,5 @@
|
||||
import useEventFeed from "Feed/EventFeed";
|
||||
import { NostrLink } from "Util";
|
||||
import { NostrLink } from "SnortUtils";
|
||||
import Note from "Element/Note";
|
||||
import PageSpinner from "Element/PageSpinner";
|
||||
|
||||
|
@ -5,7 +5,7 @@ import { EventKind, RawEvent, TaggedRawEvent, NostrPrefix } from "@snort/nostr";
|
||||
|
||||
import Note from "Element/Note";
|
||||
import ProfileImage from "Element/ProfileImage";
|
||||
import { eventLink, hexToBech32 } from "Util";
|
||||
import { eventLink, hexToBech32 } from "SnortUtils";
|
||||
import NoteTime from "Element/NoteTime";
|
||||
import useModeration from "Hooks/useModeration";
|
||||
import { EventExt } from "System/EventExt";
|
||||
|
@ -1,7 +1,7 @@
|
||||
import "./NoteToSelf.css";
|
||||
import { Link, useNavigate } from "react-router-dom";
|
||||
import { FormattedMessage } from "react-intl";
|
||||
import { profileLink } from "Util";
|
||||
import { profileLink } from "SnortUtils";
|
||||
|
||||
import messages from "./messages";
|
||||
import Icon from "Icons/Icon";
|
||||
|
@ -8,7 +8,7 @@ import useEventPublisher from "Feed/EventPublisher";
|
||||
import { useWallet } from "Wallet";
|
||||
import { useUserProfile } from "Hooks/useUserProfile";
|
||||
import { LNURL } from "LNURL";
|
||||
import { unwrap } from "Util";
|
||||
import { unwrap } from "SnortUtils";
|
||||
import { formatShort } from "Number";
|
||||
import Spinner from "Icons/Spinner";
|
||||
import SendSats from "Element/SendSats";
|
||||
|
@ -4,7 +4,7 @@ import React, { useMemo } from "react";
|
||||
import { HexKey, NostrPrefix } from "@snort/nostr";
|
||||
|
||||
import { useUserProfile } from "Hooks/useUserProfile";
|
||||
import { hexToBech32, profileLink } from "Util";
|
||||
import { hexToBech32, profileLink } from "SnortUtils";
|
||||
import Avatar from "Element/Avatar";
|
||||
import Nip05 from "Element/Nip05";
|
||||
import { MetadataCache } from "Cache";
|
||||
|
@ -1,7 +1,7 @@
|
||||
import useImgProxy from "Hooks/useImgProxy";
|
||||
import { useEffect, useState } from "react";
|
||||
import { FormattedMessage } from "react-intl";
|
||||
import { getUrlHostname } from "Util";
|
||||
import { getUrlHostname } from "SnortUtils";
|
||||
|
||||
interface ProxyImgProps extends React.DetailedHTMLProps<React.ImgHTMLAttributes<HTMLImageElement>, HTMLImageElement> {
|
||||
size?: number;
|
||||
|
@ -1,5 +1,5 @@
|
||||
import { RawEvent } from "@snort/nostr";
|
||||
import { dedupe } from "Util";
|
||||
import { dedupe } from "SnortUtils";
|
||||
import FollowListBase from "./FollowListBase";
|
||||
|
||||
export default function PubkeyList({ ev, className }: { ev: RawEvent; className?: string }) {
|
||||
|
@ -6,7 +6,7 @@ import { RelaySettings } from "@snort/nostr";
|
||||
|
||||
import useRelayState from "Feed/RelayState";
|
||||
import { System } from "System";
|
||||
import { getRelayName, unixNowMs, unwrap } from "Util";
|
||||
import { getRelayName, unixNowMs, unwrap } from "SnortUtils";
|
||||
import useLogin from "Hooks/useLogin";
|
||||
import { setRelays } from "Login";
|
||||
import Icon from "Icons/Icon";
|
||||
|
@ -11,7 +11,7 @@ import Modal from "Element/Modal";
|
||||
import QrCode from "Element/QrCode";
|
||||
import Copy from "Element/Copy";
|
||||
import { LNURL, LNURLError, LNURLErrorCode, LNURLInvoice, LNURLSuccessAction } from "LNURL";
|
||||
import { chunks, debounce } from "Util";
|
||||
import { chunks, debounce } from "SnortUtils";
|
||||
import { useWallet } from "Wallet";
|
||||
import useLogin from "Hooks/useLogin";
|
||||
import { generateRandomKey } from "Login";
|
||||
|
@ -4,7 +4,7 @@ import { useState } from "react";
|
||||
import useRelayState from "Feed/RelayState";
|
||||
import Tabs, { Tab } from "Element/Tabs";
|
||||
import { System } from "System";
|
||||
import { unwrap } from "Util";
|
||||
import { unwrap } from "SnortUtils";
|
||||
import useSystemState from "Hooks/useSystemState";
|
||||
import { RawReqFilter } from "@snort/nostr";
|
||||
import { useCopy } from "useCopy";
|
||||
|
@ -7,7 +7,7 @@ import PageSpinner from "Element/PageSpinner";
|
||||
import NostrBandApi from "External/NostrBand";
|
||||
import SemisolDevApi from "External/SemisolDev";
|
||||
import useLogin from "Hooks/useLogin";
|
||||
import { hexToBech32 } from "Util";
|
||||
import { hexToBech32 } from "SnortUtils";
|
||||
|
||||
enum Provider {
|
||||
NostrBand = 1,
|
||||
|
@ -4,7 +4,7 @@ import { Link, useLocation } from "react-router-dom";
|
||||
import { HexKey, NostrPrefix } from "@snort/nostr";
|
||||
|
||||
import { MentionRegex, InvoiceRegex, HashtagRegex, CashuRegex } from "Const";
|
||||
import { eventLink, hexToBech32, splitByUrl, validateNostrLink } from "Util";
|
||||
import { eventLink, hexToBech32, splitByUrl, validateNostrLink } from "SnortUtils";
|
||||
import Invoice from "Element/Invoice";
|
||||
import Hashtag from "Element/Hashtag";
|
||||
import Mention from "Element/Mention";
|
||||
|
@ -8,7 +8,7 @@ import { NostrPrefix } from "@snort/nostr";
|
||||
|
||||
import Avatar from "Element/Avatar";
|
||||
import Nip05 from "Element/Nip05";
|
||||
import { hexToBech32 } from "Util";
|
||||
import { hexToBech32 } from "SnortUtils";
|
||||
import { MetadataCache } from "Cache";
|
||||
import { UserCache } from "Cache/UserCache";
|
||||
|
||||
|
@ -5,7 +5,7 @@ import { useNavigate, useLocation, Link, useParams } from "react-router-dom";
|
||||
import { TaggedRawEvent, u256, EventKind, NostrPrefix } from "@snort/nostr";
|
||||
import { EventExt, Thread as ThreadInfo } from "System/EventExt";
|
||||
|
||||
import { eventLink, unwrap, getReactions, parseNostrLink, getAllReactions, findTag } from "Util";
|
||||
import { eventLink, unwrap, getReactions, parseNostrLink, getAllReactions, findTag } from "SnortUtils";
|
||||
import BackButton from "Element/BackButton";
|
||||
import Note from "Element/Note";
|
||||
import NoteGhost from "Element/NoteGhost";
|
||||
|
@ -5,7 +5,7 @@ import { useInView } from "react-intersection-observer";
|
||||
import { TaggedRawEvent, EventKind, u256 } from "@snort/nostr";
|
||||
|
||||
import Icon from "Icons/Icon";
|
||||
import { dedupeByPubkey, findTag, tagFilterOfTextRepost } from "Util";
|
||||
import { dedupeByPubkey, findTag, tagFilterOfTextRepost } from "SnortUtils";
|
||||
import ProfileImage from "Element/ProfileImage";
|
||||
import useTimelineFeed, { TimelineFeed, TimelineSubject } from "Feed/TimelineFeed";
|
||||
import LoadMore from "Element/LoadMore";
|
||||
|
@ -4,7 +4,7 @@ import { useNavigate, Link } from "react-router-dom";
|
||||
import { HexKey } from "@snort/nostr";
|
||||
|
||||
import { useUserProfile } from "Hooks/useUserProfile";
|
||||
import { profileLink } from "Util";
|
||||
import { profileLink } from "SnortUtils";
|
||||
|
||||
export default function Username({ pubkey, onLinkVisit }: { pubkey: HexKey; onLinkVisit(): void }) {
|
||||
const user = useUserProfile(pubkey);
|
||||
|
@ -4,7 +4,7 @@ import Icon from "Icons/Icon";
|
||||
import Spinner from "Icons/Spinner";
|
||||
import { useState } from "react";
|
||||
import useFileUpload from "Upload";
|
||||
import { openFile } from "Util";
|
||||
import { openFile } from "SnortUtils";
|
||||
import Textarea from "./Textarea";
|
||||
|
||||
export default function WriteDm({ chatPubKey }: { chatPubKey: string }) {
|
||||
|
@ -3,11 +3,11 @@ import { useMemo } from "react";
|
||||
import { FormattedMessage, useIntl } from "react-intl";
|
||||
import { HexKey, TaggedRawEvent } from "@snort/nostr";
|
||||
|
||||
import { decodeInvoice, InvoiceDetails, sha256, unwrap } from "Util";
|
||||
import { decodeInvoice, InvoiceDetails, sha256, unwrap } from "SnortUtils";
|
||||
import { formatShort } from "Number";
|
||||
import Text from "Element/Text";
|
||||
import ProfileImage from "Element/ProfileImage";
|
||||
import { findTag } from "Util";
|
||||
import { findTag } from "SnortUtils";
|
||||
import { UserCache } from "Cache/UserCache";
|
||||
import useLogin from "Hooks/useLogin";
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
import { useMemo } from "react";
|
||||
import { EventKind, HexKey, Lists } from "@snort/nostr";
|
||||
|
||||
import { unwrap, findTag, chunks } from "Util";
|
||||
import { unwrap, findTag, chunks } from "SnortUtils";
|
||||
import { RequestBuilder } from "System";
|
||||
import { FlatNoteStore, ReplaceableNoteStore } from "System/NoteCollection";
|
||||
import useRequestBuilder from "Hooks/useRequestBuilder";
|
||||
|
@ -3,7 +3,7 @@ import { NostrPrefix } from "@snort/nostr";
|
||||
|
||||
import useRequestBuilder from "Hooks/useRequestBuilder";
|
||||
import { RequestBuilder, ReplaceableNoteStore } from "System";
|
||||
import { NostrLink, unwrap } from "Util";
|
||||
import { NostrLink, unwrap } from "SnortUtils";
|
||||
|
||||
export default function useEventFeed(link: NostrLink) {
|
||||
const sub = useMemo(() => {
|
||||
|
@ -1,7 +1,7 @@
|
||||
import { useEffect, useMemo } from "react";
|
||||
import { TaggedRawEvent, Lists, EventKind } from "@snort/nostr";
|
||||
|
||||
import { bech32ToHex, getNewest, getNewestEventTagsByKey, unwrap } from "Util";
|
||||
import { bech32ToHex, getNewest, getNewestEventTagsByKey, unwrap } from "SnortUtils";
|
||||
import { makeNotification, sendNotification } from "Notifications";
|
||||
import useEventPublisher from "Feed/EventPublisher";
|
||||
import { getMutedKeys } from "Feed/MuteList";
|
||||
|
@ -1,7 +1,7 @@
|
||||
import { useMemo } from "react";
|
||||
import { HexKey, TaggedRawEvent, Lists, EventKind } from "@snort/nostr";
|
||||
|
||||
import { getNewest } from "Util";
|
||||
import { getNewest } from "SnortUtils";
|
||||
import { ParameterizedReplaceableNoteStore, RequestBuilder } from "System";
|
||||
import useRequestBuilder from "Hooks/useRequestBuilder";
|
||||
import useLogin from "Hooks/useLogin";
|
||||
|
@ -1,7 +1,7 @@
|
||||
import { useMemo } from "react";
|
||||
import { HexKey, FullRelaySettings, TaggedRawEvent, RelaySettings, EventKind } from "@snort/nostr";
|
||||
|
||||
import { sanitizeRelayUrl } from "Util";
|
||||
import { sanitizeRelayUrl } from "SnortUtils";
|
||||
import { PubkeyReplaceableNoteStore, RequestBuilder } from "System";
|
||||
import useRequestBuilder from "Hooks/useRequestBuilder";
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
import { useEffect, useMemo, useState } from "react";
|
||||
import { u256, EventKind } from "@snort/nostr";
|
||||
|
||||
import { appendDedupe, NostrLink } from "Util";
|
||||
import { appendDedupe, NostrLink } from "SnortUtils";
|
||||
import { FlatNoteStore, RequestBuilder } from "System";
|
||||
import useRequestBuilder from "Hooks/useRequestBuilder";
|
||||
import useLogin from "Hooks/useLogin";
|
||||
|
@ -1,7 +1,7 @@
|
||||
import { useCallback, useEffect, useMemo, useState } from "react";
|
||||
import { EventKind, u256 } from "@snort/nostr";
|
||||
|
||||
import { unixNow, unwrap, tagFilterOfTextRepost } from "Util";
|
||||
import { unixNow, unwrap, tagFilterOfTextRepost } from "SnortUtils";
|
||||
import { FlatNoteStore, RequestBuilder } from "System";
|
||||
import useRequestBuilder from "Hooks/useRequestBuilder";
|
||||
import useTimelineWindow from "Hooks/useTimelineWindow";
|
||||
|
@ -1,6 +1,6 @@
|
||||
import * as utils from "@noble/curves/abstract/utils";
|
||||
import * as base64 from "@protobufjs/base64";
|
||||
import { hmacSha256, unwrap } from "Util";
|
||||
import { hmacSha256, unwrap } from "SnortUtils";
|
||||
import useLogin from "Hooks/useLogin";
|
||||
|
||||
export interface ImgProxySettings {
|
||||
|
@ -3,7 +3,7 @@ import { HexKey, u256 } from "@snort/nostr";
|
||||
|
||||
import { InteractionCache } from "Cache/EventInteractionCache";
|
||||
import { EventInteraction } from "Db";
|
||||
import { sha256, unwrap } from "Util";
|
||||
import { sha256, unwrap } from "SnortUtils";
|
||||
|
||||
export function useInteractionCache(pubkey?: HexKey, event?: u256) {
|
||||
const id = event && pubkey ? sha256(event + pubkey) : undefined;
|
||||
|
@ -4,7 +4,7 @@ import { EmailRegex, MnemonicRegex } from "Const";
|
||||
import { LoginStore } from "Login";
|
||||
import { generateBip39Entropy, entropyToPrivateKey } from "nip6";
|
||||
import { getNip05PubKey } from "Pages/LoginPage";
|
||||
import { bech32ToHex } from "Util";
|
||||
import { bech32ToHex } from "SnortUtils";
|
||||
|
||||
export default function useLoginHandler() {
|
||||
const { formatMessage } = useIntl();
|
||||
|
@ -2,7 +2,7 @@ import { HexKey } from "@snort/nostr";
|
||||
import useEventPublisher from "Feed/EventPublisher";
|
||||
import useLogin from "Hooks/useLogin";
|
||||
import { setBlocked, setMuted } from "Login";
|
||||
import { appendDedupe } from "Util";
|
||||
import { appendDedupe } from "SnortUtils";
|
||||
|
||||
export default function useModeration() {
|
||||
const login = useLogin();
|
||||
|
@ -1,7 +1,7 @@
|
||||
import { useSyncExternalStore } from "react";
|
||||
import { RequestBuilder, System } from "System";
|
||||
import { EmptySnapshot, NoteStore, StoreSnapshot } from "System/NoteCollection";
|
||||
import { unwrap } from "Util";
|
||||
import { unwrap } from "SnortUtils";
|
||||
|
||||
const useRequestBuilder = <TStore extends NoteStore, TSnapshot = ReturnType<TStore["getSnapshotData"]>>(
|
||||
type: { new (): TStore },
|
||||
|
@ -1,6 +1,6 @@
|
||||
import { HexKey, RawEvent } from "@snort/nostr";
|
||||
import { EmailRegex } from "Const";
|
||||
import { bech32ToText, unwrap } from "Util";
|
||||
import { bech32ToText, unwrap } from "SnortUtils";
|
||||
|
||||
const PayServiceTag = "payRequest";
|
||||
|
||||
|
@ -5,7 +5,7 @@ import * as utils from "@noble/curves/abstract/utils";
|
||||
import { DefaultRelays, SnortPubKey } from "Const";
|
||||
import { LoginStore, UserPreferences, LoginSession } from "Login";
|
||||
import { generateBip39Entropy, entropyToPrivateKey } from "nip6";
|
||||
import { bech32ToHex, dedupeById, randomSample, sanitizeRelayUrl, unixNowMs, unwrap } from "Util";
|
||||
import { bech32ToHex, dedupeById, randomSample, sanitizeRelayUrl, unixNowMs, unwrap } from "SnortUtils";
|
||||
import { SubscriptionEvent } from "Subscription";
|
||||
import { EventPublisher } from "System/EventPublisher";
|
||||
|
||||
|
@ -6,7 +6,7 @@ import { HexKey, RelaySettings } from "@snort/nostr";
|
||||
import { DefaultRelays } from "Const";
|
||||
import ExternalStore from "ExternalStore";
|
||||
import { LoginSession } from "Login";
|
||||
import { deepClone, sanitizeRelayUrl, unwrap } from "Util";
|
||||
import { deepClone, sanitizeRelayUrl, unwrap } from "SnortUtils";
|
||||
import { DefaultPreferences, UserPreferences } from "./Preferences";
|
||||
|
||||
const AccountStoreKey = "sessions";
|
||||
|
@ -1,5 +1,5 @@
|
||||
import DnsOverHttpResolver from "dns-over-http-resolver";
|
||||
import { bech32ToHex } from "Util";
|
||||
import { bech32ToHex } from "SnortUtils";
|
||||
|
||||
const resolver = new DnsOverHttpResolver();
|
||||
interface NostrJson {
|
||||
|
@ -5,7 +5,7 @@ import { EventKind } from "@snort/nostr";
|
||||
import { MetadataCache } from "Cache";
|
||||
import { getDisplayName } from "Element/ProfileImage";
|
||||
import { MentionRegex } from "Const";
|
||||
import { tagFilterOfTextRepost, unwrap } from "Util";
|
||||
import { tagFilterOfTextRepost, unwrap } from "SnortUtils";
|
||||
import { UserCache } from "Cache/UserCache";
|
||||
import { LoginSession } from "Login";
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
import DmWindow from "Element/DmWindow";
|
||||
import { useParams } from "react-router-dom";
|
||||
import { bech32ToHex } from "Util";
|
||||
import { bech32ToHex } from "SnortUtils";
|
||||
|
||||
import "./ChatPage.css";
|
||||
|
||||
|
@ -5,7 +5,7 @@ import { HexKey } from "@snort/nostr";
|
||||
import { ApiHost, KieranPubKey, SnortPubKey } from "Const";
|
||||
import ProfilePreview from "Element/ProfilePreview";
|
||||
import ZapButton from "Element/ZapButton";
|
||||
import { bech32ToHex } from "Util";
|
||||
import { bech32ToHex } from "SnortUtils";
|
||||
import SnortApi, { RevenueSplit, RevenueToday } from "SnortApi";
|
||||
|
||||
const Developers = [
|
||||
|
@ -23,7 +23,7 @@ import { mapPlanName } from "./subscribe";
|
||||
import useLogin from "Hooks/useLogin";
|
||||
import Avatar from "Element/Avatar";
|
||||
import { useUserProfile } from "Hooks/useUserProfile";
|
||||
import { profileLink } from "Util";
|
||||
import { profileLink } from "SnortUtils";
|
||||
import { getCurrentSubscription } from "Subscription";
|
||||
import Toaster from "Toaster";
|
||||
|
||||
|
@ -5,7 +5,7 @@ import { useNavigate } from "react-router-dom";
|
||||
import { useIntl, FormattedMessage } from "react-intl";
|
||||
import { HexKey } from "@snort/nostr";
|
||||
|
||||
import { bech32ToHex, unwrap } from "Util";
|
||||
import { bech32ToHex, unwrap } from "SnortUtils";
|
||||
import ZapButton from "Element/ZapButton";
|
||||
import useImgProxy from "Hooks/useImgProxy";
|
||||
import Icon from "Icons/Icon";
|
||||
|
@ -5,7 +5,7 @@ import { HexKey, RawEvent, NostrPrefix } from "@snort/nostr";
|
||||
|
||||
import UnreadCount from "Element/UnreadCount";
|
||||
import ProfileImage, { getDisplayName } from "Element/ProfileImage";
|
||||
import { dedupe, hexToBech32, unwrap } from "Util";
|
||||
import { dedupe, hexToBech32, unwrap } from "SnortUtils";
|
||||
import NoteToSelf from "Element/NoteToSelf";
|
||||
import useModeration from "Hooks/useModeration";
|
||||
import { useDmCache } from "Hooks/useDmsCache";
|
||||
|
@ -4,7 +4,7 @@ import { FormattedMessage } from "react-intl";
|
||||
import { useNavigate, useParams } from "react-router-dom";
|
||||
|
||||
import Spinner from "Icons/Spinner";
|
||||
import { parseNostrLink, profileLink } from "Util";
|
||||
import { parseNostrLink, profileLink } from "SnortUtils";
|
||||
import { getNip05PubKey } from "Pages/LoginPage";
|
||||
import { System } from "System";
|
||||
|
||||
|
@ -4,7 +4,7 @@ import Timeline from "Element/Timeline";
|
||||
import { TaskList } from "Tasks/TaskList";
|
||||
import useLogin from "Hooks/useLogin";
|
||||
import { markNotificationsRead } from "Login";
|
||||
import { unixNow } from "Util";
|
||||
import { unixNow } from "SnortUtils";
|
||||
|
||||
export default function NotificationsPage() {
|
||||
const login = useLogin();
|
||||
|
@ -4,7 +4,7 @@ import { useIntl, FormattedMessage } from "react-intl";
|
||||
import { useNavigate, useParams } from "react-router-dom";
|
||||
import { encodeTLV, EventKind, HexKey, NostrPrefix } from "@snort/nostr";
|
||||
|
||||
import { parseNostrLink, getReactions, unwrap } from "Util";
|
||||
import { parseNostrLink, getReactions, unwrap } from "SnortUtils";
|
||||
import { formatShort } from "Number";
|
||||
import Note from "Element/Note";
|
||||
import Bookmarks from "Element/Bookmarks";
|
||||
@ -23,7 +23,7 @@ import useModeration from "Hooks/useModeration";
|
||||
import useZapsFeed from "Feed/ZapsFeed";
|
||||
import { default as ZapElement } from "Element/Zap";
|
||||
import FollowButton from "Element/FollowButton";
|
||||
import { parseId, hexToBech32 } from "Util";
|
||||
import { parseId, hexToBech32 } from "SnortUtils";
|
||||
import Avatar from "Element/Avatar";
|
||||
import Timeline from "Element/Timeline";
|
||||
import Text from "Element/Text";
|
||||
|
@ -7,7 +7,7 @@ import Tabs, { Tab } from "Element/Tabs";
|
||||
import Timeline from "Element/Timeline";
|
||||
import { System } from "System";
|
||||
import { TimelineSubject } from "Feed/TimelineFeed";
|
||||
import { debounce, getRelayName, sha256, unixNow, unwrap } from "Util";
|
||||
import { debounce, getRelayName, sha256, unixNow, unwrap } from "SnortUtils";
|
||||
import useLogin from "Hooks/useLogin";
|
||||
import Discover from "Pages/Discover";
|
||||
|
||||
|
@ -3,7 +3,7 @@ import { useParams } from "react-router-dom";
|
||||
import Timeline from "Element/Timeline";
|
||||
import { Tab, TabElement } from "Element/Tabs";
|
||||
import { useEffect, useState } from "react";
|
||||
import { debounce } from "Util";
|
||||
import { debounce } from "SnortUtils";
|
||||
import { router } from "index";
|
||||
import { SearchRelays } from "Const";
|
||||
import { System } from "System";
|
||||
|
@ -7,7 +7,7 @@ import { FormattedMessage, FormattedNumber, useIntl } from "react-intl";
|
||||
import NoteTime from "Element/NoteTime";
|
||||
import { WalletInvoice, Sats, WalletInfo, WalletInvoiceState, useWallet, LNWallet, Wallets } from "Wallet";
|
||||
import AsyncButton from "Element/AsyncButton";
|
||||
import { unwrap } from "Util";
|
||||
import { unwrap } from "SnortUtils";
|
||||
import { WebLNWallet } from "Wallet/WebLN";
|
||||
import Icon from "Icons/Icon";
|
||||
|
||||
|
@ -8,7 +8,7 @@ import ProfilePreview from "Element/ProfilePreview";
|
||||
import useLogin from "Hooks/useLogin";
|
||||
import { System } from "System";
|
||||
import { UploaderServices } from "Upload";
|
||||
import { bech32ToHex, getRelayName, unwrap } from "Util";
|
||||
import { bech32ToHex, getRelayName, unwrap } from "SnortUtils";
|
||||
import { ZapPoolController, ZapPoolRecipient, ZapPoolRecipientType } from "ZapPoolController";
|
||||
import { useUserProfile } from "Hooks/useUserProfile";
|
||||
import AsyncButton from "Element/AsyncButton";
|
||||
|
@ -6,7 +6,7 @@ import { ApiHost } from "Const";
|
||||
import Logo from "Element/Logo";
|
||||
import AsyncButton from "Element/AsyncButton";
|
||||
import FollowListBase from "Element/FollowListBase";
|
||||
import { bech32ToHex } from "Util";
|
||||
import { bech32ToHex } from "SnortUtils";
|
||||
import SnortApi from "SnortApi";
|
||||
import useLogin from "Hooks/useLogin";
|
||||
|
||||
|
@ -4,7 +4,7 @@ import { useNavigate } from "react-router-dom";
|
||||
import Logo from "Element/Logo";
|
||||
import { CollapsedSection } from "Element/Collapsed";
|
||||
import Copy from "Element/Copy";
|
||||
import { hexToBech32 } from "Util";
|
||||
import { hexToBech32 } from "SnortUtils";
|
||||
import { hexToMnemonic } from "nip6";
|
||||
import useLogin from "Hooks/useLogin";
|
||||
import { PROFILE } from ".";
|
||||
|
@ -4,7 +4,7 @@ import { useNavigate } from "react-router-dom";
|
||||
import Icon from "Icons/Icon";
|
||||
import { LoginStore, logout } from "Login";
|
||||
import useLogin from "Hooks/useLogin";
|
||||
import { unwrap } from "Util";
|
||||
import { unwrap } from "SnortUtils";
|
||||
import { getCurrentSubscription } from "Subscription";
|
||||
import { CollapsedSection } from "Element/Collapsed";
|
||||
|
||||
|
@ -5,7 +5,7 @@ import { encodeTLV, NostrPrefix } from "@snort/nostr";
|
||||
import Copy from "Element/Copy";
|
||||
import useLogin from "Hooks/useLogin";
|
||||
import { hexToMnemonic } from "nip6";
|
||||
import { hexToBech32 } from "Util";
|
||||
import { hexToBech32 } from "SnortUtils";
|
||||
|
||||
export default function ExportKeys() {
|
||||
const { publicKey, privateKey, generatedEntropy } = useLogin();
|
||||
|
@ -5,7 +5,7 @@ import { useEffect, useState } from "react";
|
||||
import useLogin from "Hooks/useLogin";
|
||||
import { DefaultPreferences, updatePreferences, UserPreferences } from "Login";
|
||||
import { DefaultImgProxy } from "Const";
|
||||
import { unwrap } from "Util";
|
||||
import { unwrap } from "SnortUtils";
|
||||
|
||||
import messages from "./messages";
|
||||
|
||||
|
@ -6,7 +6,7 @@ import { useNavigate } from "react-router-dom";
|
||||
|
||||
import useEventPublisher from "Feed/EventPublisher";
|
||||
import { useUserProfile } from "Hooks/useUserProfile";
|
||||
import { openFile } from "Util";
|
||||
import { openFile } from "SnortUtils";
|
||||
import useFileUpload from "Upload";
|
||||
import AsyncButton from "Element/AsyncButton";
|
||||
import { mapEventToProfile, UserCache } from "Cache";
|
||||
|
@ -2,7 +2,7 @@ import { FormattedMessage } from "react-intl";
|
||||
import ProfilePreview from "Element/ProfilePreview";
|
||||
import useRelayState from "Feed/RelayState";
|
||||
import { useNavigate, useParams } from "react-router-dom";
|
||||
import { parseId, unwrap } from "Util";
|
||||
import { parseId, unwrap } from "SnortUtils";
|
||||
import { System } from "System";
|
||||
import { removeRelay } from "Login";
|
||||
import useLogin from "Hooks/useLogin";
|
||||
|
@ -1,7 +1,7 @@
|
||||
import { useMemo, useState } from "react";
|
||||
import { FormattedMessage } from "react-intl";
|
||||
|
||||
import { randomSample, unixNowMs } from "Util";
|
||||
import { randomSample, unixNowMs } from "SnortUtils";
|
||||
import Relay from "Element/Relay";
|
||||
import useEventPublisher from "Feed/EventPublisher";
|
||||
import { System } from "System";
|
||||
|
@ -3,7 +3,7 @@ import { FormattedMessage, useIntl } from "react-intl";
|
||||
import { v4 as uuid } from "uuid";
|
||||
|
||||
import AsyncButton from "Element/AsyncButton";
|
||||
import { unwrap } from "Util";
|
||||
import { unwrap } from "SnortUtils";
|
||||
import { WalletConfig, WalletKind, Wallets } from "Wallet";
|
||||
import { useNavigate } from "react-router-dom";
|
||||
|
||||
|
@ -5,7 +5,7 @@ import { v4 as uuid } from "uuid";
|
||||
|
||||
import AsyncButton from "Element/AsyncButton";
|
||||
import { LNWallet, WalletInfo, WalletKind, Wallets } from "Wallet";
|
||||
import { unwrap } from "Util";
|
||||
import { unwrap } from "SnortUtils";
|
||||
|
||||
const ConnectLNC = () => {
|
||||
const { formatMessage } = useIntl();
|
||||
|
@ -3,7 +3,7 @@ import { FormattedMessage, useIntl } from "react-intl";
|
||||
import { v4 as uuid } from "uuid";
|
||||
|
||||
import AsyncButton from "Element/AsyncButton";
|
||||
import { unwrap } from "Util";
|
||||
import { unwrap } from "SnortUtils";
|
||||
import LNDHubWallet from "Wallet/LNDHub";
|
||||
import { WalletConfig, WalletKind, Wallets } from "Wallet";
|
||||
import { useNavigate } from "react-router-dom";
|
||||
|
@ -3,7 +3,7 @@ import { FormattedMessage, useIntl } from "react-intl";
|
||||
import { v4 as uuid } from "uuid";
|
||||
|
||||
import AsyncButton from "Element/AsyncButton";
|
||||
import { unwrap } from "Util";
|
||||
import { unwrap } from "SnortUtils";
|
||||
import { WalletConfig, WalletKind, Wallets } from "Wallet";
|
||||
import { Link, useNavigate } from "react-router-dom";
|
||||
import { NostrConnectWallet } from "Wallet/NostrWalletConnect";
|
||||
|
@ -1,4 +1,6 @@
|
||||
import { splitByUrl, magnetURIDecode, getRelayName, validateNostrLink } from "./Util";
|
||||
import { NostrPrefix } from "@snort/nostr";
|
||||
import { parseNostrLink, tryParseNostrLink } from ".";
|
||||
import { splitByUrl, magnetURIDecode, getRelayName } from ".";
|
||||
import { describe, expect } from "@jest/globals";
|
||||
|
||||
describe("splitByUrl", () => {
|
||||
@ -92,19 +94,46 @@ describe("getRelayName", () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe("validateNostrLink", () => {
|
||||
test.each([
|
||||
"nostr:npub10elfcs4fr0l0r8af98jlmgdh9c8tcxjvz9qkw038js35mp4dma8qzvjptg",
|
||||
"web+nostr:npub10elfcs4fr0l0r8af98jlmgdh9c8tcxjvz9qkw038js35mp4dma8qzvjptg",
|
||||
"nostr:note15449edq4qa5wzgqvh8td0q0dp6hwtes4pknsrm7eygeenhlj99xsq94wu9",
|
||||
"nostr:nprofile1qqsrhuxx8l9ex335q7he0f09aej04zpazpl0ne2cgukyawd24mayt8gpp4mhxue69uhhytnc9e3k7mgpz4mhxue69uhkg6nzv9ejuumpv34kytnrdaksjlyr9p",
|
||||
"nostr:nevent1qqs226juks2sw68pyqxtn4khs8ksath9uc2smfcpalvjyvuemlezjngrd87dq",
|
||||
"nostr:naddr1qqzkjurnw4ksz9thwden5te0wfjkccte9ehx7um5wghx7un8qgs2d90kkcq3nk2jry62dyf50k0h36rhpdtd594my40w9pkal876jxgrqsqqqa28pccpzu",
|
||||
])("should return true for valid nostr links", la => {
|
||||
expect(validateNostrLink(la)).toBe(true);
|
||||
describe("tryParseNostrLink", () => {
|
||||
it("is a valid nostr link", () => {
|
||||
expect(parseNostrLink("nostr:npub10elfcs4fr0l0r8af98jlmgdh9c8tcxjvz9qkw038js35mp4dma8qzvjptg")).toMatchObject({
|
||||
id: "7e7e9c42a91bfef19fa929e5fda1b72e0ebc1a4c1141673e2794234d86addf4e",
|
||||
type: NostrPrefix.PublicKey,
|
||||
});
|
||||
expect(parseNostrLink("web+nostr:npub10elfcs4fr0l0r8af98jlmgdh9c8tcxjvz9qkw038js35mp4dma8qzvjptg")).toMatchObject({
|
||||
id: "7e7e9c42a91bfef19fa929e5fda1b72e0ebc1a4c1141673e2794234d86addf4e",
|
||||
type: NostrPrefix.PublicKey,
|
||||
});
|
||||
expect(parseNostrLink("nostr:note15449edq4qa5wzgqvh8td0q0dp6hwtes4pknsrm7eygeenhlj99xsq94wu9")).toMatchObject({
|
||||
id: "a56a5cb4150768e1200cb9d6d781ed0eaee5e6150da701efd9223399dff2294d",
|
||||
type: NostrPrefix.Note,
|
||||
});
|
||||
expect(
|
||||
parseNostrLink(
|
||||
"nostr:nprofile1qqsrhuxx8l9ex335q7he0f09aej04zpazpl0ne2cgukyawd24mayt8gpp4mhxue69uhhytnc9e3k7mgpz4mhxue69uhkg6nzv9ejuumpv34kytnrdaksjlyr9p"
|
||||
)
|
||||
).toMatchObject({
|
||||
id: "3bf0c63fcb93463407af97a5e5ee64fa883d107ef9e558472c4eb9aaaefa459d",
|
||||
type: NostrPrefix.Profile,
|
||||
relays: ["wss://r.x.com", "wss://djbas.sadkb.com"],
|
||||
});
|
||||
expect(parseNostrLink("nostr:nevent1qqs226juks2sw68pyqxtn4khs8ksath9uc2smfcpalvjyvuemlezjngrd87dq")).toMatchObject({
|
||||
id: "a56a5cb4150768e1200cb9d6d781ed0eaee5e6150da701efd9223399dff2294d",
|
||||
type: NostrPrefix.Event,
|
||||
});
|
||||
expect(
|
||||
parseNostrLink(
|
||||
"nostr:naddr1qqzkjurnw4ksz9thwden5te0wfjkccte9ehx7um5wghx7un8qgs2d90kkcq3nk2jry62dyf50k0h36rhpdtd594my40w9pkal876jxgrqsqqqa28pccpzu"
|
||||
)
|
||||
).toMatchObject({
|
||||
id: "ipsum",
|
||||
type: NostrPrefix.Address,
|
||||
relays: ["wss://relay.nostr.org"],
|
||||
author: "a695f6b60119d9521934a691347d9f78e8770b56da16bb255ee286ddf9fda919",
|
||||
kind: 30023,
|
||||
});
|
||||
});
|
||||
|
||||
test.each(["nostr:npub", "web+nostr:npub", "nostr:nevent1xxx"])("should return false for invalid nostr links", lb => {
|
||||
expect(validateNostrLink(lb)).toBe(false);
|
||||
expect(tryParseNostrLink(lb)).toBeUndefined();
|
||||
});
|
||||
});
|
@ -18,6 +18,7 @@ import {
|
||||
RawEvent,
|
||||
} from "@snort/nostr";
|
||||
import { MetadataCache } from "Cache";
|
||||
import NostrLink from "Element/NostrLink";
|
||||
|
||||
export const sha256 = (str: string | Uint8Array): u256 => {
|
||||
return utils.bytesToHex(hash(str));
|
||||
@ -530,7 +531,15 @@ export function validateNostrLink(link: string): boolean {
|
||||
}
|
||||
}
|
||||
|
||||
export function parseNostrLink(link: string, prefixHint?: NostrPrefix): NostrLink | undefined {
|
||||
export function tryParseNostrLink(link: string, prefixHint?: NostrPrefix): NostrLink | undefined {
|
||||
try {
|
||||
return parseNostrLink(link, prefixHint);
|
||||
} catch {
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
|
||||
export function parseNostrLink(link: string, prefixHint?: NostrPrefix): NostrLink {
|
||||
const entity = link.startsWith("web+nostr:") || link.startsWith("nostr:") ? link.split(":")[1] : link;
|
||||
|
||||
const isPrefix = (prefix: NostrPrefix) => {
|
||||
@ -539,6 +548,7 @@ export function parseNostrLink(link: string, prefixHint?: NostrPrefix): NostrLin
|
||||
|
||||
if (isPrefix(NostrPrefix.PublicKey)) {
|
||||
const id = bech32ToHex(entity);
|
||||
if (id.length !== 64) throw new Error("Invalid nostr link, must contain 32 byte id");
|
||||
return {
|
||||
type: NostrPrefix.PublicKey,
|
||||
id: id,
|
||||
@ -546,6 +556,7 @@ export function parseNostrLink(link: string, prefixHint?: NostrPrefix): NostrLin
|
||||
};
|
||||
} else if (isPrefix(NostrPrefix.Note)) {
|
||||
const id = bech32ToHex(entity);
|
||||
if (id.length !== 64) throw new Error("Invalid nostr link, must contain 32 byte id");
|
||||
return {
|
||||
type: NostrPrefix.Note,
|
||||
id: id,
|
||||
@ -563,6 +574,7 @@ export function parseNostrLink(link: string, prefixHint?: NostrPrefix): NostrLin
|
||||
return entity; // return original
|
||||
};
|
||||
if (isPrefix(NostrPrefix.Profile)) {
|
||||
if (id.length !== 64) throw new Error("Invalid nostr link, must contain 32 byte id");
|
||||
return {
|
||||
type: NostrPrefix.Profile,
|
||||
id,
|
||||
@ -572,6 +584,7 @@ export function parseNostrLink(link: string, prefixHint?: NostrPrefix): NostrLin
|
||||
encode,
|
||||
};
|
||||
} else if (isPrefix(NostrPrefix.Event)) {
|
||||
if (id.length !== 64) throw new Error("Invalid nostr link, must contain 32 byte id");
|
||||
return {
|
||||
type: NostrPrefix.Event,
|
||||
id,
|
||||
@ -596,9 +609,8 @@ export function parseNostrLink(link: string, prefixHint?: NostrPrefix): NostrLin
|
||||
id: link,
|
||||
encode: () => hexToBech32(prefixHint, link),
|
||||
};
|
||||
} else {
|
||||
throw new Error("Invalid nostr link");
|
||||
}
|
||||
throw new Error("Invalid nostr link");
|
||||
}
|
||||
|
||||
export function sanitizeRelayUrl(url: string) {
|
@ -1,4 +1,4 @@
|
||||
import { unixNow } from "Util";
|
||||
import { unixNow } from "SnortUtils";
|
||||
|
||||
export enum SubscriptionType {
|
||||
Supporter = 0,
|
||||
|
@ -1,6 +1,6 @@
|
||||
import { EventKind, HexKey, NostrPrefix, RawEvent } from "@snort/nostr";
|
||||
import { HashtagRegex } from "Const";
|
||||
import { getPublicKey, parseNostrLink, unixNow } from "Util";
|
||||
import { getPublicKey, parseNostrLink, unixNow } from "SnortUtils";
|
||||
import { EventExt } from "./EventExt";
|
||||
|
||||
export class EventBuilder {
|
||||
|
@ -2,7 +2,7 @@ import * as secp from "@noble/curves/secp256k1";
|
||||
import * as utils from "@noble/curves/abstract/utils";
|
||||
import { EventKind, HexKey, RawEvent, Tag } from "@snort/nostr";
|
||||
import base64 from "@protobufjs/base64";
|
||||
import { sha256, unixNow } from "Util";
|
||||
import { sha256, unixNow } from "SnortUtils";
|
||||
|
||||
export interface Thread {
|
||||
root?: Tag;
|
||||
|
@ -14,7 +14,7 @@ import {
|
||||
|
||||
import { DefaultRelays } from "Const";
|
||||
import { System } from "System";
|
||||
import { unwrap } from "Util";
|
||||
import { unwrap } from "SnortUtils";
|
||||
import { EventBuilder } from "./EventBuilder";
|
||||
import { EventExt } from "./EventExt";
|
||||
import { barrierQueue, processWorkQueue, WorkQueueItem } from "WorkQueue";
|
||||
|
@ -1,6 +1,6 @@
|
||||
import { RawReqFilter } from "@snort/nostr";
|
||||
import { UserRelays } from "Cache/UserRelayCache";
|
||||
import { unwrap } from "Util";
|
||||
import { unwrap } from "SnortUtils";
|
||||
|
||||
const PickNRelays = 2;
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
import { TaggedRawEvent, u256 } from "@snort/nostr";
|
||||
import { findTag } from "Util";
|
||||
import { findTag } from "SnortUtils";
|
||||
|
||||
export interface StoreSnapshot<TSnapshot> {
|
||||
data: TSnapshot | undefined;
|
||||
|
@ -3,7 +3,7 @@ import { ProfileCacheExpire } from "Const";
|
||||
import { mapEventToProfile, MetadataCache } from "Cache";
|
||||
import { UserCache } from "Cache/UserCache";
|
||||
import { PubkeyReplaceableNoteStore, RequestBuilder, System } from "System";
|
||||
import { unixNowMs } from "Util";
|
||||
import { unixNowMs } from "SnortUtils";
|
||||
|
||||
class ProfileLoaderService {
|
||||
/**
|
||||
|
@ -1,6 +1,6 @@
|
||||
import { v4 as uuid } from "uuid";
|
||||
import { Connection, RawReqFilter, Nips } from "@snort/nostr";
|
||||
import { unixNowMs, unwrap } from "Util";
|
||||
import { unixNowMs, unwrap } from "SnortUtils";
|
||||
import { NoteStore } from "./NoteCollection";
|
||||
/**
|
||||
* Tracing for relay query status
|
||||
|
@ -1,5 +1,5 @@
|
||||
import { RawReqFilter, u256, HexKey, EventKind } from "@snort/nostr";
|
||||
import { appendDedupe } from "Util";
|
||||
import { appendDedupe } from "SnortUtils";
|
||||
|
||||
/**
|
||||
* Which strategy is used when building REQ filters
|
||||
|
@ -1,6 +1,6 @@
|
||||
import { AuthHandler, TaggedRawEvent, RelaySettings, Connection, RawReqFilter, RawEvent } from "@snort/nostr";
|
||||
|
||||
import { sanitizeRelayUrl, unixNowMs, unwrap } from "Util";
|
||||
import { sanitizeRelayUrl, unixNowMs, unwrap } from "SnortUtils";
|
||||
import { RequestBuilder } from "./RequestBuilder";
|
||||
import { EventBuilder } from "./EventBuilder";
|
||||
import {
|
||||
|
@ -2,7 +2,7 @@ import { ReactNode, useSyncExternalStore } from "react";
|
||||
import { v4 as uuid } from "uuid";
|
||||
import ExternalStore from "ExternalStore";
|
||||
import Icon from "Icons/Icon";
|
||||
import { unixNow } from "Util";
|
||||
import { unixNow } from "SnortUtils";
|
||||
|
||||
import "./Toaster.css";
|
||||
|
||||
|
@ -4,7 +4,7 @@ import { VoidApi } from "@void-cat/api";
|
||||
import { FileExtensionRegex, VoidCatHost } from "Const";
|
||||
import { EventPublisher } from "System/EventPublisher";
|
||||
import { UploadResult } from "Upload";
|
||||
import { magnetURIDecode } from "Util";
|
||||
import { magnetURIDecode } from "SnortUtils";
|
||||
|
||||
/**
|
||||
* Upload file to void.cat
|
||||
|
@ -5,7 +5,7 @@ import NostrBuild from "Upload/NostrBuild";
|
||||
import VoidCat from "Upload/VoidCat";
|
||||
import NostrImg from "Upload/NostrImg";
|
||||
import { KieranPubKey } from "Const";
|
||||
import { bech32ToHex } from "Util";
|
||||
import { bech32ToHex } from "SnortUtils";
|
||||
|
||||
export interface UploadResult {
|
||||
url?: string;
|
||||
|
@ -1,5 +1,5 @@
|
||||
import LNC from "@lightninglabs/lnc-web";
|
||||
import { unwrap } from "Util";
|
||||
import { unwrap } from "SnortUtils";
|
||||
import {
|
||||
InvoiceRequest,
|
||||
LNWallet,
|
||||
|
@ -1,7 +1,7 @@
|
||||
import { useEffect, useSyncExternalStore } from "react";
|
||||
|
||||
import ExternalStore from "ExternalStore";
|
||||
import { decodeInvoice, unwrap } from "Util";
|
||||
import { decodeInvoice, unwrap } from "SnortUtils";
|
||||
import LNDHubWallet from "./LNDHub";
|
||||
import { NostrConnectWallet } from "./NostrWalletConnect";
|
||||
import { setupWebLNWalletConfig, WebLNWallet } from "./WebLN";
|
||||
@ -135,7 +135,7 @@ export class WalletStore extends ExternalStore<WalletStoreSnapshot> {
|
||||
this.#instance = new Map();
|
||||
this.load(false);
|
||||
setupWebLNWalletConfig(this);
|
||||
this.snapshotState();
|
||||
this.notifyChange();
|
||||
}
|
||||
|
||||
list() {
|
||||
|
@ -3,7 +3,7 @@ import { getDisplayName } from "Element/ProfileImage";
|
||||
import ExternalStore from "ExternalStore";
|
||||
import { LNURL } from "LNURL";
|
||||
import { Toastore } from "Toaster";
|
||||
import { unixNow } from "Util";
|
||||
import { unixNow } from "SnortUtils";
|
||||
import { LNWallet, WalletInvoiceState, Wallets } from "Wallet";
|
||||
|
||||
export enum ZapPoolRecipientType {
|
||||
|
@ -9,7 +9,7 @@ import { createBrowserRouter, RouterProvider } from "react-router-dom";
|
||||
|
||||
import * as serviceWorkerRegistration from "serviceWorkerRegistration";
|
||||
import { IntlProvider } from "IntlProvider";
|
||||
import { unwrap } from "Util";
|
||||
import { unwrap } from "SnortUtils";
|
||||
import Store from "State/Store";
|
||||
import Layout from "Pages/Layout";
|
||||
import LoginPage from "Pages/LoginPage";
|
||||
|
@ -1,4 +1,3 @@
|
||||
// @ts-expect-error - we have a folder called util so TS gets confused
|
||||
import { TextEncoder, TextDecoder } from "util";
|
||||
|
||||
Object.assign(global, { TextDecoder, TextEncoder });
|
Loading…
x
Reference in New Issue
Block a user