mirror of
https://github.com/irislib/iris-messenger.git
synced 2024-10-18 06:03:22 +00:00
utils/Hex dir
This commit is contained in:
parent
a7ead39015
commit
91e42f69d3
@ -6,7 +6,7 @@ import { Link, route } from 'preact-router';
|
||||
import InfiniteScroll from '@/components/helpers/InfiniteScroll';
|
||||
import PubSub from '@/nostr/PubSub';
|
||||
import { getEventReplyingTo, getEventRoot } from '@/nostr/utils';
|
||||
import SortedMap from '@/utils/SortedMap';
|
||||
import SortedMap from '@/utils/SortedMap/SortedMap.tsx';
|
||||
|
||||
import Key from '../../../nostr/Key';
|
||||
import { translate as t } from '../../../translations/Translation.mjs';
|
||||
|
@ -9,7 +9,7 @@ import {
|
||||
} from 'nostr-tools';
|
||||
import { route } from 'preact-router';
|
||||
|
||||
import { PublicKey } from '@/utils/Hex.ts';
|
||||
import { PublicKey } from '@/utils/Hex/Hex.ts';
|
||||
|
||||
import localState from '../state/LocalState.ts';
|
||||
import Helpers from '../utils/Helpers';
|
||||
|
@ -4,7 +4,7 @@ import { Event } from 'nostr-tools';
|
||||
|
||||
import Filter from '@/nostr/Filter.ts';
|
||||
import PubSub from '@/nostr/PubSub.ts';
|
||||
import SortedMap from '@/utils/SortedMap.tsx';
|
||||
import SortedMap from '@/utils/SortedMap/SortedMap.tsx';
|
||||
|
||||
interface SubscribeOptions {
|
||||
filter: Filter;
|
||||
|
@ -1,6 +1,6 @@
|
||||
import { describe, expect, it } from 'vitest';
|
||||
|
||||
import { EventID, PublicKey } from '@/utils/Hex';
|
||||
import { EventID, PublicKey } from '@/utils/Hex/Hex.ts';
|
||||
|
||||
describe('PublicKey', () => {
|
||||
it('should convert npub bech32 to hex', () => {
|
||||
@ -54,4 +54,38 @@ describe('EventID', () => {
|
||||
expect(eventId.toHex()).toEqual(noteHex);
|
||||
expect(eventId.toBech32()).toEqual(noteBech32);
|
||||
});
|
||||
|
||||
it('should init from hex', () => {
|
||||
const hex = '7349d97665c15be53bb30655f8d7e6437910533047ee0e7209b22354801aae94';
|
||||
const eventId = new EventID(hex);
|
||||
expect(eventId.toHex()).toEqual(hex);
|
||||
expect(eventId.toBech32()).toEqual(
|
||||
'note1wdyajan9c9d72wanqe2l34lxgdu3q5esglhquusfkg34fqq6462qh4cjd5',
|
||||
);
|
||||
});
|
||||
|
||||
it('should fail with too long hex', () => {
|
||||
const hex =
|
||||
'7349d97665c15be53bb30655f8d7e6437910533047ee0e7209b22354801aae947349d97665c15be53bb30655f8d7e6437910533047ee0e7209b22354801aae94';
|
||||
expect(() => new EventID(hex)).toThrow();
|
||||
});
|
||||
|
||||
it('equals(hexStr)', () => {
|
||||
const hex = '7349d97665c15be53bb30655f8d7e6437910533047ee0e7209b22354801aae94';
|
||||
const eventId = new EventID(hex);
|
||||
expect(eventId.equals(hex)).toEqual(true);
|
||||
});
|
||||
|
||||
it('equals(EventID)', () => {
|
||||
const hex = '7349d97665c15be53bb30655f8d7e6437910533047ee0e7209b22354801aae94';
|
||||
const eventId = new EventID(hex);
|
||||
const eventId2 = new EventID(hex);
|
||||
expect(eventId.equals(eventId2)).toEqual(true);
|
||||
});
|
||||
|
||||
it('equals(bech32)', () => {
|
||||
const bech32 = 'note1wdyajan9c9d72wanqe2l34lxgdu3q5esglhquusfkg34fqq6462qh4cjd5';
|
||||
const eventId = new EventID(bech32);
|
||||
expect(eventId.equals(bech32)).toEqual(true);
|
||||
});
|
||||
});
|
@ -1,6 +1,6 @@
|
||||
import { describe, expect, it } from 'vitest';
|
||||
|
||||
import RBSortedMap from '../../../tests/RBSortedMap.ts';
|
||||
import RBSortedMap from '../../../../tests/RBSortedMap.ts';
|
||||
|
||||
import SortedMap from './SortedMap.tsx';
|
||||
|
@ -1,7 +1,7 @@
|
||||
import { useEffect } from 'preact/hooks';
|
||||
import { route } from 'preact-router';
|
||||
|
||||
import { EventID } from '@/utils/Hex.ts';
|
||||
import { EventID } from '@/utils/Hex/Hex.ts';
|
||||
import View from '@/views/View.tsx';
|
||||
|
||||
import CreateNoteForm from '../components/create/CreateNoteForm';
|
||||
|
@ -5,7 +5,7 @@ import InfiniteScroll from '@/components/helpers/InfiniteScroll';
|
||||
import Key from '../../nostr/Key';
|
||||
import localState from '../../state/LocalState.ts';
|
||||
import { translate as t } from '../../translations/Translation.mjs';
|
||||
import SortedMap from '../../utils/SortedMap';
|
||||
import SortedMap from '../../utils/SortedMap/SortedMap.tsx';
|
||||
|
||||
import ChatListItem from './ChatListItem';
|
||||
import NewChatButton from './NewChatButton';
|
||||
|
@ -14,7 +14,7 @@ import PubSub from '../../nostr/PubSub';
|
||||
import localState from '../../state/LocalState.ts';
|
||||
import { translate as t } from '../../translations/Translation.mjs';
|
||||
import Helpers from '../../utils/Helpers';
|
||||
import SortedMap from '../../utils/SortedMap';
|
||||
import SortedMap from '../../utils/SortedMap/SortedMap.tsx';
|
||||
|
||||
import ChatMessageForm from './ChatMessageForm';
|
||||
import { addGroup, sendSecretInvite } from './NewChat';
|
||||
|
@ -5,7 +5,7 @@ import SimpleImageModal from '@/components/modal/Image.tsx';
|
||||
import { useProfile } from '@/nostr/hooks/useProfile.ts';
|
||||
import { getEventReplyingTo, isRepost } from '@/nostr/utils.ts';
|
||||
import useLocalState from '@/state/useLocalState.ts';
|
||||
import { PublicKey } from '@/utils/Hex.ts';
|
||||
import { PublicKey } from '@/utils/Hex/Hex.ts';
|
||||
import ProfileHelmet from '@/views/profile/Helmet.tsx';
|
||||
|
||||
import Feed from '../../components/feed/Feed.tsx';
|
||||
|
@ -1,7 +1,7 @@
|
||||
import { Event } from 'nostr-tools';
|
||||
import { bench, describe } from 'vitest';
|
||||
|
||||
import SortedMap from '@/utils/SortedMap.tsx';
|
||||
import SortedMap from '@/utils/SortedMap/SortedMap.tsx';
|
||||
|
||||
import events from './events.json';
|
||||
import RBSortedMap from './RBSortedMap.ts';
|
||||
|
Loading…
Reference in New Issue
Block a user