Skip to content

Commit

Permalink
Building sunday (#419)
Browse files Browse the repository at this point in the history
* new schema + fix launch + add new  attribs + start new event

* add register token ekubo

* default address pixel

* add register token in unrug ekubo but with 1 token unsused/burn

* fmt

* fix where find claim share

* id share user

* fix form create and buy

* add new data in endpoint routes indexer

* add new data and ui if needed with threshold + bonding etc
  • Loading branch information
MSghais authored Jan 6, 2025
1 parent 5e93d8e commit a8bac5f
Show file tree
Hide file tree
Showing 20 changed files with 446 additions and 80 deletions.
9 changes: 9 additions & 0 deletions apps/data-backend/src/routes/indexer/deploy-launch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ async function deployLaunchRoute(fastify: FastifyInstance, options: RouteOptions
liquidity_raised: true,
network: true,
created_at: true,
threshold_liquidity:true,
bonding_type:true,
total_token_holded:true,
},
});

Expand Down Expand Up @@ -59,6 +62,9 @@ async function deployLaunchRoute(fastify: FastifyInstance, options: RouteOptions
liquidity_raised: true,
network: true,
created_at: true,
threshold_liquidity:true,
bonding_type:true,
total_token_holded:true,
},
});

Expand Down Expand Up @@ -96,6 +102,9 @@ async function deployLaunchRoute(fastify: FastifyInstance, options: RouteOptions
liquidity_raised: true,
network: true,
created_at: true,
threshold_liquidity:true,
bonding_type:true,
total_token_holded:true,
},
});

Expand Down
5 changes: 4 additions & 1 deletion apps/mobile/src/components/LaunchActionsForm/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -106,11 +106,14 @@ export const LaunchActionsForm: React.FC<LaunchActionsFormProps> = ({
<Input
// keyboardType="decimal-pad"
keyboardType="numeric"
inputMode="numeric"
// keyboardType="numeric"
// keyboardType=""
style={styles.input}
onChangeText={(e) => onChangeText(numericValue(e))}
placeholder="Amount"
value={Number(amount?.toString())}
// value={Number(amount?.toString())}
value={amount?.toString()}
// value={typeAction === 'BUY' ? amount?.toString() : userShare?.amount_owned?.toString()}
/>

Expand Down
153 changes: 104 additions & 49 deletions apps/mobile/src/components/pump/TokenLaunchDetail/index.tsx
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
import {NDKEvent, NDKUserProfile} from '@nostr-dev-kit/ndk';
import {useNavigation} from '@react-navigation/native';
import {useAccount} from '@starknet-react/core';
import {useProfile} from 'afk_nostr_sdk';
import {useState} from 'react';
import {ImageSourcePropType, View} from 'react-native';

import {useStyles, useWaitConnection} from '../../../hooks';
import {useBuyCoinByQuoteAmount} from '../../../hooks/launchpad/useBuyCoinByQuoteAmount';
import {useSellCoin} from '../../../hooks/launchpad/useSellCoin';
import {useToast, useWalletModal} from '../../../hooks/modals';
import {MainStackNavigationProps} from '../../../types';
import {TokenDeployInterface} from '../../../types/keys';
import {feltToAddress} from '../../../utils/format';
import {AddressComponent} from '../../AddressComponent';
import {Button} from '../../Button';
import {LaunchActionsForm} from '../../LaunchActionsForm';
import {Text} from '../../Text';
import { NDKEvent, NDKUserProfile } from '@nostr-dev-kit/ndk';
import { useNavigation } from '@react-navigation/native';
import { useAccount } from '@starknet-react/core';
import { useProfile } from 'afk_nostr_sdk';
import { useState } from 'react';
import { ImageSourcePropType, View } from 'react-native';

import { useStyles, useWaitConnection } from '../../../hooks';
import { useBuyCoinByQuoteAmount } from '../../../hooks/launchpad/useBuyCoinByQuoteAmount';
import { useSellCoin } from '../../../hooks/launchpad/useSellCoin';
import { useToast, useWalletModal } from '../../../hooks/modals';
import { MainStackNavigationProps } from '../../../types';
import { TokenDeployInterface } from '../../../types/keys';
import { feltToAddress } from '../../../utils/format';
import { AddressComponent } from '../../AddressComponent';
import { Button } from '../../Button';
import { LaunchActionsForm } from '../../LaunchActionsForm';
import { Text } from '../../Text';
import stylesheet from './styles';

export type LaunchCoinProps = {
Expand All @@ -39,7 +39,7 @@ export const TokenLaunchDetail: React.FC<LaunchCoinProps> = ({
isDisabledInfo,
isDisabledForm,
}) => {
const {data: profile} = useProfile({publicKey: event?.pubkey});
const { data: profile } = useProfile({ publicKey: event?.pubkey });
const account = useAccount();
const [amount, setAmount] = useState<number | undefined>();
console.log('launch', launch);
Expand All @@ -49,10 +49,10 @@ export const TokenLaunchDetail: React.FC<LaunchCoinProps> = ({
);
const styles = useStyles(stylesheet);

const {showToast} = useToast();
const {handleSellCoins} = useSellCoin();
const { showToast } = useToast();
const { handleSellCoins } = useSellCoin();
// const { handleBuyKeys } = useBuyKeys()
const {handleBuyCoins} = useBuyCoinByQuoteAmount();
const { handleBuyCoins } = useBuyCoinByQuoteAmount();
const waitConnection = useWaitConnection();
const walletModal = useWalletModal();
const onConnect = async () => {
Expand Down Expand Up @@ -117,7 +117,7 @@ export const TokenLaunchDetail: React.FC<LaunchCoinProps> = ({

const sellKeys = async () => {
if (!amount) {
return showToast({title: 'Select an amount to buy', type: 'info'});
return showToast({ title: 'Select an amount to buy', type: 'info' });
}
await onConnect();
if (!account || !account?.account) return;
Expand All @@ -137,14 +137,14 @@ export const TokenLaunchDetail: React.FC<LaunchCoinProps> = ({
);

if (sellResult) {
return showToast({title: 'Buy done', type: 'success'});
return showToast({ title: 'Buy done', type: 'success' });
}
};

const buyCoin = async () => {
await onConnect();
if (!amount) {
return showToast({title: 'Select an amount to buy', type: 'info'});
return showToast({ title: 'Select an amount to buy', type: 'info' });
}

if (!account || !account?.account) return;
Expand All @@ -162,7 +162,7 @@ export const TokenLaunchDetail: React.FC<LaunchCoinProps> = ({
launch?.quote_token,
);

return showToast({title: 'Buy done', type: 'success'});
return showToast({ title: 'Buy done', type: 'success' });
};

return (
Expand Down Expand Up @@ -198,13 +198,89 @@ export const TokenLaunchDetail: React.FC<LaunchCoinProps> = ({

<View style={styles.divider} />

{launch?.is_liquidity_launch && (
<View style={styles.detailRow}>
<Text style={styles.label}>Is launched in DEX</Text>
<Text style={styles.value}>
{Number(launch?.is_liquidity_launch).toLocaleString()}
</Text>
</View>
)}



{launch?.threshold_liquidity && (
<View style={styles.detailRow}>
<Text style={styles.label}>Threshold liquidity</Text>
<Text style={styles.value}>
{Number(launch?.threshold_liquidity).toLocaleString()}
</Text>
</View>
)}

{launch?.liquidity_raised && (
<View style={styles.detailRow}>
<Text style={styles.label}>Raised</Text>
<Text style={styles.value}>{Number(launch?.liquidity_raised).toLocaleString()}</Text>
</View>
)}

{launch?.liquidity_raised && launch?.threshold_liquidity &&
<View>
<View style={styles.detailRow}>
<Text style={styles.label}>Raised Progress</Text>
<Text style={styles.value}>
{Number(launch?.liquidity_raised).toLocaleString()} / {Number(launch?.threshold_liquidity).toLocaleString()}
</Text>
</View>
<View style={styles.progressBarContainer}>
<View
style={[
styles.progressBarFill,
{
width: `${Math.min((Number(launch?.liquidity_raised) / Number(launch?.threshold_liquidity)) * 100, 100)}%`,
}
]}
/>
</View>
<Text style={styles.progressText}>
{((Number(launch?.liquidity_raised) / Number(launch?.threshold_liquidity)) * 100).toFixed(1)}% Complete
</Text>
</View>
}

{launch?.bonding_type && (
<View style={styles.detailRow}>
<Text style={styles.label}>Bonding type</Text>
<Text style={styles.value}>{launch?.bonding_type}</Text>
</View>
)}

{launch?.total_token_holded && (
<View style={styles.detailRow}>
<Text style={styles.label}>Total token holded</Text>
<Text style={styles.value}>{Number(launch?.total_token_holded).toLocaleString()}</Text>
</View>
)}

<View style={styles.detailRow}>
<Text style={styles.label}>Price</Text>
<Text style={styles.value}>${Number(launch?.price ?? 0).toFixed(4)}</Text>
</View>

{launch?.quote_token && (
<View style={styles.detailRow}>
<Text style={styles.label}>Quote token</Text>
<AddressComponent
address={launch?.quote_token || ''}
textStyle={styles.addressValue}
/>
</View>
)}

</View>

<Button
{/* <Button
style={styles.toggleButton}
textStyle={styles.toggleText}
onPress={() => setIsDisabledInfoState(!isDisabledInfoState)}
Expand All @@ -215,7 +291,6 @@ export const TokenLaunchDetail: React.FC<LaunchCoinProps> = ({
{!isDisabledInfoState && (
<View style={styles.detailCard}>
<Text style={styles.sectionTitle}>Additional Details</Text>

{launch?.threshold_liquidity && (
<View style={styles.detailRow}>
<Text style={styles.label}>Threshold liquidity</Text>
Expand All @@ -231,26 +306,6 @@ export const TokenLaunchDetail: React.FC<LaunchCoinProps> = ({
<Text style={styles.value}>{Number(launch?.liquidity_raised).toLocaleString()}</Text>
</View>
)}

{launch?.is_liquidity_launch && (
<View style={styles.detailRow}>
<Text style={styles.label}>Is launched in DEX</Text>
<Text style={styles.value}>
{Number(launch?.is_liquidity_launch).toLocaleString()}
</Text>
</View>
)}

{launch?.quote_token && (
<View style={styles.detailRow}>
<Text style={styles.label}>Quote token</Text>
<AddressComponent
address={launch?.quote_token || ''}
textStyle={styles.addressValue}
/>
</View>
)}

{launch?.token_quote && (
<View style={styles.detailRow}>
<Text style={styles.label}>Token quote</Text>
Expand All @@ -261,7 +316,7 @@ export const TokenLaunchDetail: React.FC<LaunchCoinProps> = ({
</View>
)}
</View>
)}
)} */}

{!isDisabledForm && (
<LaunchActionsForm
Expand Down
23 changes: 23 additions & 0 deletions apps/mobile/src/components/pump/TokenLaunchDetail/styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,4 +61,27 @@ export default ThemedStyleSheet((theme) => ({
color: theme.colors.text,
marginBottom: Spacing.small,
},
progressBarContainer: {
width: '100%',
height: 8,
// backgroundColor: '#E5E7EB', // Light gray background
backgroundColor: theme?.colors?.primary, // Light gray background
borderRadius: 4,
marginVertical: 8,
overflow: 'hidden',
},

progressBarFill: {
height: '100%',
backgroundColor: theme?.colors?.primary, // Light gray background
// backgroundColor: '#10B981', // Green color for the fill
borderRadius: 4,
},

progressText: {
fontSize: 12,
color: theme?.colors?.text, // Light gray background
textAlign: 'center',
marginTop: 4,
},
}));
9 changes: 5 additions & 4 deletions apps/mobile/src/modules/LaunchTokenPump/FormLaunchToken.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -181,10 +181,11 @@ export const FormLaunchToken: React.FC<FormTokenCreatedProps> = () => {
<TextInput
// type="number"
value={values.initialSupply?.toString()}

onChangeText={(text) => {
handleChange('initialSupply')(numericValue(text));
}}
onChangeText={handleChange('initialSupply')}
// onChangeText={(text) => {
// handleChange('initialSupply');
// // handleChange('initialSupply')(numericValue(text));
// }}
onBlur={handleBlur('initialSupply')}
placeholder="100000"
inputMode="numeric"
Expand Down
Loading

0 comments on commit a8bac5f

Please sign in to comment.