Skip to content

Commit

Permalink
Merge branch 'main' into test/balance_claim
Browse files Browse the repository at this point in the history
  • Loading branch information
maciejka authored Jul 2, 2024
2 parents ea33fc9 + e50ee4b commit 9c2a8df
Show file tree
Hide file tree
Showing 40 changed files with 4,061 additions and 3,104 deletions.
4 changes: 2 additions & 2 deletions JoyboyCommunity/src/app/StarknetProvider.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import {sepolia} from '@starknet-react/chains';
import {
argent,
blastProvider,
braavos,
infuraProvider,
StarknetConfig,
useInjectedConnectors,
voyager,
Expand All @@ -29,7 +29,7 @@ export const StarknetReactProvider: React.FC<React.PropsWithChildren> = ({childr

const argentMobileConnector = useArgentMobileConnector();

const providers = blastProvider({apiKey: '798a58fa-a3d6-4e14-869c-a4c3494c10b4'});
const providers = infuraProvider({apiKey: '98f462b6b2644cadae88bdb695e467bf'});
const provider = providers(sepolia);

return (
Expand Down
2 changes: 2 additions & 0 deletions JoyboyCommunity/src/hooks/nostr/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
export {useContacts} from './useContacts';
export {useEditContacts} from './useEditContacts';
export {useEditProfile} from './useEditProfile';
export {useNote} from './useNote';
export {useProfile} from './useProfile';
Expand Down
27 changes: 27 additions & 0 deletions JoyboyCommunity/src/hooks/nostr/useContacts.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import {NDKKind} from '@nostr-dev-kit/ndk';
import {useQuery} from '@tanstack/react-query';

import {useNostrContext} from '../../context/NostrContext';

export type UseContactsOptions = {
authors?: string[];
search?: string;
};

export const useContacts = (options?: UseContactsOptions) => {
const {ndk} = useNostrContext();

return useQuery({
queryKey: ['contacts', options?.authors, options?.search],
queryFn: async () => {
const contacts = await ndk.fetchEvent({
kinds: [NDKKind.Contacts],
authors: options?.authors,
search: options?.search,
});

return contacts.tags.filter((tag) => tag[0] === 'p').map((tag) => tag[1]);
},
placeholderData: [],
});
};
35 changes: 35 additions & 0 deletions JoyboyCommunity/src/hooks/nostr/useEditContacts.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import {NDKEvent, NDKKind} from '@nostr-dev-kit/ndk';
import {useMutation} from '@tanstack/react-query';

import {useNostrContext} from '../../context/NostrContext';
import {useAuth} from '../../store/auth';

export const useEditContacts = () => {
const {ndk} = useNostrContext();
const {publicKey} = useAuth();

return useMutation({
mutationKey: ['editContacts'],
mutationFn: async (data: {pubkey: string; type: 'add' | 'remove'}) => {
let contacts = await ndk.fetchEvent({
kinds: [NDKKind.Contacts],
authors: [publicKey],
});

if (!contacts) {
contacts = new NDKEvent(ndk);
contacts.kind = NDKKind.Contacts;
contacts.content = '';
contacts.tags = [];
}

if (data.type === 'add') {
contacts.tags.push(['p', data.pubkey, '', '']);
} else {
contacts.tags = contacts.tags.filter((tag) => tag[1] !== data.pubkey);
}

return contacts.publish();
},
});
};
31 changes: 26 additions & 5 deletions JoyboyCommunity/src/screens/Profile/Info/index.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import {useNavigation} from '@react-navigation/native';
import {useQueryClient} from '@tanstack/react-query';
import {useState} from 'react';
import {Pressable, View} from 'react-native';

import {UserPlusIcon} from '../../../assets/icons';
import {Button, IconButton, Menu, Text} from '../../../components';
import {useProfile, useStyles, useTheme} from '../../../hooks';
import {useContacts, useEditContacts, useProfile, useStyles, useTheme} from '../../../hooks';
import {useAuth} from '../../../store/auth';
import {ProfileScreenProps} from '../../../types';
import {ProfileHead} from '../Head';
Expand All @@ -25,12 +26,31 @@ export const ProfileInfo: React.FC<ProfileInfoProps> = ({publicKey: userPublicKe
const [menuOpen, setMenuOpen] = useState(false);
const publicKey = useAuth((state) => state.publicKey);

const queryClient = useQueryClient();
const userContacts = useContacts({authors: [userPublicKey]});
const contacts = useContacts({authors: [publicKey]});
const editContacts = useEditContacts();

const isSelf = publicKey === userPublicKey;
const isConnected = contacts.data?.includes(userPublicKey);

const onEditProfilePress = () => {
navigation.navigate('EditProfile');
};

const onConnectionPress = () => {
editContacts.mutateAsync(
{pubkey: publicKey, type: isConnected ? 'remove' : 'add'},
{
onSuccess: () => {
queryClient.invalidateQueries({queryKey: ['contacts']});
userContacts.refetch();
contacts.refetch();
},
},
);
};

return (
<View>
<ProfileHead
Expand Down Expand Up @@ -72,12 +92,13 @@ export const ProfileInfo: React.FC<ProfileInfoProps> = ({publicKey: userPublicKe
<>
<Button
small
variant="secondary"
variant={isConnected ? 'default' : 'secondary'}
left={
<UserPlusIcon width={16} height={16} color="white" style={styles.buttonIcon} />
}
onPress={onConnectionPress}
>
Connect
{isConnected ? 'UnFollow' : 'Follow'}
</Button>

<IconButton icon="DoubleMessageIcon" size={20} style={styles.iconButton} />
Expand Down Expand Up @@ -132,7 +153,7 @@ export const ProfileInfo: React.FC<ProfileInfoProps> = ({publicKey: userPublicKe
{userPublicKey}
</Text>

<IconButton size={16} icon="CopyIcon" color="primary" />
<IconButton size={16} icon="CopyIconStack" color="primary" />
</Pressable>
</View>

Expand All @@ -145,7 +166,7 @@ export const ProfileInfo: React.FC<ProfileInfoProps> = ({publicKey: userPublicKe
<View style={styles.connections}>
<UserPlusIcon width={16} height={16} color={theme.colors.text} />

<Text weight="semiBold">13 Connections</Text>
<Text weight="semiBold">{userContacts.data?.length} Connections</Text>
</View>
</View>
</View>
Expand Down
Empty file removed backend/.gitkeep
Empty file.
4 changes: 4 additions & 0 deletions website/.env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
ACCOUNT_ADDRESS="0x"
ACCOUNT_PRIVATE_KEY="0x"

PROVIDER_URL="https://starknet-sepolia.infura.io/v3/your-infura-api-key"
20 changes: 20 additions & 0 deletions website/.eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
require('@uniswap/eslint-config/load');

module.exports = {
extends: ['next/core-web-vitals', '@uniswap/eslint-config/node'],
overrides: [
{
files: ['*.ts', '*.tsx', '*.js', '*.jsx'],
rules: {
'import/no-unused-modules': 'off',

'prettier/prettier': [
'error',
{
endOfLine: 'auto',
},
],
},
},
],
};
3 changes: 0 additions & 3 deletions website/.eslintrc.json

This file was deleted.

137 changes: 122 additions & 15 deletions website/.gitignore
Original file line number Diff line number Diff line change
@@ -1,26 +1,133 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
lerna-debug.log*
.pnpm-debug.log*

# dependencies
/node_modules
/.pnp
.pnp.js
# Diagnostic reports (https://nodejs.org/api/report.html)
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json

# testing
/coverage
# Runtime data
pids
*.pid
*.seed
*.pid.lock

# production
/build
# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# misc
.DS_Store
.env.local
# Coverage directory used by tools like istanbul
coverage
*.lcov

# nyc test coverage
.nyc_output

# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# Bower dependency directory (https://bower.io/)
bower_components

# node-waf configuration
.lock-wscript

# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release

# Dependency directories
node_modules/
jspm_packages/

# Snowpack dependency directory (https://snowpack.dev/)
web_modules/

# TypeScript cache
*.tsbuildinfo

# Optional npm cache directory
.npm

# Optional eslint cache
.eslintcache

# Optional stylelint cache
.stylelintcache

# Microbundle cache
.rpt2_cache/
.rts2_cache_cjs/
.rts2_cache_es/
.rts2_cache_umd/

# Optional REPL history
.node_repl_history

# Output of 'npm pack'
*.tgz

# Yarn Integrity file
.yarn-integrity

# dotenv environment variable files
.env
.env.development.local
.env.test.local
.env.production.local
.env.local

npm-debug.log*
yarn-debug.log*
yarn-error.log*
# parcel-bundler cache (https://parceljs.org/)
.cache
.parcel-cache

# Next.js build output
.next
out

# Nuxt.js build / generate output
.nuxt
dist

# Gatsby files
.cache/
# Comment in the public line in if your project uses Gatsby and not Next.js
# https://nextjs.org/blog/next-9-1#public-directory-support
# public

# vuepress build output
.vuepress/dist

# vuepress v2.x temp and cache directory
.temp
.cache

# Docusaurus cache and generated files
.docusaurus

# Serverless directories
.serverless/

# FuseBox cache
.fusebox/

# DynamoDB Local files
.dynamodb/

# TernJS port file
.tern-port

# Stores VSCode versions used for testing VSCode extensions
.vscode-test

# yarn v2
.yarn/cache
.yarn/unplugged
.yarn/build-state.yml
.yarn/install-state.gz
.pnp.*

# next
.next
Expand Down
8 changes: 8 additions & 0 deletions website/.prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"bracketSpacing": false,
"singleQuote": true,
"trailingComma": "all",
"printWidth": 100,
"semi": true,
"endOfLine": "lf"
}
Loading

0 comments on commit 9c2a8df

Please sign in to comment.