diff --git a/apps/mobile/package.json b/apps/mobile/package.json index 0cbd8467..26b058d7 100644 --- a/apps/mobile/package.json +++ b/apps/mobile/package.json @@ -60,8 +60,8 @@ "metro-react-native-babel-preset": "^0.77.0", "path": "^0.12.7", "pbkdf2": "^3.1.2", - "react": "18.2.0", - "react-dom": "18.2.0", + "react": "18.3.1", + "react-dom": "18.3.1", "react-native": "0.74.3", "react-native-gesture-handler": "2.16.2", "react-native-get-random-values": "^1.11.0", @@ -87,7 +87,7 @@ "@babel/core": "^7.20.0", "@babel/plugin-proposal-export-namespace-from": "^7.18.9", "@types/pbkdf2": "^3.1.2", - "@types/react": "~18.2.79", + "@types/react": "~18.3.1", "@uniswap/eslint-config": "^1.2.0", "eslint": "^8.57.0", "eslint-config-prettier": "^9.1.0", diff --git a/apps/mobile/src/app/Router.tsx b/apps/mobile/src/app/Router.tsx index c79b8b9f..e03141b3 100644 --- a/apps/mobile/src/app/Router.tsx +++ b/apps/mobile/src/app/Router.tsx @@ -20,13 +20,15 @@ import { PostDetail } from '../screens/PostDetail'; import { Profile } from '../screens/Profile'; import { Search } from '../screens/Search'; import { Tips } from '../screens/Tips'; -import { useAuth } from '../store/auth'; +// import { useAuth } from '../store/auth'; +// import { useAuth } from '../store/auth'; import { ThemedStyleSheet } from '../styles'; import { AuthStackParams, HomeBottomStackParams, MainStackParams, RootStackParams } from '../types'; import { retrievePublicKey } from '../utils/storage'; import Sidebar from '../components/Layout/sidebar'; import { Defi } from '../screens/Defi'; import { Games } from '../screens/Games'; +import { useAuth } from 'afk_nostr_sdk'; const RootStack = createNativeStackNavigator(); const AuthStack = createNativeStackNavigator(); diff --git a/apps/mobile/src/app/Wrapper.tsx b/apps/mobile/src/app/Wrapper.tsx index bcc68510..28ffa1b0 100644 --- a/apps/mobile/src/app/Wrapper.tsx +++ b/apps/mobile/src/app/Wrapper.tsx @@ -13,9 +13,9 @@ import { TransactionModalProvider } from '../context/TransactionModal'; import { WalletModalProvider } from '../context/WalletModal'; import App from './App'; import { StarknetProvider } from './StarknetProvider'; -import { NostrProvider } from '../context/NostrContext'; -// import { NostrProvider } from 'afk_nostr_sdk/context/NostrContext'; - +// import { NostrProvider } from '../context/NostrContext'; +import {TanstackProvider} from 'afk_nostr_sdk'; +import {NostrProvider} from 'afk_nostr_sdk'; const queryClient = new QueryClient({ defaultOptions: { queries: { retry: 2 } }, }); @@ -39,26 +39,29 @@ export const Wrapper: React.FC = () => { - {/* */} + + + {/* */} - - - - - - - - - - - - - - - - + {/* */} + + + + + + + + + + + + + + {/* */} + {/* */} + - {/* */} + ); diff --git a/apps/mobile/src/components/BubbleUser/index.tsx b/apps/mobile/src/components/BubbleUser/index.tsx index 6e6ab29e..57baedf8 100644 --- a/apps/mobile/src/components/BubbleUser/index.tsx +++ b/apps/mobile/src/components/BubbleUser/index.tsx @@ -2,10 +2,11 @@ import {NDKEvent, NDKUserProfile} from '@nostr-dev-kit/ndk'; import {useNavigation} from '@react-navigation/native'; import {Image, ImageSourcePropType, Pressable, View} from 'react-native'; -import {useProfile} from '../../hooks'; +// import {useProfile} from '../../hooks'; import {MainStackNavigationProps} from '../../types'; import {Text} from '../Text'; import styles from './styles'; +import {useProfile} from "afk_nostr_sdk" export type StoryProps = { imageProps?: ImageSourcePropType; diff --git a/apps/mobile/src/components/Layout/sidebar/index.tsx b/apps/mobile/src/components/Layout/sidebar/index.tsx index dcc99bb5..a93fed03 100644 --- a/apps/mobile/src/components/Layout/sidebar/index.tsx +++ b/apps/mobile/src/components/Layout/sidebar/index.tsx @@ -5,7 +5,8 @@ import { useStyles, useTheme } from '../../../hooks'; import { Icon } from '../../Icon'; import { useNavigation } from '@react-navigation/native'; import { MainStackNavigationProps } from '../../../types'; -import { useAuth } from '../../../store/auth'; +// import { useAuth } from '../../../store/auth'; +import { useAuth } from 'afk_nostr_sdk'; const Sidebar = () => { const styles = useStyles(stylesheet); diff --git a/apps/mobile/src/hooks/useTips.ts b/apps/mobile/src/hooks/useTips.ts index 11bb320c..c1d17a4e 100644 --- a/apps/mobile/src/hooks/useTips.ts +++ b/apps/mobile/src/hooks/useTips.ts @@ -4,7 +4,8 @@ import {uint256} from 'starknet'; import {ESCROW_ADDRESSES} from '../constants/contracts'; import {CHAIN_ID} from '../constants/env'; import {EventKey} from '../constants/misc'; -import {useAuth} from '../store/auth'; +// import {useAuth} from '../store/auth'; +import { useAuth } from 'afk_nostr_sdk'; import {parseClaimEvent, parseDepositEvent} from '../utils/events'; import {useRpcProvider} from './useRpcProvider'; diff --git a/apps/mobile/src/modules/ChannelCard/Card/ChannelInfo.tsx b/apps/mobile/src/modules/ChannelCard/Card/ChannelInfo.tsx index d1107a81..219cd478 100644 --- a/apps/mobile/src/modules/ChannelCard/Card/ChannelInfo.tsx +++ b/apps/mobile/src/modules/ChannelCard/Card/ChannelInfo.tsx @@ -15,20 +15,23 @@ import Animated, { import {LikeFillIcon, LikeIcon} from '../../../assets/icons'; import {Avatar, Text} from '../../../components'; import { - useProfile, - useReact, - useReactions, - useReplyNotes, useStyles, useTheme, } from '../../../hooks'; import {useTipModal} from '../../../hooks/modals'; -import {useAuth} from '../../../store/auth'; +// import {useAuth} from '../../../store/auth'; +import { useAuth } from 'afk_nostr_sdk'; + import {MainStackNavigationProps} from '../../../types'; import {IChannelsMetadata} from '../../../types/channels'; import {shortenPubkey} from '../../../utils/helpers'; import {getElapsedTimeStringFull} from '../../../utils/timestamp'; import stylesheet from './styles'; +import {useProfile, + useReact, + useReactions, + useReplyNotes, +} from "afk_nostr_sdk" export type PostProps = { asComment?: boolean; diff --git a/apps/mobile/src/modules/ChannelCard/Card/index.tsx b/apps/mobile/src/modules/ChannelCard/Card/index.tsx index ddf51c4d..c757bcba 100644 --- a/apps/mobile/src/modules/ChannelCard/Card/index.tsx +++ b/apps/mobile/src/modules/ChannelCard/Card/index.tsx @@ -14,15 +14,21 @@ import { import {CommentIcon} from '../../../assets/icons'; import {IconButton, Menu, Text} from '../../../components'; -import {useProfile, useReact, useReactions, useStyles, useTheme} from '../../../hooks'; +import {useStyles, useTheme} from '../../../hooks'; import {useTipModal} from '../../../hooks/modals'; -import {useMessagesChannels} from '../../../hooks/nostr/channel/useMessagesChannel'; -import {useAuth} from '../../../store/auth'; +// import {useAuth} from '../../../store/auth'; +import { useAuth } from 'afk_nostr_sdk'; + import {MainStackNavigationProps} from '../../../types'; import {IChannelsMetadata} from '../../../types/channels'; import {ChannelInfo} from './ChannelInfo'; import stylesheet from './styles'; - +import {useProfile, + useReact, + useReactions, + useReplyNotes, + useMessagesChannels +} from "afk_nostr_sdk" export type PostProps = { asComment?: boolean; event?: NDKEvent; diff --git a/apps/mobile/src/modules/ChannelDetailPage/index.tsx b/apps/mobile/src/modules/ChannelDetailPage/index.tsx index 97116cea..b191fbe5 100644 --- a/apps/mobile/src/modules/ChannelDetailPage/index.tsx +++ b/apps/mobile/src/modules/ChannelDetailPage/index.tsx @@ -6,8 +6,7 @@ import {FlatList, RefreshControl, View} from 'react-native'; import {Divider, IconButton, Input, KeyboardFixedView} from '../../components'; import {useNote, useReplyNotes, useStyles, useTheme} from '../../hooks'; import {useToast} from '../../hooks/modals'; -import {useMessagesChannels} from '../../hooks/nostr/channel/useMessagesChannel'; -import {useSendMessageChannel} from '../../hooks/nostr/channel/useSendMessage'; +import {useSendMessageChannel, useMessagesChannels} from 'afk_nostr_sdk' import {IChannelsMetadata} from '../../types/channels'; import {ChannelInfo} from '../ChannelCard/Card/ChannelInfo'; import {Post} from '../Post'; diff --git a/apps/mobile/src/modules/KeyModal/FormInstantiateKey.tsx b/apps/mobile/src/modules/KeyModal/FormInstantiateKey.tsx index 7b96ed4f..ec4742af 100644 --- a/apps/mobile/src/modules/KeyModal/FormInstantiateKey.tsx +++ b/apps/mobile/src/modules/KeyModal/FormInstantiateKey.tsx @@ -10,8 +10,10 @@ import { ESCROW_ADDRESSES, KEYS_ADDRESS } from '../../constants/contracts'; import { CHAIN_ID } from '../../constants/env'; import { DEFAULT_TIMELOCK, Entrypoint } from '../../constants/misc'; import { TOKENS, TokenSymbol } from '../../constants/tokens'; -import { useProfile, useStyles, useWaitConnection } from '../../hooks'; +import { useStyles, useWaitConnection } from '../../hooks'; import { useDataKeys } from '../../hooks/keys/useDataKeys'; +import {useProfile, +} from "afk_nostr_sdk" import { useInstantiateKeys } from '../../hooks/keys/useInstantiateKeys'; import { useTransactionModal } from '../../hooks/modals'; import { useDialog } from '../../hooks/modals/useDialog'; diff --git a/apps/mobile/src/modules/KeyModal/index.tsx b/apps/mobile/src/modules/KeyModal/index.tsx index 29fd9102..ea239101 100644 --- a/apps/mobile/src/modules/KeyModal/index.tsx +++ b/apps/mobile/src/modules/KeyModal/index.tsx @@ -4,7 +4,8 @@ import {forwardRef, useEffect, useState} from 'react'; import {Modalize, Text} from '../../components'; import {TokenSymbol} from '../../constants/tokens'; -import {useProfile, useStyles, useWaitConnection} from '../../hooks'; +import {useStyles, useWaitConnection} from '../../hooks'; +import {useProfile} from "afk_nostr_sdk" import {useDataKeys} from '../../hooks/keys/useDataKeys'; import {useInstantiateKeys} from '../../hooks/keys/useInstantiateKeys'; import {useTransactionModal} from '../../hooks/modals'; diff --git a/apps/mobile/src/modules/LaunchToken/FormLaunchToken.tsx b/apps/mobile/src/modules/LaunchToken/FormLaunchToken.tsx index 06628d70..f3afa51a 100644 --- a/apps/mobile/src/modules/LaunchToken/FormLaunchToken.tsx +++ b/apps/mobile/src/modules/LaunchToken/FormLaunchToken.tsx @@ -5,10 +5,13 @@ import { useRef } from 'react'; import { ScrollView, View } from 'react-native'; import { Button, SquareInput, Text } from '../../components'; -import { useProfile, useStyles, useWaitConnection } from '../../hooks'; +import { useStyles, useWaitConnection } from '../../hooks'; +import {useProfile} from "afk_nostr_sdk" import { useToast, useWalletModal } from '../../hooks/modals'; import stylesheet from '../../screens/CreateChannel/styles'; -import { useAuth } from '../../store/auth'; +// import { useAuth } from '../../store/auth'; +import { useAuth } from 'afk_nostr_sdk'; + import { MainStackNavigationProps } from '../../types'; import { DeployTokenFormValues, useDeployTokenUnruggable } from '../../hooks/unruggable/useDeploy'; import { useAccount } from '@starknet-react/core'; diff --git a/apps/mobile/src/modules/Post/index.tsx b/apps/mobile/src/modules/Post/index.tsx index 184c585b..d0f97f67 100644 --- a/apps/mobile/src/modules/Post/index.tsx +++ b/apps/mobile/src/modules/Post/index.tsx @@ -14,9 +14,12 @@ import Animated, { import { CommentIcon, LikeFillIcon, LikeIcon, RepostIcon } from '../../assets/icons'; import { Avatar, IconButton, Menu, Text } from '../../components'; -import { useProfile, useReact, useReactions, useReplyNotes, useStyles, useTheme } from '../../hooks'; +import { useStyles, useTheme } from '../../hooks'; +import {useProfile, useReact, useReactions, useReplyNotes, } from "afk_nostr_sdk" import { useTipModal } from '../../hooks/modals'; -import { useAuth } from '../../store/auth'; +// import { useAuth } from '../../store/auth'; +import { useAuth } from 'afk_nostr_sdk'; + import { MainStackNavigationProps } from '../../types'; import { getImageRatio, shortenPubkey } from '../../utils/helpers'; import { getElapsedTimeStringFull } from '../../utils/timestamp'; diff --git a/apps/mobile/src/modules/TipModal/index.tsx b/apps/mobile/src/modules/TipModal/index.tsx index a1714a97..81ec159d 100644 --- a/apps/mobile/src/modules/TipModal/index.tsx +++ b/apps/mobile/src/modules/TipModal/index.tsx @@ -9,7 +9,9 @@ import {ESCROW_ADDRESSES} from '../../constants/contracts'; import {CHAIN_ID} from '../../constants/env'; import {DEFAULT_TIMELOCK, Entrypoint} from '../../constants/misc'; import {TOKENS, TokenSymbol} from '../../constants/tokens'; -import {useProfile, useStyles, useWaitConnection} from '../../hooks'; +import { useStyles, useWaitConnection} from '../../hooks'; +import {useProfile} from "afk_nostr_sdk" + import {useTransactionModal} from '../../hooks/modals'; import {useDialog} from '../../hooks/modals/useDialog'; import {useTransaction} from '../../hooks/modals/useTransaction'; diff --git a/apps/mobile/src/modules/UserCard/Card/index.tsx b/apps/mobile/src/modules/UserCard/Card/index.tsx index 2f7870e6..8f19d31c 100644 --- a/apps/mobile/src/modules/UserCard/Card/index.tsx +++ b/apps/mobile/src/modules/UserCard/Card/index.tsx @@ -15,19 +15,22 @@ import Animated, { import {CommentIcon, LikeFillIcon, LikeIcon, RepostIcon} from '../../../assets/icons'; import {Avatar, IconButton, Menu, Text} from '../../../components'; import { - useProfile, - useReact, - useReactions, - useReplyNotes, useStyles, useTheme, } from '../../../hooks'; import {useTipModal} from '../../../hooks/modals'; -import {useAuth} from '../../../store/auth'; +// import {useAuth} from '../../../store/auth'; +import { useAuth } from 'afk_nostr_sdk'; + import {MainStackNavigationProps} from '../../../types'; import {getImageRatio, shortenPubkey} from '../../../utils/helpers'; import {getElapsedTimeStringFull} from '../../../utils/timestamp'; import stylesheet from './styles'; +import {useProfile, + useReact, + useReactions, + useReplyNotes, +} from "afk_nostr_sdk/hooks" export type CardProps = { asComment?: boolean; diff --git a/apps/mobile/src/screens/Auth/CreateAccount.tsx b/apps/mobile/src/screens/Auth/CreateAccount.tsx index 96fc4904..3dbfe73d 100644 --- a/apps/mobile/src/screens/Auth/CreateAccount.tsx +++ b/apps/mobile/src/screens/Auth/CreateAccount.tsx @@ -5,13 +5,13 @@ import {Platform} from 'react-native'; import {LockIcon} from '../../assets/icons'; import {Button, Input, TextButton} from '../../components'; -import {useNostrContext} from '../../context/NostrContext'; import {useTheme} from '../../hooks'; import {useDialog, useToast} from '../../hooks/modals'; import {Auth} from '../../modules/Auth'; import {AuthCreateAccountScreenProps} from '../../types'; import {generateRandomKeypair} from '../../utils/keypair'; import {storePassword, storePrivateKey, storePublicKey} from '../../utils/storage'; +import { useNostrContext } from 'afk_nostr_sdk'; export const CreateAccount: React.FC = ({navigation}) => { const {theme} = useTheme(); diff --git a/apps/mobile/src/screens/Auth/Login.tsx b/apps/mobile/src/screens/Auth/Login.tsx index 6bb5bd45..4d861e0f 100644 --- a/apps/mobile/src/screens/Auth/Login.tsx +++ b/apps/mobile/src/screens/Auth/Login.tsx @@ -7,7 +7,9 @@ import {Button, Input, TextButton} from '../../components'; import {useTheme} from '../../hooks'; import {useDialog, useToast} from '../../hooks/modals'; import {Auth} from '../../modules/Auth'; -import {useAuth} from '../../store/auth'; +// import {useAuth} from '../../store/auth'; +import { useAuth } from 'afk_nostr_sdk'; + import {AuthLoginScreenProps} from '../../types'; import {getPublicKeyFromSecret} from '../../utils/keypair'; import { diff --git a/apps/mobile/src/screens/Auth/SaveKeys.tsx b/apps/mobile/src/screens/Auth/SaveKeys.tsx index ca420754..91c0a667 100644 --- a/apps/mobile/src/screens/Auth/SaveKeys.tsx +++ b/apps/mobile/src/screens/Auth/SaveKeys.tsx @@ -7,7 +7,9 @@ import {Button, Input, Text} from '../../components'; import {useStyles, useTheme} from '../../hooks'; import {useToast} from '../../hooks/modals'; import {Auth} from '../../modules/Auth'; -import {useAuth} from '../../store/auth'; +// import {useAuth} from '../../store/auth'; +import { useAuth } from 'afk_nostr_sdk'; + import {AuthSaveKeysScreenProps} from '../../types'; import stylesheet from './styles'; diff --git a/apps/mobile/src/screens/ChannelsFeed/ChannelsFeedComponent.tsx b/apps/mobile/src/screens/ChannelsFeed/ChannelsFeedComponent.tsx index 00531341..48dec848 100644 --- a/apps/mobile/src/screens/ChannelsFeed/ChannelsFeedComponent.tsx +++ b/apps/mobile/src/screens/ChannelsFeed/ChannelsFeedComponent.tsx @@ -3,8 +3,7 @@ import {FlatList, RefreshControl, View} from 'react-native'; import {BubbleUser} from '../../components/BubbleUser'; import {useRootNotes, useStyles, useTheme} from '../../hooks'; -import {useChannels} from '../../hooks/nostr/channel/useChannels'; -import {useAllProfiles} from '../../hooks/nostr/useAllProfiles'; +import {useAllProfiles, useChannels} from "afk_nostr_sdk" import {ChannelComponent} from '../../modules/ChannelCard'; import {MainStackNavigationProps} from '../../types'; import stylesheet from './styles'; diff --git a/apps/mobile/src/screens/CreateChannel/FormCreateChannel/index.tsx b/apps/mobile/src/screens/CreateChannel/FormCreateChannel/index.tsx index b6303e9e..bbda7ad2 100644 --- a/apps/mobile/src/screens/CreateChannel/FormCreateChannel/index.tsx +++ b/apps/mobile/src/screens/CreateChannel/FormCreateChannel/index.tsx @@ -1,19 +1,24 @@ -import {useQueryClient} from '@tanstack/react-query'; +import { useQueryClient } from '@tanstack/react-query'; import * as Clipboard from 'expo-clipboard'; import * as ImagePicker from 'expo-image-picker'; -import {Formik, FormikProps} from 'formik'; -import {useRef, useState} from 'react'; -import {ScrollView, TouchableOpacity, View} from 'react-native'; - -import {CopyIconStack} from '../../../assets/icons'; -import {Button, SquareInput, Text} from '../../../components'; -import {useProfile, useStyles, useTheme} from '../../../hooks'; -import {useFileUpload} from '../../../hooks/api'; -import {useToast} from '../../../hooks/modals'; -import {useCreateChannel} from '../../../hooks/nostr/channel/useCreateChannel'; -import {useAuth} from '../../../store/auth'; -import {AFK_RELAYS} from '../../../utils/relay'; -import {ChannelHead} from '../Head'; +import { Formik, FormikProps } from 'formik'; +import { useRef, useState } from 'react'; +import { ScrollView, TouchableOpacity, View } from 'react-native'; + +import { CopyIconStack } from '../../../assets/icons'; +import { Button, SquareInput, Text } from '../../../components'; +import { useStyles, useTheme } from '../../../hooks'; +import { useFileUpload } from '../../../hooks/api'; +import { useToast } from '../../../hooks/modals'; +import { + useCreateChannel, + useProfile +} from "afk_nostr_sdk" +// import { useAuth } from '../../../store/auth'; +import { useAuth } from 'afk_nostr_sdk'; + +import { AFK_RELAYS } from '../../../utils/relay'; +import { ChannelHead } from '../Head'; import stylesheet from './styles'; const UsernameInputLeft = ( @@ -35,34 +40,34 @@ type FormValues = { tags: string[][]; picture?: string; relays: string[]; - + }; interface IFormCreateChannel { - showBackButton?:boolean; + showBackButton?: boolean; } -export const FormCreateChannel: React.FC = ({showBackButton}:IFormCreateChannel) => { +export const FormCreateChannel: React.FC = ({ showBackButton }: IFormCreateChannel) => { const formikRef = useRef>(null); - const {theme} = useTheme(); + const { theme } = useTheme(); const styles = useStyles(stylesheet); const [profilePhoto, setProfilePhoto] = useState(); const [coverPhoto, setCoverPhoto] = useState(); const publicKey = useAuth((state) => state.publicKey); - const profile = useProfile({publicKey}); + const profile = useProfile({ publicKey }); const fileUpload = useFileUpload(); const createChannel = useCreateChannel(); const queryClient = useQueryClient(); - const {showToast} = useToast(); + const { showToast } = useToast(); if (profile.isLoading) return null; const onPublicKeyCopyPress = async () => { await Clipboard.setStringAsync(publicKey); - showToast({type: 'info', title: 'Public Key Copied to clipboard'}); + showToast({ type: 'info', title: 'Public Key Copied to clipboard' }); }; const handlePhotoSelect = async (type: 'profile' | 'cover') => { @@ -117,7 +122,7 @@ export const FormCreateChannel: React.FC = ({showBackButton} }; const onFormSubmit = async (values: FormValues) => { - let {image, banner} = values; + let { image, banner } = values; try { if (profilePhoto) { @@ -153,9 +158,9 @@ export const FormCreateChannel: React.FC = ({showBackButton} // queryClient.invalidateQueries({queryKey: ['profile', publicKey]}); - showToast({type: 'success', title: 'Channel created successfully'}); + showToast({ type: 'success', title: 'Channel created successfully' }); } catch (error) { - showToast({type: 'error', title: 'Failed to create Channel'}); + showToast({ type: 'error', title: 'Failed to create Channel' }); } }; @@ -165,12 +170,12 @@ export const FormCreateChannel: React.FC = ({showBackButton} onProfilePhotoUpload={onProfilePhotoUpload} onCoverPhotoUpload={onCoverPhotoUpload} profilePhoto={ - (profilePhoto?.uri ? {uri: profilePhoto.uri} : undefined) || - (profile.data?.image ? {uri: profile.data?.image} : undefined) + (profilePhoto?.uri ? { uri: profilePhoto.uri } : undefined) || + (profile.data?.image ? { uri: profile.data?.image } : undefined) } coverPhoto={ - (coverPhoto?.uri ? {uri: coverPhoto.uri} : undefined) || - (profile.data?.banner ? {uri: profile.data?.banner} : undefined) + (coverPhoto?.uri ? { uri: coverPhoto.uri } : undefined) || + (profile.data?.banner ? { uri: profile.data?.banner } : undefined) } buttons={