Skip to content

Commit

Permalink
Merge branch 'main' into indexer-hotfix
Browse files Browse the repository at this point in the history
  • Loading branch information
EjembiEmmanuel authored Oct 6, 2024
2 parents 10b7001 + 685cd12 commit 3f5e1d8
Show file tree
Hide file tree
Showing 21 changed files with 471 additions and 292 deletions.
13 changes: 0 additions & 13 deletions .vscode/launch.json

This file was deleted.

21 changes: 10 additions & 11 deletions apps/data-backend/src/routes/indexer/deploy-launch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ async function deployLaunchRoute(
return;
}

const launches = await prisma.token_launch.findMany({
const launchPool= await prisma.token_launch.findFirst({
where: {
memecoin_address: launch
},
Expand All @@ -65,7 +65,7 @@ async function deployLaunchRoute(
});

reply.status(HTTPStatus.OK).send({
data: launches
data: launchPool
});
} catch (error) {
console.error("Error deploying launch:", error);
Expand All @@ -88,7 +88,10 @@ async function deployLaunchRoute(
return;
}

const launches = await prisma.token_launch.findMany({
const launchStats = await prisma.token_launch.findFirst({
where:{
memecoin_address:launch,
},
select: {
memecoin_address: true,
quote_token: true,
Expand All @@ -100,16 +103,12 @@ async function deployLaunchRoute(
}
});

if (launches.length) {
let statsLaunch = launches[0];

reply.status(HTTPStatus.OK).send({
data: statsLaunch
});
}
reply.status(HTTPStatus.OK).send({
data: launchStats
});

reply.status(HTTPStatus.OK).send({
data: []
data: undefined
});
} catch (error) {
console.error("Error deploying launch:", error);
Expand Down
8 changes: 7 additions & 1 deletion apps/data-backend/src/routes/indexer/token_stats.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,13 @@ async function tokenStatsRoute(
orderBy: { created_at: "desc" },
select: {
price: true,
liquidity_raised: true
liquidity_raised: true,
coin_received:true,
total_supply:true,
network:true,
last_price:true,
amount:true,
quote_amount:true
}
});

Expand Down
3 changes: 2 additions & 1 deletion apps/data-backend/src/routes/indexer/transactions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ async function transactionsRoute(
select: {
transaction_type: true,
amount: true,
quote_amount: true
quote_amount: true,
price:true
}
});

Expand Down
2 changes: 2 additions & 0 deletions apps/indexer/init.sql
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
create table token_launch(
memecoin_address TEXT,
owner_address TEXT,
network TEXT,
block_hash TEXT,
block_number BIGINT,
Expand All @@ -11,6 +12,7 @@ create table token_launch(
total_supply TEXT,
current_supply TEXT,
liquidity_raised TEXT,
threshold_liquidity TEXT,
price TEXT,
_cursor BIGINT,
time_stamp TEXT
Expand Down
3 changes: 2 additions & 1 deletion apps/indexer/src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@ export const STARTING_BLOCK = 140_000;
export const LAUNCHPAD_ADDRESS = {
// SEPOLIA:"0x74acb6752abb734a7b3388567429217988e02409d9bf43c5586dc2c4f8baf40",
// SEPOLIA:"0x29a532e6933a6d6f9939e59469d96b52b7c38561745331302e1a29f035e4dd0",
SEPOLIA: "0x3798921000573bfc442d8153fc088db97bd3794f5ed19ea8c0846db5378f4af"
// SEPOLIA: "0x3798921000573bfc442d8153fc088db97bd3794f5ed19ea8c0846db5378f4af",
SEPOLIA:"0x595d9c14d5b52bae1bd5a88f3aefb521eca956fde4de95e400197f1080fa862"
};
8 changes: 6 additions & 2 deletions apps/indexer/src/token-launch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ export default function DecodeTokenLaunchDeploy({ header, events }: Block) {

const transactionHash = transaction.meta.hash;

const [token_address, _caller] = event.keys!;
const [caller, token_address, quote_token_address] = event.keys!;

const [
amount_low,
amount_high,
Expand Down Expand Up @@ -89,6 +90,8 @@ export default function DecodeTokenLaunchDeploy({ header, events }: Block) {
const _threshold_liquidity = formatUnits(threshold_liquidity_raw, DECIMALS);

return {
owner_address:caller,
quote_token:quote_token_address,
memecoin_address: token_address,
network: "starknet-sepolia",
block_hash: blockHash,
Expand All @@ -97,7 +100,8 @@ export default function DecodeTokenLaunchDeploy({ header, events }: Block) {
transaction_hash: transactionHash,
total_supply,
price,
created_at: new Date().toISOString()
created_at: new Date().toISOString(),
threshold_liquidity:_threshold_liquidity
};
});
}
21 changes: 18 additions & 3 deletions apps/mobile/src/app/Router.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -236,9 +236,11 @@ const MainNavigator: React.FC = () => {
<View style={{ flex: 1 }}>
<Feed navigation={useNavigation()} route={useRoute()} />
</View>
<View style={{ width: 250, backgroundColor: theme.theme.colors.surface }}>
<RightSidebar />
</View>
{isDesktop &&
<View style={{ width: 250, backgroundColor: theme.theme.colors.surface }}>
<RightSidebar />
</View>
}
</View>
);

Expand Down Expand Up @@ -346,6 +348,19 @@ const linking = {
MainStack: {
path: 'app',
screens: {
AuthStack: {
path: 'auth',
screens: {
Login: 'login',
CreateAccount: 'create-account',
SaveKeys: 'save-keys',
ImportKeys: 'import-keys',
},
},
Login: 'login',
CreateAccount: 'create-account',
SaveKeys: 'save-keys',
ImportKeys: 'import-keys',
Home: 'home',
Feed: 'feed',
Profile: {
Expand Down
26 changes: 14 additions & 12 deletions apps/mobile/src/components/LaunchPad/TokenStats/index.tsx
Original file line number Diff line number Diff line change
@@ -1,31 +1,33 @@
import {FlatList, View} from 'react-native';
import {useStyles} from '../../../hooks';
import {TokenStatsInterface} from '../../../types/keys';
import {Text} from '../../Text';
import { FlatList, View } from 'react-native';
import { useStyles } from '../../../hooks';
import { TokenStatsInterface } from '../../../types/keys';
import { Text } from '../../Text';
import stylesheet from './styles';
import {Fraction} from '@uniswap/sdk-core';
import {decimalsScale} from '../../../utils/helpers';
import { Fraction } from '@uniswap/sdk-core';
import { decimalsScale } from '../../../utils/helpers';
import Loading from '../../Loading';

export type TokenStatsProps = {
loading: boolean;
stats?: TokenStatsInterface;
};

export const TokenStats: React.FC<TokenStatsProps> = ({stats, loading}) => {
export const TokenStats: React.FC<TokenStatsProps> = ({ stats, loading }) => {
const styles = useStyles(stylesheet);

if (!stats && loading) {
return <Loading />;
}

const {price, liquidity_raised} = stats || {};
const { price, liquidity_raised } = stats || {};

const lastPrice = price ? new Fraction(String(price), decimalsScale(18)).toFixed(18) : '0';
const liquidityRaised = liquidity_raised
? new Fraction(String(liquidity_raised), decimalsScale(18)).toFixed(18)
: '0';
// const lastPrice = price ? new Fraction(String(price), decimalsScale(18)).toFixed(18) : '0';
const lastPrice = price;
// const liquidityRaised = liquidity_raised
// ? new Fraction(String(liquidity_raised), decimalsScale(18)).toFixed(18)
// : '0';

const liquidityRaised = liquidity_raised;
return (
<View style={styles.card}>
<Text style={styles.title}>Token Statistics</Text>
Expand Down
6 changes: 3 additions & 3 deletions apps/mobile/src/components/LaunchPad/TokenStats/styles.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {Spacing, ThemedStyleSheet} from '../../../styles';
export default ThemedStyleSheet((theme) => ({
card: {
backgroundColor: '#fff',
backgroundColor: theme.colors.background,
borderRadius: 8,
padding: 16,
margin: 16,
Expand All @@ -24,11 +24,11 @@ export default ThemedStyleSheet((theme) => ({
},
label: {
fontSize: 14,
color: '#555',
color: theme.colors.text,
},
value: {
fontSize: 14,
fontWeight: 'bold',
color: '#333',
color: theme.colors.text,
},
}));
102 changes: 81 additions & 21 deletions apps/mobile/src/components/LaunchPad/UserShare/index.tsx
Original file line number Diff line number Diff line change
@@ -1,48 +1,108 @@
import { FlatList, View } from 'react-native';
import { FlatList, Pressable, View } from 'react-native';

import { useStyles } from '../../../hooks';
import { UserShareInterface } from '../../../types/keys';
import { useStyles, useWaitConnection } from '../../../hooks';
import { TokenStatsInterface, UserShareInterface } from '../../../types/keys';
import { Text } from '../../Text';
import stylesheet from './styles';
import Loading from '../../Loading';
import { useGetShares } from '../../../hooks/api/indexer/useUserShare';
import { useAccount } from 'wagmi';
import { useEffect, useState } from 'react';
import { useWalletModal } from '../../../hooks/modals';

export type UserShareProps = {
loading: boolean;
coinAddress: string;
shares?: UserShareInterface[];
};

export const UserShare: React.FC<UserShareProps> = ({ shares, loading }) => {
export const UserShare: React.FC<UserShareProps> = ({ shares, loading, coinAddress }) => {
const styles = useStyles(stylesheet);
const [stats, setStats] = useState<TokenStatsInterface | undefined>();
const [sharesState, setShares] = useState<UserShareInterface | undefined>();

return loading ? (
<Loading />
) : (
<FlatList
data={shares}
keyExtractor={(item, index) => index.toString()}
renderItem={({ item }) => (
const account = useAccount()
const { data: sharesData, isLoading: sharesLoading, refetch } = useGetShares(coinAddress, account?.address ?? "");

const waitConnection = useWaitConnection();
const walletModal = useWalletModal();
const onConnect = async () => {
if (!account.address) {
walletModal.show();

const result = await waitConnection();
if (!result) return;
}
};
console.log("sharesData", sharesData)
useEffect(() => {
const data = sharesData || [];
setStats(data);
setShares(sharesData)
}, [sharesData]);

// return loading ? (
// <Loading />
// )
return (



<>

{sharesLoading && <Loading></Loading>}

{account && !account?.address &&
<View>

<Pressable onPress={() => {
onConnect()
}}>
<Text>Connect</Text>
</Pressable>
</View>
}
{sharesState &&
<View style={[styles.container, styles.borderBottom]}>


<View style={styles.borderBottom}>
<Text fontSize={14} weight="semiBold">
Memecoin Address
Total
</Text>
<Text fontSize={14}>{item.token_address}</Text>
<Text fontSize={14}>{Number(sharesState?.total_buy) - Number(sharesState?.total_sell)}</Text>
</View>

<View style={styles.borderBottom}>
<Text fontSize={14} weight="semiBold">
Coin Recieved
Total sell
</Text>
<Text fontSize={14}>{Number(item.total_supply)}</Text>
<Text fontSize={14}>{sharesState?.total_sell}</Text>
</View>
<View style={styles.borderBottom}>
<Text fontSize={14} weight="semiBold">
Quote amount paid
</Text>
<Text fontSize={14}>{sharesState?.quote_amount}</Text>
</View>


</View>
)}
ListEmptyComponent={<View style={{ paddingTop: 40 }}>
<Text style={{ textAlign: 'center' }}>No user share available</Text>
</View>

}
/>

{/* <FlatList
data={stats}
keyExtractor={(item, index) => index.toString()}
renderItem={({ item }) => (
)}
ListEmptyComponent={<View style={{ paddingTop: 40 }}>
<Text style={{ textAlign: 'center' }}>No user share available</Text>
</View>
}
/> */}
</>


);
};
Loading

0 comments on commit 3f5e1d8

Please sign in to comment.