├── .env.example ├── public ├── _redirects ├── robots.txt ├── favicon.ico ├── logo192.png ├── logo512.png ├── .htaccess ├── manifest.json └── index.html ├── src ├── pages │ ├── Raffle │ │ ├── raffle.error │ │ └── RaffleSwiper.tsx │ └── Auction │ │ ├── FilterAuction.tsx │ │ ├── Profile.tsx │ │ └── AuctionParticipant.tsx ├── react-app-env.d.ts ├── actions │ └── index.ts ├── assets │ ├── Coode.png │ ├── Logo.png │ ├── edit.png │ ├── Chevron.png │ ├── Coode-2.png │ ├── create.png │ ├── discord.png │ ├── idcard.png │ ├── profile.png │ ├── twitter.png │ ├── 2xsolution.png │ ├── Edit-icon.png │ ├── FilterIcon.png │ ├── Share-icon.png │ ├── Veiw-Icon.png │ ├── magic-icon.png │ ├── Report-icon.png │ ├── Union-icons.png │ ├── leaderboard.png │ ├── return-icon.png │ ├── search-icon.png │ ├── Discord-Black.png │ ├── InfoIconBlack.png │ ├── Select-NFT-Icon.png │ ├── Twitter-black.png │ ├── add-raffle-icon.png │ ├── discord-profile.png │ ├── pricetag-icon.png │ ├── sol-icon-black.png │ ├── solana-sol-icon.png │ ├── twitter-profile.png │ ├── Subtract-bid-icon.png │ ├── Verification-icon.png │ ├── Subtract-bought-icon.png │ ├── Subtract-ticket-icon.png │ ├── Subtract-timing-icon.png │ ├── Subtract.-date-icon.png │ ├── Verification-icon-2.png │ ├── Subtract-winning-icon.png │ ├── Subtract-sol-price-icon.png │ ├── Subtract-tiiming-auction.png │ ├── fonts │ │ └── Archia_Regular │ │ │ ├── Archia Regular Desktop │ │ │ ├── Archia-Regular.otf │ │ │ └── Archia_desktop_license.pdf │ │ │ └── Archia Regular Webfont │ │ │ ├── Archia_webfont_license.pdf │ │ │ ├── archia-regular-webfont.eot │ │ │ ├── archia-regular-webfont.ttf │ │ │ ├── archia-regular-webfont.woff │ │ │ ├── archia-regular-webfont.woff2 │ │ │ ├── stylesheet.css │ │ │ ├── generator_config.txt │ │ │ └── specimen_files │ │ │ └── grid_12-825-55-15.css │ ├── detailpage │ │ ├── return-icon.svg │ │ ├── per-ticket.svg │ │ ├── ticketsOwned-icon.svg │ │ ├── time-icon.svg │ │ ├── startDate-icon.svg │ │ ├── holder-icon.svg │ │ ├── ticketSelling-icon.svg │ │ └── winning-icon.svg │ ├── verification-icon.svg │ ├── fav-icon.svg │ ├── grey-fav-icon.svg │ ├── right_arrow.svg │ ├── leaderboard.svg │ ├── left_arrow.svg │ ├── profile.svg │ ├── twitter.svg │ ├── view_icon.svg │ ├── polygon-icon.svg │ ├── Vector.svg │ ├── create.svg │ ├── idcard.svg │ ├── discord.svg │ └── opensea-icon.svg ├── config │ ├── index.ts │ ├── main.ts │ └── dev.ts ├── setupTests.ts ├── App.test.tsx ├── contract │ ├── IRandomNumberGenerator.sol │ ├── erc1155tokenMint.sol │ ├── erc721mint.sol │ └── VRFv2DirectFundingConsumer.sol ├── reducers │ └── index.tsx ├── utils │ ├── setHeader.ts │ ├── validation │ │ ├── auction.ts │ │ └── raffle.ts │ └── index.ts ├── reportWebVitals.ts ├── index.css ├── components │ ├── NFTModal │ │ ├── index.css │ │ └── index.tsx │ ├── Menus.tsx │ ├── SwiperItem.tsx │ └── AuctionItem.tsx ├── index.tsx ├── services │ ├── common.service.ts │ ├── contracts │ │ ├── transferNFT.ts │ │ ├── raffle1155.ts │ │ ├── raffle.ts │ │ ├── auction.ts │ │ └── auction1155.ts │ └── api.ts ├── App.tsx ├── logo.svg ├── App.css └── constants │ └── Token │ ├── Erc1155Token.json │ └── Erc721Token.json ├── .gitattributes ├── backend ├── .env.example ├── .gitignore ├── tsconfig.json ├── contracts │ ├── IRandomNumberGenerator.sol │ ├── Lock.sol │ ├── erc1155tokenMint.sol │ ├── erc721mint.sol │ └── VRFv2DirectFundingConsumer.sol ├── README.md ├── hardhat.config.ts ├── package.json ├── scripts │ └── deploy.ts └── test │ └── Lock.ts ├── tailwind.config.js ├── .gitignore ├── tsconfig.json ├── package.json └── README.md /.env.example: -------------------------------------------------------------------------------- 1 | GENERATE_SOURCEMAP=false -------------------------------------------------------------------------------- /public/_redirects: -------------------------------------------------------------------------------- 1 | /* /index.html 200 -------------------------------------------------------------------------------- /src/pages/Raffle/raffle.error: -------------------------------------------------------------------------------- 1 | 2 | 13 3 | 12 4 | 10 5 | 1 -------------------------------------------------------------------------------- /src/react-app-env.d.ts: -------------------------------------------------------------------------------- 1 | /// 2 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | -------------------------------------------------------------------------------- /public/robots.txt: -------------------------------------------------------------------------------- 1 | # https://www.robotstxt.org/robotstxt.html 2 | User-agent: * 3 | Disallow: 4 | -------------------------------------------------------------------------------- /src/actions/index.ts: -------------------------------------------------------------------------------- 1 | export const CONNECT = (payload: any) => ({ 2 | type: `CONNECT`, payload 3 | }) -------------------------------------------------------------------------------- /public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stayForward09/Polygon_NFT_raffle/HEAD/public/favicon.ico -------------------------------------------------------------------------------- /public/logo192.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stayForward09/Polygon_NFT_raffle/HEAD/public/logo192.png -------------------------------------------------------------------------------- /public/logo512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stayForward09/Polygon_NFT_raffle/HEAD/public/logo512.png -------------------------------------------------------------------------------- /src/assets/Coode.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stayForward09/Polygon_NFT_raffle/HEAD/src/assets/Coode.png -------------------------------------------------------------------------------- /src/assets/Logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stayForward09/Polygon_NFT_raffle/HEAD/src/assets/Logo.png -------------------------------------------------------------------------------- /src/assets/edit.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stayForward09/Polygon_NFT_raffle/HEAD/src/assets/edit.png -------------------------------------------------------------------------------- /src/assets/Chevron.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stayForward09/Polygon_NFT_raffle/HEAD/src/assets/Chevron.png -------------------------------------------------------------------------------- /src/assets/Coode-2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stayForward09/Polygon_NFT_raffle/HEAD/src/assets/Coode-2.png -------------------------------------------------------------------------------- /src/assets/create.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stayForward09/Polygon_NFT_raffle/HEAD/src/assets/create.png -------------------------------------------------------------------------------- /src/assets/discord.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stayForward09/Polygon_NFT_raffle/HEAD/src/assets/discord.png -------------------------------------------------------------------------------- /src/assets/idcard.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stayForward09/Polygon_NFT_raffle/HEAD/src/assets/idcard.png -------------------------------------------------------------------------------- /src/assets/profile.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stayForward09/Polygon_NFT_raffle/HEAD/src/assets/profile.png -------------------------------------------------------------------------------- /src/assets/twitter.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stayForward09/Polygon_NFT_raffle/HEAD/src/assets/twitter.png -------------------------------------------------------------------------------- /src/assets/2xsolution.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stayForward09/Polygon_NFT_raffle/HEAD/src/assets/2xsolution.png -------------------------------------------------------------------------------- /src/assets/Edit-icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stayForward09/Polygon_NFT_raffle/HEAD/src/assets/Edit-icon.png -------------------------------------------------------------------------------- /src/assets/FilterIcon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stayForward09/Polygon_NFT_raffle/HEAD/src/assets/FilterIcon.png -------------------------------------------------------------------------------- /src/assets/Share-icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stayForward09/Polygon_NFT_raffle/HEAD/src/assets/Share-icon.png -------------------------------------------------------------------------------- /src/assets/Veiw-Icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stayForward09/Polygon_NFT_raffle/HEAD/src/assets/Veiw-Icon.png -------------------------------------------------------------------------------- /src/assets/magic-icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stayForward09/Polygon_NFT_raffle/HEAD/src/assets/magic-icon.png -------------------------------------------------------------------------------- /src/assets/Report-icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stayForward09/Polygon_NFT_raffle/HEAD/src/assets/Report-icon.png -------------------------------------------------------------------------------- /src/assets/Union-icons.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stayForward09/Polygon_NFT_raffle/HEAD/src/assets/Union-icons.png -------------------------------------------------------------------------------- /src/assets/leaderboard.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stayForward09/Polygon_NFT_raffle/HEAD/src/assets/leaderboard.png -------------------------------------------------------------------------------- /src/assets/return-icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stayForward09/Polygon_NFT_raffle/HEAD/src/assets/return-icon.png -------------------------------------------------------------------------------- /src/assets/search-icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stayForward09/Polygon_NFT_raffle/HEAD/src/assets/search-icon.png -------------------------------------------------------------------------------- /src/assets/Discord-Black.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stayForward09/Polygon_NFT_raffle/HEAD/src/assets/Discord-Black.png -------------------------------------------------------------------------------- /src/assets/InfoIconBlack.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stayForward09/Polygon_NFT_raffle/HEAD/src/assets/InfoIconBlack.png -------------------------------------------------------------------------------- /src/assets/Select-NFT-Icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stayForward09/Polygon_NFT_raffle/HEAD/src/assets/Select-NFT-Icon.png -------------------------------------------------------------------------------- /src/assets/Twitter-black.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stayForward09/Polygon_NFT_raffle/HEAD/src/assets/Twitter-black.png -------------------------------------------------------------------------------- /src/assets/add-raffle-icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stayForward09/Polygon_NFT_raffle/HEAD/src/assets/add-raffle-icon.png -------------------------------------------------------------------------------- /src/assets/discord-profile.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stayForward09/Polygon_NFT_raffle/HEAD/src/assets/discord-profile.png -------------------------------------------------------------------------------- /src/assets/pricetag-icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stayForward09/Polygon_NFT_raffle/HEAD/src/assets/pricetag-icon.png -------------------------------------------------------------------------------- /src/assets/sol-icon-black.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stayForward09/Polygon_NFT_raffle/HEAD/src/assets/sol-icon-black.png -------------------------------------------------------------------------------- /src/assets/solana-sol-icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stayForward09/Polygon_NFT_raffle/HEAD/src/assets/solana-sol-icon.png -------------------------------------------------------------------------------- /src/assets/twitter-profile.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stayForward09/Polygon_NFT_raffle/HEAD/src/assets/twitter-profile.png -------------------------------------------------------------------------------- /src/assets/Subtract-bid-icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stayForward09/Polygon_NFT_raffle/HEAD/src/assets/Subtract-bid-icon.png -------------------------------------------------------------------------------- /src/assets/Verification-icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stayForward09/Polygon_NFT_raffle/HEAD/src/assets/Verification-icon.png -------------------------------------------------------------------------------- /src/assets/Subtract-bought-icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stayForward09/Polygon_NFT_raffle/HEAD/src/assets/Subtract-bought-icon.png -------------------------------------------------------------------------------- /src/assets/Subtract-ticket-icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stayForward09/Polygon_NFT_raffle/HEAD/src/assets/Subtract-ticket-icon.png -------------------------------------------------------------------------------- /src/assets/Subtract-timing-icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stayForward09/Polygon_NFT_raffle/HEAD/src/assets/Subtract-timing-icon.png -------------------------------------------------------------------------------- /src/assets/Subtract.-date-icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stayForward09/Polygon_NFT_raffle/HEAD/src/assets/Subtract.-date-icon.png -------------------------------------------------------------------------------- /src/assets/Verification-icon-2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stayForward09/Polygon_NFT_raffle/HEAD/src/assets/Verification-icon-2.png -------------------------------------------------------------------------------- /src/assets/Subtract-winning-icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stayForward09/Polygon_NFT_raffle/HEAD/src/assets/Subtract-winning-icon.png -------------------------------------------------------------------------------- /src/assets/Subtract-sol-price-icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stayForward09/Polygon_NFT_raffle/HEAD/src/assets/Subtract-sol-price-icon.png -------------------------------------------------------------------------------- /src/assets/Subtract-tiiming-auction.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stayForward09/Polygon_NFT_raffle/HEAD/src/assets/Subtract-tiiming-auction.png -------------------------------------------------------------------------------- /backend/.env.example: -------------------------------------------------------------------------------- 1 | POLYGONSCAN_API_KEY="6GYHJ31VV3SAIGQRPZ5IA3BGA31FNW6YCK" 2 | PRIVATE_KEY="063e638bca539d7e04d7fd09bbbd74a6218332bb89d35129f34522103ad463f1" -------------------------------------------------------------------------------- /src/config/index.ts: -------------------------------------------------------------------------------- 1 | import * as CONFIG_DEV from './dev'; 2 | // import * as CONFIG_MAIN from './main'; 3 | 4 | const CONFIG = CONFIG_DEV; 5 | export default CONFIG; 6 | -------------------------------------------------------------------------------- /backend/.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | .env 3 | coverage 4 | coverage.json 5 | typechain 6 | typechain-types 7 | 8 | # Hardhat files 9 | cache 10 | artifacts 11 | 12 | -------------------------------------------------------------------------------- /src/assets/fonts/Archia_Regular/Archia Regular Desktop/Archia-Regular.otf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stayForward09/Polygon_NFT_raffle/HEAD/src/assets/fonts/Archia_Regular/Archia Regular Desktop/Archia-Regular.otf -------------------------------------------------------------------------------- /src/assets/fonts/Archia_Regular/Archia Regular Desktop/Archia_desktop_license.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stayForward09/Polygon_NFT_raffle/HEAD/src/assets/fonts/Archia_Regular/Archia Regular Desktop/Archia_desktop_license.pdf -------------------------------------------------------------------------------- /src/assets/fonts/Archia_Regular/Archia Regular Webfont/Archia_webfont_license.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stayForward09/Polygon_NFT_raffle/HEAD/src/assets/fonts/Archia_Regular/Archia Regular Webfont/Archia_webfont_license.pdf -------------------------------------------------------------------------------- /src/assets/fonts/Archia_Regular/Archia Regular Webfont/archia-regular-webfont.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stayForward09/Polygon_NFT_raffle/HEAD/src/assets/fonts/Archia_Regular/Archia Regular Webfont/archia-regular-webfont.eot -------------------------------------------------------------------------------- /src/assets/fonts/Archia_Regular/Archia Regular Webfont/archia-regular-webfont.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stayForward09/Polygon_NFT_raffle/HEAD/src/assets/fonts/Archia_Regular/Archia Regular Webfont/archia-regular-webfont.ttf -------------------------------------------------------------------------------- /src/assets/fonts/Archia_Regular/Archia Regular Webfont/archia-regular-webfont.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stayForward09/Polygon_NFT_raffle/HEAD/src/assets/fonts/Archia_Regular/Archia Regular Webfont/archia-regular-webfont.woff -------------------------------------------------------------------------------- /src/assets/fonts/Archia_Regular/Archia Regular Webfont/archia-regular-webfont.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stayForward09/Polygon_NFT_raffle/HEAD/src/assets/fonts/Archia_Regular/Archia Regular Webfont/archia-regular-webfont.woff2 -------------------------------------------------------------------------------- /src/setupTests.ts: -------------------------------------------------------------------------------- 1 | // jest-dom adds custom jest matchers for asserting on DOM nodes. 2 | // allows you to do things like: 3 | // expect(element).toHaveTextContent(/react/i) 4 | // learn more: https://github.com/testing-library/jest-dom 5 | import '@testing-library/jest-dom'; 6 | -------------------------------------------------------------------------------- /public/.htaccess: -------------------------------------------------------------------------------- 1 | 2 | RewriteEngine On 3 | RewriteBase / 4 | RewriteRule ^index\.html$ - [L] 5 | RewriteCond %{REQUEST_FILENAME} !-f 6 | RewriteCond %{REQUEST_FILENAME} !-d 7 | RewriteCond %{REQUEST_FILENAME} !-l 8 | RewriteRule . /index.html [L] 9 | -------------------------------------------------------------------------------- /backend/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "es2020", 4 | "module": "commonjs", 5 | "esModuleInterop": true, 6 | "forceConsistentCasingInFileNames": true, 7 | "strict": true, 8 | "skipLibCheck": true, 9 | "resolveJsonModule": true 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /src/App.test.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import { render, screen } from '@testing-library/react'; 3 | import App from './App'; 4 | 5 | test('renders learn react link', () => { 6 | render(); 7 | const linkElement = screen.getByText(/learn react/i); 8 | expect(linkElement).toBeInTheDocument(); 9 | }); 10 | -------------------------------------------------------------------------------- /tailwind.config.js: -------------------------------------------------------------------------------- 1 | /** @type {import('tailwindcss').Config} */ 2 | module.exports = { 3 | content: [ 4 | "./src/**/*.{js,jsx,ts,tsx}", 5 | ], 6 | theme: { 7 | extend: { 8 | colors: { 9 | coodePurle: "#9C37FD", 10 | coodeBlue: "#15BFFD", 11 | }, 12 | }, 13 | }, 14 | plugins: [], 15 | } -------------------------------------------------------------------------------- /src/contract/IRandomNumberGenerator.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: CC0-1.0 2 | pragma solidity ^0.8.4; 3 | 4 | interface IRandomNumberGenerator { 5 | function viewRandomResult() external view returns (uint256); 6 | 7 | function requestRandomWords() external; 8 | 9 | function setKeyHash(bytes32 _keyHash) external; 10 | } -------------------------------------------------------------------------------- /backend/contracts/IRandomNumberGenerator.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: CC0-1.0 2 | pragma solidity ^0.8.4; 3 | 4 | interface IRandomNumberGenerator { 5 | function viewRandomResult() external view returns (uint256); 6 | 7 | function requestRandomWords() external; 8 | 9 | function setKeyHash(bytes32 _keyHash) external; 10 | } -------------------------------------------------------------------------------- /src/assets/detailpage/return-icon.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /backend/README.md: -------------------------------------------------------------------------------- 1 | # Sample Hardhat Project 2 | 3 | This project demonstrates a basic Hardhat use case. It comes with a sample contract, a test for that contract, and a script that deploys that contract. 4 | 5 | Try running some of the following tasks: 6 | 7 | ```shell 8 | npx hardhat help 9 | npx hardhat test 10 | REPORT_GAS=true npx hardhat test 11 | npx hardhat node 12 | npx hardhat run scripts/deploy.ts 13 | ``` 14 | -------------------------------------------------------------------------------- /src/reducers/index.tsx: -------------------------------------------------------------------------------- 1 | 2 | const INITAL_STATE = { 3 | wallet: ``, 4 | address: `` 5 | }; 6 | 7 | const reducer: any = (state = INITAL_STATE, action: any) => { 8 | switch (action.type) { 9 | case "CONNECT": 10 | return { 11 | ...state, 12 | wallet: action.payload.wallet, 13 | address: action.payload.address 14 | }; 15 | default: 16 | return state; 17 | } 18 | }; 19 | export default reducer; 20 | -------------------------------------------------------------------------------- /.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 | 8 | # testing 9 | /coverage 10 | 11 | /.vscode 12 | 13 | # production 14 | /build 15 | 16 | # misc 17 | .DS_Store 18 | .env.local 19 | .env.development.local 20 | .env.test.local 21 | .env.production.local 22 | 23 | npm-debug.log* 24 | yarn-debug.log* 25 | yarn-error.log* 26 | 27 | /backend/node_modules 28 | -------------------------------------------------------------------------------- /src/utils/setHeader.ts: -------------------------------------------------------------------------------- 1 | export default function setHeader( 2 | header: 3 | | { 4 | autherization?: string; 5 | contentType?: string; 6 | } 7 | | undefined 8 | ): object { 9 | return { 10 | Accept: "*/*", 11 | "Content-Type": header?.contentType || "application/json", 12 | "Access-Control-Allow-Origin": "http://localhost:3000", 13 | "Access-Control-Allow-Credentials": "true", 14 | //`Bearer ${header?.autherization}`, 15 | }; 16 | } 17 | -------------------------------------------------------------------------------- /src/reportWebVitals.ts: -------------------------------------------------------------------------------- 1 | import { ReportHandler } from 'web-vitals'; 2 | 3 | const reportWebVitals = (onPerfEntry?: ReportHandler) => { 4 | if (onPerfEntry && onPerfEntry instanceof Function) { 5 | import('web-vitals').then(({ getCLS, getFID, getFCP, getLCP, getTTFB }) => { 6 | getCLS(onPerfEntry); 7 | getFID(onPerfEntry); 8 | getFCP(onPerfEntry); 9 | getLCP(onPerfEntry); 10 | getTTFB(onPerfEntry); 11 | }); 12 | } 13 | }; 14 | 15 | export default reportWebVitals; 16 | -------------------------------------------------------------------------------- /src/index.css: -------------------------------------------------------------------------------- 1 | @tailwind base; 2 | @tailwind components; 3 | @tailwind utilities; 4 | 5 | body { 6 | margin: 0; 7 | font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 8 | 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', 9 | sans-serif; 10 | -webkit-font-smoothing: antialiased; 11 | -moz-osx-font-smoothing: grayscale; 12 | background: white 13 | } 14 | 15 | code { 16 | font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New', 17 | monospace; 18 | } -------------------------------------------------------------------------------- /src/assets/verification-icon.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /public/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "short_name": "React App", 3 | "name": "Create React App Sample", 4 | "icons": [ 5 | { 6 | "src": "favicon.ico", 7 | "sizes": "64x64 32x32 24x24 16x16", 8 | "type": "image/x-icon" 9 | }, 10 | { 11 | "src": "logo192.png", 12 | "type": "image/png", 13 | "sizes": "192x192" 14 | }, 15 | { 16 | "src": "logo512.png", 17 | "type": "image/png", 18 | "sizes": "512x512" 19 | } 20 | ], 21 | "start_url": ".", 22 | "display": "standalone", 23 | "theme_color": "#000000", 24 | "background_color": "#ffffff" 25 | } 26 | -------------------------------------------------------------------------------- /src/assets/fonts/Archia_Regular/Archia Regular Webfont/stylesheet.css: -------------------------------------------------------------------------------- 1 | /*! Generated by Font Squirrel (https://www.fontsquirrel.com) on September 12, 2017 */ 2 | 3 | 4 | 5 | @font-face { 6 | font-family: 'archiaregular'; 7 | src: url('archia-regular-webfont.eot'); 8 | src: url('archia-regular-webfont.eot?#iefix') format('embedded-opentype'), 9 | url('archia-regular-webfont.woff2') format('woff2'), 10 | url('archia-regular-webfont.woff') format('woff'), 11 | url('archia-regular-webfont.ttf') format('truetype'); 12 | font-weight: normal; 13 | font-style: normal; 14 | 15 | } -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "es5", 4 | "lib": [ 5 | "dom", 6 | "dom.iterable", 7 | "esnext" 8 | ], 9 | "allowJs": true, 10 | "skipLibCheck": true, 11 | "esModuleInterop": true, 12 | "allowSyntheticDefaultImports": true, 13 | "strict": true, 14 | "forceConsistentCasingInFileNames": true, 15 | "noFallthroughCasesInSwitch": true, 16 | "module": "esnext", 17 | "moduleResolution": "node", 18 | "resolveJsonModule": true, 19 | "isolatedModules": true, 20 | "noEmit": true, 21 | "jsx": "react-jsx" 22 | }, 23 | "include": [ 24 | "src" 25 | ] 26 | } 27 | -------------------------------------------------------------------------------- /src/assets/fav-icon.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /src/assets/grey-fav-icon.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /src/assets/fonts/Archia_Regular/Archia Regular Webfont/generator_config.txt: -------------------------------------------------------------------------------- 1 | # Font Squirrel Font-face Generator Configuration File 2 | # Upload this file to the generator to recreate the settings 3 | # you used to create these fonts. 4 | 5 | {"mode":"expert","formats":["ttf","woff","woff2","eotz"],"tt_instructor":"keep","fix_gasp":"xy","fix_vertical_metrics":"C","metrics_ascent":"","metrics_descent":"","metrics_linegap":"","add_spaces":"Y","add_hyphens":"Y","fallback":"none","fallback_custom":"100","webonly":"Y","options_subset":"none","subset_custom":"","subset_custom_range":"","subset_ot_features_list":"","css_stylesheet":"stylesheet.css","filename_suffix":"-webfont","spacing_adjustment":"0","rememberme":"Y"} -------------------------------------------------------------------------------- /backend/hardhat.config.ts: -------------------------------------------------------------------------------- 1 | import { HardhatUserConfig } from "hardhat/config"; 2 | import "@nomicfoundation/hardhat-toolbox"; 3 | import "dotenv/config"; 4 | 5 | const config: HardhatUserConfig = { 6 | defaultNetwork: "polygon_mumbai", 7 | networks: { 8 | hardhat: { 9 | }, 10 | polygon_mumbai: { 11 | url: "https://rpc-mumbai.maticvigil.com", 12 | accounts: [process.env.PRIVATE_KEY ?? ''] 13 | }, 14 | polygon_mainnet: { 15 | url: "https://polygon-rpc.com", 16 | accounts: [process.env.PRIVATE_KEY ?? ''] 17 | } 18 | }, 19 | solidity: "0.8.15", 20 | etherscan: { 21 | apiKey: process.env.POLYGONSCAN_API_KEY 22 | }, 23 | }; 24 | 25 | export default config; 26 | -------------------------------------------------------------------------------- /src/assets/detailpage/per-ticket.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /src/components/NFTModal/index.css: -------------------------------------------------------------------------------- 1 | #loader { 2 | position: absolute; 3 | top: 0; 4 | left: 0; 5 | right: 0; 6 | bottom: 0; 7 | z-index: 9999; 8 | overflow: hidden; 9 | background: black; 10 | opacity: 0.5; 11 | display: flex; 12 | justify-content: center; 13 | align-items: center; 14 | font-size: 30px; 15 | color: white; 16 | } 17 | 18 | #loader:before { 19 | content: ""; 20 | position: fixed; 21 | top: calc(50% - 30px); 22 | left: calc(50% - 30px); 23 | border: 6px solid #73469B; 24 | border-top-color: #e2eefd; 25 | border-radius: 50%; 26 | width: 60px; 27 | height: 60px; 28 | -webkit-animation: animate-preloader 1s linear infinite; 29 | animation: animate-preloader 1s linear infinite; 30 | } 31 | -------------------------------------------------------------------------------- /src/assets/right_arrow.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /src/config/main.ts: -------------------------------------------------------------------------------- 1 | export const CLUSTER = 'mainnet-beta'; 2 | export const COMMITMENT = 'finalized'; 3 | export const PROGRAM_ID = '4iGRmM8WkFTFk9F9pgfuTmN9UAeCZrWScK4eK8Xn8E4f'; 4 | export const REWARD_TOKEN = '6k8KkV7AZfHe14a1XeToQ2pcueKnJkP4tmk1en6CVtzz'; 5 | export const POOL_SEED = 'pool'; 6 | export const POOL_DATA_SEED = 'pool data'; 7 | export const VAULT_SEEDS = 'vault'; 8 | export const CREATOR_ADDRESS = '9E8FFC38qCM6hEDPDTxxz8xNVqZdCt7PLKhxGrzE9mDq' 9 | export const CLUSTER_API = 'https://thrumming-dry-cherry.solana-mainnet.discover.quiknode.pro/3851e219eac68c2f03f9cccd6a5363fde691b3e5/'; 10 | 11 | export const SOLANA_NETWORK = 'mainnet-beta'; 12 | 13 | export const METHODS = [ 14 | { days: 5, reward: 5, str: `5 days` }, 15 | { days: 10, reward: 7, str: `10 days` } 16 | ]; 17 | export const DAY_TIME = 86400; -------------------------------------------------------------------------------- /src/assets/leaderboard.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /src/assets/left_arrow.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /src/assets/profile.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /src/assets/detailpage/ticketsOwned-icon.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /src/assets/detailpage/time-icon.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /src/index.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import ReactDOM from 'react-dom/client'; 3 | import './index.css'; 4 | import App from './App'; 5 | import reportWebVitals from './reportWebVitals'; 6 | import { Provider } from 'react-redux' 7 | import { createStore, applyMiddleware } from 'redux' 8 | import reduxThunk from 'redux-thunk' 9 | import reducers from './reducers' 10 | 11 | 12 | const createStoreWithMiddlewares = applyMiddleware(reduxThunk)(createStore); 13 | const store = createStoreWithMiddlewares(reducers) 14 | 15 | const root = ReactDOM.createRoot( 16 | document.getElementById('root') as HTMLElement 17 | ); 18 | root.render( 19 | 20 | 21 | 22 | 23 | 24 | ); 25 | 26 | // If you want to start measuring performance in your app, pass a function 27 | // to log results (for example: reportWebVitals(console.log)) 28 | // or send to an analytics endpoint. Learn more: https://bit.ly/CRA-vitals 29 | reportWebVitals(); 30 | -------------------------------------------------------------------------------- /src/assets/twitter.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /src/utils/validation/auction.ts: -------------------------------------------------------------------------------- 1 | import { toast } from "react-toastify" 2 | 3 | export const validationAuction = (auction: any) => { 4 | if (auction.project === '') { 5 | toast.error(`Input Project Name`) 6 | return 7 | } 8 | 9 | if (auction.image === '') { 10 | toast.error(`Select Image`) 11 | return false 12 | } 13 | 14 | if (auction.price <= 0) { 15 | toast.error(`Price must bigger than 0`) 16 | return false 17 | } 18 | 19 | if (auction.start_date.getTime() <= Date.now()) { 20 | toast.error(`Start Time must bigger than now`) 21 | return false 22 | } 23 | 24 | if (auction.end_date.getTime() <= Date.now()) { 25 | toast.error(`End Time must bigger than Start Time`) 26 | return false 27 | } 28 | 29 | if (auction.twitter === '') { 30 | toast.error(`Input Twitter`) 31 | return false 32 | } 33 | if (auction.discord === '') { 34 | toast.error(`Input Discord`) 35 | return false 36 | } 37 | if (auction.description === '') { 38 | toast.error(`Input Description`) 39 | return false 40 | } 41 | 42 | return true 43 | } -------------------------------------------------------------------------------- /src/assets/view_icon.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /src/assets/detailpage/startDate-icon.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /src/services/common.service.ts: -------------------------------------------------------------------------------- 1 | import axios, { 2 | AxiosResponse, 3 | AxiosError, 4 | AxiosPromise, 5 | Method, 6 | AxiosRequestHeaders, 7 | } from "axios"; 8 | 9 | import setHeader from "../utils/setHeader"; 10 | 11 | type AxiosReturn = Promise>; 12 | 13 | interface ServiceParams { 14 | method: Method; 15 | route: string; 16 | headerCred?: { 17 | autherization?: string; 18 | contentType?: string; 19 | }; 20 | data?: object | string; 21 | } 22 | 23 | export default async ({ 24 | method, 25 | route, 26 | headerCred, 27 | data, 28 | }: ServiceParams): Promise> => { 29 | const headers = setHeader(headerCred) as AxiosRequestHeaders; 30 | console.log('route',route) 31 | try{ 32 | const response: AxiosResponse = await axios({ 33 | method, 34 | url: route, 35 | headers, 36 | data, 37 | }); 38 | if (response.data?.data) { 39 | return response.data.data; 40 | } 41 | return response.data; 42 | } catch(err:any) { 43 | console.log('error', err) 44 | return err; 45 | } 46 | }; 47 | -------------------------------------------------------------------------------- /backend/contracts/Lock.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: UNLICENSED 2 | pragma solidity ^0.8.9; 3 | 4 | // Uncomment this line to use console.log 5 | // import "hardhat/console.sol"; 6 | 7 | contract Lock { 8 | uint public unlockTime; 9 | address payable public owner; 10 | 11 | event Withdrawal(uint amount, uint when); 12 | 13 | constructor(uint _unlockTime) payable { 14 | require( 15 | block.timestamp < _unlockTime, 16 | "Unlock time should be in the future" 17 | ); 18 | 19 | unlockTime = _unlockTime; 20 | owner = payable(msg.sender); 21 | } 22 | 23 | function withdraw() public { 24 | // Uncomment this line, and the import of "hardhat/console.sol", to print a log in your terminal 25 | // console.log("Unlock time is %o and block timestamp is %o", unlockTime, block.timestamp); 26 | 27 | require(block.timestamp >= unlockTime, "You can't withdraw yet"); 28 | require(msg.sender == owner, "You aren't the owner"); 29 | 30 | emit Withdrawal(address(this).balance, block.timestamp); 31 | 32 | owner.transfer(address(this).balance); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /backend/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "backend", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "index.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1" 8 | }, 9 | "author": "", 10 | "license": "ISC", 11 | "devDependencies": { 12 | "@nomicfoundation/hardhat-chai-matchers": "^2.0.1", 13 | "@nomicfoundation/hardhat-ethers": "^3.0.2", 14 | "@nomicfoundation/hardhat-network-helpers": "^1.0.8", 15 | "@nomicfoundation/hardhat-toolbox": "^3.0.0", 16 | "@nomicfoundation/hardhat-verify": "^1.0.2", 17 | "@typechain/ethers-v6": "^0.4.0", 18 | "@typechain/hardhat": "^8.0.0", 19 | "@types/chai": "^4.3.5", 20 | "@types/mocha": "^10.0.1", 21 | "@types/node": "^20.3.1", 22 | "chai": "^4.3.7", 23 | "ethers": "^6.6.1", 24 | "hardhat": "^2.16.0", 25 | "hardhat-gas-reporter": "^1.0.9", 26 | "solidity-coverage": "^0.8.3", 27 | "ts-node": "^10.9.1", 28 | "typechain": "^8.2.0", 29 | "typescript": "^5.1.3" 30 | }, 31 | "dependencies": { 32 | "@chainlink/contracts": "^0.6.1", 33 | "@openzeppelin/contracts": "^4.9.2", 34 | "dotenv": "^16.3.1" 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/App.tsx: -------------------------------------------------------------------------------- 1 | import { BrowserRouter, Routes, Route } from "react-router-dom"; 2 | 3 | import Raffle from "./pages/Raffle/Raffle"; 4 | import CreateRaffle from "./pages/Raffle/CreateRaffle"; 5 | import DetailRaffle from "./pages/Raffle/DetailRaffle"; 6 | import DetailRaffle1155 from "./pages/Raffle/DetailRaffle1155"; 7 | import EditRaffle from "./pages/Raffle/EditRaffle"; 8 | import RaffleProfile from "./pages/Raffle/Profile"; 9 | 10 | import "./App.css"; 11 | import LeaderBoard from "./pages/LeaderBoard/LeaderBoard"; 12 | 13 | 14 | const App = () => { 15 | return ( 16 | 17 | 18 | } /> 19 | } /> 20 | } /> 21 | } /> 22 | } /> 23 | } /> 24 | } /> 25 | 26 | 27 | ); 28 | }; 29 | 30 | export default App; 31 | -------------------------------------------------------------------------------- /src/utils/validation/raffle.ts: -------------------------------------------------------------------------------- 1 | import { toast } from "react-toastify" 2 | 3 | export const validationRaffle = (raffle: any) => { 4 | // if (raffle.project === '') { 5 | // toast.error(`Input Project Name`) 6 | // return 7 | // } 8 | 9 | if (raffle.image === '') { 10 | toast.error(`Select Image`) 11 | return false 12 | } 13 | 14 | if (raffle.price <= 0) { 15 | toast.error(`Price must bigger than 0`) 16 | return false 17 | } 18 | 19 | if (raffle.start_date.getTime() <= Date.now()) { 20 | toast.error(`Start Time must bigger than now`) 21 | return false 22 | } 23 | 24 | if (raffle.end_date.getTime() <= Date.now()) { 25 | toast.error(`End Time must bigger than Start Time`) 26 | return false 27 | } 28 | 29 | if (raffle.total_tickets <= 0) { 30 | toast.error(`Max Amount must bigger than 0`) 31 | return false 32 | } 33 | 34 | // if (raffle.twitter === '') { 35 | // toast.error(`Input Twitter`) 36 | // return false 37 | // } 38 | // if (raffle.discord === '') { 39 | // toast.error(`Input Discord`) 40 | // return false 41 | // } 42 | // if (raffle.description === '') { 43 | // toast.error(`Input Description`) 44 | // return false 45 | // } 46 | 47 | return true 48 | } -------------------------------------------------------------------------------- /src/assets/detailpage/holder-icon.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /src/assets/detailpage/ticketSelling-icon.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /backend/scripts/deploy.ts: -------------------------------------------------------------------------------- 1 | import { ethers } from "hardhat"; 2 | 3 | async function main() { 4 | 5 | const raffle721 = await ethers.deployContract("nft721Raffle"); 6 | await raffle721.waitForDeployment(); 7 | console.log('raffle721 deployed to:', raffle721.target); 8 | 9 | const raffle1155 = await ethers.deployContract("nft1155Raffle"); 10 | await raffle1155.waitForDeployment(); 11 | console.log('raffle1155 deployed to:', raffle1155.target); 12 | 13 | const auction721 = await ethers.deployContract("nft721Auction"); 14 | await auction721.waitForDeployment(); 15 | console.log('auction721 deployed to:', auction721.target); 16 | 17 | const auction1155 = await ethers.deployContract("nft1155Auction"); 18 | await auction1155.waitForDeployment(); 19 | console.log('auction1155 deployed to:', auction1155.target); 20 | 21 | await raffle721.transferOwnership("0x398818ca588209Fec5348e6CA901629C553c902E"); 22 | await raffle1155.transferOwnership("0x398818ca588209Fec5348e6CA901629C553c902E"); 23 | await auction721.transferOwnership("0x398818ca588209Fec5348e6CA901629C553c902E"); 24 | await auction1155.transferOwnership("0x398818ca588209Fec5348e6CA901629C553c902E"); 25 | } 26 | 27 | // We recommend this pattern to be able to use async/await everywhere 28 | // and properly handle errors. 29 | main().catch((error) => { 30 | console.error(error); 31 | process.exitCode = 1; 32 | }); 33 | -------------------------------------------------------------------------------- /src/assets/polygon-icon.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /src/contract/erc1155tokenMint.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | pragma solidity ^0.8.11; 3 | 4 | import "@openzeppelin/contracts/token/ERC1155/extensions/ERC1155Supply.sol"; 5 | import "@openzeppelin/contracts/token/ERC1155/extensions/ERC1155URIStorage.sol"; 6 | import "@openzeppelin/contracts/access/Ownable.sol"; 7 | import "@openzeppelin/contracts/utils/cryptography/MerkleProof.sol"; 8 | import "@openzeppelin/contracts/utils/Strings.sol"; 9 | 10 | contract MyNFT is ERC1155URIStorage { 11 | 12 | constructor(string memory uri_) ERC1155(uri_){ 13 | // _setBaseURI("https://ipfs.io/ipfs/QmRiLKmhizpnwqpHGeiJnL4G6fsPAxdEdCiDkuJpt7xHPH/"); 14 | } 15 | 16 | // mint NFT 17 | function mint(uint256 amount, string memory uri) public { 18 | for(uint256 i = 1 ; i<=31 ; i ++) { 19 | _mint(msg.sender, i, amount,""); 20 | _setURI(i, string(abi.encodePacked(uri, Strings.toString(i), ".json"))); 21 | } 22 | } 23 | 24 | // get NFT metadata 25 | function getNFTMetadata(uint256 id) public view returns (string memory) { 26 | return uri(id); 27 | } 28 | 29 | // function bytes32ToString (bytes32 data) returns (string) { 30 | // bytes memory bytesString = new bytes(32); 31 | // for (uint j=0; j<32; j++) { 32 | // byte char = byte(bytes32(uint(data) * 2 ** (8 * j))); 33 | // if (char != 0) { 34 | // bytesString[j] = char; 35 | // } 36 | // } 37 | 38 | // return string(bytesString); 39 | // } 40 | } -------------------------------------------------------------------------------- /backend/contracts/erc1155tokenMint.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | pragma solidity ^0.8.11; 3 | 4 | import "@openzeppelin/contracts/token/ERC1155/extensions/ERC1155Supply.sol"; 5 | import "@openzeppelin/contracts/token/ERC1155/extensions/ERC1155URIStorage.sol"; 6 | import "@openzeppelin/contracts/access/Ownable.sol"; 7 | import "@openzeppelin/contracts/utils/cryptography/MerkleProof.sol"; 8 | import "@openzeppelin/contracts/utils/Strings.sol"; 9 | 10 | contract MyNFT is ERC1155URIStorage { 11 | 12 | constructor(string memory uri_) ERC1155(uri_){ 13 | // _setBaseURI("https://ipfs.io/ipfs/QmRiLKmhizpnwqpHGeiJnL4G6fsPAxdEdCiDkuJpt7xHPH/"); 14 | } 15 | 16 | // mint NFT 17 | function mint(uint256 amount, string memory uri) public { 18 | for(uint256 i = 1 ; i<=31 ; i ++) { 19 | _mint(msg.sender, i, amount,""); 20 | _setURI(i, string(abi.encodePacked(uri, Strings.toString(i), ".json"))); 21 | } 22 | } 23 | 24 | // get NFT metadata 25 | function getNFTMetadata(uint256 id) public view returns (string memory) { 26 | return uri(id); 27 | } 28 | 29 | // function bytes32ToString (bytes32 data) returns (string) { 30 | // bytes memory bytesString = new bytes(32); 31 | // for (uint j=0; j<32; j++) { 32 | // byte char = byte(bytes32(uint(data) * 2 ** (8 * j))); 33 | // if (char != 0) { 34 | // bytesString[j] = char; 35 | // } 36 | // } 37 | 38 | // return string(bytesString); 39 | // } 40 | } -------------------------------------------------------------------------------- /src/assets/detailpage/winning-icon.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "frontend", 3 | "version": "0.1.0", 4 | "private": true, 5 | "dependencies": { 6 | "@testing-library/jest-dom": "^5.16.5", 7 | "@testing-library/react": "^13.4.0", 8 | "@testing-library/user-event": "^13.5.0", 9 | "@types/jest": "^27.5.2", 10 | "@types/node": "^16.18.23", 11 | "@types/react": "^18.0.31", 12 | "@types/react-dom": "^18.0.11", 13 | "axios": "^1.3.4", 14 | "base58": "^2.0.1", 15 | "bignumber.js": "^9.1.1", 16 | "bs58": "^5.0.0", 17 | "ethers": "^5.7.2", 18 | "react": "^18.2.0", 19 | "react-countdown": "^2.3.5", 20 | "react-dom": "^18.2.0", 21 | "react-redux": "^8.0.5", 22 | "react-router-dom": "^6.10.0", 23 | "react-scripts": "5.0.1", 24 | "react-select": "^5.7.2", 25 | "react-toastify": "^9.1.2", 26 | "redux": "^4.2.0", 27 | "redux-thunk": "^2.4.2", 28 | "swiper": "^9.2.2", 29 | "typescript": "^4.9.5", 30 | "wagmi": "^0.12.9", 31 | "web-vitals": "^2.1.4", 32 | "web3": "^1.9.0" 33 | }, 34 | "scripts": { 35 | "start": "react-scripts start", 36 | "build": "react-scripts build", 37 | "test": "react-scripts test", 38 | "eject": "react-scripts eject" 39 | }, 40 | "eslintConfig": { 41 | "extends": [ 42 | "react-app", 43 | "react-app/jest" 44 | ] 45 | }, 46 | "browserslist": { 47 | "production": [ 48 | ">0.2%", 49 | "not dead", 50 | "not op_mini all" 51 | ], 52 | "development": [ 53 | "last 1 chrome version", 54 | "last 1 firefox version", 55 | "last 1 safari version" 56 | ] 57 | }, 58 | "devDependencies": { 59 | "tailwindcss": "^3.3.0" 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /src/assets/Vector.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /src/config/dev.ts: -------------------------------------------------------------------------------- 1 | import Raffle721Abi from '../constants/Raffle/RaffleErc721.json' 2 | import Raffle1155Abi from '../constants/Raffle/Raffle1155.json' 3 | import Auction721Abi from '../constants/Auction/AuctionErc721.json' 4 | import Auction1155Abi from '../constants/Auction/AuctionErc1155.json' 5 | import TokenErc721 from '../constants/Token/Erc721Token.json' 6 | import TokenErc1155 from '../constants/Token/Erc1155Token.json' 7 | 8 | export const Backend_URL = 'https://novaraffle-b98cb5f11cc1.herokuapp.com/' 9 | // export const Backend_URL = 'http://localhost:5000' 10 | 11 | export const API_URL = `${Backend_URL}/api` 12 | 13 | export const RAFFLE = { 14 | CONTRACTADDRESS721: `0xF915D954095FB08E3352963d00Cbe258e0AB536D`, 15 | ABI721: Raffle721Abi, 16 | CONTRACTADDRESS1155: `0x3Dfab437F4fa586503d5d08dEE9ac71AfCa52b6E`, 17 | ABI1155: Raffle1155Abi, 18 | } 19 | 20 | export const AUCTION = { 21 | CONTRACTADDRESS721: `0x2F65d49b83bB2AD6bf32aadDc0F9B17167d09E9c`, 22 | ABI721: Auction721Abi, 23 | CONTRACTADDRESS1155: `0xDa2c07fa6A7B093893a1eb6D701Cf54C2c07b06F`, 24 | ABI1155: Auction1155Abi, 25 | 26 | } 27 | 28 | export const TOKENERC721 = TokenErc721 29 | export const TOKENERC1155 = TokenErc1155 30 | 31 | export const TOAST_TIME_OUT = 2000; 32 | export const INTERVAL = 6 * 1000; 33 | export const DECIMAL = 1000000000000000000 34 | // export const CHAINID = '0x5' //Goerli 35 | // export const CHAINID = '0x13881' //Mumbai 36 | export const CHAINID = '0x89' //polygon 37 | 38 | export const WALLET_STATUS_LOCALSTORAGE = 'wallet' 39 | export const WALLET_ADRESS_LOCALSTORAGE = 'wallet_address' 40 | export const DEFAUL_NONE_WINNER = '0x0000000000000000000000000000000000000000' 41 | export const SIGN_KEY = 'VERIFY WALLET'; 42 | -------------------------------------------------------------------------------- /public/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 15 | 16 | 25 | Polygon Raffle 26 | 27 | 28 | 29 | 30 |
31 | 41 | 42 | 43 | -------------------------------------------------------------------------------- /src/assets/create.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /src/services/contracts/transferNFT.ts: -------------------------------------------------------------------------------- 1 | import { ethers, Contract } from "ethers"; 2 | import CONFIG from "../../config"; 3 | 4 | export const TransferNFT721 = async (setLoading: any) => { 5 | try { 6 | setLoading(true) 7 | const mywallet = '0x45b07A8080Ed16E7F43e2680542519b60B1c7F4f' 8 | const tokenContract = '0xe81788Ee64B306E30b3B15492DD6FBC0C0fcCc7f' 9 | const tokenId = 30 10 | const receiver = '0x91e71EbcF38b82e4d3084219f97f617022Af4de9' 11 | 12 | const Provider: any = new ethers.providers.Web3Provider(window.ethereum); 13 | const signer = Provider.getSigner(); 14 | const TokenContract = new Contract(tokenContract, CONFIG.TOKENERC721, signer) 15 | const approveTx = await TokenContract.approve(receiver, tokenId) 16 | await approveTx.wait() 17 | 18 | const tx = await TokenContract.transferFrom(mywallet, receiver, tokenId) 19 | await tx.wait() 20 | 21 | 22 | setLoading(false) 23 | 24 | } catch (error) { 25 | console.log('error', error) 26 | setLoading(false) 27 | 28 | } 29 | } 30 | 31 | export const TransferNFT1155 = async (setLoading: any) => { 32 | try { 33 | setLoading(true) 34 | const mywallet = '0x45b07A8080Ed16E7F43e2680542519b60B1c7F4f' 35 | const tokenContract = '0x12e1da203b3e47c4e36ce7a19f1fd656b4491f31' 36 | const tokenId = 12 37 | const tokenAmount = 5 38 | const receiver = '0x91e71EbcF38b82e4d3084219f97f617022Af4de9' 39 | 40 | const Provider: any = new ethers.providers.Web3Provider(window.ethereum); 41 | const signer = Provider.getSigner(); 42 | const TokenContract = new Contract(tokenContract, CONFIG.TOKENERC1155, signer) 43 | const approveTx = await TokenContract.setApprovalForAll(receiver, tokenId) 44 | await approveTx.wait() 45 | 46 | const tx = await TokenContract.safeTransferFrom(mywallet, receiver, tokenId, tokenAmount, []) 47 | await tx.wait() 48 | 49 | setLoading(false) 50 | 51 | } catch (error) { 52 | console.log('error', error) 53 | setLoading(false) 54 | 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Getting Started with Create React App 2 | 3 | This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app). 4 | 5 | ## Available Scripts 6 | 7 | In the project directory, you can run: 8 | 9 | ### `npm start` 10 | 11 | Runs the app in the development mode.\ 12 | Open [http://localhost:3000](http://localhost:3000) to view it in the browser. 13 | 14 | The page will reload if you make edits.\ 15 | You will also see any lint errors in the console. 16 | 17 | ### `npm test` 18 | 19 | Launches the test runner in the interactive watch mode.\ 20 | See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information. 21 | 22 | ### `npm run build` 23 | 24 | Builds the app for production to the `build` folder.\ 25 | It correctly bundles React in production mode and optimizes the build for the best performance. 26 | 27 | The build is minified and the filenames include the hashes.\ 28 | Your app is ready to be deployed! 29 | 30 | See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information. 31 | 32 | ### `npm run eject` 33 | 34 | **Note: this is a one-way operation. Once you `eject`, you can’t go back!** 35 | 36 | If you aren’t satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project. 37 | 38 | Instead, it will copy all the configuration files and the transitive dependencies (webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you’re on your own. 39 | 40 | You don’t have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn’t feel obligated to use this feature. However we understand that this tool wouldn’t be useful if you couldn’t customize it when you are ready for it. 41 | 42 | ## Learn More 43 | 44 | You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started). 45 | 46 | To learn React, check out the [React documentation](https://reactjs.org/). 47 | -------------------------------------------------------------------------------- /src/assets/idcard.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /src/assets/discord.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /src/logo.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/contract/erc721mint.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | 3 | pragma solidity ^0.8.15; 4 | 5 | // import "./erc721a/contracts/ERC721A.sol"; 6 | import "@openzeppelin/contracts/token/ERC721/extensions/ERC721Enumerable.sol"; 7 | import "@openzeppelin/contracts/access/Ownable.sol"; 8 | import "@openzeppelin/contracts/utils/Strings.sol"; 9 | 10 | contract ApeGalacticClubMint is ERC721Enumerable, Ownable { 11 | using Strings for uint256; 12 | 13 | string private baseURI; 14 | string public baseExtension = ".json"; 15 | uint256 public cost = 5000000000000000 wei; /// 0.005 eth 16 | uint256 public maxFreeMintAmount = 10; 17 | uint256 public maxPayMintAmount = 50; 18 | uint256 public teamMintAmount = 30; 19 | 20 | uint256 public constant MAX_BATCH_SIZE = 100; 21 | uint256 public constant MAX_SUPPLY = 10000; 22 | uint256 public freeSupply = 2500; 23 | 24 | uint256 public contributorProfit = 75; // 7.5% 25 | uint256 public developerProfit = 15; // 1.5% 26 | 27 | address public ownerAddress = 0xEe2Cf9b7A9B97BF9FE8d9aD32F8e498d3257Fc4F; 28 | address public contributorAddress = 29 | 0xc3C891b96AFa15ABa58b7D91359f76DCA77fc427; 30 | address public developerAddress = 31 | 0xBeF32f6bf96800d31f2B04C0e787C1a590f31837; 32 | 33 | bool public paused = false; 34 | bool public teamMinted = false; 35 | 36 | uint public preSaleDate = 1661561700; 37 | uint public publicSaleDate = preSaleDate + 300; 38 | mapping(address => uint256) public freeMintPerWallet; 39 | mapping(address => bool) public whitelisted; 40 | 41 | constructor(string memory _initBaseURI) ERC721("TheHexagon", "Honey") { 42 | setBaseURI(_initBaseURI); 43 | } 44 | 45 | // internal 46 | function _baseURI() internal view virtual override returns (string memory) { 47 | return baseURI; 48 | } 49 | 50 | function teamMint() public payable onlyOwner { 51 | // require(!paused, "Paused"); 52 | // require(!teamMinted, "Already minted"); 53 | 54 | // uint256 supply = totalSupply(); 55 | // require(supply + teamMintAmount <= freeSupply, "Max free supply exceeded"); 56 | // _safeMint(msg.sender, teamMintAmount); 57 | for (uint256 idx = 0; idx < teamMintAmount; ++idx) { 58 | // whitelistMintNumber[msg.sender]++; 59 | _safeMint(msg.sender, idx); 60 | } 61 | // teamMinted = true; 62 | } 63 | 64 | function setBaseURI(string memory _newURI) public onlyOwner { 65 | baseURI = _newURI; 66 | } 67 | 68 | function tokenURI( 69 | uint256 tokenId 70 | ) public view virtual override returns (string memory) { 71 | require(_exists(tokenId), "Does not exist."); 72 | 73 | string memory currentBaseURI = _baseURI(); 74 | return 75 | bytes(currentBaseURI).length > 0 76 | ? string( 77 | abi.encodePacked( 78 | currentBaseURI, 79 | tokenId.toString(), 80 | baseExtension 81 | ) 82 | ) 83 | : ""; 84 | } 85 | } 86 | -------------------------------------------------------------------------------- /backend/contracts/erc721mint.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | 3 | pragma solidity ^0.8.15; 4 | 5 | // import "./erc721a/contracts/ERC721A.sol"; 6 | import "@openzeppelin/contracts/token/ERC721/extensions/ERC721Enumerable.sol"; 7 | import "@openzeppelin/contracts/access/Ownable.sol"; 8 | import "@openzeppelin/contracts/utils/Strings.sol"; 9 | 10 | contract ApeGalacticClubMint is ERC721Enumerable, Ownable { 11 | using Strings for uint256; 12 | 13 | string private baseURI; 14 | string public baseExtension = ".json"; 15 | uint256 public cost = 5000000000000000 wei; /// 0.005 eth 16 | uint256 public maxFreeMintAmount = 10; 17 | uint256 public maxPayMintAmount = 50; 18 | uint256 public teamMintAmount = 30; 19 | 20 | uint256 public constant MAX_BATCH_SIZE = 100; 21 | uint256 public constant MAX_SUPPLY = 10000; 22 | uint256 public freeSupply = 2500; 23 | 24 | uint256 public contributorProfit = 75; // 7.5% 25 | uint256 public developerProfit = 15; // 1.5% 26 | 27 | address public ownerAddress = 0xEe2Cf9b7A9B97BF9FE8d9aD32F8e498d3257Fc4F; 28 | address public contributorAddress = 29 | 0xc3C891b96AFa15ABa58b7D91359f76DCA77fc427; 30 | address public developerAddress = 31 | 0xBeF32f6bf96800d31f2B04C0e787C1a590f31837; 32 | 33 | bool public paused = false; 34 | bool public teamMinted = false; 35 | 36 | uint public preSaleDate = 1661561700; 37 | uint public publicSaleDate = preSaleDate + 300; 38 | mapping(address => uint256) public freeMintPerWallet; 39 | mapping(address => bool) public whitelisted; 40 | 41 | constructor(string memory _initBaseURI) ERC721("TheHexagon", "Honey") { 42 | setBaseURI(_initBaseURI); 43 | } 44 | 45 | // internal 46 | function _baseURI() internal view virtual override returns (string memory) { 47 | return baseURI; 48 | } 49 | 50 | function teamMint() public payable onlyOwner { 51 | // require(!paused, "Paused"); 52 | // require(!teamMinted, "Already minted"); 53 | 54 | // uint256 supply = totalSupply(); 55 | // require(supply + teamMintAmount <= freeSupply, "Max free supply exceeded"); 56 | // _safeMint(msg.sender, teamMintAmount); 57 | for (uint256 idx = 0; idx < teamMintAmount; ++idx) { 58 | // whitelistMintNumber[msg.sender]++; 59 | _safeMint(msg.sender, idx); 60 | } 61 | // teamMinted = true; 62 | } 63 | 64 | function setBaseURI(string memory _newURI) public onlyOwner { 65 | baseURI = _newURI; 66 | } 67 | 68 | function tokenURI( 69 | uint256 tokenId 70 | ) public view virtual override returns (string memory) { 71 | require(_exists(tokenId), "Does not exist."); 72 | 73 | string memory currentBaseURI = _baseURI(); 74 | return 75 | bytes(currentBaseURI).length > 0 76 | ? string( 77 | abi.encodePacked( 78 | currentBaseURI, 79 | tokenId.toString(), 80 | baseExtension 81 | ) 82 | ) 83 | : ""; 84 | } 85 | } 86 | -------------------------------------------------------------------------------- /src/contract/VRFv2DirectFundingConsumer.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | // An example of a consumer contract that directly pays for each request. 3 | pragma solidity ^0.8.7; 4 | 5 | import "@chainlink/contracts/src/v0.8/VRFV2WrapperConsumerBase.sol"; 6 | 7 | /** 8 | * Request testnet LINK and ETH here: https://faucets.chain.link/ 9 | * Find information on LINK Token Contracts and get the latest ETH and LINK faucets here: https://docs.chain.link/docs/link-token-contracts/ 10 | */ 11 | 12 | /** 13 | * THIS IS AN EXAMPLE CONTRACT THAT USES HARDCODED VALUES FOR CLARITY. 14 | * THIS IS AN EXAMPLE CONTRACT THAT USES UN-AUDITED CODE. 15 | * DO NOT USE THIS CODE IN PRODUCTION. 16 | */ 17 | 18 | abstract contract VRFv2DirectFundingConsumer is 19 | VRFV2WrapperConsumerBase 20 | { 21 | event RequestSent(uint256 requestId, uint32 numWords); 22 | event RequestFulfilled( 23 | uint256 requestId, 24 | uint256[] randomWords, 25 | uint256 payment 26 | ); 27 | 28 | struct RequestStatus { 29 | uint256 paid; // amount paid in link 30 | bool fulfilled; // whether the request has been successfully fulfilled 31 | uint256[] randomWords; 32 | } 33 | mapping(uint256 => RequestStatus) 34 | public s_requests; /* requestId --> requestStatus */ 35 | 36 | // past requests Id. 37 | uint256[] public requestIds; 38 | uint256 public lastRequestId; 39 | 40 | // Depends on the number of requested values that you want sent to the 41 | // fulfillRandomWords() function. Test and adjust 42 | // this limit based on the network that you select, the size of the request, 43 | // and the processing of the callback request in the fulfillRandomWords() 44 | // function. 45 | uint32 callbackGasLimit = 100000; 46 | 47 | // The default is 3, but you can set this higher. 48 | uint16 requestConfirmations = 3; 49 | 50 | // For this example, retrieve 2 random values in one request. 51 | // Cannot exceed VRFV2Wrapper.getConfig().maxNumWords. 52 | uint32 numWords = 1; 53 | 54 | // Address LINK - hardcoded for your network 55 | address linkAddress = 0x326C977E6efc84E512bB9C30f76E30c160eD06FB; 56 | 57 | // address WRAPPER - hardcoded for your network 58 | address wrapperAddress = 0x99aFAf084eBA697E584501b8Ed2c0B37Dd136693; 59 | 60 | constructor() 61 | VRFV2WrapperConsumerBase(linkAddress, wrapperAddress) 62 | {} 63 | 64 | function requestRandomWords() 65 | internal 66 | returns (uint256 requestId) 67 | { 68 | requestId = requestRandomness( 69 | callbackGasLimit, 70 | requestConfirmations, 71 | numWords 72 | ); 73 | s_requests[requestId] = RequestStatus({ 74 | paid: VRF_V2_WRAPPER.calculateRequestPrice(callbackGasLimit), 75 | randomWords: new uint256[](0), 76 | fulfilled: false 77 | }); 78 | requestIds.push(requestId); 79 | lastRequestId = requestId; 80 | emit RequestSent(requestId, numWords); 81 | return requestId; 82 | } 83 | 84 | 85 | function getRequestStatus( 86 | uint256 _requestId 87 | ) 88 | external 89 | view 90 | returns (uint256 paid, bool fulfilled, uint256[] memory randomWords) 91 | { 92 | require(s_requests[_requestId].paid > 0, "request not found"); 93 | RequestStatus memory request = s_requests[_requestId]; 94 | return (request.paid, request.fulfilled, request.randomWords); 95 | } 96 | 97 | /** 98 | * Allow withdraw of Link tokens from the contract 99 | */ 100 | 101 | } 102 | -------------------------------------------------------------------------------- /backend/contracts/VRFv2DirectFundingConsumer.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | // An example of a consumer contract that directly pays for each request. 3 | pragma solidity ^0.8.7; 4 | 5 | import "@chainlink/contracts/src/v0.8/VRFV2WrapperConsumerBase.sol"; 6 | 7 | /** 8 | * Request testnet LINK and ETH here: https://faucets.chain.link/ 9 | * Find information on LINK Token Contracts and get the latest ETH and LINK faucets here: https://docs.chain.link/docs/link-token-contracts/ 10 | */ 11 | 12 | /** 13 | * THIS IS AN EXAMPLE CONTRACT THAT USES HARDCODED VALUES FOR CLARITY. 14 | * THIS IS AN EXAMPLE CONTRACT THAT USES UN-AUDITED CODE. 15 | * DO NOT USE THIS CODE IN PRODUCTION. 16 | */ 17 | 18 | abstract contract VRFv2DirectFundingConsumer is 19 | VRFV2WrapperConsumerBase 20 | { 21 | event RequestSent(uint256 requestId, uint32 numWords); 22 | event RequestFulfilled( 23 | uint256 requestId, 24 | uint256[] randomWords, 25 | uint256 payment 26 | ); 27 | 28 | struct RequestStatus { 29 | uint256 paid; // amount paid in link 30 | bool fulfilled; // whether the request has been successfully fulfilled 31 | uint256[] randomWords; 32 | } 33 | mapping(uint256 => RequestStatus) 34 | public s_requests; /* requestId --> requestStatus */ 35 | 36 | // past requests Id. 37 | uint256[] public requestIds; 38 | uint256 public lastRequestId; 39 | 40 | // Depends on the number of requested values that you want sent to the 41 | // fulfillRandomWords() function. Test and adjust 42 | // this limit based on the network that you select, the size of the request, 43 | // and the processing of the callback request in the fulfillRandomWords() 44 | // function. 45 | uint32 callbackGasLimit = 100000; 46 | 47 | // The default is 3, but you can set this higher. 48 | uint16 requestConfirmations = 3; 49 | 50 | // For this example, retrieve 2 random values in one request. 51 | // Cannot exceed VRFV2Wrapper.getConfig().maxNumWords. 52 | uint32 numWords = 1; 53 | 54 | // Address LINK - hardcoded for your network 55 | address linkAddress = 0x326C977E6efc84E512bB9C30f76E30c160eD06FB; 56 | 57 | // address WRAPPER - hardcoded for your network 58 | address wrapperAddress = 0x99aFAf084eBA697E584501b8Ed2c0B37Dd136693; 59 | 60 | constructor() 61 | VRFV2WrapperConsumerBase(linkAddress, wrapperAddress) 62 | {} 63 | 64 | function requestRandomWords() 65 | internal 66 | returns (uint256 requestId) 67 | { 68 | requestId = requestRandomness( 69 | callbackGasLimit, 70 | requestConfirmations, 71 | numWords 72 | ); 73 | s_requests[requestId] = RequestStatus({ 74 | paid: VRF_V2_WRAPPER.calculateRequestPrice(callbackGasLimit), 75 | randomWords: new uint256[](0), 76 | fulfilled: false 77 | }); 78 | requestIds.push(requestId); 79 | lastRequestId = requestId; 80 | emit RequestSent(requestId, numWords); 81 | return requestId; 82 | } 83 | 84 | 85 | function getRequestStatus( 86 | uint256 _requestId 87 | ) 88 | external 89 | view 90 | returns (uint256 paid, bool fulfilled, uint256[] memory randomWords) 91 | { 92 | require(s_requests[_requestId].paid > 0, "request not found"); 93 | RequestStatus memory request = s_requests[_requestId]; 94 | return (request.paid, request.fulfilled, request.randomWords); 95 | } 96 | 97 | /** 98 | * Allow withdraw of Link tokens from the contract 99 | */ 100 | 101 | } 102 | -------------------------------------------------------------------------------- /src/assets/opensea-icon.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/App.css: -------------------------------------------------------------------------------- 1 | .para-clip { 2 | clip-path: polygon(0 0, 100% 0%, 90% 100%, 0% 100%); 3 | } 4 | 5 | .App { 6 | text-align: center; 7 | } 8 | body{ 9 | overflow-y: scroll; 10 | overflow-x: hidden; 11 | } 12 | 13 | ::-webkit-scrollbar { 14 | width: 10px; 15 | } 16 | 17 | /* Track */ 18 | ::-webkit-scrollbar-track { 19 | background: #f1f1f1; 20 | } 21 | 22 | /* Handle */ 23 | ::-webkit-scrollbar-thumb { 24 | background: rgba(134, 82, 255, 0.2); 25 | } 26 | 27 | /* Handle on hover */ 28 | ::-webkit-scrollbar-thumb:hover { 29 | background: rgba(134, 82, 255, 0.2); 30 | } 31 | 32 | .App-logo { 33 | height: 40vmin; 34 | pointer-events: none; 35 | } 36 | 37 | @media (prefers-reduced-motion: no-preference) { 38 | .App-logo { 39 | animation: App-logo-spin infinite 20s linear; 40 | } 41 | } 42 | 43 | .App-header { 44 | background-color: #282c34; 45 | min-height: 100vh; 46 | display: flex; 47 | flex-direction: column; 48 | align-items: center; 49 | justify-content: center; 50 | font-size: calc(10px + 2vmin); 51 | color: white; 52 | } 53 | 54 | .App-link { 55 | color: #61dafb; 56 | } 57 | 58 | @keyframes App-logo-spin { 59 | from { 60 | transform: rotate(0deg); 61 | } 62 | 63 | to { 64 | transform: rotate(360deg); 65 | } 66 | } 67 | 68 | #preloader { 69 | position: fixed; 70 | top: 0; 71 | left: 0; 72 | right: 0; 73 | bottom: 0; 74 | z-index: 9999; 75 | overflow: hidden; 76 | background: black; 77 | opacity: 0.5; 78 | display: flex; 79 | justify-content: center; 80 | align-items: center; 81 | font-size: 30px; 82 | color: white; 83 | } 84 | 85 | #preloader:before { 86 | content: ""; 87 | position: fixed; 88 | top: calc(50% - 30px); 89 | left: calc(50% - 30px); 90 | border: 6px solid #ffffff; 91 | border-top-color: black; 92 | border-radius: 50%; 93 | width: 60px; 94 | height: 60px; 95 | -webkit-animation: animate-preloader 1s linear infinite; 96 | animation: animate-preloader 1s linear infinite; 97 | } 98 | 99 | @-webkit-keyframes animate-preloader { 100 | 0% { 101 | transform: rotate(0deg); 102 | } 103 | 104 | 100% { 105 | transform: rotate(360deg); 106 | } 107 | } 108 | 109 | @keyframes animate-preloader { 110 | 0% { 111 | transform: rotate(0deg); 112 | } 113 | 114 | 100% { 115 | transform: rotate(360deg); 116 | } 117 | } 118 | 119 | .nft-count { 120 | display: flex; 121 | align-items: center; 122 | gap: 16px; 123 | border: 1px solid grey; 124 | border-radius: 12px; 125 | padding: 8px; 126 | max-width: fit-content; 127 | margin: 0 auto; 128 | margin-top: 16px; 129 | } 130 | 131 | .nft-amount { 132 | /* color: white; */ 133 | font-size: 18px; 134 | } 135 | 136 | .nft-decrease, 137 | .nft-increase { 138 | font-size: 16px; 139 | /* color: white; */ 140 | cursor: pointer; 141 | } 142 | 143 | .swiper { 144 | width: 100%; 145 | height: 100%; 146 | } 147 | 148 | .swiper { 149 | padding: 1rem 0px 4rem 0px !important; 150 | } 151 | 152 | .swiper-slide img { 153 | display: block; 154 | width: 100%; 155 | height: 100%; 156 | object-fit: cover; 157 | } 158 | 159 | .swiper-pagination-bullet { 160 | background-color: #D9D9D9 !important; 161 | opacity: 1 !important; 162 | height: 16px !important; 163 | width: 16px !important; 164 | } 165 | 166 | .swiper-pagination-bullet-active { 167 | border-radius: 19px !important; 168 | background-color: #8652FF !important; 169 | /* border: 1px solid white !important; */ 170 | transition: 0.25s all ease-in-out; 171 | } 172 | 173 | .navbar-shadow { 174 | box-shadow: 0px 1px 16px #ECECEC; 175 | } 176 | 177 | .nftItem-shadow { 178 | box-shadow: 0px 1px 16px #ECECEC; 179 | } 180 | 181 | .raffle-status-active { 182 | background: rgba(134, 82, 255, 0.2); 183 | } 184 | 185 | .header-section { 186 | /* background: linear-gradient(rgb(90, 47, 190) 20%, rgba(90, 47, 190, 0)); */ 187 | background: rgb(90, 47, 190); 188 | } 189 | 190 | .button-hover:hover { 191 | background-color: rgb(93, 57, 178); 192 | transition: .2s all; 193 | /* border: 1px solid #8652FF; 194 | background: white; 195 | color: #8652FF; 196 | transition: .2s all; */ 197 | 198 | } 199 | 200 | .nftItem-hover:hover { 201 | /* transform: translateZ(-24px); */ 202 | transform: scale(1.05); 203 | transition: .6s all; 204 | } 205 | 206 | .svgImg { 207 | fill: white; 208 | } 209 | 210 | /* .svgImg:hover { 211 | fill: #1a1a1a 212 | } */ 213 | .swiper { 214 | display: flex; 215 | } 216 | 217 | .swiper-slide { 218 | width: 25%; 219 | } 220 | 221 | @media(max-width:1024px) { 222 | .swiper-slide { 223 | width: 33%; 224 | } 225 | } -------------------------------------------------------------------------------- /backend/test/Lock.ts: -------------------------------------------------------------------------------- 1 | import { 2 | time, 3 | loadFixture, 4 | } from "@nomicfoundation/hardhat-toolbox/network-helpers"; 5 | import { anyValue } from "@nomicfoundation/hardhat-chai-matchers/withArgs"; 6 | import { expect } from "chai"; 7 | import { ethers } from "hardhat"; 8 | 9 | describe("Lock", function () { 10 | // We define a fixture to reuse the same setup in every test. 11 | // We use loadFixture to run this setup once, snapshot that state, 12 | // and reset Hardhat Network to that snapshot in every test. 13 | async function deployOneYearLockFixture() { 14 | const ONE_YEAR_IN_SECS = 365 * 24 * 60 * 60; 15 | const ONE_GWEI = 1_000_000_000; 16 | 17 | const lockedAmount = ONE_GWEI; 18 | const unlockTime = (await time.latest()) + ONE_YEAR_IN_SECS; 19 | 20 | // Contracts are deployed using the first signer/account by default 21 | const [owner, otherAccount] = await ethers.getSigners(); 22 | 23 | const Lock = await ethers.getContractFactory("Lock"); 24 | const lock = await Lock.deploy(unlockTime, { value: lockedAmount }); 25 | 26 | return { lock, unlockTime, lockedAmount, owner, otherAccount }; 27 | } 28 | 29 | describe("Deployment", function () { 30 | it("Should set the right unlockTime", async function () { 31 | const { lock, unlockTime } = await loadFixture(deployOneYearLockFixture); 32 | 33 | expect(await lock.unlockTime()).to.equal(unlockTime); 34 | }); 35 | 36 | it("Should set the right owner", async function () { 37 | const { lock, owner } = await loadFixture(deployOneYearLockFixture); 38 | 39 | expect(await lock.owner()).to.equal(owner.address); 40 | }); 41 | 42 | it("Should receive and store the funds to lock", async function () { 43 | const { lock, lockedAmount } = await loadFixture( 44 | deployOneYearLockFixture 45 | ); 46 | 47 | expect(await ethers.provider.getBalance(lock.target)).to.equal( 48 | lockedAmount 49 | ); 50 | }); 51 | 52 | it("Should fail if the unlockTime is not in the future", async function () { 53 | // We don't use the fixture here because we want a different deployment 54 | const latestTime = await time.latest(); 55 | const Lock = await ethers.getContractFactory("Lock"); 56 | await expect(Lock.deploy(latestTime, { value: 1 })).to.be.revertedWith( 57 | "Unlock time should be in the future" 58 | ); 59 | }); 60 | }); 61 | 62 | describe("Withdrawals", function () { 63 | describe("Validations", function () { 64 | it("Should revert with the right error if called too soon", async function () { 65 | const { lock } = await loadFixture(deployOneYearLockFixture); 66 | 67 | await expect(lock.withdraw()).to.be.revertedWith( 68 | "You can't withdraw yet" 69 | ); 70 | }); 71 | 72 | it("Should revert with the right error if called from another account", async function () { 73 | const { lock, unlockTime, otherAccount } = await loadFixture( 74 | deployOneYearLockFixture 75 | ); 76 | 77 | // We can increase the time in Hardhat Network 78 | await time.increaseTo(unlockTime); 79 | 80 | // We use lock.connect() to send a transaction from another account 81 | await expect(lock.connect(otherAccount).withdraw()).to.be.revertedWith( 82 | "You aren't the owner" 83 | ); 84 | }); 85 | 86 | it("Shouldn't fail if the unlockTime has arrived and the owner calls it", async function () { 87 | const { lock, unlockTime } = await loadFixture( 88 | deployOneYearLockFixture 89 | ); 90 | 91 | // Transactions are sent using the first signer by default 92 | await time.increaseTo(unlockTime); 93 | 94 | await expect(lock.withdraw()).not.to.be.reverted; 95 | }); 96 | }); 97 | 98 | describe("Events", function () { 99 | it("Should emit an event on withdrawals", async function () { 100 | const { lock, unlockTime, lockedAmount } = await loadFixture( 101 | deployOneYearLockFixture 102 | ); 103 | 104 | await time.increaseTo(unlockTime); 105 | 106 | await expect(lock.withdraw()) 107 | .to.emit(lock, "Withdrawal") 108 | .withArgs(lockedAmount, anyValue); // We accept any value as `when` arg 109 | }); 110 | }); 111 | 112 | describe("Transfers", function () { 113 | it("Should transfer the funds to the owner", async function () { 114 | const { lock, unlockTime, lockedAmount, owner } = await loadFixture( 115 | deployOneYearLockFixture 116 | ); 117 | 118 | await time.increaseTo(unlockTime); 119 | 120 | await expect(lock.withdraw()).to.changeEtherBalances( 121 | [owner, lock], 122 | [lockedAmount, -lockedAmount] 123 | ); 124 | }); 125 | }); 126 | }); 127 | }); 128 | -------------------------------------------------------------------------------- /src/utils/index.ts: -------------------------------------------------------------------------------- 1 | import CONFIG from "../config"; 2 | import Web3 from "web3"; 3 | import { ToastContainer, toast } from "react-toastify"; 4 | import { utils } from 'ethers' 5 | 6 | declare global { 7 | interface Window { 8 | ethereum?: any 9 | } 10 | } 11 | 12 | 13 | export const datetimeLocal = (datetime: Date) => { 14 | let month = datetime.getMonth() + 1; 15 | let day = datetime.getDate(); 16 | let hour = datetime.getHours(); 17 | let min = datetime.getMinutes(); 18 | const result = `${datetime.getFullYear()}-${month >= 10 ? month : `0${month}`}-${day >= 10 ? day : `0${day}`}T${hour >= 10 ? hour : `0${hour}`}:${min >= 10 ? min : `0${min}`}` 19 | return result; 20 | } 21 | 22 | export const connectWallet = async () => { 23 | try { 24 | if (window.ethereum) { 25 | try { 26 | const chain = await window.ethereum.request({ method: 'eth_chainId' }) 27 | if (chain === CONFIG.CHAINID) { 28 | const addressArray = await window.ethereum.request({ 29 | method: 'eth_requestAccounts', 30 | }) 31 | if (addressArray.length > 0) { 32 | return { 33 | address: await addressArray[0], 34 | // status: "👆🏽 Ethereum Wallet is connected.", 35 | } 36 | } else { 37 | toast.error(`😥 Connect your wallet account to the site.`) 38 | 39 | } 40 | } else { 41 | // Case other chain connected so change polygon chain 42 | await window.ethereum.request({ 43 | method: 'wallet_switchEthereumChain', 44 | params: [{ chainId: CONFIG.CHAINID }], 45 | }) 46 | const addressArray = await window.ethereum.request({ 47 | method: 'eth_requestAccounts', 48 | }) 49 | if (addressArray.length > 0) { 50 | return { 51 | address: await addressArray[0], 52 | } 53 | } 54 | } 55 | 56 | } catch (err: any) { 57 | // No exist Polygon chain in your wallet 58 | const networkMap = { 59 | POLYGON_MAINNET: { 60 | chainId: utils.hexValue(137), // '0x89' 61 | chainName: "Matic(Polygon) Mainnet", 62 | nativeCurrency: { name: "MATIC", symbol: "MATIC", decimals: 18 }, 63 | rpcUrls: ["https://polygon-rpc.com"], 64 | blockExplorerUrls: ["https://www.polygonscan.com/"], 65 | }, 66 | MUMBAI_TESTNET: { 67 | chainId: utils.hexValue(80001), // '0x13881' 68 | chainName: "Matic(Polygon) Mumbai Testnet", 69 | nativeCurrency: { name: "tMATIC", symbol: "tMATIC", decimals: 18 }, 70 | rpcUrls: ["https://rpc-mumbai.maticvigil.com"], 71 | blockExplorerUrls: ["https://mumbai.polygonscan.com/"], 72 | }, 73 | }; 74 | 75 | await window.ethereum.request({ 76 | method: "wallet_addEthereumChain", 77 | params: [networkMap.MUMBAI_TESTNET], 78 | }); 79 | 80 | const addressArray = await window.ethereum.request({ 81 | method: 'eth_requestAccounts', 82 | }) 83 | if (addressArray.length > 0) { 84 | return { 85 | address: await addressArray[0], 86 | } 87 | } 88 | 89 | } 90 | } else { 91 | toast.error(`🦊 You must install Metamask, a virtual Ethereum wallet, in your browser.(https://metamask.io/download.html)`) 92 | } 93 | } catch (error) { 94 | console.log('error', error) 95 | } 96 | 97 | } 98 | 99 | export const connectedChain = async () => { 100 | try { 101 | const chain = await window.ethereum.request({ method: 'eth_chainId' }) 102 | if (chain === CONFIG.CHAINID) { 103 | return true 104 | } else { 105 | await window.ethereum.request({ 106 | method: 'wallet_switchEthereumChain', 107 | params: [{ chainId: CONFIG.CHAINID }], 108 | }) 109 | const addressArray = await window.ethereum.request({ 110 | method: 'eth_requestAccounts', 111 | }) 112 | if (addressArray.length > 0) { 113 | return { 114 | address: await addressArray[0], 115 | } 116 | } 117 | toast.error(`Please change Mumbai Chain Network`) 118 | 119 | return false 120 | } 121 | } catch (error) { 122 | console.log('error', error) 123 | } 124 | } 125 | 126 | export const getBalance = async () => { 127 | try { 128 | const web3 = new Web3(window.ethereum); 129 | const accounts = await web3.eth.getAccounts(); 130 | const balance: any = await web3.eth.getBalance(accounts[0]); 131 | 132 | return balance / 1000000000000000000 133 | } catch (error) { 134 | console.log('error', error) 135 | } 136 | 137 | } 138 | 139 | export const unknownAccount = (error: any) => { 140 | if (error === 'unknown account #0') { 141 | toast.error('Please connect your wallet again'); 142 | } 143 | } 144 | 145 | export const LOOP = 30; 146 | export const INTERVAL = 500; 147 | export const delay = (ms: any) => new Promise(resolve => setTimeout(resolve, ms)) 148 | -------------------------------------------------------------------------------- /src/assets/fonts/Archia_Regular/Archia Regular Webfont/specimen_files/grid_12-825-55-15.css: -------------------------------------------------------------------------------- 1 | /*Notes about grid: 2 | Columns: 12 3 | Grid Width: 825px 4 | Column Width: 55px 5 | Gutter Width: 15px 6 | -------------------------------*/ 7 | 8 | 9 | 10 | .section {margin-bottom: 18px; 11 | } 12 | .section:after {content: ".";display: block;height: 0;clear: both;visibility: hidden;} 13 | .section {*zoom: 1;} 14 | 15 | .section .firstcolumn, 16 | .section .firstcol {margin-left: 0;} 17 | 18 | 19 | /* Border on left hand side of a column. */ 20 | .border { 21 | padding-left: 7px; 22 | margin-left: 7px; 23 | border-left: 1px solid #eee; 24 | } 25 | 26 | /* Border with more whitespace, spans one column. */ 27 | .colborder { 28 | padding-left: 42px; 29 | margin-left: 42px; 30 | border-left: 1px solid #eee; 31 | } 32 | 33 | 34 | 35 | /* The Grid Classes */ 36 | .grid1, .grid1_2cols, .grid1_3cols, .grid1_4cols, .grid2, .grid2_3cols, .grid2_4cols, .grid3, .grid3_2cols, .grid3_4cols, .grid4, .grid4_3cols, .grid5, .grid5_2cols, .grid5_3cols, .grid5_4cols, .grid6, .grid6_4cols, .grid7, .grid7_2cols, .grid7_3cols, .grid7_4cols, .grid8, .grid8_3cols, .grid9, .grid9_2cols, .grid9_4cols, .grid10, .grid10_3cols, .grid10_4cols, .grid11, .grid11_2cols, .grid11_3cols, .grid11_4cols, .grid12 37 | {margin-left: 15px;float: left;display: inline; overflow: hidden;} 38 | 39 | 40 | .width1, .grid1, .span-1 {width: 55px;} 41 | .width1_2cols,.grid1_2cols {width: 20px;} 42 | .width1_3cols,.grid1_3cols {width: 8px;} 43 | .width1_4cols,.grid1_4cols {width: 2px;} 44 | .input_width1 {width: 49px;} 45 | 46 | .width2, .grid2, .span-2 {width: 125px;} 47 | .width2_3cols,.grid2_3cols {width: 31px;} 48 | .width2_4cols,.grid2_4cols {width: 20px;} 49 | .input_width2 {width: 119px;} 50 | 51 | .width3, .grid3, .span-3 {width: 195px;} 52 | .width3_2cols,.grid3_2cols {width: 90px;} 53 | .width3_4cols,.grid3_4cols {width: 37px;} 54 | .input_width3 {width: 189px;} 55 | 56 | .width4, .grid4, .span-4 {width: 265px;} 57 | .width4_3cols,.grid4_3cols {width: 78px;} 58 | .input_width4 {width: 259px;} 59 | 60 | .width5, .grid5, .span-5 {width: 335px;} 61 | .width5_2cols,.grid5_2cols {width: 160px;} 62 | .width5_3cols,.grid5_3cols {width: 101px;} 63 | .width5_4cols,.grid5_4cols {width: 72px;} 64 | .input_width5 {width: 329px;} 65 | 66 | .width6, .grid6, .span-6 {width: 405px;} 67 | .width6_4cols,.grid6_4cols {width: 90px;} 68 | .input_width6 {width: 399px;} 69 | 70 | .width7, .grid7, .span-7 {width: 475px;} 71 | .width7_2cols,.grid7_2cols {width: 230px;} 72 | .width7_3cols,.grid7_3cols {width: 148px;} 73 | .width7_4cols,.grid7_4cols {width: 107px;} 74 | .input_width7 {width: 469px;} 75 | 76 | .width8, .grid8, .span-8 {width: 545px;} 77 | .width8_3cols,.grid8_3cols {width: 171px;} 78 | .input_width8 {width: 539px;} 79 | 80 | .width9, .grid9, .span-9 {width: 615px;} 81 | .width9_2cols,.grid9_2cols {width: 300px;} 82 | .width9_4cols,.grid9_4cols {width: 142px;} 83 | .input_width9 {width: 609px;} 84 | 85 | .width10, .grid10, .span-10 {width: 685px;} 86 | .width10_3cols,.grid10_3cols {width: 218px;} 87 | .width10_4cols,.grid10_4cols {width: 160px;} 88 | .input_width10 {width: 679px;} 89 | 90 | .width11, .grid11, .span-11 {width: 755px;} 91 | .width11_2cols,.grid11_2cols {width: 370px;} 92 | .width11_3cols,.grid11_3cols {width: 241px;} 93 | .width11_4cols,.grid11_4cols {width: 177px;} 94 | .input_width11 {width: 749px;} 95 | 96 | .width12, .grid12, .span-12 {width: 825px;} 97 | .input_width12 {width: 819px;} 98 | 99 | /* Subdivided grid spaces */ 100 | .emptycols_left1, .prepend-1 {padding-left: 70px;} 101 | .emptycols_right1, .append-1 {padding-right: 70px;} 102 | .emptycols_left2, .prepend-2 {padding-left: 140px;} 103 | .emptycols_right2, .append-2 {padding-right: 140px;} 104 | .emptycols_left3, .prepend-3 {padding-left: 210px;} 105 | .emptycols_right3, .append-3 {padding-right: 210px;} 106 | .emptycols_left4, .prepend-4 {padding-left: 280px;} 107 | .emptycols_right4, .append-4 {padding-right: 280px;} 108 | .emptycols_left5, .prepend-5 {padding-left: 350px;} 109 | .emptycols_right5, .append-5 {padding-right: 350px;} 110 | .emptycols_left6, .prepend-6 {padding-left: 420px;} 111 | .emptycols_right6, .append-6 {padding-right: 420px;} 112 | .emptycols_left7, .prepend-7 {padding-left: 490px;} 113 | .emptycols_right7, .append-7 {padding-right: 490px;} 114 | .emptycols_left8, .prepend-8 {padding-left: 560px;} 115 | .emptycols_right8, .append-8 {padding-right: 560px;} 116 | .emptycols_left9, .prepend-9 {padding-left: 630px;} 117 | .emptycols_right9, .append-9 {padding-right: 630px;} 118 | .emptycols_left10, .prepend-10 {padding-left: 700px;} 119 | .emptycols_right10, .append-10 {padding-right: 700px;} 120 | .emptycols_left11, .prepend-11 {padding-left: 770px;} 121 | .emptycols_right11, .append-11 {padding-right: 770px;} 122 | .pull-1 {margin-left: -70px;} 123 | .push-1 {margin-right: -70px;margin-left: 18px;float: right;} 124 | .pull-2 {margin-left: -140px;} 125 | .push-2 {margin-right: -140px;margin-left: 18px;float: right;} 126 | .pull-3 {margin-left: -210px;} 127 | .push-3 {margin-right: -210px;margin-left: 18px;float: right;} 128 | .pull-4 {margin-left: -280px;} 129 | .push-4 {margin-right: -280px;margin-left: 18px;float: right;} -------------------------------------------------------------------------------- /src/components/Menus.tsx: -------------------------------------------------------------------------------- 1 | import React from "react"; 2 | import { Link, useLocation } from "react-router-dom"; 3 | import { useNavigate } from "react-router-dom"; 4 | import { useSelector } from "react-redux"; 5 | import { ToastContainer, toast } from "react-toastify"; 6 | import "react-toastify/dist/ReactToastify.css"; 7 | 8 | 9 | import AddRaffleIcon from "../assets/add-raffle-icon.png"; 10 | 11 | const Menus: React.FC = () => { 12 | const navigate = useNavigate(); 13 | const activeLink = useLocation(); 14 | const storeData: any = useSelector((status) => status) 15 | 16 | const handleNewRaffleLink = () => { 17 | if (storeData.wallet === 'connected') { 18 | navigate('/raffle/create') 19 | } else { 20 | toast("Please connect your wallet"); 21 | 22 | } 23 | } 24 | 25 | const handleNewAuctionLink = () => { 26 | if (storeData.wallet === 'connected') { 27 | navigate('/auction/create') 28 | } else { 29 | toast("Please connect your wallet"); 30 | 31 | } 32 | } 33 | 34 | return ( 35 |
36 |
37 | {activeLink.pathname === "/" || 38 | activeLink.pathname === "/auction" || 39 | activeLink.pathname === "/admin" || 40 | activeLink.pathname === "/admin/auction" || 41 | activeLink.pathname === "/profile" || 42 | activeLink.pathname === "/participant" || 43 | activeLink.pathname === "/filter-auctions" ? ( 44 |
45 |
46 |
47 |
48 |
49 | 66 | Raffles 67 | 68 | 83 | Auctions 84 | 85 |
86 |
87 |
88 |
89 | {activeLink.pathname === "/" && ( 90 |
91 |
95 | RBI 96 | 97 | New Raffle 98 |
99 |
100 | )} 101 | {activeLink.pathname === "/auction" && ( 102 |
103 |
107 | RBI 108 | 109 | New Auction 110 |
111 |
112 | )} 113 |
114 |
115 |
116 | ) : ( 117 | "" 118 | )} 119 |
120 | 121 |
122 | ); 123 | }; 124 | 125 | export default Menus; 126 | -------------------------------------------------------------------------------- /src/pages/Raffle/RaffleSwiper.tsx: -------------------------------------------------------------------------------- 1 | import React from "react"; 2 | import { Swiper, SwiperSlide } from "swiper/react"; 3 | import { Navigation, Pagination, Autoplay } from "swiper"; 4 | import Countdown, { CountdownApi } from 'react-countdown' 5 | 6 | import Chevron from "../../assets/Chevron.png"; 7 | 8 | import "swiper/css"; 9 | import "swiper/css/pagination"; 10 | import "swiper/css/navigation"; 11 | import RaffleItem from "../../components/RaffleItem"; 12 | 13 | const RaffleSwiper = (props: any) => { 14 | const { featuredData } = props 15 | const swiperRef: any = React.useRef(); 16 | let startCountdownApi: CountdownApi | null = null 17 | let endCountdownApi: CountdownApi | null = null 18 | 19 | const setStartCountdownRef = (countdown: Countdown | null) => { 20 | if (countdown) { 21 | startCountdownApi = countdown.getApi() 22 | } 23 | } 24 | 25 | const setEndCountdownRef = (countdown: Countdown | null) => { 26 | if (countdown) { 27 | endCountdownApi = countdown.getApi() 28 | } 29 | } 30 | 31 | const sliderSettings = { 32 | 240: { 33 | slidesPerView: 1, 34 | spaceBetween: 16, 35 | pagination: false, 36 | }, 37 | 680: { 38 | slidesPerView: 2, 39 | spaceBetween: 30, 40 | }, 41 | 1024: { 42 | slidesPerView: 3, 43 | spaceBetween: 30, 44 | }, 45 | }; 46 | 47 | return ( 48 |
49 | 55 |
56 | { 61 | swiperRef.current = swiper; 62 | }} 63 | speed={1200} 64 | loop={true} 65 | // navigation={true} 66 | pagination={{ 67 | clickable: true, 68 | }} 69 | autoplay={{ 70 | delay: 2500, 71 | disableOnInteraction: false, 72 | }} 73 | modules={[Navigation, Pagination, Autoplay]} 74 | className="mySwiper" 75 | > 76 | {featuredData.length > 0 77 | ? featuredData.map((item: any, index: any) => { 78 | 79 | const startCountdownRenderer = ({ api, days, hours, minutes, seconds, completed }: any) => { 80 | if (api.isPaused()) api.start() 81 | return ( 82 | completed ? 83 | 91 | : 92 |
93 |

Starts In

94 |

95 | {days.toString().length === 1 ? `0${days}` : days}: 96 | {hours.toString().length === 1 ? `0${hours}` : hours}: 97 | {minutes.toString().length === 1 ? `0${minutes}` : minutes}: 98 | {seconds.toString().length === 1 ? `0${seconds}` : seconds} 99 |

100 |
101 | ) 102 | } 103 | 104 | const endCountdownRenderer = ({ api, days, hours, minutes, seconds, completed }: any) => { 105 | if (api.isPaused()) api.start() 106 | return ( 107 | completed ? 108 |

Ended

109 | : 110 |
111 |

Live

112 |

113 | {days.toString().length === 1 ? `0${days}` : days}: 114 | {hours.toString().length === 1 ? `0${hours}` : hours}: 115 | {minutes.toString().length === 1 ? `0${minutes}` : minutes}: 116 | {seconds.toString().length === 1 ? `0${seconds}` : seconds} 117 |

118 |
119 | 120 | ) 121 | } 122 | 123 | return ( 124 | 125 | 129 | 130 | ); 131 | }) 132 | : 133 |
134 | No Exist Lived NFT Now! 135 |
136 | } 137 |
138 |
139 | 149 |
150 | ); 151 | }; 152 | 153 | export default RaffleSwiper; 154 | -------------------------------------------------------------------------------- /src/services/api.ts: -------------------------------------------------------------------------------- 1 | import commonService from "./common.service"; 2 | import { API_URL } from "../config/dev"; 3 | 4 | export const getNfts = async (address: any) => { 5 | try { 6 | const result = commonService({ 7 | method: `get`, 8 | route: `${API_URL}/nft/${address}` 9 | }) 10 | return result 11 | } catch (error) { 12 | console.log('error', error) 13 | } 14 | } 15 | 16 | export const getAllAuctions = async () => { 17 | try { 18 | const result = await commonService({ 19 | method: "get", 20 | route: `${API_URL}/auction` 21 | }) 22 | return result 23 | } 24 | catch (error) { 25 | console.log('error', error); 26 | return null; 27 | } 28 | } 29 | 30 | export const createAuction = async (payload: FormData) => { 31 | 32 | try { 33 | const result = await commonService({ 34 | method: "post", 35 | route: `${API_URL}/auction`, 36 | // headerCred: { contentType: 'multipart/form-data' }, 37 | data: payload, 38 | }) 39 | 40 | return result 41 | } catch (error) { 42 | console.log('error', error); 43 | return null 44 | } 45 | } 46 | 47 | export const updateAuction = async (id: any, payload: FormData) => { 48 | try { 49 | const result = await commonService({ 50 | method: "put", 51 | route: `${API_URL}/auction/${id}`, 52 | // headerCred: { contentType: 'multipart/form-data' }, 53 | data: payload, 54 | }) 55 | 56 | return result 57 | } catch (error) { 58 | console.log('error', error); 59 | return null 60 | } 61 | } 62 | 63 | export const deleteAuction = async (id: any) => { 64 | try { 65 | const result = await commonService({ 66 | method: "post", 67 | route: `${API_URL}/auction/${id}/delete`, 68 | }) 69 | 70 | return result 71 | } catch (error) { 72 | console.log('error', error); 73 | return null 74 | } 75 | } 76 | 77 | export const getAuctionById = async (id: any) => { 78 | try { 79 | const result = await commonService({ 80 | method: 'get', 81 | route: `${API_URL}/auction/${id}` 82 | }) 83 | return result 84 | } catch (error) { 85 | console.log('error', error); 86 | return null 87 | } 88 | } 89 | 90 | export const getAllRaffle = async () => { 91 | try { 92 | const result = await commonService({ 93 | method: 'get', 94 | route: `${API_URL}/raffle` 95 | }) 96 | 97 | return result 98 | } catch (error) { 99 | console.log('error', error); 100 | return null 101 | } 102 | } 103 | 104 | export const getRaffleById = async (id: any) => { 105 | try { 106 | const result = await commonService({ 107 | method: 'get', 108 | route: `${API_URL}/raffle/${id}` 109 | }) 110 | return result 111 | } catch (error) { 112 | console.log('error', error) 113 | return null 114 | } 115 | } 116 | 117 | 118 | export const createRaffle = async (payload: FormData) => { 119 | try { 120 | const result = await commonService({ 121 | method: "post", 122 | route: `${API_URL}/raffle`, 123 | data: payload 124 | }) 125 | 126 | return result 127 | } catch (error) { 128 | console.log('error', error); 129 | return null 130 | } 131 | } 132 | 133 | export const updateRaffle = async (id: any, payload: FormData) => { 134 | try { 135 | const result = await commonService({ 136 | method: "put", 137 | route: `${API_URL}/raffle/${id}`, 138 | data: payload, 139 | }) 140 | 141 | return result 142 | } catch (error) { 143 | console.log('error', error); 144 | return null 145 | } 146 | } 147 | 148 | export const deleteRaffle = async (id: any) => { 149 | try { 150 | const result = await commonService({ 151 | method: "post", 152 | route: `${API_URL}/raffle/${id}/delete`, 153 | }) 154 | return result 155 | } catch (error) { 156 | console.log('error', error); 157 | return null 158 | } 159 | } 160 | 161 | export const finishRaffle = async (id: any) => { 162 | try { 163 | const result = await commonService({ 164 | method: "post", 165 | route: `${API_URL}/raffle/${id}/finish_raffle`, 166 | }) 167 | return result 168 | } catch (error) { 169 | console.log('error', error); 170 | return null 171 | } 172 | } 173 | 174 | export const getUser = async (wallet: string) => { 175 | try { 176 | const result = await commonService({ 177 | method: "get", 178 | route: `${API_URL}/user/${wallet}`, 179 | }) 180 | return result; 181 | } 182 | catch (error) { 183 | console.log('error', error); 184 | return null; 185 | } 186 | } 187 | 188 | export const createUser = async (wallet: string, signedMessage: string | null) => { 189 | try { 190 | const result = await commonService({ 191 | method: "post", 192 | route: `${API_URL}/user`, 193 | data: { 194 | wallet, 195 | signedMessage 196 | } 197 | }) 198 | return result; 199 | } 200 | catch (error) { 201 | console.log('error', error); 202 | return null; 203 | } 204 | } 205 | 206 | 207 | export const checkDiscordStatus = async (wallet: string) => { 208 | try { 209 | const result = await commonService({ 210 | method: "get", 211 | route: `${API_URL}/user/discord/status/${wallet}`, 212 | }) 213 | return result; 214 | } 215 | catch (error) { 216 | console.log('error', error); 217 | } 218 | } 219 | 220 | export const checkTwitterStatus = async (wallet: string) => { 221 | try { 222 | const result = await commonService({ 223 | method: "get", 224 | route: `${API_URL}/user/twitter/status/${wallet}`, 225 | }) 226 | return result; 227 | } 228 | catch (error) { 229 | console.log('error', error); 230 | } 231 | } -------------------------------------------------------------------------------- /src/services/contracts/raffle1155.ts: -------------------------------------------------------------------------------- 1 | import { Contract, ethers } from "ethers" 2 | import BigNumber from "bignumber.js"; 3 | 4 | import CONFIG from "../../config"; 5 | import { connectWallet } from "../../utils"; 6 | 7 | 8 | export const CreateRaffle1155Contract = async ( 9 | tokenContract: string, 10 | tokenId: number, 11 | tokenAmount: number, 12 | ticketPrice: number, 13 | maxTicketAmount: any, 14 | startDate: any, 15 | endDate: any, 16 | ) => { 17 | try { 18 | const Provider: any = new ethers.providers.Web3Provider(window.ethereum); 19 | const signer = Provider.getSigner(); 20 | const TokenContract = new Contract(tokenContract, CONFIG.TOKENERC1155, signer) 21 | const approveTx = await TokenContract.setApprovalForAll(CONFIG.RAFFLE.CONTRACTADDRESS1155, tokenId) 22 | await approveTx.wait() 23 | 24 | const raffleContract = new Contract(CONFIG.RAFFLE.CONTRACTADDRESS1155, CONFIG.RAFFLE.ABI1155, signer); 25 | const price = new BigNumber(ticketPrice).times(new BigNumber(10).pow(new BigNumber(18))) 26 | const tx = await raffleContract.createRaffle( 27 | tokenContract, 28 | tokenId, 29 | tokenAmount, 30 | price.toString(), 31 | maxTicketAmount, 32 | startDate, 33 | endDate 34 | ) 35 | await tx.wait() 36 | if (tx) { 37 | return true 38 | } 39 | } catch (error) { 40 | console.log('error', error) 41 | return false 42 | } 43 | } 44 | 45 | export const UpdateRaffle1155Contract = async ( 46 | itemId: string, 47 | ticketPrice: number, 48 | maxTicketAmount: any, 49 | startDate: any, 50 | endDate: any, 51 | ) => { 52 | try { 53 | const Provider: any = new ethers.providers.Web3Provider(window.ethereum); 54 | const signer = Provider.getSigner(); 55 | const raffleContract = new Contract(CONFIG.RAFFLE.CONTRACTADDRESS1155, CONFIG.RAFFLE.ABI1155, signer); 56 | const price = new BigNumber(ticketPrice).times(new BigNumber(10).pow(new BigNumber(18))) 57 | const tx = await raffleContract.updateRaffle( 58 | itemId, 59 | price.toString(), 60 | maxTicketAmount, 61 | startDate, 62 | endDate 63 | ) 64 | await tx.wait() 65 | if (tx) { 66 | return true 67 | } 68 | } catch (error) { 69 | console.log('error', error) 70 | return false 71 | } 72 | } 73 | 74 | export const FinishRaffle1155Contract = async ( 75 | itemId: number 76 | ) => { 77 | try { 78 | const Provider: any = new ethers.providers.Web3Provider(window.ethereum); 79 | const signer = Provider.getSigner(); 80 | 81 | const raffleContract = new Contract(CONFIG.RAFFLE.CONTRACTADDRESS1155, CONFIG.RAFFLE.ABI1155, signer); 82 | const tx = await raffleContract.completeRaffle(itemId) 83 | await tx.wait() 84 | if (tx) { 85 | return true 86 | } 87 | } catch (error) { 88 | console.log('error', error) 89 | return false 90 | } 91 | } 92 | 93 | export const CancelRaffle1155Contract = async ( 94 | itemId: string, 95 | ) => { 96 | try { 97 | const Provider: any = new ethers.providers.Web3Provider(window.ethereum); 98 | const signer = Provider.getSigner(); 99 | const raffleContract = new Contract(CONFIG.RAFFLE.CONTRACTADDRESS1155, CONFIG.RAFFLE.ABI1155, signer); 100 | const tx = await raffleContract.cancelRaffle(itemId) 101 | await tx.wait() 102 | if (tx) { 103 | return true 104 | } 105 | } catch (error) { 106 | console.log('error', error) 107 | return false 108 | } 109 | } 110 | 111 | export const buyTicket1155 = async ( 112 | itemId: number, 113 | ticketAmount: number, 114 | price: number 115 | ) => { 116 | try { 117 | const Provider: any = new ethers.providers.Web3Provider(window.ethereum); 118 | const signer = Provider.getSigner(); 119 | const raffleContract = new Contract(CONFIG.RAFFLE.CONTRACTADDRESS1155, CONFIG.RAFFLE.ABI1155, signer); 120 | const send_value: any = new BigNumber(price).times(new BigNumber(10).pow(new BigNumber(18))) 121 | const res = await raffleContract.buyTicket( 122 | itemId, 123 | ticketAmount, 124 | { value: (Math.floor(send_value)).toString() } 125 | ) 126 | await res.wait() 127 | if (res) { 128 | return true 129 | } 130 | } catch (error) { 131 | console.log('error', error) 132 | return false 133 | } 134 | } 135 | 136 | export const fetchRaffleLists1155 = async () => { 137 | try { 138 | const Provider: any = new ethers.providers.Web3Provider(window.ethereum); 139 | const signer = Provider.getSigner(); 140 | 141 | const raffleContract = new Contract(CONFIG.RAFFLE.CONTRACTADDRESS1155, CONFIG.RAFFLE.ABI1155, signer); 142 | 143 | const fetch_lists = await raffleContract.fetchRaffleItems() 144 | return fetch_lists 145 | } catch (error) { 146 | console.log('error', error) 147 | } 148 | } 149 | 150 | export const fetchRaffle1155Items = async (tokenId: any, tokenAddress: any, startDate: any) => { 151 | try { 152 | const Provider: any = new ethers.providers.Web3Provider(window.ethereum); 153 | const signer = Provider.getSigner(); 154 | 155 | const raffleContract = new Contract(CONFIG.RAFFLE.CONTRACTADDRESS1155, CONFIG.RAFFLE.ABI1155, signer); 156 | 157 | const fetch_lists = await raffleContract.fetchRaffleItems() 158 | const itemId = fetch_lists.findIndex((item: any) => item.tokenId.toNumber() === tokenId && item.nftContract.toLowerCase() === tokenAddress.toLowerCase() && item.startDate.toNumber() === startDate) 159 | const myWalletAddress: any = await connectWallet() 160 | 161 | const filterWinner = fetch_lists.filter((item: any) => item.winner.toLowerCase() === myWalletAddress.address) 162 | if (itemId > -1) { 163 | const getItem = fetch_lists.find((item: any) => item.tokenId.toNumber() === tokenId && item.nftContract.toLowerCase() === tokenAddress.toLowerCase() && item.startDate.toNumber() === startDate) 164 | return { itemId, winner: getItem?.winner.toLowerCase(), price: Number(getItem?.ticketPrice), winnerCount: filterWinner.length } 165 | } 166 | 167 | } catch (error) { 168 | console.log('error', error) 169 | } 170 | } 171 | 172 | export const fetchMyTickets1155 = async () => { 173 | try { 174 | const Provider: any = new ethers.providers.Web3Provider(window.ethereum); 175 | const signer = Provider.getSigner(); 176 | 177 | const raffleContract = new Contract(CONFIG.RAFFLE.CONTRACTADDRESS1155, CONFIG.RAFFLE.ABI1155, signer); 178 | const res = await raffleContract.fetchMyTicketItems() 179 | return res 180 | 181 | } catch (error) { 182 | console.log('error', error) 183 | } 184 | } 185 | 186 | export const fetchTicket1155ItemsByID = async (itemId: number) => { 187 | try { 188 | const Provider: any = new ethers.providers.Web3Provider(window.ethereum); 189 | const signer = Provider.getSigner(); 190 | 191 | const raffleContract = new Contract(CONFIG.RAFFLE.CONTRACTADDRESS1155, CONFIG.RAFFLE.ABI1155, signer); 192 | const res = await raffleContract.fetchTicketItemsByID(itemId) 193 | return res 194 | 195 | } catch (error) { 196 | console.log('error', error) 197 | } 198 | } 199 | -------------------------------------------------------------------------------- /src/components/SwiperItem.tsx: -------------------------------------------------------------------------------- 1 | import { useState, useEffect } from 'react' 2 | import { SwiperSlide } from "swiper/react" 3 | import { Link } from "react-router-dom"; 4 | import Countdown, { CountdownApi } from 'react-countdown' 5 | 6 | 7 | import VerificationIcon from "../assets/verification-icon.svg"; 8 | import { fetchRaffle1155Items, fetchTicket1155ItemsByID } from '../services/contracts/raffle1155'; 9 | import { fetchRaffleItems, fetchTicketItemsByID } from '../services/contracts/raffle'; 10 | 11 | const SwiperItem = (props: any) => { 12 | const { item, index } = props 13 | const [sellAmount, setSellAmount] = useState(0) 14 | 15 | let startCountdownApi: CountdownApi | null = null 16 | let endCountdownApi: CountdownApi | null = null 17 | 18 | const setStartCountdownRef = (countdown: Countdown | null) => { 19 | if (countdown) { 20 | startCountdownApi = countdown.getApi() 21 | } 22 | } 23 | 24 | const setEndCountdownRef = (countdown: Countdown | null) => { 25 | if (countdown) { 26 | endCountdownApi = countdown.getApi() 27 | } 28 | } 29 | 30 | const startCountdownRenderer = ({ api, days, hours, minutes, seconds, completed }: any) => { 31 | if (api.isPaused()) api.start() 32 | return ( 33 | completed ? 34 | 41 | : 42 |
43 |

Starts In

44 |

45 | {days.toString().length === 1 ? `0${days}` : days}: 46 | {hours.toString().length === 1 ? `0${hours}` : hours}: 47 | {minutes.toString().length === 1 ? `0${minutes}` : minutes}: 48 | {seconds.toString().length === 1 ? `0${seconds}` : seconds} 49 |

50 |
51 | ) 52 | } 53 | 54 | const endCountdownRenderer = ({ api, days, hours, minutes, seconds, completed }: any) => { 55 | if (api.isPaused()) api.start() 56 | return ( 57 | completed ? 58 |

Ended

59 | : 60 |
61 |

Live

62 |

63 | {days.toString().length === 1 ? `0${days}` : days}: 64 | {hours.toString().length === 1 ? `0${hours}` : hours}: 65 | {minutes.toString().length === 1 ? `0${minutes}` : minutes}: 66 | {seconds.toString().length === 1 ? `0${seconds}` : seconds} 67 |

68 |
69 | 70 | ) 71 | } 72 | 73 | useEffect(() => { 74 | ( 75 | async () => { 76 | try { 77 | if (item.type === `ERC1155`) { 78 | const getRaffleInfo = await fetchRaffle1155Items(item.tokenId, item.tokenAddress, item.start_date) 79 | const getTicketByID = await fetchTicket1155ItemsByID(getRaffleInfo?.itemId + 1) 80 | let filter_TicketByID = getTicketByID.filter( 81 | (person: any, index: any) => index === getTicketByID.findIndex( 82 | (other: any) => person.buyer === other.buyer 83 | )); 84 | let totalAmount = 0 85 | for (let i = 0; i < filter_TicketByID.length; i++) { 86 | totalAmount += filter_TicketByID[i].ticketAmount.toNumber() 87 | } 88 | setSellAmount(totalAmount) 89 | } else { 90 | const getRaffleInfo = await fetchRaffleItems(item.tokenId, item.tokenAddress, item.start_date) 91 | 92 | const getTicketByID = await fetchTicketItemsByID(getRaffleInfo?.itemId + 1) 93 | 94 | let filter_TicketByID = getTicketByID.filter( 95 | (person: any, index: any) => index === getTicketByID.findIndex( 96 | (other: any) => person.buyer === other.buyer 97 | )); 98 | let totalAmount = 0 99 | for (let i = 0; i < filter_TicketByID.length; i++) { 100 | totalAmount += filter_TicketByID[i].ticketAmount.toNumber() 101 | } 102 | setSellAmount(totalAmount) 103 | } 104 | } catch (error) { 105 | console.log('error', error) 106 | } 107 | } 108 | )() 109 | 110 | }, []) 111 | 112 | return ( 113 |
114 |
115 | CoodeImage 120 |
121 |
122 |
123 |
124 | VerificationIcon 129 | 130 | {item.project} 131 | 132 |
133 |

{item.name}

134 |
135 | 136 |
137 |
138 |

Ticket Price

139 |

140 | {item.price} MATIC 141 |

142 |
143 |
144 |

Tickets Remaining

145 |

146 | {item.total_tickets}/{item.total_tickets} 147 |

148 |
149 |
150 |

Time Remaining

151 |

152 | setShowEdit(false)} 157 | renderer={startCountdownRenderer} 158 | /> 159 |

160 |
161 |
162 | 163 |
164 | { 165 | item.type === `ERC1155` ? 166 | 170 | View Raffle 171 | 172 | : 173 | 177 | View Raffle 178 | 179 | 180 | } 181 |
182 | 183 |
184 |
185 | 186 | ) 187 | } 188 | 189 | export default SwiperItem -------------------------------------------------------------------------------- /src/pages/Auction/FilterAuction.tsx: -------------------------------------------------------------------------------- 1 | import Countdown, { CountdownApi } from 'react-countdown' 2 | import { Link } from 'react-router-dom'; 3 | import VerificationIcon from "../../assets/Verification-icon.png"; 4 | import UnionIcons from "../../assets/Union-icons.png"; 5 | 6 | const FilterAuction = ({ item }: any) => { 7 | 8 | let startCountdownApi: CountdownApi | null = null 9 | let endCountdownApi: CountdownApi | null = null 10 | 11 | const setStartCountdownRef = (countdown: Countdown | null) => { 12 | if (countdown) { 13 | startCountdownApi = countdown.getApi() 14 | } 15 | } 16 | 17 | const setEndCountdownRef = (countdown: Countdown | null) => { 18 | if (countdown) { 19 | endCountdownApi = countdown.getApi() 20 | } 21 | } 22 | 23 | const startCountdownRenderer = ({ api, days, hours, minutes, seconds, completed }: any) => { 24 | if (api.isPaused()) api.start() 25 | return ( 26 | completed ? 27 | 34 | : 35 |
36 |

Starts In

37 |

38 | {days.toString().length === 1 ? `0${days}` : days}: 39 | {hours.toString().length === 1 ? `0${hours}` : hours}: 40 | {minutes.toString().length === 1 ? `0${minutes}` : minutes}: 41 | {seconds.toString().length === 1 ? `0${seconds}` : seconds} 42 |

43 |
44 | ) 45 | } 46 | 47 | const endCountdownRenderer = ({ api, days, hours, minutes, seconds, completed }: any) => { 48 | if (api.isPaused()) api.start() 49 | return ( 50 | completed ? 51 |

Ended

52 | : 53 |
54 |

Live

55 |

56 | {days.toString().length === 1 ? `0${days}` : days}: 57 | {hours.toString().length === 1 ? `0${hours}` : hours}: 58 | {minutes.toString().length === 1 ? `0${minutes}` : minutes}: 59 | {seconds.toString().length === 1 ? `0${seconds}` : seconds} 60 |

61 |
62 | 63 | ) 64 | } 65 | 66 | return ( 67 |
68 |
69 |
70 | CoodeImage 75 |
76 |
77 |
78 |
79 |

80 | {item.tokenName} 81 |

82 |

83 | #{item.tokenId} 84 |

85 |
86 |
87 |
88 |
89 |

90 | UnionIcons 95 |

96 |

97 | #0001 98 |

99 |
100 |
101 |

102 | Floor 103 |

104 |

105 | 9.9 106 |

107 |
108 |
109 |
110 |
111 |
112 |
113 |
114 |
115 | VerificationIcon 119 | 120 | {item.tokenName} 121 | 122 |
123 |

@{item.project}

124 |
125 |
126 |
127 |
128 |

Time Remaining

129 |

130 | 137 |

138 |
139 |
140 |

Tickets Remaining

141 |

142 | {item.count}/{item.total_tickets} 143 |

144 |
145 |
146 |
147 |
148 |

Ticket Price

149 |

150 | {item.price} Polygon 151 |

152 |
153 | {/*
154 | 160 | 166 |
*/} 167 |
168 |
169 |
170 |
171 |
172 | 176 | View Raffle 177 | 178 |
179 |
180 | ); 181 | }; 182 | 183 | export default FilterAuction; 184 | -------------------------------------------------------------------------------- /src/services/contracts/raffle.ts: -------------------------------------------------------------------------------- 1 | import { Contract, ethers } from "ethers" 2 | import BigNumber from "bignumber.js"; 3 | 4 | import CONFIG from "../../config"; 5 | import { connectWallet } from "../../utils"; 6 | 7 | 8 | export const CreateRaffleContract = async ( 9 | tokenContract: string, 10 | tokenId: number, 11 | ticketPrice: number, 12 | maxTicketAmount: any, 13 | startDate: any, 14 | endDate: any, 15 | ) => { 16 | try { 17 | const Provider: any = new ethers.providers.Web3Provider(window.ethereum); 18 | const signer = Provider.getSigner(); 19 | const TokenContract = new Contract(tokenContract, CONFIG.TOKENERC721, signer) 20 | const approveTx = await TokenContract.approve(CONFIG.RAFFLE.CONTRACTADDRESS721, tokenId) 21 | await approveTx.wait() 22 | 23 | const raffleContract = new Contract(CONFIG.RAFFLE.CONTRACTADDRESS721, CONFIG.RAFFLE.ABI721, signer); 24 | const price = new BigNumber(ticketPrice).times(new BigNumber(10).pow(new BigNumber(18))) 25 | const tx = await raffleContract.createRaffle( 26 | tokenContract, 27 | tokenId, 28 | price.toString(), 29 | maxTicketAmount, 30 | startDate, 31 | endDate 32 | ) 33 | await tx.wait() 34 | if (tx) { 35 | return true 36 | } 37 | } catch (error) { 38 | console.log('error', error) 39 | return false 40 | } 41 | } 42 | 43 | export const UpdateRaffleContract = async ( 44 | itemId: number, 45 | ticketPrice: number, 46 | maxTicketAmount: number, 47 | startDate: any, 48 | endDate: any, 49 | ) => { 50 | try { 51 | const Provider: any = new ethers.providers.Web3Provider(window.ethereum); 52 | const signer = Provider.getSigner(); 53 | 54 | const raffleContract = new Contract(CONFIG.RAFFLE.CONTRACTADDRESS721, CONFIG.RAFFLE.ABI721, signer); 55 | 56 | const price = new BigNumber(ticketPrice).times(new BigNumber(10).pow(new BigNumber(18))) 57 | const tx = await raffleContract.updateRaffle( 58 | itemId, 59 | price.toString(), 60 | maxTicketAmount, 61 | startDate, 62 | endDate 63 | ) 64 | await tx.wait() 65 | if (tx) { 66 | return true 67 | } 68 | } catch (error) { 69 | console.log('error', error) 70 | return false 71 | } 72 | } 73 | 74 | export const FinishRaffleContract = async ( 75 | itemId: number 76 | ) => { 77 | try { 78 | const Provider: any = new ethers.providers.Web3Provider(window.ethereum); 79 | const signer = Provider.getSigner(); 80 | 81 | const raffleContract = new Contract(CONFIG.RAFFLE.CONTRACTADDRESS721, CONFIG.RAFFLE.ABI721, signer); 82 | const tx = await raffleContract.completeRaffle(itemId) 83 | await tx.wait() 84 | if (tx) { 85 | return true 86 | } 87 | } catch (error) { 88 | console.log('error', error) 89 | return false 90 | } 91 | } 92 | 93 | export const CancelRaffleContract = async (itemId: any) => { 94 | try { 95 | const Provider: any = new ethers.providers.Web3Provider(window.ethereum); 96 | const signer = Provider.getSigner(); 97 | 98 | const raffleContract = new Contract(CONFIG.RAFFLE.CONTRACTADDRESS721, CONFIG.RAFFLE.ABI721, signer); 99 | const tx = await raffleContract.cancelRaffle(itemId); 100 | 101 | await tx.wait() 102 | 103 | if (tx) { 104 | return true 105 | } 106 | 107 | } catch (error) { 108 | console.log('error', error) 109 | } 110 | } 111 | 112 | export const buyTicket = async (itemId: number, ticketAmount: number, price: number) => { 113 | try { 114 | const Provider: any = new ethers.providers.Web3Provider(window.ethereum); 115 | const signer = Provider.getSigner(); 116 | 117 | const raffleContract = new Contract(CONFIG.RAFFLE.CONTRACTADDRESS721, CONFIG.RAFFLE.ABI721, signer); 118 | const send_value: any = new BigNumber(price).times(new BigNumber(10).pow(new BigNumber(18))) 119 | const res = await raffleContract.buyTicket( 120 | itemId, 121 | ticketAmount, 122 | { value: (Math.floor(send_value)).toString() } 123 | ); 124 | await res.wait() 125 | 126 | return res 127 | 128 | } catch (error) { 129 | console.log('error', error) 130 | } 131 | } 132 | 133 | export const fetchRaffleLists = async () => { 134 | try { 135 | const Provider: any = new ethers.providers.Web3Provider(window.ethereum); 136 | const signer = Provider.getSigner(); 137 | 138 | const raffleContract = new Contract(CONFIG.RAFFLE.CONTRACTADDRESS721, CONFIG.RAFFLE.ABI721, signer); 139 | const fetch_lists = await raffleContract.fetchRaffleItems() 140 | return fetch_lists 141 | 142 | } catch (error) { 143 | console.log('error', error) 144 | } 145 | } 146 | 147 | export const fetchRaffleItems = async (tokenId: any, tokenAddress: any, startDate: any) => { 148 | try { 149 | 150 | const Provider: any = new ethers.providers.Web3Provider(window.ethereum); 151 | const signer = Provider.getSigner(); 152 | 153 | const raffleContract = new Contract(CONFIG.RAFFLE.CONTRACTADDRESS721, CONFIG.RAFFLE.ABI721, signer); 154 | const fetch_lists = await raffleContract.fetchRaffleItems() 155 | 156 | const myWalletAddress: any = await connectWallet() 157 | 158 | const filterWinner = fetch_lists.filter((item: any) => item.winner.toLowerCase() === myWalletAddress.address) 159 | 160 | const itemId = fetch_lists.findIndex((item: any) => item.tokenId.toNumber() === tokenId && item.nftContract.toLowerCase() === tokenAddress.toLowerCase() && item.startDate.toNumber() === startDate) 161 | 162 | const getItem = fetch_lists.find((item: any) => item.tokenId.toNumber() === tokenId && item.nftContract.toLowerCase() === tokenAddress.toLowerCase() && item.startDate.toNumber() === startDate) 163 | 164 | return { itemId, winner: getItem?.winner.toLowerCase(), price: Number(getItem?.ticketPrice), winnerCount: filterWinner.length } 165 | } catch (error) { 166 | console.log('error', error) 167 | } 168 | } 169 | 170 | export const fetchMyTickets = async () => { 171 | try { 172 | const Provider: any = new ethers.providers.Web3Provider(window.ethereum); 173 | const signer = Provider.getSigner(); 174 | 175 | const raffleContract = new Contract(CONFIG.RAFFLE.CONTRACTADDRESS721, CONFIG.RAFFLE.ABI721, signer); 176 | 177 | const res = await raffleContract.fetchMyTicketItems() 178 | return res 179 | 180 | } catch (error) { 181 | console.log('error', error) 182 | } 183 | } 184 | 185 | export const fetchTicketItemsByID = async (itemId: number) => { 186 | try { 187 | const Provider: any = new ethers.providers.Web3Provider(window.ethereum); 188 | const signer = Provider.getSigner(); 189 | 190 | const raffleContract = new Contract(CONFIG.RAFFLE.CONTRACTADDRESS721, CONFIG.RAFFLE.ABI721, signer); 191 | 192 | const res = await raffleContract.fetchTicketItemsByID(itemId) 193 | return res 194 | } catch (error) { 195 | console.log('error', error) 196 | } 197 | } 198 | 199 | export const completeRaffle = async (itemId: any) => { 200 | try { 201 | const Provider: any = new ethers.providers.Web3Provider(window.ethereum); 202 | const signer = Provider.getSigner(); 203 | 204 | const raffleContract = new Contract(CONFIG.RAFFLE.CONTRACTADDRESS721, CONFIG.RAFFLE.ABI721, signer); 205 | const res = await raffleContract.completeRaffle(itemId); 206 | return res 207 | } catch (error) { 208 | console.log('error', error) 209 | } 210 | } -------------------------------------------------------------------------------- /src/constants/Token/Erc1155Token.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "inputs": [ 4 | { 5 | "internalType": "string", 6 | "name": "uri_", 7 | "type": "string" 8 | } 9 | ], 10 | "stateMutability": "nonpayable", 11 | "type": "constructor" 12 | }, 13 | { 14 | "anonymous": false, 15 | "inputs": [ 16 | { 17 | "indexed": true, 18 | "internalType": "address", 19 | "name": "account", 20 | "type": "address" 21 | }, 22 | { 23 | "indexed": true, 24 | "internalType": "address", 25 | "name": "operator", 26 | "type": "address" 27 | }, 28 | { 29 | "indexed": false, 30 | "internalType": "bool", 31 | "name": "approved", 32 | "type": "bool" 33 | } 34 | ], 35 | "name": "ApprovalForAll", 36 | "type": "event" 37 | }, 38 | { 39 | "anonymous": false, 40 | "inputs": [ 41 | { 42 | "indexed": true, 43 | "internalType": "address", 44 | "name": "operator", 45 | "type": "address" 46 | }, 47 | { 48 | "indexed": true, 49 | "internalType": "address", 50 | "name": "from", 51 | "type": "address" 52 | }, 53 | { 54 | "indexed": true, 55 | "internalType": "address", 56 | "name": "to", 57 | "type": "address" 58 | }, 59 | { 60 | "indexed": false, 61 | "internalType": "uint256[]", 62 | "name": "ids", 63 | "type": "uint256[]" 64 | }, 65 | { 66 | "indexed": false, 67 | "internalType": "uint256[]", 68 | "name": "values", 69 | "type": "uint256[]" 70 | } 71 | ], 72 | "name": "TransferBatch", 73 | "type": "event" 74 | }, 75 | { 76 | "anonymous": false, 77 | "inputs": [ 78 | { 79 | "indexed": true, 80 | "internalType": "address", 81 | "name": "operator", 82 | "type": "address" 83 | }, 84 | { 85 | "indexed": true, 86 | "internalType": "address", 87 | "name": "from", 88 | "type": "address" 89 | }, 90 | { 91 | "indexed": true, 92 | "internalType": "address", 93 | "name": "to", 94 | "type": "address" 95 | }, 96 | { 97 | "indexed": false, 98 | "internalType": "uint256", 99 | "name": "id", 100 | "type": "uint256" 101 | }, 102 | { 103 | "indexed": false, 104 | "internalType": "uint256", 105 | "name": "value", 106 | "type": "uint256" 107 | } 108 | ], 109 | "name": "TransferSingle", 110 | "type": "event" 111 | }, 112 | { 113 | "anonymous": false, 114 | "inputs": [ 115 | { 116 | "indexed": false, 117 | "internalType": "string", 118 | "name": "value", 119 | "type": "string" 120 | }, 121 | { 122 | "indexed": true, 123 | "internalType": "uint256", 124 | "name": "id", 125 | "type": "uint256" 126 | } 127 | ], 128 | "name": "URI", 129 | "type": "event" 130 | }, 131 | { 132 | "inputs": [ 133 | { 134 | "internalType": "address", 135 | "name": "account", 136 | "type": "address" 137 | }, 138 | { 139 | "internalType": "uint256", 140 | "name": "id", 141 | "type": "uint256" 142 | } 143 | ], 144 | "name": "balanceOf", 145 | "outputs": [ 146 | { 147 | "internalType": "uint256", 148 | "name": "", 149 | "type": "uint256" 150 | } 151 | ], 152 | "stateMutability": "view", 153 | "type": "function" 154 | }, 155 | { 156 | "inputs": [ 157 | { 158 | "internalType": "address[]", 159 | "name": "accounts", 160 | "type": "address[]" 161 | }, 162 | { 163 | "internalType": "uint256[]", 164 | "name": "ids", 165 | "type": "uint256[]" 166 | } 167 | ], 168 | "name": "balanceOfBatch", 169 | "outputs": [ 170 | { 171 | "internalType": "uint256[]", 172 | "name": "", 173 | "type": "uint256[]" 174 | } 175 | ], 176 | "stateMutability": "view", 177 | "type": "function" 178 | }, 179 | { 180 | "inputs": [ 181 | { 182 | "internalType": "address", 183 | "name": "account", 184 | "type": "address" 185 | }, 186 | { 187 | "internalType": "address", 188 | "name": "operator", 189 | "type": "address" 190 | } 191 | ], 192 | "name": "isApprovedForAll", 193 | "outputs": [ 194 | { 195 | "internalType": "bool", 196 | "name": "", 197 | "type": "bool" 198 | } 199 | ], 200 | "stateMutability": "view", 201 | "type": "function" 202 | }, 203 | { 204 | "inputs": [ 205 | { 206 | "internalType": "address", 207 | "name": "from", 208 | "type": "address" 209 | }, 210 | { 211 | "internalType": "address", 212 | "name": "to", 213 | "type": "address" 214 | }, 215 | { 216 | "internalType": "uint256[]", 217 | "name": "ids", 218 | "type": "uint256[]" 219 | }, 220 | { 221 | "internalType": "uint256[]", 222 | "name": "amounts", 223 | "type": "uint256[]" 224 | }, 225 | { 226 | "internalType": "bytes", 227 | "name": "data", 228 | "type": "bytes" 229 | } 230 | ], 231 | "name": "safeBatchTransferFrom", 232 | "outputs": [], 233 | "stateMutability": "nonpayable", 234 | "type": "function" 235 | }, 236 | { 237 | "inputs": [ 238 | { 239 | "internalType": "address", 240 | "name": "from", 241 | "type": "address" 242 | }, 243 | { 244 | "internalType": "address", 245 | "name": "to", 246 | "type": "address" 247 | }, 248 | { 249 | "internalType": "uint256", 250 | "name": "id", 251 | "type": "uint256" 252 | }, 253 | { 254 | "internalType": "uint256", 255 | "name": "amount", 256 | "type": "uint256" 257 | }, 258 | { 259 | "internalType": "bytes", 260 | "name": "data", 261 | "type": "bytes" 262 | } 263 | ], 264 | "name": "safeTransferFrom", 265 | "outputs": [], 266 | "stateMutability": "nonpayable", 267 | "type": "function" 268 | }, 269 | { 270 | "inputs": [ 271 | { 272 | "internalType": "address", 273 | "name": "operator", 274 | "type": "address" 275 | }, 276 | { 277 | "internalType": "bool", 278 | "name": "approved", 279 | "type": "bool" 280 | } 281 | ], 282 | "name": "setApprovalForAll", 283 | "outputs": [], 284 | "stateMutability": "nonpayable", 285 | "type": "function" 286 | }, 287 | { 288 | "inputs": [ 289 | { 290 | "internalType": "bytes4", 291 | "name": "interfaceId", 292 | "type": "bytes4" 293 | } 294 | ], 295 | "name": "supportsInterface", 296 | "outputs": [ 297 | { 298 | "internalType": "bool", 299 | "name": "", 300 | "type": "bool" 301 | } 302 | ], 303 | "stateMutability": "view", 304 | "type": "function" 305 | }, 306 | { 307 | "inputs": [ 308 | { 309 | "internalType": "uint256", 310 | "name": "", 311 | "type": "uint256" 312 | } 313 | ], 314 | "name": "uri", 315 | "outputs": [ 316 | { 317 | "internalType": "string", 318 | "name": "", 319 | "type": "string" 320 | } 321 | ], 322 | "stateMutability": "view", 323 | "type": "function" 324 | } 325 | ] -------------------------------------------------------------------------------- /src/services/contracts/auction.ts: -------------------------------------------------------------------------------- 1 | import { Contract, ethers } from "ethers" 2 | import BigNumber from "bignumber.js"; 3 | 4 | import CONFIG from "../../config"; 5 | 6 | 7 | export const CreateAuctionContract = async ( 8 | tokenContract: string, 9 | tokenId: number, 10 | minPrice: number, 11 | startDate: any, 12 | endDate: any, 13 | ) => { 14 | try { 15 | const Provider: any = new ethers.providers.Web3Provider(window.ethereum); 16 | const signer = Provider.getSigner(); 17 | const TokenContract = new Contract(tokenContract, CONFIG.TOKENERC721, signer) 18 | const approveTx = await TokenContract.approve(CONFIG.AUCTION.CONTRACTADDRESS721, tokenId) 19 | await approveTx.wait() 20 | 21 | const auctionContract = new Contract(CONFIG.AUCTION.CONTRACTADDRESS721, CONFIG.AUCTION.ABI721, signer); 22 | const price = new BigNumber(minPrice).times(new BigNumber(10).pow(new BigNumber(18))) 23 | const tx = await auctionContract.createAuction( 24 | tokenContract, 25 | tokenId, 26 | price.toString(), 27 | startDate, 28 | endDate 29 | ) 30 | await tx.wait() 31 | if (tx) { 32 | return true 33 | } 34 | 35 | } catch (error) { 36 | console.log('error', error) 37 | return false 38 | } 39 | } 40 | 41 | export const UpdateAuctionContract = async ( 42 | itemId: number, 43 | minPrice: number, 44 | startDate: any, 45 | endDate: any, 46 | ) => { 47 | try { 48 | const Provider: any = new ethers.providers.Web3Provider(window.ethereum); 49 | const signer = Provider.getSigner(); 50 | 51 | const auctionContract = new Contract(CONFIG.AUCTION.CONTRACTADDRESS721, CONFIG.AUCTION.ABI721, signer); 52 | 53 | const price = new BigNumber(minPrice).times(new BigNumber(10).pow(new BigNumber(18))) 54 | const tx = await auctionContract.updateAuction( 55 | itemId, 56 | price.toString(), 57 | startDate, 58 | endDate 59 | ) 60 | await tx.wait() 61 | if (tx) { 62 | return true 63 | } 64 | 65 | } catch (error) { 66 | console.log('error', error) 67 | return false 68 | 69 | } 70 | } 71 | 72 | export const CancelAuctionContract = async (itemId: any) => { 73 | try { 74 | const Provider: any = new ethers.providers.Web3Provider(window.ethereum); 75 | const signer = Provider.getSigner(); 76 | 77 | const auctionContract = new Contract(CONFIG.AUCTION.CONTRACTADDRESS721, CONFIG.AUCTION.ABI721, signer); 78 | const tx = await auctionContract.cancelAuction(itemId); 79 | 80 | await tx.wait() 81 | 82 | if (tx) { 83 | return true 84 | } 85 | 86 | } catch (error) { 87 | console.log('error', error) 88 | } 89 | } 90 | 91 | export const createBidAuction = async (itemId: number, price: number) => { 92 | try { 93 | const Provider: any = new ethers.providers.Web3Provider(window.ethereum); 94 | const signer = Provider.getSigner(); 95 | 96 | const auctionContract = new Contract(CONFIG.AUCTION.CONTRACTADDRESS721, CONFIG.AUCTION.ABI721, signer); 97 | 98 | const send_value = new BigNumber(price).times(new BigNumber(10).pow(new BigNumber(18))) 99 | const res = await auctionContract.createBid(itemId, { 100 | value: send_value.toString() 101 | }); 102 | 103 | await res.wait() 104 | 105 | return res 106 | 107 | } catch (error) { 108 | console.log('error', error) 109 | } 110 | } 111 | 112 | export const updateBidAuction = async (itemId: number, price: number) => { 113 | try { 114 | const Provider: any = new ethers.providers.Web3Provider(window.ethereum); 115 | const signer = Provider.getSigner(); 116 | 117 | const auctionContract = new Contract(CONFIG.AUCTION.CONTRACTADDRESS721, CONFIG.AUCTION.ABI721, signer); 118 | 119 | const send_value = new BigNumber(price).times(new BigNumber(10).pow(new BigNumber(18))) 120 | const res = await auctionContract.updateBid(itemId, { 121 | value: send_value.toString() 122 | }); 123 | 124 | await res.wait() 125 | 126 | return res 127 | 128 | } catch (error) { 129 | console.log('error', error) 130 | } 131 | } 132 | 133 | export const cancelBidAuction = async (itemId: number) => { 134 | try { 135 | const Provider: any = new ethers.providers.Web3Provider(window.ethereum); 136 | const signer = Provider.getSigner(); 137 | 138 | const auctionContract = new Contract(CONFIG.AUCTION.CONTRACTADDRESS721, CONFIG.AUCTION.ABI721, signer); 139 | 140 | const res = await auctionContract.cancelBid(itemId) 141 | 142 | await res.wait() 143 | 144 | return res 145 | 146 | } catch (error) { 147 | console.log('error', error) 148 | } 149 | } 150 | 151 | export const claimBidAuction = async (itemId: any) => { 152 | try { 153 | const Provider: any = new ethers.providers.Web3Provider(window.ethereum); 154 | const signer = Provider.getSigner(); 155 | 156 | const auctionContract = new Contract(CONFIG.AUCTION.CONTRACTADDRESS721, CONFIG.AUCTION.ABI721, signer); 157 | 158 | const tx = await auctionContract.claimAuction(itemId); 159 | await tx.wait() 160 | return tx 161 | 162 | } catch (error) { 163 | console.log('error', error) 164 | } 165 | } 166 | 167 | 168 | export const fetchAuctionItems = async (tokenId: any, tokenAddress: any, startDate: any) => { 169 | try { 170 | const Provider: any = new ethers.providers.Web3Provider(window.ethereum); 171 | const signer = Provider.getSigner(); 172 | 173 | const auctionContract = new Contract(CONFIG.AUCTION.CONTRACTADDRESS721, CONFIG.AUCTION.ABI721, signer); 174 | 175 | const fetch_lists = await auctionContract.fetchAuctionItems() 176 | const itemId = fetch_lists.findIndex((item: any) => item.tokenId.toNumber() === tokenId && item.nftContract.toLowerCase() === tokenAddress.toLowerCase() && item.startDate.toNumber() === Number(startDate)) 177 | 178 | const fetchLists = fetch_lists.find((item: any) => item.tokenId.toNumber() === tokenId && item.nftContract.toLowerCase() === tokenAddress.toLowerCase() && item.startDate.toNumber() === Number(startDate)) 179 | 180 | return { itemId, largestPrice: fetchLists?.largestBidPrice.toNumber() } 181 | } catch (error) { 182 | console.log('error', error) 183 | } 184 | } 185 | 186 | export const fetchMyBidItems = async () => { 187 | try { 188 | const Provider: any = new ethers.providers.Web3Provider(window.ethereum); 189 | const signer = Provider.getSigner(); 190 | 191 | const auctionContract = new Contract(CONFIG.AUCTION.CONTRACTADDRESS721, CONFIG.AUCTION.ABI721, signer); 192 | 193 | const res = await auctionContract.fetchMyBidItems() 194 | return res 195 | 196 | } catch (error) { 197 | console.log('error', error) 198 | } 199 | } 200 | 201 | export const fetchBidItemsById = async (itemId: any) => { 202 | try { 203 | const Provider: any = new ethers.providers.Web3Provider(window.ethereum); 204 | const signer = Provider.getSigner(); 205 | 206 | const auctionContract = new Contract(CONFIG.AUCTION.CONTRACTADDRESS721, CONFIG.AUCTION.ABI721, signer); 207 | 208 | const res = await auctionContract.fetchBidItemsByID(itemId); 209 | 210 | return res 211 | } catch (error) { 212 | console.log('error', error) 213 | } 214 | } 215 | 216 | export const getSoldNftStatus = async (tokenId: any, tokenAddress: any, startDate: any) => { 217 | try { 218 | const Provider: any = new ethers.providers.Web3Provider(window.ethereum); 219 | const signer = Provider.getSigner(); 220 | 221 | const auctionContract = new Contract(CONFIG.AUCTION.CONTRACTADDRESS721, CONFIG.AUCTION.ABI721, signer); 222 | 223 | const fetch_lists = await auctionContract.fetchAuctionItems() 224 | const res = fetch_lists.find((item: any) => item.tokenId.toNumber() === tokenId && item.nftContract.toLowerCase() === tokenAddress.toLowerCase() && item.startDate.toNumber() === Number(startDate)) 225 | return res?.sold 226 | } catch (error) { 227 | console.log('error', error) 228 | } 229 | } -------------------------------------------------------------------------------- /src/pages/Auction/Profile.tsx: -------------------------------------------------------------------------------- 1 | import { useState, useEffect } from 'react' 2 | import { useSelector } from 'react-redux'; 3 | import { Link } from "react-router-dom" 4 | import Navbar from "../../components/Navbar" 5 | import TwitterBlack from "../../assets/Twitter-black.png"; 6 | import DiscordBlack from "../../assets/Discord-Black.png"; 7 | import infoIconBlack from "../../assets/InfoIconBlack.png"; 8 | import { createUser, getAllAuctions, getUser, checkDiscordStatus, checkTwitterStatus } from '../../services/api'; 9 | import AuctionRarticipant from './AuctionParticipant' 10 | import { toast } from "react-toastify"; 11 | import CONFIG from '../../config'; 12 | 13 | 14 | const AuctionProfile = () => { 15 | const [isLoading, setLoading] = useState(false) 16 | const [participantLists, setParticipantLists] = useState([]) 17 | const storeData: any = useSelector((status) => status) 18 | const [token, setToken] = useState(localStorage.getItem("token")) 19 | const [discord, setDiscord] = useState(''); 20 | const [twitter, setTwitter] = useState(''); 21 | const [social, setSocial] = useState(false); 22 | 23 | const handleConnectDiscord = async () => { 24 | try { 25 | if (discord) { 26 | toast.error(`You have already Discord Account`) 27 | return; 28 | } 29 | if (storeData.wallet !== 'connected') { 30 | toast.error("Connect your Wallet!"); 31 | return 32 | } 33 | setLoading(true) 34 | let user = await getUser(storeData.address); 35 | let signedMessage = null; 36 | if (!user) { 37 | 38 | signedMessage = await window.ethereum.request({ 39 | method: "personal_sign", 40 | params: ["Sign Message", storeData.address], 41 | }); 42 | } 43 | const token: any = await createUser(storeData.address, signedMessage); 44 | localStorage.setItem('token', JSON.stringify(token)); 45 | if (token) { 46 | window.open(CONFIG.Backend_URL + "/api/oauth/discord?token=" + token); 47 | } 48 | setLoading(false) 49 | 50 | } 51 | catch (error) { 52 | console.log('error', error); 53 | setLoading(false) 54 | 55 | } 56 | } 57 | 58 | const handleConnectTwitter = async () => { 59 | try { 60 | if (twitter) { 61 | toast.error(`You have already Twitter Account`) 62 | return 63 | }; 64 | if (storeData.wallet !== `connected`) { 65 | toast.error("Connect your Wallet!"); 66 | return 67 | } 68 | let user = await getUser(storeData.address); 69 | let signedMessage = null; 70 | if (!user) { 71 | signedMessage = await window.ethereum.request({ 72 | method: "personal_sign", 73 | params: ["Sign Message", storeData.address], 74 | }); 75 | } 76 | const token: any = await createUser(storeData.address, signedMessage); 77 | localStorage.setItem('token', JSON.stringify(token)); 78 | setToken(token); 79 | if (token) { 80 | window.open(CONFIG.Backend_URL + "/api/oauth/twitter?token=" + token); 81 | setSocial(!social); 82 | } 83 | } 84 | catch (error) { 85 | console.log('error', error); 86 | setLoading(false) 87 | } 88 | } 89 | 90 | useEffect(() => { 91 | (async () => { 92 | if (storeData.wallet !== 'connected') return; 93 | const discord: any = await checkDiscordStatus(storeData.address); 94 | if (discord) setDiscord(discord); 95 | const twitter: any = await checkTwitterStatus(storeData.address); 96 | if (twitter) setTwitter(twitter); 97 | })(); 98 | }, [storeData, token, social]) 99 | 100 | useEffect(() => { 101 | ( 102 | async () => { 103 | try { 104 | if (storeData.wallet === 'connected') { 105 | setLoading(true) 106 | const getAllAuction: any = await getAllAuctions(); 107 | const filterRaffles = getAllAuction.filter((item: any) => item.walletAddress === storeData.address) 108 | setParticipantLists(filterRaffles) 109 | setLoading(false) 110 | } 111 | } catch (error) { 112 | console.log('error', error) 113 | setLoading(false) 114 | 115 | } 116 | } 117 | )() 118 | }, [storeData]) 119 | 120 | return ( 121 | <> 122 | { 123 | isLoading ? 124 |
: 125 |
126 | } 127 | 128 |
129 |
130 |
131 | 139 | 147 |
148 |
149 |
150 |
151 |

Participations

152 |
153 |
154 |
155 | 156 |
157 |
158 |
159 |
160 |
161 | 166 | Raffles 167 | 168 | 172 | Auctions 173 | 174 |
175 |
176 |
177 | 178 |
179 |
180 | 181 |
182 |
183 |
184 |
185 | 186 | { 187 | participantLists.length > 0 ? 188 | participantLists.map((item: any, idx: any) => 189 | 190 | ) 191 | : 192 | isLoading ? <> 193 | : 194 |
195 |
196 | infoIconBlack 197 |

198 | You haven’t participated in any Raffles! 199 |

200 |
201 |
202 | } 203 | 204 | ) 205 | } 206 | 207 | export default AuctionProfile -------------------------------------------------------------------------------- /src/services/contracts/auction1155.ts: -------------------------------------------------------------------------------- 1 | import { Contract, ethers } from "ethers" 2 | import BigNumber from "bignumber.js"; 3 | 4 | import CONFIG from "../../config"; 5 | 6 | 7 | export const CreateAuction1155Contract = async ( 8 | tokenContract: string, 9 | tokenId: number, 10 | tokenAmount: number, 11 | ticketPrice: number, 12 | startDate: any, 13 | endDate: any, 14 | ) => { 15 | try { 16 | const Provider: any = new ethers.providers.Web3Provider(window.ethereum); 17 | const signer = Provider.getSigner(); 18 | const TokenContract = new Contract(tokenContract, CONFIG.TOKENERC1155, signer) 19 | const approveTx = await TokenContract.setApprovalForAll(CONFIG.AUCTION.CONTRACTADDRESS1155, tokenId) 20 | await approveTx.wait() 21 | 22 | const auctionContract = new Contract(CONFIG.AUCTION.CONTRACTADDRESS1155, CONFIG.AUCTION.ABI1155, signer); 23 | const price = new BigNumber(ticketPrice).times(new BigNumber(10).pow(new BigNumber(18))) 24 | const tx = await auctionContract.createAuction( 25 | tokenContract, 26 | tokenId, 27 | tokenAmount, 28 | price.toString(), 29 | startDate, 30 | endDate 31 | ) 32 | await tx.wait() 33 | if (tx) { 34 | return true 35 | } 36 | } catch (error) { 37 | console.log('error', error) 38 | return false 39 | } 40 | } 41 | 42 | export const UpdateAuction1155Contract = async ( 43 | itemId: string, 44 | ticketPrice: number, 45 | startDate: any, 46 | endDate: any, 47 | ) => { 48 | try { 49 | const Provider: any = new ethers.providers.Web3Provider(window.ethereum); 50 | const signer = Provider.getSigner(); 51 | const auctionContract = new Contract(CONFIG.AUCTION.CONTRACTADDRESS1155, CONFIG.AUCTION.ABI1155, signer); 52 | const price = new BigNumber(ticketPrice).times(new BigNumber(10).pow(new BigNumber(18))) 53 | const tx = await auctionContract.updateAuction( 54 | itemId, 55 | price.toString(), 56 | startDate, 57 | endDate 58 | ) 59 | await tx.wait() 60 | if (tx) { 61 | return true 62 | } 63 | } catch (error) { 64 | console.log('error', error) 65 | return false 66 | } 67 | } 68 | 69 | export const CancelAuction1155Contract = async ( 70 | itemId: string 71 | ) => { 72 | try { 73 | const Provider: any = new ethers.providers.Web3Provider(window.ethereum); 74 | const signer = Provider.getSigner(); 75 | const auctionContract = new Contract(CONFIG.AUCTION.CONTRACTADDRESS1155, CONFIG.AUCTION.ABI1155, signer); 76 | const tx = await auctionContract.cancelAuction(itemId) 77 | await tx.wait() 78 | if (tx) { 79 | return true 80 | } 81 | } catch (error) { 82 | console.log('error', error) 83 | return false 84 | } 85 | } 86 | 87 | 88 | export const fetchAuction1155Items = async (tokenId: any, tokenAddress: any, startDate: any) => { 89 | try { 90 | const Provider: any = new ethers.providers.Web3Provider(window.ethereum); 91 | const signer = Provider.getSigner(); 92 | 93 | const auctionContract = new Contract(CONFIG.AUCTION.CONTRACTADDRESS1155, CONFIG.AUCTION.ABI1155, signer); 94 | 95 | const fetch_lists = await auctionContract.fetchAuctionItems() 96 | const itemId = fetch_lists.findIndex((item: any) => item.tokenId.toNumber() === tokenId && item.nftContract.toLowerCase() === tokenAddress.toLowerCase() && item.startDate.toNumber() === Number(startDate)) 97 | const get_winner = fetch_lists.find((item: any) => item.tokenId.toNumber() === tokenId && item.nftContract.toLowerCase() === tokenAddress.toLowerCase() && item.startDate.toNumber() === Number(startDate)) 98 | return { itemId, winner: get_winner?.winner.toLowerCase() } 99 | } catch (error) { 100 | console.log('error', error) 101 | } 102 | } 103 | 104 | export const createBidAuction1155 = async (itemId: any, price: any) => { 105 | try { 106 | const Provider: any = new ethers.providers.Web3Provider(window.ethereum); 107 | const signer = Provider.getSigner(); 108 | 109 | const auctionContract = new Contract(CONFIG.AUCTION.CONTRACTADDRESS1155, CONFIG.AUCTION.ABI1155, signer); 110 | 111 | const send_value = new BigNumber(price).times(new BigNumber(10).pow(new BigNumber(18))) 112 | const res = await auctionContract.createBid(itemId, { 113 | value: send_value.toString() 114 | }); 115 | await res.wait() 116 | 117 | return res 118 | 119 | } catch (error) { 120 | console.log(`error`, error) 121 | } 122 | } 123 | 124 | export const updateBidAuction1155 = async (itemId: any, price: any) => { 125 | try { 126 | const Provider: any = new ethers.providers.Web3Provider(window.ethereum); 127 | const signer = Provider.getSigner(); 128 | 129 | const auctionContract = new Contract(CONFIG.AUCTION.CONTRACTADDRESS1155, CONFIG.AUCTION.ABI1155, signer); 130 | 131 | const send_value = new BigNumber(price).times(new BigNumber(10).pow(new BigNumber(18))) 132 | const res = await auctionContract.updateBid(itemId, { 133 | value: send_value.toString() 134 | }); 135 | await res.wait() 136 | 137 | return res 138 | 139 | } catch (error) { 140 | console.log(`error`, error) 141 | } 142 | } 143 | 144 | export const cancelBidAuction1155 = async (itemId: any) => { 145 | try { 146 | const Provider: any = new ethers.providers.Web3Provider(window.ethereum); 147 | const signer = Provider.getSigner(); 148 | 149 | const auctionContract = new Contract(CONFIG.AUCTION.CONTRACTADDRESS1155, CONFIG.AUCTION.ABI1155, signer); 150 | 151 | const res = await auctionContract.cancelBid(itemId); 152 | await res.wait() 153 | 154 | return res 155 | 156 | } catch (error) { 157 | console.log(`error`, error) 158 | } 159 | } 160 | 161 | export const claimBidAuction1155 = async (itemId: any) => { 162 | try { 163 | const Provider: any = new ethers.providers.Web3Provider(window.ethereum); 164 | const signer = Provider.getSigner(); 165 | 166 | const auctionContract = new Contract(CONFIG.AUCTION.CONTRACTADDRESS1155, CONFIG.AUCTION.ABI1155, signer); 167 | 168 | const tx = await auctionContract.claimAuction(itemId); 169 | await tx.wait() 170 | return tx 171 | 172 | } catch (error) { 173 | console.log('error', error) 174 | } 175 | } 176 | 177 | 178 | export const fetchMyBidItems1155 = async () => { 179 | try { 180 | const Provider: any = new ethers.providers.Web3Provider(window.ethereum); 181 | const signer = Provider.getSigner(); 182 | 183 | const auctionContract = new Contract(CONFIG.AUCTION.CONTRACTADDRESS1155, CONFIG.AUCTION.ABI1155, signer); 184 | 185 | const res = await auctionContract.fetchMyBidItems() 186 | return res 187 | 188 | } catch (error) { 189 | console.log(`error`, error) 190 | } 191 | } 192 | 193 | export const fetchBidItemsById1155 = async (itemId: any) => { 194 | try { 195 | const Provider: any = new ethers.providers.Web3Provider(window.ethereum); 196 | const signer = Provider.getSigner(); 197 | 198 | const auctionContract = new Contract(CONFIG.AUCTION.CONTRACTADDRESS1155, CONFIG.AUCTION.ABI1155, signer); 199 | 200 | const res = await auctionContract.fetchBidItemsByID(itemId); 201 | 202 | return res 203 | 204 | } catch (error) { 205 | console.log('error', error) 206 | } 207 | } 208 | 209 | export const getSoldNftStatus1155 = async (tokenId: any, tokenAddress: any, startDate: any) => { 210 | try { 211 | const Provider: any = new ethers.providers.Web3Provider(window.ethereum); 212 | const signer = Provider.getSigner(); 213 | 214 | const auctionContract = new Contract(CONFIG.AUCTION.CONTRACTADDRESS1155, CONFIG.AUCTION.ABI1155, signer); 215 | 216 | const fetch_lists = await auctionContract.fetchAuctionItems() 217 | const res = fetch_lists.find((item: any) => item.tokenId.toNumber() === tokenId && item.nftContract.toLowerCase() === tokenAddress.toLowerCase() && item.startDate.toNumber() === Number(startDate)) 218 | return res.sold 219 | } catch (error) { 220 | console.log('error', error) 221 | } 222 | } 223 | -------------------------------------------------------------------------------- /src/components/NFTModal/index.tsx: -------------------------------------------------------------------------------- 1 | import { useState, useEffect } from "react"; 2 | import { useSelector } from "react-redux"; 3 | import { toast } from "react-toastify"; 4 | 5 | import VerificationIcon from "../../assets/Verification-icon.png"; 6 | import { getNfts } from "../../services/api"; 7 | import "./index.css"; 8 | 9 | const NFTModal = (props: any) => { 10 | const { show, title, setNftName, setContractType, raffleValue, setRaffleValue, auctionValue, setAuctionValue } = props; 11 | const storeData: any = useSelector(status => status) 12 | const [isModalLoading, setModalLoading] = useState(false); 13 | const [nfts, setNfts] = useState([]); 14 | const [selectedNft, setSelectedNft] = useState(null); 15 | const [isActive, setActive] = useState(-1) 16 | 17 | useEffect(() => { 18 | (async () => { 19 | if (show === true) { 20 | if (storeData.wallet === 'disconnect') { 21 | toast(`Please connect your wallet`) 22 | return 23 | } 24 | try { 25 | setNfts([]); 26 | setModalLoading(true); 27 | 28 | const lists: any = await getNfts(storeData.address) 29 | let filtered_nfts: any = [] 30 | await lists.result.forEach((nft: any) => { 31 | const ipfs = JSON.parse(nft?.metadata)?.image 32 | let get_image = '' 33 | if (ipfs?.includes('ipfs://')) { 34 | get_image = 'https://ipfs.io/ipfs/' + ipfs.replace('ipfs://', '') 35 | } else { 36 | get_image = ipfs 37 | } 38 | filtered_nfts.push({ 39 | metadata: JSON.parse(nft?.metadata), 40 | name: nft?.name, 41 | token_address: nft?.token_address, 42 | token_id: nft?.token_id, 43 | owner: nft?.owner_of, 44 | symbol: nft?.symbol, 45 | image: get_image, 46 | type: nft?.contract_type, 47 | nftAmount: nft?.amount 48 | }) 49 | }) 50 | setNfts(filtered_nfts) 51 | 52 | setModalLoading(false); 53 | 54 | } catch (error) { 55 | console.log("error", error); 56 | setModalLoading(false); 57 | } 58 | } 59 | 60 | })(); 61 | }, [show, storeData]); 62 | 63 | const onOkBtn = () => { 64 | if(selectedNft == null) props.onCancel(); 65 | else { 66 | if (raffleValue) { 67 | setRaffleValue({ 68 | ...raffleValue, 69 | tokenAddress: selectedNft.token_address, 70 | tokenId: selectedNft.token_id, 71 | image: selectedNft?.image, 72 | amount: selectedNft?.nftAmount 73 | }) 74 | } 75 | 76 | if (auctionValue) { 77 | setAuctionValue({ 78 | ...auctionValue, 79 | tokenAddress: selectedNft.token_address, 80 | tokenId: selectedNft.token_id ? selectedNft.token_id : ``, 81 | image: selectedNft?.image ? selectedNft?.image : ``, 82 | amount: selectedNft?.nftAmount 83 | }) 84 | } 85 | const selectedNftName = selectedNft?.name ? selectedNft?.name : selectedNft?.metadata?.name.split(`#`)[0] 86 | 87 | setNftName(`${selectedNftName} #${selectedNft.token_id} `) 88 | setContractType(selectedNft?.type) 89 | props.onCancel() 90 | } 91 | 92 | } 93 | 94 | const handleSelect = (index: number) => { 95 | try { 96 | if (isModalLoading) return; 97 | if (index >= 0) { 98 | setActive(index) 99 | } 100 | setSelectedNft({ 101 | ...nfts[index], 102 | index, 103 | }); 104 | } catch (error) { 105 | console.log("error", error); 106 | } 107 | }; 108 | 109 | return ( 110 | <> 111 | { 112 | isModalLoading ? 113 |
: 114 |
115 | } 116 | {show ? ( 117 |
118 |
119 |
120 |

{title}

121 | 127 |
128 |
129 | { 130 | nfts.length > 0 ? 131 | nfts.map((nft, index: any) => { 132 | return ( 133 |
handleSelect(index)} > 134 |
135 |
136 | CoodeImage 142 |
143 |
144 |
145 | VerificationIcon 150 | 151 | {nft?.metadata?.name.split('#')[0]} 152 | 153 |
154 |
155 |

156 | Token ID 157 |

158 |

159 | #{nft?.token_id} 160 |

161 |
162 |
163 |
164 |
165 | ) 166 | }) 167 | : isModalLoading ? <> 168 | : 169 |

No exist NFT in your wallet.

170 | } 171 |
172 |
173 | 180 | 186 |
187 |
188 |
189 | ) : ( 190 |
191 | )} 192 | 193 | ); 194 | }; 195 | 196 | export default NFTModal; 197 | -------------------------------------------------------------------------------- /src/constants/Token/Erc721Token.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "inputs": [ 4 | { 5 | "internalType": "string", 6 | "name": "name_", 7 | "type": "string" 8 | }, 9 | { 10 | "internalType": "string", 11 | "name": "symbol_", 12 | "type": "string" 13 | } 14 | ], 15 | "stateMutability": "nonpayable", 16 | "type": "constructor" 17 | }, 18 | { 19 | "anonymous": false, 20 | "inputs": [ 21 | { 22 | "indexed": true, 23 | "internalType": "address", 24 | "name": "owner", 25 | "type": "address" 26 | }, 27 | { 28 | "indexed": true, 29 | "internalType": "address", 30 | "name": "approved", 31 | "type": "address" 32 | }, 33 | { 34 | "indexed": true, 35 | "internalType": "uint256", 36 | "name": "tokenId", 37 | "type": "uint256" 38 | } 39 | ], 40 | "name": "Approval", 41 | "type": "event" 42 | }, 43 | { 44 | "anonymous": false, 45 | "inputs": [ 46 | { 47 | "indexed": true, 48 | "internalType": "address", 49 | "name": "owner", 50 | "type": "address" 51 | }, 52 | { 53 | "indexed": true, 54 | "internalType": "address", 55 | "name": "operator", 56 | "type": "address" 57 | }, 58 | { 59 | "indexed": false, 60 | "internalType": "bool", 61 | "name": "approved", 62 | "type": "bool" 63 | } 64 | ], 65 | "name": "ApprovalForAll", 66 | "type": "event" 67 | }, 68 | { 69 | "anonymous": false, 70 | "inputs": [ 71 | { 72 | "indexed": true, 73 | "internalType": "address", 74 | "name": "from", 75 | "type": "address" 76 | }, 77 | { 78 | "indexed": true, 79 | "internalType": "address", 80 | "name": "to", 81 | "type": "address" 82 | }, 83 | { 84 | "indexed": true, 85 | "internalType": "uint256", 86 | "name": "tokenId", 87 | "type": "uint256" 88 | } 89 | ], 90 | "name": "Transfer", 91 | "type": "event" 92 | }, 93 | { 94 | "inputs": [ 95 | { 96 | "internalType": "address", 97 | "name": "to", 98 | "type": "address" 99 | }, 100 | { 101 | "internalType": "uint256", 102 | "name": "tokenId", 103 | "type": "uint256" 104 | } 105 | ], 106 | "name": "approve", 107 | "outputs": [], 108 | "stateMutability": "nonpayable", 109 | "type": "function" 110 | }, 111 | { 112 | "inputs": [ 113 | { 114 | "internalType": "address", 115 | "name": "owner", 116 | "type": "address" 117 | } 118 | ], 119 | "name": "balanceOf", 120 | "outputs": [ 121 | { 122 | "internalType": "uint256", 123 | "name": "", 124 | "type": "uint256" 125 | } 126 | ], 127 | "stateMutability": "view", 128 | "type": "function" 129 | }, 130 | { 131 | "inputs": [ 132 | { 133 | "internalType": "uint256", 134 | "name": "tokenId", 135 | "type": "uint256" 136 | } 137 | ], 138 | "name": "getApproved", 139 | "outputs": [ 140 | { 141 | "internalType": "address", 142 | "name": "", 143 | "type": "address" 144 | } 145 | ], 146 | "stateMutability": "view", 147 | "type": "function" 148 | }, 149 | { 150 | "inputs": [ 151 | { 152 | "internalType": "address", 153 | "name": "owner", 154 | "type": "address" 155 | }, 156 | { 157 | "internalType": "address", 158 | "name": "operator", 159 | "type": "address" 160 | } 161 | ], 162 | "name": "isApprovedForAll", 163 | "outputs": [ 164 | { 165 | "internalType": "bool", 166 | "name": "", 167 | "type": "bool" 168 | } 169 | ], 170 | "stateMutability": "view", 171 | "type": "function" 172 | }, 173 | { 174 | "inputs": [], 175 | "name": "name", 176 | "outputs": [ 177 | { 178 | "internalType": "string", 179 | "name": "", 180 | "type": "string" 181 | } 182 | ], 183 | "stateMutability": "view", 184 | "type": "function" 185 | }, 186 | { 187 | "inputs": [ 188 | { 189 | "internalType": "uint256", 190 | "name": "tokenId", 191 | "type": "uint256" 192 | } 193 | ], 194 | "name": "ownerOf", 195 | "outputs": [ 196 | { 197 | "internalType": "address", 198 | "name": "", 199 | "type": "address" 200 | } 201 | ], 202 | "stateMutability": "view", 203 | "type": "function" 204 | }, 205 | { 206 | "inputs": [ 207 | { 208 | "internalType": "address", 209 | "name": "from", 210 | "type": "address" 211 | }, 212 | { 213 | "internalType": "address", 214 | "name": "to", 215 | "type": "address" 216 | }, 217 | { 218 | "internalType": "uint256", 219 | "name": "tokenId", 220 | "type": "uint256" 221 | } 222 | ], 223 | "name": "safeTransferFrom", 224 | "outputs": [], 225 | "stateMutability": "nonpayable", 226 | "type": "function" 227 | }, 228 | { 229 | "inputs": [ 230 | { 231 | "internalType": "address", 232 | "name": "from", 233 | "type": "address" 234 | }, 235 | { 236 | "internalType": "address", 237 | "name": "to", 238 | "type": "address" 239 | }, 240 | { 241 | "internalType": "uint256", 242 | "name": "tokenId", 243 | "type": "uint256" 244 | }, 245 | { 246 | "internalType": "bytes", 247 | "name": "data", 248 | "type": "bytes" 249 | } 250 | ], 251 | "name": "safeTransferFrom", 252 | "outputs": [], 253 | "stateMutability": "nonpayable", 254 | "type": "function" 255 | }, 256 | { 257 | "inputs": [ 258 | { 259 | "internalType": "address", 260 | "name": "operator", 261 | "type": "address" 262 | }, 263 | { 264 | "internalType": "bool", 265 | "name": "approved", 266 | "type": "bool" 267 | } 268 | ], 269 | "name": "setApprovalForAll", 270 | "outputs": [], 271 | "stateMutability": "nonpayable", 272 | "type": "function" 273 | }, 274 | { 275 | "inputs": [ 276 | { 277 | "internalType": "bytes4", 278 | "name": "interfaceId", 279 | "type": "bytes4" 280 | } 281 | ], 282 | "name": "supportsInterface", 283 | "outputs": [ 284 | { 285 | "internalType": "bool", 286 | "name": "", 287 | "type": "bool" 288 | } 289 | ], 290 | "stateMutability": "view", 291 | "type": "function" 292 | }, 293 | { 294 | "inputs": [], 295 | "name": "symbol", 296 | "outputs": [ 297 | { 298 | "internalType": "string", 299 | "name": "", 300 | "type": "string" 301 | } 302 | ], 303 | "stateMutability": "view", 304 | "type": "function" 305 | }, 306 | { 307 | "inputs": [ 308 | { 309 | "internalType": "uint256", 310 | "name": "tokenId", 311 | "type": "uint256" 312 | } 313 | ], 314 | "name": "tokenURI", 315 | "outputs": [ 316 | { 317 | "internalType": "string", 318 | "name": "", 319 | "type": "string" 320 | } 321 | ], 322 | "stateMutability": "view", 323 | "type": "function" 324 | }, 325 | { 326 | "inputs": [ 327 | { 328 | "internalType": "address", 329 | "name": "from", 330 | "type": "address" 331 | }, 332 | { 333 | "internalType": "address", 334 | "name": "to", 335 | "type": "address" 336 | }, 337 | { 338 | "internalType": "uint256", 339 | "name": "tokenId", 340 | "type": "uint256" 341 | } 342 | ], 343 | "name": "transferFrom", 344 | "outputs": [], 345 | "stateMutability": "nonpayable", 346 | "type": "function" 347 | } 348 | ] -------------------------------------------------------------------------------- /src/components/AuctionItem.tsx: -------------------------------------------------------------------------------- 1 | import { useState, useEffect } from "react"; 2 | import { useSelector } from "react-redux"; 3 | import { Link } from "react-router-dom"; 4 | import Countdown, { CountdownApi } from 'react-countdown' 5 | 6 | import VerificationIcon from "../assets/Verification-icon.png"; 7 | import { fetchAuctionItems, fetchMyBidItems } from "../services/contracts/auction"; 8 | import { DECIMAL } from "../config/dev"; 9 | import { fetchAuction1155Items, fetchMyBidItems1155 } from "../services/contracts/auction1155"; 10 | 11 | const AuctionItem = (props: any) => { 12 | const { item } = props; 13 | const storeData: any = useSelector((status) => status) 14 | const [currentBid, setCurrentBid] = useState(0) 15 | const [showEdit, setShowEdit] = useState(false) 16 | 17 | let startCountdownApi: CountdownApi | null = null 18 | let endCountdownApi: CountdownApi | null = null 19 | 20 | const setStartCountdownRef = (countdown: Countdown | null) => { 21 | if (countdown) { 22 | startCountdownApi = countdown.getApi() 23 | } 24 | } 25 | 26 | const setEndCountdownRef = (countdown: Countdown | null) => { 27 | if (countdown) { 28 | endCountdownApi = countdown.getApi() 29 | } 30 | } 31 | 32 | const startCountdownRenderer = ({ api, days, hours, minutes, seconds, completed }: any) => { 33 | if (api.isPaused()) api.start() 34 | return ( 35 | completed ? 36 | 43 | : 44 |
45 |

Starts In

46 |

47 | {days.toString().length === 1 ? `0${days}` : days}: 48 | {hours.toString().length === 1 ? `0${hours}` : hours}: 49 | {minutes.toString().length === 1 ? `0${minutes}` : minutes}: 50 | {seconds.toString().length === 1 ? `0${seconds}` : seconds} 51 |

52 |
53 | ) 54 | } 55 | 56 | const endCountdownRenderer = ({ api, days, hours, minutes, seconds, completed }: any) => { 57 | if (api.isPaused()) api.start() 58 | return ( 59 | completed ? 60 |

Ended

61 | : 62 |
63 |

Live

64 |

65 | {days.toString().length === 1 ? `0${days}` : days}: 66 | {hours.toString().length === 1 ? `0${hours}` : hours}: 67 | {minutes.toString().length === 1 ? `0${minutes}` : minutes}: 68 | {seconds.toString().length === 1 ? `0${seconds}` : seconds} 69 |

70 |
71 | ) 72 | } 73 | 74 | useEffect(() => { 75 | ( 76 | async () => { 77 | try { 78 | if (item.type === `ERC1155`) { 79 | const getAuctionInfo = await fetchAuction1155Items(item.tokenId, item.tokenAddress, item.start_date); 80 | const get_nftInfo = await fetchMyBidItems1155() 81 | 82 | const find_bidding = get_nftInfo.find((item: any) => getAuctionInfo?.itemId + 1 === item.auctionId.toNumber()) 83 | 84 | if (find_bidding) { 85 | setCurrentBid(find_bidding.bidPrice.toNumber() / DECIMAL) 86 | } 87 | } else { 88 | const getAuctionInfo = await fetchAuctionItems(item.tokenId, item.tokenAddress, item.start_date); 89 | const get_nftInfo = await fetchMyBidItems() 90 | 91 | const find_bidding = get_nftInfo.find((item: any) => getAuctionInfo?.itemId + 1 === item.auctionId.toNumber()) 92 | 93 | if (find_bidding) { 94 | setCurrentBid(find_bidding.bidPrice.toNumber() / DECIMAL) 95 | } 96 | } 97 | 98 | if (item.start_date * 1000 > Date.now() && item.walletAddress === storeData.address) { 99 | setShowEdit(true) 100 | } 101 | 102 | 103 | } catch (error) { 104 | console.log('error', error) 105 | } 106 | } 107 | )() 108 | }, []) 109 | 110 | return ( 111 |
115 |
116 |
117 | CoodeImage 122 |
123 |
124 |
125 |
126 |

127 | {item.name.split('#')[0]} 128 |

129 |

#{item.tokenId}

130 |
131 |
132 | 133 |
134 |
135 |
136 |
137 |
138 |
139 | VerificationIcon 140 | 141 | {item.name.split('#')[0]} #{item.tokenId} 142 | 143 |
144 |

@{item.project}

145 |
146 |
147 |
148 |
149 |

Time Remaining

150 |

151 | setShowEdit(false)} 156 | 157 | renderer={startCountdownRenderer} 158 | /> 159 |

160 |
161 |
162 |

Min. Increment

163 |

{item.price}

164 |
165 | 166 |
167 |

Type

168 |

{item.type}

169 |
170 |
171 | { 172 | storeData.wallet === 'connected' && 173 |
174 |
175 |

Current Bid

176 |

{currentBid ? currentBid : 0}

177 |
178 |
179 | } 180 |
181 |
182 |
183 | 184 |
185 |
186 | { 187 | item.type === `ERC1155` ? 188 | 192 | View 193 | 194 | : 195 | 199 | View 200 | 201 | 202 | } 203 |
204 | { 205 | showEdit && 206 |
207 | 211 | Edit 212 | 213 |
214 | } 215 | 216 |
217 |
218 | ); 219 | }; 220 | 221 | export default AuctionItem; 222 | -------------------------------------------------------------------------------- /src/pages/Auction/AuctionParticipant.tsx: -------------------------------------------------------------------------------- 1 | import { useState, useEffect } from 'react' 2 | import { Link } from "react-router-dom"; 3 | import Countdown, { CountdownApi } from 'react-countdown' 4 | 5 | import VerificationIcon from "../../assets/Verification-icon-2.png"; 6 | import VeiwIcon from "../../assets/Veiw-Icon.png"; 7 | import TimingIcon from "../../assets/Subtract-timing-icon.png"; 8 | import TicketIcon from "../../assets/Subtract-ticket-icon.png"; 9 | import BoughtIcon from "../../assets/Subtract-bought-icon.png"; 10 | import WinningIcon from "../../assets/Subtract-winning-icon.png"; 11 | 12 | import { fetchRaffleItems, fetchTicketItemsByID } from '../../services/contracts/raffle'; 13 | import { fetchAuctionItems, fetchMyBidItems } from '../../services/contracts/auction'; 14 | import CONFIG from '../../config'; 15 | import { fetchAuction1155Items, fetchBidItemsById1155, fetchMyBidItems1155 } from '../../services/contracts/auction1155'; 16 | 17 | 18 | const AuctionRarticipant = (props: any) => { 19 | const { item, idx } = props 20 | const [sellAmount, setSellAmount] = useState(0) 21 | 22 | let startCountdownApi: CountdownApi | null = null 23 | let endCountdownApi: CountdownApi | null = null 24 | 25 | const setStartCountdownRef = (countdown: Countdown | null) => { 26 | if (countdown) { 27 | startCountdownApi = countdown.getApi() 28 | } 29 | } 30 | 31 | const setEndCountdownRef = (countdown: Countdown | null) => { 32 | if (countdown) { 33 | endCountdownApi = countdown.getApi() 34 | } 35 | } 36 | 37 | const startCountdownRenderer = ({ api, days, hours, minutes, seconds, completed }: any) => { 38 | if (api.isPaused()) api.start() 39 | return ( 40 | completed ? 41 | 48 | : 49 |
50 |

Starts In

51 |

52 | {days.toString().length === 1 ? `0${days}` : days}: 53 | {hours.toString().length === 1 ? `0${hours}` : hours}: 54 | {minutes.toString().length === 1 ? `0${minutes}` : minutes}: 55 | {seconds.toString().length === 1 ? `0${seconds}` : seconds} 56 |

57 |
58 | ) 59 | } 60 | 61 | const endCountdownRenderer = ({ api, days, hours, minutes, seconds, completed }: any) => { 62 | if (api.isPaused()) api.start() 63 | return ( 64 | completed ? 65 |

Ended

66 | : 67 |
68 |

Live

69 |

70 | {days.toString().length === 1 ? `0${days}` : days}: 71 | {hours.toString().length === 1 ? `0${hours}` : hours}: 72 | {minutes.toString().length === 1 ? `0${minutes}` : minutes}: 73 | {seconds.toString().length === 1 ? `0${seconds}` : seconds} 74 |

75 |
76 | 77 | ) 78 | } 79 | 80 | useEffect(() => { 81 | ( 82 | async () => { 83 | try { 84 | if (item.type === `ERC1155`) { 85 | 86 | const getAuctionInfo = await fetchAuction1155Items(item.tokenId, item.tokenAddress, item.start_date); 87 | const get_nftInfo = await fetchMyBidItems1155() 88 | 89 | const find_bidding = get_nftInfo.find((item: any) => getAuctionInfo?.itemId === item.auctionId.toNumber() - 1) 90 | if (find_bidding) { 91 | setSellAmount(find_bidding.bidPrice.toNumber() / CONFIG.DECIMAL) 92 | } 93 | 94 | } else { 95 | const getAuctionInfo = await fetchAuctionItems(item.tokenId, item.tokenAddress, item.start_date); 96 | const get_nftInfo = await fetchMyBidItems() 97 | 98 | const find_bidding = get_nftInfo.find((item: any) => getAuctionInfo?.itemId === item.auctionId.toNumber() - 1) 99 | if (find_bidding) { 100 | setSellAmount(find_bidding.bidPrice.toNumber() / CONFIG.DECIMAL) 101 | } 102 | 103 | } 104 | 105 | } catch (error) { 106 | console.log('error', error) 107 | } 108 | } 109 | )() 110 | }, []) 111 | 112 | return ( 113 |
114 |
115 |
116 |
117 |
118 |
119 | Coode 124 |
125 |
126 |
127 |
128 |
129 | VerificationIcon 133 | 134 | {item?.project} 135 | 136 |
137 |

138 | {item?.name} 139 |

140 |
141 |
142 | { 143 | item.type === `ERC1155` ? 144 | 149 | VeiwIcon 150 | View Auction 151 | 152 | : 153 | 158 | VeiwIcon 159 | View Auction 160 | 161 | } 162 |
163 |
164 |
165 |
166 |
167 |
168 | TimingIcon 173 |

Time Remaining

174 |

175 | 181 |

182 |
183 |
184 | TimingIcon 189 |

Min. Bid Incrementant

190 |

{item?.price}

191 |
192 |
193 | TimingIcon 198 |

Tickets Bought

199 |

{sellAmount}

200 |
201 |
202 | TimingIcon 207 |

Winning Chance

208 |

10%

209 |
210 |
211 |
212 |
213 |
214 |
215 | ); 216 | }; 217 | 218 | export default AuctionRarticipant; 219 | --------------------------------------------------------------------------------