├── app ├── walletModal.css ├── globals.css ├── page.tsx ├── packages.tsx ├── layout.tsx └── providers.tsx ├── public ├── favicon.ico ├── package_1.png ├── package_2.png ├── package_3.png ├── package_4.png ├── package_5.png ├── package_6.png ├── package_7.png ├── package_8.png ├── images │ ├── sliderIcon.3.png │ ├── sliderIcon.4.png │ ├── sliderHomeIcon.png │ ├── sliderIcon.2png.png │ ├── sms-notification.png │ └── notification-bing.png ├── fonts │ └── Px437_Acer710_Mono.ttf ├── styles │ └── fonts.css ├── vercel.svg └── next.svg ├── next.config.mjs ├── constants ├── networkConfig.json ├── idl_4.json └── idl_3.json ├── .gitignore ├── src ├── helpers │ ├── miscellaneous.ts │ └── apis.ts └── componts │ ├── core │ ├── timer.tsx │ ├── shutDownModal.tsx │ ├── tree │ │ └── treeview.js │ ├── sidebar │ │ └── Sidebar.tsx │ └── navbar │ │ └── Navbar.tsx │ └── app │ ├── home │ ├── HomeReuseCard.tsx │ ├── TotalReferredSection.tsx │ └── Home.tsx │ ├── referrals │ ├── ReferralChart.tsx │ └── ReferralActivity.tsx │ ├── credits │ ├── Credits.tsx │ └── CreditsTable.tsx │ ├── packages │ ├── PackageDetails.tsx │ └── Packages.tsx │ └── main │ └── mainPage.tsx ├── tsconfig.json ├── package.json └── README.md /app/walletModal.css: -------------------------------------------------------------------------------- 1 | .custom-wallet-modal { 2 | z-index: 2000; 3 | } -------------------------------------------------------------------------------- /public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iTechTop/solana-referral/HEAD/public/favicon.ico -------------------------------------------------------------------------------- /public/package_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iTechTop/solana-referral/HEAD/public/package_1.png -------------------------------------------------------------------------------- /public/package_2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iTechTop/solana-referral/HEAD/public/package_2.png -------------------------------------------------------------------------------- /public/package_3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iTechTop/solana-referral/HEAD/public/package_3.png -------------------------------------------------------------------------------- /public/package_4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iTechTop/solana-referral/HEAD/public/package_4.png -------------------------------------------------------------------------------- /public/package_5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iTechTop/solana-referral/HEAD/public/package_5.png -------------------------------------------------------------------------------- /public/package_6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iTechTop/solana-referral/HEAD/public/package_6.png -------------------------------------------------------------------------------- /public/package_7.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iTechTop/solana-referral/HEAD/public/package_7.png -------------------------------------------------------------------------------- /public/package_8.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iTechTop/solana-referral/HEAD/public/package_8.png -------------------------------------------------------------------------------- /next.config.mjs: -------------------------------------------------------------------------------- 1 | /** @type {import('next').NextConfig} */ 2 | const nextConfig = {}; 3 | 4 | export default nextConfig; 5 | -------------------------------------------------------------------------------- /public/images/sliderIcon.3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iTechTop/solana-referral/HEAD/public/images/sliderIcon.3.png -------------------------------------------------------------------------------- /public/images/sliderIcon.4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iTechTop/solana-referral/HEAD/public/images/sliderIcon.4.png -------------------------------------------------------------------------------- /public/images/sliderHomeIcon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iTechTop/solana-referral/HEAD/public/images/sliderHomeIcon.png -------------------------------------------------------------------------------- /public/images/sliderIcon.2png.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iTechTop/solana-referral/HEAD/public/images/sliderIcon.2png.png -------------------------------------------------------------------------------- /public/images/sms-notification.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iTechTop/solana-referral/HEAD/public/images/sms-notification.png -------------------------------------------------------------------------------- /app/globals.css: -------------------------------------------------------------------------------- 1 | body { 2 | font-family: 'Px437 Acer710 Mono', monospace !important; 3 | background: #008080 !important; 4 | } -------------------------------------------------------------------------------- /public/fonts/Px437_Acer710_Mono.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iTechTop/solana-referral/HEAD/public/fonts/Px437_Acer710_Mono.ttf -------------------------------------------------------------------------------- /public/images/notification-bing.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iTechTop/solana-referral/HEAD/public/images/notification-bing.png -------------------------------------------------------------------------------- /app/page.tsx: -------------------------------------------------------------------------------- 1 | import MainPage from '@/src/componts/app/main/mainPage'; 2 | import React from 'react'; 3 | 4 | const Home = () => 5 | 6 | export default Home; -------------------------------------------------------------------------------- /public/styles/fonts.css: -------------------------------------------------------------------------------- 1 | @font-face { 2 | font-family: 'Px437 Acer710 Mono'; 3 | src: url('/fonts/Px437_Acer710_Mono.ttf') format('woff2'); 4 | font-weight: normal; 5 | font-style: normal; 6 | } -------------------------------------------------------------------------------- /app/packages.tsx: -------------------------------------------------------------------------------- 1 | import { Box } from '@chakra-ui/react'; 2 | import React from 'react'; 3 | 4 | const PackagesPage = () => { 5 | return ( 6 | 7 | packages page 8 | 9 | ); 10 | }; 11 | 12 | export default PackagesPage; -------------------------------------------------------------------------------- /constants/networkConfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "network": "https://api.devnet.solana.com", 3 | "backend_endpoint": "http://ec2-44-212-1-97.compute-1.amazonaws.com", 4 | "frontend_endpoint": "https://solana-referral.vercel.app/referral", 5 | "smart_contract": "FqMQ5TF8M5pEWGzbj7gDx3ezJVniebaSHBmA4MexUN51", 6 | "founder_wallet": "982fzbji2WuZNvLE7w4PiXzdeRYuiVahBEBNhv21nKyN", 7 | "lp_wallet": "AAMEXH5VRxdxwBb9zWn76kcuqVXgTHHEw4fdZWHj1KyP" 8 | } -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files. 2 | 3 | # dependencies 4 | /node_modules 5 | /.pnp 6 | .pnp.js 7 | .yarn/install-state.gz 8 | 9 | # testing 10 | /coverage 11 | 12 | # next.js 13 | /.next/ 14 | /out/ 15 | 16 | # production 17 | /build 18 | 19 | # misc 20 | .DS_Store 21 | *.pem 22 | 23 | # debug 24 | npm-debug.log* 25 | yarn-debug.log* 26 | yarn-error.log* 27 | 28 | # local env files 29 | .env*.local 30 | 31 | # vercel 32 | .vercel 33 | 34 | # typescript 35 | *.tsbuildinfo 36 | next-env.d.ts 37 | -------------------------------------------------------------------------------- /public/vercel.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/helpers/miscellaneous.ts: -------------------------------------------------------------------------------- 1 | import axios from "axios"; 2 | 3 | export async function fetchSolPrice() { 4 | try { 5 | const response: any = await axios.get('https://api.coingecko.com/api/v3/simple/price?ids=solana&vs_currencies=usd'); 6 | if (response.status !== 200) { 7 | throw new Error(`Error fetching SOL price: ${response.statusText}`); 8 | } 9 | console.log(response); 10 | const data = response.data; 11 | console.log(`The current price of SOL in USD is: $${data.solana.usd}`); 12 | return data.solana.usd; 13 | } catch (error: any) { 14 | console.error(`An error occurred: ${error.message}`); 15 | return null; 16 | } 17 | } -------------------------------------------------------------------------------- /app/layout.tsx: -------------------------------------------------------------------------------- 1 | import type { Metadata } from "next"; 2 | import { Inter } from "next/font/google"; 3 | import "./globals.css"; 4 | import '../public/styles/fonts.css'; 5 | import '@solana/wallet-adapter-react-ui/styles.css'; 6 | 7 | import { Providers } from "./providers"; 8 | 9 | const inter = Inter({ subsets: ["latin"] }); 10 | 11 | export const metadata: Metadata = { 12 | title: "Solana", 13 | description: "", 14 | }; 15 | 16 | export default function RootLayout({ 17 | children, 18 | }: Readonly<{ 19 | children: React.ReactNode; 20 | }>) { 21 | return ( 22 | 23 | 24 | {children} 25 | 26 | 27 | ); 28 | } 29 | -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "lib": [ 4 | "dom", 5 | "dom.iterable", 6 | "esnext" 7 | ], 8 | "allowJs": true, 9 | "skipLibCheck": true, 10 | "strict": true, 11 | "noEmit": true, 12 | "esModuleInterop": true, 13 | "module": "esnext", 14 | "moduleResolution": "bundler", 15 | "resolveJsonModule": true, 16 | "isolatedModules": true, 17 | "jsx": "preserve", 18 | "incremental": true, 19 | "plugins": [ 20 | { 21 | "name": "next" 22 | } 23 | ], 24 | "paths": { 25 | "@/*": [ 26 | "./*" 27 | ] 28 | } 29 | }, 30 | "include": [ 31 | "next-env.d.ts", 32 | "**/*.ts", 33 | "**/*.tsx", 34 | ".next/types/**/*.ts", 35 | "src/componts/core/tree/TreeView.js" 36 | ], 37 | "exclude": [ 38 | "node_modules" 39 | ] 40 | } -------------------------------------------------------------------------------- /constants/idl_4.json: -------------------------------------------------------------------------------- 1 | {"version":"0.1.0","name":"referral_program","instructions":[{"name":"purchasePackage","accounts":[{"name":"user","isMut":true,"isSigner":true},{"name":"lpWallet","isMut":true,"isSigner":false},{"name":"founder","isMut":true,"isSigner":false},{"name":"systemProgram","isMut":false,"isSigner":false}],"args":[{"name":"packagePrice","type":"u64"},{"name":"commissions","type":{"vec":"u64"}}]}],"types":[{"name":"Referral","type":{"kind":"struct","fields":[{"name":"pubkey","type":"publicKey"},{"name":"payableCommission","type":"u64"},{"name":"credit","type":"u64"}]}}],"events":[{"name":"PurchaseEvent","fields":[{"name":"referrals","type":{"vec":{"defined":"Referral"}},"index":false}]}],"errors":[{"code":6000,"name":"AmountTooLow","msg":"The paid amount is too low."},{"code":6001,"name":"ReceiverNotWritable","msg":"The receiver account is not writable."},{"code":6002,"name":"InvalidAccount","msg":"Invalid account provided."}]} -------------------------------------------------------------------------------- /src/componts/core/timer.tsx: -------------------------------------------------------------------------------- 1 | import { Flex, Text } from '@chakra-ui/react'; 2 | import React, { useEffect, useState } from 'react'; 3 | 4 | const Timer = () => { 5 | const [time, setTime] = useState(''); 6 | 7 | useEffect(() => { 8 | setTime(new Date().toLocaleTimeString()); 9 | 10 | const timer = setInterval(() => { 11 | setTime(new Date().toLocaleTimeString()); 12 | }, 1000); 13 | 14 | return () => clearInterval(timer); 15 | }, []); 16 | 17 | return ( 18 | 19 | {time || 'Loading time...'} 20 | 21 | ); 22 | }; 23 | 24 | export default Timer; 25 | -------------------------------------------------------------------------------- /app/providers.tsx: -------------------------------------------------------------------------------- 1 | "use client"; 2 | 3 | import { ChakraProvider } from "@chakra-ui/react"; 4 | import { WalletProvider } from "@solana/wallet-adapter-react"; 5 | import { WalletModalProvider } from "@solana/wallet-adapter-react-ui"; 6 | import { ConnectionProvider } from "@solana/wallet-adapter-react"; 7 | import { clusterApiUrl } from "@solana/web3.js"; 8 | import { PhantomWalletAdapter } from "@solana/wallet-adapter-phantom"; 9 | import { useMemo, useState } from "react"; 10 | import "./walletModal.css"; 11 | 12 | export function Providers({ children }: { children: React.ReactNode }) { 13 | const endpoint = useMemo(() => clusterApiUrl("devnet"), []); 14 | 15 | const wallets = useMemo(() => [new PhantomWalletAdapter()], []); 16 | 17 | return ( 18 | 19 | 20 | 21 | {children} 22 | 23 | 24 | 25 | ); 26 | } 27 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "pepe-project", 3 | "version": "0.1.0", 4 | "private": true, 5 | "scripts": { 6 | "dev": "next dev", 7 | "build": "next build", 8 | "start": "next start", 9 | "lint": "next lint" 10 | }, 11 | "dependencies": { 12 | "@chakra-ui/icons": "^2.1.1", 13 | "@chakra-ui/next-js": "^2.2.0", 14 | "@chakra-ui/react": "^2.8.2", 15 | "@emotion/react": "^11.11.4", 16 | "@emotion/styled": "^11.11.0", 17 | "@project-serum/anchor": "^0.26.0", 18 | "@solana/wallet-adapter-base": "^0.9.23", 19 | "@solana/wallet-adapter-phantom": "^0.9.24", 20 | "@solana/wallet-adapter-react": "^0.15.35", 21 | "@solana/wallet-adapter-react-ui": "^0.9.35", 22 | "@solana/wallet-adapter-wallets": "^0.19.32", 23 | "axios": "^1.6.8", 24 | "d3": "^7.9.0", 25 | "framer-motion": "^11.0.18", 26 | "next": "14.1.4", 27 | "react": "^18", 28 | "react-dom": "^18", 29 | "react-icons": "^5.0.1", 30 | "recharts": "^2.12.3" 31 | }, 32 | "devDependencies": { 33 | "@types/node": "^20", 34 | "@types/react": "^18", 35 | "@types/react-dom": "^18", 36 | "typescript": "^5" 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/componts/app/home/HomeReuseCard.tsx: -------------------------------------------------------------------------------- 1 | import { Box, Text, Flex } from '@chakra-ui/react'; 2 | import { IoMdArrowForward } from "react-icons/io"; 3 | import React from 'react'; 4 | 5 | const HomeReuseCard = ({ cardTitle, amount, rate, showButton, buttonAction }: any) => { 6 | return ( 7 | 8 | {cardTitle} 9 | {amount} {rate} 10 | {showButton && 11 | 12 | {cardTitle == "My Package" && amount == "No package" && PURCHASE} 13 | 14 | 15 | } 16 | 17 | ); 18 | }; 19 | 20 | export default HomeReuseCard; -------------------------------------------------------------------------------- /public/next.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /constants/idl_3.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "0.1.0", 3 | "name": "referral_program", 4 | "instructions": [ 5 | { 6 | "name": "purchasePackage", 7 | "accounts": [ 8 | { 9 | "name": "user", 10 | "isMut": true, 11 | "isSigner": true 12 | }, 13 | { 14 | "name": "lpWallet", 15 | "isMut": true, 16 | "isSigner": false 17 | }, 18 | { 19 | "name": "systemProgram", 20 | "isMut": false, 21 | "isSigner": false 22 | } 23 | ], 24 | "args": [] 25 | } 26 | ], 27 | "errors": [ 28 | { 29 | "code": 6000, 30 | "name": "AmountTooLow", 31 | "msg": "The paid amount is too low. The minimum required is 0.5 SOL." 32 | }, 33 | { 34 | "code": 6001, 35 | "name": "ReceiverNotWritable", 36 | "msg": "The receiver account is not writable." 37 | }, 38 | { 39 | "code": 6002, 40 | "name": "InvalidAccount", 41 | "msg": "Invalid account provided." 42 | } 43 | ] 44 | } -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | This is a [Next.js](https://nextjs.org/) project bootstrapped with [`create-next-app`](https://github.com/vercel/next.js/tree/canary/packages/create-next-app). 2 | 3 | ## Getting Started 4 | 5 | First, run the development server: 6 | 7 | ```bash 8 | npm run dev 9 | # or 10 | yarn dev 11 | # or 12 | pnpm dev 13 | # or 14 | bun dev 15 | ``` 16 | 17 | Open [http://localhost:3000](http://localhost:3000) with your browser to see the result. 18 | 19 | You can start editing the page by modifying `app/page.tsx`. The page auto-updates as you edit the file. 20 | 21 | This project uses [`next/font`](https://nextjs.org/docs/basic-features/font-optimization) to automatically optimize and load Inter, a custom Google Font. 22 | 23 | ## Learn More 24 | 25 | To learn more about Next.js, take a look at the following resources: 26 | 27 | - [Next.js Documentation](https://nextjs.org/docs) - learn about Next.js features and API. 28 | - [Learn Next.js](https://nextjs.org/learn) - an interactive Next.js tutorial. 29 | 30 | You can check out [the Next.js GitHub repository](https://github.com/vercel/next.js/) - your feedback and contributions are welcome! 31 | 32 | ## Deploy on Vercel 33 | 34 | The easiest way to deploy your Next.js app is to use the [Vercel Platform](https://vercel.com/new?utm_medium=default-template&filter=next.js&utm_source=create-next-app&utm_campaign=create-next-app-readme) from the creators of Next.js. 35 | 36 | Check out our [Next.js deployment documentation](https://nextjs.org/docs/deployment) for more details. 37 | -------------------------------------------------------------------------------- /src/componts/app/referrals/ReferralChart.tsx: -------------------------------------------------------------------------------- 1 | import { Box } from '@chakra-ui/react'; 2 | import React from 'react'; 3 | import { BarChart, Bar, XAxis, CartesianGrid, Tooltip, ResponsiveContainer, } from 'recharts'; 4 | 5 | const ReferralChart = () => { 6 | 7 | const earningsData = [ 8 | { month: 'Jan', earnings: 2400 }, 9 | { month: 'Feb', earnings: 1398 }, 10 | { month: 'Mar', earnings: 9800 }, 11 | { month: 'Apr', earnings: 3908 }, 12 | { month: 'May', earnings: 4800 }, 13 | { month: 'Jun', earnings: 3800 }, 14 | { month: 'Jul', earnings: 4300 }, 15 | { month: 'Aug', earnings: 5400 }, 16 | { month: 'Sep', earnings: 7600 }, 17 | { month: 'Oct', earnings: 6908 }, 18 | { month: 'Nov', earnings: 9800 }, 19 | { month: 'Dec', earnings: 12300 }, 20 | ]; 21 | 22 | return ( 23 | 24 | 25 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | ); 42 | }; 43 | 44 | export default ReferralChart; -------------------------------------------------------------------------------- /src/componts/app/home/TotalReferredSection.tsx: -------------------------------------------------------------------------------- 1 | import { Box, Text, Flex } from '@chakra-ui/react'; 2 | import React from 'react'; 3 | import NETWORK from "@/constants/networkConfig.json"; 4 | 5 | const TotalReferredSection = ({referralCode}: any) => { 6 | const copyToClipboard = async () => { 7 | try { 8 | await navigator.clipboard.writeText(`${NETWORK.frontend_endpoint}/${referralCode}`); 9 | console.log('Text copied to clipboard'); 10 | } catch (err) { 11 | console.error('Failed to copy text: ', err); 12 | } 13 | } 14 | 15 | return ( 16 | 17 | 18 | 19 | Total Referred 20 | 00 21 | 22 | 23 | Total users under me 24 | 00 25 | 26 | 27 | 28 | {referralCode !== "" && referralCode !== "no-code" && 29 | 30 | {NETWORK.frontend_endpoint}/{referralCode} 31 | 32 | 33 | Copy 34 | 35 | } 36 | 37 | ); 38 | }; 39 | 40 | export default TotalReferredSection; -------------------------------------------------------------------------------- /src/componts/core/shutDownModal.tsx: -------------------------------------------------------------------------------- 1 | import { Box, Flex, Image, Modal, ModalContent, Text } from '@chakra-ui/react'; 2 | import React from 'react'; 3 | 4 | const ShutDownModal = ({ isStartOpen, onStartClose, openModalClose }: any) => { 5 | return ( 6 | 7 | 8 | 9 | 10 | 22 | SOLANA REFERRAL 23 | 24 | 25 | { openModalClose(), onStartClose() }}> 26 | img 27 | Shut Down.. 28 | 29 | 30 | 31 | 32 | ); 33 | }; 34 | 35 | export default ShutDownModal; -------------------------------------------------------------------------------- /src/componts/app/credits/Credits.tsx: -------------------------------------------------------------------------------- 1 | import { Box, Button, Flex, Image, Text } from '@chakra-ui/react'; 2 | import React from 'react'; 3 | import CreditsTable from './CreditsTable'; 4 | 5 | const Credits = () => { 6 | return ( 7 | 8 | 9 | 10 | 11 | My Credits 12 | 50000 13 | 14 | 17 | 18 | 19 | 20 | 21 | img 22 | 23 | Credit History 24 | 25 | 26 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | What are credits 37 | 38 | 39 | Credits are earned based on commissions and time of joining, and can be used for future token airdrops. The number of credits earned depends on the commission earned & package/s bought and the phase of the business. Example: Someone purchase a Mercury Package (10m pepe 1) the user who bought it will get the same amount in CREDITS If the user sponsor someone, and make 10M pepe TOTAL COMMISSIONS, then he will get instantly in his wallet 8M PEPE, and the remaining 20% will be sent automatically in the same transaction to the LP wallet, and the user will get 20% Credits uploaded. FYI: The more you active in the network, more commission you will get, and more credits you will collect 40 | 41 | 42 | 43 | ); 44 | }; 45 | 46 | export default Credits; -------------------------------------------------------------------------------- /src/componts/core/tree/treeview.js: -------------------------------------------------------------------------------- 1 | import { useEffect, useRef } from 'react'; 2 | import * as d3 from 'd3'; 3 | import { Box } from '@chakra-ui/react'; 4 | 5 | const TreeChart = ({ data }) => { 6 | const d3Container = useRef(null); 7 | 8 | useEffect(() => { 9 | if (data && d3Container.current) { 10 | const margin = { top: 0, right: 120, bottom: 0, left: 120 }, 11 | width = 1200 - margin.right - margin.left, 12 | height = 1000 - margin.top - margin.bottom; 13 | 14 | // Process the data 15 | const root = d3.stratify() 16 | .id(function (d) { return d.name; }) 17 | .parentId(function (d) { return d.parent || undefined; }) // Handle root node by returning undefined if parent is missing 18 | (data); 19 | root.x0 = height / 2; 20 | root.y0 = 0; 21 | 22 | // Tree layout 23 | const treeLayout = d3.tree().size([height, width]); 24 | treeLayout(root); 25 | 26 | // Links 27 | const links = root.links(); 28 | const linkPathGenerator = d3.linkHorizontal() 29 | .x(d => d.y) 30 | .y(d => d.x); 31 | 32 | d3.select(d3Container.current).select('*').remove(); 33 | 34 | const svg = d3.select(d3Container.current) 35 | .append("svg") 36 | .attr("width", width + margin.right + margin.left) 37 | .attr("height", height + margin.top + margin.bottom) 38 | .append("g") 39 | .attr("transform", `translate(${margin.left},${margin.top})`); 40 | 41 | // Nodes 42 | svg.selectAll('g.node') 43 | .data(root.descendants()) 44 | .enter().append('g') 45 | .attr('class', 'node') 46 | .attr("transform", d => `translate(${d.y},${d.x})`) 47 | .append('circle') 48 | .attr("r", 10) 49 | .style("fill", "black"); 50 | 51 | // Adding text to nodes 52 | svg.selectAll('g.node') 53 | .append("text") 54 | .attr("dy", ".35em") 55 | .attr("x", d => d.children ? -13 : 13) 56 | .style("text-anchor", d => d.children ? "end" : "start") 57 | .style("fill", "#555") // Set text color 58 | .style("font-family", "Arial") // Set font family 59 | .style("font-size", "12px") // Set font size 60 | .text(d => d.data.name); 61 | 62 | // Links 63 | svg.selectAll('path.link') 64 | .data(links) 65 | .enter().insert('path', "g") 66 | .attr("class", "link") 67 | .attr("d", linkPathGenerator) 68 | .style("stroke", "#ccc") // Set the color of the links 69 | .style("stroke-width", "2px") // Set the stroke width of the links 70 | .style("fill", "none"); 71 | } 72 | }, [data]); 73 | 74 | return ; 75 | }; 76 | 77 | 78 | export default TreeChart -------------------------------------------------------------------------------- /src/helpers/apis.ts: -------------------------------------------------------------------------------- 1 | import NETWORK from "@/constants/networkConfig.json"; 2 | import axios from "axios"; 3 | 4 | export async function getUser(walletAddress: any) { 5 | try { 6 | const response = await axios.get(`${NETWORK.backend_endpoint}/get-user`, { 7 | headers: { 8 | "Content-Type": "application/json", 9 | }, 10 | params: { 11 | walletAddress, 12 | }, 13 | }); 14 | return response.data; 15 | } catch (error) { 16 | console.error("Error making GET request:", error); 17 | return error; 18 | throw error; 19 | } 20 | } 21 | 22 | export async function registerUser( 23 | name: any, 24 | email: any, 25 | referralCode: any, 26 | walletAddress: any 27 | ) { 28 | try { 29 | const response = await axios.post( 30 | `${NETWORK.backend_endpoint}/register-user`, 31 | { 32 | name, 33 | email, 34 | referralCode, 35 | walletAddress, 36 | }, 37 | { 38 | headers: { 39 | "Content-Type": "application/json", 40 | }, 41 | } 42 | ); 43 | console.log(response); 44 | return response; 45 | } catch (error) { 46 | console.log("Error making register user request: ", error); 47 | return error; 48 | } 49 | } 50 | 51 | export async function getReferralUplinks(access_token: any) { 52 | try { 53 | const response = await axios.get(`${NETWORK.backend_endpoint}/get-referral-uplinks`, { 54 | headers: { 55 | "Authorization": access_token 56 | } 57 | }) 58 | return response; 59 | } catch (error) { 60 | 61 | return error; 62 | } 63 | } 64 | 65 | export async function purchasePackage(access_token: any, package_id: any, package_price: any, referrals: any, commissions: any, credits: any) { 66 | try { 67 | const response = await axios.post( 68 | `${NETWORK.backend_endpoint}/purchase-package`, 69 | { 70 | package_id, 71 | package_price, 72 | referrals, 73 | commissions, 74 | credits 75 | }, 76 | { 77 | headers: { 78 | "Content-Type": "application/json", 79 | "Authorization": access_token 80 | }, 81 | } 82 | ); 83 | console.log(response); 84 | return response; 85 | } catch (error) { 86 | console.log("Error making register user request: ", error); 87 | return error; 88 | } 89 | } 90 | 91 | export async function fetchPurchaseEvent (txHash: any, connection: any, program: any) { 92 | try { 93 | // Fetch the transaction details 94 | const tx = await connection.getTransaction(txHash); 95 | console.log(tx); 96 | 97 | // Assuming the event is in the first log message; adjust if necessary 98 | const log = tx.meta.logMessages.find((message: any) => message.startsWith('Program log: ')); 99 | 100 | console.log({log}) 101 | if (!log) { 102 | console.log('No log found in the transaction'); 103 | return; 104 | } 105 | 106 | // Extract the base-64 encoded string 107 | const base64Data = log.split('Program log: ')[1]; 108 | 109 | // Decode the event data 110 | const eventData = program.coder.events.decode('PurchaseEvent', base64Data); 111 | 112 | console.log('Event data:', eventData); 113 | } catch (error) { 114 | console.error('Error fetching the event:', error); 115 | } 116 | }; 117 | -------------------------------------------------------------------------------- /src/componts/app/packages/PackageDetails.tsx: -------------------------------------------------------------------------------- 1 | import React from "react"; 2 | import { Box, Button, Flex, Image, Text } from "@chakra-ui/react"; 3 | import { useWallet } from "@solana/wallet-adapter-react"; 4 | import { Connection, PublicKey, Transaction, LAMPORTS_PER_SOL } from "@solana/web3.js"; 5 | import { Program, AnchorProvider, web3, BN } from "@project-serum/anchor"; 6 | import NETWORK from "@/constants/networkConfig.json"; 7 | import IDL from "@/constants/idl_4.json"; // Adjust the path to your IDL file 8 | 9 | const programID = new PublicKey(NETWORK.smart_contract); 10 | const network = NETWORK.network; 11 | 12 | const PackageDetails = ({ displayPackage }: any) => { 13 | const wallet: any = useWallet(); 14 | const idl: any = IDL; 15 | 16 | async function callPurchasePackage( package_id: any, package_price: any) { 17 | // integrate api here to call /get-referral-uplinks 18 | const referrals = ["7h7rhCPzaFFJBJ4zScfMGXPCiNctJXejNaQSeDDbkoBa", "22gbQiUoDqcyp2jPBtrewBVT5axX4vm1PFpXfc9AzXRC"]; 19 | const commissions: any = [new BN(10), new BN(10)];; 20 | 21 | if (!wallet.connected) { 22 | console.log("Wallet is not connected!"); 23 | return; 24 | } 25 | 26 | const connection = new Connection(network, "confirmed"); 27 | const provider = new AnchorProvider(connection, wallet, { 28 | preflightCommitment: "confirmed", 29 | }); 30 | 31 | const program = new Program(idl, programID, provider); 32 | const lpWallet = new PublicKey(NETWORK.lp_wallet); 33 | const founder = new PublicKey(NETWORK.founder_wallet); 34 | 35 | const listener = program.addEventListener('PurchaseEvent', (event, slot) => { 36 | console.log('Purchase event:', event); 37 | console.log('Slot:', slot); 38 | // call purchase-package api here 39 | }); 40 | 41 | try { 42 | const response = await program.methods 43 | .purchasePackage(new BN(package_price * LAMPORTS_PER_SOL), commissions) 44 | .accounts({ 45 | user: provider.wallet.publicKey, 46 | lpWallet: lpWallet, 47 | founder: founder, 48 | systemProgram: web3.SystemProgram.programId, 49 | }) 50 | .remainingAccounts( 51 | referrals.map((key: any) => ({ 52 | pubkey: new PublicKey(key), 53 | isWritable: true, 54 | isSigner: false, 55 | })) 56 | ) 57 | .signers([]) 58 | .rpc(); 59 | 60 | console.log({response}); 61 | console.log("purchase_package function called successfully."); 62 | } catch (error) { 63 | 64 | console.error("Error calling purchase_package:", error); 65 | } finally { 66 | // Remove listener after the transaction is confirmed 67 | program.removeEventListener(listener); 68 | } 69 | } 70 | 71 | return ( 72 | 73 | Packages details 74 | 75 | 76 | 81 | 82 | 83 | 84 | {displayPackage?.name} plan 85 | 86 | {displayPackage?.description} 87 | 88 | 89 | Price: {displayPackage?.price} SOL 90 | 91 | 104 | 105 | 106 | 107 | 108 | ); 109 | }; 110 | 111 | export default PackageDetails; 112 | -------------------------------------------------------------------------------- /src/componts/core/sidebar/Sidebar.tsx: -------------------------------------------------------------------------------- 1 | 'use client' 2 | import React from 'react'; 3 | import { IoHome } from 'react-icons/io5'; 4 | import { LuLineChart } from 'react-icons/lu'; 5 | import { TbPackages } from 'react-icons/tb'; 6 | import { RiWallet3Fill } from 'react-icons/ri'; 7 | import { usePathname } from "next/navigation" 8 | import { Box, Text } from '@chakra-ui/react'; 9 | import Link from 'next/link'; 10 | 11 | const Sidebar = ({ pathname, setPathname, showReferralTab }: any) => { 12 | 13 | return ( 14 | <> 15 | setPathname('/')} 27 | > 28 | 29 | 30 | 31 | 32 | HOME 33 | 34 | 35 | {showReferralTab && setPathname('/referral-activity')} 47 | > 48 | 49 | 50 | 51 | 52 | Referrals Activity 53 | 54 | } 55 | setPathname('/packages')} 67 | > 68 | 69 | 70 | 71 | 72 | Packages 73 | 74 | 75 | setPathname('/credits')} 87 | > 88 | 89 | 90 | 91 | 92 | Credits 93 | 94 | 95 | 96 | ); 97 | }; 98 | 99 | export default Sidebar; -------------------------------------------------------------------------------- /src/componts/app/home/Home.tsx: -------------------------------------------------------------------------------- 1 | import { useEffect, useState } from "react"; 2 | import { Box, Grid } from "@chakra-ui/react"; 3 | import Sidebar from "../../core/sidebar/Sidebar"; 4 | import TotalReferredSection from "./TotalReferredSection"; 5 | import HomeReuseCard from "./HomeReuseCard"; 6 | import { useWallet } from "@solana/wallet-adapter-react"; 7 | import { Connection, LAMPORTS_PER_SOL } from '@solana/web3.js'; 8 | import NETWORK from "@/constants/networkConfig.json"; 9 | import { getUser } from "@/src/helpers/apis"; 10 | 11 | const HomeIndex = ({onLogInOpen, setPathname, user, setUser}: any) => { 12 | const wallet = useWallet(); 13 | const [balance, setBalance] = useState(0); 14 | const [userPackage, setUserPackage] = useState("No package"); 15 | const connection = new Connection( 16 | NETWORK.network, 17 | "confirmed" 18 | ); 19 | 20 | const fetchUserDetails = async (walletAddress: any) => { 21 | const userData = await getUser(walletAddress); 22 | 23 | if(userData?.error == "User not found") { 24 | onLogInOpen(); 25 | } 26 | 27 | console.log(userData); 28 | setUser(userData); 29 | localStorage.setItem("access_token", userData.accessToken); 30 | 31 | 32 | if(userData.package_id !== 0) { 33 | switch(userData.package_id) { 34 | case 1: 35 | setUserPackage("ESPRESSO MARTINI"); 36 | break; 37 | case 2: 38 | setUserPackage("SPRITZ MARTINI"); 39 | break; 40 | case 3: 41 | setUserPackage("MOJITO"); 42 | break; 43 | case 4: 44 | setUserPackage("MOSCOW MULE"); 45 | break; 46 | case 5: 47 | setUserPackage("PINA COLADA"); 48 | break; 49 | case 6: 50 | setUserPackage("VODKA MARTINI"); 51 | break; 52 | case 7: 53 | setUserPackage("COSMOPOLITAN"); 54 | break; 55 | case 8: 56 | setUserPackage("MANHATTAN"); 57 | break; 58 | } 59 | } 60 | } 61 | 62 | const fetchBalance = async () => { 63 | if (!wallet?.publicKey) { 64 | console.error("Wallet is not connected"); 65 | return; 66 | } 67 | 68 | try { 69 | const balance = await connection.getBalance(wallet.publicKey); 70 | console.log(balance); 71 | setBalance(balance / LAMPORTS_PER_SOL); // Convert lamports to SOL 72 | console.log("wallet address: ", wallet.publicKey.toString()); 73 | fetchUserDetails(wallet.publicKey.toString()); 74 | } catch (error) { 75 | console.error("Error fetching balance:", error); 76 | } 77 | }; 78 | 79 | const requestAirdrop = async () => { 80 | console.log("called"); 81 | if (!wallet?.publicKey) { 82 | console.error('Wallet is not connected'); 83 | return; 84 | } 85 | 86 | try { 87 | console.log('Requesting airdrop...'); 88 | const airdropSignature = await connection.requestAirdrop( 89 | wallet.publicKey, 90 | 5 * LAMPORTS_PER_SOL // This will request 1 SOL. Adjust the amount as needed. 91 | ); 92 | 93 | await connection.confirmTransaction(airdropSignature); 94 | console.log('Airdrop successful'); 95 | } catch (error) { 96 | console.error('Airdrop failed:', error); 97 | } 98 | }; 99 | 100 | useEffect(() => { 101 | if(wallet.connected) { 102 | fetchBalance(); 103 | // requestAirdrop(); 104 | } 105 | }, [wallet]) 106 | 107 | return ( 108 | 112 | 113 | 114 | 115 | {setPathname("/packages")}} /> 116 | 121 | 122 | 123 | 124 | ); 125 | }; 126 | 127 | export default HomeIndex; 128 | -------------------------------------------------------------------------------- /src/componts/app/credits/CreditsTable.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import { Box, Flex, Image, Table, Tbody, Td, Text, Th, Thead, Tr, useBreakpointValue, VStack } from '@chakra-ui/react'; 3 | 4 | const data = [ 5 | { 6 | name: 'John Doe', 7 | date: '18 - 03 - 2024', 8 | level: '2', 9 | referrer: 'Aayush Shukla', 10 | credits: '$20', 11 | status: 'Active', 12 | }, 13 | { 14 | name: 'John Doe', 15 | date: '18 - 03 - 2024', 16 | level: '2', 17 | referrer: 'Aayush Shukla', 18 | credits: '$20', 19 | status: 'Active', 20 | }, 21 | { 22 | name: 'John Doe', 23 | date: '18 - 03 - 2024', 24 | level: '2', 25 | referrer: 'Aayush Shukla', 26 | credits: '$20', 27 | status: 'Active', 28 | }, 29 | { 30 | name: 'John Doe', 31 | date: '18 - 03 - 2024', 32 | level: '2', 33 | referrer: 'Aayush Shukla', 34 | credits: '$20', 35 | status: 'Active', 36 | }, 37 | { 38 | name: 'John Doe', 39 | date: '18 - 03 - 2024', 40 | level: '2', 41 | referrer: 'Aayush Shukla', 42 | credits: '$20', 43 | status: 'Active', 44 | }, 45 | { 46 | name: 'John Doe', 47 | date: '18 - 03 - 2024', 48 | level: '2', 49 | referrer: 'Aayush Shukla', 50 | credits: '$20', 51 | status: 'Active', 52 | }, 53 | { 54 | name: 'John Doe', 55 | date: '18 - 03 - 2024', 56 | level: '2', 57 | referrer: 'Aayush Shukla', 58 | credits: '$20', 59 | status: 'Active', 60 | }, 61 | 62 | ]; 63 | 64 | const CreditsTable = () => { 65 | const isLargeScreen = useBreakpointValue({ base: false, lg: true }); 66 | 67 | if (isLargeScreen) { 68 | return ( 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | {data.map((item, index) => ( 82 | 83 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | ))} 96 | 97 |
Full nameDateLevelReferrerCredits earnedStatus
84 | 85 | img 86 | {item.name} 87 | 88 | {item.date}{item.level}{item.referrer}{item.credits}{item.status}
98 | ); 99 | } else { 100 | // For smaller screens, render a list-like layout 101 | return ( 102 | 103 | {data.map((item, index) => ( 104 | 105 | 106 | {item.name} 107 | {item.name} 108 | 109 | Date: {item.date} 110 | Level: {item.level} 111 | Referrer: {item.referrer} 112 | Credits earned: {item.credits} 113 | Status: {item.status} 114 | 115 | ))} 116 | 117 | ); 118 | } 119 | }; 120 | 121 | export default CreditsTable; 122 | -------------------------------------------------------------------------------- /src/componts/core/navbar/Navbar.tsx: -------------------------------------------------------------------------------- 1 | 'use client' 2 | import React, { useEffect } from 'react'; 3 | import { Box, Flex, Text, Image, Drawer, DrawerOverlay, DrawerContent, DrawerHeader, DrawerBody, useDisclosure } from '@chakra-ui/react'; 4 | import { useWallet } from '@solana/wallet-adapter-react'; 5 | import { WalletMultiButton, WalletDisconnectButton, } from '@solana/wallet-adapter-react-ui'; 6 | import { RiMenuFoldLine, RiWallet3Fill } from 'react-icons/ri'; 7 | import { TbPackages } from 'react-icons/tb'; 8 | import { LuLineChart } from 'react-icons/lu'; 9 | import { IoHome } from 'react-icons/io5'; 10 | 11 | const Navbar = ({ pathname, setPathname , showReferralTab }: any) => { 12 | const { wallet, connect, disconnect, select } = useWallet(); 13 | const { isOpen, onOpen, onClose } = useDisclosure() 14 | 15 | const handleConnect = async () => { 16 | console.log(wallet); 17 | select(wallet?.adapter.name || null) 18 | try { 19 | await connect(); 20 | } catch (error) { 21 | console.log("error") 22 | } 23 | }; 24 | 25 | const getProvider = () => { 26 | if ("solana" in window) { 27 | const provider = (window as any).solana; 28 | if (provider.isPhantom) { 29 | return provider; 30 | } 31 | } 32 | window.open("https://phantom.app/", "_blank"); 33 | }; 34 | 35 | return ( 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | USER 45 | {pathname === '/' && ' / Home'} 46 | {pathname === '/referral-activity' && ' / Referral Activity'} 47 | {pathname === '/packages' && ' / Packages'} 48 | {pathname === '/packages-details' && ' / Packages / Details'} 49 | {pathname === '/credits' && ' / Credits'} 50 | 51 | 52 | 53 | 54 | 55 | 56 | navbar-notification-icon 63 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | setPathname('/')} 91 | > 92 | 93 | 94 | 95 | 96 | HOME 97 | 98 | 99 | {showReferralTab && setPathname('/referral-activity')} 111 | > 112 | 113 | 114 | 115 | 116 | Referrals Activity 117 | 118 | } 119 | setPathname('/packages')} 131 | > 132 | 133 | 134 | 135 | 136 | Packages 137 | 138 | 139 | setPathname('/credits')} 151 | > 152 | 153 | 154 | 155 | 156 | Credits 157 | 158 | 159 | 160 | 161 | 162 | 163 | ); 164 | }; 165 | 166 | export default Navbar; -------------------------------------------------------------------------------- /src/componts/app/referrals/ReferralActivity.tsx: -------------------------------------------------------------------------------- 1 | 'use client' 2 | import { Box, Button, Flex, Image, Text } from '@chakra-ui/react'; 3 | import React, { useState } from 'react'; 4 | import CreditsTable from '../credits/CreditsTable'; 5 | import { FaRegCircleCheck } from "react-icons/fa6"; 6 | import ReferralChart from './ReferralChart'; 7 | import TreeChart from '../../core/tree/treeview'; 8 | 9 | const ReferralActivity = () => { 10 | const [copySuccess, setCopySuccess] = useState(false); 11 | 12 | const copyToClipboard = async (text: any) => { 13 | if ('clipboard' in navigator) { 14 | try { 15 | await navigator.clipboard.writeText(text); 16 | setCopySuccess(true); 17 | } catch (err) { 18 | setCopySuccess(false); 19 | } 20 | } else { 21 | setCopySuccess(false); 22 | } 23 | }; 24 | 25 | if (copySuccess) { 26 | setTimeout(() => { 27 | setCopySuccess(false); 28 | }, 2000) 29 | } 30 | const data = [ 31 | { "name": "Level 2: A", "parent": "Top Level" }, 32 | { "name": "Top Level" }, // parent is implicitly null 33 | { "name": "Son of A", "parent": "Level 2: A" }, 34 | { "name": "Daughter of A", "parent": "Level 2: A" }, 35 | { "name": "Daughter of A", "parent": "Level 2: A" }, 36 | { "name": "Level 3: d", "parent": "Son of A" }, 37 | { "name": "Level 3: d", "parent": "Son of A" }, 38 | { "name": "Level 3: 3", "parent": "Son of A" }, 39 | { "name": "Level 3: 32", "parent": "Level 3: 3" }, 40 | { "name": "Level 3: d", "parent": "Son of A" }, 41 | { "name": "Level 3: 21", "parent": "Son of A" }, 42 | { "name": "Level 2: B", "parent": "Top Level" }, 43 | { "name": "Daughter of B", "parent": "Level 2: B" }, 44 | { "name": "Daughter of B", "parent": "Level 2: B" }, 45 | { "name": "Son of B", "parent": "Level 2: B" } 46 | ]; 47 | return ( 48 | 49 | 50 | 51 | 52 | img 53 | 54 | Earnings 55 | 56 | 57 | 58 | 59 | Total Referred $1004.00 60 | 61 | 62 | Total Referred this month $100.00 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | img 72 | 73 | My Referral Code 74 | 75 | 76 | 77 | 78 | https://solana.com/refferral/01jDf4 79 | 80 | {copySuccess ? 81 | 82 | 83 | 84 | : 85 | img copyToClipboard('https://solana.com/refferral/01jDf4')} 92 | />} 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | Total Commission 101 | 102 | 103 | $100.00 104 | 105 | 106 | 107 | 108 | 111 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | img 122 | 123 | User joining activity 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | img 133 | 134 | My referrals 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | What is the Referral Program? 144 | 145 | 146 | 147 | 148 | 149 | Compensation Plan [Distribution plan 85% +5%]Unilever : 85% PAYOUT to Top Line till 10th Level 150 | 151 | 152 |
1 LEVEL: 10% 153 |
2 LEVEL: 10% 154 |
3 LEVEL: 10% BRONZE 155 |
4 LEVEL: 10% SILVER 156 |
5 LEVEL: 10% GOLD 157 |
6 LEVEL: 10% EMERALD 158 |
7 LEVEL: 7.5% DIAMOND 159 |
8 LEVEL: 7.5% BLUE DIAMOND 160 |
9 LEVEL: 5% BLACK DIAMOND 161 |
10 LEVEL: 5% CROWN DIAMOND 162 |
163 |
164 | 165 | 166 | Rule 80/20%
167 | Means you can withdraw 80%, will be sent directly to your metamask. 168 |
169 | 170 | 20% remaining will be sent to LP Wallet and given the user Credits for that amount to be swapped later for our Token 171 | 172 | 173 | Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. 174 | 175 |
176 |
177 | 178 | Rules & Rewards 179 | 180 | 181 | Different phases have different difficulty coefficients, which affect the number of credits earned per commission and the token value for airdrops. The coefficient increases as the number of people in the network grows. It’s sort of halving, the number of credit you can earn (by purchasing packages or commissions) decreases over time, so we will need an algorithm in it, that measures number of people and the difficulty coefficient, naturally if you join at the beginning will give you more credits from the package you purchase, then for example when there are already 10000 users, because the more people join The more coefficient grow. 182 | 183 | 184 | 185 | 186 | 187 | Terms & Conditions 188 | 189 | 190 | Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. 191 | 192 |
193 |
194 | ); 195 | }; 196 | 197 | export default ReferralActivity; -------------------------------------------------------------------------------- /src/componts/app/packages/Packages.tsx: -------------------------------------------------------------------------------- 1 | import { Box, Button, Flex, Image, Text } from "@chakra-ui/react"; 2 | import React, { useState } from "react"; 3 | import { useWallet } from "@solana/wallet-adapter-react"; 4 | import { 5 | Connection, 6 | PublicKey, 7 | Transaction, 8 | LAMPORTS_PER_SOL, 9 | } from "@solana/web3.js"; 10 | import { Program, AnchorProvider, web3, BN } from "@project-serum/anchor"; 11 | import IDL from "@/constants/idl_4.json"; // Adjust the path to your IDL file 12 | import NETWORK from "@/constants/networkConfig.json"; 13 | import { fetchPurchaseEvent, getReferralUplinks, purchasePackage } from "@/src/helpers/apis"; 14 | import { fetchSolPrice } from "@/src/helpers/miscellaneous"; 15 | 16 | const programID = new PublicKey(NETWORK.smart_contract); 17 | const network = NETWORK.network; 18 | 19 | const Packages = ({ setPathname, setDisplayPackage, setShowReferralTab, setUser }: any) => { 20 | const wallet: any = useWallet(); 21 | const idl: any = IDL; 22 | const [activePlan, setActivePlan] = useState(false); 23 | const packageCards = [ 24 | { 25 | id: 1, 26 | price: 0.5, 27 | packageName: "ESPRESSO MARTINI", 28 | packageImage: "package_1.png", 29 | description: `Espresso Martini (The "Holy Toledo, Did I Invest in WHAT?") - This potent potion jumpstarts your investment journey (or your heart attack). Free refills, but remember, double vision might make you see double the investment opportunities... or just see Pepe twice (which might be worse).`, 30 | }, 31 | { 32 | id: 2, 33 | price: 2, 34 | packageName: "SPRITZ MARTINI", 35 | packageImage: "package_2.png", 36 | description: `Aperol Spritz (The "Tiny Win, Tiny Mimosa") - Celebrate those small financial victories (or forget your equally tiny losses) with a taste of sunshine. Dollar signs not guaranteed (but might appear on Pepe's questionable taxidermy... those beady eyes are judging your portfolio).`, 37 | }, 38 | { 39 | id: 3, 40 | price: 5, 41 | packageName: "MOJITO", 42 | packageImage: "package_3.png", 43 | description: `Mojito (The "Confident Frog, Questionable Strategy") - Refreshing as your newfound investment confidence. 20% off, but beware: mojitos and laser beam theories about the stock market might get mixed up. (Use your newfound charisma wisely. Don't accidentally convince the barflies to invest their life savings in PepeCoin.)`, 44 | }, 45 | { 46 | id: 4, 47 | price: 10, 48 | packageName: "MOSCOW MULE", 49 | packageImage: "package_4.png", 50 | description: `Moscow Mule (The "High Roller, Potential Ramen Noodle Eater") - Toast your high-risk, high-reward choices with this icy drink. Just don't be surprised by rubber duckie cravings (or a Pepe-induced headache) tomorrow. (Remember, that yacht you dreamt of might turn into a cardboard box by morning.)`, 51 | }, 52 | { 53 | id: 5, 54 | price: 15, 55 | packageName: "PINA COLADA", 56 | packageImage: "package_5.png", 57 | description: `Pina Colada (The "Escape to a Beach of Benjamins... Maybe") - Escape to a tropical paradise (or at least a comfy bar stool that suspiciously smells like swamp water) with this creamy drink. Dream of financial beaches (not included, but a frog can dream, even if those dreams involve hypnotized sheep and laser beams). Just remember, with great financial success comes great responsibility... like explaining to Pepe why you can't afford to fund his fly-powered hoverboard.`, 58 | }, 59 | { 60 | id: 6, 61 | price: 25, 62 | packageName: "VODKA MARTINI", 63 | packageImage: "package_6.png", 64 | description: `Vodka Martini (The "Forgetful Investor, Hopeful Returns") - Shaken, not stirred (because Pepe can't stir, and frankly, neither can you after dealing with Pepe's "investment advice"). This classic martini is perfect for contemplating the meaning of life, the universe, and everything, or at least forgetting about that embarrassing email you sent to your boss about "investment opportunities" involving Pepe-themed merchandise (and a suspicious amount of glitter).`, 65 | }, 66 | { 67 | id: 7, 68 | price: 75, 69 | packageName: "COSMOPOLITAN", 70 | packageImage: "package_7.png", 71 | description: `Cosmopolitan (The "Pinky Promise Your Portfolio Isn't Crying") - A suspiciously pink drink for the discerning investor (or at least someone who can afford to ignore the suspicious pink color). Just remember, with great taste comes great responsibility... like finishing the entire drink, no matter how suspicious that decorative fly looks (it might be winking at you... or plotting your financial doom with Pepe).`, 72 | }, 73 | { 74 | id: 8, 75 | price: 100, 76 | packageName: "MANHATTAN", 77 | packageImage: "package_8.png", 78 | description: `Manhattan (The "Big Cheese, Big Bucks (Hopefully)") - A classic cocktail for the truly brave (or foolhardy) investor. This rye whiskey masterpiece is smooth enough to make even Pepe put down his fly swatter for a moment (no promises on how long the peace will last, or what horrifying experiment he'll pick up next). Consider this a celebratory drink for reaching the top tier... or a potential bribe to keep Pepe from whispering his latest investment in your ear.`, 79 | }, 80 | ]; 81 | 82 | async function callPurchasePackage(package_id: any, package_price: any) { 83 | // integrate api here to call /get-referral-uplinks 84 | const access_token = localStorage.getItem("access_token") || null; 85 | const response: any = await getReferralUplinks(access_token); 86 | console.log("referrals", response); 87 | 88 | if (response.status == 200) { 89 | let referrals = response.data?.referrals?.map((ref: any) => ref.walletAddress); 90 | let commissions = response.data?.referrals?.map((ref: any) => new BN(ref.commission)); 91 | let credits: any = []; 92 | 93 | console.log({referrals, commissions}); 94 | 95 | if (!wallet.connected) { 96 | console.log("Wallet is not connected!"); 97 | return; 98 | } 99 | 100 | const connection = new Connection(network, "confirmed"); 101 | const provider = new AnchorProvider(connection, wallet, { 102 | preflightCommitment: "confirmed", 103 | }); 104 | 105 | const program = new Program(idl, programID, provider); 106 | const lpWallet = new PublicKey(NETWORK.lp_wallet); 107 | const founder = new PublicKey(NETWORK.founder_wallet); 108 | 109 | 110 | 111 | const listener = program.addEventListener( 112 | "PurchaseEvent", 113 | async (event, slot) => { 114 | console.log("Purchase event:", event); 115 | console.log("Slot:", slot); 116 | 117 | if(referrals.length == 0) { 118 | commissions = []; 119 | credits = []; 120 | 121 | } else { 122 | // store referrals, commissions, credits coming from event or slot 123 | console.log(event.referrals); 124 | 125 | referrals = event.referrals.map((ref: any) => ref.pubkey.toString()); 126 | commissions = event.referrals.map((ref: any) => ref.payableCommission.toNumber()/LAMPORTS_PER_SOL) 127 | credits = event.referrals.map((ref: any) => ref.credit.toNumber()/LAMPORTS_PER_SOL); // default credits multiplier is 50x 128 | } 129 | 130 | let access_token = localStorage.getItem("access_token") || null; 131 | purchasePackage(access_token, package_id, package_price, referrals, commissions, credits).then((res: any) => { 132 | console.log(res) 133 | setShowReferralTab(true); 134 | // setUser((prev: any) => ({...prev, referralCode: res.data.referralCode})) 135 | }).catch((err: any) => {console.log(err)}) 136 | 137 | } 138 | ); 139 | 140 | try { 141 | const response = await program.methods 142 | .purchasePackage( 143 | new BN(package_price * LAMPORTS_PER_SOL), 144 | commissions 145 | ) 146 | .accounts({ 147 | user: provider.wallet.publicKey, 148 | lpWallet: lpWallet, 149 | founder: founder, 150 | systemProgram: web3.SystemProgram.programId, 151 | }) 152 | .remainingAccounts( 153 | referrals.map((key: any) => ({ 154 | pubkey: new PublicKey(key), 155 | isWritable: true, 156 | isSigner: false, 157 | })) 158 | ) 159 | .signers([]) 160 | .rpc(); 161 | 162 | console.log({ response }); 163 | // console.log() 164 | console.log("purchase_package function called successfully."); 165 | } catch (error) { 166 | console.error("Error calling purchase_package:", error); 167 | } finally { 168 | // Remove listener after the transaction is confirmed 169 | program.removeEventListener(listener); 170 | } 171 | } else { 172 | console.log("request error"); 173 | console.log(response); 174 | } 175 | } 176 | 177 | return ( 178 | 179 | {activePlan && ( 180 | 188 | 193 | 194 | 195 | Current Plan 196 | SILVER 197 | 198 | 199 | Price 200 | 2 SOL 201 | 202 | 203 | 204 | )} 205 | 206 | { 208 | setPathname("/"); 209 | }} 210 | style={{ cursor: "pointer" }} 211 | >{`< `}{" "} 212 | Packages 213 | 214 | 215 | {packageCards.map((card: any, index: any) => ( 216 | 227 | 228 | 229 | {card.packageName} 230 | 231 | 232 | 251 | 264 | 265 | 266 | ))} 267 | 268 | 269 | ); 270 | }; 271 | 272 | export default Packages; 273 | -------------------------------------------------------------------------------- /src/componts/app/main/mainPage.tsx: -------------------------------------------------------------------------------- 1 | 'use client' 2 | import { Box, Button, Flex, Grid, Image, Input, Modal, ModalContent, ModalOverlay, Text, useDisclosure } from '@chakra-ui/react'; 3 | import React, { useEffect, useState } from 'react'; 4 | import { FaRegWindowMaximize, FaWindowMinimize } from 'react-icons/fa6'; 5 | import { IoClose } from 'react-icons/io5'; 6 | import Navbar from '../../core/navbar/Navbar'; 7 | import HomeIndex from '../home/Home'; 8 | import Sidebar from '../../core/sidebar/Sidebar'; 9 | import ReferralActivity from '../referrals/ReferralActivity'; 10 | import Packages from '../packages/Packages'; 11 | import Credits from '../credits/Credits'; 12 | import PackageDetails from '../packages/PackageDetails'; 13 | import Timer from '../../core/timer'; 14 | import ShutDownModal from '../../core/shutDownModal'; 15 | import { useWallet } from '@solana/wallet-adapter-react'; 16 | import { registerUser } from '@/src/helpers/apis'; 17 | 18 | const MainPage = () => { 19 | const wallet = useWallet(); 20 | const { isOpen: isLogInOpen, onOpen: onLogInOpen, onClose: onLogInClose } = useDisclosure(); 21 | const { isOpen, onOpen, onClose } = useDisclosure(); 22 | const { isOpen: isStartOpen, onOpen: onStartOpen, onClose: onStartClose } = useDisclosure(); 23 | const [fullScreen, setFullScreen] = useState(false) 24 | const [pathname, setPathname] = useState('/') 25 | const [showCase, setShowCase] = useState(false) 26 | const [showReferralTab, setShowReferralTab] = useState(false); 27 | const [registerUserObj, setRegisterUserObj] = useState({ 28 | name: "", 29 | email: "", 30 | referralCode: "" 31 | }) 32 | const [displayPackage, setDisplayPackage]: any = useState({ 33 | name: "", 34 | price: 0, 35 | description: "" 36 | }); 37 | const [user, setUser] = useState({ 38 | name: "", 39 | email: "", 40 | referralCode: "", 41 | package_id: 0, 42 | commission: 0, 43 | credits: 0, 44 | totalReferred: 0, 45 | totalUserUnderMe: 0 46 | }) 47 | 48 | 49 | useEffect(() => { 50 | // onLogInOpen(); 51 | onOpen(); 52 | setShowCase(true) 53 | }, []); 54 | 55 | const openModal = () => { 56 | onOpen(); 57 | setShowCase(true) 58 | } 59 | const openModalClose = () => { 60 | onClose(); 61 | setShowCase(false) 62 | } 63 | const scrollbarHideStyles = { 64 | '&::-webkit-scrollbar': { 65 | display: 'none', 66 | }, 67 | '-ms-overflow-style': 'none', 68 | 'scrollbar-width': 'none', 69 | }; 70 | 71 | const callRegisterUser = async () => { 72 | const { name, email, referralCode} = registerUserObj; 73 | const walletAddress = wallet?.publicKey?.toString(); 74 | const response: any = await registerUser(name, email, referralCode, walletAddress); 75 | 76 | if(response?.status == 200) { 77 | localStorage.setItem("access_token", response.data.access_token); 78 | onLogInClose(); 79 | } 80 | } 81 | 82 | 83 | return ( 84 | 85 | 86 | img 87 | My Computer 88 | 89 | 90 | img 91 | MY FILES 92 | 93 | 94 | img 95 | Solana Referral 96 | 97 | 98 | img 99 | Recycle bin 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | Create an Account 120 | 121 | Name 122 | { 123 | setRegisterUserObj((prev) => ({...prev, name: e.target.value})) 124 | }} /> 125 | 126 | Email 127 | { 128 | setRegisterUserObj((prev) => ({...prev, email: e.target.value})) 129 | }} /> 130 | 131 | Referral ID (optional) 132 | { 133 | setRegisterUserObj((prev) => ({...prev, referralCode: e.target.value})) 134 | }} /> 135 | 136 | 137 | 140 | 143 | 144 | 145 | 146 | 147 | 148 | 153 | 154 | 155 | 156 | img 157 | 158 | 159 | https://solana-referral.vercel.app{pathname} 160 | 161 | 162 | 163 | 164 | 165 | {fullScreen ? 166 | setFullScreen(false)}> 167 | 168 | 169 | : 170 | setFullScreen(true)}> 171 | 172 | } 173 | 174 | 175 | 176 | 177 | 178 | 179 | 183 | 184 | 185 | 186 | 187 | 188 | 189 | 190 | {pathname === '/' && } 191 | {pathname === '/referral-activity' && } 192 | {pathname === '/packages' && } 193 | {pathname === '/packages-details' && } 194 | {pathname === '/credits' && } 195 | 196 | 197 | 198 | 199 | 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207 | 208 | 209 | {showCase && 210 | 223 | 224 | Solana Referral 225 | 226 | } 227 | 228 | 229 | 230 | 231 | ); 232 | }; 233 | 234 | export default MainPage; --------------------------------------------------------------------------------