From 385970136334dc22338b8f763703a03c55c3d9f1 Mon Sep 17 00:00:00 2001 From: Qedric Date: Sun, 26 May 2024 00:09:30 +0200 Subject: [PATCH] removed marketplace folder --- .../lib}/PoEMarketplace_abi.json | 0 {marketplace => contracts/src}/scripts/api.ts | 0 .../src}/scripts/getContractState.ts | 0 marketplace/contracts/PoEMarketplace.sol | 136 --------------- marketplace/package-lock.json | 165 ------------------ marketplace/package.json | 15 -- 6 files changed, 316 deletions(-) rename {marketplace/data => contracts/lib}/PoEMarketplace_abi.json (100%) rename {marketplace => contracts/src}/scripts/api.ts (100%) rename {marketplace => contracts/src}/scripts/getContractState.ts (100%) delete mode 100644 marketplace/contracts/PoEMarketplace.sol delete mode 100644 marketplace/package-lock.json delete mode 100644 marketplace/package.json diff --git a/marketplace/data/PoEMarketplace_abi.json b/contracts/lib/PoEMarketplace_abi.json similarity index 100% rename from marketplace/data/PoEMarketplace_abi.json rename to contracts/lib/PoEMarketplace_abi.json diff --git a/marketplace/scripts/api.ts b/contracts/src/scripts/api.ts similarity index 100% rename from marketplace/scripts/api.ts rename to contracts/src/scripts/api.ts diff --git a/marketplace/scripts/getContractState.ts b/contracts/src/scripts/getContractState.ts similarity index 100% rename from marketplace/scripts/getContractState.ts rename to contracts/src/scripts/getContractState.ts diff --git a/marketplace/contracts/PoEMarketplace.sol b/marketplace/contracts/PoEMarketplace.sol deleted file mode 100644 index 8c069cb..0000000 --- a/marketplace/contracts/PoEMarketplace.sol +++ /dev/null @@ -1,136 +0,0 @@ -// SPDX-License-Identifier: MIT -pragma solidity ^0.8.20; - -import "@openzeppelin/contracts/token/ERC721/ERC721.sol"; - -/** - * @title ProofOfExploitMarketplace - * @dev A marketplace for white-hat hackers to sell proofs of exploits to - * smart contract stakeholders. - */ -contract ProofOfExploitMarketplace is ERC721 { - - struct Exploit { - address creator; - string description; - uint256 keyHash; - uint256 price; - bool redeemed; - Buyer buyer; - } - - struct Buyer { - uint256[2] publicKey; - bool hasPurchased; - } - - /// map of all exploits (which are also tokens) - mapping(uint256 => Exploit) public exploits; - - /// map of buyer information - mapping(address => Buyer) public buyers; - - /// keep track of our exploits (which are also tokens) - uint256 public exploitCount; - - event ExploitPosted(uint256 indexed id, address indexed creator, uint256 price); - event TokenPurchased(uint256 indexed id, address indexed buyer); - event ExploitRedeemed(uint256 indexed id, address indexed buyer); - - constructor() - ERC721("ProofOfExploitToken", "PET") - {} - - /** - * @notice Posts a new exploit to the marketplace. - * @param description A description of the exploit. - * @param price The price for the exploit. - * @param keyHash The hash of the key of the encryption of the proof of the exploit. - * @return The ID of the newly created exploit (token). - */ - function postExploit( - string calldata description, - uint256 price, - uint256 keyHash - ) external returns (uint256) { - uint256 id = exploitCount; - exploitCount++; - - exploits[id] = Exploit({ - creator: msg.sender, - description: description, - price: price, - redeemed: false, - keyHash: keyHash, - buyer: Buyer([uint256(0), uint256(0)], false) - }); - - _mint(msg.sender, id); - - emit ExploitPosted(id, msg.sender, price); - return id; - } - - /** - * @notice Purchases a token for a specific exploit. - * @param exploitId The ID of the exploit to purchase. - * @param publicKey The public key of the buyer. - */ - function purchaseToken(uint256 exploitId, uint256[2] calldata publicKey) external payable { - Exploit storage exploit = exploits[exploitId]; - require(msg.value >= exploit.price, "Insufficient funds"); - - buyers[msg.sender] = Buyer({ - publicKey: publicKey, - hasPurchased: true - }); - - _transfer(exploit.creator, msg.sender, exploitId); - - exploit.buyer = buyers[msg.sender]; - - emit TokenPurchased(exploitId, msg.sender); - } - - /** - * @notice Redeems an exploit by providing the encrypted key. - * @param tokenId The ID of the token (exploit). - * @param encryptedKey The encrypted key. - */ - function redeemExploit(uint256 tokenId, uint256 encryptedKey) external { - // make sure the exploit exists: - require(tokenId >= 0 && tokenId < exploitCount, "Exploit does not exist"); - Exploit storage exploit = exploits[tokenId]; - require(exploit.creator == msg.sender, "Only the creator can redeem"); - require(!exploit.redeemed, "Exploit already redeemed"); - - //require( - // Verifier.verifyEncryptionProof(a, b, c, input), - // 'DataMarketplaceCore/proof-invalid' - //); - - exploit.redeemed = true; - exploit.keyHash = encryptedKey; - - address buyer = ownerOf(tokenId); - require(buyers[buyer].hasPurchased, "No buyer for this token"); - - payable(exploit.creator).transfer(exploit.price); - - emit ExploitRedeemed(tokenId, buyer); - } - - /** - * @notice Allows a token holder to retrieve the encrypted key for the exploit. - * @param tokenId The ID of the token (exploit). - * @return The encrypted key. - */ - function getExploitKey(uint256 tokenId) external view returns (uint256) { - require(ownerOf(tokenId) == msg.sender, "Only the owner can get the key"); - - Exploit storage exploit = exploits[tokenId]; - require(exploit.redeemed, "Exploit not redeemed yet"); - - return exploit.keyHash; - } -} diff --git a/marketplace/package-lock.json b/marketplace/package-lock.json deleted file mode 100644 index 028a113..0000000 --- a/marketplace/package-lock.json +++ /dev/null @@ -1,165 +0,0 @@ -{ - "name": "marketplace", - "version": "1.0.0", - "lockfileVersion": 3, - "requires": true, - "packages": { - "": { - "name": "marketplace", - "version": "1.0.0", - "license": "ISC", - "dependencies": { - "@openzeppelin/contracts": "^5.0.2", - "viem": "^2.12.1" - } - }, - "node_modules/@adraffy/ens-normalize": { - "version": "1.10.0", - "resolved": "https://registry.npmjs.org/@adraffy/ens-normalize/-/ens-normalize-1.10.0.tgz", - "integrity": "sha512-nA9XHtlAkYfJxY7bce8DcN7eKxWWCWkU+1GR9d+U6MbNpfwQp8TI7vqOsBsMcHoT4mBu2kypKoSKnghEzOOq5Q==" - }, - "node_modules/@noble/curves": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/@noble/curves/-/curves-1.2.0.tgz", - "integrity": "sha512-oYclrNgRaM9SsBUBVbb8M6DTV7ZHRTKugureoYEncY5c65HOmRzvSiTE3y5CYaPYJA/GVkrhXEoF0M3Ya9PMnw==", - "dependencies": { - "@noble/hashes": "1.3.2" - }, - "funding": { - "url": "https://paulmillr.com/funding/" - } - }, - "node_modules/@noble/hashes": { - "version": "1.3.2", - "resolved": "https://registry.npmjs.org/@noble/hashes/-/hashes-1.3.2.tgz", - "integrity": "sha512-MVC8EAQp7MvEcm30KWENFjgR+Mkmf+D189XJTkFIlwohU5hcBbn1ZkKq7KVTi2Hme3PMGF390DaL52beVrIihQ==", - "engines": { - "node": ">= 16" - }, - "funding": { - "url": "https://paulmillr.com/funding/" - } - }, - "node_modules/@openzeppelin/contracts": { - "version": "5.0.2", - "resolved": "https://registry.npmjs.org/@openzeppelin/contracts/-/contracts-5.0.2.tgz", - "integrity": "sha512-ytPc6eLGcHHnapAZ9S+5qsdomhjo6QBHTDRRBFfTxXIpsicMhVPouPgmUPebZZZGX7vt9USA+Z+0M0dSVtSUEA==" - }, - "node_modules/@scure/base": { - "version": "1.1.6", - "resolved": "https://registry.npmjs.org/@scure/base/-/base-1.1.6.tgz", - "integrity": "sha512-ok9AWwhcgYuGG3Zfhyqg+zwl+Wn5uE+dwC0NV/2qQkx4dABbb/bx96vWu8NSj+BNjjSjno+JRYRjle1jV08k3g==", - "funding": { - "url": "https://paulmillr.com/funding/" - } - }, - "node_modules/@scure/bip32": { - "version": "1.3.2", - "resolved": "https://registry.npmjs.org/@scure/bip32/-/bip32-1.3.2.tgz", - "integrity": "sha512-N1ZhksgwD3OBlwTv3R6KFEcPojl/W4ElJOeCZdi+vuI5QmTFwLq3OFf2zd2ROpKvxFdgZ6hUpb0dx9bVNEwYCA==", - "dependencies": { - "@noble/curves": "~1.2.0", - "@noble/hashes": "~1.3.2", - "@scure/base": "~1.1.2" - }, - "funding": { - "url": "https://paulmillr.com/funding/" - } - }, - "node_modules/@scure/bip39": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/@scure/bip39/-/bip39-1.2.1.tgz", - "integrity": "sha512-Z3/Fsz1yr904dduJD0NpiyRHhRYHdcnyh73FZWiV+/qhWi83wNJ3NWolYqCEN+ZWsUz2TWwajJggcRE9r1zUYg==", - "dependencies": { - "@noble/hashes": "~1.3.0", - "@scure/base": "~1.1.0" - }, - "funding": { - "url": "https://paulmillr.com/funding/" - } - }, - "node_modules/abitype": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/abitype/-/abitype-1.0.0.tgz", - "integrity": "sha512-NMeMah//6bJ56H5XRj8QCV4AwuW6hB6zqz2LnhhLdcWVQOsXki6/Pn3APeqxCma62nXIcmZWdu1DlHWS74umVQ==", - "funding": { - "url": "https://github.com/sponsors/wevm" - }, - "peerDependencies": { - "typescript": ">=5.0.4", - "zod": "^3 >=3.22.0" - }, - "peerDependenciesMeta": { - "typescript": { - "optional": true - }, - "zod": { - "optional": true - } - } - }, - "node_modules/isows": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/isows/-/isows-1.0.4.tgz", - "integrity": "sha512-hEzjY+x9u9hPmBom9IIAqdJCwNLax+xrPb51vEPpERoFlIxgmZcHzsT5jKG06nvInKOBGvReAVz80Umed5CczQ==", - "funding": [ - { - "type": "github", - "url": "https://github.com/sponsors/wagmi-dev" - } - ], - "peerDependencies": { - "ws": "*" - } - }, - "node_modules/viem": { - "version": "2.12.1", - "resolved": "https://registry.npmjs.org/viem/-/viem-2.12.1.tgz", - "integrity": "sha512-71gxcGCXdNXQuBhpqXblVRH1F3hP/wONCptVOCW4r6VrCEXL/9vfNyCdQKtK/0WGyXm04Zs9Jf/AOAxKqf6FmQ==", - "funding": [ - { - "type": "github", - "url": "https://github.com/sponsors/wevm" - } - ], - "dependencies": { - "@adraffy/ens-normalize": "1.10.0", - "@noble/curves": "1.2.0", - "@noble/hashes": "1.3.2", - "@scure/bip32": "1.3.2", - "@scure/bip39": "1.2.1", - "abitype": "1.0.0", - "isows": "1.0.4", - "ws": "8.13.0" - }, - "peerDependencies": { - "typescript": ">=5.0.4" - }, - "peerDependenciesMeta": { - "typescript": { - "optional": true - } - } - }, - "node_modules/ws": { - "version": "8.13.0", - "resolved": "https://registry.npmjs.org/ws/-/ws-8.13.0.tgz", - "integrity": "sha512-x9vcZYTrFPC7aSIbj7sRCYo7L/Xb8Iy+pW0ng0wt2vCJv7M9HOMy0UoN3rr+IFC7hb7vXoqS+P9ktyLLLhO+LA==", - "engines": { - "node": ">=10.0.0" - }, - "peerDependencies": { - "bufferutil": "^4.0.1", - "utf-8-validate": ">=5.0.2" - }, - "peerDependenciesMeta": { - "bufferutil": { - "optional": true - }, - "utf-8-validate": { - "optional": true - } - } - } - } -} diff --git a/marketplace/package.json b/marketplace/package.json deleted file mode 100644 index 55b6018..0000000 --- a/marketplace/package.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "name": "marketplace", - "version": "1.0.0", - "description": "", - "main": "index.js", - "scripts": { - "test": "echo \"Error: no test specified\" && exit 1" - }, - "author": "", - "license": "ISC", - "dependencies": { - "@openzeppelin/contracts": "^5.0.2", - "viem": "^2.12.1" - } -}