Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix & Feat & Folder & Init #78

Merged
merged 16 commits into from
Aug 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions .all-contributorsrc
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,33 @@
"contributions": [
"code"
]
},
{
"login": "manlikeHB",
"name": "Yusuf Habib",
"avatar_url": "https://avatars.githubusercontent.com/u/109147010?v=4",
"profile": "https://github.com/manlikeHB",
"contributions": [
"code"
]
},
{
"login": "Dprof-in-tech",
"name": "Isaac Onyemaechi Ugwu",
"avatar_url": "https://avatars.githubusercontent.com/u/116242877?v=4",
"profile": "https://isaaconyemaechi.tech/",
"contributions": [
"code"
]
},
{
"login": "EjembiEmmanuel",
"name": "Oche",
"avatar_url": "https://avatars.githubusercontent.com/u/83036156?v=4",
"profile": "https://github.com/EjembiEmmanuel",
"contributions": [
"code"
]
}
],
"contributorsPerLine": 7,
Expand Down
13 changes: 8 additions & 5 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
[submodule "solidity/solidity_contracts/lib/kakarot-lib"]
path = solidity/solidity_contracts/lib/kakarot-lib
url = https://github.com/kkrt-labs/kakarot-lib
[submodule "solidity/solidity_contracts/lib/forge-std"]
path = solidity/solidity_contracts/lib/forge-std
[submodule "onchain/lib/kakarot-rpc"]
path = onchain/lib/kakarot-rpc
url = https://github.com/kkrt-labs/kakarot-rpc
[submodule "onchain/solidity_contracts/lib/forge-std"]
path = onchain/solidity_contracts/lib/forge-std
url = https://github.com/foundry-rs/forge-std
[submodule "onchain/solidity_contracts/lib/kakarot-lib"]
path = onchain/solidity_contracts/lib/kakarot-lib
url = https://github.com/kkrt-labs/kakarot-lib
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,9 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d
</tr>
<tr>
<td align="center" valign="top" width="14.28%"><a href="https://github.com/bhavyagosai"><img src="https://avatars.githubusercontent.com/u/64588227?v=4?s=100" width="100px;" alt="Bhavya Gosai"/><br /><sub><b>Bhavya Gosai</b></sub></a><br /><a href="https://github.com/AFK-AlignedFamKernel/afk_monorepo/commits?author=bhavyagosai" title="Code">💻</a></td>
<td align="center" valign="top" width="14.28%"><a href="https://github.com/manlikeHB"><img src="https://avatars.githubusercontent.com/u/109147010?v=4?s=100" width="100px;" alt="Yusuf Habib"/><br /><sub><b>Yusuf Habib</b></sub></a><br /><a href="https://github.com/AFK-AlignedFamKernel/afk_monorepo/commits?author=manlikeHB" title="Code">💻</a></td>
<td align="center" valign="top" width="14.28%"><a href="https://isaaconyemaechi.tech/"><img src="https://avatars.githubusercontent.com/u/116242877?v=4?s=100" width="100px;" alt="Isaac Onyemaechi Ugwu"/><br /><sub><b>Isaac Onyemaechi Ugwu</b></sub></a><br /><a href="https://github.com/AFK-AlignedFamKernel/afk_monorepo/commits?author=Dprof-in-tech" title="Code">💻</a></td>
<td align="center" valign="top" width="14.28%"><a href="https://github.com/EjembiEmmanuel"><img src="https://avatars.githubusercontent.com/u/83036156?v=4?s=100" width="100px;" alt="Oche"/><br /><sub><b>Oche</b></sub></a><br /><a href="https://github.com/AFK-AlignedFamKernel/afk_monorepo/commits?author=EjembiEmmanuel" title="Code">💻</a></td>
</tr>
</tbody>
<tfoot>
Expand Down
3 changes: 2 additions & 1 deletion apps/indexer/src/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@ export const FACTORY_ADDRESS = '0x01a46467a9246f45c8c340f1f155266a26a71c07bd55d3
export const STARTING_BLOCK = 100_000
export const LAUNCHPAD_ADDRESS = {
// SEPOLIA:"0x74acb6752abb734a7b3388567429217988e02409d9bf43c5586dc2c4f8baf40",
SEPOLIA:"0x29a532e6933a6d6f9939e59469d96b52b7c38561745331302e1a29f035e4dd0"
// SEPOLIA:"0x29a532e6933a6d6f9939e59469d96b52b7c38561745331302e1a29f035e4dd0",
SEPOLIA:"0x3798921000573bfc442d8153fc088db97bd3794f5ed19ea8c0846db5378f4af"
}
7 changes: 5 additions & 2 deletions apps/indexer/src/deploy-token.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,14 @@ export default function DecodeTokenDeploy({ header, events }) {
if (!event.data || !event.keys) return;

const transactionHash = transaction.meta.hash;
const [caller, token_address, name, symbol] = event.keys;
const [caller, token_address,
// name, symbol
] = event.keys;

const [
initial_supply_low, initial_supply_high,
initial_supply_low, initial_supply_high,
total_supply_low, total_supply_high,
symbol, name
] = event.data;

const initial_supply = uint256.uint256ToBN({ low: initial_supply_low, high: initial_supply_high }).toString();
Expand Down
2 changes: 1 addition & 1 deletion apps/indexer/src/token-launch.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export default function DecodeTokenLaunchDeploy({ header, events }) {

const name_decoded = shortString.decodeShortString(name.replace(/0x0+/, '0x'))
const symbol_decoded = shortString.decodeShortString(symbol.replace(/0x0+/, '0x'))
const quote_token_decoded = quote_token ? shortString.decodeShortString(quote_token.replace(/0x0+/, '0x')) : '';
const quote_token_decoded = token_address ? shortString.decodeShortString(token_address.replace(/0x0+/, '0x')) : '';
const exchange_name_decoded = exchange_name ? shortString.decodeShortString(exchange_name.replace(/0x0+/, '0x')) : '';
const price_decoded = price ? shortString.decodeShortString(price.replace(/0x0+/, '0x')) : '';
const liquidity_raised_decoded = liquidity_raised ? uint256.uint256ToBN({ low: liquidity_raised, high: 0 }).toString() : '0';
Expand Down
18 changes: 13 additions & 5 deletions apps/mobile/src/components/Filter/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {

import {useStyles} from '../../hooks';
import stylesheet from './styles';
import { SORT_OPTION_EVENT_NOSTR } from '../../types/nostr';

interface IFilterMenuProps {
visible: boolean;
Expand All @@ -30,10 +31,17 @@ const NDK_KIND_OPTIONS = [
{label: 'Metadata', value: NDKKind.Metadata},
];


// const SORT_OPTIONS = [
// {label: 'Time', value: 'time'},
// {label: 'For You', value: 'forYou'},
// {label: 'Trending', value: 'trending'},
// ];

const SORT_OPTIONS = [
{label: 'Time', value: 'time'},
{label: 'For You', value: 'forYou'},
{label: 'Trending', value: 'trending'},
{label: 'Time', value: SORT_OPTION_EVENT_NOSTR.TIME},
{label: 'For You', value: SORT_OPTION_EVENT_NOSTR.FOR_YOU},
{label: 'Trending', value: SORT_OPTION_EVENT_NOSTR.TRENDING},
];

const FilterMenu: React.FC<IFilterMenuProps> = ({
Expand Down Expand Up @@ -70,8 +78,8 @@ const FilterMenu: React.FC<IFilterMenuProps> = ({
{SORT_OPTIONS.map((option) => (
<Pressable
key={option.value}
style={[styles.button, activeSortBy === option.value && styles.activeButton]}
onPress={() => onSortChange(option.value)}
style={[styles.button, activeSortBy === option.value.toString() && styles.activeButton]}
onPress={() => onSortChange(option.value.toString())}
>
<Text style={styles.buttonText}>{option.label}</Text>
</Pressable>
Expand Down
2 changes: 1 addition & 1 deletion apps/mobile/src/components/Filter/styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export default ThemedStyleSheet((theme) => ({
closeButton: {
paddingVertical: Spacing.small,
paddingHorizontal: Spacing.large,
backgroundColor: theme.colors.primary,
// backgroundColor: theme.colors.primary,
borderRadius: 8,
marginTop: Spacing.small,
},
Expand Down
22 changes: 14 additions & 8 deletions apps/mobile/src/components/search/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,10 @@ interface ISearchComponent {
setSearchQuery: (search: string) => void;
kinds?: NDKKind[];
setKinds?: (kinds: NDKKind[]) => void;
contactList: string[];
contactList?: string[];
setSortBy?: (sort:string) => void;
sortBy?:string;

}

const SearchComponent: React.FC<ISearchComponent> = ({
Expand All @@ -22,14 +25,17 @@ const SearchComponent: React.FC<ISearchComponent> = ({
kinds = [],
setKinds = () => {},
contactList,
sortBy,
setSortBy
}) => {
const styles = useStyles(stylesheet);
const [debouncedQuery, setDebouncedQuery] = useState(searchQuery);
const [isOpenFilter, setIsOpenFilter] = useState(false);
const [activeSortBy, setActiveSortBy] = useState<string>('');
const [activeSortBy, setActiveSortBy] = useState<string>(sortBy ?? "trending");

const handleSortChange = (sortBy: string) => {
setActiveSortBy(sortBy);
setSortBy
};

useEffect(() => {
Expand All @@ -46,12 +52,12 @@ const SearchComponent: React.FC<ISearchComponent> = ({
setDebouncedQuery(text);
};

const {data, isLoading, isError} = useSearch({
search: searchQuery,
kinds,
authors: contactList,
sortBy: activeSortBy,
});
// const {data, isLoading, isError} = useSearch({
// search: searchQuery,
// kinds,
// authors: contactList,
// sortBy: activeSortBy,
// });

return (
<View style={styles.container}>
Expand Down
8 changes: 4 additions & 4 deletions apps/mobile/src/hooks/launchpad/useSellCoin.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {useAccount, useNetwork, useProvider} from '@starknet-react/core';
import {LAUNCHPAD_ADDRESS} from 'common';
import {AccountInterface, CallData, constants, RpcProvider} from 'starknet';
import {AccountInterface, CallData, constants, RpcProvider, uint256} from 'starknet';

import {TokenQuoteBuyKeys} from '../../types/keys';
import {formatFloatToUint256} from '../../utils/format';
Expand All @@ -20,15 +20,15 @@ export const useSellCoin = () => {
contractAddress?: string,
) => {
if (!account) return;
const addressContract = LAUNCHPAD_ADDRESS[constants.StarknetChainId.SN_SEPOLIA];
const addressContract = contractAddress ?? LAUNCHPAD_ADDRESS[constants.StarknetChainId.SN_SEPOLIA];
// console.log('addressContract', addressContract);
// let launchpad_contract = await prepareAndConnectContract(
// provider,
// addressContract,
// account
// );

const amountUint256 = formatFloatToUint256(amount);
let amountUint256 = formatFloatToUint256(amount);
// amountUint256 = uint256.bnToUint256(BigInt('0x' + amount));

const sellKeysParams = {
Expand All @@ -40,7 +40,7 @@ export const useSellCoin = () => {

const call = {
contractAddress: addressContract,
entrypoint: 'sell_keys',
entrypoint: 'sell_coin',
calldata: CallData.compile({
user_address: sellKeysParams.user_address,
amount: sellKeysParams.amount,
Expand Down
79 changes: 47 additions & 32 deletions apps/mobile/src/screens/Feed/index.tsx
Original file line number Diff line number Diff line change
@@ -1,21 +1,22 @@
import {NDKKind} from '@nostr-dev-kit/ndk';
import {useAllProfiles, useSearchNotes} from 'afk_nostr_sdk';
import {useState} from 'react';
import {FlatList, Image, Pressable, RefreshControl, View} from 'react-native';
import { NDKKind } from '@nostr-dev-kit/ndk';
import { useAllProfiles, useContacts, useSearch, useSearchNotes } from 'afk_nostr_sdk';
import { useState } from 'react';
import { ActivityIndicator, FlatList, Image, Pressable, RefreshControl, View } from 'react-native';

import {AddPostIcon} from '../../assets/icons';
import {BubbleUser} from '../../components/BubbleUser';
import { AddPostIcon } from '../../assets/icons';
import { BubbleUser } from '../../components/BubbleUser';
import SearchComponent from '../../components/search';
import {useStyles, useTheme} from '../../hooks';
import {ChannelComponent} from '../../modules/ChannelCard';
import {PostCard} from '../../modules/PostCard';
import {FeedScreenProps} from '../../types';
import { useStyles, useTheme } from '../../hooks';
import { ChannelComponent } from '../../modules/ChannelCard';
import { PostCard } from '../../modules/PostCard';
import { FeedScreenProps } from '../../types';
import stylesheet from './styles';

export const Feed: React.FC<FeedScreenProps> = ({navigation}) => {
const {theme} = useTheme();
export const Feed: React.FC<FeedScreenProps> = ({ navigation }) => {
const { theme } = useTheme();
const styles = useStyles(stylesheet);
const profiles = useAllProfiles();
const [activeSortBy, setSortBy] = useState<string | undefined>()
const [search, setSearch] = useState<string | undefined>(undefined);
const [kinds, setKinds] = useState<NDKKind[]>([
NDKKind.Text,
Expand All @@ -25,21 +26,27 @@ export const Feed: React.FC<FeedScreenProps> = ({navigation}) => {
NDKKind.Metadata,
]);

const notes = useSearchNotes({
const contacts = useContacts()
console.log("contacts", contacts)
const notes = useSearch({
// search: search,
kinds,
// authors: activeSortBy && contacts?.data?.?? [],
// sortBy: activeSortBy,
});


// Filter profiles based on the search query
const profilesSearch =
profiles?.data?.pages
?.flat()
.filter((item) => (search && search?.length > 0 ? item?.content?.includes(search) : true)) ??
[];
// .filter((item) => (search && search?.length > 0 ? item?.content?.includes(search) : true)) ??
?? [];

// Filter notes based on the search query
const filteredNotes = notes.data?.pages
.flat()
.filter((item) => (search && search?.length > 0 ? item?.content?.includes(search) : true));
.filter((item) => (search && search?.length > 0 ? item?.content?.includes(search) : true)) ?? [];

return (
<View style={styles.container}>
Expand All @@ -54,30 +61,38 @@ export const Feed: React.FC<FeedScreenProps> = ({navigation}) => {
searchQuery={search ?? ''}
kinds={kinds}
setKinds={setKinds}
contactList={profilesSearch.map((item) => item?.id)}
setSortBy={setSortBy}
sortBy={activeSortBy}
contactList={contacts?.data?.map((item) => item)}
/>

<FlatList
contentContainerStyle={styles.stories}
horizontal
data={profilesSearch}
showsHorizontalScrollIndicator={false}
onEndReached={() => profiles.fetchNextPage()}
refreshControl={
<RefreshControl refreshing={profiles.isFetching} onRefresh={() => profiles.refetch()} />
}
ItemSeparatorComponent={() => <View style={styles.storySeparator} />}
renderItem={({item}) => <BubbleUser event={item} />}
/>
{notes?.isLoading && <ActivityIndicator></ActivityIndicator>}

<FlatList
ListHeaderComponent={<>
<FlatList
contentContainerStyle={styles.stories}
horizontal
data={profilesSearch}
showsHorizontalScrollIndicator={false}
onEndReached={() => profiles.fetchNextPage()}
refreshControl={
<RefreshControl refreshing={profiles.isFetching} onRefresh={() => profiles.refetch()} />
}
ItemSeparatorComponent={() => <View style={styles.storySeparator} />}
renderItem={({ item }) => <BubbleUser event={item} />}
/></>}
contentContainerStyle={styles.flatListContent}
data={filteredNotes}
keyExtractor={(item) => item?.id}
renderItem={({item}) => {
renderItem={({ item }) => {
if (item.kind === NDKKind.ChannelCreation || item.kind === NDKKind.ChannelMetadata) {
return <ChannelComponent event={item} />;
} else if (item.kind === NDKKind.Text) {
}
else if (item.kind === NDKKind.ChannelMessage) {
return <PostCard event={item} />;
}
else if (item.kind === NDKKind.Text) {
return <PostCard event={item} />;
}
return <></>;
Expand All @@ -90,7 +105,7 @@ export const Feed: React.FC<FeedScreenProps> = ({navigation}) => {

<Pressable
style={styles.createPostButton}
onPress={() => navigation.navigate('MainStack', {screen: 'CreateForm'})}
onPress={() => navigation.navigate('MainStack', { screen: 'CreateForm' })}
>
<AddPostIcon width={72} height={72} color={theme.colors.primary} />
</Pressable>
Expand Down
6 changes: 6 additions & 0 deletions apps/mobile/src/types/nostr.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
export enum SORT_OPTION_EVENT_NOSTR {
TIME,
TRENDING,
FOR_YOU

}
1 change: 1 addition & 0 deletions backend/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.env
8 changes: 8 additions & 0 deletions backend/postgres/awards.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
-- TODO: Allow marking claimed
CREATE TABLE AwardWinners (
address char(64) NOT NULL,
amount int NOT NULL,
type text NOT NULL
);
CREATE INDEX address ON AwardWinners (address);
CREATE INDEX type ON AwardWinners (type);
Loading
Loading