Skip to content

Commit

Permalink
add hooks + context + store of the package
Browse files Browse the repository at this point in the history
  • Loading branch information
MSghais committed Aug 9, 2024
1 parent aca9300 commit c53dd8c
Show file tree
Hide file tree
Showing 62 changed files with 182 additions and 853 deletions.
6 changes: 3 additions & 3 deletions apps/mobile/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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",
Expand Down
4 changes: 3 additions & 1 deletion apps/mobile/src/app/Router.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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<RootStackParams>();
const AuthStack = createNativeStackNavigator<AuthStackParams>();
Expand Down
45 changes: 24 additions & 21 deletions apps/mobile/src/app/Wrapper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 } },
});
Expand All @@ -39,26 +39,29 @@ export const Wrapper: React.FC = () => {
<GestureHandlerRootView style={{ flex: 1 }}>
<ThemeProvider>
<NostrProvider>
{/* <NostrProvider> */}
<TanstackProvider>

{/* <NostrProvider> */}

<QueryClientProvider client={queryClient}>
<SafeAreaProvider>
<RootScreenContainer>
<PortalizeProvider>
<DialogProvider>
<StarknetProvider>
<ModalProviders>
<App />
</ModalProviders>
</StarknetProvider>
</DialogProvider>
</PortalizeProvider>
</RootScreenContainer>
</SafeAreaProvider>
</QueryClientProvider>
</NostrProvider>
{/* <QueryClientProvider client={queryClient}> */}
<SafeAreaProvider>
<RootScreenContainer>
<PortalizeProvider>
<DialogProvider>
<StarknetProvider>
<ModalProviders>
<App />
</ModalProviders>
</StarknetProvider>
</DialogProvider>
</PortalizeProvider>
</RootScreenContainer>
</SafeAreaProvider>
{/* </QueryClientProvider> */}
{/* </NostrProvider> */}
</TanstackProvider>

{/* </NostrProvider> */}
</NostrProvider>
</ThemeProvider>
</GestureHandlerRootView>
);
Expand Down
3 changes: 2 additions & 1 deletion apps/mobile/src/components/BubbleUser/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
3 changes: 2 additions & 1 deletion apps/mobile/src/components/Layout/sidebar/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
3 changes: 2 additions & 1 deletion apps/mobile/src/hooks/useTips.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down
13 changes: 8 additions & 5 deletions apps/mobile/src/modules/ChannelCard/Card/ChannelInfo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
14 changes: 10 additions & 4 deletions apps/mobile/src/modules/ChannelCard/Card/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
3 changes: 1 addition & 2 deletions apps/mobile/src/modules/ChannelDetailPage/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
4 changes: 3 additions & 1 deletion apps/mobile/src/modules/KeyModal/FormInstantiateKey.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
3 changes: 2 additions & 1 deletion apps/mobile/src/modules/KeyModal/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
7 changes: 5 additions & 2 deletions apps/mobile/src/modules/LaunchToken/FormLaunchToken.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
7 changes: 5 additions & 2 deletions apps/mobile/src/modules/Post/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
4 changes: 3 additions & 1 deletion apps/mobile/src/modules/TipModal/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
13 changes: 8 additions & 5 deletions apps/mobile/src/modules/UserCard/Card/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion apps/mobile/src/screens/Auth/CreateAccount.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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<AuthCreateAccountScreenProps> = ({navigation}) => {
const {theme} = useTheme();
Expand Down
4 changes: 3 additions & 1 deletion apps/mobile/src/screens/Auth/Login.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
4 changes: 3 additions & 1 deletion apps/mobile/src/screens/Auth/SaveKeys.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
Loading

0 comments on commit c53dd8c

Please sign in to comment.